1 /* 2 */ 3 /* 4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 5 * unrestricted use provided that this legend is included on all tape 6 * media and as a part of the software program in whole or part. Users 7 * may copy or modify Sun RPC without charge, but are not authorized 8 * to license or distribute it to anyone else except as part of a product or 9 * program developed by the user. 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 /* #pragma ident "@(#)rpc_util.h 1.16 94/05/15 SMI" */ 32 33 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 34 /* All Rights Reserved */ 35 36 /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ 37 /* The copyright notice above does not evidence any */ 38 /* actual or intended publication of such source code. */ 39 40 41 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 42 * PROPRIETARY NOTICE (Combined) 43 * 44 * This source code is unpublished proprietary information 45 * constituting, or derived under license from AT&T's UNIX(r) System V. 46 * In addition, portions of such source code were derived from Berkeley 47 * 4.3 BSD under license from the Regents of the University of 48 * California. 49 * 50 * 51 * 52 * Copyright Notice 53 * 54 * Notice of copyright on this source code product does not indicate 55 * publication. 56 * 57 * (c) 1986,1987,1988.1989 Sun Microsystems, Inc 58 * (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. 59 * All rights reserved. 60 */ 61 62 /* @(#)rpc_util.h 1.5 90/08/29 (C) 1987 SMI */ 63 64 /* 65 * rpc_util.h, Useful definitions for the RPC protocol compiler 66 */ 67 #include <sys/types.h> 68 #include <stdlib.h> 69 70 #define XALLOC(object) (object *) xmalloc(sizeof(object)) 71 72 #define s_print (void) sprintf 73 #define f_print (void) fprintf 74 75 struct list { 76 definition *val; 77 struct list *next; 78 }; 79 typedef struct list list; 80 81 struct xdrfunc { 82 const char *name; 83 int pointerp; 84 struct xdrfunc *next; 85 }; 86 typedef struct xdrfunc xdrfunc; 87 88 struct commandline { 89 int cflag; /* xdr C routines */ 90 int hflag; /* header file */ 91 int lflag; /* client side stubs */ 92 int mflag; /* server side stubs */ 93 int nflag; /* netid flag */ 94 int sflag; /* server stubs for the given transport */ 95 int tflag; /* dispatch Table file */ 96 int Ssflag; /* produce server sample code */ 97 int Scflag; /* produce client sample code */ 98 int makefileflag; /* Generate a template Makefile */ 99 const char *infile; /* input module name */ 100 const char *outfile; /* output module name */ 101 }; 102 103 #define PUT 1 104 #define GET 2 105 106 /* 107 * Global variables 108 */ 109 #define MAXLINESIZE 1024 110 extern char curline[MAXLINESIZE]; 111 extern char *where; 112 extern int linenum; 113 extern int tirpc_socket; 114 115 extern const char *infilename; 116 extern FILE *fout; 117 extern FILE *fin; 118 119 extern list *defined; 120 121 122 extern bas_type *typ_list_h; 123 extern bas_type *typ_list_t; 124 extern xdrfunc *xdrfunc_head, *xdrfunc_tail; 125 126 /* 127 * All the option flags 128 */ 129 extern int inetdflag; 130 extern int pmflag; 131 extern int tblflag; 132 extern int logflag; 133 extern int newstyle; 134 extern int CCflag; /* C++ flag */ 135 extern int tirpcflag; /* flag for generating tirpc code */ 136 extern int inline_size; /* if this is 0, then do not generate inline code */ 137 extern int mtflag; 138 139 /* 140 * Other flags related with inetd jumpstart. 141 */ 142 extern int indefinitewait; 143 extern int exitnow; 144 extern int timerflag; 145 146 extern int nonfatalerrors; 147 148 extern pid_t childpid; 149 150 /* 151 * rpc_util routines 152 */ 153 void reinitialize(void); 154 void crash(void) __dead2; 155 void add_type(int len, const char *type); 156 void storeval(list **lstp, definition *val); 157 void *xmalloc(size_t size); 158 void *xrealloc(void *ptr, size_t size); 159 char *xstrdup(const char *); 160 char *make_argname(const char *pname, const char *vname); 161 162 #define STOREVAL(list,item) \ 163 storeval(list,item) 164 165 definition *findval(list *lst, const char *val, int (*cmp)(definition *, const char *)); 166 167 #define FINDVAL(list,item,finder) \ 168 findval(list, item, finder) 169 170 const char *fixtype(const char *type); 171 const char *stringfix(const char *type); 172 char *locase(const char *str); 173 void pvname_svc(const char *pname, const char *vnum); 174 void pvname(const char *pname, const char *vnum); 175 void ptype(const char *prefix, const char *type, int follow); 176 int isvectordef(const char *type, relation rel); 177 int streq(const char *a, const char *b); 178 void error(const char *msg); 179 void expected1(tok_kind exp1); 180 void expected2(tok_kind exp1, tok_kind exp2); 181 void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3); 182 void tabify(FILE *f, int tab); 183 void record_open(const char *file); 184 bas_type *find_type(const char *type); 185 186 /* 187 * rpc_cout routines 188 */ 189 void emit(definition *def); 190 191 /* 192 * rpc_hout routines 193 */ 194 void pdeclaration(const char *name, declaration *dec, int tab, const char *separator); 195 void print_datadef(definition *def, int headeronly); 196 void print_funcdef(definition *def, int headeronly); 197 void print_xdr_func_def(const char* name, int pointerp); 198 199 /* 200 * rpc_svcout routines 201 */ 202 void write_most(const char *infile, int netflag, int nomain); 203 void write_rest(void); 204 void write_programs(const char *storage); 205 void write_svc_aux(int nomain); 206 void write_inetd_register(const char *transp); 207 void write_netid_register(const char *transp); 208 void write_nettype_register(const char *transp); 209 int nullproc(proc_list *proc); 210 211 /* 212 * rpc_clntout routines 213 */ 214 void write_stubs(void); 215 void printarglist(proc_list *proc, const char *result, const char *addargname, 216 const char *addargtype); 217 218 /* 219 * rpc_tblout routines 220 */ 221 void write_tables(void); 222 223 /* 224 * rpc_sample routines 225 */ 226 void write_sample_svc(definition *); 227 int write_sample_clnt(definition *); 228 void write_sample_clnt_main(void); 229 void add_sample_msg(void); 230