1995-02-18 01:27:10 +00:00
|
|
|
/*
|
|
|
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
|
|
* unrestricted use provided that this legend is included on all tape
|
|
|
|
* media and as a part of the software program in whole or part. Users
|
|
|
|
* may copy or modify Sun RPC without charge, but are not authorized
|
|
|
|
* to license or distribute it to anyone else except as part of a product or
|
1996-10-17 01:51:38 +00:00
|
|
|
* program developed by the user or with the express written consent of
|
|
|
|
* Sun Microsystems, Inc.
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
*
|
1995-02-18 01:27:10 +00:00
|
|
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
|
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
*
|
1995-02-18 01:27:10 +00:00
|
|
|
* Sun RPC is provided with no support and without any obligation on the
|
|
|
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
|
|
* modification or enhancement.
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
*
|
1995-02-18 01:27:10 +00:00
|
|
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
|
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
|
|
* OR ANY PART THEREOF.
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
*
|
1995-02-18 01:27:10 +00:00
|
|
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
|
|
* or profits or other special, indirect and consequential damages, even if
|
|
|
|
* Sun has been advised of the possibility of such damages.
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
*
|
1995-02-18 01:27:10 +00:00
|
|
|
* Sun Microsystems, Inc.
|
|
|
|
* 2550 Garcia Avenue
|
|
|
|
* Mountain View, California 94043
|
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* From @(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI;
|
|
|
|
*/
|
|
|
|
char main_rcsid[] =
|
|
|
|
"$Id$";
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
/*
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
* rpc_main.c, Top level of the RPC protocol compiler.
|
1995-02-18 01:27:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
1996-10-17 01:51:38 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
1995-02-18 01:27:10 +00:00
|
|
|
#include <sys/file.h>
|
1996-10-17 01:51:38 +00:00
|
|
|
#include <sys/stat.h>
|
1995-02-18 01:27:10 +00:00
|
|
|
#include "rpc_parse.h"
|
1996-10-17 01:51:38 +00:00
|
|
|
#include "rpc_util.h"
|
1995-02-18 01:27:10 +00:00
|
|
|
#include "rpc_scan.h"
|
1996-10-17 01:51:38 +00:00
|
|
|
#include "proto.h"
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
#define EXTEND 1 /* alias for TRUE */
|
1996-10-17 01:51:38 +00:00
|
|
|
#define DONT_EXTEND 0 /* alias for FALSE */
|
|
|
|
|
|
|
|
#define SVR4_CPP "/usr/ccs/lib/cpp"
|
|
|
|
#define SUNOS_CPP "/lib/cpp"
|
|
|
|
static int cppDefined = 0; /* explicit path for C preprocessor */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
struct commandline {
|
1996-10-17 01:51:38 +00:00
|
|
|
int cflag; /* xdr C routines */
|
|
|
|
int hflag; /* header file */
|
|
|
|
int lflag; /* client side stubs */
|
|
|
|
int mflag; /* server side stubs */
|
|
|
|
int nflag; /* netid flag */
|
|
|
|
int sflag; /* server stubs for the given transport */
|
|
|
|
int tflag; /* dispatch Table file */
|
|
|
|
int Ssflag; /* produce server sample code */
|
|
|
|
int Scflag; /* produce client sample code */
|
|
|
|
const char *infile; /* input module name */
|
|
|
|
const char *outfile; /* output module name */
|
1995-02-18 01:27:10 +00:00
|
|
|
};
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
|
|
|
|
static const char *cmdname;
|
|
|
|
|
|
|
|
static const char *svcclosetime = "120";
|
|
|
|
static const char *CPP = SVR4_CPP;
|
1995-02-18 01:27:10 +00:00
|
|
|
static char CPPFLAGS[] = "-C";
|
1996-10-17 01:51:38 +00:00
|
|
|
static char pathbuf[MAXPATHLEN + 1];
|
|
|
|
static const char *allv[] = {
|
1995-02-18 01:27:10 +00:00
|
|
|
"rpcgen", "-s", "udp", "-s", "tcp",
|
|
|
|
};
|
|
|
|
static int allc = sizeof(allv)/sizeof(allv[0]);
|
1996-10-17 01:51:38 +00:00
|
|
|
static const char *allnv[] = {
|
|
|
|
"rpcgen", "-s", "netpath",
|
|
|
|
};
|
|
|
|
static int allnc = sizeof(allnv)/sizeof(allnv[0]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* machinations for handling expanding argument list
|
|
|
|
*/
|
|
|
|
static void addarg(const char *); /* add another argument to the list */
|
|
|
|
static void putarg(int, const char *); /* put argument at specified location */
|
|
|
|
static void clear_args(void); /* clear argument list */
|
|
|
|
static void checkfiles(const char *, const char *);
|
|
|
|
/* check if out file already exists */
|
|
|
|
|
|
|
|
static void clear_args(void);
|
|
|
|
static char *extendfile(const char *file, const char *ext);
|
|
|
|
static void open_output(const char *infile, const char *outfile);
|
|
|
|
static void add_warning(void);
|
|
|
|
static void clear_args(void);
|
|
|
|
static void find_cpp(void);
|
|
|
|
static void open_input(const char *infile, const char *define);
|
|
|
|
static int check_nettype(const char *name, const char *list_to_check[]);
|
|
|
|
static void c_output(const char *infile, const char *define,
|
|
|
|
int extend, const char *outfile);
|
|
|
|
static void h_output(const char *infile, const char *define,
|
|
|
|
int extend, const char *outfile);
|
|
|
|
static void s_output(int argc, const char *argv[], const char *infile,
|
|
|
|
const char *define, int extend,
|
|
|
|
const char *outfile, int nomain, int netflag);
|
|
|
|
static void l_output(const char *infile, const char *define,
|
|
|
|
int extend, const char *outfile);
|
|
|
|
static void t_output(const char *infile, const char *define,
|
|
|
|
int extend, const char *outfile);
|
|
|
|
static void svc_output(const char *infile, const char *define,
|
|
|
|
int extend, const char *outfile);
|
|
|
|
static void clnt_output(const char *infile, const char *define,
|
|
|
|
int extend, const char *outfile);
|
|
|
|
static int do_registers(int argc, const char *argv[]);
|
|
|
|
static void addarg(const char *cp);
|
|
|
|
static void putarg(int whereto, const char *cp);
|
|
|
|
static void checkfiles(const char *infile, const char *outfile);
|
|
|
|
static int parseargs(int argc, const char *argv[], struct commandline *cmd);
|
|
|
|
static void usage(void);
|
|
|
|
static void options_usage(void);
|
|
|
|
static void c_initialize(void);
|
|
|
|
static char *generate_guard(const char *pathname);
|
|
|
|
|
|
|
|
|
|
|
|
#define ARGLISTLEN 20
|
|
|
|
#define FIXEDARGS 2
|
|
|
|
|
|
|
|
static const char *arglist[ARGLISTLEN];
|
|
|
|
static int argcount = FIXEDARGS;
|
|
|
|
|
|
|
|
|
|
|
|
int nonfatalerrors; /* errors */
|
|
|
|
int inetdflag/* = 1*/; /* Support for inetd */ /* is now the default */
|
|
|
|
int pmflag; /* Support for port monitors */
|
|
|
|
int logflag; /* Use syslog instead of fprintf for errors */
|
|
|
|
int tblflag; /* Support for dispatch table file */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
#define INLINE 3
|
|
|
|
/*length at which to start doing an inline */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
int inlineflag=INLINE; /* length at which to start doing an inline. 3 = default
|
|
|
|
if 0, no xdr_inline code */
|
|
|
|
|
|
|
|
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) */
|
|
|
|
#ifdef __GNU_LIBRARY__
|
|
|
|
int Cflag = 1 ; /* ANSI C syntax */
|
|
|
|
#else
|
|
|
|
int Cflag = 0 ; /* ANSI C syntax */
|
|
|
|
#endif
|
|
|
|
static int allfiles; /* generate all files */
|
|
|
|
#ifdef __GNU_LIBRARY__
|
|
|
|
int tirpcflag = 0; /* generating code for tirpc, by default */
|
|
|
|
#else
|
|
|
|
int tirpcflag = 1; /* generating code for tirpc, by default */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, const char *argv[])
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
struct commandline cmd;
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
(void) memset((char *)&cmd, 0, sizeof (struct commandline));
|
|
|
|
clear_args();
|
|
|
|
if (!parseargs(argc, argv, &cmd))
|
|
|
|
usage();
|
1996-03-28 21:00:28 +00:00
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
|
|
|
|
cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag ) {
|
|
|
|
checkfiles(cmd.infile, cmd.outfile);
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
else
|
|
|
|
checkfiles(cmd.infile,NULL);
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
if (cmd.cflag) {
|
1996-10-17 01:51:38 +00:00
|
|
|
c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
|
1995-02-18 01:27:10 +00:00
|
|
|
} else if (cmd.hflag) {
|
1996-10-17 01:51:38 +00:00
|
|
|
h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
|
1995-02-18 01:27:10 +00:00
|
|
|
} else if (cmd.lflag) {
|
1996-10-17 01:51:38 +00:00
|
|
|
l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
|
|
|
|
} else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
|
|
|
|
s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
|
|
|
|
cmd.outfile, cmd.mflag, cmd.nflag);
|
|
|
|
} else if (cmd.tflag) {
|
|
|
|
t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
|
|
|
|
} else if (cmd.Ssflag) {
|
|
|
|
svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
|
|
|
|
} else if (cmd.Scflag) {
|
|
|
|
clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
|
1995-02-18 01:27:10 +00:00
|
|
|
} else {
|
1996-10-17 01:51:38 +00:00
|
|
|
/* the rescans are required, since cpp may effect input */
|
1995-02-18 01:27:10 +00:00
|
|
|
c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
|
|
|
|
reinitialize();
|
|
|
|
h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h");
|
|
|
|
reinitialize();
|
|
|
|
l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
|
|
|
|
reinitialize();
|
1996-10-17 01:51:38 +00:00
|
|
|
if (inetdflag || !tirpcflag )
|
|
|
|
s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
|
|
|
|
"_svc.c", cmd.mflag, cmd.nflag);
|
|
|
|
else
|
|
|
|
s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
|
|
|
|
EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
|
|
|
|
if (tblflag) {
|
|
|
|
reinitialize();
|
|
|
|
t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
|
|
|
|
}
|
|
|
|
if (allfiles) {
|
|
|
|
reinitialize();
|
|
|
|
svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
|
|
|
|
}
|
|
|
|
if (allfiles) {
|
|
|
|
reinitialize();
|
|
|
|
clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
exit(nonfatalerrors);
|
|
|
|
/* NOTREACHED */
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
* add extension to filename
|
1995-02-18 01:27:10 +00:00
|
|
|
*/
|
|
|
|
static char *
|
1996-10-17 01:51:38 +00:00
|
|
|
extendfile(const char *file, const char *ext)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
char *res;
|
1996-10-17 01:51:38 +00:00
|
|
|
const char *p;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
res = alloc(strlen(file) + strlen(ext) + 1);
|
|
|
|
if (res == NULL) {
|
|
|
|
abort();
|
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
p = strrchr(file, '.');
|
1995-02-18 01:27:10 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
p = file + strlen(file);
|
|
|
|
}
|
|
|
|
(void) strcpy(res, file);
|
|
|
|
(void) strcpy(res + (p - file), ext);
|
|
|
|
return (res);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
* Open output file with given extension
|
1995-02-18 01:27:10 +00:00
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
static void
|
|
|
|
open_output(const char *infile, const char *outfile)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
1996-10-17 01:51:38 +00:00
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
if (outfile == NULL) {
|
|
|
|
fout = stdout;
|
|
|
|
return;
|
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
if (infile != NULL && streq(outfile, infile)) {
|
1996-10-17 01:51:38 +00:00
|
|
|
f_print(stderr, "%s: output would overwrite %s\n", cmdname,
|
1995-02-18 01:27:10 +00:00
|
|
|
infile);
|
|
|
|
crash();
|
|
|
|
}
|
|
|
|
fout = fopen(outfile, "w");
|
|
|
|
if (fout == NULL) {
|
1996-10-17 01:51:38 +00:00
|
|
|
f_print(stderr, "%s: unable to open ", cmdname);
|
1995-02-18 01:27:10 +00:00
|
|
|
perror(outfile);
|
|
|
|
crash();
|
|
|
|
}
|
|
|
|
record_open(outfile);
|
|
|
|
}
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
static void
|
|
|
|
add_warning(void)
|
|
|
|
{
|
|
|
|
f_print(fout, "/*\n");
|
|
|
|
f_print(fout, " * Please do not edit this file.\n");
|
|
|
|
f_print(fout, " * It was generated using rpcgen.\n");
|
|
|
|
f_print(fout, " */\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_stdheaders(void)
|
|
|
|
{
|
|
|
|
f_print(fout, "#include <rpc/types.h>\n");
|
|
|
|
f_print(fout, "#include <rpc/xdr.h>\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear list of arguments */
|
|
|
|
static void clear_args(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for( i=FIXEDARGS; i<ARGLISTLEN; i++ )
|
|
|
|
arglist[i] = NULL;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
/*
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
* Open input file with given define for C-preprocessor
|
1995-02-18 01:27:10 +00:00
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
static void
|
|
|
|
open_input(const char *infile, const char *define)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
int pd[2];
|
|
|
|
|
|
|
|
infilename = (infile == NULL) ? "<stdin>" : infile;
|
|
|
|
(void) pipe(pd);
|
|
|
|
switch (fork()) {
|
|
|
|
case 0:
|
1996-10-17 01:51:38 +00:00
|
|
|
find_cpp();
|
|
|
|
putarg(0, CPP);
|
|
|
|
putarg(1, CPPFLAGS);
|
|
|
|
addarg(define);
|
|
|
|
addarg(infile);
|
|
|
|
addarg((char *)NULL);
|
1995-02-18 01:27:10 +00:00
|
|
|
(void) close(1);
|
|
|
|
(void) dup2(pd[1], 1);
|
|
|
|
(void) close(pd[0]);
|
1996-10-17 01:51:38 +00:00
|
|
|
execv(arglist[0], (char **)arglist);
|
|
|
|
perror("execv");
|
1995-02-18 01:27:10 +00:00
|
|
|
exit(1);
|
|
|
|
case -1:
|
|
|
|
perror("fork");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
(void) close(pd[1]);
|
|
|
|
fin = fdopen(pd[0], "r");
|
|
|
|
if (fin == NULL) {
|
|
|
|
f_print(stderr, "%s: ", cmdname);
|
|
|
|
perror(infilename);
|
|
|
|
crash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
/* valid tirpc nettypes */
|
|
|
|
static const char *valid_ti_nettypes[] =
|
|
|
|
{
|
|
|
|
"netpath",
|
|
|
|
"visible",
|
|
|
|
"circuit_v",
|
|
|
|
"datagram_v",
|
|
|
|
"circuit_n",
|
|
|
|
"datagram_n",
|
|
|
|
"udp",
|
|
|
|
"tcp",
|
|
|
|
"raw",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* valid inetd nettypes */
|
|
|
|
static const char *valid_i_nettypes[] =
|
|
|
|
{
|
|
|
|
"udp",
|
|
|
|
"tcp",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static int check_nettype(const char *name, const char *list_to_check[]) {
|
|
|
|
int i;
|
|
|
|
for( i = 0; list_to_check[i] != NULL; i++ ) {
|
|
|
|
if( strcmp( name, list_to_check[i] ) == 0 ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f_print( stderr, "illegal nettype :\'%s\'\n", name );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
/*
|
|
|
|
* Compile into an XDR routine output file
|
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
c_output(const char *infile, const char *define, int extend,
|
|
|
|
const char *outfile)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
definition *def;
|
|
|
|
char *include;
|
1996-10-17 01:51:38 +00:00
|
|
|
const char *outfilename;
|
1995-02-18 01:27:10 +00:00
|
|
|
long tell;
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
c_initialize();
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
open_input(infile, define);
|
1995-02-18 01:27:10 +00:00
|
|
|
outfilename = extend ? extendfile(infile, outfile) : outfile;
|
|
|
|
open_output(infile, outfilename);
|
1996-10-17 01:51:38 +00:00
|
|
|
add_warning();
|
|
|
|
add_stdheaders();
|
1995-02-18 01:27:10 +00:00
|
|
|
if (infile && (include = extendfile(infile, ".h"))) {
|
|
|
|
f_print(fout, "#include \"%s\"\n", include);
|
|
|
|
free(include);
|
1996-10-17 01:51:38 +00:00
|
|
|
/* .h file already contains rpc/rpc.h */
|
|
|
|
} else
|
|
|
|
f_print(fout, "#include <rpc/rpc.h>\n");
|
1995-02-18 01:27:10 +00:00
|
|
|
tell = ftell(fout);
|
1996-10-17 01:51:38 +00:00
|
|
|
while ((def = get_definition())!=NULL) {
|
1995-02-18 01:27:10 +00:00
|
|
|
emit(def);
|
|
|
|
}
|
|
|
|
if (extend && tell == ftell(fout)) {
|
|
|
|
(void) unlink(outfilename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
void
|
|
|
|
c_initialize(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* add all the starting basic types */
|
|
|
|
|
|
|
|
add_type(1,"int");
|
|
|
|
add_type(1,"long");
|
|
|
|
add_type(1,"short");
|
|
|
|
add_type(1,"bool");
|
|
|
|
|
|
|
|
add_type(1,"u_int");
|
|
|
|
add_type(1,"u_long");
|
|
|
|
add_type(1,"u_short");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
|
|
|
|
char *(*proc)();\n\
|
|
|
|
xdrproc_t xdr_arg;\n\
|
|
|
|
unsigned len_arg;\n\
|
|
|
|
xdrproc_t xdr_res;\n\
|
|
|
|
unsigned len_res;\n\
|
|
|
|
};\n";
|
|
|
|
|
|
|
|
|
|
|
|
static char *generate_guard(const char *pathname) {
|
|
|
|
const char *filename;
|
|
|
|
char *guard, *tmp;
|
|
|
|
|
|
|
|
filename = strrchr(pathname, '/' ); /* find last component */
|
|
|
|
filename = ((filename == NULL) ? pathname : filename+1);
|
|
|
|
guard = strdup(filename);
|
|
|
|
/* convert to upper case */
|
|
|
|
tmp = guard;
|
|
|
|
while (*tmp) {
|
|
|
|
if (islower(*tmp))
|
|
|
|
*tmp = toupper(*tmp);
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
guard = extendfile(guard, "_H_RPCGEN");
|
|
|
|
return guard;
|
|
|
|
}
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
/*
|
|
|
|
* Compile into an XDR header file
|
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
h_output(const char *infile, const char *define, int extend,
|
|
|
|
const char *outfile)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
definition *def;
|
1996-10-17 01:51:38 +00:00
|
|
|
const char *ifilename;
|
|
|
|
const char *outfilename;
|
1995-02-18 01:27:10 +00:00
|
|
|
long tell;
|
1996-10-17 01:51:38 +00:00
|
|
|
char *guard;
|
|
|
|
list *l;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
open_input(infile, define);
|
|
|
|
outfilename = extend ? extendfile(infile, outfile) : outfile;
|
|
|
|
open_output(infile, outfilename);
|
1996-10-17 01:51:38 +00:00
|
|
|
add_warning();
|
|
|
|
ifilename = (infile == NULL) ? "STDIN" : infile;
|
|
|
|
guard = generate_guard( outfilename ? outfilename: ifilename );
|
|
|
|
|
|
|
|
f_print(fout,"#ifndef _%s\n#define _%s\n\n", guard,
|
|
|
|
guard);
|
|
|
|
|
|
|
|
f_print(fout, "#include <rpc/rpc.h>\n\n");
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
tell = ftell(fout);
|
1996-10-17 01:51:38 +00:00
|
|
|
/* print data definitions */
|
|
|
|
while ((def = get_definition())!=NULL) {
|
1995-02-18 01:27:10 +00:00
|
|
|
print_datadef(def);
|
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
|
|
|
|
/* print function declarations.
|
|
|
|
Do this after data definitions because they might be used as
|
|
|
|
arguments for functions */
|
|
|
|
for (l = defined; l != NULL; l = l->next) {
|
|
|
|
print_funcdef(l->val);
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
if (extend && tell == ftell(fout)) {
|
|
|
|
(void) unlink(outfilename);
|
1996-10-17 01:51:38 +00:00
|
|
|
} else if (tblflag) {
|
|
|
|
f_print(fout, rpcgen_table_dcl);
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
f_print(fout, "\n#endif /* !_%s */\n", guard);
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compile into an RPC service
|
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
static void
|
|
|
|
s_output(int argc, const char *argv[], const char *infile, const char *define,
|
|
|
|
int extend, const char *outfile, int nomain, int netflag)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
char *include;
|
|
|
|
definition *def;
|
1996-10-17 01:51:38 +00:00
|
|
|
int foundprogram = 0;
|
|
|
|
const char *outfilename;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
open_input(infile, define);
|
|
|
|
outfilename = extend ? extendfile(infile, outfile) : outfile;
|
|
|
|
open_output(infile, outfilename);
|
1996-10-17 01:51:38 +00:00
|
|
|
add_warning();
|
1995-02-18 01:27:10 +00:00
|
|
|
if (infile && (include = extendfile(infile, ".h"))) {
|
|
|
|
f_print(fout, "#include \"%s\"\n", include);
|
|
|
|
free(include);
|
1996-10-17 01:51:38 +00:00
|
|
|
} else
|
|
|
|
f_print(fout, "#include <rpc/rpc.h>\n");
|
|
|
|
|
|
|
|
f_print(fout, "#include <stdio.h>\n");
|
|
|
|
f_print(fout, "#include <stdlib.h>/* getenv, exit */\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) {
|
|
|
|
f_print(fout, "#include <signal.h>\n");
|
|
|
|
timerflag = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !tirpcflag && inetdflag )
|
|
|
|
#ifdef __GNU_LIBRARY__
|
|
|
|
f_print(fout, "#include <sys/ioctl.h> /* ioctl, TIOCNOTTY */\n");
|
|
|
|
#else
|
|
|
|
f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
|
|
|
|
#endif
|
|
|
|
if( Cflag && (inetdflag || pmflag ) ) {
|
|
|
|
#ifdef __GNU_LIBRARY__
|
|
|
|
f_print(fout, "#include <sys/types.h> /* open */\n");
|
|
|
|
f_print(fout, "#include <sys/stat.h> /* open */\n");
|
|
|
|
f_print(fout, "#include <fcntl.h> /* open */\n");
|
|
|
|
f_print(fout, "#include <unistd.h> /* getdtablesize */\n");
|
|
|
|
#else
|
|
|
|
f_print(fout, "#ifdef __cplusplus\n");
|
|
|
|
f_print(fout, "#include <sysent.h> /* getdtablesize, open */\n");
|
|
|
|
f_print(fout, "#endif /* __cplusplus */\n");
|
|
|
|
#endif
|
|
|
|
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");
|
|
|
|
#ifndef __GNU_LIBRARY__
|
|
|
|
f_print(fout, "#include <stropts.h>\n");
|
|
|
|
#endif
|
|
|
|
if (inetdflag || !tirpcflag ) {
|
|
|
|
f_print(fout, "#include <sys/socket.h>\n");
|
|
|
|
f_print(fout, "#include <netinet/in.h>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (netflag || pmflag) && tirpcflag ) {
|
|
|
|
f_print(fout, "#include <netconfig.h>\n");
|
|
|
|
}
|
|
|
|
if (/*timerflag &&*/ tirpcflag)
|
|
|
|
f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
|
|
|
|
if (logflag || inetdflag || pmflag) {
|
|
|
|
#ifdef __GNU_LIBRARY__
|
|
|
|
f_print(fout, "#include <syslog.h>\n");
|
|
|
|
#else
|
|
|
|
f_print(fout, "#ifdef SYSLOG\n");
|
|
|
|
f_print(fout, "#include <syslog.h>\n");
|
|
|
|
f_print(fout, "#else\n");
|
|
|
|
f_print(fout, "#define LOG_ERR 1\n");
|
|
|
|
f_print(fout, "#define openlog(a, b, c)\n");
|
|
|
|
f_print(fout, "#endif\n");
|
|
|
|
#endif
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
|
|
|
|
/* for ANSI-C */
|
|
|
|
f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
|
|
|
|
|
|
|
|
#ifndef __GNU_LIBRARY__
|
|
|
|
f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
|
|
|
|
#endif
|
|
|
|
if (timerflag)
|
|
|
|
f_print(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime);
|
|
|
|
while ((def = get_definition())!=NULL) {
|
1995-02-18 01:27:10 +00:00
|
|
|
foundprogram |= (def->def_kind == DEF_PROGRAM);
|
|
|
|
}
|
|
|
|
if (extend && !foundprogram) {
|
|
|
|
(void) unlink(outfilename);
|
|
|
|
return;
|
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
write_most(infile, netflag, nomain);
|
|
|
|
if (!nomain) {
|
|
|
|
if( !do_registers(argc, argv) ) {
|
|
|
|
if (outfilename)
|
|
|
|
(void) unlink(outfilename);
|
|
|
|
usage();
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
write_rest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
/*
|
|
|
|
* generate client side stubs
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
l_output(const char *infile, const char *define, int extend,
|
|
|
|
const char *outfile)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
char *include;
|
|
|
|
definition *def;
|
1996-10-17 01:51:38 +00:00
|
|
|
int foundprogram = 0;
|
|
|
|
const char *outfilename;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
open_input(infile, define);
|
|
|
|
outfilename = extend ? extendfile(infile, outfile) : outfile;
|
|
|
|
open_output(infile, outfilename);
|
1996-10-17 01:51:38 +00:00
|
|
|
add_warning();
|
|
|
|
if (Cflag)
|
|
|
|
f_print (fout, "#include <memory.h> /* for memset */\n");
|
1995-02-18 01:27:10 +00:00
|
|
|
if (infile && (include = extendfile(infile, ".h"))) {
|
|
|
|
f_print(fout, "#include \"%s\"\n", include);
|
|
|
|
free(include);
|
1996-10-17 01:51:38 +00:00
|
|
|
} else
|
|
|
|
f_print(fout, "#include <rpc/rpc.h>\n");
|
|
|
|
while ((def = get_definition())!=NULL) {
|
1995-02-18 01:27:10 +00:00
|
|
|
foundprogram |= (def->def_kind == DEF_PROGRAM);
|
|
|
|
}
|
|
|
|
if (extend && !foundprogram) {
|
|
|
|
(void) unlink(outfilename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
write_stubs();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-10-17 01:51:38 +00:00
|
|
|
* generate the dispatch table
|
1995-02-18 01:27:10 +00:00
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
static void
|
|
|
|
t_output(const char *infile, const char *define, int extend,
|
|
|
|
const char *outfile)
|
|
|
|
{
|
|
|
|
definition *def;
|
|
|
|
int foundprogram = 0;
|
|
|
|
const char *outfilename;
|
|
|
|
|
|
|
|
open_input(infile, define);
|
|
|
|
outfilename = extend ? extendfile(infile, outfile) : outfile;
|
|
|
|
open_output(infile, outfilename);
|
|
|
|
add_warning();
|
|
|
|
while ((def = get_definition())!=NULL) {
|
|
|
|
foundprogram |= (def->def_kind == DEF_PROGRAM);
|
|
|
|
}
|
|
|
|
if (extend && !foundprogram) {
|
|
|
|
(void) unlink(outfilename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
write_tables();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sample routine for the server template */
|
|
|
|
static void
|
|
|
|
svc_output(const char *infile, const char *define, int extend,
|
|
|
|
const char *outfile)
|
|
|
|
{
|
|
|
|
definition *def;
|
|
|
|
char *include;
|
|
|
|
const char *outfilename;
|
|
|
|
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"))) {
|
|
|
|
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())!=NULL) {
|
|
|
|
write_sample_svc(def);
|
|
|
|
}
|
|
|
|
if (extend && tell == ftell(fout)) {
|
|
|
|
(void) unlink(outfilename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* sample main routine for client */
|
|
|
|
static void
|
|
|
|
clnt_output(const char *infile, const char *define, int extend,
|
|
|
|
const char *outfile)
|
|
|
|
{
|
|
|
|
definition *def;
|
|
|
|
char *include;
|
|
|
|
const char *outfilename;
|
|
|
|
long tell;
|
|
|
|
int has_program = 0;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
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"))) {
|
|
|
|
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())!=NULL) {
|
|
|
|
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
|
|
|
|
* Return 0 if failed; 1 otherwise.
|
|
|
|
*/
|
|
|
|
static int do_registers(int argc, const char *argv[])
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
if ( inetdflag || !tirpcflag) {
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (streq(argv[i], "-s")) {
|
|
|
|
if(!check_nettype( argv[i + 1], valid_i_nettypes ))
|
|
|
|
return 0;
|
|
|
|
write_inetd_register(argv[i + 1]);
|
|
|
|
i++;
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
} else {
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
if (streq(argv[i], "-s")) {
|
|
|
|
if(!check_nettype( argv[i + 1], valid_ti_nettypes ))
|
|
|
|
return 0;
|
|
|
|
write_nettype_register(argv[i + 1]);
|
|
|
|
i++;
|
|
|
|
} else if (streq(argv[i], "-n")) {
|
|
|
|
write_netid_register(argv[i + 1]);
|
|
|
|
i++;
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
return 1;
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-10-17 01:51:38 +00:00
|
|
|
* Add another argument to the arg list
|
1995-02-18 01:27:10 +00:00
|
|
|
*/
|
1996-10-17 01:51:38 +00:00
|
|
|
static void
|
|
|
|
addarg(const char *cp)
|
|
|
|
{
|
|
|
|
if (argcount >= ARGLISTLEN) {
|
|
|
|
f_print(stderr, "rpcgen: too many defines\n");
|
|
|
|
crash();
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
arglist[argcount++] = cp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
putarg(int whereto, const char *cp)
|
|
|
|
{
|
|
|
|
if (whereto >= ARGLISTLEN) {
|
|
|
|
f_print(stderr, "rpcgen: arglist coding error\n");
|
|
|
|
crash();
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
arglist[whereto] = cp;
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-10-17 01:51:38 +00:00
|
|
|
/*
|
|
|
|
* 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 input file does not exist, exit with an error
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
checkfiles(const char *infile, const char *outfile)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
if(infile) /* infile ! = NULL */
|
|
|
|
if(stat(infile,&buf) < 0)
|
|
|
|
{
|
|
|
|
perror(infile);
|
|
|
|
crash();
|
|
|
|
};
|
|
|
|
if (outfile) {
|
|
|
|
if (stat(outfile, &buf) < 0)
|
|
|
|
return; /* file does not exist */
|
|
|
|
else {
|
|
|
|
f_print(stderr,
|
|
|
|
"file '%s' already exists and may be overwritten\n", outfile);
|
|
|
|
crash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse command line arguments
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
parseargs(int argc, const char *argv[], struct commandline *cmd)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
1996-10-17 01:51:38 +00:00
|
|
|
int c;
|
1995-02-18 01:27:10 +00:00
|
|
|
char flag[(1 << 8 * sizeof(char))];
|
|
|
|
int nflags;
|
|
|
|
|
|
|
|
cmdname = argv[0];
|
|
|
|
cmd->infile = cmd->outfile = NULL;
|
|
|
|
if (argc < 2) {
|
|
|
|
return (0);
|
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
allfiles = 0;
|
1995-02-18 01:27:10 +00:00
|
|
|
flag['c'] = 0;
|
|
|
|
flag['h'] = 0;
|
|
|
|
flag['l'] = 0;
|
|
|
|
flag['m'] = 0;
|
1996-10-17 01:51:38 +00:00
|
|
|
flag['o'] = 0;
|
|
|
|
flag['s'] = 0;
|
|
|
|
flag['n'] = 0;
|
|
|
|
flag['t'] = 0;
|
|
|
|
flag['S'] = 0;
|
|
|
|
flag['C'] = 0;
|
1995-02-18 01:27:10 +00:00
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (argv[i][0] != '-') {
|
|
|
|
if (cmd->infile) {
|
1996-10-17 01:51:38 +00:00
|
|
|
f_print( stderr, "Cannot specify more than one input file!\n");
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
cmd->infile = argv[i];
|
|
|
|
} else {
|
|
|
|
for (j = 1; argv[i][j] != 0; j++) {
|
|
|
|
c = argv[i][j];
|
|
|
|
switch (c) {
|
1996-10-17 01:51:38 +00:00
|
|
|
case 'a':
|
|
|
|
allfiles = 1;
|
|
|
|
break;
|
1995-02-18 01:27:10 +00:00
|
|
|
case 'c':
|
|
|
|
case 'h':
|
|
|
|
case 'l':
|
|
|
|
case 'm':
|
1996-10-17 01:51:38 +00:00
|
|
|
case 't':
|
1995-02-18 01:27:10 +00:00
|
|
|
if (flag[c]) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
flag[c] = 1;
|
|
|
|
break;
|
1996-10-17 01:51:38 +00:00
|
|
|
case 'S':
|
|
|
|
/* sample flag: Ss or Sc.
|
|
|
|
Ss means set flag['S'];
|
|
|
|
Sc means set flag['C']; */
|
|
|
|
c = argv[i][++j]; /* get next char */
|
|
|
|
if( c == 's' )
|
|
|
|
c = 'S';
|
|
|
|
else if( c == 'c' )
|
|
|
|
c = 'C';
|
|
|
|
else
|
|
|
|
return( 0 );
|
|
|
|
|
|
|
|
if (flag[c]) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
flag[c] = 1;
|
|
|
|
break;
|
|
|
|
case 'C': /* ANSI C syntax */
|
|
|
|
Cflag = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef __GNU_LIBRARY__
|
|
|
|
case 'k': /* K&R C syntax */
|
|
|
|
Cflag = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
case 'b': /* turn TIRPC flag off for
|
|
|
|
generating backward compatible
|
|
|
|
*/
|
|
|
|
tirpcflag = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef __GNU_LIBRARY__
|
|
|
|
case '5': /* turn TIRPC flag on for
|
|
|
|
generating SysVr4 compatible
|
|
|
|
*/
|
|
|
|
tirpcflag = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
case 'I':
|
|
|
|
inetdflag = 1;
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
newstyle = 1;
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
logflag = 1;
|
|
|
|
break;
|
|
|
|
case 'K':
|
|
|
|
if (++i == argc) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
svcclosetime = argv[i];
|
|
|
|
goto nextarg;
|
|
|
|
case 'T':
|
|
|
|
tblflag = 1;
|
|
|
|
break;
|
|
|
|
case 'i' :
|
|
|
|
if (++i == argc) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
inlineflag = atoi(argv[i]);
|
|
|
|
goto nextarg;
|
|
|
|
case 'n':
|
1995-02-18 01:27:10 +00:00
|
|
|
case 'o':
|
|
|
|
case 's':
|
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
Sat Nov 25 02:48:47 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* assert/assert-perr.c, assert/assert.c, inet/rcmd.c,
malloc/mcheck.c, malloc/vm-limit.c, posix/getconf.c, posix/id.c,
resolv/herror.c, sunrpc/auth_unix.c, sunrpc/clnt_perr.c,
sunrpc/clnt_raw.c, sunrpc/get_myaddr.c, sunrpc/pmap_clnt.c,
sunrpc/pmap_rmt.c, sunrpc/portmap.c, sunrpc/rpc_main.c,
sunrpc/rpc_parse.c, sunrpc/rpc_scan.c, sunrpc/rpc_util.c,
sunrpc/rpcinfo.c, sunrpc/svc_simple.c, sunrpc/svc_tcp.c,
sunrpc/svc_udp.c, time/zdump.c, time/zic.c: Mark translatable
strings.
1995-11-26 17:37:11 +00:00
|
|
|
if (argv[i][j - 1] != '-' ||
|
1995-02-18 01:27:10 +00:00
|
|
|
argv[i][j + 1] != 0) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
flag[c] = 1;
|
|
|
|
if (++i == argc) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (c == 's') {
|
|
|
|
if (!streq(argv[i], "udp") &&
|
|
|
|
!streq(argv[i], "tcp")) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
} else if (c == 'o') {
|
|
|
|
if (cmd->outfile) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
cmd->outfile = argv[i];
|
|
|
|
}
|
|
|
|
goto nextarg;
|
1996-10-17 01:51:38 +00:00
|
|
|
case 'D':
|
|
|
|
if (argv[i][j - 1] != '-') {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
(void) addarg(argv[i]);
|
|
|
|
goto nextarg;
|
|
|
|
case 'Y':
|
|
|
|
if (++i == argc) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
(void) strcpy(pathbuf, argv[i]);
|
|
|
|
(void) strcat(pathbuf, "/cpp");
|
|
|
|
CPP = pathbuf;
|
|
|
|
cppDefined = 1;
|
|
|
|
goto nextarg;
|
|
|
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nextarg:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
cmd->cflag = flag['c'];
|
|
|
|
cmd->hflag = flag['h'];
|
|
|
|
cmd->lflag = flag['l'];
|
|
|
|
cmd->mflag = flag['m'];
|
1996-10-17 01:51:38 +00:00
|
|
|
cmd->nflag = flag['n'];
|
|
|
|
cmd->sflag = flag['s'];
|
|
|
|
cmd->tflag = flag['t'];
|
|
|
|
cmd->Ssflag = flag['S'];
|
|
|
|
cmd->Scflag = flag['C'];
|
|
|
|
|
|
|
|
if( tirpcflag ) {
|
|
|
|
pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is always TRUE */
|
|
|
|
if( (inetdflag && cmd->nflag)) { /* netid not allowed with inetdflag */
|
|
|
|
f_print(stderr, "Cannot use netid flag with inetd flag!\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
} else { /* 4.1 mode */
|
|
|
|
pmflag = 0; /* set pmflag only in tirpcmode */
|
|
|
|
#ifndef __GNU_LIBRARY__
|
|
|
|
inetdflag = 1; /* inetdflag is TRUE by default */
|
|
|
|
#endif
|
|
|
|
if( cmd->nflag ) { /* netid needs TIRPC */
|
|
|
|
f_print( stderr, "Cannot use netid flag without TIRPC!\n");
|
|
|
|
return( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( newstyle && ( tblflag || cmd->tflag) ) {
|
|
|
|
f_print( stderr, "Cannot use table flags with newstyle!\n");
|
|
|
|
return( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check no conflicts with file generation flags */
|
|
|
|
nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +
|
|
|
|
cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
if (nflags == 0) {
|
|
|
|
if (cmd->outfile != NULL || cmd->infile == NULL) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
} else if (nflags > 1) {
|
1996-10-17 01:51:38 +00:00
|
|
|
f_print( stderr, "Cannot have more than one file generation flag!\n");
|
1995-02-18 01:27:10 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
1996-10-17 01:51:38 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
f_print(stderr, "usage: %s infile\n", cmdname);
|
|
|
|
f_print(stderr, "\t%s [-a][-b][-C][-Dname[=value]] -i size [-I [-K seconds]] [-L][-N][-T] infile\n",
|
|
|
|
cmdname);
|
|
|
|
f_print(stderr, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-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 void
|
|
|
|
options_usage(void)
|
|
|
|
{
|
|
|
|
f_print(stderr, "options:\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);
|
|
|
|
}
|