python/py_conv.c

ソースコードを見る。

関数

static void fstr_pull (fstring str, UNISTR *uni)
static void fstr_pull2 (fstring str, UNISTR2 *uni)
PyObject * from_struct (void *s, struct pyconv *conv)
BOOL to_struct (void *s, PyObject *dict, struct pyconv *conv)
PyObject * from_unistr_list (uint16 *dependentfiles)


関数

static void fstr_pull ( fstring  str,
UNISTR uni 
) [static]

py_conv.c25 行で定義されています。

参照先 UNISTR::bufferrpcstr_pull().

参照元 from_struct().

00026 {
00027         rpcstr_pull(str, uni->buffer, sizeof(fstring), -1, STR_TERMINATE);
00028 }

static void fstr_pull2 ( fstring  str,
UNISTR2 uni 
) [static]

py_conv.c30 行で定義されています。

参照先 UNISTR2::bufferrpcstr_pull().

参照元 from_struct().

00031 {
00032         rpcstr_pull(str, uni->buffer, sizeof(fstring), -1, STR_TERMINATE);
00033 }

PyObject* from_struct ( void *  s,
struct pyconv conv 
)

py_conv.c37 行で定義されています。

参照先 UNISTR2::bufferfstr_pull()fstr_pull2()pyconv::namenamePY_GIDPY_STRINGPY_UIDPY_UINT16PY_UINT32PY_UNISTRPY_UNISTR2type.

参照元 py_from_DEVICEMODE()py_from_DOC_INFO_1()py_from_DRIVER_DIRECTORY_1()py_from_DRIVER_INFO_1()py_from_DRIVER_INFO_2()py_from_DRIVER_INFO_3()py_from_DRIVER_INFO_6()py_from_FORM_1()py_from_JOB_INFO_1()py_from_JOB_INFO_2()py_from_PORT_INFO_1()py_from_PORT_INFO_2()py_from_PRINTER_INFO_0()py_from_PRINTER_INFO_1()py_from_PRINTER_INFO_2()py_from_PRINTER_INFO_3()py_from_SAM_USER_INFO_16()py_from_SAM_USER_INFO_21()py_from_SRV_INFO_101()py_from_winbind_passwd().

00038 {
00039         PyObject *obj, *item;
00040         int i;
00041 
00042         obj = PyDict_New();
00043 
00044         for (i = 0; conv[i].name; i++) {
00045                 switch (conv[i].type) {
00046                 case PY_UNISTR: {
00047                         UNISTR *u = (UNISTR *)((char *)s + conv[i].offset);
00048                         fstring str = "";
00049 
00050                         if (u->buffer)
00051                                 fstr_pull(str, u);
00052 
00053                         item = PyString_FromString(str);
00054                         PyDict_SetItemString(obj, conv[i].name, item);
00055 
00056                         break;
00057                 }
00058                 case PY_UNISTR2: {
00059                         UNISTR2 *u = (UNISTR2 *)((char *)s + conv[i].offset);
00060                         fstring str = "";
00061 
00062                         if (u->buffer)
00063                                 fstr_pull2(str, u);
00064 
00065                         item = PyString_FromString(str);
00066                         PyDict_SetItemString(obj, conv[i].name, item);
00067 
00068                         break;
00069                 }
00070                 case PY_UINT32: {
00071                         uint32 *u = (uint32 *)((char *)s + conv[i].offset);
00072 
00073                         item = PyInt_FromLong(*u);
00074                         PyDict_SetItemString(obj, conv[i].name, item);
00075                         
00076                         break;
00077                 }
00078                 case PY_UINT16: {
00079                         uint16 *u = (uint16 *)((char *)s + conv[i].offset);
00080 
00081                         item = PyInt_FromLong(*u);
00082                         PyDict_SetItemString(obj, conv[i].name, item);
00083 
00084                         break;
00085                 }
00086                 case PY_STRING: {
00087                         char *str = (char *)s + conv[i].offset;
00088 
00089                         item = PyString_FromString(str);
00090                         PyDict_SetItemString(obj, conv[i].name, item);
00091 
00092                         break;
00093                 }
00094                 case PY_UID: {
00095                         uid_t *uid = (uid_t *)((char *)s + conv[i].offset);
00096 
00097                         item = PyInt_FromLong(*uid);
00098                         PyDict_SetItemString(obj, conv[i].name, item);
00099 
00100                         break;
00101                 }
00102                 case PY_GID: {
00103                         gid_t *gid = (gid_t *)((char *)s + conv[i].offset);
00104 
00105                         item = PyInt_FromLong(*gid);
00106                         PyDict_SetItemString(obj, conv[i].name, item);
00107 
00108                         break;
00109                 }
00110                 default:
00111                         
00112                         break;
00113                 }
00114         }
00115 
00116         return obj;
00117 }

