summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python/src/PC
diff options
context:
space:
mode:
authorpefavel <[email protected]>2026-03-16 17:44:57 +0300
committerpefavel <[email protected]>2026-03-17 11:40:58 +0300
commit6eecc739c342dbfca9be6328231233dd8e77d9f4 (patch)
tree491834a1c01185c100a79d420a7492c7e53ba32a /contrib/tools/python/src/PC
parent58b88dfd7db837890ffc2edbe80e5235298cec10 (diff)
revert piglet config change
commit_hash:d068d68a89226c414a3d5a1f8ad102579bdd233b
Diffstat (limited to 'contrib/tools/python/src/PC')
-rw-r--r--contrib/tools/python/src/PC/WinMain.c16
-rw-r--r--contrib/tools/python/src/PC/_msi.c1084
-rw-r--r--contrib/tools/python/src/PC/config.c170
-rw-r--r--contrib/tools/python/src/PC/dllbase_nt.txt77
-rw-r--r--contrib/tools/python/src/PC/empty.c6
-rw-r--r--contrib/tools/python/src/PC/errmap.mak5
-rw-r--r--contrib/tools/python/src/PC/frozen_dllmain.c134
-rw-r--r--contrib/tools/python/src/PC/generrmap.c20
-rw-r--r--contrib/tools/python/src/PC/icons.mak9
-rw-r--r--contrib/tools/python/src/PC/icons.rc4
-rw-r--r--contrib/tools/python/src/PC/make_versioninfo.c38
-rw-r--r--contrib/tools/python/src/PC/py.icobin19790 -> 0 bytes
-rw-r--r--contrib/tools/python/src/PC/pyc.icobin19790 -> 0 bytes
-rw-r--r--contrib/tools/python/src/PC/pycon.icobin19790 -> 0 bytes
-rw-r--r--contrib/tools/python/src/PC/python.mk5
-rw-r--r--contrib/tools/python/src/PC/python_exe.rc1
-rw-r--r--contrib/tools/python/src/PC/python_nt.rc74
-rw-r--r--contrib/tools/python/src/PC/readme.txt99
-rw-r--r--contrib/tools/python/src/PC/testpy.py32
-rw-r--r--contrib/tools/python/src/PC/w9xpopen.c112
-rw-r--r--contrib/tools/python/src/PC/winsound.c191
21 files changed, 0 insertions, 2077 deletions
diff --git a/contrib/tools/python/src/PC/WinMain.c b/contrib/tools/python/src/PC/WinMain.c
deleted file mode 100644
index 2cdd0cb695d..00000000000
--- a/contrib/tools/python/src/PC/WinMain.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Minimal main program -- everything is loaded from the library. */
-
-#include "Python.h"
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-int WINAPI WinMain(
- HINSTANCE hInstance, /* handle to current instance */
- HINSTANCE hPrevInstance, /* handle to previous instance */
- LPSTR lpCmdLine, /* pointer to command line */
- int nCmdShow /* show state of window */
-)
-{
- return Py_Main(__argc, __argv);
-}
diff --git a/contrib/tools/python/src/PC/_msi.c b/contrib/tools/python/src/PC/_msi.c
deleted file mode 100644
index 4d094ae997e..00000000000
--- a/contrib/tools/python/src/PC/_msi.c
+++ /dev/null
@@ -1,1084 +0,0 @@
-/* Helper library for MSI creation with Python.
- * Copyright (C) 2005 Martin v. L�wis
- * Licensed to PSF under a contributor agreement.
- */
-
-#include <Python.h>
-#include <fci.h>
-#include <fcntl.h>
-#include <windows.h>
-#include <msi.h>
-#include <msiquery.h>
-#include <msidefs.h>
-#include <rpc.h>
-
-static PyObject *MSIError;
-
-static PyObject*
-uuidcreate(PyObject* obj, PyObject*args)
-{
- UUID result;
- RPC_CSTR 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 (UuidToString(&result, &cresult) == RPC_S_OUT_OF_MEMORY) {
- PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen");
- return NULL;
- }
-
- oresult = PyString_FromString((const char*)cresult);
- RpcStringFree(&cresult);
- return oresult;
-
-}
-
-/* FCI callback functions */
-
-static FNFCIALLOC(cb_alloc)
-{
- return malloc(cb);
-}
-
-static FNFCIFREE(cb_free)
-{
- free(memory);
-}
-
-static FNFCIOPEN(cb_open)
-{
- int result = _open(pszFile, oflag, pmode);
- if (result == -1)
- *err = errno;
- return result;
-}
-
-static FNFCIREAD(cb_read)
-{
- UINT result = (UINT)_read(hf, memory, cb);
- if (result != cb)
- *err = errno;
- return result;
-}
-
-static FNFCIWRITE(cb_write)
-{
- UINT result = (UINT)_write(hf, memory, cb);
- if (result != cb)
- *err = errno;
- return result;
-}
-
-static FNFCICLOSE(cb_close)
-{
- int result = _close(hf);
- if (result != 0)
- *err = errno;
- return result;
-}
-
-static FNFCISEEK(cb_seek)
-{
- long result = (long)_lseek(hf, dist, seektype);
- if (result == -1)
- *err = errno;
- return result;
-}
-
-static FNFCIDELETE(cb_delete)
-{
- int result = remove(pszFile);
- if (result != 0)
- *err = errno;
- return result;
-}
-
-static FNFCIFILEPLACED(cb_fileplaced)
-{
- return 0;
-}
-
-static FNFCIGETTEMPFILE(cb_gettempfile)
-{
- 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 FNFCISTATUS(cb_status)
-{
- if (pv) {
- PyObject *result = PyObject_CallMethod((PyObject*)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((PyObject*)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;
-}
-
-static FNFCIGETOPENINFO(cb_getopeninfo)
-{
- 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);
-}
-
-static PyObject* fcicreate(PyObject* obj, PyObject* args)
-{
- 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;
-}
-
-typedef struct msiobj{
- PyObject_HEAD
- MSIHANDLE h;
-}msiobj;
-
-static void
-msiobj_dealloc(msiobj* msidb)
-{
- MsiCloseHandle(msidb->h);
- msidb->h = 0;
- PyObject_Del(msidb);
-}
-
-static PyObject*
-msiobj_close(msiobj* msidb, PyObject *args)
-{
- MsiCloseHandle(msidb->h);
- msidb->h = 0;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject*
-msierror(int status)
-{
- 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 = (char*)malloc(size+1);
- if (res == NULL) {
- MsiCloseHandle(err);
- return PyErr_NoMemory();
- }
- MsiFormatRecord(0, err, res, &size);
- res[size]='\0';
- }
- MsiCloseHandle(err);
- PyErr_SetString(MSIError, res);
- if (res != buf)
- free(res);
- return NULL;
-}
-
-/*************************** Record objects **********************/
-
-static PyObject*
-record_getfieldcount(msiobj* record, PyObject* args)
-{
- return PyInt_FromLong(MsiRecordGetFieldCount(record->h));
-}
-
-static PyObject*
-record_getinteger(msiobj* record, PyObject* args)
-{
- 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 PyInt_FromLong((long) status);
-}
-
-static PyObject*
-record_getstring(msiobj* record, PyObject* args)
-{
- unsigned int field;
- unsigned int status;
- char buf[2000];
- char *res = buf;
- DWORD size = sizeof(buf);
- PyObject* string;
-
- if (!PyArg_ParseTuple(args, "I:GetString", &field))
- 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);
- }
- if (status != ERROR_SUCCESS)
- return msierror((int) status);
- string = PyString_FromString(res);
- if (buf != res)
- free(res);
- return string;
-}
-
-static PyObject*
-record_cleardata(msiobj* record, PyObject *args)
-{
- int status = MsiRecordClearData(record->h);
- if (status != ERROR_SUCCESS)
- return msierror(status);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject*
-record_setstring(msiobj* record, PyObject *args)
-{
- int status;
- int field;
- char *data;
-
- if (!PyArg_ParseTuple(args, "is:SetString", &field, &data))
- return NULL;
-
- if ((status = MsiRecordSetString(record->h, field, data)) != ERROR_SUCCESS)
- return msierror(status);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject*
-record_setstream(msiobj* record, PyObject *args)
-{
- int status;
- int field;
- char *data;
-
- if (!PyArg_ParseTuple(args, "is:SetStream", &field, &data))
- return NULL;
-
- if ((status = MsiRecordSetStream(record->h, field, data)) != ERROR_SUCCESS)
- return msierror(status);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject*
-record_setinteger(msiobj* record, PyObject *args)
-{
- 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;
-}
-
-
-
-static PyMethodDef record_methods[] = {
- { "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 }
-};
-
-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*/
-};
-
-static PyObject*
-record_new(MSIHANDLE h)
-{
- msiobj *result = PyObject_NEW(struct msiobj, &record_Type);
-
- if (!result) {
- MsiCloseHandle(h);
- return NULL;
- }
-
- result->h = h;
- return (PyObject*)result;
-}
-
-/*************************** SummaryInformation objects **************/
-
-static PyObject*
-summary_getproperty(msiobj* si, PyObject *args)
-{
- int status;
- int field;
- PyObject *result;
- UINT type;
- INT ival;
- FILETIME fval;
- char sbuf[1000];
- char *sval = sbuf;
- DWORD ssize = sizeof(sbuf);
-
- if (!PyArg_ParseTuple(args, "i:GetProperty", &field))
- return NULL;
-
- status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
- &fval, sval, &ssize);
- if (status == ERROR_MORE_DATA) {
- ssize++;
- sval = (char*)malloc(ssize);
- if (sval == NULL) {
- return PyErr_NoMemory();
- }
- status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
- &fval, sval, &ssize);
- }
-
- switch(type) {
- case VT_I2:
- case VT_I4:
- result = PyLong_FromLong(ival);
- break;
- case VT_FILETIME:
- PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
- result = NULL;
- break;
- case VT_LPSTR:
- result = PyBytes_FromStringAndSize(sval, ssize);
- break;
- case VT_EMPTY:
- Py_INCREF(Py_None);
- result = Py_None;
- break;
- default:
- PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
- result = NULL;
- break;
- }
- if (sval != sbuf)
- free(sval);
- return result;
-}
-
-static PyObject*
-summary_getpropertycount(msiobj* si, PyObject *args)
-{
- int status;
- UINT result;
-
- status = MsiSummaryInfoGetPropertyCount(si->h, &result);
- if (status != ERROR_SUCCESS)
- return msierror(status);
-
- return PyInt_FromLong(result);
-}
-
-static PyObject*
-summary_setproperty(msiobj* si, PyObject *args)
-{
- int status;
- int field;
- PyObject* data;
-
- if (!PyArg_ParseTuple(args, "iO:SetProperty", &field, &data))
- return NULL;
-
- if (PyString_Check(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);
- } else {
- PyErr_SetString(PyExc_TypeError, "unsupported type");
- return NULL;
- }
-
- if (status != ERROR_SUCCESS)
- return msierror(status);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-
-static PyObject*
-summary_persist(msiobj* si, PyObject *args)
-{
- int status;
-
- status = MsiSummaryInfoPersist(si->h);
- if (status != ERROR_SUCCESS)
- 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")},
- { "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 }
-};
-
-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*/
-};
-
-/*************************** View objects **************/
-
-static PyObject*
-view_execute(msiobj *view, PyObject*args)
-{
- 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;
-}
-
-static PyObject*
-view_fetch(msiobj *view, PyObject*args)
-{
- int status;
- MSIHANDLE result;
-
- if ((status = MsiViewFetch(view->h, &result)) != ERROR_SUCCESS)
- return msierror(status);
-
- return record_new(result);
-}
-
-static PyObject*
-view_getcolumninfo(msiobj *view, PyObject *args)
-{
- int status;
- MSICOLINFO 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);
-}
-
-static PyObject*
-view_modify(msiobj *view, PyObject *args)
-{
- MSIMODIFY 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;
-}
-
-static PyObject*
-view_close(msiobj *view, PyObject*args)
-{
- int status;
-
- if ((status = MsiViewClose(view->h)) != ERROR_SUCCESS)
- 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")},
- { "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 }
-};
-
-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*/
-};
-
-/*************************** Database objects **************/
-
-static PyObject*
-msidb_openview(msiobj *msidb, PyObject *args)
-{
- 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;
-}
-
-static PyObject*
-msidb_commit(msiobj *msidb, PyObject *args)
-{
- int status;
-
- if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS)
- return msierror(status);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject*
-msidb_getsummaryinformation(msiobj *db, PyObject *args)
-{
- 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 (!oresult) {
- MsiCloseHandle(result);
- return NULL;
- }
-
- oresult->h = result;
- return (PyObject*)oresult;
-}
-
-static PyMethodDef db_methods[] = {
- { "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 }
-};
-
-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*/
-};
-
-#define Py_NOT_PERSIST(x, flag) \
- (x != (int)(flag) && \
- x != ((int)(flag) | MSIDBOPEN_PATCHFILE))
-
-#define Py_INVALID_PERSIST(x) \
- (Py_NOT_PERSIST(x, MSIDBOPEN_READONLY) && \
- Py_NOT_PERSIST(x, MSIDBOPEN_TRANSACT) && \
- Py_NOT_PERSIST(x, MSIDBOPEN_DIRECT) && \
- Py_NOT_PERSIST(x, MSIDBOPEN_CREATE) && \
- Py_NOT_PERSIST(x, MSIDBOPEN_CREATEDIRECT))
-
-static PyObject* msiopendb(PyObject *obj, PyObject *args)
-{
- int status;
- char *path;
- int persist;
- MSIHANDLE h;
- msiobj *result;
- if (!PyArg_ParseTuple(args, "si:MSIOpenDatabase", &path, &persist))
- return NULL;
- /* We need to validate that persist is a valid MSIDBOPEN_* value. Otherwise,
- MsiOpenDatabase may treat the value as a pointer, leading to unexpected
- behavior. */
- if (Py_INVALID_PERSIST(persist))
- return msierror(ERROR_INVALID_PARAMETER);
- 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;
-}
-
-static PyObject*
-createrecord(PyObject *o, PyObject *args)
-{
- 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);
-}
-
-
-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 */
-};
-
-static char msi_doc[] = "Documentation";
-
-PyMODINIT_FUNC
-init_msi(void)
-{
- PyObject *m;
-
- m = Py_InitModule3("_msi", msi_methods, msi_doc);
- if (m == NULL)
- return;
-
- 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;
- PyModule_AddObject(m, "MSIError", MSIError);
-}
diff --git a/contrib/tools/python/src/PC/config.c b/contrib/tools/python/src/PC/config.c
deleted file mode 100644
index 35c66085146..00000000000
--- a/contrib/tools/python/src/PC/config.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* Module configuration */
-
-/* This file contains the table of built-in modules.
- See init_builtin() in import.c. */
-
-#include "Python.h"
-
-extern void initarray(void);
-#ifndef MS_WINI64
-extern void initaudioop(void);
-#endif
-extern void initbinascii(void);
-extern void initcmath(void);
-extern void initerrno(void);
-extern void initfuture_builtins(void);
-extern void initgc(void);
-#ifndef MS_WINI64
-extern void initimageop(void);
-#endif
-extern void initmath(void);
-extern void init_md5(void);
-extern void initnt(void);
-extern void initoperator(void);
-extern void initsignal(void);
-extern void init_sha(void);
-extern void init_sha256(void);
-extern void init_sha512(void);
-extern void initstrop(void);
-extern void inittime(void);
-extern void initthread(void);
-extern void initcStringIO(void);
-extern void initcPickle(void);
-#ifdef WIN32
-extern void initmsvcrt(void);
-extern void init_locale(void);
-#endif
-extern void init_codecs(void);
-extern void init_weakref(void);
-extern void init_hotshot(void);
-extern void initxxsubtype(void);
-extern void initzipimport(void);
-extern void init_random(void);
-extern void inititertools(void);
-extern void init_collections(void);
-extern void init_heapq(void);
-extern void init_bisect(void);
-extern void init_symtable(void);
-extern void initmmap(void);
-extern void init_csv(void);
-extern void init_sre(void);
-extern void initparser(void);
-extern void init_winreg(void);
-extern void init_struct(void);
-extern void initdatetime(void);
-extern void init_functools(void);
-extern void init_json(void);
-extern void initzlib(void);
-
-extern void init_multibytecodec(void);
-extern void init_codecs_cn(void);
-extern void init_codecs_hk(void);
-extern void init_codecs_iso2022(void);
-extern void init_codecs_jp(void);
-extern void init_codecs_kr(void);
-extern void init_codecs_tw(void);
-extern void init_subprocess(void);
-extern void init_lsprof(void);
-extern void init_ast(void);
-extern void init_io(void);
-extern void _PyWarnings_Init(void);
-
-/* tools/freeze/makeconfig.py marker for additional "extern" */
-/* -- ADDMODULE MARKER 1 -- */
-
-extern void PyMarshal_Init(void);
-extern void initimp(void);
-
-struct _inittab _PyImport_Inittab[] = {
-
- {"array", initarray},
- {"_ast", init_ast},
-#ifdef MS_WINDOWS
-#ifndef MS_WINI64
- {"audioop", initaudioop},
-#endif
-#endif
- {"binascii", initbinascii},
- {"cmath", initcmath},
- {"errno", initerrno},
- {"future_builtins", initfuture_builtins},
- {"gc", initgc},
-#ifndef MS_WINI64
- {"imageop", initimageop},
-#endif
- {"math", initmath},
- {"_md5", init_md5},
- {"nt", initnt}, /* Use the NT os functions, not posix */
- {"operator", initoperator},
- {"signal", initsignal},
- {"_sha", init_sha},
- {"_sha256", init_sha256},
- {"_sha512", init_sha512},
- {"strop", initstrop},
- {"time", inittime},
-#ifdef WITH_THREAD
- {"thread", initthread},
-#endif
- {"cStringIO", initcStringIO},
- {"cPickle", initcPickle},
-#ifdef WIN32
- {"msvcrt", initmsvcrt},
- {"_locale", init_locale},
-#endif
- /* XXX Should _subprocess go in a WIN32 block? not WIN64? */
- {"_subprocess", init_subprocess},
-
- {"_codecs", init_codecs},
- {"_weakref", init_weakref},
- {"_hotshot", init_hotshot},
- {"_random", init_random},
- {"_bisect", init_bisect},
- {"_heapq", init_heapq},
- {"_lsprof", init_lsprof},
- {"itertools", inititertools},
- {"_collections", init_collections},
- {"_symtable", init_symtable},
- {"mmap", initmmap},
- {"_csv", init_csv},
- {"_sre", init_sre},
- {"parser", initparser},
- {"_winreg", init_winreg},
- {"_struct", init_struct},
- {"datetime", initdatetime},
- {"_functools", init_functools},
- {"_json", init_json},
-
- {"xxsubtype", initxxsubtype},
- {"zipimport", initzipimport},
- {"zlib", initzlib},
-
- /* CJK codecs */
- {"_multibytecodec", init_multibytecodec},
- {"_codecs_cn", init_codecs_cn},
- {"_codecs_hk", init_codecs_hk},
- {"_codecs_iso2022", init_codecs_iso2022},
- {"_codecs_jp", init_codecs_jp},
- {"_codecs_kr", init_codecs_kr},
- {"_codecs_tw", init_codecs_tw},
-
-/* tools/freeze/makeconfig.py marker for additional "_inittab" entries */
-/* -- ADDMODULE MARKER 2 -- */
-
- /* This module "lives in" with marshal.c */
- {"marshal", PyMarshal_Init},
-
- /* This lives it with import.c */
- {"imp", initimp},
-
- /* These entries are here for sys.builtin_module_names */
- {"__main__", NULL},
- {"__builtin__", NULL},
- {"sys", NULL},
- {"exceptions", NULL},
- {"_warnings", _PyWarnings_Init},
-
- {"_io", init_io},
-
- /* Sentinel */
- {0, 0}
-};
diff --git a/contrib/tools/python/src/PC/dllbase_nt.txt b/contrib/tools/python/src/PC/dllbase_nt.txt
deleted file mode 100644
index c06e497e751..00000000000
--- a/contrib/tools/python/src/PC/dllbase_nt.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-In Win32, DLL's are "pre-linked" using a specified base address.
-When the DLL is loaded, an attempt is made to place it at
-that address. If that address is already in use, a new base address
-is selected, and the DLL subject to fixups. Apparently, these
-fixups are very slow, and significant performance gains can be
-made by selecting a good base address.
-
-This document is to allocate base addresses to core Python
-and Python .PYD files, to give a better change of optimal performance.
-This base address is passed to the linker using the /BASE
-command line switch.
-
-
-Python.exe/Pythonw.exe - 1d000000 - 1e000000 (-1)
-Python.dll - 1e000000 - 1e100000 (-1)
-
-Standard Extension Modules 1e100000 - 1e200000 ""
- - _symtable 1e100000 - 1e110000 pyd removed in 2.4
- - bsddb 1e180000 - 1e188000
- - _tkinter 1e190000 - 1e1A0000
- - parser 1e1A0000 - 1e1B0000 pyd removed in 2.4
- - zlib 1e1B0000 - 1e1C0000
- - winreg 1e1C0000 - 1e1D0000 pyd removed in 2.4
- - _socket 1e1D0000 - 1e1E0000
- - _sre 1e1E0000 - 1e1F0000 pyd removed in 2.4
- - mmap 1e1F0000 - 1e1FFFFF pyd removed in 2.4
-
-More standard extensions 1D100000 - 1e000000
- - pyexpat 1D100000 - 1D110000
- - select 1D110000 - 1D120000
- - unicodedata 1D120000 - 1D160000
- - winsound 1D160000 - 1D170000
- - bZ2 1D170000 - 1D180000
- - datetime 1D180000 - 1D190000 pyd removed in 2.4
- - _csv 1D190000 - 1D1A0000 pyd removed in 2.4
- - _ctypes 1D1A0000 - 1D1B0000
-
-Other extension modules
- - win32api 1e200000 - 1e220000
- - win32ras 1e220000 - 1e230000
- - win32lz 1e230000 - 1e240000
- - timer 1e240000 - 1e250000
- - mmapfile 1e250000 - 1e260000
- - win32pipe 1e260000 - 1e270000
- - avl 1e270000 - 1e270000
- - dbhash 1e280000 - 1e290000
- - win32net 1e290000 - 1e2A0000
- - win32security 1e2A0000 - 1e2B0000
- - win32print 1e2B0000 - 1e2c0000
- - <unused> 1e2d0000 - 1e2e0000
- - win32gui 1e2e0000 - 1e2f0000
- - _imaging 1e2f0000 - 1e300000
- - multiarray 1e300000 - 1e310000
- - win32help 1e310000 - 1e320000
- - win32clipboard 1e320000 - 1e330000
- - win2kras 1e330000 - 1e340000
- - pythoncom 1e340000 - 1e400000
- - win32ui 1e400000 - 1e500000
- - win32uiole 1e500000 - 1e600000
- - pywintypes 1e600000 - 1e700000
- - win32process 1e700000 - 1e800000
- - odbc 1e710000 - 1e720000
- - dbi 1e720000 - 1e730000
- - win32file 1e730000 - 1e740000
- - win32wnet 1e740000 - 1e750000
- - win32com.shell 1e750000 - 1e760000
- - win32com.internet 1e760000 - 1e770000
- - win32com.exchange 1e770000 - 1e780000
- - win32com.exchdapi 1e780000 - 1e790000
- - win32com.axscript 1e790000 - 1e7a0000
- - win32com.axdebug 1e7b0000 - 1e7c0000
- - win32com.adsi 1e7f0000 - 1e800000
- - win32event 1e810000 - 1e820000
- - win32evtlog 1e820000 - 1e830000
- - win32com.axcontrol 1e830000 - 1e840000
-
-
diff --git a/contrib/tools/python/src/PC/empty.c b/contrib/tools/python/src/PC/empty.c
deleted file mode 100644
index 846b4d0d646..00000000000
--- a/contrib/tools/python/src/PC/empty.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <windows.h>
-int __stdcall
-WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-{
- return 0;
-} \ No newline at end of file
diff --git a/contrib/tools/python/src/PC/errmap.mak b/contrib/tools/python/src/PC/errmap.mak
deleted file mode 100644
index 646bcd0a209..00000000000
--- a/contrib/tools/python/src/PC/errmap.mak
+++ /dev/null
@@ -1,5 +0,0 @@
-errmap.h: generrmap.exe
- .\generrmap.exe > errmap.h
-
-genermap.exe: generrmap.c
- cl generrmap.c
diff --git a/contrib/tools/python/src/PC/frozen_dllmain.c b/contrib/tools/python/src/PC/frozen_dllmain.c
deleted file mode 100644
index a8cc8851845..00000000000
--- a/contrib/tools/python/src/PC/frozen_dllmain.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* FreezeDLLMain.cpp
-
-This is a DLLMain suitable for frozen applications/DLLs on
-a Windows platform.
-
-The general problem is that many Python extension modules may define
-DLL main functions, but when statically linked together to form
-a frozen application, this DLLMain symbol exists multiple times.
-
-The solution is:
-* Each module checks for a frozen build, and if so, defines its DLLMain
- function as "__declspec(dllexport) DllMain%module%"
- (eg, DllMainpythoncom, or DllMainpywintypes)
-
-* The frozen .EXE/.DLL links against this module, which provides
- the single DllMain.
-
-* This DllMain attempts to locate and call the DllMain for each
- of the extension modules.
-
-* This code also has hooks to "simulate" DllMain when used from
- a frozen .EXE.
-
-At this stage, there is a static table of "possibly embedded modules".
-This should change to something better, but it will work OK for now.
-
-Note that this scheme does not handle dependencies in the order
-of DllMain calls - except it does call pywintypes first :-)
-
-As an example of how an extension module with a DllMain should be
-changed, here is a snippet from the pythoncom extension module.
-
- // end of example code from pythoncom's DllMain.cpp
- #ifndef BUILD_FREEZE
- #define DLLMAIN DllMain
- #define DLLMAIN_DECL
- #else
- #define DLLMAIN DllMainpythoncom
- #define DLLMAIN_DECL __declspec(dllexport)
- #endif
-
- extern "C" DLLMAIN_DECL
- BOOL WINAPI DLLMAIN(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
- // end of example code from pythoncom's DllMain.cpp
-
-***************************************************************************/
-#include "windows.h"
-
-static char *possibleModules[] = {
- "pywintypes",
- "pythoncom",
- "win32ui",
- NULL,
-};
-
-BOOL CallModuleDllMain(char *modName, DWORD dwReason);
-
-
-/*
- Called by a frozen .EXE only, so that built-in extension
- modules are initialized correctly
-*/
-void PyWinFreeze_ExeInit(void)
-{
- char **modName;
- for (modName = possibleModules;*modName;*modName++) {
-/* printf("Initialising '%s'\n", *modName); */
- CallModuleDllMain(*modName, DLL_PROCESS_ATTACH);
- }
-}
-
-/*
- Called by a frozen .EXE only, so that built-in extension
- modules are cleaned up
-*/
-void PyWinFreeze_ExeTerm(void)
-{
- // Must go backwards
- char **modName;
- for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2;
- modName >= possibleModules;
- *modName--) {
-/* printf("Terminating '%s'\n", *modName);*/
- CallModuleDllMain(*modName, DLL_PROCESS_DETACH);
- }
-}
-
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
-{
- BOOL ret = TRUE;
- switch (dwReason) {
- case DLL_PROCESS_ATTACH:
- {
- char **modName;
- for (modName = possibleModules;*modName;*modName++) {
- BOOL ok = CallModuleDllMain(*modName, dwReason);
- if (!ok)
- ret = FALSE;
- }
- break;
- }
- case DLL_PROCESS_DETACH:
- {
- // Must go backwards
- char **modName;
- for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2;
- modName >= possibleModules;
- *modName--)
- CallModuleDllMain(*modName, DLL_PROCESS_DETACH);
- break;
- }
- }
- return ret;
-}
-
-BOOL CallModuleDllMain(char *modName, DWORD dwReason)
-{
- BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID);
-
- char funcName[255];
- HMODULE hmod = GetModuleHandle(NULL);
- strcpy(funcName, "_DllMain");
- strcat(funcName, modName);
- strcat(funcName, "@12"); // stdcall convention.
- pfndllmain = (BOOL (WINAPI *)(HINSTANCE, DWORD, LPVOID))GetProcAddress(hmod, funcName);
- if (pfndllmain==NULL) {
- /* No function by that name exported - then that module does
- not appear in our frozen program - return OK
- */
- return TRUE;
- }
- return (*pfndllmain)(hmod, dwReason, NULL);
-}
-
diff --git a/contrib/tools/python/src/PC/generrmap.c b/contrib/tools/python/src/PC/generrmap.c
deleted file mode 100644
index bf1081b7449..00000000000
--- a/contrib/tools/python/src/PC/generrmap.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-
-/* Extract the mapping of Win32 error codes to errno */
-
-int main()
-{
- int i;
- printf("/* Generated file. Do not edit. */\n");
- printf("int winerror_to_errno(int winerror)\n");
- printf("{\n\tswitch(winerror) {\n");
- for(i=1; i < 65000; i++) {
- _dosmaperr(i);
- if (errno == EINVAL)
- continue;
- printf("\t\tcase %d: return %d;\n", i, errno);
- }
- printf("\t\tdefault: return EINVAL;\n");
- printf("\t}\n}\n");
-}
diff --git a/contrib/tools/python/src/PC/icons.mak b/contrib/tools/python/src/PC/icons.mak
deleted file mode 100644
index 4a132c918b4..00000000000
--- a/contrib/tools/python/src/PC/icons.mak
+++ /dev/null
@@ -1,9 +0,0 @@
-python_icon.exe: py.res empty.obj
- link /out:python_icon.exe /machine:x86 /subsystem:windows py.res empty.obj
-
-py.res: py.ico pyc.ico pycon.ico icons.rc
- rc /fo py.res icons.rc
-
-empty.obj: empty.c
- cl /c empty.c
-
diff --git a/contrib/tools/python/src/PC/icons.rc b/contrib/tools/python/src/PC/icons.rc
deleted file mode 100644
index d0b44105c00..00000000000
--- a/contrib/tools/python/src/PC/icons.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-101 ICON "py.ico"
-102 ICON "pyc.ico"
-103 ICON "pycon.ico"
-
diff --git a/contrib/tools/python/src/PC/make_versioninfo.c b/contrib/tools/python/src/PC/make_versioninfo.c
deleted file mode 100644
index e9696713517..00000000000
--- a/contrib/tools/python/src/PC/make_versioninfo.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <stdio.h>
-#include "patchlevel.h"
-/*
- * This program prints out an include file containing fields required to build
- * the version info resource of pythonxx.dll because the resource compiler
- * cannot do the arithmetic.
- */
-/*
- * FIELD3 is the third field of the version number.
- * This is what we'd like FIELD3 to be:
- *
- * #define FIELD3 (PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL)
- *
- * but that neither gives an error nor comes anywhere close to working.
- *
- * For 2.4a0,
- * PY_MICRO_VERSION = 0
- * PY_RELEASE_LEVEL = 'alpha' = 0xa
- * PY_RELEASE_SERIAL = 0
- *
- * gives FIELD3 = 0*1000 + 10*10 + 0 = 100
- */
-int main(int argc, char **argv)
-{
- printf("/* This file created by make_versioninfo.exe */\n");
- printf("#define FIELD3 %d\n",
- PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL);
- printf("#define MS_DLL_ID \"%d.%d\"\n",
- PY_MAJOR_VERSION, PY_MINOR_VERSION);
- printf("#ifndef _DEBUG\n");
- printf("#define PYTHON_DLL_NAME \"python%d%d.dll\"\n",
- PY_MAJOR_VERSION, PY_MINOR_VERSION);
- printf("#else\n");
- printf("#define PYTHON_DLL_NAME \"python%d%d_d.dll\"\n",
- PY_MAJOR_VERSION, PY_MINOR_VERSION);
- printf("#endif\n");
- return 0;
-}
diff --git a/contrib/tools/python/src/PC/py.ico b/contrib/tools/python/src/PC/py.ico
deleted file mode 100644
index 3357aef1488..00000000000
--- a/contrib/tools/python/src/PC/py.ico
+++ /dev/null
Binary files differ
diff --git a/contrib/tools/python/src/PC/pyc.ico b/contrib/tools/python/src/PC/pyc.ico
deleted file mode 100644
index f7bd2b1cc23..00000000000
--- a/contrib/tools/python/src/PC/pyc.ico
+++ /dev/null
Binary files differ
diff --git a/contrib/tools/python/src/PC/pycon.ico b/contrib/tools/python/src/PC/pycon.ico
deleted file mode 100644
index 1ab629eff26..00000000000
--- a/contrib/tools/python/src/PC/pycon.ico
+++ /dev/null
Binary files differ
diff --git a/contrib/tools/python/src/PC/python.mk b/contrib/tools/python/src/PC/python.mk
deleted file mode 100644
index 5f66eb980a4..00000000000
--- a/contrib/tools/python/src/PC/python.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-project : n:\python\python-1.5.1\pc\wat_os2\pyth_os2.exe n:\python\python-1.&
-5.1\pc\wat_dos\pyth_dos.exe .SYMBOLIC
-
-!include n:\python\python-1.5.1\pc\wat_os2\pyth_os2.mk1
-!include n:\python\python-1.5.1\pc\wat_dos\pyth_dos.mk1
diff --git a/contrib/tools/python/src/PC/python_exe.rc b/contrib/tools/python/src/PC/python_exe.rc
deleted file mode 100644
index 14e2574377b..00000000000
--- a/contrib/tools/python/src/PC/python_exe.rc
+++ /dev/null
@@ -1 +0,0 @@
-1 ICON DISCARDABLE "pycon.ico"
diff --git a/contrib/tools/python/src/PC/python_nt.rc b/contrib/tools/python/src/PC/python_nt.rc
deleted file mode 100644
index 2b2be3c7b5f..00000000000
--- a/contrib/tools/python/src/PC/python_nt.rc
+++ /dev/null
@@ -1,74 +0,0 @@
-// Resource script for Python core DLL.
-// Currently only holds version information.
-//
-#include "winver.h"
-
-#define MS_WINDOWS
-#include "modsupport.h"
-#include "patchlevel.h"
-#ifdef _DEBUG
-# include "pythonnt_rc_d.h"
-#else
-# include "pythonnt_rc.h"
-#endif
-
-/* e.g., 2.1a2
- * PY_VERSION comes from patchevel.h
- */
-#define PYTHON_VERSION PY_VERSION "\0"
-
-/* 64-bit version number as comma-separated list of 4 16-bit ints */
-#if PY_MICRO_VERSION > 64
-# error "PY_MICRO_VERSION > 64"
-#endif
-#if PY_RELEASE_LEVEL > 99
-# error "PY_RELEASE_LEVEL > 99"
-#endif
-#if PY_RELEASE_SERIAL > 9
-# error "PY_RELEASE_SERIAL > 9"
-#endif
-#define PYVERSION64 PY_MAJOR_VERSION, PY_MINOR_VERSION, FIELD3, PYTHON_API_VERSION
-
-// String Tables
-STRINGTABLE DISCARDABLE
-BEGIN
- 1000, MS_DLL_ID
-END
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION PYVERSION64
- PRODUCTVERSION PYVERSION64
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x40004L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "000004b0"
- BEGIN
- VALUE "CompanyName", "Python Software Foundation\0"
- VALUE "FileDescription", "Python Core\0"
- VALUE "FileVersion", PYTHON_VERSION
- VALUE "InternalName", "Python DLL\0"
- VALUE "LegalCopyright", "Copyright � 2001-2017 Python Software Foundation. Copyright � 2000 BeOpen.com. Copyright � 1995-2001 CNRI. Copyright � 1991-1995 SMC.\0"
- VALUE "OriginalFilename", PYTHON_DLL_NAME "\0"
- VALUE "ProductName", "Python\0"
- VALUE "ProductVersion", PYTHON_VERSION
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0, 1200
- END
-END
diff --git a/contrib/tools/python/src/PC/readme.txt b/contrib/tools/python/src/PC/readme.txt
deleted file mode 100644
index 9206bbb1634..00000000000
--- a/contrib/tools/python/src/PC/readme.txt
+++ /dev/null
@@ -1,99 +0,0 @@
-Welcome to the "PC" subdirectory of the Python distribution
-***********************************************************
-
-This "PC" subdirectory contains complete project files to make
-several older PC ports of Python, as well as all the PC-specific
-Python source files. It should be located in the root of the
-Python distribution, and there should be directories "Modules",
-"Objects", "Python", etc. in the parent directory of this "PC"
-subdirectory. Be sure to read the documentation in the Python
-distribution.
-
-Python requires library files such as string.py to be available in
-one or more library directories. The search path of libraries is
-set up when Python starts. To see the current Python library search
-path, start Python and enter "import sys" and "print sys.path".
-
-All PC ports use this scheme to try to set up a module search path:
-
- 1) The script location; the current directory without script.
- 2) The PYTHONPATH variable, if set.
- 3) For Win32 platforms (NT/95), paths specified in the Registry.
- 4) Default directories lib, lib/win, lib/test, lib/tkinter;
- these are searched relative to the environment variable
- PYTHONHOME, if set, or relative to the executable and its
- ancestors, if a landmark file (Lib/string.py) is found ,
- or the current directory (not useful).
- 5) The directory containing the executable.
-
-The best installation strategy is to put the Python executable (and
-DLL, for Win32 platforms) in some convenient directory such as
-C:/python, and copy all library files and subdirectories (using XCOPY)
-to C:/python/lib. Then you don't need to set PYTHONPATH. Otherwise,
-set the environment variable PYTHONPATH to your Python search path.
-For example,
- set PYTHONPATH=.;d:\python\lib;d:\python\lib\win;d:\python\lib\dos-8x3
-
-There are several add-in modules to build Python programs which use
-the native Windows operating environment. The ports here just make
-"QuickWin" and DOS Python versions which support a character-mode
-(console) environment. Look in www.python.org for Tkinter, PythonWin,
-WPY and wxPython.
-
-To make a Python port, start the Integrated Development Environment
-(IDE) of your compiler, and read in the native "project file"
-(or makefile) provided. This will enable you to change any source
-files or build settings so you can make custom builds.
-
-pyconfig.h An important configuration file specific to PC's.
-
-config.c The list of C modules to include in the Python PC
- version. Manually edit this file to add or
- remove Python modules.
-
-testpy.py A Python test program. Run this to test your
- Python port. It should produce copious output,
- ending in a report on how many tests were OK, how many
- failed, and how many were skipped. Don't worry about
- skipped tests (these test unavailable optional features).
-
-
-Additional files and subdirectories for 32-bit Windows
-======================================================
-
-python_nt.rc Resource compiler input for python15.dll.
-
-dl_nt.c, import_nt.c
- Additional sources used for 32-bit Windows features.
-
-getpathp.c Default sys.path calculations (for all PC platforms).
-
-dllbase_nt.txt A (manually maintained) list of base addresses for
- various DLLs, to avoid run-time relocation.
-
-
-Legacy support for older versions of Visual Studio
-==================================================
-The subdirectories VC6, VS7.1 and VS8.0 contain legacy support older
-versions of Microsoft Visual Studio. See PCbuild/readme.txt.
-
-EMX development tools for OS/2
-==============================
-
-See os2emx/readme.txt. This platform is maintained by Andrew MacIntyre.
-
-IBM VisualAge C/C++ for OS/2
-============================
-
-See os2vacpp/readme.txt. This platform is supported by Jeff Rush.
-
-NOTE: Support for os2vacpp may be dropped in the near future. Please move
- to EMX.
-
-Note for Windows 3.x and DOS users
-==================================
-
-Neither Windows 3.x nor DOS is supported any more. The last Python
-version that supported these was Python 1.5.2; the support files were
-present in Python 2.0 but weren't updated, and it is not our intention
-to support these platforms for Python 2.x.
diff --git a/contrib/tools/python/src/PC/testpy.py b/contrib/tools/python/src/PC/testpy.py
deleted file mode 100644
index 78ad63ca429..00000000000
--- a/contrib/tools/python/src/PC/testpy.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import sys
-
-# This is a test module for Python. It looks in the standard
-# places for various *.py files. If these are moved, you must
-# change this module too.
-
-try:
- import os
-except:
- print """Could not import the standard "os" module.
- Please check your PYTHONPATH environment variable."""
- sys.exit(1)
-
-try:
- import symbol
-except:
- print """Could not import the standard "symbol" module. If this is
- a PC, you should add the dos_8x3 directory to your PYTHONPATH."""
- sys.exit(1)
-
-import os
-
-for dir in sys.path:
- file = os.path.join(dir, "os.py")
- if os.path.isfile(file):
- test = os.path.join(dir, "test")
- if os.path.isdir(test):
- # Add the "test" directory to PYTHONPATH.
- sys.path = sys.path + [test]
-
-import regrtest # Standard Python tester.
-regrtest.main()
diff --git a/contrib/tools/python/src/PC/w9xpopen.c b/contrib/tools/python/src/PC/w9xpopen.c
deleted file mode 100644
index b3978dd42d9..00000000000
--- a/contrib/tools/python/src/PC/w9xpopen.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * w9xpopen.c
- *
- * Serves as an intermediate stub Win32 console application to
- * avoid a hanging pipe when redirecting 16-bit console based
- * programs (including MS-DOS console based programs and batch
- * files) on Window 95 and Windows 98.
- *
- * This program is to be launched with redirected standard
- * handles. It will launch the command line specified 16-bit
- * console based application in the same console, forwarding
- * its own redirected standard handles to the 16-bit child.
-
- * AKA solution to the problem described in KB: Q150956.
- */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h> /* for malloc and its friends */
-
-const char *usage =
-"This program is used by Python's os.popen function\n"
-"to work around a limitation in Windows 95/98. It is\n"
-"not designed to be used as a stand-alone program.";
-
-int main(int argc, char *argv[])
-{
- BOOL bRet;
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- DWORD exit_code=0;
- size_t cmdlen = 0;
- int i;
- char *cmdline, *cmdlinefill;
-
- if (argc < 2) {
- if (GetFileType(GetStdHandle(STD_INPUT_HANDLE))==FILE_TYPE_CHAR)
- /* Attached to a console, and therefore not executed by Python
- Display a message box for the inquisitive user
- */
- MessageBox(NULL, usage, argv[0], MB_OK);
- else {
- /* Eeek - executed by Python, but args are screwed!
- Write an error message to stdout so there is at
- least some clue for the end user when it appears
- in their output.
- A message box would be hidden and blocks the app.
- */
- fprintf(stdout, "Internal popen error - no args specified\n%s\n", usage);
- }
- return 1;
- }
- /* Build up the command-line from the args.
- Args with a space are quoted, existing quotes are escaped.
- To keep things simple calculating the buffer size, we assume
- every character is a quote - ie, we allocate double what we need
- in the worst case. As this is only double the command line passed
- to us, there is a good chance this is reasonably small, so the total
- allocation will almost always be < 512 bytes.
- */
- for (i=1;i<argc;i++)
- cmdlen += strlen(argv[i])*2 + 3; /* one space, maybe 2 quotes */
- cmdline = cmdlinefill = (char *)malloc(cmdlen+1);
- if (cmdline == NULL)
- return -1;
- for (i=1;i<argc;i++) {
- const char *arglook;
- int bQuote = strchr(argv[i], ' ') != NULL;
- if (bQuote)
- *cmdlinefill++ = '"';
- /* escape quotes */
- for (arglook=argv[i];*arglook;arglook++) {
- if (*arglook=='"')
- *cmdlinefill++ = '\\';
- *cmdlinefill++ = *arglook;
- }
- if (bQuote)
- *cmdlinefill++ = '"';
- *cmdlinefill++ = ' ';
- }
- *cmdlinefill = '\0';
-
- /* Make child process use this app's standard files. */
- ZeroMemory(&si, sizeof si);
- si.cb = sizeof si;
- si.dwFlags = STARTF_USESTDHANDLES;
- si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
- si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
- si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
-
- bRet = CreateProcess(
- NULL, cmdline,
- NULL, NULL,
- TRUE, 0,
- NULL, NULL,
- &si, &pi
- );
-
- free(cmdline);
-
- if (bRet) {
- if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_FAILED) {
- GetExitCodeProcess(pi.hProcess, &exit_code);
- }
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- return exit_code;
- }
-
- return 1;
-}
diff --git a/contrib/tools/python/src/PC/winsound.c b/contrib/tools/python/src/PC/winsound.c
deleted file mode 100644
index f3c5be4e887..00000000000
--- a/contrib/tools/python/src/PC/winsound.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* Author: Toby Dickenson <[email protected]>
- *
- * Copyright (c) 1999 Toby Dickenson
- *
- * Permission to use this software in any way is granted without
- * fee, provided that the copyright notice above appears in all
- * copies. This software is provided "as is" without any warranty.
- */
-
-/* Modified by Guido van Rossum */
-/* Beep added by Mark Hammond */
-/* Win9X Beep and platform identification added by Uncle Timmy */
-
-/* Example:
-
- import winsound
- import time
-
- # Play wav file
- winsound.PlaySound('c:/windows/media/Chord.wav', winsound.SND_FILENAME)
-
- # Play sound from control panel settings
- winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
-
- # Play wav file from memory
- data=open('c:/windows/media/Chimes.wav',"rb").read()
- winsound.PlaySound(data, winsound.SND_MEMORY)
-
- # Start playing the first bit of wav file asynchronously
- winsound.PlaySound('c:/windows/media/Chord.wav',
- winsound.SND_FILENAME|winsound.SND_ASYNC)
- # But dont let it go for too long...
- time.sleep(0.1)
- # ...Before stopping it
- winsound.PlaySound(None, 0)
-*/
-
-#include <Python.h>
-#include <windows.h>
-#include <mmsystem.h>
-
-PyDoc_STRVAR(sound_playsound_doc,
-"PlaySound(sound, flags) - a wrapper around the Windows PlaySound API\n"
-"\n"
-"The sound argument can be a filename, data, or None.\n"
-"For flag values, ored together, see module documentation.");
-
-PyDoc_STRVAR(sound_beep_doc,
-"Beep(frequency, duration) - a wrapper around the Windows Beep API\n"
-"\n"
-"The frequency argument specifies frequency, in hertz, of the sound.\n"
-"This parameter must be in the range 37 through 32,767.\n"
-"The duration argument specifies the number of milliseconds.\n");
-
-PyDoc_STRVAR(sound_msgbeep_doc,
-"MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.");
-
-PyDoc_STRVAR(sound_module_doc,
-"PlaySound(sound, flags) - play a sound\n"
-"SND_FILENAME - sound is a wav file name\n"
-"SND_ALIAS - sound is a registry sound association name\n"
-"SND_LOOP - Play the sound repeatedly; must also specify SND_ASYNC\n"
-"SND_MEMORY - sound is a memory image of a wav file\n"
-"SND_PURGE - stop all instances of the specified sound\n"
-"SND_ASYNC - PlaySound returns immediately\n"
-"SND_NODEFAULT - Do not play a default beep if the sound can not be found\n"
-"SND_NOSTOP - Do not interrupt any sounds currently playing\n" // Raising RuntimeError if needed
-"SND_NOWAIT - Return immediately if the sound driver is busy\n" // Without any errors
-"\n"
-"Beep(frequency, duration) - Make a beep through the PC speaker.");
-
-static PyObject *
-sound_playsound(PyObject *s, PyObject *args)
-{
- const char *sound;
- int flags;
- int length;
- int ok;
-
- if (!PyArg_ParseTuple(args, "z#i:PlaySound", &sound, &length, &flags)) {
- return NULL;
- }
-
- if (flags & SND_ASYNC && flags & SND_MEMORY) {
- /* Sidestep reference counting headache; unfortunately this also
- prevent SND_LOOP from memory. */
- PyErr_SetString(PyExc_RuntimeError, "Cannot play asynchronously from memory");
- return NULL;
- }
-
- Py_BEGIN_ALLOW_THREADS
- ok = PlaySound(sound, NULL, flags);
- Py_END_ALLOW_THREADS
- if (!ok) {
- PyErr_SetString(PyExc_RuntimeError, "Failed to play sound");
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-sound_beep(PyObject *self, PyObject *args)
-{
- int freq;
- int dur;
- BOOL ok;
-
- if (!PyArg_ParseTuple(args, "ii:Beep", &freq, &dur))
- return NULL;
-
- if (freq < 37 || freq > 32767) {
- PyErr_SetString(PyExc_ValueError,
- "frequency must be in 37 thru 32767");
- return NULL;
- }
-
- Py_BEGIN_ALLOW_THREADS
- ok = Beep(freq, dur);
- Py_END_ALLOW_THREADS
- if (!ok) {
- PyErr_SetString(PyExc_RuntimeError,"Failed to beep");
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-sound_msgbeep(PyObject *self, PyObject *args)
-{
- int x = MB_OK;
- if (!PyArg_ParseTuple(args, "|i:MessageBeep", &x))
- return NULL;
- MessageBeep(x);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static struct PyMethodDef sound_methods[] =
-{
- {"PlaySound", sound_playsound, METH_VARARGS, sound_playsound_doc},
- {"Beep", sound_beep, METH_VARARGS, sound_beep_doc},
- {"MessageBeep", sound_msgbeep, METH_VARARGS, sound_msgbeep_doc},
- {NULL, NULL}
-};
-
-static void
-add_define(PyObject *dict, const char *key, long value)
-{
- PyObject *k = PyString_FromString(key);
- PyObject *v = PyLong_FromLong(value);
- if (v && k) {
- PyDict_SetItem(dict, k, v);
- }
- Py_XDECREF(k);
- Py_XDECREF(v);
-}
-
-#define ADD_DEFINE(tok) add_define(dict,#tok,tok)
-
-PyMODINIT_FUNC
-initwinsound(void)
-{
- PyObject *dict;
- PyObject *module = Py_InitModule3("winsound",
- sound_methods,
- sound_module_doc);
- if (module == NULL)
- return;
- dict = PyModule_GetDict(module);
-
- ADD_DEFINE(SND_ASYNC);
- ADD_DEFINE(SND_NODEFAULT);
- ADD_DEFINE(SND_NOSTOP);
- ADD_DEFINE(SND_NOWAIT);
- ADD_DEFINE(SND_ALIAS);
- ADD_DEFINE(SND_FILENAME);
- ADD_DEFINE(SND_MEMORY);
- ADD_DEFINE(SND_PURGE);
- ADD_DEFINE(SND_LOOP);
- ADD_DEFINE(SND_APPLICATION);
-
- ADD_DEFINE(MB_OK);
- ADD_DEFINE(MB_ICONASTERISK);
- ADD_DEFINE(MB_ICONEXCLAMATION);
- ADD_DEFINE(MB_ICONHAND);
- ADD_DEFINE(MB_ICONQUESTION);
-}