Overview
Context
Changes
Modified src/OFConstantString.m
from [743f51b49a]
to [1a9a1e4686].
︙ | | |
670
671
672
673
674
675
676
677
678
679
680
681
682
683
|
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
488
489
490
491
492
493
494
495
496
497
498
499
|
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
path = [[OFWindowsRegistryKey localMachineKey]
OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey]
stringForValue: @"DataBasePath"
subkeyPath: @"SYSTEM\\CurrentControlSet\\Services\\"
@"Tcpip\\Parameters"];
path = [path stringByAppendingPathComponent: @"hosts"];
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
|
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
|
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
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
183
184
185
186
187
188
189
190
191
192
|
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 LPSECURITY_ATTRIBUTES)securityAttributes
disposition: (nullable LPDWORD)disposition;
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 subkeyPath The path of the key from which to retrieve the value
* @param flags Extra flags for `RegGetValue()`. Usually 0.
* @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
subkeyPath: (nullable OFString *)subkeyPath
flags: (DWORD)flags
type: (nullable LPDWORD)type;
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
* @param subkeyPath The path of the key from which to retrieve the value
* @return The string for the specified value
*/
- (nullable OFString *)stringForValue: (nullable OFString *)value
- (nullable OFString *)stringForValue: (nullable OFString *)value;
subkeyPath: (nullable OFString *)subkeyPath;
/*!
* @brief Returns the string for the specified value at the specified path.
*
* @param value The name of the value to return
* @param subkeyPath The path of the key from which to retrieve the value
* @param flags Extra flags for `RegGetValue()`. Usually 0.
* @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
subkeyPath: (nullable OFString *)subkeyPath
flags: (DWORD)flags
type: (nullable LPDWORD)type;
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
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
subkeyPath: (OFString *)subkeyPath
flags: (DWORD)flags
type: (LPDWORD)type
{
void *pool = objc_autoreleasePoolPush();
char stackBuffer[256], *buffer = stackBuffer;
BYTE stackBuffer[256], *buffer = stackBuffer;
DWORD length = sizeof(stackBuffer);
OFMutableData *ret = nil;
LSTATUS status;
for (;;) {
status = RegGetValueW(_hKey, subkeyPath.UTF16String,
value.UTF16String, flags, type, buffer, &length);
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
218
219
220
221
222
223
224
225
226
|
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
subkeyPath: subkeyPath
flags: flags
status: status];
}
}
}
- (void)setData: (OFData *)data
forValue: (OFString *)value
|
︙ | | |
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
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
subkeyPath: (OFString *)subkeyPath
{
return [self stringForValue: value
subkeyPath: subkeyPath
flags: RRF_RT_REG_SZ
type: NULL];
}
- (OFString *)stringForValue: (OFString *)value
subkeyPath: (OFString *)subkeyPath
flags: (DWORD)flags
type: (LPDWORD)type
{
void *pool = objc_autoreleasePoolPush();
OFData *data = [self dataForValue: value
subkeyPath: subkeyPath
flags: flags
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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
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, *_Nullable _subkeyPath;
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 subkey path at which getting the value failed.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *subkeyPath;
/*!
* @brief The flags with which getting the value failed.
*/
@property (readonly, nonatomic) DWORD flags;
/*!
* @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 subkeyPath The subkey path at which getting the value failed
* @param flags The flags with which getting the value failed
* @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
subkeyPath: (nullable OFString *)subkeyPath
flags: (DWORD)flags
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 subkeyPath The subkey path at which getting the value failed
* @param flags The flags with which getting the value failed
* @param status The status returned by RegGetValueEx()
* @return An initialized get Windows registry value failed exception
*/
- (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey
value: (nullable OFString *)value
subkeyPath: (nullable OFString *)subkeyPath
flags: (DWORD)flags
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
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
72
73
74
75
76
77
78
79
80
81
|
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;
@synthesize registryKey = _registryKey, value = _value, status = _status;
@synthesize subkeyPath = _subkeyPath, flags = _flags, status = _status;
+ (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey
value: (OFString *)value
subkeyPath: (OFString *)subkeyPath
flags: (DWORD)flags
status: (LSTATUS)status
{
return [[[self alloc] initWithRegistryKey: registryKey
value: value
subkeyPath: subkeyPath
flags: flags
status: status] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey
value: (OFString *)value
subkeyPath: (OFString *)subkeyPath
flags: (DWORD)flags
status: (LSTATUS)status
{
self = [super init];
@try {
_registryKey = [registryKey retain];
_value = [value copy];
_subkeyPath = [subkeyPath copy];
_flags = flags;
_status = status;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_registryKey release];
[_value release];
[_subkeyPath release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to get value %@ at subkey path %@: %@",
_value, _subkeyPath, of_windows_status_to_string(_status)];
@"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
32
33
34
35
36
37
38
39
|
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;
OFString *string;
TEST(@"+[OFWindowsRegistryKey classesRootKey]",
[OFWindowsRegistryKey classesRootKey])
TEST(@"+[OFWindowsRegistryKey currentConfigKey]",
[OFWindowsRegistryKey currentConfigKey])
|
︙ | | |
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
91
92
93
94
95
96
97
98
99
100
|
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:]",
[[softwareKey dataForValue: @"data"
[[ObjFWKey dataForValue: @"data"
subkeyPath: @"ObjFW"
flags: RRF_RT_REG_BINARY
type: &type] isEqual: 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:]",
[[softwareKey stringForValue: @"string"
[[ObjFWKey stringForValue: @"string"] isEqual: @"foobar"] &&
subkeyPath: @"ObjFW"] isEqual: @"foobar"] &&
[[softwareKey stringForValue: @"expand"
[[ObjFWKey stringForValue: @"expand"
subkeyPath: @"ObjFW"
flags: RRF_RT_REG_EXPAND_SZ | RRF_NOEXPAND
type: &type] isEqual: @"%PATH%;foo"] &&
type == REG_EXPAND_SZ &&
type: &type] isEqual: @"%PATH%;foo"] &&
type == REG_EXPAND_SZ)
(string = [ObjFWKey stringForValue: @"expand"
subkeyPath: nil]) &&
![string isEqual: @"%PATH%;foo"] &&
[string hasSuffix: @";foo"])
TEST(@"-[deleteValue:]", R([ObjFWKey deleteValue: @"data"]))
TEST(@"-[deleteSubkeyAtPath:]",
R([softwareKey deleteSubkeyAtPath: @"ObjFW"]))
objc_autoreleasePoolPop(pool);
}
@end
|