For RPC_S_UUID_NO_ADDRESS, it's not clear whether we can
use the result. */
if (UuidCreate(&result) == RPC_S_UUID_NO_ADDRESS) {
- PyErr_SetString(PyExc_NotImplementedError, "processing 'no address' result");
- return NULL;
+ PyErr_SetString(PyExc_NotImplementedError, "processing 'no address' result");
+ return NULL;
}
if (UuidToString(&result, &cresult) == RPC_S_OUT_OF_MEMORY) {
- PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen");
- return NULL;
+ PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen");
+ return NULL;
}
oresult = PyString_FromString(cresult);
{
int result = _open(pszFile, oflag, pmode);
if (result == -1)
- *err = errno;
+ *err = errno;
return result;
}
{
UINT result = (UINT)_read(hf, memory, cb);
if (result != cb)
- *err = errno;
+ *err = errno;
return result;
}
{
UINT result = (UINT)_write(hf, memory, cb);
if (result != cb)
- *err = errno;
+ *err = errno;
return result;
}
{
int result = _close(hf);
if (result != 0)
- *err = errno;
+ *err = errno;
return result;
}
{
long result = (long)_lseek(hf, dist, seektype);
if (result == -1)
- *err = errno;
+ *err = errno;
return result;
}
{
int result = remove(pszFile);
if (result != 0)
- *err = errno;
+ *err = errno;
return result;
}
{
char *name = _tempnam("", "tmp");
if ((name != NULL) && ((int)strlen(name) < cbTempName)) {
- strcpy(pszTempName, name);
- free(name);
- return TRUE;
+ strcpy(pszTempName, name);
+ free(name);
+ return TRUE;
}
if (name) free(name);
static FNFCISTATUS(cb_status)
{
if (pv) {
- PyObject *result = PyObject_CallMethod(pv, "status", "iii", typeStatus, cb1, cb2);
- if (result == NULL)
- return -1;
- Py_DECREF(result);
+ PyObject *result = PyObject_CallMethod(pv, "status", "iii", typeStatus, cb1, cb2);
+ if (result == NULL)
+ return -1;
+ Py_DECREF(result);
}
return 0;
}
static FNFCIGETNEXTCABINET(cb_getnextcabinet)
{
if (pv) {
- PyObject *result = PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab);
- if (result == NULL)
- return -1;
- if (!PyString_Check(result)) {
- PyErr_Format(PyExc_TypeError,
- "Incorrect return type %s from getnextcabinet",
- result->ob_type->tp_name);
- Py_DECREF(result);
- return FALSE;
- }
- strncpy(pccab->szCab, PyString_AsString(result), sizeof(pccab->szCab));
- return TRUE;
+ PyObject *result = PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab);
+ if (result == NULL)
+ return -1;
+ if (!PyString_Check(result)) {
+ PyErr_Format(PyExc_TypeError,
+ "Incorrect return type %s from getnextcabinet",
+ result->ob_type->tp_name);
+ Py_DECREF(result);
+ return FALSE;
+ }
+ strncpy(pccab->szCab, PyString_AsString(result), sizeof(pccab->szCab));
+ return TRUE;
}
return FALSE;
}
/* Need Win32 handle to get time stamps */
handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle == INVALID_HANDLE_VALUE)
- return -1;
+ return -1;
if (GetFileInformationByHandle(handle, &bhfi) == FALSE)
{
- CloseHandle(handle);
- return -1;
+ CloseHandle(handle);
+ return -1;
}
FileTimeToLocalFileTime(&bhfi.ftLastWriteTime, &filetime);
FileTimeToDosDateTime(&filetime, pdate, ptime);
*pattribs = (int)(bhfi.dwFileAttributes &
- (_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH));
+ (_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH));
CloseHandle(handle);
if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files))
- return NULL;
+ return NULL;
if (!PyList_Check(files)) {
- PyErr_SetString(PyExc_TypeError, "FCICreate expects a list");
- return NULL;
+ PyErr_SetString(PyExc_TypeError, "FCICreate expects a list");
+ return NULL;
}
ccab.cb = INT_MAX; /* no need to split CAB into multiple media */
ccab.szDisk[0] = '\0';
for (i = 0, p = cabname; *p; p = CharNext(p))
- if (*p == '\\' || *p == '/')
- i = p - cabname + 1;
+ if (*p == '\\' || *p == '/')
+ i = p - cabname + 1;
if (i >= sizeof(ccab.szCabPath) ||
- strlen(cabname+i) >= sizeof(ccab.szCab)) {
- PyErr_SetString(PyExc_ValueError, "path name too long");
- return 0;
+ strlen(cabname+i) >= sizeof(ccab.szCab)) {
+ PyErr_SetString(PyExc_ValueError, "path name too long");
+ return 0;
}
if (i > 0) {
- memcpy(ccab.szCabPath, cabname, i);
- ccab.szCabPath[i] = '\0';
- strcpy(ccab.szCab, cabname+i);
+ memcpy(ccab.szCabPath, cabname, i);
+ ccab.szCabPath[i] = '\0';
+ strcpy(ccab.szCab, cabname+i);
} else {
- strcpy(ccab.szCabPath, ".\\");
- strcpy(ccab.szCab, cabname);
+ strcpy(ccab.szCabPath, ".\\");
+ strcpy(ccab.szCab, cabname);
}
hfci = FCICreate(&erf, cb_fileplaced, cb_alloc, cb_free,
- cb_open, cb_read, cb_write, cb_close, cb_seek, cb_delete,
- cb_gettempfile, &ccab, NULL);
+ cb_open, cb_read, cb_write, cb_close, cb_seek, cb_delete,
+ cb_gettempfile, &ccab, NULL);
if (hfci == NULL) {
- PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper);
- return NULL;
+ PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper);
+ return NULL;
}
for (i=0; i < PyList_GET_SIZE(files); i++) {
- PyObject *item = PyList_GET_ITEM(files, i);
- char *filename, *cabname;
- if (!PyArg_ParseTuple(item, "ss", &filename, &cabname))
- goto err;
- if (!FCIAddFile(hfci, filename, cabname, FALSE,
- cb_getnextcabinet, cb_status, cb_getopeninfo,
- tcompTYPE_MSZIP))
- goto err;
+ PyObject *item = PyList_GET_ITEM(files, i);
+ char *filename, *cabname;
+ if (!PyArg_ParseTuple(item, "ss", &filename, &cabname))
+ goto err;
+ if (!FCIAddFile(hfci, filename, cabname, FALSE,
+ cb_getnextcabinet, cb_status, cb_getopeninfo,
+ tcompTYPE_MSZIP))
+ goto err;
}
if (!FCIFlushCabinet(hfci, FALSE, cb_getnextcabinet, cb_status))
- goto err;
+ goto err;
if (!FCIDestroy(hfci))
- goto err;
+ goto err;
Py_INCREF(Py_None);
return Py_None;
MSIHANDLE err = MsiGetLastErrorRecord();
if (err == 0) {
- switch(status) {
- case ERROR_ACCESS_DENIED:
- PyErr_SetString(MSIError, "access denied");
- return NULL;
- case ERROR_FUNCTION_FAILED:
- PyErr_SetString(MSIError, "function failed");
- return NULL;
- case ERROR_INVALID_DATA:
- PyErr_SetString(MSIError, "invalid data");
- return NULL;
- case ERROR_INVALID_HANDLE:
- PyErr_SetString(MSIError, "invalid handle");
- return NULL;
- case ERROR_INVALID_STATE:
- PyErr_SetString(MSIError, "invalid state");
- return NULL;
- case ERROR_INVALID_PARAMETER:
- PyErr_SetString(MSIError, "invalid parameter");
- return NULL;
- default:
- PyErr_Format(MSIError, "unknown error %x", status);
- return NULL;
- }
+ switch(status) {
+ case ERROR_ACCESS_DENIED:
+ PyErr_SetString(MSIError, "access denied");
+ return NULL;
+ case ERROR_FUNCTION_FAILED:
+ PyErr_SetString(MSIError, "function failed");
+ return NULL;
+ case ERROR_INVALID_DATA:
+ PyErr_SetString(MSIError, "invalid data");
+ return NULL;
+ case ERROR_INVALID_HANDLE:
+ PyErr_SetString(MSIError, "invalid handle");
+ return NULL;
+ case ERROR_INVALID_STATE:
+ PyErr_SetString(MSIError, "invalid state");
+ return NULL;
+ case ERROR_INVALID_PARAMETER:
+ PyErr_SetString(MSIError, "invalid parameter");
+ return NULL;
+ default:
+ PyErr_Format(MSIError, "unknown error %x", status);
+ return NULL;
+ }
}
code = MsiRecordGetInteger(err, 1); /* XXX code */
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
- res = malloc(size+1);
- MsiFormatRecord(0, err, res, &size);
- res[size]='\0';
+ res = malloc(size+1);
+ MsiFormatRecord(0, err, res, &size);
+ res[size]='\0';
}
MsiCloseHandle(err);
PyErr_SetString(MSIError, res);
if (res != buf)
- free(res);
+ free(res);
return NULL;
}
int status;
if (!PyArg_ParseTuple(args, "I:GetInteger", &field))
- return NULL;
+ return NULL;
status = MsiRecordGetInteger(record->h, field);
if (status == MSI_NULL_INTEGER){
- PyErr_SetString(MSIError, "could not convert record field to integer");
- return NULL;
+ PyErr_SetString(MSIError, "could not convert record field to integer");
+ return NULL;
}
return PyInt_FromLong((long) status);
}
PyObject* string;
if (!PyArg_ParseTuple(args, "I:GetString", &field))
- return NULL;
+ return NULL;
status = MsiRecordGetString(record->h, field, res, &size);
if (status == ERROR_MORE_DATA) {
- res = (char*) malloc(size + 1);
- if (res == NULL)
- return PyErr_NoMemory();
- status = MsiRecordGetString(record->h, field, res, &size);
+ res = (char*) malloc(size + 1);
+ if (res == NULL)
+ return PyErr_NoMemory();
+ status = MsiRecordGetString(record->h, field, res, &size);
}
if (status != ERROR_SUCCESS)
- return msierror((int) status);
+ return msierror((int) status);
string = PyString_FromString(res);
if (buf != res)
- free(res);
+ free(res);
return string;
}
{
int status = MsiRecordClearData(record->h);
if (status != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
char *data;
if (!PyArg_ParseTuple(args, "is:SetString", &field, &data))
- return NULL;
+ return NULL;
if ((status = MsiRecordSetString(record->h, field, data)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
char *data;
if (!PyArg_ParseTuple(args, "is:SetStream", &field, &data))
- return NULL;
+ return NULL;
if ((status = MsiRecordSetStream(record->h, field, data)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
int data;
if (!PyArg_ParseTuple(args, "ii:SetInteger", &field, &data))
- return NULL;
+ return NULL;
if ((status = MsiRecordSetInteger(record->h, field, data)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
static PyMethodDef record_methods[] = {
{ "GetFieldCount", (PyCFunction)record_getfieldcount, METH_NOARGS,
- PyDoc_STR("GetFieldCount() -> int\nWraps MsiRecordGetFieldCount")},
+ PyDoc_STR("GetFieldCount() -> int\nWraps MsiRecordGetFieldCount")},
{ "GetInteger", (PyCFunction)record_getinteger, METH_VARARGS,
PyDoc_STR("GetInteger(field) -> int\nWraps MsiRecordGetInteger")},
{ "GetString", (PyCFunction)record_getstring, METH_VARARGS,
PyDoc_STR("GetString(field) -> string\nWraps MsiRecordGetString")},
{ "SetString", (PyCFunction)record_setstring, METH_VARARGS,
- PyDoc_STR("SetString(field,str) -> None\nWraps MsiRecordSetString")},
+ PyDoc_STR("SetString(field,str) -> None\nWraps MsiRecordSetString")},
{ "SetStream", (PyCFunction)record_setstream, METH_VARARGS,
- PyDoc_STR("SetStream(field,filename) -> None\nWraps MsiRecordSetInteger")},
+ PyDoc_STR("SetStream(field,filename) -> None\nWraps MsiRecordSetInteger")},
{ "SetInteger", (PyCFunction)record_setinteger, METH_VARARGS,
- PyDoc_STR("SetInteger(field,int) -> None\nWraps MsiRecordSetInteger")},
+ PyDoc_STR("SetInteger(field,int) -> None\nWraps MsiRecordSetInteger")},
{ "ClearData", (PyCFunction)record_cleardata, METH_NOARGS,
- PyDoc_STR("ClearData() -> int\nWraps MsiRecordGClearData")},
+ PyDoc_STR("ClearData() -> int\nWraps MsiRecordGClearData")},
{ NULL, NULL }
};
static PyTypeObject record_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_msi.Record", /*tp_name*/
- sizeof(msiobj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)msiobj_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- PyObject_GenericGetAttr,/*tp_getattro*/
- PyObject_GenericSetAttr,/*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- record_methods, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_msi.Record", /*tp_name*/
+ sizeof(msiobj), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)msiobj_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr,/*tp_getattro*/
+ PyObject_GenericSetAttr,/*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ record_methods, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
};
static PyObject*
msiobj *result = PyObject_NEW(struct msiobj, &record_Type);
if (!result) {
- MsiCloseHandle(h);
- return NULL;
+ MsiCloseHandle(h);
+ return NULL;
}
result->h = h;
DWORD ssize = sizeof(sval);
if (!PyArg_ParseTuple(args, "i:GetProperty", &field))
- return NULL;
+ return NULL;
- status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
- &fval, sval, &ssize);
- if (status == ERROR_MORE_DATA) {
- sval = malloc(ssize);
status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
&fval, sval, &ssize);
+ if (status == ERROR_MORE_DATA) {
+ sval = malloc(ssize);
+ status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
+ &fval, sval, &ssize);
}
switch(type) {
- case VT_I2: case VT_I4:
- return PyInt_FromLong(ival);
- case VT_FILETIME:
- PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
- return NULL;
- case VT_LPSTR:
- result = PyString_FromStringAndSize(sval, ssize);
- if (sval != sbuf)
- free(sval);
- return result;
+ case VT_I2: case VT_I4:
+ return PyInt_FromLong(ival);
+ case VT_FILETIME:
+ PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
+ return NULL;
+ case VT_LPSTR:
+ result = PyString_FromStringAndSize(sval, ssize);
+ if (sval != sbuf)
+ free(sval);
+ return result;
}
PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
return NULL;
status = MsiSummaryInfoGetPropertyCount(si->h, &result);
if (status != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
return PyInt_FromLong(result);
}
PyObject* data;
if (!PyArg_ParseTuple(args, "iO:SetProperty", &field, &data))
- return NULL;
+ return NULL;
if (PyString_Check(data)) {
- status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR,
- 0, NULL, PyString_AsString(data));
+ status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR,
+ 0, NULL, PyString_AsString(data));
} else if (PyInt_Check(data)) {
- status = MsiSummaryInfoSetProperty(si->h, field, VT_I4,
- PyInt_AsLong(data), NULL, NULL);
+ status = MsiSummaryInfoSetProperty(si->h, field, VT_I4,
+ PyInt_AsLong(data), NULL, NULL);
} else {
- PyErr_SetString(PyExc_TypeError, "unsupported type");
- return NULL;
+ PyErr_SetString(PyExc_TypeError, "unsupported type");
+ return NULL;
}
if (status != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
status = MsiSummaryInfoPersist(si->h);
if (status != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef summary_methods[] = {
{ "GetProperty", (PyCFunction)summary_getproperty, METH_VARARGS,
- PyDoc_STR("GetProperty(propid) -> value\nWraps MsiSummaryInfoGetProperty")},
+ PyDoc_STR("GetProperty(propid) -> value\nWraps MsiSummaryInfoGetProperty")},
{ "GetPropertyCount", (PyCFunction)summary_getpropertycount, METH_NOARGS,
- PyDoc_STR("GetProperty() -> int\nWraps MsiSummaryInfoGetPropertyCount")},
+ PyDoc_STR("GetProperty() -> int\nWraps MsiSummaryInfoGetPropertyCount")},
{ "SetProperty", (PyCFunction)summary_setproperty, METH_VARARGS,
- PyDoc_STR("SetProperty(value) -> None\nWraps MsiSummaryInfoProperty")},
+ PyDoc_STR("SetProperty(value) -> None\nWraps MsiSummaryInfoProperty")},
{ "Persist", (PyCFunction)summary_persist, METH_NOARGS,
- PyDoc_STR("Persist() -> None\nWraps MsiSummaryInfoPersist")},
+ PyDoc_STR("Persist() -> None\nWraps MsiSummaryInfoPersist")},
{ NULL, NULL }
};
static PyTypeObject summary_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_msi.SummaryInformation", /*tp_name*/
- sizeof(msiobj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)msiobj_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- PyObject_GenericGetAttr,/*tp_getattro*/
- PyObject_GenericSetAttr,/*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- summary_methods, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_msi.SummaryInformation", /*tp_name*/
+ sizeof(msiobj), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)msiobj_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr,/*tp_getattro*/
+ PyObject_GenericSetAttr,/*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ summary_methods, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
};
/*************************** View objects **************/
PyObject *oparams = Py_None;
if (!PyArg_ParseTuple(args, "O:Execute", &oparams))
- return NULL;
+ return NULL;
if (oparams != Py_None) {
- if (oparams->ob_type != &record_Type) {
- PyErr_SetString(PyExc_TypeError, "Execute argument must be a record");
- return NULL;
- }
- params = ((msiobj*)oparams)->h;
+ if (oparams->ob_type != &record_Type) {
+ PyErr_SetString(PyExc_TypeError, "Execute argument must be a record");
+ return NULL;
+ }
+ params = ((msiobj*)oparams)->h;
}
status = MsiViewExecute(view->h, params);
if (status != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
MSIHANDLE result;
if ((status = MsiViewFetch(view->h, &result)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
return record_new(result);
}
MSIHANDLE result;
if (!PyArg_ParseTuple(args, "i:GetColumnInfo", &kind))
- return NULL;
+ return NULL;
if ((status = MsiViewGetColumnInfo(view->h, kind, &result)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
return record_new(result);
}
int status;
if (!PyArg_ParseTuple(args, "iO:Modify", &kind, &data))
- return NULL;
+ return NULL;
if (data->ob_type != &record_Type) {
- PyErr_SetString(PyExc_TypeError, "Modify expects a record object");
- return NULL;
+ PyErr_SetString(PyExc_TypeError, "Modify expects a record object");
+ return NULL;
}
if ((status = MsiViewModify(view->h, kind, ((msiobj*)data)->h)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
int status;
if ((status = MsiViewClose(view->h)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
static PyMethodDef view_methods[] = {
{ "Execute", (PyCFunction)view_execute, METH_VARARGS,
- PyDoc_STR("Execute(params=None) -> None\nWraps MsiViewExecute")},
+ PyDoc_STR("Execute(params=None) -> None\nWraps MsiViewExecute")},
{ "GetColumnInfo", (PyCFunction)view_getcolumninfo, METH_VARARGS,
- PyDoc_STR("GetColumnInfo() -> result\nWraps MsiGetColumnInfo")},
+ PyDoc_STR("GetColumnInfo() -> result\nWraps MsiGetColumnInfo")},
{ "Fetch", (PyCFunction)view_fetch, METH_NOARGS,
- PyDoc_STR("Fetch() -> result\nWraps MsiViewFetch")},
+ PyDoc_STR("Fetch() -> result\nWraps MsiViewFetch")},
{ "Modify", (PyCFunction)view_modify, METH_VARARGS,
- PyDoc_STR("Modify(mode,record) -> None\nWraps MsiViewModify")},
+ PyDoc_STR("Modify(mode,record) -> None\nWraps MsiViewModify")},
{ "Close", (PyCFunction)view_close, METH_NOARGS,
- PyDoc_STR("Close() -> result\nWraps MsiViewClose")},
+ PyDoc_STR("Close() -> result\nWraps MsiViewClose")},
{ NULL, NULL }
};
static PyTypeObject msiview_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_msi.View", /*tp_name*/
- sizeof(msiobj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)msiobj_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- PyObject_GenericGetAttr,/*tp_getattro*/
- PyObject_GenericSetAttr,/*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- view_methods, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_msi.View", /*tp_name*/
+ sizeof(msiobj), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)msiobj_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr,/*tp_getattro*/
+ PyObject_GenericSetAttr,/*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ view_methods, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
};
/*************************** Database objects **************/
msiobj *result;
if (!PyArg_ParseTuple(args, "s:OpenView", &sql))
- return NULL;
+ return NULL;
if ((status = MsiDatabaseOpenView(msidb->h, sql, &hView)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
result = PyObject_NEW(struct msiobj, &msiview_Type);
if (!result) {
- MsiCloseHandle(hView);
- return NULL;
+ MsiCloseHandle(hView);
+ return NULL;
}
result->h = hView;
int status;
if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
Py_INCREF(Py_None);
return Py_None;
msiobj *oresult;
if (!PyArg_ParseTuple(args, "i:GetSummaryInformation", &count))
- return NULL;
+ return NULL;
status = MsiGetSummaryInformation(db->h, NULL, count, &result);
if (status != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
oresult = PyObject_NEW(struct msiobj, &summary_Type);
if (!result) {
- MsiCloseHandle(result);
- return NULL;
+ MsiCloseHandle(result);
+ return NULL;
}
oresult->h = result;
static PyMethodDef db_methods[] = {
{ "OpenView", (PyCFunction)msidb_openview, METH_VARARGS,
- PyDoc_STR("OpenView(sql) -> viewobj\nWraps MsiDatabaseOpenView")},
+ PyDoc_STR("OpenView(sql) -> viewobj\nWraps MsiDatabaseOpenView")},
{ "Commit", (PyCFunction)msidb_commit, METH_NOARGS,
- PyDoc_STR("Commit() -> None\nWraps MsiDatabaseCommit")},
+ PyDoc_STR("Commit() -> None\nWraps MsiDatabaseCommit")},
{ "GetSummaryInformation", (PyCFunction)msidb_getsummaryinformation, METH_VARARGS,
- PyDoc_STR("GetSummaryInformation(updateCount) -> viewobj\nWraps MsiGetSummaryInformation")},
+ PyDoc_STR("GetSummaryInformation(updateCount) -> viewobj\nWraps MsiGetSummaryInformation")},
{ NULL, NULL }
};
static PyTypeObject msidb_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_msi.Database", /*tp_name*/
- sizeof(msiobj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)msiobj_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- PyObject_GenericGetAttr,/*tp_getattro*/
- PyObject_GenericSetAttr,/*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- db_methods, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_msi.Database", /*tp_name*/
+ sizeof(msiobj), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)msiobj_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr,/*tp_getattro*/
+ PyObject_GenericSetAttr,/*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ db_methods, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
};
static PyObject* msiopendb(PyObject *obj, PyObject *args)
msiobj *result;
if (!PyArg_ParseTuple(args, "si:MSIOpenDatabase", &path, &persist))
- return NULL;
+ return NULL;
- status = MsiOpenDatabase(path, (LPCSTR)persist, &h);
+ status = MsiOpenDatabase(path, (LPCSTR)persist, &h);
if (status != ERROR_SUCCESS)
- return msierror(status);
+ return msierror(status);
result = PyObject_NEW(struct msiobj, &msidb_Type);
if (!result) {
- MsiCloseHandle(h);
- return NULL;
+ MsiCloseHandle(h);
+ return NULL;
}
result->h = h;
return (PyObject*)result;
MSIHANDLE h;
if (!PyArg_ParseTuple(args, "i:CreateRecord", &count))
- return NULL;
+ return NULL;
h = MsiCreateRecord(count);
if (h == 0)
- return msierror(0);
+ return msierror(0);
return record_new(h);
}
static PyMethodDef msi_methods[] = {
- {"UuidCreate", (PyCFunction)uuidcreate, METH_NOARGS,
- PyDoc_STR("UuidCreate() -> string")},
- {"FCICreate", (PyCFunction)fcicreate, METH_VARARGS,
- PyDoc_STR("fcicreate(cabname,files) -> None")},
- {"OpenDatabase", (PyCFunction)msiopendb, METH_VARARGS,
- PyDoc_STR("OpenDatabase(name, flags) -> dbobj\nWraps MsiOpenDatabase")},
- {"CreateRecord", (PyCFunction)createrecord, METH_VARARGS,
- PyDoc_STR("OpenDatabase(name, flags) -> dbobj\nWraps MsiCreateRecord")},
- {NULL, NULL} /* sentinel */
+ {"UuidCreate", (PyCFunction)uuidcreate, METH_NOARGS,
+ PyDoc_STR("UuidCreate() -> string")},
+ {"FCICreate", (PyCFunction)fcicreate, METH_VARARGS,
+ PyDoc_STR("fcicreate(cabname,files) -> None")},
+ {"OpenDatabase", (PyCFunction)msiopendb, METH_VARARGS,
+ PyDoc_STR("OpenDatabase(name, flags) -> dbobj\nWraps MsiOpenDatabase")},
+ {"CreateRecord", (PyCFunction)createrecord, METH_VARARGS,
+ PyDoc_STR("OpenDatabase(name, flags) -> dbobj\nWraps MsiCreateRecord")},
+ {NULL, NULL} /* sentinel */
};
static char msi_doc[] = "Documentation";
m = Py_InitModule3("_msi", msi_methods, msi_doc);
if (m == NULL)
- return;
+ return;
PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (int)MSIDBOPEN_CREATEDIRECT);
PyModule_AddIntConstant(m, "MSIDBOPEN_CREATE", (int)MSIDBOPEN_CREATE);
MSIError = PyErr_NewException ("_msi.MSIError", NULL, NULL);
if (!MSIError)
- return;
+ return;
PyModule_AddObject(m, "MSIError", MSIError);
}