Index: src/OFDNSResolverSettings.m ================================================================== --- src/OFDNSResolverSettings.m +++ src/OFDNSResolverSettings.m @@ -619,11 +619,11 @@ # ifdef OF_HAVE_FILES OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey] openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters" securityAndAccessRights: KEY_QUERY_VALUE]; - path = [[[key stringForValue: @"DataBasePath"] + path = [[[key stringForValueNamed: @"DataBasePath"] stringByAppendingPathComponent: @"hosts"] stringByExpandingWindowsEnvironmentStrings]; if (path != nil) [self parseHosts: path]; Index: src/OFWindowsRegistryKey.h ================================================================== --- src/OFWindowsRegistryKey.h +++ src/OFWindowsRegistryKey.h @@ -134,72 +134,72 @@ 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 - */ -- (void)setString: (nullable OFString *)string - forValue: (nullable OFString *)value; - -/** - * @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 - * @param type The type for the value - */ -- (void)setString: (nullable OFString *)string - forValue: (nullable OFString *)value - type: (DWORD)type; - -/** - * @brief Deletes the specified value. - * - * @param value The value to delete - */ -- (void)deleteValue: (nullable OFString *)value; + * @param name 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 *)dataForValueNamed: (nullable OFString *)name + type: (nullable DWORD *)type; + +/** + * @brief Sets the data for the specified value. + * + * @param data The data to set the value to + * @param name The name of the value to set + * @param type The type for the value + */ +- (void)setData: (nullable OFData *)data + forValueNamed: (nullable OFString *)name + type: (DWORD)type; + +/** + * @brief Returns the string for the specified value at the specified path. + * + * @param name The name of the value to return + * @return The string for the specified value + */ +- (nullable OFString *)stringForValueNamed: (nullable OFString *)name; + +/** + * @brief Returns the string for the specified value at the specified path. + * + * @param name 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 *)stringForValueNamed: (nullable OFString *)name + type: (nullable DWORD *)type; + +/** + * @brief Sets the string for the specified value. + * + * @param string The string to set the value to + * @param name The name of the value to set + */ +- (void)setString: (nullable OFString *)string + forValueNamed: (nullable OFString *)name; + +/** + * @brief Sets the string for the specified value. + * + * @param string The string to set the value to + * @param name The name of the value to set + * @param type The type for the value + */ +- (void)setString: (nullable OFString *)string + forValueNamed: (nullable OFString *)name + type: (DWORD)type; + +/** + * @brief Deletes the specified value. + * + * @param name The value to delete + */ +- (void)deleteValueNamed: (nullable OFString *)name; /** * @brief Deletes the specified subkey. * * @param subkeyPath The path of the subkey to delete Index: src/OFWindowsRegistryKey.m ================================================================== --- src/OFWindowsRegistryKey.m +++ src/OFWindowsRegistryKey.m @@ -183,12 +183,12 @@ return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey close: true] autorelease]; } -- (OFData *)dataForValue: (OFString *)value - type: (DWORD *)type +- (OFData *)dataForValueNamed: (OFString *)name + type: (DWORD *)type { void *pool = objc_autoreleasePoolPush(); BYTE stackBuffer[256], *buffer = stackBuffer; DWORD length = sizeof(stackBuffer); OFMutableData *ret = nil; @@ -195,15 +195,15 @@ bool winNT = [OFSystemInfo isWindowsNT]; LSTATUS status; for (;;) { if (winNT) - status = RegQueryValueExW(_hKey, value.UTF16String, + status = RegQueryValueExW(_hKey, name.UTF16String, NULL, type, buffer, &length); else status = RegQueryValueExA(_hKey, - [value cStringWithEncoding: [OFLocale encoding]], + [name cStringWithEncoding: [OFLocale encoding]], NULL, type, buffer, &length); switch (status) { case ERROR_SUCCESS: if (buffer == stackBuffer) { @@ -233,56 +233,56 @@ continue; default: @throw [OFGetWindowsRegistryValueFailedException exceptionWithRegistryKey: self - value: value + valueName: name status: status]; } } } - (void)setData: (OFData *)data - forValue: (OFString *)value + forValueNamed: (OFString *)name type: (DWORD)type { size_t length = data.count * data.itemSize; LSTATUS status; if (length > UINT32_MAX) @throw [OFOutOfRangeException exception]; if ([OFSystemInfo isWindowsNT]) - status = RegSetValueExW(_hKey, value.UTF16String, 0, type, + status = RegSetValueExW(_hKey, name.UTF16String, 0, type, data.items, (DWORD)length); else status = RegSetValueExA(_hKey, - [value cStringWithEncoding: [OFLocale encoding]], 0, type, + [name cStringWithEncoding: [OFLocale encoding]], 0, type, data.items, (DWORD)length); if (status != ERROR_SUCCESS) @throw [OFSetWindowsRegistryValueFailedException exceptionWithRegistryKey: self - value: value + valueName: name data: data type: type status: status]; } -- (OFString *)stringForValue: (OFString *)value +- (OFString *)stringForValueNamed: (OFString *)name { - return [self stringForValue: value - type: NULL]; + return [self stringForValueNamed: name + type: NULL]; } -- (OFString *)stringForValue: (OFString *)value - type: (DWORD *)typeOut +- (OFString *)stringForValueNamed: (OFString *)name + type: (DWORD *)typeOut { void *pool = objc_autoreleasePoolPush(); DWORD type; - OFData *data = [self dataForValue: value - type: &type]; + OFData *data = [self dataForValueNamed: name + type: &type]; OFString *ret; if (data == nil) return nil; @@ -341,19 +341,19 @@ return [ret autorelease]; } - (void)setString: (OFString *)string - forValue: (OFString *)value + forValueNamed: (OFString *)name { - [self setString: string - forValue: value - type: REG_SZ]; + [self setString: string + forValueNamed: name + type: REG_SZ]; } - (void)setString: (OFString *)string - forValue: (OFString *)value + forValueNamed: (OFString *)name type: (DWORD)type { void *pool = objc_autoreleasePoolPush(); OFData *data; @@ -368,32 +368,32 @@ data = [OFData dataWithItems: cString count: length + 1]; } - [self setData: data - forValue: value - type: type]; + [self setData: data + forValueNamed: name + type: type]; objc_autoreleasePoolPop(pool); } -- (void)deleteValue: (OFString *)value +- (void)deleteValueNamed: (OFString *)name { void *pool = objc_autoreleasePoolPush(); LSTATUS status; if ([OFSystemInfo isWindowsNT]) - status = RegDeleteValueW(_hKey, value.UTF16String); + status = RegDeleteValueW(_hKey, name.UTF16String); else status = RegDeleteValueA(_hKey, - [value cStringWithEncoding: [OFLocale encoding]]); + [name cStringWithEncoding: [OFLocale encoding]]); if (status != ERROR_SUCCESS) @throw [OFDeleteWindowsRegistryValueFailedException exceptionWithRegistryKey: self - value: value + valueName: name status: status]; objc_autoreleasePoolPop(pool); } Index: src/exceptions/OFDeleteWindowsRegistryValueFailedException.h ================================================================== --- src/exceptions/OFDeleteWindowsRegistryValueFailedException.h +++ src/exceptions/OFDeleteWindowsRegistryValueFailedException.h @@ -28,23 +28,23 @@ * @brief An exception indicating that deleting a Windows registry value failed. */ @interface OFDeleteWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; - OFString *_Nullable _value; + OFString *_Nullable _valueName; LSTATUS _status; } /** * @brief The registry key on which deleting the value failed. */ @property (readonly, nonatomic) OFWindowsRegistryKey *registryKey; /** - * @brief The value which could not be deleted. + * @brief The name of the value which could not be deleted. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *value; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *valueName; /** * @brief The status returned by RegDeleteValueEx(). */ @property (readonly, nonatomic) LSTATUS status; @@ -52,30 +52,30 @@ /** * @brief Creates a new, autoreleased delete Windows registry value failed * exception. * * @param registryKey The registry key on which deleting the value failed - * @param value The value which could not be deleted + * @param valueName The name of the value which could not be deleted * @param status The status returned by RegDeleteValueEx() * @return A new, autoreleased delete Windows registry value failed exception */ + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated delete Windows registry value failed * exception. * * @param registryKey The registry key on which deleting the value failed - * @param value The value which could not be deleted + * @param valueName The name of the value which could not be deleted * @param status The status returned by RegDeleteValueEx() * @return An initialized delete Windows registry value failed exception */ - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFDeleteWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFDeleteWindowsRegistryValueFailedException.m +++ src/exceptions/OFDeleteWindowsRegistryValueFailedException.m @@ -18,35 +18,36 @@ #import "OFDeleteWindowsRegistryValueFailedException.h" #import "OFData.h" @implementation OFDeleteWindowsRegistryValueFailedException -@synthesize registryKey = _registryKey, value = _value, status = _status; +@synthesize registryKey = _registryKey, valueName = _valueName; +@synthesize status = _status; + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey - value: value + valueName: valueName status: status] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; - _value = [value copy]; + _valueName = [valueName copy]; _status = status; } @catch (id e) { [self release]; @throw e; } @@ -55,17 +56,17 @@ } - (void)dealloc { [_registryKey release]; - [_value release]; + [_valueName release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: - @"Failed to delete value %@: %@", - _value, of_windows_status_to_string(_status)]; + @"Failed to delete value named %@: %@", + _valueName, of_windows_status_to_string(_status)]; } @end Index: src/exceptions/OFGetWindowsRegistryValueFailedException.h ================================================================== --- src/exceptions/OFGetWindowsRegistryValueFailedException.h +++ src/exceptions/OFGetWindowsRegistryValueFailedException.h @@ -28,11 +28,11 @@ * @brief An exception indicating that getting a Windows registry value failed. */ @interface OFGetWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; - OFString *_Nullable _value; + OFString *_Nullable _valueName; DWORD _flags; LSTATUS _status; } /** @@ -39,13 +39,13 @@ * @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. + * @brief The name of the value which could not be retrieved. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *value; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *valueName; /** * @brief The status returned by RegGetValueEx(). */ @property (readonly, nonatomic) LSTATUS status; @@ -54,16 +54,16 @@ * @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 valueName The name of 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 + valueName: (nullable OFString *)valueName status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; /** @@ -70,15 +70,15 @@ * @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 valueName The name of 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 + valueName: (nullable OFString *)valueName status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFGetWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFGetWindowsRegistryValueFailedException.m +++ src/exceptions/OFGetWindowsRegistryValueFailedException.m @@ -16,35 +16,36 @@ #include "config.h" #import "OFGetWindowsRegistryValueFailedException.h" @implementation OFGetWindowsRegistryValueFailedException -@synthesize registryKey = _registryKey, value = _value, status = _status; +@synthesize registryKey = _registryKey, valueName = _valueName; +@synthesize status = _status; + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey - value: value + valueName: valueName status: status] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; - _value = [value copy]; + _valueName = [valueName copy]; _status = status; } @catch (id e) { [self release]; @throw e; } @@ -53,17 +54,17 @@ } - (void)dealloc { [_registryKey release]; - [_value release]; + [_valueName release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: - @"Failed to get value %@: %@", - _value, of_windows_status_to_string(_status)]; + @"Failed to get value named %@: %@", + _valueName, of_windows_status_to_string(_status)]; } @end Index: src/exceptions/OFSetWindowsRegistryValueFailedException.h ================================================================== --- src/exceptions/OFSetWindowsRegistryValueFailedException.h +++ src/exceptions/OFSetWindowsRegistryValueFailedException.h @@ -28,11 +28,11 @@ * @brief An exception indicating that setting a Windows registry value failed. */ @interface OFSetWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; - OFString *_Nullable _value; + OFString *_Nullable _valueName; OFData *_Nullable _data; DWORD _type; LSTATUS _status; } @@ -40,13 +40,13 @@ * @brief The registry key on which setting the value failed. */ @property (readonly, nonatomic) OFWindowsRegistryKey *registryKey; /** - * @brief The value which could not be set. + * @brief The name of the value which could not be set. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *value; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *valueName; /** * @brief The data to which the value could not be set. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFData *data; @@ -64,18 +64,18 @@ /** * @brief Creates a new, autoreleased set Windows registry value failed * exception. * * @param registryKey The registry key on which setting the value failed - * @param value The value which could not be set + * @param valueName The name of the value which could not be set * @param data The data to which the value could not be set * @param type The type for the value that could not be set * @param status The status returned by RegSetValueEx() * @return A new, autoreleased set Windows registry value failed exception */ + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName data: (nullable OFData *)data type: (DWORD)type status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; @@ -83,19 +83,19 @@ /** * @brief Initializes an already allocated set Windows registry value failed * exception. * * @param registryKey The registry key on which setting the value failed - * @param value The value which could not be set + * @param valueName The name of the value which could not be set * @param data The data to which the value could not be set * @param type The type for the value that could not be set * @param status The status returned by RegSetValueEx() * @return An initialized set Windows registry value failed exception */ - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName data: (nullable OFData *)data type: (DWORD)type status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFSetWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFSetWindowsRegistryValueFailedException.m +++ src/exceptions/OFSetWindowsRegistryValueFailedException.m @@ -18,21 +18,21 @@ #import "OFSetWindowsRegistryValueFailedException.h" #import "OFData.h" @implementation OFSetWindowsRegistryValueFailedException -@synthesize registryKey = _registryKey, value = _value, data = _data; +@synthesize registryKey = _registryKey, valueName = _valueName, data = _data; @synthesize type = _type, status = _status; + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName data: (OFData *)data type: (DWORD)type status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey - value: value + valueName: valueName data: data type: type status: status] autorelease]; } @@ -40,20 +40,20 @@ { OF_INVALID_INIT_METHOD } - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName data: (OFData *)data type: (DWORD)type status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; - _value = [value copy]; + _valueName = [valueName copy]; _data = [data copy]; _type = type; _status = status; } @catch (id e) { [self release]; @@ -64,18 +64,18 @@ } - (void)dealloc { [_registryKey release]; - [_value release]; + [_valueName release]; [_data release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: - @"Failed to set value %@ of type %u: %@", - _value, _type, of_windows_status_to_string(_status)]; + @"Failed to set value named %@ of type %u: %@", + _valueName, _type, of_windows_status_to_string(_status)]; } @end Index: tests/OFWindowsRegistryKeyTests.m ================================================================== --- tests/OFWindowsRegistryKeyTests.m +++ tests/OFWindowsRegistryKeyTests.m @@ -53,36 +53,36 @@ TEST(@"-[createSubkeyAtPath:securityAndAccessRights:]", (ObjFWKey = [softwareKey createSubkeyAtPath: @"ObjFW" securityAndAccessRights: KEY_ALL_ACCESS])) - TEST(@"-[setData:forValue:type:]", + TEST(@"-[setData:forValueNamed:type:]", R([ObjFWKey setData: data - forValue: @"data" + forValueNamed: @"data" type: REG_BINARY])) - TEST(@"-[dataForValue:subkeyPath:flags:type:]", - [[ObjFWKey dataForValue: @"data" - type: &type] isEqual: data] && + TEST(@"-[dataForValueNamed:subkeyPath:flags:type:]", + [[ObjFWKey dataForValueNamed: @"data" + type: &type] isEqual: data] && type == REG_BINARY) - TEST(@"-[setString:forValue:type:]", + TEST(@"-[setString:forValueNamed:type:]", R([ObjFWKey setString: @"foobar" - forValue: @"string"]) && + forValueNamed: @"string"]) && R([ObjFWKey setString: @"%PATH%;foo" - forValue: @"expand" + forValueNamed: @"expand" type: REG_EXPAND_SZ])) TEST(@"-[stringForValue:subkeyPath:]", - [[ObjFWKey stringForValue: @"string"] isEqual: @"foobar"] && - [[ObjFWKey stringForValue: @"expand" - type: &type] isEqual: @"%PATH%;foo"] && + [[ObjFWKey stringForValueNamed: @"string"] isEqual: @"foobar"] && + [[ObjFWKey stringForValueNamed: @"expand" + type: &type] isEqual: @"%PATH%;foo"] && type == REG_EXPAND_SZ) - TEST(@"-[deleteValue:]", R([ObjFWKey deleteValue: @"data"])) + TEST(@"-[deleteValueNamed:]", R([ObjFWKey deleteValueNamed: @"data"])) TEST(@"-[deleteSubkeyAtPath:]", R([softwareKey deleteSubkeyAtPath: @"ObjFW"])) objc_autoreleasePoolPop(pool); } @end