r25598: Add missing become_root/unbecome_root around calls of add_aliases.
[sfrench/samba-autobuild/.git] / source3 / python / py_spoolss_jobs.c
index cc5d42e0eefe28dd8a11d1a0cb4065b0dbe0a3c0..3c160025bab48ad50a9b8f6ea8499de74dc8f648 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,
@@ -14,8 +14,7 @@
    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"
@@ -28,7 +27,7 @@ PyObject *spoolss_hnd_enumjobs(PyObject *self, PyObject *args, PyObject *kw)
        WERROR werror;
        PyObject *result;
        int level = 1;
-       uint32 i, needed, num_jobs;
+       uint32 i, num_jobs;
        static char *kwlist[] = {"level", NULL};
        JOB_INFO_CTR ctr;
 
@@ -39,14 +38,9 @@ PyObject *spoolss_hnd_enumjobs(PyObject *self, PyObject *args, PyObject *kw)
        
        /* Call rpc function */
        
-       werror = cli_spoolss_enumjobs(
-               hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, level, 0,
-               1000, &num_jobs, &ctr);
-
-       if (W_ERROR_V(werror) == ERRinsufficientbuffer)
-               werror = cli_spoolss_enumjobs(
-                       hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol,
-                       level, 0, 1000, &num_jobs, &ctr);
+       werror = rpccli_spoolss_enumjobs(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, level, 0, 1000, 
+               &num_jobs, &ctr);
 
        /* Return value */
        
@@ -104,8 +98,8 @@ PyObject *spoolss_hnd_setjob(PyObject *self, PyObject *args, PyObject *kw)
        
        /* Call rpc function */
        
-       werror = cli_spoolss_setjob(hnd->cli, hnd->mem_ctx, &hnd->pol,
-                                   jobid, level, command);
+       werror = rpccli_spoolss_setjob(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, jobid, level, command);
 
        if (!W_ERROR_IS_OK(werror)) {
                PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
@@ -123,7 +117,7 @@ PyObject *spoolss_hnd_getjob(PyObject *self, PyObject *args, PyObject *kw)
        spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
        WERROR werror;
        PyObject *result;
-       uint32 level = 1, jobid, needed;
+       uint32 level = 1, jobid;
        static char *kwlist[] = {"jobid", "level", NULL};
        JOB_INFO_CTR ctr;
 
@@ -135,13 +129,8 @@ PyObject *spoolss_hnd_getjob(PyObject *self, PyObject *args, PyObject *kw)
        
        /* Call rpc function */
        
-       werror = cli_spoolss_getjob(hnd->cli, hnd->mem_ctx, 0, &needed,
-                                   &hnd->pol, jobid, level, &ctr);
-
-       if (W_ERROR_V(werror) == ERRinsufficientbuffer)
-               werror = cli_spoolss_getjob(
-                       hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol,
-                       jobid, level, &ctr);
+       werror = rpccli_spoolss_getjob(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, jobid, level, &ctr);
 
        if (!W_ERROR_IS_OK(werror)) {
                PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
@@ -150,10 +139,10 @@ PyObject *spoolss_hnd_getjob(PyObject *self, PyObject *args, PyObject *kw)
 
        switch(level) {
        case 1:
-               py_from_JOB_INFO_1(&result, ctr.job.job_info_1);
+               py_from_JOB_INFO_1(&result, &ctr.job.job_info_1[0]);
                break;
        case 2:
-               py_from_JOB_INFO_2(&result, ctr.job.job_info_2);
+               py_from_JOB_INFO_2(&result, &ctr.job.job_info_2[0]);
                break;
        }
 
@@ -176,7 +165,7 @@ PyObject *spoolss_hnd_startpageprinter(PyObject *self, PyObject *args, PyObject
        
        /* Call rpc function */
        
-       werror = cli_spoolss_startpageprinter(
+       werror = rpccli_spoolss_startpageprinter(
                hnd->cli, hnd->mem_ctx, &hnd->pol);
 
        if (!W_ERROR_IS_OK(werror)) {
@@ -204,7 +193,7 @@ PyObject *spoolss_hnd_endpageprinter(PyObject *self, PyObject *args, PyObject *k
        
        /* Call rpc function */
        
-       werror = cli_spoolss_endpageprinter(
+       werror = rpccli_spoolss_endpageprinter(
                hnd->cli, hnd->mem_ctx, &hnd->pol);
 
        if (!W_ERROR_IS_OK(werror)) {
@@ -296,7 +285,7 @@ PyObject *spoolss_hnd_startdocprinter(PyObject *self, PyObject *args, PyObject *
 
        /* Call rpc function */
        
-       werror = cli_spoolss_startdocprinter(
+       werror = rpccli_spoolss_startdocprinter(
                hnd->cli, hnd->mem_ctx, &hnd->pol, document_name,
                output_file, data_type, &jobid);
 
@@ -328,7 +317,8 @@ PyObject *spoolss_hnd_enddocprinter(PyObject *self, PyObject *args, PyObject *kw
        
        /* Call rpc function */
        
-       werror = cli_spoolss_enddocprinter(hnd->cli, hnd->mem_ctx, &hnd->pol);
+       werror = rpccli_spoolss_enddocprinter(
+               hnd->cli, hnd->mem_ctx, &hnd->pol);
 
        if (!W_ERROR_IS_OK(werror)) {
                PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
@@ -357,7 +347,7 @@ PyObject *spoolss_hnd_writeprinter(PyObject *self, PyObject *args, PyObject *kw)
        
        /* Call rpc function */
        
-       werror = cli_spoolss_writeprinter(
+       werror = rpccli_spoolss_writeprinter(
                hnd->cli, hnd->mem_ctx, &hnd->pol, PyString_Size(data),
                PyString_AsString(data), &num_written);