loading ruby scripts specified at command line
authorMartin Willi <martin@strongswan.org>
Wed, 9 Jul 2008 12:18:06 +0000 (12:18 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 9 Jul 2008 12:18:06 +0000 (12:18 -0000)
src/dumm/irdumm.c

index 16f7014..a3d392a 100644 (file)
@@ -587,8 +587,9 @@ static void template_init()
  */
 int main(int argc, char *argv[])
 {      
-       int state;
+       int state, i;
        struct sigaction action;
+       char buf[512];
        
        ruby_init();
        ruby_init_loadpath();
@@ -616,9 +617,23 @@ int main(int argc, char *argv[])
        sigaction(SIGTERM, &action, NULL);
        sigaction(SIGSEGV, &action, NULL);
        sigaction(SIGHUP, &action, NULL);
-
-       rb_require("irb");
+       
        rb_eval_string_protect("include Dumm", &state);
+       if (state)
+       {
+               rb_p(ruby_errinfo);
+       }
+       for (i = 1; i < argc; i++)
+       {
+               snprintf(buf, sizeof(buf), "load \"%s\"", argv[i]);
+               printf("%s\n", buf);
+               rb_eval_string_protect(buf, &state);
+               if (state)
+               {
+                       rb_p(ruby_errinfo);
+               }
+       }
+       rb_require("irb");
        rb_eval_string_protect("IRB.start", &state);
        if (state)
        {