From f8f37d42f3b95127bfde0526a4eb7edb486f21b1 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sun, 16 Nov 2025 08:26:03 +0900 Subject: [PATCH] yaep --- include/MDE/CommandLine.h | 25 ------------------------- include/MDE/Foundation.h | 2 +- src/commandline.c | 39 --------------------------------------- 3 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 include/MDE/CommandLine.h delete mode 100644 src/commandline.c diff --git a/include/MDE/CommandLine.h b/include/MDE/CommandLine.h deleted file mode 100644 index de95e8a..0000000 --- a/include/MDE/CommandLine.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __MDE_COMMANDLINE_H__ -#define __MDE_COMMANDLINE_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _MDECommandLine MDECommandLine; - -struct _MDECommandLine { - const char* short_opt; - const char* long_opt; - int need_arg; - void(*call)(const char* arg); -}; - -int MDECommandLineParse(MDECommandLine* param, int count, int argc, char** argv); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/MDE/Foundation.h b/include/MDE/Foundation.h index 0ebdf6f..81070cb 100644 --- a/include/MDE/Foundation.h +++ b/include/MDE/Foundation.h @@ -1,6 +1,6 @@ #ifndef __MDE_FOUNDATION_H__ #define __MDE_FOUNDATION_H__ -#include +#include #endif diff --git a/src/commandline.c b/src/commandline.c deleted file mode 100644 index ed6c880..0000000 --- a/src/commandline.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -int MDECommandLineParse(MDECommandLine* param, int count, int argc, char** argv){ - int i; - for(i = 1; i < argc; i++){ - int j; - for(j = 0; j < count; j++){ - char* s = malloc(1 + strlen(param[j].short_opt) + 1); - char* l = malloc(2 + strlen(param[j].long_opt) + 1); - - strcpy(s, "-"); - strcat(s, param[j].short_opt); - - strcpy(l, "--"); - strcat(s, param[j].long_opt); - - if(strcmp(s, argv[i]) == 0 || strcmp(l, argv[i]) == 0){ - free(l); - free(s); - - if(param[j].need_arg && (i + 1) >= argc){ - fprintf(stderr, "%s: %s needs 1 argument\n", argv[0], argv[i]); - return 1; - }else if(param[j].need_arg){ - param[j].call(argv[++i]); - }else{ - param[j].call(NULL); - } - - break; - }else{ - free(l); - free(s); - } - } - } - - return 0; -}