=for html
<div class="synopsis">
-B<rxgen> [B<-h> | B<-c> | B<-C> | B<-S> | B<-r>] [B<-dkpR>]
+B<rxgen> [B<-h> | B<-c> | B<-C> | B<-S> | B<-r>] [B<-dkp>]
[B<-I> I<dir>] [B<-P> I<prefix>] [B<-o> I<outfile>] [I<infile>]
-B<rxgen> B<-s> I<transport> [B<-o> I<outfile>] [I<infile>]
-
-B<rxgen> B<-l> [B<-o> I<outfile>] [I<infile>]
-
-B<rxgen> B<-m> [B<-o> I<outfile>] [I<infile>]
-
=for html
</div>
it takes as input a description of an application interface similar to C
and produces a number of server and/or client stub routines to be linked
with RPC-based programs. These stubs allow programs to invoke remote
-procedures through local procedure calls. B<rxgen> is an extension of
-Sun's B<rpcgen> (version 3.9) and retains full B<rpcgen> functionality (at
-least as of that version). Please refer to rpcgen(1) for more details on
-the Sun's RPC specific flags, and to the RPC programming guide regarding
-the RPC language along with useful examples.
+procedures through local procedure calls. B<rxgen> is based on Sun's
+B<rpcgen> (version 3.9) but does not maintain compatibility with rpcgen
+RPC descriptions.
=head1 OPTIONS
=over 4
-=item B<-R>
-
-Generate code for the older \R protocol, as opposed to Rx, which is the
-default.
-
=item B<-k>
Must be specified when the generated code is intended to be used by the
=back
-The B<-s>, B<-l>, and B<-m> options are present only for B<rpcgen>
-support. See rpcgen(1) for information on their use.
-
=head1 B<rxgen> SYNTAX SUMMARY
Specification file:
OUT long *nentries,
OUT vldb_list *linkedentries) = VLLINKEDLIST;
-We'll concentrate only on the Rx generated code since the R generated code
-(B<-R> option) will soon be obsolete. For a detailed description on the
-Rx-related calls inside the generated stubs (i.e., rx_NewCall(),
-rx_EndCall()), along with details on what happens inside certain calls
-(like xdrrx_create()) please refer to the Rx documentation. Typing C<rxgen
-vldbint.xg> will result in the creation of four files: F<vldbint.h>,
-F<vldbint.xdr.c>, F<vldbint.cs.c> and F<vldbint.ss.c>. A closer look at
-these files follows.
+For a detailed description on the Rx-related calls inside the generated
+stubs (i.e., rx_NewCall(), rx_EndCall()), along with details on what happens
+inside certain calls (like xdrrx_create()) please refer to the Rx
+documentation. Typing C<rxgen vldbint.xg> will result in the creation of
+four files: F<vldbint.h>, F<vldbint.xdr.c>, F<vldbint.cs.c> and
+F<vldbint.ss.c>. A closer look at these files follows.
=head3 Header file (F<vldbint.h>)
=head1 NOTES
-B<rxgen> is implemented from Sun's B<rpcgen> utility. All of the standard
-B<rpcgen>'s functionality is fully maintained. Note that some active
-B<rpcgen> options that don't apply to B<rxgen>'s purpose aren't referenced
-here (i.e., B<-s>, B<-l>, B<-m> options) and the interested reader should
-refer to rpcgen(1) for details.
+B<rxgen> is implemented from Sun's B<rpcgen> utility.
When the C<%#include <include file>> feature is used make sure that you
don't have any B<rxgen> language features (i.e. %#defines) since you'll
include @TOP_OBJDIR@/src/config/Makefile.lwp
-SRCS= rpc_main.c rpc_hout.c rpc_cout.c rpc_parse.c rpc_scan.c rpc_util.c \
- rpc_svcout.c rpc_clntout.c
+SRCS= rpc_main.c rpc_hout.c rpc_cout.c rpc_parse.c rpc_scan.c rpc_util.c
HDRS= rpc_util.h rpc_parse.h rpc_scan.h
-OBJS= rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o rpc_scan.o rpc_util.o \
- rpc_svcout.o rpc_clntout.o
+OBJS= rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o rpc_scan.o rpc_util.o
all: rxgen ${TOP_INCDIR}/afs/rxgen_consts.h
$(OUT)\rpc_cout.obj \
$(OUT)\rpc_parse.obj \
$(OUT)\rpc_scan.obj \
- $(OUT)\rpc_util.obj \
- $(OUT)\rpc_svcout.obj \
- $(OUT)\rpc_clntout.obj
+ $(OUT)\rpc_util.obj
$(EXEOBJS): $$(@B).c
$(C2OBJ) $**
+++ /dev/null
-/* @(#)rpc_clntout.c 1.2 87/11/24 3.9 RPCSRC */
-/*
- * 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
- * program developed by the user.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsytsems, Inc.
- */
-#include <afsconfig.h>
-#include <afs/param.h>
-
-#include <roken.h>
-
-#include "rpc_scan.h"
-#include "rpc_parse.h"
-#include "rpc_util.h"
-
-#define DEFAULT_TIMEOUT 25 /* in seconds */
-
-/* static prototypes */
-static void write_program(definition * def);
-static char *ampr(char *type);
-static void printbody(proc_list * proc);
-
-void
-write_stubs(void)
-{
- list *l;
- definition *def;
-
- f_print(fout, "\nstatic struct timeval TIMEOUT = { %d, 0 };\n",
- DEFAULT_TIMEOUT);
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM) {
- write_program(def);
- }
- }
-}
-
-
-static void
-write_program(definition * def)
-{
- version_list *vp;
- proc_list *proc;
-
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- for (proc = vp->procs; proc != NULL; proc = proc->next) {
- f_print(fout, "\n");
- ptype(proc->res_prefix, proc->res_type, 1);
- f_print(fout, "*\n");
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "(argp, clnt)\n");
- f_print(fout, "\t");
- ptype(proc->arg_prefix, proc->arg_type, 1);
- f_print(fout, "*argp;\n");
- f_print(fout, "\tCLIENT *clnt;\n");
- f_print(fout, "{\n");
- printbody(proc);
- f_print(fout, "}\n\n");
- }
- }
-}
-
-static char *
-ampr(char *type)
-{
- if (isvectordef(type, REL_ALIAS)) {
- return ("");
- } else {
- return ("&");
- }
-}
-
-static void
-printbody(proc_list * proc)
-{
- f_print(fout, "\tstatic ");
- if (streq(proc->res_type, "void")) {
- f_print(fout, "char ");
- } else {
- ptype(proc->res_prefix, proc->res_type, 0);
- }
- f_print(fout, "res;\n");
- f_print(fout, "\n");
- f_print(fout, "\tmemset(%sres, 0, sizeof(res));\n", ampr(proc->res_type));
- f_print(fout,
- "\tif (clnt_call(clnt, %s, xdr_%s, argp, xdr_%s, %sres, TIMEOUT) != RPC_SUCCESS) {\n",
- proc->proc_name, stringfix(proc->arg_type),
- stringfix(proc->res_type), ampr(proc->res_type));
- f_print(fout, "\t\treturn (NULL);\n");
- f_print(fout, "\t}\n");
- if (streq(proc->res_type, "void")) {
- f_print(fout, "\treturn ((void *)%sres);\n", ampr(proc->res_type));
- } else {
- f_print(fout, "\treturn (%sres);\n", ampr(proc->res_type));
- }
-}
void
emit(definition * def)
{
- if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
+ if (def->def_kind == DEF_CONST) {
return;
}
print_header(def);
static int
findtype(definition * def, char *type)
{
- if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
+ if (def->def_kind == DEF_CONST) {
return (0);
} else {
return (streq(def->def_name, type));
static void pconstdef(definition * def);
static void pstructdef(definition * def);
static void puniondef(definition * def);
-static void puldefine(char *name, char *num);
-static int define_printed(proc_list * stop, version_list * start);
-static void pprogramdef(definition * def);
static void psproc1(definition * defp, int callTconnF, char *type,
char *prefix, int iomask);
static void psprocdef(definition * defp);
case DEF_TYPEDEF:
ptypedef(def);
break;
- case DEF_PROGRAM:
- pprogramdef(def);
- break;
case DEF_PROC:
psprocdef(def);
break;
default:
break;
}
- if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST
- && (!IsRxgenDefinition(def))) {
+ if (def->def_kind != DEF_CONST && (!IsRxgenDefinition(def))) {
f_print(fout, "bool_t xdr_%s(XDR *xdrs, %s *objp);\n", def->def_name,
def->def_name);
}
}
static void
-puldefine(char *name, char *num)
-{
- f_print(fout, "#define %s ((afs_uint32)%s)\n", name, num);
-}
-
-static int
-define_printed(proc_list * stop, version_list * start)
-{
- version_list *vers;
- proc_list *proc;
-
- for (vers = start; vers != NULL; vers = vers->next) {
- for (proc = vers->procs; proc != NULL; proc = proc->next) {
- if (proc == stop) {
- return (0);
- } else if (streq(proc->proc_name, stop->proc_name)) {
- return (1);
- }
- }
- }
- abort();
- return 0;/* NOTREACHED */
-}
-
-
-static void
-pprogramdef(definition * def)
-{
- version_list *vers;
- proc_list *proc;
-
- puldefine(def->def_name, def->def.pr.prog_num);
- for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
- puldefine(vers->vers_name, vers->vers_num);
- for (proc = vers->procs; proc != NULL; proc = proc->next) {
- if (!define_printed(proc, def->def.pr.versions)) {
- puldefine(proc->proc_name, proc->proc_num);
- }
- pprocdef(proc, vers);
- }
- }
-}
-
-static void
psproc1(definition * defp, int callTconnF, char *type, char *prefix,
int iomask)
{
psproc1(defp, 3, "afs_int32", ServerPrefix, 0xFFFFFFFF);
}
-
-void
-pprocdef(proc_list * proc, version_list * vp)
-{
- f_print(fout, "extern ");
- if (proc->res_prefix) {
- if (streq(proc->res_prefix, "enum")) {
- f_print(fout, "enum ");
- } else {
- f_print(fout, "struct ");
- }
- }
- if (streq(proc->res_type, "bool")) {
- f_print(fout, "bool_t *");
- } else if (streq(proc->res_type, "string")) {
- f_print(fout, "char **");
- } else {
- f_print(fout, "%s *", fixtype(proc->res_type));
- }
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "();\n");
-}
-
static void
penumdef(definition * def)
{
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
- if (def->def_kind != DEF_PROGRAM) {
- if (streq(def->def_name, stop)) {
- return (1);
- } else if (streq(def->def_name, type)) {
- return (0);
- }
+ if (streq(def->def_name, stop)) {
+ return (1);
+ } else if (streq(def->def_name, type)) {
+ return (0);
}
}
return (1);
int brief_flag;
int cflag;
int hflag;
- int lflag;
- int sflag;
- int mflag;
int Cflag;
int Sflag;
int rflag;
int append);
static void h_output(char *infile, char *define, int extend, char *outfile,
int append);
-static void s_output(int argc, char *argv[], char *infile, char *define,
- int extend, char *outfile, int nomain);
-static void l_output(char *infile, char *define, int extend, char *outfile);
-static void do_registers(int argc, char *argv[]);
static int parseargs(int argc, char *argv[], struct commandline *cmd);
static void C_output(char *infile, char *define, int extend, char *outfile,
int append);
if (!parseargs(argc, argv, &cmd)) {
f_print(stderr, "usage: %s infile\n", cmdname);
f_print(stderr,
- " %s [-c | -h | -l | -m | -C | -S | -r | -b | -k | -R | -p | -d | -z | -u] [-Pprefix] [-Idir] [-o outfile] [infile]\n",
+ " %s [-c | -h | -C | -S | -r | -b | -k | -p | -d | -z | -u] [-Pprefix] [-Idir] [-o outfile] [infile]\n",
cmdname);
- f_print(stderr, " %s [-s udp|tcp]* [-o outfile] [infile]\n",
+ f_print(stderr, " %s [-o outfile] [infile]\n",
cmdname);
exit(1);
}
c_output(cmd.infile, "-DRPC_XDR", !EXTEND, cmd.outfile, 0);
} else if (cmd.hflag) {
h_output(cmd.infile, "-DRPC_HDR", !EXTEND, cmd.outfile, 0);
- } else if (cmd.lflag) {
- l_output(cmd.infile, "-DRPC_CLNT", !EXTEND, cmd.outfile);
- } else if (cmd.sflag || cmd.mflag) {
- s_output(argc, argv, cmd.infile, "-DRPC_SVC", !EXTEND, cmd.outfile,
- cmd.mflag);
} else if (cmd.Cflag) {
OutFileFlag = NULL;
C_output(cmd.infile, "-DRPC_CLIENT", !EXTEND, cmd.outfile, 1);
}
}
-/*
- * Compile into an RPC service
- */
-static void
-s_output(int argc, char *argv[], char *infile, char *define, int extend,
- char *outfile, int nomain)
-{
- char *include;
- definition *def;
- int foundprogram;
- char *outfilename;
-
- open_input(infile, define);
- outfilename = extend ? extendfile(infile, outfile) : outfile;
- open_output(infile, outfilename);
- f_print(fout, "#include <stdio.h>\n");
- f_print(fout, "#include <rpc/rpc.h>\n");
- if (infile && (include = extendfile(infile, ".h"))) {
- f_print(fout, "#include \"%s\"\n", include);
- free(include);
- }
- foundprogram = 0;
- while ((def = get_definition())) {
- foundprogram |= (def->def_kind == DEF_PROGRAM);
- }
- if (extend && !foundprogram) {
- (void)unlink(outfilename);
- return;
- }
- if (nomain) {
- write_programs(NULL);
- } else {
- write_most();
- do_registers(argc, argv);
- write_rest();
- write_programs("static");
- }
-}
-
-static void
-l_output(char *infile, char *define, int extend, char *outfile)
-{
- char *include;
- definition *def;
- int foundprogram;
- char *outfilename;
-
- open_input(infile, define);
- outfilename = extend ? extendfile(infile, outfile) : outfile;
- open_output(infile, outfilename);
- f_print(fout, "#include <rpc/rpc.h>\n");
- f_print(fout, "#include <sys/time.h>\n");
- if (infile && (include = extendfile(infile, ".h"))) {
- f_print(fout, "#include \"%s\"\n", include);
- free(include);
- }
- foundprogram = 0;
- while ((def = get_definition())) {
- foundprogram |= (def->def_kind == DEF_PROGRAM);
- }
- if (extend && !foundprogram) {
- (void)unlink(outfilename);
- return;
- }
- write_stubs();
-}
-
-/*
- * Perform registrations for service output
- */
-static void
-do_registers(int argc, char *argv[])
-{
- int i;
-
- for (i = 1; i < argc; i++) {
- if (streq(argv[i], "-s")) {
- write_register(argv[i + 1]);
- i++;
- }
- }
-}
-
-
static void
C_output(char *infile, char *define, int extend, char *outfile, int append)
{
case 'A':
case 'c':
case 'h':
- case 'l':
- case 'm':
case 'C':
case 'S':
case 'b':
case 'r':
- case 'R':
case 'k':
case 'p':
case 'd':
flag[(int)c] = 1;
break;
case 'o':
- case 's':
if (argv[i][j - 1] != '-' || argv[i][j + 1] != 0) {
return (0);
}
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];
+ if (cmd->outfile) {
+ return (0);
}
+ cmd->outfile = argv[i];
goto nextarg;
case 'P':
if (argv[i][j - 1] != '-')
cmd->brief_flag = brief_flag = flag['b'];
cmd->cflag = cflag = flag['c'];
cmd->hflag = hflag = flag['h'];
- cmd->sflag = flag['s'];
- cmd->lflag = flag['l'];
- cmd->mflag = flag['m'];
cmd->xflag = xflag = flag['x'];
cmd->yflag = yflag = flag['y'];
cmd->Cflag = Cflag = flag['C'];
if (cmd->pflag)
combinepackages = 1;
nflags =
- cmd->cflag + cmd->hflag + cmd->sflag + cmd->lflag + cmd->mflag +
- cmd->Cflag + cmd->Sflag + cmd->rflag;
+ cmd->cflag + cmd->hflag + cmd->Cflag + cmd->Sflag + cmd->rflag;
if (nflags == 0) {
if (cmd->outfile != NULL || cmd->infile == NULL) {
return (0);
/* static prototypes */
static void isdefined(definition * defp);
static void def_struct(definition * defp);
-static void def_program(definition * defp);
static void def_enum(definition * defp);
static void def_const(definition * defp);
static void def_union(definition * defp);
case TOK_ENUM:
def_enum(defp);
break;
- case TOK_PROGRAM:
- def_program(defp);
- break;
case TOK_CONST:
def_const(defp);
break;
}
static void
-def_program(definition * defp)
-{
- token tok;
- version_list *vlist;
- version_list **vtailp;
- proc_list *plist;
- proc_list **ptailp;
-
- defp->def_kind = DEF_PROGRAM;
- scan(TOK_IDENT, &tok);
- defp->def_name = tok.str;
- scan(TOK_LBRACE, &tok);
- vtailp = &defp->def.pr.versions;
- scan(TOK_VERSION, &tok);
- do {
- scan(TOK_IDENT, &tok);
- vlist = ALLOC(version_list);
- vlist->vers_name = tok.str;
- scan(TOK_LBRACE, &tok);
- ptailp = &vlist->procs;
- do {
- plist = ALLOC(proc_list);
- get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM);
- if (streq(plist->res_type, "opaque")) {
- error("illegal result type");
- }
- scan(TOK_IDENT, &tok);
- plist->proc_name = tok.str;
- scan(TOK_LPAREN, &tok);
- get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM);
- if (streq(plist->arg_type, "opaque")) {
- error("illegal argument type");
- }
- scan(TOK_RPAREN, &tok);
- scan(TOK_EQUAL, &tok);
- scan_num(&tok);
- scan(TOK_SEMICOLON, &tok);
- plist->proc_num = tok.str;
- *ptailp = plist;
- ptailp = &plist->next;
- peek(&tok);
- } while (tok.kind != TOK_RBRACE);
- *vtailp = vlist;
- vtailp = &vlist->next;
- scan(TOK_RBRACE, &tok);
- scan(TOK_EQUAL, &tok);
- scan_num(&tok);
- vlist->vers_num = tok.str;
- scan(TOK_SEMICOLON, &tok);
- scan2(TOK_VERSION, TOK_RBRACE, &tok);
- } while (tok.kind == TOK_VERSION);
- scan(TOK_EQUAL, &tok);
- scan_num(&tok);
- defp->def.pr.prog_num = tok.str;
- *vtailp = NULL;
-}
-
-static void
def_enum(definition * defp)
{
token tok;
(void)peekscan(TOK_INT, &tok);
break;
case TOK_VOID:
- if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
- error("voids allowed only inside union and program definitions");
+ if (dkind != DEF_UNION) {
+ error("voids allowed only inside union definitions");
}
*typep = tok.str;
break;
DEF_UNION,
DEF_ENUM,
DEF_TYPEDEF,
- DEF_PROGRAM
};
typedef enum defkind defkind;
};
typedef struct union_def union_def;
-
-
-struct proc_list {
- char *proc_name;
- char *proc_num;
- char *arg_type;
- char *arg_prefix;
- char *res_type;
- char *res_prefix;
- struct proc_list *next;
-};
-typedef struct proc_list proc_list;
-
-
-struct version_list {
- char *vers_name;
- char *vers_num;
- proc_list *procs;
- struct version_list *next;
-};
-typedef struct version_list version_list;
-
-struct program_def {
- char *prog_num;
- version_list *versions;
-};
-typedef struct program_def program_def;
-
struct param_list {
defkind param_kind;
char *param_name;
union_def un;
enum_def en;
typedef_def ty;
- program_def pr;
spec_def sd;
} def;
procedure_def pc;
{TOK_FLOAT, "float"},
{TOK_DOUBLE, "double"},
{TOK_STRING, "string"},
- {TOK_PROGRAM, "program"},
- {TOK_VERSION, "version"},
{TOK_PACKAGE, "package"},
{TOK_PREFIX, "prefix"},
{TOK_STATINDEX, "statindex"},
TOK_STRING,
TOK_BOOL,
TOK_VOID,
- TOK_PROGRAM,
- TOK_VERSION,
TOK_PACKAGE,
TOK_PREFIX,
TOK_STATINDEX,
+++ /dev/null
-/* @(#)rpc_svcout.c 1.2 87/11/24 3.9 RPCSRC */
-/*
- * 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
- * program developed by the user.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsytsems, Inc.
- */
-#include <afsconfig.h>
-#include <afs/param.h>
-
-#include <roken.h>
-
-#include "rpc_scan.h"
-#include "rpc_parse.h"
-#include "rpc_util.h"
-
-static char RQSTP[] = "rqstp";
-static char TRANSP[] = "transp";
-static char ARG[] = "argument";
-static char RESULT[] = "result";
-static char ROUTINE[] = "local";
-
-/* static prototypes */
-static void write_program(definition * def, char *storage);
-static void printerr(char *err, char *transp);
-static void printif(char *proc, char *transp, char *prefix, char *arg);
-
-
-/*
- * write most of the service, that is, everything but the registrations.
- */
-void
-write_most(void)
-{
- list *l;
- definition *def;
- version_list *vp;
-
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM) {
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\nstatic void ");
- pvname(def->def_name, vp->vers_num);
- f_print(fout, "();");
- }
- }
- }
- f_print(fout, "\n\n");
- f_print(fout, "main()\n");
- f_print(fout, "{\n");
- f_print(fout, "\tSVCXPRT *%s;\n", TRANSP);
- f_print(fout, "\n");
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind != DEF_PROGRAM) {
- continue;
- }
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\tpmap_unset(%s, %s);\n", def->def_name,
- vp->vers_name);
- }
- }
-}
-
-
-/*
- * write a registration for the given transport
- */
-void
-write_register(char *transp)
-{
- list *l;
- definition *def;
- version_list *vp;
-
- f_print(fout, "\n");
- f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp);
- if (streq(transp, "tcp")) {
- f_print(fout, ", 0, 0");
- }
- f_print(fout, ");\n");
- f_print(fout, "\tif (%s == NULL) {\n", TRANSP);
- f_print(fout, "\t\tfprintf(stderr, \"cannot create %s service.\\n\");\n",
- transp);
- f_print(fout, "\t\texit(1);\n");
- f_print(fout, "\t}\n");
-
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind != DEF_PROGRAM) {
- continue;
- }
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\tif (!svc_register(%s, %s, %s, ", TRANSP,
- def->def_name, vp->vers_name);
- pvname(def->def_name, vp->vers_num);
- f_print(fout, ", IPPROTO_%s)) {\n",
- streq(transp, "udp") ? "UDP" : "TCP");
- f_print(fout,
- "\t\tfprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n",
- def->def_name, vp->vers_name, transp);
- f_print(fout, "\t\texit(1);\n");
- f_print(fout, "\t}\n");
- }
- }
-}
-
-
-/*
- * write the rest of the service
- */
-void
-write_rest(void)
-{
- f_print(fout, "\tsvc_run();\n");
- f_print(fout, "\tfprintf(stderr, \"svc_run returned\\n\");\n");
- f_print(fout, "\texit(1);\n");
- f_print(fout, "}\n");
-}
-
-void
-write_programs(char *storage)
-{
- list *l;
- definition *def;
-
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM) {
- write_program(def, storage);
- }
- }
-}
-
-
-static void
-write_program(definition * def, char *storage)
-{
- version_list *vp;
- proc_list *proc;
- int filled;
-
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\n");
- if (storage != NULL) {
- f_print(fout, "%s ", storage);
- }
- f_print(fout, "void\n");
- pvname(def->def_name, vp->vers_num);
- f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
- f_print(fout, " struct svc_req *%s;\n", RQSTP);
- f_print(fout, " SVCXPRT *%s;\n", TRANSP);
- f_print(fout, "{\n");
-
- filled = 0;
- f_print(fout, "\tunion {\n");
- for (proc = vp->procs; proc != NULL; proc = proc->next) {
- if (streq(proc->arg_type, "void")) {
- continue;
- }
- filled = 1;
- f_print(fout, "\t\t");
- ptype(proc->arg_prefix, proc->arg_type, 0);
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "_arg;\n");
- }
- if (!filled) {
- f_print(fout, "\t\tint fill;\n");
- }
- f_print(fout, "\t} %s;\n", ARG);
- f_print(fout, "\tchar *%s;\n", RESULT);
- f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
- f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
- f_print(fout, "\n");
- f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
-
- if (!nullproc(vp->procs)) {
- f_print(fout, "\tcase NULLPROC:\n");
- f_print(fout, "\t\tsvc_sendreply(%s, xdr_void, NULL);\n", TRANSP);
- f_print(fout, "\t\treturn;\n\n");
- }
- for (proc = vp->procs; proc != NULL; proc = proc->next) {
- f_print(fout, "\tcase %s:\n", proc->proc_name);
- f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG,
- stringfix(proc->arg_type));
- f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT,
- stringfix(proc->res_type));
- f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, ";\n");
- f_print(fout, "\t\tbreak;\n\n");
- }
- f_print(fout, "\tdefault:\n");
- printerr("noproc", TRANSP);
- f_print(fout, "\t\treturn;\n");
- f_print(fout, "\t}\n");
-
- f_print(fout, "\tmemset(&%s, 0, sizeof(%s));\n", ARG, ARG);
- printif("getargs", TRANSP, "&", ARG);
- printerr("decode", TRANSP);
- f_print(fout, "\t\treturn;\n");
- f_print(fout, "\t}\n");
-
- f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG,
- RQSTP);
- f_print(fout,
- "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
- RESULT, TRANSP, RESULT, RESULT);
- printerr("systemerr", TRANSP);
- f_print(fout, "\t}\n");
-
- printif("freeargs", TRANSP, "&", ARG);
- f_print(fout,
- "\t\tfprintf(stderr, \"unable to free arguments\\n\");\n");
- f_print(fout, "\t\texit(1);\n");
- f_print(fout, "\t}\n");
-
- f_print(fout, "}\n\n");
- }
-}
-
-static void
-printerr(char *err, char *transp)
-{
- f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
-}
-
-static void
-printif(char *proc, char *transp, char *prefix, char *arg)
-{
- f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", proc, transp, arg,
- prefix, arg);
-}
-
-
-int
-nullproc(proc_list * proc)
-{
- for (; proc != NULL; proc = proc->next) {
- if (streq(proc->proc_num, "0")) {
- return (1);
- }
- }
- return (0);
-}
{TOK_OPAQUE, "opaque"},
{TOK_BOOL, "bool"},
{TOK_VOID, "void"},
- {TOK_PROGRAM, "program"},
- {TOK_VERSION, "version"},
{TOK_PACKAGE, "package"},
{TOK_PREFIX, "prefix"},
{TOK_STATINDEX, "statindex"},
#define FINDVAL(list,item,finder) \
findval(list, (char *) item, finder)
-/* rpc_clntout.c */
-extern void write_stubs(void);
-
/* rpc_cout.c */
extern void emit(definition * def);
extern void print_param(declaration * dec);
/* rpc_hout.c */
extern void print_datadef(definition * def);
extern void pdefine(char *name, char *num);
-extern void pprocdef(proc_list * proc, version_list * vp);
/* rpc_parse.c */
extern list *proc_defined[MAX_PACKAGES], *special_defined, *typedef_defined,
extern proc1_list *Proc_list, **Proc_listp;
-/* rpc_svcout.c */
-extern int nullproc(proc_list * proc);
-extern void write_programs(char *storage);
-extern void write_rest(void);
-extern void write_most(void);
-extern void write_register(char *transp);
-
/* rpc_scan.c */
extern int pushed;
extern token lasttok;