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

Generated by: LCOV version 1.13