version 1.5, 2001/07/18 22:26:00 |
version 1.6, 2001/11/24 19:17:47 |
|
|
#include "rpc_parse.h" |
#include "rpc_parse.h" |
#include "rpc_util.h" |
#include "rpc_util.h" |
|
|
static write_program __P((definition *)); |
static void write_program __P((definition *)); |
static void printbody __P((proc_list *)); |
static void printbody __P((proc_list *)); |
|
|
extern pdeclaration(); |
extern void pdeclaration(); |
|
|
#define DEFAULT_TIMEOUT 25 /* in seconds */ |
#define DEFAULT_TIMEOUT 25 /* in seconds */ |
static char RESULT[] = "clnt_res"; |
static char RESULT[] = "clnt_res"; |
|
|
list *l; |
list *l; |
definition *def; |
definition *def; |
|
|
f_print(fout, |
f_print(fout, |
"\n/* Default timeout can be changed using clnt_control() */\n"); |
"\n/* Default timeout can be changed using clnt_control() */\n"); |
f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", |
f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", |
DEFAULT_TIMEOUT); |
DEFAULT_TIMEOUT); |
|
|
} |
} |
} |
} |
|
|
static |
static void |
write_program(def) |
write_program(def) |
definition *def; |
definition *def; |
{ |
{ |
|
|
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); |
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); |
f_print(fout, "*argp;\n"); |
f_print(fout, "*argp;\n"); |
} |
} |
} else if (streq( proc->args.decls->decl.type, "void")) { |
} else if (streq( proc->args.decls->decl.type, "void")) { |
/* newstyle, 0 argument */ |
/* newstyle, 0 argument */ |
if( Cflag ) |
if (Cflag) |
f_print(fout, "(%s%s)\n", addargtype, addargname ); |
f_print(fout, "(%s%s)\n", addargtype, addargname ); |
else |
else |
f_print(fout, "(%s)\n", addargname); |
f_print(fout, "(%s)\n", addargname); |
} else { |
} else { |
/* new style, 1 or multiple arguments */ |
/* new style, 1 or multiple arguments */ |
if( !Cflag ) { |
if (!Cflag) { |
f_print(fout, "("); |
f_print(fout, "("); |
for (l = proc->args.decls; l != NULL; l = l->next) |
for (l = proc->args.decls; l != NULL; l = l->next) |
f_print(fout, "%s, ", l->decl.name); |
f_print(fout, "%s, ", l->decl.name); |
f_print(fout, "%s)\n", addargname ); |
f_print(fout, "%s)\n", addargname ); |
for (l = proc->args.decls; l != NULL; l = l->next) { |
for (l = proc->args.decls; l != NULL; l = l->next) { |
|
|
} |
} |
} |
} |
|
|
if( !Cflag ) |
if (!Cflag) |
f_print(fout, "\t%s%s;\n", addargtype, addargname ); |
f_print(fout, "\t%s%s;\n", addargtype, addargname ); |
} |
} |
|
|
|
|
{ |
{ |
decl_list *l; |
decl_list *l; |
bool_t args2 = (proc->arg_num > 1); |
bool_t args2 = (proc->arg_num > 1); |
int i; |
|
|
|
/* For new style with multiple arguments, need a structure in which |
/* For new style with multiple arguments, need a structure in which |
to stuff the arguments. */ |
to stuff the arguments. */ |
if ( newstyle && args2) { |
if ( newstyle && args2) { |
f_print(fout, "\t%s", proc->args.argname); |
f_print(fout, "\t%s", proc->args.argname); |
f_print(fout, " arg;\n"); |
f_print(fout, " arg;\n"); |
} |
} |
f_print(fout, "\tstatic "); |
f_print(fout, "\tstatic "); |
if (streq(proc->res_type, "void")) { |
if (streq(proc->res_type, "void")) { |
|
|
/* newstyle, 0 arguments */ |
/* newstyle, 0 arguments */ |
f_print(fout, |
f_print(fout, |
"\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name); |
"\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name); |
f_print(fout, |
f_print(fout, |
", NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", |
", NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", |
stringfix(proc->res_type), ampr(proc->res_type), RESULT); |
stringfix(proc->res_type), ampr(proc->res_type), RESULT); |
|
|
|
|
f_print(fout, |
f_print(fout, |
"\tif (clnt_call(clnt, %s, xdr_%s", proc->proc_name, |
"\tif (clnt_call(clnt, %s, xdr_%s", proc->proc_name, |
proc->args.argname); |
proc->args.argname); |
f_print(fout, |
f_print(fout, |
", &arg, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", |
", &arg, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", |
stringfix(proc->res_type), |
stringfix(proc->res_type), |
ampr(proc->res_type), RESULT); |
ampr(proc->res_type), RESULT); |
} else { /* single argument, new or old style */ |
} else { /* single argument, new or old style */ |
f_print(fout, |
f_print(fout, |
"\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", |
"\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", |
proc->proc_name, |
proc->proc_name, |
stringfix(proc->args.decls->decl.type), |
stringfix(proc->args.decls->decl.type), |
(newstyle ? "&" : ""), |
(newstyle ? "&" : ""), |
(newstyle ? proc->args.decls->decl.name : "argp"), |
(newstyle ? proc->args.decls->decl.name : "argp"), |
stringfix(proc->res_type), |
stringfix(proc->res_type), |
|
|
f_print(fout, "\t\treturn (NULL);\n"); |
f_print(fout, "\t\treturn (NULL);\n"); |
f_print(fout, "\t}\n"); |
f_print(fout, "\t}\n"); |
if (streq(proc->res_type, "void")) { |
if (streq(proc->res_type, "void")) { |
f_print(fout, "\treturn ((void *)%s%s);\n", |
f_print(fout, "\treturn ((void *)%s%s);\n", |
ampr(proc->res_type),RESULT); |
ampr(proc->res_type),RESULT); |
} else { |
} else { |
f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type),RESULT); |
f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type),RESULT); |