14e115012SGarrett Wollman /* 240ad8885SAlfred Perlstein * $FreeBSD$ 340ad8885SAlfred Perlstein */ 440ad8885SAlfred Perlstein /* 54e115012SGarrett Wollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 64e115012SGarrett Wollman * unrestricted use provided that this legend is included on all tape 74e115012SGarrett Wollman * media and as a part of the software program in whole or part. Users 84e115012SGarrett Wollman * may copy or modify Sun RPC without charge, but are not authorized 94e115012SGarrett Wollman * to license or distribute it to anyone else except as part of a product or 104e115012SGarrett Wollman * program developed by the user. 114e115012SGarrett Wollman * 124e115012SGarrett Wollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 134e115012SGarrett Wollman * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 144e115012SGarrett Wollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 154e115012SGarrett Wollman * 164e115012SGarrett Wollman * Sun RPC is provided with no support and without any obligation on the 174e115012SGarrett Wollman * part of Sun Microsystems, Inc. to assist in its use, correction, 184e115012SGarrett Wollman * modification or enhancement. 194e115012SGarrett Wollman * 204e115012SGarrett Wollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 214e115012SGarrett Wollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 224e115012SGarrett Wollman * OR ANY PART THEREOF. 234e115012SGarrett Wollman * 244e115012SGarrett Wollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue 254e115012SGarrett Wollman * or profits or other special, indirect and consequential damages, even if 264e115012SGarrett Wollman * Sun has been advised of the possibility of such damages. 274e115012SGarrett Wollman * 284e115012SGarrett Wollman * Sun Microsystems, Inc. 294e115012SGarrett Wollman * 2550 Garcia Avenue 304e115012SGarrett Wollman * Mountain View, California 94043 314e115012SGarrett Wollman */ 3240ad8885SAlfred Perlstein /* #pragma ident "@(#)rpc_util.h 1.16 94/05/15 SMI" */ 33ff49530fSBill Paul 34ff49530fSBill Paul /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 35ff49530fSBill Paul /* All Rights Reserved */ 36ff49530fSBill Paul 37ff49530fSBill Paul /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ 38ff49530fSBill Paul /* The copyright notice above does not evidence any */ 39ff49530fSBill Paul /* actual or intended publication of such source code. */ 40ff49530fSBill Paul 41ff49530fSBill Paul 42ff49530fSBill Paul /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 43ff49530fSBill Paul * PROPRIETARY NOTICE (Combined) 44ff49530fSBill Paul * 45ff49530fSBill Paul * This source code is unpublished proprietary information 46ff49530fSBill Paul * constituting, or derived under license from AT&T's UNIX(r) System V. 47ff49530fSBill Paul * In addition, portions of such source code were derived from Berkeley 48ff49530fSBill Paul * 4.3 BSD under license from the Regents of the University of 49ff49530fSBill Paul * California. 50ff49530fSBill Paul * 51ff49530fSBill Paul * 52ff49530fSBill Paul * 53ff49530fSBill Paul * Copyright Notice 54ff49530fSBill Paul * 55ff49530fSBill Paul * Notice of copyright on this source code product does not indicate 56ff49530fSBill Paul * publication. 57ff49530fSBill Paul * 58ff49530fSBill Paul * (c) 1986,1987,1988.1989 Sun Microsystems, Inc 59ff49530fSBill Paul * (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. 60ff49530fSBill Paul * All rights reserved. 61ff49530fSBill Paul */ 62ff49530fSBill Paul 63ff49530fSBill Paul /* @(#)rpc_util.h 1.5 90/08/29 (C) 1987 SMI */ 644e115012SGarrett Wollman 654e115012SGarrett Wollman /* 664e115012SGarrett Wollman * rpc_util.h, Useful definitions for the RPC protocol compiler 674e115012SGarrett Wollman */ 68ff49530fSBill Paul #include <sys/types.h> 69ff49530fSBill Paul #include <stdlib.h> 704e115012SGarrett Wollman 7175863a6dSPhilippe Charnier #define XALLOC(object) (object *) xmalloc(sizeof(object)) 724e115012SGarrett Wollman 734e115012SGarrett Wollman #define s_print (void) sprintf 744e115012SGarrett Wollman #define f_print (void) fprintf 754e115012SGarrett Wollman 764e115012SGarrett Wollman struct list { 77ff49530fSBill Paul definition *val; 784e115012SGarrett Wollman struct list *next; 794e115012SGarrett Wollman }; 804e115012SGarrett Wollman typedef struct list list; 814e115012SGarrett Wollman 82ff49530fSBill Paul struct xdrfunc { 83e390e3afSDavid Malone const char *name; 84ff49530fSBill Paul int pointerp; 85ff49530fSBill Paul struct xdrfunc *next; 86ff49530fSBill Paul }; 87ff49530fSBill Paul typedef struct xdrfunc xdrfunc; 88ff49530fSBill Paul 89ff49530fSBill Paul struct commandline { 90ff49530fSBill Paul int cflag; /* xdr C routines */ 91ff49530fSBill Paul int hflag; /* header file */ 92ff49530fSBill Paul int lflag; /* client side stubs */ 93ff49530fSBill Paul int mflag; /* server side stubs */ 94ff49530fSBill Paul int nflag; /* netid flag */ 95ff49530fSBill Paul int sflag; /* server stubs for the given transport */ 96ff49530fSBill Paul int tflag; /* dispatch Table file */ 97ff49530fSBill Paul int Ssflag; /* produce server sample code */ 98ff49530fSBill Paul int Scflag; /* produce client sample code */ 99ff49530fSBill Paul int makefileflag; /* Generate a template Makefile */ 100e390e3afSDavid Malone const char *infile; /* input module name */ 101e390e3afSDavid Malone const char *outfile; /* output module name */ 102ff49530fSBill Paul }; 103ff49530fSBill Paul 104ff49530fSBill Paul #define PUT 1 105ff49530fSBill Paul #define GET 2 106ff49530fSBill Paul 1074e115012SGarrett Wollman /* 1084e115012SGarrett Wollman * Global variables 1094e115012SGarrett Wollman */ 1104e115012SGarrett Wollman #define MAXLINESIZE 1024 1114e115012SGarrett Wollman extern char curline[MAXLINESIZE]; 1124e115012SGarrett Wollman extern char *where; 1134e115012SGarrett Wollman extern int linenum; 114e390e3afSDavid Malone extern int tirpc_socket; 1154e115012SGarrett Wollman 116e390e3afSDavid Malone extern const char *infilename; 1174e115012SGarrett Wollman extern FILE *fout; 1184e115012SGarrett Wollman extern FILE *fin; 1194e115012SGarrett Wollman 1204e115012SGarrett Wollman extern list *defined; 1214e115012SGarrett Wollman 122ff49530fSBill Paul 123ff49530fSBill Paul extern bas_type *typ_list_h; 124ff49530fSBill Paul extern bas_type *typ_list_t; 125ff49530fSBill Paul extern xdrfunc *xdrfunc_head, *xdrfunc_tail; 126ff49530fSBill Paul 127ff49530fSBill Paul /* 128ff49530fSBill Paul * All the option flags 129ff49530fSBill Paul */ 130ff49530fSBill Paul extern int inetdflag; 131ff49530fSBill Paul extern int pmflag; 132ff49530fSBill Paul extern int tblflag; 133ff49530fSBill Paul extern int logflag; 134ff49530fSBill Paul extern int newstyle; 135ff49530fSBill Paul extern int CCflag; /* C++ flag */ 136ff49530fSBill Paul extern int tirpcflag; /* flag for generating tirpc code */ 137122562cdSStefan Farfeleder extern int inline_size; /* if this is 0, then do not generate inline code */ 138ff49530fSBill Paul extern int mtflag; 139ff49530fSBill Paul 140ff49530fSBill Paul /* 141ff49530fSBill Paul * Other flags related with inetd jumpstart. 142ff49530fSBill Paul */ 143ff49530fSBill Paul extern int indefinitewait; 144ff49530fSBill Paul extern int exitnow; 145ff49530fSBill Paul extern int timerflag; 146ff49530fSBill Paul 147ff49530fSBill Paul extern int nonfatalerrors; 148ff49530fSBill Paul 149ff49530fSBill Paul extern pid_t childpid; 150ff49530fSBill Paul 1514e115012SGarrett Wollman /* 1524e115012SGarrett Wollman * rpc_util routines 1534e115012SGarrett Wollman */ 154d0cc804bSStefan Farfeleder void reinitialize(void); 155d0cc804bSStefan Farfeleder void crash(void); 156e390e3afSDavid Malone void add_type(int len, const char *type); 157d0cc804bSStefan Farfeleder void storeval(list **lstp, definition *val); 15875863a6dSPhilippe Charnier void *xmalloc(size_t size); 15975863a6dSPhilippe Charnier void *xrealloc(void *ptr, size_t size); 160e390e3afSDavid Malone char *xstrdup(const char *); 161e390e3afSDavid Malone char *make_argname(const char *pname, const char *vname); 1624e115012SGarrett Wollman 1634e115012SGarrett Wollman #define STOREVAL(list,item) \ 164ff49530fSBill Paul storeval(list,item) 1654e115012SGarrett Wollman 166e390e3afSDavid Malone definition *findval(list *lst, const char *val, int (*cmp)(definition *, const char *)); 1674e115012SGarrett Wollman 1684e115012SGarrett Wollman #define FINDVAL(list,item,finder) \ 169ff49530fSBill Paul findval(list, item, finder) 1704e115012SGarrett Wollman 171e390e3afSDavid Malone const char *fixtype(const char *type); 172e390e3afSDavid Malone const char *stringfix(const char *type); 173e390e3afSDavid Malone char *locase(const char *str); 174e390e3afSDavid Malone void pvname_svc(const char *pname, const char *vnum); 175e390e3afSDavid Malone void pvname(const char *pname, const char *vnum); 176e390e3afSDavid Malone void ptype(const char *prefix, const char *type, int follow); 177e390e3afSDavid Malone int isvectordef(const char *type, relation rel); 178e390e3afSDavid Malone int streq(const char *a, const char *b); 179e390e3afSDavid Malone void error(const char *msg); 180d0cc804bSStefan Farfeleder void expected1(tok_kind exp1); 181d0cc804bSStefan Farfeleder void expected2(tok_kind exp1, tok_kind exp2); 182d0cc804bSStefan Farfeleder void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3); 183d0cc804bSStefan Farfeleder void tabify(FILE *f, int tab); 184e390e3afSDavid Malone void record_open(const char *file); 185e390e3afSDavid Malone bas_type *find_type(const char *type); 186d0cc804bSStefan Farfeleder 1874e115012SGarrett Wollman /* 1884e115012SGarrett Wollman * rpc_cout routines 1894e115012SGarrett Wollman */ 190d0cc804bSStefan Farfeleder void emit(definition *def); 1914e115012SGarrett Wollman 1924e115012SGarrett Wollman /* 1934e115012SGarrett Wollman * rpc_hout routines 1944e115012SGarrett Wollman */ 195e390e3afSDavid Malone void pdeclaration(const char *name, declaration *dec, int tab, const char *separator); 196ec06b5e8SStefan Farfeleder void print_datadef(definition *def, int headeronly); 197ec06b5e8SStefan Farfeleder void print_funcdef(definition *def, int headeronly); 198e390e3afSDavid Malone void print_xdr_func_def(const char* name, int pointerp); 1994e115012SGarrett Wollman 2004e115012SGarrett Wollman /* 2014e115012SGarrett Wollman * rpc_svcout routines 2024e115012SGarrett Wollman */ 203e390e3afSDavid Malone void write_most(const char *infile, int netflag, int nomain); 204d0cc804bSStefan Farfeleder void write_rest(void); 205e390e3afSDavid Malone void write_programs(const char *storage); 206d0cc804bSStefan Farfeleder void write_svc_aux(int nomain); 207e390e3afSDavid Malone void write_inetd_register(const char *transp); 208e390e3afSDavid Malone void write_netid_register(const char *transp); 209e390e3afSDavid Malone void write_nettype_register(const char *transp); 210e390e3afSDavid Malone int nullproc(proc_list *proc); 211d0cc804bSStefan Farfeleder 2124e115012SGarrett Wollman /* 2134e115012SGarrett Wollman * rpc_clntout routines 2144e115012SGarrett Wollman */ 215d0cc804bSStefan Farfeleder void write_stubs(void); 216e390e3afSDavid Malone void printarglist(proc_list *proc, const char *result, const char *addargname, 217e390e3afSDavid Malone const char *addargtype); 218ff49530fSBill Paul 219ff49530fSBill Paul /* 220ff49530fSBill Paul * rpc_tblout routines 221ff49530fSBill Paul */ 222d0cc804bSStefan Farfeleder void write_tables(void); 223e390e3afSDavid Malone 224e390e3afSDavid Malone /* 225e390e3afSDavid Malone * rpc_sample routines 226e390e3afSDavid Malone */ 227e390e3afSDavid Malone void write_sample_svc(definition *); 228e390e3afSDavid Malone int write_sample_clnt(definition *); 229e390e3afSDavid Malone void write_sample_clnt_main(void); 230e390e3afSDavid Malone void add_sample_msg(void); 231