rpc_clntout.c revision 61961e0f20c7637a3846bb39786bb9dffa91dfb9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* rpc_clntout.c, Client-stub outputter for the RPC protocol compiler
*/
#include <stdio.h>
#include <string.h>
#include "rpc_parse.h"
#include "rpc_util.h"
extern void pdeclaration(char *, declaration *, int, char *);
extern void printarglist(proc_list *, char *, char *, char *);
static void write_program(definition *);
static char RESULT[] = "clnt_res";
void
write_stubs(void)
{
list *l;
"\n/* Default timeout can be changed using clnt_control() */\n");
}
}
}
static void
{
if (mtflag == 0) {
} else {
}
}
}
}
/*
* Writes out declarations of procedure's argument list.
* In either ANSI C style, in one of old rpcgen style (pass by reference),
* or new rpcgen style (multiple arguments, pass by value);
*/
/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
void
{
decl_list *l;
if (!newstyle) {
/* old style: always pass argument by reference */
if (Cflag) { /* C++ style heading */
if (mtflag) { /* Generate result field */
if (!oneway) {
}
} else
} else {
if (!mtflag)
else {
if (!oneway) {
result);
}
}
}
}
/* newstyle, 0 argument */
if (mtflag) {
if (Cflag) {
if (!oneway) {
}
} else
} else
if (Cflag)
else
} else {
/* new style, 1 or multiple arguments */
if (!Cflag) {
}
}
} else { /* C++ style header */
", ");
}
}
}
}
if (!Cflag)
}
static char *
{
return ("");
} else {
return ("&");
}
}
static void
{
decl_list *l;
/*
* For new style with multiple arguments, need a structure in which
* to stuff the arguments.
*/
}
if (!oneway) {
if (!mtflag) {
} else {
}
"\t(void) memset(%s%s, 0, sizeof (%s));\n",
}
/* newstyle, 0 arguments */
if (mtflag)
else
"(clnt_call(clnt, %s,\n\t\t(xdrproc_t)xdr_void, ",
"NULL,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s,",
RESULT);
if (mtflag)
else
"\n\t\tTIMEOUT) != RPC_SUCCESS) {\n");
/*
* Newstyle, multiple arguments
* stuff arguments into structure
*/
}
if (mtflag)
else
"(clnt_call(clnt, %s,\n\t\t(xdrproc_t)xdr_%s",
", (caddr_t)&arg,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s,",
RESULT);
if (mtflag)
else
"\n\t\tTIMEOUT) != RPC_SUCCESS) {\n");
} else { /* single argument, new or old style */
if (!mtflag)
"\tif (clnt_call(clnt, "
"%s,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s,\n\t\tTIMEOUT) != "
"RPC_SUCCESS) {\n",
(newstyle ?
"argp"),
RESULT);
else
"\treturn (clnt_call(clnt, "
"%s,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s,\n\t\tTIMEOUT));\n",
(newstyle ?
"argp"),
RESULT);
}
if (!mtflag) {
} else {
}
}
} else {
/* oneway call */
if (!mtflag) {
"\t(void) memset(&%s, 0, sizeof (%s));\n",
}
/* newstyle, 0 arguments */
if (mtflag)
else
"clnt_send(clnt, %s,\n\t\t(xdrproc_t)xdr_void, ",
if (mtflag)
else
/*
* Newstyle, multiple arguments
* stuff arguments into structure
*/
}
if (mtflag)
else
"clnt_send(clnt, %s,\n\t\t(xdrproc_t)xdr_%s",
", (caddr_t)&arg)");
if (mtflag)
else
} else { /* single argument, new or old style */
if (!mtflag)
"\tif ((%s = clnt_send(clnt, "
"%s,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s)) != RPC_SUCCESS) {\n",
(newstyle ?
"argp"));
else
"\treturn (clnt_send(clnt, "
"%s,\n\t\t(xdrproc_t)xdr_%s, "
"(caddr_t)%s%s));\n",
(newstyle ?
"argp"));
}
if (!mtflag) {
RESULT);
}
}
}