BOOL to_struct ( void *  s,
PyObject *  dict,
struct pyconv conv 
)

py_conv.c121 行で定義されています。

参照先 init_unistr()pyconv::namenamePY_UINT16PY_UINT32PY_UNISTRresulttype.

参照元 py_to_DEVICEMODE()py_to_DOC_INFO_1()py_to_DRIVER_INFO_3()py_to_FORM()py_to_PRINTER_INFO_1()py_to_PRINTER_INFO_2()py_to_PRINTER_INFO_3()py_to_SAM_USER_INFO_16()py_to_SAM_USER_INFO_21().

00122 {
00123         PyObject *visited, *key, *value;
00124         BOOL result = False;
00125         int i;
00126 
00127         visited = PyDict_New();
00128 
00129         for (i = 0; conv[i].name; i++) {
00130                 PyObject *obj;
00131                 
00132                 obj = PyDict_GetItemString(dict, conv[i].name);
00133 
00134                 if (!obj)
00135                         goto done;
00136                 
00137                 switch (conv[i].type) {
00138                 case PY_UNISTR: {
00139                         UNISTR *u = (UNISTR *)((char *)s + conv[i].offset);
00140                         char *str = "";
00141 
00142                         if (!PyString_Check(obj))
00143                                 goto done;
00144 
00145                         str = PyString_AsString(obj);
00146                         init_unistr(u, str);
00147                         
00148                         break;
00149                 }
00150                 case PY_UINT32: {
00151                         uint32 *u = (uint32 *)((char *)s + conv[i].offset);
00152 
00153                         if (!PyInt_Check(obj))
00154                                 goto done;
00155 
00156                         *u = PyInt_AsLong(obj);
00157 
00158                         break;
00159                 }
00160                 case PY_UINT16: {
00161                         uint16 *u = (uint16 *)((char *)s + conv[i].offset);
00162 
00163                         if (!PyInt_Check(obj)) 
00164                                 goto done;
00165 
00166                         *u = PyInt_AsLong(obj);
00167                         break;
00168                 }
00169                 default:
00170                         break;
00171                 }
00172 
00173                 /* Mark as visited */
00174 
00175                 PyDict_SetItemString(visited, conv[i].name, 
00176                                      PyInt_FromLong(1));
00177         }
00178 
00179         /* Iterate over each item in the input dictionary and see if it was
00180            visited.  If it wasn't then the user has added some extra crap
00181            to the dictionary. */
00182 
00183         i = 0;
00184 
00185         while (PyDict_Next(dict, &i, &key, &value)) {
00186                 if (!PyDict_GetItem(visited, key))
00187                         goto done;
00188         }
00189 
00190         result = True;
00191 
00192 done:
00193         /* We must decrement the reference count here or the visited
00194            dictionary will not be freed. */
00195                
00196         Py_DECREF(visited);
00197 
00198         return result;
00199 }

PyObject* from_unistr_list ( uint16 *  dependentfiles  ) 

py_conv.c204 行で定義されています。

参照先 lenlist()namerpcstr_pull().

参照元 py_from_DRIVER_INFO_3()py_from_DRIVER_INFO_6()spoolss_hnd_enumprinterkey().

00205 {
00206         PyObject *list;
00207         int offset = 0;
00208 
00209         list = PyList_New(0);
00210 
00211         while (*(dependentfiles + offset) != 0) {
00212                 fstring name;
00213                 int len;
00214 
00215                 len = rpcstr_pull(name, dependentfiles + offset,
00216                                   sizeof(fstring), -1, STR_TERMINATE);
00217 
00218                 offset += len / 2;
00219                 PyList_Append(list, PyString_FromString(name));
00220         }
00221 
00222         return list;
00223 }


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