xref: /netbsd-src/usr.bin/rpcgen/rpc_util.h (revision 1d5828794c1022dd0a7852844ba3bfbf75ecbb30)
1*1d582879Sjoerg /*	$NetBSD: rpc_util.h,v 1.12 2015/05/13 20:13:21 joerg Exp $	*/
28f0abce1Sglass /*
38f0abce1Sglass  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
48f0abce1Sglass  * unrestricted use provided that this legend is included on all tape
58f0abce1Sglass  * media and as a part of the software program in whole or part.  Users
68f0abce1Sglass  * may copy or modify Sun RPC without charge, but are not authorized
78f0abce1Sglass  * to license or distribute it to anyone else except as part of a product or
871a0fb45Spk  * program developed by the user or with the express written consent of
971a0fb45Spk  * Sun Microsystems, Inc.
108f0abce1Sglass  *
118f0abce1Sglass  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
128f0abce1Sglass  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
138f0abce1Sglass  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
148f0abce1Sglass  *
158f0abce1Sglass  * Sun RPC is provided with no support and without any obligation on the
168f0abce1Sglass  * part of Sun Microsystems, Inc. to assist in its use, correction,
178f0abce1Sglass  * modification or enhancement.
188f0abce1Sglass  *
198f0abce1Sglass  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
208f0abce1Sglass  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
218f0abce1Sglass  * OR ANY PART THEREOF.
228f0abce1Sglass  *
238f0abce1Sglass  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
248f0abce1Sglass  * or profits or other special, indirect and consequential damages, even if
258f0abce1Sglass  * Sun has been advised of the possibility of such damages.
268f0abce1Sglass  *
278f0abce1Sglass  * Sun Microsystems, Inc.
288f0abce1Sglass  * 2550 Garcia Avenue
298f0abce1Sglass  * Mountain View, California  94043
308f0abce1Sglass  */
318f0abce1Sglass 
3271a0fb45Spk /*      @(#)rpc_util.h  1.5  90/08/29  (C) 1987 SMI   */
3371a0fb45Spk 
348f0abce1Sglass /*
358f0abce1Sglass  * rpc_util.h, Useful definitions for the RPC protocol compiler
368f0abce1Sglass  */
378f0abce1Sglass 
3898fbb52aSdholland #define alloc(size)		((char *)malloc((size_t)(size)))
3998fbb52aSdholland #define ALLOC(object)		((object *)malloc(sizeof(object)))
408f0abce1Sglass 
418f0abce1Sglass #define s_print	(void) sprintf
428f0abce1Sglass #define f_print (void) fprintf
438f0abce1Sglass 
448f0abce1Sglass struct list {
4571a0fb45Spk 	definition *val;
468f0abce1Sglass 	struct list *next;
478f0abce1Sglass };
488f0abce1Sglass typedef struct list list;
498f0abce1Sglass 
5071a0fb45Spk #define PUT 1
5171a0fb45Spk #define GET 2
5271a0fb45Spk 
538f0abce1Sglass /*
548f0abce1Sglass  * Global variables
558f0abce1Sglass  */
568f0abce1Sglass #define MAXLINESIZE 1024
578f0abce1Sglass extern char curline[MAXLINESIZE];
588f0abce1Sglass extern char *where;
598f0abce1Sglass extern int linenum;
608cde9e3dSchristos extern int docleanup;
618f0abce1Sglass 
62e9067f11Sdholland extern const char *infilename;
638f0abce1Sglass extern FILE *fout;
648f0abce1Sglass extern FILE *fin;
658f0abce1Sglass 
668f0abce1Sglass extern list *defined;
678f0abce1Sglass 
6871a0fb45Spk 
6971a0fb45Spk extern bas_type *typ_list_h;
7071a0fb45Spk extern bas_type *typ_list_t;
7171a0fb45Spk 
7271a0fb45Spk /*
7371a0fb45Spk  * All the option flags
7471a0fb45Spk  */
7571a0fb45Spk extern int inetdflag;
7671a0fb45Spk extern int pmflag;
7771a0fb45Spk extern int tblflag;
780213edf0Schristos extern int BSDflag;
7971a0fb45Spk extern int logflag;
8071a0fb45Spk extern int newstyle;
81b1bad8f6Smycroft extern int Mflag;     /* multithread flag */
8271a0fb45Spk extern int tirpcflag; /* flag for generating tirpc code */
8393579481Schristos extern int doinline; /* if this is 0, then do not generate inline code */
8471a0fb45Spk extern int callerflag;
8571a0fb45Spk 
8671a0fb45Spk /*
8771a0fb45Spk  * Other flags related with inetd jumpstart.
8871a0fb45Spk  */
8971a0fb45Spk extern int indefinitewait;
9071a0fb45Spk extern int exitnow;
9171a0fb45Spk extern int timerflag;
9271a0fb45Spk 
9371a0fb45Spk extern int nonfatalerrors;
9471a0fb45Spk 
958f0abce1Sglass /*
968f0abce1Sglass  * rpc_util routines
978f0abce1Sglass  */
988f0abce1Sglass 
998f0abce1Sglass #define STOREVAL(list,item)	\
10071a0fb45Spk 	storeval(list,item)
1018f0abce1Sglass 
1028f0abce1Sglass #define FINDVAL(list,item,finder) \
10371a0fb45Spk 	findval(list, item, finder)
1048f0abce1Sglass 
1050213edf0Schristos void reinitialize(void);
1060213edf0Schristos int streq(const char *, const char *);
1070213edf0Schristos definition *findval(list *, const char *,
1080213edf0Schristos 			 int (*)(definition *, const char *));
1090213edf0Schristos void storeval(list **, definition *);
1100213edf0Schristos const char *fixtype(const char *);
1110213edf0Schristos const char *stringfix(const char *);
1120213edf0Schristos void ptype(const char *, const char *, int);
1130213edf0Schristos int isvectordef(const char *, relation);
1140213edf0Schristos char *locase(const char *);
1150213edf0Schristos void pvname_svc(const char *, const char *);
1160213edf0Schristos void pvname(const char *, const char *);
117*1d582879Sjoerg __dead __printflike(1, 2) void error(const char *, ...);
1188cde9e3dSchristos void crash(void);
1190213edf0Schristos void record_open(const char *);
1202c7fa373Sjoerg void expected1(tok_kind) __dead;
1212c7fa373Sjoerg void expected2(tok_kind, tok_kind) __dead;
1222c7fa373Sjoerg void expected3(tok_kind, tok_kind, tok_kind) __dead;
1230213edf0Schristos void tabify(FILE *, int);
1240213edf0Schristos char *make_argname(const char *, const char *);
1250213edf0Schristos void add_type(int, const char *);
1260213edf0Schristos bas_type *find_type(const char *);
1278f0abce1Sglass /*
1288f0abce1Sglass  * rpc_cout routines
1298f0abce1Sglass  */
1300213edf0Schristos void emit(definition *);
1310213edf0Schristos void emit_inline(declaration *, int);
1320213edf0Schristos void emit_single_in_line(declaration *, int, relation);
1330213edf0Schristos char *upcase(const char *);
1348f0abce1Sglass 
1358f0abce1Sglass /*
1368f0abce1Sglass  * rpc_hout routines
1378f0abce1Sglass  */
13893579481Schristos 
1390213edf0Schristos void print_datadef(definition *);
1400213edf0Schristos void print_progdef(definition *);
1410213edf0Schristos void print_funcdef(definition *, int *);
1420213edf0Schristos void print_funcend(int);
1430213edf0Schristos void pxdrfuncdecl(const char *, int);
1440213edf0Schristos void pprocdef(proc_list *, version_list *, const char *, int);
1450213edf0Schristos void pdeclaration(const char *, declaration *, int, const char *);
1468f0abce1Sglass 
1478f0abce1Sglass /*
1488f0abce1Sglass  * rpc_svcout routines
1498f0abce1Sglass  */
1500213edf0Schristos void write_most(char *, int, int);
1510213edf0Schristos void write_netid_register(const char *);
1520213edf0Schristos void write_nettype_register(const char *);
1530213edf0Schristos void write_rest(void);
1540213edf0Schristos void write_programs(const char *);
1550213edf0Schristos int nullproc(proc_list *);
1560213edf0Schristos void write_svc_aux(int);
1570213edf0Schristos void write_msg_out(void);
1580213edf0Schristos void write_inetd_register(const char *);
15993579481Schristos 
1608f0abce1Sglass /*
1618f0abce1Sglass  * rpc_clntout routines
1628f0abce1Sglass  */
1630213edf0Schristos void write_stubs(void);
1640213edf0Schristos void printarglist(proc_list *, const char *, const char *, const char *);
16571a0fb45Spk 
16671a0fb45Spk 
16771a0fb45Spk /*
16871a0fb45Spk  * rpc_tblout routines
16971a0fb45Spk  */
1700213edf0Schristos void write_tables(void);
17171a0fb45Spk 
17271a0fb45Spk /*
17371a0fb45Spk  * rpc_sample routines
17471a0fb45Spk  */
1750213edf0Schristos void write_sample_svc(definition *);
1760213edf0Schristos int write_sample_clnt(definition *);
1770213edf0Schristos void add_sample_msg(void);
1780213edf0Schristos void write_sample_clnt_main(void);
179