static void emit_enum(definition * def) { print_ifopen(1, "enum"); print_ifarg("(enum_t *)objp"); print_ifclose(1); }
static void print_ifstat(int indent, const char *prefix, const char *type, relation rel, const char *amax, const char *objname, const char *name) { const char *alt = NULL; int brace = 0; switch (rel) { case REL_POINTER: brace = 1; f_print(fout, "\t{\n"); f_print(fout, "\t%s **pp = %s;\n", type, objname); print_ifopen(indent, "pointer"); print_ifarg("(char **)"); f_print(fout, "pp"); print_ifsizeof(0, prefix, type); break; case REL_VECTOR: if (streq(type, "string")) alt = "string"; else if (streq(type, "opaque")) alt = "opaque"; if (alt) { print_ifopen(indent, alt); print_ifarg(objname); } else { print_ifopen(indent, "vector"); print_ifarg("(char *)"); f_print(fout, "%s", objname); } print_ifarg(amax); if (!alt) print_ifsizeof(indent + 1, prefix, type); break; case REL_ARRAY: if (streq(type, "string")) alt = "string"; else if (streq(type, "opaque")) alt = "bytes"; if (streq(type, "string")) { print_ifopen(indent, alt); print_ifarg(objname); } else { if (alt) print_ifopen(indent, alt); else print_ifopen(indent, "array"); print_ifarg("(char **)"); if (*objname == '&') { f_print(fout, "%s.%s_val, (u_int *) %s.%s_len", objname, name, objname, name); } else { f_print(fout, "&%s->%s_val, (u_int *) &%s->%s_len", objname, name, objname, name); } } print_ifarg(amax); if (!alt) print_ifsizeof(indent + 1, prefix, type); break; case REL_ALIAS: print_ifopen(indent, type); print_ifarg(objname); break; } print_ifclose(indent, brace); }
static void print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax, char *objname, char *name) { char *alt = NULL; char *altcast = NULL; switch (rel) { case REL_POINTER: print_ifopen(indent, "pointer"); print_ifarg_with_cast(1, "char *", objname); print_ifsizeof(prefix, type); break; case REL_VECTOR: if (streq(type, "string")) { alt = "string"; } else if (streq(type, "opaque")) { alt = "opaque"; altcast = "caddr_t"; } if (alt) { print_ifopen(indent, alt); if (altcast) { print_ifarg_with_cast(0, altcast, objname); } else { print_ifarg(objname); } } else { print_ifopen(indent, "vector"); print_ifarg_with_cast(1, "char", objname); } print_ifarg(amax); if (!alt) { print_ifsizeof(prefix, type); } break; case REL_ARRAY: if (streq(type, "string")) { alt = "string"; } else if (streq(type, "opaque")) { alt = "bytes"; } if (streq(type, "string")) { print_ifopen(indent, alt); print_ifarg(objname); } else { if (alt) { print_ifopen(indent, alt); print_ifarg("(char **)"); } else { print_ifopen(indent, "array"); print_ifarg("(caddr_t *)"); } if (*objname == '&') { f_print(fout, "%s.%s_val, (u_int *)%s.%s_len", objname, name, objname, name); } else { f_print(fout, "&%s->%s_val, (u_int *)&%s->%s_len", objname, name, objname, name); } } print_ifarg(amax); if (!alt) { print_ifsizeof(prefix, type); } break; case REL_ALIAS: print_ifopen(indent, type); print_ifarg_with_cast(1, type, objname); break; } print_ifclose(indent); }
static void print_ifstat (int indent, char *prefix, char *type, relation rel, char *amax, char *objname, char *name) { char *alt = NULL; switch (rel) { case REL_POINTER: print_ifopen (indent, "pointer"); print_ifarg ("(char **)"); f_print (fout, "%s", objname); print_ifsizeof (prefix, type); break; case REL_VECTOR: if (streq (type, "string")) { alt = "string"; } else if (streq (type, "opaque")) { alt = "opaque"; } if (alt) { print_ifopen (indent, alt); print_ifarg (objname); } else { print_ifopen (indent, "vector"); print_ifarg ("(char *)"); f_print (fout, "%s", objname); } print_ifarg (amax); if (!alt) { print_ifsizeof (prefix, type); } break; case REL_ARRAY: if (streq (type, "string")) { alt = "string"; } else if (streq (type, "opaque")) { alt = "bytes"; } if (streq (type, "string")) { print_ifopen (indent, alt); print_ifarg (objname); } else { if (alt) { print_ifopen (indent, alt); } else { print_ifopen (indent, "array"); } print_ifarg ("(char **)"); #if 0 if (*objname == '&') { f_print (fout, "%s.%s_val, (u_int *)%s.%s_len", objname, name, objname, name); } else { f_print (fout, "&%s->%s_val, (u_int *)&%s->%s_len", objname, name, objname, name); } #else if (*objname == '&') { /* Don't know what this does but it seems broken */ f_print (fout, "%s.val, (u_int *)%s.len", objname, objname); } else { f_print (fout, "&%s->val, (u_int *)&%s->len", objname, objname); } #endif } print_ifarg (amax); if (!alt) { print_ifsizeof (prefix, type); } break; case REL_ALIAS: print_ifopen (indent, type); print_ifarg (objname); break; } print_ifclose (indent); }