X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/546efe9fbd6c3c651c39b369e97d0835230a0f9f..3f80b5713f755394d2d1a3bc3befb0dd82a19f64:/generate_uudmap.c diff --git a/generate_uudmap.c b/generate_uudmap.c index 6159259..b6307c0 100644 --- a/generate_uudmap.c +++ b/generate_uudmap.c @@ -12,6 +12,46 @@ "hello world" won't port easily to it. */ #include +struct mg_data_raw_t { + unsigned char type; + const char *value; + const char *comment; +}; + +static struct mg_data_raw_t mg_data_raw[] = { +#ifdef WIN32 +# include "..\mg_raw.h" +#else +# include "mg_raw.h" +#endif + {0, 0, 0} +}; + +struct mg_data_t { + const char *value; + const char *comment; +}; + +static struct mg_data_t mg_data[256]; + +static void +format_mg_data(FILE *out, const void *thing, size_t count) { + const struct mg_data_t *p = (const struct mg_data_t *)thing; + + while (1) { + if (p->value) { + fprintf(out, " %s\n %s", p->comment, p->value); + } else { + fputs(" 0", out); + } + ++p; + if (!--count) + break; + fputs(",\n", out); + } + fputc('\n', out); +} + static void format_char_block(FILE *out, const void *thing, size_t count) { const char *block = (const char *)thing; @@ -66,9 +106,11 @@ static char PL_bitcount[256]; int main(int argc, char **argv) { size_t i; int bits; + struct mg_data_raw_t *p = mg_data_raw; - if (argc < 3 || argv[1][0] == '\0' || argv[2][0] == '\0') { - fprintf(stderr, "Usage: %s uudemap.h bitcount.h\n", argv[0]); + if (argc < 4 || argv[1][0] == '\0' || argv[2][0] == '\0' + || argv[3][0] == '\0') { + fprintf(stderr, "Usage: %s uudemap.h bitcount.h mg_data.h\n", argv[0]); return 1; } @@ -97,5 +139,14 @@ int main(int argc, char **argv) { output_to_file(argv[0], argv[2], &format_char_block, (const void *)PL_bitcount, sizeof(PL_bitcount)); + while (p->value) { + mg_data[p->type].value = p->value; + mg_data[p->type].comment = p->comment; + ++p; + } + + output_to_file(argv[0], argv[3], &format_mg_data, + (const void *)mg_data, sizeof(mg_data)/sizeof(mg_data[0])); + return 0; }