aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-05-11 17:19:36 +0200
committerMartin Willi <martin@strongswan.org>2009-05-11 17:19:36 +0200
commit47a9a48f5bf69ac50d511ba3762dd11b2b9c20b4 (patch)
tree20b3abaf26ce6118a8c3beb114f0e846f04af34f /src
parent608046c09c66797c9068f2f741df7c4d0100c2d3 (diff)
downloadstrongswan-47a9a48f5bf69ac50d511ba3762dd11b2b9c20b4.tar.bz2
strongswan-47a9a48f5bf69ac50d511ba3762dd11b2b9c20b4.tar.xz
ruby bindings for template enumerator
Diffstat (limited to 'src')
-rw-r--r--src/dumm/ext/dumm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/dumm/ext/dumm.c b/src/dumm/ext/dumm.c
index 59fbcd3c9..3c860bb68 100644
--- a/src/dumm/ext/dumm.c
+++ b/src/dumm/ext/dumm.c
@@ -651,12 +651,31 @@ static VALUE template_unload(VALUE class)
return class;
}
+static VALUE template_each(int argc, VALUE *argv, VALUE class)
+{
+ enumerator_t *enumerator;
+ char *template;
+
+ if (!rb_block_given_p())
+ {
+ rb_raise(rb_eArgError, "must be called with a block");
+ }
+ enumerator = dumm->create_template_enumerator(dumm);
+ while (enumerator->enumerate(enumerator, &template))
+ {
+ rb_yield(rb_str_new2(template));
+ }
+ enumerator->destroy(enumerator);
+ 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);
+ rb_define_singleton_method(rbc_template, "each", template_each, -1);
}
/**