14e115012SGarrett Wollman /* 24e115012SGarrett Wollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 34e115012SGarrett Wollman * unrestricted use provided that this legend is included on all tape 44e115012SGarrett Wollman * media and as a part of the software program in whole or part. Users 54e115012SGarrett Wollman * may copy or modify Sun RPC without charge, but are not authorized 64e115012SGarrett Wollman * to license or distribute it to anyone else except as part of a product or 74e115012SGarrett Wollman * program developed by the user. 84e115012SGarrett Wollman * 94e115012SGarrett Wollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 104e115012SGarrett Wollman * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 114e115012SGarrett Wollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 124e115012SGarrett Wollman * 134e115012SGarrett Wollman * Sun RPC is provided with no support and without any obligation on the 144e115012SGarrett Wollman * part of Sun Microsystems, Inc. to assist in its use, correction, 154e115012SGarrett Wollman * modification or enhancement. 164e115012SGarrett Wollman * 174e115012SGarrett Wollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 184e115012SGarrett Wollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 194e115012SGarrett Wollman * OR ANY PART THEREOF. 204e115012SGarrett Wollman * 214e115012SGarrett Wollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue 224e115012SGarrett Wollman * or profits or other special, indirect and consequential damages, even if 234e115012SGarrett Wollman * Sun has been advised of the possibility of such damages. 244e115012SGarrett Wollman * 254e115012SGarrett Wollman * Sun Microsystems, Inc. 264e115012SGarrett Wollman * 2550 Garcia Avenue 274e115012SGarrett Wollman * Mountain View, California 94043 284e115012SGarrett Wollman */ 29ff49530fSBill Paul 30ff49530fSBill Paul 310e76f40dSPhilippe Charnier #if 0 3275863a6dSPhilippe Charnier #ifndef lint 3363f17371SStefan Farfeleder #ident "@(#)rpc_main.c 1.21 94/04/25 SMI" 34ff49530fSBill Paul static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI"; 354e115012SGarrett Wollman #endif 360e76f40dSPhilippe Charnier #endif 374e115012SGarrett Wollman 3875863a6dSPhilippe Charnier #include <sys/cdefs.h> 3975863a6dSPhilippe Charnier __FBSDID("$FreeBSD$"); 4075863a6dSPhilippe Charnier 414e115012SGarrett Wollman /* 424e115012SGarrett Wollman * rpc_main.c, Top level of the RPC protocol compiler. 434e115012SGarrett Wollman * Copyright (C) 1987, Sun Microsystems, Inc. 444e115012SGarrett Wollman */ 454e115012SGarrett Wollman 460e76f40dSPhilippe Charnier #include <err.h> 470e76f40dSPhilippe Charnier #include <ctype.h> 484e115012SGarrett Wollman #include <stdio.h> 49ff49530fSBill Paul #include <string.h> 50ff49530fSBill Paul #include <unistd.h> 51ff49530fSBill Paul #include <sys/types.h> 52ff49530fSBill Paul #include <sys/param.h> 534e115012SGarrett Wollman #include <sys/file.h> 54ff49530fSBill Paul #include <sys/stat.h> 554e115012SGarrett Wollman #include "rpc_parse.h" 564e115012SGarrett Wollman #include "rpc_scan.h" 57d0cc804bSStefan Farfeleder #include "rpc_util.h" 584e115012SGarrett Wollman 59e390e3afSDavid Malone static void c_output(const char *, const char *, int, const char *); 60e390e3afSDavid Malone static void h_output(const char *, const char *, int, const char *, int); 61e390e3afSDavid Malone static void l_output(const char *, const char *, int, const char *); 62e390e3afSDavid Malone static void t_output(const char *, const char *, int, const char *); 63e390e3afSDavid Malone static void clnt_output(const char *, const char *, int, const char * ); 64e390e3afSDavid Malone static char *generate_guard(const char *); 65e390e3afSDavid Malone static void c_initialize(void); 664e115012SGarrett Wollman 67d3cb5dedSWarner Losh static void usage(void); 68d3cb5dedSWarner Losh static void options_usage(void); 69e390e3afSDavid Malone static int do_registers(int, const char **); 70e390e3afSDavid Malone static int parseargs(int, const char **, struct commandline *); 71e390e3afSDavid Malone static void svc_output(const char *, const char *, int, const char *); 72d3cb5dedSWarner Losh static void mkfile_output(struct commandline *); 73e390e3afSDavid Malone static void s_output(int, const char **, const char *, const char *, int, const char *, int, int); 74ff49530fSBill Paul 75ff49530fSBill Paul #define EXTEND 1 /* alias for TRUE */ 76ff49530fSBill Paul #define DONT_EXTEND 0 /* alias for FALSE */ 77ff49530fSBill Paul 78ff49530fSBill Paul #define SVR4_CPP "/usr/ccs/lib/cpp" 79d7c089b7SJohn Birrell #define SUNOS_CPP "/usr/bin/cpp" 80ff49530fSBill Paul 81ff49530fSBill Paul static int cppDefined = 0; /* explicit path for C preprocessor */ 82ff49530fSBill Paul 83e390e3afSDavid Malone static const char *svcclosetime = "120"; 84e390e3afSDavid Malone static const char *CPP = SVR4_CPP; 85e390e3afSDavid Malone static const char CPPFLAGS[] = "-C"; 86ff49530fSBill Paul static char pathbuf[MAXPATHLEN + 1]; 87e390e3afSDavid Malone static const char *allv[] = { 884e115012SGarrett Wollman "rpcgen", "-s", "udp", "-s", "tcp", 894e115012SGarrett Wollman }; 904e115012SGarrett Wollman static int allc = sizeof (allv)/sizeof (allv[0]); 91e390e3afSDavid Malone static const char *allnv[] = { 92ff49530fSBill Paul "rpcgen", "-s", "netpath", 93ff49530fSBill Paul }; 94ff49530fSBill Paul static int allnc = sizeof (allnv)/sizeof (allnv[0]); 95ff49530fSBill Paul 96ff49530fSBill Paul /* 97ff49530fSBill Paul * machinations for handling expanding argument list 98ff49530fSBill Paul */ 99e390e3afSDavid Malone static void addarg(const char *); /* add another argument to the list */ 100e390e3afSDavid Malone static void putarg(int, const char *); /* put argument at specified location */ 101e390e3afSDavid Malone static void clear_args(void); /* clear argument list */ 102e390e3afSDavid Malone static void checkfiles(const char *, const char *); 103e390e3afSDavid Malone /* check if out file already exists */ 1044e115012SGarrett Wollman 1054e115012SGarrett Wollman 106ff49530fSBill Paul 107ff49530fSBill Paul #define ARGLISTLEN 20 108ff49530fSBill Paul #define FIXEDARGS 2 109ff49530fSBill Paul 110075775c9SCraig Rodrigues static char *arglist[ARGLISTLEN]; 111ff49530fSBill Paul static int argcount = FIXEDARGS; 112ff49530fSBill Paul 113ff49530fSBill Paul 114ff49530fSBill Paul int nonfatalerrors; /* errors */ 11540ad8885SAlfred Perlstein int inetdflag = 0; /* Support for inetd is disabled by default, use -I */ 11640ad8885SAlfred Perlstein int pmflag = 0; /* Support for port monitors is disabled by default */ 11740ad8885SAlfred Perlstein int tirpc_socket = 1; /* TI-RPC on socket, no TLI library */ 118ff49530fSBill Paul int logflag; /* Use syslog instead of fprintf for errors */ 119ff49530fSBill Paul int tblflag; /* Support for dispatch table file */ 120ff49530fSBill Paul int mtflag = 0; /* Support for MT */ 12140ad8885SAlfred Perlstein 122ff49530fSBill Paul #define INLINE 0 123ff49530fSBill Paul /* length at which to start doing an inline */ 124ff49530fSBill Paul 125122562cdSStefan Farfeleder int inline_size = INLINE; 126ff49530fSBill Paul /* 127ff49530fSBill Paul * Length at which to start doing an inline. INLINE = default 128ff49530fSBill Paul * if 0, no xdr_inline code 129ff49530fSBill Paul */ 130ff49530fSBill Paul 131ff49530fSBill Paul int indefinitewait; /* If started by port monitors, hang till it wants */ 132ff49530fSBill Paul int exitnow; /* If started by port monitors, exit after the call */ 133ff49530fSBill Paul int timerflag; /* TRUE if !indefinite && !exitnow */ 134ff49530fSBill Paul int newstyle; /* newstyle of passing arguments (by value) */ 135ff49530fSBill Paul int CCflag = 0; /* C++ files */ 136ff49530fSBill Paul static int allfiles; /* generate all files */ 137ff49530fSBill Paul int tirpcflag = 1; /* generating code for tirpc, by default */ 138ff49530fSBill Paul xdrfunc *xdrfunc_head = NULL; /* xdr function list */ 139ff49530fSBill Paul xdrfunc *xdrfunc_tail = NULL; /* xdr function list */ 140ff49530fSBill Paul pid_t childpid; 141ff49530fSBill Paul 1424e115012SGarrett Wollman 143526195adSJordan K. Hubbard int 144e390e3afSDavid Malone main(int argc, const char *argv[]) 1454e115012SGarrett Wollman { 1464e115012SGarrett Wollman struct commandline cmd; 1474e115012SGarrett Wollman 148ff49530fSBill Paul (void) memset((char *)&cmd, 0, sizeof (struct commandline)); 149ff49530fSBill Paul clear_args(); 150ff49530fSBill Paul if (!parseargs(argc, argv, &cmd)) 151ff49530fSBill Paul usage(); 152ff49530fSBill Paul /* 153ff49530fSBill Paul * Only the client and server side stubs are likely to be customized, 154ff49530fSBill Paul * so in that case only, check if the outfile exists, and if so, 155ff49530fSBill Paul * print an error message and exit. 156ff49530fSBill Paul */ 157ff49530fSBill Paul if (cmd.Ssflag || cmd.Scflag || cmd.makefileflag) { 158ff49530fSBill Paul checkfiles(cmd.infile, cmd.outfile); 1594e115012SGarrett Wollman } 160ff49530fSBill Paul else 161ff49530fSBill Paul checkfiles(cmd.infile, NULL); 162ff49530fSBill Paul 1634e115012SGarrett Wollman if (cmd.cflag) { 164ff49530fSBill Paul c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile); 1654e115012SGarrett Wollman } else if (cmd.hflag) { 166ec06b5e8SStefan Farfeleder h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile, 167ec06b5e8SStefan Farfeleder cmd.hflag); 1684e115012SGarrett Wollman } else if (cmd.lflag) { 169ff49530fSBill Paul l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile); 170ff49530fSBill Paul } else if (cmd.sflag || cmd.mflag || (cmd.nflag)) { 171ff49530fSBill Paul s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND, 172ff49530fSBill Paul cmd.outfile, cmd.mflag, cmd.nflag); 173ff49530fSBill Paul } else if (cmd.tflag) { 174ff49530fSBill Paul t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile); 175ff49530fSBill Paul } else if (cmd.Ssflag) { 176ff49530fSBill Paul svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, 177ff49530fSBill Paul cmd.outfile); 178ff49530fSBill Paul } else if (cmd.Scflag) { 179ff49530fSBill Paul clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, 180ff49530fSBill Paul cmd.outfile); 181ff49530fSBill Paul } else if (cmd.makefileflag) { 182ff49530fSBill Paul mkfile_output(&cmd); 1834e115012SGarrett Wollman } else { 184ff49530fSBill Paul /* the rescans are required, since cpp may effect input */ 1854e115012SGarrett Wollman c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c"); 1864e115012SGarrett Wollman reinitialize(); 187ec06b5e8SStefan Farfeleder h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h", cmd.hflag); 1884e115012SGarrett Wollman reinitialize(); 1894e115012SGarrett Wollman l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c"); 1904e115012SGarrett Wollman reinitialize(); 191ff49530fSBill Paul if (inetdflag || !tirpcflag) 1924e115012SGarrett Wollman s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND, 193ff49530fSBill Paul "_svc.c", cmd.mflag, cmd.nflag); 194ff49530fSBill Paul else 195ff49530fSBill Paul s_output(allnc, allnv, cmd.infile, "-DRPC_SVC", 196ff49530fSBill Paul EXTEND, "_svc.c", cmd.mflag, cmd.nflag); 197ff49530fSBill Paul if (tblflag) { 198ff49530fSBill Paul reinitialize(); 199ff49530fSBill Paul t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i"); 2004e115012SGarrett Wollman } 2014e115012SGarrett Wollman 202ff49530fSBill Paul if (allfiles) { 203ff49530fSBill Paul reinitialize(); 204ff49530fSBill Paul svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, 205ff49530fSBill Paul "_server.c"); 206ff49530fSBill Paul reinitialize(); 207ff49530fSBill Paul clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, 208ff49530fSBill Paul "_client.c"); 209ff49530fSBill Paul 210ff49530fSBill Paul } 211ff49530fSBill Paul if (allfiles || (cmd.makefileflag == 1)){ 212ff49530fSBill Paul reinitialize(); 213ff49530fSBill Paul mkfile_output(&cmd); 214ff49530fSBill Paul } 215ff49530fSBill Paul 216ff49530fSBill Paul } 217ff49530fSBill Paul exit(nonfatalerrors); 218ff49530fSBill Paul /* NOTREACHED */ 219ff49530fSBill Paul } 220ff49530fSBill Paul 221ff49530fSBill Paul 2224e115012SGarrett Wollman /* 223ff49530fSBill Paul * add extension to filename 2244e115012SGarrett Wollman */ 2254e115012SGarrett Wollman static char * 226e390e3afSDavid Malone extendfile(const char *path, const char *ext) 2274e115012SGarrett Wollman { 2284e115012SGarrett Wollman char *res; 229e390e3afSDavid Malone const char *p; 230e390e3afSDavid Malone const char *file; 2314e115012SGarrett Wollman 232*b3608ae1SEd Schouten if ((file = strrchr(path, '/')) == NULL) 2335ec07232SNate Williams file = path; 2345ec07232SNate Williams else 2355ec07232SNate Williams file++; 23675863a6dSPhilippe Charnier res = xmalloc(strlen(file) + strlen(ext) + 1); 237ff49530fSBill Paul p = strrchr(file, '.'); 2384e115012SGarrett Wollman if (p == NULL) { 2394e115012SGarrett Wollman p = file + strlen(file); 2404e115012SGarrett Wollman } 2414e115012SGarrett Wollman (void) strcpy(res, file); 2424e115012SGarrett Wollman (void) strcpy(res + (p - file), ext); 2434e115012SGarrett Wollman return (res); 2444e115012SGarrett Wollman } 2454e115012SGarrett Wollman 2464e115012SGarrett Wollman /* 2474e115012SGarrett Wollman * Open output file with given extension 2484e115012SGarrett Wollman */ 249526195adSJordan K. Hubbard static void 250e390e3afSDavid Malone open_output(const char *infile, const char *outfile) 2514e115012SGarrett Wollman { 252ff49530fSBill Paul 2534e115012SGarrett Wollman if (outfile == NULL) { 2544e115012SGarrett Wollman fout = stdout; 2554e115012SGarrett Wollman return; 2564e115012SGarrett Wollman } 257ff49530fSBill Paul 2584e115012SGarrett Wollman if (infile != NULL && streq(outfile, infile)) { 2590e76f40dSPhilippe Charnier warnx("%s already exists. No output generated", infile); 2604e115012SGarrett Wollman crash(); 2614e115012SGarrett Wollman } 2624e115012SGarrett Wollman fout = fopen(outfile, "w"); 2634e115012SGarrett Wollman if (fout == NULL) { 2640e76f40dSPhilippe Charnier warn("unable to open %s", outfile); 2654e115012SGarrett Wollman crash(); 2664e115012SGarrett Wollman } 2674e115012SGarrett Wollman record_open(outfile); 268ff49530fSBill Paul 269526195adSJordan K. Hubbard return; 270ff49530fSBill Paul } 271ff49530fSBill Paul 272526195adSJordan K. Hubbard static void 273e390e3afSDavid Malone add_warning(void) 274ff49530fSBill Paul { 275ff49530fSBill Paul f_print(fout, "/*\n"); 276ff49530fSBill Paul f_print(fout, " * Please do not edit this file.\n"); 277ff49530fSBill Paul f_print(fout, " * It was generated using rpcgen.\n"); 278ff49530fSBill Paul f_print(fout, " */\n\n"); 279ff49530fSBill Paul } 280ff49530fSBill Paul 281ff49530fSBill Paul /* clear list of arguments */ 282e390e3afSDavid Malone static void 283e390e3afSDavid Malone clear_args(void) 284ff49530fSBill Paul { 285ff49530fSBill Paul int i; 286ff49530fSBill Paul for (i = FIXEDARGS; i < ARGLISTLEN; i++) 287ff49530fSBill Paul arglist[i] = NULL; 288ff49530fSBill Paul argcount = FIXEDARGS; 289ff49530fSBill Paul } 290ff49530fSBill Paul 291ff49530fSBill Paul /* make sure that a CPP exists */ 292e390e3afSDavid Malone static void 293e390e3afSDavid Malone find_cpp(void) 294ff49530fSBill Paul { 295ff49530fSBill Paul struct stat buf; 296ff49530fSBill Paul 297ff49530fSBill Paul if (stat(CPP, &buf) < 0) { /* SVR4 or explicit cpp does not exist */ 298ff49530fSBill Paul if (cppDefined) { 2990e76f40dSPhilippe Charnier warnx("cannot find C preprocessor: %s", CPP); 300ff49530fSBill Paul crash(); 301ff49530fSBill Paul } else { /* try the other one */ 302ff49530fSBill Paul CPP = SUNOS_CPP; 303ff49530fSBill Paul if (stat(CPP, &buf) < 0) { /* can't find any cpp */ 304f2912673SDavid E. O'Brien warnx("cannot find C preprocessor: %s", CPP); 305ff49530fSBill Paul crash(); 306ff49530fSBill Paul } 307ff49530fSBill Paul } 308ff49530fSBill Paul } 3094e115012SGarrett Wollman } 3104e115012SGarrett Wollman 3114e115012SGarrett Wollman /* 3124e115012SGarrett Wollman * Open input file with given define for C-preprocessor 3134e115012SGarrett Wollman */ 314526195adSJordan K. Hubbard static void 315e390e3afSDavid Malone open_input(const char *infile, const char *define) 3164e115012SGarrett Wollman { 3174e115012SGarrett Wollman int pd[2]; 3184e115012SGarrett Wollman 3194e115012SGarrett Wollman infilename = (infile == NULL) ? "<stdin>" : infile; 3204e115012SGarrett Wollman (void) pipe(pd); 321ff49530fSBill Paul switch (childpid = fork()) { 3224e115012SGarrett Wollman case 0: 323ff49530fSBill Paul find_cpp(); 324ff49530fSBill Paul putarg(0, CPP); 325ff49530fSBill Paul putarg(1, CPPFLAGS); 326ff49530fSBill Paul addarg(define); 327ff49530fSBill Paul if (infile) 328ff49530fSBill Paul addarg(infile); 329ff49530fSBill Paul addarg((char *)NULL); 3304e115012SGarrett Wollman (void) close(1); 3314e115012SGarrett Wollman (void) dup2(pd[1], 1); 3324e115012SGarrett Wollman (void) close(pd[0]); 333ff49530fSBill Paul execv(arglist[0], arglist); 33475863a6dSPhilippe Charnier err(1, "execv"); 3354e115012SGarrett Wollman case -1: 33675863a6dSPhilippe Charnier err(1, "fork"); 3374e115012SGarrett Wollman } 3384e115012SGarrett Wollman (void) close(pd[1]); 3394e115012SGarrett Wollman fin = fdopen(pd[0], "r"); 3404e115012SGarrett Wollman if (fin == NULL) { 3410e76f40dSPhilippe Charnier warn("%s", infilename); 3424e115012SGarrett Wollman crash(); 3434e115012SGarrett Wollman } 3444e115012SGarrett Wollman } 3454e115012SGarrett Wollman 346ff49530fSBill Paul /* valid tirpc nettypes */ 347e390e3afSDavid Malone static const char *valid_ti_nettypes[] = 348ff49530fSBill Paul { 349ff49530fSBill Paul "netpath", 350ff49530fSBill Paul "visible", 351ff49530fSBill Paul "circuit_v", 352ff49530fSBill Paul "datagram_v", 353ff49530fSBill Paul "circuit_n", 354ff49530fSBill Paul "datagram_n", 355ff49530fSBill Paul "udp", 356ff49530fSBill Paul "tcp", 357ff49530fSBill Paul "raw", 358ff49530fSBill Paul NULL 359ff49530fSBill Paul }; 360ff49530fSBill Paul 361ff49530fSBill Paul /* valid inetd nettypes */ 362e390e3afSDavid Malone static const char *valid_i_nettypes[] = 363ff49530fSBill Paul { 364ff49530fSBill Paul "udp", 365ff49530fSBill Paul "tcp", 366ff49530fSBill Paul NULL 367ff49530fSBill Paul }; 368ff49530fSBill Paul 369e390e3afSDavid Malone static int 370e390e3afSDavid Malone check_nettype(const char *name, const char *list_to_check[]) 371ff49530fSBill Paul { 372ff49530fSBill Paul int i; 373ff49530fSBill Paul for (i = 0; list_to_check[i] != NULL; i++) { 374ff49530fSBill Paul if (strcmp(name, list_to_check[i]) == 0) { 375ff49530fSBill Paul return (1); 376ff49530fSBill Paul } 377ff49530fSBill Paul } 3780e76f40dSPhilippe Charnier warnx("illegal nettype :\'%s\'", name); 379ff49530fSBill Paul return (0); 380ff49530fSBill Paul } 381ff49530fSBill Paul 382e390e3afSDavid Malone static const char * 383e390e3afSDavid Malone file_name(const char *file, const char *ext) 384ff49530fSBill Paul { 385ff49530fSBill Paul char *temp; 386ff49530fSBill Paul temp = extendfile(file, ext); 387ff49530fSBill Paul 388ff49530fSBill Paul if (access(temp, F_OK) != -1) 389ff49530fSBill Paul return (temp); 390ff49530fSBill Paul else 391e390e3afSDavid Malone return (" "); 392ff49530fSBill Paul 393ff49530fSBill Paul } 394ff49530fSBill Paul 395ff49530fSBill Paul 396526195adSJordan K. Hubbard static void 397e390e3afSDavid Malone c_output(const char *infile, const char *define, int extend, const char *outfile) 3984e115012SGarrett Wollman { 3994e115012SGarrett Wollman definition *def; 4004e115012SGarrett Wollman char *include; 401e390e3afSDavid Malone const char *outfilename; 4024e115012SGarrett Wollman long tell; 4034e115012SGarrett Wollman 404ff49530fSBill Paul c_initialize(); 4054e115012SGarrett Wollman open_input(infile, define); 4064e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 4074e115012SGarrett Wollman open_output(infile, outfilename); 408ff49530fSBill Paul add_warning(); 4094e115012SGarrett Wollman if (infile && (include = extendfile(infile, ".h"))) { 4104e115012SGarrett Wollman f_print(fout, "#include \"%s\"\n", include); 4114e115012SGarrett Wollman free(include); 412ff49530fSBill Paul /* .h file already contains rpc/rpc.h */ 413ff49530fSBill Paul } else 414ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 4154e115012SGarrett Wollman tell = ftell(fout); 416526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 4174e115012SGarrett Wollman emit(def); 4184e115012SGarrett Wollman } 4194e115012SGarrett Wollman if (extend && tell == ftell(fout)) { 4204e115012SGarrett Wollman (void) unlink(outfilename); 4214e115012SGarrett Wollman } 4224e115012SGarrett Wollman } 4234e115012SGarrett Wollman 424ff49530fSBill Paul 425526195adSJordan K. Hubbard void 426e390e3afSDavid Malone c_initialize(void) 427ff49530fSBill Paul { 428ff49530fSBill Paul 429ff49530fSBill Paul /* add all the starting basic types */ 430ff49530fSBill Paul add_type(1, "int"); 431ff49530fSBill Paul add_type(1, "long"); 432ff49530fSBill Paul add_type(1, "short"); 433ff49530fSBill Paul add_type(1, "bool"); 434ff49530fSBill Paul add_type(1, "u_int"); 435ff49530fSBill Paul add_type(1, "u_long"); 436ff49530fSBill Paul add_type(1, "u_short"); 437ff49530fSBill Paul 438ff49530fSBill Paul } 439ff49530fSBill Paul 440e390e3afSDavid Malone const char rpcgen_table_dcl[] = "struct rpcgen_table {\n\ 441ff49530fSBill Paul char *(*proc)(); \n\ 442ff49530fSBill Paul xdrproc_t xdr_arg; \n\ 443ff49530fSBill Paul unsigned len_arg; \n\ 444ff49530fSBill Paul xdrproc_t xdr_res; \n\ 445ff49530fSBill Paul unsigned len_res; \n\ 446ff49530fSBill Paul }; \n"; 447ff49530fSBill Paul 448ff49530fSBill Paul 449e390e3afSDavid Malone char * 450e390e3afSDavid Malone generate_guard(const char *pathname) 451ff49530fSBill Paul { 452e390e3afSDavid Malone const char *filename; 453e390e3afSDavid Malone char *guard, *tmp, *stopat; 454ff49530fSBill Paul 455ff49530fSBill Paul filename = strrchr(pathname, '/'); /* find last component */ 456ff49530fSBill Paul filename = ((filename == 0) ? pathname : filename+1); 45775863a6dSPhilippe Charnier guard = xstrdup(filename); 458080f4020SSean Kelly stopat = strrchr(guard, '.'); 459080f4020SSean Kelly 460080f4020SSean Kelly /* 461080f4020SSean Kelly * Convert to a valid C macro name and make it upper case. 462080f4020SSean Kelly * Map macro unfriendly characterss to '_'. 46310c546c4SSean Kelly */ 464080f4020SSean Kelly for (tmp = guard; *tmp != '\000'; ++tmp) { 465ff49530fSBill Paul if (islower(*tmp)) 466ff49530fSBill Paul *tmp = toupper(*tmp); 467080f4020SSean Kelly else if (isupper(*tmp) || *tmp == '_') 46810c546c4SSean Kelly /* OK for C */; 46910c546c4SSean Kelly else if (tmp == guard) 47010c546c4SSean Kelly *tmp = '_'; 47110c546c4SSean Kelly else if (isdigit(*tmp)) 47210c546c4SSean Kelly /* OK for all but first character */; 473080f4020SSean Kelly else if (tmp == stopat) { 474080f4020SSean Kelly *tmp = '\0'; 47510c546c4SSean Kelly break; 47610c546c4SSean Kelly } else 47710c546c4SSean Kelly *tmp = '_'; 47810c546c4SSean Kelly } 479080f4020SSean Kelly /* 480080f4020SSean Kelly * Can't have a '_' in front, because it'll end up being "__". 481080f4020SSean Kelly * "__" macros shoudln't be used. So, remove all of the 482080f4020SSean Kelly * '_' characters from the front. 48310c546c4SSean Kelly */ 484080f4020SSean Kelly if (*guard == '_') { 485080f4020SSean Kelly for (tmp = guard; *tmp == '_'; ++tmp) 486080f4020SSean Kelly ; 487080f4020SSean Kelly strcpy(guard, tmp); 488ff49530fSBill Paul } 489ff49530fSBill Paul guard = extendfile(guard, "_H_RPCGEN"); 490ff49530fSBill Paul return (guard); 491ff49530fSBill Paul } 492ff49530fSBill Paul 4934e115012SGarrett Wollman /* 4944e115012SGarrett Wollman * Compile into an XDR header file 4954e115012SGarrett Wollman */ 496ff49530fSBill Paul 497ff49530fSBill Paul 498526195adSJordan K. Hubbard static void 499e390e3afSDavid Malone h_output(const char *infile, const char *define, int extend, const char *outfile, int headeronly) 5004e115012SGarrett Wollman { 5014e115012SGarrett Wollman definition *def; 502e390e3afSDavid Malone const char *outfilename; 5034e115012SGarrett Wollman long tell; 504e390e3afSDavid Malone const char *guard; 505ff49530fSBill Paul list *l; 506ff49530fSBill Paul xdrfunc *xdrfuncp; 5074e115012SGarrett Wollman 5084e115012SGarrett Wollman open_input(infile, define); 5094e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 5104e115012SGarrett Wollman open_output(infile, outfilename); 511ff49530fSBill Paul add_warning(); 512ff49530fSBill Paul if (outfilename || infile){ 513ff49530fSBill Paul guard = generate_guard(outfilename ? outfilename: infile); 514ff49530fSBill Paul } else 515ff49530fSBill Paul guard = "STDIN_"; 516ff49530fSBill Paul 517ff49530fSBill Paul f_print(fout, "#ifndef _%s\n#define _%s\n\n", guard, 518ff49530fSBill Paul guard); 519ff49530fSBill Paul 520ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 521ff49530fSBill Paul 52240ad8885SAlfred Perlstein if (mtflag) 52335ab9586SDavid E. O'Brien f_print(fout, "#include <pthread.h>\n"); 524ff49530fSBill Paul 525ff49530fSBill Paul /* put the C++ support */ 52615df5e2dSStefan Farfeleder if (!CCflag) { 527ff49530fSBill Paul f_print(fout, "\n#ifdef __cplusplus\n"); 528ff49530fSBill Paul f_print(fout, "extern \"C\" {\n"); 529ff49530fSBill Paul f_print(fout, "#endif\n\n"); 530ff49530fSBill Paul } 531ff49530fSBill Paul 532ff49530fSBill Paul /* put in a typedef for quadprecision. Only with Cflag */ 533ff49530fSBill Paul 5344e115012SGarrett Wollman tell = ftell(fout); 535ff49530fSBill Paul 536ff49530fSBill Paul /* print data definitions */ 537526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 538ec06b5e8SStefan Farfeleder print_datadef(def, headeronly); 5394e115012SGarrett Wollman } 540ff49530fSBill Paul 541ff49530fSBill Paul /* 542ff49530fSBill Paul * print function declarations. 543ff49530fSBill Paul * Do this after data definitions because they might be used as 544ff49530fSBill Paul * arguments for functions 545ff49530fSBill Paul */ 546ff49530fSBill Paul for (l = defined; l != NULL; l = l->next) { 547ec06b5e8SStefan Farfeleder print_funcdef(l->val, headeronly); 548ff49530fSBill Paul } 549ff49530fSBill Paul /* Now print all xdr func declarations */ 550ff49530fSBill Paul if (xdrfunc_head != NULL){ 551ff49530fSBill Paul 552ff49530fSBill Paul f_print(fout, 553ff49530fSBill Paul "\n/* the xdr functions */\n"); 554ff49530fSBill Paul 555ff49530fSBill Paul if (CCflag){ 556ff49530fSBill Paul f_print(fout, "\n#ifdef __cplusplus\n"); 557ff49530fSBill Paul f_print(fout, "extern \"C\" {\n"); 558ff49530fSBill Paul f_print(fout, "#endif\n"); 559ff49530fSBill Paul } 560ff49530fSBill Paul 561ff49530fSBill Paul xdrfuncp = xdrfunc_head; 562ff49530fSBill Paul while (xdrfuncp != NULL){ 56315df5e2dSStefan Farfeleder print_xdr_func_def(xdrfuncp->name, xdrfuncp->pointerp); 564ff49530fSBill Paul xdrfuncp = xdrfuncp->next; 565ff49530fSBill Paul } 566ff49530fSBill Paul } 567ff49530fSBill Paul 5684e115012SGarrett Wollman if (extend && tell == ftell(fout)) { 5694e115012SGarrett Wollman (void) unlink(outfilename); 570ff49530fSBill Paul } else if (tblflag) { 571ff49530fSBill Paul f_print(fout, rpcgen_table_dcl); 5724e115012SGarrett Wollman } 573ff49530fSBill Paul 574ff49530fSBill Paul f_print(fout, "\n#ifdef __cplusplus\n"); 575ff49530fSBill Paul f_print(fout, "}\n"); 576ff49530fSBill Paul f_print(fout, "#endif\n"); 577ff49530fSBill Paul 578ff49530fSBill Paul f_print(fout, "\n#endif /* !_%s */\n", guard); 5794e115012SGarrett Wollman } 5804e115012SGarrett Wollman 5814e115012SGarrett Wollman /* 5824e115012SGarrett Wollman * Compile into an RPC service 5834e115012SGarrett Wollman */ 584526195adSJordan K. Hubbard static void 585e390e3afSDavid Malone s_output(int argc, const char *argv[], const char *infile, const char *define, 586e390e3afSDavid Malone int extend, const char *outfile, int nomain, int netflag) 5874e115012SGarrett Wollman { 5884e115012SGarrett Wollman char *include; 5894e115012SGarrett Wollman definition *def; 590ff49530fSBill Paul int foundprogram = 0; 591e390e3afSDavid Malone const char *outfilename; 5924e115012SGarrett Wollman 5934e115012SGarrett Wollman open_input(infile, define); 5944e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 5954e115012SGarrett Wollman open_output(infile, outfilename); 596ff49530fSBill Paul add_warning(); 5974e115012SGarrett Wollman if (infile && (include = extendfile(infile, ".h"))) { 5984e115012SGarrett Wollman f_print(fout, "#include \"%s\"\n", include); 5994e115012SGarrett Wollman free(include); 600ff49530fSBill Paul } else 601ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 602ff49530fSBill Paul 603ff49530fSBill Paul f_print(fout, "#include <stdio.h>\n"); 604ff49530fSBill Paul f_print(fout, "#include <stdlib.h> /* getenv, exit */\n"); 60515df5e2dSStefan Farfeleder f_print (fout, "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n"); 606ff49530fSBill Paul f_print (fout, "#include <string.h> /* strcmp */\n"); 607bcb53b16SMartin Blapp if (tirpcflag) 608bcb53b16SMartin Blapp f_print(fout, "#include <rpc/rpc_com.h>\n"); 609ff49530fSBill Paul if (strcmp(svcclosetime, "-1") == 0) 610ff49530fSBill Paul indefinitewait = 1; 611ff49530fSBill Paul else if (strcmp(svcclosetime, "0") == 0) 612ff49530fSBill Paul exitnow = 1; 613ff49530fSBill Paul else if (inetdflag || pmflag) { 614ff49530fSBill Paul f_print(fout, "#include <signal.h>\n"); 615ff49530fSBill Paul timerflag = 1; 616ff49530fSBill Paul } 617ff49530fSBill Paul 618ff49530fSBill Paul if (!tirpcflag && inetdflag) 619ff49530fSBill Paul f_print(fout, "#include <sys/ttycom.h> /* TIOCNOTTY */\n"); 62015df5e2dSStefan Farfeleder if (inetdflag || pmflag) { 621ff49530fSBill Paul f_print(fout, "#ifdef __cplusplus\n"); 622ff49530fSBill Paul f_print(fout, 623f87730d4SXin LI "#include <sys/sysent.h> /* getdtablesize, open */\n"); 624ff49530fSBill Paul f_print(fout, "#endif /* __cplusplus */\n"); 625ff49530fSBill Paul } 62640ad8885SAlfred Perlstein if (tirpcflag) { 62740ad8885SAlfred Perlstein f_print(fout, "#include <fcntl.h> /* open */\n"); 62840ad8885SAlfred Perlstein f_print(fout, "#include <unistd.h> /* fork / setsid */\n"); 629ff49530fSBill Paul f_print(fout, "#include <sys/types.h>\n"); 63040ad8885SAlfred Perlstein } 631ff49530fSBill Paul 6324f83fd19SStefan Farfeleder f_print(fout, "#include <string.h>\n"); 633ff49530fSBill Paul if (inetdflag || !tirpcflag) { 634ff49530fSBill Paul f_print(fout, "#include <sys/socket.h>\n"); 635ff49530fSBill Paul f_print(fout, "#include <netinet/in.h>\n"); 636ff49530fSBill Paul } 637ff49530fSBill Paul 638ff49530fSBill Paul if ((netflag || pmflag) && tirpcflag && !nomain) { 639ff49530fSBill Paul f_print(fout, "#include <netconfig.h>\n"); 640ff49530fSBill Paul } 641ff49530fSBill Paul if (tirpcflag) 642ff49530fSBill Paul f_print(fout, "#include <sys/resource.h> /* rlimit */\n"); 64340ad8885SAlfred Perlstein if (logflag || inetdflag || pmflag || tirpcflag) 644ff49530fSBill Paul f_print(fout, "#include <syslog.h>\n"); 645ff49530fSBill Paul 646ff49530fSBill Paul f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n"); 647ff49530fSBill Paul if (timerflag) 648ff49530fSBill Paul f_print(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", 649ff49530fSBill Paul svcclosetime); 650526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 6514e115012SGarrett Wollman foundprogram |= (def->def_kind == DEF_PROGRAM); 6524e115012SGarrett Wollman } 6534e115012SGarrett Wollman if (extend && !foundprogram) { 6544e115012SGarrett Wollman (void) unlink(outfilename); 6554e115012SGarrett Wollman return; 6564e115012SGarrett Wollman } 657ff49530fSBill Paul write_most(infile, netflag, nomain); 658ff49530fSBill Paul if (!nomain) { 659ff49530fSBill Paul if (!do_registers(argc, argv)) { 660ff49530fSBill Paul if (outfilename) 661ff49530fSBill Paul (void) unlink(outfilename); 662ff49530fSBill Paul usage(); 663ff49530fSBill Paul } 6644e115012SGarrett Wollman write_rest(); 6654e115012SGarrett Wollman } 6664e115012SGarrett Wollman } 6674e115012SGarrett Wollman 668ff49530fSBill Paul /* 669ff49530fSBill Paul * generate client side stubs 670ff49530fSBill Paul */ 671526195adSJordan K. Hubbard static void 672e390e3afSDavid Malone l_output(const char *infile, const char *define, int extend, const char *outfile) 6734e115012SGarrett Wollman { 6744e115012SGarrett Wollman char *include; 6754e115012SGarrett Wollman definition *def; 676ff49530fSBill Paul int foundprogram = 0; 677e390e3afSDavid Malone const char *outfilename; 6784e115012SGarrett Wollman 6794e115012SGarrett Wollman open_input(infile, define); 6804e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 6814e115012SGarrett Wollman open_output(infile, outfilename); 682ff49530fSBill Paul add_warning(); 6834f83fd19SStefan Farfeleder f_print (fout, "#include <string.h> /* for memset */\n"); 6844e115012SGarrett Wollman if (infile && (include = extendfile(infile, ".h"))) { 6854e115012SGarrett Wollman f_print(fout, "#include \"%s\"\n", include); 6864e115012SGarrett Wollman free(include); 687ff49530fSBill Paul } else 688ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 689526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 6904e115012SGarrett Wollman foundprogram |= (def->def_kind == DEF_PROGRAM); 6914e115012SGarrett Wollman } 6924e115012SGarrett Wollman if (extend && !foundprogram) { 6934e115012SGarrett Wollman (void) unlink(outfilename); 6944e115012SGarrett Wollman return; 6954e115012SGarrett Wollman } 6964e115012SGarrett Wollman write_stubs(); 6974e115012SGarrett Wollman } 6984e115012SGarrett Wollman 6994e115012SGarrett Wollman /* 700ff49530fSBill Paul * generate the dispatch table 7014e115012SGarrett Wollman */ 702526195adSJordan K. Hubbard static void 703e390e3afSDavid Malone t_output(const char *infile, const char *define, int extend, const char *outfile) 704ff49530fSBill Paul { 705ff49530fSBill Paul definition *def; 706ff49530fSBill Paul int foundprogram = 0; 707e390e3afSDavid Malone const char *outfilename; 708ff49530fSBill Paul 709ff49530fSBill Paul open_input(infile, define); 710ff49530fSBill Paul outfilename = extend ? extendfile(infile, outfile) : outfile; 711ff49530fSBill Paul open_output(infile, outfilename); 712ff49530fSBill Paul add_warning(); 713526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 714ff49530fSBill Paul foundprogram |= (def->def_kind == DEF_PROGRAM); 715ff49530fSBill Paul } 716ff49530fSBill Paul if (extend && !foundprogram) { 717ff49530fSBill Paul (void) unlink(outfilename); 718ff49530fSBill Paul return; 719ff49530fSBill Paul } 720ff49530fSBill Paul write_tables(); 721ff49530fSBill Paul } 722ff49530fSBill Paul 723ff49530fSBill Paul /* sample routine for the server template */ 724526195adSJordan K. Hubbard static void 725e390e3afSDavid Malone svc_output(const char *infile, const char *define, int extend, const char *outfile) 726ff49530fSBill Paul { 727ff49530fSBill Paul definition *def; 728ff49530fSBill Paul char *include; 729e390e3afSDavid Malone const char *outfilename; 730ff49530fSBill Paul long tell; 731ff49530fSBill Paul open_input(infile, define); 732ff49530fSBill Paul outfilename = extend ? extendfile(infile, outfile) : outfile; 733ff49530fSBill Paul checkfiles(infile, outfilename); 734ff49530fSBill Paul /* 735ff49530fSBill Paul * Check if outfile already exists. 736ff49530fSBill Paul * if so, print an error message and exit 737ff49530fSBill Paul */ 738ff49530fSBill Paul open_output(infile, outfilename); 739ff49530fSBill Paul add_sample_msg(); 740ff49530fSBill Paul 741ff49530fSBill Paul if (infile && (include = extendfile(infile, ".h"))) { 742ff49530fSBill Paul f_print(fout, "#include \"%s\"\n", include); 743ff49530fSBill Paul free(include); 744ff49530fSBill Paul } else 745ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 746ff49530fSBill Paul 747ff49530fSBill Paul tell = ftell(fout); 748526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 749ff49530fSBill Paul write_sample_svc(def); 750ff49530fSBill Paul } 751ff49530fSBill Paul if (extend && tell == ftell(fout)) { 752ff49530fSBill Paul (void) unlink(outfilename); 753ff49530fSBill Paul } 754ff49530fSBill Paul } 755ff49530fSBill Paul 756ff49530fSBill Paul /* sample main routine for client */ 757526195adSJordan K. Hubbard static void 758e390e3afSDavid Malone clnt_output(const char *infile, const char *define, int extend, const char *outfile) 759ff49530fSBill Paul { 760ff49530fSBill Paul definition *def; 761ff49530fSBill Paul char *include; 762e390e3afSDavid Malone const char *outfilename; 763ff49530fSBill Paul long tell; 764ff49530fSBill Paul int has_program = 0; 765ff49530fSBill Paul 766ff49530fSBill Paul open_input(infile, define); 767ff49530fSBill Paul outfilename = extend ? extendfile(infile, outfile) : outfile; 768ff49530fSBill Paul checkfiles(infile, outfilename); 769ff49530fSBill Paul /* 770ff49530fSBill Paul * Check if outfile already exists. 771ff49530fSBill Paul * if so, print an error message and exit 772ff49530fSBill Paul */ 773ff49530fSBill Paul 774ff49530fSBill Paul open_output(infile, outfilename); 775ff49530fSBill Paul add_sample_msg(); 776ff49530fSBill Paul if (infile && (include = extendfile(infile, ".h"))) { 777ff49530fSBill Paul f_print(fout, "#include \"%s\"\n", include); 778ff49530fSBill Paul free(include); 779ff49530fSBill Paul } else 780ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 781ff49530fSBill Paul tell = ftell(fout); 782526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 783ff49530fSBill Paul has_program += write_sample_clnt(def); 784ff49530fSBill Paul } 785ff49530fSBill Paul 786ff49530fSBill Paul if (has_program) 787ff49530fSBill Paul write_sample_clnt_main(); 788ff49530fSBill Paul 789ff49530fSBill Paul if (extend && tell == ftell(fout)) { 790ff49530fSBill Paul (void) unlink(outfilename); 791ff49530fSBill Paul } 792ff49530fSBill Paul } 793ff49530fSBill Paul 794ff49530fSBill Paul 795e390e3afSDavid Malone static void mkfile_output(struct commandline *cmd) 796ff49530fSBill Paul { 797e390e3afSDavid Malone const char *mkfilename, *clientname, *clntname, *xdrname, *hdrname; 798e390e3afSDavid Malone const char *servername, *svcname, *servprogname, *clntprogname; 799e390e3afSDavid Malone char *temp, *mkftemp; 800ff49530fSBill Paul 801ff49530fSBill Paul svcname = file_name(cmd->infile, "_svc.c"); 802ff49530fSBill Paul clntname = file_name(cmd->infile, "_clnt.c"); 803ff49530fSBill Paul xdrname = file_name(cmd->infile, "_xdr.c"); 804ff49530fSBill Paul hdrname = file_name(cmd->infile, ".h"); 805ff49530fSBill Paul 806ff49530fSBill Paul 807ff49530fSBill Paul if (allfiles){ 808ff49530fSBill Paul servername = extendfile(cmd->infile, "_server.c"); 809ff49530fSBill Paul clientname = extendfile(cmd->infile, "_client.c"); 810ff49530fSBill Paul }else{ 811ff49530fSBill Paul servername = " "; 812ff49530fSBill Paul clientname = " "; 813ff49530fSBill Paul } 814ff49530fSBill Paul servprogname = extendfile(cmd->infile, "_server"); 815ff49530fSBill Paul clntprogname = extendfile(cmd->infile, "_client"); 816ff49530fSBill Paul 817ff49530fSBill Paul if (allfiles){ 818e390e3afSDavid Malone mkftemp = xmalloc(strlen("makefile.") + 819ff49530fSBill Paul strlen(cmd->infile) + 1); 820*b3608ae1SEd Schouten temp = strrchr(cmd->infile, '.'); 821e390e3afSDavid Malone strcpy(mkftemp, "makefile."); 822e390e3afSDavid Malone (void) strncat(mkftemp, cmd->infile, 823ff49530fSBill Paul (temp - cmd->infile)); 824e390e3afSDavid Malone mkfilename = mkftemp; 825ff49530fSBill Paul } else 826ff49530fSBill Paul mkfilename = cmd->outfile; 827ff49530fSBill Paul 828ff49530fSBill Paul 829ff49530fSBill Paul checkfiles(NULL, mkfilename); 830ff49530fSBill Paul open_output(NULL, mkfilename); 831ff49530fSBill Paul 832ff49530fSBill Paul f_print(fout, "\n# This is a template makefile generated\ 833ff49530fSBill Paul by rpcgen \n"); 834ff49530fSBill Paul 835ff49530fSBill Paul f_print(fout, "\n# Parameters \n\n"); 836ff49530fSBill Paul 837ff49530fSBill Paul f_print(fout, "CLIENT = %s\nSERVER = %s\n\n", 838ff49530fSBill Paul clntprogname, servprogname); 839ff49530fSBill Paul f_print(fout, "SOURCES_CLNT.c = \nSOURCES_CLNT.h = \n"); 840ff49530fSBill Paul f_print(fout, "SOURCES_SVC.c = \nSOURCES_SVC.h = \n"); 841ff49530fSBill Paul f_print(fout, "SOURCES.x = %s\n\n", cmd->infile); 842ff49530fSBill Paul f_print(fout, "TARGETS_SVC.c = %s %s %s \n", 843ff49530fSBill Paul svcname, servername, xdrname); 844ff49530fSBill Paul f_print(fout, "TARGETS_CLNT.c = %s %s %s \n", 845ff49530fSBill Paul clntname, clientname, xdrname); 846ff49530fSBill Paul f_print(fout, "TARGETS = %s %s %s %s %s %s\n\n", 847ff49530fSBill Paul hdrname, xdrname, clntname, 848ff49530fSBill Paul svcname, clientname, servername); 849ff49530fSBill Paul 850ff49530fSBill Paul f_print(fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) \ 851ff49530fSBill Paul $(TARGETS_CLNT.c:%%.c=%%.o) "); 852ff49530fSBill Paul 853ff49530fSBill Paul f_print(fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) \ 854ff49530fSBill Paul $(TARGETS_SVC.c:%%.c=%%.o) "); 855ff49530fSBill Paul 856ff49530fSBill Paul 857ff49530fSBill Paul f_print(fout, "\n# Compiler flags \n"); 858ff49530fSBill Paul if (mtflag) 85940ad8885SAlfred Perlstein f_print(fout, "\nCFLAGS += -D_REENTRANT -D_THEAD_SAFE \nLDLIBS += -pthread\n"); 86040ad8885SAlfred Perlstein 861ff49530fSBill Paul f_print(fout, "RPCGENFLAGS = \n"); 862ff49530fSBill Paul 863ff49530fSBill Paul f_print(fout, "\n# Targets \n\n"); 864ff49530fSBill Paul 865ff49530fSBill Paul f_print(fout, "all : $(CLIENT) $(SERVER)\n\n"); 866ff49530fSBill Paul f_print(fout, "$(TARGETS) : $(SOURCES.x) \n"); 867ff49530fSBill Paul f_print(fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n"); 868ff49530fSBill Paul f_print(fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \ 869ff49530fSBill Paul $(TARGETS_CLNT.c) \n\n"); 870ff49530fSBill Paul 871ff49530fSBill Paul f_print(fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \ 872ff49530fSBill Paul $(TARGETS_SVC.c) \n\n"); 873ff49530fSBill Paul f_print(fout, "$(CLIENT) : $(OBJECTS_CLNT) \n"); 874ff49530fSBill Paul f_print(fout, "\t$(CC) -o $(CLIENT) $(OBJECTS_CLNT) \ 875ff49530fSBill Paul $(LDLIBS) \n\n"); 876ff49530fSBill Paul f_print(fout, "$(SERVER) : $(OBJECTS_SVC) \n"); 877ff49530fSBill Paul f_print(fout, "\t$(CC) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n "); 878ff49530fSBill Paul f_print(fout, "clean:\n\t $(RM) -f core $(TARGETS) $(OBJECTS_CLNT) \ 879ff49530fSBill Paul $(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n"); 880ff49530fSBill Paul } 881ff49530fSBill Paul 882ff49530fSBill Paul 883ff49530fSBill Paul 884ff49530fSBill Paul /* 885ff49530fSBill Paul * Perform registrations for service output 886ff49530fSBill Paul * Return 0 if failed; 1 otherwise. 887ff49530fSBill Paul */ 888526195adSJordan K. Hubbard static int 889e390e3afSDavid Malone do_registers(int argc, const char *argv[]) 8904e115012SGarrett Wollman { 8914e115012SGarrett Wollman int i; 8924e115012SGarrett Wollman 893ff49530fSBill Paul if (inetdflag || !tirpcflag) { 8944e115012SGarrett Wollman for (i = 1; i < argc; i++) { 8954e115012SGarrett Wollman if (streq(argv[i], "-s")) { 896ff49530fSBill Paul if (!check_nettype(argv[i + 1], 897ff49530fSBill Paul valid_i_nettypes)) 898ff49530fSBill Paul return (0); 899ff49530fSBill Paul write_inetd_register(argv[i + 1]); 9004e115012SGarrett Wollman i++; 9014e115012SGarrett Wollman } 9024e115012SGarrett Wollman } 903ff49530fSBill Paul } else { 904ff49530fSBill Paul for (i = 1; i < argc; i++) 905ff49530fSBill Paul if (streq(argv[i], "-s")) { 906ff49530fSBill Paul if (!check_nettype(argv[i + 1], 907ff49530fSBill Paul valid_ti_nettypes)) 908ff49530fSBill Paul return (0); 909ff49530fSBill Paul write_nettype_register(argv[i + 1]); 910ff49530fSBill Paul i++; 911ff49530fSBill Paul } else if (streq(argv[i], "-n")) { 912ff49530fSBill Paul write_netid_register(argv[i + 1]); 913ff49530fSBill Paul i++; 914ff49530fSBill Paul } 915ff49530fSBill Paul } 916ff49530fSBill Paul return (1); 917ff49530fSBill Paul } 918ff49530fSBill Paul 919ff49530fSBill Paul /* 920ff49530fSBill Paul * Add another argument to the arg list 921ff49530fSBill Paul */ 922ff49530fSBill Paul static void 923e390e3afSDavid Malone addarg(const char *cp) 924ff49530fSBill Paul { 925ff49530fSBill Paul if (argcount >= ARGLISTLEN) { 9260e76f40dSPhilippe Charnier warnx("too many defines"); 927ff49530fSBill Paul crash(); 928ff49530fSBill Paul /*NOTREACHED*/ 929ff49530fSBill Paul } 9308cb6926eSCraig Rodrigues if (cp != NULL) 9318cb6926eSCraig Rodrigues arglist[argcount++] = xstrdup(cp); 9328cb6926eSCraig Rodrigues else 9338cb6926eSCraig Rodrigues arglist[argcount++] = NULL; 934ff49530fSBill Paul 935ff49530fSBill Paul } 936ff49530fSBill Paul 937ff49530fSBill Paul static void 938e390e3afSDavid Malone putarg(int place, const char *cp) 939ff49530fSBill Paul { 940e390e3afSDavid Malone if (place >= ARGLISTLEN) { 9410e76f40dSPhilippe Charnier warnx("arglist coding error"); 942ff49530fSBill Paul crash(); 943ff49530fSBill Paul /*NOTREACHED*/ 944ff49530fSBill Paul } 9458cb6926eSCraig Rodrigues if (cp != NULL) 9468cb6926eSCraig Rodrigues arglist[place] = xstrdup(cp); 9478cb6926eSCraig Rodrigues else 9488cb6926eSCraig Rodrigues arglist[place] = NULL; 949ff49530fSBill Paul } 950ff49530fSBill Paul 951ff49530fSBill Paul /* 952ff49530fSBill Paul * if input file is stdin and an output file is specified then complain 953ff49530fSBill Paul * if the file already exists. Otherwise the file may get overwritten 954ff49530fSBill Paul * If input file does not exist, exit with an error 955ff49530fSBill Paul */ 956ff49530fSBill Paul 957ff49530fSBill Paul static void 958e390e3afSDavid Malone checkfiles(const char *infile, const char *outfile) 959ff49530fSBill Paul { 960ff49530fSBill Paul 961ff49530fSBill Paul struct stat buf; 962ff49530fSBill Paul 963ff49530fSBill Paul if (infile) /* infile ! = NULL */ 964ff49530fSBill Paul if (stat(infile, &buf) < 0) 965ff49530fSBill Paul { 9660e76f40dSPhilippe Charnier warn("%s", infile); 967ff49530fSBill Paul crash(); 968ff49530fSBill Paul }; 969ff49530fSBill Paul if (outfile) { 970ff49530fSBill Paul if (stat(outfile, &buf) < 0) 971ff49530fSBill Paul return; /* file does not exist */ 972ff49530fSBill Paul else { 9730e76f40dSPhilippe Charnier warnx("file '%s' already exists and may be overwritten", outfile); 974ff49530fSBill Paul crash(); 975ff49530fSBill Paul } 976ff49530fSBill Paul } 9774e115012SGarrett Wollman } 9784e115012SGarrett Wollman 9794e115012SGarrett Wollman /* 9804e115012SGarrett Wollman * Parse command line arguments 9814e115012SGarrett Wollman */ 982526195adSJordan K. Hubbard static int 983e390e3afSDavid Malone parseargs(int argc, const char *argv[], struct commandline *cmd) 9844e115012SGarrett Wollman { 9854e115012SGarrett Wollman int i; 9864e115012SGarrett Wollman int j; 987ff49530fSBill Paul char c, ch; 9884e115012SGarrett Wollman char flag[(1 << 8 * sizeof (char))]; 9894e115012SGarrett Wollman int nflags; 9904e115012SGarrett Wollman 9914e115012SGarrett Wollman cmd->infile = cmd->outfile = NULL; 9924e115012SGarrett Wollman if (argc < 2) { 9934e115012SGarrett Wollman return (0); 9944e115012SGarrett Wollman } 995ff49530fSBill Paul allfiles = 0; 9964e115012SGarrett Wollman flag['c'] = 0; 9974e115012SGarrett Wollman flag['h'] = 0; 9984e115012SGarrett Wollman flag['l'] = 0; 9994e115012SGarrett Wollman flag['m'] = 0; 1000ff49530fSBill Paul flag['o'] = 0; 1001ff49530fSBill Paul flag['s'] = 0; 1002ff49530fSBill Paul flag['n'] = 0; 1003ff49530fSBill Paul flag['t'] = 0; 1004ff49530fSBill Paul flag['S'] = 0; 1005ff49530fSBill Paul flag['C'] = 0; 1006ff49530fSBill Paul flag['M'] = 0; 1007ff49530fSBill Paul 10084e115012SGarrett Wollman for (i = 1; i < argc; i++) { 10094e115012SGarrett Wollman if (argv[i][0] != '-') { 10104e115012SGarrett Wollman if (cmd->infile) { 10110e76f40dSPhilippe Charnier warnx("cannot specify more than one input file"); 10124e115012SGarrett Wollman return (0); 10134e115012SGarrett Wollman } 10144e115012SGarrett Wollman cmd->infile = argv[i]; 10154e115012SGarrett Wollman } else { 10164e115012SGarrett Wollman for (j = 1; argv[i][j] != 0; j++) { 10174e115012SGarrett Wollman c = argv[i][j]; 10184e115012SGarrett Wollman switch (c) { 1019ff49530fSBill Paul case 'a': 1020ff49530fSBill Paul allfiles = 1; 1021ff49530fSBill Paul break; 10224e115012SGarrett Wollman case 'c': 10234e115012SGarrett Wollman case 'h': 10244e115012SGarrett Wollman case 'l': 10254e115012SGarrett Wollman case 'm': 1026ff49530fSBill Paul case 't': 1027526195adSJordan K. Hubbard if (flag[(int)c]) { 10284e115012SGarrett Wollman return (0); 10294e115012SGarrett Wollman } 1030526195adSJordan K. Hubbard flag[(int)c] = 1; 10314e115012SGarrett Wollman break; 1032ff49530fSBill Paul case 'S': 1033ff49530fSBill Paul /* 1034ff49530fSBill Paul * sample flag: Ss or Sc. 1035ff49530fSBill Paul * Ss means set flag['S']; 1036ff49530fSBill Paul * Sc means set flag['C']; 1037ff49530fSBill Paul * Sm means set flag['M']; 1038ff49530fSBill Paul */ 1039ff49530fSBill Paul ch = argv[i][++j]; /* get next char */ 1040ff49530fSBill Paul if (ch == 's') 1041ff49530fSBill Paul ch = 'S'; 1042ff49530fSBill Paul else if (ch == 'c') 1043ff49530fSBill Paul ch = 'C'; 1044ff49530fSBill Paul else if (ch == 'm') 1045ff49530fSBill Paul ch = 'M'; 1046ff49530fSBill Paul else 1047ff49530fSBill Paul return (0); 1048ff49530fSBill Paul 1049526195adSJordan K. Hubbard if (flag[(int)ch]) { 1050ff49530fSBill Paul return (0); 1051ff49530fSBill Paul } 1052526195adSJordan K. Hubbard flag[(int)ch] = 1; 1053ff49530fSBill Paul break; 1054ff49530fSBill Paul case 'C': /* ANSI C syntax */ 1055ff49530fSBill Paul ch = argv[i][j+1]; /* get next char */ 1056ff49530fSBill Paul 1057ff49530fSBill Paul if (ch != 'C') 1058ff49530fSBill Paul break; 1059ff49530fSBill Paul CCflag = 1; 1060ff49530fSBill Paul break; 1061ff49530fSBill Paul case 'b': 1062ff49530fSBill Paul /* 1063ff49530fSBill Paul * Turn TIRPC flag off for 1064ff49530fSBill Paul * generating backward compatible 1065ff49530fSBill Paul * code 1066ff49530fSBill Paul */ 1067ff49530fSBill Paul tirpcflag = 0; 1068ff49530fSBill Paul break; 1069ff49530fSBill Paul 1070ff49530fSBill Paul case 'I': 1071ff49530fSBill Paul inetdflag = 1; 1072ff49530fSBill Paul break; 1073ff49530fSBill Paul case 'N': 1074ff49530fSBill Paul newstyle = 1; 1075ff49530fSBill Paul break; 1076ff49530fSBill Paul case 'L': 1077ff49530fSBill Paul logflag = 1; 1078ff49530fSBill Paul break; 107940ad8885SAlfred Perlstein case 'P': 108040ad8885SAlfred Perlstein pmflag = 1; 108140ad8885SAlfred Perlstein break; 1082ff49530fSBill Paul case 'K': 1083ff49530fSBill Paul if (++i == argc) { 1084ff49530fSBill Paul return (0); 1085ff49530fSBill Paul } 1086ff49530fSBill Paul svcclosetime = argv[i]; 1087ff49530fSBill Paul goto nextarg; 1088ff49530fSBill Paul case 'T': 1089ff49530fSBill Paul tblflag = 1; 1090ff49530fSBill Paul break; 1091ff49530fSBill Paul case 'M': 1092ff49530fSBill Paul mtflag = 1; 1093ff49530fSBill Paul break; 1094ff49530fSBill Paul case 'i' : 1095ff49530fSBill Paul if (++i == argc) { 1096ff49530fSBill Paul return (0); 1097ff49530fSBill Paul } 1098122562cdSStefan Farfeleder inline_size = atoi(argv[i]); 1099ff49530fSBill Paul goto nextarg; 1100ff49530fSBill Paul case 'n': 11014e115012SGarrett Wollman case 'o': 11024e115012SGarrett Wollman case 's': 11034e115012SGarrett Wollman if (argv[i][j - 1] != '-' || 11044e115012SGarrett Wollman argv[i][j + 1] != 0) { 11054e115012SGarrett Wollman return (0); 11064e115012SGarrett Wollman } 1107526195adSJordan K. Hubbard flag[(int)c] = 1; 11084e115012SGarrett Wollman if (++i == argc) { 11094e115012SGarrett Wollman return (0); 11104e115012SGarrett Wollman } 1111ff49530fSBill Paul if (c == 'o') { 11124e115012SGarrett Wollman if (cmd->outfile) { 11134e115012SGarrett Wollman return (0); 11144e115012SGarrett Wollman } 11154e115012SGarrett Wollman cmd->outfile = argv[i]; 11164e115012SGarrett Wollman } 11174e115012SGarrett Wollman goto nextarg; 1118ff49530fSBill Paul case 'D': 1119ff49530fSBill Paul if (argv[i][j - 1] != '-') { 1120ff49530fSBill Paul return (0); 1121ff49530fSBill Paul } 1122ff49530fSBill Paul (void) addarg(argv[i]); 1123ff49530fSBill Paul goto nextarg; 1124ff49530fSBill Paul case 'Y': 1125ff49530fSBill Paul if (++i == argc) { 1126ff49530fSBill Paul return (0); 1127ff49530fSBill Paul } 1128a0b13740SKris Kennaway (void) strlcpy(pathbuf, argv[i], sizeof(pathbuf)); 1129a0b13740SKris Kennaway if (strlcat(pathbuf, "/cpp", sizeof(pathbuf)) 1130a0b13740SKris Kennaway >= sizeof(pathbuf)) { 1131a0b13740SKris Kennaway warnx("argument too long"); 1132a0b13740SKris Kennaway return (0); 1133a0b13740SKris Kennaway } 1134ff49530fSBill Paul CPP = pathbuf; 1135ff49530fSBill Paul cppDefined = 1; 1136ff49530fSBill Paul goto nextarg; 1137ff49530fSBill Paul 1138ff49530fSBill Paul 11394e115012SGarrett Wollman 11404e115012SGarrett Wollman default: 11414e115012SGarrett Wollman return (0); 11424e115012SGarrett Wollman } 11434e115012SGarrett Wollman } 11444e115012SGarrett Wollman nextarg: 11454e115012SGarrett Wollman ; 11464e115012SGarrett Wollman } 11474e115012SGarrett Wollman } 1148ff49530fSBill Paul 11494e115012SGarrett Wollman cmd->cflag = flag['c']; 11504e115012SGarrett Wollman cmd->hflag = flag['h']; 11514e115012SGarrett Wollman cmd->lflag = flag['l']; 11524e115012SGarrett Wollman cmd->mflag = flag['m']; 1153ff49530fSBill Paul cmd->nflag = flag['n']; 1154ff49530fSBill Paul cmd->sflag = flag['s']; 1155ff49530fSBill Paul cmd->tflag = flag['t']; 1156ff49530fSBill Paul cmd->Ssflag = flag['S']; 1157ff49530fSBill Paul cmd->Scflag = flag['C']; 1158ff49530fSBill Paul cmd->makefileflag = flag['M']; 1159ff49530fSBill Paul 1160ff49530fSBill Paul if (tirpcflag) { 116140ad8885SAlfred Perlstein if (inetdflag) 116240ad8885SAlfred Perlstein pmflag = 0; 1163ff49530fSBill Paul if ((inetdflag && cmd->nflag)) { 1164ff49530fSBill Paul /* netid not allowed with inetdflag */ 11650e76f40dSPhilippe Charnier warnx("cannot use netid flag with inetd flag"); 1166ff49530fSBill Paul return (0); 1167ff49530fSBill Paul } 1168ff49530fSBill Paul } else { /* 4.1 mode */ 1169ff49530fSBill Paul pmflag = 0; /* set pmflag only in tirpcmode */ 1170ff49530fSBill Paul if (cmd->nflag) { /* netid needs TIRPC */ 11710e76f40dSPhilippe Charnier warnx("cannot use netid flag without TIRPC"); 1172ff49530fSBill Paul return (0); 1173ff49530fSBill Paul } 1174ff49530fSBill Paul } 1175ff49530fSBill Paul 1176ff49530fSBill Paul if (newstyle && (tblflag || cmd->tflag)) { 11770e76f40dSPhilippe Charnier warnx("cannot use table flags with newstyle"); 1178ff49530fSBill Paul return (0); 1179ff49530fSBill Paul } 1180ff49530fSBill Paul 1181ff49530fSBill Paul /* check no conflicts with file generation flags */ 1182ff49530fSBill Paul nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag + 1183ff49530fSBill Paul cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + 1184ff49530fSBill Paul cmd->Scflag + cmd->makefileflag; 1185ff49530fSBill Paul 11864e115012SGarrett Wollman if (nflags == 0) { 11874e115012SGarrett Wollman if (cmd->outfile != NULL || cmd->infile == NULL) { 11884e115012SGarrett Wollman return (0); 11894e115012SGarrett Wollman } 1190ff49530fSBill Paul } else if (cmd->infile == NULL && 1191ff49530fSBill Paul (cmd->Ssflag || cmd->Scflag || cmd->makefileflag)) { 11920e76f40dSPhilippe Charnier warnx("\"infile\" is required for template generation flags"); 1193ff49530fSBill Paul return (0); 1194ff49530fSBill Paul } if (nflags > 1) { 11950e76f40dSPhilippe Charnier warnx("cannot have more than one file generation flag"); 11964e115012SGarrett Wollman return (0); 11974e115012SGarrett Wollman } 11984e115012SGarrett Wollman return (1); 11994e115012SGarrett Wollman } 1200ff49530fSBill Paul 1201526195adSJordan K. Hubbard static void 1202ef636796SEd Schouten usage(void) 1203ff49530fSBill Paul { 12040e76f40dSPhilippe Charnier f_print(stderr, "%s\n%s\n%s\n%s\n%s\n", 12050e76f40dSPhilippe Charnier "usage: rpcgen infile", 12060e76f40dSPhilippe Charnier " rpcgen [-abCLNTM] [-Dname[=value]] [-i size]\ 120740ad8885SAlfred Perlstein [-I -P [-K seconds]] [-Y path] infile", 12080e76f40dSPhilippe Charnier " rpcgen [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm]\ 12090e76f40dSPhilippe Charnier [-o outfile] [infile]", 12100e76f40dSPhilippe Charnier " rpcgen [-s nettype]* [-o outfile] [infile]", 12110e76f40dSPhilippe Charnier " rpcgen [-n netid]* [-o outfile] [infile]"); 1212ff49530fSBill Paul options_usage(); 1213ff49530fSBill Paul exit(1); 1214ff49530fSBill Paul } 1215ff49530fSBill Paul 1216526195adSJordan K. Hubbard static void 1217ef636796SEd Schouten options_usage(void) 1218ff49530fSBill Paul { 1219ff49530fSBill Paul f_print(stderr, "options:\n"); 1220ff49530fSBill Paul f_print(stderr, "-a\t\tgenerate all files, including samples\n"); 1221ff49530fSBill Paul f_print(stderr, "-b\t\tbackward compatibility mode (generates code \ 122240ad8885SAlfred Perlstein for FreeBSD 4.X)\n"); 1223ff49530fSBill Paul f_print(stderr, "-c\t\tgenerate XDR routines\n"); 1224ff49530fSBill Paul f_print(stderr, "-C\t\tANSI C mode\n"); 1225ff49530fSBill Paul f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n"); 1226ff49530fSBill Paul f_print(stderr, "-h\t\tgenerate header file\n"); 1227ff49530fSBill Paul f_print(stderr, "-i size\t\tsize at which to start generating\ 1228ff49530fSBill Paul inline code\n"); 122940ad8885SAlfred Perlstein f_print(stderr, "-I\t\tgenerate code for inetd support in server\n"); 1230ff49530fSBill Paul f_print(stderr, "-K seconds\tserver exits after K seconds of\ 1231ff49530fSBill Paul inactivity\n"); 1232ff49530fSBill Paul f_print(stderr, "-l\t\tgenerate client side stubs\n"); 1233ff49530fSBill Paul f_print(stderr, "-L\t\tserver errors will be printed to syslog\n"); 1234ff49530fSBill Paul f_print(stderr, "-m\t\tgenerate server side stubs\n"); 1235ff49530fSBill Paul f_print(stderr, "-M\t\tgenerate MT-safe code\n"); 1236ff49530fSBill Paul f_print(stderr, "-n netid\tgenerate server code that supports\ 1237ff49530fSBill Paul named netid\n"); 1238ff49530fSBill Paul f_print(stderr, "-N\t\tsupports multiple arguments and\ 1239ff49530fSBill Paul call-by-value\n"); 1240ff49530fSBill Paul f_print(stderr, "-o outfile\tname of the output file\n"); 124140ad8885SAlfred Perlstein f_print(stderr, "-P\t\tgenerate code for port monitoring support in server\n"); 1242ff49530fSBill Paul f_print(stderr, "-s nettype\tgenerate server code that supports named\ 1243ff49530fSBill Paul nettype\n"); 1244ff49530fSBill Paul f_print(stderr, "-Sc\t\tgenerate sample client code that uses remote\ 1245ff49530fSBill Paul procedures\n"); 1246ff49530fSBill Paul f_print(stderr, "-Ss\t\tgenerate sample server code that defines\ 1247ff49530fSBill Paul remote procedures\n"); 1248ff49530fSBill Paul f_print(stderr, "-Sm \t\tgenerate makefile template \n"); 1249ff49530fSBill Paul 1250ff49530fSBill Paul f_print(stderr, "-t\t\tgenerate RPC dispatch table\n"); 1251ff49530fSBill Paul f_print(stderr, "-T\t\tgenerate code to support RPC dispatch tables\n"); 1252ff49530fSBill Paul f_print(stderr, "-Y path\t\tpath where cpp is found\n"); 1253ff49530fSBill Paul exit(1); 1254ff49530fSBill Paul } 1255