static void fprintComplGroups(FILE *f, int indent, SmiNode *smiNode) { SmiNode *optSmiNode; SmiModule *optSmiModule; SmiOption *smiOption; if (! smiGetFirstElement(smiNode) && !smiGetFirstOption(smiNode)) { return; } fprintSegment(f, indent, "<requires>\n", 0); fprintElementList(f, indent + INDENT, "mandatory", smiGetFirstElement(smiNode)); for(smiOption = smiGetFirstOption(smiNode); smiOption; smiOption = smiGetNextOption(smiOption)) { optSmiNode = smiGetOptionNode(smiOption); optSmiModule = smiGetNodeModule(optSmiNode); fprintSegment(f, indent + INDENT, "", 0); fprint(f, "<option module=\"%s\" name=\"%s\">\n", optSmiModule->name, optSmiNode->name); fprintDescription(f, indent + 2 * INDENT, smiOption->description); fprintSegment(f, indent + INDENT, "</option>\n", 0); } fprintSegment(f, indent, "</requires>\n", 0); }
static void fprintMultilineString(FILE *f, int column, const char *s) { int i, j, len; #ifdef INDENTTEXTS fprintSegment(f, column + INDENTTEXTS, "", 0); #endif if (s) { len = strlen(s); for (i=0; i < len; i++) { for (j = 0; xmlEscapes[j].character; j++) { if (xmlEscapes[j].character == s[i]) break; } if (xmlEscapes[j].character) { fputs(xmlEscapes[j].escape, f); current_column += strlen(xmlEscapes[j].escape); } else { putc(s[i], f); current_column++; } if (s[i] == '\n') { current_column = 0; #ifdef INDENTTEXTS fprintSegment(f, column + INDENTTEXTS, "", 0); #endif } } } current_column++; }
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 void fprintNodes(FILE *f, SmiModule *smiModule) { int i; SmiNode *smiNode, *lastSmiNode; SmiNodekind nodekinds; nodekinds = SMI_NODEKIND_NODE | SMI_NODEKIND_TABLE | SMI_NODEKIND_ROW | SMI_NODEKIND_COLUMN | SMI_NODEKIND_SCALAR | SMI_NODEKIND_CAPABILITIES; for (i = 0, lastSmiNode = NULL, smiNode = smiGetFirstNode(smiModule, nodekinds); smiNode; i++, lastSmiNode = smiNode, smiNode = smiGetNextNode(smiNode, nodekinds)) { if (i == 0) { fprintSegment(f, INDENT, "<nodes>\n", 0); } fprintNode(f, 2 * INDENT, smiNode, lastSmiNode); } if (lastSmiNode && lastSmiNode->nodekind == SMI_NODEKIND_COLUMN) { fprintNodeEndTag(f, 3 * INDENT, "row"); fprintNodeEndTag(f, 2 * INDENT, "table"); } if (i) { fprintSegment(f, INDENT, "</nodes>\n\n", 0); } }
static void fprintReference(FILE *f, int indent, const char *reference) { if (reference) { fprintSegment(f, indent, "<reference>\n", 0); fprintMultilineString(f, indent, reference); fprint(f, "\n"); fprintSegment(f, indent, "</reference>\n", 0); } }
static void fprintDescription(FILE *f, int indent, const char *description) { if (description) { fprintSegment(f, indent, "<description>\n", 0); fprintMultilineString(f, indent, description); fprint(f, "\n"); fprintSegment(f, indent, "</description>\n", 0); } }
static void fprintNotification(FILE *f, int indent, SmiNode *smiNode) { fprintNodeStartTag(f, indent, "notification", smiNode); fprintSegment(f, indent + INDENT, "<objects>\n", 0); fprintElementList(f, indent + 2 * INDENT, "object", smiGetFirstElement(smiNode)); fprintSegment(f, indent + INDENT, "</objects>\n", 0); fprintDescription(f, indent + INDENT, smiNode->description); fprintReference(f, indent + INDENT, smiNode->reference); fprintNodeEndTag(f, indent, "notification"); }
static void fprintGroup(FILE *f, int indent, SmiNode *smiNode) { fprintNodeStartTag(f, indent, "group", smiNode); fprintSegment(f, indent + INDENT, "<members>\n", 0); fprintElementList(f, indent + 2 * INDENT, "member", smiGetFirstElement(smiNode)); fprintSegment(f, indent + INDENT, "</members>\n", 0); fprintDescription(f, indent + INDENT, smiNode->description); fprintReference(f, indent + INDENT, smiNode->reference); fprintNodeEndTag(f, indent, "group"); }
static void fprintModule(FILE *f, SmiModule *smiModule) { SmiRevision *smiRevision; SmiNode *smiNode; int i; char *lang; lang = getStringLanguage(smiModule->language); fprintSegment(f, INDENT, "", 0); if (lang) { fprint(f, "<module name=\"%s\" language=\"%s\">\n", smiModule->name, lang); } else { fprint(f, "<module name=\"%s\">\n", smiModule->name); } if (smiModule->organization) { fprintSegment(f, 2 * INDENT, "<organization>", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiModule->organization); fprint(f, "\n"); fprintSegment(f, 2 * INDENT, "</organization>\n", 0); } if (smiModule->contactinfo) { fprintSegment(f, 2 * INDENT, "<contact>", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiModule->contactinfo); fprint(f, "\n"); fprintSegment(f, 2 * INDENT, "</contact>\n", 0); } fprintDescription(f, 2 * INDENT, smiModule->description); fprintReference(f, 2 * INDENT, smiModule->reference); for(i = 0, smiRevision = smiGetFirstRevision(smiModule); smiRevision; smiRevision = smiGetNextRevision(smiRevision)) { fprintSegment(f, 2 * INDENT, "", 0); fprint(f, "<revision date=\"%s\">\n", getTimeString(smiRevision->date)); fprintDescription(f, 3 * INDENT, smiRevision->description); fprintSegment(f, 2 * INDENT, "</revision>\n", 0); i++; } smiNode = smiGetModuleIdentityNode(smiModule); if (smiNode) { fprintSegment(f, 2 * INDENT, "", 0); fprint(f, "<identity node=\"%s\"/>\n", smiNode->name); } fprintSegment(f, INDENT, "</module>\n\n", 0); }
static void fprintFormat(FILE *f, int indent, const char *format) { if (format) { fprintSegment(f, indent, "", 0); fprint(f, "<format>%s</format>\n", format); } }
static void fprintAccess(FILE *f, int indent, SmiAccess smiAccess) { if (smiAccess != SMI_ACCESS_UNKNOWN) { fprintSegment(f, indent, "", 0); fprint(f, "<access>%s</access>\n", getAccessString(smiAccess)); } }
static void fprintUnits(FILE *f, int indent, const char *units) { if (units) { fprintSegment(f, indent, "", 0); fprint(f, "<units>%s</units>\n", units); } }
static void fprintImports(FILE *f, SmiModule *smiModule) { Import *import; char *lastModuleName = NULL; int pos = 0, len, maxlen = 0; createImportList(smiModule); for (import = importList; import; import = import->nextPtr) { len = strlen(import->module); maxlen = (len > maxlen) ? len : maxlen; } for (import = importList; import; import = import->nextPtr) { int yaba = !lastModuleName || strcmp(import->module, lastModuleName); if (yaba) { if (lastModuleName) { fprint(f, ");\n"); } fprintSegment(f, INDENT, "", 0); fprint(f, "import %-*s (", maxlen, import->module); pos = INDENT + 12 + maxlen; } else { fprint(f, ", "); } len = strlen(import->name); if (len + pos > INDENTMAX) { fprint(f, "\n"); fprintSegment(f, INDENT, "", 0); fprintSegment(f, INDENT, "", 0); fprint(f, " %-*s ", maxlen, ""); pos = INDENT + 12 + maxlen; } fprint(f, "%s", import->name); pos += len; lastModuleName = import->module; } if (lastModuleName) { fprintf(f, ");\n"); } fprint(f, "\n"); freeImportList(); }
static void fprintValue(FILE *f, int indent, SmiValue *smiValue, SmiType *smiType) { if (smiType && smiValue && smiValue->basetype != SMI_BASETYPE_UNKNOWN) { fprintSegment(f, indent, "<default>", 0); fprint(f, "%s", getValueString(smiValue, smiType)); fprint(f, "</default>\n"); } }
static void fprintWrapped(FILE *f, int column, char *string) { if ((current_column + strlen(string)) > INDENTMAX) { putc('\n', f); current_column = 0; fprintSegment(f, column, "", 0); } fprint(f, "%s", string); }
static void fprintImports(FILE *f, SmiModule *smiModule) { SmiImport *smiImport; int i; for (i = 0, smiImport = smiGetFirstImport(smiModule); smiImport; i++, smiImport = smiGetNextImport(smiImport)) { if (i == 0) { fprintSegment(f, INDENT, "<imports>\n", 0); } fprintImport(f, 2 * INDENT, smiImport); } if (i) { fprintSegment(f, INDENT, "</imports>\n\n", 0); } }
static void fprintTypedefs(FILE *f, SmiModule *smiModule) { int i; SmiType *smiType; for(i = 0, smiType = smiGetFirstType(smiModule); smiType; i++, smiType = smiGetNextType(smiType)) { if (i == 0) { fprintSegment(f, INDENT, "<typedefs>\n", 0); } fprintTypedef(f, 2 * INDENT, smiType); } if (i) { fprintSegment(f, INDENT, "</typedefs>\n\n", 0); } }
static void fprintGroups(FILE *f, SmiModule *smiModule) { SmiNode *smiNode; int i; for(i = 0, smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_GROUP); smiNode; i++, smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_GROUP)) { if (i == 0) { fprintSegment(f, INDENT, "<groups>\n", 0); } fprintGroup(f, 2 * INDENT, smiNode); } if (i) { fprintSegment(f, INDENT, "</groups>\n\n", 0); } }
void fprintWrapped(FILE *f, int column, char *string) { if ((fprint_current_column + strlen(string)) > fprint_indent_max) { putc('\n', f); fprint_current_column = 0; fprintSegment(f, column, "", 0); } fprint(f, "%s", string); }
static void fprintNotifications(FILE *f, SmiModule *smiModule) { SmiNode *smiNode; int i; for(i = 0, smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_NOTIFICATION); smiNode; i++, smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_NOTIFICATION)) { if (i == 0) { fprintSegment(f, INDENT, "<notifications>\n", 0); } fprintNotification(f, 2 * INDENT, smiNode); } if (i) { fprintSegment(f, INDENT, "</notifications>\n\n", 0); } }
static void fprintMultilineString(FILE *f, int column, const char *s) { int i, len; fprintSegment(f, column - 1 + INDENTTEXTS, "\"", 0); if (s) { len = strlen(s); for (i=0; i < len; i++) { putc(s[i], f); current_column++; if (s[i] == '\n') { current_column = 0; fprintSegment(f, column + INDENTTEXTS, "", 0); } } } putc('\"', f); current_column++; }
void fprintMultilineString(FILE *f, int column, const char *s) { int i, len; fprintSegment(f, column - 1 + fprint_indent_texts, "\"", 0); if (s) { len = strlen(s); for (i=0; i < len; i++) { putc(s[i], f); fprint_current_column++; if (s[i] == '\n') { fprint_current_column = 0; fprintSegment(f, column + fprint_indent_texts, "", 0); } } } putc('\"', f); fprint_current_column++; }
static void fprintCompliances(FILE *f, SmiModule *smiModule) { SmiNode *smiNode; int i; for(i = 0, smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_COMPLIANCE); smiNode; i++, smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_COMPLIANCE)) { if (!i) { fprintSegment(f, INDENT, "<compliances>\n", 0); } fprintCompliance(f, 2 * INDENT, smiNode); } if (i) { fprintSegment(f, INDENT, "</compliances>\n\n", 0); } }
static void fprintRefinements(FILE *f, int indent, SmiNode *smiNode) { SmiRefinement *smiRefinement; int i; for(i = 0, smiRefinement = smiGetFirstRefinement(smiNode); smiRefinement; i++, smiRefinement = smiGetNextRefinement(smiRefinement)) { if (!i) { fprintSegment(f, indent, "<refinements>\n", 0); } fprintRefinement(f, indent + INDENT, smiRefinement); } if (i) { fprintSegment(f, indent, "</refinements>\n\n", 0); } }
static void fprintRevisions(FILE *f, SmiModule *smiModule) { int i; SmiRevision *smiRevision; for(i = 0, smiRevision = smiGetFirstRevision(smiModule); smiRevision; smiRevision = smiGetNextRevision(smiRevision)) { fprintSegment(f, INDENT, "revision {\n", 0); fprintSegment(f, 2 * INDENT, "date", INDENTVALUE); fprint(f, "\"%s\";\n", getStringTime(smiRevision->date)); fprintSegment(f, 2 * INDENT, "description", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiRevision->description); fprint(f, ";\n"); fprintSegment(f, INDENT, "};\n", 0); i++; } if (i) { fprint(f, "\n"); } }
static void fprintRefinement(FILE *f, int indent, SmiRefinement *smiRefinement) { SmiModule *smiModule; SmiNode *smiNode; SmiType *smiType; smiNode = smiGetRefinementNode(smiRefinement); smiModule = smiGetNodeModule(smiNode); fprintSegment(f, indent, "<refinement ", 0); fprintf(f, "module=\"%s\" name=\"%s\">\n", smiModule->name, smiNode->name); smiType = smiGetRefinementType(smiRefinement); if (smiType) { fprintSegment(f, indent + INDENT, "<syntax>\n", 0); fprintTypedef(f, indent + 2 * INDENT, smiType); fprintSegment(f, indent + INDENT, "</syntax>\n", 0); } smiType = smiGetRefinementWriteType(smiRefinement); if (smiType) { fprintSegment(f, indent + INDENT, "<writesyntax>\n", 0); fprintTypedef(f, indent + 2 * INDENT, smiType); fprintSegment(f, indent + INDENT, "</writesyntax>\n", 0); } if (smiRefinement->access != SMI_ACCESS_UNKNOWN) { fprintAccess(f, indent + INDENT, smiRefinement->access); } fprintDescription(f, indent + INDENT, smiRefinement->description); fprintSegment(f, indent, "</refinement>\n", 0); }
static void fprintRanges(FILE *f, int indent, SmiType *smiType) { SmiRange *range; for(range = smiGetFirstRange(smiType); range; range = smiGetNextRange(range)) { fprintSegment(f, indent, "<range", 0); fprint(f, " min=\"%s\"", getValueString(&range->minValue, smiType)); fprint(f, " max=\"%s\"", getValueString(&range->maxValue, smiType)); fprint(f, "/>\n"); } }
static void fprintElementList(FILE *f, int indent, const char *tag, SmiElement *smiElement) { SmiModule *smiModule; SmiNode *smiNode; for (; smiElement; smiElement = smiGetNextElement(smiElement)) { smiNode = smiGetElementNode(smiElement); smiModule = smiGetNodeModule(smiNode); fprintSegment(f, indent, "", 0); fprint(f, "<%s module=\"%s\" name=\"%s\"/>\n", tag, smiModule->name, smiNode->name); } }
static void fprintIndex(FILE *f, int indent, SmiNode *smiNode) { SmiNode *relatedNode; SmiModule *relatedModule = NULL; fprintSegment(f, indent, "<linkage", 0); if (smiNode->implied) { fprint(f, " implied=\"true\""); } fprint(f, ">\n"); relatedNode = smiGetRelatedNode(smiNode); if (relatedNode) { relatedModule = smiGetNodeModule(relatedNode); } switch (smiNode->indexkind) { case SMI_INDEX_INDEX: fprintElementList(f, indent + INDENT, "index", smiGetFirstElement(smiNode)); break; case SMI_INDEX_AUGMENT: if (relatedNode && relatedModule) { fprintSegment(f, indent + INDENT, "", 0); fprint(f, "<augments module=\"%s\" name=\"%s\"/>\n", relatedModule->name, relatedNode->name); } /* TODO: else print error */ break; case SMI_INDEX_REORDER: if (relatedNode && relatedModule) { fprintSegment(f, indent + INDENT, "", 0); fprint(f, "<reorders module=\"%s\" name=\"%s\"/>\n", relatedModule->name, relatedNode->name); fprintElementList(f, indent + INDENT, "index", smiGetFirstElement(smiNode)); } /* TODO: else print error */ break; case SMI_INDEX_SPARSE: if (relatedNode && relatedModule) { fprintSegment(f, indent + INDENT, "", 0); fprint(f, "<sparse module=\"%s\" name=\"%s\"/>\n", relatedModule->name, relatedNode->name); } /* TODO: else print error */ break; case SMI_INDEX_EXPAND: if (relatedNode && relatedModule) { fprintSegment(f, indent + INDENT, "", 0); fprint(f, "<expands module=\"%s\" name=\"%s\"/>\n", relatedModule->name, relatedNode->name); fprintElementList(f, indent + INDENT, "index", smiGetFirstElement(smiNode)); } /* TODO: else print error */ break; case SMI_INDEX_UNKNOWN: break; } fprintSegment(f, indent, "</linkage>\n", 0); }
static void fprintNamedNumbers(FILE *f, int indent, SmiType *smiType) { SmiNamedNumber *nn; if ((smiType->basetype != SMI_BASETYPE_ENUM) && (smiType->basetype != SMI_BASETYPE_BITS)) { return; } for (nn = smiGetFirstNamedNumber(smiType); nn; nn = smiGetNextNamedNumber(nn)) { fprintSegment(f, indent, "<namednumber", 0); fprint(f, " name=\"%s\"", nn->name); fprint(f, " number=\"%s\"", getValueString(&nn->value, smiType)); fprint(f, "/>\n"); } }