diff --git a/ext/tox/extconf.rb b/ext/tox/extconf.rb index b681d67..0b258bf 100755 --- a/ext/tox/extconf.rb +++ b/ext/tox/extconf.rb @@ -12,5 +12,6 @@ have_library LIBTOXCORE, 'tox_get_savedata_size' and have_library LIBTOXCORE, 'tox_get_savedata' and have_library LIBTOXCORE, 'tox_self_get_address' and have_library LIBTOXCORE, 'tox_bootstrap' and +have_library LIBTOXCORE, 'tox_kill' and create_makefile "#{NAME}/#{NAME}" or exit(1) diff --git a/ext/tox/tox.c b/ext/tox/tox.c index 6eebb69..5d5adba 100644 --- a/ext/tox/tox.c +++ b/ext/tox/tox.c @@ -30,6 +30,7 @@ static VALUE cTox_initialize(VALUE self, VALUE options); static VALUE cTox_savedata(VALUE self); static VALUE cTox_id(VALUE self); static VALUE cTox_bootstrap(VALUE self, VALUE options); +static VALUE cTox_kill(VALUE self); typedef struct Tox_Options cTox_cOptions_; @@ -47,6 +48,7 @@ void Init_tox() rb_define_method(cTox, "savedata", cTox_savedata, 0); rb_define_method(cTox, "id", cTox_id, 0); rb_define_method(cTox, "bootstrap", cTox_bootstrap, 1); + rb_define_method(cTox, "kill", cTox_kill, 0); cTox_cOptions = rb_define_class_under(cTox, "Options", rb_cObject); rb_define_alloc_func(cTox_cOptions, cTox_cOptions_alloc); @@ -182,6 +184,17 @@ VALUE cTox_bootstrap(const VALUE self, const VALUE options) return Qfalse; } +VALUE cTox_kill(const VALUE self) +{ + cTox_ *tox; + + Data_Get_Struct(self, cTox_, tox); + + tox_kill(tox->tox); + + return self; +} + /****************************************************************************** * Tox::Options ******************************************************************************/