Print this page
rpcgen should only produce ANSI code
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/rpcgen/rpc_tblout.c
+++ new/usr/src/cmd/rpcgen/rpc_tblout.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 + *
23 25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 26 * Use is subject to license terms.
25 27 */
26 28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 29 /* All Rights Reserved */
28 30 /*
29 31 * University Copyright- Copyright (c) 1982, 1986, 1988
30 32 * The Regents of the University of California
31 33 * All Rights Reserved
32 34 *
33 35 * University Acknowledgment- Portions of this document are derived from
34 36 * software developed by the University of California, Berkeley, and its
35 37 * contributors.
36 38 */
37 39
38 40 /*
39 41 * rpc_tblout.c, Dispatch table outputter for the RPC protocol compiler
40 42 */
41 43 #include <stdio.h>
42 44 #include <string.h>
43 45 #include "rpc_parse.h"
44 46 #include "rpc_util.h"
45 47
46 48 extern int nullproc(proc_list *);
47 49
48 50 static void write_table(definition *);
49 51 static void printit(char *, char *);
50 52
51 53 #define TABSIZE 8
52 54 #define TABCOUNT 5
53 55 #define TABSTOP (TABSIZE*TABCOUNT)
54 56
55 57 static char tabstr[TABCOUNT+1] = "\t\t\t\t\t";
56 58
57 59 static char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n";
58 60 static char tbl_end[] = "};\n";
59 61
60 62 static char null_entry_b[] = "\n\t(char *(*)())0,\n"
61 63 " \t(xdrproc_t)xdr_void,\t\t\t0,\n"
62 64 " \t(xdrproc_t)xdr_void,\t\t\t0,\n";
63 65
64 66 static char null_entry[] = "\n\t(void *(*)())0,\n"
65 67 " \t(xdrproc_t)xdr_void,\t\t\t0,\n"
66 68 " \t(xdrproc_t)xdr_void,\t\t\t0,\n";
67 69
68 70
69 71 static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)"
70 72 "/sizeof(%s_table[0]);\n\n";
71 73
72 74 void
73 75 write_tables(void)
74 76 {
75 77 list *l;
76 78 definition *def;
77 79
78 80 f_print(fout, "\n");
79 81 for (l = defined; l != NULL; l = l->next) {
80 82 def = (definition *)l->val;
81 83 if (def->def_kind == DEF_PROGRAM) {
82 84 write_table(def);
83 85 }
84 86 }
85 87 }
86 88
87 89 static void
88 90 write_table(definition *def)
89 91 {
90 92 version_list *vp;
91 93 proc_list *proc;
92 94 int current;
93 95 int expected;
94 96 char progvers[100];
95 97 int warning;
96 98
97 99 for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
98 100 warning = 0;
99 101 (void) snprintf(progvers, sizeof (progvers), "%s_%s",
100 102 locase(def->def_name), vp->vers_num);
101 103 /* print the table header */
102 104 f_print(fout, tbl_hdr, progvers);
103 105
104 106 if (nullproc(vp->procs)) {
105 107 expected = 0;
106 108 } else {
107 109 expected = 1;
108 110 if (tirpcflag)
109 111 f_print(fout, null_entry);
110 112 else
111 113 f_print(fout, null_entry_b);
112 114 }
113 115 for (proc = vp->procs; proc != NULL; proc = proc->next) {
114 116 current = atoi(proc->proc_num);
115 117 if (current != expected++) {
116 118 f_print(fout,
117 119 "\n/*\n * WARNING: table out of order\n */\n");
118 120 if (warning == 0) {
119 121 f_print(stderr,
120 122 "WARNING %s table is out of order\n",
121 123 progvers);
122 124 warning = 1;
123 125 nonfatalerrors = 1;
124 126 }
↓ open down ↓ |
92 lines elided |
↑ open up ↑ |
125 127 expected = current + 1;
126 128 }
127 129 if (tirpcflag)
128 130 f_print(fout,
129 131 "\n\t(void *(*)())RPCGEN_ACTION(");
130 132 else
131 133 f_print(fout,
132 134 "\n\t(char *(*)())RPCGEN_ACTION(");
133 135
134 136 /* routine to invoke */
135 - if (Cflag && !newstyle)
137 + if (!newstyle)
136 138 pvname_svc(proc->proc_name, vp->vers_num);
137 139 else {
138 140 if (newstyle) /* calls internal func */
139 141 f_print(fout, "_");
140 142 pvname(proc->proc_name, vp->vers_num);
141 143 }
142 144 f_print(fout, "),\n");
143 145
144 146 /* argument info */
145 147 if (proc->arg_num > 1)
146 148 printit(NULL, proc->args.argname);
147 149 else
148 150 /* do we have to do something special for newstyle */
149 151 printit(proc->args.decls->decl.prefix,
150 152 proc->args.decls->decl.type);
151 153 /* result info */
152 154 printit(proc->res_prefix, proc->res_type);
153 155 }
154 156
155 157 /* print the table trailer */
156 158 f_print(fout, tbl_end);
157 159 f_print(fout, tbl_nproc, progvers, progvers, progvers);
158 160 }
159 161 }
160 162
161 163 static void
162 164 printit(char *prefix, char *type)
163 165 {
164 166 int len;
165 167 int tabs;
166 168
167 169
168 170 if (streq(type, "oneway"))
169 171 len = fprintf(fout, "\t(xdrproc_t)xdr_void,");
170 172 else
171 173 len = fprintf(fout, "\t(xdrproc_t)xdr_%s,", stringfix(type));
172 174 /* account for leading tab expansion */
173 175 len += TABSIZE - 1;
174 176 if (len >= TABSTOP) {
175 177 f_print(fout, "\n");
176 178 len = 0;
177 179 }
178 180 /* round up to tabs required */
179 181 tabs = (TABSTOP - len + TABSIZE - 1)/TABSIZE;
180 182 f_print(fout, "%s", &tabstr[TABCOUNT-tabs]);
181 183
182 184 if (streq(type, "void") || streq(type, "oneway")) {
183 185 f_print(fout, "0");
184 186 } else {
185 187 f_print(fout, "sizeof ( ");
186 188 /* XXX: should "follow" be 1 ??? */
187 189 ptype(prefix, type, 0);
188 190 f_print(fout, ")");
189 191 }
190 192 f_print(fout, ",\n");
191 193 }
↓ open down ↓ |
46 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX