/* * prints all columns objects of the given node */ static void diaPrintXMLAllColumns(GraphNode *node) { SmiModule *module = NULL; SmiNode *smiNode = NULL; SmiNode *ppNode; module = smiGetNodeModule(node->smiNode); for (smiNode = smiGetFirstNode(module, SMI_NODEKIND_COLUMN); smiNode; smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_COLUMN)) { ppNode = smiGetParentNode(smiNode); ppNode = smiGetParentNode(ppNode); if (!algIsIndexElement(node->smiNode, smiNode) && cmpSmiNodes(node->smiNode, ppNode)) diaPrintXMLAttribute(smiNode, 0); } }
static char *getOidString(SmiNode *smiNode, int importedParent) { SmiNode *parentNode; SmiModule *smiModule; static char s[200]; char append[200]; unsigned int i; append[0] = 0; parentNode = smiNode; smiModule = smiGetNodeModule(smiNode); do { if (parentNode->oidlen <= 1) { break; } /* prepend the cut-off subidentifier to `append'. */ strcpy(s, append); sprintf(append, ".%u%s", parentNode->oid[parentNode->oidlen-1], s); /* retrieve the parent SmiNode */ parentNode = smiGetParentNode(parentNode); if (!parentNode) { sprintf(s, "%s", append); return s; } /* found an imported or a local parent node? */ if ((parentNode->name && strlen(parentNode->name)) && (smiIsImported(smiModule, NULL, parentNode->name) || (!importedParent && (smiGetNodeModule(parentNode) == smiModule)) || (parentNode->oidlen == 1))) { sprintf(s, "%s%s", parentNode->name, append); return s; } } while (parentNode); s[0] = 0; for (i=0; i < smiNode->oidlen; i++) { if (i) strcat(s, "."); sprintf(&s[strlen(s)], "%u", smiNode->oid[i]); } return s; }
static void printCreateTable(SmiNode *groupNode) { SmiNode *smiNode; SmiType *smiType; char *sqlTableName; int i; if (groupNode->nodekind == SMI_NODEKIND_ROW) { sqlTableName = translate(smiGetParentNode(groupNode)->name); } else { sqlTableName = translate(groupNode->name); } printf("create table %s (\n", sqlTableName); xfree(sqlTableName); for (smiNode = smiGetFirstChildNode(groupNode), i = 0; smiNode; smiNode = smiGetNextChildNode(smiNode), i++) { if (smiNode->nodekind & (SMI_NODEKIND_COLUMN | SMI_NODEKIND_SCALAR) #if 0 && (smiNode->access == SMI_ACCESS_READ_ONLY || smiNode->access == SMI_ACCESS_READ_WRITE) #endif ) { smiType = smiGetNodeType(smiNode); if (smiType && ! smiType->name) { smiType = smiGetParentType(smiType); } if (i) { printf(",\n"); } if (smiType) { printf(" %s %s", smiNode->name, smiType->name); } } } printf("\n);\n\n"); }
static int ber_len_varbind(SmiNode *smiNode, len_type flags) { SmiNode *row; SmiSubid oid[128]; unsigned int oidlen = sizeof(oid)/sizeof(oid[0]); int len = 0; #ifdef DUMP_OID int x; #endif switch (smiNode->nodekind) { case SMI_NODEKIND_SCALAR: for (oidlen = 0; oidlen < smiNode->oidlen; oidlen++) { oid[oidlen] = smiNode->oid[oidlen]; } oid[oidlen++] = 0; break; case SMI_NODEKIND_COLUMN: for (oidlen = 0; oidlen < smiNode->oidlen; oidlen++) { oid[oidlen] = smiNode->oid[oidlen]; } row = smiGetParentNode(smiNode); if (row) { SmiNode *indexNode = NULL, *iNode; SmiElement *smiElement; switch (row->indexkind) { case SMI_INDEX_INDEX: case SMI_INDEX_REORDER: indexNode = row; break; case SMI_INDEX_EXPAND: /* TODO: we have to do more work here! */ break; case SMI_INDEX_AUGMENT: case SMI_INDEX_SPARSE: indexNode = smiGetRelatedNode(row); break; case SMI_INDEX_UNKNOWN: break; } if (indexNode) { for (smiElement = smiGetFirstElement(indexNode); smiElement; smiElement = smiGetNextElement(smiElement)) { iNode = smiGetElementNode(smiElement); append_index(oid, &oidlen, iNode, flags); } } } break; default: return 0; } #ifdef DUMP_OID fprintf(stderr, "%-32s\t", smiNode->name); for (x = 0; x < oidlen; x++) { fprintf(stderr, ".%u", oid[x]); } fprintf(stderr, "\n"); #endif len += ber_len_oid(oid, oidlen); len += ber_len_val(smiGetNodeType(smiNode), flags); len += ber_len_length(len) + 1; return len; }
/* * diaCalcSize * * Calculates the size of a given node for the UML representation. */ static GraphNode *diaCalcSize(GraphNode *node) { GraphEdge *tEdge; SmiNode *tNode,*ppNode; SmiElement *smiElement; SmiModule *module; if (node->smiNode->nodekind == SMI_NODEKIND_SCALAR) return node; node->dia.w = (strlen(node->smiNode->name)+4) * HEADFONTSIZETABLE + HEADSPACESIZETABLE; node->dia.h = TABLEHEIGHT; for (smiElement = smiGetFirstElement( smiGetFirstChildNode(node->smiNode)); smiElement; smiElement = smiGetNextElement(smiElement)) { tNode = smiGetElementNode(smiElement); node->dia.w = max(node->dia.w, (strlen(tNode->name) + strlen(algGetTypeName(tNode)) + strlen(INDEXPROPERTY)) * ATTRFONTSIZE + ATTRSPACESIZE); node->dia.h += TABLEELEMHEIGHT; } for (tEdge = graphGetFirstEdgeByNode(graph,node); tEdge; tEdge = graphGetNextEdgeByNode(graph, tEdge, node)) { if (tEdge->startNode == node && tEdge->endNode->smiNode->nodekind == SMI_NODEKIND_SCALAR) { node->dia.h += TABLEELEMHEIGHT; tNode = tEdge->endNode->smiNode; node->dia.w = max(node->dia.w, (strlen(tNode->name) + strlen(algGetTypeName(tNode))) * ATTRFONTSIZE + ATTRSPACESIZE); } } if (PRINT_DETAILED_ATTR && node->smiNode->nodekind == SMI_NODEKIND_TABLE) { module = smiGetNodeModule(node->smiNode); for (tNode = smiGetFirstNode(module, SMI_NODEKIND_COLUMN); tNode; tNode = smiGetNextNode(tNode, SMI_NODEKIND_COLUMN)) { ppNode = smiGetParentNode(tNode); ppNode = smiGetParentNode(ppNode); if (cmpSmiNodes(node->smiNode, ppNode)) { int len; char *typeName; typeName = algGetTypeName(tNode); len = strlen(tNode->name) + (typeName ? strlen(typeName) : 0); node->dia.h += TABLEELEMHEIGHT; node->dia.w = max(node->dia.w, len) * ATTRFONTSIZE + ATTRSPACESIZE; } } } return node; }
/* * prints a group of scalars denoted by group */ static void diaPrintXMLGroup(int group, float x, float y) { GraphNode *tNode; for (tNode = graph->nodes; tNode; tNode = tNode->nextPtr) { if (tNode->group == group) break; } if (!tNode) return; printf(" <object type=\"UML - Class\" version=\"0\" id=\"%s\">\n", smiGetParentNode(tNode->smiNode)->name); printf(" <attribute name=\"obj_pos\">\n"); printf(" <point val=\"%.2f,%.2f\"/>\n",x,y); printf(" </attribute>\n"); printf(" <attribute name=\"obj_bb\">\n"); printf(" <rectangle val=\"0.0,0.0;0.0,0.0\"/>\n"); printf(" </attribute>\n"); printf(" <attribute name=\"elem_corner\">\n"); printf(" <point val=\"%.2f,%.2f\"/>\n",x,y); printf(" </attribute>\n"); printf(" <attribute name=\"elem_width\">\n"); printf(" <real val=\"%.2f\"/>\n",0.0); printf(" </attribute>\n"); printf(" <attribute name=\"elem_height\">\n"); printf(" <real val=\"%.2f\"/>\n",0.0); printf(" </attribute>\n"); printf(" <attribute name=\"name\">\n"); printf(" <string>#%s#</string>\n", smiGetParentNode(tNode->smiNode)->name); printf(" </attribute>\n"); printf(" <attribute name=\"stereotype\">\n"); printf(" <string>#%s#</string>\n", STEREOTYPE); printf(" </attribute>\n"); printf(" <attribute name=\"abstract\">\n"); printf(" <boolean val=\"false\"/>\n"); printf(" </attribute>\n"); printf(" <attribute name=\"suppress_attributes\">\n"); printf(" <boolean val=\"false\"/>\n"); printf(" </attribute>\n"); printf(" <attribute name=\"suppress_operations\">\n"); printf(" <boolean val=\"true\"/>\n"); printf(" </attribute>\n"); printf(" <attribute name=\"visible_attributes\">\n"); printf(" <boolean val=\"true\"/>\n"); printf(" </attribute>\n"); printf(" <attribute name=\"visible_operations\">\n"); printf(" <boolean val=\"false\"/>\n"); printf(" </attribute>\n"); printf(" <attribute name=\"attributes\">\n"); for (tNode = graph->nodes; tNode; tNode = tNode->nextPtr) { if (tNode->group == group) { diaPrintXMLAttribute(tNode->smiNode,0); } } printf(" </attribute>\n"); printf(" <attribute name=\"operations\"/>\n"); printf(" <attribute name=\"template\">\n"); printf(" <boolean val=\"false\"/>\n"); printf(" </attribute>\n"); printf(" <attribute name=\"templates\"/>\n"); printf(" </object>\n"); }