[BACK]Return to rpc_main.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rpcgen

Diff for /src/usr.bin/rpcgen/rpc_main.c between version 1.10 and 1.11

version 1.10, 2001/11/24 19:19:59 version 1.11, 2001/12/05 09:50:31
Line 1 
Line 1 
 /*      $OpenBSD$       */  /* $OpenBSD$     */
 /*      $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $  */  /* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $        */
 /*  /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for   * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape   * unrestricted use provided that this legend is included on all tape
Line 31 
Line 31 
  */   */
   
 #ifndef lint  #ifndef lint
 static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";  static char     sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
 static char cvsid[] = "$OpenBSD$";  static char     cvsid[] = "$OpenBSD$";
 #endif  #endif
   
 /*  /*
  * rpc_main.c, Top level of the RPC protocol compiler.   * rpc_main.c, Top level of the RPC protocol compiler.
  */   */
   
 #define RPCGEN_VERSION  "199506"    /* This program's version (year & month) */  #define RPCGEN_VERSION  "199506"/* This program's version (year & month) */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 59 
Line 59 
 #include "rpc_scan.h"  #include "rpc_scan.h"
   
 #define EXTEND  1               /* alias for TRUE */  #define EXTEND  1               /* alias for TRUE */
 #define DONT_EXTEND     0               /* alias for FALSE */  #define DONT_EXTEND     0       /* alias for FALSE */
   
 #define SVR4_CPP "/usr/ccs/lib/cpp"  #define SVR4_CPP "/usr/ccs/lib/cpp"
 #define SUNOS_CPP "/lib/cpp"  #define SUNOS_CPP "/lib/cpp"
 static int cppDefined = 0;          /* explicit path for C preprocessor */  static int      cppDefined = 0; /* explicit path for C preprocessor */
   
 struct commandline {  struct commandline {
         int cflag;              /* xdr C routines */          int cflag;      /* xdr C routines */
         int hflag;              /* header file */          int hflag;      /* header file */
         int lflag;              /* client side stubs */          int lflag;      /* client side stubs */
         int mflag;              /* server side stubs */          int mflag;      /* server side stubs */
         int nflag;              /* netid flag */          int nflag;      /* netid flag */
         int sflag;              /* server stubs for the given transport */          int sflag;      /* server stubs for the given transport */
         int tflag;              /* dispatch Table file */          int tflag;      /* dispatch Table file */
         int Ssflag;             /* produce server sample code */          int Ssflag;     /* produce server sample code */
         int Scflag;             /* produce client sample code */          int Scflag;     /* produce client sample code */
         char *infile;           /* input module name */          char *infile;   /* input module name */
         char *outfile;          /* output module name */          char *outfile;/* output module name */
 };  };
   
   static char    *cmdname;
   
 static char *cmdname;  static char    *svcclosetime = "120";
   static char    *CPP = "/usr/bin/cpp";
 static char *svcclosetime = "120";  static char     CPPFLAGS[] = "-C";
 static char *CPP = "/usr/bin/cpp";  static char     pathbuf[MAXPATHLEN];
 static char CPPFLAGS[] = "-C";  static char    *allv[] = {
 static char pathbuf[MAXPATHLEN];  
 static char *allv[] = {  
         "rpcgen", "-s", "udp", "-s", "tcp",          "rpcgen", "-s", "udp", "-s", "tcp",
 };  };
 static int allc = sizeof(allv)/sizeof(allv[0]);  static int      allc = sizeof(allv) / sizeof(allv[0]);
 static char *allnv[] = {  static char    *allnv[] = {
         "rpcgen", "-s", "netpath",          "rpcgen", "-s", "netpath",
 };  };
 static int allnc = sizeof(allnv)/sizeof(allnv[0]);  static int      allnc = sizeof(allnv) / sizeof(allnv[0]);
   
 #define ARGLISTLEN      20  #define ARGLISTLEN      20
 #define FIXEDARGS         2  #define FIXEDARGS         2
   
 static char *arglist[ARGLISTLEN];  static char    *arglist[ARGLISTLEN];
 static int argcount = FIXEDARGS;  static int      argcount = FIXEDARGS;
   
   
 int nonfatalerrors;     /* errors */  int             nonfatalerrors; /* errors */
 int inetdflag/* = 1*/;  /* Support for inetd */ /* is now the default */  int             inetdflag /* = 1 */ ;   /* Support for inetd *//* is now the
 int pmflag;             /* Support for port monitors */                                           * default */
 int logflag;            /* Use syslog instead of fprintf for errors */  int             pmflag;         /* Support for port monitors */
 int tblflag;            /* Support for dispatch table file */  int             logflag;        /* Use syslog instead of fprintf for errors */
 int callerflag;         /* Generate svc_caller() function */  int             tblflag;        /* Support for dispatch table file */
   int             callerflag;     /* Generate svc_caller() function */
   
 #define INLINE 3  #define INLINE 3
 /*length at which to start doing an inline */  /* length at which to start doing an inline */
   
 int doinline=INLINE;  /* length at which to start doing an inline. 3 = default  int doinline = INLINE;  /* length at which to start doing an
                 if 0, no xdr_inline code */                           * inline. 3 = default if 0, no
                            * xdr_inline code */
   
 int indefinitewait;     /* If started by port monitors, hang till it wants */  int indefinitewait;     /* If started by port monitors, hang till it
 int exitnow;            /* If started by port monitors, exit after the call */                           * wants */
 int timerflag;          /* TRUE if !indefinite && !exitnow */  int exitnow;    /* If started by port monitors, exit after
 int newstyle;           /* newstyle of passing arguments (by value) */                   * the call */
 int Cflag = 0 ;         /* ANSI C syntax */  int timerflag;  /* TRUE if !indefinite && !exitnow */
 static int allfiles;   /* generate all files */  int newstyle;   /* newstyle of passing arguments (by value) */
 int tirpcflag = 0;       /* generating code for tirpc, by default */  int Cflag = 0;  /* ANSI C syntax */
   static int allfiles;    /* generate all files */
   int tirpcflag = 0;      /* generating code for tirpc, by default */
   
 #ifdef __MSDOS__  #ifdef __MSDOS__
 static char *dos_cppfile = NULL;  static char    *dos_cppfile = NULL;
 #endif  #endif
   
 static c_output __P((char *, char *, int, char *));  static c_output __P((char *, char *, int, char *));
