10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*9497SJordan.Brown@Sun.COM * Common Development and Distribution License (the "License").
6*9497SJordan.Brown@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
20132Srobinson */
21132Srobinson
22132Srobinson /*
23*9497SJordan.Brown@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
270Sstevel@tonic-gate /* All Rights Reserved */
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
300Sstevel@tonic-gate * The Regents of the University of California
310Sstevel@tonic-gate * All Rights Reserved
320Sstevel@tonic-gate *
330Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
340Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
350Sstevel@tonic-gate * contributors.
360Sstevel@tonic-gate */
370Sstevel@tonic-gate
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler
400Sstevel@tonic-gate */
410Sstevel@tonic-gate #include <stdio.h>
420Sstevel@tonic-gate #include <string.h>
430Sstevel@tonic-gate #include <rpc/types.h>
440Sstevel@tonic-gate #include "rpc_parse.h"
450Sstevel@tonic-gate #include "rpc_util.h"
460Sstevel@tonic-gate
47132Srobinson extern void pdeclaration(char *, declaration *, int, char *);
48132Srobinson extern void printarglist(proc_list *, char *, char *, char *);
490Sstevel@tonic-gate
50132Srobinson static void write_program(definition *);
51132Srobinson static void printbody(proc_list *);
520Sstevel@tonic-gate
530Sstevel@tonic-gate static char RESULT[] = "clnt_res";
540Sstevel@tonic-gate
55132Srobinson #define DEFAULT_TIMEOUT 25 /* in seconds */
560Sstevel@tonic-gate
570Sstevel@tonic-gate void
write_stubs(void)58132Srobinson write_stubs(void)
590Sstevel@tonic-gate {
600Sstevel@tonic-gate list *l;
610Sstevel@tonic-gate definition *def;
620Sstevel@tonic-gate
630Sstevel@tonic-gate f_print(fout,
64132Srobinson "\n/* Default timeout can be changed using clnt_control() */\n");
650Sstevel@tonic-gate f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
66*9497SJordan.Brown@Sun.COM DEFAULT_TIMEOUT);
670Sstevel@tonic-gate for (l = defined; l != NULL; l = l->next) {
680Sstevel@tonic-gate def = (definition *) l->val;
690Sstevel@tonic-gate if (def->def_kind == DEF_PROGRAM) {
700Sstevel@tonic-gate write_program(def);
710Sstevel@tonic-gate }
720Sstevel@tonic-gate }
730Sstevel@tonic-gate }
740Sstevel@tonic-gate
75132Srobinson static void
write_program(definition * def)76132Srobinson write_program(definition *def)
770Sstevel@tonic-gate {
780Sstevel@tonic-gate version_list *vp;
790Sstevel@tonic-gate proc_list *proc;
800Sstevel@tonic-gate
810Sstevel@tonic-gate for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
820Sstevel@tonic-gate for (proc = vp->procs; proc != NULL; proc = proc->next) {
830Sstevel@tonic-gate f_print(fout, "\n");
840Sstevel@tonic-gate if (mtflag == 0) {
850Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1);
860Sstevel@tonic-gate f_print(fout, "*\n");
870Sstevel@tonic-gate pvname(proc->proc_name, vp->vers_num);
880Sstevel@tonic-gate printarglist(proc, RESULT, "clnt", "CLIENT *");
890Sstevel@tonic-gate } else {
900Sstevel@tonic-gate f_print(fout, "enum clnt_stat \n");
910Sstevel@tonic-gate pvname(proc->proc_name, vp->vers_num);
920Sstevel@tonic-gate printarglist(proc, RESULT, "clnt", "CLIENT *");
930Sstevel@tonic-gate
940Sstevel@tonic-gate }
950Sstevel@tonic-gate f_print(fout, "{\n");
960Sstevel@tonic-gate printbody(proc);
970Sstevel@tonic-gate
980Sstevel@tonic-gate f_print(fout, "}\n");
990Sstevel@tonic-gate }
1000Sstevel@tonic-gate }
1010Sstevel@tonic-gate }
1020Sstevel@tonic-gate
1030Sstevel@tonic-gate /*
1040Sstevel@tonic-gate * Writes out declarations of procedure's argument list.
1050Sstevel@tonic-gate * In either ANSI C style, in one of old rpcgen style (pass by reference),
1060Sstevel@tonic-gate * or new rpcgen style (multiple arguments, pass by value);
1070Sstevel@tonic-gate */
1080Sstevel@tonic-gate
1090Sstevel@tonic-gate /* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
1100Sstevel@tonic-gate
111132Srobinson void
printarglist(proc_list * proc,char * result,char * addargname,char * addargtype)112132Srobinson printarglist(proc_list *proc, char *result, char *addargname, char *addargtype)
1130Sstevel@tonic-gate {
1140Sstevel@tonic-gate bool_t oneway = streq(proc->res_type, "oneway");
1150Sstevel@tonic-gate decl_list *l;
1160Sstevel@tonic-gate
1170Sstevel@tonic-gate if (!newstyle) {
1180Sstevel@tonic-gate /* old style: always pass argument by reference */
1190Sstevel@tonic-gate if (Cflag) { /* C++ style heading */
1200Sstevel@tonic-gate f_print(fout, "(");
1210Sstevel@tonic-gate ptype(proc->args.decls->decl.prefix,
122*9497SJordan.Brown@Sun.COM proc->args.decls->decl.type, 1);
1230Sstevel@tonic-gate
124132Srobinson if (mtflag) { /* Generate result field */
1250Sstevel@tonic-gate f_print(fout, "*argp, ");
1260Sstevel@tonic-gate if (!oneway) {
1270Sstevel@tonic-gate ptype(proc->res_prefix,
1280Sstevel@tonic-gate proc->res_type, 1);
1290Sstevel@tonic-gate f_print(fout, "*%s, ", result);
1300Sstevel@tonic-gate }
1310Sstevel@tonic-gate f_print(fout, "%s%s)\n",
132*9497SJordan.Brown@Sun.COM addargtype, addargname);
1330Sstevel@tonic-gate } else
134132Srobinson f_print(fout, "*argp, %s%s)\n",
135*9497SJordan.Brown@Sun.COM addargtype, addargname);
1360Sstevel@tonic-gate } else {
1370Sstevel@tonic-gate if (!mtflag)
1380Sstevel@tonic-gate f_print(fout, "(argp, %s)\n", addargname);
1390Sstevel@tonic-gate else {
1400Sstevel@tonic-gate f_print(fout, "(argp, ");
1410Sstevel@tonic-gate if (!oneway) {
1420Sstevel@tonic-gate f_print(fout, "%s, ",
1430Sstevel@tonic-gate result);
1440Sstevel@tonic-gate }
1450Sstevel@tonic-gate f_print(fout, "%s)\n",
1460Sstevel@tonic-gate addargname);
1470Sstevel@tonic-gate }
1480Sstevel@tonic-gate f_print(fout, "\t");
1490Sstevel@tonic-gate ptype(proc->args.decls->decl.prefix,
1500Sstevel@tonic-gate proc->args.decls->decl.type, 1);
1510Sstevel@tonic-gate f_print(fout, "*argp;\n");
1520Sstevel@tonic-gate if (mtflag && !oneway) {
1530Sstevel@tonic-gate f_print(fout, "\t");
1540Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1);
1550Sstevel@tonic-gate f_print(fout, "*%s;\n", result);
1560Sstevel@tonic-gate }
1570Sstevel@tonic-gate }
1580Sstevel@tonic-gate } else if (streq(proc->args.decls->decl.type, "void")) {
1590Sstevel@tonic-gate /* newstyle, 0 argument */
1600Sstevel@tonic-gate if (mtflag) {
1610Sstevel@tonic-gate f_print(fout, "(");
162132Srobinson
1630Sstevel@tonic-gate if (Cflag) {
1640Sstevel@tonic-gate if (!oneway) {
1650Sstevel@tonic-gate ptype(proc->res_prefix,
1660Sstevel@tonic-gate proc->res_type, 1);
1670Sstevel@tonic-gate f_print(fout, "*%s, ", result);
1680Sstevel@tonic-gate }
1690Sstevel@tonic-gate f_print(fout, "%s%s)\n",
1700Sstevel@tonic-gate addargtype, addargname);
1710Sstevel@tonic-gate } else
172132Srobinson f_print(fout, "(%s)\n", addargname);
1730Sstevel@tonic-gate
1740Sstevel@tonic-gate } else
1750Sstevel@tonic-gate if (Cflag)
1760Sstevel@tonic-gate f_print(fout, "(%s%s)\n", addargtype, addargname);
1770Sstevel@tonic-gate else
1780Sstevel@tonic-gate f_print(fout, "(%s)\n", addargname);
1790Sstevel@tonic-gate } else {
1800Sstevel@tonic-gate /* new style, 1 or multiple arguments */
1810Sstevel@tonic-gate if (!Cflag) {
1820Sstevel@tonic-gate f_print(fout, "(");
1830Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next)
1840Sstevel@tonic-gate f_print(fout, "%s, ", l->decl.name);
1850Sstevel@tonic-gate if (mtflag && !oneway)
186132Srobinson f_print(fout, "%s, ", result);
1870Sstevel@tonic-gate
1880Sstevel@tonic-gate f_print(fout, "%s)\n", addargname);
1890Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) {
1900Sstevel@tonic-gate pdeclaration(proc->args.argname,
191*9497SJordan.Brown@Sun.COM &l->decl, 1, ";\n");
1920Sstevel@tonic-gate }
1930Sstevel@tonic-gate if (mtflag && !oneway) {
1940Sstevel@tonic-gate f_print(fout, "\t");
1950Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1);
1960Sstevel@tonic-gate f_print(fout, "*%s;\n", result);
1970Sstevel@tonic-gate }
1980Sstevel@tonic-gate
1990Sstevel@tonic-gate } else { /* C++ style header */
2000Sstevel@tonic-gate f_print(fout, "(");
2010Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) {
2020Sstevel@tonic-gate pdeclaration(proc->args.argname, &l->decl, 0,
203*9497SJordan.Brown@Sun.COM ", ");
2040Sstevel@tonic-gate }
2050Sstevel@tonic-gate if (mtflag && !oneway) {
2060Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1);
2070Sstevel@tonic-gate f_print(fout, "*%s, ", result);
2080Sstevel@tonic-gate
2090Sstevel@tonic-gate }
2100Sstevel@tonic-gate f_print(fout, "%s%s)\n", addargtype, addargname);
2110Sstevel@tonic-gate }
2120Sstevel@tonic-gate }
2130Sstevel@tonic-gate
2140Sstevel@tonic-gate if (!Cflag)
2150Sstevel@tonic-gate f_print(fout, "\t%s%s;\n", addargtype, addargname);
2160Sstevel@tonic-gate }
2170Sstevel@tonic-gate
2180Sstevel@tonic-gate
2190Sstevel@tonic-gate
2200Sstevel@tonic-gate static char *
ampr(char * type)221132Srobinson ampr(char *type)
2220Sstevel@tonic-gate {
2230Sstevel@tonic-gate if (isvectordef(type, REL_ALIAS)) {
2240Sstevel@tonic-gate return ("");
2250Sstevel@tonic-gate } else {
2260Sstevel@tonic-gate return ("&");
2270Sstevel@tonic-gate }
2280Sstevel@tonic-gate }
2290Sstevel@tonic-gate
230132Srobinson static void
printbody(proc_list * proc)231132Srobinson printbody(proc_list *proc)
2320Sstevel@tonic-gate {
2330Sstevel@tonic-gate decl_list *l;
2340Sstevel@tonic-gate bool_t args2 = (proc->arg_num > 1);
2350Sstevel@tonic-gate bool_t oneway = streq(proc->res_type, "oneway");
2360Sstevel@tonic-gate
2370Sstevel@tonic-gate /*
2380Sstevel@tonic-gate * For new style with multiple arguments, need a structure in which
2390Sstevel@tonic-gate * to stuff the arguments.
2400Sstevel@tonic-gate */
2410Sstevel@tonic-gate if (newstyle && args2) {
2420Sstevel@tonic-gate f_print(fout, "\t%s", proc->args.argname);
2430Sstevel@tonic-gate f_print(fout, " arg;\n");
2440Sstevel@tonic-gate }
2450Sstevel@tonic-gate if (!oneway) {
2460Sstevel@tonic-gate if (!mtflag) {
2470Sstevel@tonic-gate f_print(fout, "\tstatic ");
2480Sstevel@tonic-gate if (streq(proc->res_type, "void")) {
2490Sstevel@tonic-gate f_print(fout, "char ");
2500Sstevel@tonic-gate } else {
2510Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 0);
2520Sstevel@tonic-gate }
2530Sstevel@tonic-gate f_print(fout, "%s;\n", RESULT);
2540Sstevel@tonic-gate f_print(fout, "\n");
2550Sstevel@tonic-gate f_print(fout,
256132Srobinson "\t(void) memset(%s%s, 0, sizeof (%s));\n",
2570Sstevel@tonic-gate ampr(proc->res_type), RESULT, RESULT);
2580Sstevel@tonic-gate
2590Sstevel@tonic-gate }
2600Sstevel@tonic-gate if (newstyle && !args2 &&
2610Sstevel@tonic-gate (streq(proc->args.decls->decl.type, "void"))) {
2620Sstevel@tonic-gate /* newstyle, 0 arguments */
2630Sstevel@tonic-gate
2640Sstevel@tonic-gate if (mtflag)
2650Sstevel@tonic-gate f_print(fout, "\t return ");
2660Sstevel@tonic-gate else
2670Sstevel@tonic-gate f_print(fout, "\t if ");
2680Sstevel@tonic-gate
2690Sstevel@tonic-gate f_print(fout,
270132Srobinson "(clnt_call(clnt, %s,\n\t\t(xdrproc_t)xdr_void, ",
2710Sstevel@tonic-gate proc->proc_name);
2720Sstevel@tonic-gate f_print(fout,
273132Srobinson "NULL,\n\t\t(xdrproc_t)xdr_%s, "
274132Srobinson "(caddr_t)%s%s,",
2750Sstevel@tonic-gate stringfix(proc->res_type),
2760Sstevel@tonic-gate (mtflag)?"":ampr(proc->res_type),
2770Sstevel@tonic-gate RESULT);
2780Sstevel@tonic-gate
2790Sstevel@tonic-gate if (mtflag)
2800Sstevel@tonic-gate f_print(fout, "\n\t\tTIMEOUT));\n");
2810Sstevel@tonic-gate else
2820Sstevel@tonic-gate f_print(fout,
2830Sstevel@tonic-gate "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n");
2840Sstevel@tonic-gate
2850Sstevel@tonic-gate } else if (newstyle && args2) {
2860Sstevel@tonic-gate /*
2870Sstevel@tonic-gate * Newstyle, multiple arguments
2880Sstevel@tonic-gate * stuff arguments into structure
2890Sstevel@tonic-gate */
2900Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) {
2910Sstevel@tonic-gate f_print(fout, "\targ.%s = %s;\n",
2920Sstevel@tonic-gate l->decl.name, l->decl.name);
2930Sstevel@tonic-gate }
2940Sstevel@tonic-gate if (mtflag)
2950Sstevel@tonic-gate f_print(fout, "\treturn ");
2960Sstevel@tonic-gate else
2970Sstevel@tonic-gate f_print(fout, "\tif ");
2980Sstevel@tonic-gate f_print(fout,
299132Srobinson "(clnt_call(clnt, %s,\n\t\t(xdrproc_t)xdr_%s",
3000Sstevel@tonic-gate proc->proc_name, proc->args.argname);
3010Sstevel@tonic-gate f_print(fout,
302132Srobinson ", (caddr_t)&arg,\n\t\t(xdrproc_t)xdr_%s, "
303132Srobinson "(caddr_t)%s%s,",
3040Sstevel@tonic-gate stringfix(proc->res_type),
3050Sstevel@tonic-gate (mtflag)?"":ampr(proc->res_type),
3060Sstevel@tonic-gate RESULT);
3070Sstevel@tonic-gate if (mtflag)
3080Sstevel@tonic-gate f_print(fout, "\n\t\tTIMEOUT));\n");
3090Sstevel@tonic-gate else
3100Sstevel@tonic-gate f_print(fout,
3110Sstevel@tonic-gate "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n");
3120Sstevel@tonic-gate } else { /* single argument, new or old style */
3130Sstevel@tonic-gate if (!mtflag)
3140Sstevel@tonic-gate f_print(fout,
3150Sstevel@tonic-gate "\tif (clnt_call(clnt, "
316132Srobinson "%s,\n\t\t(xdrproc_t)xdr_%s, "
317132Srobinson "(caddr_t)%s%s,\n\t\t(xdrproc_t)xdr_%s, "
318132Srobinson "(caddr_t)%s%s,\n\t\tTIMEOUT) != "
3190Sstevel@tonic-gate "RPC_SUCCESS) {\n",
3200Sstevel@tonic-gate proc->proc_name,
3210Sstevel@tonic-gate stringfix(proc->args.decls->decl.type),
3220Sstevel@tonic-gate (newstyle ? "&" : ""),
3230Sstevel@tonic-gate (newstyle ?
324*9497SJordan.Brown@Sun.COM proc->args.decls->decl.name :
325*9497SJordan.Brown@Sun.COM "argp"),
3260Sstevel@tonic-gate stringfix(proc->res_type),
3270Sstevel@tonic-gate ampr(proc->res_type),
3280Sstevel@tonic-gate RESULT);
3290Sstevel@tonic-gate else
3300Sstevel@tonic-gate f_print(fout,
3310Sstevel@tonic-gate "\treturn (clnt_call(clnt, "
332132Srobinson "%s,\n\t\t(xdrproc_t)xdr_%s, "
333132Srobinson "(caddr_t)%s%s,\n\t\t(xdrproc_t)xdr_%s, "
334132Srobinson "(caddr_t)%s%s,\n\t\tTIMEOUT));\n",
3350Sstevel@tonic-gate proc->proc_name,
3360Sstevel@tonic-gate stringfix(proc->args.decls->decl.type),
3370Sstevel@tonic-gate (newstyle ? "&" : ""),
3380Sstevel@tonic-gate (newstyle ?
339*9497SJordan.Brown@Sun.COM proc->args.decls->decl.name :
340*9497SJordan.Brown@Sun.COM "argp"),
3410Sstevel@tonic-gate stringfix(proc->res_type), "",
3420Sstevel@tonic-gate RESULT);
3430Sstevel@tonic-gate }
3440Sstevel@tonic-gate if (!mtflag) {
3450Sstevel@tonic-gate f_print(fout, "\t\treturn (NULL);\n");
3460Sstevel@tonic-gate f_print(fout, "\t}\n");
3470Sstevel@tonic-gate
3480Sstevel@tonic-gate if (streq(proc->res_type, "void")) {
3490Sstevel@tonic-gate f_print(fout, "\treturn ((void *)%s%s);\n",
3500Sstevel@tonic-gate ampr(proc->res_type), RESULT);
3510Sstevel@tonic-gate } else {
3520Sstevel@tonic-gate f_print(fout, "\treturn (%s%s);\n",
3530Sstevel@tonic-gate ampr(proc->res_type), RESULT);
3540Sstevel@tonic-gate }
3550Sstevel@tonic-gate }
3560Sstevel@tonic-gate } else {
3570Sstevel@tonic-gate /* oneway call */
3580Sstevel@tonic-gate if (!mtflag) {
3590Sstevel@tonic-gate f_print(fout, "\tstatic enum clnt_stat ");
3600Sstevel@tonic-gate f_print(fout, "%s;\n", RESULT);
3610Sstevel@tonic-gate f_print(fout, "\n");
3620Sstevel@tonic-gate f_print(fout,
363132Srobinson "\t(void) memset(&%s, 0, sizeof (%s));\n",
3640Sstevel@tonic-gate RESULT, RESULT);
3650Sstevel@tonic-gate
3660Sstevel@tonic-gate }
3670Sstevel@tonic-gate if (newstyle && !args2 &&
3680Sstevel@tonic-gate (streq(proc->args.decls->decl.type, "void"))) {
3690Sstevel@tonic-gate /* newstyle, 0 arguments */
3700Sstevel@tonic-gate
3710Sstevel@tonic-gate if (mtflag)
3720Sstevel@tonic-gate f_print(fout, "\t return (");
3730Sstevel@tonic-gate else
3740Sstevel@tonic-gate f_print(fout, "\t if ((%s = ", RESULT);
3750Sstevel@tonic-gate
3760Sstevel@tonic-gate f_print(fout,
377132Srobinson "clnt_send(clnt, %s,\n\t\t(xdrproc_t)xdr_void, ",
3780Sstevel@tonic-gate proc->proc_name);
379132Srobinson f_print(fout, "NULL)");
3800Sstevel@tonic-gate
3810Sstevel@tonic-gate if (mtflag)
3820Sstevel@tonic-gate f_print(fout, ");\n");
3830Sstevel@tonic-gate else
3840Sstevel@tonic-gate f_print(fout, ") != RPC_SUCCESS) {\n");
3850Sstevel@tonic-gate
3860Sstevel@tonic-gate } else if (newstyle && args2) {
3870Sstevel@tonic-gate /*
3880Sstevel@tonic-gate * Newstyle, multiple arguments
3890Sstevel@tonic-gate * stuff arguments into structure
3900Sstevel@tonic-gate */
3910Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) {
3920Sstevel@tonic-gate f_print(fout, "\targ.%s = %s;\n",
3930Sstevel@tonic-gate l->decl.name, l->decl.name);
3940Sstevel@tonic-gate }
3950Sstevel@tonic-gate if (mtflag)
3960Sstevel@tonic-gate f_print(fout, "\treturn (");
3970Sstevel@tonic-gate else
3980Sstevel@tonic-gate f_print(fout, "\tif ((%s =", RESULT);
3990Sstevel@tonic-gate f_print(fout,
400132Srobinson "clnt_send(clnt, %s,\n\t\t(xdrproc_t)xdr_%s",
4010Sstevel@tonic-gate proc->proc_name, proc->args.argname);
4020Sstevel@tonic-gate f_print(fout,
403132Srobinson ", (caddr_t)&arg)");
4040Sstevel@tonic-gate if (mtflag)
4050Sstevel@tonic-gate f_print(fout, ");\n");
4060Sstevel@tonic-gate else
4070Sstevel@tonic-gate f_print(fout, ") != RPC_SUCCESS) {\n");
4080Sstevel@tonic-gate } else { /* single argument, new or old style */
4090Sstevel@tonic-gate if (!mtflag)
4100Sstevel@tonic-gate f_print(fout,
4110Sstevel@tonic-gate "\tif ((%s = clnt_send(clnt, "
412132Srobinson "%s,\n\t\t(xdrproc_t)xdr_%s, "
413132Srobinson "(caddr_t)%s%s)) != RPC_SUCCESS) {\n",
4140Sstevel@tonic-gate RESULT,
4150Sstevel@tonic-gate proc->proc_name,
4160Sstevel@tonic-gate stringfix(proc->args.decls->decl.type),
4170Sstevel@tonic-gate (newstyle ? "&" : ""),
4180Sstevel@tonic-gate (newstyle ?
419*9497SJordan.Brown@Sun.COM proc->args.decls->decl.name :
420*9497SJordan.Brown@Sun.COM "argp"));
4210Sstevel@tonic-gate else
4220Sstevel@tonic-gate
4230Sstevel@tonic-gate f_print(fout,
4240Sstevel@tonic-gate "\treturn (clnt_send(clnt, "
425132Srobinson "%s,\n\t\t(xdrproc_t)xdr_%s, "
426132Srobinson "(caddr_t)%s%s));\n",
4270Sstevel@tonic-gate proc->proc_name,
4280Sstevel@tonic-gate stringfix(proc->args.decls->decl.type),
4290Sstevel@tonic-gate (newstyle ? "&" : ""),
4300Sstevel@tonic-gate (newstyle ?
431*9497SJordan.Brown@Sun.COM proc->args.decls->decl.name :
432*9497SJordan.Brown@Sun.COM "argp"));
4330Sstevel@tonic-gate }
4340Sstevel@tonic-gate if (!mtflag) {
4350Sstevel@tonic-gate f_print(fout, "\t\treturn (NULL);\n");
4360Sstevel@tonic-gate f_print(fout, "\t}\n");
4370Sstevel@tonic-gate
4380Sstevel@tonic-gate f_print(fout, "\treturn ((void *)&%s);\n",
4390Sstevel@tonic-gate RESULT);
4400Sstevel@tonic-gate }
4410Sstevel@tonic-gate }
4420Sstevel@tonic-gate }
443