Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: PC/winreg.c

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « PC/pyconfig.h ('k') | pyconfig.h.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 winreg.c 2 winreg.c
3 3
4 Windows Registry access module for Python. 4 Windows Registry access module for Python.
5 5
6 * Simple registry access written by Mark Hammond in win32api 6 * Simple registry access written by Mark Hammond in win32api
7 module circa 1995. 7 module circa 1995.
8 * Bill Tutt expanded the support significantly not long after. 8 * Bill Tutt expanded the support significantly not long after.
9 * Numerous other people have submitted patches since then. 9 * Numerous other people have submitted patches since then.
10 * Ripped from win32api module 03-Feb-2000 by Mark Hammond, and 10 * Ripped from win32api module 03-Feb-2000 by Mark Hammond, and
11 basic Unicode support added. 11 basic Unicode support added.
12 12
13 */ 13 */
14 14
15 #include "Python.h" 15 #include "Python.h"
16 #include "structmember.h" 16 #include "structmember.h"
17 #include "windows.h" 17 #include "windows.h"
18
19 #if defined(__MINGW32__)
20 _CRTIMP size_t __cdecl __MINGW_NOTHROW _mbstrlen(const char *s);
21 #endif
22
23 #if !defined(REG_LEGAL_CHANGE_FILTER)
24 #define REG_LEGAL_CHANGE_FILTER \
25 (REG_NOTIFY_CHANGE_NAME |\
26 REG_NOTIFY_CHANGE_ATTRIBUTES |\
27 REG_NOTIFY_CHANGE_LAST_SET |\
28 REG_NOTIFY_CHANGE_SECURITY)
29 #endif
18 30
19 static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); 31 static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK);
20 static PyObject *PyHKEY_FromHKEY(HKEY h); 32 static PyObject *PyHKEY_FromHKEY(HKEY h);
21 static BOOL PyHKEY_Close(PyObject *obHandle); 33 static BOOL PyHKEY_Close(PyObject *obHandle);
22 34
23 static char errNotAHandle[] = "Object is not a handle"; 35 static char errNotAHandle[] = "Object is not a handle";
24 36
25 /* The win32api module reports the function name that failed, 37 /* The win32api module reports the function name that failed,
26 but this concept is not in the Python core. 38 but this concept is not in the Python core.
27 Hopefully it will one day, and in the meantime I dont 39 Hopefully it will one day, and in the meantime I dont
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 rc = RegDeleteKeyW(hKey, subKey ); 1084 rc = RegDeleteKeyW(hKey, subKey );
1073 if (rc != ERROR_SUCCESS) 1085 if (rc != ERROR_SUCCESS)
1074 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey"); 1086 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey");
1075 Py_INCREF(Py_None); 1087 Py_INCREF(Py_None);
1076 return Py_None; 1088 return Py_None;
1077 } 1089 }
1078 1090
1079 static PyObject * 1091 static PyObject *
1080 PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) 1092 PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs)
1081 { 1093 {
1094 #ifndef KEY_WOW64_64KEY
1095 /* KEY_WOW64_64KEY is defined for _WIN32_WINNT >= 0x0502,
1096 i.e. Windows Server 2003 with SP1, Windows XP with SP2
1097 and not supported on w2k
1098 */
1099 PyErr_SetString(PyExc_NotImplementedError,
1100 "not implemented on this platform");
1101 return NULL;
1102 #else /*def KEY_WOW64_64KEY*/
1082 HKEY hKey; 1103 HKEY hKey;
1083 PyObject *key; 1104 PyObject *key;
1084 HMODULE hMod; 1105 HMODULE hMod;
1085 typedef LONG (WINAPI *RDKEFunc)(HKEY, const wchar_t*, REGSAM, int); 1106 typedef LONG (WINAPI *RDKEFunc)(HKEY, const wchar_t*, REGSAM, int);
1086 RDKEFunc pfn = NULL; 1107 RDKEFunc pfn = NULL;
1087 wchar_t *sub_key; 1108 wchar_t *sub_key;
1088 long rc; 1109 long rc;
1089 int reserved = 0; 1110 int reserved = 0;
1090 REGSAM access = KEY_WOW64_64KEY; 1111 REGSAM access = KEY_WOW64_64KEY;
1091 1112
(...skipping 16 matching lines...) Expand all
1108 return NULL; 1129 return NULL;
1109 } 1130 }
1110 Py_BEGIN_ALLOW_THREADS 1131 Py_BEGIN_ALLOW_THREADS
1111 rc = (*pfn)(hKey, sub_key, access, reserved); 1132 rc = (*pfn)(hKey, sub_key, access, reserved);
1112 Py_END_ALLOW_THREADS 1133 Py_END_ALLOW_THREADS
1113 1134
1114 if (rc != ERROR_SUCCESS) 1135 if (rc != ERROR_SUCCESS)
1115 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx"); 1136 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx");
1116 Py_INCREF(Py_None); 1137 Py_INCREF(Py_None);
1117 return Py_None; 1138 return Py_None;
1139 #endif
1118 } 1140 }
1119 1141
1120 static PyObject * 1142 static PyObject *
1121 PyDeleteValue(PyObject *self, PyObject *args) 1143 PyDeleteValue(PyObject *self, PyObject *args)
1122 { 1144 {
1123 HKEY hKey; 1145 HKEY hKey;
1124 PyObject *obKey; 1146 PyObject *obKey;
1125 wchar_t *subKey; 1147 wchar_t *subKey;
1126 long rc; 1148 long rc;
1127 if (!PyArg_ParseTuple(args, "OZ:DeleteValue", &obKey, &subKey)) 1149 if (!PyArg_ParseTuple(args, "OZ:DeleteValue", &obKey, &subKey))
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 ADD_INT(REG_DWORD_BIG_ENDIAN); 1875 ADD_INT(REG_DWORD_BIG_ENDIAN);
1854 ADD_INT(REG_LINK); 1876 ADD_INT(REG_LINK);
1855 ADD_INT(REG_MULTI_SZ); 1877 ADD_INT(REG_MULTI_SZ);
1856 ADD_INT(REG_RESOURCE_LIST); 1878 ADD_INT(REG_RESOURCE_LIST);
1857 ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR); 1879 ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR);
1858 ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST); 1880 ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST);
1859 return m; 1881 return m;
1860 } 1882 }
1861 1883
1862 1884
OLDNEW
« no previous file with comments | « PC/pyconfig.h ('k') | pyconfig.h.in » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+