class CapNG::Print
Print Linux capabitlities.
@example
require 'capng' @print = CapNG::Print.new @print.caps_text(:buffer, :effective)
Constants
Public Class Methods
new()
click to toggle source
Initalize Print class.
@return [nil]
static VALUE
rb_capng_print_initialize(VALUE self)
{
return Qnil;
}
Public Instance Methods
caps_numeric(p1, p2)
click to toggle source
Print capability as numeric.
@param rb_where_name_or_type [String or Symbol or Fixnum] Print target. @param rb_select_name_or_enum [String or Symbol or Fixnum] Select set name or constants @return [Integer]
static VALUE
rb_capng_print_caps_numeric(VALUE self, VALUE rb_where_name_or_type,
VALUE rb_select_name_or_enum)
{
char* result = NULL;
capng_select_t select = 0;
capng_print_t print_type = 0;
switch (TYPE(rb_where_name_or_type)) {
case T_SYMBOL:
print_type =
print_name_to_print_type(RSTRING_PTR(rb_sym2str(rb_where_name_or_type)));
break;
case T_STRING:
print_type = print_name_to_print_type(StringValuePtr(rb_where_name_or_type));
break;
case T_FIXNUM:
print_type = NUM2INT(rb_where_name_or_type);
break;
default:
rb_raise(rb_eArgError,
"Expected a String or a Symbol instance, or a print type constant");
}
switch (TYPE(rb_select_name_or_enum)) {
case T_SYMBOL:
select =
select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
break;
case T_STRING:
select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
break;
case T_FIXNUM:
select = NUM2INT(rb_select_name_or_enum);
break;
default:
rb_raise(rb_eArgError,
"Expected a String or a Symbol instance, or a capability type constant");
}
switch (print_type) {
case CAPNG_PRINT_STDOUT:
capng_print_caps_numeric(CAPNG_PRINT_STDOUT, select);
break;
case CAPNG_PRINT_BUFFER:
result = capng_print_caps_numeric(CAPNG_PRINT_BUFFER, select);
}
if (result)
return rb_str_new2(result);
else
return rb_str_new2("none");
}
caps_text(p1, p2)
click to toggle source
Print capability as text.
@param rb_where_name_or_type [String or Symbol or Fixnum] Print target. @param rb_capability_name_or_type [String or Symbol or Fixnum] Capability name or constants @return [Integer]
static VALUE
rb_capng_print_caps_text(VALUE self, VALUE rb_where_name_or_type,
VALUE rb_capability_name_or_type)
{
char* result = NULL;
capng_type_t capability_type = 0;
capng_print_t print_type = 0;
switch (TYPE(rb_capability_name_or_type)) {
case T_SYMBOL:
capability_type = capability_type_name_to_capability_type(
RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
break;
case T_STRING:
capability_type = capability_type_name_to_capability_type(
StringValuePtr(rb_capability_name_or_type));
break;
case T_FIXNUM:
capability_type = NUM2INT(rb_capability_name_or_type);
break;
default:
rb_raise(rb_eArgError,
"Expected a String or a Symbol instance, or a capability type constant");
}
switch (TYPE(rb_where_name_or_type)) {
case T_SYMBOL:
print_type =
print_name_to_print_type(RSTRING_PTR(rb_sym2str(rb_where_name_or_type)));
break;
case T_STRING:
print_type = print_name_to_print_type(StringValuePtr(rb_where_name_or_type));
break;
case T_FIXNUM:
print_type = NUM2INT(rb_where_name_or_type);
break;
default:
rb_raise(rb_eArgError,
"Expected a String or a Symbol instance, or a print type constant");
}
switch (print_type) {
case CAPNG_PRINT_STDOUT:
capng_print_caps_text(CAPNG_PRINT_STDOUT, capability_type);
break;
case CAPNG_PRINT_BUFFER:
result = capng_print_caps_text(CAPNG_PRINT_BUFFER, capability_type);
}
if (result)
return rb_str_new2(result);
else
return rb_str_new2("none");
}