Back to index

python3.2  3.2.2
Classes | Typedefs | Functions | Variables
_msi.c File Reference
#include <Python.h>
#include <fci.h>
#include <fcntl.h>
#include <windows.h>
#include <msi.h>
#include <msiquery.h>
#include <msidefs.h>
#include <rpc.h>

Go to the source code of this file.

Classes

struct  msiobj

Typedefs

typedef struct msiobj msiobj

Functions

static PyObjectuuidcreate (PyObject *obj, PyObject *args)
static FNFCIALLOC (cb_alloc)
static FNFCIFREE (cb_free)
static FNFCIOPEN (cb_open)
static FNFCIREAD (cb_read)
static FNFCIWRITE (cb_write)
static FNFCICLOSE (cb_close)
static FNFCISEEK (cb_seek)
static FNFCIDELETE (cb_delete)
static FNFCIFILEPLACED (cb_fileplaced)
static FNFCIGETTEMPFILE (cb_gettempfile)
static FNFCISTATUS (cb_status)
static FNFCIGETNEXTCABINET (cb_getnextcabinet)
static FNFCIGETOPENINFO (cb_getopeninfo)
static PyObjectfcicreate (PyObject *obj, PyObject *args)
static void msiobj_dealloc (msiobj *msidb)
static PyObjectmsiobj_close (msiobj *msidb, PyObject *args)
static PyObjectmsierror (int status)
static PyObjectrecord_getfieldcount (msiobj *record, PyObject *args)
static PyObjectrecord_getinteger (msiobj *record, PyObject *args)
static PyObjectrecord_getstring (msiobj *record, PyObject *args)
static PyObjectrecord_cleardata (msiobj *record, PyObject *args)
static PyObjectrecord_setstring (msiobj *record, PyObject *args)
static PyObjectrecord_setstream (msiobj *record, PyObject *args)
static PyObjectrecord_setinteger (msiobj *record, PyObject *args)
static PyObjectrecord_new (MSIHANDLE h)
static PyObjectsummary_getproperty (msiobj *si, PyObject *args)
static PyObjectsummary_getpropertycount (msiobj *si, PyObject *args)
static PyObjectsummary_setproperty (msiobj *si, PyObject *args)
static PyObjectsummary_persist (msiobj *si, PyObject *args)
static PyObjectview_execute (msiobj *view, PyObject *args)
static PyObjectview_fetch (msiobj *view, PyObject *args)
static PyObjectview_getcolumninfo (msiobj *view, PyObject *args)
static PyObjectview_modify (msiobj *view, PyObject *args)
static PyObjectview_close (msiobj *view, PyObject *args)
static PyObjectmsidb_openview (msiobj *msidb, PyObject *args)
static PyObjectmsidb_commit (msiobj *msidb, PyObject *args)
static PyObjectmsidb_getsummaryinformation (msiobj *db, PyObject *args)
static PyObjectmsiopendb (PyObject *obj, PyObject *args)
static PyObjectcreaterecord (PyObject *o, PyObject *args)
PyMODINIT_FUNC PyInit__msi (void)

Variables

static PyObjectMSIError
static PyMethodDef record_methods []
static PyTypeObject record_Type
static PyMethodDef summary_methods []
static PyTypeObject summary_Type
static PyMethodDef view_methods []
static PyTypeObject msiview_Type
static PyMethodDef db_methods []
static PyTypeObject msidb_Type
static PyMethodDef msi_methods []
static char msi_doc [] = "Documentation"
static struct PyModuleDef

Class Documentation

struct msiobj

Definition at line 264 of file _msi.c.

Class Members
PyObject_HEAD MSIHANDLE h

Typedef Documentation

typedef struct msiobj msiobj

Function Documentation

static PyObject* createrecord ( PyObject o,
PyObject args 
) [static]

Definition at line 970 of file _msi.c.

{
    int count;
    MSIHANDLE h;

    if (!PyArg_ParseTuple(args, "i:CreateRecord", &count))
        return NULL;

    h = MsiCreateRecord(count);
    if (h == 0)
        return msierror(0);

    return record_new(h);
}

Here is the call graph for this function:

static PyObject* fcicreate ( PyObject obj,
PyObject args 
) [static]

Definition at line 181 of file _msi.c.

