initial commit
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
#include "args.h"
|
||||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void print_help(int status_code) {
|
||||
puts(PACKAGE " " VERSION "\n\n"
|
||||
"usage: " PACKAGE " "
|
||||
"[--help] "
|
||||
"[-v] "
|
||||
"\n\n"
|
||||
"Fusion Of Real-time Generative Effects.\n\n"
|
||||
"options:\n"
|
||||
" --help show this help message and exit\n"
|
||||
" -v, --version print version\n");
|
||||
exit(status_code);
|
||||
}
|
||||
|
||||
void invalid_arg(char *arg) {
|
||||
fprintf(stderr, "invalid argument: '%s'\n\n", arg);
|
||||
print_help(1);
|
||||
}
|
||||
|
||||
bool is_arg(char *arg, char *ref) { return strcoll(arg, ref) == 0; }
|
||||
|
||||
char *split_arg_value(char *arg) {
|
||||
strtok(arg, "=");
|
||||
return strtok(NULL, "=");
|
||||
}
|
||||
|
||||
parameters parse_args(int argc, char **argv) {
|
||||
parameters params;
|
||||
|
||||
int i;
|
||||
char *arg;
|
||||
char *value;
|
||||
for (i = 1; i < argc; i++) {
|
||||
arg = argv[i];
|
||||
value = split_arg_value(arg);
|
||||
if (is_arg(arg, "--help")) {
|
||||
print_help(0);
|
||||
} else if (is_arg(arg, "-v") || is_arg(arg, "--version")) {
|
||||
puts(PACKAGE " " VERSION);
|
||||
exit(0);
|
||||
} else {
|
||||
invalid_arg(arg);
|
||||
}
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "types.h"
|
||||
|
||||
#ifndef ARGS_H
|
||||
#define ARGS_H
|
||||
|
||||
parameters parse_args(int argc, char **argv);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#ifndef PACKAGE
|
||||
#define PACKAGE "forge"
|
||||
#endif
|
||||
|
||||
#ifndef VERSION
|
||||
#define VERSION "(dev)"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "args.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
parameters params;
|
||||
params = parse_args(argc, argv);
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#endif
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
struct Parameters {
|
||||
// TODO
|
||||
};
|
||||
|
||||
typedef struct Parameters parameters;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user