1 /* @(#)rpc_main.c 1.4 87/11/30 3.9 RPCSRC */
3 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4 * unrestricted use provided that this legend is included on all tape
5 * media and as a part of the software program in whole or part. Users
6 * may copy or modify Sun RPC without charge, but are not authorized
7 * to license or distribute it to anyone else except as part of a product or
8 * program developed by the user.
10 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 * Sun RPC is provided with no support and without any obligation on the
15 * part of Sun Microsystems, Inc. to assist in its use, correction,
16 * modification or enhancement.
18 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20 * OR ANY PART THEREOF.
22 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23 * or profits or other special, indirect and consequential damages, even if
24 * Sun has been advised of the possibility of such damages.
26 * Sun Microsystems, Inc.
28 * Mountain View, California 94043
32 * rpc_main.c, Top level of the RPC protocol compiler.
33 * Copyright (C) 1987, Sun Microsystems, Inc.
36 #include <afs/param.h>
43 #if defined(AFS_SUN5_ENV) || defined(AFS_NT40_ENV)
52 #include "rpc_parse.h"
55 #define EXTEND 1 /* alias for TRUE */
75 #define MAXCPPARGS 256 /* maximum number of arguments to cpp */
76 #define MAXCMDLINE 1024 /* MAX chars on a single cmd line */
79 static char *IncludeDir[MAXCPPARGS];
83 char Sflag = 0, Cflag = 0, hflag = 0, cflag = 0, kflag = 0;
84 char zflag = 0; /* If set, abort server stub if rpc call returns non-zero */
85 char xflag = 0; /* if set, add stats code to stubs */
86 char yflag = 0; /* if set, only emit function name arrays to xdr file */
90 static char CPP[] = "/usr/ccs/lib/cpp";
91 #elif defined(AFS_FBSD_ENV)
92 static char CPP[] = "/usr/bin/cpp";
93 #elif defined(AFS_NT40_ENV)
94 static char CPP[MAXCMDLINE];
95 #elif defined(AFS_DARWIN_ENV)
96 static char CPP[] = "cc -E";
98 static char CPP[] = "/lib/cpp";
100 static char CPPFLAGS[] = "-C";
101 static char *allv[] = {
102 "rpcgen", "-s", "udp", "-s", "tcp",
107 * Running "cpp" directly on DEC OSF/1 does not define anything; the "cc"
108 * driver is responsible. To compensate (and allow for other definitions
109 * which should always be passed to "cpp"), place definitions which whould
110 * always be passed to "rxgen" in this table.
112 static char *XTRA_CPPFLAGS[] = {
127 static do_registers();
130 static int allc = sizeof(allv)/sizeof(allv[0]);
132 #include "AFS_component_version_number.c"
139 struct commandline cmd;
142 /* initialize CPP with the correct pre-processor on NT */
144 ep = getenv("RXGEN_CPPCMD");
148 strcpy(CPP, "cl /EP /C /nologo");
152 * The following signal action for AIX is necessary so that in case of a
153 * crash (i.e. core is generated) we can include the user's data section
154 * in the core dump. Unfortunately, by default, only a partial core is
155 * generated which, in many cases, isn't too useful.
157 struct sigaction nsa;
159 sigemptyset(&nsa.sa_mask);
160 nsa.sa_handler = SIG_DFL;
161 nsa.sa_flags = SA_FULLDUMP;
162 sigaction(SIGSEGV, &nsa, NULL);
165 if (!parseargs(argc, argv, &cmd)) {
167 "usage: %s infile\n", cmdname);
169 " %s [-c | -h | -l | -m | -C | -S | -r | -k | -R | -p | -d | -z] [-Pprefix] [-Idir] [-o outfile] [infile]\n",
172 " %s [-s udp|tcp]* [-o outfile] [infile]\n",
176 OutFileFlag = cmd.outfile;
178 strcpy(OutFile, cmd.outfile);
181 c_output(cmd.infile, "-DRPC_XDR", !EXTEND, cmd.outfile, 0);
182 } else if (cmd.hflag) {
183 h_output(cmd.infile, "-DRPC_HDR", !EXTEND, cmd.outfile);
184 } else if (cmd.lflag) {
185 l_output(cmd.infile, "-DRPC_CLNT", !EXTEND, cmd.outfile);
186 } else if (cmd.sflag || cmd.mflag) {
187 s_output(argc, argv, cmd.infile, "-DRPC_SVC", !EXTEND,
188 cmd.outfile, cmd.mflag);
189 } else if (cmd.Cflag) {
191 C_output(cmd.infile, "-DRPC_CLIENT", !EXTEND, cmd.outfile, 1);
192 } else if (cmd.Sflag) {
194 S_output(cmd.infile, "-DRPC_SERVER", !EXTEND, cmd.outfile, 1);
196 if (OutFileFlag && (rindex(OutFile,'.') == NULL))
197 strcat(OutFile, ".");
199 C_output((OutFileFlag ? OutFile : cmd.infile), "-DRPC_CLIENT", EXTEND, ".cs.c", 1);
201 S_output((OutFileFlag ? OutFile : cmd.infile), "-DRPC_SERVER", EXTEND, ".ss.c", 1);
205 c_output((OutFileFlag ? OutFile : cmd.infile), "-DRPC_XDR", EXTEND, ".xdr.c", 0);
207 h_output((OutFileFlag ? OutFile : cmd.infile), "-DRPC_HDR", EXTEND, ".h", 0);
209 C_output((OutFileFlag ? OutFile : cmd.infile), "-DRPC_CLIENT", EXTEND, ".cs.c", 1);
211 S_output((OutFileFlag ? OutFile : cmd.infile), "-DRPC_SERVER", EXTEND, ".ss.c", 1);
219 write_int32_macros(fout)
223 * Note that rxgen writes code that uses xdr_afs_int32() and
224 * xdr_afs_uint32(). Systems do not provide these natively, so we
225 * #define them to locally provided equivalents.
227 * Some systems do come with native xdr_int32() and xdr_uint32()
228 * functions, but the prototypes are not always in the same
229 * place and are not always consistent so it is less trouble to
230 * use the original int and u_int functions. We do check that
231 * an int is 32 bits...
233 * A cleaner solution than these #defines would be to make rxgen
234 * emit calls to xdr_int() and xdr_u_int() to process the types
235 * afs_int32 and afs_uint32 (if, of course, an int is 32 bits).
237 * Note that to avoid compiler warnings we need to keep
238 * the types of the native xdr_* routines in sync with the
239 * definitions of afs_int32 and afs_uint32 in config/stds.h.
243 * If you change the definitions of xdr_afs_int32 and xdr_afs_uint32,
244 * be sure to change them in BOTH rx/xdr.h and rxgen/rpc_main.c.
247 #if (INT_MAX == 0x7FFFFFFF) && (UINT_MAX == 0xFFFFFFFFu)
248 f_print(fout, "#ifndef xdr_afs_int32\n");
249 f_print(fout, "#ifdef AFS_64BIT_ENV\n");
250 f_print(fout, "#define xdr_afs_int32 xdr_int\n");
251 f_print(fout, "#else\n");
252 f_print(fout, "#define xdr_afs_int32 xdr_long\n");
253 f_print(fout, "#endif\n");
254 f_print(fout, "#endif\n");
255 f_print(fout, "#ifndef xdr_afs_uint32\n");
256 f_print(fout, "#define xdr_afs_uint32 xdr_u_int\n");
257 f_print(fout, "#endif\n");
258 f_print(fout, "#ifndef xdr_afs_int64\n");
259 f_print(fout, "#define xdr_afs_int64 xdr_int64\n");
260 f_print(fout, "#endif\n");
261 f_print(fout, "#ifndef xdr_afs_uint64\n");
262 f_print(fout, "#define xdr_afs_uint64 xdr_uint64\n");
263 f_print(fout, "#endif\n");
265 #error Need to do some work here...
270 * add extension to filename
273 extendfile(file, ext)
281 res = alloc(strlen(file) + strlen(ext) + 1);
285 p = (char *) rindex(file, '.');
287 p = file + strlen(file);
289 sname = (char *) rindex(file,'/');
295 strcpy(res + (p - sname),ext);
300 * Open output file with given extension
303 open_output(infile, outfile)
307 if (outfile == NULL) {
311 if (infile != NULL && streq(outfile, infile)) {
312 f_print(stderr, "%s: output would overwrite %s\n", cmdname,
316 fout = fopen(outfile, "w");
318 f_print(stderr, "%s: unable to open ", cmdname);
322 record_open(outfile);
326 * Open input file with given define for C-preprocessor
329 open_input(infile, define)
333 char *exec_args[MAXCPPARGS+10];
336 char cpp_cmdline[MAXCMDLINE];
340 infilename = (infile == NULL) ? "<stdin>" : infile;
341 strcpy(cpp_cmdline, CPP);
342 strcat(cpp_cmdline, " ");
343 strcat(cpp_cmdline, CPPFLAGS);
344 strcat(cpp_cmdline, " ");
345 strcat(cpp_cmdline, define);
349 i < (sizeof(XTRA_CPPFLAGS)/
350 sizeof(XTRA_CPPFLAGS[0])) - 1;
352 strcat(cpp_cmdline, " ");
353 strcat(cpp_cmdline, XTRA_CPPFLAGS[i]);
356 for (i = 0; i < nincludes; i++) {
357 strcat(cpp_cmdline, " ");
358 strcat(cpp_cmdline, IncludeDir[i]);
361 strcat(cpp_cmdline, " ");
362 strcat(cpp_cmdline, infile);
364 fin = popen(cpp_cmdline, "r");
369 if (infile == NULL) {
373 fin = fopen(infile, "r");
376 f_print(stderr, "%s: ", cmdname);
383 * Compile into an XDR routine output file
386 c_output(infile, define, extend, outfile, append)
398 char *currfile = (OutFileFlag ? OutFile : infile);
401 open_input(infile, define);
403 bzero(fullname, sizeof(fullname));
405 strcpy(fullname, prefix);
406 strcat(fullname, infile);
408 strcpy(fullname, infile);
409 outfilename = extend ? extendfile(fullname, outfile) : outfile;
410 open_output(infile, outfilename);
411 f_print(fout, "/* Machine generated file -- Do NOT edit */\n\n");
414 f_print(fout, "#include \"../afs/param.h\"\n");
416 f_print(fout, "#include <afs/param.h>\n");
418 f_print(fout, "#ifdef AFS_NT40_ENV\n");
419 f_print(fout, "#define AFS_RXGEN_EXPORT __declspec(dllexport)\n");
420 f_print(fout, "#endif /* AFS_NT40_ENV */\n");
422 if (currfile && (include = extendfile(currfile,".h"))) {
424 f_print(fout, "#include \"../afsint/%s\"\n\n",include);
426 f_print(fout, "#include \"%s\"\n\n", include);
429 /* In case we can't include the interface's own header file... */
431 f_print(fout, "#include \"../h/types.h\"\n");
432 f_print(fout, "#include \"../h/socket.h\"\n");
433 f_print(fout, "#include \"../h/file.h\"\n");
434 f_print(fout, "#include \"../h/stat.h\"\n");
435 f_print(fout, "#include \"../netinet/in.h\"\n");
436 f_print(fout, "#include \"../h/time.h\"\n");
437 f_print(fout, "#ifndef AFS_LINUX22_ENV\n");
438 f_print(fout, "#include \"../rpc/types.h\"\n");
439 f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
440 f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
441 f_print(fout, "#include \"../rx/xdr.h\"\n");
442 f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
443 f_print(fout, "#include \"../rpc/xdr.h\"\n");
444 f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
445 f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
447 f_print(fout, "#include <rx/xdr.h>\n");
451 write_int32_macros(fout);
454 while (def = get_definition()) {
455 extern int IsRxgenDefinition();
458 if ((!IsRxgenDefinition(def)) && def->def_kind != DEF_CUSTOMIZED)
464 * Print out array containing list of all functions in the interface
469 for(j=0;j<=PackageIndex;j++) {
470 f_print(fout, "AFS_RXGEN_EXPORT\n");
471 f_print(fout, "const char *%sfunction_names[] = {\n",
474 for(i=0;i<no_of_stat_funcs_header[j];i++) {
476 f_print(fout, "\t\"%s\"",
477 &function_list[j][i]);
479 f_print(fout, ",\n\t\"%s\"",
480 &function_list[j][i]);
484 f_print(fout, "\n};\n");
488 if (extend && tell == ftell(fout)) {
489 (void) unlink(outfilename);
495 * Compile into an XDR header file
498 h_output(infile, define, extend, outfile, append)
508 extern char *uppercase();
509 char fullname[1024], *p;
510 extern int h_opcode_stats();
513 open_input(infile, define);
515 bzero(fullname, sizeof(fullname));
517 strcpy(fullname, prefix);
518 strcat(fullname, infile);
520 strcpy(fullname, infile);
521 outfilename = extend ? extendfile(fullname, outfile) : outfile;
522 open_output(infile, outfilename);
523 strcpy(fullname, outfilename);
524 if (p = (char *)index(fullname, '.')) *p = '\0';
525 f_print(fout, "/* Machine generated file -- Do NOT edit */\n\n");
526 f_print(fout, "#ifndef _RXGEN_%s_\n", uppercase(fullname));
527 f_print(fout, "#define _RXGEN_%s_\n\n", uppercase(fullname));
528 f_print(fout, "#ifdef KERNEL\n");
529 f_print(fout, "/* The following 'ifndefs' are not a good solution to the vendor's omission of surrounding all system includes with 'ifndef's since it requires that this file is included after the system includes...*/\n");
530 f_print(fout, "#include \"../afs/param.h\"\n");
531 f_print(fout, "#ifdef UKERNEL\n");
532 f_print(fout, "#include \"../afs/sysincludes.h\"\n");
533 f_print(fout, "#include \"../rx/xdr.h\"\n");
534 f_print(fout, "#include \"../rx/rx.h\"\n");
536 f_print(fout, "#include \"../rx/rx_globals.h\"\n");
538 f_print(fout, "#else /* UKERNEL */\n");
539 f_print(fout, "#include \"../h/types.h\"\n");
540 f_print(fout, "#ifndef SOCK_DGRAM /* XXXXX */\n");
541 f_print(fout, "#include \"../h/socket.h\"\n");
542 f_print(fout, "#endif\n");
543 f_print(fout, "#ifndef DTYPE_SOCKET /* XXXXX */\n");
544 f_print(fout, "#ifdef AFS_DEC_ENV\n");
545 f_print(fout, "#include \"../h/smp_lock.h\"\n");
546 f_print(fout, "#endif\n");
547 f_print(fout, "#ifndef AFS_LINUX22_ENV\n");
548 f_print(fout, "#include \"../h/file.h\"\n");
549 f_print(fout, "#endif\n");
550 f_print(fout, "#endif\n");
551 f_print(fout, "#ifndef S_IFMT /* XXXXX */\n");
552 f_print(fout, "#include \"../h/stat.h\"\n");
553 f_print(fout, "#endif\n");
554 f_print(fout, "#ifndef IPPROTO_UDP /* XXXXX */\n");
555 f_print(fout, "#include \"../netinet/in.h\"\n");
556 f_print(fout, "#endif\n");
557 f_print(fout, "#ifndef DST_USA /* XXXXX */\n");
558 f_print(fout, "#include \"../h/time.h\"\n");
559 f_print(fout, "#endif\n");
560 f_print(fout, "#ifndef AFS_LINUX22_ENV\n");
561 f_print(fout, "#include \"../rpc/types.h\"\n");
562 f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
563 f_print(fout, "#ifndef XDR_GETLONG /* XXXXX */\n");
564 f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
565 f_print(fout, "#ifndef quad_t\n");
566 f_print(fout, "#define quad_t __quad_t\n");
567 f_print(fout, "#define u_quad_t __u_quad_t\n");
568 f_print(fout, "#endif\n");
569 f_print(fout, "#endif\n");
570 f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
571 f_print(fout, "#include \"../rx/xdr.h\"\n");
572 f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
573 f_print(fout, "extern bool_t xdr_int64();\n");
574 f_print(fout, "extern bool_t xdr_uint64();\n");
575 f_print(fout, "#include \"../rpc/xdr.h\"\n");
576 f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
577 f_print(fout, "#endif /* XDR_GETLONG */\n");
578 f_print(fout, "#endif /* UKERNEL */\n");
579 f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
580 f_print(fout, "#include \"../afs/afs_osi.h\"\n");
581 f_print(fout, "#include \"../rx/rx.h\"\n");
583 f_print(fout, "#include \"../rx/rx_globals.h\"\n");
585 f_print(fout, "#else /* KERNEL */\n");
586 f_print(fout, "#include <afs/param.h>\n");
587 f_print(fout, "#include <afs/stds.h>\n");
588 f_print(fout, "#include <sys/types.h>\n");
589 f_print(fout, "#include <rx/xdr.h>\n");
590 f_print(fout, "#include <rx/rx.h>\n");
592 f_print(fout, "#include <rx/rx_globals.h>\n");
594 f_print(fout, "#include <afs/rxgen_consts.h>\n");
595 f_print(fout, "#endif /* KERNEL */\n\n");
596 f_print(fout, "#ifdef AFS_NT40_ENV\n");
597 f_print(fout, "#ifndef AFS_RXGEN_EXPORT\n");
598 f_print(fout, "#define AFS_RXGEN_EXPORT __declspec(dllimport)\n");
599 f_print(fout, "#endif /* AFS_RXGEN_EXPORT */\n");
600 f_print(fout, "#else /* AFS_NT40_ENV */\n");
601 f_print(fout, "#define AFS_RXGEN_EXPORT\n");
602 f_print(fout, "#endif /* AFS_NT40_ENV */\n\n");
604 while (def = get_definition()) {
609 f_print(fout, "#endif /* _RXGEN_%s_ */\n", uppercase(fullname));
610 if (extend && tell == ftell(fout)) {
611 (void) unlink(outfilename);
616 * Compile into an RPC service
619 s_output(argc, argv, infile, define, extend, outfile, nomain)
633 open_input(infile, define);
634 outfilename = extend ? extendfile(infile, outfile) : outfile;
635 open_output(infile, outfilename);
636 f_print(fout, "#include <stdio.h>\n");
637 f_print(fout, "#include <rpc/rpc.h>\n");
638 if (infile && (include = extendfile(infile, ".h"))) {
639 f_print(fout, "#include \"%s\"\n", include);
643 while (def = get_definition()) {
644 foundprogram |= (def->def_kind == DEF_PROGRAM);
646 if (extend && !foundprogram) {
647 (void) unlink(outfilename);
651 write_programs((char *)NULL);
654 do_registers(argc, argv);
656 write_programs("static");
661 l_output(infile, define, extend, outfile)
672 open_input(infile, define);
673 outfilename = extend ? extendfile(infile, outfile) : outfile;
674 open_output(infile, outfilename);
675 f_print(fout, "#include <rpc/rpc.h>\n");
676 f_print(fout, "#include <sys/time.h>\n");
677 if (infile && (include = extendfile(infile, ".h"))) {
678 f_print(fout, "#include \"%s\"\n", include);
682 while (def = get_definition()) {
683 foundprogram |= (def->def_kind == DEF_PROGRAM);
685 if (extend && !foundprogram) {
686 (void) unlink(outfilename);
693 * Perform registrations for service output
696 do_registers(argc, argv)
703 for (i = 1; i < argc; i++) {
704 if (streq(argv[i], "-s")) {
705 write_register(argv[i + 1]);
712 C_output(infile, define, extend, outfile, append)
723 char *currfile = (OutFileFlag ? OutFile : infile);
726 open_input(infile, define);
727 bzero(fullname, sizeof(fullname));
729 strcpy(fullname, prefix);
730 strcat(fullname, infile);
732 strcpy(fullname, infile);
733 outfilename = extend ? extendfile(fullname, outfile) : outfile;
734 open_output(infile, outfilename);
735 f_print(fout, "/* Machine generated file -- Do NOT edit */\n\n");
736 if (currfile && (include = extendfile(currfile,".h"))) {
738 f_print(fout, "#include \"../afsint/%s\"\n\n",include);
740 f_print(fout,"#include \"%s\"\n\n",include);
745 f_print(fout, "#include \"../h/types.h\"\n");
746 f_print(fout, "#include \"../h/socket.h\"\n");
747 f_print(fout, "#include \"../h/file.h\"\n");
748 f_print(fout, "#include \"../h/stat.h\"\n");
749 f_print(fout, "#include \"../netinet/in.h\"\n");
750 f_print(fout, "#include \"../h/time.h\"\n");
751 f_print(fout, "#include \"../rpc/types.h\"\n");
752 f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
753 f_print(fout, "#include \"../rx/xdr.h\"\n");
754 f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
755 f_print(fout, "#include \"../rpc/xdr.h\"\n");
756 f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
757 f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
758 f_print(fout, "#include \"../afs/afs_osi.h\"\n");
759 f_print(fout, "#include \"../rx/rx.h\"\n");
761 f_print(fout, "#include \"../rx/rx_globals.h\"\n");
764 f_print(fout, "#include <sys/types.h>\n");
765 f_print(fout, "#include <rx/xdr.h>\n");
766 f_print(fout, "#include <rx/rx.h>\n");
768 f_print(fout, "#include <rx/rx_globals.h>\n");
770 f_print(fout, "#include <afs/rxgen_consts.h>\n");
774 write_int32_macros(fout);
777 while (get_definition()) continue;
778 if (extend && tell == ftell(fout)) {
779 (void) unlink(outfilename);
785 S_output(infile, define, extend, outfile, append)
797 extern int er_Proc_CodeGeneration();
798 char *currfile = (OutFileFlag ? OutFile : infile);
801 open_input(infile, define);
802 bzero(fullname, sizeof(fullname));
804 strcpy(fullname, prefix);
805 strcat(fullname, infile);
807 strcpy(fullname, infile);
808 outfilename = extend ? extendfile(fullname, outfile) : outfile;
809 open_output(infile, outfilename);
810 f_print(fout, "/* Machine generated file -- Do NOT edit */\n\n");
811 if (currfile && (include = extendfile(currfile,".h"))) {
813 f_print(fout, "#include \"../afsint/%s\"\n",include);
815 f_print(fout,"#include \"%s\"\n\n",include);
820 f_print(fout, "#include \"../h/types.h\"\n");
821 f_print(fout, "#include \"../h/socket.h\"\n");
822 f_print(fout, "#include \"../h/file.h\"\n");
823 f_print(fout, "#include \"../h/stat.h\"\n");
824 f_print(fout, "#include \"../netinet/in.h\"\n");
825 f_print(fout, "#include \"../h/time.h\"\n");
826 f_print(fout, "#include \"../rpc/types.h\"\n");
827 f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
828 f_print(fout, "#include \"../rx/xdr.h\"\n");
829 f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
830 f_print(fout, "#include \"../rpc/xdr.h\"\n");
831 f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
832 f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
833 f_print(fout, "#include \"../afs/afs_osi.h\"\n");
834 f_print(fout, "#include \"../rx/rx.h\"\n");
836 f_print(fout, "#include \"../rx/rx_globals.h\"\n");
839 f_print(fout, "#include <sys/types.h>\n");
840 f_print(fout, "#include <rx/xdr.h>\n");
841 f_print(fout, "#include <rx/rx.h>\n");
843 f_print(fout, "#include <rx/rx_globals.h>\n");
845 f_print(fout, "#include <afs/rxgen_consts.h>\n");
849 write_int32_macros(fout);
853 while (def = get_definition()) {
858 er_Proc_CodeGeneration();
860 if (extend && tell == ftell(fout)) {
861 (void) unlink(outfilename);
869 static char max_size[100];
871 int len = strlen(str);
873 for (pnt = max_size; len > 0; len--, str++) {
874 *pnt++ = (islower(*str) ? toupper(*str) : *str);
881 * Parse command line arguments
884 parseargs(argc, argv, cmd)
887 struct commandline *cmd;
893 char flag[(1 << 8 * sizeof(char))];
897 cmd->infile = cmd->outfile = NULL;
901 bzero(flag, sizeof(flag));
903 for (i = 1; i < argc; i++) {
904 if (argv[i][0] != '-') {
908 cmd->infile = argv[i];
910 for (j = 1; argv[i][j] != 0; j++) {
934 if (argv[i][j - 1] != '-' ||
935 argv[i][j + 1] != 0) {
943 if (!streq(argv[i], "udp") &&
944 !streq(argv[i], "tcp")) {
947 } else if (c == 'o') {
951 cmd->outfile = argv[i];
955 if (argv[i][j-1] != '-')
957 prefix = &argv[i][j+1];
960 if (argv[i][j-1] != '-')
962 IncludeDir[nincludes++]= &argv[i][j-1];
972 cmd->cflag = cflag = flag['c'];
973 cmd->hflag = hflag = flag['h'];
974 cmd->sflag = flag['s'];
975 cmd->lflag = flag['l'];
976 cmd->mflag = flag['m'];
977 cmd->xflag = xflag = flag['x'];
978 cmd->yflag = yflag = flag['y'];
979 cmd->Cflag = Cflag = flag['C'];
980 cmd->Sflag = Sflag = flag['S'];
981 cmd->rflag = flag['r'];
982 cmd->kflag = kflag = flag['k'];
983 cmd->pflag = flag['p'];
984 cmd->dflag = debug = flag['d'];
986 if (cmd->pflag) combinepackages = 1;
987 nflags = cmd->cflag + cmd->hflag + cmd->sflag + cmd->lflag + cmd->mflag + cmd->Cflag + cmd->Sflag + cmd->rflag;
989 if (cmd->outfile != NULL || cmd->infile == NULL) {
992 } else if (nflags > 1) {