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 67d7c089b7SJohn Birrell #if !defined(__FreeBSD__) && !defined(__NetBSD__) 68ff49530fSBill Paul char * rindex(); 69ff49530fSBill Paul #endif 70ff49530fSBill Paul 71d3cb5dedSWarner Losh static void usage(void); 72d3cb5dedSWarner Losh static void options_usage(void); 73e390e3afSDavid Malone static int do_registers(int, const char **); 74e390e3afSDavid Malone static int parseargs(int, const char **, struct commandline *); 75e390e3afSDavid Malone static void svc_output(const char *, const char *, int, const char *); 76d3cb5dedSWarner Losh static void mkfile_output(struct commandline *); 77e390e3afSDavid Malone static void s_output(int, const char **, const char *, const char *, int, const char *, int, int); 78ff49530fSBill Paul 79ff49530fSBill Paul #define EXTEND 1 /* alias for TRUE */ 80ff49530fSBill Paul #define DONT_EXTEND 0 /* alias for FALSE */ 81ff49530fSBill Paul 82ff49530fSBill Paul #define SVR4_CPP "/usr/ccs/lib/cpp" 83d7c089b7SJohn Birrell #define SUNOS_CPP "/usr/bin/cpp" 84ff49530fSBill Paul 85ff49530fSBill Paul static int cppDefined = 0; /* explicit path for C preprocessor */ 86ff49530fSBill Paul 87e390e3afSDavid Malone static const char *svcclosetime = "120"; 88e390e3afSDavid Malone static const char *CPP = SVR4_CPP; 89e390e3afSDavid Malone static const char CPPFLAGS[] = "-C"; 90ff49530fSBill Paul static char pathbuf[MAXPATHLEN + 1]; 91e390e3afSDavid Malone static const char *allv[] = { 924e115012SGarrett Wollman "rpcgen", "-s", "udp", "-s", "tcp", 934e115012SGarrett Wollman }; 944e115012SGarrett Wollman static int allc = sizeof (allv)/sizeof (allv[0]); 95e390e3afSDavid Malone static const char *allnv[] = { 96ff49530fSBill Paul "rpcgen", "-s", "netpath", 97ff49530fSBill Paul }; 98ff49530fSBill Paul static int allnc = sizeof (allnv)/sizeof (allnv[0]); 99ff49530fSBill Paul 100ff49530fSBill Paul /* 101ff49530fSBill Paul * machinations for handling expanding argument list 102ff49530fSBill Paul */ 103e390e3afSDavid Malone static void addarg(const char *); /* add another argument to the list */ 104e390e3afSDavid Malone static void putarg(int, const char *); /* put argument at specified location */ 105e390e3afSDavid Malone static void clear_args(void); /* clear argument list */ 106e390e3afSDavid Malone static void checkfiles(const char *, const char *); 107e390e3afSDavid Malone /* check if out file already exists */ 1084e115012SGarrett Wollman 1094e115012SGarrett Wollman 110ff49530fSBill Paul 111ff49530fSBill Paul #define ARGLISTLEN 20 112ff49530fSBill Paul #define FIXEDARGS 2 113ff49530fSBill Paul 114e390e3afSDavid Malone static const char *arglist[ARGLISTLEN]; 115ff49530fSBill Paul static int argcount = FIXEDARGS; 116ff49530fSBill Paul 117ff49530fSBill Paul 118ff49530fSBill Paul int nonfatalerrors; /* errors */ 11940ad8885SAlfred Perlstein int inetdflag = 0; /* Support for inetd is disabled by default, use -I */ 12040ad8885SAlfred Perlstein int pmflag = 0; /* Support for port monitors is disabled by default */ 12140ad8885SAlfred Perlstein int tirpc_socket = 1; /* TI-RPC on socket, no TLI library */ 122ff49530fSBill Paul int logflag; /* Use syslog instead of fprintf for errors */ 123ff49530fSBill Paul int tblflag; /* Support for dispatch table file */ 124ff49530fSBill Paul int mtflag = 0; /* Support for MT */ 12540ad8885SAlfred Perlstein 126ff49530fSBill Paul #define INLINE 0 127ff49530fSBill Paul /* length at which to start doing an inline */ 128ff49530fSBill Paul 129122562cdSStefan Farfeleder int inline_size = INLINE; 130ff49530fSBill Paul /* 131ff49530fSBill Paul * Length at which to start doing an inline. INLINE = default 132ff49530fSBill Paul * if 0, no xdr_inline code 133ff49530fSBill Paul */ 134ff49530fSBill Paul 135ff49530fSBill Paul int indefinitewait; /* If started by port monitors, hang till it wants */ 136ff49530fSBill Paul int exitnow; /* If started by port monitors, exit after the call */ 137ff49530fSBill Paul int timerflag; /* TRUE if !indefinite && !exitnow */ 138ff49530fSBill Paul int newstyle; /* newstyle of passing arguments (by value) */ 139ff49530fSBill Paul int CCflag = 0; /* C++ files */ 140ff49530fSBill Paul static int allfiles; /* generate all files */ 141ff49530fSBill Paul int tirpcflag = 1; /* generating code for tirpc, by default */ 142ff49530fSBill Paul xdrfunc *xdrfunc_head = NULL; /* xdr function list */ 143ff49530fSBill Paul xdrfunc *xdrfunc_tail = NULL; /* xdr function list */ 144ff49530fSBill Paul pid_t childpid; 145ff49530fSBill Paul 1464e115012SGarrett Wollman 147526195adSJordan K. Hubbard int 148e390e3afSDavid Malone main(int argc, const char *argv[]) 1494e115012SGarrett Wollman { 1504e115012SGarrett Wollman struct commandline cmd; 1514e115012SGarrett Wollman 152ff49530fSBill Paul (void) memset((char *)&cmd, 0, sizeof (struct commandline)); 153ff49530fSBill Paul clear_args(); 154ff49530fSBill Paul if (!parseargs(argc, argv, &cmd)) 155ff49530fSBill Paul usage(); 156ff49530fSBill Paul /* 157ff49530fSBill Paul * Only the client and server side stubs are likely to be customized, 158ff49530fSBill Paul * so in that case only, check if the outfile exists, and if so, 159ff49530fSBill Paul * print an error message and exit. 160ff49530fSBill Paul */ 161ff49530fSBill Paul if (cmd.Ssflag || cmd.Scflag || cmd.makefileflag) { 162ff49530fSBill Paul checkfiles(cmd.infile, cmd.outfile); 1634e115012SGarrett Wollman } 164ff49530fSBill Paul else 165ff49530fSBill Paul checkfiles(cmd.infile, NULL); 166ff49530fSBill Paul 1674e115012SGarrett Wollman if (cmd.cflag) { 168ff49530fSBill Paul c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile); 1694e115012SGarrett Wollman } else if (cmd.hflag) { 170ec06b5e8SStefan Farfeleder h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile, 171ec06b5e8SStefan Farfeleder cmd.hflag); 1724e115012SGarrett Wollman } else if (cmd.lflag) { 173ff49530fSBill Paul l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile); 174ff49530fSBill Paul } else if (cmd.sflag || cmd.mflag || (cmd.nflag)) { 175ff49530fSBill Paul s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND, 176ff49530fSBill Paul cmd.outfile, cmd.mflag, cmd.nflag); 177ff49530fSBill Paul } else if (cmd.tflag) { 178ff49530fSBill Paul t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile); 179ff49530fSBill Paul } else if (cmd.Ssflag) { 180ff49530fSBill Paul svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, 181ff49530fSBill Paul cmd.outfile); 182ff49530fSBill Paul } else if (cmd.Scflag) { 183ff49530fSBill Paul clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, 184ff49530fSBill Paul cmd.outfile); 185ff49530fSBill Paul } else if (cmd.makefileflag) { 186ff49530fSBill Paul mkfile_output(&cmd); 1874e115012SGarrett Wollman } else { 188ff49530fSBill Paul /* the rescans are required, since cpp may effect input */ 1894e115012SGarrett Wollman c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c"); 1904e115012SGarrett Wollman reinitialize(); 191ec06b5e8SStefan Farfeleder h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h", cmd.hflag); 1924e115012SGarrett Wollman reinitialize(); 1934e115012SGarrett Wollman l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c"); 1944e115012SGarrett Wollman reinitialize(); 195ff49530fSBill Paul if (inetdflag || !tirpcflag) 1964e115012SGarrett Wollman s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND, 197ff49530fSBill Paul "_svc.c", cmd.mflag, cmd.nflag); 198ff49530fSBill Paul else 199ff49530fSBill Paul s_output(allnc, allnv, cmd.infile, "-DRPC_SVC", 200ff49530fSBill Paul EXTEND, "_svc.c", cmd.mflag, cmd.nflag); 201ff49530fSBill Paul if (tblflag) { 202ff49530fSBill Paul reinitialize(); 203ff49530fSBill Paul t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i"); 2044e115012SGarrett Wollman } 2054e115012SGarrett Wollman 206ff49530fSBill Paul if (allfiles) { 207ff49530fSBill Paul reinitialize(); 208ff49530fSBill Paul svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, 209ff49530fSBill Paul "_server.c"); 210ff49530fSBill Paul reinitialize(); 211ff49530fSBill Paul clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, 212ff49530fSBill Paul "_client.c"); 213ff49530fSBill Paul 214ff49530fSBill Paul } 215ff49530fSBill Paul if (allfiles || (cmd.makefileflag == 1)){ 216ff49530fSBill Paul reinitialize(); 217ff49530fSBill Paul mkfile_output(&cmd); 218ff49530fSBill Paul } 219ff49530fSBill Paul 220ff49530fSBill Paul } 221ff49530fSBill Paul exit(nonfatalerrors); 222ff49530fSBill Paul /* NOTREACHED */ 223ff49530fSBill Paul } 224ff49530fSBill Paul 225ff49530fSBill Paul 2264e115012SGarrett Wollman /* 227ff49530fSBill Paul * add extension to filename 2284e115012SGarrett Wollman */ 2294e115012SGarrett Wollman static char * 230e390e3afSDavid Malone extendfile(const char *path, const char *ext) 2314e115012SGarrett Wollman { 2324e115012SGarrett Wollman char *res; 233e390e3afSDavid Malone const char *p; 234e390e3afSDavid Malone const char *file; 2354e115012SGarrett Wollman 2365ec07232SNate Williams if ((file = rindex(path, '/')) == NULL) 2375ec07232SNate Williams file = path; 2385ec07232SNate Williams else 2395ec07232SNate Williams file++; 24075863a6dSPhilippe Charnier res = xmalloc(strlen(file) + strlen(ext) + 1); 241ff49530fSBill Paul p = strrchr(file, '.'); 2424e115012SGarrett Wollman if (p == NULL) { 2434e115012SGarrett Wollman p = file + strlen(file); 2444e115012SGarrett Wollman } 2454e115012SGarrett Wollman (void) strcpy(res, file); 2464e115012SGarrett Wollman (void) strcpy(res + (p - file), ext); 2474e115012SGarrett Wollman return (res); 2484e115012SGarrett Wollman } 2494e115012SGarrett Wollman 2504e115012SGarrett Wollman /* 2514e115012SGarrett Wollman * Open output file with given extension 2524e115012SGarrett Wollman */ 253526195adSJordan K. Hubbard static void 254e390e3afSDavid Malone open_output(const char *infile, const char *outfile) 2554e115012SGarrett Wollman { 256ff49530fSBill Paul 2574e115012SGarrett Wollman if (outfile == NULL) { 2584e115012SGarrett Wollman fout = stdout; 2594e115012SGarrett Wollman return; 2604e115012SGarrett Wollman } 261ff49530fSBill Paul 2624e115012SGarrett Wollman if (infile != NULL && streq(outfile, infile)) { 2630e76f40dSPhilippe Charnier warnx("%s already exists. No output generated", infile); 2644e115012SGarrett Wollman crash(); 2654e115012SGarrett Wollman } 2664e115012SGarrett Wollman fout = fopen(outfile, "w"); 2674e115012SGarrett Wollman if (fout == NULL) { 2680e76f40dSPhilippe Charnier warn("unable to open %s", outfile); 2694e115012SGarrett Wollman crash(); 2704e115012SGarrett Wollman } 2714e115012SGarrett Wollman record_open(outfile); 272ff49530fSBill Paul 273526195adSJordan K. Hubbard return; 274ff49530fSBill Paul } 275ff49530fSBill Paul 276526195adSJordan K. Hubbard static void 277e390e3afSDavid Malone add_warning(void) 278ff49530fSBill Paul { 279ff49530fSBill Paul f_print(fout, "/*\n"); 280ff49530fSBill Paul f_print(fout, " * Please do not edit this file.\n"); 281ff49530fSBill Paul f_print(fout, " * It was generated using rpcgen.\n"); 282ff49530fSBill Paul f_print(fout, " */\n\n"); 283ff49530fSBill Paul } 284ff49530fSBill Paul 285ff49530fSBill Paul /* clear list of arguments */ 286e390e3afSDavid Malone static void 287e390e3afSDavid Malone clear_args(void) 288ff49530fSBill Paul { 289ff49530fSBill Paul int i; 290ff49530fSBill Paul for (i = FIXEDARGS; i < ARGLISTLEN; i++) 291ff49530fSBill Paul arglist[i] = NULL; 292ff49530fSBill Paul argcount = FIXEDARGS; 293ff49530fSBill Paul } 294ff49530fSBill Paul 295ff49530fSBill Paul /* make sure that a CPP exists */ 296e390e3afSDavid Malone static void 297e390e3afSDavid Malone find_cpp(void) 298ff49530fSBill Paul { 299ff49530fSBill Paul struct stat buf; 300ff49530fSBill Paul 301ff49530fSBill Paul if (stat(CPP, &buf) < 0) { /* SVR4 or explicit cpp does not exist */ 302ff49530fSBill Paul if (cppDefined) { 3030e76f40dSPhilippe Charnier warnx("cannot find C preprocessor: %s", CPP); 304ff49530fSBill Paul crash(); 305ff49530fSBill Paul } else { /* try the other one */ 306ff49530fSBill Paul CPP = SUNOS_CPP; 307ff49530fSBill Paul if (stat(CPP, &buf) < 0) { /* can't find any cpp */ 308f2912673SDavid E. O'Brien warnx("cannot find C preprocessor: %s", CPP); 309ff49530fSBill Paul crash(); 310ff49530fSBill Paul } 311ff49530fSBill Paul } 312ff49530fSBill Paul } 3134e115012SGarrett Wollman } 3144e115012SGarrett Wollman 3154e115012SGarrett Wollman /* 3164e115012SGarrett Wollman * Open input file with given define for C-preprocessor 3174e115012SGarrett Wollman */ 318526195adSJordan K. Hubbard static void 319e390e3afSDavid Malone open_input(const char *infile, const char *define) 3204e115012SGarrett Wollman { 3214e115012SGarrett Wollman int pd[2]; 3224e115012SGarrett Wollman 3234e115012SGarrett Wollman infilename = (infile == NULL) ? "<stdin>" : infile; 3244e115012SGarrett Wollman (void) pipe(pd); 325ff49530fSBill Paul switch (childpid = fork()) { 3264e115012SGarrett Wollman case 0: 327ff49530fSBill Paul find_cpp(); 328ff49530fSBill Paul putarg(0, CPP); 329ff49530fSBill Paul putarg(1, CPPFLAGS); 330ff49530fSBill Paul addarg(define); 331ff49530fSBill Paul if (infile) 332ff49530fSBill Paul addarg(infile); 333ff49530fSBill Paul addarg((char *)NULL); 3344e115012SGarrett Wollman (void) close(1); 3354e115012SGarrett Wollman (void) dup2(pd[1], 1); 3364e115012SGarrett Wollman (void) close(pd[0]); 337ff49530fSBill Paul execv(arglist[0], arglist); 33875863a6dSPhilippe Charnier err(1, "execv"); 3394e115012SGarrett Wollman case -1: 34075863a6dSPhilippe Charnier err(1, "fork"); 3414e115012SGarrett Wollman } 3424e115012SGarrett Wollman (void) close(pd[1]); 3434e115012SGarrett Wollman fin = fdopen(pd[0], "r"); 3444e115012SGarrett Wollman if (fin == NULL) { 3450e76f40dSPhilippe Charnier warn("%s", infilename); 3464e115012SGarrett Wollman crash(); 3474e115012SGarrett Wollman } 3484e115012SGarrett Wollman } 3494e115012SGarrett Wollman 350ff49530fSBill Paul /* valid tirpc nettypes */ 351e390e3afSDavid Malone static const char *valid_ti_nettypes[] = 352ff49530fSBill Paul { 353ff49530fSBill Paul "netpath", 354ff49530fSBill Paul "visible", 355ff49530fSBill Paul "circuit_v", 356ff49530fSBill Paul "datagram_v", 357ff49530fSBill Paul "circuit_n", 358ff49530fSBill Paul "datagram_n", 359ff49530fSBill Paul "udp", 360ff49530fSBill Paul "tcp", 361ff49530fSBill Paul "raw", 362ff49530fSBill Paul NULL 363ff49530fSBill Paul }; 364ff49530fSBill Paul 365ff49530fSBill Paul /* valid inetd nettypes */ 366e390e3afSDavid Malone static const char *valid_i_nettypes[] = 367ff49530fSBill Paul { 368ff49530fSBill Paul "udp", 369ff49530fSBill Paul "tcp", 370ff49530fSBill Paul NULL 371ff49530fSBill Paul }; 372ff49530fSBill Paul 373e390e3afSDavid Malone static int 374e390e3afSDavid Malone check_nettype(const char *name, const char *list_to_check[]) 375ff49530fSBill Paul { 376ff49530fSBill Paul int i; 377ff49530fSBill Paul for (i = 0; list_to_check[i] != NULL; i++) { 378ff49530fSBill Paul if (strcmp(name, list_to_check[i]) == 0) { 379ff49530fSBill Paul return (1); 380ff49530fSBill Paul } 381ff49530fSBill Paul } 3820e76f40dSPhilippe Charnier warnx("illegal nettype :\'%s\'", name); 383ff49530fSBill Paul return (0); 384ff49530fSBill Paul } 385ff49530fSBill Paul 386e390e3afSDavid Malone static const char * 387e390e3afSDavid Malone file_name(const char *file, const char *ext) 388ff49530fSBill Paul { 389ff49530fSBill Paul char *temp; 390ff49530fSBill Paul temp = extendfile(file, ext); 391ff49530fSBill Paul 392ff49530fSBill Paul if (access(temp, F_OK) != -1) 393ff49530fSBill Paul return (temp); 394ff49530fSBill Paul else 395e390e3afSDavid Malone return (" "); 396ff49530fSBill Paul 397ff49530fSBill Paul } 398ff49530fSBill Paul 399ff49530fSBill Paul 400526195adSJordan K. Hubbard static void 401e390e3afSDavid Malone c_output(const char *infile, const char *define, int extend, const char *outfile) 4024e115012SGarrett Wollman { 4034e115012SGarrett Wollman definition *def; 4044e115012SGarrett Wollman char *include; 405e390e3afSDavid Malone const char *outfilename; 4064e115012SGarrett Wollman long tell; 4074e115012SGarrett Wollman 408ff49530fSBill Paul c_initialize(); 4094e115012SGarrett Wollman open_input(infile, define); 4104e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 4114e115012SGarrett Wollman open_output(infile, outfilename); 412ff49530fSBill Paul add_warning(); 4134e115012SGarrett Wollman if (infile && (include = extendfile(infile, ".h"))) { 4144e115012SGarrett Wollman f_print(fout, "#include \"%s\"\n", include); 4154e115012SGarrett Wollman free(include); 416ff49530fSBill Paul /* .h file already contains rpc/rpc.h */ 417ff49530fSBill Paul } else 418ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 4194e115012SGarrett Wollman tell = ftell(fout); 420526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 4214e115012SGarrett Wollman emit(def); 4224e115012SGarrett Wollman } 4234e115012SGarrett Wollman if (extend && tell == ftell(fout)) { 4244e115012SGarrett Wollman (void) unlink(outfilename); 4254e115012SGarrett Wollman } 4264e115012SGarrett Wollman } 4274e115012SGarrett Wollman 428ff49530fSBill Paul 429526195adSJordan K. Hubbard void 430e390e3afSDavid Malone c_initialize(void) 431ff49530fSBill Paul { 432ff49530fSBill Paul 433ff49530fSBill Paul /* add all the starting basic types */ 434ff49530fSBill Paul add_type(1, "int"); 435ff49530fSBill Paul add_type(1, "long"); 436ff49530fSBill Paul add_type(1, "short"); 437ff49530fSBill Paul add_type(1, "bool"); 438ff49530fSBill Paul add_type(1, "u_int"); 439ff49530fSBill Paul add_type(1, "u_long"); 440ff49530fSBill Paul add_type(1, "u_short"); 441ff49530fSBill Paul 442ff49530fSBill Paul } 443ff49530fSBill Paul 444e390e3afSDavid Malone const char rpcgen_table_dcl[] = "struct rpcgen_table {\n\ 445ff49530fSBill Paul char *(*proc)(); \n\ 446ff49530fSBill Paul xdrproc_t xdr_arg; \n\ 447ff49530fSBill Paul unsigned len_arg; \n\ 448ff49530fSBill Paul xdrproc_t xdr_res; \n\ 449ff49530fSBill Paul unsigned len_res; \n\ 450ff49530fSBill Paul }; \n"; 451ff49530fSBill Paul 452ff49530fSBill Paul 453e390e3afSDavid Malone char * 454e390e3afSDavid Malone generate_guard(const char *pathname) 455ff49530fSBill Paul { 456e390e3afSDavid Malone const char *filename; 457e390e3afSDavid Malone char *guard, *tmp, *stopat; 458ff49530fSBill Paul 459ff49530fSBill Paul filename = strrchr(pathname, '/'); /* find last component */ 460ff49530fSBill Paul filename = ((filename == 0) ? pathname : filename+1); 46175863a6dSPhilippe Charnier guard = xstrdup(filename); 462080f4020SSean Kelly stopat = strrchr(guard, '.'); 463080f4020SSean Kelly 464080f4020SSean Kelly /* 465080f4020SSean Kelly * Convert to a valid C macro name and make it upper case. 466080f4020SSean Kelly * Map macro unfriendly characterss to '_'. 46710c546c4SSean Kelly */ 468080f4020SSean Kelly for (tmp = guard; *tmp != '\000'; ++tmp) { 469ff49530fSBill Paul if (islower(*tmp)) 470ff49530fSBill Paul *tmp = toupper(*tmp); 471080f4020SSean Kelly else if (isupper(*tmp) || *tmp == '_') 47210c546c4SSean Kelly /* OK for C */; 47310c546c4SSean Kelly else if (tmp == guard) 47410c546c4SSean Kelly *tmp = '_'; 47510c546c4SSean Kelly else if (isdigit(*tmp)) 47610c546c4SSean Kelly /* OK for all but first character */; 477080f4020SSean Kelly else if (tmp == stopat) { 478080f4020SSean Kelly *tmp = '\0'; 47910c546c4SSean Kelly break; 48010c546c4SSean Kelly } else 48110c546c4SSean Kelly *tmp = '_'; 48210c546c4SSean Kelly } 483080f4020SSean Kelly /* 484080f4020SSean Kelly * Can't have a '_' in front, because it'll end up being "__". 485080f4020SSean Kelly * "__" macros shoudln't be used. So, remove all of the 486080f4020SSean Kelly * '_' characters from the front. 48710c546c4SSean Kelly */ 488080f4020SSean Kelly if (*guard == '_') { 489080f4020SSean Kelly for (tmp = guard; *tmp == '_'; ++tmp) 490080f4020SSean Kelly ; 491080f4020SSean Kelly strcpy(guard, tmp); 492ff49530fSBill Paul } 493ff49530fSBill Paul guard = extendfile(guard, "_H_RPCGEN"); 494ff49530fSBill Paul return (guard); 495ff49530fSBill Paul } 496ff49530fSBill Paul 4974e115012SGarrett Wollman /* 4984e115012SGarrett Wollman * Compile into an XDR header file 4994e115012SGarrett Wollman */ 500ff49530fSBill Paul 501ff49530fSBill Paul 502526195adSJordan K. Hubbard static void 503e390e3afSDavid Malone h_output(const char *infile, const char *define, int extend, const char *outfile, int headeronly) 5044e115012SGarrett Wollman { 5054e115012SGarrett Wollman definition *def; 506e390e3afSDavid Malone const char *outfilename; 5074e115012SGarrett Wollman long tell; 508e390e3afSDavid Malone const char *guard; 509ff49530fSBill Paul list *l; 510ff49530fSBill Paul xdrfunc *xdrfuncp; 5114e115012SGarrett Wollman 5124e115012SGarrett Wollman open_input(infile, define); 5134e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 5144e115012SGarrett Wollman open_output(infile, outfilename); 515ff49530fSBill Paul add_warning(); 516ff49530fSBill Paul if (outfilename || infile){ 517ff49530fSBill Paul guard = generate_guard(outfilename ? outfilename: infile); 518ff49530fSBill Paul } else 519ff49530fSBill Paul guard = "STDIN_"; 520ff49530fSBill Paul 521ff49530fSBill Paul f_print(fout, "#ifndef _%s\n#define _%s\n\n", guard, 522ff49530fSBill Paul guard); 523ff49530fSBill Paul 524ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 525ff49530fSBill Paul 52640ad8885SAlfred Perlstein if (mtflag) 52735ab9586SDavid E. O'Brien f_print(fout, "#include <pthread.h>\n"); 528ff49530fSBill Paul 529ff49530fSBill Paul /* put the C++ support */ 53015df5e2dSStefan Farfeleder if (!CCflag) { 531ff49530fSBill Paul f_print(fout, "\n#ifdef __cplusplus\n"); 532ff49530fSBill Paul f_print(fout, "extern \"C\" {\n"); 533ff49530fSBill Paul f_print(fout, "#endif\n\n"); 534ff49530fSBill Paul } 535ff49530fSBill Paul 536ff49530fSBill Paul /* put in a typedef for quadprecision. Only with Cflag */ 537ff49530fSBill Paul 5384e115012SGarrett Wollman tell = ftell(fout); 539ff49530fSBill Paul 540ff49530fSBill Paul /* print data definitions */ 541526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 542ec06b5e8SStefan Farfeleder print_datadef(def, headeronly); 5434e115012SGarrett Wollman } 544ff49530fSBill Paul 545ff49530fSBill Paul /* 546ff49530fSBill Paul * print function declarations. 547ff49530fSBill Paul * Do this after data definitions because they might be used as 548ff49530fSBill Paul * arguments for functions 549ff49530fSBill Paul */ 550ff49530fSBill Paul for (l = defined; l != NULL; l = l->next) { 551ec06b5e8SStefan Farfeleder print_funcdef(l->val, headeronly); 552ff49530fSBill Paul } 553ff49530fSBill Paul /* Now print all xdr func declarations */ 554ff49530fSBill Paul if (xdrfunc_head != NULL){ 555ff49530fSBill Paul 556ff49530fSBill Paul f_print(fout, 557ff49530fSBill Paul "\n/* the xdr functions */\n"); 558ff49530fSBill Paul 559ff49530fSBill Paul if (CCflag){ 560ff49530fSBill Paul f_print(fout, "\n#ifdef __cplusplus\n"); 561ff49530fSBill Paul f_print(fout, "extern \"C\" {\n"); 562ff49530fSBill Paul f_print(fout, "#endif\n"); 563ff49530fSBill Paul } 564ff49530fSBill Paul 565ff49530fSBill Paul xdrfuncp = xdrfunc_head; 566ff49530fSBill Paul while (xdrfuncp != NULL){ 56715df5e2dSStefan Farfeleder print_xdr_func_def(xdrfuncp->name, xdrfuncp->pointerp); 568ff49530fSBill Paul xdrfuncp = xdrfuncp->next; 569ff49530fSBill Paul } 570ff49530fSBill Paul } 571ff49530fSBill Paul 5724e115012SGarrett Wollman if (extend && tell == ftell(fout)) { 5734e115012SGarrett Wollman (void) unlink(outfilename); 574ff49530fSBill Paul } else if (tblflag) { 575ff49530fSBill Paul f_print(fout, rpcgen_table_dcl); 5764e115012SGarrett Wollman } 577ff49530fSBill Paul 578ff49530fSBill Paul f_print(fout, "\n#ifdef __cplusplus\n"); 579ff49530fSBill Paul f_print(fout, "}\n"); 580ff49530fSBill Paul f_print(fout, "#endif\n"); 581ff49530fSBill Paul 582ff49530fSBill Paul f_print(fout, "\n#endif /* !_%s */\n", guard); 5834e115012SGarrett Wollman } 5844e115012SGarrett Wollman 5854e115012SGarrett Wollman /* 5864e115012SGarrett Wollman * Compile into an RPC service 5874e115012SGarrett Wollman */ 588526195adSJordan K. Hubbard static void 589e390e3afSDavid Malone s_output(int argc, const char *argv[], const char *infile, const char *define, 590e390e3afSDavid Malone int extend, const char *outfile, int nomain, int netflag) 5914e115012SGarrett Wollman { 5924e115012SGarrett Wollman char *include; 5934e115012SGarrett Wollman definition *def; 594ff49530fSBill Paul int foundprogram = 0; 595e390e3afSDavid Malone const char *outfilename; 5964e115012SGarrett Wollman 5974e115012SGarrett Wollman open_input(infile, define); 5984e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 5994e115012SGarrett Wollman open_output(infile, outfilename); 600ff49530fSBill Paul add_warning(); 6014e115012SGarrett Wollman if (infile && (include = extendfile(infile, ".h"))) { 6024e115012SGarrett Wollman f_print(fout, "#include \"%s\"\n", include); 6034e115012SGarrett Wollman free(include); 604ff49530fSBill Paul } else 605ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 606ff49530fSBill Paul 607ff49530fSBill Paul f_print(fout, "#include <stdio.h>\n"); 608ff49530fSBill Paul f_print(fout, "#include <stdlib.h> /* getenv, exit */\n"); 60915df5e2dSStefan Farfeleder f_print (fout, "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n"); 610ff49530fSBill Paul f_print (fout, "#include <string.h> /* strcmp */\n"); 611bcb53b16SMartin Blapp if (tirpcflag) 612bcb53b16SMartin Blapp f_print(fout, "#include <rpc/rpc_com.h>\n"); 613ff49530fSBill Paul if (strcmp(svcclosetime, "-1") == 0) 614ff49530fSBill Paul indefinitewait = 1; 615ff49530fSBill Paul else if (strcmp(svcclosetime, "0") == 0) 616ff49530fSBill Paul exitnow = 1; 617ff49530fSBill Paul else if (inetdflag || pmflag) { 618ff49530fSBill Paul f_print(fout, "#include <signal.h>\n"); 619ff49530fSBill Paul timerflag = 1; 620ff49530fSBill Paul } 621ff49530fSBill Paul 622ff49530fSBill Paul if (!tirpcflag && inetdflag) 623ff49530fSBill Paul f_print(fout, "#include <sys/ttycom.h> /* TIOCNOTTY */\n"); 62415df5e2dSStefan Farfeleder if (inetdflag || pmflag) { 625ff49530fSBill Paul f_print(fout, "#ifdef __cplusplus\n"); 626ff49530fSBill Paul f_print(fout, 627ff49530fSBill Paul "#include <sysent.h> /* getdtablesize, open */\n"); 628ff49530fSBill Paul f_print(fout, "#endif /* __cplusplus */\n"); 629ff49530fSBill Paul } 63040ad8885SAlfred Perlstein if (tirpcflag) { 63140ad8885SAlfred Perlstein f_print(fout, "#include <fcntl.h> /* open */\n"); 63240ad8885SAlfred Perlstein f_print(fout, "#include <unistd.h> /* fork / setsid */\n"); 633ff49530fSBill Paul f_print(fout, "#include <sys/types.h>\n"); 63440ad8885SAlfred Perlstein } 635ff49530fSBill Paul 6364f83fd19SStefan Farfeleder f_print(fout, "#include <string.h>\n"); 637ff49530fSBill Paul if (inetdflag || !tirpcflag) { 638ff49530fSBill Paul f_print(fout, "#include <sys/socket.h>\n"); 639ff49530fSBill Paul f_print(fout, "#include <netinet/in.h>\n"); 640ff49530fSBill Paul } 641ff49530fSBill Paul 642ff49530fSBill Paul if ((netflag || pmflag) && tirpcflag && !nomain) { 643ff49530fSBill Paul f_print(fout, "#include <netconfig.h>\n"); 644ff49530fSBill Paul } 645ff49530fSBill Paul if (tirpcflag) 646ff49530fSBill Paul f_print(fout, "#include <sys/resource.h> /* rlimit */\n"); 64740ad8885SAlfred Perlstein if (logflag || inetdflag || pmflag || tirpcflag) 648ff49530fSBill Paul f_print(fout, "#include <syslog.h>\n"); 649ff49530fSBill Paul 650ff49530fSBill Paul f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n"); 651ff49530fSBill Paul if (timerflag) 652ff49530fSBill Paul f_print(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", 653ff49530fSBill Paul svcclosetime); 654526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 6554e115012SGarrett Wollman foundprogram |= (def->def_kind == DEF_PROGRAM); 6564e115012SGarrett Wollman } 6574e115012SGarrett Wollman if (extend && !foundprogram) { 6584e115012SGarrett Wollman (void) unlink(outfilename); 6594e115012SGarrett Wollman return; 6604e115012SGarrett Wollman } 661ff49530fSBill Paul write_most(infile, netflag, nomain); 662ff49530fSBill Paul if (!nomain) { 663ff49530fSBill Paul if (!do_registers(argc, argv)) { 664ff49530fSBill Paul if (outfilename) 665ff49530fSBill Paul (void) unlink(outfilename); 666ff49530fSBill Paul usage(); 667ff49530fSBill Paul } 6684e115012SGarrett Wollman write_rest(); 6694e115012SGarrett Wollman } 6704e115012SGarrett Wollman } 6714e115012SGarrett Wollman 672ff49530fSBill Paul /* 673ff49530fSBill Paul * generate client side stubs 674ff49530fSBill Paul */ 675526195adSJordan K. Hubbard static void 676e390e3afSDavid Malone l_output(const char *infile, const char *define, int extend, const char *outfile) 6774e115012SGarrett Wollman { 6784e115012SGarrett Wollman char *include; 6794e115012SGarrett Wollman definition *def; 680ff49530fSBill Paul int foundprogram = 0; 681e390e3afSDavid Malone const char *outfilename; 6824e115012SGarrett Wollman 6834e115012SGarrett Wollman open_input(infile, define); 6844e115012SGarrett Wollman outfilename = extend ? extendfile(infile, outfile) : outfile; 6854e115012SGarrett Wollman open_output(infile, outfilename); 686ff49530fSBill Paul add_warning(); 6874f83fd19SStefan Farfeleder f_print (fout, "#include <string.h> /* for memset */\n"); 6884e115012SGarrett Wollman if (infile && (include = extendfile(infile, ".h"))) { 6894e115012SGarrett Wollman f_print(fout, "#include \"%s\"\n", include); 6904e115012SGarrett Wollman free(include); 691ff49530fSBill Paul } else 692ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 693526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 6944e115012SGarrett Wollman foundprogram |= (def->def_kind == DEF_PROGRAM); 6954e115012SGarrett Wollman } 6964e115012SGarrett Wollman if (extend && !foundprogram) { 6974e115012SGarrett Wollman (void) unlink(outfilename); 6984e115012SGarrett Wollman return; 6994e115012SGarrett Wollman } 7004e115012SGarrett Wollman write_stubs(); 7014e115012SGarrett Wollman } 7024e115012SGarrett Wollman 7034e115012SGarrett Wollman /* 704ff49530fSBill Paul * generate the dispatch table 7054e115012SGarrett Wollman */ 706526195adSJordan K. Hubbard static void 707e390e3afSDavid Malone t_output(const char *infile, const char *define, int extend, const char *outfile) 708ff49530fSBill Paul { 709ff49530fSBill Paul definition *def; 710ff49530fSBill Paul int foundprogram = 0; 711e390e3afSDavid Malone const char *outfilename; 712ff49530fSBill Paul 713ff49530fSBill Paul open_input(infile, define); 714ff49530fSBill Paul outfilename = extend ? extendfile(infile, outfile) : outfile; 715ff49530fSBill Paul open_output(infile, outfilename); 716ff49530fSBill Paul add_warning(); 717526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 718ff49530fSBill Paul foundprogram |= (def->def_kind == DEF_PROGRAM); 719ff49530fSBill Paul } 720ff49530fSBill Paul if (extend && !foundprogram) { 721ff49530fSBill Paul (void) unlink(outfilename); 722ff49530fSBill Paul return; 723ff49530fSBill Paul } 724ff49530fSBill Paul write_tables(); 725ff49530fSBill Paul } 726ff49530fSBill Paul 727ff49530fSBill Paul /* sample routine for the server template */ 728526195adSJordan K. Hubbard static void 729e390e3afSDavid Malone svc_output(const char *infile, const char *define, int extend, const char *outfile) 730ff49530fSBill Paul { 731ff49530fSBill Paul definition *def; 732ff49530fSBill Paul char *include; 733e390e3afSDavid Malone const char *outfilename; 734ff49530fSBill Paul long tell; 735ff49530fSBill Paul open_input(infile, define); 736ff49530fSBill Paul outfilename = extend ? extendfile(infile, outfile) : outfile; 737ff49530fSBill Paul checkfiles(infile, outfilename); 738ff49530fSBill Paul /* 739ff49530fSBill Paul * Check if outfile already exists. 740ff49530fSBill Paul * if so, print an error message and exit 741ff49530fSBill Paul */ 742ff49530fSBill Paul open_output(infile, outfilename); 743ff49530fSBill Paul add_sample_msg(); 744ff49530fSBill Paul 745ff49530fSBill Paul if (infile && (include = extendfile(infile, ".h"))) { 746ff49530fSBill Paul f_print(fout, "#include \"%s\"\n", include); 747ff49530fSBill Paul free(include); 748ff49530fSBill Paul } else 749ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 750ff49530fSBill Paul 751ff49530fSBill Paul tell = ftell(fout); 752526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 753ff49530fSBill Paul write_sample_svc(def); 754ff49530fSBill Paul } 755ff49530fSBill Paul if (extend && tell == ftell(fout)) { 756ff49530fSBill Paul (void) unlink(outfilename); 757ff49530fSBill Paul } 758ff49530fSBill Paul } 759ff49530fSBill Paul 760ff49530fSBill Paul /* sample main routine for client */ 761526195adSJordan K. Hubbard static void 762e390e3afSDavid Malone clnt_output(const char *infile, const char *define, int extend, const char *outfile) 763ff49530fSBill Paul { 764ff49530fSBill Paul definition *def; 765ff49530fSBill Paul char *include; 766e390e3afSDavid Malone const char *outfilename; 767ff49530fSBill Paul long tell; 768ff49530fSBill Paul int has_program = 0; 769ff49530fSBill Paul 770ff49530fSBill Paul open_input(infile, define); 771ff49530fSBill Paul outfilename = extend ? extendfile(infile, outfile) : outfile; 772ff49530fSBill Paul checkfiles(infile, outfilename); 773ff49530fSBill Paul /* 774ff49530fSBill Paul * Check if outfile already exists. 775ff49530fSBill Paul * if so, print an error message and exit 776ff49530fSBill Paul */ 777ff49530fSBill Paul 778ff49530fSBill Paul open_output(infile, outfilename); 779ff49530fSBill Paul add_sample_msg(); 780ff49530fSBill Paul if (infile && (include = extendfile(infile, ".h"))) { 781ff49530fSBill Paul f_print(fout, "#include \"%s\"\n", include); 782ff49530fSBill Paul free(include); 783ff49530fSBill Paul } else 784ff49530fSBill Paul f_print(fout, "#include <rpc/rpc.h>\n"); 785ff49530fSBill Paul tell = ftell(fout); 786526195adSJordan K. Hubbard while ( (def = get_definition()) ) { 787ff49530fSBill Paul has_program += write_sample_clnt(def); 788ff49530fSBill Paul } 789ff49530fSBill Paul 790ff49530fSBill Paul if (has_program) 791ff49530fSBill Paul write_sample_clnt_main(); 792ff49530fSBill Paul 793ff49530fSBill Paul if (extend && tell == ftell(fout)) { 794ff49530fSBill Paul (void) unlink(outfilename); 795ff49530fSBill Paul } 796ff49530fSBill Paul } 797ff49530fSBill Paul 798ff49530fSBill Paul 799e390e3afSDavid Malone static void mkfile_output(struct commandline *cmd) 800ff49530fSBill Paul { 801e390e3afSDavid Malone const char *mkfilename, *clientname, *clntname, *xdrname, *hdrname; 802e390e3afSDavid Malone const char *servername, *svcname, *servprogname, *clntprogname; 803e390e3afSDavid Malone char *temp, *mkftemp; 804ff49530fSBill Paul 805ff49530fSBill Paul svcname = file_name(cmd->infile, "_svc.c"); 806ff49530fSBill Paul clntname = file_name(cmd->infile, "_clnt.c"); 807ff49530fSBill Paul xdrname = file_name(cmd->infile, "_xdr.c"); 808ff49530fSBill Paul hdrname = file_name(cmd->infile, ".h"); 809ff49530fSBill Paul 810ff49530fSBill Paul 811ff49530fSBill Paul if (allfiles){ 812ff49530fSBill Paul servername = extendfile(cmd->infile, "_server.c"); 813ff49530fSBill Paul clientname = extendfile(cmd->infile, "_client.c"); 814ff49530fSBill Paul }else{ 815ff49530fSBill Paul servername = " "; 816ff49530fSBill Paul clientname = " "; 817ff49530fSBill Paul } 818ff49530fSBill Paul servprogname = extendfile(cmd->infile, "_server"); 819ff49530fSBill Paul clntprogname = extendfile(cmd->infile, "_client"); 820ff49530fSBill Paul 821ff49530fSBill Paul if (allfiles){ 822e390e3afSDavid Malone mkftemp = xmalloc(strlen("makefile.") + 823ff49530fSBill Paul strlen(cmd->infile) + 1); 824ff49530fSBill Paul temp = (char *)rindex(cmd->infile, '.'); 825e390e3afSDavid Malone strcpy(mkftemp, "makefile."); 826e390e3afSDavid Malone (void) strncat(mkftemp, cmd->infile, 827ff49530fSBill Paul (temp - cmd->infile)); 828e390e3afSDavid Malone mkfilename = mkftemp; 829ff49530fSBill Paul } else 830ff49530fSBill Paul mkfilename = cmd->outfile; 831ff49530fSBill Paul 832ff49530fSBill Paul 833ff49530fSBill Paul checkfiles(NULL, mkfilename); 834ff49530fSBill Paul open_output(NULL, mkfilename); 835ff49530fSBill Paul 836ff49530fSBill Paul f_print(fout, "\n# This is a template makefile generated\ 837ff49530fSBill Paul by rpcgen \n"); 838ff49530fSBill Paul 839ff49530fSBill Paul f_print(fout, "\n# Parameters \n\n"); 840ff49530fSBill Paul 841ff49530fSBill Paul f_print(fout, "CLIENT = %s\nSERVER = %s\n\n", 842ff49530fSBill Paul clntprogname, servprogname); 843ff49530fSBill Paul f_print(fout, "SOURCES_CLNT.c = \nSOURCES_CLNT.h = \n"); 844ff49530fSBill Paul f_print(fout, "SOURCES_SVC.c = \nSOURCES_SVC.h = \n"); 845ff49530fSBill Paul f_print(fout, "SOURCES.x = %s\n\n", cmd->infile); 846ff49530fSBill Paul f_print(fout, "TARGETS_SVC.c = %s %s %s \n", 847ff49530fSBill Paul svcname, servername, xdrname); 848ff49530fSBill Paul f_print(fout, "TARGETS_CLNT.c = %s %s %s \n", 849ff49530fSBill Paul clntname, clientname, xdrname); 850ff49530fSBill Paul f_print(fout, "TARGETS = %s %s %s %s %s %s\n\n", 851ff49530fSBill Paul hdrname, xdrname, clntname, 852ff49530fSBill Paul svcname, clientname, servername); 853ff49530fSBill Paul 854ff49530fSBill Paul f_print(fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) \ 855ff49530fSBill Paul $(TARGETS_CLNT.c:%%.c=%%.o) "); 856ff49530fSBill Paul 857ff49530fSBill Paul f_print(fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) \ 858ff49530fSBill Paul $(TARGETS_SVC.c:%%.c=%%.o) "); 859ff49530fSBill Paul 860ff49530fSBill Paul 861ff49530fSBill Paul f_print(fout, "\n# Compiler flags \n"); 862ff49530fSBill Paul if (mtflag) 86340ad8885SAlfred Perlstein f_print(fout, "\nCFLAGS += -D_REENTRANT -D_THEAD_SAFE \nLDLIBS += -pthread\n"); 86440ad8885SAlfred Perlstein 865ff49530fSBill Paul f_print(fout, "RPCGENFLAGS = \n"); 866ff49530fSBill Paul 867ff49530fSBill Paul f_print(fout, "\n# Targets \n\n"); 868ff49530fSBill Paul 869ff49530fSBill Paul f_print(fout, "all : $(CLIENT) $(SERVER)\n\n"); 870ff49530fSBill Paul f_print(fout, "$(TARGETS) : $(SOURCES.x) \n"); 871ff49530fSBill Paul f_print(fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n"); 872ff49530fSBill Paul f_print(fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \ 873ff49530fSBill Paul $(TARGETS_CLNT.c) \n\n"); 874ff49530fSBill Paul 875ff49530fSBill Paul f_print(fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \ 876ff49530fSBill Paul $(TARGETS_SVC.c) \n\n"); 877ff49530fSBill Paul f_print(fout, "$(CLIENT) : $(OBJECTS_CLNT) \n"); 878ff49530fSBill Paul f_print(fout, "\t$(CC) -o $(CLIENT) $(OBJECTS_CLNT) \ 879ff49530fSBill Paul $(LDLIBS) \n\n"); 880ff49530fSBill Paul f_print(fout, "$(SERVER) : $(OBJECTS_SVC) \n"); 881ff49530fSBill Paul f_print(fout, "\t$(CC) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n "); 882ff49530fSBill Paul f_print(fout, "clean:\n\t $(RM) -f core $(TARGETS) $(OBJECTS_CLNT) \ 883ff49530fSBill Paul $(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n"); 884ff49530fSBill Paul } 885ff49530fSBill Paul 886ff49530fSBill Paul 887ff49530fSBill Paul 888ff49530fSBill Paul /* 889ff49530fSBill Paul * Perform registrations for service output 890ff49530fSBill Paul * Return 0 if failed; 1 otherwise. 891ff49530fSBill Paul */ 892526195adSJordan K. Hubbard static int 893e390e3afSDavid Malone do_registers(int argc, const char *argv[]) 8944e115012SGarrett Wollman { 8954e115012SGarrett Wollman int i; 8964e115012SGarrett Wollman 897ff49530fSBill Paul if (inetdflag || !tirpcflag) { 8984e115012SGarrett Wollman for (i = 1; i < argc; i++) { 8994e115012SGarrett Wollman if (streq(argv[i], "-s")) { 900ff49530fSBill Paul if (!check_nettype(argv[i + 1], 901ff49530fSBill Paul valid_i_nettypes)) 902ff49530fSBill Paul return (0); 903ff49530fSBill Paul write_inetd_register(argv[i + 1]); 9044e115012SGarrett Wollman i++; 9054e115012SGarrett Wollman } 9064e115012SGarrett Wollman } 907ff49530fSBill Paul } else { 908ff49530fSBill Paul for (i = 1; i < argc; i++) 909ff49530fSBill Paul if (streq(argv[i], "-s")) { 910ff49530fSBill Paul if (!check_nettype(argv[i + 1], 911ff49530fSBill Paul valid_ti_nettypes)) 912ff49530fSBill Paul return (0); 913ff49530fSBill Paul write_nettype_register(argv[i + 1]); 914ff49530fSBill Paul i++; 915ff49530fSBill Paul } else if (streq(argv[i], "-n")) { 916ff49530fSBill Paul write_netid_register(argv[i + 1]); 917ff49530fSBill Paul i++; 918ff49530fSBill Paul } 919ff49530fSBill Paul } 920ff49530fSBill Paul return (1); 921ff49530fSBill Paul } 922ff49530fSBill Paul 923ff49530fSBill Paul /* 924ff49530fSBill Paul * Add another argument to the arg list 925ff49530fSBill Paul */ 926ff49530fSBill Paul static void 927e390e3afSDavid Malone addarg(const char *cp) 928ff49530fSBill Paul { 929ff49530fSBill Paul if (argcount >= ARGLISTLEN) { 9300e76f40dSPhilippe Charnier warnx("too many defines"); 931ff49530fSBill Paul crash(); 932ff49530fSBill Paul /*NOTREACHED*/ 933ff49530fSBill Paul } 934ff49530fSBill Paul arglist[argcount++] = cp; 935ff49530fSBill Paul 936ff49530fSBill Paul } 937ff49530fSBill Paul 938ff49530fSBill Paul static void 939e390e3afSDavid Malone putarg(int place, const char *cp) 940ff49530fSBill Paul { 941e390e3afSDavid Malone if (place >= ARGLISTLEN) { 9420e76f40dSPhilippe Charnier warnx("arglist coding error"); 943ff49530fSBill Paul crash(); 944ff49530fSBill Paul /*NOTREACHED*/ 945ff49530fSBill Paul } 946e390e3afSDavid Malone arglist[place] = cp; 947ff49530fSBill Paul } 948ff49530fSBill Paul 949ff49530fSBill Paul /* 950ff49530fSBill Paul * if input file is stdin and an output file is specified then complain 951ff49530fSBill Paul * if the file already exists. Otherwise the file may get overwritten 952ff49530fSBill Paul * If input file does not exist, exit with an error 953ff49530fSBill Paul */ 954ff49530fSBill Paul 955ff49530fSBill Paul static void 956e390e3afSDavid Malone checkfiles(const char *infile, const char *outfile) 957ff49530fSBill Paul { 958ff49530fSBill Paul 959ff49530fSBill Paul struct stat buf; 960ff49530fSBill Paul 961ff49530fSBill Paul if (infile) /* infile ! = NULL */ 962ff49530fSBill Paul if (stat(infile, &buf) < 0) 963ff49530fSBill Paul { 9640e76f40dSPhilippe Charnier warn("%s", infile); 965ff49530fSBill Paul crash(); 966ff49530fSBill Paul }; 967ff49530fSBill Paul if (outfile) { 968ff49530fSBill Paul if (stat(outfile, &buf) < 0) 969ff49530fSBill Paul return; /* file does not exist */ 970ff49530fSBill Paul else { 9710e76f40dSPhilippe Charnier warnx("file '%s' already exists and may be overwritten", outfile); 972ff49530fSBill Paul crash(); 973ff49530fSBill Paul } 974ff49530fSBill Paul } 9754e115012SGarrett Wollman } 9764e115012SGarrett Wollman 9774e115012SGarrett Wollman /* 9784e115012SGarrett Wollman * Parse command line arguments 9794e115012SGarrett Wollman */ 980526195adSJordan K. Hubbard static int 981e390e3afSDavid Malone parseargs(int argc, const char *argv[], struct commandline *cmd) 9824e115012SGarrett Wollman { 9834e115012SGarrett Wollman int i; 9844e115012SGarrett Wollman int j; 985ff49530fSBill Paul char c, ch; 9864e115012SGarrett Wollman char flag[(1 << 8 * sizeof (char))]; 9874e115012SGarrett Wollman int nflags; 9884e115012SGarrett Wollman 9894e115012SGarrett Wollman cmd->infile = cmd->outfile = NULL; 9904e115012SGarrett Wollman if (argc < 2) { 9914e115012SGarrett Wollman return (0); 9924e115012SGarrett Wollman } 993ff49530fSBill Paul allfiles = 0; 9944e115012SGarrett Wollman flag['c'] = 0; 9954e115012SGarrett Wollman flag['h'] = 0; 9964e115012SGarrett Wollman flag['l'] = 0; 9974e115012SGarrett Wollman flag['m'] = 0; 998ff49530fSBill Paul flag['o'] = 0; 999ff49530fSBill Paul flag['s'] = 0; 1000ff49530fSBill Paul flag['n'] = 0; 1001ff49530fSBill Paul flag['t'] = 0; 1002ff49530fSBill Paul flag['S'] = 0; 1003ff49530fSBill Paul flag['C'] = 0; 1004ff49530fSBill Paul flag['M'] = 0; 1005ff49530fSBill Paul 10064e115012SGarrett Wollman for (i = 1; i < argc; i++) { 10074e115012SGarrett Wollman if (argv[i][0] != '-') { 10084e115012SGarrett Wollman if (cmd->infile) { 10090e76f40dSPhilippe Charnier warnx("cannot specify more than one input file"); 10104e115012SGarrett Wollman return (0); 10114e115012SGarrett Wollman } 10124e115012SGarrett Wollman cmd->infile = argv[i]; 10134e115012SGarrett Wollman } else { 10144e115012SGarrett Wollman for (j = 1; argv[i][j] != 0; j++) { 10154e115012SGarrett Wollman c = argv[i][j]; 10164e115012SGarrett Wollman switch (c) { 1017ff49530fSBill Paul case 'a': 1018ff49530fSBill Paul allfiles = 1; 1019ff49530fSBill Paul break; 10204e115012SGarrett Wollman case 'c': 10214e115012SGarrett Wollman case 'h': 10224e115012SGarrett Wollman case 'l': 10234e115012SGarrett Wollman case 'm': 1024ff49530fSBill Paul case 't': 1025526195adSJordan K. Hubbard if (flag[(int)c]) { 10264e115012SGarrett Wollman return (0); 10274e115012SGarrett Wollman } 1028526195adSJordan K. Hubbard flag[(int)c] = 1; 10294e115012SGarrett Wollman break; 1030ff49530fSBill Paul case 'S': 1031ff49530fSBill Paul /* 1032ff49530fSBill Paul * sample flag: Ss or Sc. 1033ff49530fSBill Paul * Ss means set flag['S']; 1034ff49530fSBill Paul * Sc means set flag['C']; 1035ff49530fSBill Paul * Sm means set flag['M']; 1036ff49530fSBill Paul */ 1037ff49530fSBill Paul ch = argv[i][++j]; /* get next char */ 1038ff49530fSBill Paul if (ch == 's') 1039ff49530fSBill Paul ch = 'S'; 1040ff49530fSBill Paul else if (ch == 'c') 1041ff49530fSBill Paul ch = 'C'; 1042ff49530fSBill Paul else if (ch == 'm') 1043ff49530fSBill Paul ch = 'M'; 1044ff49530fSBill Paul else 1045ff49530fSBill Paul return (0); 1046ff49530fSBill Paul 1047526195adSJordan K. Hubbard if (flag[(int)ch]) { 1048ff49530fSBill Paul return (0); 1049ff49530fSBill Paul } 1050526195adSJordan K. Hubbard flag[(int)ch] = 1; 1051ff49530fSBill Paul break; 1052ff49530fSBill Paul case 'C': /* ANSI C syntax */ 1053ff49530fSBill Paul ch = argv[i][j+1]; /* get next char */ 1054ff49530fSBill Paul 1055ff49530fSBill Paul if (ch != 'C') 1056ff49530fSBill Paul break; 1057ff49530fSBill Paul CCflag = 1; 1058ff49530fSBill Paul break; 1059ff49530fSBill Paul case 'b': 1060ff49530fSBill Paul /* 1061ff49530fSBill Paul * Turn TIRPC flag off for 1062ff49530fSBill Paul * generating backward compatible 1063ff49530fSBill Paul * code 1064ff49530fSBill Paul */ 1065ff49530fSBill Paul tirpcflag = 0; 1066ff49530fSBill Paul break; 1067ff49530fSBill Paul 1068ff49530fSBill Paul case 'I': 1069ff49530fSBill Paul inetdflag = 1; 1070ff49530fSBill Paul break; 1071ff49530fSBill Paul case 'N': 1072ff49530fSBill Paul newstyle = 1; 1073ff49530fSBill Paul break; 1074ff49530fSBill Paul case 'L': 1075ff49530fSBill Paul logflag = 1; 1076ff49530fSBill Paul break; 107740ad8885SAlfred Perlstein case 'P': 107840ad8885SAlfred Perlstein pmflag = 1; 107940ad8885SAlfred Perlstein break; 1080ff49530fSBill Paul case 'K': 1081ff49530fSBill Paul if (++i == argc) { 1082ff49530fSBill Paul return (0); 1083ff49530fSBill Paul } 1084ff49530fSBill Paul svcclosetime = argv[i]; 1085ff49530fSBill Paul goto nextarg; 1086ff49530fSBill Paul case 'T': 1087ff49530fSBill Paul tblflag = 1; 1088ff49530fSBill Paul break; 1089ff49530fSBill Paul case 'M': 1090ff49530fSBill Paul mtflag = 1; 1091ff49530fSBill Paul break; 1092ff49530fSBill Paul case 'i' : 1093ff49530fSBill Paul if (++i == argc) { 1094ff49530fSBill Paul return (0); 1095ff49530fSBill Paul } 1096122562cdSStefan Farfeleder inline_size = atoi(argv[i]); 1097ff49530fSBill Paul goto nextarg; 1098ff49530fSBill Paul case 'n': 10994e115012SGarrett Wollman case 'o': 11004e115012SGarrett Wollman case 's': 11014e115012SGarrett Wollman if (argv[i][j - 1] != '-' || 11024e115012SGarrett Wollman argv[i][j + 1] != 0) { 11034e115012SGarrett Wollman return (0); 11044e115012SGarrett Wollman } 1105526195adSJordan K. Hubbard flag[(int)c] = 1; 11064e115012SGarrett Wollman if (++i == argc) { 11074e115012SGarrett Wollman return (0); 11084e115012SGarrett Wollman } 1109ff49530fSBill Paul if (c == 'o') { 11104e115012SGarrett Wollman if (cmd->outfile) { 11114e115012SGarrett Wollman return (0); 11124e115012SGarrett Wollman } 11134e115012SGarrett Wollman cmd->outfile = argv[i]; 11144e115012SGarrett Wollman } 11154e115012SGarrett Wollman goto nextarg; 1116ff49530fSBill Paul case 'D': 1117ff49530fSBill Paul if (argv[i][j - 1] != '-') { 1118ff49530fSBill Paul return (0); 1119ff49530fSBill Paul } 1120ff49530fSBill Paul (void) addarg(argv[i]); 1121ff49530fSBill Paul goto nextarg; 1122ff49530fSBill Paul case 'Y': 1123ff49530fSBill Paul if (++i == argc) { 1124ff49530fSBill Paul return (0); 1125ff49530fSBill Paul } 1126a0b13740SKris Kennaway (void) strlcpy(pathbuf, argv[i], sizeof(pathbuf)); 1127a0b13740SKris Kennaway if (strlcat(pathbuf, "/cpp", sizeof(pathbuf)) 1128a0b13740SKris Kennaway >= sizeof(pathbuf)) { 1129a0b13740SKris Kennaway warnx("argument too long"); 1130a0b13740SKris Kennaway return (0); 1131a0b13740SKris Kennaway } 1132ff49530fSBill Paul CPP = pathbuf; 1133ff49530fSBill Paul cppDefined = 1; 1134ff49530fSBill Paul goto nextarg; 1135ff49530fSBill Paul 1136ff49530fSBill Paul 11374e115012SGarrett Wollman 11384e115012SGarrett Wollman default: 11394e115012SGarrett Wollman return (0); 11404e115012SGarrett Wollman } 11414e115012SGarrett Wollman } 11424e115012SGarrett Wollman nextarg: 11434e115012SGarrett Wollman ; 11444e115012SGarrett Wollman } 11454e115012SGarrett Wollman } 1146ff49530fSBill Paul 11474e115012SGarrett Wollman cmd->cflag = flag['c']; 11484e115012SGarrett Wollman cmd->hflag = flag['h']; 11494e115012SGarrett Wollman cmd->lflag = flag['l']; 11504e115012SGarrett Wollman cmd->mflag = flag['m']; 1151ff49530fSBill Paul cmd->nflag = flag['n']; 1152ff49530fSBill Paul cmd->sflag = flag['s']; 1153ff49530fSBill Paul cmd->tflag = flag['t']; 1154ff49530fSBill Paul cmd->Ssflag = flag['S']; 1155ff49530fSBill Paul cmd->Scflag = flag['C']; 1156ff49530fSBill Paul cmd->makefileflag = flag['M']; 1157ff49530fSBill Paul 1158ff49530fSBill Paul if (tirpcflag) { 115940ad8885SAlfred Perlstein if (inetdflag) 116040ad8885SAlfred Perlstein pmflag = 0; 1161ff49530fSBill Paul if ((inetdflag && cmd->nflag)) { 1162ff49530fSBill Paul /* netid not allowed with inetdflag */ 11630e76f40dSPhilippe Charnier warnx("cannot use netid flag with inetd flag"); 1164ff49530fSBill Paul return (0); 1165ff49530fSBill Paul } 1166ff49530fSBill Paul } else { /* 4.1 mode */ 1167ff49530fSBill Paul pmflag = 0; /* set pmflag only in tirpcmode */ 1168ff49530fSBill Paul if (cmd->nflag) { /* netid needs TIRPC */ 11690e76f40dSPhilippe Charnier warnx("cannot use netid flag without TIRPC"); 1170ff49530fSBill Paul return (0); 1171ff49530fSBill Paul } 1172ff49530fSBill Paul } 1173ff49530fSBill Paul 1174ff49530fSBill Paul if (newstyle && (tblflag || cmd->tflag)) { 11750e76f40dSPhilippe Charnier warnx("cannot use table flags with newstyle"); 1176ff49530fSBill Paul return (0); 1177ff49530fSBill Paul } 1178ff49530fSBill Paul 1179ff49530fSBill Paul /* check no conflicts with file generation flags */ 1180ff49530fSBill Paul nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag + 1181ff49530fSBill Paul cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + 1182ff49530fSBill Paul cmd->Scflag + cmd->makefileflag; 1183ff49530fSBill Paul 11844e115012SGarrett Wollman if (nflags == 0) { 11854e115012SGarrett Wollman if (cmd->outfile != NULL || cmd->infile == NULL) { 11864e115012SGarrett Wollman return (0); 11874e115012SGarrett Wollman } 1188ff49530fSBill Paul } else if (cmd->infile == NULL && 1189ff49530fSBill Paul (cmd->Ssflag || cmd->Scflag || cmd->makefileflag)) { 11900e76f40dSPhilippe Charnier warnx("\"infile\" is required for template generation flags"); 1191ff49530fSBill Paul return (0); 1192ff49530fSBill Paul } if (nflags > 1) { 11930e76f40dSPhilippe Charnier warnx("cannot have more than one file generation flag"); 11944e115012SGarrett Wollman return (0); 11954e115012SGarrett Wollman } 11964e115012SGarrett Wollman return (1); 11974e115012SGarrett Wollman } 1198ff49530fSBill Paul 1199526195adSJordan K. Hubbard static void 1200ff49530fSBill Paul usage() 1201ff49530fSBill Paul { 12020e76f40dSPhilippe Charnier f_print(stderr, "%s\n%s\n%s\n%s\n%s\n", 12030e76f40dSPhilippe Charnier "usage: rpcgen infile", 12040e76f40dSPhilippe Charnier " rpcgen [-abCLNTM] [-Dname[=value]] [-i size]\ 120540ad8885SAlfred Perlstein [-I -P [-K seconds]] [-Y path] infile", 12060e76f40dSPhilippe Charnier " rpcgen [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm]\ 12070e76f40dSPhilippe Charnier [-o outfile] [infile]", 12080e76f40dSPhilippe Charnier " rpcgen [-s nettype]* [-o outfile] [infile]", 12090e76f40dSPhilippe Charnier " rpcgen [-n netid]* [-o outfile] [infile]"); 1210ff49530fSBill Paul options_usage(); 1211ff49530fSBill Paul exit(1); 1212ff49530fSBill Paul } 1213ff49530fSBill Paul 1214526195adSJordan K. Hubbard static void 1215ff49530fSBill Paul options_usage() 1216ff49530fSBill Paul { 1217ff49530fSBill Paul f_print(stderr, "options:\n"); 1218ff49530fSBill Paul f_print(stderr, "-a\t\tgenerate all files, including samples\n"); 1219ff49530fSBill Paul f_print(stderr, "-b\t\tbackward compatibility mode (generates code \ 122040ad8885SAlfred Perlstein for FreeBSD 4.X)\n"); 1221ff49530fSBill Paul f_print(stderr, "-c\t\tgenerate XDR routines\n"); 1222ff49530fSBill Paul f_print(stderr, "-C\t\tANSI C mode\n"); 1223ff49530fSBill Paul f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n"); 1224ff49530fSBill Paul f_print(stderr, "-h\t\tgenerate header file\n"); 1225ff49530fSBill Paul f_print(stderr, "-i size\t\tsize at which to start generating\ 1226ff49530fSBill Paul inline code\n"); 122740ad8885SAlfred Perlstein f_print(stderr, "-I\t\tgenerate code for inetd support in server\n"); 1228ff49530fSBill Paul f_print(stderr, "-K seconds\tserver exits after K seconds of\ 1229ff49530fSBill Paul inactivity\n"); 1230ff49530fSBill Paul f_print(stderr, "-l\t\tgenerate client side stubs\n"); 1231ff49530fSBill Paul f_print(stderr, "-L\t\tserver errors will be printed to syslog\n"); 1232ff49530fSBill Paul f_print(stderr, "-m\t\tgenerate server side stubs\n"); 1233ff49530fSBill Paul f_print(stderr, "-M\t\tgenerate MT-safe code\n"); 1234ff49530fSBill Paul f_print(stderr, "-n netid\tgenerate server code that supports\ 1235ff49530fSBill Paul named netid\n"); 1236ff49530fSBill Paul f_print(stderr, "-N\t\tsupports multiple arguments and\ 1237ff49530fSBill Paul call-by-value\n"); 1238ff49530fSBill Paul f_print(stderr, "-o outfile\tname of the output file\n"); 123940ad8885SAlfred Perlstein f_print(stderr, "-P\t\tgenerate code for port monitoring support in server\n"); 1240ff49530fSBill Paul f_print(stderr, "-s nettype\tgenerate server code that supports named\ 1241ff49530fSBill Paul nettype\n"); 1242ff49530fSBill Paul f_print(stderr, "-Sc\t\tgenerate sample client code that uses remote\ 1243ff49530fSBill Paul procedures\n"); 1244ff49530fSBill Paul f_print(stderr, "-Ss\t\tgenerate sample server code that defines\ 1245ff49530fSBill Paul remote procedures\n"); 1246ff49530fSBill Paul f_print(stderr, "-Sm \t\tgenerate makefile template \n"); 1247ff49530fSBill Paul 1248ff49530fSBill Paul f_print(stderr, "-t\t\tgenerate RPC dispatch table\n"); 1249ff49530fSBill Paul f_print(stderr, "-T\t\tgenerate code to support RPC dispatch tables\n"); 1250ff49530fSBill Paul f_print(stderr, "-Y path\t\tpath where cpp is found\n"); 1251ff49530fSBill Paul exit(1); 1252ff49530fSBill Paul } 1253