1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate * 22*0Sstevel@tonic-gate * Copyright 2001 Sun Microsystems, Inc. All rights reserved. 23*0Sstevel@tonic-gate * Use is subject to license terms. 24*0Sstevel@tonic-gate */ 25*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 26*0Sstevel@tonic-gate /* All Rights Reserved */ 27*0Sstevel@tonic-gate /* 28*0Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 29*0Sstevel@tonic-gate * The Regents of the University of California 30*0Sstevel@tonic-gate * All Rights Reserved 31*0Sstevel@tonic-gate * 32*0Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 33*0Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 34*0Sstevel@tonic-gate * contributors. 35*0Sstevel@tonic-gate */ 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate /* 40*0Sstevel@tonic-gate * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler 41*0Sstevel@tonic-gate */ 42*0Sstevel@tonic-gate #include <stdio.h> 43*0Sstevel@tonic-gate #include <string.h> 44*0Sstevel@tonic-gate #include <rpc/types.h> 45*0Sstevel@tonic-gate #include "rpc_parse.h" 46*0Sstevel@tonic-gate #include "rpc_util.h" 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate extern pdeclaration(); 49*0Sstevel@tonic-gate void printarglist(); 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate static char RESULT[] = "clnt_res"; 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #define DEFAULT_TIMEOUT 25 /* in seconds */ 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate void 59*0Sstevel@tonic-gate write_stubs() 60*0Sstevel@tonic-gate { 61*0Sstevel@tonic-gate list *l; 62*0Sstevel@tonic-gate definition *def; 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate f_print(fout, 65*0Sstevel@tonic-gate "\n/* Default timeout can be changed using clnt_control() */\n"); 66*0Sstevel@tonic-gate f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", 67*0Sstevel@tonic-gate DEFAULT_TIMEOUT); 68*0Sstevel@tonic-gate for (l = defined; l != NULL; l = l->next) { 69*0Sstevel@tonic-gate def = (definition *) l->val; 70*0Sstevel@tonic-gate if (def->def_kind == DEF_PROGRAM) { 71*0Sstevel@tonic-gate write_program(def); 72*0Sstevel@tonic-gate } 73*0Sstevel@tonic-gate } 74*0Sstevel@tonic-gate } 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate static 77*0Sstevel@tonic-gate write_program(def) 78*0Sstevel@tonic-gate definition *def; 79*0Sstevel@tonic-gate { 80*0Sstevel@tonic-gate version_list *vp; 81*0Sstevel@tonic-gate proc_list *proc; 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { 84*0Sstevel@tonic-gate for (proc = vp->procs; proc != NULL; proc = proc->next) { 85*0Sstevel@tonic-gate f_print(fout, "\n"); 86*0Sstevel@tonic-gate if (mtflag == 0) { 87*0Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1); 88*0Sstevel@tonic-gate f_print(fout, "*\n"); 89*0Sstevel@tonic-gate pvname(proc->proc_name, vp->vers_num); 90*0Sstevel@tonic-gate printarglist(proc, RESULT, "clnt", "CLIENT *"); 91*0Sstevel@tonic-gate } else { 92*0Sstevel@tonic-gate f_print(fout, "enum clnt_stat \n"); 93*0Sstevel@tonic-gate pvname(proc->proc_name, vp->vers_num); 94*0Sstevel@tonic-gate printarglist(proc, RESULT, "clnt", "CLIENT *"); 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate } 97*0Sstevel@tonic-gate f_print(fout, "{\n"); 98*0Sstevel@tonic-gate printbody(proc); 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate f_print(fout, "}\n"); 101*0Sstevel@tonic-gate } 102*0Sstevel@tonic-gate } 103*0Sstevel@tonic-gate } 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate /* 106*0Sstevel@tonic-gate * Writes out declarations of procedure's argument list. 107*0Sstevel@tonic-gate * In either ANSI C style, in one of old rpcgen style (pass by reference), 108*0Sstevel@tonic-gate * or new rpcgen style (multiple arguments, pass by value); 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate /* sample addargname = "clnt"; sample addargtype = "CLIENT * " */ 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate void printarglist(proc, result, addargname, addargtype) 114*0Sstevel@tonic-gate proc_list *proc; 115*0Sstevel@tonic-gate char *result; 116*0Sstevel@tonic-gate char* addargname, * addargtype; 117*0Sstevel@tonic-gate { 118*0Sstevel@tonic-gate bool_t oneway = streq(proc->res_type, "oneway"); 119*0Sstevel@tonic-gate decl_list *l; 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate if (!newstyle) { 122*0Sstevel@tonic-gate /* old style: always pass argument by reference */ 123*0Sstevel@tonic-gate if (Cflag) { /* C++ style heading */ 124*0Sstevel@tonic-gate f_print(fout, "("); 125*0Sstevel@tonic-gate ptype(proc->args.decls->decl.prefix, 126*0Sstevel@tonic-gate proc->args.decls->decl.type, 1); 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate if (mtflag) {/* Generate result field */ 129*0Sstevel@tonic-gate f_print(fout, "*argp, "); 130*0Sstevel@tonic-gate if (!oneway) { 131*0Sstevel@tonic-gate ptype(proc->res_prefix, 132*0Sstevel@tonic-gate proc->res_type, 1); 133*0Sstevel@tonic-gate f_print(fout, "*%s, ", result); 134*0Sstevel@tonic-gate } 135*0Sstevel@tonic-gate f_print(fout, "%s%s)\n", 136*0Sstevel@tonic-gate addargtype, addargname); 137*0Sstevel@tonic-gate } else 138*0Sstevel@tonic-gate f_print(fout, "*argp, %s%s)\n", addargtype, addargname); 139*0Sstevel@tonic-gate } else { 140*0Sstevel@tonic-gate if (!mtflag) 141*0Sstevel@tonic-gate f_print(fout, "(argp, %s)\n", addargname); 142*0Sstevel@tonic-gate else { 143*0Sstevel@tonic-gate f_print(fout, "(argp, "); 144*0Sstevel@tonic-gate if (!oneway) { 145*0Sstevel@tonic-gate f_print(fout, "%s, ", 146*0Sstevel@tonic-gate result); 147*0Sstevel@tonic-gate } 148*0Sstevel@tonic-gate f_print(fout, "%s)\n", 149*0Sstevel@tonic-gate addargname); 150*0Sstevel@tonic-gate } 151*0Sstevel@tonic-gate f_print(fout, "\t"); 152*0Sstevel@tonic-gate ptype(proc->args.decls->decl.prefix, 153*0Sstevel@tonic-gate proc->args.decls->decl.type, 1); 154*0Sstevel@tonic-gate f_print(fout, "*argp;\n"); 155*0Sstevel@tonic-gate if (mtflag && !oneway) { 156*0Sstevel@tonic-gate f_print(fout, "\t"); 157*0Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1); 158*0Sstevel@tonic-gate f_print(fout, "*%s;\n", result); 159*0Sstevel@tonic-gate } 160*0Sstevel@tonic-gate } 161*0Sstevel@tonic-gate } else if (streq(proc->args.decls->decl.type, "void")) { 162*0Sstevel@tonic-gate /* newstyle, 0 argument */ 163*0Sstevel@tonic-gate if (mtflag) { 164*0Sstevel@tonic-gate f_print(fout, "("); 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate if (Cflag) { 167*0Sstevel@tonic-gate if (!oneway) { 168*0Sstevel@tonic-gate ptype(proc->res_prefix, 169*0Sstevel@tonic-gate proc->res_type, 1); 170*0Sstevel@tonic-gate f_print(fout, "*%s, ", result); 171*0Sstevel@tonic-gate } 172*0Sstevel@tonic-gate f_print(fout, "%s%s)\n", 173*0Sstevel@tonic-gate addargtype, addargname); 174*0Sstevel@tonic-gate } else 175*0Sstevel@tonic-gate f_print(fout, "(%s)\n", addargname); 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate } else 178*0Sstevel@tonic-gate if (Cflag) 179*0Sstevel@tonic-gate f_print(fout, "(%s%s)\n", addargtype, addargname); 180*0Sstevel@tonic-gate else 181*0Sstevel@tonic-gate f_print(fout, "(%s)\n", addargname); 182*0Sstevel@tonic-gate } else { 183*0Sstevel@tonic-gate /* new style, 1 or multiple arguments */ 184*0Sstevel@tonic-gate if (!Cflag) { 185*0Sstevel@tonic-gate f_print(fout, "("); 186*0Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) 187*0Sstevel@tonic-gate f_print(fout, "%s, ", l->decl.name); 188*0Sstevel@tonic-gate if (mtflag && !oneway) 189*0Sstevel@tonic-gate f_print(fout, "%s, ", result); 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate f_print(fout, "%s)\n", addargname); 192*0Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) { 193*0Sstevel@tonic-gate pdeclaration(proc->args.argname, 194*0Sstevel@tonic-gate &l->decl, 1, ";\n"); 195*0Sstevel@tonic-gate } 196*0Sstevel@tonic-gate if (mtflag && !oneway) { 197*0Sstevel@tonic-gate f_print(fout, "\t"); 198*0Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1); 199*0Sstevel@tonic-gate f_print(fout, "*%s;\n", result); 200*0Sstevel@tonic-gate } 201*0Sstevel@tonic-gate 202*0Sstevel@tonic-gate } else { /* C++ style header */ 203*0Sstevel@tonic-gate f_print(fout, "("); 204*0Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) { 205*0Sstevel@tonic-gate pdeclaration(proc->args.argname, &l->decl, 0, 206*0Sstevel@tonic-gate ", "); 207*0Sstevel@tonic-gate } 208*0Sstevel@tonic-gate if (mtflag && !oneway) { 209*0Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 1); 210*0Sstevel@tonic-gate f_print(fout, "*%s, ", result); 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate } 213*0Sstevel@tonic-gate f_print(fout, "%s%s)\n", addargtype, addargname); 214*0Sstevel@tonic-gate } 215*0Sstevel@tonic-gate } 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate if (!Cflag) 218*0Sstevel@tonic-gate f_print(fout, "\t%s%s;\n", addargtype, addargname); 219*0Sstevel@tonic-gate } 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate 223*0Sstevel@tonic-gate static char * 224*0Sstevel@tonic-gate ampr(type) 225*0Sstevel@tonic-gate char *type; 226*0Sstevel@tonic-gate { 227*0Sstevel@tonic-gate if (isvectordef(type, REL_ALIAS)) { 228*0Sstevel@tonic-gate return (""); 229*0Sstevel@tonic-gate } else { 230*0Sstevel@tonic-gate return ("&"); 231*0Sstevel@tonic-gate } 232*0Sstevel@tonic-gate } 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate static 235*0Sstevel@tonic-gate printbody(proc) 236*0Sstevel@tonic-gate proc_list *proc; 237*0Sstevel@tonic-gate { 238*0Sstevel@tonic-gate decl_list *l; 239*0Sstevel@tonic-gate bool_t args2 = (proc->arg_num > 1); 240*0Sstevel@tonic-gate int i; 241*0Sstevel@tonic-gate bool_t oneway = streq(proc->res_type, "oneway"); 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate /* 244*0Sstevel@tonic-gate * For new style with multiple arguments, need a structure in which 245*0Sstevel@tonic-gate * to stuff the arguments. 246*0Sstevel@tonic-gate */ 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate if (newstyle && args2) { 250*0Sstevel@tonic-gate f_print(fout, "\t%s", proc->args.argname); 251*0Sstevel@tonic-gate f_print(fout, " arg;\n"); 252*0Sstevel@tonic-gate } 253*0Sstevel@tonic-gate if (!oneway) { 254*0Sstevel@tonic-gate if (!mtflag) { 255*0Sstevel@tonic-gate f_print(fout, "\tstatic "); 256*0Sstevel@tonic-gate if (streq(proc->res_type, "void")) { 257*0Sstevel@tonic-gate f_print(fout, "char "); 258*0Sstevel@tonic-gate } else { 259*0Sstevel@tonic-gate ptype(proc->res_prefix, proc->res_type, 0); 260*0Sstevel@tonic-gate } 261*0Sstevel@tonic-gate f_print(fout, "%s;\n", RESULT); 262*0Sstevel@tonic-gate f_print(fout, "\n"); 263*0Sstevel@tonic-gate f_print(fout, 264*0Sstevel@tonic-gate "\tmemset((char *)%s%s, 0, sizeof (%s));\n", 265*0Sstevel@tonic-gate ampr(proc->res_type), RESULT, RESULT); 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gate } 268*0Sstevel@tonic-gate if (newstyle && !args2 && 269*0Sstevel@tonic-gate (streq(proc->args.decls->decl.type, "void"))) { 270*0Sstevel@tonic-gate /* newstyle, 0 arguments */ 271*0Sstevel@tonic-gate 272*0Sstevel@tonic-gate if (mtflag) 273*0Sstevel@tonic-gate f_print(fout, "\t return "); 274*0Sstevel@tonic-gate else 275*0Sstevel@tonic-gate f_print(fout, "\t if "); 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gate f_print(fout, 278*0Sstevel@tonic-gate "(clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_void, ", 279*0Sstevel@tonic-gate proc->proc_name); 280*0Sstevel@tonic-gate f_print(fout, 281*0Sstevel@tonic-gate "(caddr_t) NULL,\n\t\t(xdrproc_t) xdr_%s, " 282*0Sstevel@tonic-gate "(caddr_t) %s%s,", 283*0Sstevel@tonic-gate stringfix(proc->res_type), 284*0Sstevel@tonic-gate (mtflag)?"":ampr(proc->res_type), 285*0Sstevel@tonic-gate RESULT); 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate if (mtflag) 288*0Sstevel@tonic-gate f_print(fout, "\n\t\tTIMEOUT));\n"); 289*0Sstevel@tonic-gate else 290*0Sstevel@tonic-gate f_print(fout, 291*0Sstevel@tonic-gate "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n"); 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate } else if (newstyle && args2) { 294*0Sstevel@tonic-gate /* 295*0Sstevel@tonic-gate * Newstyle, multiple arguments 296*0Sstevel@tonic-gate * stuff arguments into structure 297*0Sstevel@tonic-gate */ 298*0Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) { 299*0Sstevel@tonic-gate f_print(fout, "\targ.%s = %s;\n", 300*0Sstevel@tonic-gate l->decl.name, l->decl.name); 301*0Sstevel@tonic-gate } 302*0Sstevel@tonic-gate if (mtflag) 303*0Sstevel@tonic-gate f_print(fout, "\treturn "); 304*0Sstevel@tonic-gate else 305*0Sstevel@tonic-gate f_print(fout, "\tif "); 306*0Sstevel@tonic-gate f_print(fout, 307*0Sstevel@tonic-gate "(clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_%s", 308*0Sstevel@tonic-gate proc->proc_name, proc->args.argname); 309*0Sstevel@tonic-gate f_print(fout, 310*0Sstevel@tonic-gate ", (caddr_t) &arg,\n\t\t(xdrproc_t) xdr_%s, " 311*0Sstevel@tonic-gate "(caddr_t) %s%s,", 312*0Sstevel@tonic-gate stringfix(proc->res_type), 313*0Sstevel@tonic-gate (mtflag)?"":ampr(proc->res_type), 314*0Sstevel@tonic-gate RESULT); 315*0Sstevel@tonic-gate if (mtflag) 316*0Sstevel@tonic-gate f_print(fout, "\n\t\tTIMEOUT));\n"); 317*0Sstevel@tonic-gate else 318*0Sstevel@tonic-gate f_print(fout, 319*0Sstevel@tonic-gate "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n"); 320*0Sstevel@tonic-gate } else { /* single argument, new or old style */ 321*0Sstevel@tonic-gate if (!mtflag) 322*0Sstevel@tonic-gate f_print(fout, 323*0Sstevel@tonic-gate "\tif (clnt_call(clnt, " 324*0Sstevel@tonic-gate "%s,\n\t\t(xdrproc_t) xdr_%s, " 325*0Sstevel@tonic-gate "(caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, " 326*0Sstevel@tonic-gate "(caddr_t) %s%s,\n\t\tTIMEOUT) != " 327*0Sstevel@tonic-gate "RPC_SUCCESS) {\n", 328*0Sstevel@tonic-gate proc->proc_name, 329*0Sstevel@tonic-gate stringfix(proc->args.decls->decl.type), 330*0Sstevel@tonic-gate (newstyle ? "&" : ""), 331*0Sstevel@tonic-gate (newstyle ? 332*0Sstevel@tonic-gate proc->args.decls->decl.name : 333*0Sstevel@tonic-gate "argp"), 334*0Sstevel@tonic-gate stringfix(proc->res_type), 335*0Sstevel@tonic-gate ampr(proc->res_type), 336*0Sstevel@tonic-gate RESULT); 337*0Sstevel@tonic-gate else 338*0Sstevel@tonic-gate f_print(fout, 339*0Sstevel@tonic-gate "\treturn (clnt_call(clnt, " 340*0Sstevel@tonic-gate "%s,\n\t\t(xdrproc_t) xdr_%s, " 341*0Sstevel@tonic-gate "(caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, " 342*0Sstevel@tonic-gate "(caddr_t) %s%s,\n\t\tTIMEOUT));\n", 343*0Sstevel@tonic-gate proc->proc_name, 344*0Sstevel@tonic-gate stringfix(proc->args.decls->decl.type), 345*0Sstevel@tonic-gate (newstyle ? "&" : ""), 346*0Sstevel@tonic-gate (newstyle ? 347*0Sstevel@tonic-gate proc->args.decls->decl.name : 348*0Sstevel@tonic-gate "argp"), 349*0Sstevel@tonic-gate stringfix(proc->res_type), "", 350*0Sstevel@tonic-gate RESULT); 351*0Sstevel@tonic-gate } 352*0Sstevel@tonic-gate if (!mtflag) { 353*0Sstevel@tonic-gate f_print(fout, "\t\treturn (NULL);\n"); 354*0Sstevel@tonic-gate f_print(fout, "\t}\n"); 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate if (streq(proc->res_type, "void")) { 357*0Sstevel@tonic-gate f_print(fout, "\treturn ((void *)%s%s);\n", 358*0Sstevel@tonic-gate ampr(proc->res_type), RESULT); 359*0Sstevel@tonic-gate } else { 360*0Sstevel@tonic-gate f_print(fout, "\treturn (%s%s);\n", 361*0Sstevel@tonic-gate ampr(proc->res_type), RESULT); 362*0Sstevel@tonic-gate } 363*0Sstevel@tonic-gate } 364*0Sstevel@tonic-gate } else { 365*0Sstevel@tonic-gate /* oneway call */ 366*0Sstevel@tonic-gate if (!mtflag) { 367*0Sstevel@tonic-gate f_print(fout, "\tstatic enum clnt_stat "); 368*0Sstevel@tonic-gate f_print(fout, "%s;\n", RESULT); 369*0Sstevel@tonic-gate f_print(fout, "\n"); 370*0Sstevel@tonic-gate f_print(fout, 371*0Sstevel@tonic-gate "\tmemset((char *)&%s, 0, sizeof (%s));\n", 372*0Sstevel@tonic-gate RESULT, RESULT); 373*0Sstevel@tonic-gate 374*0Sstevel@tonic-gate } 375*0Sstevel@tonic-gate if (newstyle && !args2 && 376*0Sstevel@tonic-gate (streq(proc->args.decls->decl.type, "void"))) { 377*0Sstevel@tonic-gate /* newstyle, 0 arguments */ 378*0Sstevel@tonic-gate 379*0Sstevel@tonic-gate if (mtflag) 380*0Sstevel@tonic-gate f_print(fout, "\t return ("); 381*0Sstevel@tonic-gate else 382*0Sstevel@tonic-gate f_print(fout, "\t if ((%s = ", RESULT); 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate f_print(fout, 385*0Sstevel@tonic-gate "clnt_send(clnt, %s,\n\t\t(xdrproc_t) xdr_void, ", 386*0Sstevel@tonic-gate proc->proc_name); 387*0Sstevel@tonic-gate f_print(fout, 388*0Sstevel@tonic-gate "(caddr_t) NULL)"); 389*0Sstevel@tonic-gate 390*0Sstevel@tonic-gate if (mtflag) 391*0Sstevel@tonic-gate f_print(fout, ");\n"); 392*0Sstevel@tonic-gate else 393*0Sstevel@tonic-gate f_print(fout, ") != RPC_SUCCESS) {\n"); 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gate } else if (newstyle && args2) { 396*0Sstevel@tonic-gate /* 397*0Sstevel@tonic-gate * Newstyle, multiple arguments 398*0Sstevel@tonic-gate * stuff arguments into structure 399*0Sstevel@tonic-gate */ 400*0Sstevel@tonic-gate for (l = proc->args.decls; l != NULL; l = l->next) { 401*0Sstevel@tonic-gate f_print(fout, "\targ.%s = %s;\n", 402*0Sstevel@tonic-gate l->decl.name, l->decl.name); 403*0Sstevel@tonic-gate } 404*0Sstevel@tonic-gate if (mtflag) 405*0Sstevel@tonic-gate f_print(fout, "\treturn ("); 406*0Sstevel@tonic-gate else 407*0Sstevel@tonic-gate f_print(fout, "\tif ((%s =", RESULT); 408*0Sstevel@tonic-gate f_print(fout, 409*0Sstevel@tonic-gate "clnt_send(clnt, %s,\n\t\t(xdrproc_t) xdr_%s", 410*0Sstevel@tonic-gate proc->proc_name, proc->args.argname); 411*0Sstevel@tonic-gate f_print(fout, 412*0Sstevel@tonic-gate ", (caddr_t) &arg)"); 413*0Sstevel@tonic-gate if (mtflag) 414*0Sstevel@tonic-gate f_print(fout, ");\n"); 415*0Sstevel@tonic-gate else 416*0Sstevel@tonic-gate f_print(fout, ") != RPC_SUCCESS) {\n"); 417*0Sstevel@tonic-gate } else { /* single argument, new or old style */ 418*0Sstevel@tonic-gate if (!mtflag) 419*0Sstevel@tonic-gate f_print(fout, 420*0Sstevel@tonic-gate "\tif ((%s = clnt_send(clnt, " 421*0Sstevel@tonic-gate "%s,\n\t\t(xdrproc_t) xdr_%s, " 422*0Sstevel@tonic-gate "(caddr_t) %s%s)) != RPC_SUCCESS) {\n", 423*0Sstevel@tonic-gate RESULT, 424*0Sstevel@tonic-gate proc->proc_name, 425*0Sstevel@tonic-gate stringfix(proc->args.decls->decl.type), 426*0Sstevel@tonic-gate (newstyle ? "&" : ""), 427*0Sstevel@tonic-gate (newstyle ? 428*0Sstevel@tonic-gate proc->args.decls->decl.name : 429*0Sstevel@tonic-gate "argp")); 430*0Sstevel@tonic-gate else 431*0Sstevel@tonic-gate 432*0Sstevel@tonic-gate f_print(fout, 433*0Sstevel@tonic-gate "\treturn (clnt_send(clnt, " 434*0Sstevel@tonic-gate "%s,\n\t\t(xdrproc_t) xdr_%s, " 435*0Sstevel@tonic-gate "(caddr_t) %s%s));\n", 436*0Sstevel@tonic-gate proc->proc_name, 437*0Sstevel@tonic-gate stringfix(proc->args.decls->decl.type), 438*0Sstevel@tonic-gate (newstyle ? "&" : ""), 439*0Sstevel@tonic-gate (newstyle ? 440*0Sstevel@tonic-gate proc->args.decls->decl.name : 441*0Sstevel@tonic-gate "argp")); 442*0Sstevel@tonic-gate } 443*0Sstevel@tonic-gate if (!mtflag) { 444*0Sstevel@tonic-gate f_print(fout, "\t\treturn (NULL);\n"); 445*0Sstevel@tonic-gate f_print(fout, "\t}\n"); 446*0Sstevel@tonic-gate 447*0Sstevel@tonic-gate f_print(fout, "\treturn ((void *)&%s);\n", 448*0Sstevel@tonic-gate RESULT); 449*0Sstevel@tonic-gate } 450*0Sstevel@tonic-gate } 451*0Sstevel@tonic-gate } 452