#include <afsconfig.h>
#include <afs/param.h>
-RCSID("$Header$");
+RCSID
+ ("$Header$");
#include <stdio.h>
#ifdef HAVE_STRING_H
static char ROUTINE[] = "local";
/* static prototypes */
-static void write_program(definition *def, char *storage);
+static void write_program(definition * def, char *storage);
static void printerr(char *err, char *transp);
static void printif(char *proc, char *transp, char *prefix, char *arg);
/*
* write most of the service, that is, everything but the registrations.
*/
-void write_most(void)
+void
+write_most(void)
{
- list *l;
- definition *def;
- version_list *vp;
+ list *l;
+ definition *def;
+ version_list *vp;
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM) {
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\nstatic void ");
- pvname(def->def_name, vp->vers_num);
- f_print(fout, "();");
- }
- }
+ for (l = defined; l != NULL; l = l->next) {
+ def = (definition *) l->val;
+ if (def->def_kind == DEF_PROGRAM) {
+ for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+ f_print(fout, "\nstatic void ");
+ pvname(def->def_name, vp->vers_num);
+ f_print(fout, "();");
+ }
}
- f_print(fout, "\n\n");
- f_print(fout, "main()\n");
- f_print(fout, "{\n");
- f_print(fout, "\tSVCXPRT *%s;\n", TRANSP);
- f_print(fout, "\n");
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind != DEF_PROGRAM) {
- continue;
- }
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\tpmap_unset(%s, %s);\n", def->def_name, vp->vers_name);
- }
+ }
+ f_print(fout, "\n\n");
+ f_print(fout, "main()\n");
+ f_print(fout, "{\n");
+ f_print(fout, "\tSVCXPRT *%s;\n", TRANSP);
+ f_print(fout, "\n");
+ for (l = defined; l != NULL; l = l->next) {
+ def = (definition *) l->val;
+ if (def->def_kind != DEF_PROGRAM) {
+ continue;
}
+ for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+ f_print(fout, "\tpmap_unset(%s, %s);\n", def->def_name,
+ vp->vers_name);
+ }
+ }
}
/*
* write a registration for the given transport
*/
-void write_register(char *transp)
+void
+write_register(char *transp)
{
- list *l;
- definition *def;
- version_list *vp;
+ list *l;
+ definition *def;
+ version_list *vp;
- f_print(fout, "\n");
- f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp);
- if (streq(transp, "tcp")) {
- f_print(fout, ", 0, 0");
- }
- f_print(fout, ");\n");
- f_print(fout, "\tif (%s == NULL) {\n", TRANSP);
- f_print(fout, "\t\tfprintf(stderr, \"cannot create %s service.\\n\");\n", transp);
- f_print(fout, "\t\texit(1);\n");
- f_print(fout, "\t}\n");
+ f_print(fout, "\n");
+ f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp);
+ if (streq(transp, "tcp")) {
+ f_print(fout, ", 0, 0");
+ }
+ f_print(fout, ");\n");
+ f_print(fout, "\tif (%s == NULL) {\n", TRANSP);
+ f_print(fout, "\t\tfprintf(stderr, \"cannot create %s service.\\n\");\n",
+ transp);
+ f_print(fout, "\t\texit(1);\n");
+ f_print(fout, "\t}\n");
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind != DEF_PROGRAM) {
- continue;
- }
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout,
- "\tif (!svc_register(%s, %s, %s, ",
- TRANSP, def->def_name, vp->vers_name);
- pvname(def->def_name, vp->vers_num);
- f_print(fout, ", IPPROTO_%s)) {\n",
- streq(transp, "udp") ? "UDP" : "TCP");
- f_print(fout,
- "\t\tfprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n",
- def->def_name, vp->vers_name, transp);
- f_print(fout, "\t\texit(1);\n");
- f_print(fout, "\t}\n");
- }
+ for (l = defined; l != NULL; l = l->next) {
+ def = (definition *) l->val;
+ if (def->def_kind != DEF_PROGRAM) {
+ continue;
+ }
+ for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+ f_print(fout, "\tif (!svc_register(%s, %s, %s, ", TRANSP,
+ def->def_name, vp->vers_name);
+ pvname(def->def_name, vp->vers_num);
+ f_print(fout, ", IPPROTO_%s)) {\n",
+ streq(transp, "udp") ? "UDP" : "TCP");
+ f_print(fout,
+ "\t\tfprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n",
+ def->def_name, vp->vers_name, transp);
+ f_print(fout, "\t\texit(1);\n");
+ f_print(fout, "\t}\n");
}
+ }
}
/*
* write the rest of the service
*/
-void write_rest(void)
+void
+write_rest(void)
{
- f_print(fout, "\tsvc_run();\n");
- f_print(fout, "\tfprintf(stderr, \"svc_run returned\\n\");\n");
- f_print(fout, "\texit(1);\n");
- f_print(fout, "}\n");
+ f_print(fout, "\tsvc_run();\n");
+ f_print(fout, "\tfprintf(stderr, \"svc_run returned\\n\");\n");
+ f_print(fout, "\texit(1);\n");
+ f_print(fout, "}\n");
}
-void write_programs(char *storage)
+void
+write_programs(char *storage)
{
- list *l;
- definition *def;
+ list *l;
+ definition *def;
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM) {
- write_program(def, storage);
- }
+ for (l = defined; l != NULL; l = l->next) {
+ def = (definition *) l->val;
+ if (def->def_kind == DEF_PROGRAM) {
+ write_program(def, storage);
}
+ }
}
-static void write_program(definition *def, char *storage)
+static void
+write_program(definition * def, char *storage)
{
- version_list *vp;
- proc_list *proc;
- int filled;
+ version_list *vp;
+ proc_list *proc;
+ int filled;
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\n");
- if (storage != NULL) {
- f_print(fout, "%s ", storage);
- }
- f_print(fout, "void\n");
- pvname(def->def_name, vp->vers_num);
- f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
- f_print(fout, " struct svc_req *%s;\n", RQSTP);
- f_print(fout, " SVCXPRT *%s;\n", TRANSP);
- f_print(fout, "{\n");
+ for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+ f_print(fout, "\n");
+ if (storage != NULL) {
+ f_print(fout, "%s ", storage);
+ }
+ f_print(fout, "void\n");
+ pvname(def->def_name, vp->vers_num);
+ f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
+ f_print(fout, " struct svc_req *%s;\n", RQSTP);
+ f_print(fout, " SVCXPRT *%s;\n", TRANSP);
+ f_print(fout, "{\n");
- filled = 0;
- f_print(fout, "\tunion {\n");
- for (proc = vp->procs; proc != NULL; proc = proc->next) {
- if (streq(proc->arg_type, "void")) {
- continue;
- }
- filled = 1;
- f_print(fout, "\t\t");
- ptype(proc->arg_prefix, proc->arg_type, 0);
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "_arg;\n");
- }
- if (!filled) {
- f_print(fout, "\t\tint fill;\n");
- }
- f_print(fout, "\t} %s;\n", ARG);
- f_print(fout, "\tchar *%s;\n", RESULT);
- f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
- f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
- f_print(fout, "\n");
- f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
+ filled = 0;
+ f_print(fout, "\tunion {\n");
+ for (proc = vp->procs; proc != NULL; proc = proc->next) {
+ if (streq(proc->arg_type, "void")) {
+ continue;
+ }
+ filled = 1;
+ f_print(fout, "\t\t");
+ ptype(proc->arg_prefix, proc->arg_type, 0);
+ pvname(proc->proc_name, vp->vers_num);
+ f_print(fout, "_arg;\n");
+ }
+ if (!filled) {
+ f_print(fout, "\t\tint fill;\n");
+ }
+ f_print(fout, "\t} %s;\n", ARG);
+ f_print(fout, "\tchar *%s;\n", RESULT);
+ f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
+ f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
+ f_print(fout, "\n");
+ f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
- if (!nullproc(vp->procs)) {
- f_print(fout, "\tcase NULLPROC:\n");
- f_print(fout, "\t\tsvc_sendreply(%s, xdr_void, NULL);\n", TRANSP);
- f_print(fout, "\t\treturn;\n\n");
- }
- for (proc = vp->procs; proc != NULL; proc = proc->next) {
- f_print(fout, "\tcase %s:\n", proc->proc_name);
- f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG,
- stringfix(proc->arg_type));
- f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT,
- stringfix(proc->res_type));
- f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, ";\n");
- f_print(fout, "\t\tbreak;\n\n");
- }
- f_print(fout, "\tdefault:\n");
- printerr("noproc", TRANSP);
- f_print(fout, "\t\treturn;\n");
- f_print(fout, "\t}\n");
+ if (!nullproc(vp->procs)) {
+ f_print(fout, "\tcase NULLPROC:\n");
+ f_print(fout, "\t\tsvc_sendreply(%s, xdr_void, NULL);\n", TRANSP);
+ f_print(fout, "\t\treturn;\n\n");
+ }
+ for (proc = vp->procs; proc != NULL; proc = proc->next) {
+ f_print(fout, "\tcase %s:\n", proc->proc_name);
+ f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG,
+ stringfix(proc->arg_type));
+ f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT,
+ stringfix(proc->res_type));
+ f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
+ pvname(proc->proc_name, vp->vers_num);
+ f_print(fout, ";\n");
+ f_print(fout, "\t\tbreak;\n\n");
+ }
+ f_print(fout, "\tdefault:\n");
+ printerr("noproc", TRANSP);
+ f_print(fout, "\t\treturn;\n");
+ f_print(fout, "\t}\n");
- f_print(fout, "\tmemset(&%s, 0, sizeof(%s));\n", ARG, ARG);
- printif("getargs", TRANSP, "&", ARG);
- printerr("decode", TRANSP);
- f_print(fout, "\t\treturn;\n");
- f_print(fout, "\t}\n");
+ f_print(fout, "\tmemset(&%s, 0, sizeof(%s));\n", ARG, ARG);
+ printif("getargs", TRANSP, "&", ARG);
+ printerr("decode", TRANSP);
+ f_print(fout, "\t\treturn;\n");
+ f_print(fout, "\t}\n");
- f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG,
- RQSTP);
- f_print(fout,
- "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
- RESULT, TRANSP, RESULT, RESULT);
- printerr("systemerr", TRANSP);
- f_print(fout, "\t}\n");
+ f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG,
+ RQSTP);
+ f_print(fout,
+ "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
+ RESULT, TRANSP, RESULT, RESULT);
+ printerr("systemerr", TRANSP);
+ f_print(fout, "\t}\n");
- printif("freeargs", TRANSP, "&", ARG);
- f_print(fout, "\t\tfprintf(stderr, \"unable to free arguments\\n\");\n");
- f_print(fout, "\t\texit(1);\n");
- f_print(fout, "\t}\n");
+ printif("freeargs", TRANSP, "&", ARG);
+ f_print(fout,
+ "\t\tfprintf(stderr, \"unable to free arguments\\n\");\n");
+ f_print(fout, "\t\texit(1);\n");
+ f_print(fout, "\t}\n");
- f_print(fout, "}\n\n");
- }
+ f_print(fout, "}\n\n");
+ }
}
-static void printerr(char *err, char *transp)
+static void
+printerr(char *err, char *transp)
{
- f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
+ f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
}
-static void printif(char *proc, char *transp, char *prefix, char *arg)
+static void
+printif(char *proc, char *transp, char *prefix, char *arg)
{
- f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n",
- proc, transp, arg, prefix, arg);
+ f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", proc, transp, arg,
+ prefix, arg);
}
-int nullproc(proc_list *proc)
+int
+nullproc(proc_list * proc)
{
- for (; proc != NULL; proc = proc->next) {
- if (streq(proc->proc_num, "0")) {
- return (1);
- }
+ for (; proc != NULL; proc = proc->next) {
+ if (streq(proc->proc_num, "0")) {
+ return (1);
}
- return (0);
+ }
+ return (0);
}