aboutsummaryrefslogtreecommitdiffstats
path: root/src/dumm/irdumm.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-07-09 11:43:48 +0000
committerMartin Willi <martin@strongswan.org>2008-07-09 11:43:48 +0000
commita9c46ace99b455d04a9934d83d7d1693019cde07 (patch)
tree936bd43dc10bd82f216d48e919b8a64d25b82966 /src/dumm/irdumm.c
parentee70c94835ca6e3ec5862dd56888796a14d85fb8 (diff)
downloadstrongswan-a9c46ace99b455d04a9934d83d7d1693019cde07.tar.bz2
strongswan-a9c46ace99b455d04a9934d83d7d1693019cde07.tar.xz
ruby bindings/fixes for template loading
Diffstat (limited to 'src/dumm/irdumm.c')
-rw-r--r--src/dumm/irdumm.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/dumm/irdumm.c b/src/dumm/irdumm.c
index 9b5e02109..16f7014bc 100644
--- a/src/dumm/irdumm.c
+++ b/src/dumm/irdumm.c
@@ -34,6 +34,7 @@ VALUE rbm_dumm;
VALUE rbc_guest;
VALUE rbc_bridge;
VALUE rbc_iface;
+VALUE rbc_template;
/**
* Guest invocation callback
@@ -179,11 +180,7 @@ static VALUE guest_stop(VALUE self)
guest_t *guest;
Data_Get_Struct(self, guest_t, guest);
-
- if (!guest->stop(guest, NULL))
- {
- rb_raise(rb_eRuntimeError, "stopping guest failed");
- }
+ guest->stop(guest, NULL);
return self;
}
@@ -355,7 +352,7 @@ static VALUE bridge_get(VALUE class, VALUE key)
enumerator->destroy(enumerator);
if (!found)
{
- rb_raise(rb_eRuntimeError, "bridgne not found");
+ rb_raise(rb_eRuntimeError, "bridge not found");
}
return Data_Wrap_Struct(class, NULL, NULL, found);
}
@@ -560,6 +557,31 @@ static void iface_init()
rb_include_module(rbc_iface, rb_mEnumerable);
}
+static VALUE template_load(VALUE class, VALUE name)
+{
+ if (!dumm->load_template(dumm, StringValuePtr(name)))
+ {
+ rb_raise(rb_eRuntimeError, "loading template failed");
+ }
+ return class;
+}
+
+static VALUE template_unload(VALUE class)
+{
+ if (!dumm->load_template(dumm, NULL))
+ {
+ rb_raise(rb_eRuntimeError, "unloading template failed");
+ }
+ return class;
+}
+
+static void template_init()
+{
+ rbc_template = rb_define_class_under(rbm_dumm , "Template", rb_cObject);
+ rb_define_singleton_method(rbc_template, "load", template_load, 1);
+ rb_define_singleton_method(rbc_template, "unload", template_unload, 0);
+}
+
/**
* main routine, parses args and reads from console
*/
@@ -583,6 +605,7 @@ int main(int argc, char *argv[])
guest_init();
bridge_init();
iface_init();
+ template_init();
sigemptyset(&action.sa_mask);
action.sa_flags = SA_SIGINFO;