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); }
void LabelVersion::showMessage( const std::string & str) { std::cout << str << std::endl; if(( status != SS_None ) && ( message == afqt::stoq(str) )) return; phase = 0; message = afqt::stoq( str); status = getStringStatus( str); if( status == SS_None ) return; setToolTip( message); repaint(); timer.start(); }
static void fprintNodeStartTag(FILE *f, int indent, const char *tag, SmiNode *smiNode) { unsigned int i; fprintSegment(f, indent, "", 0); fprint(f, "<%s name=\"%s\"", tag, smiNode->name); fprint(f, " oid=\""); for (i = 0; i < smiNode->oidlen; i++) { fprint(f, i ? ".%u" : "%u", smiNode->oid[i]); } fprint(f, "\""); if (smiNode->create) { fprint(f, " create=\"true\""); } if (smiNode->status != SMI_STATUS_UNKNOWN) { fprint(f, " status=\"%s\"", getStringStatus(smiNode->status)); } fprint(f, ">\n"); }
static void fprintNotifications(FILE *f, SmiModule *smiModule) { int i, j; SmiNode *smiNode; SmiElement *smiElement; for(i = 0, smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_NOTIFICATION); smiNode; smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_NOTIFICATION)) { if (!i && !silent) { fprint(f, "//\n// NOTIFICATION DEFINITIONS\n//\n\n"); } fprintSegment(f, INDENT, "", 0); fprint(f, "notification %s {\n", smiNode->name); if (smiNode->oid) { fprintSegment(f, 2 * INDENT, "oid", INDENTVALUE); fprint(f, "%s;\n", getOidString(smiNode, 0)); } if ((smiElement = smiGetFirstElement(smiNode))) { fprintSegment(f, 2 * INDENT, "objects", INDENTVALUE); fprint(f, "("); for (j = 0; smiElement; j++, smiElement = smiGetNextElement(smiElement)) { if (j) { fprint(f, ", "); } fprintWrapped(f, INDENTVALUE + 1, smiGetElementNode(smiElement)->name); /* TODO: non-local name if non-local */ } /* TODO: empty? -> print error */ fprint(f, ");\n"); } if ((smiNode->status != SMI_STATUS_CURRENT) && (smiNode->status != SMI_STATUS_UNKNOWN) && (smiNode->status != SMI_STATUS_MANDATORY) && (smiNode->status != SMI_STATUS_OPTIONAL)) { fprintSegment(f, 2 * INDENT, "status", INDENTVALUE); fprint(f, "%s;\n", getStringStatus(smiNode->status)); } if (smiNode->description) { fprintSegment(f, 2 * INDENT, "description", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiNode->description); fprint(f, ";\n"); } if (smiNode->reference) { fprintSegment(f, 2 * INDENT, "reference", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiNode->reference); fprint(f, ";\n"); } fprintSegment(f, INDENT, "", 0); fprint(f, "};\n\n"); i++; } }
static void fprintObjects(FILE *f, SmiModule *smiModule) { int i, j; SmiNode *smiNode, *relatedNode; SmiElement *smiElement; SmiType *smiType; int indent = 0; int lastindent = -1; char *s = NULL; SmiNodekind nodekinds; nodekinds = SMI_NODEKIND_NODE | SMI_NODEKIND_TABLE | SMI_NODEKIND_ROW | SMI_NODEKIND_COLUMN | SMI_NODEKIND_SCALAR | SMI_NODEKIND_CAPABILITIES; for(i = 0, smiNode = smiGetFirstNode(smiModule, nodekinds); smiNode; smiNode = smiGetNextNode(smiNode, nodekinds)) { if (smiNode->nodekind == SMI_NODEKIND_NODE) { indent = 0; s = "node"; } else if (smiNode->nodekind == SMI_NODEKIND_CAPABILITIES) { indent = 0; s = "node"; } else if (smiNode->nodekind == SMI_NODEKIND_TABLE) { indent = 0; s = "table"; } else if (smiNode->nodekind == SMI_NODEKIND_ROW) { indent = 1; s = "row"; } else if (smiNode->nodekind == SMI_NODEKIND_COLUMN) { indent = 2; s = "column"; } else if (smiNode->nodekind == SMI_NODEKIND_SCALAR) { indent = 0; s = "scalar"; } if (!i && !silent) { fprint(f, "//\n// OBJECT DEFINITIONS\n//\n\n"); } for (j = lastindent; j >= indent; j--) { fprintSegment(f, (1 + j) * INDENT, "", 0); fprint(f, "};\n"); } fprint(f, "\n"); lastindent = indent; if (smiNode->nodekind == SMI_NODEKIND_CAPABILITIES) { fprintSegment(f, (1 + indent) * INDENT, "", 0); fprint(f, "-- This has been an SMIv2 AGENT-CAPABILITIES node:\n"); } fprintSegment(f, (1 + indent) * INDENT, "", 0); fprint(f, "%s %s {\n", s, smiNode->name); if (smiNode->oid) { fprintSegment(f, (2 + indent) * INDENT, "oid", INDENTVALUE); fprint(f, "%s;\n", getOidString(smiNode, 0)); } smiType = smiGetNodeType(smiNode); if (smiType && (smiType->basetype != SMI_BASETYPE_UNKNOWN)) { fprintSegment(f, (2 + indent) * INDENT, "type", INDENTVALUE); if (!smiType->name) { /* * an implicitly restricted type. */ fprint(f, "%s", getTypeString(smiType->basetype, smiGetParentType(smiType))); fprintSubtype(f, smiType); fprint(f, ";\n"); } else { fprint(f, "%s;\n", getTypeString(smiType->basetype, smiType)); } } if ((smiNode->nodekind != SMI_NODEKIND_TABLE) && (smiNode->nodekind != SMI_NODEKIND_ROW) && (smiNode->nodekind != SMI_NODEKIND_CAPABILITIES) && (smiNode->nodekind != SMI_NODEKIND_NODE)) { if (smiNode->access != SMI_ACCESS_UNKNOWN) { fprintSegment(f, (2 + indent) * INDENT, "access", INDENTVALUE); fprint(f, "%s;\n", getAccessString(smiNode->access)); } } relatedNode = smiGetRelatedNode(smiNode); switch (smiNode->indexkind) { case SMI_INDEX_INDEX: if (smiNode->implied) { fprintSegment(f, (2 + indent) * INDENT, "index implied", INDENTVALUE); } else { fprintSegment(f, (2 + indent) * INDENT, "index", INDENTVALUE); } fprint(f, "("); for (j = 0, smiElement = smiGetFirstElement(smiNode); smiElement; j++, smiElement = smiGetNextElement(smiElement)) { if (j) { fprint(f, ", "); } fprintWrapped(f, INDENTVALUE + 1, smiGetElementNode(smiElement)->name); /* TODO: non-local name if non-local */ } /* TODO: empty? -> print error */ fprint(f, ");\n"); break; case SMI_INDEX_AUGMENT: if (relatedNode) { fprintSegment(f, (2 + indent) * INDENT, "augments", INDENTVALUE); fprint(f, "%s;\n", relatedNode->name); /* TODO: non-local name if non-local */ } /* TODO: else print error */ break; case SMI_INDEX_REORDER: if (relatedNode) { fprintSegment(f, (2 + indent) * INDENT, "", 0); fprint(f, "reorders %s", relatedNode->name); /* TODO: non-local name if non-local */ if (smiNode->implied) { fprint(f, " implied"); } fprint(f, " ("); for (j = 0, smiElement = smiGetFirstElement(smiNode); smiElement; j++, smiElement = smiGetNextElement(smiElement)) { if (j) { fprint(f, ", "); } fprintWrapped(f, INDENTVALUE + 1, smiGetElementNode(smiElement)->name); /* TODO: non-local name if non-local */ } /* TODO: empty? -> print error */ fprint(f, ");\n"); } /* TODO: else print error */ break; case SMI_INDEX_SPARSE: if (relatedNode) { fprintSegment(f, (2 + indent) * INDENT, "sparse", INDENTVALUE); fprint(f, "%s;\n", relatedNode->name); /* TODO: non-local name if non-local */ } /* TODO: else print error */ break; case SMI_INDEX_EXPAND: if (relatedNode) { fprintSegment(f, (2 + indent) * INDENT, "", 0); fprint(f, "expands %s", relatedNode->name); /* TODO: non-local name if non-local */ if (smiNode->implied) { fprint(f, " implied"); } fprint(f, " ("); for (j = 0, smiElement = smiGetFirstElement(smiNode); smiElement; j++, smiElement = smiGetNextElement(smiElement)) { if (j) { fprint(f, ", "); } fprintWrapped(f, INDENTVALUE + 1, smiGetElementNode(smiElement)->name); /* TODO: non-local name if non-local */ } /* TODO: empty? -> print error */ fprint(f, ");\n"); } /* TODO: else print error */ break; case SMI_INDEX_UNKNOWN: break; } if (smiNode->create) { fprintSegment(f, (2 + indent) * INDENT, "create", INDENTVALUE); /* TODO: create list */ fprint(f, ";\n"); } if (smiNode->value.basetype != SMI_BASETYPE_UNKNOWN) { fprintSegment(f, (2 + indent) * INDENT, "default", INDENTVALUE); fprint(f, "%s", getValueString(&smiNode->value, smiType)); fprint(f, ";\n"); } if (smiNode->format) { fprintSegment(f, (2 + indent) * INDENT, "format", INDENTVALUE); fprint(f, "\"%s\";\n",smiNode->format); } if (smiNode->units) { fprintSegment(f, (2 + indent) * INDENT, "units", INDENTVALUE); fprint(f, "\"%s\";\n", smiNode->units); } if ((smiNode->status != SMI_STATUS_CURRENT) && (smiNode->status != SMI_STATUS_UNKNOWN) && (smiNode->status != SMI_STATUS_MANDATORY) && (smiNode->status != SMI_STATUS_OPTIONAL)) { fprintSegment(f, (2 + indent) * INDENT, "status", INDENTVALUE); fprint(f, "%s;\n", getStringStatus(smiNode->status)); } if (smiNode->description) { fprintSegment(f, (2 + indent) * INDENT, "description", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, (2 + indent) * INDENT, smiNode->description); fprint(f, ";\n"); } if (smiNode->reference) { fprintSegment(f, (2 + indent) * INDENT, "reference", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, (2 + indent) * INDENT, smiNode->reference); fprint(f, ";\n"); } i++; } if (i) { fprintSegment(f, (1 + indent) * INDENT, "", 0); fprint(f, "};\n\n"); } }
static void fprintTypedefs(FILE *f, SmiModule *smiModule) { int i, j; SmiType *smiType; for(i = 0, smiType = smiGetFirstType(smiModule); smiType; smiType = smiGetNextType(smiType)) { if ((!(strcmp(smiModule->name, "SNMPv2-SMI"))) || (!(strcmp(smiModule->name, "RFC1155-SMI")))) { for(j=0; excludeType[j]; j++) { if (!strcmp(smiType->name, excludeType[j])) break; } if (excludeType[j]) break; } if (!i && !silent) { fprint(f, "//\n// TYPE DEFINITIONS\n//\n\n"); } fprintSegment(f, INDENT, "", 0); fprint(f, "typedef %s {\n", smiType->name); fprintSegment(f, 2 * INDENT, "type", INDENTVALUE); fprint(f, "%s", getTypeString(smiType->basetype, smiGetParentType(smiType))); fprintSubtype(f, smiType); fprint(f, ";\n"); if (smiType->value.basetype != SMI_BASETYPE_UNKNOWN) { fprintSegment(f, 2 * INDENT, "default", INDENTVALUE); fprint(f, "%s", getValueString(&smiType->value, smiType)); fprint(f, ";\n"); } if (smiType->format) { fprintSegment(f, 2 * INDENT, "format", INDENTVALUE); fprint(f, "\"%s\";\n", smiType->format); } if (smiType->units) { fprintSegment(f, 2 * INDENT, "units", INDENTVALUE); fprint(f, "\"%s\";\n", smiType->units); } if ((smiType->status != SMI_STATUS_CURRENT) && (smiType->status != SMI_STATUS_UNKNOWN) && (smiType->status != SMI_STATUS_MANDATORY) && (smiType->status != SMI_STATUS_OPTIONAL)) { fprintSegment(f, 2 * INDENT, "status", INDENTVALUE); fprint(f, "%s;\n", getStringStatus(smiType->status)); } fprintSegment(f, 2 * INDENT, "description", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiType->description); fprint(f, ";\n"); if (smiType->reference) { fprintSegment(f, 2 * INDENT, "reference", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiType->reference); fprint(f, ";\n"); } fprintSegment(f, INDENT, "};\n\n", 0); i++; } }
static void fprintCompliances(FILE *f, SmiModule *smiModule) { int i, j; SmiNode *smiNode, *smiNode2; SmiType *smiType; SmiOption *smiOption; SmiRefinement *smiRefinement; SmiElement *smiElement; for(i = 0, smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_COMPLIANCE); smiNode; smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_COMPLIANCE)) { if (!i && !silent) { fprint(f, "//\n// COMPLIANCE DEFINITIONS\n//\n\n"); } fprintSegment(f, INDENT, "", 0); fprint(f, "compliance %s {\n", smiNode->name); if (smiNode->oid) { fprintSegment(f, 2 * INDENT, "oid", INDENTVALUE); fprint(f, "%s;\n", getOidString(smiNode, 0)); } if ((smiNode->status != SMI_STATUS_CURRENT) && (smiNode->status != SMI_STATUS_UNKNOWN) && (smiNode->status != SMI_STATUS_MANDATORY) && (smiNode->status != SMI_STATUS_OPTIONAL)) { fprintSegment(f, 2 * INDENT, "status", INDENTVALUE); fprint(f, "%s;\n", getStringStatus(smiNode->status)); } if (smiNode->description) { fprintSegment(f, 2 * INDENT, "description", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiNode->description); fprint(f, ";\n"); } if (smiNode->reference) { fprintSegment(f, 2 * INDENT, "reference", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 2 * INDENT, smiNode->reference); fprint(f, ";\n"); } if ((smiElement = smiGetFirstElement(smiNode))) { fprint(f, "\n"); fprintSegment(f, 2 * INDENT, "mandatory", INDENTVALUE); fprint(f, "("); for (j = 0; smiElement; j++, smiElement = smiGetNextElement(smiElement)) { if (j) { fprint(f, ", "); } fprintWrapped(f, INDENTVALUE + 1, smiGetElementNode(smiElement)->name); /* TODO: non-local name if non-local */ } /* TODO: empty? -> print error */ fprint(f, ");\n"); } if ((smiOption = smiGetFirstOption(smiNode))) { fprint(f, "\n"); for(; smiOption; smiOption = smiGetNextOption(smiOption)) { smiNode2 = smiGetOptionNode(smiOption); fprintSegment(f, 2 * INDENT, "", 0); fprint(f, "optional %s {\n", smiNode2->name); fprintSegment(f, 3 * INDENT, "description", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 3 * INDENT, smiOption->description); fprint(f, ";\n"); fprintSegment(f, 2 * INDENT, "};\n", 0); } } if ((smiRefinement = smiGetFirstRefinement(smiNode))) { fprint(f, "\n"); for(; smiRefinement; smiRefinement = smiGetNextRefinement(smiRefinement)) { fprintSegment(f, 2 * INDENT, "", 0); fprint(f, "refine %s {\n", smiGetRefinementNode(smiRefinement)->name); smiType = smiGetRefinementType(smiRefinement); if (smiType) { fprintSegment(f, 3 * INDENT, "type", INDENTVALUE); fprint(f, "%s", getTypeString(smiType->basetype, smiGetParentType(smiType))); fprintSubtype(f, smiType); fprint(f, ";\n"); } smiType = smiGetRefinementWriteType(smiRefinement); if (smiType) { fprintSegment(f, 3 * INDENT, "writetype", INDENTVALUE); fprint(f, "%s", getTypeString(smiType->basetype, smiGetParentType(smiType))); fprintSubtype(f, smiType); fprint(f, ";\n"); } if (smiRefinement->access != SMI_ACCESS_UNKNOWN) { fprintSegment(f, 3 * INDENT, "access", INDENTVALUE); fprint(f, "%s;\n", getAccessString(smiRefinement->access)); } fprintSegment(f, 3 * INDENT, "description", INDENTVALUE); fprint(f, "\n"); fprintMultilineString(f, 3 * INDENT, smiRefinement->description); fprint(f, ";\n"); fprintSegment(f, 2 * INDENT, "};\n", 0); } } fprintSegment(f, INDENT, "", 0); fprint(f, "};\n\n"); i++; } }