python-msilib 0.1.1__cp314-cp314t-win_amd64.whl → 0.3.0__cp314-cp314t-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of python-msilib might be problematic. Click here for more details.
- msilib/__init__.py +281 -109
- msilib/_msi.c +333 -358
- msilib/_msi.cp314t-win_amd64.pyd +0 -0
- msilib/include/_msi.h +334 -331
- msilib/include/pythoncapi_compat.h +40 -1
- msilib/schema.py +5752 -1002
- msilib/sequence.py +117 -111
- msilib/text.py +285 -122
- python_msilib-0.3.0.dist-info/METADATA +91 -0
- python_msilib-0.3.0.dist-info/RECORD +13 -0
- python_msilib-0.1.1.dist-info/METADATA +0 -39
- python_msilib-0.1.1.dist-info/RECORD +0 -13
- {python_msilib-0.1.1.dist-info → python_msilib-0.3.0.dist-info}/WHEEL +0 -0
- {python_msilib-0.1.1.dist-info → python_msilib-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {python_msilib-0.1.1.dist-info → python_msilib-0.3.0.dist-info}/top_level.txt +0 -0
msilib/_msi.c
CHANGED
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
* Licensed to PSF under a contributor agreement.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
|
|
6
|
+
#define PY_SSIZE_T_CLEAN
|
|
8
7
|
#include <Python.h>
|
|
8
|
+
// clang-format off
|
|
9
|
+
#include <windows.h>
|
|
10
|
+
// clang-format on
|
|
11
|
+
#include "include/pythoncapi_compat.h"
|
|
9
12
|
#include <fci.h>
|
|
10
13
|
#include <fcntl.h>
|
|
11
|
-
#include <windows.h>
|
|
12
14
|
#include <msi.h>
|
|
13
|
-
#include <msiquery.h>
|
|
14
15
|
#include <msidefs.h>
|
|
16
|
+
#include <msiquery.h>
|
|
15
17
|
#include <rpc.h>
|
|
16
18
|
|
|
17
19
|
/*[clinic input]
|
|
@@ -23,7 +25,7 @@ class _msi.Database "msiobj *" "&msidb_Type"
|
|
|
23
25
|
[clinic start generated code]*/
|
|
24
26
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=89a3605762cf4bdc]*/
|
|
25
27
|
|
|
26
|
-
static PyObject
|
|
28
|
+
static PyObject* MSIError;
|
|
27
29
|
|
|
28
30
|
/*[clinic input]
|
|
29
31
|
_msi.UuidCreate
|
|
@@ -31,20 +33,20 @@ _msi.UuidCreate
|
|
|
31
33
|
Return the string representation of a new unique identifier.
|
|
32
34
|
[clinic start generated code]*/
|
|
33
35
|
|
|
34
|
-
static PyObject *
|
|
35
|
-
_msi_UuidCreate_impl(PyObject *module)
|
|
36
|
+
static PyObject* _msi_UuidCreate_impl(PyObject* module)
|
|
36
37
|
/*[clinic end generated code: output=534ecf36f10af98e input=168024ab4b3e832b]*/
|
|
37
38
|
{
|
|
38
39
|
UUID result;
|
|
39
|
-
wchar_t
|
|
40
|
-
PyObject
|
|
40
|
+
wchar_t* cresult;
|
|
41
|
+
PyObject* oresult;
|
|
41
42
|
|
|
42
43
|
/* May return ok, local only, and no address.
|
|
43
44
|
For local only, the documentation says we still get a uuid.
|
|
44
45
|
For RPC_S_UUID_NO_ADDRESS, it's not clear whether we can
|
|
45
46
|
use the result. */
|
|
46
47
|
if (UuidCreate(&result) == RPC_S_UUID_NO_ADDRESS) {
|
|
47
|
-
PyErr_SetString(
|
|
48
|
+
PyErr_SetString(
|
|
49
|
+
PyExc_NotImplementedError, "processing 'no address' result");
|
|
48
50
|
return NULL;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -56,25 +58,22 @@ _msi_UuidCreate_impl(PyObject *module)
|
|
|
56
58
|
oresult = PyUnicode_FromWideChar(cresult, wcslen(cresult));
|
|
57
59
|
RpcStringFreeW(&cresult);
|
|
58
60
|
return oresult;
|
|
59
|
-
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/* Helper for converting file names from UTF-8 to wchat_t*. */
|
|
63
|
-
static wchar_t *
|
|
64
|
-
utf8_to_wchar(const char *s, int *err)
|
|
64
|
+
static wchar_t* utf8_to_wchar(const char* s, int* err)
|
|
65
65
|
{
|
|
66
|
-
PyObject
|
|
66
|
+
PyObject* obj = PyUnicode_FromString(s);
|
|
67
67
|
if (obj == NULL) {
|
|
68
68
|
if (PyErr_ExceptionMatches(PyExc_MemoryError)) {
|
|
69
69
|
*err = ENOMEM;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
70
|
+
} else {
|
|
72
71
|
*err = EINVAL;
|
|
73
72
|
}
|
|
74
73
|
PyErr_Clear();
|
|
75
74
|
return NULL;
|
|
76
75
|
}
|
|
77
|
-
wchar_t
|
|
76
|
+
wchar_t* ws = PyUnicode_AsWideCharString(obj, NULL);
|
|
78
77
|
if (ws == NULL) {
|
|
79
78
|
*err = ENOMEM;
|
|
80
79
|
PyErr_Clear();
|
|
@@ -85,19 +84,13 @@ utf8_to_wchar(const char *s, int *err)
|
|
|
85
84
|
|
|
86
85
|
/* FCI callback functions */
|
|
87
86
|
|
|
88
|
-
static FNFCIALLOC(cb_alloc)
|
|
89
|
-
{
|
|
90
|
-
return PyMem_RawMalloc(cb);
|
|
91
|
-
}
|
|
87
|
+
static FNFCIALLOC(cb_alloc) { return PyMem_RawMalloc(cb); }
|
|
92
88
|
|
|
93
|
-
static FNFCIFREE(cb_free)
|
|
94
|
-
{
|
|
95
|
-
PyMem_RawFree(memory);
|
|
96
|
-
}
|
|
89
|
+
static FNFCIFREE(cb_free) { PyMem_RawFree(memory); }
|
|
97
90
|
|
|
98
91
|
static FNFCIOPEN(cb_open)
|
|
99
92
|
{
|
|
100
|
-
wchar_t
|
|
93
|
+
wchar_t* ws = utf8_to_wchar(pszFile, err);
|
|
101
94
|
if (ws == NULL) {
|
|
102
95
|
return -1;
|
|
103
96
|
}
|
|
@@ -142,7 +135,7 @@ static FNFCISEEK(cb_seek)
|
|
|
142
135
|
|
|
143
136
|
static FNFCIDELETE(cb_delete)
|
|
144
137
|
{
|
|
145
|
-
wchar_t
|
|
138
|
+
wchar_t* ws = utf8_to_wchar(pszFile, err);
|
|
146
139
|
if (ws == NULL) {
|
|
147
140
|
return -1;
|
|
148
141
|
}
|
|
@@ -153,28 +146,27 @@ static FNFCIDELETE(cb_delete)
|
|
|
153
146
|
return result;
|
|
154
147
|
}
|
|
155
148
|
|
|
156
|
-
static FNFCIFILEPLACED(cb_fileplaced)
|
|
157
|
-
{
|
|
158
|
-
return 0;
|
|
159
|
-
}
|
|
149
|
+
static FNFCIFILEPLACED(cb_fileplaced) { return 0; }
|
|
160
150
|
|
|
161
151
|
static FNFCIGETTEMPFILE(cb_gettempfile)
|
|
162
152
|
{
|
|
163
|
-
char
|
|
153
|
+
char* name = _tempnam("", "tmp");
|
|
164
154
|
if ((name != NULL) && ((int)strlen(name) < cbTempName)) {
|
|
165
155
|
strcpy(pszTempName, name);
|
|
166
156
|
free(name);
|
|
167
157
|
return TRUE;
|
|
168
158
|
}
|
|
169
159
|
|
|
170
|
-
if (name)
|
|
160
|
+
if (name)
|
|
161
|
+
free(name);
|
|
171
162
|
return FALSE;
|
|
172
163
|
}
|
|
173
164
|
|
|
174
165
|
static FNFCISTATUS(cb_status)
|
|
175
166
|
{
|
|
176
167
|
if (pv) {
|
|
177
|
-
PyObject
|
|
168
|
+
PyObject* result
|
|
169
|
+
= PyObject_CallMethod(pv, "status", "iii", typeStatus, cb1, cb2);
|
|
178
170
|
if (result == NULL)
|
|
179
171
|
return -1;
|
|
180
172
|
Py_DECREF(result);
|
|
@@ -185,7 +177,8 @@ static FNFCISTATUS(cb_status)
|
|
|
185
177
|
static FNFCIGETNEXTCABINET(cb_getnextcabinet)
|
|
186
178
|
{
|
|
187
179
|
if (pv) {
|
|
188
|
-
PyObject
|
|
180
|
+
PyObject* result
|
|
181
|
+
= PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab);
|
|
189
182
|
if (result == NULL)
|
|
190
183
|
return -1;
|
|
191
184
|
if (!PyBytes_Check(result)) {
|
|
@@ -207,7 +200,7 @@ static FNFCIGETOPENINFO(cb_getopeninfo)
|
|
|
207
200
|
FILETIME filetime;
|
|
208
201
|
HANDLE handle;
|
|
209
202
|
|
|
210
|
-
wchar_t
|
|
203
|
+
wchar_t* ws = utf8_to_wchar(pszName, err);
|
|
211
204
|
if (ws == NULL) {
|
|
212
205
|
return -1;
|
|
213
206
|
}
|
|
@@ -229,8 +222,8 @@ static FNFCIGETOPENINFO(cb_getopeninfo)
|
|
|
229
222
|
FileTimeToLocalFileTime(&bhfi.ftLastWriteTime, &filetime);
|
|
230
223
|
FileTimeToDosDateTime(&filetime, pdate, ptime);
|
|
231
224
|
|
|
232
|
-
*pattribs = (int)(bhfi.dwFileAttributes
|
|
233
|
-
(_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH));
|
|
225
|
+
*pattribs = (int)(bhfi.dwFileAttributes
|
|
226
|
+
& (_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH));
|
|
234
227
|
|
|
235
228
|
CloseHandle(handle);
|
|
236
229
|
|
|
@@ -251,11 +244,11 @@ _msi.FCICreate
|
|
|
251
244
|
Create a new CAB file.
|
|
252
245
|
[clinic start generated code]*/
|
|
253
246
|
|
|
254
|
-
static PyObject
|
|
255
|
-
|
|
247
|
+
static PyObject* _msi_FCICreate_impl(
|
|
248
|
+
PyObject* module, const char* cabname, PyObject* files)
|
|
256
249
|
/*[clinic end generated code: output=55dc05728361b799 input=1d2d75fdc8b44b71]*/
|
|
257
250
|
{
|
|
258
|
-
const char
|
|
251
|
+
const char* p;
|
|
259
252
|
CCAB ccab;
|
|
260
253
|
HFCI hfci;
|
|
261
254
|
ERF erf;
|
|
@@ -282,8 +275,8 @@ _msi_FCICreate_impl(PyObject *module, const char *cabname, PyObject *files)
|
|
|
282
275
|
if (*p == '\\' || *p == '/')
|
|
283
276
|
i = p - cabname + 1;
|
|
284
277
|
|
|
285
|
-
if (i >= sizeof(ccab.szCabPath)
|
|
286
|
-
strlen(cabname+i) >= sizeof(ccab.szCab)) {
|
|
278
|
+
if (i >= sizeof(ccab.szCabPath)
|
|
279
|
+
|| strlen(cabname + i) >= sizeof(ccab.szCab)) {
|
|
287
280
|
PyErr_SetString(PyExc_ValueError, "path name too long");
|
|
288
281
|
return 0;
|
|
289
282
|
}
|
|
@@ -291,34 +284,33 @@ _msi_FCICreate_impl(PyObject *module, const char *cabname, PyObject *files)
|
|
|
291
284
|
if (i > 0) {
|
|
292
285
|
memcpy(ccab.szCabPath, cabname, i);
|
|
293
286
|
ccab.szCabPath[i] = '\0';
|
|
294
|
-
strcpy(ccab.szCab, cabname+i);
|
|
287
|
+
strcpy(ccab.szCab, cabname + i);
|
|
295
288
|
} else {
|
|
296
289
|
strcpy(ccab.szCabPath, ".\\");
|
|
297
290
|
strcpy(ccab.szCab, cabname);
|
|
298
291
|
}
|
|
299
292
|
|
|
300
|
-
hfci = FCICreate(&erf, cb_fileplaced, cb_alloc, cb_free,
|
|
301
|
-
|
|
302
|
-
cb_gettempfile, &ccab, NULL);
|
|
293
|
+
hfci = FCICreate(&erf, cb_fileplaced, cb_alloc, cb_free, cb_open, cb_read,
|
|
294
|
+
cb_write, cb_close, cb_seek, cb_delete, cb_gettempfile, &ccab, NULL);
|
|
303
295
|
|
|
304
296
|
if (hfci == NULL) {
|
|
305
297
|
PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper);
|
|
306
298
|
return NULL;
|
|
307
299
|
}
|
|
308
300
|
|
|
309
|
-
for (i=0; i <
|
|
310
|
-
PyObject
|
|
301
|
+
for (i = 0; i < PyList_Size(files); i++) {
|
|
302
|
+
PyObject* item = PyList_GetItemRef(files, i);
|
|
311
303
|
char *filename, *cabname;
|
|
312
304
|
|
|
313
305
|
if (!PyArg_ParseTuple(item, "ss", &filename, &cabname)) {
|
|
314
|
-
PyErr_SetString(PyExc_TypeError,
|
|
306
|
+
PyErr_SetString(PyExc_TypeError,
|
|
307
|
+
"FCICreate expects a list of tuples containing two strings");
|
|
315
308
|
FCIDestroy(hfci);
|
|
316
309
|
return NULL;
|
|
317
310
|
}
|
|
318
311
|
|
|
319
|
-
if (!FCIAddFile(hfci, filename, cabname, FALSE,
|
|
320
|
-
|
|
321
|
-
tcompTYPE_MSZIP))
|
|
312
|
+
if (!FCIAddFile(hfci, filename, cabname, FALSE, cb_getnextcabinet,
|
|
313
|
+
cb_status, cb_getopeninfo, tcompTYPE_MSZIP))
|
|
322
314
|
goto err;
|
|
323
315
|
}
|
|
324
316
|
|
|
@@ -330,8 +322,9 @@ _msi_FCICreate_impl(PyObject *module, const char *cabname, PyObject *files)
|
|
|
330
322
|
|
|
331
323
|
Py_RETURN_NONE;
|
|
332
324
|
err:
|
|
333
|
-
if(erf.fError)
|
|
334
|
-
PyErr_Format(PyExc_ValueError, "FCI error %d",
|
|
325
|
+
if (erf.fError)
|
|
326
|
+
PyErr_Format(PyExc_ValueError, "FCI error %d",
|
|
327
|
+
erf.erfOper); /* XXX better error type */
|
|
335
328
|
else
|
|
336
329
|
PyErr_SetString(PyExc_ValueError, "FCI general error");
|
|
337
330
|
|
|
@@ -339,30 +332,27 @@ err:
|
|
|
339
332
|
return NULL;
|
|
340
333
|
}
|
|
341
334
|
|
|
342
|
-
typedef struct msiobj{
|
|
343
|
-
PyObject_HEAD
|
|
344
|
-
|
|
345
|
-
}msiobj;
|
|
335
|
+
typedef struct msiobj {
|
|
336
|
+
PyObject_HEAD MSIHANDLE h;
|
|
337
|
+
} msiobj;
|
|
346
338
|
|
|
347
|
-
static void
|
|
348
|
-
msiobj_dealloc(msiobj* msidb)
|
|
339
|
+
static void msiobj_dealloc(msiobj* msidb)
|
|
349
340
|
{
|
|
350
341
|
MsiCloseHandle(msidb->h);
|
|
351
342
|
msidb->h = 0;
|
|
352
343
|
PyObject_Free(msidb);
|
|
353
344
|
}
|
|
354
345
|
|
|
355
|
-
static PyObject*
|
|
356
|
-
msierror(int status)
|
|
346
|
+
static PyObject* msierror(int status)
|
|
357
347
|
{
|
|
358
348
|
int code;
|
|
359
349
|
char buf[2000];
|
|
360
|
-
char
|
|
350
|
+
char* res = buf;
|
|
361
351
|
DWORD size = Py_ARRAY_LENGTH(buf);
|
|
362
352
|
MSIHANDLE err = MsiGetLastErrorRecord();
|
|
363
353
|
|
|
364
354
|
if (err == 0) {
|
|
365
|
-
switch(status) {
|
|
355
|
+
switch (status) {
|
|
366
356
|
case ERROR_ACCESS_DENIED:
|
|
367
357
|
PyErr_SetString(MSIError, "access denied");
|
|
368
358
|
return NULL;
|
|
@@ -395,13 +385,13 @@ msierror(int status)
|
|
|
395
385
|
|
|
396
386
|
code = MsiRecordGetInteger(err, 1); /* XXX code */
|
|
397
387
|
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
|
|
398
|
-
res = malloc(size+1);
|
|
388
|
+
res = malloc(size + 1);
|
|
399
389
|
if (res == NULL) {
|
|
400
390
|
MsiCloseHandle(err);
|
|
401
391
|
return PyErr_NoMemory();
|
|
402
392
|
}
|
|
403
393
|
MsiFormatRecord(0, err, res, &size);
|
|
404
|
-
res[size]='\0';
|
|
394
|
+
res[size] = '\0';
|
|
405
395
|
}
|
|
406
396
|
MsiCloseHandle(err);
|
|
407
397
|
PyErr_SetString(MSIError, res);
|
|
@@ -418,8 +408,7 @@ _msi.Database.Close
|
|
|
418
408
|
Close the database object.
|
|
419
409
|
[clinic start generated code]*/
|
|
420
410
|
|
|
421
|
-
static PyObject *
|
|
422
|
-
_msi_Database_Close_impl(msiobj *self)
|
|
411
|
+
static PyObject* _msi_Database_Close_impl(msiobj* self)
|
|
423
412
|
/*[clinic end generated code: output=ddf2d7712ea804f1 input=104330ce4a486187]*/
|
|
424
413
|
{
|
|
425
414
|
int status;
|
|
@@ -438,8 +427,7 @@ _msi.Record.GetFieldCount
|
|
|
438
427
|
Return the number of fields of the record.
|
|
439
428
|
[clinic start generated code]*/
|
|
440
429
|
|
|
441
|
-
static PyObject *
|
|
442
|
-
_msi_Record_GetFieldCount_impl(msiobj *self)
|
|
430
|
+
static PyObject* _msi_Record_GetFieldCount_impl(msiobj* self)
|
|
443
431
|
/*[clinic end generated code: output=112795079c904398 input=5fb9d4071b28897b]*/
|
|
444
432
|
{
|
|
445
433
|
return PyLong_FromLong(MsiRecordGetFieldCount(self->h));
|
|
@@ -453,18 +441,17 @@ _msi.Record.GetInteger
|
|
|
453
441
|
Return the value of field as an integer where possible.
|
|
454
442
|
[clinic start generated code]*/
|
|
455
443
|
|
|
456
|
-
static PyObject *
|
|
457
|
-
_msi_Record_GetInteger_impl(msiobj *self, unsigned int field)
|
|
444
|
+
static PyObject* _msi_Record_GetInteger_impl(msiobj* self, unsigned int field)
|
|
458
445
|
/*[clinic end generated code: output=7174ebb6e8ed1c79 input=d19209947e2bfe61]*/
|
|
459
446
|
{
|
|
460
447
|
int status;
|
|
461
448
|
|
|
462
449
|
status = MsiRecordGetInteger(self->h, field);
|
|
463
|
-
if (status == MSI_NULL_INTEGER){
|
|
450
|
+
if (status == MSI_NULL_INTEGER) {
|
|
464
451
|
PyErr_SetString(MSIError, "could not convert record field to integer");
|
|
465
452
|
return NULL;
|
|
466
453
|
}
|
|
467
|
-
return PyLong_FromLong((long)
|
|
454
|
+
return PyLong_FromLong((long)status);
|
|
468
455
|
}
|
|
469
456
|
|
|
470
457
|
/*[clinic input]
|
|
@@ -475,25 +462,24 @@ _msi.Record.GetString
|
|
|
475
462
|
Return the value of field as a string where possible.
|
|
476
463
|
[clinic start generated code]*/
|
|
477
464
|
|
|
478
|
-
static PyObject *
|
|
479
|
-
_msi_Record_GetString_impl(msiobj *self, unsigned int field)
|
|
465
|
+
static PyObject* _msi_Record_GetString_impl(msiobj* self, unsigned int field)
|
|
480
466
|
/*[clinic end generated code: output=f670d1b484cfa47c input=ffa11f21450b77d8]*/
|
|
481
467
|
{
|
|
482
468
|
unsigned int status;
|
|
483
469
|
WCHAR buf[2000];
|
|
484
|
-
WCHAR
|
|
470
|
+
WCHAR* res = buf;
|
|
485
471
|
DWORD size = Py_ARRAY_LENGTH(buf);
|
|
486
472
|
PyObject* string;
|
|
487
473
|
|
|
488
474
|
status = MsiRecordGetStringW(self->h, field, res, &size);
|
|
489
475
|
if (status == ERROR_MORE_DATA) {
|
|
490
|
-
res = (WCHAR*)
|
|
476
|
+
res = (WCHAR*)malloc((size + 1) * sizeof(WCHAR));
|
|
491
477
|
if (res == NULL)
|
|
492
478
|
return PyErr_NoMemory();
|
|
493
479
|
status = MsiRecordGetStringW(self->h, field, res, &size);
|
|
494
480
|
}
|
|
495
481
|
if (status != ERROR_SUCCESS)
|
|
496
|
-
return msierror((int)
|
|
482
|
+
return msierror((int)status);
|
|
497
483
|
string = PyUnicode_FromWideChar(res, size);
|
|
498
484
|
if (buf != res)
|
|
499
485
|
free(res);
|
|
@@ -506,8 +492,7 @@ _msi.Record.ClearData
|
|
|
506
492
|
Set all fields of the record to 0.
|
|
507
493
|
[clinic start generated code]*/
|
|
508
494
|
|
|
509
|
-
static PyObject *
|
|
510
|
-
_msi_Record_ClearData_impl(msiobj *self)
|
|
495
|
+
static PyObject* _msi_Record_ClearData_impl(msiobj* self)
|
|
511
496
|
/*[clinic end generated code: output=1891467214b977f4 input=2a911c95aaded102]*/
|
|
512
497
|
{
|
|
513
498
|
int status = MsiRecordClearData(self->h);
|
|
@@ -526,8 +511,8 @@ _msi.Record.SetString
|
|
|
526
511
|
Set field to a string value.
|
|
527
512
|
[clinic start generated code]*/
|
|
528
513
|
|
|
529
|
-
static PyObject
|
|
530
|
-
|
|
514
|
+
static PyObject* _msi_Record_SetString_impl(
|
|
515
|
+
msiobj* self, int field, const wchar_t* value)
|
|
531
516
|
/*[clinic end generated code: output=2e37505b0f11f985 input=fb8ec70a2a6148e0]*/
|
|
532
517
|
{
|
|
533
518
|
int status;
|
|
@@ -547,8 +532,8 @@ _msi.Record.SetStream
|
|
|
547
532
|
Set field to the contents of the file named value.
|
|
548
533
|
[clinic start generated code]*/
|
|
549
534
|
|
|
550
|
-
static PyObject
|
|
551
|
-
|
|
535
|
+
static PyObject* _msi_Record_SetStream_impl(
|
|
536
|
+
msiobj* self, int field, const wchar_t* value)
|
|
552
537
|
/*[clinic end generated code: output=442facac16913b48 input=a07aa19b865e8292]*/
|
|
553
538
|
{
|
|
554
539
|
int status;
|
|
@@ -568,8 +553,8 @@ _msi.Record.SetInteger
|
|
|
568
553
|
Set field to an integer value.
|
|
569
554
|
[clinic start generated code]*/
|
|
570
555
|
|
|
571
|
-
static PyObject
|
|
572
|
-
|
|
556
|
+
static PyObject* _msi_Record_SetInteger_impl(
|
|
557
|
+
msiobj* self, int field, int value)
|
|
573
558
|
/*[clinic end generated code: output=669e8647775d0ce7 input=c571aa775e7e451b]*/
|
|
574
559
|
{
|
|
575
560
|
int status;
|
|
@@ -580,8 +565,7 @@ _msi_Record_SetInteger_impl(msiobj *self, int field, int value)
|
|
|
580
565
|
Py_RETURN_NONE;
|
|
581
566
|
}
|
|
582
567
|
|
|
583
|
-
|
|
584
|
-
|
|
568
|
+
// clang-format off
|
|
585
569
|
static PyMethodDef record_methods[] = {
|
|
586
570
|
_MSI_RECORD_GETFIELDCOUNT_METHODDEF
|
|
587
571
|
_MSI_RECORD_GETINTEGER_METHODDEF
|
|
@@ -592,55 +576,54 @@ static PyMethodDef record_methods[] = {
|
|
|
592
576
|
_MSI_RECORD_CLEARDATA_METHODDEF
|
|
593
577
|
{ NULL, NULL }
|
|
594
578
|
};
|
|
579
|
+
// clang-format on
|
|
595
580
|
|
|
596
581
|
static PyTypeObject record_Type = {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
0, /*tp_is_gc*/
|
|
582
|
+
PyVarObject_HEAD_INIT(NULL, 0) "_msi.Record", /*tp_name*/
|
|
583
|
+
sizeof(msiobj), /*tp_basicsize*/
|
|
584
|
+
0, /*tp_itemsize*/
|
|
585
|
+
/* methods */
|
|
586
|
+
(destructor)msiobj_dealloc, /*tp_dealloc*/
|
|
587
|
+
0, /*tp_vectorcall_offset*/
|
|
588
|
+
0, /*tp_getattr*/
|
|
589
|
+
0, /*tp_setattr*/
|
|
590
|
+
0, /*tp_as_async*/
|
|
591
|
+
0, /*tp_repr*/
|
|
592
|
+
0, /*tp_as_number*/
|
|
593
|
+
0, /*tp_as_sequence*/
|
|
594
|
+
0, /*tp_as_mapping*/
|
|
595
|
+
0, /*tp_hash*/
|
|
596
|
+
0, /*tp_call*/
|
|
597
|
+
0, /*tp_str*/
|
|
598
|
+
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
599
|
+
PyObject_GenericSetAttr, /*tp_setattro*/
|
|
600
|
+
0, /*tp_as_buffer*/
|
|
601
|
+
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
|
602
|
+
0, /*tp_doc*/
|
|
603
|
+
0, /*tp_traverse*/
|
|
604
|
+
0, /*tp_clear*/
|
|
605
|
+
0, /*tp_richcompare*/
|
|
606
|
+
0, /*tp_weaklistoffset*/
|
|
607
|
+
0, /*tp_iter*/
|
|
608
|
+
0, /*tp_iternext*/
|
|
609
|
+
record_methods, /*tp_methods*/
|
|
610
|
+
0, /*tp_members*/
|
|
611
|
+
0, /*tp_getset*/
|
|
612
|
+
0, /*tp_base*/
|
|
613
|
+
0, /*tp_dict*/
|
|
614
|
+
0, /*tp_descr_get*/
|
|
615
|
+
0, /*tp_descr_set*/
|
|
616
|
+
0, /*tp_dictoffset*/
|
|
617
|
+
0, /*tp_init*/
|
|
618
|
+
0, /*tp_alloc*/
|
|
619
|
+
0, /*tp_new*/
|
|
620
|
+
0, /*tp_free*/
|
|
621
|
+
0, /*tp_is_gc*/
|
|
638
622
|
};
|
|
639
623
|
|
|
640
|
-
static PyObject*
|
|
641
|
-
record_new(MSIHANDLE h)
|
|
624
|
+
static PyObject* record_new(MSIHANDLE h)
|
|
642
625
|
{
|
|
643
|
-
msiobj
|
|
626
|
+
msiobj* result = PyObject_New(struct msiobj, &record_Type);
|
|
644
627
|
|
|
645
628
|
if (!result) {
|
|
646
629
|
MsiCloseHandle(h);
|
|
@@ -662,53 +645,53 @@ _msi.SummaryInformation.GetProperty
|
|
|
662
645
|
Return a property of the summary.
|
|
663
646
|
[clinic start generated code]*/
|
|
664
647
|
|
|
665
|
-
static PyObject
|
|
666
|
-
|
|
648
|
+
static PyObject* _msi_SummaryInformation_GetProperty_impl(
|
|
649
|
+
msiobj* self, int field)
|
|
667
650
|
/*[clinic end generated code: output=f8946a33ee14f6ef input=f8dfe2c890d6cb8b]*/
|
|
668
651
|
{
|
|
669
652
|
int status;
|
|
670
|
-
PyObject
|
|
653
|
+
PyObject* result;
|
|
671
654
|
UINT type;
|
|
672
655
|
INT ival;
|
|
673
656
|
FILETIME fval;
|
|
674
657
|
char sbuf[1000];
|
|
675
|
-
char
|
|
658
|
+
char* sval = sbuf;
|
|
676
659
|
DWORD ssize = sizeof(sbuf);
|
|
677
660
|
|
|
678
|
-
status = MsiSummaryInfoGetProperty(
|
|
679
|
-
&fval, sval, &ssize);
|
|
661
|
+
status = MsiSummaryInfoGetProperty(
|
|
662
|
+
self->h, field, &type, &ival, &fval, sval, &ssize);
|
|
680
663
|
if (status == ERROR_MORE_DATA) {
|
|
681
664
|
ssize++;
|
|
682
665
|
sval = malloc(ssize);
|
|
683
666
|
if (sval == NULL) {
|
|
684
667
|
return PyErr_NoMemory();
|
|
685
668
|
}
|
|
686
|
-
status = MsiSummaryInfoGetProperty(
|
|
687
|
-
&fval, sval, &ssize);
|
|
669
|
+
status = MsiSummaryInfoGetProperty(
|
|
670
|
+
self->h, field, &type, &ival, &fval, sval, &ssize);
|
|
688
671
|
}
|
|
689
672
|
if (status != ERROR_SUCCESS) {
|
|
690
673
|
return msierror(status);
|
|
691
674
|
}
|
|
692
675
|
|
|
693
|
-
switch(type) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
676
|
+
switch (type) {
|
|
677
|
+
case VT_I2:
|
|
678
|
+
case VT_I4:
|
|
679
|
+
result = PyLong_FromLong(ival);
|
|
680
|
+
break;
|
|
681
|
+
case VT_FILETIME:
|
|
682
|
+
PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
|
|
683
|
+
result = NULL;
|
|
684
|
+
break;
|
|
685
|
+
case VT_LPSTR:
|
|
686
|
+
result = PyBytes_FromStringAndSize(sval, ssize);
|
|
687
|
+
break;
|
|
688
|
+
case VT_EMPTY:
|
|
689
|
+
result = Py_NewRef(Py_None);
|
|
690
|
+
break;
|
|
691
|
+
default:
|
|
692
|
+
PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
|
|
693
|
+
result = NULL;
|
|
694
|
+
break;
|
|
712
695
|
}
|
|
713
696
|
if (sval != sbuf)
|
|
714
697
|
free(sval);
|
|
@@ -721,8 +704,7 @@ _msi.SummaryInformation.GetPropertyCount
|
|
|
721
704
|
Return the number of summary properties.
|
|
722
705
|
[clinic start generated code]*/
|
|
723
706
|
|
|
724
|
-
static PyObject *
|
|
725
|
-
_msi_SummaryInformation_GetPropertyCount_impl(msiobj *self)
|
|
707
|
+
static PyObject* _msi_SummaryInformation_GetPropertyCount_impl(msiobj* self)
|
|
726
708
|
/*[clinic end generated code: output=68e94b2aeee92b3d input=2e71e985586d82dc]*/
|
|
727
709
|
{
|
|
728
710
|
int status;
|
|
@@ -746,28 +728,27 @@ _msi.SummaryInformation.SetProperty
|
|
|
746
728
|
Set a property.
|
|
747
729
|
[clinic start generated code]*/
|
|
748
730
|
|
|
749
|
-
static PyObject
|
|
750
|
-
|
|
751
|
-
PyObject *data)
|
|
731
|
+
static PyObject* _msi_SummaryInformation_SetProperty_impl(
|
|
732
|
+
msiobj* self, int field, PyObject* data)
|
|
752
733
|
/*[clinic end generated code: output=3d4692c8984bb675 input=f2a7811b905abbed]*/
|
|
753
734
|
{
|
|
754
735
|
int status;
|
|
755
736
|
|
|
756
737
|
if (PyUnicode_Check(data)) {
|
|
757
|
-
WCHAR
|
|
738
|
+
WCHAR* value = PyUnicode_AsWideCharString(data, NULL);
|
|
758
739
|
if (value == NULL) {
|
|
759
740
|
return NULL;
|
|
760
741
|
}
|
|
761
|
-
status = MsiSummaryInfoSetPropertyW(
|
|
762
|
-
0, NULL, value);
|
|
742
|
+
status = MsiSummaryInfoSetPropertyW(
|
|
743
|
+
self->h, field, VT_LPSTR, 0, NULL, value);
|
|
763
744
|
PyMem_Free(value);
|
|
764
745
|
} else if (PyLong_CheckExact(data)) {
|
|
765
746
|
long value = PyLong_AsLong(data);
|
|
766
747
|
if (value == -1 && PyErr_Occurred()) {
|
|
767
748
|
return NULL;
|
|
768
749
|
}
|
|
769
|
-
status = MsiSummaryInfoSetProperty(
|
|
770
|
-
value, NULL, NULL);
|
|
750
|
+
status = MsiSummaryInfoSetProperty(
|
|
751
|
+
self->h, field, VT_I4, value, NULL, NULL);
|
|
771
752
|
} else {
|
|
772
753
|
PyErr_SetString(PyExc_TypeError, "unsupported type");
|
|
773
754
|
return NULL;
|
|
@@ -779,15 +760,13 @@ _msi_SummaryInformation_SetProperty_impl(msiobj *self, int field,
|
|
|
779
760
|
Py_RETURN_NONE;
|
|
780
761
|
}
|
|
781
762
|
|
|
782
|
-
|
|
783
763
|
/*[clinic input]
|
|
784
764
|
_msi.SummaryInformation.Persist
|
|
785
765
|
|
|
786
766
|
Write the modified properties to the summary information stream.
|
|
787
767
|
[clinic start generated code]*/
|
|
788
768
|
|
|
789
|
-
static PyObject *
|
|
790
|
-
_msi_SummaryInformation_Persist_impl(msiobj *self)
|
|
769
|
+
static PyObject* _msi_SummaryInformation_Persist_impl(msiobj* self)
|
|
791
770
|
/*[clinic end generated code: output=c564bd17f5e122c9 input=e3dda9d530095ef7]*/
|
|
792
771
|
{
|
|
793
772
|
int status;
|
|
@@ -798,6 +777,7 @@ _msi_SummaryInformation_Persist_impl(msiobj *self)
|
|
|
798
777
|
Py_RETURN_NONE;
|
|
799
778
|
}
|
|
800
779
|
|
|
780
|
+
// clang-format off
|
|
801
781
|
static PyMethodDef summary_methods[] = {
|
|
802
782
|
_MSI_SUMMARYINFORMATION_GETPROPERTY_METHODDEF
|
|
803
783
|
_MSI_SUMMARYINFORMATION_GETPROPERTYCOUNT_METHODDEF
|
|
@@ -805,49 +785,49 @@ static PyMethodDef summary_methods[] = {
|
|
|
805
785
|
_MSI_SUMMARYINFORMATION_PERSIST_METHODDEF
|
|
806
786
|
{ NULL, NULL }
|
|
807
787
|
};
|
|
788
|
+
// clang-format on
|
|
808
789
|
|
|
809
790
|
static PyTypeObject summary_Type = {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
0, /*tp_is_gc*/
|
|
791
|
+
PyVarObject_HEAD_INIT(NULL, 0) "_msi.SummaryInformation", /*tp_name*/
|
|
792
|
+
sizeof(msiobj), /*tp_basicsize*/
|
|
793
|
+
0, /*tp_itemsize*/
|
|
794
|
+
/* methods */
|
|
795
|
+
(destructor)msiobj_dealloc, /*tp_dealloc*/
|
|
796
|
+
0, /*tp_vectorcall_offset*/
|
|
797
|
+
0, /*tp_getattr*/
|
|
798
|
+
0, /*tp_setattr*/
|
|
799
|
+
0, /*tp_as_async*/
|
|
800
|
+
0, /*tp_repr*/
|
|
801
|
+
0, /*tp_as_number*/
|
|
802
|
+
0, /*tp_as_sequence*/
|
|
803
|
+
0, /*tp_as_mapping*/
|
|
804
|
+
0, /*tp_hash*/
|
|
805
|
+
0, /*tp_call*/
|
|
806
|
+
0, /*tp_str*/
|
|
807
|
+
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
808
|
+
PyObject_GenericSetAttr, /*tp_setattro*/
|
|
809
|
+
0, /*tp_as_buffer*/
|
|
810
|
+
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
|
811
|
+
0, /*tp_doc*/
|
|
812
|
+
0, /*tp_traverse*/
|
|
813
|
+
0, /*tp_clear*/
|
|
814
|
+
0, /*tp_richcompare*/
|
|
815
|
+
0, /*tp_weaklistoffset*/
|
|
816
|
+
0, /*tp_iter*/
|
|
817
|
+
0, /*tp_iternext*/
|
|
818
|
+
summary_methods, /*tp_methods*/
|
|
819
|
+
0, /*tp_members*/
|
|
820
|
+
0, /*tp_getset*/
|
|
821
|
+
0, /*tp_base*/
|
|
822
|
+
0, /*tp_dict*/
|
|
823
|
+
0, /*tp_descr_get*/
|
|
824
|
+
0, /*tp_descr_set*/
|
|
825
|
+
0, /*tp_dictoffset*/
|
|
826
|
+
0, /*tp_init*/
|
|
827
|
+
0, /*tp_alloc*/
|
|
828
|
+
0, /*tp_new*/
|
|
829
|
+
0, /*tp_free*/
|
|
830
|
+
0, /*tp_is_gc*/
|
|
851
831
|
};
|
|
852
832
|
|
|
853
833
|
/*************************** View objects **************/
|
|
@@ -862,8 +842,7 @@ _msi.View.Execute
|
|
|
862
842
|
Execute the SQL query of the view.
|
|
863
843
|
[clinic start generated code]*/
|
|
864
844
|
|
|
865
|
-
static PyObject *
|
|
866
|
-
_msi_View_Execute(msiobj *self, PyObject *oparams)
|
|
845
|
+
static PyObject* _msi_View_Execute(msiobj* self, PyObject* oparams)
|
|
867
846
|
/*[clinic end generated code: output=f0f65fd2900bcb4e input=cb163a15d453348e]*/
|
|
868
847
|
{
|
|
869
848
|
int status;
|
|
@@ -871,7 +850,8 @@ _msi_View_Execute(msiobj *self, PyObject *oparams)
|
|
|
871
850
|
|
|
872
851
|
if (!Py_IsNone(oparams)) {
|
|
873
852
|
if (!Py_IS_TYPE(oparams, &record_Type)) {
|
|
874
|
-
PyErr_SetString(
|
|
853
|
+
PyErr_SetString(
|
|
854
|
+
PyExc_TypeError, "Execute argument must be a record");
|
|
875
855
|
return NULL;
|
|
876
856
|
}
|
|
877
857
|
params = ((msiobj*)oparams)->h;
|
|
@@ -890,8 +870,7 @@ _msi.View.Fetch
|
|
|
890
870
|
Return a result record of the query.
|
|
891
871
|
[clinic start generated code]*/
|
|
892
872
|
|
|
893
|
-
static PyObject *
|
|
894
|
-
_msi_View_Fetch_impl(msiobj *self)
|
|
873
|
+
static PyObject* _msi_View_Fetch_impl(msiobj* self)
|
|
895
874
|
/*[clinic end generated code: output=ba154a3794537d4e input=7f3e3d06c449001c]*/
|
|
896
875
|
{
|
|
897
876
|
int status;
|
|
@@ -916,14 +895,14 @@ _msi.View.GetColumnInfo
|
|
|
916
895
|
Return a record describing the columns of the view.
|
|
917
896
|
[clinic start generated code]*/
|
|
918
897
|
|
|
919
|
-
static PyObject *
|
|
920
|
-
_msi_View_GetColumnInfo_impl(msiobj *self, int kind)
|
|
898
|
+
static PyObject* _msi_View_GetColumnInfo_impl(msiobj* self, int kind)
|
|
921
899
|
/*[clinic end generated code: output=e7c1697db9403660 input=afedb892bf564a3b]*/
|
|
922
900
|
{
|
|
923
901
|
int status;
|
|
924
902
|
MSIHANDLE result;
|
|
925
903
|
|
|
926
|
-
if ((status = MsiViewGetColumnInfo(self->h, kind, &result))
|
|
904
|
+
if ((status = MsiViewGetColumnInfo(self->h, kind, &result))
|
|
905
|
+
!= ERROR_SUCCESS)
|
|
927
906
|
return msierror(status);
|
|
928
907
|
|
|
929
908
|
return record_new(result);
|
|
@@ -940,8 +919,7 @@ _msi.View.Modify
|
|
|
940
919
|
Modify the view.
|
|
941
920
|
[clinic start generated code]*/
|
|
942
921
|
|
|
943
|
-
static PyObject *
|
|
944
|
-
_msi_View_Modify_impl(msiobj *self, int kind, PyObject *data)
|
|
922
|
+
static PyObject* _msi_View_Modify_impl(msiobj* self, int kind, PyObject* data)
|
|
945
923
|
/*[clinic end generated code: output=69aaf3ce8ddac0ba input=2828de22de0d47b4]*/
|
|
946
924
|
{
|
|
947
925
|
int status;
|
|
@@ -951,7 +929,8 @@ _msi_View_Modify_impl(msiobj *self, int kind, PyObject *data)
|
|
|
951
929
|
return NULL;
|
|
952
930
|
}
|
|
953
931
|
|
|
954
|
-
if ((status = MsiViewModify(self->h, kind, ((msiobj*)data)->h))
|
|
932
|
+
if ((status = MsiViewModify(self->h, kind, ((msiobj*)data)->h))
|
|
933
|
+
!= ERROR_SUCCESS)
|
|
955
934
|
return msierror(status);
|
|
956
935
|
|
|
957
936
|
Py_RETURN_NONE;
|
|
@@ -963,8 +942,7 @@ _msi.View.Close
|
|
|
963
942
|
Close the view.
|
|
964
943
|
[clinic start generated code]*/
|
|
965
944
|
|
|
966
|
-
static PyObject *
|
|
967
|
-
_msi_View_Close_impl(msiobj *self)
|
|
945
|
+
static PyObject* _msi_View_Close_impl(msiobj* self)
|
|
968
946
|
/*[clinic end generated code: output=488f7b8645ca104a input=de6927d1308c401c]*/
|
|
969
947
|
{
|
|
970
948
|
int status;
|
|
@@ -975,6 +953,7 @@ _msi_View_Close_impl(msiobj *self)
|
|
|
975
953
|
Py_RETURN_NONE;
|
|
976
954
|
}
|
|
977
955
|
|
|
956
|
+
// clang-format off
|
|
978
957
|
static PyMethodDef view_methods[] = {
|
|
979
958
|
_MSI_VIEW_EXECUTE_METHODDEF
|
|
980
959
|
_MSI_VIEW_GETCOLUMNINFO_METHODDEF
|
|
@@ -983,49 +962,49 @@ static PyMethodDef view_methods[] = {
|
|
|
983
962
|
_MSI_VIEW_CLOSE_METHODDEF
|
|
984
963
|
{ NULL, NULL }
|
|
985
964
|
};
|
|
965
|
+
// clang-format on
|
|
986
966
|
|
|
987
967
|
static PyTypeObject msiview_Type = {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
0, /*tp_is_gc*/
|
|
968
|
+
PyVarObject_HEAD_INIT(NULL, 0) "_msi.View", /*tp_name*/
|
|
969
|
+
sizeof(msiobj), /*tp_basicsize*/
|
|
970
|
+
0, /*tp_itemsize*/
|
|
971
|
+
/* methods */
|
|
972
|
+
(destructor)msiobj_dealloc, /*tp_dealloc*/
|
|
973
|
+
0, /*tp_vectorcall_offset*/
|
|
974
|
+
0, /*tp_getattr*/
|
|
975
|
+
0, /*tp_setattr*/
|
|
976
|
+
0, /*tp_as_async*/
|
|
977
|
+
0, /*tp_repr*/
|
|
978
|
+
0, /*tp_as_number*/
|
|
979
|
+
0, /*tp_as_sequence*/
|
|
980
|
+
0, /*tp_as_mapping*/
|
|
981
|
+
0, /*tp_hash*/
|
|
982
|
+
0, /*tp_call*/
|
|
983
|
+
0, /*tp_str*/
|
|
984
|
+
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
985
|
+
PyObject_GenericSetAttr, /*tp_setattro*/
|
|
986
|
+
0, /*tp_as_buffer*/
|
|
987
|
+
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
|
988
|
+
0, /*tp_doc*/
|
|
989
|
+
0, /*tp_traverse*/
|
|
990
|
+
0, /*tp_clear*/
|
|
991
|
+
0, /*tp_richcompare*/
|
|
992
|
+
0, /*tp_weaklistoffset*/
|
|
993
|
+
0, /*tp_iter*/
|
|
994
|
+
0, /*tp_iternext*/
|
|
995
|
+
view_methods, /*tp_methods*/
|
|
996
|
+
0, /*tp_members*/
|
|
997
|
+
0, /*tp_getset*/
|
|
998
|
+
0, /*tp_base*/
|
|
999
|
+
0, /*tp_dict*/
|
|
1000
|
+
0, /*tp_descr_get*/
|
|
1001
|
+
0, /*tp_descr_set*/
|
|
1002
|
+
0, /*tp_dictoffset*/
|
|
1003
|
+
0, /*tp_init*/
|
|
1004
|
+
0, /*tp_alloc*/
|
|
1005
|
+
0, /*tp_new*/
|
|
1006
|
+
0, /*tp_free*/
|
|
1007
|
+
0, /*tp_is_gc*/
|
|
1029
1008
|
};
|
|
1030
1009
|
|
|
1031
1010
|
/*************************** Database objects **************/
|
|
@@ -1039,13 +1018,12 @@ _msi.Database.OpenView
|
|
|
1039
1018
|
Return a view object.
|
|
1040
1019
|
[clinic start generated code]*/
|
|
1041
1020
|
|
|
1042
|
-
static PyObject *
|
|
1043
|
-
_msi_Database_OpenView_impl(msiobj *self, const wchar_t *sql)
|
|
1021
|
+
static PyObject* _msi_Database_OpenView_impl(msiobj* self, const wchar_t* sql)
|
|
1044
1022
|
/*[clinic end generated code: output=e712e6a11229abfd input=50f1771f37e500df]*/
|
|
1045
1023
|
{
|
|
1046
1024
|
int status;
|
|
1047
1025
|
MSIHANDLE hView;
|
|
1048
|
-
msiobj
|
|
1026
|
+
msiobj* result;
|
|
1049
1027
|
|
|
1050
1028
|
if ((status = MsiDatabaseOpenViewW(self->h, sql, &hView)) != ERROR_SUCCESS)
|
|
1051
1029
|
return msierror(status);
|
|
@@ -1066,8 +1044,7 @@ _msi.Database.Commit
|
|
|
1066
1044
|
Commit the changes pending in the current transaction.
|
|
1067
1045
|
[clinic start generated code]*/
|
|
1068
1046
|
|
|
1069
|
-
static PyObject *
|
|
1070
|
-
_msi_Database_Commit_impl(msiobj *self)
|
|
1047
|
+
static PyObject* _msi_Database_Commit_impl(msiobj* self)
|
|
1071
1048
|
/*[clinic end generated code: output=f33021feb8b0cdd8 input=375bb120d402266d]*/
|
|
1072
1049
|
{
|
|
1073
1050
|
int status;
|
|
@@ -1087,13 +1064,13 @@ _msi.Database.GetSummaryInformation
|
|
|
1087
1064
|
Return a new summary information object.
|
|
1088
1065
|
[clinic start generated code]*/
|
|
1089
1066
|
|
|
1090
|
-
static PyObject
|
|
1091
|
-
|
|
1067
|
+
static PyObject* _msi_Database_GetSummaryInformation_impl(
|
|
1068
|
+
msiobj* self, int count)
|
|
1092
1069
|
/*[clinic end generated code: output=781e51a4ea4da847 input=18a899ead6521735]*/
|
|
1093
1070
|
{
|
|
1094
1071
|
int status;
|
|
1095
1072
|
MSIHANDLE result;
|
|
1096
|
-
msiobj
|
|
1073
|
+
msiobj* oresult;
|
|
1097
1074
|
|
|
1098
1075
|
status = MsiGetSummaryInformation(self->h, NULL, count, &result);
|
|
1099
1076
|
if (status != ERROR_SUCCESS)
|
|
@@ -1109,6 +1086,7 @@ _msi_Database_GetSummaryInformation_impl(msiobj *self, int count)
|
|
|
1109
1086
|
return (PyObject*)oresult;
|
|
1110
1087
|
}
|
|
1111
1088
|
|
|
1089
|
+
// clang-format off
|
|
1112
1090
|
static PyMethodDef db_methods[] = {
|
|
1113
1091
|
_MSI_DATABASE_OPENVIEW_METHODDEF
|
|
1114
1092
|
_MSI_DATABASE_COMMIT_METHODDEF
|
|
@@ -1116,61 +1094,60 @@ static PyMethodDef db_methods[] = {
|
|
|
1116
1094
|
_MSI_DATABASE_CLOSE_METHODDEF
|
|
1117
1095
|
{ NULL, NULL }
|
|
1118
1096
|
};
|
|
1097
|
+
// clang-format on
|
|
1119
1098
|
|
|
1120
1099
|
static PyTypeObject msidb_Type = {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
0, /*tp_is_gc*/
|
|
1100
|
+
PyVarObject_HEAD_INIT(NULL, 0) "_msi.Database", /*tp_name*/
|
|
1101
|
+
sizeof(msiobj), /*tp_basicsize*/
|
|
1102
|
+
0, /*tp_itemsize*/
|
|
1103
|
+
/* methods */
|
|
1104
|
+
(destructor)msiobj_dealloc, /*tp_dealloc*/
|
|
1105
|
+
0, /*tp_vectorcall_offset*/
|
|
1106
|
+
0, /*tp_getattr*/
|
|
1107
|
+
0, /*tp_setattr*/
|
|
1108
|
+
0, /*tp_as_async*/
|
|
1109
|
+
0, /*tp_repr*/
|
|
1110
|
+
0, /*tp_as_number*/
|
|
1111
|
+
0, /*tp_as_sequence*/
|
|
1112
|
+
0, /*tp_as_mapping*/
|
|
1113
|
+
0, /*tp_hash*/
|
|
1114
|
+
0, /*tp_call*/
|
|
1115
|
+
0, /*tp_str*/
|
|
1116
|
+
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
1117
|
+
PyObject_GenericSetAttr, /*tp_setattro*/
|
|
1118
|
+
0, /*tp_as_buffer*/
|
|
1119
|
+
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
|
1120
|
+
0, /*tp_doc*/
|
|
1121
|
+
0, /*tp_traverse*/
|
|
1122
|
+
0, /*tp_clear*/
|
|
1123
|
+
0, /*tp_richcompare*/
|
|
1124
|
+
0, /*tp_weaklistoffset*/
|
|
1125
|
+
0, /*tp_iter*/
|
|
1126
|
+
0, /*tp_iternext*/
|
|
1127
|
+
db_methods, /*tp_methods*/
|
|
1128
|
+
0, /*tp_members*/
|
|
1129
|
+
0, /*tp_getset*/
|
|
1130
|
+
0, /*tp_base*/
|
|
1131
|
+
0, /*tp_dict*/
|
|
1132
|
+
0, /*tp_descr_get*/
|
|
1133
|
+
0, /*tp_descr_set*/
|
|
1134
|
+
0, /*tp_dictoffset*/
|
|
1135
|
+
0, /*tp_init*/
|
|
1136
|
+
0, /*tp_alloc*/
|
|
1137
|
+
0, /*tp_new*/
|
|
1138
|
+
0, /*tp_free*/
|
|
1139
|
+
0, /*tp_is_gc*/
|
|
1162
1140
|
};
|
|
1163
1141
|
|
|
1164
|
-
#define Py_NOT_PERSIST(x, flag)
|
|
1165
|
-
(x != (SIZE_T)(flag) &&
|
|
1166
|
-
x != ((SIZE_T)(flag) | MSIDBOPEN_PATCHFILE))
|
|
1142
|
+
#define Py_NOT_PERSIST(x, flag) \
|
|
1143
|
+
(x != (SIZE_T)(flag) && x != ((SIZE_T)(flag) | MSIDBOPEN_PATCHFILE))
|
|
1167
1144
|
|
|
1168
|
-
#define Py_INVALID_PERSIST(x)
|
|
1169
|
-
(Py_NOT_PERSIST(x, MSIDBOPEN_READONLY)
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1145
|
+
#define Py_INVALID_PERSIST(x) \
|
|
1146
|
+
(Py_NOT_PERSIST(x, MSIDBOPEN_READONLY) \
|
|
1147
|
+
&& Py_NOT_PERSIST(x, MSIDBOPEN_TRANSACT) \
|
|
1148
|
+
&& Py_NOT_PERSIST(x, MSIDBOPEN_DIRECT) \
|
|
1149
|
+
&& Py_NOT_PERSIST(x, MSIDBOPEN_CREATE) \
|
|
1150
|
+
&& Py_NOT_PERSIST(x, MSIDBOPEN_CREATEDIRECT))
|
|
1174
1151
|
|
|
1175
1152
|
/*[clinic input]
|
|
1176
1153
|
_msi.OpenDatabase
|
|
@@ -1183,17 +1160,17 @@ _msi.OpenDatabase
|
|
|
1183
1160
|
Return a new database object.
|
|
1184
1161
|
[clinic start generated code]*/
|
|
1185
1162
|
|
|
1186
|
-
static PyObject
|
|
1187
|
-
|
|
1163
|
+
static PyObject* _msi_OpenDatabase_impl(
|
|
1164
|
+
PyObject* module, const wchar_t* path, int persist)
|
|
1188
1165
|
/*[clinic end generated code: output=d34b7202b745de05 input=1300f3b97659559b]*/
|
|
1189
1166
|
{
|
|
1190
1167
|
int status;
|
|
1191
1168
|
MSIHANDLE h;
|
|
1192
|
-
msiobj
|
|
1169
|
+
msiobj* result;
|
|
1193
1170
|
|
|
1194
|
-
/* We need to validate that persist is a valid MSIDBOPEN_* value.
|
|
1195
|
-
MsiOpenDatabase may treat the value as a pointer, leading to
|
|
1196
|
-
behavior. */
|
|
1171
|
+
/* We need to validate that persist is a valid MSIDBOPEN_* value.
|
|
1172
|
+
Otherwise, MsiOpenDatabase may treat the value as a pointer, leading to
|
|
1173
|
+
unexpected behavior. */
|
|
1197
1174
|
if (Py_INVALID_PERSIST(persist))
|
|
1198
1175
|
return msierror(ERROR_INVALID_PARAMETER);
|
|
1199
1176
|
status = MsiOpenDatabaseW(path, (LPCWSTR)(SIZE_T)persist, &h);
|
|
@@ -1218,8 +1195,7 @@ _msi.CreateRecord
|
|
|
1218
1195
|
Return a new record object.
|
|
1219
1196
|
[clinic start generated code]*/
|
|
1220
1197
|
|
|
1221
|
-
static PyObject *
|
|
1222
|
-
_msi_CreateRecord_impl(PyObject *module, int count)
|
|
1198
|
+
static PyObject* _msi_CreateRecord_impl(PyObject* module, int count)
|
|
1223
1199
|
/*[clinic end generated code: output=0ba0a00beea3e99e input=53f17d5b5d9b077d]*/
|
|
1224
1200
|
{
|
|
1225
1201
|
MSIHANDLE h;
|
|
@@ -1231,7 +1207,7 @@ _msi_CreateRecord_impl(PyObject *module, int count)
|
|
|
1231
1207
|
return record_new(h);
|
|
1232
1208
|
}
|
|
1233
1209
|
|
|
1234
|
-
|
|
1210
|
+
// clang-format off
|
|
1235
1211
|
static PyMethodDef msi_methods[] = {
|
|
1236
1212
|
_MSI_UUIDCREATE_METHODDEF
|
|
1237
1213
|
_MSI_FCICREATE_METHODDEF
|
|
@@ -1239,37 +1215,33 @@ static PyMethodDef msi_methods[] = {
|
|
|
1239
1215
|
_MSI_CREATERECORD_METHODDEF
|
|
1240
1216
|
{NULL, NULL} /* sentinel */
|
|
1241
1217
|
};
|
|
1218
|
+
// clang-format on
|
|
1242
1219
|
|
|
1243
1220
|
static char msi_doc[] = "Documentation";
|
|
1244
1221
|
|
|
1222
|
+
static struct PyModuleDef _msimodule = { PyModuleDef_HEAD_INIT, "_msi",
|
|
1223
|
+
msi_doc, -1, msi_methods, NULL, NULL, NULL, NULL };
|
|
1245
1224
|
|
|
1246
|
-
|
|
1247
|
-
PyModuleDef_HEAD_INIT,
|
|
1248
|
-
"_msi",
|
|
1249
|
-
msi_doc,
|
|
1250
|
-
-1,
|
|
1251
|
-
msi_methods,
|
|
1252
|
-
NULL,
|
|
1253
|
-
NULL,
|
|
1254
|
-
NULL,
|
|
1255
|
-
NULL
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1258
|
-
PyMODINIT_FUNC
|
|
1259
|
-
PyInit__msi(void)
|
|
1225
|
+
PyMODINIT_FUNC PyInit__msi(void)
|
|
1260
1226
|
{
|
|
1261
|
-
PyObject
|
|
1227
|
+
PyObject* m;
|
|
1262
1228
|
|
|
1263
1229
|
m = PyModule_Create(&_msimodule);
|
|
1264
1230
|
if (m == NULL)
|
|
1265
1231
|
return NULL;
|
|
1266
1232
|
|
|
1267
|
-
PyModule_AddIntConstant(
|
|
1268
|
-
|
|
1269
|
-
PyModule_AddIntConstant(
|
|
1270
|
-
|
|
1271
|
-
PyModule_AddIntConstant(
|
|
1272
|
-
|
|
1233
|
+
PyModule_AddIntConstant(
|
|
1234
|
+
m, "MSIDBOPEN_CREATEDIRECT", (long)(SIZE_T)MSIDBOPEN_CREATEDIRECT);
|
|
1235
|
+
PyModule_AddIntConstant(
|
|
1236
|
+
m, "MSIDBOPEN_CREATE", (long)(SIZE_T)MSIDBOPEN_CREATE);
|
|
1237
|
+
PyModule_AddIntConstant(
|
|
1238
|
+
m, "MSIDBOPEN_DIRECT", (long)(SIZE_T)MSIDBOPEN_DIRECT);
|
|
1239
|
+
PyModule_AddIntConstant(
|
|
1240
|
+
m, "MSIDBOPEN_READONLY", (long)(SIZE_T)MSIDBOPEN_READONLY);
|
|
1241
|
+
PyModule_AddIntConstant(
|
|
1242
|
+
m, "MSIDBOPEN_TRANSACT", (long)(SIZE_T)MSIDBOPEN_TRANSACT);
|
|
1243
|
+
PyModule_AddIntConstant(
|
|
1244
|
+
m, "MSIDBOPEN_PATCHFILE", (long)(SIZE_T)MSIDBOPEN_PATCHFILE);
|
|
1273
1245
|
|
|
1274
1246
|
PyModule_AddIntMacro(m, MSICOLINFO_NAMES);
|
|
1275
1247
|
PyModule_AddIntMacro(m, MSICOLINFO_TYPES);
|
|
@@ -1306,9 +1278,12 @@ PyInit__msi(void)
|
|
|
1306
1278
|
PyModule_AddIntMacro(m, PID_APPNAME);
|
|
1307
1279
|
PyModule_AddIntMacro(m, PID_SECURITY);
|
|
1308
1280
|
|
|
1309
|
-
MSIError = PyErr_NewException
|
|
1281
|
+
MSIError = PyErr_NewException("_msi.MSIError", NULL, NULL);
|
|
1310
1282
|
if (!MSIError)
|
|
1311
1283
|
return NULL;
|
|
1312
1284
|
PyModule_AddObject(m, "MSIError", MSIError);
|
|
1285
|
+
#ifdef Py_GIL_DISABLED
|
|
1286
|
+
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
|
|
1287
|
+
#endif
|
|
1313
1288
|
return m;
|
|
1314
1289
|
}
|