/* @(#)Copyright (c), 1987, 1996 StatSci, Inc.  All rights reserved. */
/* @(#)S_structs.h version 3.2 created 5/12/96 */
/***
   NAME S_structs
   PURPOSE
     Split off some struct/union defs from S.h for potential inclusion
     elsewhere, along with a few macros for looking at their contents.
   NOTES
     
***/
#ifndef S_structsINCLUDED
#define S_structsINCLUDED 1

/* Pre-requisite includes go here. */
#include <sccs.h>
SCCS_ID_C(S_structsDotH,@(#)S_structs.h 3.2 last edit 5/12/96 StatSci)

#include <ansi_things.h>
#include <S_rpchelp.h>
#include <S_types.h>

#ifdef S_structsDEFINE
#define INIT(x) = x
#define vextern
#else
#define INIT(x)
#define vextern extern
#endif /* S_structsDEFINE */

/* stucture for hash tables */
typedef struct s_x_h {
    char *name;
    long index;
    struct s_x_h *next;
} x_h;

union s_pointer {
    RPCMOD(caseis(LGL))     long *Long;
    RPCMOD(caseis(REAL))    float *Float;
    RPCMOD(caseis(CHAR))    string8 **Char;
    RPCMOD(caseis(DOUBLE))  double *Double;
    RPCMOD(caseis(COMPLEX)) struct _S_complex *Complex;
    RPCMOD(caseis(NAME))    string8 *name;
#ifndef RPC_FILE    /*(*/
    /* I don't think These cases shouldn't be going thru the RPC
       interface. -SAB */
    unsigned long offset;	/* disk offset */
    struct s_vector *(*sys)(); /* type for an internal system function */
#endif /* ) RPC_FILE */
    RPCMOD(caseis(LIST))    struct s_vector **tree; /* point to a list of vector pointers */
};

struct s_vector {
    int Type;
    string8 *name;
    int mode;
    long length;
    RPCMOD(unionis(mode) sizeis(length)) union s_pointer value;

    /* NOTE: In RPC land, this (struct s_vector) has a special xdr
             function that handles this next union.  The caseis() values
             are probably wrong, but it doesn't really matter.  The source
             is in SAPI_HOME/src/rpc/common/s_obj_xdr.c. */
    RPCMOD(unionis(mode)) union _s_vector_x {
        RPCMOD(caseis(0)) struct s_vector *frame;
        RPCMOD(caseis(1)) struct s_vector *next; /* for lists */
    } x;
    
    long nalloc;
    long status; 
};

#define NULL_ENTRY		((struct s_vector *)NULL)
#define NULL_ENTRYP		((struct s_vector **)NULL)
#define NA_STRING		""

#define S_IS_VOID_VECTOR(p) ((p)==NULL_ENTRY||(p)==S_void||(p)->mode==MISSING)

#undef INIT
#undef vextern

/* Sub-includes go here. */
#endif /* S_structsINCLUDED */