Line 140 
Line 143 
 static void clear_args __P((void));  static void clear_args __P((void));
 static void checkfiles __P((char *, char *));  static void checkfiles __P((char *, char *));
 static int parseargs __P((int, char **, struct commandline *));  static int parseargs __P((int, char **, struct commandline *));
 static usage __P((void));  static usage    __P((void));
 static options_usage __P((void));  
   
   
   int
 main(argc, argv)  main(argc, argv)
         int argc;          int argc;
         char *argv[];          char *argv[];
 {  {
         struct commandline cmd;          struct commandline cmd;
   
         (void) memset((char *)&cmd, 0, sizeof (struct commandline));          (void) memset((char *) &cmd, 0, sizeof(struct commandline));
         clear_args();          clear_args();
         if (!parseargs(argc, argv, &cmd))          if (!parseargs(argc, argv, &cmd))
                 usage();                  usage();
   
         if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||          if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
                 cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag ) {              cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag) {
           checkfiles(cmd.infile, cmd.outfile);                  checkfiles(cmd.infile, cmd.outfile);
         }          } else
         else                  checkfiles(cmd.infile, NULL);
           checkfiles(cmd.infile,NULL);  
   
         if (cmd.cflag) {          if (cmd.cflag) {
                 c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);                  c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
Line 170 
Line 171 
         } else if (cmd.lflag) {          } else if (cmd.lflag) {
                 l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);                  l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
         } else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {          } else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
                 s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,                  s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
                          cmd.outfile, cmd.mflag, cmd.nflag);                           cmd.outfile, cmd.mflag, cmd.nflag);
         } else if (cmd.tflag) {          } else if (cmd.tflag) {
                 t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);                  t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
         } else if  (cmd.Ssflag) {          } else if (cmd.Ssflag) {
                   svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);                  svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
         } else if (cmd.Scflag) {          } else if (cmd.Scflag) {
                   clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);                  clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
         } else {          } else {
                 /* the rescans are required, since cpp may effect input */                  /* the rescans are required, since cpp may effect input */
                 c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");                  c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
Line 186 
Line 187 
                 reinitialize();                  reinitialize();
                 l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");                  l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
                 reinitialize();                  reinitialize();
                 if (inetdflag || !tirpcflag )                  if (inetdflag || !tirpcflag)
                         s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,                          s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
                                  "_svc.c", cmd.mflag, cmd.nflag);                              "_svc.c", cmd.mflag, cmd.nflag);
                 else                  else
                         s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",                          s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
                                  EXTEND, "_svc.c", cmd.mflag, cmd.nflag);                              EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
                 if (tblflag) {                  if (tblflag) {
                         reinitialize();                          reinitialize();
                         t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");                          t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
                 }                  }
                 if (allfiles) {                  if (allfiles) {
                   reinitialize();                          reinitialize();
                   svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");                          svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
                 }                  }
                 if (allfiles) {                  if (allfiles) {
                   reinitialize();                          reinitialize();
                   clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");                          clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
                 }                  }
         }          }
 #ifdef __MSDOS__  #ifdef __MSDOS__
         if (dos_cppfile != NULL) {          if (dos_cppfile != NULL) {
Line 216 
Line 217 
 }  }
   
 /*  /*
  * add extension to filename   * add extension to filename
  */   */
 static char *  static char *
 extendfile(path, ext)  extendfile(path, ext)
Line 233 
Line 234 
                 file++;                  file++;
   
         res = alloc(strlen(file) + strlen(ext) + 1);          res = alloc(strlen(file) + strlen(ext) + 1);
         if (res == NULL) {          if (res == NULL)
                 abort();                  abort();
         }  
         p = strrchr(file, '.');          p = strrchr(file, '.');
         if (p == NULL) {          if (p == NULL)
                 p = file + strlen(file);                  p = file + strlen(file);
         }  
         (void) strcpy(res, file);          (void) strcpy(res, file);
         (void) strcpy(res + (p - file), ext);          (void) strcpy(res + (p - file), ext);
         return (res);          return (res);
 }  }
   
 /*  /*
  * Open output file with given extension   * Open output file with given extension
  */   */
 static  static void
 open_output(infile, outfile)  open_output(infile, outfile)
         char *infile;          char *infile;
         char *outfile;          char *outfile;
Line 258 
Line 257 
                 fout = stdout;                  fout = stdout;
                 return;                  return;
         }          }
   
         if (infile != NULL && streq(outfile, infile)) {          if (infile != NULL && streq(outfile, infile)) {
                 f_print(stderr, "%s: output would overwrite %s\n", cmdname,                  f_print(stderr, "%s: output would overwrite %s\n", cmdname,
                         infile);                      infile);
                 crash();                  crash();
         }          }
         fout = fopen(outfile, "w");          fout = fopen(outfile, "w");