{
    char *cabname, *p;
    PyObject *files;
    CCAB ccab;
    HFCI hfci;
    ERF erf;
    Py_ssize_t i;


    if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files))
        return NULL;

    if (!PyList_Check(files)) {
        PyErr_SetString(PyExc_TypeError, "FCICreate expects a list");
        return NULL;
    }

    ccab.cb = INT_MAX; /* no need to split CAB into multiple media */
    ccab.cbFolderThresh = 1000000; /* flush directory after this many bytes */
    ccab.cbReserveCFData = 0;
    ccab.cbReserveCFFolder = 0;
    ccab.cbReserveCFHeader = 0;

    ccab.iCab = 1;
    ccab.iDisk = 1;

    ccab.setID = 0;
    ccab.szDisk[0] = '\0';

    for (i = 0, p = cabname; *p; p = CharNext(p))
        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;
    }

    if (i > 0) {
        memcpy(ccab.szCabPath, cabname, i);
        ccab.szCabPath[i] = '\0';
        strcpy(ccab.szCab, cabname+i);
    } else {
        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);

    if (hfci == 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;
    }

    if (!FCIFlushCabinet(hfci, FALSE, cb_getnextcabinet, cb_status))
        goto err;

    if (!FCIDestroy(hfci))
        goto err;

    Py_INCREF(Py_None);
    return Py_None;
err:
    PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); /* XXX better error type */
    FCIDestroy(hfci);
    return NULL;
}

Here is the call graph for this function:

static FNFCIALLOC ( cb_alloc  ) [static]

Definition at line 46 of file _msi.c.

{
    return malloc(cb);
}
static FNFCICLOSE ( cb_close  ) [static]

Definition at line 80 of file _msi.c.

{
    int result = _close(hf);
    if (result != 0)
        *err = errno;
    return result;
}

Here is the call graph for this function:

static FNFCIDELETE ( cb_delete  ) [static]

Definition at line 96 of file _msi.c.

{
    int result = remove(pszFile);
    if (result != 0)
        *err = errno;
    return result;
}
static FNFCIFILEPLACED ( cb_fileplaced  ) [static]

Definition at line 104 of file _msi.c.

{
    return 0;
}
static FNFCIFREE ( cb_free  ) [static]

Definition at line 51 of file _msi.c.

{
    free(memory);
}
static FNFCIGETNEXTCABINET ( cb_getnextcabinet  ) [static]

Definition at line 133 of file _msi.c.

{
    if (pv) {
        PyObject *result = PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab);
        if (result == NULL)
            return -1;
        if (!PyBytes_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, PyBytes_AsString(result), sizeof(pccab->szCab));
        return TRUE;
    }
    return FALSE;
}

Here is the call graph for this function:

static FNFCIGETOPENINFO ( cb_getopeninfo  ) [static]

Definition at line 152 of file _msi.c.

{
    BY_HANDLE_FILE_INFORMATION bhfi;
    FILETIME filetime;
    HANDLE handle;

    /* Need Win32 handle to get time stamps */
    handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if (handle == INVALID_HANDLE_VALUE)
        return -1;

    if (GetFileInformationByHandle(handle, &bhfi) == FALSE)
    {
        CloseHandle(handle);
        return -1;
    }

    FileTimeToLocalFileTime(&bhfi.ftLastWriteTime, &filetime);
    FileTimeToDosDateTime(&filetime, pdate, ptime);

    *pattribs = (int)(bhfi.dwFileAttributes &
        (_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH));

    CloseHandle(handle);

    return _open(pszName, _O_RDONLY | _O_BINARY);
}

Here is the call graph for this function:

static FNFCIGETTEMPFILE ( cb_gettempfile  ) [static]

Definition at line 109 of file _msi.c.

{
    char *name = _tempnam("", "tmp");
    if ((name != NULL) && ((int)strlen(name) < cbTempName)) {
        strcpy(pszTempName, name);
        free(name);
        return TRUE;
    }

    if (name) free(name);
    return FALSE;
}
static FNFCIOPEN ( cb_open  ) [static]

Definition at line 56 of file _msi.c.

{
    int result = _open(pszFile, oflag, pmode);
    if (result == -1)
        *err = errno;
    return result;
}

