r25598: Add missing become_root/unbecome_root around calls of add_aliases.
[jerry/samba.git] / source / python / py_spoolss_printerdata.c
index 583d097e845a372d1cd13e5129a66d71970341da..5faac0e3919e5b1c866b8e772d5a5d26063190f9 100644 (file)
@@ -5,7 +5,7 @@
    
    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
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    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.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "python/py_spoolss.h"
+#include "python/py_conv.h"
 
 static BOOL py_from_printerdata(PyObject **dict, char *key, char *value,
                                uint16 data_type, uint8 *data, 
@@ -111,7 +111,6 @@ PyObject *spoolss_hnd_getprinterdata(PyObject *self, PyObject *args, PyObject *k
        static char *kwlist[] = { "value", NULL };
        char *valuename;
        WERROR werror;
-       uint32 needed;
        PyObject *result;
        REGISTRY_VALUE value;
 
@@ -122,15 +121,10 @@ PyObject *spoolss_hnd_getprinterdata(PyObject *self, PyObject *args, PyObject *k
 
        /* Call rpc function */
 
-       werror = cli_spoolss_getprinterdata(
-               hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, valuename,
+       werror = rpccli_spoolss_getprinterdata(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, valuename,
                &value);
 
-       if (W_ERROR_V(werror) == ERRmoredata) 
-               werror = cli_spoolss_getprinterdata(
-                       hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol, 
-                       valuename, &value);
-
        if (!W_ERROR_IS_OK(werror)) {
                PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
                return NULL;
@@ -165,7 +159,7 @@ PyObject *spoolss_hnd_setprinterdata(PyObject *self, PyObject *args, PyObject *k
        
        /* Call rpc function */
 
-       werror = cli_spoolss_setprinterdata(
+       werror = rpccli_spoolss_setprinterdata(
                hnd->cli, hnd->mem_ctx, &hnd->pol, &value);
 
        if (!W_ERROR_IS_OK(werror)) {
@@ -191,7 +185,7 @@ PyObject *spoolss_hnd_enumprinterdata(PyObject *self, PyObject *args, PyObject *
 
        /* Get max buffer sizes for value and data */
 
-       werror = cli_spoolss_enumprinterdata(
+       werror = rpccli_spoolss_enumprinterdata(
                hnd->cli, hnd->mem_ctx, &hnd->pol, ndx, 0, 0,
                &value_needed, &data_needed, NULL);
 
@@ -207,7 +201,7 @@ PyObject *spoolss_hnd_enumprinterdata(PyObject *self, PyObject *args, PyObject *
        while (W_ERROR_IS_OK(werror)) {
                PyObject *obj;
 
-               werror = cli_spoolss_enumprinterdata(
+               werror = rpccli_spoolss_enumprinterdata(
                        hnd->cli, hnd->mem_ctx, &hnd->pol, ndx,
                        value_needed, data_needed, NULL, NULL, &value);
 
@@ -236,7 +230,7 @@ PyObject *spoolss_hnd_deleteprinterdata(PyObject *self, PyObject *args, PyObject
 
        /* Call rpc function */
 
-       werror = cli_spoolss_deleteprinterdata(
+       werror = rpccli_spoolss_deleteprinterdata(
                hnd->cli, hnd->mem_ctx, &hnd->pol, value);
 
        if (!W_ERROR_IS_OK(werror)) {
@@ -254,7 +248,6 @@ PyObject *spoolss_hnd_getprinterdataex(PyObject *self, PyObject *args, PyObject
        static char *kwlist[] = { "key", "value", NULL };
        char *key, *valuename;
        WERROR werror;
-       uint32 needed;
        PyObject *result;
        REGISTRY_VALUE value;
 
@@ -265,15 +258,10 @@ PyObject *spoolss_hnd_getprinterdataex(PyObject *self, PyObject *args, PyObject
 
        /* Call rpc function */
 
-       werror = cli_spoolss_getprinterdataex(
-               hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, key,
+       werror = rpccli_spoolss_getprinterdataex(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, key,
                valuename, &value);
 
-       if (W_ERROR_V(werror) == ERRmoredata) 
-               werror = cli_spoolss_getprinterdataex(
-                       hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol, key,
-                       valuename, &value);
-
        if (!W_ERROR_IS_OK(werror)) {
                PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
                return NULL;
@@ -306,7 +294,7 @@ PyObject *spoolss_hnd_setprinterdataex(PyObject *self, PyObject *args, PyObject
 
        /* Call rpc function */
 
-       werror = cli_spoolss_setprinterdataex(
+       werror = rpccli_spoolss_setprinterdataex(
                hnd->cli, hnd->mem_ctx, &hnd->pol, keyname, &value);
 
        if (!W_ERROR_IS_OK(werror)) {
@@ -322,24 +310,24 @@ PyObject *spoolss_hnd_enumprinterdataex(PyObject *self, PyObject *args, PyObject
 {
        spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
        static char *kwlist[] = { "key", NULL };
-       uint32 needed, i;
+       uint32 i;
        char *key;
        WERROR werror;
        PyObject *result;
-       REGVAL_CTR ctr;
+       REGVAL_CTR *ctr;
 
        if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &key))
                return NULL;
 
-       /* Get max buffer sizes for value and data */
+       if (!(ctr = TALLOC_ZERO_P(hnd->mem_ctx, REGVAL_CTR))) {
+               PyErr_SetString(spoolss_error, "talloc failed");
+               return NULL;
+       }
 
-       werror = cli_spoolss_enumprinterdataex(
-               hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, key, &ctr);
+       /* Get max buffer sizes for value and data */
 
-       if (W_ERROR_V(werror) == ERRmoredata) 
-               werror = cli_spoolss_enumprinterdataex(
-                       hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol, key, 
-                       &ctr);
+       werror = rpccli_spoolss_enumprinterdataex(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, key, &ctr);
 
        if (!W_ERROR_IS_OK(werror)) {
                PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
@@ -380,7 +368,7 @@ PyObject *spoolss_hnd_deleteprinterdataex(PyObject *self, PyObject *args, PyObje
 
        /* Call rpc function */
 
-       werror = cli_spoolss_deleteprinterdataex(
+       werror = rpccli_spoolss_deleteprinterdataex(
                hnd->cli, hnd->mem_ctx, &hnd->pol, key, value);
 
        if (!W_ERROR_IS_OK(werror)) {
@@ -399,7 +387,7 @@ PyObject *spoolss_hnd_enumprinterkey(PyObject *self, PyObject *args,
        static char *kwlist[] = { "key", NULL };
        char *keyname;
        WERROR werror;
-       uint32 needed, keylist_len;
+       uint32 keylist_len;
        uint16 *keylist;
        PyObject *result;
 
@@ -410,14 +398,9 @@ PyObject *spoolss_hnd_enumprinterkey(PyObject *self, PyObject *args,
 
        /* Call rpc function */
 
-       werror = cli_spoolss_enumprinterkey(
-               hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol,
-               keyname, &keylist, &keylist_len);
-
-       if (W_ERROR_V(werror) == ERRmoredata) 
-               werror = cli_spoolss_enumprinterkey(
-                       hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol,
-                       keyname, &keylist, &keylist_len);
+       werror = rpccli_spoolss_enumprinterkey(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, keyname, &keylist, 
+               &keylist_len);
 
        if (!W_ERROR_IS_OK(werror)) {
                PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));