summaryrefslogtreecommitdiff
path: root/ex.c
blob: 14c5c329fb2ecb20ab93a3b2efb0aa4c97f4e957 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define _XOPEN_SOURCE 700
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
	int visual = 0;
	const char *options = "rRsvc:t:w:";
	if (!strcmp(basename(argv[0]), "vi")) {
		options = "rRc:t:w:";
		visual = 1;
	}

	char *command = NULL;
	int recovery = 0;
	int readonly = 0;
	int batch = 0;
	char *tag = NULL;
	int window = 0;

	int c;
	while ((c = getopt(argc, argv, options)) != -1) {
		switch (c) {
		case 'c':
			command = optarg;
			break;

		case 'r':
			recovery = 1;
			break;

		case 'R':
			readonly = 1;
			break;

		case 's':
			batch = 1;
			break;

		case 't':
			tag = optarg;
			break;

		case 'v':
			visual = 1;
			break;

		case 'w':
			window = atoi(optarg);
			break;

		default:
			return 1;
		}
	}

	printf("starting in %s mode\n", visual ? "visual" : "line");
	printf("tag: %s\n", tag ? tag : "-");
	printf("command: %s\n", command ? command : "-");

	return 0;
}