]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sunrpc/rpc_main.c
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.
46 #include <sys/types.h>
47 #include <sys/param.h>
50 #include "rpc_parse.h"
56 #define EXTEND 1 /* alias for TRUE */
57 #define DONT_EXTEND 0 /* alias for FALSE */
59 #define SVR4_CPP "/usr/ccs/lib/cpp"
60 #define SUNOS_CPP "/lib/cpp"
61 static int cppDefined
= 0; /* explicit path for C preprocessor */
64 int cflag
; /* xdr C routines */
65 int hflag
; /* header file */
66 int lflag
; /* client side stubs */
67 int mflag
; /* server side stubs */
68 int nflag
; /* netid flag */
69 int sflag
; /* server stubs for the given transport */
70 int tflag
; /* dispatch Table file */
71 int Ssflag
; /* produce server sample code */
72 int Scflag
; /* produce client sample code */
73 const char *infile
; /* input module name */
74 const char *outfile
; /* output module name */
78 static const char *cmdname
;
80 static const char *svcclosetime
= "120";
81 static const char *CPP
= SVR4_CPP
;
82 static char CPPFLAGS
[] = "-C";
84 static const char *allv
[] = {
85 "rpcgen", "-s", "udp", "-s", "tcp",
87 static int allc
= sizeof(allv
)/sizeof(allv
[0]);
88 static const char *allnv
[] = {
89 "rpcgen", "-s", "netpath",
91 static int allnc
= sizeof(allnv
)/sizeof(allnv
[0]);
94 * machinations for handling expanding argument list
96 static void addarg(const char *); /* add another argument to the list */
97 static void putarg(int, const char *); /* put argument at specified location */
98 static void clear_args(void); /* clear argument list */
99 static void checkfiles(const char *, const char *);
100 /* check if out file already exists */
102 static void clear_args(void);
103 static char *extendfile(const char *file
, const char *ext
);
104 static void open_output(const char *infile
, const char *outfile
);
105 static void add_warning(void);
106 static void clear_args(void);
107 static void find_cpp(void);
108 static void open_input(const char *infile
, const char *define
);
109 static int check_nettype(const char *name
, const char *list_to_check
[]);
110 static void c_output(const char *infile
, const char *define
,
111 int extend
, const char *outfile
);
112 static void h_output(const char *infile
, const char *define
,
113 int extend
, const char *outfile
);
114 static void s_output(int argc
, const char *argv
[], const char *infile
,
115 const char *define
, int extend
,
116 const char *outfile
, int nomain
, int netflag
);
117 static void l_output(const char *infile
, const char *define
,
118 int extend
, const char *outfile
);
119 static void t_output(const char *infile
, const char *define
,
120 int extend
, const char *outfile
);
121 static void svc_output(const char *infile
, const char *define
,
122 int extend
, const char *outfile
);
123 static void clnt_output(const char *infile
, const char *define
,
124 int extend
, const char *outfile
);
125 static int do_registers(int argc
, const char *argv
[]);
126 static void addarg(const char *cp
);
127 static void putarg(int whereto
, const char *cp
);
128 static void checkfiles(const char *infile
, const char *outfile
);
129 static int parseargs(int argc
, const char *argv
[], struct commandline
*cmd
);
130 static void usage(void);
131 static void options_usage(void);
132 static void c_initialize(void);
133 static char *generate_guard(const char *pathname
);
136 #define ARGLISTLEN 20
139 static const char *arglist
[ARGLISTLEN
];
140 static int argcount
= FIXEDARGS
;
143 int nonfatalerrors
; /* errors */
144 int inetdflag
/* = 1*/; /* Support for inetd */ /* is now the default */
145 int pmflag
; /* Support for port monitors */
146 int logflag
; /* Use syslog instead of fprintf for errors */
147 int tblflag
; /* Support for dispatch table file */
150 /*length at which to start doing an inline */
152 int inlineflag
=INLINE
; /* length at which to start doing an inline. 3 = default
153 if 0, no xdr_inline code */
155 int indefinitewait
; /* If started by port monitors, hang till it wants */
156 int exitnow
; /* If started by port monitors, exit after the call */
157 int timerflag
; /* TRUE if !indefinite && !exitnow */
158 int newstyle
; /* newstyle of passing arguments (by value) */
159 #ifdef __GNU_LIBRARY__
160 int Cflag
= 1 ; /* ANSI C syntax */
162 int Cflag
= 0 ; /* ANSI C syntax */
164 static int allfiles
; /* generate all files */
165 #ifdef __GNU_LIBRARY__
166 int tirpcflag
= 0; /* generating code for tirpc, by default */
168 int tirpcflag
= 1; /* generating code for tirpc, by default */
171 #ifdef __GNU_LIBRARY__
172 int building_libc
= 0; /* running as part of libc built process */
176 main(int argc
, const char *argv
[])
178 struct commandline cmd
;
180 (void) memset((char *)&cmd
, 0, sizeof (struct commandline
));
182 if (!parseargs(argc
, argv
, &cmd
))
185 if (cmd
.cflag
|| cmd
.hflag
|| cmd
.lflag
|| cmd
.tflag
|| cmd
.sflag
||
186 cmd
.mflag
|| cmd
.nflag
|| cmd
.Ssflag
|| cmd
.Scflag
) {
187 checkfiles(cmd
.infile
, cmd
.outfile
);
190 checkfiles(cmd
.infile
,NULL
);
193 c_output(cmd
.infile
, "-DRPC_XDR", DONT_EXTEND
, cmd
.outfile
);
194 } else if (cmd
.hflag
) {
195 h_output(cmd
.infile
, "-DRPC_HDR", DONT_EXTEND
, cmd
.outfile
);
196 } else if (cmd
.lflag
) {
197 l_output(cmd
.infile
, "-DRPC_CLNT", DONT_EXTEND
, cmd
.outfile
);
198 } else if (cmd
.sflag
|| cmd
.mflag
|| (cmd
.nflag
)) {
199 s_output(argc
, argv
, cmd
.infile
, "-DRPC_SVC", DONT_EXTEND
,
200 cmd
.outfile
, cmd
.mflag
, cmd
.nflag
);
201 } else if (cmd
.tflag
) {
202 t_output(cmd
.infile
, "-DRPC_TBL", DONT_EXTEND
, cmd
.outfile
);
203 } else if (cmd
.Ssflag
) {
204 svc_output(cmd
.infile
, "-DRPC_SERVER", DONT_EXTEND
, cmd
.outfile
);
205 } else if (cmd
.Scflag
) {
206 clnt_output(cmd
.infile
, "-DRPC_CLIENT", DONT_EXTEND
, cmd
.outfile
);
208 /* the rescans are required, since cpp may effect input */
209 c_output(cmd
.infile
, "-DRPC_XDR", EXTEND
, "_xdr.c");
211 h_output(cmd
.infile
, "-DRPC_HDR", EXTEND
, ".h");
213 l_output(cmd
.infile
, "-DRPC_CLNT", EXTEND
, "_clnt.c");
215 if (inetdflag
|| !tirpcflag
)
216 s_output(allc
, allv
, cmd
.infile
, "-DRPC_SVC", EXTEND
,
217 "_svc.c", cmd
.mflag
, cmd
.nflag
);
219 s_output(allnc
, allnv
, cmd
.infile
, "-DRPC_SVC",
220 EXTEND
, "_svc.c", cmd
.mflag
, cmd
.nflag
);
223 t_output(cmd
.infile
, "-DRPC_TBL", EXTEND
, "_tbl.i");
227 svc_output(cmd
.infile
, "-DRPC_SERVER", EXTEND
, "_server.c");
231 clnt_output(cmd
.infile
, "-DRPC_CLIENT", EXTEND
, "_client.c");
234 exit(nonfatalerrors
);
239 * add extension to filename
242 extendfile(const char *file
, const char *ext
)
247 res
= alloc(strlen(file
) + strlen(ext
) + 1);
251 p
= strrchr(file
, '.');
253 p
= file
+ strlen(file
);
255 (void) strcpy(res
, file
);
256 (void) strcpy(res
+ (p
- file
), ext
);
261 * Open output file with given extension
264 open_output(const char *infile
, const char *outfile
)
267 if (outfile
== NULL
) {
272 if (infile
!= NULL
&& streq(outfile
, infile
)) {
273 f_print(stderr
, "%s: output would overwrite %s\n", cmdname
,
277 fout
= fopen(outfile
, "w");
279 f_print(stderr
, "%s: unable to open ", cmdname
);
283 record_open(outfile
);
289 f_print(fout
, "/*\n");
290 f_print(fout
, " * Please do not edit this file.\n");
291 f_print(fout
, " * It was generated using rpcgen.\n");
292 f_print(fout
, " */\n\n");
298 f_print(fout
, "#include <rpc/types.h>\n");
299 f_print(fout
, "#include <rpc/xdr.h>\n\n");
302 /* clear list of arguments */
303 static void clear_args(void)
306 for( i
=FIXEDARGS
; i
<ARGLISTLEN
; i
++ )
308 argcount
= FIXEDARGS
;
311 /* make sure that a CPP exists */
312 static void find_cpp(void)
316 if (stat(CPP
, &buf
) < 0 ) { /* SVR4 or explicit cpp does not exist */
318 fprintf( stderr
, "cannot find C preprocessor: %s \n", CPP
);
320 } else { /* try the other one */
322 if( stat( CPP
, &buf
) < 0 ) { /* can't find any cpp */
323 fprintf( stderr
, "cannot find any C preprocessor (cpp)\n" );
331 * Open input file with given define for C-preprocessor
334 open_input(const char *infile
, const char *define
)
338 infilename
= (infile
== NULL
) ? "<stdin>" : infile
;
342 #ifdef __GNU_LIBRARY__
343 /* While building libc we don't want to use the libc from
344 the build directory which may be incompatible with the
345 installed dynamic linker. */
347 unsetenv ("LD_LIBRARY_PATH");
354 addarg((char *)NULL
);
356 (void) dup2(pd
[1], 1);
358 execv(arglist
[0], (char **)arglist
);
366 fin
= fdopen(pd
[0], "r");
368 f_print(stderr
, "%s: ", cmdname
);
374 /* valid tirpc nettypes */
375 static const char *valid_ti_nettypes
[] =
389 /* valid inetd nettypes */
390 static const char *valid_i_nettypes
[] =
397 static int check_nettype(const char *name
, const char *list_to_check
[]) {
399 for( i
= 0; list_to_check
[i
] != NULL
; i
++ ) {
400 if( strcmp( name
, list_to_check
[i
] ) == 0 ) {
404 f_print( stderr
, "illegal nettype :\'%s\'\n", name
);
409 * Compile into an XDR routine output file
413 c_output(const char *infile
, const char *define
, int extend
,
418 const char *outfilename
;
422 open_input(infile
, define
);
423 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
424 open_output(infile
, outfilename
);
427 if (infile
&& (include
= extendfile(infile
, ".h"))) {
428 f_print(fout
, "#include \"%s\"\n", include
);
430 /* .h file already contains rpc/rpc.h */
432 f_print(fout
, "#include <rpc/rpc.h>\n");
434 while ((def
= get_definition())!=NULL
) {
437 if (extend
&& tell
== ftell(fout
)) {
438 (void) unlink(outfilename
);
446 /* add all the starting basic types */
454 add_type(1,"u_long");
455 add_type(1,"u_short");
459 char rpcgen_table_dcl
[] = "struct rpcgen_table {\n\
461 xdrproc_t xdr_arg;\n\
463 xdrproc_t xdr_res;\n\
468 static char *generate_guard(const char *pathname
) {
469 const char *filename
;
472 filename
= strrchr(pathname
, '/' ); /* find last component */
473 filename
= ((filename
== NULL
) ? pathname
: filename
+1);
474 guard
= strdup(filename
);
475 /* convert to upper case */
479 *tmp
= toupper(*tmp
);
483 guard
= extendfile(guard
, "_H_RPCGEN");
488 * Compile into an XDR header file
493 h_output(const char *infile
, const char *define
, int extend
,
497 const char *ifilename
;
498 const char *outfilename
;
503 open_input(infile
, define
);
504 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
505 open_output(infile
, outfilename
);
507 ifilename
= (infile
== NULL
) ? "STDIN" : infile
;
508 guard
= generate_guard( outfilename
? outfilename
: ifilename
);
510 f_print(fout
,"#ifndef _%s\n#define _%s\n\n", guard
,
513 f_print(fout
, "#include <rpc/rpc.h>\n\n");
516 /* print data definitions */
517 while ((def
= get_definition())!=NULL
) {
521 /* print function declarations.
522 Do this after data definitions because they might be used as
523 arguments for functions */
524 for (l
= defined
; l
!= NULL
; l
= l
->next
) {
525 print_funcdef(l
->val
);
527 if (extend
&& tell
== ftell(fout
)) {
528 (void) unlink(outfilename
);
529 } else if (tblflag
) {
530 f_print(fout
, rpcgen_table_dcl
);
532 f_print(fout
, "\n#endif /* !_%s */\n", guard
);
536 * Compile into an RPC service
539 s_output(int argc
, const char *argv
[], const char *infile
, const char *define
,
540 int extend
, const char *outfile
, int nomain
, int netflag
)
544 int foundprogram
= 0;
545 const char *outfilename
;
547 open_input(infile
, define
);
548 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
549 open_output(infile
, outfilename
);
551 if (infile
&& (include
= extendfile(infile
, ".h"))) {
552 f_print(fout
, "#include \"%s\"\n", include
);
555 f_print(fout
, "#include <rpc/rpc.h>\n");
557 f_print(fout
, "#include <stdio.h>\n");
558 f_print(fout
, "#include <stdlib.h>/* getenv, exit */\n");
560 f_print (fout
, "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
561 f_print (fout
, "#include <string.h> /* strcmp */ \n");
563 if (strcmp(svcclosetime
, "-1") == 0)
565 else if (strcmp(svcclosetime
, "0") == 0)
567 else if (inetdflag
|| pmflag
) {
568 f_print(fout
, "#include <signal.h>\n");
572 if( !tirpcflag
&& inetdflag
)
573 #ifdef __GNU_LIBRARY__
574 f_print(fout
, "#include <sys/ioctl.h> /* ioctl, TIOCNOTTY */\n");
576 f_print(fout
, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
578 if( Cflag
&& (inetdflag
|| pmflag
) ) {
579 #ifdef __GNU_LIBRARY__
580 f_print(fout
, "#include <sys/types.h> /* open */\n");
581 f_print(fout
, "#include <sys/stat.h> /* open */\n");
582 f_print(fout
, "#include <fcntl.h> /* open */\n");
583 f_print(fout
, "#include <unistd.h> /* getdtablesize */\n");
585 f_print(fout
, "#ifdef __cplusplus\n");
586 f_print(fout
, "#include <sysent.h> /* getdtablesize, open */\n");
587 f_print(fout
, "#endif /* __cplusplus */\n");
590 f_print(fout
, "#include <unistd.h> /* setsid */\n");
593 f_print(fout
, "#include <sys/types.h>\n");
595 f_print(fout
, "#include <memory.h>\n");
596 #ifndef __GNU_LIBRARY__
597 f_print(fout
, "#include <stropts.h>\n");
599 if (inetdflag
|| !tirpcflag
) {
600 f_print(fout
, "#include <sys/socket.h>\n");
601 f_print(fout
, "#include <netinet/in.h>\n");
604 if ( (netflag
|| pmflag
) && tirpcflag
) {
605 f_print(fout
, "#include <netconfig.h>\n");
607 if (/*timerflag &&*/ tirpcflag
)
608 f_print(fout
, "#include <sys/resource.h> /* rlimit */\n");
609 if (logflag
|| inetdflag
|| pmflag
) {
610 #ifdef __GNU_LIBRARY__
611 f_print(fout
, "#include <syslog.h>\n");
613 f_print(fout
, "#ifdef SYSLOG\n");
614 f_print(fout
, "#include <syslog.h>\n");
615 f_print(fout
, "#else\n");
616 f_print(fout
, "#define LOG_ERR 1\n");
617 f_print(fout
, "#define openlog(a, b, c)\n");
618 f_print(fout
, "#endif\n");
623 f_print(fout
, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
625 #ifndef __GNU_LIBRARY__
626 f_print(fout
, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
629 f_print(fout
, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime
);
630 while ((def
= get_definition())!=NULL
) {
631 foundprogram
|= (def
->def_kind
== DEF_PROGRAM
);
633 if (extend
&& !foundprogram
) {
634 (void) unlink(outfilename
);
637 write_most(infile
, netflag
, nomain
);
639 if( !do_registers(argc
, argv
) ) {
641 (void) unlink(outfilename
);
649 * generate client side stubs
652 l_output(const char *infile
, const char *define
, int extend
,
657 int foundprogram
= 0;
658 const char *outfilename
;
660 open_input(infile
, define
);
661 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
662 open_output(infile
, outfilename
);
665 f_print (fout
, "#include <memory.h> /* for memset */\n");
666 if (infile
&& (include
= extendfile(infile
, ".h"))) {
667 f_print(fout
, "#include \"%s\"\n", include
);
670 f_print(fout
, "#include <rpc/rpc.h>\n");
671 while ((def
= get_definition())!=NULL
) {
672 foundprogram
|= (def
->def_kind
== DEF_PROGRAM
);
674 if (extend
&& !foundprogram
) {
675 (void) unlink(outfilename
);
682 * generate the dispatch table
685 t_output(const char *infile
, const char *define
, int extend
,
689 int foundprogram
= 0;
690 const char *outfilename
;
692 open_input(infile
, define
);
693 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
694 open_output(infile
, outfilename
);
696 while ((def
= get_definition())!=NULL
) {
697 foundprogram
|= (def
->def_kind
== DEF_PROGRAM
);
699 if (extend
&& !foundprogram
) {
700 (void) unlink(outfilename
);
706 /* sample routine for the server template */
708 svc_output(const char *infile
, const char *define
, int extend
,
713 const char *outfilename
;
716 open_input(infile
, define
);
717 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
718 checkfiles(infile
,outfilename
); /*check if outfile already exists.
719 if so, print an error message and exit*/
720 open_output(infile
, outfilename
);
723 if (infile
&& (include
= extendfile(infile
, ".h"))) {
724 f_print(fout
, "#include \"%s\"\n", include
);
727 f_print(fout
, "#include <rpc/rpc.h>\n");
730 while ((def
= get_definition())!=NULL
) {
731 write_sample_svc(def
);
733 if (extend
&& tell
== ftell(fout
)) {
734 (void) unlink(outfilename
);
739 /* sample main routine for client */
741 clnt_output(const char *infile
, const char *define
, int extend
,
746 const char *outfilename
;
750 open_input(infile
, define
);
751 outfilename
= extend
? extendfile(infile
, outfile
) : outfile
;
752 checkfiles(infile
,outfilename
); /*check if outfile already exists.
753 if so, print an error message and exit*/
755 open_output(infile
, outfilename
);
757 if (infile
&& (include
= extendfile(infile
, ".h"))) {
758 f_print(fout
, "#include \"%s\"\n", include
);
761 f_print(fout
, "#include <rpc/rpc.h>\n");
763 while ((def
= get_definition())!=NULL
) {
764 has_program
+= write_sample_clnt(def
);
768 write_sample_clnt_main();
770 if (extend
&& tell
== ftell(fout
)) {
771 (void) unlink(outfilename
);
776 * Perform registrations for service output
777 * Return 0 if failed; 1 otherwise.
779 static int do_registers(int argc
, const char *argv
[])
783 if ( inetdflag
|| !tirpcflag
) {
784 for (i
= 1; i
< argc
; i
++) {
785 if (streq(argv
[i
], "-s")) {
786 if(!check_nettype( argv
[i
+ 1], valid_i_nettypes
))
788 write_inetd_register(argv
[i
+ 1]);
793 for (i
= 1; i
< argc
; i
++)
794 if (streq(argv
[i
], "-s")) {
795 if(!check_nettype( argv
[i
+ 1], valid_ti_nettypes
))
797 write_nettype_register(argv
[i
+ 1]);
799 } else if (streq(argv
[i
], "-n")) {
800 write_netid_register(argv
[i
+ 1]);
808 * Add another argument to the arg list
811 addarg(const char *cp
)
813 if (argcount
>= ARGLISTLEN
) {
814 f_print(stderr
, "rpcgen: too many defines\n");
818 arglist
[argcount
++] = cp
;
823 putarg(int whereto
, const char *cp
)
825 if (whereto
>= ARGLISTLEN
) {
826 f_print(stderr
, "rpcgen: arglist coding error\n");
830 arglist
[whereto
] = cp
;
834 * if input file is stdin and an output file is specified then complain
835 * if the file already exists. Otherwise the file may get overwritten
836 * If input file does not exist, exit with an error
840 checkfiles(const char *infile
, const char *outfile
)
845 if(infile
) /* infile ! = NULL */
846 if(stat(infile
,&buf
) < 0)
852 if (stat(outfile
, &buf
) < 0)
853 return; /* file does not exist */
856 "file '%s' already exists and may be overwritten\n", outfile
);
863 * Parse command line arguments
866 parseargs(int argc
, const char *argv
[], struct commandline
*cmd
)
871 char flag
[(1 << 8 * sizeof(char))];
875 cmd
->infile
= cmd
->outfile
= NULL
;
890 for (i
= 1; i
< argc
; i
++) {
891 if (argv
[i
][0] != '-') {
893 f_print( stderr
, "Cannot specify more than one input file!\n");
897 cmd
->infile
= argv
[i
];
899 for (j
= 1; argv
[i
][j
] != 0; j
++) {
916 /* sample flag: Ss or Sc.
917 Ss means set flag['S'];
918 Sc means set flag['C']; */
919 c
= argv
[i
][++j
]; /* get next char */
932 case 'C': /* ANSI C syntax */
936 #ifdef __GNU_LIBRARY__
937 case 'k': /* K&R C syntax */
942 case 'b': /* turn TIRPC flag off for
943 generating backward compatible
948 #ifdef __GNU_LIBRARY__
949 case '5': /* turn TIRPC flag on for
950 generating SysVr4 compatible
971 svcclosetime
= argv
[i
];
980 inlineflag
= atoi(argv
[i
]);
985 if (argv
[i
][j
- 1] != '-' ||
986 argv
[i
][j
+ 1] != 0) {
994 if (!streq(argv
[i
], "udp") &&
995 !streq(argv
[i
], "tcp")) {
998 } else if (c
== 'o') {
1002 cmd
->outfile
= argv
[i
];
1006 if (argv
[i
][j
- 1] != '-') {
1009 (void) addarg(argv
[i
]);
1016 size_t len
= strlen (argv
[i
]);
1017 pathbuf
= malloc (len
+ 5);
1018 if (pathbuf
== NULL
) {
1022 stpcpy (stpcpy (pathbuf
,
1040 cmd
->cflag
= flag
['c'];
1041 cmd
->hflag
= flag
['h'];
1042 cmd
->lflag
= flag
['l'];
1043 cmd
->mflag
= flag
['m'];
1044 cmd
->nflag
= flag
['n'];
1045 cmd
->sflag
= flag
['s'];
1046 cmd
->tflag
= flag
['t'];
1047 cmd
->Ssflag
= flag
['S'];
1048 cmd
->Scflag
= flag
['C'];
1051 pmflag
= inetdflag
? 0 : 1; /* pmflag or inetdflag is always TRUE */
1052 if( (inetdflag
&& cmd
->nflag
)) { /* netid not allowed with inetdflag */
1053 f_print(stderr
, "Cannot use netid flag with inetd flag!\n");
1056 } else { /* 4.1 mode */
1057 pmflag
= 0; /* set pmflag only in tirpcmode */
1058 #ifndef __GNU_LIBRARY__
1059 inetdflag
= 1; /* inetdflag is TRUE by default */
1061 if( cmd
->nflag
) { /* netid needs TIRPC */
1062 f_print( stderr
, "Cannot use netid flag without TIRPC!\n");
1067 if( newstyle
&& ( tblflag
|| cmd
->tflag
) ) {
1068 f_print( stderr
, "Cannot use table flags with newstyle!\n");
1072 /* check no conflicts with file generation flags */
1073 nflags
= cmd
->cflag
+ cmd
->hflag
+ cmd
->lflag
+ cmd
->mflag
+
1074 cmd
->sflag
+ cmd
->nflag
+ cmd
->tflag
+ cmd
->Ssflag
+ cmd
->Scflag
;
1077 if (cmd
->outfile
!= NULL
|| cmd
->infile
== NULL
) {
1080 } else if (nflags
> 1) {
1081 f_print( stderr
, "Cannot have more than one file generation flag!\n");
1090 f_print(stderr
, "usage: %s infile\n", cmdname
);
1091 f_print(stderr
, "\t%s [-a][-b][-C][-Dname[=value]] -i size [-I [-K seconds]] [-L][-N][-T] infile\n",
1093 f_print(stderr
, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",
1095 f_print(stderr
, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname
);
1096 f_print(stderr
, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname
);
1104 f_print(stderr
, "options:\n");
1105 f_print(stderr
, "-a\t\tgenerate all files, including samples\n");
1106 f_print(stderr
, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");
1107 f_print(stderr
, "-c\t\tgenerate XDR routines\n");
1108 f_print(stderr
, "-C\t\tANSI C mode\n");
1109 f_print(stderr
, "-Dname[=value]\tdefine a symbol (same as #define)\n");
1110 f_print(stderr
, "-h\t\tgenerate header file\n");
1111 f_print(stderr
, "-i size\t\tsize at which to start generating inline code\n");
1112 f_print(stderr
, "-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n");
1113 f_print(stderr
, "-K seconds\tserver exits after K seconds of inactivity\n");
1114 f_print(stderr
, "-l\t\tgenerate client side stubs\n");
1115 f_print(stderr
, "-L\t\tserver errors will be printed to syslog\n");
1116 f_print(stderr
, "-m\t\tgenerate server side stubs\n");
1117 f_print(stderr
, "-n netid\tgenerate server code that supports named netid\n");
1118 f_print(stderr
, "-N\t\tsupports multiple arguments and call-by-value\n");
1119 f_print(stderr
, "-o outfile\tname of the output file\n");
1120 f_print(stderr
, "-s nettype\tgenerate server code that supports named nettype\n");
1121 f_print(stderr
, "-Sc\t\tgenerate sample client code that uses remote procedures\n");
1122 f_print(stderr
, "-Ss\t\tgenerate sample server code that defines remote procedures\n");
1123 f_print(stderr
, "-t\t\tgenerate RPC dispatch table\n");
1124 f_print(stderr
, "-T\t\tgenerate code to support RPC dispatch tables\n");
1125 f_print(stderr
, "-Y path\t\tdirectory name to find C preprocessor (cpp)\n");