home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume30 / mibcc / part02 < prev    next >
Encoding:
Text File  |  1992-06-20  |  41.7 KB  |  1,425 lines

  1. Newsgroups: comp.sources.misc
  2. From: wegrzyn@nic.cerf.net (Chuck Wegrzyn)
  3. Subject:  v30i075:  mibcc - SNMP MIB Compiler, Part02/02
  4. Message-ID: <1992Jun20.174927.4943@sparky.imd.sterling.com>
  5. X-Md4-Signature: a4f1c05389578e740b1637052f2a4263
  6. Date: Sat, 20 Jun 1992 17:49:27 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: wegrzyn@nic.cerf.net (Chuck Wegrzyn)
  10. Posting-number: Volume 30, Issue 75
  11. Archive-name: mibcc/part02
  12. Environment: UNIX
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  AssignOBJECT.h AssignOID.c AssignOID.h AssignTRAP.h
  21. #   AssignTYPE.c Makefile MibCompiler.h debug.c error.c keyword.h
  22. #   lex.l oid.h support.c symbol.c symbol.h version.c
  23. # Wrapped by kent@sparky on Sat Jun 20 12:45:45 1992
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 2 (of 2)."'
  27. if test -f 'AssignOBJECT.h' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'AssignOBJECT.h'\"
  29. else
  30.   echo shar: Extracting \"'AssignOBJECT.h'\" \(859 characters\)
  31.   sed "s/^X//" >'AssignOBJECT.h' <<'END_OF_FILE'
  32. Xtypedef struct qobject {
  33. X                        struct qobject *Next;
  34. X                                  char *Name;
  35. X                                  TYPE *Syntax;
  36. X                                   int  Access; 
  37. X                                   int  Status;
  38. X                                  char *Description;
  39. X                                  char *Reference;
  40. X                                  LIST *Index;
  41. X                                  LIST *Default;
  42. X                                  LIST *OID;
  43. X                                   int  LineNo;
  44. X                       } QUEUEOBJ;
  45. X
  46. X#if defined(__STDC__)
  47. Xvoid ProcessObject(char *,TYPE *,int,int,char *,char *,LIST *,LIST *,
  48. X                                                          LIST *,int,int);
  49. Xvoid FinishObjectProcessing(void);
  50. X#else
  51. Xvoid ProcessObject();
  52. Xvoid FinishObjectProcessing();
  53. X#endif
  54. END_OF_FILE
  55.   if test 859 -ne `wc -c <'AssignOBJECT.h'`; then
  56.     echo shar: \"'AssignOBJECT.h'\" unpacked with wrong size!
  57.   fi
  58.   # end of 'AssignOBJECT.h'
  59. fi
  60. if test -f 'AssignOID.c' -a "${1}" != "-c" ; then 
  61.   echo shar: Will not clobber existing file \"'AssignOID.c'\"
  62. else
  63.   echo shar: Extracting \"'AssignOID.c'\" \(9310 characters\)
  64.   sed "s/^X//" >'AssignOID.c' <<'END_OF_FILE'
  65. X#include <stdlib.h>
  66. X#include <string.h>
  67. X
  68. X#include "MibCompiler.h"
  69. X#include "symbol.h"
  70. X#include "AssignOID.h"
  71. X
  72. X
  73. Xextern int bResolveOIDsNeeded,nCheckOnly;
  74. X
  75. X
  76. Xvoid AddOIDSymbol(char *pName,LIST *pOID,int nLineNo)
  77. X {
  78. X    SYMBOL *pSym;
  79. X    /*
  80. X     * Make sure that the symbol isn't already known to us.
  81. X     */
  82. X    if( pSym = FindSymbol(pName,OIDTABLE) )
  83. X             {
  84. X                /*
  85. X                 * Yes. See if it is one of the names we added. If so,
  86. X         * we don't do anything. Otherwise we complain.
  87. X                 */
  88. X                if( pSym->DefinedLineNo )
  89. X                    RestoreErrorMsg("Line %d : Symbol defintion of \"%s\" is already defined on line %d\n",
  90. X                                        nLineNo,pName,pSym->DefinedLineNo);
  91. X             }
  92. X        else {
  93. X                /*
  94. X                 * It isn't known to us, so add it to the system.
  95. X                 */
  96. X                pSym = (SYMBOL *) malloc(sizeof(SYMBOL));
  97. X                if( pSym )
  98. X                         {
  99. X                            /*
  100. X                             * Okay. So fill in the details.
  101. X                             */
  102. X                            pSym->DefinedLineNo = nLineNo;
  103. X                            pSym->SymbolName = strdup(pName);
  104. X                            pSym->SymbolValue = pOID;
  105. X
  106. X                            /*
  107. X                             * Add the symbol to the system.
  108. X                             */
  109. X                            AddToSymbolTable(pSym,OIDTABLE);
  110. X                         }
  111. X                    else {
  112. X                            /*
  113. X                             * Out of memory!
  114. X                             */
  115. X                            RestoreErrorMsg("Out of memory\n");
  116. X                            exit(1);
  117. X                         }
  118. X             }
  119. X }
  120. X
  121. X
  122. Xstatic LIST *GraftLists(LIST *pS,LIST *pAdd)
  123. X {
  124. X    LIST *pNext = (LIST *)pS->Next;
  125. X    LIST *pFirst = pS;
  126. X    for( ; pAdd; )
  127. X        {
  128. X            /*
  129. X             * Copy the pAdd element over the pS element.
  130. X             */
  131. X            memcpy((char *)pS,(char *)pAdd,sizeof(LIST));
  132. X
  133. X            /*
  134. X             * Advance to the next to add in.
  135. X             */
  136. X            pAdd = (LIST *)pAdd->Next;
  137. X
  138. X            /*
  139. X             * If we have another to add, we need to allocate space 
  140. X             * for it.
  141. X             */
  142. X            if( pAdd )
  143. X                {
  144. X                    pS->Next = (struct list *) malloc(sizeof(LIST));
  145. X                    if( pS->Next )
  146. X                             {
  147. X                                /*
  148. X                                 * Ok. 
  149. X                                 */
  150. X                                pS = (LIST *)pS->Next;
  151. X                             }
  152. X                        else {
  153. X                                /*
  154. X                                 * Too bad, we are out of memory.
  155. X                                 */
  156. X                                RestoreErrorMsg("Out of memory\n");
  157. X                                return((LIST *)0);
  158. X                             }
  159. X                }
  160. X        }
  161. X
  162. X    /*
  163. X     * Make the last one point to the rest of the list.
  164. X     */
  165. X    pS->Next = (struct list *)pNext;
  166. X
  167. X    /*
  168. X     * Return a pointer to the insertion point.
  169. X     */
  170. X    return(pS);
  171. X }
  172. X
  173. X
  174. X/*
  175. X * Convert a Name/Number oid list to just numbers, such as 1.3.6.
  176. X */
  177. XLIST *ResolveSpecificOID(LIST *pL,char *pName,int bPrintMsg)
  178. X {
  179. X    SYMBOL *pSym;
  180. X    LIST *pT,*pFirst = pL;
  181. X    /*
  182. X     * For each element in the list, make sure we have a number for it.
  183. X     */
  184. X    for( ; pL; pL = (LIST *)pL->Next )
  185. X        {
  186. X            /*
  187. X             * If this is a name only entry we need to resolve it.  
  188. X             */
  189. X            if( pL->Type == NAMEONLY )
  190. X                {
  191. X                    /*
  192. X                     * First, make sure that we have a symbol defined.
  193. X                     */
  194. X                    pSym = FindSymbol(pL->Name,OIDTABLE);
  195. X                    if(pSym)
  196. X                             {
  197. X                                /*
  198. X                                 * Ok. Resolve this specific symbol now.
  199. X                                 */
  200. X                                pT = ResolveSpecificOID(pSym->SymbolValue,pL->Name,bPrintMsg);
  201. X                                if( pT )
  202. X                                         {
  203. X                                            /*
  204. X                                             * Okay, we need to graft the
  205. X                                             * two lists together.
  206. X                                             */
  207. X                                            GraftLists(pL,pT);
  208. X                                         }
  209. X                                    else {
  210. X                                            /*
  211. X                                             * Too bad, we couldn't resolve
  212. X                                             * it.
  213. X                                             */
  214. X                                            return((LIST *)0);
  215. X                                         }
  216. X                             }
  217. X                        else {
  218. X                                /*
  219. X                                 * Too bad!
  220. X                                 */
  221. X                                if( bPrintMsg )
  222. X                                    {
  223. X                                        if( pName )
  224. X                                             RestoreErrorMsg("While trying to resolve object id \"%s\", the symbol \"%s\" couldn't be found\n",pName,pL->Name);
  225. X                                        else RestoreErrorMsg("While trying to resolve an object id, the symbol %s couldn't be found\n",pL->Name);
  226. X                                    }
  227. X                                return((LIST *)0);
  228. X                             }
  229. X                }
  230. X        }
  231. X
  232. X    /*
  233. X     * Return the list head.
  234. X     */
  235. X    return(pFirst);
  236. X }
  237. X
  238. X
  239. X/*
  240. X * See if all the OIDs that where defined are complete -- they can
  241. X * be resolved into numbers.
  242. X */
  243. Xint AllOIDsResolved(void)
  244. X {
  245. X    SYMBOL *pSym;
  246. X    int nRc = 1,nTemp;
  247. X    /*
  248. X     * For each symbol in the table, do...
  249. X     */
  250. X    for( pSym = 0; pSym = GetNextSymbol(pSym,OIDTABLE); )
  251. X        {
  252. X            nTemp = (ResolveSpecificOID(pSym->SymbolValue,pSym->SymbolName,1) != (LIST *)0);
  253. X            if( nRc ) nRc = nTemp;
  254. X        }
  255. X    return( nRc );
  256. X }
  257. X
  258. X
  259. X/*
  260. X * Dump everything in the OID symbol table.
  261. X */
  262. Xvoid DumpAllOIDs(void)
  263. X {
  264. X    SYMBOL *pSym;
  265. X    /*
  266. X     * For each symbol in the table, do...
  267. X     */
  268. X    for( pSym = 0; pSym = GetNextSymbol(pSym,OIDTABLE); )
  269. X        {
  270. X            printf("Symbol: %s\n",pSym->SymbolName);
  271. X            PrintList(pSym->SymbolValue,0);printf("\n");
  272. X        }
  273. X }
  274. X
  275. X
  276. X/*
  277. X * pName    name of the OID definition.
  278. X * pOID        pointer to linked list defining the OID (watch out
  279. X *            the linked list can have both names and
  280. X *            numbers in it)
  281. X * nLineNo    definition of OID starts on nLineNo in MIB file.
  282. X */
  283. Xvoid ProcessOID(char *pName,LIST *pOID,int nLineNo)
  284. X {
  285. X    LIST *pNew;
  286. X    /*
  287. X     * See if we can resolve the OID to numbers only at this time.
  288. X     */
  289. X    *pNew = ResolveSpecificOID(pOID,pName,0);
  290. X
  291. X    /*
  292. X     * Use the resolved address, if we can. This will save us a lot of
  293. X     * time in later steps.
  294. X     */
  295. X    if( pNew )
  296. X           pOID = pNew;
  297. X      else bResolveOIDsNeeded++;
  298. X
  299. X    /*
  300. X     * Add the symbol to the table.
  301. X     */
  302. X    AddOIDSymbol(pName,pOID,nLineNo);
  303. X }
  304. X
  305. X
  306. X
  307. Xvoid AddStandardOIDS(void)
  308. X { 
  309. X        LIST *pList;
  310. X    /*
  311. X         * The first "standard" names are iso, ccitt and joint-iso-ccitt.
  312. X         */
  313. X        pList = newListElement(NUMBERONLY,(char *)0,0);
  314. X        AddOIDSymbol("ccitt",pList,0);
  315. X        pList = newListElement(NUMBERONLY,(char *)0,1);
  316. X        AddOIDSymbol("iso",pList,0);
  317. X        pList = newListElement(NUMBERONLY,(char *)0,2);
  318. X        AddOIDSymbol("joint-iso-ccitt",pList,0);
  319. X
  320. X        /*
  321. X         * Now add the things from RFC-1155.
  322. X         * Start with internet.
  323. X         */
  324. X        pList = newListElement(NAMEONLY,"iso",0);
  325. X        pList = LinkToList(pList,newListElement(NAMEANDNUMBER,"org",3));
  326. X        pList = LinkToList(pList,newListElement(NAMEANDNUMBER,"dod",6));
  327. X        pList = LinkToList(pList,newListElement(NUMBERONLY,(char *)0,1));
  328. X        ProcessOID("internet",pList,0);
  329. X
  330. X        /*
  331. X         * Add directory.
  332. X         */
  333. X        pList = newListElement(NAMEONLY,"internet",0);
  334. X        pList = LinkToList(pList,newListElement(NUMBERONLY,(char *)0,1));
  335. X        ProcessOID("directory",pList,0);
  336. X
  337. X        /*
  338. X         * The 'mgmt' thing.
  339. X         */
  340. X        pList = newListElement(NAMEONLY,"internet",0);
  341. X        pList = LinkToList(pList,newListElement(NUMBERONLY,(char *)0,2));
  342. X        ProcessOID("mgmt",pList,0);
  343. X
  344. X        /*
  345. X         * The 'experimental' thing.
  346. X         */
  347. X        pList = newListElement(NAMEONLY,"internet",0);
  348. X        pList = LinkToList(pList,newListElement(NUMBERONLY,(char *)0,3));
  349. X        ProcessOID("experimental",pList,0);
  350. X
  351. X        /*
  352. X         * The 'private' thing.
  353. X         */
  354. X        pList = newListElement(NAMEONLY,"internet",0);
  355. X        pList = LinkToList(pList,newListElement(NUMBERONLY,(char *)0,4));
  356. X        ProcessOID("private",pList,0);
  357. X
  358. X        /*
  359. X         * The 'enterprises' thing.
  360. X         */
  361. X        pList = newListElement(NAMEONLY,"private",0);
  362. X        pList = LinkToList(pList,newListElement(NUMBERONLY,(char *)0,1));
  363. X        ProcessOID("enterprises",pList,0);
  364. X }
  365. END_OF_FILE
  366.   if test 9310 -ne `wc -c <'AssignOID.c'`; then
  367.     echo shar: \"'AssignOID.c'\" unpacked with wrong size!
  368.   fi
  369.   # end of 'AssignOID.c'
  370. fi
  371. if test -f 'AssignOID.h' -a "${1}" != "-c" ; then 
  372.   echo shar: Will not clobber existing file \"'AssignOID.h'\"
  373. else
  374.   echo shar: Extracting \"'AssignOID.h'\" \(325 characters\)
  375.   sed "s/^X//" >'AssignOID.h' <<'END_OF_FILE'
  376. X#if defined(__STDC__)
  377. Xvoid AddOIDSymbol(char *,LIST *,int);
  378. Xint AllOIDsResolved(void);
  379. Xvoid AddStandardOIDS(void);
  380. XLIST *ResolveSpecificOID(LIST *,char *,int);
  381. Xvoid ProcessOID(char *,LIST *,int);
  382. X#else
  383. Xvoid AddOIDSymbol();
  384. Xint AllOIDsResolved();
  385. Xvoid AddStandardOIDS();
  386. XLIST *ResolveSpecificOID();
  387. Xvoid ProcessOID();
  388. X#endif
  389. X
  390. END_OF_FILE
  391.   if test 325 -ne `wc -c <'AssignOID.h'`; then
  392.     echo shar: \"'AssignOID.h'\" unpacked with wrong size!
  393.   fi
  394.   # end of 'AssignOID.h'
  395. fi
  396. if test -f 'AssignTRAP.h' -a "${1}" != "-c" ; then 
  397.   echo shar: Will not clobber existing file \"'AssignTRAP.h'\"
  398. else
  399.   echo shar: Extracting \"'AssignTRAP.h'\" \(118 characters\)
  400.   sed "s/^X//" >'AssignTRAP.h' <<'END_OF_FILE'
  401. X#if defined(__STDC__)
  402. Xvoid ProcessTrap(char *,LIST *,LIST *,char *,char *,int,int);
  403. X#else
  404. Xvoid ProcessTrap();
  405. X#endif
  406. X
  407. END_OF_FILE
  408.   if test 118 -ne `wc -c <'AssignTRAP.h'`; then
  409.     echo shar: \"'AssignTRAP.h'\" unpacked with wrong size!
  410.   fi
  411.   # end of 'AssignTRAP.h'
  412. fi
  413. if test -f 'AssignTYPE.c' -a "${1}" != "-c" ; then 
  414.   echo shar: Will not clobber existing file \"'AssignTYPE.c'\"
  415. else
  416.   echo shar: Extracting \"'AssignTYPE.c'\" \(2326 characters\)
  417.   sed "s/^X//" >'AssignTYPE.c' <<'END_OF_FILE'
  418. X#include <stdio.h>
  419. X#include <stdlib.h>
  420. X#include <string.h>
  421. X
  422. X#include "MibCompiler.h"
  423. X#include "AssignTYPE.h"
  424. X#include "symbol.h"
  425. X
  426. X
  427. Xextern int yyErrorCnt;
  428. X
  429. X
  430. X/*
  431. X * pName        name of TYPE definition
  432. X * type            pointer to TYPE structure that details what
  433. X *                is being named.
  434. X * nLineNo        where the TYPE is defined in the MIB file.
  435. X */
  436. Xvoid ProcessType(char *pName,TYPE *type,int nLineNo)
  437. X {
  438. X    SYMBOL *pSym;
  439. X    /*
  440. X     * This is simple; we just mark things as an alias. 'pName' is the
  441. X     * new name for type 'type'.
  442. X     */
  443. X    if( pSym = FindSymbol(pName,NEWTYPES) )
  444. X                 {
  445. X                    /*
  446. X                     * Symbol is already known! See if it is one of the 
  447. X                     * predefined types...
  448. X                     */
  449. X                    if( pSym->DefinedLineNo )
  450. X                        {
  451. X                            RestoreErrorMsg("Line %d : %s is an already known data type defined at line %d\n",pName,pSym->DefinedLineNo);
  452. X                            yyErrorCnt++;
  453. X                        }
  454. X                 }
  455. X            else {
  456. X                    /*
  457. X                     * We have a new one. So add it for later use.
  458. X                     */
  459. X                    pSym = (SYMBOL *) malloc( sizeof(SYMBOL) );
  460. X                    if( pSym )
  461. X                             {
  462. X                                /*
  463. X                                 * Save it.
  464. X                                 */
  465. X                                pSym->DefinedLineNo = nLineNo;
  466. X                                pSym->SymbolName = strdup(pName);
  467. X                                pSym->SymbolValue = (LIST *)type;
  468. X                                AddToSymbolTable(pSym,NEWTYPES);
  469. X                             }
  470. X                        else {
  471. X                                /*
  472. X                                 * No memory left!
  473. X                                 */
  474. X                                RestoreErrorMsg("Out of memory\n");
  475. X                             }
  476. X                 }
  477. X }
  478. X
  479. X
  480. Xvoid AddStandardTypes(void)
  481. X {
  482. X    PAIR all0;
  483. X    /*
  484. X     * We add in any standard types that are created from basic level
  485. X     * types.
  486. X     */
  487. X    memset((char *)&all0,0,sizeof(all0));
  488. X    ProcessType("DisplayString",newTypeElement(OCTETTYPE,(char *)&all0),0);
  489. X    ProcessType("PhysAddress",newTypeElement(OCTETTYPE,(char *)&all0),0);
  490. X }
  491. X
  492. END_OF_FILE
  493.   if test 2326 -ne `wc -c <'AssignTYPE.c'`; then
  494.     echo shar: \"'AssignTYPE.c'\" unpacked with wrong size!
  495.   fi
  496.   # end of 'AssignTYPE.c'
  497. fi
  498. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  499.   echo shar: Will not clobber existing file \"'Makefile'\"
  500. else
  501.   echo shar: Extracting \"'Makefile'\" \(611 characters\)
  502.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  503. X#
  504. X# If you can use varargs.h, you should change CFLAGS to be the following:
  505. X#
  506. X#CFLAGS = -g -DVARARGS
  507. X#
  508. X# If you need to use stdarg.h, use just the included CFLAGS...
  509. X#
  510. X# Of course, use -g to include debugging information.
  511. X#
  512. XCFLAGS    = -g
  513. X
  514. XOBJECTS = y.tab.o lex.yy.o support.o symbol.o debug.o AssignOID.o \
  515. X        AssignTRAP.o AssignOBJECT.o AssignTYPE.o error.o main.o \
  516. X                version.o
  517. X
  518. X
  519. XMIBcompiler:    $(OBJECTS)
  520. X        $(CC) -o $@ $(OBJECTS) -ll -ly -lx
  521. Xclean:
  522. X        -rm -f y.tab.* lex.yy.* *.o MIBcompiler yacc.tmp yacc.acts\
  523. X             yacc.debug y.output
  524. X
  525. Xy.tab.c:    yacc.y
  526. X        yacc -d yacc.y
  527. X
  528. Xlex.yy.c:    lex.l
  529. X        lex lex.l
  530. X
  531. END_OF_FILE
  532.   if test 611 -ne `wc -c <'Makefile'`; then
  533.     echo shar: \"'Makefile'\" unpacked with wrong size!
  534.   fi
  535.   # end of 'Makefile'
  536. fi
  537. if test -f 'MibCompiler.h' -a "${1}" != "-c" ; then 
  538.   echo shar: Will not clobber existing file \"'MibCompiler.h'\"
  539. else
  540.   echo shar: Extracting \"'MibCompiler.h'\" \(2052 characters\)
  541.   sed "s/^X//" >'MibCompiler.h' <<'END_OF_FILE'
  542. X#if defined(__STDC__)
  543. X#if defined(VARARGS)
  544. Xvoid RestoreErrorMsg(const char *,int);
  545. Xvoid ErrorMsg(const char *,int);
  546. X#else
  547. Xvoid RestoreErrorMsg(const char *,...);
  548. Xvoid ErrorMsg(const char *,...);
  549. X#endif
  550. X#else
  551. Xvoid ErrorMsg();
  552. Xvoid RestoreErrorMsg();
  553. X#endif
  554. X
  555. Xtypedef enum {ALLKEYWORDS,NOKEYWORDS} KEYTYPES;
  556. X
  557. Xtypedef enum {TRUTH,FALSITY} BOOLEAN;
  558. X
  559. Xtypedef enum {NAMEONLY,NUMBERONLY,NAMEANDNUMBER,
  560. X                           NAMEANDOID,STRINGONLY} ENTRYTYPE;
  561. Xtypedef struct list {
  562. X                        struct list *Next;
  563. X                          ENTRYTYPE  Type;
  564. X                               char *Name;
  565. X                                int  Number;
  566. X                        struct list *OID;
  567. X                    } LIST;
  568. X#if defined(__STDC__)
  569. XLIST *newListElement(ENTRYTYPE,char *,int);
  570. XLIST *LinkToList(LIST *,LIST *);
  571. Xchar *OIDListToString(LIST *);
  572. X#else
  573. XLIST *newListElement();
  574. XLIST *LinkToList();
  575. Xchar *OIDListToString();
  576. X#endif
  577. X
  578. X
  579. Xtypedef struct {
  580. X                long int Lower;
  581. X                long int Upper;
  582. X               } PAIR;
  583. X
  584. Xtypedef enum {NULLTYPE,TICKTYPE,COUNTERTYPE,OBJIDTYPE,
  585. X                    GAUGETYPE,IPADDRTYPE,NETWORKTYPE,
  586. X                        INTEGERTYPE,RANGEINTEGER,ENUMINTEGER,
  587. X                            OCTETTYPE,ITEMTYPE,SEQTYPE,SEQOFTYPE,
  588. X                                               STRINGTYPE,TYPENAME} TYPEofTYPE;
  589. Xtypedef struct {
  590. X                char *ItemName;
  591. X                void *ItemType;
  592. X               } NAMEPAIR;
  593. X
  594. Xtypedef union {
  595. X                    PAIR  Range;
  596. X                    LIST *EnumList;
  597. X                    char *TypeList;
  598. X                NAMEPAIR  Names;
  599. X                    char *SeqName;
  600. X                    char *TypeName;
  601. X              } DATAUNION;
  602. X
  603. Xtypedef struct type {
  604. X                        struct type *Next;
  605. X                         TYPEofTYPE  Type;
  606. X                          DATAUNION  Data;
  607. X                    } TYPE;
  608. X
  609. X#if defined(__STDC__)
  610. XTYPE *newTypeElement(TYPEofTYPE,char *);
  611. XTYPE *LinkToType(TYPE *,TYPE *);
  612. X#else
  613. XTYPE *newTypeElement();
  614. XTYPE *LinkToType();
  615. X#endif
  616. END_OF_FILE
  617.   if test 2052 -ne `wc -c <'MibCompiler.h'`; then
  618.     echo shar: \"'MibCompiler.h'\" unpacked with wrong size!
  619.   fi
  620.   # end of 'MibCompiler.h'
  621. fi
  622. if test -f 'debug.c' -a "${1}" != "-c" ; then 
  623.   echo shar: Will not clobber existing file \"'debug.c'\"
  624. else
  625.   echo shar: Extracting \"'debug.c'\" \(3993 characters\)
  626.   sed "s/^X//" >'debug.c' <<'END_OF_FILE'
  627. X#include <stdio.h>
  628. X#include <stdlib.h>
  629. X
  630. X#include "MibCompiler.h"
  631. X
  632. X
  633. Xvoid PrintList(LIST *p1,int bNewLine)
  634. X {
  635. X    for( ; p1; p1 = p1->Next )
  636. X        {
  637. X            switch(p1->Type)
  638. X                {
  639. X                    case NAMEONLY   : 
  640. X                                      printf(bNewLine ? "%s\n":"%s ",p1->Name);
  641. X                                      break;
  642. X                    case NUMBERONLY :
  643. X                                      printf(bNewLine ? "%d\n":"%d ",p1->Number);
  644. X                                      break;
  645. X                    case NAMEANDNUMBER :
  646. X                                      printf(bNewLine ? "%s(%d)\n":"%s(%d) ",p1->Name,p1->Number);
  647. X                                      break;
  648. X                }
  649. X        }
  650. X }
  651. X
  652. X
  653. Xstatic char *RangeToString(PAIR range)
  654. X {
  655. X    char *pStr;
  656. X    static char buf[32];
  657. X    if( range.Lower || range.Upper )
  658. X             {
  659. X                sprintf(buf,"(%d...%d)",range.Lower,range.Upper);
  660. X                pStr = buf;
  661. X             }
  662. X        else pStr = 0;
  663. X    return(pStr);
  664. X }
  665. X
  666. Xvoid PrintType(TYPE *p1)
  667. X {
  668. X    char *pStr;
  669. X    for( ; p1; p1 = p1->Next )
  670. X        {
  671. X            /*
  672. X             * Print out the type info...
  673. X             */
  674. X            switch(p1->Type)
  675. X                {
  676. X                    case TICKTYPE :
  677. X                            pStr = RangeToString(p1->Data.Range);
  678. X                            printf(pStr ? "Tick %s\n" : "Tick\n",pStr);
  679. X                            break;
  680. X                    case COUNTERTYPE :
  681. X                            pStr = RangeToString(p1->Data.Range);
  682. X                            printf(pStr ? "Counter %s\n" : "Counter\n",pStr);
  683. X                            break;
  684. X                    case GAUGETYPE :
  685. X                            pStr = RangeToString(p1->Data.Range);
  686. X                            printf(pStr ? "Gauge %s\n" : "Gauge\n",pStr);
  687. X                            break;
  688. X                    case RANGEINTEGER :
  689. X                    case INTEGERTYPE :
  690. X                            pStr = RangeToString(p1->Data.Range);
  691. X                            printf(pStr ? "Integer %s\n":"Integer\n",pStr);
  692. X                            break;
  693. X                    case OCTETTYPE :
  694. X                            pStr = RangeToString(p1->Data.Range);
  695. X                            printf(pStr ? "Octet string %s\n" :"Octet string\n",pStr);
  696. X                            break;
  697. X                    case STRINGTYPE :
  698. X                            pStr = RangeToString(p1->Data.Range);
  699. X                            printf(pStr ? "String %s\n":"String\n",pStr);
  700. X                            break;
  701. X                    case OBJIDTYPE :
  702. X                            printf("ObjectId\n");
  703. X                            break;
  704. X                    case IPADDRTYPE :
  705. X                            printf("IpAddress\n");
  706. X                            break;
  707. X                    case NETWORKTYPE :
  708. X                            printf("NetworkAddress\n");
  709. X                            break;
  710. X                    case NULLTYPE :
  711. X                            printf("Null\n");
  712. X                            break;
  713. X                    case ENUMINTEGER :
  714. X                            printf("Integer\n");
  715. X                            PrintList(p1->Data.EnumList,1);
  716. X                            break;
  717. X                    case ITEMTYPE :
  718. X                            printf("%s ",p1->Data.Names.ItemName);
  719. X                            PrintType(p1->Data.Names.ItemType);
  720. X                            break;
  721. X                    case SEQTYPE :
  722. X                            printf("Sequence\n");
  723. X                            PrintType((TYPE *)(p1->Data.TypeList));
  724. X                            break;
  725. X                    case SEQOFTYPE :
  726. X                            printf("SequenceOf\n");
  727. X                            PrintType((TYPE *)(p1->Data.TypeList));
  728. X                            break;
  729. X                    case TYPENAME :
  730. X                            printf("%s\n",p1->Data.TypeName);
  731. X                            break;
  732. X                }
  733. X        }
  734. X }
  735. X
  736. END_OF_FILE
  737.   if test 3993 -ne `wc -c <'debug.c'`; then
  738.     echo shar: \"'debug.c'\" unpacked with wrong size!
  739.   fi
  740.   # end of 'debug.c'
  741. fi
  742. if test -f 'error.c' -a "${1}" != "-c" ; then 
  743.   echo shar: Will not clobber existing file \"'error.c'\"
  744. else
  745.   echo shar: Extracting \"'error.c'\" \(1007 characters\)
  746.   sed "s/^X//" >'error.c' <<'END_OF_FILE'
  747. X#include <stdio.h>
  748. X#if defined(VARARGS)
  749. X#include <varargs.h>
  750. X#else
  751. X#include <stdarg.h>
  752. X#endif
  753. X
  754. X
  755. X#include "MibCompiler.h"
  756. X
  757. X
  758. Xint nErrorCount = 0;
  759. X
  760. X#if defined(VARARGS)
  761. Xvoid RestoreErrorMsg(format,va_alist)
  762. Xconst char *format;
  763. Xva_dcl
  764. X#else
  765. Xvoid RestoreErrorMsg(const char *format,...)
  766. X#endif
  767. X {
  768. X    va_list ap;
  769. X    /*
  770. X     * Convert the format string and arguments to something we can use.
  771. X     */
  772. X#if defined(VARARGS)
  773. X    va_start(ap);
  774. X#else
  775. X    va_start(ap,char *);
  776. X#endif
  777. X    (void) vprintf(format,ap);
  778. X#if defined(VARARGS)
  779. X    va_end(ap)
  780. X#else
  781. X    va_end(ap);
  782. X#endif
  783. X    nErrorCount++;
  784. X }
  785. X
  786. X
  787. X#if defined(VARARGS)
  788. Xvoid ErrorMsg(format,va_alist)
  789. Xconst char *format;
  790. Xva_dcl
  791. X#else
  792. Xvoid ErrorMsg(const char *format,...)
  793. X#endif
  794. X {
  795. X    va_list ap;
  796. X    /*
  797. X     * Convert the format string and arguments to something we can use.
  798. X     */
  799. X#if defined(VARARGS)
  800. X    va_start(ap);
  801. X#else
  802. X    va_start(ap,char *);
  803. X#endif
  804. X    (void) vprintf(format,ap);
  805. X#if defined(VARARGS)
  806. X    va_end(ap)
  807. X#else
  808. X    va_end(ap);
  809. X#endif
  810. X }
  811. X
  812. X
  813. X
  814. END_OF_FILE
  815.   if test 1007 -ne `wc -c <'error.c'`; then
  816.     echo shar: \"'error.c'\" unpacked with wrong size!
  817.   fi
  818.   # end of 'error.c'
  819. fi
  820. if test -f 'keyword.h' -a "${1}" != "-c" ; then 
  821.   echo shar: Will not clobber existing file \"'keyword.h'\"
  822. else
  823.   echo shar: Extracting \"'keyword.h'\" \(49 characters\)
  824.   sed "s/^X//" >'keyword.h' <<'END_OF_FILE'
  825. Xtypedef enum {ALLKEYWORDS,NOKEYWORDS} KEYTYPES;
  826. X
  827. END_OF_FILE
  828.   if test 49 -ne `wc -c <'keyword.h'`; then
  829.     echo shar: \"'keyword.h'\" unpacked with wrong size!
  830.   fi
  831.   # end of 'keyword.h'
  832. fi
  833. if test -f 'lex.l' -a "${1}" != "-c" ; then 
  834.   echo shar: Will not clobber existing file \"'lex.l'\"
  835. else
  836.   echo shar: Extracting \"'lex.l'\" \(8265 characters\)
  837.   sed "s/^X//" >'lex.l' <<'END_OF_FILE'
  838. X%{
  839. X#include <string.h>
  840. X#include <ctype.h>
  841. X
  842. X#include "MibCompiler.h"
  843. X#include "symbol.h"
  844. X#include "y.tab.h"
  845. X
  846. X
  847. X#define    myyerror    yyerror
  848. X#undef    YYLMAX
  849. X#define    YYLMAX        8192
  850. X
  851. XKEYTYPES eNoKeyWords = {ALLKEYWORDS};
  852. X
  853. X
  854. Xstruct table {
  855. X    char   *t_keyword;
  856. X    int        t_value;
  857. X};
  858. X
  859. Xextern struct table reserved[];
  860. Xextern struct table lowerReserved[];
  861. X%}
  862. X
  863. X%%
  864. X
  865. X"--"            {
  866. X                            int c, d;
  867. X                for( d = 0; c = input(); d = c == '-' )
  868. X                if( (c == '\n') || (d && c == '-') ) break;
  869. X            }
  870. X[ \t]*            {
  871. X            }
  872. X\n            {
  873. X            }
  874. X"::="            {
  875. X                return CCE;
  876. X            }
  877. X".."                    {
  878. X                            return DOTDOT;
  879. X                        }
  880. X";"            {
  881. X                return SEMICOLON;
  882. X            }
  883. X","            {
  884. X                return COMMA;
  885. X            }
  886. X"{"            {
  887. X                return LBRACE;
  888. X            }
  889. X"}"            {
  890. X                return RBRACE;
  891. X            }
  892. X"("            {
  893. X                return LPAREN;
  894. X            }
  895. X")"            {
  896. X                return RPAREN;
  897. X            }
  898. X[0-9]+            {
  899. X                (void) sscanf (yytext, "%d", &yylval.yy_number);
  900. X                return LITNUMBER;
  901. X            }
  902. X-[0-9]+            {
  903. X                (void) sscanf (yytext, "%d", &yylval.yy_number);
  904. X                return LITNUMBER;
  905. X            }
  906. X'[^'$]*'[BbHh]        {   register char *cp; register int i;
  907. X
  908. X                switch (*(cp = yytext + strlen (yytext) - 1)) {
  909. X                case 'H':
  910. X                case 'h':
  911. X                    *cp = NULL;
  912. X                    (void) sscanf (yytext + 1, "%x",
  913. X                        &yylval.yy_number);
  914. X                    break;
  915. X
  916. X                case 'B':
  917. X                case 'b':
  918. X                    *cp-- = NULL, *cp = NULL;
  919. X                    for (i = 0, cp = yytext + 1; *cp; ) {
  920. X                    i <<= 1;
  921. X                    i += *cp++ - '0';
  922. X                    }
  923. X                    yylval.yy_number = i;
  924. X                    break; 
  925. X                }
  926. X                return LITNUMBER;
  927. X            }
  928. X\"[^\"$]*\"        {
  929. X                            char *pF,*pT;
  930. X                            /*
  931. X                             * Process the literal string... we start
  932. X                             * by stripping out multiple WHITESPACE
  933. X                             * and replacing it with a single space.
  934. X                             */
  935. X                yytext[strlen (yytext) - 1] = NULL;
  936. X                yylval.yy_string = strdup(yytext + 1);
  937. X                            for( pF = pT = yylval.yy_string; *pF; )
  938. X                                if( isspace(*pF) && *(pF+1) && isspace(*(pF+1)) )
  939. X                                       {
  940. X                                            /*
  941. X                                             * We have multiple WHITESPACE. So
  942. X                                             * keep one as a BLANK.
  943. X                                             */
  944. X                                            *pF++;
  945. X                                       }
  946. X                                  else {
  947. X                                            /*
  948. X                                             * No. Save it away.
  949. X                                             */
  950. X                                            if( isspace(*pF) )
  951. X                                                     *pT++ = ' ';
  952. X                                                else *pT++ = *pF;
  953. X                                            pF++;
  954. X                                       }
  955. X                            *pT = '\0';
  956. X                return LITSTRING;
  957. X            }
  958. X[A-Z][A-Za-z0-9-]*    {
  959. X                            /*
  960. X                             * See if we need to look for keywords.
  961. X                             */
  962. X                            int n;
  963. X                            SYMBOL *pSym;
  964. X                            if( eNoKeyWords == ALLKEYWORDS )
  965. X                                {
  966. X                                    /*
  967. X                                     * First, look for the unchanged keyword.
  968. X                                     * If we find it, cool. Just return the
  969. X                                     * type.
  970. X                                     */
  971. X                                    n = CompareKeywords(reserved,yytext,0);
  972. X                                    if( n >= 0 ) return(n);  
  973. X
  974. X                                    /*
  975. X                                     * See if we have a case mismatch. If so
  976. X                                     * force an error!
  977. X                                     */
  978. X                                    n = CompareKeywords(reserved,yytext,1);
  979. X                                    if( n >= 0 ) return(ERROR);
  980. X
  981. X                                    /*
  982. X                                     * Finally, check out the typedef types
  983. X                                     * of symbols.
  984. X                                     */
  985. X                                    pSym = FindSymbol(yytext,NEWTYPES);
  986. X                                    if( pSym )
  987. X                    {
  988. X                     switch(((TYPE *)(pSym->SymbolValue))->Type)
  989. X                        {
  990. X                                                    case NULLTYPE : return(NULLID);
  991. X                                                    case TICKTYPE : return(TIMETICKS);
  992. X                                                    case COUNTERTYPE : return(COUNTER);
  993. X                                                    case GAUGETYPE : return(GAUGE);
  994. X                                                    case IPADDRTYPE : return(IPADDRESS);
  995. X                                                    case NETWORKTYPE : return(NETWORKADDRESS);
  996. X                                                    case INTEGERTYPE : return(INTEGER);
  997. X                                                    case OCTETTYPE :   return(OCTSTR);
  998. X                                                    case STRINGTYPE : return(STRING);
  999. X                        }
  1000. X                    }
  1001. X                                }
  1002. X                yylval.yy_string = strdup(yytext);
  1003. X                return ID;
  1004. X            }
  1005. X[a-z][A-Za-z0-9-]*    { 
  1006. X                            int n;
  1007. X                            if( eNoKeyWords ==  ALLKEYWORDS )
  1008. X                                {
  1009. X                                    /*
  1010. X                                     * First, look for the unchanged keyword.
  1011. X                                     */
  1012. X                                    n = CompareKeywords(lowerReserved,yytext,0);
  1013. X                                    if( n >= 0 ) return(n);
  1014. X                                }
  1015. X                yylval.yy_string = strdup(yytext);
  1016. X                return NAME;
  1017. X            }
  1018. X.            {   
  1019. X                myyerror ("unknown token: \"%s\"", yytext);
  1020. X            }
  1021. X
  1022. X%%
  1023. X
  1024. Xstruct table lowerReserved[] = {
  1025. X    "deprecated", DEPRECATEDOBJECT,
  1026. X    "mandatory", MANDATORYOBJECT,
  1027. X    "obsolete", OBSOLETEOBJECT,
  1028. X    "optional", OPTIONALOBJECT,
  1029. X
  1030. X    "not-accessible", NOTACCESSIBLEOBJECT,
  1031. X    "read-only", READONLYOBJECT,
  1032. X    "read-write", READWRITEOBJECT,
  1033. X    "write-only", WRITEONLYOBJECT,
  1034. X
  1035. X    0,0
  1036. X};
  1037. X
  1038. Xstruct table reserved[] = {
  1039. X    "ACCESS", ACCESS,
  1040. X    "BEGIN", BGIN,
  1041. X    "DEFINITIONS", DEFINITIONS,
  1042. X    "DEFVAL", DEFVAL,
  1043. X    "DESCRIPTION", DESCRIPTION,
  1044. X    "END", END,
  1045. X    "ENTERPRISE", ENTERPRISE,
  1046. X    "EXPORTS", EXPORTS,
  1047. X    "FROM", FROM,
  1048. X    "IMPORTS", IMPORTS,
  1049. X    "INDEX", INDEX,
  1050. X    "OBJECT-TYPE", OBJECTTYPE,
  1051. X    "OF", OF,
  1052. X    "REFERENCE", REFERENCE,
  1053. X    "SEQUENCE", SEQUENCE,
  1054. X    "SIZE", SIZE,
  1055. X    "STATUS", STATUS,
  1056. X    "SYNTAX", SYNTAX,
  1057. X    "TRAP-TYPE", TRAPTYPE,
  1058. X    "VARIABLES", VARIABLES,
  1059. X
  1060. X    "Counter", COUNTER,
  1061. X    "Gauge", GAUGE,
  1062. X    "INTEGER", INTEGER,
  1063. X    "IpAddress", IPADDRESS,
  1064. X    "NetworkAddress", NETWORKADDRESS,
  1065. X    "NULL", NULLID,
  1066. X    "OCTET", OCTET,
  1067. X    "STRING", STRING,
  1068. X    "OPAQUE", OPAQUE,
  1069. X    "TimeTicks", TIMETICKS,
  1070. X    "OBJECT", OBJECT,
  1071. X    "IDENTIFIER", IDENTIFIER,
  1072. X
  1073. X    0,0
  1074. X};
  1075. X
  1076. Xstatic int stricmp(char *pS,char *pT)
  1077. X {
  1078. X    for( ; *pS && *pT; pS++,pT++ )
  1079. X        if( toupper(*pS) != toupper(*pT) ) break;
  1080. X    return( *pS - *pT );
  1081. X }
  1082. X
  1083. Xstatic int CompareKeywords(struct table *pT,char *pS,int bNotCaseSensitive)
  1084. X {
  1085. X    /*
  1086. X     * Cycle through the table looking for a match.
  1087. X     */
  1088. X    for( ; pT->t_keyword; pT++ )
  1089. X        {
  1090. X            /*
  1091. X             * See if we need to pay attention to the case or not.
  1092. X             */
  1093. X            if( bNotCaseSensitive & (stricmp(pT->t_keyword,pS) == 0) ||
  1094. X                                             (strcmp(pT->t_keyword,pS) == 0) )
  1095. X                                                     return(pT->t_value);
  1096. X        }
  1097. X    return(-1);
  1098. X }
  1099. X
  1100. X
  1101. Xchar *ShouldBeKeyword(char *pS)
  1102. X {
  1103. X    struct table *pT = reserved;
  1104. X    /*
  1105. X     * Cycle through the table looking for a match.
  1106. X     */
  1107. X    for( ; pT->t_keyword; pT++ )
  1108. X        {
  1109. X            /*
  1110. X             * See if we need to pay attention to the case or not.
  1111. X             */
  1112. X            if( stricmp(pT->t_keyword,pS) == 0 ) return(pT->t_keyword);
  1113. X        }
  1114. X    return(0);
  1115. X }
  1116. X
  1117. END_OF_FILE
  1118.   if test 8265 -ne `wc -c <'lex.l'`; then
  1119.     echo shar: \"'lex.l'\" unpacked with wrong size!
  1120.   fi
  1121.   # end of 'lex.l'
  1122. fi
  1123. if test -f 'oid.h' -a "${1}" != "-c" ; then 
  1124.   echo shar: Will not clobber existing file \"'oid.h'\"
  1125. else
  1126.   echo shar: Extracting \"'oid.h'\" \(1799 characters\)
  1127.   sed "s/^X//" >'oid.h' <<'END_OF_FILE'
  1128. X#define MAXNOELEMS      (50)
  1129. X
  1130. Xtypedef enum {
  1131. X              DISPLAYSTRING,
  1132. X              OBJECTID,
  1133. X              TIMETICKS,
  1134. X              OPAQUE,
  1135. X              NULLOBJ,
  1136. X              GAUGE,
  1137. X              OCTETSTRING,
  1138. X              COUNTER,
  1139. X              IPADDR,
  1140. X              INTEGER,
  1141. X              AGGREGATE,
  1142. X              NOTYPE,
  1143. X              NETADDR
  1144. X             } OIDTYPE;
  1145. X
  1146. Xtypedef enum {
  1147. X              RONLY,
  1148. X              RWRITE,
  1149. X              WRITEONLY,
  1150. X              NOACCESS,
  1151. X              UNKNOWN = -1
  1152. X             } OIDACCESS;
  1153. X
  1154. Xtypedef enum {
  1155. X              MANDATORY,
  1156. X              OPTIONAL,
  1157. X              OBSOLETE,
  1158. X              DEPRECATED
  1159. X             } OIDSTATUS;
  1160. X
  1161. Xtypedef enum {
  1162. X               LEAFTYPE,
  1163. X                ROWTYPE,
  1164. X                COLTYPE,
  1165. X                ARRAYTYPE
  1166. X             } OIDFLAG;
  1167. X
  1168. Xtypedef enum {
  1169. X                RANGESET,NOSUBTYPE,ENUMSET
  1170. X             } OIDSUBTYPE;
  1171. X
  1172. Xtypedef struct {
  1173. X                char *EnumName;
  1174. X                 int  EnumValue;
  1175. X               } ENUMDATA;
  1176. X
  1177. Xtypedef struct {
  1178. X                 int Lower;
  1179. X                 int Upper;
  1180. X               } PAIROFINTS;
  1181. X
  1182. Xtypedef union {
  1183. X                      long  RecPtr;
  1184. X                  ENUMDATA  EnumData;
  1185. X                      char *IndexName;
  1186. X                      char *Comments;
  1187. X                PAIROFINTS Pair;
  1188. X              } OIDEXTRA;
  1189. X
  1190. Xtypedef struct {
  1191. X                        char *OIDname;
  1192. X                        char *OIDoid;
  1193. X                   OIDACCESS  OIDaccess;
  1194. X                     OIDTYPE  OIDtype;
  1195. X                  OIDSUBTYPE  OIDsubtype;
  1196. X                   OIDSTATUS  OIDstatus;
  1197. X                     OIDFLAG  OIDflag;
  1198. X                    OIDEXTRA  OIDcomments;
  1199. X                unsigned int  NoElems;
  1200. X                    OIDEXTRA  extra[MAXNOELEMS];
  1201. X               } OIDINFO;
  1202. END_OF_FILE
  1203.   if test 1799 -ne `wc -c <'oid.h'`; then
  1204.     echo shar: \"'oid.h'\" unpacked with wrong size!
  1205.   fi
  1206.   # end of 'oid.h'
  1207. fi
  1208. if test -f 'support.c' -a "${1}" != "-c" ; then 
  1209.   echo shar: Will not clobber existing file \"'support.c'\"
  1210. else
  1211.   echo shar: Extracting \"'support.c'\" \(2150 characters\)
  1212.   sed "s/^X//" >'support.c' <<'END_OF_FILE'
  1213. X#include <stdlib.h>
  1214. X
  1215. X#include "MibCompiler.h"
  1216. X
  1217. Xextern char yytext[];
  1218. Xextern int yylineno;
  1219. X
  1220. Xint yyErrorCnt = {0};
  1221. X
  1222. X
  1223. Xyyerror(char *pStr)
  1224. X {
  1225. X    RestoreErrorMsg("Line: %d  %s (Last token %s)\n",yylineno,pStr,yytext);
  1226. X    yyErrorCnt++;
  1227. X }
  1228. X
  1229. X
  1230. XTYPE *newTypeElement(TYPEofTYPE type,char *pName)
  1231. X {
  1232. X    TYPE *pRc;
  1233. X    pRc = (TYPE *) malloc(sizeof(TYPE));
  1234. X    if( pRc == (TYPE *)0 )
  1235. X        {
  1236. X            RestoreErrorMsg("Out of memory\n");
  1237. X            return((TYPE *)0);
  1238. X        }
  1239. X    memset(pRc,0,sizeof(TYPE));
  1240. X    pRc->Type = type;
  1241. X    switch(type)
  1242. X        {
  1243. X            case TYPENAME : 
  1244. X                            pRc->Data.TypeName = pName;
  1245. X                            break;
  1246. X            case SEQTYPE :
  1247. X            case SEQOFTYPE:
  1248. X                            pRc->Data.TypeList = pName;
  1249. X                            break;
  1250. X            case ENUMINTEGER :
  1251. X                            pRc->Data.EnumList = (LIST *)pName;
  1252. X                            break;
  1253. X            case STRINGTYPE:
  1254. X            case OCTETTYPE:
  1255. X            case RANGEINTEGER :
  1256. X                            memcpy(&pRc->Data.Range,(PAIR *)pName,sizeof(PAIR));
  1257. X                            break;
  1258. X        }
  1259. X    return(pRc);
  1260. X }
  1261. X
  1262. X
  1263. XLIST *newListElement(ENTRYTYPE type,char *pName,int nValue)
  1264. X {
  1265. X    LIST *pRc;
  1266. X    pRc = (LIST *) malloc(sizeof(LIST));
  1267. X    if( pRc == (LIST *)0 )
  1268. X        {
  1269. X            RestoreErrorMsg("Out of memory\n");
  1270. X            return((LIST *)0);
  1271. X        }
  1272. X    memset(pRc,0,sizeof(LIST));
  1273. X    pRc->Type = type;
  1274. X    pRc->Name = pName;
  1275. X    pRc->Number = nValue;
  1276. X    return(pRc);
  1277. X }
  1278. X
  1279. X
  1280. XLIST *LinkToList(LIST *p1,LIST *p2)
  1281. X {
  1282. X    LIST *pTemp = p1;
  1283. X    while( pTemp->Next ) pTemp = pTemp->Next;
  1284. X    pTemp->Next = p2;
  1285. X    return(p1);
  1286. X }
  1287. X
  1288. X
  1289. XTYPE *LinkToType(TYPE *p1,TYPE *p2)
  1290. X {
  1291. X    TYPE *pTemp = p1;
  1292. X    while( pTemp->Next ) pTemp = pTemp->Next;
  1293. X    pTemp->Next = p2;
  1294. X    return(p1);
  1295. X }
  1296. X
  1297. X
  1298. Xchar *OIDListToString(LIST *pL)
  1299. X {
  1300. X    static char buffer[128];
  1301. X    char *pStr;
  1302. X    for( pStr = buffer; pL; pL = (LIST *)pL->Next )
  1303. X        {
  1304. X            sprintf(pStr,"%d",pL->Number);
  1305. X            pStr += strlen(pStr);
  1306. X            if( pL->Next ) *pStr++ = '.';
  1307. X        }
  1308. X    return(buffer);
  1309. X }
  1310. END_OF_FILE
  1311.   if test 2150 -ne `wc -c <'support.c'`; then
  1312.     echo shar: \"'support.c'\" unpacked with wrong size!
  1313.   fi
  1314.   # end of 'support.c'
  1315. fi
  1316. if test -f 'symbol.c' -a "${1}" != "-c" ; then 
  1317.   echo shar: Will not clobber existing file \"'symbol.c'\"
  1318. else
  1319.   echo shar: Extracting \"'symbol.c'\" \(601 characters\)
  1320.   sed "s/^X//" >'symbol.c' <<'END_OF_FILE'
  1321. X#include <stdio.h>
  1322. X#include <stdlib.h>
  1323. X#include <string.h>
  1324. X
  1325. X#include "MibCompiler.h"
  1326. X#include "symbol.h"
  1327. X
  1328. X
  1329. Xstatic SYMBOL *(HeadSymbol[MAXSYMBOLTABLES]) = {0,};
  1330. X
  1331. X
  1332. XSYMBOL *GetNextSymbol(SYMBOL *pSym,int nWhich)
  1333. X {
  1334. X    return( pSym ? (SYMBOL *)pSym->Next : HeadSymbol[nWhich] );
  1335. X }
  1336. X
  1337. X
  1338. XSYMBOL *FindSymbol(char *pName,int nWhich)
  1339. X {
  1340. X    SYMBOL *pS;
  1341. X    pS = HeadSymbol[nWhich];
  1342. X    for( ; pS && strcmp(pS->SymbolName,pName); pS = (SYMBOL *)pS->Next ) ;
  1343. X    return(pS);
  1344. X }
  1345. X
  1346. X
  1347. Xvoid AddToSymbolTable(SYMBOL *pS,int nWhich)
  1348. X {
  1349. X    pS->Next = (struct symbol *) HeadSymbol[nWhich];
  1350. X    HeadSymbol[nWhich] = pS;
  1351. X }
  1352. END_OF_FILE
  1353.   if test 601 -ne `wc -c <'symbol.c'`; then
  1354.     echo shar: \"'symbol.c'\" unpacked with wrong size!
  1355.   fi
  1356.   # end of 'symbol.c'
  1357. fi
  1358. if test -f 'symbol.h' -a "${1}" != "-c" ; then 
  1359.   echo shar: Will not clobber existing file \"'symbol.h'\"
  1360. else
  1361.   echo shar: Extracting \"'symbol.h'\" \(633 characters\)
  1362.   sed "s/^X//" >'symbol.h' <<'END_OF_FILE'
  1363. Xtypedef struct symbol {
  1364. X                        struct symbol *Next;
  1365. X                                  int  DefinedLineNo;
  1366. X                                 char *SymbolName;
  1367. X                                 LIST *SymbolValue;
  1368. X                      } SYMBOL;
  1369. X
  1370. X/* List of defined Symbol Tables in the system... */
  1371. X#define OIDTABLE    0
  1372. X#define    ARRAYTABLE    1
  1373. X#define NEWTYPES    2
  1374. X#define ROWTABLE    3
  1375. X
  1376. X#define MAXSYMBOLTABLES    4
  1377. X
  1378. X
  1379. X#if defined(__STDC__)
  1380. XSYMBOL *FindSymbol(char *,int);
  1381. Xvoid AddToSymbolTable(SYMBOL *,int);
  1382. XSYMBOL *GetNextSymbol(SYMBOL *,int);
  1383. X#else
  1384. XSYMBOL *FindSymbol();
  1385. Xvoid AddToSymbolTable();
  1386. XSYMBOL *GetNextSymbol();
  1387. X#endif
  1388. X
  1389. END_OF_FILE
  1390.   if test 633 -ne `wc -c <'symbol.h'`; then
  1391.     echo shar: \"'symbol.h'\" unpacked with wrong size!
  1392.   fi
  1393.   # end of 'symbol.h'
  1394. fi
  1395. if test -f 'version.c' -a "${1}" != "-c" ; then 
  1396.   echo shar: Will not clobber existing file \"'version.c'\"
  1397. else
  1398.   echo shar: Extracting \"'version.c'\" \(35 characters\)
  1399.   sed "s/^X//" >'version.c' <<'END_OF_FILE'
  1400. Xchar *Version = "Version 1.3a\n";
  1401. X
  1402. END_OF_FILE
  1403.   if test 35 -ne `wc -c <'version.c'`; then
  1404.     echo shar: \"'version.c'\" unpacked with wrong size!
  1405.   fi
  1406.   # end of 'version.c'
  1407. fi
  1408. echo shar: End of archive 2 \(of 2\).
  1409. cp /dev/null ark2isdone
  1410. MISSING=""
  1411. for I in 1 2 ; do
  1412.     if test ! -f ark${I}isdone ; then
  1413.     MISSING="${MISSING} ${I}"
  1414.     fi
  1415. done
  1416. if test "${MISSING}" = "" ; then
  1417.     echo You have unpacked both archives.
  1418.     rm -f ark[1-9]isdone
  1419. else
  1420.     echo You still must unpack the following archives:
  1421.     echo "        " ${MISSING}
  1422. fi
  1423. exit 0
  1424. exit 0 # Just in case...
  1425.