python/py_samr_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_samr.h"
00022 #include "python/py_conv.h"
00023 
00024 /*
00025  * Convert between SAM_USER_INFO_16 and Python
00026  */
00027 
00028 struct pyconv py_SAM_USER_INFO_16[] = {
00029         { "acb_info", PY_UINT32, offsetof(SAM_USER_INFO_16, acb_info) },
00030         { NULL }
00031 };
00032 
00033 BOOL py_from_SAM_USER_INFO_16(PyObject **dict, SAM_USER_INFO_16 *info)
00034 {
00035         *dict = from_struct(info, py_SAM_USER_INFO_16);
00036         PyDict_SetItemString(*dict, "level", PyInt_FromLong(16));
00037         return True;
00038 }
00039 
00040 BOOL py_to_SAM_USER_INFO_16(SAM_USER_INFO_16 *info, PyObject *dict)
00041 {
00042         PyObject *obj, *dict_copy = PyDict_Copy(dict);
00043         BOOL result = False;
00044 
00045         if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
00046             !PyInt_Check(obj))
00047                 goto done;
00048 
00049         PyDict_DelItemString(dict_copy, "level");
00050 
00051         if (!to_struct(info, dict_copy, py_SAM_USER_INFO_16))
00052                 goto done;
00053 
00054         result = True;
00055 
00056 done:
00057         Py_DECREF(dict_copy);
00058         return result;
00059 }
00060 
00061 /*
00062  * Convert between SAM_USER_INFO_21 and Python
00063  */
00064 
00065 struct pyconv py_SAM_USER_INFO_21[] = {
00066         { NULL }
00067 };
00068 
00069 BOOL py_from_SAM_USER_INFO_21(PyObject **dict, SAM_USER_INFO_21 *info)
00070 {
00071         *dict = from_struct(info, py_SAM_USER_INFO_21);
00072         PyDict_SetItemString(*dict, "level", PyInt_FromLong(21));
00073         return True;
00074 }
00075 
00076 BOOL py_to_SAM_USER_INFO_21(SAM_USER_INFO_21 *info, PyObject *dict)
00077 {
00078         PyObject *obj, *dict_copy = PyDict_Copy(dict);
00079         BOOL result = False;
00080 
00081         if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
00082             !PyInt_Check(obj))
00083                 goto done;
00084 
00085         PyDict_DelItemString(dict_copy, "level");
00086 
00087         if (!to_struct(info, dict_copy, py_SAM_USER_INFO_21))
00088                 goto done;
00089 
00090         result = True;
00091 
00092 done:
00093         Py_DECREF(dict_copy);
00094         return result;
00095 }
00096 
00097 /*
00098  * Convert between acct_info and Python 
00099  */
00100 
00101 BOOL py_from_acct_info(PyObject **array, struct acct_info *info, int num_accts)
00102 {
00103         int i;
00104 
00105         *array = PyList_New(num_accts);
00106 
00107         for (i = 0; i < num_accts; i++) {
00108                 PyObject *obj;  
00109 
00110                 obj = PyDict_New();
00111                 
00112                 PyDict_SetItemString(
00113                         obj, "name", PyString_FromString(info[i].acct_name));
00114 
00115                 PyDict_SetItemString(
00116                         obj, "description", 
00117                         PyString_FromString(info[i].acct_desc));
00118 
00119                 PyDict_SetItemString(obj, "rid", PyInt_FromLong(info[i].rid));
00120 
00121                 PyList_SetItem(*array, i, obj);
00122         }
00123 
00124         return True;
00125 }
00126 
00127 BOOL py_to_acct_info(PRINTER_INFO_3 *info, PyObject *dict,
00128                      TALLOC_CTX *mem_ctx)
00129 {
00130         return False;
00131 }

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