00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <string.h>
00016 #include <stdio.h>
00017
00018 char *strip(char *str)
00019 {
00020 char *c;
00021 if ((c = strchr(str,'\n')))
00022 *c = 0;
00023 if ((c = strchr(str,'\r')))
00024 *c = 0;
00025 return str;
00026 }
00027
00028 int main(int argc, char *argv[])
00029 {
00030 if (argc < 2)
00031 exit(1);
00032
00033
00034 if (!strcmp(argv[1], "index"))
00035 {
00036 FILE *fd = fopen("en_us.l", "rb");
00037 FILE *fdout = fopen("index", "wb");
00038 char buf[1024];
00039 if (!fd || !fdout)
00040 exit(2);
00041
00042 while (fgets(buf, 1023, fd))
00043 {
00044 if (isupper(*buf))
00045 fprintf(fdout, "%s", buf);
00046 }
00047 fclose(fd);
00048 fclose(fdout);
00049 }
00050
00051 else if (!strcmp(argv[1], "language.h"))
00052 {
00053 FILE *fd = fopen("index", "r");
00054 FILE *fdout = fopen("language.h", "w");
00055 char buf[1024];
00056 int i = 0;
00057
00058 if (!fd || !fdout)
00059 exit(2);
00060
00061 fprintf(stderr, "Generating language.h... ");
00062
00063 while (fgets(buf, 1023, fd)) {
00064 fprintf(fdout, "#define %-32s %d\n", strip(buf), i++);
00065 }
00066
00067 fprintf(fdout, "#define NUM_STRINGS %d\n", i);
00068 fprintf(stderr, "%d strings\n", i);
00069 fclose(fd);
00070 fclose(fdout);
00071 }
00072 return 0;
00073
00074 }