summaryrefslogtreecommitdiffstats
path: root/source/python/py_spoolss_ports.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-05-16 04:00:31 +0000
committerTim Potter <tpot@samba.org>2002-05-16 04:00:31 +0000
commitd35cad359df3bd53e6bb49f6655d4c7b9993abb0 (patch)
treeefb1d228784af05eb67569b41d2aefd8b03bc5f5 /source/python/py_spoolss_ports.c
parent36ed06cb5078429445f3bbb0f69baa2e0f8356a4 (diff)
downloadsamba-d35cad359df3bd53e6bb49f6655d4c7b9993abb0.tar.gz
samba-d35cad359df3bd53e6bb49f6655d4c7b9993abb0.tar.xz
samba-d35cad359df3bd53e6bb49f6655d4c7b9993abb0.zip
More cleanups.
- removed dodgy fprintf() error handling - return an error string from open_pipe_creds() so the appropriate exception can be raised by the caller - reformatting
Diffstat (limited to 'source/python/py_spoolss_ports.c')
-rw-r--r--source/python/py_spoolss_ports.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/python/py_spoolss_ports.c b/source/python/py_spoolss_ports.c
index 8e74017f4a7..fb3f47c746a 100644
--- a/source/python/py_spoolss_ports.c
+++ b/source/python/py_spoolss_ports.c
@@ -31,21 +31,31 @@ PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw)
static char *kwlist[] = {"server", "level", "creds", NULL};
TALLOC_CTX *mem_ctx = NULL;
struct cli_state *cli = NULL;
- char *server;
+ char *server, *errstr;
PORT_INFO_CTR ctr;
/* Parse parameters */
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s|iO!", kwlist,
- &server, &creds, &level,
- &PyDict_Type))
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kw, "s|iO!", kwlist, &server, &creds, &level,
+ &PyDict_Type))
return NULL;
if (server[0] == '\\' && server[1] == '\\')
server += 2;
- mem_ctx = talloc_init();
- cli = open_pipe_creds(server, creds, cli_spoolss_initialise);
+ if (!(cli = open_pipe_creds(
+ server, creds, cli_spoolss_initialise, &errstr))) {
+ PyErr_SetString(spoolss_error, errstr);
+ free(errstr);
+ return NULL;
+ }
+
+ if (!(mem_ctx = talloc_init())) {
+ PyErr_SetString(
+ spoolss_error, "unable to initialise talloc context\n");
+ return NULL;
+ }
/* Call rpc function */