From 520b40e4235f26cf2bc670128ff277141084e53c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 14 May 2002 02:37:47 +0000 Subject: General cleanup of compiler warnings etc. (This used to be commit 18aeadc591b69bbbd874b7285ecaed50ff587e68) --- source3/python/py_common.h | 2 ++ source3/python/py_lsa.c | 42 ++++++++++++++++++------ source3/python/py_samr.c | 27 +++++++++++++--- source3/python/py_spoolss.c | 78 ++++++++++++++++++++++++++------------------- source3/python/py_winbind.c | 8 ++--- source3/python/py_winreg.c | 11 +++---- source3/python/py_winreg.h | 29 +++++++++++++++++ 7 files changed, 139 insertions(+), 58 deletions(-) create mode 100644 source3/python/py_winreg.h (limited to 'source3') diff --git a/source3/python/py_common.h b/source3/python/py_common.h index 6661d87fe0..f13224a020 100644 --- a/source3/python/py_common.h +++ b/source3/python/py_common.h @@ -21,6 +21,8 @@ #ifndef _PY_COMMON_H #define _PY_COMMON_H +#include "includes.h" + /* Return a cli_state struct opened on the SPOOLSS pipe. If credentials are passed use them. */ diff --git a/source3/python/py_lsa.c b/source3/python/py_lsa.c index 82ae99c53e..23566282f6 100644 --- a/source3/python/py_lsa.c +++ b/source3/python/py_lsa.c @@ -18,9 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" -#include "Python.h" - #include "python/py_lsa.h" PyObject *new_lsa_policy_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, @@ -300,15 +297,18 @@ static PyMethodDef lsa_hnd_methods[] = { /* SIDs<->names */ - { "lookup_sids", lsa_lookup_sids, METH_VARARGS | METH_KEYWORDS, + { "lookup_sids", (PyCFunction)lsa_lookup_sids, + METH_VARARGS | METH_KEYWORDS, "Convert sids to names." }, - { "lookup_names", lsa_lookup_names, METH_VARARGS | METH_KEYWORDS, + { "lookup_names", (PyCFunction)lsa_lookup_names, + METH_VARARGS | METH_KEYWORDS, "Convert names to sids." }, /* Trusted domains */ - { "enum_trusted_domains", lsa_enum_trust_dom, METH_VARARGS, + { "enum_trusted_domains", (PyCFunction)lsa_enum_trust_dom, + METH_VARARGS, "Enumerate trusted domains." }, { NULL } @@ -346,17 +346,39 @@ static PyMethodDef lsa_methods[] = { /* Open/close lsa handles */ - { "open_policy", lsa_open_policy, METH_VARARGS | METH_KEYWORDS, + { "open_policy", (PyCFunction)lsa_open_policy, + METH_VARARGS | METH_KEYWORDS, "Open a policy handle" }, - { "close", lsa_close, METH_VARARGS, "Close a policy handle" }, + { "close", (PyCFunction)lsa_close, + METH_VARARGS, + "Close a policy handle" }, + + { NULL } +}; +static struct const_vals { + char *name; + uint32 value; +} module_const_vals[] = { { NULL } }; +static void const_init(PyObject *dict) +{ + struct const_vals *tmp; + PyObject *obj; + + for (tmp = module_const_vals; tmp->name; tmp++) { + obj = PyInt_FromLong(tmp->value); + PyDict_SetItemString(dict, tmp->name, obj); + Py_DECREF(obj); + } +} + /* * Module initialisation -*/ + */ void initlsa(void) { @@ -379,7 +401,7 @@ void initlsa(void) /* Initialise constants */ -// const_init(dict); + const_init(dict); /* Do samba initialisation */ diff --git a/source3/python/py_samr.c b/source3/python/py_samr.c index 9a19f9abd5..6c52ebe8cd 100644 --- a/source3/python/py_samr.c +++ b/source3/python/py_samr.c @@ -18,9 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" -#include "Python.h" - #include "python/py_samr.h" /* @@ -327,12 +324,32 @@ static PyMethodDef samr_methods[] = { /* Open/close samr connect handles */ - { "connect", samr_connect, METH_VARARGS | METH_KEYWORDS, + { "connect", (PyCFunction)samr_connect, + METH_VARARGS | METH_KEYWORDS, "Open a connect handle" }, { NULL } }; +static struct const_vals { + char *name; + uint32 value; +} module_const_vals[] = { + { NULL } +}; + +static void const_init(PyObject *dict) +{ + struct const_vals *tmp; + PyObject *obj; + + for (tmp = module_const_vals; tmp->name; tmp++) { + obj = PyInt_FromLong(tmp->value); + PyDict_SetItemString(dict, tmp->name, obj); + Py_DECREF(obj); + } +} + void initsamr(void) { PyObject *module, *dict; @@ -358,7 +375,7 @@ void initsamr(void) /* Initialise constants */ -// const_init(dict); + const_init(dict); /* Do samba initialisation */ diff --git a/source3/python/py_spoolss.c b/source3/python/py_spoolss.c index d57867dd7c..b209e6243b 100644 --- a/source3/python/py_spoolss.c +++ b/source3/python/py_spoolss.c @@ -50,7 +50,7 @@ static PyMethodDef spoolss_methods[] = { /* Open/close printer handles */ - { "openprinter", spoolss_openprinter, METH_VARARGS | METH_KEYWORDS, + { "openprinter", (PyCFunction)spoolss_openprinter, METH_VARARGS | METH_KEYWORDS, "openprinter(printername, [creds, access]) -> Open a printer given by printername in UNC format. Optionally a dictionary @@ -75,7 +75,8 @@ Example: /* Server enumeratation functions */ - { "enumprinters", spoolss_enumprinters, METH_VARARGS | METH_KEYWORDS, + { "enumprinters", (PyCFunction)spoolss_enumprinters, + METH_VARARGS | METH_KEYWORDS, "enumprinters(server, [creds, level, flags]) -> list Return a list of printers on a print server. The credentials, info level @@ -90,7 +91,8 @@ Example: 'description': 'fileprint,Generic / Text Only,'}] "}, - { "enumports", spoolss_enumports, METH_VARARGS | METH_KEYWORDS, + { "enumports", (PyCFunction)spoolss_enumports, + METH_VARARGS | METH_KEYWORDS, "enumports(server, [creds, level]) -> list Return a list of ports on a print server. @@ -102,15 +104,15 @@ Example: {'name': 'FILE:'}, {'name': '\\\\nautilus1\\zpekt3r'}] "}, - { "enumprinterdrivers", spoolss_enumprinterdrivers, METH_VARARGS | - METH_KEYWORDS, -"enumprinterdrivers(server, [creds, level, arch]) -> list + { "enumprinterdrivers", (PyCFunction)spoolss_enumprinterdrivers, + METH_VARARGS | METH_KEYWORDS, + "enumprinterdrivers(server, [creds, level, arch]) -> list Return a list of printer drivers. "}, /* Miscellaneous other commands */ - { "getprinterdriverdir", spoolss_getprinterdriverdir, METH_VARARGS | + { "getprinterdriverdir", (PyCFunction)spoolss_getprinterdriverdir, METH_VARARGS | METH_KEYWORDS, "getprinterdriverdir(server, [creds]) -> string Return the printer driver directory for a given architecture. The @@ -120,11 +122,11 @@ architecture defaults to \"Windows NT x86\". /* Other stuff - this should really go into a samba config module but for the moment let's leave it here. */ - { "setup_logging", py_setup_logging, METH_VARARGS | METH_KEYWORDS, - "" }, + { "setup_logging", (PyCFunction)py_setup_logging, + METH_VARARGS | METH_KEYWORDS, "" }, - { "get_debuglevel", get_debuglevel, METH_VARARGS, "" }, - { "set_debuglevel", set_debuglevel, METH_VARARGS, "" }, + { "get_debuglevel", (PyCFunction)get_debuglevel, METH_VARARGS, "" }, + { "set_debuglevel", (PyCFunction)set_debuglevel, METH_VARARGS, "" }, { NULL } }; @@ -135,7 +137,8 @@ static PyMethodDef spoolss_hnd_methods[] = { /* Printer info */ - { "getprinter", spoolss_getprinter, METH_VARARGS | METH_KEYWORDS, + { "getprinter", (PyCFunction)spoolss_getprinter, + METH_VARARGS | METH_KEYWORDS, "getprinter([level]) -> dict Return a dictionary of print information. The info level defaults to 1. @@ -148,7 +151,8 @@ Example: 'flags': 8388608} "}, - { "setprinter", spoolss_setprinter, METH_VARARGS | METH_KEYWORDS, + { "setprinter", (PyCFunction)spoolss_setprinter, + METH_VARARGS | METH_KEYWORDS, "setprinter(dict) -> None Set printer information. @@ -156,7 +160,7 @@ Set printer information. /* Printer drivers */ - { "getprinterdriver", spoolss_getprinterdriver, + { "getprinterdriver", (PyCFunction)spoolss_getprinterdriver, METH_VARARGS | METH_KEYWORDS, "getprinterdriver([level = 1, arch = \"Windows NT x86\"] -> dict @@ -165,65 +169,73 @@ Return a dictionary of printer driver information. /* Forms */ - { "enumforms", spoolss_enumforms, METH_VARARGS | METH_KEYWORDS, + { "enumforms", (PyCFunction)spoolss_enumforms, + METH_VARARGS | METH_KEYWORDS, "enumforms([level = 1]) -> list Return a list of forms supported by a printer. "}, - { "setform", spoolss_setform, METH_VARARGS | METH_KEYWORDS, + { "setform", (PyCFunction)spoolss_setform, + METH_VARARGS | METH_KEYWORDS, "setform(dict) -> None Set the form given by the dictionary argument. "}, - { "addform", spoolss_addform, METH_VARARGS | METH_KEYWORDS, + { "addform", (PyCFunction)spoolss_addform, + METH_VARARGS | METH_KEYWORDS, "Insert a form" }, - { "getform", spoolss_getform, METH_VARARGS | METH_KEYWORDS, + { "getform", (PyCFunction)spoolss_getform, + METH_VARARGS | METH_KEYWORDS, "Fetch form properties" }, - { "deleteform", spoolss_deleteform, METH_VARARGS | METH_KEYWORDS, + { "deleteform", (PyCFunction)spoolss_deleteform, + METH_VARARGS | METH_KEYWORDS, "Delete a form" }, /* Job related methods */ - { "enumjobs", spoolss_enumjobs, METH_VARARGS | METH_KEYWORDS, + { "enumjobs", (PyCFunction)spoolss_enumjobs, + METH_VARARGS | METH_KEYWORDS, "Enumerate jobs" }, - { "setjob", spoolss_setjob, METH_VARARGS | METH_KEYWORDS, + { "setjob", (PyCFunction)spoolss_setjob, + METH_VARARGS | METH_KEYWORDS, "Set job information" }, - { "getjob", spoolss_getjob, METH_VARARGS | METH_KEYWORDS, + { "getjob", (PyCFunction)spoolss_getjob, + METH_VARARGS | METH_KEYWORDS, "Get job information" }, - { "startpageprinter", spoolss_startpageprinter, + { "startpageprinter", (PyCFunction)spoolss_startpageprinter, METH_VARARGS | METH_KEYWORDS, "Notify spooler that a page is about to be printed." }, - { "endpageprinter", spoolss_endpageprinter, + { "endpageprinter", (PyCFunction)spoolss_endpageprinter, METH_VARARGS | METH_KEYWORDS, "Notify spooler that a page is about to be printed." }, - { "startdocprinter", spoolss_startdocprinter, + { "startdocprinter", (PyCFunction)spoolss_startdocprinter, METH_VARARGS | METH_KEYWORDS, "Notify spooler that a document is about to be printed." }, - { "enddocprinter", spoolss_enddocprinter, + { "enddocprinter", (PyCFunction)spoolss_enddocprinter, METH_VARARGS | METH_KEYWORDS, "Notify spooler that a document is about to be printed." }, /* Printer data */ - { "getprinterdata", spoolss_getprinterdata, + { "getprinterdata", (PyCFunction)spoolss_getprinterdata, METH_VARARGS | METH_KEYWORDS, "Get printer data." }, - { "setprinterdata", spoolss_setprinterdata, + { "setprinterdata", (PyCFunction)spoolss_setprinterdata, METH_VARARGS | METH_KEYWORDS, "Set printer data." }, - { "enumprinterdata", spoolss_enumprinterdata, + { "enumprinterdata", (PyCFunction)spoolss_enumprinterdata, METH_VARARGS | METH_KEYWORDS, "Enumerate printer data." }, @@ -280,10 +292,10 @@ PyTypeObject spoolss_policy_hnd_type = { /* Initialise constants */ -struct spoolss_const { +static struct const_vals { char *name; uint32 value; -} spoolss_const_vals[] = { +} module_const_vals[] = { /* Access permissions */ @@ -374,10 +386,10 @@ struct spoolss_const { static void const_init(PyObject *dict) { - struct spoolss_const *tmp; + struct const_vals *tmp; PyObject *obj; - for (tmp = spoolss_const_vals; tmp->name; tmp++) { + for (tmp = module_const_vals; tmp->name; tmp++) { obj = PyInt_FromLong(tmp->value); PyDict_SetItemString(dict, tmp->name, obj); Py_DECREF(obj); diff --git a/source3/python/py_winbind.c b/source3/python/py_winbind.c index 657e98281d..e55d12afb2 100644 --- a/source3/python/py_winbind.c +++ b/source3/python/py_winbind.c @@ -578,11 +578,11 @@ success." }, { NULL } }; -static struct winbind_const { +static struct const_vals { char *name; uint32 value; char *docstring; -} winbind_const_vals[] = { +} module_const_vals[] = { /* Well known RIDs */ @@ -606,10 +606,10 @@ static struct winbind_const { static void const_init(PyObject *dict) { - struct winbind_const *tmp; + struct const_vals *tmp; PyObject *obj; - for (tmp = winbind_const_vals; tmp->name; tmp++) { + for (tmp = module_const_vals; tmp->name; tmp++) { obj = PyInt_FromLong(tmp->value); PyDict_SetItemString(dict, tmp->name, obj); Py_DECREF(obj); diff --git a/source3/python/py_winreg.c b/source3/python/py_winreg.c index 105ad25db2..ce27f5c533 100644 --- a/source3/python/py_winreg.c +++ b/source3/python/py_winreg.c @@ -18,13 +18,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" -#include "Python.h" +#include "python/py_winreg.h" -struct spoolss_const { +static struct const_vals { char *name; uint32 value; -} spoolss_const_vals[] = { +} module_const_vals[] = { /* Registry value types */ @@ -46,10 +45,10 @@ struct spoolss_const { static void const_init(PyObject *dict) { - struct spoolss_const *tmp; + struct const_vals *tmp; PyObject *obj; - for (tmp = spoolss_const_vals; tmp->name; tmp++) { + for (tmp = module_const_vals; tmp->name; tmp++) { obj = PyInt_FromLong(tmp->value); PyDict_SetItemString(dict, tmp->name, obj); Py_DECREF(obj); diff --git a/source3/python/py_winreg.h b/source3/python/py_winreg.h new file mode 100644 index 0000000000..e19674d218 --- /dev/null +++ b/source3/python/py_winreg.h @@ -0,0 +1,29 @@ +/* + 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. +*/ + +#ifndef _PY_WINREG_H +#define _PY_WINREG_H + +#include "includes.h" +#include "Python.h" + +#include "python/py_common.h" + +#endif /* _PY_WINREG_H */ -- cgit