/* * Print the C-version of an xdr definition */ void print_datadef(definition *def) { if (def->def_kind == DEF_PROGRAM) /* handle data only */ return; if (def->def_kind != DEF_CONST) f_print(fout, "\n"); switch (def->def_kind) { case DEF_STRUCT: pstructdef(def); break; case DEF_UNION: puniondef(def); break; case DEF_ENUM: penumdef(def); break; case DEF_TYPEDEF: ptypedef(def); break; case DEF_PROGRAM: pprogramdef(def); break; case DEF_CONST: pconstdef(def); break; } if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) storexdrfuncdecl(def->def_name, def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type, def->def.ty.rel)); }
static const char * ampr(const char *type) { if (isvectordef(type, REL_ALIAS)) return (""); else return ("&"); }
static char * ampr(char *type) { if (isvectordef(type, REL_ALIAS)) { return (""); } else { return ("&"); } }
static void print_header(definition *def) { print_generic_header(def->def_name, def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type, def->def.ty.rel)); /* Now add Inline support */ if (inline_size == 0) return; /* May cause lint to complain. but ... */ f_print(fout, "\tlong *buf;\n\n"); }
static const char * ampr (const char *type) { if (isvectordef (type, REL_ALIAS)) { return ""; } else { return "&"; } }
static void print_header(definition *def) { print_generic_header(def->def_name, def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type, def->def.ty.rel)); /* Now add Inline support */ if (Inline == 0) return; }
static void print_header(definition *def) { space(); f_print(fout, "pwr_tBoolean\n"); f_print(fout, "pdr_%s(PDR *pdrs, %s *objp)\n", def->def_name, def->def_name); #if 0 if (def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type, def->def.ty.rel)) { f_print(fout, "*"); } f_print(fout, "objp;\n"); #endif f_print(fout, "{\n"); }
static void print_stat(declaration * dec) { char *prefix = dec->prefix; char *type = dec->type; char *amax = dec->array_max; relation rel = dec->rel; char name[256]; if (isvectordef(type, rel)) { s_print(name, "objp->%s", dec->name); } else { s_print(name, "&objp->%s", dec->name); } print_ifstat(1, prefix, type, rel, amax, name, dec->name); }
static void print_header(definition * def) { space(); f_print(fout, "bool_t\n"); f_print(fout, "xdr_%s(XDR *xdrs, ", def->def_name); f_print(fout, "%s ", def->def_name); #if 0 if (def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type, def->def.ty.rel)) { f_print(fout, "*"); } #else f_print(fout, "*"); #endif f_print(fout, "objp)\n"); f_print(fout, "{\n"); }
void pprocdef(proc_list *proc, version_list *vp, const char *addargtype, int server_p) { decl_list *dl; if (Mflag) { if (server_p) f_print(fout, "bool_t "); else f_print(fout, "enum clnt_stat "); } else { ptype(proc->res_prefix, proc->res_type, 1); f_print(fout, "*"); } if (server_p) pvname_svc(proc->proc_name, vp->vers_num); else pvname(proc->proc_name, vp->vers_num); f_print(fout, "("); if (proc->arg_num < 2 && newstyle && streq(proc->args.decls->decl.type, "void")) { /* 0 argument in new style: do nothing */ } else { for (dl = proc->args.decls; dl != NULL; dl = dl->next) { ptype(dl->decl.prefix, dl->decl.type, 1); if (!newstyle) f_print(fout, "*"); f_print(fout, ", "); } } if (Mflag) { if (streq(proc->res_type, "void")) f_print(fout, "char"); else ptype(proc->res_prefix, proc->res_type, 0); if (!isvectordef(proc->res_type, REL_ALIAS)) f_print(fout, "*"); f_print(fout, ", "); } f_print(fout, "%s);\n", addargtype); }
void print_funcdef(definition *def, int *did) { switch (def->def_kind) { case DEF_PROGRAM: case DEF_CONST: break; case DEF_TYPEDEF: case DEF_ENUM: case DEF_UNION: case DEF_STRUCT: if (!*did) { f_print(fout, "\n"); cplusplusstart(); *did = 1; } pxdrfuncdecl(def->def_name, def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type, def->def.ty.rel)); break; } }
static void emit_union (definition * def) { declaration *dflt; case_list *cl; declaration *cs; char *object; #if 1 char *vecformat = "objp->RPC_UNION_NAME(%s).%s"; char *format = "&objp->RPC_UNION_NAME(%s).%s"; #else char *vecformat = "objp->u.%s"; char *format = "&objp->u.%s"; #endif print_stat (1, &def->def.un.enum_decl); f_print (fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { f_print (fout, "\tcase %s:\n", cl->case_name); if (cl->contflag == 1) /* a continued case statement */ continue; cs = &cl->case_decl; if (!streq (cs->type, "void")) { object = alloc (strlen (def->def_name) + strlen (format) + strlen (cs->name) + 1); #if 1 if (isvectordef (cs->type, cs->rel)) { s_print (object, vecformat, def->def_name, cs->name); } else { s_print (object, format, def->def_name, cs->name); } #else if (isvectordef (cs->type, cs->rel)) s_print (object, vecformat, cs->name); else s_print (object, format, cs->name); #endif print_ifstat (2, cs->prefix, cs->type, cs->rel, cs->array_max, object, cs->name); free (object); } f_print (fout, "\t\tbreak;\n"); } dflt = def->def.un.default_decl; if (dflt != NULL) { if (!streq (dflt->type, "void")) { f_print (fout, "\tdefault:\n"); object = alloc (strlen (def->def_name) + strlen (format) + strlen (dflt->name) + 1); #if 1 if (isvectordef (dflt->type, dflt->rel)) { s_print (object, vecformat, def->def_name, dflt->name); } else { s_print (object, format, def->def_name, dflt->name); } #else if (isvectordef (dflt->type, dflt->rel)) s_print (object, vecformat, dflt->name); else s_print (object, format, dflt->name); #endif print_ifstat (2, dflt->prefix, dflt->type, dflt->rel, dflt->array_max, object, dflt->name); free (object); f_print (fout, "\t\tbreak;\n"); } } else { f_print (fout, "\tdefault:\n"); f_print (fout, "\t\treturn (FALSE);\n"); } f_print (fout, "\t}\n"); }