Print this page
rpcgen should only produce ANSI code
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/rpcgen/rpc_main.c
+++ new/usr/src/cmd/rpcgen/rpc_main.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_main.c, Top level of the RPC protocol compiler.
40 42 */
41 43
42 44 #include <stdio.h>
43 45 #include <stdlib.h>
44 46 #include <string.h>
45 47 #include <strings.h>
46 48 #include <unistd.h>
47 49 #include <ctype.h>
48 50 #include <sys/types.h>
49 51 #include <sys/param.h>
50 52 #include <sys/file.h>
51 53 #include <sys/stat.h>
52 54 #include "rpc_parse.h"
53 55 #include "rpc_util.h"
54 56 #include "rpc_scan.h"
55 57
56 58
57 59 extern void write_sample_svc(definition *);
58 60 extern int write_sample_clnt(definition *);
59 61 extern void write_sample_clnt_main(void);
60 62 extern void reinitialize(void);
61 63 extern void crash(void);
62 64 extern void add_type(int, char *);
63 65 extern void add_sample_msg(void);
64 66
65 67 static void svc_output(char *, char *, int, char *);
66 68 static void clnt_output(char *, char *, int, char *);
67 69 static void c_output(char *, char *, int, char *);
68 70 static void mkfile_output(struct commandline *);
69 71 static void c_initialize(void);
70 72 static void h_output(char *, char *, int, char *);
71 73 static void s_output(int, char *[], char *, char *, int, char *, int, int);
72 74 static void l_output(char *, char *, int, char *);
73 75 static void t_output(char *, char *, int, char *);
74 76 static int do_registers(int, char *[]);
75 77 static uint_t parseargs(int, char *[], struct commandline *);
76 78 static void usage(void);
77 79 static void version_info(void);
78 80 static void options_usage(void);
79 81
80 82 #define EXTEND 1 /* alias for TRUE */
81 83 #define DONT_EXTEND 0 /* alias for FALSE */
82 84
83 85 #define SUNOS_CPP "/usr/lib/cpp"
84 86 static int cppDefined = 0; /* explicit path for C preprocessor */
85 87
86 88
87 89 static char *cmdname;
88 90
89 91 static char *svcclosetime = "120";
90 92 static char *CPP = SUNOS_CPP;
91 93 static char CPPFLAGS[] = "-C";
92 94 static char pathbuf[MAXPATHLEN + 1];
93 95 static char *allv[] = {
94 96 "rpcgen", "-s", "udp", "-s", "tcp",
95 97 };
96 98 static int allc = sizeof (allv)/sizeof (allv[0]);
97 99 static char *allnv[] = {
98 100 "rpcgen", "-s", "netpath",
99 101 };
100 102 static int allnc = sizeof (allnv)/sizeof (allnv[0]);
101 103
102 104 /*
103 105 * machinations for handling expanding argument list
104 106 */
105 107 static void addarg(char *); /* add another argument to the list */
106 108 static void putarg(int, char *); /* put argument at specified location */
107 109 static void clear_args(void); /* clear argument list */
108 110 static void checkfiles(char *, char *); /* check if out file already exists */
109 111
110 112
111 113 #define ARGLISTLEN 20
112 114 #define FIXEDARGS 2
113 115
114 116 static char *arglist[ARGLISTLEN];
115 117 static int argcount = FIXEDARGS;
116 118
117 119
118 120 int nonfatalerrors; /* errors */
119 121 int inetdflag; /* Support for inetd is now the default */
120 122 int pmflag; /* Support for port monitors */
121 123 int logflag; /* Use syslog instead of fprintf for errors */
122 124 int tblflag; /* Support for dispatch table file */
123 125 int mtflag = 0; /* Support for MT */
124 126 int mtauto = 0; /* Enable automatic mode */
125 127 int rflag = 1; /* Eliminate tail recursion from structures */
126 128 #define INLINE 5
127 129 /* length at which to start doing an inline */
128 130
↓ open down ↓ |
96 lines elided |
↑ open up ↑ |
129 131 int inlinelen = INLINE;
130 132 /*
131 133 * Length at which to start doing an inline. INLINE = default
132 134 * if 0, no xdr_inline code
133 135 */
134 136
135 137 int indefinitewait; /* If started by port monitors, hang till it wants */
136 138 int exitnow; /* If started by port monitors, exit after the call */
137 139 int timerflag; /* TRUE if !indefinite && !exitnow */
138 140 int newstyle; /* newstyle of passing arguments (by value) */
139 -int Cflag = 0; /* ANSI C syntax */
140 141 int CCflag = 0; /* C++ files */
141 142 static int allfiles; /* generate all files */
142 143 int tirpcflag = 1; /* generating code for tirpc, by default */
143 144 xdrfunc *xdrfunc_head = NULL; /* xdr function list */
144 145 xdrfunc *xdrfunc_tail = NULL; /* xdr function list */
145 146 pid_t childpid;
146 147
147 148
148 149 int
149 150 main(int argc, char *argv[])
150 151 {
151 152 struct commandline cmd;
152 153
153 154 (void) memset(&cmd, 0, sizeof (struct commandline));
154 155 clear_args();
155 156 if (!parseargs(argc, argv, &cmd))
156 157 usage();
157 158 /*
158 159 * Only the client and server side stubs are likely to be customized,
159 160 * so in that case only, check if the outfile exists, and if so,
160 161 * print an error message and exit.
161 162 */
162 163 if (cmd.Ssflag || cmd.Scflag || cmd.makefileflag)
163 164 checkfiles(cmd.infile, cmd.outfile);
164 165 else
165 166 checkfiles(cmd.infile, NULL);
166 167
167 168 if (cmd.cflag) {
168 169 c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
169 170 } else if (cmd.hflag) {
170 171 h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
171 172 } else if (cmd.lflag) {
172 173 l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
173 174 } else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
174 175 s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
175 176 cmd.outfile, cmd.mflag, cmd.nflag);
176 177 } else if (cmd.tflag) {
177 178 t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
178 179 } else if (cmd.Ssflag) {
179 180 svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND,
180 181 cmd.outfile);
181 182 } else if (cmd.Scflag) {
182 183 clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND,
183 184 cmd.outfile);
184 185 } else if (cmd.makefileflag) {
185 186 mkfile_output(&cmd);
186 187 } else {
187 188 /* the rescans are required, since cpp may effect input */
188 189 c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
189 190 reinitialize();
190 191 h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h");
191 192 reinitialize();
192 193 l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
193 194 reinitialize();
194 195 if (inetdflag || !tirpcflag)
195 196 s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
196 197 "_svc.c", cmd.mflag, cmd.nflag);
197 198 else
198 199 s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
199 200 EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
200 201 if (tblflag) {
201 202 reinitialize();
202 203 t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
203 204 }
204 205
205 206 if (allfiles) {
206 207 reinitialize();
207 208 svc_output(cmd.infile, "-DRPC_SERVER", EXTEND,
208 209 "_server.c");
209 210 reinitialize();
210 211 clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND,
211 212 "_client.c");
212 213
213 214 }
214 215 if (allfiles || (cmd.makefileflag == 1)) {
215 216 reinitialize();
216 217 mkfile_output(&cmd);
217 218 }
218 219
219 220 }
220 221 return (nonfatalerrors);
221 222 }
222 223
223 224
224 225 /*
225 226 * add extension to filename
226 227 */
227 228 static char *
228 229 extendfile(char *file, char *ext)
229 230 {
230 231 char *res;
231 232 char *p;
232 233
233 234 res = malloc(strlen(file) + strlen(ext) + 1);
234 235 if (res == NULL)
235 236 abort();
236 237 p = strrchr(file, '.');
237 238 if (p == NULL)
238 239 p = file + strlen(file);
239 240 (void) strcpy(res, file);
240 241 (void) strcpy(res + (p - file), ext);
241 242 return (res);
242 243 }
243 244
244 245 /*
245 246 * Open output file with given extension
246 247 */
247 248 static void
248 249 open_output(char *infile, char *outfile)
249 250 {
250 251
251 252 if (outfile == NULL) {
252 253 fout = stdout;
253 254 return;
254 255 }
255 256
256 257 if (infile != NULL && streq(outfile, infile)) {
257 258 f_print(stderr,
258 259 "%s: %s already exists. No output generated.\n",
259 260 cmdname, infile);
260 261 crash();
261 262 }
262 263 fout = fopen(outfile, "w");
263 264 if (fout == NULL) {
264 265 f_print(stderr, "%s: unable to open ", cmdname);
265 266 perror(outfile);
266 267 crash();
267 268 }
268 269 record_open(outfile);
269 270
270 271 }
271 272
272 273 static void
273 274 add_warning(void)
274 275 {
275 276 f_print(fout, "/*\n");
276 277 f_print(fout, " * Please do not edit this file.\n");
277 278 f_print(fout, " * It was generated using rpcgen.\n");
278 279 f_print(fout, " */\n\n");
279 280 }
280 281
281 282 /* clear list of arguments */
282 283 static void
283 284 clear_args(void)
284 285 {
285 286 int i;
286 287
287 288 for (i = FIXEDARGS; i < ARGLISTLEN; i++)
288 289 arglist[i] = NULL;
289 290 argcount = FIXEDARGS;
290 291 }
291 292
292 293 /* make sure that a CPP exists */
293 294 static void
294 295 find_cpp(void)
295 296 {
296 297 struct stat buf;
297 298
298 299 if (stat(CPP, &buf) < 0) { /* SVR4 or explicit cpp does not exist */
299 300 if (cppDefined) {
300 301 (void) fprintf(stderr,
301 302 "cannot find C preprocessor: %s \n", CPP);
302 303 crash();
303 304 } else { /* try the other one */
304 305 CPP = SUNOS_CPP;
305 306 if (stat(CPP, &buf) < 0) { /* can't find any cpp */
306 307 (void) fprintf(stderr,
307 308 "cannot find any C preprocessor (cpp)\n");
308 309 crash();
309 310 }
310 311 }
311 312 }
312 313 }
313 314
314 315 /*
315 316 * Open input file with given define for C-preprocessor
316 317 */
317 318 static void
318 319 open_input(char *infile, char *define)
319 320 {
320 321 int pd[2];
321 322
322 323 infilename = (infile == NULL) ? "<stdin>" : infile;
323 324 (void) pipe(pd);
324 325 switch (childpid = fork()) {
325 326 case 0:
326 327 find_cpp();
327 328 putarg(0, CPP);
328 329 putarg(1, CPPFLAGS);
329 330 addarg(define);
330 331 if (infile)
331 332 addarg(infile);
332 333 addarg((char *)NULL);
333 334 (void) close(1);
334 335 (void) dup2(pd[1], 1);
335 336 (void) close(pd[0]);
336 337 (void) execv(arglist[0], arglist);
337 338 perror("execv");
338 339 exit(1);
339 340 /* NOTREACHED */
340 341 case -1:
341 342 perror("fork");
342 343 exit(1);
343 344 }
344 345 (void) close(pd[1]);
345 346 fin = fdopen(pd[0], "r");
346 347 if (fin == NULL) {
347 348 f_print(stderr, "%s: ", cmdname);
348 349 perror(infilename);
349 350 crash();
350 351 }
351 352 }
352 353
353 354 /* valid tirpc nettypes */
354 355 static char *valid_ti_nettypes[] = {
355 356 "netpath",
356 357 "visible",
357 358 "circuit_v",
358 359 "datagram_v",
359 360 "circuit_n",
360 361 "datagram_n",
361 362 "udp",
362 363 "tcp",
363 364 "raw",
364 365 NULL
365 366 };
366 367
367 368 /* valid inetd nettypes */
368 369 static char *valid_i_nettypes[] = {
369 370 "udp",
370 371 "tcp",
371 372 NULL
372 373 };
373 374
374 375 static int
375 376 check_nettype(char *name, char *list_to_check[])
376 377 {
377 378 int i;
378 379 for (i = 0; list_to_check[i] != NULL; i++) {
379 380 if (strcmp(name, list_to_check[i]) == 0) {
380 381 return (1);
381 382 }
382 383 }
383 384 f_print(stderr, "illegal nettype :\'%s\'\n", name);
384 385 return (0);
385 386 }
386 387
387 388 static char *
388 389 file_name(char *file, char *ext)
389 390 {
390 391 char *temp;
391 392 temp = extendfile(file, ext);
392 393
393 394 if (access(temp, F_OK) != -1)
394 395 return (temp);
395 396 else
396 397 return ((char *)" ");
397 398 }
398 399
399 400
400 401 static void
401 402 c_output(char *infile, char *define, int extend, char *outfile)
402 403 {
403 404 definition *def;
404 405 char *include;
405 406 char *outfilename;
406 407 long tell;
407 408
408 409 c_initialize();
409 410 open_input(infile, define);
410 411 outfilename = extend ? extendfile(infile, outfile) : outfile;
411 412 open_output(infile, outfilename);
412 413 add_warning();
413 414 if (infile && (include = extendfile(infile, ".h"))) {
414 415 f_print(fout, "#include \"%s\"\n", include);
415 416 free(include);
416 417 /* .h file already contains rpc/rpc.h */
417 418 } else
418 419 f_print(fout, "#include <rpc/rpc.h>\n");
419 420 /*
420 421 * Include stdlib.h to support mem_alloc calls.
421 422 */
422 423 f_print(fout, "\n#ifndef _KERNEL\n");
423 424 f_print(fout, "#include <stdlib.h>\n");
424 425 f_print(fout, "#endif /* !_KERNEL */\n\n");
425 426 tell = ftell(fout);
426 427 while (def = get_definition()) {
427 428 emit(def);
428 429 }
429 430 if (extend && tell == ftell(fout)) {
430 431 (void) unlink(outfilename);
431 432 }
432 433 }
433 434
434 435
435 436 static void
436 437 c_initialize(void)
437 438 {
438 439 /*
439 440 * add all the starting basic types.
440 441 * We may need to add some derived types
441 442 * if we need to generate INLINE macros.
442 443 * These types are defined in rpc/types.h
443 444 */
444 445 add_type(1, "int");
445 446 add_type(1, "long");
446 447 add_type(1, "short");
447 448 add_type(1, "bool");
448 449 add_type(1, "u_int");
449 450 add_type(1, "u_long");
450 451 add_type(1, "u_short");
451 452 add_type(1, "rpcprog_t");
452 453 add_type(1, "rpcvers_t");
453 454 add_type(1, "rpcproc_t");
454 455 add_type(1, "rpcprot_t");
455 456 add_type(1, "rpcport_t");
456 457 }
457 458
458 459 char rpcgen_table_dcl1[] = "struct rpcgen_table {\n";
459 460
460 461 char rpcgen_table_dcl2[] = "\txdrproc_t\txdr_arg;\n"
461 462 "\tunsigned\tlen_arg;\n"
462 463 "\txdrproc_t\txdr_res;\n"
463 464 "\tunsigned\tlen_res;\n"
464 465 "};\n";
465 466
466 467 char rpcgen_table_proc[] = "\tvoid\t*(*proc)();\n";
467 468
468 469 char rpcgen_table_proc_b[] = "\tchar\t*(*proc)();\n";
469 470
470 471
471 472 char *
472 473 generate_guard(char *pathname)
473 474 {
474 475 char *filename, *guard, *tmp;
475 476
476 477 filename = strrchr(pathname, '/'); /* find last component */
477 478 filename = ((filename == 0) ? pathname : filename+1);
478 479 guard = extendfile(filename, "_H_RPCGEN");
479 480
480 481 /*
481 482 * Guard must be an ANSI C identifier composed of
482 483 * upper case letters, digits, or '_'.
483 484 * Convert invalid characters to '_'.
484 485 */
485 486 for (tmp = guard; *tmp; tmp++) {
486 487 if (!isalpha(*tmp) && !isdigit(*tmp)) {
487 488 *tmp = '_';
488 489 continue;
489 490 }
490 491 if (islower(*tmp))
491 492 *tmp = toupper(*tmp);
492 493 }
493 494
494 495 /*
495 496 * The first character must be a letter; the underscore '_'
496 497 * counts as a letter.
497 498 */
498 499 if (!isalpha(guard[0]))
499 500 guard[0] = '_';
500 501
501 502 return (guard);
502 503 }
503 504
504 505 /*
505 506 * Compile into an XDR header file
506 507 */
507 508
↓ open down ↓ |
358 lines elided |
↑ open up ↑ |
508 509
509 510 static void
510 511 h_output(char *infile, char *define, int extend, char *outfile)
511 512 {
512 513 definition *def;
513 514 char *outfilename;
514 515 long tell;
515 516 char *guard;
516 517 list *l;
517 518 xdrfunc *xdrfuncp;
518 - int i;
519 519
520 520 open_input(infile, define);
521 521 outfilename = extend ? extendfile(infile, outfile) : outfile;
522 522 open_output(infile, outfilename);
523 523 add_warning();
524 524 if (outfilename || infile)
525 525 guard = generate_guard(outfilename ? outfilename: infile);
526 526 else
527 527 guard = "STDIN_";
528 528
529 529 f_print(fout, "#ifndef _%s\n#define _%s\n\n", guard, guard);
530 530
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
531 531 f_print(fout, "#include <rpc/rpc.h>\n");
532 532
533 533 if (mtflag) {
534 534 f_print(fout, "#ifndef _KERNEL\n");
535 535 f_print(fout, "#include <synch.h>\n");
536 536 f_print(fout, "#include <thread.h>\n");
537 537 f_print(fout, "#endif /* !_KERNEL */\n");
538 538 };
539 539
540 540 /* put the C++ support */
541 - if (Cflag && !CCflag) {
541 + if (!CCflag) {
542 542 f_print(fout, "\n#ifdef __cplusplus\n");
543 543 f_print(fout, "extern \"C\" {\n");
544 544 f_print(fout, "#endif\n\n");
545 545 }
546 546
547 - /* put in a typedef for quadprecision. Only with Cflag */
547 + /* put in a typedef for quadprecision. */
548 548
549 549 /*
550 550 * declaration of struct rpcgen_table must go before
551 551 * the definition of arrays like *_1_table[]
552 552 */
553 553 if (tblflag) {
554 554 f_print(fout, rpcgen_table_dcl1);
555 555 if (tirpcflag)
556 556 f_print(fout, rpcgen_table_proc);
557 557 else
558 558 f_print(fout, rpcgen_table_proc_b);
559 559 f_print(fout, rpcgen_table_dcl2);
560 560 }
561 561
562 562 tell = ftell(fout);
563 563
564 564 /* print data definitions */
565 565 while (def = get_definition())
566 566 print_datadef(def);
567 567
568 568 /*
569 569 * print function declarations.
570 570 * Do this after data definitions because they might be used as
571 571 * arguments for functions
572 572 */
573 573 for (l = defined; l != NULL; l = l->next)
574 574 print_funcdef(l->val);
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
575 575 /* Now print all xdr func declarations */
576 576 if (xdrfunc_head != NULL) {
577 577 f_print(fout, "\n/* the xdr functions */\n");
578 578
579 579 if (CCflag) {
580 580 f_print(fout, "\n#ifdef __cplusplus\n");
581 581 f_print(fout, "extern \"C\" {\n");
582 582 f_print(fout, "#endif\n");
583 583 }
584 584
585 - if (!Cflag) {
586 - xdrfuncp = xdrfunc_head;
587 - while (xdrfuncp != NULL) {
588 - print_xdr_func_def(xdrfuncp->name,
589 - xdrfuncp->pointerp, 2);
590 - xdrfuncp = xdrfuncp->next;
591 - }
592 - } else {
593 - for (i = 1; i < 3; i++) {
594 - if (i == 1)
595 - f_print(fout,
596 -"\n#if defined(__STDC__) || defined(__cplusplus)\n");
597 - else
598 - f_print(fout, "\n#else /* K&R C */\n");
585 + f_print(fout, "\n");
599 586
600 - xdrfuncp = xdrfunc_head;
601 - while (xdrfuncp != NULL) {
602 - print_xdr_func_def(xdrfuncp->name,
603 - xdrfuncp->pointerp, i);
604 - xdrfuncp = xdrfuncp->next;
605 - }
606 - }
607 - f_print(fout, "\n#endif /* K&R C */\n");
587 + xdrfuncp = xdrfunc_head;
588 + while (xdrfuncp != NULL) {
589 + print_xdr_func_def(xdrfuncp->name, xdrfuncp->pointerp);
590 + xdrfuncp = xdrfuncp->next;
608 591 }
592 + f_print(fout, "\n");
609 593 }
610 594
611 595 if (extend && tell == ftell(fout)) {
612 596 (void) unlink(outfilename);
613 597 }
614 598
615 - if (Cflag) {
616 - f_print(fout, "\n#ifdef __cplusplus\n");
617 - f_print(fout, "}\n");
618 - f_print(fout, "#endif\n");
619 - }
599 + f_print(fout, "\n#ifdef __cplusplus\n");
600 + f_print(fout, "}\n");
601 + f_print(fout, "#endif\n");
620 602
621 603 f_print(fout, "\n#endif /* !_%s */\n", guard);
622 604 }
623 605
624 606 /*
625 607 * Compile into an RPC service
626 608 */
627 609 static void
628 610 s_output(int argc, char *argv[], char *infile, char *define, int extend,
629 611 char *outfile, int nomain, int netflag)
630 612 {
631 613 char *include;
632 614 definition *def;
633 615 int foundprogram = 0;
634 616 char *outfilename;
635 617
636 618 open_input(infile, define);
637 619 outfilename = extend ? extendfile(infile, outfile) : outfile;
638 620 open_output(infile, outfilename);
639 621 add_warning();
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
640 622 if (infile && (include = extendfile(infile, ".h"))) {
641 623 f_print(fout, "#include \"%s\"\n", include);
642 624 free(include);
643 625 } else
644 626 f_print(fout, "#include <rpc/rpc.h>\n");
645 627
646 628 f_print(fout, "#include <stdio.h>\n");
647 629 f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
648 630 f_print(fout, "#include <signal.h>\n");
649 631
650 - if (Cflag) {
651 - f_print(fout,
652 - "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
653 - f_print(fout, "#include <string.h> /* strcmp */\n");
654 - }
632 + f_print(fout,
633 + "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
634 + f_print(fout, "#include <string.h> /* strcmp */\n");
635 +
655 636 if (strcmp(svcclosetime, "-1") == 0)
656 637 indefinitewait = 1;
657 638 else if (strcmp(svcclosetime, "0") == 0)
658 639 exitnow = 1;
659 640 else if (inetdflag || pmflag)
660 641 timerflag = 1;
661 642
662 643 if (!tirpcflag && inetdflag)
663 644 f_print(fout, "#include <sys/termios.h> /* TIOCNOTTY */\n");
664 - if (Cflag && (inetdflag || pmflag))
645 + if (inetdflag || pmflag)
665 646 if (tirpcflag)
666 647 f_print(fout, "#include <unistd.h> /* setsid */\n");
667 648 if (tirpcflag)
668 649 f_print(fout, "#include <sys/types.h>\n");
669 650
670 - f_print(fout, "#include <memory.h>\n");
671 651 f_print(fout, "#include <stropts.h>\n");
672 652 if (inetdflag || !tirpcflag) {
673 653 f_print(fout, "#include <sys/socket.h>\n");
674 654 f_print(fout, "#include <netinet/in.h>\n");
675 655 f_print(fout, "#include <rpc/svc_soc.h>\n");
676 656 }
677 657
678 658 if ((netflag || pmflag) && tirpcflag && !nomain)
679 659 f_print(fout, "#include <netconfig.h>\n");
680 660 if (tirpcflag)
681 661 f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
682 662 if (logflag || inetdflag || pmflag)
683 663 f_print(fout, "#include <syslog.h>\n");
684 664
685 665 /* for ANSI-C */
686 - if (Cflag)
687 - f_print(fout,
688 - "\n#ifndef SIG_PF\n#define SIG_PF void(*)\
689 -(int)\n#endif\n");
666 + f_print(fout, "\n#ifndef SIG_PF\n"
667 + "#define SIG_PF void(*)(int)\n#endif\n");
690 668
691 669 f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
692 670 if (timerflag)
693 671 f_print(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n",
694 672 svcclosetime);
695 673 while (def = get_definition())
696 674 foundprogram |= (def->def_kind == DEF_PROGRAM);
697 675 if (extend && !foundprogram) {
698 676 (void) unlink(outfilename);
699 677 return;
700 678 }
701 679 write_most(infile, netflag, nomain);
702 680 if (!nomain) {
703 681 if (!do_registers(argc, argv)) {
704 682 if (outfilename)
705 683 (void) unlink(outfilename);
706 684 usage();
707 685 }
708 686 write_rest();
709 687 }
710 688 }
711 689
712 690 /*
713 691 * generate client side stubs
714 692 */
715 693 static void
716 694 l_output(char *infile, char *define, int extend, char *outfile)
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
717 695 {
718 696 char *include;
719 697 definition *def;
720 698 int foundprogram = 0;
721 699 char *outfilename;
722 700
723 701 open_input(infile, define);
724 702 outfilename = extend ? extendfile(infile, outfile) : outfile;
725 703 open_output(infile, outfilename);
726 704 add_warning();
727 - if (Cflag)
728 - f_print(fout, "#include <memory.h> /* for memset */\n");
705 + f_print(fout, "#include <memory.h> /* for memset */\n");
729 706 if (infile && (include = extendfile(infile, ".h"))) {
730 707 f_print(fout, "#include \"%s\"\n", include);
731 708 free(include);
732 709 } else
733 710 f_print(fout, "#include <rpc/rpc.h>\n");
734 711
735 712 f_print(fout, "#ifndef _KERNEL\n");
736 713 f_print(fout, "#include <stdio.h>\n");
737 714 f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
738 715 f_print(fout, "#endif /* !_KERNEL */\n");
739 716
740 717 while (def = get_definition())
741 718 foundprogram |= (def->def_kind == DEF_PROGRAM);
742 719 if (extend && !foundprogram) {
743 720 (void) unlink(outfilename);
744 721 return;
745 722 }
746 723 write_stubs();
747 724 }
748 725
749 726 /*
750 727 * generate the dispatch table
751 728 */
752 729 static void
753 730 t_output(char *infile, char *define, int extend, char *outfile)
754 731 {
755 732 definition *def;
756 733 int foundprogram = 0;
757 734 char *outfilename;
758 735
759 736 open_input(infile, define);
760 737 outfilename = extend ? extendfile(infile, outfile) : outfile;
761 738 open_output(infile, outfilename);
762 739 add_warning();
763 740 while (def = get_definition()) {
764 741 foundprogram |= (def->def_kind == DEF_PROGRAM);
765 742 }
766 743 if (extend && !foundprogram) {
767 744 (void) unlink(outfilename);
768 745 return;
769 746 }
770 747 write_tables();
771 748 }
772 749
773 750 /* sample routine for the server template */
774 751 static void
775 752 svc_output(char *infile, char *define, int extend, char *outfile)
776 753 {
777 754 definition *def;
778 755 char *include;
779 756 char *outfilename;
780 757 long tell;
781 758 open_input(infile, define);
782 759 outfilename = extend ? extendfile(infile, outfile) : outfile;
783 760 checkfiles(infile, outfilename);
784 761 /*
785 762 * Check if outfile already exists.
786 763 * if so, print an error message and exit
787 764 */
788 765 open_output(infile, outfilename);
789 766 add_sample_msg();
790 767
791 768 if (infile && (include = extendfile(infile, ".h"))) {
792 769 f_print(fout, "#include \"%s\"\n", include);
793 770 free(include);
794 771 } else {
795 772 f_print(fout, "#include <rpc/rpc.h>\n");
796 773 }
797 774
798 775 f_print(fout, "#include <stdio.h>\n");
799 776 f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
800 777 f_print(fout, "#include <signal.h>\n");
801 778
802 779 tell = ftell(fout);
803 780 while (def = get_definition())
804 781 write_sample_svc(def);
805 782 if (extend && tell == ftell(fout))
806 783 (void) unlink(outfilename);
807 784 }
808 785
809 786 /* sample main routine for client */
810 787 static void
811 788 clnt_output(char *infile, char *define, int extend, char *outfile)
812 789 {
813 790 definition *def;
814 791 char *include;
815 792 char *outfilename;
816 793 long tell;
817 794 int has_program = 0;
818 795
819 796 open_input(infile, define);
820 797 outfilename = extend ? extendfile(infile, outfile) : outfile;
821 798 checkfiles(infile, outfilename);
822 799 /*
823 800 * Check if outfile already exists.
824 801 * if so, print an error message and exit
825 802 */
826 803
827 804 open_output(infile, outfilename);
828 805 add_sample_msg();
829 806 if (infile && (include = extendfile(infile, ".h"))) {
830 807 f_print(fout, "#include \"%s\"\n", include);
831 808 free(include);
832 809 } else
833 810 f_print(fout, "#include <rpc/rpc.h>\n");
834 811
835 812 f_print(fout, "#include <stdio.h>\n");
836 813 f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
837 814
838 815 tell = ftell(fout);
839 816 while (def = get_definition())
840 817 has_program += write_sample_clnt(def);
841 818
842 819 if (has_program)
843 820 write_sample_clnt_main();
844 821
845 822 if (extend && tell == ftell(fout))
846 823 (void) unlink(outfilename);
847 824 }
848 825
849 826
850 827 static void
851 828 mkfile_output(struct commandline *cmd)
852 829 {
853 830 char *mkfilename, *clientname, *clntname, *xdrname, *hdrname;
854 831 char *servername, *svcname, *servprogname, *clntprogname;
855 832 char *temp;
856 833
857 834 svcname = file_name(cmd->infile, "_svc.c");
858 835 clntname = file_name(cmd->infile, "_clnt.c");
859 836 xdrname = file_name(cmd->infile, "_xdr.c");
860 837 hdrname = file_name(cmd->infile, ".h");
861 838
862 839
863 840 if (allfiles) {
864 841 servername = extendfile(cmd->infile, "_server.c");
865 842 clientname = extendfile(cmd->infile, "_client.c");
866 843 } else {
867 844 servername = " ";
868 845 clientname = " ";
869 846 }
870 847 servprogname = extendfile(cmd->infile, "_server");
871 848 clntprogname = extendfile(cmd->infile, "_client");
872 849
873 850 if (allfiles) {
874 851 mkfilename = malloc(strlen("makefile.") +
875 852 strlen(cmd->infile) + 1);
876 853 if (mkfilename == NULL) {
877 854 f_print(stderr, "Out of memory!\n");
878 855 return;
879 856 }
880 857 temp = (char *)rindex(cmd->infile, '.');
881 858 (void) strcpy(mkfilename, "makefile.");
882 859 (void) strncat(mkfilename, cmd->infile,
883 860 (temp - cmd->infile));
884 861 } else
885 862 mkfilename = cmd->outfile;
886 863
887 864
888 865 checkfiles(NULL, mkfilename);
889 866 open_output(NULL, mkfilename);
890 867
891 868 f_print(fout, "\n# This is a template makefile generated\
892 869 by rpcgen \n");
893 870
894 871 f_print(fout, "\n# Parameters \n\n");
895 872
896 873 f_print(fout, "CLIENT = %s\nSERVER = %s\n\n",
897 874 clntprogname, servprogname);
898 875 f_print(fout, "SOURCES_CLNT.c = \nSOURCES_CLNT.h = \n");
899 876 f_print(fout, "SOURCES_SVC.c = \nSOURCES_SVC.h = \n");
900 877 f_print(fout, "SOURCES.x = %s\n\n", cmd->infile);
901 878 f_print(fout, "TARGETS_SVC.c = %s %s %s \n",
902 879 svcname, servername, xdrname);
903 880 f_print(fout, "TARGETS_CLNT.c = %s %s %s \n",
904 881 clntname, clientname, xdrname);
905 882 f_print(fout, "TARGETS = %s %s %s %s %s %s\n\n",
906 883 hdrname, xdrname, clntname,
907 884 svcname, clientname, servername);
908 885
909 886 f_print(fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) "
910 887 "$(TARGETS_CLNT.c:%%.c=%%.o) ");
911 888
912 889 f_print(fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) "
913 890 "$(TARGETS_SVC.c:%%.c=%%.o) ");
914 891
915 892
916 893 f_print(fout, "\n# Compiler flags \n");
917 894 if (mtflag)
918 895 f_print(fout, "\nCPPFLAGS += -D_REENTRANT\n"
919 896 "CFLAGS += -g\nLDLIBS += -lnsl\n");
920 897 else
921 898 f_print(fout, "\nCFLAGS += -g \nLDLIBS += -lnsl\n");
922 899 f_print(fout, "RPCGENFLAGS = \n");
923 900
924 901 f_print(fout, "\n# Targets \n\n");
925 902
926 903 f_print(fout, "all : $(CLIENT) $(SERVER)\n\n");
927 904 f_print(fout, "$(TARGETS) : $(SOURCES.x) \n");
928 905 f_print(fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n");
929 906 f_print(fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \
930 907 $(TARGETS_CLNT.c) \n\n");
931 908
932 909 f_print(fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \
933 910 $(TARGETS_SVC.c) \n\n");
934 911 f_print(fout, "$(CLIENT) : $(OBJECTS_CLNT) \n");
935 912 f_print(fout, "\t$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) \
936 913 $(LDLIBS) \n\n");
937 914 f_print(fout, "$(SERVER) : $(OBJECTS_SVC) \n");
938 915 f_print(fout, "\t$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n ");
939 916 f_print(fout, "clean:\n\t $(RM) core $(TARGETS) $(OBJECTS_CLNT) \
940 917 $(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");
941 918 }
942 919
943 920
944 921 /*
945 922 * Perform registrations for service output
946 923 * Return 0 if failed; 1 otherwise.
947 924 */
948 925 static int
949 926 do_registers(int argc, char *argv[])
950 927 {
951 928 int i;
952 929
953 930 if (inetdflag || !tirpcflag) {
954 931 for (i = 1; i < argc; i++) {
955 932 if (streq(argv[i], "-s")) {
956 933 if (!check_nettype(argv[i + 1],
957 934 valid_i_nettypes))
958 935 return (0);
959 936 write_inetd_register(argv[i + 1]);
960 937 i++;
961 938 }
962 939 }
963 940 } else {
964 941 for (i = 1; i < argc; i++)
965 942 if (streq(argv[i], "-s")) {
966 943 if (!check_nettype(argv[i + 1],
967 944 valid_ti_nettypes))
968 945 return (0);
969 946 write_nettype_register(argv[i + 1]);
970 947 i++;
971 948 } else if (streq(argv[i], "-n")) {
972 949 write_netid_register(argv[i + 1]);
973 950 i++;
974 951 }
975 952 }
976 953 return (1);
977 954 }
978 955
979 956 /*
980 957 * Add another argument to the arg list
981 958 */
982 959 static void
983 960 addarg(char *cp)
984 961 {
985 962 if (argcount >= ARGLISTLEN) {
986 963 f_print(stderr, "rpcgen: too many defines\n");
987 964 crash();
988 965 /*NOTREACHED*/
989 966 }
990 967 arglist[argcount++] = cp;
991 968 }
992 969
993 970 static void
994 971 putarg(int where, char *cp)
995 972 {
996 973 if (where >= ARGLISTLEN) {
997 974 f_print(stderr, "rpcgen: arglist coding error\n");
998 975 crash();
999 976 /*NOTREACHED*/
1000 977 }
1001 978 arglist[where] = cp;
1002 979 }
1003 980
1004 981 /*
1005 982 * if input file is stdin and an output file is specified then complain
1006 983 * if the file already exists. Otherwise the file may get overwritten
1007 984 * If input file does not exist, exit with an error
1008 985 */
1009 986 static void
1010 987 checkfiles(char *infile, char *outfile)
1011 988 {
1012 989 struct stat buf;
1013 990
1014 991 if (infile) { /* infile ! = NULL */
1015 992 if (stat(infile, &buf) < 0) {
1016 993 perror(infile);
1017 994 crash();
1018 995 }
1019 996 }
1020 997 if (outfile) {
1021 998 if (stat(outfile, &buf) < 0)
1022 999 return; /* file does not exist */
1023 1000 f_print(stderr,
1024 1001 "file '%s' already exists and may be overwritten\n",
1025 1002 outfile);
1026 1003 crash();
1027 1004 }
1028 1005 }
1029 1006
1030 1007 /*
1031 1008 * Parse command line arguments
1032 1009 */
1033 1010 static uint_t
1034 1011 parseargs(int argc, char *argv[], struct commandline *cmd)
1035 1012 {
1036 1013 int i;
1037 1014 int j;
1038 1015 char c, ch;
1039 1016 char flag[(1 << 8 * sizeof (char))];
1040 1017 int nflags;
1041 1018
1042 1019 cmdname = argv[0];
1043 1020 cmd->infile = cmd->outfile = NULL;
1044 1021 if (argc < 2)
1045 1022 return (0);
1046 1023 allfiles = 0;
1047 1024 flag['c'] = 0;
1048 1025 flag['h'] = 0;
1049 1026 flag['l'] = 0;
1050 1027 flag['m'] = 0;
1051 1028 flag['o'] = 0;
1052 1029 flag['s'] = 0;
1053 1030 flag['n'] = 0;
1054 1031 flag['t'] = 0;
1055 1032 flag['S'] = 0;
1056 1033 flag['C'] = 0;
1057 1034 flag['M'] = 0;
1058 1035
1059 1036 for (i = 1; i < argc; i++) {
1060 1037 if (argv[i][0] != '-') {
1061 1038 if (cmd->infile) {
1062 1039 f_print(stderr,
1063 1040 "Cannot specify more than one input file.\n");
1064 1041
1065 1042 return (0);
1066 1043 }
1067 1044 cmd->infile = argv[i];
1068 1045 } else {
1069 1046 for (j = 1; argv[i][j] != 0; j++) {
1070 1047 c = argv[i][j];
1071 1048 switch (c) {
1072 1049 case 'a':
1073 1050 allfiles = 1;
1074 1051 break;
1075 1052 case 'c':
1076 1053 case 'h':
1077 1054 case 'l':
1078 1055 case 'm':
1079 1056 case 't':
1080 1057 if (flag[c])
1081 1058 return (0);
1082 1059 flag[c] = 1;
1083 1060 break;
1084 1061 case 'S':
1085 1062 /*
1086 1063 * sample flag: Ss or Sc.
1087 1064 * Ss means set flag['S'];
1088 1065 * Sc means set flag['C'];
1089 1066 * Sm means set flag['M'];
1090 1067 */
1091 1068 ch = argv[i][++j]; /* get next char */
1092 1069 if (ch == 's')
1093 1070 ch = 'S';
1094 1071 else if (ch == 'c')
↓ open down ↓ |
356 lines elided |
↑ open up ↑ |
1095 1072 ch = 'C';
1096 1073 else if (ch == 'm')
1097 1074 ch = 'M';
1098 1075 else
1099 1076 return (0);
1100 1077
1101 1078 if (flag[ch])
1102 1079 return (0);
1103 1080 flag[ch] = 1;
1104 1081 break;
1105 - case 'C': /* ANSI C syntax */
1106 - Cflag = 1;
1082 + case 'C': /* ANSI C syntax (default) */
1107 1083 ch = argv[i][j+1]; /* get next char */
1108 1084
1109 1085 if (ch != 'C')
1110 1086 break;
1087 + /* Undocumented C++ mode */
1111 1088 CCflag = 1;
1112 1089 break;
1113 1090 case 'b':
1114 1091 /*
1115 1092 * Turn TIRPC flag off for
1116 1093 * generating backward compatible
1117 1094 * code
1118 1095 */
1119 1096 tirpcflag = 0;
1120 1097 break;
1121 1098
1122 1099 case 'I':
1123 1100 inetdflag = 1;
1124 1101 break;
1125 1102 case 'N':
1126 1103 newstyle = 1;
1127 1104 break;
1128 1105 case 'L':
1129 1106 logflag = 1;
1130 1107 break;
1131 1108 case 'K':
1132 1109 if (++i == argc)
1133 1110 return (0);
1134 1111 svcclosetime = argv[i];
1135 1112 goto nextarg;
1136 1113 case 'T':
1137 1114 tblflag = 1;
1138 1115 break;
1139 1116 case 'A':
1140 1117 mtauto = 1;
1141 1118 /* FALLTHRU */
1142 1119 case 'M':
1143 1120 mtflag = 1;
1144 1121 break;
1145 1122 case 'i' :
1146 1123 if (++i == argc)
1147 1124 return (0);
1148 1125 inlinelen = atoi(argv[i]);
1149 1126 goto nextarg;
1150 1127 case 'n':
1151 1128 case 'o':
1152 1129 case 's':
1153 1130 if (argv[i][j - 1] != '-' ||
1154 1131 argv[i][j + 1] != 0)
1155 1132 return (0);
1156 1133 flag[c] = 1;
1157 1134 if (++i == argc)
1158 1135 return (0);
1159 1136 if (c == 'o') {
1160 1137 if (cmd->outfile)
1161 1138 return (0);
1162 1139 cmd->outfile = argv[i];
1163 1140 }
1164 1141 goto nextarg;
1165 1142 case 'D':
1166 1143 if (argv[i][j - 1] != '-')
1167 1144 return (0);
1168 1145 (void) addarg(argv[i]);
1169 1146 goto nextarg;
1170 1147 case 'v':
1171 1148 version_info();
1172 1149 return (0);
1173 1150 case 'Y':
1174 1151 if (++i == argc)
1175 1152 return (0);
1176 1153 (void) strcpy(pathbuf, argv[i]);
1177 1154 (void) strcat(pathbuf, "/cpp");
1178 1155 CPP = pathbuf;
1179 1156 cppDefined = 1;
1180 1157 goto nextarg;
1181 1158 case 'r':
1182 1159 rflag = !rflag;
1183 1160 break;
1184 1161 default:
1185 1162 return (0);
1186 1163 }
1187 1164 }
1188 1165 nextarg:
1189 1166 ;
1190 1167 }
1191 1168 }
1192 1169
1193 1170 cmd->cflag = flag['c'];
1194 1171 cmd->hflag = flag['h'];
1195 1172 cmd->lflag = flag['l'];
1196 1173 cmd->mflag = flag['m'];
1197 1174 cmd->nflag = flag['n'];
1198 1175 cmd->sflag = flag['s'];
1199 1176 cmd->tflag = flag['t'];
1200 1177 cmd->Ssflag = flag['S'];
1201 1178 cmd->Scflag = flag['C'];
1202 1179 cmd->makefileflag = flag['M'];
1203 1180
1204 1181 if (tirpcflag) {
1205 1182 if (inetdflag) {
1206 1183 f_print(stderr,
1207 1184 "Cannot use -I flag without -b flag.\n");
1208 1185 return (0);
1209 1186 }
1210 1187 pmflag = 1;
1211 1188 } else { /* 4.1 mode */
1212 1189 pmflag = 0; /* set pmflag only in tirpcmode */
1213 1190 inetdflag = 1; /* inetdflag is TRUE by default */
1214 1191 if (cmd->nflag) { /* netid needs TIRPC */
1215 1192 f_print(stderr,
1216 1193 "Cannot use netid flag without TIRPC.\n");
1217 1194 return (0);
1218 1195 }
1219 1196 }
1220 1197
1221 1198 if (newstyle && (tblflag || cmd->tflag)) {
1222 1199 f_print(stderr, "Cannot use table flags with newstyle.\n");
1223 1200 return (0);
1224 1201 }
1225 1202
1226 1203 /* check no conflicts with file generation flags */
1227 1204 nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +
1228 1205 cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag +
1229 1206 cmd->Scflag + cmd->makefileflag;
1230 1207
1231 1208 if (nflags == 0) {
1232 1209 if (cmd->outfile != NULL || cmd->infile == NULL)
1233 1210 return (0);
1234 1211 } else if (cmd->infile == NULL &&
1235 1212 (cmd->Ssflag || cmd->Scflag || cmd->makefileflag)) {
1236 1213 f_print(stderr, "\"infile\" is required for template"
1237 1214 " generation flags.\n");
1238 1215 return (0);
1239 1216 }
1240 1217 if (nflags > 1) {
1241 1218 f_print(stderr,
1242 1219 "Cannot have more than one file generation flag.\n");
1243 1220 return (0);
1244 1221 }
1245 1222 return (1);
1246 1223 }
1247 1224
1248 1225 static void
1249 1226 usage(void)
1250 1227 {
1251 1228 f_print(stderr, "%s (%d.%d)\n", cmdname, RPCGEN_MAJOR, RPCGEN_MINOR);
1252 1229 f_print(stderr, "usage: %s infile\n", cmdname);
1253 1230 f_print(stderr, "\t%s [-abCLNTMA] [-Dname[=value]] [-i size]"
1254 1231 " [-I [-K seconds]] [-Y path] infile\n", cmdname);
1255 1232 f_print(stderr, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm]"
1256 1233 " [-o outfile] [infile]\n", cmdname);
1257 1234 f_print(stderr, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname);
1258 1235 f_print(stderr, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname);
1259 1236 options_usage();
1260 1237 exit(1);
1261 1238 }
1262 1239
1263 1240 static void
1264 1241 version_info(void)
1265 1242 {
1266 1243 f_print(stderr, "%s %d.%d\n", cmdname, RPCGEN_MAJOR, RPCGEN_MINOR);
1267 1244 exit(1);
1268 1245 }
1269 1246
1270 1247 static void
1271 1248 options_usage(void)
1272 1249 {
1273 1250 /* BEGIN CSTYLED */
1274 1251 f_print(stderr, "options:\n");
1275 1252 f_print(stderr, "-a\t\tgenerate all files, including samples\n");
1276 1253 f_print(stderr, "-A\t\tgenerate code to enable automatic MT mode\n");
1277 1254 f_print(stderr, "-b\t\tbackward compatibility mode (generates code"
1278 1255 " for SunOS 4.X)\n");
1279 1256 f_print(stderr, "-c\t\tgenerate XDR routines\n");
1280 1257 f_print(stderr, "-C\t\tANSI C mode\n");
1281 1258 f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n");
1282 1259 f_print(stderr, "-h\t\tgenerate header file\n");
1283 1260 f_print(stderr, "-i size\t\tsize at which to start generating"
1284 1261 " inline code\n");
1285 1262 f_print(stderr, "-I\t\tgenerate code for inetd support in server"
1286 1263 " (for SunOS 4.X)\n");
1287 1264 f_print(stderr, "-K seconds\tserver exits after K seconds of"
1288 1265 " inactivity\n");
1289 1266 f_print(stderr, "-l\t\tgenerate client side stubs\n");
1290 1267 f_print(stderr, "-L\t\tserver errors will be printed to syslog\n");
1291 1268 f_print(stderr, "-m\t\tgenerate server side stubs\n");
1292 1269 f_print(stderr, "-M\t\tgenerate MT-safe code\n");
1293 1270 f_print(stderr, "-n netid\tgenerate server code that supports"
1294 1271 " named netid\n");
1295 1272 f_print(stderr, "-N\t\tsupports multiple arguments and"
1296 1273 " call-by-value\n");
1297 1274 f_print(stderr, "-o outfile\tname of the output file\n");
1298 1275 f_print(stderr, "-s nettype\tgenerate server code that supports named"
1299 1276 " nettype\n");
1300 1277 f_print(stderr, "-Sc\t\tgenerate sample client code that uses remote"
1301 1278 " procedures\n");
1302 1279 f_print(stderr, "-Ss\t\tgenerate sample server code that defines"
1303 1280 " remote procedures\n");
1304 1281 f_print(stderr, "-Sm \t\tgenerate makefile template \n");
1305 1282
1306 1283 f_print(stderr, "-t\t\tgenerate RPC dispatch table\n");
1307 1284 f_print(stderr, "-T\t\tgenerate code to support RPC dispatch tables\n");
1308 1285 f_print(stderr, "-v\t\tprint version information and exit\n");
1309 1286 f_print(stderr, "-Y path\t\tpath where cpp is found\n");
1310 1287 /* END CSTYLED */
1311 1288 exit(1);
1312 1289 }
↓ open down ↓ |
192 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX