1 /* $NetBSD: rpc_util.h,v 1.12 2015/05/13 20:13:21 joerg Exp $ */ 2 /* 3 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 4 * unrestricted use provided that this legend is included on all tape 5 * media and as a part of the software program in whole or part. Users 6 * may copy or modify Sun RPC without charge, but are not authorized 7 * to license or distribute it to anyone else except as part of a product or 8 * program developed by the user or with the express written consent of 9 * Sun Microsystems, Inc. 10 * 11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 14 * 15 * Sun RPC is provided with no support and without any obligation on the 16 * part of Sun Microsystems, Inc. to assist in its use, correction, 17 * modification or enhancement. 18 * 19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 21 * OR ANY PART THEREOF. 22 * 23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 24 * or profits or other special, indirect and consequential damages, even if 25 * Sun has been advised of the possibility of such damages. 26 * 27 * Sun Microsystems, Inc. 28 * 2550 Garcia Avenue 29 * Mountain View, California 94043 30 */ 31 32 /* @(#)rpc_util.h 1.5 90/08/29 (C) 1987 SMI */ 33 34 /* 35 * rpc_util.h, Useful definitions for the RPC protocol compiler 36 */ 37 38 #define alloc(size) ((char *)malloc((size_t)(size))) 39 #define ALLOC(object) ((object *)malloc(sizeof(object))) 40 41 #define s_print (void) sprintf 42 #define f_print (void) fprintf 43 44 struct list { 45 definition *val; 46 struct list *next; 47 }; 48 typedef struct list list; 49 50 #define PUT 1 51 #define GET 2 52 53 /* 54 * Global variables 55 */ 56 #define MAXLINESIZE 1024 57 extern char curline[MAXLINESIZE]; 58 extern char *where; 59 extern int linenum; 60 extern int docleanup; 61 62 extern const char *infilename; 63 extern FILE *fout; 64 extern FILE *fin; 65 66 extern list *defined; 67 68 69 extern bas_type *typ_list_h; 70 extern bas_type *typ_list_t; 71 72 /* 73 * All the option flags 74 */ 75 extern int inetdflag; 76 extern int pmflag; 77 extern int tblflag; 78 extern int BSDflag; 79 extern int logflag; 80 extern int newstyle; 81 extern int Mflag; /* multithread flag */ 82 extern int tirpcflag; /* flag for generating tirpc code */ 83 extern int doinline; /* if this is 0, then do not generate inline code */ 84 extern int callerflag; 85 86 /* 87 * Other flags related with inetd jumpstart. 88 */ 89 extern int indefinitewait; 90 extern int exitnow; 91 extern int timerflag; 92 93 extern int nonfatalerrors; 94 95 /* 96 * rpc_util routines 97 */ 98 99 #define STOREVAL(list,item) \ 100 storeval(list,item) 101 102 #define FINDVAL(list,item,finder) \ 103 findval(list, item, finder) 104 105 void reinitialize(void); 106 int streq(const char *, const char *); 107 definition *findval(list *, const char *, 108 int (*)(definition *, const char *)); 109 void storeval(list **, definition *); 110 const char *fixtype(const char *); 111 const char *stringfix(const char *); 112 void ptype(const char *, const char *, int); 113 int isvectordef(const char *, relation); 114 char *locase(const char *); 115 void pvname_svc(const char *, const char *); 116 void pvname(const char *, const char *); 117 __dead __printflike(1, 2) void error(const char *, ...); 118 void crash(void); 119 void record_open(const char *); 120 void expected1(tok_kind) __dead; 121 void expected2(tok_kind, tok_kind) __dead; 122 void expected3(tok_kind, tok_kind, tok_kind) __dead; 123 void tabify(FILE *, int); 124 char *make_argname(const char *, const char *); 125 void add_type(int, const char *); 126 bas_type *find_type(const char *); 127 /* 128 * rpc_cout routines 129 */ 130 void emit(definition *); 131 void emit_inline(declaration *, int); 132 void emit_single_in_line(declaration *, int, relation); 133 char *upcase(const char *); 134 135 /* 136 * rpc_hout routines 137 */ 138 139 void print_datadef(definition *); 140 void print_progdef(definition *); 141 void print_funcdef(definition *, int *); 142 void print_funcend(int); 143 void pxdrfuncdecl(const char *, int); 144 void pprocdef(proc_list *, version_list *, const char *, int); 145 void pdeclaration(const char *, declaration *, int, const char *); 146 147 /* 148 * rpc_svcout routines 149 */ 150 void write_most(char *, int, int); 151 void write_netid_register(const char *); 152 void write_nettype_register(const char *); 153 void write_rest(void); 154 void write_programs(const char *); 155 int nullproc(proc_list *); 156 void write_svc_aux(int); 157 void write_msg_out(void); 158 void write_inetd_register(const char *); 159 160 /* 161 * rpc_clntout routines 162 */ 163 void write_stubs(void); 164 void printarglist(proc_list *, const char *, const char *, const char *); 165 166 167 /* 168 * rpc_tblout routines 169 */ 170 void write_tables(void); 171 172 /* 173 * rpc_sample routines 174 */ 175 void write_sample_svc(definition *); 176 int write_sample_clnt(definition *); 177 void add_sample_msg(void); 178 void write_sample_clnt_main(void); 179