1 /* $OpenBSD: rpc_util.h,v 1.17 2017/01/21 08:33:07 krw Exp $ */ 2 /* $NetBSD: rpc_util.h,v 1.3 1995/06/11 21:50:10 pk Exp $ */ 3 4 /* 5 * Copyright (c) 2010, Oracle America, Inc. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials 16 * provided with the distribution. 17 * * Neither the name of the "Oracle America, Inc." nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 28 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 /* @(#)rpc_util.h 1.5 90/08/29 (C) 1987 SMI */ 36 37 /* 38 * rpc_util.h, Useful definitions for the RPC protocol compiler 39 */ 40 41 struct list { 42 definition *val; 43 struct list *next; 44 }; 45 typedef struct list list; 46 47 #define PUT 1 48 #define GET 2 49 50 /* 51 * Global variables 52 */ 53 #define MAXLINESIZE 1024 54 extern char curline[MAXLINESIZE]; 55 extern char *where; 56 extern int linenum; 57 58 extern char *infilename; 59 extern FILE *fout; 60 extern FILE *fin; 61 62 extern list *defined; 63 64 65 extern bas_type *typ_list_h; 66 extern bas_type *typ_list_t; 67 68 /* 69 * All the option flags 70 */ 71 extern int inetdflag; 72 extern int pmflag; 73 extern int tblflag; 74 extern int logflag; 75 extern int newstyle; 76 extern int Cflag; /* C++ flag */ 77 extern int tirpcflag; /* flag for generating tirpc code */ 78 extern int doinline; /* if this is 0, then do not generate inline code */ 79 extern int callerflag; 80 81 /* 82 * Other flags related with inetd jumpstart. 83 */ 84 extern int indefinitewait; 85 extern int exitnow; 86 extern int timerflag; 87 88 extern int nonfatalerrors; 89 90 /* 91 * rpc_util routines 92 */ 93 void storeval(list **, definition *); 94 95 #define STOREVAL(list,item) \ 96 storeval(list,item) 97 98 definition *findval(list *, char *, int (*)(definition *, char *)); 99 100 #define FINDVAL(list,item,finder) \ 101 findval(list, item, finder) 102 103 void crash(void); 104 char *fixtype(char *); 105 char *stringfix(char *); 106 char *locase(char *); 107 void pvname_svc(char *, char *); 108 void pvname(char *, char *); 109 void ptype(char *, char *, int); 110 int isvectordef(char *, relation); 111 int streq(char *, char *); 112 void error(char *); 113 void tabify(FILE *, int); 114 void record_open(char *); 115 bas_type *find_type(char *); 116 char *make_argname(char *, char *); 117 /* 118 * rpc_cout routines 119 */ 120 void emit(definition *); 121 122 /* 123 * rpc_hout routines 124 */ 125 void print_datadef(definition *); 126 void print_funcdef(definition *); 127 128 /* 129 * rpc_svcout routines 130 */ 131 void write_most(char *, int, int); 132 void write_rest(void); 133 void write_programs(char *); 134 void write_svc_aux(int); 135 void write_inetd_register(char *); 136 void write_netid_register(char *); 137 void write_nettype_register(char *); 138 int nullproc(proc_list *); 139 140 /* 141 * rpc_clntout routines 142 */ 143 void write_stubs(void); 144 void printarglist(proc_list *, char *, char *); 145 146 147 /* 148 * rpc_tblout routines 149 */ 150 void write_tables(void); 151 152 /* 153 * rpc_sample routines 154 */ 155 void write_sample_svc(definition *); 156 int write_sample_clnt(definition *); 157 void write_sample_clnt_main(void); 158 159 void add_type(int len, char *type); 160 161 void pdeclaration(char *, declaration *, int, char *); 162 void add_sample_msg(void); 163