| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#include <common.h> |
| 23 |
#include <types.h> |
| 24 |
|
| 25 |
#if defined( HAVE_STDLIB_H ) || defined( HAVE_WINAPI ) |
| 26 |
#include <stdlib.h> |
| 27 |
#endif |
| 28 |
|
| 29 |
#include "pyfwsi_control_panel_category.h" |
| 30 |
#include "pyfwsi_error.h" |
| 31 |
#include "pyfwsi_integer.h" |
| 32 |
#include "pyfwsi_item.h" |
| 33 |
#include "pyfwsi_libcerror.h" |
| 34 |
#include "pyfwsi_libfwsi.h" |
| 35 |
#include "pyfwsi_python.h" |
| 36 |
#include "pyfwsi_unused.h" |
| 37 |
|
| 38 |
PyMethodDef pyfwsi_control_panel_category_object_methods[] = { |
| 39 |
|
| 40 |
{ "get_identifier", |
| 41 |
(PyCFunction) pyfwsi_control_panel_category_get_identifier, |
| 42 |
METH_NOARGS, |
| 43 |
"get_identifier() -> Integer\n" |
| 44 |
"\n" |
| 45 |
"Retrieves the identifier." }, |
| 46 |
|
| 47 |
|
| 48 |
{ NULL, NULL, 0, NULL } |
| 49 |
}; |
| 50 |
|
| 51 |
PyGetSetDef pyfwsi_control_panel_category_object_get_set_definitions[] = { |
| 52 |
|
| 53 |
{ "identifier", |
| 54 |
(getter) pyfwsi_control_panel_category_get_identifier, |
| 55 |
(setter) 0, |
| 56 |
"The identifier.", |
| 57 |
NULL }, |
| 58 |
|
| 59 |
|
| 60 |
{ NULL, NULL, NULL, NULL, NULL } |
| 61 |
}; |
| 62 |
|
| 63 |
PyTypeObject pyfwsi_control_panel_category_type_object = { |
| 64 |
PyVarObject_HEAD_INIT( NULL, 0 ) |
| 65 |
|
| 66 |
|
| 67 |
"pyfwsi.control_panel_category", |
| 68 |
|
| 69 |
sizeof( pyfwsi_item_t ), |
| 70 |
|
| 71 |
0, |
| 72 |
|
| 73 |
0, |
| 74 |
|
| 75 |
0, |
| 76 |
|
| 77 |
0, |
| 78 |
|
| 79 |
0, |
| 80 |
|
| 81 |
0, |
| 82 |
|
| 83 |
0, |
| 84 |
|
| 85 |
0, |
| 86 |
|
| 87 |
0, |
| 88 |
|
| 89 |
0, |
| 90 |
|
| 91 |
0, |
| 92 |
|
| 93 |
0, |
| 94 |
|
| 95 |
0, |
| 96 |
|
| 97 |
0, |
| 98 |
|
| 99 |
0, |
| 100 |
|
| 101 |
0, |
| 102 |
|
| 103 |
Py_TPFLAGS_DEFAULT, |
| 104 |
|
| 105 |
"pyfwsi control_panel_category object (wraps libfwsi_item_t type LIBFWSI_ITEM_TYPE_CONTROL_PANEL_CATEGORY)", |
| 106 |
|
| 107 |
0, |
| 108 |
|
| 109 |
0, |
| 110 |
|
| 111 |
0, |
| 112 |
|
| 113 |
0, |
| 114 |
|
| 115 |
0, |
| 116 |
|
| 117 |
0, |
| 118 |
|
| 119 |
pyfwsi_control_panel_category_object_methods, |
| 120 |
|
| 121 |
0, |
| 122 |
|
| 123 |
pyfwsi_control_panel_category_object_get_set_definitions, |
| 124 |
|
| 125 |
&pyfwsi_item_type_object, |
| 126 |
|
| 127 |
0, |
| 128 |
|
| 129 |
0, |
| 130 |
|
| 131 |
0, |
| 132 |
|
| 133 |
0, |
| 134 |
|
| 135 |
0, |
| 136 |
|
| 137 |
0, |
| 138 |
|
| 139 |
0, |
| 140 |
|
| 141 |
0, |
| 142 |
|
| 143 |
0, |
| 144 |
|
| 145 |
NULL, |
| 146 |
|
| 147 |
NULL, |
| 148 |
|
| 149 |
NULL, |
| 150 |
|
| 151 |
NULL, |
| 152 |
|
| 153 |
NULL, |
| 154 |
|
| 155 |
0 |
| 156 |
}; |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
PyObject *pyfwsi_control_panel_category_get_identifier( |
| 162 |
pyfwsi_item_t *pyfwsi_item, |
| 163 |
PyObject *arguments PYFWSI_ATTRIBUTE_UNUSED ) |
| 164 |
{ |
| 165 |
libcerror_error_t *error = NULL; |
| 166 |
PyObject *integer_object = NULL; |
| 167 |
static char *function = "pyfwsi_control_panel_category_get_identifier"; |
| 168 |
uint32_t identifier = 0; |
| 169 |
int result = 0; |
| 170 |
|
| 171 |
PYFWSI_UNREFERENCED_PARAMETER( arguments ) |
| 172 |
|
| 173 |
if( pyfwsi_item == NULL ) |
| 174 |
{ |
| 175 |
PyErr_Format( |
| 176 |
PyExc_TypeError, |
| 177 |
"%s: invalid item.", |
| 178 |
function ); |
| 179 |
|
| 180 |
return( NULL ); |
| 181 |
} |
| 182 |
Py_BEGIN_ALLOW_THREADS |
| 183 |
|
| 184 |
result = libfwsi_control_panel_category_get_identifier( |
| 185 |
pyfwsi_item->item, |
| 186 |
&identifier, |
| 187 |
&error ); |
| 188 |
|
| 189 |
Py_END_ALLOW_THREADS |
| 190 |
|
| 191 |
if( result != 1 ) |
| 192 |
{ |
| 193 |
pyfwsi_error_raise( |
| 194 |
error, |
| 195 |
PyExc_IOError, |
| 196 |
"%s: unable to retrieve identifier.", |
| 197 |
function ); |
| 198 |
|
| 199 |
libcerror_error_free( |
| 200 |
&error ); |
| 201 |
|
| 202 |
return( NULL ); |
| 203 |
} |
| 204 |
integer_object = pyfwsi_integer_unsigned_new_from_64bit( |
| 205 |
(uint64_t) identifier ); |
| 206 |
|
| 207 |
return( integer_object ); |
| 208 |
} |
| 209 |
|