Example #1
0
/*
 * Parse file, calling action specific functions for:
 * 1) Lines containing !E
 * 2) Lines containing !I
 * 3) Lines containing !D
 * 4) Lines containing !F
 * 5) Lines containing !P
 * 6) Lines containing !C
 * 7) Default lines - lines not matching the above
 */
static void parse_file(FILE *infile)
{
	char line[MAXLINESZ];
	char * s;
	while (fgets(line, MAXLINESZ, infile)) {
		if (line[0] == '!') {
			s = line + 2;
			switch (line[1]) {
				case 'E':
					while (*s && !isspace(*s)) s++;
					*s = '\0';
					externalfunctions(line+2);
					break;
				case 'I':
					while (*s && !isspace(*s)) s++;
					*s = '\0';
					internalfunctions(line+2);
					break;
				case 'D':
					while (*s && !isspace(*s)) s++;
                                        *s = '\0';
                                        symbolsonly(line+2);
                                        break;
				case 'F':
					/* filename */
					while (*s && !isspace(*s)) s++;
					*s++ = '\0';
                                        /* function names */
					while (isspace(*s))
						s++;
					singlefunctions(line +2, s);
					break;
				case 'P':
					/* filename */
					while (*s && !isspace(*s)) s++;
					*s++ = '\0';
					/* DOC: section name */
					while (isspace(*s))
						s++;
					docsection(line + 2, s);
					break;
				case 'C':
					while (*s && !isspace(*s)) s++;
					*s = '\0';
					if (findall)
						findall(line+2);
					break;
				default:
					defaultline(line);
			}
		}
		else {
			defaultline(line);
		}
	}
	fflush(stdout);
}
Example #2
0
/*
 * Parse file, calling action specific functions for:
 * 1) Lines containing !E
 * 2) Lines containing !I
 * 3) Lines containing !D
 * 4) Lines containing !F
 * 5) Lines containing !P
 * 6) Lines containing !C
 * 7) Default lines - lines not matching the above
 */
static void parse_file(FILE *infile)
{
	char line[MAXLINESZ];
	char *p, *s;
	while (fgets(line, MAXLINESZ, infile)) {
		p = is_directive(line);
		if (!p) {
			defaultline(line);
			continue;
		}

		switch (*p++) {
		case 'E':
			chomp(p);
			externalfunctions(p);
			break;
		case 'I':
			chomp(p);
			internalfunctions(p);
			break;
		case 'D':
			chomp(p);
			symbolsonly(p);
			break;
		case 'F':
			/* filename */
			s = chomp(p);
			/* function names */
			while (isspace(*s))
				s++;
			singlefunctions(p, s);
			break;
		case 'P':
			/* filename */
			s = chomp(p);
			/* DOC: section name */
			while (isspace(*s))
				s++;
			docsection(p, s);
			break;
		case 'C':
			chomp(p);
			if (findall)
				findall(p);
			break;
		default:
			defaultline(line);
		}
	}
	fflush(stdout);
}