cpp-fixes-20080630
[openafs.git] / src / rxgen / rpc_main.c
index b4463a5..e2d2b56 100644 (file)
@@ -43,13 +43,7 @@ RCSID
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
 #endif
@@ -66,6 +60,7 @@ RCSID
 #define EXTEND 1               /* alias for TRUE */
 
 struct commandline {
+    int ansic_flag;
     int cflag;
     int hflag;
     int lflag;
@@ -79,6 +74,7 @@ struct commandline {
     int dflag;
     int xflag;
     int yflag;
+    int uflag;
     char *infile;
     char *outfile;
 };
@@ -91,20 +87,15 @@ static char *IncludeDir[MAXCPPARGS];
 int nincludes = 0;
 char *OutFileFlag = "";
 char OutFile[256];
-char Sflag = 0, Cflag = 0, hflag = 0, cflag = 0, kflag = 0;
+char Sflag = 0, Cflag = 0, hflag = 0, cflag = 0, kflag = 0, uflag = 0;
+char ansic_flag = 0;           /* If set, build ANSI C style prototypes */
 char zflag = 0;                        /* If set, abort server stub if rpc call returns non-zero */
 char xflag = 0;                        /* if set, add stats code to stubs */
 char yflag = 0;                        /* if set, only emit function name arrays to xdr file */
 int debug = 0;
 static char *cmdname;
-#ifdef AFS_SUN5_ENV
-static char CPP[] = "/usr/ccs/lib/cpp";
-#elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN60_ENV)
-static char CPP[] = "/usr/bin/cpp";
-#elif defined(AFS_NT40_ENV)
-static char CPP[MAXCMDLINE];
-#elif defined(AFS_DARWIN_ENV)
-static char CPP[] = "cc -E";
+#ifdef PATH_CPP
+static char CPP[] = PATH_CPP;
 #else
 static char CPP[] = "/lib/cpp";
 #endif
@@ -181,7 +172,7 @@ main(int argc, char *argv[])
     if (!parseargs(argc, argv, &cmd)) {
        f_print(stderr, "usage: %s infile\n", cmdname);
        f_print(stderr,
-               "       %s [-c | -h | -l | -m | -C | -S | -r | -k | -R | -p | -d | -z] [-Pprefix] [-Idir] [-o outfile] [infile]\n",
+               "       %s [-c | -h | -l | -m | -C | -S | -r | -k | -R | -p | -d | -z | -u] [-Pprefix] [-Idir] [-o outfile] [infile]\n",
                cmdname);
        f_print(stderr, "       %s [-s udp|tcp]* [-o outfile] [infile]\n",
                cmdname);
@@ -470,15 +461,15 @@ h_output(char *infile, char *define, int extend, char *outfile, int append)
     if (xflag) {
        f_print(fout, "#include \"rx/rx_globals.h\"\n");
     }
+    if (uflag)
+       f_print(fout, "#include <ubik.h>\n");
     f_print(fout, "#else       /* UKERNEL */\n");
     f_print(fout, "#include \"h/types.h\"\n");
     f_print(fout, "#ifndef     SOCK_DGRAM  /* XXXXX */\n");
     f_print(fout, "#include \"h/socket.h\"\n");
     f_print(fout, "#endif\n");
+    f_print(fout, "struct ubik_client;\n");
     f_print(fout, "#ifndef     DTYPE_SOCKET  /* XXXXX */\n");
-    f_print(fout, "#ifdef AFS_DEC_ENV\n");
-    f_print(fout, "#include \"h/smp_lock.h\"\n");
-    f_print(fout, "#endif\n");
     f_print(fout, "#ifndef AFS_LINUX22_ENV\n");
     f_print(fout, "#include \"h/file.h\"\n");
     f_print(fout, "#endif\n");
@@ -524,6 +515,8 @@ h_output(char *infile, char *define, int extend, char *outfile, int append)
        f_print(fout, "#include <rx/rx_globals.h>\n");
     }
     f_print(fout, "#include <afs/rxgen_consts.h>\n");
+    if (uflag)
+       f_print(fout, "#include <ubik.h>\n");
     f_print(fout, "#endif      /* KERNEL */\n\n");
     f_print(fout, "#ifdef AFS_NT40_ENV\n");
     f_print(fout, "#ifndef AFS_RXGEN_EXPORT\n");
@@ -767,7 +760,7 @@ uppercase(char *str)
 {
     static char max_size[100];
     char *pnt;
-    int len = strlen(str);
+    int len = (int)strlen(str);
 
     for (pnt = max_size; len > 0; len--, str++) {
        *pnt++ = (islower(*str) ? toupper(*str) : *str);
@@ -785,7 +778,7 @@ parseargs(int argc, char *argv[], struct commandline *cmd)
     int i;
     int j;
     char c;
-    char flag[(1 << 8 * sizeof(char))];
+    char flag[(1 << (8 * sizeof(char)))];
     int nflags;
 
     cmdname = argv[0];
@@ -805,6 +798,7 @@ parseargs(int argc, char *argv[], struct commandline *cmd)
            for (j = 1; argv[i][j] != 0; j++) {
                c = argv[i][j];
                switch (c) {
+               case 'A':
                case 'c':
                case 'h':
                case 'l':
@@ -816,6 +810,7 @@ parseargs(int argc, char *argv[], struct commandline *cmd)
                case 'k':
                case 'p':
                case 'd':
+               case 'u':
                case 'x':
                case 'y':
                case 'z':
@@ -862,6 +857,7 @@ parseargs(int argc, char *argv[], struct commandline *cmd)
            ;
        }
     }
+    cmd->ansic_flag = ansic_flag = flag['A'];
     cmd->cflag = cflag = flag['c'];
     cmd->hflag = hflag = flag['h'];
     cmd->sflag = flag['s'];
@@ -872,6 +868,7 @@ parseargs(int argc, char *argv[], struct commandline *cmd)
     cmd->Cflag = Cflag = flag['C'];
     cmd->Sflag = Sflag = flag['S'];
     cmd->rflag = flag['r'];
+    cmd->uflag = uflag = flag['u'];
     cmd->kflag = kflag = flag['k'];
     cmd->pflag = flag['p'];
     cmd->dflag = debug = flag['d'];