29 lines
419 B
C
29 lines
419 B
C
|
#include <stdbool.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
extern char *optarg;
|
||
|
char *f_host;
|
||
|
|
||
|
int parse(int argc, char **argv) {
|
||
|
char opt;
|
||
|
bool h;
|
||
|
|
||
|
while ((opt = getopt(argc, argv, "h:")) != EOF) {
|
||
|
switch (opt) {
|
||
|
case 'h':
|
||
|
f_host = optarg;
|
||
|
h = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!h) {
|
||
|
printf("Please provide all arguments.\n");
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
return optind;
|
||
|
}
|