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 3 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, see <http://www.gnu.org/licenses/>.
20 #include "python/py_spoolss.h"
21 #include "python/py_conv.h"
23 struct pyconv py_FORM
[] = {
24 { "flags", PY_UINT32
, offsetof(FORM
, flags
) },
25 { "width", PY_UINT32
, offsetof(FORM
, size_x
) },
26 { "length", PY_UINT32
, offsetof(FORM
, size_y
) },
27 { "top", PY_UINT32
, offsetof(FORM
, top
) },
28 { "left", PY_UINT32
, offsetof(FORM
, left
) },
29 { "right", PY_UINT32
, offsetof(FORM
, right
) },
30 { "bottom", PY_UINT32
, offsetof(FORM
, bottom
) },
34 struct pyconv py_FORM_1
[] = {
35 { "flags", PY_UINT32
, offsetof(FORM_1
, flag
) },
36 { "width", PY_UINT32
, offsetof(FORM_1
, width
) },
37 { "length", PY_UINT32
, offsetof(FORM_1
, length
) },
38 { "top", PY_UINT32
, offsetof(FORM_1
, top
) },
39 { "left", PY_UINT32
, offsetof(FORM_1
, left
) },
40 { "right", PY_UINT32
, offsetof(FORM_1
, right
) },
41 { "bottom", PY_UINT32
, offsetof(FORM_1
, bottom
) },
42 { "name", PY_UNISTR
, offsetof(FORM_1
, name
) },
46 BOOL
py_from_FORM_1(PyObject
**dict
, FORM_1
*form
)
48 *dict
= from_struct(form
, py_FORM_1
);
50 PyDict_SetItemString(*dict
, "level", PyInt_FromLong(1));
55 BOOL
py_to_FORM(FORM
*form
, PyObject
*dict
)
57 PyObject
*obj
, *dict_copy
= PyDict_Copy(dict
);
61 if (!(obj
= PyDict_GetItemString(dict_copy
, "name")) ||
65 PyDict_DelItemString(dict_copy
, "name");
67 if (!(obj
= PyDict_GetItemString(dict_copy
, "level")) ||
71 PyDict_DelItemString(dict_copy
, "level");
73 if (!to_struct(form
, dict_copy
, py_FORM
))
76 /* Careful! We can't call PyString_AsString(obj) then delete
77 obj and still expect to have our pointer pointing somewhere
80 obj
= PyDict_GetItemString(dict
, "name");
81 name
= PyString_AsString(obj
);
83 init_unistr2(&form
->name
, name
, UNI_STR_TERMINATE
);