Here is the call graph for this function:

static FNFCIREAD ( cb_read  ) [static]

Definition at line 64 of file _msi.c.

{
    UINT result = (UINT)_read(hf, memory, cb);
    if (result != cb)
        *err = errno;
    return result;
}

Here is the call graph for this function:

static FNFCISEEK ( cb_seek  ) [static]

Definition at line 88 of file _msi.c.

{
    long result = (long)_lseek(hf, dist, seektype);
    if (result == -1)
        *err = errno;
    return result;
}
static FNFCISTATUS ( cb_status  ) [static]

Definition at line 122 of file _msi.c.

{
    if (pv) {
        PyObject *result = PyObject_CallMethod(pv, "status", "iii", typeStatus, cb1, cb2);
        if (result == NULL)
            return -1;
        Py_DECREF(result);
    }
    return 0;
}

Here is the call graph for this function:

static FNFCIWRITE ( cb_write  ) [static]

Definition at line 72 of file _msi.c.

{
    UINT result = (UINT)_write(hf, memory, cb);
    if (result != cb)
        *err = errno;
    return result;
}
static PyObject* msidb_commit ( msiobj msidb,
PyObject args 
) [static]

Definition at line 855 of file _msi.c.

{
    int status;

    if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* msidb_getsummaryinformation ( msiobj db,
PyObject args 
) [static]

Definition at line 867 of file _msi.c.

{
    int status;
    int count;
    MSIHANDLE result;
    msiobj *oresult;

    if (!PyArg_ParseTuple(args, "i:GetSummaryInformation", &count))
        return NULL;

    status = MsiGetSummaryInformation(db->h, NULL, count, &result);
    if (status != ERROR_SUCCESS)
        return msierror(status);

    oresult = PyObject_NEW(struct msiobj, &summary_Type);
    if (!result) {
        MsiCloseHandle(result);
        return NULL;
    }

    oresult->h = result;
    return (PyObject*)oresult;
}

Here is the call graph for this function:

static PyObject* msidb_openview ( msiobj msidb,
PyObject args 
) [static]

Definition at line 831 of file _msi.c.

{
    int status;
    char *sql;
    MSIHANDLE hView;
    msiobj *result;

    if (!PyArg_ParseTuple(args, "s:OpenView", &sql))
        return NULL;

    if ((status = MsiDatabaseOpenView(msidb->h, sql, &hView)) != ERROR_SUCCESS)
        return msierror(status);

    result = PyObject_NEW(struct msiobj, &msiview_Type);
    if (!result) {
        MsiCloseHandle(hView);
        return NULL;
    }

    result->h = hView;
    return (PyObject*)result;
}

Here is the call graph for this function:

static PyObject* msierror ( int  status) [static]

Definition at line 286 of file _msi.c.

{
    int code;
    char buf[2000];
    char *res = buf;
    DWORD size = sizeof(buf);
    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;
        }
    }

    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';
    }
    MsiCloseHandle(err);
    PyErr_SetString(MSIError, res);
    if (res != buf)
        free(res);
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* msiobj_close ( msiobj msidb,
PyObject args 
) [static]

Definition at line 277 of file _msi.c.

{
    MsiCloseHandle(msidb->h);
    msidb->h = 0;
    Py_INCREF(Py_None);
    return Py_None;
}
static void msiobj_dealloc ( msiobj msidb) [static]

Definition at line 270 of file _msi.c.

{
    MsiCloseHandle(msidb->h);
    msidb->h = 0;
}
static PyObject* msiopendb ( PyObject obj,
PyObject args 
) [static]

Definition at line 945 of file _msi.c.

{
    int status;
    char *path;
    int persist;
    MSIHANDLE h;
    msiobj *result;

    if (!PyArg_ParseTuple(args, "si:MSIOpenDatabase", &path, &persist))
        return NULL;

        status = MsiOpenDatabase(path, (LPCSTR)persist, &h);
    if (status != ERROR_SUCCESS)
        return msierror(status);

    result = PyObject_NEW(struct msiobj, &msidb_Type);
    if (!result) {
        MsiCloseHandle(h);
        return NULL;
    }
    result->h = h;
    return (PyObject*)result;
}

Here is the call graph for this function:

Definition at line 1014 of file _msi.c.

