6 # define ED_VERSION "1.0"
9 #define IS_OPTARG(a, s, l) a[1] == s || \
10 strcmp(a + 1, "-" l) == 0
12 static const char *prg_name;
17 printf(
"%s v%s\n", prg_name, ED_VERSION);
18 printf(
"Copyright (C) 2022 d0p1\n");
19 printf(
"License BSD-3: <https://directory.fsf.org/wiki/License:BSD-3-Clause>\n");
20 printf(
"This is free software: you are free to change and redistribute it.\n");
21 printf(
"There is NO WARRANTY, to the extent permitted by law.\n");
26 usage(FILE *out,
int retval)
28 fprintf(out,
"Usage: %s [OPTION]... [FILE]\n\n", prg_name);
29 fprintf(out,
"Options:\n");
30 fprintf(out,
"\t-h, --help\tdisplay this help and exit\n");
31 fprintf(out,
"\t-V, --version\toutput version information and exit\n");
37 parse_flags(
int argc,
char *
const argv[])
41 for (idx = 0; idx < argc; idx++)
43 if (argv[idx][0] ==
'-')
45 if (IS_OPTARG(argv[idx],
'h',
"help"))
47 usage(stdout, EXIT_SUCCESS);
49 else if (IS_OPTARG(argv[idx],
'V',
"version"))
55 usage(stderr, EXIT_FAILURE);
66 usage(stderr, EXIT_FAILURE);
73 main(
int argc,
char *
const argv[])
80 idx = parse_flags(argc, argv);
82 return (EXIT_SUCCESS);