00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "defs.h"
00022
00023 int main(int argc, char *argv[])
00024 {
00025 FILE *in, *out;
00026 char *file, s[100], cat[100], *macro, *desc;
00027 int len;
00028
00029 if (argc < 2)
00030 file = "/aup/common/macrostr.txt";
00031 else
00032 file = argv[1];
00033 ec_null( in = fopen(file, "r") )
00034 ec_null( out = fopen("/aup/common/macrostr.incl", "w") )
00035 while (fgets(s, sizeof(s), in) != NULL) {
00036 for (len = strlen(s); len > 0 && isspace((int)s[len - 1]); len--)
00037 ;
00038 s[len] = '\0';
00039 if (s[0] == '#') {
00040 fprintf(out, "%s\n", s);
00041 continue;
00042 }
00043 if (s[len - 1] == ':') {
00044 strcpy(cat, s);
00045 cat[len - 1] = '\0';
00046 }
00047 else {
00048 macro = strtok(s, " \t");
00049 if (macro == NULL)
00050 continue;
00051 desc = strtok(NULL, "\t");
00052 if (desc == NULL)
00053 desc = "";
00054 else
00055 while (isspace((int)*desc))
00056 desc++;
00057 fprintf(out, "{\"%s\", (intptr_t)%s, \"%s\", \"%s\"},\n",
00058 cat, macro, macro, desc);
00059 }
00060 }
00061 exit(EXIT_SUCCESS);
00062
00063 EC_CLEANUP_BGN
00064 exit(EXIT_FAILURE);
00065 EC_CLEANUP_END
00066 }