4 * Operations to dump graphic representation of MIBs in fig format.
6 * Copyright (c) 1999 J. Schoenwaelder, Technical University of Braunschweig.
8 * See the file "COPYING" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * @(#) $Id: dump-fig.c 1050 2000-11-29 16:34:45Z strauss $
31 static void setupPage()
35 "# This FIG file has been generated by smidump " SMI_VERSION_STRING
49 static void printString(int x, int y, int angle, char *string)
51 int height = 180, length = 22;
53 printf("4 0 0 0 0 18 12 0.0 4 %d %d %d %d %s\\001\n",
54 height, length, x, y, string);
59 static int isGroup(SmiNode *smiNode)
63 for(childNode = smiGetFirstChildNode(smiNode);
65 childNode = smiGetNextChildNode(childNode)) {
66 if ((childNode->nodekind == SMI_NODEKIND_SCALAR
67 || childNode->nodekind == SMI_NODEKIND_TABLE)
68 && childNode->status == SMI_STATUS_CURRENT) {
78 static void printGroup(int *x, int *y, SmiNode *smiNode)
84 printString(*x, *y, 0, smiNode->name);
86 for(childNode = smiGetFirstChildNode(smiNode);
88 childNode = smiGetNextChildNode(childNode)) {
89 if (childNode->nodekind == SMI_NODEKIND_SCALAR
90 || childNode->nodekind == SMI_NODEKIND_COLUMN) {
91 if (childNode->status != SMI_STATUS_OBSOLETE) {
93 sprintf(string, "%s(%d)", childNode->name,
94 childNode->oid[childNode->oidlen-1]);
95 printString(*x + X_INDENT, *y, 0, string);
104 static void printGroups(int *x, int *y, SmiModule *smiModule)
108 for(smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_ANY);
110 smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_ANY)) {
111 if (isGroup(smiNode)) {
112 printGroup(x, y, smiNode);
114 if (smiNode->nodekind == SMI_NODEKIND_ROW) {
115 printGroup(x, y, smiNode);
122 void dumpFigTree(Module *module)
124 SmiModule *smiModule;
127 smiModule = module->smiModule;
131 x = X_OFFSET, y = Y_OFFSET;
132 printGroups(&x, &y, smiModule);
137 static void printClass(int *x, int *y, SmiNode *smiNode)
144 printString(*x, *y, 0, smiNode->name);
146 for(childNode = smiGetFirstChildNode(smiNode);
148 childNode = smiGetNextChildNode(childNode)) {
149 if (childNode->nodekind == SMI_NODEKIND_SCALAR
150 || childNode->nodekind == SMI_NODEKIND_COLUMN) {
151 if (childNode->status != SMI_STATUS_OBSOLETE) {
152 smiType = smiGetNodeType(childNode);
154 sprintf(string, "%s : %s", childNode->name, smiType->name);
155 printString(*x + X_INDENT, *y, 0, string);
164 static void printClasses(int *x, int *y, SmiModule *smiModule)
168 for(smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_ANY);
170 smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_ANY)) {
171 if (isGroup(smiNode)) {
172 printClass(x, y, smiNode);
174 if (smiNode->nodekind == SMI_NODEKIND_ROW) {
175 printClass(x, y, smiNode);
182 void dumpFigUml(Module *module)
184 SmiModule *smiModule;
187 smiModule = module->smiModule;
191 x = X_OFFSET, y = Y_OFFSET;
192 printClasses(&x, &y, smiModule);
199 static SmidumpDriver driverTree = {
203 SMIDUMP_DRIVER_CANT_UNITE | SMIDUMP_DRIVER_CANT_OUTPUT,
204 "tree graphics in xfig fig format",
208 static SmidumpDriver driverUml = {
212 SMIDUMP_DRIVER_CANT_UNITE | SMIDUMP_DRIVER_CANT_OUTPUT,
213 "UML graphics in xfig fig format",
218 smidumpRegisterDriver(&driverTree);
219 smidumpRegisterDriver(&driverUml);