X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=tools%2Frpcgen%2Frpc_main.c;h=265106029cc79dd914d7097b11ecc8bffbd25a48;hp=bd1a2c0d225d3b59dfa241beb693e1b329f6a2ba;hb=e46ab0be95bb71f399e4ee0e9d06f16ad80d2b61;hpb=8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9 diff --git a/tools/rpcgen/rpc_main.c b/tools/rpcgen/rpc_main.c index bd1a2c0..2651060 100644 --- a/tools/rpcgen/rpc_main.c +++ b/tools/rpcgen/rpc_main.c @@ -45,6 +45,7 @@ static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI"; #include #include #include +#include #include "rpc_parse.h" #include "rpc_util.h" #include "rpc_scan.h" @@ -67,7 +68,6 @@ static char * extendfile(char *file, char *ext); static void open_output(char *infile, char *outfile); static void add_warning(void); static void clear_args(void); -static void find_cpp(void); static void open_input(char *infile, char *define); static int check_nettype(char *name, char **list_to_check); static void c_output(char *infile, char *define, int extend, char *outfile); @@ -293,26 +293,6 @@ clear_args(void) argcount = FIXEDARGS; } -/* make sure that a CPP exists */ -static void -find_cpp(void) -{ - struct stat buf; - - if (stat(CPP, &buf) < 0) { /* SVR4 or explicit cpp does not exist */ - if (cppDefined) { - fprintf(stderr, "cannot find C preprocessor: %s \n", CPP); - crash(); - } else { /* try the other one */ - CPP = SUNOS_CPP; - if (stat(CPP, &buf) < 0) { /* can't find any cpp */ - fprintf(stderr, "cannot find any C preprocessor (cpp)\n"); - crash(); - } - } - } -} - /* * Open input file with given define for C-preprocessor */ @@ -325,8 +305,7 @@ open_input(char *infile, char *define) (void) pipe(pd); switch (fork()) { case 0: - find_cpp(); - putarg(0, CPP); + putarg(0, "cpp"); putarg(1, CPPFLAGS); addarg(define); addarg(infile); @@ -334,7 +313,15 @@ open_input(char *infile, char *define) (void) close(1); (void) dup2(pd[1], 1); (void) close(pd[0]); - execv(arglist[0], arglist); + if (cppDefined) + execv(CPP, arglist); + else { + execvp("cpp", arglist); + if (errno == ENOENT) + execvp(SVR4_CPP, arglist); + if (errno == ENOENT) + execvp(SUNOS_CPP, arglist); + } perror("execv"); exit(1); case -1: @@ -426,12 +413,12 @@ c_initialize(void) /* add all the starting basic types */ add_type(1,"int"); - add_type(1,"long"); + add_type(1,"int32_t"); add_type(1,"short"); add_type(1,"bool"); add_type(1,"u_int"); - add_type(1,"u_long"); + add_type(1,"u_int32_t"); add_type(1,"u_short"); } @@ -488,6 +475,19 @@ h_output(char *infile, char *define, int extend, char *outfile) f_print(fout, "#include \n\n"); + f_print(fout, "#ifndef IXDR_GET_INT32\n"); + f_print(fout, "#define IXDR_GET_INT32(buf) IXDR_GET_LONG((buf))\n"); + f_print(fout, "#endif\n"); + f_print(fout, "#ifndef IXDR_PUT_INT32\n"); + f_print(fout, "#define IXDR_PUT_INT32(buf, v) IXDR_PUT_LONG((buf), (v))\n"); + f_print(fout, "#endif\n"); + f_print(fout, "#ifndef IXDR_GET_U_INT32\n"); + f_print(fout, "#define IXDR_GET_U_INT32(buf) IXDR_GET_U_LONG((buf))\n"); + f_print(fout, "#endif\n"); + f_print(fout, "#ifndef IXDR_PUT_U_INT32\n"); + f_print(fout, "#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_U_LONG((buf), (v))\n"); + f_print(fout, "#endif\n"); + tell = ftell(fout); /* print data definitions */ while ((def = get_definition()) != NULL) {