Line 284 
Line 282 
 }  }
   
 /* clear list of arguments */  /* clear list of arguments */
 static void clear_args()  static void
   clear_args()
 {  {
   int i;          int             i;
   for( i=FIXEDARGS; i<ARGLISTLEN; i++ )          for (i = FIXEDARGS; i < ARGLISTLEN; i++)
     arglist[i] = NULL;                  arglist[i] = NULL;
   argcount = FIXEDARGS;          argcount = FIXEDARGS;
 }  }
   
 /* make sure that a CPP exists */  /* make sure that a CPP exists */
 static void find_cpp()  static void
   find_cpp()
 {  {
   struct stat buf;          struct stat     buf;
   
   if( stat(CPP, &buf) < 0 )  {  /* SVR4 or explicit cpp does not exist */          /* SVR4 or explicit cpp does not exist */
     if (cppDefined) {          if (stat(CPP, &buf) < 0) {
       fprintf( stderr, "cannot find C preprocessor: %s \n", CPP );                  if (cppDefined) {
       crash();                          fprintf(stderr, "cannot find C preprocessor: %s \n", CPP);
     } else {                    /* try the other one */                          crash();
       CPP = SUNOS_CPP;                  } else {
       if( stat( CPP, &buf ) < 0 ) { /* can't find any cpp */                          /* try the other one */
         fprintf( stderr, "cannot find any C preprocessor: %s\n", CPP );                          CPP = SUNOS_CPP;
         crash();                          if (stat(CPP, &buf) < 0) {      /* can't find any cpp */
       }                                  fprintf(stderr,
     }                                      "cannot find any C preprocessor: %s\n", CPP);
   }                                  crash();
                           }
                   }
           }
 }  }
   
 /*  /*
  * Open input file with given define for C-preprocessor   * Open input file with given define for C-preprocessor
  */   */
 static  static
 open_input(infile, define)  open_input(infile, define)
         char *infile;          char           *infile;
         char *define;          char           *define;
 {  {
         int pd[2];          int             pd[2];
   
         infilename = (infile == NULL) ? "<stdin>" : infile;          infilename = (infile == NULL) ? "<stdin>" : infile;
 #ifdef __MSDOS__  #ifdef __MSDOS__
 #define DOSCPP  "\\prog\\bc31\\bin\\cpp.exe"  #define DOSCPP  "\\prog\\bc31\\bin\\cpp.exe"
         { int retval;          {
         char drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE], ext[MAXEXT];                  int             retval;
         char cppfile[MAXPATH];                  char            drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE],
         char *cpp;                                  ext[MAXEXT];
                   char            cppfile[MAXPATH];
                   char           *cpp;
   
         if ((cpp = searchpath("cpp.exe")) == NULL                  if ((cpp = searchpath("cpp.exe")) == NULL &&
         && (cpp = getenv("RPCGENCPP")) == NULL)                      (cpp = getenv("RPCGENCPP")) == NULL)
                 cpp = DOSCPP;                          cpp = DOSCPP;
   
         putarg(0, cpp);                  putarg(0, cpp);
         putarg(1, "-P-");                  putarg(1, "-P-");
         putarg(2, CPPFLAGS);                  putarg(2, CPPFLAGS);
         addarg(define);                  addarg(define);
         addarg(infile);                  addarg(infile);
         addarg(NULL);                  addarg(NULL);
   
         retval = spawnvp(P_WAIT, arglist[0], arglist);                  retval = spawnvp(P_WAIT, arglist[0], arglist);
         if (retval != 0) {                  if (retval != 0) {
                 fprintf(stderr, "%s: C PreProcessor failed\n", cmdname);                          fprintf(stderr, "%s: C PreProcessor failed\n", cmdname);
                 crash();                          crash();
         }                  }
                   fnsplit(infile, drive, dir, name, ext);
                   fnmerge(cppfile, drive, dir, name, ".i");
   
         fnsplit(infile, drive, dir, name, ext);                  fin = fopen(cppfile, "r");
         fnmerge(cppfile, drive, dir, name, ".i");                  if (fin == NULL) {
                           f_print(stderr, "%s: ", cmdname);
         fin = fopen(cppfile, "r");                          perror(cppfile);
         if (fin == NULL) {                          crash();
                 f_print(stderr, "%s: ", cmdname);                  }
                 perror(cppfile);                  dos_cppfile = strdup(cppfile);
                 crash();                  if (dos_cppfile == NULL) {
                           fprintf(stderr, "%s: out of memory\n", cmdname);
                           crash();
                   }
         }          }
         dos_cppfile = strdup(cppfile);  
         if (dos_cppfile == NULL) {  
                 fprintf(stderr, "%s: out of memory\n", cmdname);  
                 crash();  
         }  
         }  
 #else  #else
         (void) pipe(pd);          (void) pipe(pd);
         switch (fork()) {          switch (fork()) {
Line 370 
Line 374 
                 putarg(1, CPPFLAGS);                  putarg(1, CPPFLAGS);
                 addarg(define);                  addarg(define);
                 addarg(infile);                  addarg(infile);
                 addarg((char *)NULL);                  addarg((char *) NULL);
                 (void) close(1);                  (void) close(1);
                 (void) dup2(pd[1], 1);                  (void) dup2(pd[1], 1);
                 (void) close(pd[0]);                  (void) close(pd[0]);
Line 392 
Line 396 
 }  }
   
 /* valid tirpc nettypes */  /* valid tirpc nettypes */
 static char* valid_ti_nettypes[] =  static char    *valid_ti_nettypes[] = {
 {          "netpath",
   "netpath",          "visible",
   "visible",          "circuit_v",
   "circuit_v",          "datagram_v",
   "datagram_v",          "circuit_n",
   "circuit_n",          "datagram_n",
   "datagram_n",          "udp",
   "udp",          "tcp",
   "tcp",          "raw",
   "raw",          NULL
   NULL  };
   };  
   
 /* valid inetd nettypes */  /* valid inetd nettypes */
 static char* valid_i_nettypes[] =  static char    *valid_i_nettypes[] = {
 {          "udp",
   "udp",          "tcp",
   "tcp",          NULL
   NULL  
 };  };
   
 static int check_nettype( name, list_to_check )  static int
 char* name;  check_nettype(name, list_to_check)
 char* list_to_check[];          char           *name;
           char           *list_to_check[];
 {  {
   int i;          int             i;
   for( i = 0; list_to_check[i] != NULL; i++ ) {          for (i = 0; list_to_check[i] != NULL; i++) {
           if( strcmp( name, list_to_check[i] ) == 0 ) {                  if (strcmp(name, list_to_check[i]) == 0)
             return 1;                          return 1;
           }          }
   }          f_print(stderr, "illegal nettype :\'%s\'\n", name);
   f_print( stderr, "illegal nettype :\'%s\'\n", name );          return 0;
   return 0;  
 }  }
   
 /*  /*
Line 434 
Line 436 
   
 static  static
 c_output(infile, define, extend, outfile)  c_output(infile, define, extend, outfile)
         char *infile;          char           *infile;
         char *define;          char           *define;
         int extend;          int             extend;
         char *outfile;          char           *outfile;
 {  {
         definition *def;          definition     *def;
         char *include;          char           *include;
         char *outfilename;          char           *outfilename;
         long tell;          long            tell;
   
         c_initialize();          c_initialize();
         open_input(infile, define);          open_input(infile, define);
         outfilename = extend ? extendfile(infile, outfile) : outfile;          outfilename = extend ? extendfile(infile, outfile) : outfile;
         open_output(infile, outfilename);          open_output(infile, outfilename);
         add_warning();          add_warning();
Line 454 
Line 456 
                 free(include);                  free(include);
                 /* .h file already contains rpc/rpc.h */                  /* .h file already contains rpc/rpc.h */
         } else          } else
           f_print(fout, "#include <rpc/rpc.h>\n");                  f_print(fout, "#include <rpc/rpc.h>\n");
         tell = ftell(fout);          tell = ftell(fout);
         while (def = get_definition()) {          while (def = get_definition()) {
                 emit(def);                  emit(def);
Line 468 
Line 470 
 c_initialize()  c_initialize()
 {  {
   
   /* add all the starting basic types */          /* add all the starting basic types */
   
   add_type(1,"int");          add_type(1, "int");
   add_type(1,"long");          add_type(1, "long");
   add_type(1,"short");          add_type(1, "short");
   add_type(1,"bool");          add_type(1, "bool");
   
   add_type(1,"u_int");          add_type(1, "u_int");
   add_type(1,"u_long");          add_type(1, "u_long");
   add_type(1,"u_short");          add_type(1, "u_short");
   
 }  }
   
 char rpcgen_table_dcl[] = "struct rpcgen_table {\n\  char            rpcgen_table_dcl[] = "struct rpcgen_table {\n\
         char    *(*proc)();\n\          char    *(*proc)();\n\
         xdrproc_t       xdr_arg;\n\          xdrproc_t       xdr_arg;\n\
         unsigned        len_arg;\n\          unsigned        len_arg;\n\
Line 490 
Line 492 
 };\n";  };\n";
   
   
 char* generate_guard( pathname )  char           *
      char* pathname;  generate_guard(pathname)
           char           *pathname;
 {  {
         char* filename, *guard, *tmp;          char           *filename, *guard, *tmp;
   
         filename = strrchr(pathname, '/' );  /* find last component */          filename = strrchr(pathname, '/');      /* find last component */
         filename = ((filename == 0) ? pathname : filename+1);          filename = ((filename == 0) ? pathname : filename + 1);
         guard = strdup(filename);          guard = strdup(filename);
         /* convert to upper case */          /* convert to upper case */
         tmp = guard;          tmp = guard;
Line 505 
Line 508 
                         *tmp = toupper(*tmp);                          *tmp = toupper(*tmp);
                 tmp++;                  tmp++;
         }          }
   
         guard = extendfile(guard, "_H_RPCGEN");          guard = extendfile(guard, "_H_RPCGEN");
         return( guard );          return (guard);
 }  }
   
 /*  /*
Line 516 
Line 519 
   
 static  static
 h_output(infile, define, extend, outfile)  h_output(infile, define, extend, outfile)
         char *infile;          char           *infile;
         char *define;          char           *define;
         int extend;          int             extend;
         char *outfile;          char           *outfile;
 {  {
         definition *def;          definition     *def;
         char *outfilename;          char           *outfilename;
         long tell;          long            tell;
         char *guard;          char           *guard;
         list *l;          list           *l;
   
         open_input(infile, define);          open_input(infile, define);
         outfilename =  extend ? extendfile(infile, outfile) : outfile;          outfilename = extend ? extendfile(infile, outfile) : outfile;
         open_output(infile, outfilename);          open_output(infile, outfilename);
         add_warning();          add_warning();
         guard = generate_guard(  outfilename ? outfilename: infile );          guard = generate_guard(outfilename ? outfilename : infile);
   
         f_print(fout,"#ifndef _%s\n#define _%s\n\n", guard,          f_print(fout, "#ifndef _%s\n#define _%s\n\n", guard,
                 guard);                  guard);
   
         f_print(fout, "#define RPCGEN_VERSION\t%s\n\n", RPCGEN_VERSION);          f_print(fout, "#define RPCGEN_VERSION\t%s\n\n", RPCGEN_VERSION);
Line 545 
Line 548 
                 print_datadef(def);                  print_datadef(def);
         }          }
   
         /* print function declarations.          /*
            Do this after data definitions because they might be used as           * print function declarations. Do this after data definitions
            arguments for functions */           * because they might be used as arguments for functions
            */
         for (l = defined; l != NULL; l = l->next) {          for (l = defined; l != NULL; l = l->next) {
                 print_funcdef(l->val);                  print_funcdef(l->val);
         }          }
