/* 
 * $RCSfile: part.h,v $
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 *
 * $Log: part.h,v $
 * Revision 1.2  1996/01/29 20:25:55  slm
 * Updated copyright and version.
 *
 * Revision 1.1  1995/07/28  21:29:10  slm
 * Initial revision
 *
 * Revision 1.15.1.3.1.1  1994/10/27  20:48:06  hkaram
 * New branch
 *
 * Revision 1.15.1.3  1994/09/13  05:44:56  gkim
 * added ANY_HIGH_PORT
 *
 * Revision 1.15.1.2  1994/06/10  22:58:00  ho
 * Added ANY_LOW_PORT.
 *
 * Revision 1.15.1.1  1994/06/04  01:42:18  menze
 * Added parens in partLen macro
 */

#ifndef part_h
#define part_h

#ifndef xtype_h
#include "xtype.h"
#endif

/* Participant library */

/********************  private/opaque declarations ****************/

#define PART_MAX_STACK 20

typedef struct {
    struct {
	void *ptr;
	int  len;
    } arr[PART_MAX_STACK];
    int top;
} PartStack;

typedef struct {
    int       len;
    PartStack stack;	/* A stack of void* pointers */
} Part;

#ifdef __STDC__

void partStackPush(PartStack *stack, void *addr, int length);
void *partStackPop(PartStack *stack);

#else

void partStackPush();
void *partStackPop();

#endif /* __STDC__ */

/********************  public declarations ****************/

#define LOCAL_PART  1
#define REMOTE_PART 0

/* Initialize a vector of N participants */
#ifdef __STDC__
void partInit(Part *p, int N);
#else
void partInit();
#endif

/* push 'addr' onto the stack of participant 'participant' */
#define partPush(participant, addr, length) \
	partStackPush(&(participant).stack, addr, length)

/* 
 * pop off and return the top element of participant's stack
 * return NULL if there are no more elements
 */
#define partPop(participant) partStackPop(&(participant).stack)

#ifdef __STDC__
int partStackTopByteLen(Part);
#else
int partStackTopByteLen();
#endif

#define partLength(participant) ((participant)->len)

#ifdef __STDC__
XkReturn partExternalize(Part *, void *, int *);
#else
XkReturn partExternalize();
#endif

#ifdef __STDC__
void partInternalize(Part *, void *);
#else
void partInternalize();
#endif

#define ANY_HOST      ((void *) -1)
#define ANY_PORT      -1
#define ANY_LOW_PORT  -2
#define ANY_HIGH_PORT -3

#endif /* part_h */
