From ed0a6480f75b3eefc52bc3311d8c3816abefcff2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 5 Apr 2002 05:48:01 +0000 Subject: [PATCH] Converted drivers, forms and ports functions to use new conversion routines and exception throwing. --- source/python/py_spoolss_drivers.c | 123 ++++++--------------- source/python/py_spoolss_drivers_conv.c | 137 ++++++++++++++++++++++++ source/python/py_spoolss_forms.c | 54 +++------- source/python/py_spoolss_forms_conv.c | 57 ++++++++++ source/python/py_spoolss_ports.c | 20 +--- source/python/py_spoolss_ports_conv.c | 58 ++++++++++ 6 files changed, 304 insertions(+), 145 deletions(-) create mode 100644 source/python/py_spoolss_drivers_conv.c create mode 100644 source/python/py_spoolss_forms_conv.c create mode 100644 source/python/py_spoolss_ports_conv.c diff --git a/source/python/py_spoolss_drivers.c b/source/python/py_spoolss_drivers.c index b19d93b4c14..5c0d6174cf0 100644 --- a/source/python/py_spoolss_drivers.c +++ b/source/python/py_spoolss_drivers.c @@ -20,66 +20,6 @@ #include "python/py_spoolss.h" -/* Structure/hash conversions */ - -struct pyconv py_DRIVER_INFO_1[] = { - { "name", PY_UNISTR, offsetof(DRIVER_INFO_1, name) }, - { NULL } -}; - -struct pyconv py_DRIVER_INFO_2[] = { - { "version", PY_UINT32, offsetof(DRIVER_INFO_2, version) }, - { "name", PY_UNISTR, offsetof(DRIVER_INFO_2, name) }, - { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_2, architecture) }, - { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_2, driverpath) }, - { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_2, datafile) }, - { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_2, configfile) }, - { NULL } -}; - -struct pyconv py_DRIVER_INFO_3[] = { - { "version", PY_UINT32, offsetof(DRIVER_INFO_3, version) }, - { "name", PY_UNISTR, offsetof(DRIVER_INFO_3, name) }, - { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_3, architecture) }, - { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_3, driverpath) }, - { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_3, datafile) }, - { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_3, configfile) }, - { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_3, helpfile) }, - /* dependentfiles */ - { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_3, monitorname) }, - { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_3, defaultdatatype) }, - { NULL } -}; - -struct pyconv py_DRIVER_INFO_6[] = { - { "version", PY_UINT32, offsetof(DRIVER_INFO_6, version) }, - { "name", PY_UNISTR, offsetof(DRIVER_INFO_6, name) }, - { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_6, architecture) }, - { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_6, driverpath) }, - { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_6, datafile) }, - { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_6, configfile) }, - { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_6, helpfile) }, - /* dependentfiles */ - { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_6, monitorname) }, - { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_6, defaultdatatype) }, - /* driver_date */ - - { "padding", PY_UINT32, offsetof(DRIVER_INFO_6, padding) }, - { "driver_version_low", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_low) }, - { "driver_version_high", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_high) }, - { "mfg_name", PY_UNISTR, offsetof(DRIVER_INFO_6, mfgname) }, - { "oem_url", PY_UNISTR, offsetof(DRIVER_INFO_6, oem_url) }, - { "hardware_id", PY_UNISTR, offsetof(DRIVER_INFO_6, hardware_id) }, - { "provider", PY_UNISTR, offsetof(DRIVER_INFO_6, provider) }, - - { NULL } -}; - -struct pyconv py_DRIVER_DIRECTORY_1[] = { - { "name", PY_UNISTR, offsetof(DRIVER_DIRECTORY_1, name) }, - { NULL } -}; - /* Enumerate printer drivers */ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, @@ -124,11 +64,13 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, cli, mem_ctx, needed, NULL, level, arch, &num_drivers, &ctr); + if (!W_ERROR_IS_OK(werror)) { + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); + return NULL; + } + /* Return value */ - if (!W_ERROR_IS_OK(werror)) - goto done; - switch (level) { case 1: result = PyList_New(num_drivers); @@ -136,7 +78,7 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, for (i = 0; i < num_drivers; i++) { PyObject *value; - value = from_struct(&ctr.info1, py_DRIVER_INFO_1); + py_from_DRIVER_INFO_1(&value, ctr.info1); PyList_SetItem(result, i, value); } @@ -147,7 +89,7 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, for(i = 0; i < num_drivers; i++) { PyObject *value; - value = from_struct(&ctr.info2, py_DRIVER_INFO_2); + py_from_DRIVER_INFO_2(&value, ctr.info2); PyList_SetItem(result, i, value); } @@ -158,7 +100,7 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, for(i = 0; i < num_drivers; i++) { PyObject *value; - value = from_struct(&ctr.info2, py_DRIVER_INFO_6); + py_from_DRIVER_INFO_6(&value, ctr.info6); PyList_SetItem(result, i, value); } @@ -210,22 +152,25 @@ PyObject *spoolss_getprinterdriver(PyObject *self, PyObject *args, hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol, level, arch, &ctr); + if (!W_ERROR_IS_OK(werror)) { + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); + return NULL; + } + /* Return value */ - if (W_ERROR_IS_OK(werror)) { - switch (level) { - case 1: - result = from_struct(&ctr.info1, py_DRIVER_INFO_1); - break; - case 2: - result = from_struct(&ctr.info2, py_DRIVER_INFO_2); - break; - case 6: - result = from_struct(&ctr.info6, py_DRIVER_INFO_6); - break; - default: - break; - } + switch (level) { + case 1: + py_from_DRIVER_INFO_1(&result, ctr.info1); + break; + case 2: + py_from_DRIVER_INFO_2(&result, ctr.info2); + break; + case 6: + py_from_DRIVER_INFO_6(&result, ctr.info6); + break; + default: + break; } Py_INCREF(result); @@ -273,17 +218,17 @@ PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args, werror = cli_spoolss_getprinterdriverdir( cli, mem_ctx, needed, NULL, level, arch, &ctr); + if (!W_ERROR_IS_OK(werror)) { + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); + return NULL; + } + /* Return value */ - if (W_ERROR_IS_OK(werror)) { - switch (level) { - case 1: - result = from_struct( - &ctr.info1, py_DRIVER_DIRECTORY_1); - break; - default: - break; - } + switch (level) { + case 1: + py_from_DRIVER_DIRECTORY_1(&result, ctr.info1); + break; } done: diff --git a/source/python/py_spoolss_drivers_conv.c b/source/python/py_spoolss_drivers_conv.c new file mode 100644 index 00000000000..70a57a13575 --- /dev/null +++ b/source/python/py_spoolss_drivers_conv.c @@ -0,0 +1,137 @@ +/* + Python wrappers for DCERPC/SMB client routines. + + Copyright (C) Tim Potter, 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "python/py_spoolss.h" +#include "python/py_conv.h" + +/* Structure/hash conversions */ + +struct pyconv py_DRIVER_INFO_1[] = { + { "name", PY_UNISTR, offsetof(DRIVER_INFO_1, name) }, + { NULL } +}; + +struct pyconv py_DRIVER_INFO_2[] = { + { "version", PY_UINT32, offsetof(DRIVER_INFO_2, version) }, + { "name", PY_UNISTR, offsetof(DRIVER_INFO_2, name) }, + { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_2, architecture) }, + { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_2, driverpath) }, + { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_2, datafile) }, + { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_2, configfile) }, + { NULL } +}; + +struct pyconv py_DRIVER_INFO_3[] = { + { "version", PY_UINT32, offsetof(DRIVER_INFO_3, version) }, + { "name", PY_UNISTR, offsetof(DRIVER_INFO_3, name) }, + { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_3, architecture) }, + { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_3, driverpath) }, + { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_3, datafile) }, + { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_3, configfile) }, + { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_3, helpfile) }, + /* dependentfiles */ + { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_3, monitorname) }, + { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_3, defaultdatatype) }, + { NULL } +}; + +struct pyconv py_DRIVER_INFO_6[] = { + { "version", PY_UINT32, offsetof(DRIVER_INFO_6, version) }, + { "name", PY_UNISTR, offsetof(DRIVER_INFO_6, name) }, + { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_6, architecture) }, + { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_6, driverpath) }, + { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_6, datafile) }, + { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_6, configfile) }, + { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_6, helpfile) }, + /* dependentfiles */ + { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_6, monitorname) }, + { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_6, defaultdatatype) }, + /* driver_date */ + + { "padding", PY_UINT32, offsetof(DRIVER_INFO_6, padding) }, + { "driver_version_low", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_low) }, + { "driver_version_high", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_high) }, + { "mfg_name", PY_UNISTR, offsetof(DRIVER_INFO_6, mfgname) }, + { "oem_url", PY_UNISTR, offsetof(DRIVER_INFO_6, oem_url) }, + { "hardware_id", PY_UNISTR, offsetof(DRIVER_INFO_6, hardware_id) }, + { "provider", PY_UNISTR, offsetof(DRIVER_INFO_6, provider) }, + + { NULL } +}; + +struct pyconv py_DRIVER_DIRECTORY_1[] = { + { "name", PY_UNISTR, offsetof(DRIVER_DIRECTORY_1, name) }, + { NULL } +}; + +BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info) +{ + *dict = from_struct(info, py_DRIVER_INFO_1); + return True; +} + +BOOL py_to_DRIVER_INFO_1(DRIVER_INFO_1 *info, PyObject *dict) +{ + return False; +} + +BOOL py_from_DRIVER_INFO_2(PyObject **dict, DRIVER_INFO_2 *info) +{ + *dict = from_struct(info, py_DRIVER_INFO_2); + return True; +} + +BOOL py_to_DRIVER_INFO_2(DRIVER_INFO_2 *info, PyObject *dict) +{ + return False; +} + +BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info) +{ + *dict = from_struct(info, py_DRIVER_INFO_3); + return True; +} + +BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict) +{ + return False; +} + +BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info) +{ + *dict = from_struct(info, py_DRIVER_INFO_6); + return True; +} + +BOOL py_to_DRIVER_INFO_6(DRIVER_INFO_6 *info, PyObject *dict) +{ + return False; +} + +BOOL py_from_DRIVER_DIRECTORY_1(PyObject **dict, DRIVER_DIRECTORY_1 *info) +{ + *dict = from_struct(info, py_DRIVER_DIRECTORY_1); + return True; +} + +BOOL py_to_DRIVER_DIRECTORY_1(DRIVER_DIRECTORY_1 *info, PyObject *dict) +{ + return False; +} diff --git a/source/python/py_spoolss_forms.c b/source/python/py_spoolss_forms.c index 75e37f3f0d8..f7b80d0f330 100644 --- a/source/python/py_spoolss_forms.c +++ b/source/python/py_spoolss_forms.c @@ -20,29 +20,6 @@ #include "python/py_spoolss.h" -struct pyconv py_FORM[] = { - { "flags", PY_UINT32, offsetof(FORM, flags) }, - { "width", PY_UINT32, offsetof(FORM, size_x) }, - { "length", PY_UINT32, offsetof(FORM, size_y) }, - { "top", PY_UINT32, offsetof(FORM, top) }, - { "left", PY_UINT32, offsetof(FORM, left) }, - { "right", PY_UINT32, offsetof(FORM, right) }, - { "bottom", PY_UINT32, offsetof(FORM, bottom) }, - { NULL } -}; - -struct pyconv py_FORM_1[] = { - { "flags", PY_UINT32, offsetof(FORM_1, flag) }, - { "width", PY_UINT32, offsetof(FORM_1, width) }, - { "length", PY_UINT32, offsetof(FORM_1, length) }, - { "top", PY_UINT32, offsetof(FORM_1, top) }, - { "left", PY_UINT32, offsetof(FORM_1, left) }, - { "right", PY_UINT32, offsetof(FORM_1, right) }, - { "bottom", PY_UINT32, offsetof(FORM_1, bottom) }, - { "name", PY_UNISTR, offsetof(FORM_1, name) }, - { NULL } -}; - /* Add a form */ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) @@ -67,7 +44,10 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) PyObject *py_form_name; char *form_name; - to_struct(&form, py_form, py_FORM); + if (!py_to_FORM(&form, py_form)) { + PyErr_SetString(spoolss_error, "invalid form"); + return NULL; + } py_form_name = PyDict_GetItemString(py_form, "name"); form_name = PyString_AsString(py_form_name); @@ -86,8 +66,7 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, - PyInt_FromLong(W_ERROR_V(werror))); + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); return NULL; } @@ -125,8 +104,7 @@ PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw) form_name, 1, &form); if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, - PyInt_FromLong(W_ERROR_V(werror))); + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); return NULL; } @@ -134,7 +112,7 @@ PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw) switch(level) { case 1: - result = from_struct(&form, py_FORM_1); + py_from_FORM_1(&result, &form); break; } @@ -163,16 +141,18 @@ PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw) /* Call rpc function */ - to_struct(&form, py_form, py_FORM); + if (!py_to_FORM(&form, py_form)) { + PyErr_SetString(spoolss_error, "invalid form"); + return NULL; + } + init_unistr2(&form.name, form_name, strlen(form_name) + 1); werror = cli_spoolss_setform(hnd->cli, hnd->mem_ctx, &hnd->pol, level, form_name, &form); if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, - PyInt_FromLong(W_ERROR_V(werror))); - + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); return NULL; } @@ -202,8 +182,7 @@ PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw) hnd->cli, hnd->mem_ctx, &hnd->pol, form_name); if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, - PyInt_FromLong(W_ERROR_V(werror))); + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); return NULL; } @@ -240,8 +219,7 @@ PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw) &num_forms, &forms); if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, - PyInt_FromLong(W_ERROR_V(werror))); + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); return NULL; } @@ -252,7 +230,7 @@ PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw) switch(level) { case 1: - obj = from_struct(&forms[i], py_FORM_1); + py_from_FORM_1(&obj, &forms[i]); break; } diff --git a/source/python/py_spoolss_forms_conv.c b/source/python/py_spoolss_forms_conv.c new file mode 100644 index 00000000000..2ded9afe91f --- /dev/null +++ b/source/python/py_spoolss_forms_conv.c @@ -0,0 +1,57 @@ +/* + Python wrappers for DCERPC/SMB client routines. + + Copyright (C) Tim Potter, 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "python/py_spoolss.h" +#include "python/py_conv.h" + +struct pyconv py_FORM[] = { + { "flags", PY_UINT32, offsetof(FORM, flags) }, + { "width", PY_UINT32, offsetof(FORM, size_x) }, + { "length", PY_UINT32, offsetof(FORM, size_y) }, + { "top", PY_UINT32, offsetof(FORM, top) }, + { "left", PY_UINT32, offsetof(FORM, left) }, + { "right", PY_UINT32, offsetof(FORM, right) }, + { "bottom", PY_UINT32, offsetof(FORM, bottom) }, + { NULL } +}; + +struct pyconv py_FORM_1[] = { + { "flags", PY_UINT32, offsetof(FORM_1, flag) }, + { "width", PY_UINT32, offsetof(FORM_1, width) }, + { "length", PY_UINT32, offsetof(FORM_1, length) }, + { "top", PY_UINT32, offsetof(FORM_1, top) }, + { "left", PY_UINT32, offsetof(FORM_1, left) }, + { "right", PY_UINT32, offsetof(FORM_1, right) }, + { "bottom", PY_UINT32, offsetof(FORM_1, bottom) }, + { "name", PY_UNISTR, offsetof(FORM_1, name) }, + { NULL } +}; + +BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form) +{ + *dict = from_struct(form, py_FORM_1); + return True; +} + +BOOL py_to_FORM(FORM *form, PyObject *dict) +{ + to_struct(form, dict, py_FORM); + return True; +} diff --git a/source/python/py_spoolss_ports.c b/source/python/py_spoolss_ports.c index d224408476e..2d73a6e033e 100644 --- a/source/python/py_spoolss_ports.c +++ b/source/python/py_spoolss_ports.c @@ -20,20 +20,6 @@ #include "python/py_spoolss.h" -struct pyconv py_PORT_INFO_1[] = { - { "name", PY_UNISTR, offsetof(PORT_INFO_1, port_name) }, - { NULL } -}; - -struct pyconv py_PORT_INFO_2[] = { - { "name", PY_UNISTR, offsetof(PORT_INFO_2, port_name) }, - { "monitor_name", PY_UNISTR, offsetof(PORT_INFO_2, monitor_name) }, - { "description", PY_UNISTR, offsetof(PORT_INFO_2, description) }, - { "reserved", PY_UINT32, offsetof(PORT_INFO_2, reserved) }, - { "type", PY_UINT32, offsetof(PORT_INFO_2, port_type) }, - { NULL } -}; - /* Enumerate ports */ PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw) @@ -85,8 +71,7 @@ PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw) for (i = 0; i < num_ports; i++) { PyObject *value; - value = from_struct ( - &ctr.port.info_1[i], py_PORT_INFO_1); + py_from_PORT_INFO_1(&value, &ctr.port.info_1[i]); PyList_SetItem(result, i, value); } @@ -96,8 +81,7 @@ PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw) for(i = 0; i < num_ports; i++) { PyObject *value; - value = from_struct( - &ctr.port.info_2[i], py_PORT_INFO_2); + py_from_PORT_INFO_2(&value, &ctr.port.info_2[i]); PyList_SetItem(result, i, value); } diff --git a/source/python/py_spoolss_ports_conv.c b/source/python/py_spoolss_ports_conv.c new file mode 100644 index 00000000000..3f6d94bf7e7 --- /dev/null +++ b/source/python/py_spoolss_ports_conv.c @@ -0,0 +1,58 @@ +/* + Python wrappers for DCERPC/SMB client routines. + + Copyright (C) Tim Potter, 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "python/py_spoolss.h" +#include "python/py_conv.h" + +struct pyconv py_PORT_INFO_1[] = { + { "name", PY_UNISTR, offsetof(PORT_INFO_1, port_name) }, + { NULL } +}; + +struct pyconv py_PORT_INFO_2[] = { + { "name", PY_UNISTR, offsetof(PORT_INFO_2, port_name) }, + { "monitor_name", PY_UNISTR, offsetof(PORT_INFO_2, monitor_name) }, + { "description", PY_UNISTR, offsetof(PORT_INFO_2, description) }, + { "reserved", PY_UINT32, offsetof(PORT_INFO_2, reserved) }, + { "type", PY_UINT32, offsetof(PORT_INFO_2, port_type) }, + { NULL } +}; + +BOOL py_from_PORT_INFO_1(PyObject **dict, PORT_INFO_1 *info) +{ + *dict = from_struct(info, py_PORT_INFO_1); + return True; +} + +BOOL py_to_PORT_INFO_1(PORT_INFO_1 *info, PyObject *dict) +{ + return False; +} + +BOOL py_from_PORT_INFO_2(PyObject **dict, PORT_INFO_2 *info) +{ + *dict = from_struct(info, py_PORT_INFO_2); + return True; +} + +BOOL py_to_PORT_INFO_2(PORT_INFO_2 *info, PyObject *dict) +{ + return False; +} -- 2.34.1