Line 564 
Line 568 
  */   */
 static  static
 s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)  s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
         int argc;          int             argc;
         char *argv[];          char           *argv[];
         char *infile;          char           *infile;
         char *define;          char           *define;
         int extend;          int             extend;
         char *outfile;          char           *outfile;
         int nomain;          int             nomain;
         int netflag;          int             netflag;
 {  {
         char *include;          char           *include;
         definition *def;          definition     *def;
         int foundprogram = 0;          int             foundprogram = 0;
         char *outfilename;          char           *outfilename;
   
         open_input(infile, define);          open_input(infile, define);
         outfilename = extend ? extendfile(infile, outfile) : outfile;          outfilename = extend ? extendfile(infile, outfile) : outfile;
Line 586 
Line 590 
                 f_print(fout, "#include \"%s\"\n", include);                  f_print(fout, "#include \"%s\"\n", include);
                 free(include);                  free(include);
         } else          } else
           f_print(fout, "#include <rpc/rpc.h>\n");                  f_print(fout, "#include <rpc/rpc.h>\n");
   
         f_print(fout, "#include <stdio.h>\n");          f_print(fout, "#include <stdio.h>\n");
         f_print(fout, "#include <stdlib.h>/* getenv, exit */\n");          f_print(fout, "#include <stdlib.h>/* getenv, exit */\n");
         if (Cflag) {          if (Cflag) {
                 f_print (fout,                  f_print(fout,
                         "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");                          "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
                 f_print (fout, "#include <string.h> /* strcmp */ \n");                  f_print(fout, "#include <string.h> /* strcmp */ \n");
         }          }
         f_print(fout, "#include <netdb.h>\n"); /*evas*/          f_print(fout, "#include <netdb.h>\n");  /* evas */
         if (strcmp(svcclosetime, "-1") == 0)          if (strcmp(svcclosetime, "-1") == 0)
                 indefinitewait = 1;                  indefinitewait = 1;
         else if (strcmp(svcclosetime, "0") == 0)          else if (strcmp(svcclosetime, "0") == 0)
                 exitnow = 1;                  exitnow = 1;
         else if (inetdflag || pmflag) {          else if (inetdflag || pmflag) {
                 f_print(fout, "#include <signal.h>\n");                  f_print(fout, "#include <signal.h>\n");
           timerflag = 1;                  timerflag = 1;
         }          }
           if (!tirpcflag && inetdflag)
                   f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
           if (Cflag && (inetdflag || pmflag)) {
                   f_print(fout, "#ifdef __cplusplus\n");
                   f_print(fout, "#include <sysent.h> /* getdtablesize, open */\n");
                   f_print(fout, "#endif /* __cplusplus */\n");
   
         if( !tirpcflag && inetdflag )                  if (tirpcflag)
           f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");                          f_print(fout, "#include <unistd.h> /* setsid */\n");
         if( Cflag && (inetdflag || pmflag ) ) {  
           f_print(fout, "#ifdef __cplusplus\n");  
           f_print(fout, "#include <sysent.h> /* getdtablesize, open */\n");  
           f_print(fout, "#endif /* __cplusplus */\n");  
   
           if( tirpcflag )  
             f_print(fout, "#include <unistd.h> /* setsid */\n");  
         }          }
         if( tirpcflag )          if (tirpcflag)
           f_print(fout, "#include <sys/types.h>\n");                  f_print(fout, "#include <sys/types.h>\n");
   
         f_print(fout, "#include <memory.h>\n");          f_print(fout, "#include <memory.h>\n");
         if (tirpcflag)          if (tirpcflag)
                 f_print(fout, "#include <stropts.h>\n");                  f_print(fout, "#include <stropts.h>\n");
   
         if (inetdflag || !tirpcflag ) {          if (inetdflag || !tirpcflag) {
                 f_print(fout, "#include <sys/socket.h>\n");                  f_print(fout, "#include <sys/socket.h>\n");
                 f_print(fout, "#include <netinet/in.h>\n");                  f_print(fout, "#include <netinet/in.h>\n");
         }          }
           if ((netflag || pmflag) && tirpcflag) {
         if ( (netflag || pmflag) && tirpcflag ) {  
                 f_print(fout, "#include <netconfig.h>\n");                  f_print(fout, "#include <netconfig.h>\n");
         }          }
         if (/*timerflag &&*/ tirpcflag)          if ( /* timerflag && */ tirpcflag)
                 f_print(fout, "#include <sys/resource.h> /* rlimit */\n");                  f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
         if (logflag || inetdflag || pmflag) {          if (logflag || inetdflag || pmflag) {
                 f_print(fout, "#include <syslog.h>\n");                  f_print(fout, "#include <syslog.h>\n");
                 f_print(fout, "#include <errno.h>\n");                  f_print(fout, "#include <errno.h>\n");
         }          }
   
         /* for ANSI-C */          /* for ANSI-C */
         f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");          f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
   
Line 650 
Line 651 
                 (void) unlink(outfilename);                  (void) unlink(outfilename);
                 return;                  return;
         }          }
         if (callerflag)                                         /*EVAS*/          if (callerflag)         /* EVAS */
                 f_print(fout, "\nstatic SVCXPRT *caller;\n");   /*EVAS*/                  f_print(fout, "\nstatic SVCXPRT *caller;\n");   /* EVAS */
         write_most(infile, netflag, nomain);          write_most(infile, netflag, nomain);
         if (!nomain) {          if (!nomain) {
                 if( !do_registers(argc, argv) ) {                  if (!do_registers(argc, argv)) {
                   if (outfilename)                          if (outfilename)
                     (void) unlink(outfilename);                                  (void) unlink(outfilename);
                   usage();                          usage();
                 }                  }
                 write_rest();                  write_rest();
         }          }
