2022-04-26 19:36:15 +02:00
|
|
|
#include "arg.h"
|
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
Args parseArgs(int argc, char** argv) {
|
|
|
|
Args a;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
static struct option long_options[] = {
|
|
|
|
{"debug-log", no_argument, &a.debugLog, 1},
|
2023-09-02 11:52:18 +02:00
|
|
|
{"access", no_argument, &a.access, 1},
|
2022-04-26 19:36:15 +02:00
|
|
|
{0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
/* getopt_long stores the option index here. */
|
|
|
|
int option_index = 0;
|
|
|
|
|
|
|
|
int c = getopt_long (argc, argv, "", long_options, &option_index);
|
|
|
|
|
|
|
|
/* Detect the end of the options. */
|
|
|
|
if (c == -1) break;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 0:
|
|
|
|
/* If this option set a flag, do nothing else now. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
/* getopt_long already printed an error message. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|