diff options
author | Martin Willi <martin@strongswan.org> | 2008-07-09 11:43:48 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-07-09 11:43:48 +0000 |
commit | a9c46ace99b455d04a9934d83d7d1693019cde07 (patch) | |
tree | 936bd43dc10bd82f216d48e919b8a64d25b82966 /src/dumm | |
parent | ee70c94835ca6e3ec5862dd56888796a14d85fb8 (diff) | |
download | strongswan-a9c46ace99b455d04a9934d83d7d1693019cde07.tar.bz2 strongswan-a9c46ace99b455d04a9934d83d7d1693019cde07.tar.xz |
ruby bindings/fixes for template loading
Diffstat (limited to 'src/dumm')
-rw-r--r-- | src/dumm/cowfs.c | 5 | ||||
-rw-r--r-- | src/dumm/guest.h | 3 | ||||
-rw-r--r-- | src/dumm/irdumm.c | 35 |
3 files changed, 33 insertions, 10 deletions
diff --git a/src/dumm/cowfs.c b/src/dumm/cowfs.c index f7984635a..88041811e 100644 --- a/src/dumm/cowfs.c +++ b/src/dumm/cowfs.c @@ -709,8 +709,9 @@ static int cowfs_write(const char *path, const char *buf, size_t size, rel(&path); - fd = get_rd(path); - if (fd == this->master_fd) + fd = get_wr(path); + if (fd == this->master_fd || + (this->over_fd > 0 && fd == this->host_fd)) { fd = copy(path); if (fd < 0) diff --git a/src/dumm/guest.h b/src/dumm/guest.h index 1109622f9..98e5ebb44 100644 --- a/src/dumm/guest.h +++ b/src/dumm/guest.h @@ -107,9 +107,8 @@ struct guest_t { * @brief Kill the guest. * * @param idle idle function to call while waiting to termination - * @return TRUE if guest was running and killed */ - bool (*stop) (guest_t *this, idle_function_t idle); + void (*stop) (guest_t *this, idle_function_t idle); /** * @brief Create a new interface in the current scenario. 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; |