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