Line 668 
Line 669 
  */   */
 static  static
 l_output(infile, define, extend, outfile)  l_output(infile, define, extend, outfile)
         char *infile;          char           *infile;
         char *define;          char           *define;
         int extend;          int             extend;
         char *outfile;          char           *outfile;
 {  {
         char *include;          char           *include;
         definition *def;          definition     *def;
         int foundprogram = 0;          int             foundprogram = 0;
         char *outfilename;          char           *outfilename;
   
         open_input(infile, define);          open_input(infile, define);
         outfilename = extend ? extendfile(infile, outfile) : outfile;          outfilename = extend ? extendfile(infile, outfile) : outfile;
         open_output(infile, outfilename);          open_output(infile, outfilename);
         add_warning();          add_warning();
         if (Cflag)          if (Cflag)
           f_print (fout, "#include <memory.h> /* for memset */\n");                  f_print(fout, "#include <memory.h> /* for memset */\n");
         if (infile && (include = extendfile(infile, ".h"))) {          if (infile && (include = extendfile(infile, ".h"))) {
                 f_print(fout, "#include \"%s\"\n", include);                  f_print(fout, "#include \"%s\"\n", include);
                 free(include);                  free(include);
         } else          } else
           f_print(fout, "#include <rpc/rpc.h>\n");                  f_print(fout, "#include <rpc/rpc.h>\n");
         while (def = get_definition()) {          while (def = get_definition())
                 foundprogram |= (def->def_kind == DEF_PROGRAM);                  foundprogram |= (def->def_kind == DEF_PROGRAM);
         }  
         if (extend && !foundprogram) {          if (extend && !foundprogram) {
                 (void) unlink(outfilename);                  (void) unlink(outfilename);
                 return;                  return;
Line 704 
Line 705 
  */   */
 static  static
 t_output(infile, define, extend, outfile)  t_output(infile, define, extend, outfile)
         char *infile;          char           *infile;
         char *define;          char           *define;
         int extend;          int             extend;
         char *outfile;          char           *outfile;
 {  {
         definition *def;          definition     *def;
         int foundprogram = 0;          int             foundprogram = 0;
         char *outfilename;          char           *outfilename;
   
         open_input(infile, define);          open_input(infile, define);
         outfilename = extend ? extendfile(infile, outfile) : outfile;          outfilename = extend ? extendfile(infile, outfile) : outfile;
         open_output(infile, outfilename);          open_output(infile, outfilename);
         add_warning();          add_warning();
         while (def = get_definition()) {          while (def = get_definition())
                 foundprogram |= (def->def_kind == DEF_PROGRAM);                  foundprogram |= (def->def_kind == DEF_PROGRAM);
         }  
         if (extend && !foundprogram) {          if (extend && !foundprogram) {
                 (void) unlink(outfilename);                  (void) unlink(outfilename);
                 return;                  return;
Line 728 
Line 729 
 }  }
   
 /* sample routine for the server template */  /* sample routine for the server template */
 static  static
 svc_output(infile, define, extend, outfile)  svc_output(infile, define, extend, outfile)
      char *infile;          char           *infile;
      char *define;          char           *define;
      int extend;          int             extend;
      char *outfile;          char           *outfile;
 {  {
   definition *def;          definition     *def;
   char *include;          char           *include;
   char *outfilename;          char           *outfilename;
   long tell;          long            tell;
   
   open_input(infile, define);  
   outfilename = extend ? extendfile(infile, outfile) : outfile;  
   checkfiles(infile,outfilename); /*check if outfile already exists.  
                                   if so, print an error message and exit*/  
   open_output(infile, outfilename);  
   add_sample_msg();  
   
   if (infile && (include = extendfile(infile, ".h"))) {          open_input(infile, define);
     f_print(fout, "#include \"%s\"\n", include);          outfilename = extend ? extendfile(infile, outfile) : outfile;
     free(include);          checkfiles(infile, outfilename);        /* check if outfile already
   } else                                                   * exists. if so, print an
     f_print(fout, "#include <rpc/rpc.h>\n");                                                   * error message and exit */
           open_output(infile, outfilename);
           add_sample_msg();
   
   tell = ftell(fout);          if (infile && (include = extendfile(infile, ".h"))) {
   while (def = get_definition()) {                  f_print(fout, "#include \"%s\"\n", include);
           write_sample_svc(def);                  free(include);
   }          } else
   if (extend && tell == ftell(fout)) {                  f_print(fout, "#include <rpc/rpc.h>\n");
           (void) unlink(outfilename);  
   }          tell = ftell(fout);
           while (def = get_definition())
                   write_sample_svc(def);
   
           if (extend && tell == ftell(fout))
                   (void) unlink(outfilename);
 }  }
   
   
 /* sample main routine for client */  /* sample main routine for client */
 static  static
 clnt_output(infile, define, extend, outfile)  clnt_output(infile, define, extend, outfile)
      char *infile;          char           *infile;
      char *define;          char           *define;
      int extend;          int             extend;
      char *outfile;          char           *outfile;
 {  {
   definition *def;          definition *def;
   char *include;          char *include, *outfilename;
   char *outfilename;          long tell;
   long tell;          int has_program = 0;
   int has_program = 0;  
   
   open_input(infile, define);  
   outfilename = extend ? extendfile(infile, outfile) : outfile;  
   checkfiles(infile,outfilename); /*check if outfile already exists.  
                                   if so, print an error message and exit*/  
   
   open_output(infile, outfilename);          open_input(infile, define);
   add_sample_msg();          outfilename = extend ? extendfile(infile, outfile) : outfile;
   if (infile && (include = extendfile(infile, ".h"))) {  
     f_print(fout, "#include \"%s\"\n", include);  
     free(include);  
   } else  
     f_print(fout, "#include <rpc/rpc.h>\n");  
   tell = ftell(fout);  
   while (def = get_definition()) {  
     has_program += write_sample_clnt(def);  
   }  
   
   if( has_program )          /*
     write_sample_clnt_main();           * check if outfile already exists. if so,
            * print an error message and exit
            */
           checkfiles(infile, outfilename);
   
   if (extend && tell == ftell(fout)) {          open_output(infile, outfilename);
     (void) unlink(outfilename);          add_sample_msg();
   }          if (infile && (include = extendfile(infile, ".h"))) {
                   f_print(fout, "#include \"%s\"\n", include);
                   free(include);
           } else
                   f_print(fout, "#include <rpc/rpc.h>\n");
           tell = ftell(fout);
           while (def = get_definition())
                   has_program += write_sample_clnt(def);
   
           if (has_program)
                   write_sample_clnt_main();
   
           if (extend && tell == ftell(fout))
                   (void) unlink(outfilename);
 }  }
   
 /*  /*
  * Perform registrations for service output   * Perform registrations for service output
  * Return 0 if failed; 1 otherwise.   * Return 0 if failed; 1 otherwise.
  */   */
 static  static
 int do_registers(argc, argv)  int
         int argc;  do_registers(argc, argv)
         char *argv[];          int             argc;
           char           *argv[];
 {  {
         int i;          int             i;
   
         if ( inetdflag || !tirpcflag) {          if (inetdflag || !tirpcflag) {
                 for (i = 1; i < argc; i++) {                  for (i = 1; i < argc; i++) {
                         if (streq(argv[i], "-s")) {                          if (streq(argv[i], "-s")) {
                                 if(!check_nettype( argv[i + 1], valid_i_nettypes ))                                  if (!check_nettype(argv[i + 1], valid_i_nettypes))
                                   return 0;                                          return 0;
                                 write_inetd_register(argv[i + 1]);                                  write_inetd_register(argv[i + 1]);
                                 i++;                                  i++;
                         }                          }
                 }                  }
         } else {          } else {
                 for (i = 1; i < argc; i++)                  for (i = 1; i < argc; i++)
                         if (streq(argv[i], "-s")) {                          if (streq(argv[i], "-s")) {
                                 if(!check_nettype( argv[i + 1], valid_ti_nettypes ))                                  if (!check_nettype(argv[i + 1], valid_ti_nettypes))
                                   return 0;                                          return 0;
                                 write_nettype_register(argv[i + 1]);                                  write_nettype_register(argv[i + 1]);
                                 i++;                                  i++;
                         } else if (streq(argv[i], "-n")) {                          } else if (streq(argv[i], "-n")) {
Line 842 
Line 845 
  */   */
 static void  static void
 addarg(cp)  addarg(cp)
         char *cp;          char           *cp;
 {  {
         if (argcount >= ARGLISTLEN) {          if (argcount >= ARGLISTLEN) {
                 f_print(stderr, "rpcgen: too many defines\n");                  f_print(stderr, "rpcgen: too many defines\n");
                 crash();                  crash();
                 /*NOTREACHED*/                  /* NOTREACHED */
         }          }
         arglist[argcount++] = cp;          arglist[argcount++] = cp;
   
Line 855 
Line 858 
   
 static void  static void
 putarg(where, cp)  putarg(where, cp)
         char *cp;          char           *cp;
         int where;          int             where;
 {  {
         if (where >= ARGLISTLEN) {          if (where >= ARGLISTLEN) {
                 f_print(stderr, "rpcgen: arglist coding error\n");                  f_print(stderr, "rpcgen: arglist coding error\n");
                 crash();                  crash();
                 /*NOTREACHED*/                  /* NOTREACHED */
         }          }
         arglist[where] = cp;          arglist[where] = cp;
   
 }  }
   
 /*  /*
  * if input file is stdin and an output file is specified then complain   * if input file is stdin and an output file is specified then complain
  * if the file already exists. Otherwise the file may get overwritten   * if the file already exists. Otherwise the file may get overwritten
  * If input file does not exist, exit with an error   * If input file does not exist, exit with an error
  */   */
   
 static void  static void
 checkfiles(infile, outfile)  checkfiles(infile, outfile)
 char *infile;          char           *infile;
 char *outfile;          char           *outfile;
 {  {
   
   struct stat buf;          struct stat     buf;
   
   if(infile)                    /* infile ! = NULL */          if (infile)             /* infile ! = NULL */
     if(stat(infile,&buf) < 0)                  if (stat(infile, &buf) < 0) {
       {                          perror(infile);
         perror(infile);                          crash();
         crash();                  }
       }  
 #if 0  #if 0
   if (outfile) {          if (outfile) {
     if (stat(outfile, &buf) < 0)                  if (stat(outfile, &buf) < 0)
       return;                   /* file does not exist */                          return; /* file does not exist */
     else {                  else {
       f_print(stderr,                          f_print(stderr,
               "file '%s' already exists and may be overwritten\n", outfile);                              "file '%s' already exists and may be overwritten\n",
       crash();                              outfile);
     }                          crash();
   }                  }
           }
 #endif  #endif
 }  }
   
 /*  /*
  * Parse command line arguments   * Parse command line arguments
  */   */
 static int  static int
 parseargs(argc, argv, cmd)  parseargs(argc, argv, cmd)
Line 909 
Line 910 
         char *argv[];          char *argv[];
         struct commandline *cmd;          struct commandline *cmd;
 {  {
         int i;          int i, j, nflags;
         int j;          char c, flag[(1 << 8 * sizeof(char))];
         char c;  
         char flag[(1 << 8 * sizeof(char))];  
         int nflags;  
   
         cmdname = argv[0];          cmdname = argv[0];
         cmd->infile = cmd->outfile = NULL;          cmd->infile = cmd->outfile = NULL;
         if (argc < 2) {          if (argc < 2)
                 return (0);                  return (0);
         }  
         allfiles = 0;          allfiles = 0;
         flag['c'] = 0;          flag['c'] = 0;
         flag['h'] = 0;          flag['h'] = 0;
Line 934 
Line 932 
         for (i = 1; i < argc; i++) {          for (i = 1; i < argc; i++) {
                 if (argv[i][0] != '-') {                  if (argv[i][0] != '-') {
                         if (cmd->infile) {                          if (cmd->infile) {
                                 f_print( stderr, "Cannot specify more than one input file!\n");                                  f_print(stderr,
                                       "Cannot specify more than one input file!\n");
                                 return (0);                                  return (0);
                         }                          }
                         cmd->infile = argv[i];                          cmd->infile = argv[i];
Line 954 
Line 952 
                                 case 'l':                                  case 'l':
                                 case 'm':                                  case 'm':
                                 case 't':                                  case 't':
                                         if (flag[c]) {                                          if (flag[c])
                                                 return (0);                                                  return (0);
                                         }  
                                         flag[c] = 1;                                          flag[c] = 1;
                                         break;                                          break;
                                 case 'S':                                  case 'S':
                                         /* sample flag: Ss or Sc.                                          /*
                                            Ss means set flag['S'];                                           * sample flag: Ss or Sc. Ss means
                                            Sc means set flag['C']; */                                           * set flag['S']; Sc means set
                                         c = argv[i][++j];  /* get next char */                                           * flag['C'];
                                         if( c == 's' )                                           */
                                           c = 'S';                                          c = argv[i][++j];       /* get next char */
                                         else if( c == 'c' )                                          if (c == 's')
                                           c = 'C';                                                  c = 'S';
                                           else if (c == 'c')
                                                   c = 'C';
                                         else                                          else
                                           return( 0 );                                                  return (0);
   
                                         if (flag[c]) {                                          if (flag[c])
                                                 return (0);                                                  return (0);
                                         }  
                                         flag[c] = 1;                                          flag[c] = 1;
                                         break;                                          break;
                                 case 'C':  /* ANSI C syntax */                                  case 'C':       /* ANSI C syntax */
                                         Cflag = 1;                                          Cflag = 1;
                                         break;                                          break;
   
                                 case 'b':  /* turn TIRPC flag off for                                  case 'b':
                                             generating backward compatible                                          /*
                                             */                                           * turn TIRPC flag off for
                                            * generating backward compatible
                                            */
                                         tirpcflag = 0;                                          tirpcflag = 0;
                                         break;                                          break;
   
Line 996 
Line 996 
                                         logflag = 1;                                          logflag = 1;
                                         break;                                          break;
                                 case 'K':                                  case 'K':
                                         if (++i == argc) {                                          if (++i == argc)
                                                 return (0);                                                  return (0);
                                         }  
                                         svcclosetime = argv[i];                                          svcclosetime = argv[i];
                                         goto nextarg;                                          goto nextarg;
                                 case 'T':                                  case 'T':
                                         tblflag = 1;                                          tblflag = 1;
                                         break;                                          break;
                                 case 'i' :                                  case 'i':
                                         if (++i == argc) {                                          if (++i == argc)
                                                 return (0);                                                  return (0);
                                         }  
                                         doinline = atoi(argv[i]);                                          doinline = atoi(argv[i]);
                                         goto nextarg;                                          goto nextarg;
                                 case 'n':                                  case 'n':
                                 case 'o':                                  case 'o':
                                 case 's':                                  case 's':
                                         if (argv[i][j - 1] != '-' ||                                          if (argv[i][j - 1] != '-' ||
                                             argv[i][j + 1] != 0) {                                              argv[i][j + 1] != 0)
                                                 return (0);                                                  return (0);
                                         }  
                                         flag[c] = 1;                                          flag[c] = 1;
                                         if (++i == argc) {                                          if (++i == argc)
                                                 return (0);                                                  return (0);
                                         }  
                                         if (c == 's') {                                          if (c == 's') {
                                                 if (!streq(argv[i], "udp") &&                                                  if (!streq(argv[i], "udp") &&
                                                     !streq(argv[i], "tcp")) {                                                      !streq(argv[i], "tcp"))
                                                         return (0);                                                          return (0);
                                                 }  
                                         } else if (c == 'o') {                                          } else if (c == 'o') {
                                                 if (cmd->outfile) {                                                  if (cmd->outfile)
                                                         return (0);                                                          return (0);
                                                 }  
                                                 cmd->outfile = argv[i];                                                  cmd->outfile = argv[i];
                                         }                                          }
                                         goto nextarg;                                          goto nextarg;
                                 case 'D':                                  case 'D':
                                         if (argv[i][j - 1] != '-') {                                          if (argv[i][j - 1] != '-')
                                                 return (0);                                                  return (0);
                                         }  
                                         (void) addarg(argv[i]);                                          (void) addarg(argv[i]);
                                         goto nextarg;                                          goto nextarg;
                                 case 'Y':                                  case 'Y':
                                         if (++i == argc) {                                          if (++i == argc)
                                                 return (0);                                                  return (0);
                                         }  
                                         if (snprintf(pathbuf, sizeof pathbuf,                                          if (snprintf(pathbuf, sizeof pathbuf,
                                             "%s/cpp", argv[i]) >= sizeof pathbuf)                                              "%s/cpp", argv[i]) >= sizeof pathbuf)
                                                 usage();                                                  usage();
                                         CPP = pathbuf;                                          CPP = pathbuf;
                                         cppDefined = 1;                                          cppDefined = 1;
                                         goto nextarg;                                          goto nextarg;
   
   
   
                                 default:                                  default:
                                         return (0);                                          return (0);
                                 }                                  }
Line 1071 
Line 1060 
         cmd->Ssflag = flag['S'];          cmd->Ssflag = flag['S'];
         cmd->Scflag = flag['C'];          cmd->Scflag = flag['C'];
   
         if( tirpcflag ) {          if (tirpcflag) {
           pmflag = inetdflag ? 0 : 1;     /* pmflag or inetdflag is always TRUE */                  pmflag = inetdflag ? 0 : 1;     /* pmflag or inetdflag is
           if( (inetdflag && cmd->nflag)) { /* netid not allowed with inetdflag */                                                   * always TRUE */
             f_print(stderr, "Cannot use netid flag with inetd flag!\n");                  if (inetdflag && cmd->nflag) {
             return (0);                          /* netid not allowed with inetdflag */
           }                          f_print(stderr, "Cannot use netid flag with inetd flag!\n");
         } else {  /* 4.1 mode */                          return (0);
           pmflag = 0;               /* set pmflag only in tirpcmode */                  }
           inetdflag = 1;            /* inetdflag is TRUE by default */          } else {
           if( cmd->nflag ) {          /* netid needs TIRPC */                  /* 4.1 mode */
             f_print( stderr, "Cannot use netid flag without TIRPC!\n");                  pmflag = 0;     /* set pmflag only in tirpcmode */
             return( 0 );                  inetdflag = 1;  /* inetdflag is TRUE by default */
           }                  if (cmd->nflag) {
                           /* netid needs TIRPC */
                           f_print(stderr, "Cannot use netid flag without TIRPC!\n");
                           return (0);
                   }
         }          }
   
         if( newstyle && ( tblflag || cmd->tflag) ) {          if (newstyle && (tblflag || cmd->tflag)) {
           f_print( stderr, "Cannot use table flags with newstyle!\n");                  f_print(stderr, "Cannot use table flags with newstyle!\n");
           return( 0 );                  return (0);
         }          }
   
         /* check no conflicts with file generation flags */          /* check no conflicts with file generation flags */
         nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +          nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +
                 cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;              cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;
   
         if (nflags == 0) {          if (nflags == 0) {
                 if (cmd->outfile != NULL || cmd->infile == NULL) {                  if (cmd->outfile != NULL || cmd->infile == NULL)
                         return (0);                          return (0);
                 }  
         } else if (nflags > 1) {          } else if (nflags > 1) {
                 f_print( stderr, "Cannot have more than one file generation flag!\n");                  f_print(stderr, "Cannot have more than one file generation flag!\n");
                 return (0);                  return (0);
         }          }
         return (1);          return (1);
Line 1109 
Line 1100 
 static  static
 usage()  usage()
 {  {
         f_print(stderr, "usage:  %s infile\n", cmdname);          f_print(stderr, "usage: %s [-abACILNT] [-Dname[=value]] [-i lines] "
         f_print(stderr, "\t%s [-a][-b][-C][-Dname[=value]] -i size  [-I [-K seconds]] [-A][-L][-M toolkit][-N][-T] infile\n",              "[-K seconds] infile\n", cmdname);
                         cmdname);          f_print(stderr, "       %s [-c | -h | -l | -m | -t | -Sc | -Ss] "
         f_print(stderr, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",              "[-o outfile] [infile]\n", cmdname);
                         cmdname);          f_print(stderr, "       %s [-s nettype]* [-o outfile] [infile]\n", cmdname);
         f_print(stderr, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname);  
         f_print(stderr, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname);  
         options_usage();  
         exit(1);  
 }  
   
 static  
 options_usage()  
 {  
         f_print(stderr, "options:\n");  
         f_print(stderr, "-A\t\tgenerate svc_caller() function\n");  
         f_print(stderr, "-a\t\tgenerate all files, including samples\n");  
         f_print(stderr, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");  
         f_print(stderr, "-c\t\tgenerate XDR routines\n");  
         f_print(stderr, "-C\t\tANSI C mode\n");  
         f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n");  
         f_print(stderr, "-h\t\tgenerate header file\n");  
         f_print(stderr, "-i size\t\tsize at which to start generating inline code\n");  
         f_print(stderr, "-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n");  
         f_print(stderr, "-K seconds\tserver exits after K seconds of inactivity\n");  
         f_print(stderr, "-l\t\tgenerate client side stubs\n");  
         f_print(stderr, "-L\t\tserver errors will be printed to syslog\n");  
         f_print(stderr, "-m\t\tgenerate server side stubs\n");  
         f_print(stderr, "-n netid\tgenerate server code that supports named netid\n");  
         f_print(stderr, "-N\t\tsupports multiple arguments and call-by-value\n");  
         f_print(stderr, "-o outfile\tname of the output file\n");  
         f_print(stderr, "-s nettype\tgenerate server code that supports named nettype\n");  
         f_print(stderr, "-Sc\t\tgenerate sample client code that uses remote procedures\n");  
         f_print(stderr, "-Ss\t\tgenerate sample server code that defines remote procedures\n");  
         f_print(stderr, "-t\t\tgenerate RPC dispatch table\n");  
         f_print(stderr, "-T\t\tgenerate code to support RPC dispatch tables\n");  
         f_print(stderr, "-Y path\t\tdirectory name to find C preprocessor (cpp)\n");  
   
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11