1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  24  *
  25  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  */
  28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  29 /* All Rights Reserved */
  30 /*
  31  * University Copyright- Copyright (c) 1982, 1986, 1988
  32  * The Regents of the University of California
  33  * All Rights Reserved
  34  *
  35  * University Acknowledgment- Portions of this document are derived from
  36  * software developed by the University of California, Berkeley, and its
  37  * contributors.
  38  */
  39 
  40 #ifndef _RPC_UTIL_H
  41 #define _RPC_UTIL_H
  42 
  43 #include <sys/types.h>
  44 #include <stdlib.h>
  45 #include "rpc_scan.h"
  46 
  47 #ifdef __cplusplus
  48 extern "C" {
  49 #endif
  50 
  51 /*
  52  * rpc_util.h, Useful definitions for the RPC protocol compiler
  53  */
  54 
  55 
  56 /* Current version number of rpcgen. */
  57 #define RPCGEN_MAJOR 1
  58 #define RPCGEN_MINOR 1
  59 
  60 #define f_print (void) fprintf
  61 
  62 struct list {
  63         definition *val;
  64         struct list *next;
  65 };
  66 typedef struct list list;
  67 
  68 struct xdrfunc {
  69         char *name;
  70         int pointerp;
  71         struct xdrfunc *next;
  72 };
  73 typedef struct xdrfunc xdrfunc;
  74 
  75 struct commandline {
  76         int cflag;              /* xdr C routines */
  77         int hflag;              /* header file */
  78         int lflag;              /* client side stubs */
  79         int mflag;              /* server side stubs */
  80         int nflag;              /* netid flag */
  81         int sflag;              /* server stubs for the given transport */
  82         int tflag;              /* dispatch Table file */
  83         int Ssflag;             /* produce server sample code */
  84         int Scflag;             /* produce client sample code */
  85         int makefileflag;       /* Generate a template Makefile */
  86         char *infile;           /* input module name */
  87         char *outfile;          /* output module name */
  88 };
  89 
  90 #define PUT 1
  91 #define GET 2
  92 
  93 /*
  94  * Global variables
  95  */
  96 #define MAXLINESIZE 1024
  97 extern char curline[MAXLINESIZE];
  98 extern char *where;
  99 extern int linenum;
 100 
 101 extern char *infilename;
 102 extern FILE *fout;
 103 extern FILE *fin;
 104 
 105 extern list *defined;
 106 
 107 extern bas_type *typ_list_h;
 108 extern bas_type *typ_list_t;
 109 extern xdrfunc *xdrfunc_head, *xdrfunc_tail;
 110 
 111 /*
 112  * All the option flags
 113  */
 114 extern int inetdflag;
 115 extern int pmflag;
 116 extern int tblflag;
 117 extern int logflag;
 118 extern int newstyle;
 119 extern int CCflag;      /* C++ flag */
 120 extern int tirpcflag;   /* flag for generating tirpc code */
 121 extern int inlinelen;   /* if this is 0, then do not generate inline code */
 122 extern int mtflag;
 123 extern int mtauto;
 124 extern int rflag;
 125 
 126 /*
 127  * Other flags related with inetd jumpstart.
 128  */
 129 extern int indefinitewait;
 130 extern int exitnow;
 131 extern int timerflag;
 132 
 133 extern int nonfatalerrors;
 134 
 135 extern pid_t childpid;
 136 
 137 /*
 138  * rpc_util routines
 139  */
 140 extern void storeval(list **, definition *);
 141 
 142 #define STOREVAL(list, item)    \
 143         storeval(list, item)
 144 
 145 extern definition *findval(list *, char *, int (*)());
 146 
 147 #define FINDVAL(list, item, finder) \
 148         findval(list, item, finder)
 149 
 150 extern char *fixtype(char *);
 151 extern char *stringfix(char *);
 152 extern char *locase(char *);
 153 extern void pvname_svc(char *, char *);
 154 extern void pvname(char *, char *);
 155 extern void ptype(char *, char *, int);
 156 extern int isvectordef(char *, relation);
 157 extern int streq(char *, char *);
 158 extern void error(char *);
 159 extern void expected1(tok_kind);
 160 extern void expected2(tok_kind, tok_kind);
 161 extern void expected3(tok_kind, tok_kind, tok_kind);
 162 extern void tabify(FILE *, int);
 163 extern void record_open(char *);
 164 extern bas_type *find_type(char *);
 165 
 166 /*
 167  * rpc_cout routines
 168  */
 169 extern void emit(definition *);
 170 
 171 /*
 172  * rpc_hout routines
 173  */
 174 extern void print_datadef(definition *);
 175 extern void print_funcdef(definition *);
 176 extern void print_xdr_func_def(char *, int);
 177 
 178 /*
 179  * rpc_svcout routines
 180  */
 181 extern void write_most(char *, int, int);
 182 extern void write_rest(void);
 183 extern void write_inetd_register(char *);
 184 extern void write_netid_register(char *);
 185 extern void write_nettype_register(char *);
 186 
 187 /*
 188  * rpc_clntout routines
 189  */
 190 extern void write_stubs(void);
 191 
 192 /*
 193  * rpc_tblout routines
 194  */
 195 extern void write_tables(void);
 196 
 197 #ifdef __cplusplus
 198 }
 199 #endif
 200 
 201 #endif  /* !_RPC_UTIL_H */