diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-04-05 20:50:28 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-04-05 20:50:28 -0400 |
commit | 344b1d241863cdee4ae645d1d02df48bf905af3f (patch) | |
tree | d2ee3b8285818fe95a3c9c728dca323511bdbf5e /ex.c |
outline
Diffstat (limited to 'ex.c')
-rw-r--r-- | ex.c | 65 |
1 files changed, 65 insertions, 0 deletions
@@ -0,0 +1,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; +} |