/* * Name: find_obj.c * * Description: * This routine locates all network objects in the objects.C file, and * passes them one-by-one to the parse_obj() function to be inserted * into the proper structure. */ #include "objects.h" /* Name: find_obj(char *objectsC) * * Description: This routine is responsible for finding the next netobj, * adding it to an array, and passing it to be inserted into the * object structure. * */ void find_obj(char *objectsC) { /* Array to hold a line */ char buf[LNSIZE]; /* Number of objects in the linked list */ int objcount=0; /* Current object name and the current line */ char *objname, *lineptr; /* counter for main loop and object or services */ int substack=0; /* loop counter */ int i; /* file pointer to objects.C file */ FILE *fp; /* Allocate a line to contain the label */ if((objname = malloc(LNSIZE)) == NULL) { fprintf(stderr,"find_netobj: malloc failed\n"); exit(1); } /* Open objects.C file for parsing */ if((fp = fopen(objectsC,"r")) == NULL) { fprintf(stderr,"find_netobj: cannot open %s\n",objectsC); exit(1); } /* * Main loop. This loop runs thru the objects.C file from the beginning, * checking each line to determine whether it is the objects body or * services body. */ while((fgets(buf,LNSIZE,fp)) != NULL) { /* Have we found the beginning of the objects? */ if(strstr(buf,":netobj (netobj")) { substack = 1; /* continue until all objects are read and entered */ while(substack > 0) { fgets(buf,LNSIZE,fp); for(i=0;i