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