CFLAGS = -Wall -Wextra -g
LIBS = -lcurl
SRC = src/main.c src/cpu.c src/downloader.c src/cli.c
-OBJ = build/main.o build/cpu.o build/downloader.o src/cli.o
+OBJ = build/main.o build/cpu.o build/downloader.o build/cli.o
RES = build/Thoryum
all: setup $(OBJ) build
#include "cli.h"
extern char *optarg; // What the hell is that glibc ???
+extern int optind, opterr, optopt;
+
+void check_help(int argc, char **argv) {
+ for (int i = 1; i < argc; i++)
+ if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
+ print_help();
+ exit(EXIT_SUCCESS);
+ }
+}
struct ctx *init_ctx(int argc, char **argv) {
+ check_help(argc, argv);
+
struct ctx *ctx = calloc(1, sizeof(struct ctx));
int opt;
return NULL;
}
+void print_ctx(struct ctx *ctx) {
+ printf(
+ "Thoryum context:\n"
+ "Mode = %s\n"
+ "Install location = '%s'\n"
+ "Silent = %s\n",
+ ctx->mode ? "UPDATE" : "NORMAL",
+ ctx->install_loc,
+ ctx->silent ? "YES" : "NOPE"
+ );
+}
+
void print_help() {
printf(
"Usage: thoryum [options]\n"
int silent;
};
+struct ctx *init_ctx(int argc, char **argv);
+void *free_ctx(struct ctx *ctx);
+void print_ctx(struct ctx *ctx);
void print_help();
#endif
wait(NULL);
}
-int main() {
+int main(int argc, char **argv) {
printf("Hello this is Thoryum ;)\n");
enum CPU_opti opti = CPU_fetch_opti();
char opti_name[5] = {0};
*/
//printf("Latest version url : '%s,'\n",DL_get_latest_version_url("AVX.zip"));
//patch_desktop_file(".");
- print_help();
+ struct ctx *ctx = init_ctx(argc, argv);
+ print_ctx(ctx);
+ ctx = free_ctx(ctx);
}