11897Swollman/* 299979Salfred * $FreeBSD$ 399979Salfred */ 499979Salfred/* 51897Swollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 61897Swollman * unrestricted use provided that this legend is included on all tape 71897Swollman * media and as a part of the software program in whole or part. Users 81897Swollman * may copy or modify Sun RPC without charge, but are not authorized 91897Swollman * to license or distribute it to anyone else except as part of a product or 101897Swollman * program developed by the user. 11100441Scharnier * 121897Swollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 131897Swollman * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 141897Swollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 15100441Scharnier * 161897Swollman * Sun RPC is provided with no support and without any obligation on the 171897Swollman * part of Sun Microsystems, Inc. to assist in its use, correction, 181897Swollman * modification or enhancement. 19100441Scharnier * 201897Swollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 211897Swollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 221897Swollman * OR ANY PART THEREOF. 23100441Scharnier * 241897Swollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue 251897Swollman * or profits or other special, indirect and consequential damages, even if 261897Swollman * Sun has been advised of the possibility of such damages. 27100441Scharnier * 281897Swollman * Sun Microsystems, Inc. 291897Swollman * 2550 Garcia Avenue 301897Swollman * Mountain View, California 94043 311897Swollman */ 3299979Salfred/* #pragma ident "@(#)rpc_util.h 1.16 94/05/15 SMI" */ 331897Swollman 3412798Swpaul/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 3512798Swpaul/* All Rights Reserved */ 3612798Swpaul 3712798Swpaul/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ 3812798Swpaul/* The copyright notice above does not evidence any */ 3912798Swpaul/* actual or intended publication of such source code. */ 4012798Swpaul 4112798Swpaul 4212798Swpaul/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4312798Swpaul* PROPRIETARY NOTICE (Combined) 4412798Swpaul* 4512798Swpaul* This source code is unpublished proprietary information 4612798Swpaul* constituting, or derived under license from AT&T's UNIX(r) System V. 4712798Swpaul* In addition, portions of such source code were derived from Berkeley 4812798Swpaul* 4.3 BSD under license from the Regents of the University of 4912798Swpaul* California. 5012798Swpaul* 5112798Swpaul* 5212798Swpaul* 53100441Scharnier* Copyright Notice 5412798Swpaul* 55100441Scharnier* Notice of copyright on this source code product does not indicate 5612798Swpaul* publication. 5712798Swpaul* 5812798Swpaul* (c) 1986,1987,1988.1989 Sun Microsystems, Inc 5912798Swpaul* (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. 6012798Swpaul* All rights reserved. 61100441Scharnier*/ 6212798Swpaul 6312798Swpaul/* @(#)rpc_util.h 1.5 90/08/29 (C) 1987 SMI */ 6412798Swpaul 651897Swollman/* 66100441Scharnier * rpc_util.h, Useful definitions for the RPC protocol compiler 671897Swollman */ 6812798Swpaul#include <sys/types.h> 6912798Swpaul#include <stdlib.h> 701897Swollman 71100441Scharnier#define XALLOC(object) (object *) xmalloc(sizeof(object)) 721897Swollman 7312798Swpaul#define s_print (void) sprintf 7412798Swpaul#define f_print (void) fprintf 751897Swollman 761897Swollmanstruct list { 7712798Swpaul definition *val; 781897Swollman struct list *next; 791897Swollman}; 801897Swollmantypedef struct list list; 811897Swollman 8212798Swpaulstruct xdrfunc { 83152398Sdwmalone const char *name; 8412798Swpaul int pointerp; 8512798Swpaul struct xdrfunc *next; 8612798Swpaul}; 8712798Swpaultypedef struct xdrfunc xdrfunc; 8812798Swpaul 8912798Swpaulstruct commandline { 9012798Swpaul int cflag; /* xdr C routines */ 9112798Swpaul int hflag; /* header file */ 9212798Swpaul int lflag; /* client side stubs */ 9312798Swpaul int mflag; /* server side stubs */ 9412798Swpaul int nflag; /* netid flag */ 9512798Swpaul int sflag; /* server stubs for the given transport */ 9612798Swpaul int tflag; /* dispatch Table file */ 9712798Swpaul int Ssflag; /* produce server sample code */ 9812798Swpaul int Scflag; /* produce client sample code */ 9912798Swpaul int makefileflag; /* Generate a template Makefile */ 100152398Sdwmalone const char *infile; /* input module name */ 101152398Sdwmalone const char *outfile; /* output module name */ 10212798Swpaul}; 10312798Swpaul 10412798Swpaul#define PUT 1 10512798Swpaul#define GET 2 10612798Swpaul 1071897Swollman/* 108100441Scharnier * Global variables 1091897Swollman */ 11012798Swpaul#define MAXLINESIZE 1024 1111897Swollmanextern char curline[MAXLINESIZE]; 1121897Swollmanextern char *where; 1131897Swollmanextern int linenum; 114152398Sdwmaloneextern int tirpc_socket; 1151897Swollman 116152398Sdwmaloneextern const char *infilename; 1171897Swollmanextern FILE *fout; 1181897Swollmanextern FILE *fin; 1191897Swollman 1201897Swollmanextern list *defined; 1211897Swollman 12212798Swpaul 12312798Swpaulextern bas_type *typ_list_h; 12412798Swpaulextern bas_type *typ_list_t; 12512798Swpaulextern xdrfunc *xdrfunc_head, *xdrfunc_tail; 12612798Swpaul 1271897Swollman/* 12812798Swpaul * All the option flags 1291897Swollman */ 13012798Swpaulextern int inetdflag; 131100441Scharnierextern int pmflag; 13212798Swpaulextern int tblflag; 13312798Swpaulextern int logflag; 13412798Swpaulextern int newstyle; 13512798Swpaulextern int CCflag; /* C++ flag */ 13612798Swpaulextern int tirpcflag; /* flag for generating tirpc code */ 137149680Sstefanfextern int inline_size; /* if this is 0, then do not generate inline code */ 13812798Swpaulextern int mtflag; 13912798Swpaul 14012798Swpaul/* 14112798Swpaul * Other flags related with inetd jumpstart. 14212798Swpaul */ 14312798Swpaulextern int indefinitewait; 14412798Swpaulextern int exitnow; 14512798Swpaulextern int timerflag; 14612798Swpaul 14712798Swpaulextern int nonfatalerrors; 14812798Swpaul 14912798Swpaulextern pid_t childpid; 15012798Swpaul 15112798Swpaul/* 152100441Scharnier * rpc_util routines 15312798Swpaul */ 154149682Sstefanfvoid reinitialize(void); 155149682Sstefanfvoid crash(void); 156152398Sdwmalonevoid add_type(int len, const char *type); 157149682Sstefanfvoid storeval(list **lstp, definition *val); 158100441Scharniervoid *xmalloc(size_t size); 159100441Scharniervoid *xrealloc(void *ptr, size_t size); 160152398Sdwmalonechar *xstrdup(const char *); 161152398Sdwmalonechar *make_argname(const char *pname, const char *vname); 1621897Swollman 16312798Swpaul#define STOREVAL(list,item) \ 16412798Swpaul storeval(list,item) 1651897Swollman 166152398Sdwmalonedefinition *findval(list *lst, const char *val, int (*cmp)(definition *, const char *)); 1671897Swollman 16812798Swpaul#define FINDVAL(list,item,finder) \ 16912798Swpaul findval(list, item, finder) 1701897Swollman 171152398Sdwmaloneconst char *fixtype(const char *type); 172152398Sdwmaloneconst char *stringfix(const char *type); 173152398Sdwmalonechar *locase(const char *str); 174152398Sdwmalonevoid pvname_svc(const char *pname, const char *vnum); 175152398Sdwmalonevoid pvname(const char *pname, const char *vnum); 176152398Sdwmalonevoid ptype(const char *prefix, const char *type, int follow); 177152398Sdwmaloneint isvectordef(const char *type, relation rel); 178152398Sdwmaloneint streq(const char *a, const char *b); 179152398Sdwmalonevoid error(const char *msg); 180149682Sstefanfvoid expected1(tok_kind exp1); 181149682Sstefanfvoid expected2(tok_kind exp1, tok_kind exp2); 182149682Sstefanfvoid expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3); 183149682Sstefanfvoid tabify(FILE *f, int tab); 184152398Sdwmalonevoid record_open(const char *file); 185152398Sdwmalonebas_type *find_type(const char *type); 186149682Sstefanf 1871897Swollman/* 188100441Scharnier * rpc_cout routines 1891897Swollman */ 190149682Sstefanfvoid emit(definition *def); 1911897Swollman 1921897Swollman/* 193100441Scharnier * rpc_hout routines 1941897Swollman */ 195152398Sdwmalonevoid pdeclaration(const char *name, declaration *dec, int tab, const char *separator); 196149695Sstefanfvoid print_datadef(definition *def, int headeronly); 197149695Sstefanfvoid print_funcdef(definition *def, int headeronly); 198152398Sdwmalonevoid print_xdr_func_def(const char* name, int pointerp); 1991897Swollman 2001897Swollman/* 201100441Scharnier * rpc_svcout routines 2021897Swollman */ 203152398Sdwmalonevoid write_most(const char *infile, int netflag, int nomain); 204149682Sstefanfvoid write_rest(void); 205152398Sdwmalonevoid write_programs(const char *storage); 206149682Sstefanfvoid write_svc_aux(int nomain); 207152398Sdwmalonevoid write_inetd_register(const char *transp); 208152398Sdwmalonevoid write_netid_register(const char *transp); 209152398Sdwmalonevoid write_nettype_register(const char *transp); 210152398Sdwmaloneint nullproc(proc_list *proc); 211149682Sstefanf 2121897Swollman/* 2131897Swollman * rpc_clntout routines 2141897Swollman */ 215149682Sstefanfvoid write_stubs(void); 216152398Sdwmalonevoid printarglist(proc_list *proc, const char *result, const char *addargname, 217152398Sdwmalone const char *addargtype); 21812798Swpaul 21912798Swpaul/* 22012798Swpaul * rpc_tblout routines 22112798Swpaul */ 222149682Sstefanfvoid write_tables(void); 223152398Sdwmalone 224152398Sdwmalone/* 225152398Sdwmalone * rpc_sample routines 226152398Sdwmalone */ 227152398Sdwmalonevoid write_sample_svc(definition *); 228152398Sdwmaloneint write_sample_clnt(definition *); 229152398Sdwmalonevoid write_sample_clnt_main(void); 230152398Sdwmalonevoid add_sample_msg(void); 231