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