static void puniondef (definition * def) { case_list *l; char *name = def->def_name; declaration *decl; f_print (fout, "typedef struct %s {\n", name); decl = &def->def.un.enum_decl; if (streq (decl->type, "bool")) { f_print (fout, "\tbool_t %s;\n", decl->name); } else { f_print (fout, "\t%s %s;\n", decl->type, decl->name); } f_print (fout, "\tunion {\n"); for (l = def->def.un.cases; l != NULL; l = l->next) { if (l->contflag == 0) pdeclaration (name, &l->case_decl, 2, ";\n"); } decl = def->def.un.default_decl; if (decl && !streq (decl->type, "void")) { pdeclaration (name, decl, 2, ";\n"); } /* f_print (fout, "\t} %s_u;\n", name); */ f_print (fout, "\t} RPC_UNION_NAME(%s);\n", name); f_print (fout, "} %s;\n", name); if (compatflag) f_print (fout, "#define %s_u u\n", name); /* f_print (fout, "typedef struct %s %s;\n", name, name); */ pxdrfuncdecl (name, 1, 0); f_print (fout, "RPC_CONSTRUCT (%c%s, %s)\n", toupper (*name), name + 1, name); }
static void puniondef (definition *def) { case_list *l; const char *name = def->def_name; declaration *decl; f_print (fout, "struct %s {\n", name); decl = &def->def.un.enum_decl; if (streq (decl->type, "bool")) { f_print (fout, "\tbool_t %s;\n", decl->name); } else { f_print (fout, "\t%s %s;\n", decl->type, decl->name); } f_print (fout, "\tunion {\n"); for (l = def->def.un.cases; l != NULL; l = l->next) { if (l->contflag == 0) pdeclaration (name, &l->case_decl, 2, ";\n"); } decl = def->def.un.default_decl; if (decl && !streq (decl->type, "void")) { pdeclaration (name, decl, 2, ";\n"); } f_print (fout, "\t} %s_u;\n", name); f_print (fout, "};\n"); f_print (fout, "typedef struct %s %s;\n", name, name); }
/* print out the definitions for the arguments of functions in the header file */ static void pargdef (definition * def) { decl_list *l; version_list *vers; const char *name; proc_list *plist; for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) { for (plist = vers->procs; plist != NULL; plist = plist->next) { if (!newstyle || plist->arg_num < 2) { continue; /* old style or single args */ } name = plist->args.argname; f_print (fout, "struct %s {\n", name); for (l = plist->args.decls; l != NULL; l = l->next) { pdeclaration (name, &l->decl, 1, ";\n"); } f_print (fout, "};\n"); f_print (fout, "typedef struct %s %s;\n", name, name); storexdrfuncdecl (name, 1); f_print (fout, "\n"); } } }
void printarglist(proc_list *proc, char *addargname, char *addargtype) { decl_list *l; if (!newstyle) { /* old style: always pass arg by reference */ if (Cflag) { /* C++ style heading */ f_print(fout, "("); ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); f_print(fout, "*argp, %s%s)\n", addargtype, addargname); } else { f_print(fout, "(argp, %s)\n", addargname); f_print(fout, "\t"); ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); f_print(fout, "*argp;\n"); } } else if (streq(proc->args.decls->decl.type, "void")) { /* newstyle, 0 argument */ if (Cflag) f_print(fout, "(%s%s)\n", addargtype, addargname); else f_print(fout, "(%s)\n", addargname); } else { /* new style, 1 or multiple arguments */ if (!Cflag) { f_print(fout, "("); for (l = proc->args.decls; l != NULL; l = l->next) f_print(fout, "%s, ", l->decl.name); f_print(fout, "%s)\n", addargname); for (l = proc->args.decls; l != NULL; l = l->next) { pdeclaration(proc->args.argname, &l->decl, 1, ";\n"); } } else { /* C++ style header */ f_print(fout, "("); for (l = proc->args.decls; l != NULL; l = l->next) { pdeclaration(proc->args.argname, &l->decl, 0, ", "); } f_print(fout, " %s%s)\n", addargtype, addargname); } } if (!Cflag) f_print(fout, "\t%s%s;\n", addargtype, addargname); }
static void pstructdef(definition *def) { decl_list *l; char *name = def->def_name; f_print(fout, "struct %s {\n", name); for (l = def->def.st.decls; l != NULL; l = l->next) pdeclaration(name, &l->decl, 1, ";\n"); f_print(fout, "};\n"); f_print(fout, "typedef struct %s %s;\n", name, name); }
static void pstructdef (definition * def) { decl_list *l; char *name = def->def_name; f_print (fout, "typedef struct %s {\n", name); for (l = def->def.st.decls; l != NULL; l = l->next) { pdeclaration (name, &l->decl, 1, ";\n"); } f_print (fout, "} %s;\n", name); /* f_print (fout, "typedef struct %s %s;\n", name, name); */ pxdrfuncdecl (name, 1, 0); if (*name != toupper (*name)) f_print (fout, "RPC_CONSTRUCT (%c%s, %s)\n", toupper (*name), name + 1, name); }
void printarglist(proc_list *proc, const char *result, const char *addargname, const char *addargtype) { decl_list *l; if (!newstyle) { /* old style: always pass argument by reference */ f_print(fout, "("); ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); if (mtflag) {/* Generate result field */ f_print(fout, "*argp, "); ptype(proc->res_prefix, proc->res_type, 1); f_print(fout, "*%s, %s%s)\n", result, addargtype, addargname); } else f_print(fout, "*argp, %s%s)\n", addargtype, addargname); } else if (streq(proc->args.decls->decl.type, "void")) { /* newstyle, 0 argument */ if (mtflag) { f_print(fout, "("); ptype(proc->res_prefix, proc->res_type, 1); f_print(fout, "*%s, %s%s)\n", result, addargtype, addargname); } else f_print(fout, "(%s%s)\n", addargtype, addargname); } else { /* new style, 1 or multiple arguments */ f_print(fout, "("); for (l = proc->args.decls; l != NULL; l = l->next) { pdeclaration(proc->args.argname, &l->decl, 0, ", "); } if (mtflag) { ptype(proc->res_prefix, proc->res_type, 1); f_print(fout, "*%s, ", result); } f_print(fout, "%s%s)\n", addargtype, addargname); } }