{
    PyObject *m;

    m = PyModule_Create(&_msimodule);
    if (m == NULL)
        return NULL;

    PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (int)MSIDBOPEN_CREATEDIRECT);
    PyModule_AddIntConstant(m, "MSIDBOPEN_CREATE", (int)MSIDBOPEN_CREATE);
    PyModule_AddIntConstant(m, "MSIDBOPEN_DIRECT", (int)MSIDBOPEN_DIRECT);
    PyModule_AddIntConstant(m, "MSIDBOPEN_READONLY", (int)MSIDBOPEN_READONLY);
    PyModule_AddIntConstant(m, "MSIDBOPEN_TRANSACT", (int)MSIDBOPEN_TRANSACT);
    PyModule_AddIntConstant(m, "MSIDBOPEN_PATCHFILE", (int)MSIDBOPEN_PATCHFILE);

    PyModule_AddIntConstant(m, "MSICOLINFO_NAMES", MSICOLINFO_NAMES);
    PyModule_AddIntConstant(m, "MSICOLINFO_TYPES", MSICOLINFO_TYPES);

    PyModule_AddIntConstant(m, "MSIMODIFY_SEEK", MSIMODIFY_SEEK);
    PyModule_AddIntConstant(m, "MSIMODIFY_REFRESH", MSIMODIFY_REFRESH);
    PyModule_AddIntConstant(m, "MSIMODIFY_INSERT", MSIMODIFY_INSERT);
    PyModule_AddIntConstant(m, "MSIMODIFY_UPDATE", MSIMODIFY_UPDATE);
    PyModule_AddIntConstant(m, "MSIMODIFY_ASSIGN", MSIMODIFY_ASSIGN);
    PyModule_AddIntConstant(m, "MSIMODIFY_REPLACE", MSIMODIFY_REPLACE);
    PyModule_AddIntConstant(m, "MSIMODIFY_MERGE", MSIMODIFY_MERGE);
    PyModule_AddIntConstant(m, "MSIMODIFY_DELETE", MSIMODIFY_DELETE);
    PyModule_AddIntConstant(m, "MSIMODIFY_INSERT_TEMPORARY", MSIMODIFY_INSERT_TEMPORARY);
    PyModule_AddIntConstant(m, "MSIMODIFY_VALIDATE", MSIMODIFY_VALIDATE);
    PyModule_AddIntConstant(m, "MSIMODIFY_VALIDATE_NEW", MSIMODIFY_VALIDATE_NEW);
    PyModule_AddIntConstant(m, "MSIMODIFY_VALIDATE_FIELD", MSIMODIFY_VALIDATE_FIELD);
    PyModule_AddIntConstant(m, "MSIMODIFY_VALIDATE_DELETE", MSIMODIFY_VALIDATE_DELETE);

    PyModule_AddIntConstant(m, "PID_CODEPAGE", PID_CODEPAGE);
    PyModule_AddIntConstant(m, "PID_TITLE", PID_TITLE);
    PyModule_AddIntConstant(m, "PID_SUBJECT", PID_SUBJECT);
    PyModule_AddIntConstant(m, "PID_AUTHOR", PID_AUTHOR);
    PyModule_AddIntConstant(m, "PID_KEYWORDS", PID_KEYWORDS);
    PyModule_AddIntConstant(m, "PID_COMMENTS", PID_COMMENTS);
    PyModule_AddIntConstant(m, "PID_TEMPLATE", PID_TEMPLATE);
    PyModule_AddIntConstant(m, "PID_LASTAUTHOR", PID_LASTAUTHOR);
    PyModule_AddIntConstant(m, "PID_REVNUMBER", PID_REVNUMBER);
    PyModule_AddIntConstant(m, "PID_LASTPRINTED", PID_LASTPRINTED);
    PyModule_AddIntConstant(m, "PID_CREATE_DTM", PID_CREATE_DTM);
    PyModule_AddIntConstant(m, "PID_LASTSAVE_DTM", PID_LASTSAVE_DTM);
    PyModule_AddIntConstant(m, "PID_PAGECOUNT", PID_PAGECOUNT);
    PyModule_AddIntConstant(m, "PID_WORDCOUNT", PID_WORDCOUNT);
    PyModule_AddIntConstant(m, "PID_CHARCOUNT", PID_CHARCOUNT);
    PyModule_AddIntConstant(m, "PID_APPNAME", PID_APPNAME);
    PyModule_AddIntConstant(m, "PID_SECURITY", PID_SECURITY);

    MSIError = PyErr_NewException ("_msi.MSIError", NULL, NULL);
    if (!MSIError)
        return NULL;
    PyModule_AddObject(m, "MSIError", MSIError);
    return m;
}

