Print this page
rpcgen should only produce ANSI code

@@ -18,10 +18,12 @@
  *
  * CDDL HEADER END
  */
 
 /*
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ *
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
 /* All Rights Reserved */

@@ -134,11 +136,10 @@
 
 int indefinitewait;     /* If started by port monitors, hang till it wants */
 int exitnow;            /* If started by port monitors, exit after the call */
 int timerflag;          /* TRUE if !indefinite && !exitnow */
 int newstyle;           /* newstyle of passing arguments (by value) */
-int Cflag = 0;          /* ANSI C syntax */
 int CCflag = 0;         /* C++ files */
 static int allfiles;   /* generate all files */
 int tirpcflag = 1;    /* generating code for tirpc, by default */
 xdrfunc *xdrfunc_head = NULL; /* xdr function list */
 xdrfunc *xdrfunc_tail = NULL; /* xdr function list */

@@ -513,11 +514,10 @@
         char *outfilename;
         long tell;
         char *guard;
         list *l;
         xdrfunc *xdrfuncp;
-        int i;
 
         open_input(infile, define);
         outfilename =  extend ? extendfile(infile, outfile) : outfile;
         open_output(infile, outfilename);
         add_warning();

@@ -536,17 +536,17 @@
                 f_print(fout, "#include <thread.h>\n");
                 f_print(fout, "#endif /* !_KERNEL */\n");
         };
 
         /* put the C++ support */
-        if (Cflag && !CCflag) {
+        if (!CCflag) {
                 f_print(fout, "\n#ifdef __cplusplus\n");
                 f_print(fout, "extern \"C\" {\n");
                 f_print(fout, "#endif\n\n");
         }
 
-        /* put in a typedef for quadprecision. Only with Cflag */
+        /* put in a typedef for quadprecision. */
 
         /*
          * declaration of struct rpcgen_table must go before
          *  the definition of arrays like *_1_table[]
          */

@@ -580,45 +580,27 @@
                         f_print(fout, "\n#ifdef __cplusplus\n");
                         f_print(fout, "extern \"C\" {\n");
                         f_print(fout, "#endif\n");
                 }
 
-                if (!Cflag) {
-                        xdrfuncp = xdrfunc_head;
-                        while (xdrfuncp != NULL) {
-                                print_xdr_func_def(xdrfuncp->name,
-                                    xdrfuncp->pointerp, 2);
-                                xdrfuncp = xdrfuncp->next;
-                        }
-                } else {
-                        for (i = 1; i < 3; i++) {
-                                if (i == 1)
-                                        f_print(fout,
-"\n#if defined(__STDC__) || defined(__cplusplus)\n");
-                                else
-                                        f_print(fout, "\n#else /* K&R C */\n");
+                f_print(fout, "\n");
 
                                 xdrfuncp = xdrfunc_head;
                                 while (xdrfuncp != NULL) {
-                                        print_xdr_func_def(xdrfuncp->name,
-                                            xdrfuncp->pointerp, i);
+                        print_xdr_func_def(xdrfuncp->name, xdrfuncp->pointerp);
                                         xdrfuncp = xdrfuncp->next;
                                 }
+                f_print(fout, "\n");
                         }
-                        f_print(fout, "\n#endif /* K&R C */\n");
-                }
-        }
 
         if (extend && tell == ftell(fout)) {
                 (void) unlink(outfilename);
         }
 
-        if (Cflag) {
                 f_print(fout, "\n#ifdef __cplusplus\n");
                 f_print(fout, "}\n");
                 f_print(fout, "#endif\n");
-        }
 
         f_print(fout, "\n#endif /* !_%s */\n", guard);
 }
 
 /*

@@ -645,31 +627,29 @@
 
         f_print(fout, "#include <stdio.h>\n");
         f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
         f_print(fout, "#include <signal.h>\n");
 
-        if (Cflag) {
                 f_print(fout,
                 "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
                 f_print(fout, "#include <string.h> /* strcmp */\n");
-        }
+
         if (strcmp(svcclosetime, "-1") == 0)
                 indefinitewait = 1;
         else if (strcmp(svcclosetime, "0") == 0)
                 exitnow = 1;
         else if (inetdflag || pmflag)
                 timerflag = 1;
 
         if (!tirpcflag && inetdflag)
                 f_print(fout, "#include <sys/termios.h> /* TIOCNOTTY */\n");
-        if (Cflag && (inetdflag || pmflag))
+        if (inetdflag || pmflag)
                 if (tirpcflag)
                         f_print(fout, "#include <unistd.h> /* setsid */\n");
         if (tirpcflag)
                 f_print(fout, "#include <sys/types.h>\n");
 
-        f_print(fout, "#include <memory.h>\n");
         f_print(fout, "#include <stropts.h>\n");
         if (inetdflag || !tirpcflag) {
                 f_print(fout, "#include <sys/socket.h>\n");
                 f_print(fout, "#include <netinet/in.h>\n");
                 f_print(fout, "#include <rpc/svc_soc.h>\n");

@@ -681,14 +661,12 @@
                 f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
         if (logflag || inetdflag || pmflag)
                 f_print(fout, "#include <syslog.h>\n");
 
         /* for ANSI-C */
-        if (Cflag)
-                f_print(fout,
-                    "\n#ifndef SIG_PF\n#define  SIG_PF void(*)\
-(int)\n#endif\n");
+        f_print(fout, "\n#ifndef SIG_PF\n"
+            "#define    SIG_PF void(*)(int)\n#endif\n");
 
         f_print(fout, "\n#ifdef DEBUG\n#define  RPC_SVC_FG\n#endif\n");
         if (timerflag)
                 f_print(fout, "\n#define        _RPCSVC_CLOSEDOWN %s\n",
                     svcclosetime);

@@ -722,11 +700,10 @@
 
         open_input(infile, define);
         outfilename = extend ? extendfile(infile, outfile) : outfile;
         open_output(infile, outfilename);
         add_warning();
-        if (Cflag)
                 f_print(fout, "#include <memory.h> /* for memset */\n");
         if (infile && (include = extendfile(infile, ".h"))) {
                 f_print(fout, "#include \"%s\"\n", include);
                 free(include);
         } else

@@ -1100,16 +1077,16 @@
 
                                         if (flag[ch])
                                                 return (0);
                                         flag[ch] = 1;
                                         break;
-                                case 'C': /* ANSI C syntax */
-                                        Cflag = 1;
+                                case 'C': /* ANSI C syntax (default) */
                                         ch = argv[i][j+1]; /* get next char */
 
                                         if (ch != 'C')
                                                 break;
+                                        /* Undocumented C++ mode */
                                         CCflag = 1;
                                         break;
                                 case 'b':
                                         /*
                                          *  Turn TIRPC flag off for