static void fprintTypedef(FILE *f, int indent, SmiType *smiType) { SmiModule *parentModule; SmiType *parentType; fprintSegment(f, indent, "<typedef", 0); if (smiType->name) { fprint(f, " name=\"%s\"", smiType->name); } fprint(f, " basetype=\"%s\"", getStringBasetype(smiType->basetype)); if (smiType->name && smiType->status != SMI_STATUS_UNKNOWN) { fprint(f, " status=\"%s\"", getStringStatus(smiType->status)); } fprint(f, ">\n"); parentType = smiGetParentType(smiType); parentModule = smiGetTypeModule(parentType); if (parentType && parentType->name && parentModule && strlen(parentModule->name)) { fprintSegment(f, indent + INDENT, "<parent ", 0); fprintf(f, "module=\"%s\" name=\"%s\"/>\n", parentModule->name, parentType->name); } fprintRanges(f, indent + INDENT, smiType); fprintNamedNumbers(f, indent + INDENT, smiType); fprintValue(f, indent + INDENT, &smiType->value, smiType); fprintFormat(f, indent + INDENT, smiType->format); fprintUnits(f, indent + INDENT, smiType->units); fprintDescription(f, indent + INDENT, smiType->description); fprintReference(f, indent + INDENT, smiType->reference); fprintSegment(f, indent, "</typedef>\n", 0); }
static char *getTypeString(SmiBasetype basetype, SmiType *smiType) { int i; char *typeModule, *typeName; typeName = smiType ? smiType->name : NULL; typeModule = smiType ? smiGetTypeModule(smiType)->name : NULL; if ((!typeModule) && (typeName) && (basetype != SMI_BASETYPE_ENUM) && (basetype != SMI_BASETYPE_BITS)) { for(i=0; convertType[i]; i += 2) { if (!strcmp(typeName, convertType[i])) { return convertType[i+1]; } } } if ((!typeModule) || (!strlen(typeModule)) || (!typeName)) { if (basetype == SMI_BASETYPE_ENUM) { return "Enumeration"; } if (basetype == SMI_BASETYPE_BITS) { return "Bits"; } } if (!typeName) { return getStringBasetype(basetype); } /* TODO: fully qualified if unambigous */ return typeName; }