Comment: | OFWindowsRegistryKey: Compatibility with Win XP
This requires a slight API change to OFWindowsRegistryKey, as the |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
94f1f0f47976e81f80da2e0c384510f9 |
User & Date: | js on 2020-04-21 22:47:25 |
Other Links: | manifest | tags |
2020-04-22
| ||
22:04 | Fix missing cast for AmigaOS check-in: 4edc83ee08 user: js tags: trunk | |
2020-04-21
| ||
22:47 | OFWindowsRegistryKey: Compatibility with Win XP check-in: 94f1f0f479 user: js tags: trunk | |
19:51 | Fix AmigaOS and devkitPro build check-in: d57a77b9cd user: js tags: trunk | |
Modified src/OFConstantString.m from [743f51b49a] to [1a9a1e4686].
︙ | ︙ | |||
670 671 672 673 674 675 676 677 678 679 680 681 682 683 | - (OFString *)decomposedStringWithCompatibilityMapping { [self finishInitialization]; return self.decomposedStringWithCompatibilityMapping; } #endif #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { [self finishInitialization]; [self writeToFile: path]; | > > > > > > > > > | 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | - (OFString *)decomposedStringWithCompatibilityMapping { [self finishInitialization]; return self.decomposedStringWithCompatibilityMapping; } #endif #ifdef OF_WINDOWS - (OFString *)stringByExpandingWindowsEnvironmentStrings { [self finishInitialization]; return self.stringByExpandingWindowsEnvironmentStrings; } #endif #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { [self finishInitialization]; [self writeToFile: path]; |
︙ | ︙ |
Modified src/OFDNSResolverSettings.m from [67fa5dd9c3] to [5313f1e2ca].
︙ | ︙ | |||
481 482 483 484 485 486 487 | pool = objc_autoreleasePoolPush(); [self setDefaults]; #if defined(OF_WINDOWS) # ifdef OF_HAVE_FILES | | < | | > > | > | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | pool = objc_autoreleasePoolPush(); [self setDefaults]; #if defined(OF_WINDOWS) # ifdef OF_HAVE_FILES OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey] openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters" securityAndAccessRights: KEY_QUERY_VALUE]; path = [[[key stringForValue: @"DataBasePath"] stringByAppendingPathComponent: @"hosts"] stringByExpandingWindowsEnvironmentStrings]; if (path != nil) [self parseHosts: path]; # endif [self obtainWindowsSystemConfig]; #elif defined(OF_AMIGAOS4) |
︙ | ︙ |
Modified src/OFString.h from [8801d5dd21] to [18fc9bbd71].
︙ | ︙ | |||
283 284 285 286 287 288 289 290 291 292 293 294 295 296 | /*! * @brief The string in Unicode Normalization Form KD (NFKD). */ @property (readonly, nonatomic) OFString *decomposedStringWithCompatibilityMapping; # endif /*! * @brief Creates a new OFString. * * @return A new, autoreleased OFString */ + (instancetype)string; | > > > > > > > > | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | /*! * @brief The string in Unicode Normalization Form KD (NFKD). */ @property (readonly, nonatomic) OFString *decomposedStringWithCompatibilityMapping; # endif # ifdef OF_WINDOWS /*! * @brief The string with the Windows Environment Strings expanded. */ @property (readonly, nonatomic) OFString *stringByExpandingWindowsEnvironmentStrings; # endif /*! * @brief Creates a new OFString. * * @return A new, autoreleased OFString */ + (instancetype)string; |
︙ | ︙ |
Modified src/OFString.m from [1cad4eddab] to [1a087004fb].
︙ | ︙ | |||
2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 | - (OFString *)decomposedStringWithCompatibilityMapping { return decomposedString(self, of_unicode_decomposition_compat_table, OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE); } #endif #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { [self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8]; } | > > > > > > > > > > > > > > > | 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 | - (OFString *)decomposedStringWithCompatibilityMapping { return decomposedString(self, of_unicode_decomposition_compat_table, OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE); } #endif #ifdef OF_WINDOWS - (OFString *)stringByExpandingWindowsEnvironmentStrings { wchar_t buffer[512]; size_t length; if ((length = ExpandEnvironmentStringsW(self.UTF16String, buffer, sizeof(buffer))) == 0) return self; return [OFString stringWithUTF16String: buffer length: length - 1]; } #endif #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { [self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8]; } |
︙ | ︙ |
Modified src/OFWindowsRegistryKey.h from [e667684d2c] to [1bed1bb2f4].
︙ | ︙ | |||
128 129 130 131 132 133 134 | * `lpdwDisposition`. * @return The subkey with the specified path */ - (OFWindowsRegistryKey *) createSubkeyAtPath: (OFString *)path options: (DWORD)options securityAndAccessRights: (REGSAM)securityAndAccessRights | | | < < < < | < | < < < < < | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | * `lpdwDisposition`. * @return The subkey with the specified path */ - (OFWindowsRegistryKey *) createSubkeyAtPath: (OFString *)path options: (DWORD)options securityAndAccessRights: (REGSAM)securityAndAccessRights securityAttributes: (nullable SECURITY_ATTRIBUTES *)securityAttributes disposition: (nullable DWORD *)disposition; /*! * @brief Returns the data for the specified value at the specified path. * * @param value The name of the value to return * @param type A pointer to store the type of the value, or NULL * @return The data for the specified value */ - (nullable OFData *)dataForValue: (nullable OFString *)value type: (nullable DWORD *)type; /*! * @brief Sets the data for the specified value. * * @param data The data to set the value to * @param value The name of the value to set * @param type The type for the value */ - (void)setData: (nullable OFData *)data forValue: (nullable OFString *)value type: (DWORD)type; /*! * @brief Returns the string for the specified value at the specified path. * * @param value The name of the value to return * @return The string for the specified value */ - (nullable OFString *)stringForValue: (nullable OFString *)value; /*! * @brief Returns the string for the specified value at the specified path. * * @param value The name of the value to return * @param type A pointer to store the type of the value, or NULL * @return The string for the specified value */ - (nullable OFString *)stringForValue: (nullable OFString *)value type: (nullable DWORD *)type; /*! * @brief Sets the string for the specified value. * * @param string The string to set the value to * @param value The name of the value to set */ |
︙ | ︙ |
Modified src/OFWindowsRegistryKey.m from [c6d5abaa71] to [752886f486].
︙ | ︙ | |||
165 166 167 168 169 170 171 | return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey close: true] autorelease]; } - (OFData *)dataForValue: (OFString *)value | < < | | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey close: true] autorelease]; } - (OFData *)dataForValue: (OFString *)value type: (LPDWORD)type { void *pool = objc_autoreleasePoolPush(); BYTE stackBuffer[256], *buffer = stackBuffer; DWORD length = sizeof(stackBuffer); OFMutableData *ret = nil; LSTATUS status; for (;;) { status = RegQueryValueExW(_hKey, value.UTF16String, NULL, type, buffer, &length); switch (status) { case ERROR_SUCCESS: if (buffer == stackBuffer) { objc_autoreleasePoolPop(pool); return [OFData dataWithItems: buffer |
︙ | ︙ | |||
211 212 213 214 215 216 217 | buffer = ret.mutableItems; continue; default: @throw [OFGetWindowsRegistryValueFailedException exceptionWithRegistryKey: self value: value | < < | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | buffer = ret.mutableItems; continue; default: @throw [OFGetWindowsRegistryValueFailedException exceptionWithRegistryKey: self value: value status: status]; } } } - (void)setData: (OFData *)data forValue: (OFString *)value |
︙ | ︙ | |||
239 240 241 242 243 244 245 | value: value data: data type: type status: status]; } - (OFString *)stringForValue: (OFString *)value | < < < < < < < | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | value: value data: data type: type status: status]; } - (OFString *)stringForValue: (OFString *)value { return [self stringForValue: value type: NULL]; } - (OFString *)stringForValue: (OFString *)value type: (LPDWORD)type { void *pool = objc_autoreleasePoolPush(); OFData *data = [self dataForValue: value type: type]; const of_char16_t *UTF16String; size_t length; OFString *ret; if (data == nil) return nil; |
︙ | ︙ |
Modified src/exceptions/OFGetWindowsRegistryValueFailedException.h from [d8a164b776] to [f3d99ecbde].
︙ | ︙ | |||
28 29 30 31 32 33 34 | * ObjFW/OFGetWindowsRegistryValueFailedException.h * * @brief An exception indicating that getting a Windows registry value failed. */ @interface OFGetWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; | | < < < < < < < < < < < < < < < < < < | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | * ObjFW/OFGetWindowsRegistryValueFailedException.h * * @brief An exception indicating that getting a Windows registry value failed. */ @interface OFGetWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; OFString *_Nullable _value; DWORD _flags; LSTATUS _status; } /*! * @brief The registry key on which getting the value at the key path failed. */ @property (readonly, nonatomic) OFWindowsRegistryKey *registryKey; /*! * @brief The value which could not be retrieved. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *value; /*! * @brief The status returned by RegGetValueEx(). */ @property (readonly, nonatomic) LSTATUS status; /*! * @brief Creates a new, autoreleased get Windows registry value failed * exception. * * @param registryKey The registry key on which getting the value at the sub * key path failed * @param value The value which could not be retrieved * @param status The status returned by RegGetValueEx() * @return A new, autoreleased get Windows registry value failed exception */ + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey value: (nullable OFString *)value status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated get Windows registry value failed * exception. * * @param registryKey The registry key on which getting the value at the sub * key path failed * @param value The value which could not be retrieved * @param status The status returned by RegGetValueEx() * @return An initialized get Windows registry value failed exception */ - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey value: (nullable OFString *)value status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFGetWindowsRegistryValueFailedException.m from [3f3297c06e] to [1c37f45def].
︙ | ︙ | |||
16 17 18 19 20 21 22 | */ #include "config.h" #import "OFGetWindowsRegistryValueFailedException.h" @implementation OFGetWindowsRegistryValueFailedException | | < < < < < < < < < < | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | */ #include "config.h" #import "OFGetWindowsRegistryValueFailedException.h" @implementation OFGetWindowsRegistryValueFailedException @synthesize registryKey = _registryKey, value = _value, status = _status; + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey value: (OFString *)value status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey value: value status: status] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey value: (OFString *)value status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; _value = [value copy]; _status = status; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_registryKey release]; [_value release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to get value %@: %@", _value, of_windows_status_to_string(_status)]; } @end |
Modified tests/OFWindowsRegistryKeyTests.m from [d53759aab6] to [814a5cca52].
︙ | ︙ | |||
25 26 27 28 29 30 31 | - (void)windowsRegistryKeyTests { void *pool = objc_autoreleasePoolPush(); OFData *data = [OFData dataWithItems: "abcdef" count: 6]; OFWindowsRegistryKey *softwareKey, *ObjFWKey; DWORD type; | < | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | - (void)windowsRegistryKeyTests { void *pool = objc_autoreleasePoolPush(); OFData *data = [OFData dataWithItems: "abcdef" count: 6]; OFWindowsRegistryKey *softwareKey, *ObjFWKey; DWORD type; TEST(@"+[OFWindowsRegistryKey classesRootKey]", [OFWindowsRegistryKey classesRootKey]) TEST(@"+[OFWindowsRegistryKey currentConfigKey]", [OFWindowsRegistryKey currentConfigKey]) |
︙ | ︙ | |||
60 61 62 63 64 65 66 | TEST(@"-[setData:forValue:type:]", R([ObjFWKey setData: data forValue: @"data" type: REG_BINARY])) TEST(@"-[dataForValue:subkeyPath:flags:type:]", | | < < | | < | < < | | < < < < | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | TEST(@"-[setData:forValue:type:]", R([ObjFWKey setData: data forValue: @"data" type: REG_BINARY])) TEST(@"-[dataForValue:subkeyPath:flags:type:]", [[ObjFWKey dataForValue: @"data" type: &type] isEqual: data] && type == REG_BINARY) TEST(@"-[setString:forValue:type:]", R([ObjFWKey setString: @"foobar" forValue: @"string"]) && R([ObjFWKey setString: @"%PATH%;foo" forValue: @"expand" type: REG_EXPAND_SZ])) TEST(@"-[stringForValue:subkeyPath:]", [[ObjFWKey stringForValue: @"string"] isEqual: @"foobar"] && [[ObjFWKey stringForValue: @"expand" type: &type] isEqual: @"%PATH%;foo"] && type == REG_EXPAND_SZ) TEST(@"-[deleteValue:]", R([ObjFWKey deleteValue: @"data"])) TEST(@"-[deleteSubkeyAtPath:]", R([softwareKey deleteSubkeyAtPath: @"ObjFW"])) objc_autoreleasePoolPop(pool); } @end |