BOOL py_to_DEVICEMODE(DEVICEMODE *devmode, PyObject *dict) { PyObject *obj, *dict_copy = PyDict_Copy(dict); BOOL result = False; if (!(obj = PyDict_GetItemString(dict_copy, "private"))) goto done; if (!PyString_Check(obj)) goto done; devmode->dev_private = PyString_AsString(obj); devmode->driverextra = PyString_Size(obj); PyDict_DelItemString(dict_copy, "private"); if (!to_struct(devmode, dict_copy, py_DEVICEMODE)) goto done; result = True; done: Py_DECREF(dict_copy); return result; }
PCIDevice *pci_device(uint8_t bus, uint8_t slot, uint8_t func) { KListEntry *le = klist_next(&pci_list); while (le != &pci_list) { PCIDevice *d = to_struct(le, PCIDevice, pci_list); if (d->pci_bus == bus && d->pci_slot == slot && d->pci_func == func) return d; le = klist_next(le); } return NULL; }
// ---- Find or get a particular pci device ---- PCIDevice *pci_find(uint8_t vendor, uint8_t device) { KListEntry *le = klist_next(&pci_list); while (le != &pci_list) { PCIDevice *d = to_struct(le, PCIDevice, pci_list); if (d->pci_vendor == vendor && d->pci_device == device) return d; le = klist_next(le); } return NULL; }
BOOL py_to_PRINTER_INFO_2(PRINTER_INFO_2 *info, PyObject *dict, TALLOC_CTX *mem_ctx) { PyObject *obj, *dict_copy = PyDict_Copy(dict); BOOL result = False; /* Convert security descriptor - may be NULL */ info->secdesc = NULL; if ((obj = PyDict_GetItemString(dict_copy, "security_descriptor"))) { if (!PyDict_Check(obj)) goto done; if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx)) goto done; PyDict_DelItemString(dict_copy, "security_descriptor"); } /* Convert device mode */ if (!(obj = PyDict_GetItemString(dict_copy, "device_mode")) || !PyDict_Check(obj)) goto done; info->devmode = _talloc(mem_ctx, sizeof(DEVICEMODE)); if (!py_to_DEVICEMODE(info->devmode, obj)) goto done; PyDict_DelItemString(dict_copy, "device_mode"); /* Check info level */ if (!(obj = PyDict_GetItemString(dict_copy, "level")) || !PyInt_Check(obj)) goto done; PyDict_DelItemString(dict_copy, "level"); /* Convert remaining elements of dictionary */ if (!to_struct(info, dict_copy, py_PRINTER_INFO_2)) goto done; result = True; done: Py_DECREF(dict_copy); return result; }
BOOL py_to_PRINTER_INFO_3(PRINTER_INFO_3 *info, PyObject *dict, TALLOC_CTX *mem_ctx) { PyObject *obj; if (!to_struct(info, dict, py_PRINTER_INFO_3)) return False; if (!(obj = PyDict_GetItemString(dict, "security_descriptor"))) return False; if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx)) return False; return True; }
BOOL py_to_PRINTER_INFO_1(PRINTER_INFO_1 *info, PyObject *dict) { PyObject *obj, *dict_copy = PyDict_Copy(dict); BOOL result = False; if (!(obj = PyDict_GetItemString(dict_copy, "level")) || !PyInt_Check(obj)) goto done; PyDict_DelItemString(dict_copy, "level"); if (!to_struct(info, dict_copy, py_PRINTER_INFO_1)) goto done; result = True; done: Py_DECREF(dict_copy); return result; }
main() { int x; UC str[10]; SC aux[100]; S_INDEX si, so; while ( 1 ) { printf("Registro ? "); gets(aux); si.registro = atol(aux); if ( aux[0] == '.' ) return(0); printf("campo ? "); gets(aux); si.campo = atoi(aux); printf("paragrafo ? "); gets(aux); si.paragrafo = atoi(aux); printf("frase ? "); gets(aux); si.frase = atoi(aux); printf("sequencia ? "); gets(aux); si.sequencia = atoi(aux); x = to_bits(&si, str); printf("%d %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", x, str[0], str[1], str[2], str[3], str[4], str[5], str[6], str[7], str[8]); to_struct( &so, str); x = 0; if (si.registro != so.registro ) { printf("si.registro diferente\n"); x=1; }; if (si.campo != so.campo ) { printf("si.campo diferente\n"); x=1; }; if (si.paragrafo != so.paragrafo ) { printf("si.paragrafo diferente\n"); x=1; }; if (si.frase != so.frase ) { printf("si.frase diferente\n"); x=1; }; if (si.sequencia != so.sequencia ) { printf("si.sequencia diferente\n"); x=1; }; if ( x ) { printf("Reg = %ld\nCampo = %d\nParagrafo = %d\nFrase = %d\nSequencia = %d\n", si.registro, si.campo, si.paragrafo, si.frase, si.sequencia); } } }
BOOL py_to_DOC_INFO_1(DOC_INFO_1 *info, PyObject *dict) { return to_struct(info, dict, py_DOC_INFO_1); }