/* @(#)rpc←util.h 1.1 90/10/29 (C) 1987 SMI */

/*
 * rpc←util.h, Useful definitions for the RPC protocol compiler 
 * Copyright (C) 1987, Sun Microsystems, Inc. 
 */

#include "StringHashTable.h"

extern char *malloc();

#define FALSE 0
#define TRUE 1

#define alloc(size)		malloc((unsigned)(size))
#define ALLOC(object)   (object *) malloc(sizeof(object))

extern char *sprintf();

#define s←print	(void) sprintf
#define f←print (void) fprintf

struct list {
	char *val;
	struct list *next;
};
typedef struct list list;

struct ImportModuleRec {
    char *moduleName;		/* Module name for the associated name. */
    char *defnName;		/* String of the form foo.bar, where
				   foo is the module name. */
};
typedef struct ImportModuleRec ImportModuleRec;

/*
 * Global variables 
 */

#define MAXLINESIZE 1024

typedef struct Context {
    char curline[MAXLINESIZE];	/* current read line */
    char *where;		/* current point in line */
    int linenum;		/* current line number */
    char *infilename;		/* current input filename */
    FILE *fin;			/* file pointer of current input */
    list *defined;		/* list of defined things */
    int printDirectives;	/* TRUE => emit directives when encountered */
} Context;

extern Context *CurrentContext;

extern FILE *fout;

extern char *svcName;

extern int BadProgNameFlag[];
extern int CurrentProgNameFlag;

extern int PCedar;
extern int PCedarUDP;
extern int PCedarTCP;
extern char *SunRPC;

extern int SeqTypeId;

extern list *Imports;
extern StringHashTableHandle ImportNames;
extern StringHashTableHandle SymbolNames;
extern StringHashTableHandle SeqTypes;
extern StringHashTableHandle EnumTypes;

extern int ExpandProcArgs;
extern int RecoveryFlag;
extern int PFlag;

/*
 * All the option flags
 */
extern int inetdflag;
extern int tblflag;
extern int logflag;

/*
 * Other flags related with inetd jumpstart.
 */
extern int indefinitewait;
extern int exitnow;
extern int timerflag;

/*
 * rpc←util routines 
 */
void storeval();

#define STOREVAL(list,item)	\
	storeval(list,(char *)item)

char *findval();

#define FINDVAL(list,item,finder) \
	findval(list, (char *) item, finder)

char *fixtype();
char *stringfix();
char *locase();
void pvname();
void ptype();
int isvectordef();
int streq();
void error();
void expected1();
void expected2();
void expected3();
void record←open();
char *ModuleName();
char *GetPutModuleName();
char *MapToCedarName();
char *MapToCedarType();
char *rpcgenBaseType();
char *ArrayMax();
char *FindUniqueName();
char *StripPrefix();
char *DefaultEnumTypes();

/*
 * rpc←cout routines 
 */
void emit();

/*
 * rpc←hout routines 
 */
void print←datadef();

/*
 * rpc←svcout routines 
 */
void write←server←prog();

/*
 * rpc←clntout routines
 */
void write←stubs();

/*
 * rpc←tblout routines
 */
void write←tables();