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