summaryrefslogtreecommitdiff
path: root/lang/langtool.c
diff options
context:
space:
mode:
authorsjaz <sjaz@5417fbe8-f217-4b02-8779-1006273d7864>2009-01-01 12:00:20 +0000
committersjaz <sjaz@5417fbe8-f217-4b02-8779-1006273d7864>2009-01-01 12:00:20 +0000
commitc777c8d9aa7cd5c2e9a399727a7fa9985a77fb1c (patch)
tree9e996ae4a1bbb833cec036c5cd4d87a590149e85 /lang/langtool.c
Anope Stable Branch
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/stable@1902 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'lang/langtool.c')
-rw-r--r--lang/langtool.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/lang/langtool.c b/lang/langtool.c
new file mode 100644
index 000000000..f97f29b99
--- /dev/null
+++ b/lang/langtool.c
@@ -0,0 +1,74 @@
+/* Language stuff generator for win32.
+ *
+ * (C) 2003-2008 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter 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;
+
+}