49 lines
807 B
C
49 lines
807 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "argparser.h"
|
|
|
|
void usage() {
|
|
printf("Astrophysics: <option> <param file> [--debug]\n");
|
|
}
|
|
|
|
int getArgs(char *arg) {
|
|
int res = FALSE;
|
|
int i;
|
|
/* List arguments */
|
|
char listArgs[3][BUF_SIZE];
|
|
strcpy(listArgs[0], "-p"); // Projectile
|
|
|
|
for(i = 0; i < 3; i++){
|
|
if(strcmp(listArgs[i], arg) == 0)
|
|
res = TRUE;
|
|
}
|
|
|
|
if(res == FALSE){
|
|
printf("%s: unknown\n", arg);
|
|
usage();
|
|
}
|
|
return res;
|
|
}
|
|
int getArgsOptional(char *arg){
|
|
int res = FALSE;
|
|
int i;
|
|
/* List arguments */
|
|
char listArgs[1][BUF_SIZE];
|
|
strcpy(listArgs[0], "--debug");
|
|
|
|
for(i = 0; i < 1; i++){
|
|
if(strcmp(listArgs[i], arg) == 0)
|
|
res = TRUE;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
int checkParamFileExist(char *path){
|
|
FILE *f = fopen(path, "r");
|
|
|
|
if (f == NULL)
|
|
return -1;
|
|
fclose(f);
|
|
return 0;
|
|
}
|