LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - py_preg.c (source / functions) Hit Total Coverage
Test: coverage report for master 98b443d9 Lines: 223 671 33.2 %
Date: 2024-05-31 13:13:24 Functions: 23 48 47.9 %

          Line data    Source code
       1             : 
       2             : /* Python wrapper functions auto-generated by pidl */
       3             : #define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
       4             : #include "lib/replace/system/python.h"
       5             : #include "python/py3compat.h"
       6             : #include "includes.h"
       7             : #include "python/modules.h"
       8             : #include <pytalloc.h>
       9             : #include "librpc/rpc/pyrpc.h"
      10             : #include "librpc/rpc/pyrpc_util.h"
      11             : #include "bin/default/librpc/gen_ndr/ndr_preg.h"
      12             : 
      13             : 
      14             : /*
      15             :  * Suppress compiler warnings if the generated code does not call these
      16             :  * functions
      17             :  */
      18             : #ifndef _MAYBE_UNUSED_
      19             : #ifdef __has_attribute
      20             : #if __has_attribute(unused)
      21             : #define _MAYBE_UNUSED_ __attribute__ ((unused))
      22             : #else
      23             : #define _MAYBE_UNUSED_
      24             : #endif
      25             : #endif
      26             : #endif
      27             : /*
      28             :  * These functions are here to ensure they can be optimized out by
      29             :  * the compiler based on the constant input values
      30             :  */
      31             : 
      32        5952 : static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
      33             : {
      34        5952 :         switch (var_size) {
      35           0 :         case 8:
      36           0 :                 return UINT64_MAX;
      37        5952 :         case 4:
      38        5952 :                 return UINT32_MAX;
      39           0 :         case 2:
      40           0 :                 return UINT16_MAX;
      41           0 :         case 1:
      42           0 :                 return UINT8_MAX;
      43             :         }
      44             : 
      45           0 :         return 0;
      46             : }
      47             : 
      48             : static inline _MAYBE_UNUSED_ long long ndr_sizeof2intmax(size_t var_size)
      49             : {
      50             :         switch (var_size) {
      51             :         case 8:
      52             :                 return INT64_MAX;
      53             :         case 4:
      54             :                 return INT32_MAX;
      55             :         case 2:
      56             :                 return INT16_MAX;
      57             :         case 1:
      58             :                 return INT8_MAX;
      59             :         }
      60             : 
      61             :         return 0;
      62             : }
      63             : 
      64             : #include "librpc/gen_ndr/misc.h"
      65             : static PyTypeObject preg_entry_Type;
      66             : static PyTypeObject preg_header_Type;
      67             : static PyTypeObject preg_file_Type;
      68             : static PyTypeObject preg_InterfaceType;
      69             : 
      70             : static PyTypeObject *winreg_Data_GPO_Type;
      71             : static PyTypeObject *BaseObject_Type;
      72             : static PyTypeObject *ClientConnection_Type;
      73             : static PyTypeObject *ndr_syntax_id_Type;
      74             : 
      75           0 : static PyObject *py_preg_entry_get__opening_bracket(PyObject *obj, void *closure)
      76             : {
      77           0 :         struct preg_entry *object = pytalloc_get_ptr(obj);
      78           0 :         PyObject *py__opening_bracket;
      79           0 :         if (object->_opening_bracket == NULL) {
      80           0 :                 py__opening_bracket = Py_None;
      81           0 :                 Py_INCREF(py__opening_bracket);
      82             :         } else {
      83           0 :                 py__opening_bracket = PyUnicode_Decode(object->_opening_bracket, strlen(object->_opening_bracket), "utf-8", "ignore");
      84             :         }
      85           0 :         return py__opening_bracket;
      86             : }
      87             : 
      88           0 : static int py_preg_entry_set__opening_bracket(PyObject *py_obj, PyObject *value, void *closure)
      89             : {
      90           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
      91           0 :         if (value == NULL) {
      92           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->_opening_bracket");
      93           0 :                 return -1;
      94             :         }
      95             :         {
      96           0 :                 const char *test_str;
      97           0 :                 const char *talloc_str;
      98           0 :                 PyObject *unicode = NULL;
      99           0 :                 if (PyUnicode_Check(value)) {
     100           0 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     101           0 :                         if (unicode == NULL) {
     102           0 :                                 return -1;
     103             :                         }
     104           0 :                         test_str = PyBytes_AS_STRING(unicode);
     105           0 :                 } else if (PyBytes_Check(value)) {
     106           0 :                         test_str = PyBytes_AS_STRING(value);
     107             :                 } else {
     108           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     109           0 :                         return -1;
     110             :                 }
     111           0 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     112           0 :                 if (unicode != NULL) {
     113           0 :                         Py_DECREF(unicode);
     114             :                 }
     115           0 :                 if (talloc_str == NULL) {
     116           0 :                         PyErr_NoMemory();
     117           0 :                         return -1;
     118             :                 }
     119           0 :                 object->_opening_bracket = talloc_str;
     120             :         }
     121           0 :         return 0;
     122             : }
     123             : 
     124       38918 : static PyObject *py_preg_entry_get_keyname(PyObject *obj, void *closure)
     125             : {
     126       38918 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     127           0 :         PyObject *py_keyname;
     128       38918 :         py_keyname = PyString_FromStringOrNULL(object->keyname);
     129       38918 :         return py_keyname;
     130             : }
     131             : 
     132        5618 : static int py_preg_entry_set_keyname(PyObject *py_obj, PyObject *value, void *closure)
     133             : {
     134        5618 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     135        5618 :         if (value == NULL) {
     136           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->keyname");
     137           0 :                 return -1;
     138             :         }
     139             :         {
     140           0 :                 const char *test_str;
     141           0 :                 const char *talloc_str;
     142        5618 :                 PyObject *unicode = NULL;
     143        5618 :                 if (PyUnicode_Check(value)) {
     144        5542 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     145        5542 :                         if (unicode == NULL) {
     146           0 :                                 return -1;
     147             :                         }
     148        5542 :                         test_str = PyBytes_AS_STRING(unicode);
     149          76 :                 } else if (PyBytes_Check(value)) {
     150          76 :                         test_str = PyBytes_AS_STRING(value);
     151             :                 } else {
     152           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     153           0 :                         return -1;
     154             :                 }
     155        5618 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     156        5618 :                 if (unicode != NULL) {
     157        4125 :                         Py_DECREF(unicode);
     158             :                 }
     159        5618 :                 if (talloc_str == NULL) {
     160           0 :                         PyErr_NoMemory();
     161           0 :                         return -1;
     162             :                 }
     163        5618 :                 object->keyname = talloc_str;
     164             :         }
     165        5618 :         return 0;
     166             : }
     167             : 
     168           0 : static PyObject *py_preg_entry_get__sep1(PyObject *obj, void *closure)
     169             : {
     170           0 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     171           0 :         PyObject *py__sep1;
     172           0 :         if (object->_sep1 == NULL) {
     173           0 :                 py__sep1 = Py_None;
     174           0 :                 Py_INCREF(py__sep1);
     175             :         } else {
     176           0 :                 py__sep1 = PyUnicode_Decode(object->_sep1, strlen(object->_sep1), "utf-8", "ignore");
     177             :         }
     178           0 :         return py__sep1;
     179             : }
     180             : 
     181           0 : static int py_preg_entry_set__sep1(PyObject *py_obj, PyObject *value, void *closure)
     182             : {
     183           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     184           0 :         if (value == NULL) {
     185           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->_sep1");
     186           0 :                 return -1;
     187             :         }
     188             :         {
     189           0 :                 const char *test_str;
     190           0 :                 const char *talloc_str;
     191           0 :                 PyObject *unicode = NULL;
     192           0 :                 if (PyUnicode_Check(value)) {
     193           0 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     194           0 :                         if (unicode == NULL) {
     195           0 :                                 return -1;
     196             :                         }
     197           0 :                         test_str = PyBytes_AS_STRING(unicode);
     198           0 :                 } else if (PyBytes_Check(value)) {
     199           0 :                         test_str = PyBytes_AS_STRING(value);
     200             :                 } else {
     201           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     202           0 :                         return -1;
     203             :                 }
     204           0 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     205           0 :                 if (unicode != NULL) {
     206           0 :                         Py_DECREF(unicode);
     207             :                 }
     208           0 :                 if (talloc_str == NULL) {
     209           0 :                         PyErr_NoMemory();
     210           0 :                         return -1;
     211             :                 }
     212           0 :                 object->_sep1 = talloc_str;
     213             :         }
     214           0 :         return 0;
     215             : }
     216             : 
     217       18900 : static PyObject *py_preg_entry_get_valuename(PyObject *obj, void *closure)
     218             : {
     219       18900 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     220           0 :         PyObject *py_valuename;
     221       18900 :         py_valuename = PyString_FromStringOrNULL(object->valuename);
     222       18900 :         return py_valuename;
     223             : }
     224             : 
     225        5618 : static int py_preg_entry_set_valuename(PyObject *py_obj, PyObject *value, void *closure)
     226             : {
     227        5618 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     228        5618 :         if (value == NULL) {
     229           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->valuename");
     230           0 :                 return -1;
     231             :         }
     232             :         {
     233           0 :                 const char *test_str;
     234           0 :                 const char *talloc_str;
     235        5618 :                 PyObject *unicode = NULL;
     236        5618 :                 if (PyUnicode_Check(value)) {
     237        5542 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     238        5542 :                         if (unicode == NULL) {
     239           0 :                                 return -1;
     240             :                         }
     241        5542 :                         test_str = PyBytes_AS_STRING(unicode);
     242          76 :                 } else if (PyBytes_Check(value)) {
     243          76 :                         test_str = PyBytes_AS_STRING(value);
     244             :                 } else {
     245           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     246           0 :                         return -1;
     247             :                 }
     248        5618 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     249        5618 :                 if (unicode != NULL) {
     250        4125 :                         Py_DECREF(unicode);
     251             :                 }
     252        5618 :                 if (talloc_str == NULL) {
     253           0 :                         PyErr_NoMemory();
     254           0 :                         return -1;
     255             :                 }
     256        5618 :                 object->valuename = talloc_str;
     257             :         }
     258        5618 :         return 0;
     259             : }
     260             : 
     261           0 : static PyObject *py_preg_entry_get__sep2(PyObject *obj, void *closure)
     262             : {
     263           0 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     264           0 :         PyObject *py__sep2;
     265           0 :         if (object->_sep2 == NULL) {
     266           0 :                 py__sep2 = Py_None;
     267           0 :                 Py_INCREF(py__sep2);
     268             :         } else {
     269           0 :                 py__sep2 = PyUnicode_Decode(object->_sep2, strlen(object->_sep2), "utf-8", "ignore");
     270             :         }
     271           0 :         return py__sep2;
     272             : }
     273             : 
     274           0 : static int py_preg_entry_set__sep2(PyObject *py_obj, PyObject *value, void *closure)
     275             : {
     276           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     277           0 :         if (value == NULL) {
     278           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->_sep2");
     279           0 :                 return -1;
     280             :         }
     281             :         {
     282           0 :                 const char *test_str;
     283           0 :                 const char *talloc_str;
     284           0 :                 PyObject *unicode = NULL;
     285           0 :                 if (PyUnicode_Check(value)) {
     286           0 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     287           0 :                         if (unicode == NULL) {
     288           0 :                                 return -1;
     289             :                         }
     290           0 :                         test_str = PyBytes_AS_STRING(unicode);
     291           0 :                 } else if (PyBytes_Check(value)) {
     292           0 :                         test_str = PyBytes_AS_STRING(value);
     293             :                 } else {
     294           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     295           0 :                         return -1;
     296             :                 }
     297           0 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     298           0 :                 if (unicode != NULL) {
     299           0 :                         Py_DECREF(unicode);
     300             :                 }
     301           0 :                 if (talloc_str == NULL) {
     302           0 :                         PyErr_NoMemory();
     303           0 :                         return -1;
     304             :                 }
     305           0 :                 object->_sep2 = talloc_str;
     306             :         }
     307           0 :         return 0;
     308             : }
     309             : 
     310       24394 : static PyObject *py_preg_entry_get_type(PyObject *obj, void *closure)
     311             : {
     312       24394 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     313           0 :         PyObject *py_type;
     314       24394 :         py_type = PyLong_FromUnsignedLongLong((uint32_t)(object->type));
     315       24394 :         return py_type;
     316             : }
     317             : 
     318        5618 : static int py_preg_entry_set_type(PyObject *py_obj, PyObject *value, void *closure)
     319             : {
     320        5618 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     321        5618 :         if (value == NULL) {
     322           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->type");
     323           0 :                 return -1;
     324             :         }
     325             :         {
     326        5618 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->type));
     327        5618 :                 if (PyLong_Check(value)) {
     328           0 :                         unsigned long long test_var;
     329        5618 :                         test_var = PyLong_AsUnsignedLongLong(value);
     330        5618 :                         if (PyErr_Occurred() != NULL) {
     331           0 :                                 return -1;
     332             :                         }
     333        5618 :                         if (test_var > uint_max) {
     334           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     335             :                                   PyLong_Type.tp_name, uint_max, test_var);
     336           0 :                                 return -1;
     337             :                         }
     338        5618 :                         object->type = test_var;
     339             :                 } else {
     340           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     341             :                           PyLong_Type.tp_name);
     342           0 :                         return -1;
     343             :                 }
     344             :         }
     345        5618 :         return 0;
     346             : }
     347             : 
     348           0 : static PyObject *py_preg_entry_get__sep3(PyObject *obj, void *closure)
     349             : {
     350           0 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     351           0 :         PyObject *py__sep3;
     352           0 :         if (object->_sep3 == NULL) {
     353           0 :                 py__sep3 = Py_None;
     354           0 :                 Py_INCREF(py__sep3);
     355             :         } else {
     356           0 :                 py__sep3 = PyUnicode_Decode(object->_sep3, strlen(object->_sep3), "utf-8", "ignore");
     357             :         }
     358           0 :         return py__sep3;
     359             : }
     360             : 
     361           0 : static int py_preg_entry_set__sep3(PyObject *py_obj, PyObject *value, void *closure)
     362             : {
     363           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     364           0 :         if (value == NULL) {
     365           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->_sep3");
     366           0 :                 return -1;
     367             :         }
     368             :         {
     369           0 :                 const char *test_str;
     370           0 :                 const char *talloc_str;
     371           0 :                 PyObject *unicode = NULL;
     372           0 :                 if (PyUnicode_Check(value)) {
     373           0 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     374           0 :                         if (unicode == NULL) {
     375           0 :                                 return -1;
     376             :                         }
     377           0 :                         test_str = PyBytes_AS_STRING(unicode);
     378           0 :                 } else if (PyBytes_Check(value)) {
     379           0 :                         test_str = PyBytes_AS_STRING(value);
     380             :                 } else {
     381           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     382           0 :                         return -1;
     383             :                 }
     384           0 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     385           0 :                 if (unicode != NULL) {
     386           0 :                         Py_DECREF(unicode);
     387             :                 }
     388           0 :                 if (talloc_str == NULL) {
     389           0 :                         PyErr_NoMemory();
     390           0 :                         return -1;
     391             :                 }
     392           0 :                 object->_sep3 = talloc_str;
     393             :         }
     394           0 :         return 0;
     395             : }
     396             : 
     397           0 : static PyObject *py_preg_entry_get_size(PyObject *obj, void *closure)
     398             : {
     399           0 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     400           0 :         PyObject *py_size;
     401           0 :         py_size = PyLong_FromUnsignedLongLong((uint32_t)(object->size));
     402           0 :         return py_size;
     403             : }
     404             : 
     405           0 : static int py_preg_entry_set_size(PyObject *py_obj, PyObject *value, void *closure)
     406             : {
     407           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     408           0 :         if (value == NULL) {
     409           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->size");
     410           0 :                 return -1;
     411             :         }
     412             :         {
     413           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->size));
     414           0 :                 if (PyLong_Check(value)) {
     415           0 :                         unsigned long long test_var;
     416           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     417           0 :                         if (PyErr_Occurred() != NULL) {
     418           0 :                                 return -1;
     419             :                         }
     420           0 :                         if (test_var > uint_max) {
     421           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     422             :                                   PyLong_Type.tp_name, uint_max, test_var);
     423           0 :                                 return -1;
     424             :                         }
     425           0 :                         object->size = test_var;
     426             :                 } else {
     427           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     428             :                           PyLong_Type.tp_name);
     429           0 :                         return -1;
     430             :                 }
     431             :         }
     432           0 :         return 0;
     433             : }
     434             : 
     435           0 : static PyObject *py_preg_entry_get__sep4(PyObject *obj, void *closure)
     436             : {
     437           0 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     438           0 :         PyObject *py__sep4;
     439           0 :         if (object->_sep4 == NULL) {
     440           0 :                 py__sep4 = Py_None;
     441           0 :                 Py_INCREF(py__sep4);
     442             :         } else {
     443           0 :                 py__sep4 = PyUnicode_Decode(object->_sep4, strlen(object->_sep4), "utf-8", "ignore");
     444             :         }
     445           0 :         return py__sep4;
     446             : }
     447             : 
     448           0 : static int py_preg_entry_set__sep4(PyObject *py_obj, PyObject *value, void *closure)
     449             : {
     450           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     451           0 :         if (value == NULL) {
     452           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->_sep4");
     453           0 :                 return -1;
     454             :         }
     455             :         {
     456           0 :                 const char *test_str;
     457           0 :                 const char *talloc_str;
     458           0 :                 PyObject *unicode = NULL;
     459           0 :                 if (PyUnicode_Check(value)) {
     460           0 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     461           0 :                         if (unicode == NULL) {
     462           0 :                                 return -1;
     463             :                         }
     464           0 :                         test_str = PyBytes_AS_STRING(unicode);
     465           0 :                 } else if (PyBytes_Check(value)) {
     466           0 :                         test_str = PyBytes_AS_STRING(value);
     467             :                 } else {
     468           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     469           0 :                         return -1;
     470             :                 }
     471           0 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     472           0 :                 if (unicode != NULL) {
     473           0 :                         Py_DECREF(unicode);
     474             :                 }
     475           0 :                 if (talloc_str == NULL) {
     476           0 :                         PyErr_NoMemory();
     477           0 :                         return -1;
     478             :                 }
     479           0 :                 object->_sep4 = talloc_str;
     480             :         }
     481           0 :         return 0;
     482             : }
     483             : 
     484       12410 : static PyObject *py_preg_entry_get_data(PyObject *obj, void *closure)
     485             : {
     486       12410 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     487           0 :         PyObject *py_data;
     488       12410 :         py_data = pyrpc_import_union(winreg_Data_GPO_Type, pytalloc_get_mem_ctx(obj), object->type, &object->data, "union winreg_Data_GPO");
     489       12410 :         if (py_data == NULL) {
     490           0 :                 return NULL;
     491             :         }
     492       12410 :         return py_data;
     493             : }
     494             : 
     495        3968 : static int py_preg_entry_set_data(PyObject *py_obj, PyObject *value, void *closure)
     496             : {
     497        3968 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     498        3968 :         if (value == NULL) {
     499           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->data");
     500           0 :                 return -1;
     501             :         }
     502             :         {
     503           0 :                 union winreg_Data_GPO *data_switch_1;
     504        3968 :                 data_switch_1 = (union winreg_Data_GPO *)pyrpc_export_union(winreg_Data_GPO_Type, pytalloc_get_mem_ctx(py_obj), object->type, value, "union winreg_Data_GPO");
     505        3968 :                 if (data_switch_1 == NULL) {
     506           0 :                         return -1;
     507             :                 }
     508        3968 :                 object->data = *data_switch_1;
     509             :         }
     510        3968 :         return 0;
     511             : }
     512             : 
     513           0 : static PyObject *py_preg_entry_get__closing_bracket(PyObject *obj, void *closure)
     514             : {
     515           0 :         struct preg_entry *object = pytalloc_get_ptr(obj);
     516           0 :         PyObject *py__closing_bracket;
     517           0 :         if (object->_closing_bracket == NULL) {
     518           0 :                 py__closing_bracket = Py_None;
     519           0 :                 Py_INCREF(py__closing_bracket);
     520             :         } else {
     521           0 :                 py__closing_bracket = PyUnicode_Decode(object->_closing_bracket, strlen(object->_closing_bracket), "utf-8", "ignore");
     522             :         }
     523           0 :         return py__closing_bracket;
     524             : }
     525             : 
     526           0 : static int py_preg_entry_set__closing_bracket(PyObject *py_obj, PyObject *value, void *closure)
     527             : {
     528           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     529           0 :         if (value == NULL) {
     530           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->_closing_bracket");
     531           0 :                 return -1;
     532             :         }
     533             :         {
     534           0 :                 const char *test_str;
     535           0 :                 const char *talloc_str;
     536           0 :                 PyObject *unicode = NULL;
     537           0 :                 if (PyUnicode_Check(value)) {
     538           0 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     539           0 :                         if (unicode == NULL) {
     540           0 :                                 return -1;
     541             :                         }
     542           0 :                         test_str = PyBytes_AS_STRING(unicode);
     543           0 :                 } else if (PyBytes_Check(value)) {
     544           0 :                         test_str = PyBytes_AS_STRING(value);
     545             :                 } else {
     546           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     547           0 :                         return -1;
     548             :                 }
     549           0 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     550           0 :                 if (unicode != NULL) {
     551           0 :                         Py_DECREF(unicode);
     552             :                 }
     553           0 :                 if (talloc_str == NULL) {
     554           0 :                         PyErr_NoMemory();
     555           0 :                         return -1;
     556             :                 }
     557           0 :                 object->_closing_bracket = talloc_str;
     558             :         }
     559           0 :         return 0;
     560             : }
     561             : 
     562             : static PyGetSetDef py_preg_entry_getsetters[] = {
     563             :         {
     564             :                 .name = discard_const_p(char, "_opening_bracket"),
     565             :                 .get = py_preg_entry_get__opening_bracket,
     566             :                 .set = py_preg_entry_set__opening_bracket,
     567             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     568             :         },
     569             :         {
     570             :                 .name = discard_const_p(char, "keyname"),
     571             :                 .get = py_preg_entry_get_keyname,
     572             :                 .set = py_preg_entry_set_keyname,
     573             :                 .doc = discard_const_p(char, "PIDL-generated element of base type string")
     574             :         },
     575             :         {
     576             :                 .name = discard_const_p(char, "_sep1"),
     577             :                 .get = py_preg_entry_get__sep1,
     578             :                 .set = py_preg_entry_set__sep1,
     579             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     580             :         },
     581             :         {
     582             :                 .name = discard_const_p(char, "valuename"),
     583             :                 .get = py_preg_entry_get_valuename,
     584             :                 .set = py_preg_entry_set_valuename,
     585             :                 .doc = discard_const_p(char, "PIDL-generated element of base type string")
     586             :         },
     587             :         {
     588             :                 .name = discard_const_p(char, "_sep2"),
     589             :                 .get = py_preg_entry_get__sep2,
     590             :                 .set = py_preg_entry_set__sep2,
     591             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     592             :         },
     593             :         {
     594             :                 .name = discard_const_p(char, "type"),
     595             :                 .get = py_preg_entry_get_type,
     596             :                 .set = py_preg_entry_set_type,
     597             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_Type")
     598             :         },
     599             :         {
     600             :                 .name = discard_const_p(char, "_sep3"),
     601             :                 .get = py_preg_entry_get__sep3,
     602             :                 .set = py_preg_entry_set__sep3,
     603             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     604             :         },
     605             :         {
     606             :                 .name = discard_const_p(char, "size"),
     607             :                 .get = py_preg_entry_get_size,
     608             :                 .set = py_preg_entry_set_size,
     609             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
     610             :         },
     611             :         {
     612             :                 .name = discard_const_p(char, "_sep4"),
     613             :                 .get = py_preg_entry_get__sep4,
     614             :                 .set = py_preg_entry_set__sep4,
     615             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     616             :         },
     617             :         {
     618             :                 .name = discard_const_p(char, "data"),
     619             :                 .get = py_preg_entry_get_data,
     620             :                 .set = py_preg_entry_set_data,
     621             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_Data_GPO")
     622             :         },
     623             :         {
     624             :                 .name = discard_const_p(char, "_closing_bracket"),
     625             :                 .get = py_preg_entry_get__closing_bracket,
     626             :                 .set = py_preg_entry_set__closing_bracket,
     627             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     628             :         },
     629             :         { .name = NULL }
     630             : };
     631             : 
     632        5618 : static PyObject *py_preg_entry_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     633             : {
     634        5618 :         return pytalloc_new(struct preg_entry, type);
     635             : }
     636             : 
     637           0 : static PyObject *py_preg_entry_ndr_pack(PyObject *py_obj,  PyObject *Py_UNUSED(ignored))
     638             : {
     639           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     640           0 :         PyObject *ret = NULL;
     641           0 :         DATA_BLOB blob;
     642           0 :         enum ndr_err_code err;
     643           0 :         TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
     644           0 :         if (tmp_ctx == NULL) {
     645           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
     646           0 :                 return NULL;
     647             :         }
     648           0 :         err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_preg_entry);
     649           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     650           0 :                 TALLOC_FREE(tmp_ctx);
     651           0 :                 PyErr_SetNdrError(err);
     652           0 :                 return NULL;
     653             :         }
     654             : 
     655           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
     656           0 :         TALLOC_FREE(tmp_ctx);
     657           0 :         return ret;
     658             : }
     659             : 
     660           0 : static PyObject *py_preg_entry_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
     661             : {
     662           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     663           0 :         DATA_BLOB blob = {.data = NULL, .length = 0};
     664           0 :         Py_ssize_t blob_length = 0;
     665           0 :         enum ndr_err_code err;
     666           0 :         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
     667           0 :         PyObject *allow_remaining_obj = NULL;
     668           0 :         bool allow_remaining = false;
     669             : 
     670           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|O:__ndr_unpack__",
     671             :                 discard_const_p(char *, kwnames),
     672             :                 &blob.data, &blob_length,
     673             :                 &allow_remaining_obj)) {
     674           0 :                 return NULL;
     675             :         }
     676           0 :         blob.length = blob_length;
     677             : 
     678           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
     679           0 :                 allow_remaining = true;
     680             :         }
     681             : 
     682           0 :         if (allow_remaining) {
     683           0 :                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_preg_entry);
     684             :         } else {
     685           0 :                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_preg_entry);
     686             :         }
     687           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     688           0 :                 PyErr_SetNdrError(err);
     689           0 :                 return NULL;
     690             :         }
     691             : 
     692           0 :         Py_RETURN_NONE;
     693             : }
     694             : 
     695           0 : static PyObject *py_preg_entry_ndr_print(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
     696             : {
     697           0 :         struct preg_entry *object = pytalloc_get_ptr(py_obj);
     698           0 :         PyObject *ret;
     699           0 :         char *retstr;
     700             : 
     701           0 :         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_preg_entry, "preg_entry", object);
     702           0 :         ret = PyUnicode_FromString(retstr);
     703           0 :         talloc_free(retstr);
     704             : 
     705           0 :         return ret;
     706             : }
     707             : 
     708             : static PyMethodDef py_preg_entry_methods[] = {
     709             :         { "__ndr_pack__", (PyCFunction)py_preg_entry_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
     710             :         { "__ndr_unpack__", PY_DISCARD_FUNC_SIG(PyCFunction,py_preg_entry_ndr_unpack), METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
     711             :         { "__ndr_print__", (PyCFunction)py_preg_entry_ndr_print, METH_NOARGS, "S.ndr_print(object) -> None\nNDR print" },
     712             :         { NULL, NULL, 0, NULL }
     713             : };
     714             : 
     715             : 
     716             : static PyTypeObject preg_entry_Type = {
     717             :         PyVarObject_HEAD_INIT(NULL, 0)
     718             :         .tp_name = "preg.entry",
     719             :         .tp_getset = py_preg_entry_getsetters,
     720             :         .tp_methods = py_preg_entry_methods,
     721             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     722             :         .tp_new = py_preg_entry_new,
     723             : };
     724             : 
     725             : 
     726          76 : static PyObject *py_preg_header_get_signature(PyObject *obj, void *closure)
     727             : {
     728          76 :         struct preg_header *object = pytalloc_get_ptr(obj);
     729           0 :         PyObject *py_signature;
     730          76 :         if (object->signature == NULL) {
     731           0 :                 py_signature = Py_None;
     732           0 :                 Py_INCREF(py_signature);
     733             :         } else {
     734          76 :                 py_signature = PyUnicode_Decode(object->signature, strlen(object->signature), "utf-8", "ignore");
     735             :         }
     736          76 :         return py_signature;
     737             : }
     738             : 
     739          94 : static int py_preg_header_set_signature(PyObject *py_obj, PyObject *value, void *closure)
     740             : {
     741          94 :         struct preg_header *object = pytalloc_get_ptr(py_obj);
     742          94 :         if (value == NULL) {
     743           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->signature");
     744           0 :                 return -1;
     745             :         }
     746             :         {
     747           0 :                 const char *test_str;
     748           0 :                 const char *talloc_str;
     749          94 :                 PyObject *unicode = NULL;
     750          94 :                 if (PyUnicode_Check(value)) {
     751          94 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     752          94 :                         if (unicode == NULL) {
     753           0 :                                 return -1;
     754             :                         }
     755          94 :                         test_str = PyBytes_AS_STRING(unicode);
     756           0 :                 } else if (PyBytes_Check(value)) {
     757           0 :                         test_str = PyBytes_AS_STRING(value);
     758             :                 } else {
     759           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     760           0 :                         return -1;
     761             :                 }
     762          94 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     763          94 :                 if (unicode != NULL) {
     764          71 :                         Py_DECREF(unicode);
     765             :                 }
     766          94 :                 if (talloc_str == NULL) {
     767           0 :                         PyErr_NoMemory();
     768           0 :                         return -1;
     769             :                 }
     770          94 :                 object->signature = talloc_str;
     771             :         }
     772          94 :         return 0;
     773             : }
     774             : 
     775          76 : static PyObject *py_preg_header_get_version(PyObject *obj, void *closure)
     776             : {
     777          76 :         struct preg_header *object = pytalloc_get_ptr(obj);
     778           0 :         PyObject *py_version;
     779          76 :         py_version = PyLong_FromUnsignedLongLong((uint32_t)(object->version));
     780          76 :         return py_version;
     781             : }
     782             : 
     783          94 : static int py_preg_header_set_version(PyObject *py_obj, PyObject *value, void *closure)
     784             : {
     785          94 :         struct preg_header *object = pytalloc_get_ptr(py_obj);
     786          94 :         if (value == NULL) {
     787           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->version");
     788           0 :                 return -1;
     789             :         }
     790             :         {
     791          94 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->version));
     792          94 :                 if (PyLong_Check(value)) {
     793           0 :                         unsigned long long test_var;
     794          94 :                         test_var = PyLong_AsUnsignedLongLong(value);
     795          94 :                         if (PyErr_Occurred() != NULL) {
     796           0 :                                 return -1;
     797             :                         }
     798          94 :                         if (test_var > uint_max) {
     799           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     800             :                                   PyLong_Type.tp_name, uint_max, test_var);
     801           0 :                                 return -1;
     802             :                         }
     803          94 :                         object->version = test_var;
     804             :                 } else {
     805           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     806             :                           PyLong_Type.tp_name);
     807           0 :                         return -1;
     808             :                 }
     809             :         }
     810          94 :         return 0;
     811             : }
     812             : 
     813             : static PyGetSetDef py_preg_header_getsetters[] = {
     814             :         {
     815             :                 .name = discard_const_p(char, "signature"),
     816             :                 .get = py_preg_header_get_signature,
     817             :                 .set = py_preg_header_set_signature,
     818             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     819             :         },
     820             :         {
     821             :                 .name = discard_const_p(char, "version"),
     822             :                 .get = py_preg_header_get_version,
     823             :                 .set = py_preg_header_set_version,
     824             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
     825             :         },
     826             :         { .name = NULL }
     827             : };
     828             : 
     829           0 : static PyObject *py_preg_header_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     830             : {
     831           0 :         return pytalloc_new(struct preg_header, type);
     832             : }
     833             : 
     834           0 : static PyObject *py_preg_header_ndr_pack(PyObject *py_obj,  PyObject *Py_UNUSED(ignored))
     835             : {
     836           0 :         struct preg_header *object = pytalloc_get_ptr(py_obj);
     837           0 :         PyObject *ret = NULL;
     838           0 :         DATA_BLOB blob;
     839           0 :         enum ndr_err_code err;
     840           0 :         TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
     841           0 :         if (tmp_ctx == NULL) {
     842           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
     843           0 :                 return NULL;
     844             :         }
     845           0 :         err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_preg_header);
     846           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     847           0 :                 TALLOC_FREE(tmp_ctx);
     848           0 :                 PyErr_SetNdrError(err);
     849           0 :                 return NULL;
     850             :         }
     851             : 
     852           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
     853           0 :         TALLOC_FREE(tmp_ctx);
     854           0 :         return ret;
     855             : }
     856             : 
     857           0 : static PyObject *py_preg_header_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
     858             : {
     859           0 :         struct preg_header *object = pytalloc_get_ptr(py_obj);
     860           0 :         DATA_BLOB blob = {.data = NULL, .length = 0};
     861           0 :         Py_ssize_t blob_length = 0;
     862           0 :         enum ndr_err_code err;
     863           0 :         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
     864           0 :         PyObject *allow_remaining_obj = NULL;
     865           0 :         bool allow_remaining = false;
     866             : 
     867           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|O:__ndr_unpack__",
     868             :                 discard_const_p(char *, kwnames),
     869             :                 &blob.data, &blob_length,
     870             :                 &allow_remaining_obj)) {
     871           0 :                 return NULL;
     872             :         }
     873           0 :         blob.length = blob_length;
     874             : 
     875           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
     876           0 :                 allow_remaining = true;
     877             :         }
     878             : 
     879           0 :         if (allow_remaining) {
     880           0 :                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_preg_header);
     881             :         } else {
     882           0 :                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_preg_header);
     883             :         }
     884           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     885           0 :                 PyErr_SetNdrError(err);
     886           0 :                 return NULL;
     887             :         }
     888             : 
     889           0 :         Py_RETURN_NONE;
     890             : }
     891             : 
     892           0 : static PyObject *py_preg_header_ndr_print(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
     893             : {
     894           0 :         struct preg_header *object = pytalloc_get_ptr(py_obj);
     895           0 :         PyObject *ret;
     896           0 :         char *retstr;
     897             : 
     898           0 :         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_preg_header, "preg_header", object);
     899           0 :         ret = PyUnicode_FromString(retstr);
     900           0 :         talloc_free(retstr);
     901             : 
     902           0 :         return ret;
     903             : }
     904             : 
     905             : static PyMethodDef py_preg_header_methods[] = {
     906             :         { "__ndr_pack__", (PyCFunction)py_preg_header_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
     907             :         { "__ndr_unpack__", PY_DISCARD_FUNC_SIG(PyCFunction,py_preg_header_ndr_unpack), METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
     908             :         { "__ndr_print__", (PyCFunction)py_preg_header_ndr_print, METH_NOARGS, "S.ndr_print(object) -> None\nNDR print" },
     909             :         { NULL, NULL, 0, NULL }
     910             : };
     911             : 
     912             : 
     913             : static PyTypeObject preg_header_Type = {
     914             :         PyVarObject_HEAD_INIT(NULL, 0)
     915             :         .tp_name = "preg.header",
     916             :         .tp_getset = py_preg_header_getsetters,
     917             :         .tp_methods = py_preg_header_methods,
     918             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     919             :         .tp_new = py_preg_header_new,
     920             : };
     921             : 
     922             : 
     923         340 : static PyObject *py_preg_file_get_header(PyObject *obj, void *closure)
     924             : {
     925         340 :         struct preg_file *object = pytalloc_get_ptr(obj);
     926           0 :         PyObject *py_header;
     927         340 :         py_header = pytalloc_reference_ex(&preg_header_Type, pytalloc_get_mem_ctx(obj), &object->header);
     928         340 :         return py_header;
     929             : }
     930             : 
     931           0 : static int py_preg_file_set_header(PyObject *py_obj, PyObject *value, void *closure)
     932             : {
     933           0 :         struct preg_file *object = pytalloc_get_ptr(py_obj);
     934           0 :         if (value == NULL) {
     935           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->header");
     936           0 :                 return -1;
     937             :         }
     938           0 :         PY_CHECK_TYPE(&preg_header_Type, value, return -1;);
     939           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
     940           0 :                 PyErr_NoMemory();
     941           0 :                 return -1;
     942             :         }
     943           0 :         object->header = *(struct preg_header *)pytalloc_get_ptr(value);
     944           0 :         return 0;
     945             : }
     946             : 
     947          76 : static PyObject *py_preg_file_get_num_entries(PyObject *obj, void *closure)
     948             : {
     949          76 :         struct preg_file *object = pytalloc_get_ptr(obj);
     950           0 :         PyObject *py_num_entries;
     951          76 :         py_num_entries = PyLong_FromUnsignedLongLong((uint32_t)(object->num_entries));
     952          76 :         return py_num_entries;
     953             : }
     954             : 
     955         240 : static int py_preg_file_set_num_entries(PyObject *py_obj, PyObject *value, void *closure)
     956             : {
     957         240 :         struct preg_file *object = pytalloc_get_ptr(py_obj);
     958         240 :         if (value == NULL) {
     959           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->num_entries");
     960           0 :                 return -1;
     961             :         }
     962             :         {
     963         240 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->num_entries));
     964         240 :                 if (PyLong_Check(value)) {
     965           0 :                         unsigned long long test_var;
     966         240 :                         test_var = PyLong_AsUnsignedLongLong(value);
     967         240 :                         if (PyErr_Occurred() != NULL) {
     968           0 :                                 return -1;
     969             :                         }
     970         240 :                         if (test_var > uint_max) {
     971           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     972             :                                   PyLong_Type.tp_name, uint_max, test_var);
     973           0 :                                 return -1;
     974             :                         }
     975         240 :                         object->num_entries = test_var;
     976             :                 } else {
     977           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     978             :                           PyLong_Type.tp_name);
     979           0 :                         return -1;
     980             :                 }
     981             :         }
     982         240 :         return 0;
     983             : }
     984             : 
     985        2232 : static PyObject *py_preg_file_get_entries(PyObject *obj, void *closure)
     986             : {
     987        2232 :         struct preg_file *object = pytalloc_get_ptr(obj);
     988           0 :         PyObject *py_entries;
     989        2232 :         py_entries = PyList_New(object->num_entries);
     990        2232 :         if (py_entries == NULL) {
     991           0 :                 return NULL;
     992             :         }
     993             :         {
     994             :                 int entries_cntr_0;
     995       34804 :                 for (entries_cntr_0 = 0; entries_cntr_0 < (object->num_entries); entries_cntr_0++) {
     996           0 :                         PyObject *py_entries_0;
     997       32572 :                         py_entries_0 = pytalloc_reference_ex(&preg_entry_Type, object->entries, &(object->entries)[entries_cntr_0]);
     998       32572 :                         PyList_SetItem(py_entries, entries_cntr_0, py_entries_0);
     999             :                 }
    1000             :         }
    1001        2232 :         return py_entries;
    1002             : }
    1003             : 
    1004         240 : static int py_preg_file_set_entries(PyObject *py_obj, PyObject *value, void *closure)
    1005             : {
    1006         240 :         struct preg_file *object = pytalloc_get_ptr(py_obj);
    1007         240 :         if (value == NULL) {
    1008           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->entries");
    1009           0 :                 return -1;
    1010             :         }
    1011         240 :         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    1012             :         {
    1013           0 :                 int entries_cntr_0;
    1014         240 :                 object->entries = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->entries, PyList_GET_SIZE(value));
    1015         240 :                 if (!object->entries) { return -1; }
    1016         240 :                 talloc_set_name_const(object->entries, "ARRAY: object->entries");
    1017        6420 :                 for (entries_cntr_0 = 0; entries_cntr_0 < PyList_GET_SIZE(value); entries_cntr_0++) {
    1018        6180 :                         if (PyList_GET_ITEM(value, entries_cntr_0) == NULL) {
    1019           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (object->entries)[entries_cntr_0]");
    1020           0 :                                 return -1;
    1021             :                         }
    1022        6180 :                         PY_CHECK_TYPE(&preg_entry_Type, PyList_GET_ITEM(value, entries_cntr_0), return -1;);
    1023        6180 :                         if (talloc_reference(object->entries, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, entries_cntr_0))) == NULL) {
    1024           0 :                                 PyErr_NoMemory();
    1025           0 :                                 return -1;
    1026             :                         }
    1027        6180 :                         (object->entries)[entries_cntr_0] = *(struct preg_entry *)pytalloc_get_ptr(PyList_GET_ITEM(value, entries_cntr_0));
    1028             :                 }
    1029             :         }
    1030         240 :         return 0;
    1031             : }
    1032             : 
    1033             : static PyGetSetDef py_preg_file_getsetters[] = {
    1034             :         {
    1035             :                 .name = discard_const_p(char, "header"),
    1036             :                 .get = py_preg_file_get_header,
    1037             :                 .set = py_preg_file_set_header,
    1038             :                 .doc = discard_const_p(char, "PIDL-generated element of base type preg_header")
    1039             :         },
    1040             :         {
    1041             :                 .name = discard_const_p(char, "num_entries"),
    1042             :                 .get = py_preg_file_get_num_entries,
    1043             :                 .set = py_preg_file_set_num_entries,
    1044             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1045             :         },
    1046             :         {
    1047             :                 .name = discard_const_p(char, "entries"),
    1048             :                 .get = py_preg_file_get_entries,
    1049             :                 .set = py_preg_file_set_entries,
    1050             :                 .doc = discard_const_p(char, "PIDL-generated element of base type preg_entry")
    1051             :         },
    1052             :         { .name = NULL }
    1053             : };
    1054             : 
    1055        2300 : static PyObject *py_preg_file_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1056             : {
    1057        2300 :         return pytalloc_new(struct preg_file, type);
    1058             : }
    1059             : 
    1060         204 : static PyObject *py_preg_file_ndr_pack(PyObject *py_obj,  PyObject *Py_UNUSED(ignored))
    1061             : {
    1062         204 :         struct preg_file *object = pytalloc_get_ptr(py_obj);
    1063         204 :         PyObject *ret = NULL;
    1064           0 :         DATA_BLOB blob;
    1065           0 :         enum ndr_err_code err;
    1066         204 :         TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
    1067         204 :         if (tmp_ctx == NULL) {
    1068           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    1069           0 :                 return NULL;
    1070             :         }
    1071         204 :         err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_preg_file);
    1072         204 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    1073           0 :                 TALLOC_FREE(tmp_ctx);
    1074           0 :                 PyErr_SetNdrError(err);
    1075           0 :                 return NULL;
    1076             :         }
    1077             : 
    1078         204 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    1079         204 :         TALLOC_FREE(tmp_ctx);
    1080         204 :         return ret;
    1081             : }
    1082             : 
    1083        2124 : static PyObject *py_preg_file_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1084             : {
    1085        2124 :         struct preg_file *object = pytalloc_get_ptr(py_obj);
    1086        2124 :         DATA_BLOB blob = {.data = NULL, .length = 0};
    1087        2124 :         Py_ssize_t blob_length = 0;
    1088           0 :         enum ndr_err_code err;
    1089        2124 :         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
    1090        2124 :         PyObject *allow_remaining_obj = NULL;
    1091        2124 :         bool allow_remaining = false;
    1092             : 
    1093        2124 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|O:__ndr_unpack__",
    1094             :                 discard_const_p(char *, kwnames),
    1095             :                 &blob.data, &blob_length,
    1096             :                 &allow_remaining_obj)) {
    1097           0 :                 return NULL;
    1098             :         }
    1099        2124 :         blob.length = blob_length;
    1100             : 
    1101        2124 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    1102           0 :                 allow_remaining = true;
    1103             :         }
    1104             : 
    1105        2124 :         if (allow_remaining) {
    1106           0 :                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_preg_file);
    1107             :         } else {
    1108        2124 :                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_preg_file);
    1109             :         }
    1110        2124 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    1111           0 :                 PyErr_SetNdrError(err);
    1112           0 :                 return NULL;
    1113             :         }
    1114             : 
    1115        2124 :         Py_RETURN_NONE;
    1116             : }
    1117             : 
    1118           0 : static PyObject *py_preg_file_ndr_print(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    1119             : {
    1120           0 :         struct preg_file *object = pytalloc_get_ptr(py_obj);
    1121           0 :         PyObject *ret;
    1122           0 :         char *retstr;
    1123             : 
    1124           0 :         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_preg_file, "preg_file", object);
    1125           0 :         ret = PyUnicode_FromString(retstr);
    1126           0 :         talloc_free(retstr);
    1127             : 
    1128           0 :         return ret;
    1129             : }
    1130             : 
    1131             : static PyMethodDef py_preg_file_methods[] = {
    1132             :         { "__ndr_pack__", (PyCFunction)py_preg_file_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
    1133             :         { "__ndr_unpack__", PY_DISCARD_FUNC_SIG(PyCFunction,py_preg_file_ndr_unpack), METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
    1134             :         { "__ndr_print__", (PyCFunction)py_preg_file_ndr_print, METH_NOARGS, "S.ndr_print(object) -> None\nNDR print" },
    1135             :         { NULL, NULL, 0, NULL }
    1136             : };
    1137             : 
    1138             : 
    1139             : static PyTypeObject preg_file_Type = {
    1140             :         PyVarObject_HEAD_INIT(NULL, 0)
    1141             :         .tp_name = "preg.file",
    1142             :         .tp_getset = py_preg_file_getsetters,
    1143             :         .tp_methods = py_preg_file_methods,
    1144             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1145             :         .tp_new = py_preg_file_new,
    1146             : };
    1147             : 
    1148             : 
    1149             : const struct PyNdrRpcMethodDef py_ndr_preg_methods[] = {
    1150             :         {0}
    1151             : };
    1152             : 
    1153           0 : static PyObject *interface_preg_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1154             : {
    1155           0 :         return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_preg);
    1156             : }
    1157             : 
    1158             : #define PY_DOC_PREG "PReg structure"
    1159             : static PyTypeObject preg_InterfaceType = {
    1160             :         PyVarObject_HEAD_INIT(NULL, 0)
    1161             :         .tp_name = "preg.preg",
    1162             :         .tp_basicsize = sizeof(dcerpc_InterfaceObject),
    1163             :         .tp_doc = "preg(binding, lp_ctx=None, credentials=None) -> connection\n"
    1164             : "\n"
    1165             : "binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
    1166             : "lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
    1167             : "credentials should be a credentials.Credentials object.\n\n"PY_DOC_PREG,
    1168             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1169             :         .tp_new = interface_preg_new,
    1170             : };
    1171             : 
    1172           0 : static PyObject *syntax_preg_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1173             : {
    1174           0 :         return py_dcerpc_syntax_init_helper(type, args, kwargs, &ndr_table_preg.syntax_id);
    1175             : }
    1176             : 
    1177             : #define PY_DOC_PREG_SYNTAX "PReg structure"
    1178             : static PyTypeObject preg_SyntaxType = {
    1179             :         PyVarObject_HEAD_INIT(NULL, 0)
    1180             :         .tp_name = "preg.preg_abstract_syntax",
    1181             :         .tp_doc = "preg_abstract_syntax()\n"PY_DOC_PREG_SYNTAX,
    1182             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1183             :         .tp_new = syntax_preg_new,
    1184             : };
    1185             : 
    1186             : static PyMethodDef preg_methods[] = {
    1187             :         { NULL, NULL, 0, NULL }
    1188             : };
    1189             : 
    1190             : static struct PyModuleDef moduledef = {
    1191             :         PyModuleDef_HEAD_INIT,
    1192             :         .m_name = "preg",
    1193             :         .m_doc = "preg DCE/RPC",
    1194             :         .m_size = -1,
    1195             :         .m_methods = preg_methods,
    1196             : };
    1197         338 : MODULE_INIT_FUNC(preg)
    1198             : {
    1199         338 :         PyObject *m = NULL;
    1200         338 :         PyObject *dep_samba_dcerpc_misc = NULL;
    1201         338 :         PyObject *dep_talloc = NULL;
    1202         338 :         PyObject *dep_samba_dcerpc_base = NULL;
    1203             : 
    1204         338 :         dep_samba_dcerpc_misc = PyImport_ImportModule("samba.dcerpc.misc");
    1205         338 :         if (dep_samba_dcerpc_misc == NULL)
    1206           0 :                 goto out;
    1207             : 
    1208         338 :         dep_talloc = PyImport_ImportModule("talloc");
    1209         338 :         if (dep_talloc == NULL)
    1210           0 :                 goto out;
    1211             : 
    1212         338 :         dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
    1213         338 :         if (dep_samba_dcerpc_base == NULL)
    1214           0 :                 goto out;
    1215             : 
    1216         338 :         winreg_Data_GPO_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "winreg_Data_GPO");
    1217         338 :         if (winreg_Data_GPO_Type == NULL)
    1218           0 :                 goto out;
    1219             : 
    1220         338 :         BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
    1221         338 :         if (BaseObject_Type == NULL)
    1222           0 :                 goto out;
    1223             : 
    1224         338 :         ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
    1225         338 :         if (ClientConnection_Type == NULL)
    1226           0 :                 goto out;
    1227             : 
    1228         338 :         ndr_syntax_id_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "ndr_syntax_id");
    1229         338 :         if (ndr_syntax_id_Type == NULL)
    1230           0 :                 goto out;
    1231             : 
    1232         338 :         preg_entry_Type.tp_base = BaseObject_Type;
    1233         338 :         preg_entry_Type.tp_basicsize = pytalloc_BaseObject_size();
    1234             : 
    1235         338 :         preg_header_Type.tp_base = BaseObject_Type;
    1236         338 :         preg_header_Type.tp_basicsize = pytalloc_BaseObject_size();
    1237             : 
    1238         338 :         preg_file_Type.tp_base = BaseObject_Type;
    1239         338 :         preg_file_Type.tp_basicsize = pytalloc_BaseObject_size();
    1240             : 
    1241         338 :         preg_InterfaceType.tp_base = ClientConnection_Type;
    1242             : 
    1243         338 :         preg_SyntaxType.tp_base = ndr_syntax_id_Type;
    1244         338 :         preg_SyntaxType.tp_basicsize = pytalloc_BaseObject_size();
    1245             : 
    1246         338 :         if (PyType_Ready(&preg_entry_Type) < 0)
    1247           0 :                 goto out;
    1248         338 :         if (PyType_Ready(&preg_header_Type) < 0)
    1249           0 :                 goto out;
    1250         338 :         if (PyType_Ready(&preg_file_Type) < 0)
    1251           0 :                 goto out;
    1252         338 :         if (PyType_Ready(&preg_InterfaceType) < 0)
    1253           0 :                 goto out;
    1254         338 :         if (PyType_Ready(&preg_SyntaxType) < 0)
    1255           0 :                 goto out;
    1256         338 :         if (!PyInterface_AddNdrRpcMethods(&preg_InterfaceType, py_ndr_preg_methods))
    1257           0 :                 return NULL;
    1258             : 
    1259             : #ifdef PY_ENTRY_PATCH
    1260             :         PY_ENTRY_PATCH(&preg_entry_Type);
    1261             : #endif
    1262             : #ifdef PY_HEADER_PATCH
    1263             :         PY_HEADER_PATCH(&preg_header_Type);
    1264             : #endif
    1265             : #ifdef PY_FILE_PATCH
    1266             :         PY_FILE_PATCH(&preg_file_Type);
    1267             : #endif
    1268             : #ifdef PY_PREG_PATCH
    1269             :         PY_PREG_PATCH(&preg_InterfaceType);
    1270             : #endif
    1271             : #ifdef PY_PREG_ABSTRACT_SYNTAX_PATCH
    1272             :         PY_PREG_ABSTRACT_SYNTAX_PATCH(&preg_SyntaxType);
    1273             : #endif
    1274             : #ifdef PY_ABSTRACT_SYNTAX_PATCH
    1275             :         PY_ABSTRACT_SYNTAX_PATCH(&preg_SyntaxType);
    1276             : #endif
    1277             : 
    1278         338 :         m = PyModule_Create(&moduledef);
    1279         338 :         if (m == NULL)
    1280           0 :                 goto out;
    1281             : 
    1282         283 :         Py_INCREF((PyObject *)(void *)&preg_entry_Type);
    1283         338 :         PyModule_AddObject(m, "entry", (PyObject *)(void *)&preg_entry_Type);
    1284         283 :         Py_INCREF((PyObject *)(void *)&preg_header_Type);
    1285         338 :         PyModule_AddObject(m, "header", (PyObject *)(void *)&preg_header_Type);
    1286         283 :         Py_INCREF((PyObject *)(void *)&preg_file_Type);
    1287         338 :         PyModule_AddObject(m, "file", (PyObject *)(void *)&preg_file_Type);
    1288         283 :         Py_INCREF((PyObject *)(void *)&preg_InterfaceType);
    1289         338 :         PyModule_AddObject(m, "preg", (PyObject *)(void *)&preg_InterfaceType);
    1290         283 :         Py_INCREF((PyObject *)(void *)&preg_SyntaxType);
    1291         338 :         PyModule_AddObject(m, "preg_abstract_syntax", (PyObject *)(void *)&preg_SyntaxType);
    1292         283 :         Py_INCREF((PyObject *)(void *)&preg_SyntaxType);
    1293         338 :         PyModule_AddObject(m, "abstract_syntax", (PyObject *)(void *)&preg_SyntaxType);
    1294             : #ifdef PY_MOD_PREG_PATCH
    1295             :         PY_MOD_PREG_PATCH(m);
    1296             : #endif
    1297         338 :         out:
    1298         338 :         Py_XDECREF(dep_samba_dcerpc_misc);
    1299         338 :         Py_XDECREF(dep_talloc);
    1300         338 :         Py_XDECREF(dep_samba_dcerpc_base);
    1301         337 :         return m;
    1302             : 
    1303             : }

Generated by: LCOV version 1.14