diff options
author | Tim Potter <tpot@samba.org> | 2002-05-16 04:00:31 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-05-16 04:00:31 +0000 |
commit | 286d3a80fdcd316ebbf63b007a24e787143313a4 (patch) | |
tree | 7eeabd842ec6e6f1721f5b3ecb19d350092d53e8 /source3/python/py_spoolss_drivers.c | |
parent | ce03ce2e5629930e582f9fd17445e52ce1b08907 (diff) | |
download | samba-286d3a80fdcd316ebbf63b007a24e787143313a4.tar.gz samba-286d3a80fdcd316ebbf63b007a24e787143313a4.tar.bz2 samba-286d3a80fdcd316ebbf63b007a24e787143313a4.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
(This used to be commit d35cad359df3bd53e6bb49f6655d4c7b9993abb0)
Diffstat (limited to 'source3/python/py_spoolss_drivers.c')
-rw-r--r-- | source3/python/py_spoolss_drivers.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/source3/python/py_spoolss_drivers.c b/source3/python/py_spoolss_drivers.c index 416d46f1d2..64d3a37afa 100644 --- a/source3/python/py_spoolss_drivers.c +++ b/source3/python/py_spoolss_drivers.c @@ -30,28 +30,30 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, PRINTER_DRIVER_CTR ctr; int level = 1, i; uint32 needed, num_drivers; - char *arch = "Windows NT x86", *server_name; + char *arch = "Windows NT x86", *server, *errstr; static char *kwlist[] = {"server", "creds", "level", "arch", NULL}; struct cli_state *cli = NULL; TALLOC_CTX *mem_ctx = NULL; /* Parse parameters */ - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|O!is", kwlist, - &server_name, &PyDict_Type, &creds, - &level, &arch)) + if (!PyArg_ParseTupleAndKeywords( + args, kw, "s|O!is", kwlist, &server, &PyDict_Type, + &creds, &level, &arch)) return NULL; /* Call rpc function */ if (!(cli = open_pipe_creds( - server_name, creds, cli_spoolss_initialise))) { - fprintf(stderr, "could not initialise cli state\n"); + server, creds, cli_spoolss_initialise, &errstr))) { + PyErr_SetString(spoolss_error, errstr); + free(errstr); goto done; } if (!(mem_ctx = talloc_init())) { - fprintf(stderr, "unable to initialise talloc context\n"); + PyErr_SetString( + spoolss_error, "unable to initialise talloc context\n"); goto done; } @@ -181,8 +183,8 @@ PyObject *spoolss_hnd_getprinterdriver(PyObject *self, PyObject *args, /* Parse parameters */ - if (!PyArg_ParseTupleAndKeywords(args, kw, "|is", kwlist, - &level, &arch)) + if (!PyArg_ParseTupleAndKeywords( + args, kw, "|is", kwlist, &level, &arch)) return NULL; /* Call rpc function */ @@ -230,28 +232,30 @@ PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args, PyObject *result = Py_None, *creds = NULL; DRIVER_DIRECTORY_CTR ctr; uint32 needed, level; - char *arch = "Windows NT x86", *server_name; + char *arch = "Windows NT x86", *server, *errstr; static char *kwlist[] = {"server", "level", "arch", "creds", NULL}; struct cli_state *cli = NULL; TALLOC_CTX *mem_ctx = NULL; /* Parse parameters */ - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|isO!", kwlist, - &server_name, &level, &arch, - &PyDict_Type, &creds)) + if (!PyArg_ParseTupleAndKeywords( + args, kw, "s|isO!", kwlist, &server, &level, + &arch, &PyDict_Type, &creds)) return NULL; /* Call rpc function */ if (!(cli = open_pipe_creds( - server_name, creds, cli_spoolss_initialise))) { - fprintf(stderr, "could not initialise cli state\n"); + server, creds, cli_spoolss_initialise, &errstr))) { + PyErr_SetString(spoolss_error, errstr); + free(errstr); goto done; } if (!(mem_ctx = talloc_init())) { - fprintf(stderr, "unable to initialise talloc context\n"); + PyErr_SetString( + spoolss_error, "unable to initialise talloc context\n"); goto done; } @@ -290,7 +294,7 @@ PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args, PyObject *kw) { static char *kwlist[] = { "server", "info", "creds", NULL }; - char *server; + char *server, *errstr; uint32 level; PyObject *info, *result = NULL, *creds = NULL, *level_obj; WERROR werror; @@ -309,10 +313,18 @@ PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args, if (server[0] == '\\' && server[1] == '\\') server += 2; - mem_ctx = talloc_init(); + if (!(mem_ctx = talloc_init())) { + PyErr_SetString( + spoolss_error, "unable to initialise talloc context\n"); + return NULL; + } - if (!(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); goto done; + } if ((level_obj = PyDict_GetItemString(info, "level"))) { |