add net_route_list wrapper

This commit is contained in:
Doug MacEachern 2007-09-24 03:21:29 +00:00
parent 6921e887e0
commit d33284b094
1 changed files with 20 additions and 2 deletions

View File

@ -320,9 +320,26 @@ static VALUE rb_sigar_who_list(VALUE obj)
static VALUE rb_cSigarNetRoute;
static VALUE rb_sigar_net_route(VALUE obj)
static VALUE rb_sigar_net_route_list(VALUE obj)
{
return obj; /*XXX*/
int status;
sigar_t *sigar = rb_sigar_get(obj);
sigar_net_route_list_t list;
VALUE RETVAL;
status = sigar_net_route_list_get(sigar, &list);
if (status != SIGAR_OK) {
RB_SIGAR_CROAK;
}
RETVAL = rb_sigar_new_list((char *)&list.data[0],
list.number,
sizeof(*list.data),
rb_cSigarNetRoute);
sigar_net_route_list_destroy(sigar, &list);
return RETVAL;
}
static VALUE rb_sigar_proc_args(VALUE obj, VALUE pid)
@ -432,6 +449,7 @@ void Init_rbsigar(void)
rb_define_method(rclass, "net_services_name", rb_sigar_net_services_name, 2);
rb_define_method(rclass, "net_stat", rb_sigar_net_stat, 1);
rb_define_method(rclass, "net_stat_port", rb_sigar_net_stat_port, 3);
rb_define_method(rclass, "net_route_list", rb_sigar_net_route_list, 0);
rb_define_method(rclass, "who_list", rb_sigar_who_list, 0);
rb_define_method(rclass, "proc_args", rb_sigar_proc_args, 1);
rb_define_method(rclass, "proc_env", rb_sigar_proc_env, 1);