From: nishi Date: Wed, 24 Apr 2024 00:11:29 +0000 (+0000) Subject: configgen X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=63278f2807ed74412c3210ca405ec10183ec0603;p=serenade.git configgen git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@25 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- diff --git a/Tool/configgen.c b/Tool/configgen.c index 1b6ac5f..0df50ca 100644 --- a/Tool/configgen.c +++ b/Tool/configgen.c @@ -30,6 +30,7 @@ #include #include +#include #include char choice[256]; @@ -48,6 +49,10 @@ void show_dialog(int n) { int main(int argc, char** argv) { FILE* out = stdout; bool load = false; + bool def = false; + + int stack_size = 1024; + if(argv[1] != NULL) { out = fopen(argv[1], "w"); if(out != NULL) { @@ -56,8 +61,25 @@ int main(int argc, char** argv) { fprintf(stderr, "%s: %s: couldn't open the file\n", argv[0], argv[1]); return 1; } + if(argv[2] != NULL && strcmp(argv[2], "default") == 0){ + def = true; + } } fprintf(out, "/* Autogenerated config */\n"); + if(def){ + int n; + for(n = 0; asks[n * 4] != NULL; n++){ + fprintf(out, "#%s %s\n", asks[n * 4 + 1][0] == 'y' ? "define" : "undef", asks[n * 4 + 2]); + } + fprintf(out, "#define PARSER_STACK_SIZE %d\n", stack_size); + fprintf(out, "#define SUPPORT \""); + for(n = 0; asks[n * 4] != NULL; n++) { + if(n > 0) fprintf(out, " "); + fprintf(out, "%c%s", asks[n * 4 + 1][0] == 'y' ? '+' : '-', asks[n * 4]); + } + fprintf(out, "\"\n"); + return 0; + } char c; char oldc; bool nl = false; @@ -81,7 +103,6 @@ int main(int argc, char** argv) { nl = true; } } - int stack_size = 1024; fprintf(stderr, "[recommended: 1024] Parser stack size? "); fflush(stderr); scanf("%d", &stack_size);