7543e6bd624a2b0235d596d86a9906d95d516ea3
[strongswan.git] / src / dumm / irdumm.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #undef PACKAGE_NAME
17 #undef PACKAGE_TARNAME
18 #undef PACKAGE_VERSION
19 #undef PACKAGE_STRING
20 #undef PACKAGE_BUGREPORT
21 #undef PACKAGE_URL
22 #include <ruby.h>
23
24 /**
25 * main routine, parses args and reads from console
26 */
27 int main(int argc, char *argv[])
28 {
29 int state, i;
30 char buf[512];
31
32 ruby_init();
33 ruby_init_loadpath();
34
35 rb_eval_string_protect("require 'dumm' and include Dumm", &state);
36 if (state)
37 {
38 rb_p(ruby_errinfo);
39 printf("Please install the ruby extension first!\n");
40 }
41 for (i = 1; i < argc; i++)
42 {
43 snprintf(buf, sizeof(buf), "load \"%s\"", argv[i]);
44 printf("%s\n", buf);
45 rb_eval_string_protect(buf, &state);
46 if (state)
47 {
48 rb_p(ruby_errinfo);
49 }
50 }
51 rb_require("irb");
52 rb_require("irb/completion");
53 rb_eval_string_protect("IRB.start", &state);
54 if (state)
55 {
56 rb_p(ruby_errinfo);
57 }
58
59 ruby_finalize();
60 return 0;
61 }
62