Class: CapNG::Print
- Inherits:
-
Object
- Object
- CapNG::Print
- Defined in:
- ext/capng/print.c,
ext/capng/print.c
Overview
Print Linux capabitlities.
Constant Summary collapse
- STDOUT =
Print target into STDOUT.
LONG2NUM(CAPNG_PRINT_STDOUT)
- BUFFER =
Print target into buffer varible.
LONG2NUM(CAPNG_PRINT_BUFFER)
Instance Method Summary collapse
-
#caps_numeric(rb_where_name_or_type, rb_select_name_or_enum) ⇒ Integer
Print capability as numeric.
-
#caps_text(rb_where_name_or_type, rb_capability_name_or_type) ⇒ Integer
Print capability as text.
-
#initialize ⇒ nil
constructor
Initalize Print class.
Constructor Details
#initialize ⇒ nil
Initalize Print class.
68 69 70 71 72 |
# File 'ext/capng/print.c', line 68 static VALUE rb_capng_print_initialize(VALUE self) { return Qnil; } |
Instance Method Details
#caps_numeric(rb_where_name_or_type, rb_select_name_or_enum) ⇒ Integer
Print capability as numeric.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'ext/capng/print.c', line 146 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(rb_where_name_or_type, rb_capability_name_or_type) ⇒ Integer
Print capability as text.
constants
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'ext/capng/print.c', line 83 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"); } |