python/py_spoolss_forms_conv.c

説明を見る。
00001 /* 
00002    Python wrappers for DCERPC/SMB client routines.
00003 
00004    Copyright (C) Tim Potter, 2002
00005    
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015    
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #include "python/py_spoolss.h"
00022 #include "python/py_conv.h"
00023 
00024 struct pyconv py_FORM[] = {
00025         { "flags", PY_UINT32, offsetof(FORM, flags) },
00026         { "width", PY_UINT32, offsetof(FORM, size_x) },
00027         { "length", PY_UINT32, offsetof(FORM, size_y) },
00028         { "top", PY_UINT32, offsetof(FORM, top) },
00029         { "left", PY_UINT32, offsetof(FORM, left) },
00030         { "right", PY_UINT32, offsetof(FORM, right) },
00031         { "bottom", PY_UINT32, offsetof(FORM, bottom) },
00032         { NULL }
00033 };
00034 
00035 struct pyconv py_FORM_1[] = {
00036         { "flags", PY_UINT32, offsetof(FORM_1, flag) },
00037         { "width", PY_UINT32, offsetof(FORM_1, width) },
00038         { "length", PY_UINT32, offsetof(FORM_1, length) },
00039         { "top", PY_UINT32, offsetof(FORM_1, top) },
00040         { "left", PY_UINT32, offsetof(FORM_1, left) },
00041         { "right", PY_UINT32, offsetof(FORM_1, right) },
00042         { "bottom", PY_UINT32, offsetof(FORM_1, bottom) },
00043         { "name", PY_UNISTR, offsetof(FORM_1, name) },
00044         { NULL }
00045 };
00046 
00047 BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form)
00048 {
00049         *dict = from_struct(form, py_FORM_1);
00050 
00051         PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
00052 
00053         return True;
00054 }
00055 
00056 BOOL py_to_FORM(FORM *form, PyObject *dict)
00057 {
00058         PyObject *obj, *dict_copy = PyDict_Copy(dict);
00059         char *name;
00060         BOOL result = False;
00061 
00062         if (!(obj = PyDict_GetItemString(dict_copy, "name")) || 
00063             !PyString_Check(obj))
00064                 goto done;
00065 
00066         PyDict_DelItemString(dict_copy, "name");
00067 
00068         if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
00069             !PyInt_Check(obj))
00070                 goto done;
00071 
00072         PyDict_DelItemString(dict_copy, "level");
00073 
00074         if (!to_struct(form, dict_copy, py_FORM))
00075                 goto done;
00076 
00077         /* Careful!  We can't call PyString_AsString(obj) then delete
00078            obj and still expect to have our pointer pointing somewhere
00079            useful. */
00080 
00081         obj = PyDict_GetItemString(dict, "name");
00082         name = PyString_AsString(obj);
00083 
00084         init_unistr2(&form->name, name, UNI_STR_TERMINATE);
00085         
00086         result = True;
00087 
00088 done:
00089         Py_DECREF(dict_copy);
00090         return result;
00091 }

Sambaに対してSat Aug 29 21:23:14 2009に生成されました。  doxygen 1.4.7