1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* Language stuff generator for win32.
*
* (C) 2003-2013 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
* Written by Dominick Meglio <codemastr@unrealircd.com>
*
*/
#include <string.h>
#include <stdio.h>
char *strip(char *str)
{
char *c;
if ((c = strchr(str,'\n')))
*c = 0;
if ((c = strchr(str,'\r')))
*c = 0;
return str;
}
int main(int argc, char *argv[])
{
if (argc < 2)
exit(1);
/* Build the index file */
if (!strcmp(argv[1], "index"))
{
FILE *fd = fopen("en_us.l", "rb");
FILE *fdout = fopen("index", "wb");
char buf[1024];
if (!fd || !fdout)
exit(2);
while (fgets(buf, 1023, fd))
{
if (isupper(*buf))
fprintf(fdout, "%s", buf);
}
fclose(fd);
fclose(fdout);
}
/* Build the language.h file */
else if (!strcmp(argv[1], "language.h"))
{
FILE *fd = fopen("index", "r");
FILE *fdout = fopen("language.h", "w");
char buf[1024];
int i = 0;
if (!fd || !fdout)
exit(2);
fprintf(stderr, "Generating language.h... ");
while (fgets(buf, 1023, fd)) {
fprintf(fdout, "#define %-32s %d\n", strip(buf), i++);
}
fprintf(fdout, "#define NUM_STRINGS %d\n", i);
fprintf(stderr, "%d strings\n", i);
fclose(fd);
fclose(fdout);
}
return 0;
}
|