2 Python wrappers for DCERPC/SMB client routines.
4 Copyright (C) Tim Potter, 2002
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "python/py_spoolss.h"
25 PyObject *spoolss_enumjobs(PyObject *self, PyObject *args, PyObject *kw)
27 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
31 uint32 i, needed, num_jobs;
32 static char *kwlist[] = {"level", NULL};
35 /* Parse parameters */
37 if (!PyArg_ParseTupleAndKeywords(args, kw, "|i", kwlist, &level))
40 /* Call rpc function */
42 werror = cli_spoolss_enumjobs(
43 hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, level, 0,
44 1000, &num_jobs, &ctr);
46 if (W_ERROR_V(werror) == ERRinsufficientbuffer)
47 werror = cli_spoolss_enumjobs(
48 hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol,
49 level, 0, 1000, &num_jobs, &ctr);
55 if (!W_ERROR_IS_OK(werror))
58 result = PyList_New(num_jobs);
62 for (i = 0; i < num_jobs; i++) {
65 py_from_JOB_INFO_1(&value, &ctr.job.job_info_1[i]);
67 PyList_SetItem(result, i, value);
72 for(i = 0; i < num_jobs; i++) {
75 py_from_JOB_INFO_2(&value, &ctr.job.job_info_2[i]);
77 PyList_SetItem(result, i, value);
90 PyObject *spoolss_setjob(PyObject *self, PyObject *args, PyObject *kw)
92 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
94 uint32 level = 0, command, jobid;
95 static char *kwlist[] = {"jobid", "command", "level", NULL};
97 /* Parse parameters */
99 if (!PyArg_ParseTupleAndKeywords(args, kw, "ii|i", kwlist, &jobid,
103 /* Call rpc function */
105 werror = cli_spoolss_setjob(hnd->cli, hnd->mem_ctx, &hnd->pol,
106 jobid, level, command);
108 if (!W_ERROR_IS_OK(werror)) {
109 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
119 PyObject *spoolss_getjob(PyObject *self, PyObject *args, PyObject *kw)
121 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
124 uint32 level = 1, jobid, needed;
125 static char *kwlist[] = {"jobid", "level", NULL};
128 /* Parse parameters */
130 if (!PyArg_ParseTupleAndKeywords(args, kw, "i|i", kwlist, &jobid,
134 /* Call rpc function */
136 werror = cli_spoolss_getjob(hnd->cli, hnd->mem_ctx, 0, &needed,
137 &hnd->pol, jobid, level, &ctr);
139 if (W_ERROR_V(werror) == ERRinsufficientbuffer)
140 werror = cli_spoolss_getjob(
141 hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol,
144 if (!W_ERROR_IS_OK(werror)) {
145 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
151 py_from_JOB_INFO_1(&result, ctr.job.job_info_1);
154 py_from_JOB_INFO_2(&result, ctr.job.job_info_2);
161 /* Start page printer. This notifies the spooler that a page is about to be
162 printed on the specified printer. */
164 PyObject *spoolss_startpageprinter(PyObject *self, PyObject *args, PyObject *kw)
166 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
168 static char *kwlist[] = { NULL };
170 /* Parse parameters */
172 if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
175 /* Call rpc function */
177 werror = cli_spoolss_startpageprinter(
178 hnd->cli, hnd->mem_ctx, &hnd->pol);
180 if (!W_ERROR_IS_OK(werror)) {
181 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
189 /* End page printer. This notifies the spooler that a page has finished
190 being printed on the specified printer. */
192 PyObject *spoolss_endpageprinter(PyObject *self, PyObject *args, PyObject *kw)
194 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
196 static char *kwlist[] = { NULL };
198 /* Parse parameters */
200 if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
203 /* Call rpc function */
205 werror = cli_spoolss_endpageprinter(
206 hnd->cli, hnd->mem_ctx, &hnd->pol);
208 if (!W_ERROR_IS_OK(werror)) {
209 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));