Print this page
rpcgen should only produce ANSI code
*** 18,27 ****
--- 18,29 ----
*
* CDDL HEADER END
*/
/*
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ *
* Copyright 2009 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 */
*** 73,89 ****
static void open_log_file(char *, char *);
static void
p_xdrfunc(char *rname, char *typename)
{
- if (Cflag) {
f_print(fout, "\t\t_xdr_%s = (xdrproc_t)\n", rname);
f_print(fout, "\t\t xdr_%s;\n", stringfix(typename));
- } else {
- f_print(fout, "\t\t_xdr_%s = xdr_%s;\n",
- rname, stringfix(typename));
- }
}
static void
internal_proctype(proc_list *plist)
{
--- 75,86 ----
*** 298,308 ****
f_print(fout, "\t\t}\n");
f_print(fout, "\t}\n");
} else {
f_print(fout,
"\t\t(void) signal(SIGALRM, %s closedown);\n",
! Cflag? "(SIG_PF)":"(void(*)())");
f_print(fout,
"\t\t(void) alarm(_RPCSVC_CLOSEDOWN/2);\n");
f_print(fout, "\t}\n");
}
}
--- 295,305 ----
f_print(fout, "\t\t}\n");
f_print(fout, "\t}\n");
} else {
f_print(fout,
"\t\t(void) signal(SIGALRM, %s closedown);\n",
! "(SIG_PF)");
f_print(fout,
"\t\t(void) alarm(_RPCSVC_CLOSEDOWN/2);\n");
f_print(fout, "\t}\n");
}
}
*** 365,375 ****
internal_proctype(proc);
else
f_print(fout, "int");
f_print(fout, "\n_");
pvname(proc->proc_name, vp->vers_num);
! if (Cflag) {
f_print(fout, "(\n");
f_print(fout, " ");
/* arg name */
if (proc->arg_num > 1)
/* LINTED variable format */
--- 362,372 ----
internal_proctype(proc);
else
f_print(fout, "int");
f_print(fout, "\n_");
pvname(proc->proc_name, vp->vers_num);
!
f_print(fout, "(\n");
f_print(fout, " ");
/* arg name */
if (proc->arg_num > 1)
/* LINTED variable format */
*** 378,422 ****
ptype(proc->args.decls->decl.prefix,
proc->args.decls->decl.type, 0);
f_print(fout, " *argp,\n");
if (mtflag) {
f_print(fout, " ");
! ptype(proc->res_prefix,
! proc->res_type, 1);
f_print(fout, "*%s,\n", RESULT);
}
! f_print(fout, " struct svc_req *%s)\n",
! RQSTP);
- } else {
- if (mtflag)
- f_print(fout, "(argp, %s, %s)\n",
- RESULT, RQSTP);
- else
- f_print(fout, "(argp, %s)\n", RQSTP);
- /* arg name */
- if (proc->arg_num > 1)
- f_print(fout, "\t%s *argp;\n",
- proc->args.argname);
- else {
- f_print(fout, "\t");
- ptype(proc->args.decls->decl.prefix,
- proc->args.decls->decl.type, 0);
- f_print(fout, " *argp;\n");
- }
- if (mtflag)
- f_print(fout, "\tvoid *%s;\n", RESULT);
- f_print(fout, "\tstruct svc_req *%s;\n", RQSTP);
- }
-
f_print(fout, "{\n");
f_print(fout, "\treturn (");
/* for mtflag, arguments are different */
- if (Cflag || mtflag)
pvname_svc(proc->proc_name, vp->vers_num);
- else
- pvname(proc->proc_name, vp->vers_num);
f_print(fout, "(");
if (proc->arg_num < 2) { /* single argument */
/* only print if non-void */
if (!streq(proc->args.decls->decl.type, "void"))
f_print(fout, "*argp, ");
--- 375,393 ----
ptype(proc->args.decls->decl.prefix,
proc->args.decls->decl.type, 0);
f_print(fout, " *argp,\n");
if (mtflag) {
f_print(fout, " ");
! ptype(proc->res_prefix, proc->res_type, 1);
f_print(fout, "*%s,\n", RESULT);
}
! f_print(fout, " struct svc_req *%s)\n", RQSTP);
f_print(fout, "{\n");
f_print(fout, "\treturn (");
/* for mtflag, arguments are different */
pvname_svc(proc->proc_name, vp->vers_num);
f_print(fout, "(");
if (proc->arg_num < 2) { /* single argument */
/* only print if non-void */
if (!streq(proc->args.decls->decl.type, "void"))
f_print(fout, "*argp, ");
*** 448,465 ****
f_print(fout, "%s ", storage);
}
f_print(fout, "void\n");
pvname(def->def_name, vp->vers_num);
- if (Cflag) {
f_print(fout, "(struct svc_req *%s, ", RQSTP);
f_print(fout, "register SVCXPRT *%s)\n", TRANSP);
- } else {
- f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
- f_print(fout, " struct svc_req *%s;\n", RQSTP);
- f_print(fout, " register SVCXPRT *%s;\n", TRANSP);
- }
f_print(fout, "{\n");
filled = 0;
f_print(fout, "\tunion {\n");
--- 419,430 ----
*** 509,538 ****
f_print(fout, "\tbool_t %s;\n", RETVAL);
} else
f_print(fout, "\tchar *%s;\n", RESULT);
! if (Cflag) {
! f_print(fout, "\txdrproc_t _xdr_%s, _xdr_%s;\n",
! ARG, RESULT);
if (mtflag)
! f_print(fout,
! "\tbool_t (*%s)(char *, void *, struct svc_req *);\n",
ROUTINE);
else
! f_print(fout,
! "\tchar *(*%s)(char *, struct svc_req *);\n",
ROUTINE);
- } else {
- f_print(fout,
- "\tbool_t (*_xdr_%s)(), (*_xdr_%s)();\n",
- ARG, RESULT);
- if (mtflag)
- f_print(fout, "\tbool_t (*%s)();\n", ROUTINE);
- else
- f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
- }
f_print(fout, "\n");
if (timerflag) {
if (mtflag)
f_print(fout,
--- 474,492 ----
f_print(fout, "\tbool_t %s;\n", RETVAL);
} else
f_print(fout, "\tchar *%s;\n", RESULT);
! f_print(fout, "\txdrproc_t _xdr_%s, _xdr_%s;\n", ARG, RESULT);
if (mtflag)
! f_print(fout, "\tbool_t "
! "(*%s)(char *, void *, struct svc_req *);\n",
ROUTINE);
else
! f_print(fout, "\tchar *(*%s)"
! "(char *, struct svc_req *);\n",
ROUTINE);
f_print(fout, "\n");
if (timerflag) {
if (mtflag)
f_print(fout,
*** 546,558 ****
f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
if (!nullproc(vp->procs)) {
f_print(fout, "\tcase NULLPROC:\n");
f_print(fout,
! Cflag ?
! "\t\t(void) svc_sendreply(%s,\n\t\t (xdrproc_t)xdr_void, NULL);\n" :
! "\t\t(void) svc_sendreply(%s, xdr_void,\n\t\t\tNULL);\n",
TRANSP);
print_return("\t\t");
f_print(fout, "\n");
}
for (proc = vp->procs; proc != NULL; proc = proc->next) {
--- 500,510 ----
f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
if (!nullproc(vp->procs)) {
f_print(fout, "\tcase NULLPROC:\n");
f_print(fout,
! "\t\t(void) svc_sendreply(%s,\n\t\t (xdrproc_t)xdr_void, NULL);\n",
TRANSP);
print_return("\t\t");
f_print(fout, "\n");
}
for (proc = vp->procs; proc != NULL; proc = proc->next) {
*** 567,577 ****
/* One-way call */
f_print(fout, "\t\t_xdr_%s = NULL;\n", RESULT);
} else {
p_xdrfunc(RESULT, proc->res_type);
}
- if (Cflag) {
if (mtflag) {
f_print(fout,
"\t\t%s = (bool_t (*) (char *, "
"void *, struct svc_req *))",
ROUTINE);
--- 519,528 ----
*** 579,604 ****
f_print(fout,
"\t\t%s = (char *(*)(char *, "
"struct svc_req *))",
ROUTINE);
}
- } else {
- if (mtflag) {
- f_print(fout,
- "\t\t%s = (bool_t (*)())",
- ROUTINE);
- } else {
- f_print(fout, "\t\t%s = (char *(*)())",
- ROUTINE);
- }
- }
f_print(fout, "\n\t\t ");
if (newstyle) { /* new style: calls internal routine */
f_print(fout, "_");
}
! if ((Cflag || mtflag) && !newstyle)
pvname_svc(proc->proc_name, vp->vers_num);
else
pvname(proc->proc_name, vp->vers_num);
f_print(fout, ";\n");
f_print(fout, "\t\tbreak;\n\n");
--- 530,545 ----
f_print(fout,
"\t\t%s = (char *(*)(char *, "
"struct svc_req *))",
ROUTINE);
}
f_print(fout, "\n\t\t ");
if (newstyle) { /* new style: calls internal routine */
f_print(fout, "_");
}
! if (!newstyle)
pvname_svc(proc->proc_name, vp->vers_num);
else
pvname(proc->proc_name, vp->vers_num);
f_print(fout, ";\n");
f_print(fout, "\t\tbreak;\n\n");
*** 615,644 ****
printerr("decode", TRANSP);
print_return("\t\t");
f_print(fout, "\t}\n");
if (!mtflag)
- if (Cflag)
f_print(fout,
"\t%s = (*%s)((char *)&%s, %s);\n",
RESULT, ROUTINE, ARG, RQSTP);
else
- f_print(fout, "\t%s = (*%s)(&%s, %s);\n",
- RESULT, ROUTINE, ARG, RQSTP);
- else
- if (Cflag)
f_print(fout,
! "\t%s = (bool_t)(*%s)((char *)&%s, (void *)&%s, %s);\n",
RETVAL, ROUTINE, ARG, RESULT, RQSTP);
- else
- f_print(fout,
- "\t%s = (bool_t)(*%s)(&%s, &%s, %s);\n",
- RETVAL, ROUTINE, ARG, RESULT, RQSTP);
-
if (mtflag)
f_print(fout,
"\tif (_xdr_%s && %s > 0 &&\n"
"\t !svc_sendreply(%s, _xdr_%s, (char *)&%s)) {\n",
RESULT, RETVAL, TRANSP, RESULT, RESULT);
--- 556,576 ----
printerr("decode", TRANSP);
print_return("\t\t");
f_print(fout, "\t}\n");
if (!mtflag)
f_print(fout,
"\t%s = (*%s)((char *)&%s, %s);\n",
RESULT, ROUTINE, ARG, RQSTP);
else
f_print(fout,
! "\t%s = (bool_t)(*%s)"
! "((char *)&%s, (void *)&%s, %s);\n",
RETVAL, ROUTINE, ARG, RESULT, RQSTP);
if (mtflag)
f_print(fout,
"\tif (_xdr_%s && %s > 0 &&\n"
"\t !svc_sendreply(%s, _xdr_%s, (char *)&%s)) {\n",
RESULT, RETVAL, TRANSP, RESULT, RESULT);
*** 811,834 ****
static void
write_msg_out(void)
{
f_print(fout, "\n");
f_print(fout, "#if\tdefined(RPC_MSGOUT)\n");
- if (!Cflag) {
- f_print(fout, "extern void RPC_MSGOUT();\n");
- } else {
f_print(fout, "extern void RPC_MSGOUT(const char *, ...);\n");
- }
f_print(fout, "#else\t/* defined(RPC_MSGOUT) */\n");
f_print(fout, "static ");
- if (!Cflag) {
- f_print(fout, "void\nRPC_MSGOUT(fmt, msg)\n");
- f_print(fout, "\tchar *fmt;\n");
- f_print(fout, "\tchar *msg;\n");
- } else {
f_print(fout, "void\nRPC_MSGOUT(const char *fmt, char *msg)\n");
- }
f_print(fout, "{\n");
f_print(fout, "#ifdef RPC_SVC_FG\n");
if (inetdflag || pmflag)
f_print(fout, "\tif (_rpcpmstart)\n");
f_print(fout, "\t\tsyslog(LOG_ERR, fmt, msg);\n");
--- 743,756 ----
*** 854,867 ****
f_print(fout, "\n");
if (mtflag) {
f_print(fout, "/*ARGSUSED*/\n");
f_print(fout, "static void *\n");
- if (!Cflag) {
- f_print(fout, "closedown(arg)\n");
- f_print(fout, "\tvoid *arg;\n");
- } else
f_print(fout, "closedown(void *arg)\n");
f_print(fout, "{\n");
f_print(fout, "\t/*CONSTCOND*/\n");
f_print(fout, "\twhile (1) {\n");
f_print(fout, "\t\t(void) sleep(_RPCSVC_CLOSEDOWN/2);\n\n");
--- 776,785 ----
*** 901,914 ****
f_print(fout, "}\n");
return;
}
f_print(fout, "static void\n");
- if (!Cflag) {
- f_print(fout, "closedown(sig)\n");
- f_print(fout, "\tint sig;\n");
- } else
f_print(fout, "closedown(int sig)\n");
f_print(fout, "{\n");
f_print(fout, "\tif (_rpcsvcstate == _IDLE && _rpcsvccount == 0) {\n");
if (tirpcflag) {
f_print(fout, "\t\tint size;\n");
--- 819,828 ----
*** 935,946 ****
f_print(fout, "\t\tif (openfd <= 1)\n");
f_print(fout, "\t\t\texit(0);\n");
f_print(fout, "\t} else\n");
f_print(fout, "\t\t_rpcsvcstate = _IDLE;\n\n");
! f_print(fout, "\t(void) signal(SIGALRM, %s closedown);\n",
! Cflag? "(SIG_PF)" : "(void(*)())");
f_print(fout, "\t(void) alarm(_RPCSVC_CLOSEDOWN/2);\n");
f_print(fout, "}\n");
}
/*
--- 849,859 ----
f_print(fout, "\t\tif (openfd <= 1)\n");
f_print(fout, "\t\t\texit(0);\n");
f_print(fout, "\t} else\n");
f_print(fout, "\t\t_rpcsvcstate = _IDLE;\n\n");
! f_print(fout, "\t(void) signal(SIGALRM, (SIG_PF) closedown);\n");
f_print(fout, "\t(void) alarm(_RPCSVC_CLOSEDOWN/2);\n");
f_print(fout, "}\n");
}
/*
*** 1025,1036 ****
"cannot create closedown thread");
f_print(fout, "\t\t\t\texit(1);\n");
f_print(fout, "\t\t\t}\n");
} else {
f_print(fout,
! "\t\t\t(void) signal(SIGALRM, %s closedown);\n",
! Cflag? "(SIG_PF)" : "(void(*)())");
f_print(fout,
"\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN/2);\n");
}
f_print(fout, "\t\t}\n");
}
--- 938,948 ----
"cannot create closedown thread");
f_print(fout, "\t\t\t\texit(1);\n");
f_print(fout, "\t\t\t}\n");
} else {
f_print(fout,
! "\t\t\t(void) signal(SIGALRM, (SIG_PF) closedown);\n");
f_print(fout,
"\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN/2);\n");
}
f_print(fout, "\t\t}\n");
}