1 /* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. 8 * 9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 * 13 * Sun RPC is provided with no support and without any obligation on the 14 * part of Sun Microsystems, Inc. to assist in its use, correction, 15 * modification or enhancement. 16 * 17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 * OR ANY PART THEREOF. 20 * 21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 * or profits or other special, indirect and consequential damages, even if 23 * Sun has been advised of the possibility of such damages. 24 * 25 * Sun Microsystems, Inc. 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 * 29 * @(#)rpc_util.h 1.16 94/05/15 SMI; 1.5 90/08/29 (C) 1987 SMI 30 * $FreeBSD: src/usr.bin/rpcgen/rpc_util.h,v 1.12 2005/11/13 21:17:24 dwmalone Exp $ 31 */ 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 /* 63 * rpc_util.h, Useful definitions for the RPC protocol compiler 64 */ 65 #include <sys/types.h> 66 #include <stdlib.h> 67 68 #define XALLOC(object) (object *) xmalloc(sizeof(object)) 69 70 #define s_print (void) sprintf 71 #define f_print (void) fprintf 72 73 struct list { 74 definition *val; 75 struct list *next; 76 }; 77 typedef struct list list; 78 79 struct xdrfunc { 80 const char *name; 81 int pointerp; 82 struct xdrfunc *next; 83 }; 84 typedef struct xdrfunc xdrfunc; 85 86 struct commandline { 87 int cflag; /* xdr C routines */ 88 int hflag; /* header file */ 89 int lflag; /* client side stubs */ 90 int mflag; /* server side stubs */ 91 int nflag; /* netid flag */ 92 int sflag; /* server stubs for the given transport */ 93 int tflag; /* dispatch Table file */ 94 int Ssflag; /* produce server sample code */ 95 int Scflag; /* produce client sample code */ 96 int makefileflag; /* Generate a template Makefile */ 97 const char *infile; /* input module name */ 98 const char *outfile; /* output module name */ 99 }; 100 101 #define PUT 1 102 #define GET 2 103 104 /* 105 * Global variables 106 */ 107 #define MAXLINESIZE 1024 108 extern char curline[MAXLINESIZE]; 109 extern char *where; 110 extern int linenum; 111 extern int tirpc_socket; 112 113 extern const char *infilename; 114 extern FILE *fout; 115 extern FILE *fin; 116 117 extern list *defined; 118 119 120 extern bas_type *typ_list_h; 121 extern bas_type *typ_list_t; 122 extern xdrfunc *xdrfunc_head, *xdrfunc_tail; 123 124 /* 125 * All the option flags 126 */ 127 extern int inetdflag; 128 extern int pmflag; 129 extern int tblflag; 130 extern int logflag; 131 extern int newstyle; 132 extern int CCflag; /* C++ flag */ 133 extern int tirpcflag; /* flag for generating tirpc code */ 134 extern int inline_size; /* if this is 0, then do not generate inline code */ 135 extern int mtflag; 136 137 /* 138 * Other flags related with inetd jumpstart. 139 */ 140 extern int indefinitewait; 141 extern int exitnow; 142 extern int timerflag; 143 144 extern int nonfatalerrors; 145 146 extern pid_t childpid; 147 148 /* 149 * rpc_util routines 150 */ 151 void reinitialize(void); 152 void crash(void) __dead2; 153 void add_type(int, const char *); 154 void storeval(list **, definition *); 155 void *xmalloc(size_t); 156 void *xrealloc(void *, size_t); 157 char *xstrdup(const char *); 158 char *make_argname(const char *, const char *); 159 160 #define STOREVAL(list,item) \ 161 storeval(list,item) 162 163 definition *findval(list *, const char *, int (*)(definition *, const char *)); 164 165 #define FINDVAL(list,item,finder) \ 166 findval(list, item, finder) 167 168 const char *fixtype(const char *); 169 const char *stringfix(const char *); 170 char *locase(const char *); 171 void pvname_svc(const char *, const char *); 172 void pvname(const char *, const char *); 173 void ptype(const char *, const char *, int); 174 int isvectordef(const char *, relation); 175 int streq(const char *, const char *); 176 void error(const char *) __dead2; 177 void expected1(tok_kind) __dead2; 178 void expected2(tok_kind, tok_kind) __dead2; 179 void expected3(tok_kind, tok_kind, tok_kind) __dead2; 180 void tabify(FILE *, int); 181 void record_open(const char *); 182 bas_type *find_type(const char *); 183 184 /* 185 * rpc_cout routines 186 */ 187 void emit(definition *); 188 189 /* 190 * rpc_hout routines 191 */ 192 void pdeclaration(const char *, declaration *, int, const char *); 193 void print_datadef(definition *, int); 194 void print_funcdef(definition *, int); 195 void print_xdr_func_def(const char *, int); 196 197 /* 198 * rpc_svcout routines 199 */ 200 void write_most(const char *, int, int); 201 void write_rest(void); 202 void write_programs(const char *); 203 void write_svc_aux(int); 204 void write_inetd_register(const char *); 205 void write_netid_register(const char *); 206 void write_nettype_register(const char *); 207 int nullproc(proc_list *); 208 209 /* 210 * rpc_clntout routines 211 */ 212 void write_stubs(void); 213 void printarglist(proc_list *, const char *, const char *, 214 const char *); 215 216 /* 217 * rpc_tblout routines 218 */ 219 void write_tables(void); 220 221 /* 222 * rpc_sample routines 223 */ 224 void write_sample_svc(definition *); 225 int write_sample_clnt(definition *); 226 void write_sample_clnt_main(void); 227 void add_sample_msg(void); 228