2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user or with the express written consent of
8 * Sun Microsystems, Inc.
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 * From @(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI;
38 * rpc_main.c, Top level of the RPC protocol compiler.
45 #include <sys/types.h>
46 #include <sys/param.h>
49 #include "rpc_parse.h"
55 #define EXTEND 1 /* alias for TRUE */
56 #define DONT_EXTEND 0 /* alias for FALSE */
58 #define SVR4_CPP "/usr/ccs/lib/cpp"
59 #define SUNOS_CPP "/lib/cpp"
60 static int cppDefined
= 0; /* explicit path for C preprocessor */
63 int cflag
; /* xdr C routines */
64 int hflag
; /* header file */
65 int lflag
; /* client side stubs */
66 int mflag
; /* server side stubs */
67 int nflag
; /* netid flag */
68 int sflag
; /* server stubs for the given transport */
69 int tflag
; /* dispatch Table file */
70 int Ssflag
; /* produce server sample code */
71 int Scflag
; /* produce client sample code */
72 const char *infile
; /* input module name */
73 const char *outfile
; /* output module name */
77 static const char *cmdname
;
79 static const char *svcclosetime
= "120";
80 static const char *CPP
= SVR4_CPP
;
81 static char CPPFLAGS
[] = "-C";
82 static char pathbuf
[MAXPATHLEN
+ 1];
83 static const char *allv
[] = {
84 "rpcgen", "-s", "udp", "-s", "tcp",
86 static int allc
= sizeof(allv
)/sizeof(allv
[0]);
87 static const char *allnv
[] = {
88 "rpcgen", "-s", "netpath",
90 static int allnc
= sizeof(allnv
)/sizeof(allnv
[0]);
93 * machinations for handling expanding argument list
95 static void addarg(const char *); /* add another argument to the list */
96 static void putarg(int, const char *); /* put argument at specified location */
97 static void clear_args(void); /* clear argument list */
98 static void checkfiles(const char *, const char *);
99 /* check if out file already exists */
101 static void clear_args(void);
102 static char *extendfile(const char *file
, const char *ext
);
103 static void open_output(const char *infile
, const char *outfile
);
104 static void add_warning(void);
105 static void clear_args(void);
106 static void find_cpp(void);
107 static void open_input(const char *infile
, const char *define
);
108 static int check_nettype(const char *name
, const char *list_to_check
[]);
109 static void c_output(const char *infile
, const char *define
,
110 int extend
, const char *outfile
);
111 static void h_output(const char *infile
, const char *define
,
112 int extend
, const char *outfile
);
113 static void s_output(int argc
, const char *argv
[], const char *infile
,
114 const char *define
, int extend
,
115 const char *outfile
, int nomain
, int netflag
);
116 static void l_output(const char *infile
, const char *define
,
117 int extend
, const char *outfile
);
118 static void t_output(const char *infile
, const char *define
,
119 int extend
, const char *outfile
);
120 static void svc_output(const char *infile
, const char *define
,
121 int extend
, const char *outfile
);
122 static void clnt_output(const char *infile
, const char *define
,
123 int extend
, const char *outfile
);
124 static int do_registers(int argc
, const char *argv
[]);
125 static void addarg(const char *cp
);
126 static void putarg(int whereto
, const char *cp
);
127 static void checkfiles(const char *infile
, const char *outfile
);
128 static int parseargs(int argc
, const char *argv
[], struct commandline
*cmd
);
129 static void usage(void);
130 static void options_usage(void);
131 static void c_initialize(void);
132 static char *generate_guard(const char *pathname
);
135 #define ARGLISTLEN 20
138 static const char *arglist
[ARGLISTLEN
];
139 static int argcount
= FIXEDARGS
;
142 int nonfatalerrors
; /* errors */
143 int inetdflag
/* = 1*/; /* Support for inetd */ /* is now the default */
144 int pmflag
; /* Support for port monitors */
145 int logflag
; /* Use syslog instead of fprintf for errors */
146 int tblflag
; /* Support for dispatch table file */
149 /*length at which to start doing an inline */
151 int inlineflag
=INLINE
; /* length at which to start doing an inline. 3 = default
152 if 0, no xdr_inline code */
154 int indefinitewait
; /* If started by port monitors, hang till it wants */
155 int exitnow
; /* If started by port monitors, exit after the call */
156 int timerflag
; /* TRUE if !indefinite && !exitnow */
157 int newstyle
; /* newstyle of passing arguments (by value) */
158 #ifdef __GNU_LIBRARY__
159 int Cflag
= 1 ; /* ANSI C syntax */
161 int Cflag
= 0 ; /* ANSI C syntax */
163 static int allfiles
; /* generate all files */
164 #ifdef __GNU_LIBRARY__
165 int tirpcflag
= 0; /* generating code for tirpc, by default */
167 int tirpcflag
= 1; /* generating code for tirpc, by default */
171 main(int argc
, const char *argv
[])
173 struct commandline cmd
;
175 (void) memset((char *)&cmd
, 0, sizeof (struct commandline
));
177 if (!parseargs(argc
, argv
, &cmd
))
180 if (cmd
.cflag
|| cmd
.hflag
|| cmd
.lflag
|| cmd
.tflag
|| cmd
.sflag
||
181 cmd
.mflag
|| cmd
.nflag
|| cmd
.Ssflag
|| cmd
.Scflag
) {
182 checkfiles(cmd
.infile
, cmd
.outfile
);
185 checkfiles(cmd
.infile
,NULL
);
188 c_output(cmd
.infile
, "-DRPC_XDR", DONT_EXTEND
, cmd
.outfile
);
189 } else if (cmd
.hflag
) {
190 h_output(cmd
.infile
, "-DRPC_HDR", DONT_EXTEND
, cmd
.outfile
);
191 } else if (cmd
.lflag
) {
192 l_output(cmd
.infile
, "-DRPC_CLNT", DONT_EXTEND
, cmd
.outfile
);
193 } else if (cmd
.sflag
|| cmd
.mflag
|| (cmd
.nflag
)) {
194 s_output(argc
, argv
, cmd
.infile
, "-DRPC_SVC", DONT_EXTEND
,
195 cmd
.outfile
, cmd
.mflag
, cmd
.nflag
);
196 } else if (cmd
.tflag
) {
197 t_output(cmd
.infile
, "-DRPC_TBL", DONT_EXTEND
, cmd
.outfile
);
198 } else if (cmd
.Ssflag
) {
199 svc_output(cmd
.infile
, "-DRPC_SERVER", DONT_EXTEND
, cmd
.outfile
);
200 } else if (cmd
.Scflag
) {
201 clnt_output(cmd
.infile
, "-DRPC_CLIENT", DONT_EXTEND
, cmd
.outfile
);
203 /* the rescans are required, since cpp may effect input */
204 c_output(cmd
.infile
, "-DRPC_XDR", EXTEND
, "_xdr.c");
206 h_output(cmd
.infile
, "-DRPC_HDR", EXTEND
, ".h");
208 l_output(cmd
.infile
, "-DRPC_CLNT", EXTEND
, "_clnt.c");
210 if (inetdflag
|| !tirpcflag
)
211 s_output(allc
, allv
, cmd
.infile
, "-DRPC_SVC", EXTEND
,
212 "_svc.c", cmd
.mflag
, cmd
.nflag
);
214 s_output(allnc
, allnv
, cmd
.infile
, "-DRPC_SVC",
215 EXTEND
, "_svc.c", cmd
.mflag
, cmd
.nflag
);
218 t_output(cmd
.infile
, "-DRPC_TBL", EXTEND
, "_tbl.i");
222 svc_output(cmd
.infile
, "-DRPC_SERVER", EXTEND
, "_server.c");
226 clnt_output(cmd
.infile
, "-DRPC_CLIENT", EXTEND
, "_client.c");
229 exit(nonfatalerrors
);
234 * add extension to filename
237 extendfile(const char *file
, const char *ext
)
242 res
= alloc(strlen(file
) + strlen(ext
) + 1);
246 p
= strrchr(file
, '.');
248 p
= file
+ strlen(file
);
250 (void) strcpy(res
, file
);
251 (void) strcpy(res
+ (p
- file
), ext
);
256 * Open output file with given extension
259 open_output(const char *infile
, const char *outfile
)
262 if (outfile
== NULL
) {
267 if (infile
!= NULL
&& streq(outfile
, infile
)) {
268 f_print(stderr
, "%s: output would overwrite %s\n", cmdname
,
272 fout
= fopen(outfile
, "w");
274 f_print(stderr
, "%s: unable to open ", cmdname
);
278 record_open(outfile
);
284 f_print(fout
, "/*\n");
285 f_print(fout
, " * Please do not edit this file.\n");
286 f_print(fout
, " * It was generated using rpcgen.\n");
287 f_print(fout
, " */\n\n");
293 f_print(fout
, "#include <rpc/types.h>\n");
294 f_print(fout
, "#include <rpc/xdr.h>\n\n");
297 /* clear list of arguments */
298 static void clear_args(void)
301 for( i
=FIXEDARGS
; i
<ARGLISTLEN
; i
++ )
303 argcount
= FIXEDARGS
;
306 /* make sure that a CPP exists */
307 static void find_cpp(void)
311 if (stat(CPP
, &buf
) < 0 ) { /* SVR4 or explicit cpp does not exist */
313 fprintf( stderr
, "cannot find C preprocessor: %s \n", CPP
);
315 } else { /* try the other one */
317 if( stat( CPP
, &buf
) < 0 ) { /* can't find any cpp */
318 fprintf( stderr
, "cannot find any C preprocessor (cpp)\n" );
326 * Open input file with given define for C-preprocessor
329 open_input(const char *infile
, const char *define
)
333 infilename
= (infile
== NULL
) ? "<stdin>" : infile
;
342 addarg((char *)NULL
);
344 (void) dup2(pd
[1], 1);
346 execv(arglist
[0], (char **)arglist
);
354 fin
= fdopen(pd
[0], "r");
356 f_print(stderr
, "%s: ", cmdname
);
362 /* valid tirpc nettypes */
363 static const char *valid_ti_nettypes
[] =
377 /* valid inetd nettypes */
378 static const char *valid_i_nettypes
[] =
385 static int check_nettype(const char *name
, const char *list_to_check
[]) {
387 for( i
= 0; list_to_check
[i
] != NULL
; i
++ ) {
388 if( strcmp( name
, list_to_check
[i
] ) == 0 ) {
392 f_print( stderr
, "illegal nettype :\'%s\'\n", name
);
397 * Compile into an XDR routine output file
401 c_output(const char *infile
, const char *define
, int extend
,
406 const char *outfilename
;
410 open_input(infile
, define
);
411 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
412 open_output(infile
, outfilename
);
415 if (infile
&& (include
= extendfile(infile
, ".h"))) {
416 f_print(fout
, "#include \"%s\"\n", include
);
418 /* .h file already contains rpc/rpc.h */
420 f_print(fout
, "#include <rpc/rpc.h>\n");
422 while ((def
= get_definition())!=NULL
) {
425 if (extend
&& tell
== ftell(fout
)) {
426 (void) unlink(outfilename
);
434 /* add all the starting basic types */
442 add_type(1,"u_long");
443 add_type(1,"u_short");
447 char rpcgen_table_dcl
[] = "struct rpcgen_table {\n\
449 xdrproc_t xdr_arg;\n\
451 xdrproc_t xdr_res;\n\
456 static char *generate_guard(const char *pathname
) {
457 const char *filename
;
460 filename
= strrchr(pathname
, '/' ); /* find last component */
461 filename
= ((filename
== NULL
) ? pathname
: filename
+1);
462 guard
= strdup(filename
);
463 /* convert to upper case */
467 *tmp
= toupper(*tmp
);
471 guard
= extendfile(guard
, "_H_RPCGEN");
476 * Compile into an XDR header file
481 h_output(const char *infile
, const char *define
, int extend
,
485 const char *ifilename
;
486 const char *outfilename
;
491 open_input(infile
, define
);
492 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
493 open_output(infile
, outfilename
);
495 ifilename
= (infile
== NULL
) ? "STDIN" : infile
;
496 guard
= generate_guard( outfilename
? outfilename
: ifilename
);
498 f_print(fout
,"#ifndef _%s\n#define _%s\n\n", guard
,
501 f_print(fout
, "#include <rpc/rpc.h>\n\n");
504 /* print data definitions */
505 while ((def
= get_definition())!=NULL
) {
509 /* print function declarations.
510 Do this after data definitions because they might be used as
511 arguments for functions */
512 for (l
= defined
; l
!= NULL
; l
= l
->next
) {
513 print_funcdef(l
->val
);
515 if (extend
&& tell
== ftell(fout
)) {
516 (void) unlink(outfilename
);
517 } else if (tblflag
) {
518 f_print(fout
, rpcgen_table_dcl
);
520 f_print(fout
, "\n#endif /* !_%s */\n", guard
);
524 * Compile into an RPC service
527 s_output(int argc
, const char *argv
[], const char *infile
, const char *define
,
528 int extend
, const char *outfile
, int nomain
, int netflag
)
532 int foundprogram
= 0;
533 const char *outfilename
;
535 open_input(infile
, define
);
536 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
537 open_output(infile
, outfilename
);
539 if (infile
&& (include
= extendfile(infile
, ".h"))) {
540 f_print(fout
, "#include \"%s\"\n", include
);
543 f_print(fout
, "#include <rpc/rpc.h>\n");
545 f_print(fout
, "#include <stdio.h>\n");
546 f_print(fout
, "#include <stdlib.h>/* getenv, exit */\n");
548 f_print (fout
, "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
549 f_print (fout
, "#include <string.h> /* strcmp */ \n");
551 if (strcmp(svcclosetime
, "-1") == 0)
553 else if (strcmp(svcclosetime
, "0") == 0)
555 else if (inetdflag
|| pmflag
) {
556 f_print(fout
, "#include <signal.h>\n");
560 if( !tirpcflag
&& inetdflag
)
561 #ifdef __GNU_LIBRARY__
562 f_print(fout
, "#include <sys/ioctl.h> /* ioctl, TIOCNOTTY */\n");
564 f_print(fout
, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
566 if( Cflag
&& (inetdflag
|| pmflag
) ) {
567 #ifdef __GNU_LIBRARY__
568 f_print(fout
, "#include <sys/types.h> /* open */\n");
569 f_print(fout
, "#include <sys/stat.h> /* open */\n");
570 f_print(fout
, "#include <fcntl.h> /* open */\n");
571 f_print(fout
, "#include <unistd.h> /* getdtablesize */\n");
573 f_print(fout
, "#ifdef __cplusplus\n");
574 f_print(fout
, "#include <sysent.h> /* getdtablesize, open */\n");
575 f_print(fout
, "#endif /* __cplusplus */\n");
578 f_print(fout
, "#include <unistd.h> /* setsid */\n");
581 f_print(fout
, "#include <sys/types.h>\n");
583 f_print(fout
, "#include <memory.h>\n");
584 #ifndef __GNU_LIBRARY__
585 f_print(fout
, "#include <stropts.h>\n");
587 if (inetdflag
|| !tirpcflag
) {
588 f_print(fout
, "#include <sys/socket.h>\n");
589 f_print(fout
, "#include <netinet/in.h>\n");
592 if ( (netflag
|| pmflag
) && tirpcflag
) {
593 f_print(fout
, "#include <netconfig.h>\n");
595 if (/*timerflag &&*/ tirpcflag
)
596 f_print(fout
, "#include <sys/resource.h> /* rlimit */\n");
597 if (logflag
|| inetdflag
|| pmflag
) {
598 #ifdef __GNU_LIBRARY__
599 f_print(fout
, "#include <syslog.h>\n");
601 f_print(fout
, "#ifdef SYSLOG\n");
602 f_print(fout
, "#include <syslog.h>\n");
603 f_print(fout
, "#else\n");
604 f_print(fout
, "#define LOG_ERR 1\n");
605 f_print(fout
, "#define openlog(a, b, c)\n");
606 f_print(fout
, "#endif\n");
611 f_print(fout
, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
613 #ifndef __GNU_LIBRARY__
614 f_print(fout
, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
617 f_print(fout
, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime
);
618 while ((def
= get_definition())!=NULL
) {
619 foundprogram
|= (def
->def_kind
== DEF_PROGRAM
);
621 if (extend
&& !foundprogram
) {
622 (void) unlink(outfilename
);
625 write_most(infile
, netflag
, nomain
);
627 if( !do_registers(argc
, argv
) ) {
629 (void) unlink(outfilename
);
637 * generate client side stubs
640 l_output(const char *infile
, const char *define
, int extend
,
645 int foundprogram
= 0;
646 const char *outfilename
;
648 open_input(infile
, define
);
649 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
650 open_output(infile
, outfilename
);
653 f_print (fout
, "#include <memory.h> /* for memset */\n");
654 if (infile
&& (include
= extendfile(infile
, ".h"))) {
655 f_print(fout
, "#include \"%s\"\n", include
);
658 f_print(fout
, "#include <rpc/rpc.h>\n");
659 while ((def
= get_definition())!=NULL
) {
660 foundprogram
|= (def
->def_kind
== DEF_PROGRAM
);
662 if (extend
&& !foundprogram
) {
663 (void) unlink(outfilename
);
670 * generate the dispatch table
673 t_output(const char *infile
, const char *define
, int extend
,
677 int foundprogram
= 0;
678 const char *outfilename
;
680 open_input(infile
, define
);
681 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
682 open_output(infile
, outfilename
);
684 while ((def
= get_definition())!=NULL
) {
685 foundprogram
|= (def
->def_kind
== DEF_PROGRAM
);
687 if (extend
&& !foundprogram
) {
688 (void) unlink(outfilename
);
694 /* sample routine for the server template */
696 svc_output(const char *infile
, const char *define
, int extend
,
701 const char *outfilename
;
704 open_input(infile
, define
);
705 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
706 checkfiles(infile
,outfilename
); /*check if outfile already exists.
707 if so, print an error message and exit*/
708 open_output(infile
, outfilename
);
711 if (infile
&& (include
= extendfile(infile
, ".h"))) {
712 f_print(fout
, "#include \"%s\"\n", include
);
715 f_print(fout
, "#include <rpc/rpc.h>\n");
718 while ((def
= get_definition())!=NULL
) {
719 write_sample_svc(def
);
721 if (extend
&& tell
== ftell(fout
)) {
722 (void) unlink(outfilename
);
727 /* sample main routine for client */
729 clnt_output(const char *infile
, const char *define
, int extend
,
734 const char *outfilename
;
738 open_input(infile
, define
);
739 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
740 checkfiles(infile
,outfilename
); /*check if outfile already exists.
741 if so, print an error message and exit*/
743 open_output(infile
, outfilename
);
745 if (infile
&& (include
= extendfile(infile
, ".h"))) {
746 f_print(fout
, "#include \"%s\"\n", include
);
749 f_print(fout
, "#include <rpc/rpc.h>\n");
751 while ((def
= get_definition())!=NULL
) {
752 has_program
+= write_sample_clnt(def
);
756 write_sample_clnt_main();
758 if (extend
&& tell
== ftell(fout
)) {
759 (void) unlink(outfilename
);
764 * Perform registrations for service output
765 * Return 0 if failed; 1 otherwise.
767 static int do_registers(int argc
, const char *argv
[])
771 if ( inetdflag
|| !tirpcflag
) {
772 for (i
= 1; i
< argc
; i
++) {
773 if (streq(argv
[i
], "-s")) {
774 if(!check_nettype( argv
[i
+ 1], valid_i_nettypes
))
776 write_inetd_register(argv
[i
+ 1]);
781 for (i
= 1; i
< argc
; i
++)
782 if (streq(argv
[i
], "-s")) {
783 if(!check_nettype( argv
[i
+ 1], valid_ti_nettypes
))
785 write_nettype_register(argv
[i
+ 1]);
787 } else if (streq(argv
[i
], "-n")) {
788 write_netid_register(argv
[i
+ 1]);
796 * Add another argument to the arg list
799 addarg(const char *cp
)
801 if (argcount
>= ARGLISTLEN
) {
802 f_print(stderr
, "rpcgen: too many defines\n");
806 arglist
[argcount
++] = cp
;
811 putarg(int whereto
, const char *cp
)
813 if (whereto
>= ARGLISTLEN
) {
814 f_print(stderr
, "rpcgen: arglist coding error\n");
818 arglist
[whereto
] = cp
;
822 * if input file is stdin and an output file is specified then complain
823 * if the file already exists. Otherwise the file may get overwritten
824 * If input file does not exist, exit with an error
828 checkfiles(const char *infile
, const char *outfile
)
833 if(infile
) /* infile ! = NULL */
834 if(stat(infile
,&buf
) < 0)
840 if (stat(outfile
, &buf
) < 0)
841 return; /* file does not exist */
844 "file '%s' already exists and may be overwritten\n", outfile
);
851 * Parse command line arguments
854 parseargs(int argc
, const char *argv
[], struct commandline
*cmd
)
859 char flag
[(1 << 8 * sizeof(char))];
863 cmd
->infile
= cmd
->outfile
= NULL
;
878 for (i
= 1; i
< argc
; i
++) {
879 if (argv
[i
][0] != '-') {
881 f_print( stderr
, "Cannot specify more than one input file!\n");
885 cmd
->infile
= argv
[i
];
887 for (j
= 1; argv
[i
][j
] != 0; j
++) {
904 /* sample flag: Ss or Sc.
905 Ss means set flag['S'];
906 Sc means set flag['C']; */
907 c
= argv
[i
][++j
]; /* get next char */
920 case 'C': /* ANSI C syntax */
924 #ifdef __GNU_LIBRARY__
925 case 'k': /* K&R C syntax */
930 case 'b': /* turn TIRPC flag off for
931 generating backward compatible
936 #ifdef __GNU_LIBRARY__
937 case '5': /* turn TIRPC flag on for
938 generating SysVr4 compatible
957 svcclosetime
= argv
[i
];
966 inlineflag
= atoi(argv
[i
]);
971 if (argv
[i
][j
- 1] != '-' ||
972 argv
[i
][j
+ 1] != 0) {
980 if (!streq(argv
[i
], "udp") &&
981 !streq(argv
[i
], "tcp")) {
984 } else if (c
== 'o') {
988 cmd
->outfile
= argv
[i
];
992 if (argv
[i
][j
- 1] != '-') {
995 (void) addarg(argv
[i
]);
1001 (void) strcpy(pathbuf
, argv
[i
]);
1002 (void) strcat(pathbuf
, "/cpp");
1018 cmd
->cflag
= flag
['c'];
1019 cmd
->hflag
= flag
['h'];
1020 cmd
->lflag
= flag
['l'];
1021 cmd
->mflag
= flag
['m'];
1022 cmd
->nflag
= flag
['n'];
1023 cmd
->sflag
= flag
['s'];
1024 cmd
->tflag
= flag
['t'];
1025 cmd
->Ssflag
= flag
['S'];
1026 cmd
->Scflag
= flag
['C'];
1029 pmflag
= inetdflag
? 0 : 1; /* pmflag or inetdflag is always TRUE */
1030 if( (inetdflag
&& cmd
->nflag
)) { /* netid not allowed with inetdflag */
1031 f_print(stderr
, "Cannot use netid flag with inetd flag!\n");
1034 } else { /* 4.1 mode */
1035 pmflag
= 0; /* set pmflag only in tirpcmode */
1036 #ifndef __GNU_LIBRARY__
1037 inetdflag
= 1; /* inetdflag is TRUE by default */
1039 if( cmd
->nflag
) { /* netid needs TIRPC */
1040 f_print( stderr
, "Cannot use netid flag without TIRPC!\n");
1045 if( newstyle
&& ( tblflag
|| cmd
->tflag
) ) {
1046 f_print( stderr
, "Cannot use table flags with newstyle!\n");
1050 /* check no conflicts with file generation flags */
1051 nflags
= cmd
->cflag
+ cmd
->hflag
+ cmd
->lflag
+ cmd
->mflag
+
1052 cmd
->sflag
+ cmd
->nflag
+ cmd
->tflag
+ cmd
->Ssflag
+ cmd
->Scflag
;
1055 if (cmd
->outfile
!= NULL
|| cmd
->infile
== NULL
) {
1058 } else if (nflags
> 1) {
1059 f_print( stderr
, "Cannot have more than one file generation flag!\n");
1068 f_print(stderr
, "usage: %s infile\n", cmdname
);
1069 f_print(stderr
, "\t%s [-a][-b][-C][-Dname[=value]] -i size [-I [-K seconds]] [-L][-N][-T] infile\n",
1071 f_print(stderr
, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",
1073 f_print(stderr
, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname
);
1074 f_print(stderr
, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname
);
1082 f_print(stderr
, "options:\n");
1083 f_print(stderr
, "-a\t\tgenerate all files, including samples\n");
1084 f_print(stderr
, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");
1085 f_print(stderr
, "-c\t\tgenerate XDR routines\n");
1086 f_print(stderr
, "-C\t\tANSI C mode\n");
1087 f_print(stderr
, "-Dname[=value]\tdefine a symbol (same as #define)\n");
1088 f_print(stderr
, "-h\t\tgenerate header file\n");
1089 f_print(stderr
, "-i size\t\tsize at which to start generating inline code\n");
1090 f_print(stderr
, "-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n");
1091 f_print(stderr
, "-K seconds\tserver exits after K seconds of inactivity\n");
1092 f_print(stderr
, "-l\t\tgenerate client side stubs\n");
1093 f_print(stderr
, "-L\t\tserver errors will be printed to syslog\n");
1094 f_print(stderr
, "-m\t\tgenerate server side stubs\n");
1095 f_print(stderr
, "-n netid\tgenerate server code that supports named netid\n");
1096 f_print(stderr
, "-N\t\tsupports multiple arguments and call-by-value\n");
1097 f_print(stderr
, "-o outfile\tname of the output file\n");
1098 f_print(stderr
, "-s nettype\tgenerate server code that supports named nettype\n");
1099 f_print(stderr
, "-Sc\t\tgenerate sample client code that uses remote procedures\n");
1100 f_print(stderr
, "-Ss\t\tgenerate sample server code that defines remote procedures\n");
1101 f_print(stderr
, "-t\t\tgenerate RPC dispatch table\n");
1102 f_print(stderr
, "-T\t\tgenerate code to support RPC dispatch tables\n");
1103 f_print(stderr
, "-Y path\t\tdirectory name to find C preprocessor (cpp)\n");