Here is the call graph for this function:

static PyObject* record_cleardata ( msiobj record,
PyObject args 
) [static]

Definition at line 385 of file _msi.c.

{
    int status = MsiRecordClearData(record->h);
    if (status != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* record_getfieldcount ( msiobj record,
PyObject args 
) [static]

Definition at line 336 of file _msi.c.

{
    return PyLong_FromLong(MsiRecordGetFieldCount(record->h));
}

Here is the call graph for this function:

static PyObject* record_getinteger ( msiobj record,
PyObject args 
) [static]

Definition at line 342 of file _msi.c.

{
    unsigned int field;
    int status;

    if (!PyArg_ParseTuple(args, "I:GetInteger", &field))
        return NULL;
    status = MsiRecordGetInteger(record->h, field);
    if (status == MSI_NULL_INTEGER){
        PyErr_SetString(MSIError, "could not convert record field to integer");
        return NULL;
    }
    return PyLong_FromLong((long) status);
}

Here is the call graph for this function:

static PyObject* record_getstring ( msiobj record,
PyObject args 
) [static]

Definition at line 358 of file _msi.c.

{
    unsigned int field;
    unsigned int status;
    WCHAR buf[2000];
    WCHAR *res = buf;
    DWORD size = sizeof(buf);
    PyObject* string;

    if (!PyArg_ParseTuple(args, "I:GetString", &field))
        return NULL;
    status = MsiRecordGetStringW(record->h, field, res, &size);
    if (status == ERROR_MORE_DATA) {
        res = (WCHAR*) malloc((size + 1)*sizeof(WCHAR));
        if (res == NULL)
            return PyErr_NoMemory();
        status = MsiRecordGetStringW(record->h, field, res, &size);
    }
    if (status != ERROR_SUCCESS)
        return msierror((int) status);
    string = PyUnicode_FromUnicode(res, size);
    if (buf != res)
        free(res);
    return string;
}

Here is the call graph for this function:

static PyObject* record_new ( MSIHANDLE  h) [static]

Definition at line 511 of file _msi.c.

{
    msiobj *result = PyObject_NEW(struct msiobj, &record_Type);

    if (!result) {
        MsiCloseHandle(h);
        return NULL;
    }

    result->h = h;
    return (PyObject*)result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* record_setinteger ( msiobj record,
PyObject args 
) [static]

Definition at line 430 of file _msi.c.

{
    int status;
    int field;
    int data;

    if (!PyArg_ParseTuple(args, "ii:SetInteger", &field, &data))
        return NULL;

    if ((status = MsiRecordSetInteger(record->h, field, data)) != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* record_setstream ( msiobj record,
PyObject args 
) [static]

Definition at line 413 of file _msi.c.

{
    int status;
    int field;
    Py_UNICODE *data;

    if (!PyArg_ParseTuple(args, "iu:SetStream", &field, &data))
        return NULL;

    if ((status = MsiRecordSetStreamW(record->h, field, data)) != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* record_setstring ( msiobj record,
PyObject args 
) [static]

Definition at line 396 of file _msi.c.

{
    int status;
    int field;
    Py_UNICODE *data;

    if (!PyArg_ParseTuple(args, "iu:SetString", &field, &data))
        return NULL;

    if ((status = MsiRecordSetStringW(record->h, field, data)) != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* summary_getproperty ( msiobj si,
PyObject args 
) [static]

Definition at line 527 of file _msi.c.

{
    int status;
    int field;
    PyObject *result;
    UINT type;
    INT ival;
    FILETIME fval;
    char sbuf[1000];
    char *sval = sbuf;
    DWORD ssize = sizeof(sval);

    if (!PyArg_ParseTuple(args, "i:GetProperty", &field))
        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);
    }

    switch(type) {
        case VT_I2: case VT_I4:
            return PyLong_FromLong(ival);
        case VT_FILETIME:
            PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
            return NULL;
        case VT_LPSTR:
            result = PyBytes_FromStringAndSize(sval, ssize);
            if (sval != sbuf)
                free(sval);
            return result;
    }
    PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
    return NULL;
}

Here is the call graph for this function:

static PyObject* summary_getpropertycount ( msiobj si,
PyObject args 
) [static]

Definition at line 567 of file _msi.c.

{
    int status;
    UINT result;

    status = MsiSummaryInfoGetPropertyCount(si->h, &result);
    if (status != ERROR_SUCCESS)
        return msierror(status);

    return PyLong_FromLong(result);
}

Here is the call graph for this function:

static PyObject* summary_persist ( msiobj si,
PyObject args 
) [static]

Definition at line 613 of file _msi.c.

{
    int status;

    status = MsiSummaryInfoPersist(si->h);
    if (status != ERROR_SUCCESS)
        return msierror(status);
    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* summary_setproperty ( msiobj si,
PyObject args 
) [static]

Definition at line 580 of file _msi.c.

{
    int status;
    int field;
    PyObject* data;

    if (!PyArg_ParseTuple(args, "iO:SetProperty", &field, &data))
        return NULL;

    if (PyUnicode_Check(data)) {
        status = MsiSummaryInfoSetPropertyW(si->h, field, VT_LPSTR,
            0, NULL, PyUnicode_AsUnicode(data));
    } else if (PyLong_CheckExact(data)) {
        long value = PyLong_AsLong(data);
        if (value == -1 && PyErr_Occurred()) {
            return NULL;
        }
        status = MsiSummaryInfoSetProperty(si->h, field, VT_I4,
            value, NULL, NULL);
    } else {
        PyErr_SetString(PyExc_TypeError, "unsupported type");
        return NULL;
    }

    if (status != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* uuidcreate ( PyObject obj,
PyObject args 
) [static]

Definition at line 18 of file _msi.c.

{
    UUID result;
    unsigned short *cresult;
    PyObject *oresult;

    /* May return ok, local only, and no address.
       For local only, the documentation says we still get a uuid.
       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;
    }

    if (UuidToStringW(&result, &cresult) == RPC_S_OUT_OF_MEMORY) {
        PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen");
        return NULL;
    }

    oresult = PyUnicode_FromUnicode(cresult, wcslen(cresult));
    RpcStringFreeW(&cresult);
    return oresult;

}

Here is the call graph for this function:

static PyObject* view_close ( msiobj view,
PyObject args 
) [static]

Definition at line 759 of file _msi.c.

{
    int status;

    if ((status = MsiViewClose(view->h)) != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* view_execute ( msiobj view,
PyObject args 
) [static]

Definition at line 683 of file _msi.c.

{
    int status;
    MSIHANDLE params = 0;
    PyObject *oparams = Py_None;

    if (!PyArg_ParseTuple(args, "O:Execute", &oparams))
        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;
    }

    status = MsiViewExecute(view->h, params);
    if (status != ERROR_SUCCESS)
        return msierror(status);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:

static PyObject* view_fetch ( msiobj view,
PyObject args 
) [static]

Definition at line 709 of file _msi.c.

{
    int status;
    MSIHANDLE result;

    if ((status = MsiViewFetch(view->h, &result)) != ERROR_SUCCESS)
        return msierror(status);

    return record_new(result);
}

Here is the call graph for this function:

static PyObject* view_getcolumninfo ( msiobj view,
PyObject args 
) [static]

Definition at line 721 of file _msi.c.

{
    int status;
    int kind;
    MSIHANDLE result;

    if (!PyArg_ParseTuple(args, "i:GetColumnInfo", &kind))
        return NULL;

    if ((status = MsiViewGetColumnInfo(view->h, kind, &result)) != ERROR_SUCCESS)
        return msierror(status);

    return record_new(result);
}

Here is the call graph for this function:

static PyObject* view_modify ( msiobj view,
PyObject args 
) [static]

Definition at line 737 of file _msi.c.

{
    int kind;
    PyObject *data;
    int status;

    if (!PyArg_ParseTuple(args, "iO:Modify", &kind, &data))
        return NULL;

    if (data->ob_type != &record_Type) {
        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);

    Py_INCREF(Py_None);
    return Py_None;
}

Here is the call graph for this function:


Variable Documentation

PyMethodDef db_methods[] [static]
Initial value:
 {
    { "OpenView", (PyCFunction)msidb_openview, METH_VARARGS,
        PyDoc_STR("OpenView(sql) -> viewobj\nWraps MsiDatabaseOpenView")},
    { "Commit", (PyCFunction)msidb_commit, METH_NOARGS,
        PyDoc_STR("Commit() -> None\nWraps MsiDatabaseCommit")},
    { "GetSummaryInformation", (PyCFunction)msidb_getsummaryinformation, METH_VARARGS,
        PyDoc_STR("GetSummaryInformation(updateCount) -> viewobj\nWraps MsiGetSummaryInformation")},
    { NULL, NULL }
}

Definition at line 891 of file _msi.c.

char msi_doc[] = "Documentation" [static]

Definition at line 998 of file _msi.c.

Initial value:
 {
        {"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}           
}

Definition at line 986 of file _msi.c.

Definition at line 901 of file _msi.c.

PyObject* MSIError [static]

Definition at line 15 of file _msi.c.

Definition at line 784 of file _msi.c.

struct PyModuleDef [static]
Initial value:
 {
        PyModuleDef_HEAD_INIT,
        "_msi",
        msi_doc,
        -1,
        msi_methods,
        NULL,
        NULL,
        NULL,
        NULL
}

Definition at line 1001 of file _msi.c.

Initial value:
 {
    { "GetFieldCount", (PyCFunction)record_getfieldcount, METH_NOARGS,
        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")},
    { "SetStream", (PyCFunction)record_setstream, METH_VARARGS,
        PyDoc_STR("SetStream(field,filename) -> None\nWraps MsiRecordSetInteger")},
    { "SetInteger", (PyCFunction)record_setinteger, METH_VARARGS,
        PyDoc_STR("SetInteger(field,int) -> None\nWraps MsiRecordSetInteger")},
    { "ClearData", (PyCFunction)record_cleardata, METH_NOARGS,
        PyDoc_STR("ClearData() -> int\nWraps MsiRecordGClearData")},
    { NULL, NULL }
}

Definition at line 448 of file _msi.c.

Definition at line 466 of file _msi.c.

Initial value:
 {
    { "GetProperty", (PyCFunction)summary_getproperty, METH_VARARGS,
        PyDoc_STR("GetProperty(propid) -> value\nWraps MsiSummaryInfoGetProperty")},
    { "GetPropertyCount", (PyCFunction)summary_getpropertycount, METH_NOARGS,
        PyDoc_STR("GetProperty() -> int\nWraps MsiSummaryInfoGetPropertyCount")},
    { "SetProperty", (PyCFunction)summary_setproperty, METH_VARARGS,
        PyDoc_STR("SetProperty(value) -> None\nWraps MsiSummaryInfoProperty")},
    { "Persist", (PyCFunction)summary_persist, METH_NOARGS,
        PyDoc_STR("Persist() -> None\nWraps MsiSummaryInfoPersist")},
    { NULL, NULL }
}

Definition at line 624 of file _msi.c.

Definition at line 636 of file _msi.c.

Initial value:
 {
    { "Execute", (PyCFunction)view_execute, METH_VARARGS,
        PyDoc_STR("Execute(params=None) -> None\nWraps MsiViewExecute")},
    { "GetColumnInfo", (PyCFunction)view_getcolumninfo, METH_VARARGS,
        PyDoc_STR("GetColumnInfo() -> result\nWraps MsiGetColumnInfo")},
    { "Fetch", (PyCFunction)view_fetch, METH_NOARGS,
        PyDoc_STR("Fetch() -> result\nWraps MsiViewFetch")},
    { "Modify", (PyCFunction)view_modify, METH_VARARGS,
        PyDoc_STR("Modify(mode,record) -> None\nWraps MsiViewModify")},
    { "Close", (PyCFunction)view_close, METH_NOARGS,
        PyDoc_STR("Close() -> result\nWraps MsiViewClose")},
    { NULL, NULL }
}

Definition at line 770 of file _msi.c.