-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_args.c
38 lines (36 loc) · 1.03 KB
/
parse_args.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* authors: Dillon O'Leary
* Ezra Boley
*/
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include "parse_args.h"
#include <string.h>
void parse_args(int argc, char *argv[], bool *fflag, char *filename) {
char option;
while ((option = getopt(argc, argv, "f:")) != -1) {
switch (option) {
case 'f':
for (int i = 0; i < MAX_ARG_LENGTH; i++) {
filename[i] = optarg[i];
if (filename[i] == '\0') {
*fflag = true;
break;
}
}
if (!*fflag)
printf("ERROR File path too long, reverting to standard makefile name search\n");
break;
case '?':
printf("WOW AN ARG?!\n");
exit(1);
break;
default:
printf("Unrecognized command line arg, exiting...\n");
exit(1);
}
}
}