Add command line source/header files.

This commit is contained in:
gamemann
2021-11-12 16:38:10 +00:00
parent d4d361d9a5
commit ad48c3c7f7
2 changed files with 63 additions and 0 deletions

52
src/cmdline.c Normal file
View File

@@ -0,0 +1,52 @@
#include <stdio.h>
#include <getopt.h>
#include "cmdline.h"
const struct option opts[] =
{
{"config", required_argument, NULL, 'c'},
{"offload", no_argument, NULL, 'o'},
{"list", no_argument, NULL, 'l'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
void parsecommandline(struct cmdline *cmd, int argc, char *argv[])
{
int c;
while ((c = getopt_long(argc, argv, "c:lho", opts, NULL)) != -1)
{
switch (c)
{
case 'c':
cmd->cfgfile = optarg;
break;
case 'o':
cmd->offload = 1;
break;
case 'l':
cmd->list = 1;
break;
case 'h':
cmd->help = 1;
break;
case '?':
fprintf(stderr, "Missing argument option...\n");
break;
default:
break;
}
}
}