File: cmdparse.c

package info (click to toggle)
oddjob 0.34.7-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,520 kB
  • sloc: ansic: 6,003; sh: 4,517; makefile: 258; python: 3
file content (34 lines) | stat: -rw-r--r-- 667 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <sys/types.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include "../../src/util.h"
int
main(int argc, char **argv)
{
	char buf[LINE_MAX], **args;
	const char *p;
	int i, line;
	line = 1;
	while (fgets(buf, sizeof(buf), stdin) != NULL) {
		buf[strcspn(buf, "\r\n")] = '\0';
		if (strlen(buf) > 0) {
			fprintf(stdout, "%d -----\n", line++);
		}
		p = NULL;
		args = oddjob_parse_args(buf, &p);
		if (p != NULL) {
			fprintf(stderr, "%s\n", p);
		} else {
			if (args != NULL) {
				for (i = 0; args[i] != NULL; i++) {
					fprintf(stdout, "%s\n", args[i]);
				}
			}
		}
		if (args != NULL) {
			oddjob_free_args(args);
		}
	}
	return 0;
}