diff options
author | katherine <ageha@airen-no-jikken.icu> | 2019-06-04 17:52:21 -0700 |
---|---|---|
committer | katherine <ageha@airen-no-jikken.icu> | 2019-06-04 17:52:21 -0700 |
commit | 01209d714d3720cd4aa18edac10a549177c81b1e (patch) | |
tree | 756e2609e85c0fcea9a5bb9af71cf735965ea905 /src/gen.c | |
parent | 233bac703ee5849cb18d02330ccb97038ffc6439 (diff) | |
download | confconf-01209d714d3720cd4aa18edac10a549177c81b1e.tar.gz |
add name-suffix and uthash-header options
Diffstat (limited to 'src/gen.c')
-rw-r--r-- | src/gen.c | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -2,6 +2,7 @@ #include "version.h" #include "parse.h" +#include "opt.h" #include <time.h> #include <assert.h> @@ -28,8 +29,8 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) fprintf(f, "/* generated by %s on %04d-%02d-%02d */\n", VERSION, ti->tm_year + 1900, ti->tm_mon + 1, ti->tm_mday); - fprintf(f, sheaderp1); - fprintf(f, sheaderp2); + fprintf(f, sheadp1); + fprintf(f, sheadp2); if (ar.uses_type[PARSE_TYPE_BOOL]) fprintf(f, sbool); @@ -54,8 +55,10 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) if (ar.uses_type[PARSE_TYPE_DOUBLEL]) fprintf(f, sdoublel); + /* if (ar.uses_array) */ + /* fprintf(f, sarray); */ if (ar.uses_hash) - fprintf(f, shash, pr.location); + fprintf(f, shash, (opt_header_str() ? opt_header_str() : pr.header)); /******** * BODY * @@ -64,10 +67,11 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) fprintf(f, "#ifndef CONFCONF_BODY_%s_H\n" "#define CONFCONF_BODY_%s_H\n\n", - pr.suffix, pr.suffix - ); + (opt_suffix_str() ? opt_suffix_str() : pr.suffix), + (opt_suffix_str() ? opt_suffix_str() : pr.suffix) + ); - /* types */ + /* deftypes */ HASH_ITER(hh, pr.deftypes, dcur, dtmp) { if (!dcur->is_used) continue; @@ -77,14 +81,17 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) (dcur->type == PARSE_DEFTYPE_UNION ? "union" : "struct") ), - dcur->name, pr.suffix); + dcur->name, + (opt_suffix_str() ? opt_suffix_str() : pr.suffix) + ); for (i = 0; i < dcur->member_list_len; i++) { if (dcur->type == PARSE_DEFTYPE_ENUM) { fprintf(f, " CONFCONF_TYPE_%s_%s_%s,\n", dcur->name, dcur->member_name_list[i], - pr.suffix); + (opt_suffix_str() ? opt_suffix_str() : pr.suffix) + ); continue; } @@ -135,9 +142,7 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) fprintf(f, "};\n\n"); } - /* array */ - - /* hash */ + /* hash type */ if (ar.uses_hash) { fprintf(f, "#include %s\n\n" @@ -145,8 +150,8 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) " char *key;\n" " union {\n" "%s%s%s%s%s%s%s%s%s%s%s", - pr.location, - pr.suffix, + (opt_header_str() ? opt_header_str() : pr.header), + (opt_suffix_str() ? opt_suffix_str() : pr.suffix), (ar.uses_type[PARSE_TYPE_HASH_BOOL] ? " bool b;\n" : ""), (ar.uses_type[PARSE_TYPE_HASH_STRING] @@ -177,7 +182,10 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) (dcur->type == PARSE_DEFTYPE_UNION ? "union" : "struct") ), - dcur->name, pr.suffix, dcur->name); + dcur->name, + (opt_suffix_str() ? opt_suffix_str() : pr.suffix), + dcur->name + ); } } fprintf(f, |