add entry for 'enable privileges'
[Samba.git] / source / python / py_spoolss_forms_conv.c
blobede729cad33fc35d5f550069326a8c51db8d50e8
1 /*
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"
22 #include "python/py_conv.h"
24 struct pyconv py_FORM[] = {
25 { "flags", PY_UINT32, offsetof(FORM, flags) },
26 { "width", PY_UINT32, offsetof(FORM, size_x) },
27 { "length", PY_UINT32, offsetof(FORM, size_y) },
28 { "top", PY_UINT32, offsetof(FORM, top) },
29 { "left", PY_UINT32, offsetof(FORM, left) },
30 { "right", PY_UINT32, offsetof(FORM, right) },
31 { "bottom", PY_UINT32, offsetof(FORM, bottom) },
32 { NULL }
35 struct pyconv py_FORM_1[] = {
36 { "flags", PY_UINT32, offsetof(FORM_1, flag) },
37 { "width", PY_UINT32, offsetof(FORM_1, width) },
38 { "length", PY_UINT32, offsetof(FORM_1, length) },
39 { "top", PY_UINT32, offsetof(FORM_1, top) },
40 { "left", PY_UINT32, offsetof(FORM_1, left) },
41 { "right", PY_UINT32, offsetof(FORM_1, right) },
42 { "bottom", PY_UINT32, offsetof(FORM_1, bottom) },
43 { "name", PY_UNISTR, offsetof(FORM_1, name) },
44 { NULL }
47 BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form)
49 *dict = from_struct(form, py_FORM_1);
51 PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
53 return True;
56 BOOL py_to_FORM(FORM *form, PyObject *dict)
58 PyObject *obj, *dict_copy = PyDict_Copy(dict);
59 char *name;
60 BOOL result = False;
62 if (!(obj = PyDict_GetItemString(dict_copy, "name")) ||
63 !PyString_Check(obj))
64 goto done;
66 PyDict_DelItemString(dict_copy, "name");
68 if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
69 !PyInt_Check(obj))
70 goto done;
72 PyDict_DelItemString(dict_copy, "level");
74 if (!to_struct(form, dict_copy, py_FORM))
75 goto done;
77 /* Careful! We can't call PyString_AsString(obj) then delete
78 obj and still expect to have our pointer pointing somewhere
79 useful. */
81 obj = PyDict_GetItemString(dict, "name");
82 name = PyString_AsString(obj);
84 init_unistr2(&form->name, name, UNI_STR_TERMINATE);
86 result = True;
88 done:
89 Py_DECREF(dict_copy);
90 return result;