Modified src/OFASN1BitString.m
from [323c648f9c]
to [843d69d324].
︙ | | |
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
-
+
-
-
+
-
|
if (bitStringValueCount + 1 > UINT8_MAX ||
bitStringValueCount != roundedUpLength / 8)
@throw [OFInvalidFormatException exception];
data = [OFMutableData
dataWithCapacity: sizeof(header) + bitStringValueCount];
[data addItems: header
[data addItems: header count: sizeof(header)];
count: sizeof(header)];
[data addItems: [_bitStringValue items]
[data addItems: [_bitStringValue items] count: bitStringValueCount];
count: bitStringValueCount];
[data makeImmutable];
return data;
}
- (bool)isEqual: (id)object
|
︙ | | |
Modified src/OFASN1Boolean.m
from [1a29ed76f3]
to [ae373739b8].
︙ | | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
+
-
|
{
char buffer[] = {
OF_ASN1_TAG_NUMBER_BOOLEAN,
1,
(_booleanValue ? 0xFF : 0x00)
};
return [OFData dataWithItems: buffer
return [OFData dataWithItems: buffer count: sizeof(buffer)];
count: sizeof(buffer)];
}
- (bool)isEqual: (id)object
{
OFASN1Boolean *boolean;
if (object == self)
|
︙ | | |
Modified src/OFAdjacentArray.m
from [a432edffec]
to [0ad6ceaf6f].
︙ | | |
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
[_array addItem: &firstObject];
|
︙ | | |
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
-
+
-
-
+
-
-
+
-
|
@throw e;
}
@try {
for (size_t i = 0; i < count; i++)
[objects[i] retain];
[_array addItems: objects
[_array addItems: objects count: count];
count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
/* Prevent double-release of objects */
[_array release];
_array = nil;
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
self = [self init];
@try {
bool ok = true;
for (size_t i = 0; i < count; i++) {
if (objects[i] == nil)
ok = false;
[objects[i] retain];
}
if (!ok)
@throw [OFInvalidArgumentException exception];
[_array addItems: objects
[_array addItems: objects count: count];
count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
[self release];
@throw e;
}
|
︙ | | |
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
-
+
-
|
}
- (id)objectAtIndexedSubscript: (size_t)idx
{
return *((id *)[_array itemAtIndex: idx]);
}
- (void)getObjects: (id *)buffer
- (void)getObjects: (id *)buffer inRange: (of_range_t)range
inRange: (of_range_t)range
{
id const *objects = _array.items;
size_t count = _array.count;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > count)
@throw [OFOutOfRangeException exception];
|
︙ | | |
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
-
+
-
|
@throw [OFOutOfRangeException exception];
if ([self isKindOfClass: [OFMutableArray class]])
return [OFArray
arrayWithObjects: (id *)_array.items + range.location
count: range.length];
return [OFAdjacentSubarray arrayWithArray: self
return [OFAdjacentSubarray arrayWithArray: self range: range];
range: range];
}
- (bool)isEqual: (id)object
{
OFArray *otherArray;
id const *objects, *otherObjects;
size_t count;
|
︙ | | |
Modified src/OFApplication.m
from [84a11f1539]
to [8597dbb10a].
︙ | | |
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
-
+
-
-
+
-
|
# include <nds.h>
# undef asm
#endif
OF_DIRECT_MEMBERS
@interface OFApplication ()
- (instancetype)of_init OF_METHOD_FAMILY(init);
- (void)of_setArgumentCount: (int *)argc
- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv;
andArgumentValues: (char **[])argv;
#ifdef OF_WINDOWS
- (void)of_setArgumentCount: (int)argc
- (void)of_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t *[])argv;
andWideArgumentValues: (wchar_t *[])argv;
#endif
- (void)of_run;
@end
static OFApplication *app = nil;
static void
|
︙ | | |
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
-
+
-
-
+
-
|
[[OFLocale alloc] init];
app = [[OFApplication alloc] of_init];
#ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT]) {
__wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si);
[app of_setArgumentCount: wargc
[app of_setArgumentCount: wargc andWideArgumentValues: wargv];
andWideArgumentValues: wargv];
} else
#endif
[app of_setArgumentCount: argc
[app of_setArgumentCount: argc andArgumentValues: argv];
andArgumentValues: argv];
app.delegate = delegate;
[app of_run];
[delegate release];
|
︙ | | |
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
-
+
-
|
continue;
path = [@"ENV:" stringByAppendingString: name];
if ([fileManager directoryExistsAtPath: path])
continue;
file = [OFFile fileWithPath: path
file = [OFFile fileWithPath: path mode: @"r"];
mode: @"r"];
value = [file readLineWithEncoding: encoding];
if (value != nil)
[_environment setObject: value forKey: name];
objc_autoreleasePoolPop(pool2);
}
|
︙ | | |
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
|
-
+
-
|
{
[_arguments release];
[_environment release];
[super dealloc];
}
- (void)of_setArgumentCount: (int *)argc
- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char ***)argv
andArgumentValues: (char ***)argv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
of_string_encoding_t encoding;
_argc = argc;
_argv = argv;
|
︙ | | |
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
|
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
-
+
-
-
+
-
|
[arguments makeImmutable];
}
objc_autoreleasePoolPop(pool);
}
#ifdef OF_WINDOWS
- (void)of_setArgumentCount: (int)argc
- (void)of_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t **)argv
andWideArgumentValues: (wchar_t **)argv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
if (argc > 0) {
_programName = [[OFString alloc] initWithUTF16String: argv[0]];
arguments = [[OFMutableArray alloc] init];
for (int i = 1; i < argc; i++)
[arguments addObject:
[OFString stringWithUTF16String: argv[i]]];
[arguments makeImmutable];
_arguments = arguments;
}
objc_autoreleasePoolPop(pool);
}
#endif
- (void)getArgumentCount: (int **)argc
- (void)getArgumentCount: (int **)argc andArgumentValues: (char ****)argv
andArgumentValues: (char ****)argv
{
*argc = _argc;
*argv = _argv;
}
- (id <OFApplicationDelegate>)delegate
{
|
︙ | | |
Modified src/OFArray.m
from [e8aa9a3165]
to [f6ae42a2d9].
︙ | | |
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
-
+
-
|
}
- (size_t)count
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)getObjects: (id *)buffer
- (void)getObjects: (id *)buffer inRange: (of_range_t)range
inRange: (of_range_t)range
{
for (size_t i = 0; i < range.length; i++)
buffer[i] = [self objectAtIndex: range.location + i];
}
- (id const *)objects
{
|
︙ | | |
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
-
+
|
@throw [OFInvalidArgumentException exception];
if (self.count == 0)
return @"";
if (self.count == 1) {
OFString *component =
[[self firstObject] performSelector: selector];
[[self objectAtIndex: 0] performSelector: selector];
if (component == nil)
@throw [OFInvalidArgumentException exception];
return component;
}
|
︙ | | |
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
|
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
|
-
+
|
{
size_t count = self.count;
__block id current;
if (count == 0)
return nil;
if (count == 1)
return [[[self firstObject] retain] autorelease];
return [[[self objectAtIndex: 0] retain] autorelease];
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
id new;
if (idx == 0) {
current = [object retain];
|
︙ | | |
Modified src/OFBytesValue.m
from [a0f881f925]
to [5fd2ddb8ad].
︙ | | |
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
+
-
|
- (void)dealloc
{
free(_bytes);
[super dealloc];
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
if (size != _size)
@throw [OFOutOfRangeException exception];
memcpy(value, _bytes, _size);
}
@end
|
Modified src/OFCondition.m
from [00d905a1c0]
to [a2bba1aee6].
︙ | | |
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
-
+
-
|
- (bool)waitUntilDate: (OFDate *)date
{
return [self waitForTimeInterval: date.timeIntervalSinceNow];
}
#ifdef OF_AMIGAOS
- (bool)waitUntilDate: (OFDate *)date
- (bool)waitUntilDate: (OFDate *)date orExecSignal: (ULONG *)signalMask
orExecSignal: (ULONG *)signalMask
{
return [self waitForTimeInterval: date.timeIntervalSinceNow
orExecSignal: signalMask];
}
#endif
- (void)signal
|
︙ | | |
Modified src/OFConstantString.m
from [41b6262c76]
to [3252c9a3ca].
︙ | | |
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
|
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
+
-
-
|
* OFConstantUTF8String and the message sent again.
*/
/* From protocol OFCopying */
- (id)copy
{
[self finishInitialization];
return [self copy];
}
/* From protocol OFMutableCopying */
- (id)mutableCopy
{
[self finishInitialization];
return [self mutableCopy];
}
/* From protocol OFComparing */
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
[self finishInitialization];
return [self compare: object];
}
/* From OFObject, but reimplemented in OFString */
- (bool)isEqual: (id)object
{
[self finishInitialization];
return [self isEqual: object];
}
- (unsigned long)hash
{
[self finishInitialization];
return self.hash;
}
- (OFString *)description
{
[self finishInitialization];
return self.description;
}
/* From OFString */
- (const char *)UTF8String
{
[self finishInitialization];
return self.UTF8String;
}
- (size_t)getCString: (char *)cString_
maxLength: (size_t)maxLength
encoding: (of_string_encoding_t)encoding
{
[self finishInitialization];
return [self getCString: cString_
maxLength: maxLength
encoding: encoding];
}
- (const char *)cStringWithEncoding: (of_string_encoding_t)encoding
{
[self finishInitialization];
return [self cStringWithEncoding: encoding];
}
- (size_t)length
{
[self finishInitialization];
return self.length;
}
- (size_t)UTF8StringLength
{
[self finishInitialization];
return self.UTF8StringLength;
}
- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
{
[self finishInitialization];
return [self cStringLengthWithEncoding: encoding];
}
- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString
{
[self finishInitialization];
return [self caseInsensitiveCompare: otherString];
}
- (of_unichar_t)characterAtIndex: (size_t)idx
{
[self finishInitialization];
return [self characterAtIndex: idx];
}
- (void)getCharacters: (of_unichar_t *)buffer
- (void)getCharacters: (of_unichar_t *)buffer inRange: (of_range_t)range
inRange: (of_range_t)range
{
[self finishInitialization];
[self getCharacters: buffer
[self getCharacters: buffer inRange: range];
inRange: range];
}
- (of_range_t)rangeOfString: (OFString *)string
{
[self finishInitialization];
return [self rangeOfString: string];
}
- (of_range_t)rangeOfString: (OFString *)string
- (of_range_t)rangeOfString: (OFString *)string options: (int)options
options: (int)options
{
[self finishInitialization];
return [self rangeOfString: string
return [self rangeOfString: string options: options];
options: options];
}
- (of_range_t)rangeOfString: (OFString *)string
options: (int)options
range: (of_range_t)range
{
[self finishInitialization];
return [self rangeOfString: string
return [self rangeOfString: string options: options range: range];
options: options
range: range];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
{
[self finishInitialization];
return [self indexOfCharacterFromSet: characterSet];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
options: (int)options
{
[self finishInitialization];
return [self indexOfCharacterFromSet: characterSet
return [self indexOfCharacterFromSet: characterSet options: options];
options: options];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
options: (int)options
range: (of_range_t)range
{
[self finishInitialization];
return [self indexOfCharacterFromSet: characterSet
options: options
range: range];
}
- (bool)containsString: (OFString *)string
{
[self finishInitialization];
return [self containsString: string];
}
- (OFString *)substringFromIndex: (size_t)idx
{
[self finishInitialization];
return [self substringFromIndex: idx];
}
- (OFString *)substringToIndex: (size_t)idx
{
[self finishInitialization];
return [self substringToIndex: idx];
}
- (OFString *)substringWithRange: (of_range_t)range
{
[self finishInitialization];
return [self substringWithRange: range];
}
- (OFString *)stringByAppendingString: (OFString *)string
{
[self finishInitialization];
return [self stringByAppendingString: string];
}
- (OFString *)stringByAppendingFormat: (OFConstantString *)format
arguments: (va_list)arguments
{
[self finishInitialization];
return [self stringByAppendingFormat: format
return [self stringByAppendingFormat: format arguments: arguments];
arguments: arguments];
}
- (OFString *)stringByAppendingPathComponent: (OFString *)component
{
[self finishInitialization];
return [self stringByAppendingPathComponent: component];
}
- (OFString *)stringByPrependingString: (OFString *)string
{
[self finishInitialization];
return [self stringByPrependingString: string];
}
- (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string
withString: (OFString *)replacement
{
[self finishInitialization];
return [self stringByReplacingOccurrencesOfString: string
withString: replacement];
}
- (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string
withString: (OFString *)replacement
options: (int)options
range: (of_range_t)range
{
[self finishInitialization];
return [self stringByReplacingOccurrencesOfString: string
withString: replacement
options: options
range: range];
}
- (OFString *)uppercaseString
{
[self finishInitialization];
return self.uppercaseString;
}
- (OFString *)lowercaseString
{
[self finishInitialization];
return self.lowercaseString;
}
- (OFString *)capitalizedString
{
[self finishInitialization];
return self.capitalizedString;
}
- (OFString *)stringByDeletingLeadingWhitespaces
{
[self finishInitialization];
return self.stringByDeletingLeadingWhitespaces;
}
- (OFString *)stringByDeletingTrailingWhitespaces
{
[self finishInitialization];
return self.stringByDeletingTrailingWhitespaces;
}
- (OFString *)stringByDeletingEnclosingWhitespaces
{
[self finishInitialization];
return self.stringByDeletingEnclosingWhitespaces;
}
- (bool)hasPrefix: (OFString *)prefix
{
[self finishInitialization];
return [self hasPrefix: prefix];
}
- (bool)hasSuffix: (OFString *)suffix
{
[self finishInitialization];
return [self hasSuffix: suffix];
}
- (OFArray *)componentsSeparatedByString: (OFString *)delimiter
{
[self finishInitialization];
return [self componentsSeparatedByString: delimiter];
}
- (OFArray *)componentsSeparatedByString: (OFString *)delimiter
options: (int)options
{
[self finishInitialization];
return [self componentsSeparatedByString: delimiter
return [self componentsSeparatedByString: delimiter options: options];
options: options];
}
- (OFArray *)
componentsSeparatedByCharactersInSet: (OFCharacterSet *)characterSet
{
[self finishInitialization];
return [self componentsSeparatedByCharactersInSet: characterSet];
}
- (OFArray *)
componentsSeparatedByCharactersInSet: (OFCharacterSet *)characterSet
options: (int)options
{
[self finishInitialization];
return [self componentsSeparatedByCharactersInSet: characterSet
options: options];
}
- (OFArray *)pathComponents
{
[self finishInitialization];
return self.pathComponents;
}
- (OFString *)lastPathComponent
{
[self finishInitialization];
return self.lastPathComponent;
}
- (OFString *)stringByDeletingLastPathComponent
{
[self finishInitialization];
return self.stringByDeletingLastPathComponent;
}
- (long long)longLongValue
{
[self finishInitialization];
return self.longLongValue;
}
- (long long)longLongValueWithBase: (int)base
{
[self finishInitialization];
return [self longLongValueWithBase: base];
}
- (unsigned long long)unsignedLongLongValue
{
[self finishInitialization];
return self.unsignedLongLongValue;
}
- (unsigned long long)unsignedLongLongValueWithBase: (int)base
{
[self finishInitialization];
return [self unsignedLongLongValueWithBase: base];
}
- (float)floatValue
{
[self finishInitialization];
return self.floatValue;
}
- (double)doubleValue
{
[self finishInitialization];
return self.doubleValue;
}
- (const of_unichar_t *)characters
{
[self finishInitialization];
return self.characters;
}
- (const of_char16_t *)UTF16String
{
[self finishInitialization];
return self.UTF16String;
}
- (const of_char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder
{
[self finishInitialization];
return [self UTF16StringWithByteOrder: byteOrder];
}
- (size_t)UTF16StringLength
{
[self finishInitialization];
return self.UTF16StringLength;
}
- (const of_char32_t *)UTF32String
{
[self finishInitialization];
return self.UTF32String;
}
- (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
{
[self finishInitialization];
return [self UTF32StringWithByteOrder: byteOrder];
}
- (OFData *)dataWithEncoding: (of_string_encoding_t)encoding
{
[self finishInitialization];
return [self dataWithEncoding: encoding];
}
#ifdef OF_HAVE_UNICODE_TABLES
- (OFString *)decomposedStringWithCanonicalMapping
{
[self finishInitialization];
return self.decomposedStringWithCanonicalMapping;
}
- (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];
}
- (void)writeToFile: (OFString *)path
- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding
encoding: (of_string_encoding_t)encoding
{
[self finishInitialization];
[self writeToFile: path
[self writeToFile: path encoding: encoding];
encoding: encoding];
}
#endif
- (void)writeToURL: (OFURL *)URL
{
[self finishInitialization];
[self writeToURL: URL];
}
- (void)writeToURL: (OFURL *)URL
- (void)writeToURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding
encoding: (of_string_encoding_t)encoding
{
[self finishInitialization];
[self writeToURL: URL
[self writeToURL: URL encoding: encoding];
encoding: encoding];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block
{
[self finishInitialization];
[self enumerateLinesUsingBlock: block];
}
#endif
@end
|
Modified src/OFCountedMapTableSet.m
from [dc614750e5]
to [1688e99723].
︙ | | |
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
105
106
107
108
109
110
|
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
105
106
107
108
|
-
+
-
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
self = [self init];
@try {
for (size_t i = 0; i < count; i++)
[self addObject: objects[i]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
[self addObject: firstObject];
|
︙ | | |
Modified src/OFCountedSet.m
from [2a2cd32bfd]
to [d6c7218230].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
-
+
-
-
+
-
|
ret = [[OFCountedMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
return (id)[[OFCountedMapTableSet alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
return (id)[[OFCountedMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
|
︙ | | |
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
-
+
-
-
|
[ret appendFormat: @": %zu", [self countForObject: object]];
if (++i < count)
[ret appendString: @",\n"];
objc_autoreleasePoolPop(pool2);
}
[ret replaceOccurrencesOfString: @"\n"
[ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"];
withString: @"\n\t"];
[ret appendString: @"\n)}"];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
|
︙ | | |
Modified src/OFDNSResolver.m
from [46f2a3f0a5]
to [536c83ec11].
︙ | | |
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
-
+
-
-
-
+
-
-
-
+
-
-
|
_delegate = [delegate retain];
queryData = [OFMutableData dataWithCapacity: 512];
/* Header */
tmp = OF_BSWAP16_IF_LE(_ID.unsignedShortValue);
[queryData addItems: &tmp
[queryData addItems: &tmp count: 2];
count: 2];
/* RD */
tmp = OF_BSWAP16_IF_LE(1u << 8);
[queryData addItems: &tmp
[queryData addItems: &tmp count: 2];
count: 2];
/* QDCOUNT */
tmp = OF_BSWAP16_IF_LE(1);
[queryData addItems: &tmp
[queryData addItems: &tmp count: 2];
count: 2];
/* ANCOUNT, NSCOUNT and ARCOUNT */
[queryData increaseCountBy: 6];
/* Question */
/* QNAME */
for (OFString *component in
|
︙ | | |
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
|
-
+
-
-
-
+
-
-
|
[queryData addItem: &length8];
[queryData addItems: component.UTF8String
count: length];
}
/* QTYPE */
tmp = OF_BSWAP16_IF_LE(_query.recordType);
[queryData addItems: &tmp
[queryData addItems: &tmp count: 2];
count: 2];
/* QCLASS */
tmp = OF_BSWAP16_IF_LE(_query.DNSClass);
[queryData addItems: &tmp
[queryData addItems: &tmp count: 2];
count: 2];
[queryData makeImmutable];
_queryData = [queryData copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
|
︙ | | |
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
|
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
|
-
+
-
|
}
context = [[[OFDNSResolverContext alloc]
initWithQuery: query
ID: ID
settings: _settings
delegate: delegate] autorelease];
[self of_sendQueryForContext: context
[self of_sendQueryForContext: context runLoopMode: runLoopMode];
runLoopMode: runLoopMode];
objc_autoreleasePoolPop(pool);
}
- (void)of_contextTimedOut: (OFDNSResolverContext *)context
{
of_run_loop_mode_t runLoopMode = [OFRunLoop currentRunLoop].currentMode;
|
︙ | | |
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
|
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
|
-
+
-
-
+
-
-
+
-
-
+
-
|
context->_TCPSocket = nil;
context->_responseLength = 0;
}
if (context->_nameServersIndex + 1 <
context->_settings->_nameServers.count) {
context->_nameServersIndex++;
[self of_sendQueryForContext: context
[self of_sendQueryForContext: context runLoopMode: runLoopMode];
runLoopMode: runLoopMode];
return;
}
if (++context->_attempt < context->_settings->_maxAttempts) {
context->_nameServersIndex = 0;
[self of_sendQueryForContext: context
[self of_sendQueryForContext: context runLoopMode: runLoopMode];
runLoopMode: runLoopMode];
return;
}
context = [[context retain] autorelease];
[_queries removeObjectForKey: context->_ID];
/*
* Cancel any pending queries, to avoid a send being still pending and
* trying to access the query once it no longer exists.
*/
[_IPv4Socket cancelAsyncRequests];
[_IPv4Socket asyncReceiveIntoBuffer: _buffer
[_IPv4Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH];
length: BUFFER_LENGTH];
#ifdef OF_HAVE_IPV6
[_IPv6Socket cancelAsyncRequests];
[_IPv6Socket asyncReceiveIntoBuffer: _buffer
[_IPv6Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH];
length: BUFFER_LENGTH];
#endif
exception = [OFDNSQueryFailedException
exceptionWithQuery: context->_query
error: OF_DNS_RESOLVER_ERROR_TIMEOUT];
[context->_delegate resolver: self
|
︙ | | |
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
|
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
|
-
+
-
|
if (queryDataCount > UINT16_MAX)
@throw [OFOutOfRangeException exception];
context->_TCPQueryData = [[OFMutableData alloc]
initWithCapacity: queryDataCount + 2];
tmp = OF_BSWAP16_IF_LE(queryDataCount);
[context->_TCPQueryData addItems: &tmp
[context->_TCPQueryData addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
[context->_TCPQueryData addItems: context->_queryData.items
count: queryDataCount];
}
[sock asyncWriteData: context->_TCPQueryData];
}
|
︙ | | |
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
|
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
|
-
+
-
|
context->_responseLength = 0;
return nil;
}
if (context->_TCPBuffer == nil)
context->_TCPBuffer = of_alloc(MAX_DNS_RESPONSE_LENGTH, 1);
[sock asyncReadIntoBuffer: context->_TCPBuffer
[sock asyncReadIntoBuffer: context->_TCPBuffer exactLength: 2];
exactLength: 2];
return nil;
}
- (bool)stream: (OFStream *)stream
didReadIntoBuffer: (void *)buffer
length: (size_t)length
exception: (id)exception
|
︙ | | |
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
|
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
|
-
+
-
-
|
if (length != context->_responseLength)
/*
* The connection was closed before we received the entire
* response.
*/
goto done;
[self of_handleResponseBuffer: buffer
[self of_handleResponseBuffer: buffer length: length sender: NULL];
length: length
sender: NULL];
done:
[_TCPQueries removeObjectForKey: context->_TCPSocket];
[context->_TCPSocket release];
context->_TCPSocket = nil;
context->_responseLength = 0;
|
︙ | | |
Modified src/OFDNSResolverSettings.m
from [ace801f6de]
to [a893fa1b35].
︙ | | |
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
-
+
-
|
OFCharacterSet *whitespaceCharacterSet =
[OFCharacterSet whitespaceCharacterSet];
OFMutableDictionary *staticHosts;
OFFile *file;
OFString *line;
@try {
file = [OFFile fileWithPath: path
file = [OFFile fileWithPath: path mode: @"r"];
mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
objc_autoreleasePoolPop(pool);
return;
}
staticHosts = [OFMutableDictionary dictionary];
|
︙ | | |
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
-
+
-
|
OFCharacterSet *commentCharacters = [OFCharacterSet
characterSetWithCharactersInString: @"#;"];
OFMutableArray *nameServers = [[_nameServers mutableCopy] autorelease];
OFFile *file;
OFString *line;
@try {
file = [OFFile fileWithPath: path
file = [OFFile fileWithPath: path mode: @"r"];
mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
objc_autoreleasePoolPop(pool);
return;
}
if (nameServers == nil)
nameServers = [OFMutableArray array];
|
︙ | | |
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
-
+
|
if ([option isEqual: @"nameserver"]) {
if (arguments.count != 1) {
objc_autoreleasePoolPop(pool2);
continue;
}
[nameServers addObject: [arguments firstObject]];
[nameServers addObject: arguments.firstObject];
} else if ([option isEqual: @"domain"]) {
if (arguments.count != 1) {
objc_autoreleasePoolPop(pool2);
continue;
}
[_localDomain release];
|
︙ | | |
Modified src/OFData+CryptoHashing.m
from [42a49bdd70]
to [7bd2a07f00].
︙ | | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-
+
-
|
void *pool = objc_autoreleasePoolPush();
id <OFCryptoHash> hash =
[class cryptoHashWithAllowsSwappableMemory: true];
size_t digestSize = [class digestSize];
const unsigned char *digest;
char cString[digestSize * 2];
[hash updateWithBuffer: _items
[hash updateWithBuffer: _items length: _count * _itemSize];
length: _count * _itemSize];
digest = hash.digest;
for (size_t i = 0; i < digestSize; i++) {
uint8_t high, low;
high = digest[i] >> 4;
low = digest[i] & 0x0F;
|
︙ | | |
Modified src/OFData+MessagePackParsing.m
from [f67dfe7d8e]
to [e2ef80fc28].
︙ | | |
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
|
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
@throw [OFTruncatedDataException exception];
count = buffer[1];
if (length < count + 2)
@throw [OFTruncatedDataException exception];
*object = [OFData dataWithItems: buffer + 2
*object = [OFData dataWithItems: buffer + 2 count: count];
count: count];
return count + 2;
case 0xC5: /* bin 16 */
if (length < 3)
@throw [OFTruncatedDataException exception];
count = readUInt16(buffer + 1);
if (length < count + 3)
@throw [OFTruncatedDataException exception];
*object = [OFData dataWithItems: buffer + 3
*object = [OFData dataWithItems: buffer + 3 count: count];
count: count];
return count + 3;
case 0xC6: /* bin 32 */
if (length < 5)
@throw [OFTruncatedDataException exception];
count = readUInt32(buffer + 1);
if (length < count + 5)
@throw [OFTruncatedDataException exception];
*object = [OFData dataWithItems: buffer + 5
*object = [OFData dataWithItems: buffer + 5 count: count];
count: count];
return count + 5;
/* Extensions */
case 0xC7: /* ext 8 */
if (length < 3)
@throw [OFTruncatedDataException exception];
count = buffer[1];
if (length < count + 3)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 3
data = [[OFData alloc] initWithItems: buffer + 3 count: count];
count: count];
@try {
*object = createExtension(buffer[2], data);
} @finally {
[data release];
}
return count + 3;
case 0xC8: /* ext 16 */
if (length < 4)
@throw [OFTruncatedDataException exception];
count = readUInt16(buffer + 1);
if (length < count + 4)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 4
data = [[OFData alloc] initWithItems: buffer + 4 count: count];
count: count];
@try {
*object = createExtension(buffer[3], data);
} @finally {
[data release];
}
return count + 4;
case 0xC9: /* ext 32 */
if (length < 6)
@throw [OFTruncatedDataException exception];
count = readUInt32(buffer + 1);
if (length < count + 6)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 6
data = [[OFData alloc] initWithItems: buffer + 6 count: count];
count: count];
@try {
*object = createExtension(buffer[5], data);
} @finally {
[data release];
}
return count + 6;
case 0xD4: /* fixext 1 */
if (length < 3)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 2
data = [[OFData alloc] initWithItems: buffer + 2 count: 1];
count: 1];
@try {
*object = createExtension(buffer[1], data);
} @finally {
[data release];
}
return 3;
case 0xD5: /* fixext 2 */
if (length < 4)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 2
data = [[OFData alloc] initWithItems: buffer + 2 count: 2];
count: 2];
@try {
*object = createExtension(buffer[1], data);
} @finally {
[data release];
}
return 4;
case 0xD6: /* fixext 4 */
if (length < 6)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 2
data = [[OFData alloc] initWithItems: buffer + 2 count: 4];
count: 4];
@try {
*object = createExtension(buffer[1], data);
} @finally {
[data release];
}
return 6;
case 0xD7: /* fixext 8 */
if (length < 10)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 2
data = [[OFData alloc] initWithItems: buffer + 2 count: 8];
count: 8];
@try {
*object = createExtension(buffer[1], data);
} @finally {
[data release];
}
return 10;
case 0xD8: /* fixext 16 */
if (length < 18)
@throw [OFTruncatedDataException exception];
data = [[OFData alloc] initWithItems: buffer + 2
data = [[OFData alloc] initWithItems: buffer + 2 count: 16];
count: 16];
@try {
*object = createExtension(buffer[1], data);
} @finally {
[data release];
}
return 18;
|
︙ | | |
Modified src/OFData.m
from [e36b8d42d3]
to [0640a57f3d].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
-
+
-
-
+
-
|
_OFData_CryptoHashing_reference = 1;
_OFData_MessagePackParsing_reference = 1;
}
@implementation OFData
@synthesize itemSize = _itemSize;
+ (instancetype)dataWithItems: (const void *)items
+ (instancetype)dataWithItems: (const void *)items count: (size_t)count
count: (size_t)count
{
return [[[self alloc] initWithItems: items
return [[[self alloc] initWithItems: items count: count] autorelease];
count: count] autorelease];
}
+ (instancetype)dataWithItems: (const void *)items
count: (size_t)count
itemSize: (size_t)itemSize
{
return [[[self alloc] initWithItems: items
|
︙ | | |
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-
+
-
-
+
-
-
|
}
+ (instancetype)dataWithBase64EncodedString: (OFString *)string
{
return [[[self alloc] initWithBase64EncodedString: string] autorelease];
}
- (instancetype)initWithItems: (const void *)items
- (instancetype)initWithItems: (const void *)items count: (size_t)count
count: (size_t)count
{
return [self initWithItems: items
return [self initWithItems: items count: count itemSize: 1];
count: count
itemSize: 1];
}
- (instancetype)initWithItems: (const void *)items
count: (size_t)count
itemSize: (size_t)itemSize
{
self = [super init];
|
︙ | | |
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
-
+
-
-
+
-
|
# if ULLONG_MAX > SIZE_MAX
if (size > SIZE_MAX)
@throw [OFOutOfRangeException exception];
# endif
buffer = of_alloc((size_t)size, 1);
file = [[OFFile alloc] initWithPath: path
file = [[OFFile alloc] initWithPath: path mode: @"r"];
mode: @"r"];
@try {
[file readIntoBuffer: buffer
[file readIntoBuffer: buffer exactLength: (size_t)size];
exactLength: (size_t)size];
} @finally {
[file release];
}
} @catch (id e) {
free(buffer);
[self release];
|
︙ | | |
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
-
+
-
|
size_t pageSize;
unsigned char *buffer;
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: URL];
stream = [URLHandler openItemAtURL: URL
stream = [URLHandler openItemAtURL: URL mode: @"r"];
mode: @"r"];
_count = 0;
_itemSize = 1;
_freeWhenDone = true;
pageSize = [OFSystemInfo pageSize];
buffer = of_alloc(1, pageSize);
|
︙ | | |
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
|
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
|
-
+
-
-
-
+
-
-
-
+
-
-
|
return of_range(OF_NOT_FOUND, 0);
}
#ifdef OF_HAVE_FILES
- (void)writeToFile: (OFString *)path
{
OFFile *file = [[OFFile alloc] initWithPath: path
OFFile *file = [[OFFile alloc] initWithPath: path mode: @"w"];
mode: @"w"];
@try {
[file writeBuffer: _items
[file writeBuffer: _items length: _count * _itemSize];
length: _count * _itemSize];
} @finally {
[file release];
}
}
#endif
- (void)writeToURL: (OFURL *)URL
{
void *pool = objc_autoreleasePoolPush();
OFURLHandler *URLHandler;
OFStream *stream;
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
stream = [URLHandler openItemAtURL: URL
[[URLHandler openItemAtURL: URL mode: @"w"] writeData: self];
mode: @"w"];
[stream writeData: self];
objc_autoreleasePoolPop(pool);
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool;
|
︙ | | |
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
|
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
-
+
-
-
-
+
-
-
-
+
-
-
+
-
-
-
+
-
-
+
-
-
|
if (_itemSize != 1)
@throw [OFInvalidArgumentException exception];
if (_count <= UINT8_MAX) {
uint8_t type = 0xC4;
uint8_t tmp = (uint8_t)_count;
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: _count + 2];
capacity: _count + 2];
[data addItem: &type];
[data addItem: &tmp];
} else if (_count <= UINT16_MAX) {
uint8_t type = 0xC5;
uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)_count);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: _count + 3];
capacity: _count + 3];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (_count <= UINT32_MAX) {
uint8_t type = 0xC6;
uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)_count);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: _count + 5];
capacity: _count + 5];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
[data addItems: _items
[data addItems: _items count: _count];
count: _count];
[data makeImmutable];
return data;
}
@end
|
Modified src/OFDatagramSocket.m
from [e03ee47321]
to [ed638b6427].
︙ | | |
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
-
+
-
|
sender->family = OF_SOCKET_ADDRESS_FAMILY_UNKNOWN;
break;
}
return ret;
}
- (void)asyncReceiveIntoBuffer: (void *)buffer
- (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
[self asyncReceiveIntoBuffer: buffer
length: length
runLoopMode: of_run_loop_mode_default];
}
- (void)asyncReceiveIntoBuffer: (void *)buffer
|
︙ | | |
Modified src/OFDate.m
from [3377ad9619]
to [a6b8335541].
︙ | | |
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
|
-
-
-
-
-
+
+
+
-
|
ret = [[OFMessagePackExtension
extensionWithType: -1
data: data] messagePackRepresentation];
}
} else {
OFMutableData *data = [OFMutableData dataWithCapacity: 12];
seconds = OF_BSWAP64_IF_LE(seconds);
nanoseconds = OF_BSWAP32_IF_LE(nanoseconds);
[data addItems: &nanoseconds
count: sizeof(nanoseconds)];
[data addItems: &seconds
[data addItems: &nanoseconds count: sizeof(nanoseconds)];
seconds = OF_BSWAP64_IF_LE(seconds);
[data addItems: &seconds count: sizeof(seconds)];
count: sizeof(seconds)];
ret = [[OFMessagePackExtension
extensionWithType: -1
data: data] messagePackRepresentation];
}
[ret retain];
|
︙ | | |
Modified src/OFDictionary.m
from [dca613f5bc]
to [45778dda9e].
︙ | | |
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-
+
-
-
+
-
|
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
return (id)[[OFMapTableDictionary alloc]
initWithDictionary: dictionary];
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object forKey: (id)key
forKey: (id)key
{
return (id)[[OFMapTableDictionary alloc] initWithObject: object
forKey: key];
}
- (instancetype)initWithObjects: (OFArray *)objects
- (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys
forKeys: (OFArray *)keys
{
return (id)[[OFMapTableDictionary alloc] initWithObjects: objects
forKeys: keys];
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
|
︙ | | |
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
-
+
-
-
+
-
-
+
|
+ (instancetype)dictionaryWithDictionary: (OFDictionary *)dictionary
{
return [[(OFDictionary *)[self alloc]
initWithDictionary: dictionary] autorelease];
}
+ (instancetype)dictionaryWithObject: (id)object
+ (instancetype)dictionaryWithObject: (id)object forKey: (id)key
forKey: (id)key
{
return [[[self alloc] initWithObject: object
return [[[self alloc] initWithObject: object forKey: key] autorelease];
forKey: key] autorelease];
}
+ (instancetype)dictionaryWithObjects: (OFArray *)objects
forKeys: (OFArray *)keys
{
return [[[self alloc] initWithObjects: objects
forKeys: keys] autorelease];
}
+ (instancetype)dictionaryWithObjects: (id const *)objects
forKeys: (id const *)keys
count: (size_t)count
count: (size_t)count
{
return [[[self alloc] initWithObjects: objects
forKeys: keys
count: count] autorelease];
}
+ (instancetype)dictionaryWithKeysAndObjects: (id)firstKey, ...
|
︙ | | |
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
-
+
-
|
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object forKey: (id)key
forKey: (id)key
{
if (key == nil || object == nil)
@throw [OFInvalidArgumentException exception];
return [self initWithKeysAndObjects: key, object, nil];
}
|
︙ | | |
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
-
+
-
-
-
+
-
|
objects = objects_.objects;
keys = keys_.objects;
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithObjects: objects
return [self initWithObjects: objects forKeys: keys count: count];
forKeys: keys
count: count];
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
count: (size_t)count
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithKeysAndObjects: (id)firstKey, ...
{
id ret;
va_list arguments;
va_start(arguments, firstKey);
ret = [self initWithKey: firstKey
ret = [self initWithKey: firstKey arguments: arguments];
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
|
︙ | | |
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
|
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
|
-
+
-
-
+
-
|
uint8_t tmp = 0x80 | ((uint8_t)count & 0xF);
[data addItem: &tmp];
} else if (count <= UINT16_MAX) {
uint8_t type = 0xDE;
uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)count);
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (count <= UINT32_MAX) {
uint8_t type = 0xDF;
uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count);
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
pool = objc_autoreleasePoolPush();
i = 0;
keyEnumerator = [self keyEnumerator];
|
︙ | | |
Modified src/OFDimensionValue.m
from [8625e742ff]
to [8d1db9e33c].
︙ | | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
-
+
-
|
}
- (const char *)objCType
{
return @encode(of_dimension_t);
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
if (size != sizeof(_dimension))
@throw [OFOutOfRangeException exception];
memcpy(value, &_dimension, sizeof(_dimension));
}
|
︙ | | |
Modified src/OFFileManager.m
from [638373cb3e]
to [6804846ccf].
︙ | | |
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
-
+
-
-
-
|
if (URL == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
[URLHandler setAttributes: attributes
[URLHandler setAttributes: attributes ofItemAtURL: URL];
ofItemAtURL: URL];
}
#ifdef OF_HAVE_FILES
- (void)setAttributes: (of_file_attributes_t)attributes
ofItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self setAttributes: attributes
ofItemAtURL: [OFURL fileURLWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
- (bool)fileExistsAtURL: (OFURL *)URL
{
OFURLHandler *URLHandler;
|
︙ | | |
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
|
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
-
+
-
-
+
-
-
+
-
|
void *pool = objc_autoreleasePoolPush();
[self changeCurrentDirectoryPath: URL.fileSystemRepresentation];
objc_autoreleasePoolPop(pool);
}
- (void)copyItemAtPath: (OFString *)source
- (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination
toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self copyItemAtURL: [OFURL fileURLWithPath: source]
toURL: [OFURL fileURLWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)copyItemAtURL: (OFURL *)source
- (void)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
void *pool;
OFURLHandler *URLHandler;
of_file_attributes_t attributes;
of_file_type_t type;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if ((URLHandler = [OFURLHandler handlerForURL: source]) == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: source];
if ([URLHandler copyItemAtURL: source
if ([URLHandler copyItemAtURL: source toURL: destination])
toURL: destination])
return;
if ([self fileExistsAtURL: destination])
@throw [OFCopyItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
errNo: EEXIST];
|
︙ | | |
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
|
-
+
-
|
OFURL *sourceURL, *destinationURL;
sourceURL =
[source URLByAppendingPathComponent: item];
destinationURL =
[destination URLByAppendingPathComponent: item];
[self copyItemAtURL: sourceURL
[self copyItemAtURL: sourceURL toURL: destinationURL];
toURL: destinationURL];
objc_autoreleasePoolPop(pool2);
}
} else if ([type isEqual: of_file_type_regular]) {
size_t pageSize = [OFSystemInfo pageSize];
OFStream *sourceStream = nil;
OFStream *destinationStream = nil;
|
︙ | | |
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
|
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
|
-
+
-
-
-
-
+
-
-
+
-
-
+
-
|
destinationURL: destination
errNo: EINVAL];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_FILES
- (void)moveItemAtPath: (OFString *)source
- (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination
toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self moveItemAtURL: [OFURL fileURLWithPath: source]
toURL: [OFURL fileURLWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)moveItemAtURL: (OFURL *)source
- (void)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
void *pool;
OFURLHandler *URLHandler;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if ((URLHandler = [OFURLHandler handlerForURL: source]) == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: source];
@try {
if ([URLHandler moveItemAtURL: source
if ([URLHandler moveItemAtURL: source toURL: destination])
toURL: destination])
return;
} @catch (OFMoveItemFailedException *e) {
if (e.errNo != EXDEV)
@throw e;
}
if ([self fileExistsAtURL: destination])
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
errNo: EEXIST];
@try {
[self copyItemAtURL: source
[self copyItemAtURL: source toURL: destination];
toURL: destination];
} @catch (OFCopyItemFailedException *e) {
[self removeItemAtURL: destination];
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
errNo: e.errNo];
|
︙ | | |
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
|
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
|
-
-
-
+
-
-
+
-
-
+
-
-
-
-
+
-
-
-
|
[URLHandler removeItemAtURL: URL];
}
#ifdef OF_HAVE_FILES
- (void)removeItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self removeItemAtURL: [OFURL fileURLWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)linkItemAtURL: (OFURL *)source
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
void *pool = objc_autoreleasePoolPush();
OFURLHandler *URLHandler;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
if (![destination.scheme isEqual: source.scheme])
@throw [OFInvalidArgumentException exception];
URLHandler = [OFURLHandler handlerForURL: source];
if (URLHandler == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: source];
[URLHandler linkItemAtURL: source
[URLHandler linkItemAtURL: source toURL: destination];
toURL: destination];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
- (void)linkItemAtPath: (OFString *)source
- (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination
toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self linkItemAtURL: [OFURL fileURLWithPath: source]
toURL: [OFURL fileURLWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)createSymbolicLinkAtURL: (OFURL *)URL
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
OFURLHandler *URLHandler;
if (URL == nil || target == nil)
@throw [OFInvalidArgumentException exception];
URLHandler = [OFURLHandler handlerForURL: URL];
if (URLHandler == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
[URLHandler createSymbolicLinkAtURL: URL
[URLHandler createSymbolicLinkAtURL: URL withDestinationPath: target];
withDestinationPath: target];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
- (void)createSymbolicLinkAtPath: (OFString *)path
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
[self createSymbolicLinkAtURL: [OFURL fileURLWithPath: path]
withDestinationPath: target];
objc_autoreleasePoolPop(pool);
}
#endif
@end
@implementation OFDefaultFileManager
- (instancetype)autorelease
|
︙ | | |
Modified src/OFFileURLHandler.m
from [1adfb51735]
to [5499dbdb21].
︙ | | |
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
|
-
+
-
|
if (of_stat(path, &s) != 0)
return false;
return S_ISDIR(s.st_mode);
}
- (OFStream *)openItemAtURL: (OFURL *)URL
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [[OFFile alloc]
initWithPath: URL.fileSystemRepresentation
mode: mode];
objc_autoreleasePoolPop(pool);
|
︙ | | |
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
|
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
|
-
-
|
mode: nil
errNo: retrieveError()];
while (ExNext(lock, &fib)) {
OFString *file = [[OFString alloc]
initWithCString: fib.fib_FileName
encoding: encoding];
@try {
[files addObject: file];
} @finally {
[file release];
}
}
# endif
if (IoErr() != ERROR_NO_MORE_ENTRIES)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: 0
errNo: retrieveError()];
} @finally {
UnLock(lock);
}
#else
of_string_encoding_t encoding = [OFLocale encoding];
DIR *dir;
if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL)
@throw [OFOpenItemFailedException exceptionWithURL: URL
mode: nil
errNo: errno];
# if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS)
@try {
|
︙ | | |
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
|
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
|
-
+
-
|
errNo: retrieveError()];
#endif
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
- (void)linkItemAtURL: (OFURL *)source
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
void *pool = objc_autoreleasePoolPush();
OFString *sourcePath, *destinationPath;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
|
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
|
-
+
-
|
errNo: retrieveError()];
# endif
objc_autoreleasePoolPop(pool);
}
#endif
- (bool)moveItemAtURL: (OFURL *)source
- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
void *pool;
if (![source.scheme isEqual: _scheme] ||
![destination.scheme isEqual: _scheme])
return false;
|
︙ | | |
Modified src/OFGZIPStream.m
from [4ed53f9a5c]
to [5c08122bde].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
#import "OFNotOpenException.h"
#import "OFTruncatedDataException.h"
@implementation OFGZIPStream
@synthesize operatingSystemMadeOn = _operatingSystemMadeOn;
@synthesize modificationDate = _modificationDate;
+ (instancetype)streamWithStream: (OFStream *)stream
+ (instancetype)streamWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
mode: mode] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithStream: (OFStream *)stream
- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
self = [super init];
@try {
if (![mode isEqual: @"r"])
@throw [OFNotImplementedException
exceptionWithSelector: _cmd
|
︙ | | |
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
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
105
106
107
108
109
110
111
112
113
114
115
116
|
-
+
-
-
+
-
-
+
-
|
[_inflateStream release];
[_modificationDate release];
[super dealloc];
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
for (;;) {
uint8_t byte;
uint32_t CRC32, uncompressedSize;
if (_stream.atEndOfStream) {
if (_state != OF_GZIP_STREAM_ID1)
@throw [OFTruncatedDataException exception];
return 0;
}
switch (_state) {
case OF_GZIP_STREAM_ID1:
case OF_GZIP_STREAM_ID2:
case OF_GZIP_STREAM_COMPRESSION_METHOD:
if ([_stream readIntoBuffer: &byte
if ([_stream readIntoBuffer: &byte length: 1] < 1)
length: 1] < 1)
return 0;
if ((_state == OF_GZIP_STREAM_ID1 && byte != 0x1F) ||
(_state == OF_GZIP_STREAM_ID2 && byte != 0x8B) ||
(_state == OF_GZIP_STREAM_COMPRESSION_METHOD &&
byte != 8))
@throw [OFInvalidFormatException exception];
_state++;
break;
case OF_GZIP_STREAM_FLAGS:
if ([_stream readIntoBuffer: &byte
if ([_stream readIntoBuffer: &byte length: 1] < 1)
length: 1] < 1)
return 0;
_flags = byte;
_state++;
break;
case OF_GZIP_STREAM_MODIFICATION_TIME:
_bytesRead += [_stream
|
︙ | | |
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
-
+
-
-
+
-
|
(_buffer[3] << 24) | (_buffer[2] << 16) |
(_buffer[1] << 8) | _buffer[0]];
_bytesRead = 0;
_state++;
break;
case OF_GZIP_STREAM_EXTRA_FLAGS:
if ([_stream readIntoBuffer: &byte
if ([_stream readIntoBuffer: &byte length: 1] < 1)
length: 1] < 1)
return 0;
_extraFlags = byte;
_state++;
break;
case OF_GZIP_STREAM_OPERATING_SYSTEM:
if ([_stream readIntoBuffer: &byte
if ([_stream readIntoBuffer: &byte length: 1] < 1)
length: 1] < 1)
return 0;
_operatingSystemMadeOn = byte;
_state++;
break;
case OF_GZIP_STREAM_EXTRA_LENGTH:
if (!(_flags & OF_GZIP_STREAM_FLAG_EXTRA)) {
|
︙ | | |
Modified src/OFHMAC.m
from [0effc9def0]
to [a4fe560b23].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
-
+
-
|
[_innerHash release];
[_outerHashCopy release];
[_innerHashCopy release];
[super dealloc];
}
- (void)setKey: (const void *)key
- (void)setKey: (const void *)key length: (size_t)length
length: (size_t)length
{
void *pool = objc_autoreleasePoolPush();
size_t blockSize = [_hashClass blockSize];
OFSecureData *outerKeyPad = [OFSecureData
dataWithCount: blockSize
allowsSwappableMemory: _allowsSwappableMemory];
OFSecureData *innerKeyPad = [OFSecureData
|
︙ | | |
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
-
-
+
-
|
_outerHash = _innerHash = _outerHashCopy = _innerHashCopy = nil;
@try {
if (length > blockSize) {
id <OFCryptoHash> hash = [_hashClass
cryptoHashWithAllowsSwappableMemory:
_allowsSwappableMemory];
[hash updateWithBuffer: key
[hash updateWithBuffer: key length: length];
length: length];
length = hash.digestSize;
if OF_UNLIKELY (length > blockSize)
length = blockSize;
memcpy(outerKeyPadItems, hash.digest, length);
memcpy(innerKeyPadItems, hash.digest, length);
|
︙ | | |
127
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
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
-
+
-
-
+
-
|
_outerHashCopy = [_outerHash copy];
_innerHashCopy = [_innerHash copy];
_calculated = false;
}
- (void)updateWithBuffer: (const void *)buffer
- (void)updateWithBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
if (_innerHash == nil)
@throw [OFInvalidArgumentException exception];
if (_calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithObject: self];
[_innerHash updateWithBuffer: buffer
[_innerHash updateWithBuffer: buffer length: length];
length: length];
}
- (const unsigned char *)digest
{
if (_outerHash == nil || _innerHash == nil)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
Modified src/OFHTTPClient.m
from [4079ebb727]
to [02e9faa541].
︙ | | |
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
|
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
|
-
+
-
|
}
URLPort = URL.port;
if (URLPort != nil)
port = URLPort.unsignedShortValue;
sock.delegate = self;
[sock asyncConnectToHost: URL.host
[sock asyncConnectToHost: URL.host port: port];
port: port];
} @catch (id e) {
[self raiseException: e];
}
}
@end
@implementation OFHTTPClientRequestBodyStream
|
︙ | | |
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
|
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
|
-
+
-
|
errNo: 0];
if (_chunked)
[_socket writeFormat: @"%zX\r\n", length];
else if (length > _toWrite)
length = (size_t)_toWrite;
ret = [_socket writeBuffer: buffer
ret = [_socket writeBuffer: buffer length: length];
length: length];
if (_chunked)
[_socket writeString: @"\r\n"];
if (ret > length)
@throw [OFOutOfRangeException exception];
if (!_chunked) {
|
︙ | | |
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
|
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
|
-
+
-
-
+
-
-
+
-
-
-
+
-
-
+
-
-
+
-
-
|
_toRead = (long long)toRead;
} @catch (OFInvalidFormatException *e) {
@throw [OFInvalidServerReplyException exception];
}
}
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
if (_socket == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
return 0;
if (!_hasContentLength && !_chunked)
return [_socket readIntoBuffer: buffer
return [_socket readIntoBuffer: buffer length: length];
length: length];
if (_socket.atEndOfStream)
@throw [OFTruncatedDataException exception];
/* Content-Length */
if (!_chunked) {
size_t ret;
if (length > (unsigned long long)_toRead)
length = (size_t)_toRead;
ret = [_socket readIntoBuffer: buffer
ret = [_socket readIntoBuffer: buffer length: length];
length: length];
if (ret > length)
@throw [OFOutOfRangeException exception];
_toRead -= ret;
if (_toRead == 0)
_atEndOfStream = true;
return ret;
}
/* Chunked */
if (_toRead == -2) {
char tmp[2];
switch ([_socket readIntoBuffer: tmp
switch ([_socket readIntoBuffer: tmp length: 2]) {
length: 2]) {
case 2:
_toRead++;
if (tmp[1] != '\n')
@throw [OFInvalidServerReplyException
exception];
case 1:
_toRead++;
if (tmp[0] != '\r')
@throw [OFInvalidServerReplyException
exception];
}
if (_setAtEndOfStream && _toRead == 0)
_atEndOfStream = true;
return 0;
} else if (_toRead == -1) {
char tmp;
if ([_socket readIntoBuffer: &tmp
if ([_socket readIntoBuffer: &tmp length: 1] == 1) {
length: 1] == 1) {
_toRead++;
if (tmp != '\n')
@throw [OFInvalidServerReplyException
exception];
}
if (_setAtEndOfStream && _toRead == 0)
_atEndOfStream = true;
return 0;
} else if (_toRead > 0) {
if (length > (unsigned long long)_toRead)
length = (size_t)_toRead;
length = [_socket readIntoBuffer: buffer
length = [_socket readIntoBuffer: buffer length: length];
length: length];
_toRead -= length;
if (_toRead == 0)
_toRead = -2;
return length;
} else {
void *pool = objc_autoreleasePoolPush();
OFString *line;
|
︙ | | |
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
|
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
|
-
+
-
-
-
|
[super dealloc];
}
- (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request
redirects: (unsigned int)redirects
{
[_client asyncPerformRequest: request
[_client asyncPerformRequest: request redirects: redirects];
redirects: redirects];
[[OFRunLoop currentRunLoop] run];
return _response;
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
exception: (id)exception
|
︙ | | |
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
|
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
|
-
+
-
|
[self close];
[super dealloc];
}
- (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request
{
return [self performRequest: request
return [self performRequest: request redirects: REDIRECTS_DEFAULT];
redirects: REDIRECTS_DEFAULT];
}
- (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request
redirects: (unsigned int)redirects
{
void *pool = objc_autoreleasePoolPush();
OFHTTPClientSyncPerformer *syncPerformer =
|
︙ | | |
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
|
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
|
-
+
-
|
objc_autoreleasePoolPop(pool);
return [response autorelease];
}
- (void)asyncPerformRequest: (OFHTTPRequest *)request
{
[self asyncPerformRequest: request
[self asyncPerformRequest: request redirects: REDIRECTS_DEFAULT];
redirects: REDIRECTS_DEFAULT];
}
- (void)asyncPerformRequest: (OFHTTPRequest *)request
redirects: (unsigned int)redirects
{
void *pool = objc_autoreleasePoolPush();
OFURL *URL = request.URL;
|
︙ | | |
Modified src/OFHTTPCookieManager.m
from [3511ad0390]
to [a7b81a9286].
︙ | | |
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
-
+
-
|
}
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
{
return [[_cookies copy] autorelease];
}
- (void)addCookie: (OFHTTPCookie *)cookie
- (void)addCookie: (OFHTTPCookie *)cookie forURL: (OFURL *)URL
forURL: (OFURL *)URL
{
void *pool = objc_autoreleasePoolPush();
OFString *cookieDomain, *URLHost;
size_t i;
if (![cookie.path hasPrefix: @"/"])
cookie.path = @"/";
|
︙ | | |
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
-
+
-
-
-
+
-
|
}
i = 0;
for (OFHTTPCookie *iter in _cookies) {
if ([iter.name isEqual: cookie.name] &&
[iter.domain isEqual: cookie.domain] &&
[iter.path isEqual: cookie.path]) {
[_cookies replaceObjectAtIndex: i
[_cookies replaceObjectAtIndex: i withObject: cookie];
withObject: cookie];
objc_autoreleasePoolPop(pool);
return;
}
i++;
}
[_cookies addObject: cookie];
objc_autoreleasePoolPop(pool);
}
- (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
forURL: (OFURL *)URL
{
for (OFHTTPCookie *cookie in cookies)
[self addCookie: cookie
[self addCookie: cookie forURL: URL];
forURL: URL];
}
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURL: (OFURL *)URL
{
OFMutableArray *ret = [OFMutableArray array];
for (OFHTTPCookie *cookie in _cookies) {
|
︙ | | |
Modified src/OFHTTPServer.m
from [038308e952]
to [bf72062f11].
︙ | | |
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
-
+
-
-
+
-
-
+
-
|
_headersSent = true;
_chunked = [[headers objectForKey: @"Transfer-Encoding"]
isEqual: @"chunked"];
objc_autoreleasePoolPop(pool);
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
/* TODO: Use non-blocking writes */
void *pool;
if (_socket == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (!_headersSent)
[self of_sendHeaders];
if (!_chunked)
return [_socket writeBuffer: buffer
return [_socket writeBuffer: buffer length: length];
length: length];
pool = objc_autoreleasePoolPush();
[_socket writeString: [OFString stringWithFormat: @"%zX\r\n", length]];
objc_autoreleasePoolPop(pool);
[_socket writeBuffer: buffer
[_socket writeBuffer: buffer length: length];
length: length];
[_socket writeString: @"\r\n"];
return length;
}
- (void)close
{
|
︙ | | |
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
-
-
|
return true;
}
- (bool)sendErrorAndClose: (short)statusCode
{
OFString *date = [[OFDate date]
dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"];
[_socket writeFormat: @"HTTP/1.1 %hd %@\r\n"
@"Date: %@\r\n"
@"Server: %@\r\n"
@"\r\n",
statusCode,
of_http_status_code_to_string(statusCode),
date, _server.name];
return false;
}
- (void)createResponse
{
void *pool = objc_autoreleasePoolPush();
OFMutableURL *URL;
|
︙ | | |
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
|
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
|
}
- (bool)lowlevelIsAtEndOfStream
{
return _atEndOfStream;
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
if (_socket == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
return 0;
if (_socket.atEndOfStream)
@throw [OFTruncatedDataException exception];
/* Content-Length */
if (!_chunked) {
size_t ret;
if (length > (unsigned long long)_toRead)
length = (size_t)_toRead;
ret = [_socket readIntoBuffer: buffer
ret = [_socket readIntoBuffer: buffer length: length];
length: length];
_toRead -= ret;
if (_toRead == 0)
_atEndOfStream = true;
return ret;
}
/* Chunked */
if (_toRead == -2) {
char tmp[2];
switch ([_socket readIntoBuffer: tmp
switch ([_socket readIntoBuffer: tmp length: 2]) {
length: 2]) {
case 2:
_toRead++;
if (tmp[1] != '\n')
@throw [OFInvalidFormatException exception];
case 1:
_toRead++;
if (tmp[0] != '\r')
@throw [OFInvalidFormatException exception];
}
if (_setAtEndOfStream && _toRead == 0)
_atEndOfStream = true;
return 0;
} else if (_toRead == -1) {
char tmp;
if ([_socket readIntoBuffer: &tmp
if ([_socket readIntoBuffer: &tmp length: 1] == 1) {
length: 1] == 1) {
_toRead++;
if (tmp != '\n')
@throw [OFInvalidFormatException exception];
}
if (_setAtEndOfStream && _toRead == 0)
_atEndOfStream = true;
return 0;
} else if (_toRead > 0) {
if (length > (unsigned long long)_toRead)
length = (size_t)_toRead;
length = [_socket readIntoBuffer: buffer
length = [_socket readIntoBuffer: buffer length: length];
length: length];
_toRead -= length;
if (_toRead == 0)
_toRead = -2;
return length;
} else {
void *pool = objc_autoreleasePoolPush();
OFString *line;
|
︙ | | |
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
|
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
|
-
+
-
|
TLSSocket.certificateFile = _certificateFile;
TLSSocket.privateKeyFile = _privateKeyFile;
TLSSocket.privateKeyPassphrase = _privateKeyPassphrase;
} else
_listeningSocket = [[OFTCPSocket alloc] init];
_port = [_listeningSocket bindToHost: _host
_port = [_listeningSocket bindToHost: _host port: _port];
port: _port];
[_listeningSocket listen];
#ifdef OF_HAVE_THREADS
if (_numberOfThreads > 1) {
OFMutableArray *threads =
[OFMutableArray arrayWithCapacity: _numberOfThreads - 1];
|
︙ | | |
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
|
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
|
-
+
|
exception: (id)exception
{
if (exception != nil) {
if (![_delegate respondsToSelector:
@selector(server:didReceiveExceptionOnListeningSocket:)])
return false;
return [_delegate server: self
return [_delegate server: self
didReceiveExceptionOnListeningSocket: exception];
}
#ifdef OF_HAVE_THREADS
if (_numberOfThreads > 1) {
OFHTTPServerThread *thread =
[_threadPool objectAtIndex: _nextThreadIndex];
|
︙ | | |
Modified src/OFHostAddressResolver.m
from [2d5bf5c91e]
to [4a261c10a0].
︙ | | |
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
-
+
-
-
+
-
-
-
|
delegate = [[[OFHostAddressResolverDelegate alloc] init] autorelease];
_runLoopMode = [resolveRunLoopMode copy];
_delegate = [delegate retain];
[self asyncResolve];
while (!delegate->_done)
[runLoop runMode: resolveRunLoopMode
[runLoop runMode: resolveRunLoopMode beforeDate: nil];
beforeDate: nil];
/* Cleanup */
[runLoop runMode: resolveRunLoopMode
[runLoop runMode: resolveRunLoopMode beforeDate: [OFDate date]];
beforeDate: [OFDate date]];
if (delegate->_exception != nil)
@throw delegate->_exception;
ret = [delegate->_addresses copy];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
@end
@implementation OFHostAddressResolverDelegate
- (void)dealloc
{
|
︙ | | |
Modified src/OFINICategory.m
from [504a2316bf]
to [af996b6de2].
︙ | | |
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
-
-
+
-
|
[stream writeFormat: @"%@\r\n", comment->_comment];
} else if ([line isKindOfClass: [OFINICategoryPair class]]) {
OFINICategoryPair *pair = line;
OFString *key = escapeString(pair->_key);
OFString *value = escapeString(pair->_value);
OFString *tmp = [OFString
stringWithFormat: @"%@=%@\r\n", key, value];
[stream writeString: tmp
[stream writeString: tmp encoding: encoding];
encoding: encoding];
} else
@throw [OFInvalidArgumentException exception];
}
return true;
}
@end
|
Modified src/OFINIFile.m
from [4d99c8e035]
to [78baed50c0].
︙ | | |
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
|
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
|
-
-
+
-
|
OFString *categoryName;
if (![line hasSuffix: @"]"])
@throw [OFInvalidFormatException exception];
categoryName = [line substringWithRange:
of_range(1, line.length - 2)];
category = [[[OFINICategory alloc]
of_initWithName: categoryName] autorelease];
[_categories addObject: category];
} else {
if (category == nil)
@throw [OFInvalidFormatException exception];
[category of_parseLine: line];
}
}
objc_autoreleasePoolPop(pool);
}
- (void)writeToFile: (OFString *)path
{
[self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8];
}
- (void)writeToFile: (OFString *)path
- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding
encoding: (of_string_encoding_t)encoding
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [OFFile fileWithPath: path mode: @"w"];
bool first = true;
for (OFINICategory *category in _categories)
if ([category of_writeToStream: file
|
︙ | | |
Modified src/OFIPSocketAsyncConnector.m
from [dac9c59275]
to [63e1f39b43].
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
-
+
-
+
-
|
# endif
else
OF_ENSURE(0);
} else {
#endif
if ([_delegate respondsToSelector:
@selector(socket:didConnectToHost:port:exception:)])
[_delegate socket: _socket
[_delegate socket: _socket
didConnectToHost: _host
port: _port
exception: _exception];
#ifdef OF_HAVE_BLOCKS
}
#endif
}
- (void)of_socketDidConnect: (id)sock
- (void)of_socketDidConnect: (id)sock exception: (id)exception
exception: (id)exception
{
if (exception != nil) {
/*
* self might be retained only by the pending async requests,
* which we're about to cancel.
*/
[[self retain] autorelease];
|
︙ | | |
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
-
+
-
|
@selector(tryNextAddressWithRunLoopMode:);
OFTimer *timer = [OFTimer
timerWithTimeInterval: 0
target: self
selector: selector
object: runLoop.currentMode
repeats: false];
[runLoop addTimer: timer
[runLoop addTimer: timer forMode: runLoop.currentMode];
forMode: runLoop.currentMode];
}
return;
}
[self didConnect];
}
|
︙ | | |
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
-
+
-
|
{
of_socket_address_t address = *(const of_socket_address_t *)
[_socketAddresses itemAtIndex: _socketAddressesIndex++];
int errNo;
of_socket_address_set_port(&address, _port);
if (![_socket of_createSocketForAddress: &address
if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [[OFConnectionFailedException alloc]
initWithHost: _host
port: _port
socket: _socket
errNo: errNo];
[self didConnect];
|
︙ | | |
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
-
+
-
|
* FIXME: Use a different thread as a work around.
*/
[_socket setCanBlock: true];
#else
[_socket setCanBlock: false];
#endif
if (![_socket of_connectSocketToAddress: &address
if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
#if !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
if (errNo == EINPROGRESS) {
[OFRunLoop of_addAsyncConnectForSocket: _socket
mode: runLoopMode
delegate: self];
return;
} else {
|
︙ | | |
Modified src/OFIPXSocket.m
from [aa8a1a2ffd]
to [8d511b567a].
︙ | | |
119
120
121
122
123
124
125
126
127
128
129
130
131
|
119
120
121
122
123
124
125
126
127
128
129
|
-
+
-
-
|
memcpy(&fixedReceiver, receiver, sizeof(fixedReceiver));
/* If it's not IPX, no fix-up needed - it will fail anyway. */
if (fixedReceiver.family == OF_SOCKET_ADDRESS_FAMILY_IPX)
fixedReceiver.sockaddr.ipx.sipx_type = _packetType;
[super sendBuffer: buffer
[super sendBuffer: buffer length: length receiver: &fixedReceiver];
length: length
receiver: &fixedReceiver];
}
#endif
@end
|
Modified src/OFInvocation.m
from [85fef7c394]
to [fa4bb596dc].
︙ | | |
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
-
+
-
-
-
+
-
-
|
[_methodSignature release];
[_arguments release];
[_returnValue release];
[super dealloc];
}
- (void)setArgument: (const void *)buffer
- (void)setArgument: (const void *)buffer atIndex: (size_t)idx
atIndex: (size_t)idx
{
OFMutableData *data = [_arguments objectAtIndex: idx];
memcpy(data.mutableItems, buffer, data.itemSize);
}
- (void)getArgument: (void *)buffer
- (void)getArgument: (void *)buffer atIndex: (size_t)idx
atIndex: (size_t)idx
{
OFData *data = [_arguments objectAtIndex: idx];
memcpy(buffer, data.items, data.itemSize);
}
- (void)setReturnValue: (const void *)buffer
{
memcpy(_returnValue.mutableItems, buffer, _returnValue.itemSize);
}
|
︙ | | |
Modified src/OFLHAArchive.m
from [2ae2007028]
to [7c9dae9bb4].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
entry: (OFLHAArchiveEntry *)entry
encoding: (of_string_encoding_t)encoding;
@end
@implementation OFLHAArchive
@synthesize encoding = _encoding;
+ (instancetype)archiveWithStream: (OFStream *)stream
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
mode: mode] autorelease];
}
#ifdef OF_HAVE_FILES
+ (instancetype)archiveWithPath: (OFString *)path
+ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode
mode: (OFString *)mode
{
return [[[self alloc] initWithPath: path
return [[[self alloc] initWithPath: path mode: mode] autorelease];
mode: mode] autorelease];
}
#endif
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithStream: (OFStream *)stream
- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
self = [super init];
@try {
_stream = [stream retain];
if ([mode isEqual: @"r"])
|
︙ | | |
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
-
+
-
-
+
-
-
+
-
-
+
-
|
@throw e;
}
return self;
}
#ifdef OF_HAVE_FILES
- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode
mode: (OFString *)mode
{
OFFile *file;
if ([mode isEqual: @"a"])
file = [[OFFile alloc] initWithPath: path
file = [[OFFile alloc] initWithPath: path mode: @"r+"];
mode: @"r+"];
else
file = [[OFFile alloc] initWithPath: path
file = [[OFFile alloc] initWithPath: path mode: mode];
mode: mode];
@try {
self = [self initWithStream: file
self = [self initWithStream: file mode: mode];
mode: mode];
} @finally {
[file release];
}
return self;
}
#endif
|
︙ | | |
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
-
+
-
-
+
-
|
{
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
return _atEndOfStream;
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
size_t ret;
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
return 0;
if (_stream.atEndOfStream && !_decompressedStream.hasDataInReadBuffer)
@throw [OFTruncatedDataException exception];
if (length > _toRead)
length = _toRead;
ret = [_decompressedStream readIntoBuffer: buffer
ret = [_decompressedStream readIntoBuffer: buffer length: length];
length: length];
_toRead -= ret;
_CRC16 = of_crc16(_CRC16, buffer, ret);
if (_toRead == 0) {
_atEndOfStream = true;
|
︙ | | |
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
-
+
-
|
while (toRead > 0) {
char buffer[512];
size_t min = toRead;
if (min > 512)
min = 512;
toRead -= [stream readIntoBuffer: buffer
toRead -= [stream readIntoBuffer: buffer length: min];
length: min];
}
}
_toRead = 0;
_skipped = true;
}
|
︙ | | |
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
-
+
-
-
+
-
|
{
self = [super init];
@try {
_entry = [entry mutableCopy];
_encoding = encoding;
_headerOffset = [stream seekToOffset: 0
_headerOffset = [stream seekToOffset: 0 whence: SEEK_CUR];
whence: SEEK_CUR];
[_entry of_writeToStream: stream
[_entry of_writeToStream: stream encoding: _encoding];
encoding: _encoding];
/*
* Retain stream last, so that -[close] called by -[dealloc]
* doesn't write in case of an error.
*/
_stream = [stream retain];
} @catch (id e) {
|
︙ | | |
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
-
+
-
|
[self close];
[_entry release];
[super dealloc];
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
uint32_t bytesWritten;
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (UINT32_MAX - _bytesWritten < length)
|
︙ | | |
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
|
-
+
-
-
+
-
-
+
-
-
+
-
|
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
_entry.uncompressedSize = _bytesWritten;
_entry.compressedSize = _bytesWritten;
_entry.CRC16 = _CRC16;
offset = [_stream seekToOffset: 0
offset = [_stream seekToOffset: 0 whence: SEEK_CUR];
whence:SEEK_CUR];
[_stream seekToOffset: _headerOffset
[_stream seekToOffset: _headerOffset whence: SEEK_SET];
whence: SEEK_SET];
[_entry of_writeToStream: _stream
[_entry of_writeToStream: _stream encoding: _encoding];
encoding: _encoding];
[_stream seekToOffset: offset
[_stream seekToOffset: offset whence: SEEK_SET];
whence: SEEK_SET];
[_stream release];
_stream = nil;
[super close];
}
@end
|
Modified src/OFLHAArchiveEntry.m
from [a71890ea74]
to [d68323165e].
︙ | | |
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
|
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
[data increaseCountBy: 2];
[data addItems: [_compressionMethod
cStringWithEncoding: OF_STRING_ENCODING_ASCII]
count: 5];
tmp32 = OF_BSWAP32_IF_BE(_compressedSize);
[data addItems: &tmp32
[data addItems: &tmp32 count: sizeof(tmp32)];
count: sizeof(tmp32)];
tmp32 = OF_BSWAP32_IF_BE(_uncompressedSize);
[data addItems: &tmp32
[data addItems: &tmp32 count: sizeof(tmp32)];
count: sizeof(tmp32)];
tmp32 = OF_BSWAP32_IF_BE((uint32_t)_date.timeIntervalSince1970);
[data addItems: &tmp32
[data addItems: &tmp32 count: sizeof(tmp32)];
count: sizeof(tmp32)];
/* Reserved */
[data increaseCountBy: 1];
/* Header level */
[data addItem: "\x02"];
/* CRC16 */
tmp16 = OF_BSWAP16_IF_BE(_CRC16);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
/* Operating system identifier */
[data addItem: "U"];
/* Common header. Contains CRC16, which is written at the end. */
tmp16 = OF_BSWAP16_IF_BE(5);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x00"];
[data increaseCountBy: 2];
tmp16 = OF_BSWAP16_IF_BE((uint16_t)fileNameLength + 3);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x01"];
[data addItems: fileName
[data addItems: fileName count: fileNameLength];
count: fileNameLength];
if (directoryNameLength > 0) {
tmp16 = OF_BSWAP16_IF_BE((uint16_t)directoryNameLength + 3);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x02"];
[data addItems: directoryName
[data addItems: directoryName count: directoryNameLength];
count: directoryNameLength];
}
if (_fileComment != nil) {
size_t fileCommentLength =
[_fileComment cStringLengthWithEncoding: encoding];
if (fileCommentLength > UINT16_MAX - 3)
@throw [OFOutOfRangeException exception];
tmp16 = OF_BSWAP16_IF_BE((uint16_t)fileCommentLength + 3);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x3F"];
[data addItems: [_fileComment cStringWithEncoding: encoding]
count: fileCommentLength];
}
if (_mode != nil) {
tmp16 = OF_BSWAP16_IF_BE(5);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x50"];
tmp16 = OF_BSWAP16_IF_BE(_mode.unsignedShortValue);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
}
if (_UID != nil || _GID != nil) {
if (_UID == nil || _GID == nil)
@throw [OFInvalidArgumentException exception];
tmp16 = OF_BSWAP16_IF_BE(7);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x51"];
tmp16 = OF_BSWAP16_IF_BE(_GID.unsignedShortValue);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
tmp16 = OF_BSWAP16_IF_BE(_UID.unsignedShortValue);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
}
if (_group != nil) {
size_t groupLength =
[_group cStringLengthWithEncoding: encoding];
if (groupLength > UINT16_MAX - 3)
@throw [OFOutOfRangeException exception];
tmp16 = OF_BSWAP16_IF_BE((uint16_t)groupLength + 3);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x52"];
[data addItems: [_group cStringWithEncoding: encoding]
count: groupLength];
}
if (_owner != nil) {
size_t ownerLength =
[_owner cStringLengthWithEncoding: encoding];
if (ownerLength > UINT16_MAX - 3)
@throw [OFOutOfRangeException exception];
tmp16 = OF_BSWAP16_IF_BE((uint16_t)ownerLength + 3);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x53"];
[data addItems: [_owner cStringWithEncoding: encoding]
count: ownerLength];
}
if (_modificationDate != nil) {
tmp16 = OF_BSWAP16_IF_BE(7);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItem: "\x54"];
tmp32 = OF_BSWAP32_IF_BE(
(uint32_t)_modificationDate.timeIntervalSince1970);
[data addItems: &tmp32
[data addItems: &tmp32 count: sizeof(tmp32)];
count: sizeof(tmp32)];
}
for (OFData *extension in _extensions) {
size_t extensionLength = extension.count;
if (extension.itemSize != 1)
@throw [OFInvalidArgumentException exception];
if (extensionLength > UINT16_MAX - 2)
@throw [OFOutOfRangeException exception];
tmp16 = OF_BSWAP16_IF_BE((uint16_t)extensionLength + 2);
[data addItems: &tmp16
[data addItems: &tmp16 count: sizeof(tmp16)];
count: sizeof(tmp16)];
[data addItems: extension.items
[data addItems: extension.items count: extension.count];
count: extension.count];
}
/* Zero-length extension to terminate */
[data increaseCountBy: 2];
headerSize = data.count;
|
︙ | | |
Modified src/OFList.m
from [9079ad9449]
to [734046ca66].
︙ | | |
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
-
+
-
|
[ret appendString: [iter->object description]];
if (iter->next != NULL)
[ret appendString: @",\n"];
objc_autoreleasePoolPop(pool);
}
[ret replaceOccurrencesOfString: @"\n"
[ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"];
withString: @"\n\t"];
[ret appendString: @"\n]"];
[ret makeImmutable];
return ret;
}
|
︙ | | |
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
-
+
-
-
+
+
|
memcpy(state->extra, &listObject, sizeof(listObject));
return count;
}
- (OFEnumerator *)objectEnumerator
{
return [[[OFListEnumerator alloc]
return [[[OFListEnumerator alloc] initWithList: self
initWithList: self
mutationsPointer: &_mutations] autorelease];
mutationsPointer: &_mutations]
autorelease];
}
@end
@implementation OFListEnumerator
- (instancetype)initWithList: (OFList *)list
mutationsPointer: (unsigned long *)mutationsPtr
{
|
︙ | | |
Modified src/OFLocale.m
from [f919bded41]
to [43f4209e77].
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
-
+
+
-
-
+
-
-
+
-
-
+
|
} @finally {
free(locale);
}
}
#endif
static bool
evaluateCondition(OFString *condition, OFDictionary *variables)
evaluateCondition(OFString *condition_, OFDictionary *variables)
{
OFMutableString *condition = [[condition_ mutableCopy] autorelease];
OFMutableArray *tokens, *operators, *stack;
/* Empty condition is the fallback that's always true */
if (condition.length == 0)
return true;
/*
* Dirty hack to allow not needing spaces after "!" or "(" and spaces
* before ")".
* TODO: Replace with a proper tokenizer.
*/
condition = [condition stringByReplacingOccurrencesOfString: @"!"
withString: @"! "];
[condition replaceOccurrencesOfString: @"!" withString: @"! "];
condition = [condition stringByReplacingOccurrencesOfString: @"("
withString: @"( "];
[condition replaceOccurrencesOfString: @"(" withString: @"( "];
condition = [condition stringByReplacingOccurrencesOfString: @")"
withString: @" )"];
[condition replaceOccurrencesOfString: @")" withString: @" )"];
/* Substitute variables and convert to RPN first */
tokens = [OFMutableArray array];
operators = [OFMutableArray array];
for (OFString *token in [condition
componentsSeparatedByString: @" "
options: OF_STRING_SKIP_EMPTY]) {
|
︙ | | |
Modified src/OFMD5Hash.m
from [5fb4681c4e]
to [bf7cb6efee].
︙ | | |
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
-
+
-
|
{
_iVars->state[0] = 0x67452301;
_iVars->state[1] = 0xEFCDAB89;
_iVars->state[2] = 0x98BADCFE;
_iVars->state[3] = 0x10325476;
}
- (void)updateWithBuffer: (const void *)buffer_
- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length
length: (size_t)length
{
const unsigned char *buffer = buffer_;
if (_calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithObject: self];
|
︙ | | |
Modified src/OFMapTable.m
from [9ddf5a7d27]
to [79fa6ef127].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-
-
-
-
-
-
-
|
static bool
defaultEqual(void *object1, void *object2)
{
return (object1 == object2);
}
OF_DIRECT_MEMBERS
@interface OFMapTable ()
- (void)of_setObject: (void *)object
forKey: (void *)key
hash: (unsigned long)hash;
@end
OF_DIRECT_MEMBERS
@interface OFMapTableEnumerator ()
- (instancetype)of_initWithMapTable: (OFMapTable *)mapTable
buckets: (struct of_map_table_bucket **)buckets
capacity: (unsigned long)capacity
mutationsPointer: (unsigned long *)mutationsPtr
OF_METHOD_FAMILY(init);
|
︙ | | |
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
-
-
-
+
+
+
-
|
initWithKeyFunctions: _keyFunctions
objectFunctions: _objectFunctions
capacity: _capacity];
@try {
for (unsigned long i = 0; i < _capacity; i++)
if (_buckets[i] != NULL && _buckets[i] != &deleted)
[copy of_setObject: _buckets[i]->object
forKey: _buckets[i]->key
hash: OF_ROR(_buckets[i]->hash,
setObject(copy, _buckets[i]->key,
_buckets[i]->object,
OF_ROR(_buckets[i]->hash, _rotate));
_rotate)];
} @catch (id e) {
[copy release];
@throw e;
}
return copy;
}
|
︙ | | |
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
|
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
|
+
-
+
-
+
+
-
+
-
+
-
+
-
+
+
-
+
-
-
+
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
+
-
-
+
+
-
+
-
+
-
-
+
+
+
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
|
if (_keyFunctions.equal(_buckets[i]->key, key))
return _buckets[i]->object;
}
return NULL;
}
static void
- (void)of_resizeForCount: (unsigned long)count OF_DIRECT
resizeForCount(OFMapTable *self, unsigned long count)
{
unsigned long fullness, capacity;
struct of_map_table_bucket **buckets;
if (count > ULONG_MAX / sizeof(*_buckets) || count > ULONG_MAX / 8)
if (count > ULONG_MAX / sizeof(*self->_buckets) ||
count > ULONG_MAX / 8)
@throw [OFOutOfRangeException exception];
fullness = count * 8 / _capacity;
fullness = count * 8 / self->_capacity;
if (fullness >= 6) {
if (_capacity > ULONG_MAX / 2)
if (self->_capacity > ULONG_MAX / 2)
return;
capacity = _capacity * 2;
capacity = self->_capacity * 2;
} else if (fullness <= 1)
capacity = _capacity / 2;
capacity = self->_capacity / 2;
else
return;
/*
* Don't downsize if we have an initial capacity or if we would fall
* below the minimum capacity.
*/
if ((capacity < self->_capacity && count > self->_count) ||
if ((capacity < _capacity && count > _count) || capacity < MIN_CAPACITY)
capacity < MIN_CAPACITY)
return;
buckets = of_alloc_zeroed(capacity, sizeof(*buckets));
for (unsigned long i = 0; i < _capacity; i++) {
if (_buckets[i] != NULL && _buckets[i] != &deleted) {
for (unsigned long i = 0; i < self->_capacity; i++) {
if (self->_buckets[i] != NULL &&
self->_buckets[i] != &deleted) {
unsigned long j, last;
last = capacity;
for (j = _buckets[i]->hash & (capacity - 1);
for (j = self->_buckets[i]->hash & (capacity - 1);
j < last && buckets[j] != NULL; j++);
/* In case the last bucket is already used */
if (j >= last) {
last = _buckets[i]->hash & (capacity - 1);
last = self->_buckets[i]->hash & (capacity - 1);
for (j = 0; j < last &&
buckets[j] != NULL; j++);
}
if (j >= last)
@throw [OFOutOfRangeException exception];
buckets[j] = _buckets[i];
buckets[j] = self->_buckets[i];
}
}
free(_buckets);
_buckets = buckets;
_capacity = capacity;
free(self->_buckets);
self->_buckets = buckets;
self->_capacity = capacity;
}
- (void)of_setObject: (void *)object
forKey: (void *)key
hash: (unsigned long)hash
static void
setObject(OFMapTable *restrict self, void *key, void *object,
unsigned long hash)
{
unsigned long i, last;
void *old;
if (key == NULL || object == NULL)
@throw [OFInvalidArgumentException exception];
hash = OF_ROL(hash, _rotate);
last = _capacity;
hash = OF_ROL(hash, self->_rotate);
last = self->_capacity;
for (i = hash & (self->_capacity - 1);
for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) {
if (_buckets[i] == &deleted)
i < last && self->_buckets[i] != NULL; i++) {
if (self->_buckets[i] == &deleted)
continue;
if (_keyFunctions.equal(_buckets[i]->key, key))
if (self->_keyFunctions.equal(self->_buckets[i]->key, key))
break;
}
/* In case the last bucket is already used */
if (i >= last) {
last = hash & (_capacity - 1);
last = hash & (self->_capacity - 1);
for (i = 0; i < last && _buckets[i] != NULL; i++) {
if (_buckets[i] == &deleted)
for (i = 0; i < last && self->_buckets[i] != NULL; i++) {
if (self->_buckets[i] == &deleted)
continue;
if (self->_keyFunctions.equal(
if (_keyFunctions.equal(_buckets[i]->key, key))
self->_buckets[i]->key, key))
break;
}
}
/* Key not in map table */
if (i >= last || self->_buckets[i] == NULL ||
if (i >= last || _buckets[i] == NULL || _buckets[i] == &deleted ||
!_keyFunctions.equal(_buckets[i]->key, key)) {
self->_buckets[i] == &deleted ||
!self->_keyFunctions.equal(self->_buckets[i]->key, key)) {
struct of_map_table_bucket *bucket;
[self of_resizeForCount: _count + 1];
resizeForCount(self, self->_count + 1);
_mutations++;
last = _capacity;
self->_mutations++;
last = self->_capacity;
for (i = hash & (_capacity - 1); i < last &&
_buckets[i] != NULL && _buckets[i] != &deleted; i++);
for (i = hash & (self->_capacity - 1); i < last &&
self->_buckets[i] != NULL && self->_buckets[i] != &deleted;
i++);
/* In case the last bucket is already used */
if (i >= last) {
last = hash & (_capacity - 1);
last = hash & (self->_capacity - 1);
for (i = 0; i < last && _buckets[i] != NULL &&
_buckets[i] != &deleted; i++);
for (i = 0; i < last && self->_buckets[i] != NULL &&
self->_buckets[i] != &deleted; i++);
}
if (i >= last)
@throw [OFOutOfRangeException exception];
bucket = of_alloc(1, sizeof(*bucket));
@try {
bucket->key = _keyFunctions.retain(key);
bucket->key = self->_keyFunctions.retain(key);
} @catch (id e) {
free(bucket);
@throw e;
}
@try {
bucket->object = _objectFunctions.retain(object);
bucket->object = self->_objectFunctions.retain(object);
} @catch (id e) {
_keyFunctions.release(bucket->key);
self->_keyFunctions.release(bucket->key);
free(bucket);
@throw e;
}
bucket->hash = hash;
_buckets[i] = bucket;
_count++;
self->_buckets[i] = bucket;
self->_count++;
return;
}
old = _buckets[i]->object;
_buckets[i]->object = _objectFunctions.retain(object);
_objectFunctions.release(old);
old = self->_buckets[i]->object;
self->_buckets[i]->object = self->_objectFunctions.retain(object);
self->_objectFunctions.release(old);
}
- (void)setObject: (void *)object forKey: (void *)key
{
[self of_setObject: object forKey: key hash: _keyFunctions.hash(key)];
setObject(self, key, object,_keyFunctions.hash(key));
}
- (void)removeObjectForKey: (void *)key
{
unsigned long i, hash, last;
if (key == NULL)
|
︙ | | |
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
-
+
|
_keyFunctions.release(_buckets[i]->key);
_objectFunctions.release(_buckets[i]->object);
free(_buckets[i]);
_buckets[i] = &deleted;
_count--;
[self of_resizeForCount: _count];
resizeForCount(self, _count);
return;
}
}
if (i < last)
return;
|
︙ | | |
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
-
+
|
_objectFunctions.release(_buckets[i]->object);
free(_buckets[i]);
_buckets[i] = &deleted;
_count--;
_mutations++;
[self of_resizeForCount: _count];
resizeForCount(self, _count);
return;
}
}
}
- (void)removeAllObjects
|
︙ | | |
Modified src/OFMapTableDictionary.m
from [0842a7ed65]
to [992c305595].
︙ | | |
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithKey: (id)firstKey
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
arguments: (va_list)arguments
{
self = [super init];
@try {
va_list argumentsCopy;
id key, object;
size_t i, count;
|
︙ | | |
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
-
+
-
|
assert(i < count);
keys[i++] = (id)*keyPtr;
}
objc_autoreleasePoolPop(pool);
ret = [OFArray arrayWithObjects: keys
ret = [OFArray arrayWithObjects: keys count: count];
count: count];
} @finally {
free(keys);
}
return ret;
}
|
︙ | | |
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
-
+
-
|
assert(i < count);
objects[i++] = (id)*objectPtr;
}
objc_autoreleasePoolPop(pool);
ret = [OFArray arrayWithObjects: objects
ret = [OFArray arrayWithObjects: objects count: count];
count: count];
} @finally {
free(objects);
}
return ret;
}
|
︙ | | |
Modified src/OFMapTableSet.m
from [61aefc4e65]
to [c0e93f6d5b].
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
self = [self initWithCapacity: count];
@try {
for (size_t i = 0; i < count; i++)
[_mapTable setObject: (void *)1 forKey: objects[i]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
self = [super init];
@try {
id object;
va_list argumentsCopy;
size_t count;
|
︙ | | |
Modified src/OFMessagePackExtension.m
from [2e0b603741]
to [bfafebb5dc].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@implementation OFMessagePackExtension
@synthesize type = _type, data = _data;
+ (instancetype)extensionWithType: (int8_t)type
+ (instancetype)extensionWithType: (int8_t)type data: (OFData *)data
data: (OFData *)data
{
return [[[self alloc] initWithType: type
return [[[self alloc] initWithType: type data: data] autorelease];
data: data] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithType: (int8_t)type
- (instancetype)initWithType: (int8_t)type data: (OFData *)data
data: (OFData *)data
{
self = [super init];
@try {
if (data == nil || data.itemSize != 1)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
120
121
122
123
124
125
126
127
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
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
-
+
-
-
+
-
-
+
-
-
|
ret = [OFMutableData dataWithCapacity: count + 4];
prefix = 0xC8;
[ret addItem: &prefix];
length = OF_BSWAP16_IF_LE((uint16_t)count);
[ret addItems: &length
[ret addItems: &length count: 2];
count: 2];
[ret addItem: &_type];
} else {
uint32_t length;
ret = [OFMutableData dataWithCapacity: count + 6];
prefix = 0xC9;
[ret addItem: &prefix];
length = OF_BSWAP32_IF_LE((uint32_t)count);
[ret addItems: &length
[ret addItems: &length count: 4];
count: 4];
[ret addItem: &_type];
}
[ret addItems: _data.items
[ret addItems: _data.items count: _data.count];
count: _data.count];
[ret makeImmutable];
return ret;
}
- (OFString *)description
{
|
︙ | | |
Modified src/OFMutableAdjacentArray.m
from [a783390738]
to [7c769150fe].
︙ | | |
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
105
106
107
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
-
+
-
|
[_array addItem: &object];
[object retain];
_mutations++;
}
- (void)insertObject: (id)object
- (void)insertObject: (id)object atIndex: (size_t)idx
atIndex: (size_t)idx
{
if (object == nil)
@throw [OFInvalidArgumentException exception];
@try {
[_array insertItem: &object
[_array insertItem: &object atIndex: idx];
atIndex: idx];
} @catch (OFOutOfRangeException *e) {
@throw [OFOutOfRangeException exception];
}
[object retain];
_mutations++;
}
- (void)insertObjectsFromArray: (OFArray *)array
- (void)insertObjectsFromArray: (OFArray *)array atIndex: (size_t)idx
atIndex: (size_t)idx
{
id const *objects = array.objects;
size_t count = array.count;
@try {
[_array insertItems: objects
[_array insertItems: objects atIndex: idx count: count];
atIndex: idx
count: count];
} @catch (OFOutOfRangeException *e) {
@throw [OFOutOfRangeException exception];
}
for (size_t i = 0; i < count; i++)
[objects[i] retain];
_mutations++;
}
- (void)replaceObject: (id)oldObject
- (void)replaceObject: (id)oldObject withObject: (id)newObject
withObject: (id)newObject
{
id *objects;
size_t count;
if (oldObject == nil || newObject == nil)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
-
+
-
-
+
-
|
objects[i] = newObject;
return;
}
}
}
- (void)replaceObjectAtIndex: (size_t)idx
- (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object
withObject: (id)object
{
id *objects;
id oldObject;
if (object == nil)
@throw [OFInvalidArgumentException exception];
objects = _array.mutableItems;
if (idx >= _array.count)
@throw [OFOutOfRangeException exception];
oldObject = objects[idx];
objects[idx] = [object retain];
[oldObject release];
}
- (void)replaceObjectIdenticalTo: (id)oldObject
- (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject
withObject: (id)newObject
{
id *objects;
size_t count;
if (oldObject == nil || newObject == nil)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
-
+
-
|
[_array removeLastItem];
[object release];
_mutations++;
#endif
}
- (void)exchangeObjectAtIndex: (size_t)idx1
- (void)exchangeObjectAtIndex: (size_t)idx1 withObjectAtIndex: (size_t)idx2
withObjectAtIndex: (size_t)idx2
{
id *objects = _array.mutableItems;
size_t count = _array.count;
id tmp;
if (idx1 >= count || idx2 >= count)
@throw [OFOutOfRangeException exception];
|
︙ | | |
Modified src/OFMutableArray.m
from [72ac5c5c33]
to [2a2941cb17].
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
ret = [[OFMutableAdjacentArray alloc] initWithObject: firstObject
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
return (id)[[OFMutableAdjacentArray alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithArray: (OFArray *)array
{
return (id)[[OFMutableAdjacentArray alloc] initWithArray: array];
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
return (id)[[OFMutableAdjacentArray alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
|
︙ | | |
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
-
+
-
|
if (count == 0 || count == 1)
return;
quicksort(self, 0, count - 1, selector, options);
}
#ifdef OF_HAVE_BLOCKS
- (void)sortUsingComparator: (of_comparator_t)comparator
- (void)sortUsingComparator: (of_comparator_t)comparator options: (int)options
options: (int)options
{
size_t count = self.count;
if (count == 0 || count == 1)
return;
quicksortWithBlock(self, 0, count - 1, comparator, options);
|
︙ | | |
Modified src/OFMutableData.m
from [636b152d9a]
to [01aa579278].
︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
-
+
-
|
}
+ (instancetype)dataWithCapacity: (size_t)capacity
{
return [[[self alloc] initWithCapacity: capacity] autorelease];
}
+ (instancetype)dataWithItemSize: (size_t)itemSize
+ (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity
capacity: (size_t)capacity
{
return [[[self alloc] initWithItemSize: itemSize
capacity: capacity] autorelease];
}
- (instancetype)init
{
|
︙ | | |
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
-
+
-
|
- (instancetype)initWithCapacity: (size_t)capacity
{
return [self initWithItemSize: 1
capacity: capacity];
}
- (instancetype)initWithItemSize: (size_t)itemSize
- (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity
capacity: (size_t)capacity
{
self = [super init];
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
-
+
-
-
-
+
-
-
|
return self;
}
- (instancetype)initWithItems: (const void *)items
count: (size_t)count
itemSize: (size_t)itemSize
{
self = [super initWithItems: items
self = [super initWithItems: items count: count itemSize: itemSize];
count: count
itemSize: itemSize];
_capacity = _count;
return self;
}
- (instancetype)initWithItemsNoCopy: (void *)items
count: (size_t)count
itemSize: (size_t)itemSize
freeWhenDone: (bool)freeWhenDone
{
self = [self initWithItems: items
self = [self initWithItems: items count: count itemSize: itemSize];
count: count
itemSize: itemSize];
if (freeWhenDone)
free(items);
return self;
}
|
︙ | | |
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
-
+
-
-
+
-
-
-
+
-
|
}
memcpy(_items + _count * _itemSize, item, _itemSize);
_count++;
}
- (void)insertItem: (const void *)item
- (void)insertItem: (const void *)item atIndex: (size_t)idx
atIndex: (size_t)idx
{
[self insertItems: item
[self insertItems: item atIndex: idx count: 1];
atIndex: idx
count: 1];
}
- (void)addItems: (const void *)items
- (void)addItems: (const void *)items count: (size_t)count
count: (size_t)count
{
if (count > SIZE_MAX - _count)
@throw [OFOutOfRangeException exception];
if (_count + count > _capacity) {
_items = of_realloc(_items, _count + count, _itemSize);
_capacity = _count + count;
|
︙ | | |
Modified src/OFMutableDictionary.m
from [6a9ceedcaa]
to [76370e25f8].
︙ | | |
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
-
+
-
-
+
-
|
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
return (id)[[OFMutableMapTableDictionary alloc]
initWithDictionary: dictionary];
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object forKey: (id)key
forKey: (id)key
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObject: object
forKey: key];
}
- (instancetype)initWithObjects: (OFArray *)objects
- (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys
forKeys: (OFArray *)keys
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects
forKeys: keys];
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
|
︙ | | |
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-
+
-
|
ret = (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
|
︙ | | |
Modified src/OFMutablePair.m
from [4ca2c970a8]
to [12c9fcd056].
︙ | | |
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-
-
|
_secondObject = [secondObject retain];
[old release];
}
- (id)copy
{
OFMutablePair *copy = [self mutableCopy];
[copy makeImmutable];
return copy;
}
- (void)makeImmutable
{
object_setClass(self, [OFPair class]);
}
@end
|
Modified src/OFMutableSet.m
from [00cf253ec8]
to [880e8c01b7].
︙ | | |
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
-
+
-
-
+
-
|
ret = [[OFMutableMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
return (id)[[OFMutableMapTableSet alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
|
︙ | | |
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
-
+
|
for (id object in self) {
assert(i < count);
cArray[i++] = object;
}
for (i = 0; i < count; i++)
if (![set containsObject: cArray[i]])
[self removeObject: cArray[i]];
[self removeObject: cArray[i]];
} @finally {
free(cArray);
}
objc_autoreleasePoolPop(pool);
}
|
︙ | | |
Modified src/OFMutableString.m
from [b6e6846a4c]
to [65e4058789].
︙ | | |
229
230
231
232
233
234
235
236
237
238
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
229
230
231
232
233
234
235
236
237
238
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
-
+
-
+
-
+
-
-
+
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
return [super alloc];
}
#ifdef OF_HAVE_UNICODE_TABLES
- (void)of_convertWithWordStartTable: (const of_unichar_t *const [])startTable
wordMiddleTable: (const of_unichar_t *const [])middleTable
wordStartTableSize: (size_t)startTableSize
wordMiddleTableSize: (size_t)middleTableSize OF_DIRECT
wordMiddleTableSize: (size_t)middleTableSize
{
void *pool = objc_autoreleasePoolPush();
const of_unichar_t *characters = self.characters;
size_t length = self.length;
bool isStart = true;
for (size_t i = 0; i < length; i++) {
const of_unichar_t *const *table;
size_t tableSize;
of_unichar_t c = characters[i];
if (isStart) {
table = startTable;
tableSize = middleTableSize;
} else {
table = middleTable;
tableSize = middleTableSize;
}
if (c >> 8 < tableSize && table[c >> 8][c & 0xFF])
[self setCharacter: table[c >> 8][c & 0xFF]
[self setCharacter: table[c >> 8][c & 0xFF] atIndex: i];
atIndex: i];
isStart = of_ascii_isspace(c);
}
objc_autoreleasePoolPop(pool);
}
#else
static void
- (void)of_convertWithWordStartFunction: (char (*)(char))startFunction
wordMiddleFunction: (char (*)(char))middleFunction
convert(OFMutableString *self, char (*startFunction)(char),
char (*middleFunction)(char))
OF_DIRECT
{
void *pool = objc_autoreleasePoolPush();
const of_unichar_t *characters = self.characters;
size_t length = self.length;
bool isStart = true;
for (size_t i = 0; i < length; i++) {
char (*function)(char) =
(isStart ? startFunction : middleFunction);
of_unichar_t c = characters[i];
if (c <= 0x7F)
[self setCharacter: (int)function(c)
[self setCharacter: (int)function(c) atIndex: i];
atIndex: i];
isStart = of_ascii_isspace(c);
}
objc_autoreleasePoolPop(pool);
}
#endif
- (void)setCharacter: (of_unichar_t)character
- (void)setCharacter: (of_unichar_t)character atIndex: (size_t)idx
atIndex: (size_t)idx
{
void *pool = objc_autoreleasePoolPush();
OFString *string;
OFString *string =
string = [OFString stringWithCharacters: &character
[OFString stringWithCharacters: &character length: 1];
length: 1];
[self replaceCharactersInRange: of_range(idx, 1)
[self replaceCharactersInRange: of_range(idx, 1) withString: string];
withString: string];
objc_autoreleasePoolPop(pool);
}
- (void)appendString: (OFString *)string
{
[self insertString: string
[self insertString: string atIndex: self.length];
atIndex: self.length];
}
- (void)appendCharacters: (const of_unichar_t *)characters
length: (size_t)length
{
void *pool = objc_autoreleasePoolPush();
[self appendString: [OFString stringWithCharacters: characters
length: length]];
objc_autoreleasePoolPop(pool);
}
- (void)appendUTF8String: (const char *)UTF8String
{
void *pool = objc_autoreleasePoolPush();
[self appendString: [OFString stringWithUTF8String: UTF8String]];
objc_autoreleasePoolPop(pool);
}
- (void)appendUTF8String: (const char *)UTF8String
length: (size_t)UTF8StringLength
{
void *pool = objc_autoreleasePoolPush();
[self appendString: [OFString stringWithUTF8String: UTF8String
length: UTF8StringLength]];
objc_autoreleasePoolPop(pool);
}
- (void)appendCString: (const char *)cString
encoding: (of_string_encoding_t)encoding
{
void *pool = objc_autoreleasePoolPush();
[self appendString: [OFString stringWithCString: cString
encoding: encoding]];
objc_autoreleasePoolPop(pool);
}
- (void)appendCString: (const char *)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
{
void *pool = objc_autoreleasePoolPush();
[self appendString: [OFString stringWithCString: cString
encoding: encoding
length: cStringLength]];
objc_autoreleasePoolPop(pool);
}
- (void)appendFormat: (OFConstantString *)format, ...
{
va_list arguments;
va_start(arguments, format);
[self appendFormat: format
arguments: arguments];
va_end(arguments);
}
- (void)appendFormat: (OFConstantString *)format
- (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments
arguments: (va_list)arguments
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException exception];
if ((UTF8StringLength = of_vasprintf(&UTF8String, format.UTF8String,
arguments)) == -1)
@throw [OFInvalidFormatException exception];
@try {
[self appendUTF8String: UTF8String
[self appendUTF8String: UTF8String length: UTF8StringLength];
length: UTF8StringLength];
} @finally {
free(UTF8String);
}
}
- (void)prependString: (OFString *)string
{
[self insertString: string
[self insertString: string atIndex: 0];
atIndex: 0];
}
- (void)reverse
{
size_t i, j, length = self.length;
for (i = 0, j = length - 1; i < length / 2; i++, j--) {
of_unichar_t tmp = [self characterAtIndex: j];
[self setCharacter: [self characterAtIndex: i]
[self setCharacter: [self characterAtIndex: i] atIndex: j];
atIndex: j];
[self setCharacter: tmp
[self setCharacter: tmp atIndex: i];
atIndex: i];
}
}
#ifdef OF_HAVE_UNICODE_TABLES
- (void)uppercase
{
[self of_convertWithWordStartTable: of_unicode_uppercase_table
|
︙ | | |
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
|
-
-
+
-
-
+
-
-
+
-
+
-
-
+
-
-
+
-
|
wordMiddleTable: of_unicode_lowercase_table
wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE
wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];
}
#else
- (void)uppercase
{
[self of_convertWithWordStartFunction: of_ascii_toupper
wordMiddleFunction: of_ascii_toupper];
convert(self, of_ascii_toupper, of_ascii_toupper);
}
- (void)lowercase
{
[self of_convertWithWordStartFunction: of_ascii_tolower
wordMiddleFunction: of_ascii_tolower];
convert(self, of_ascii_tolower, of_ascii_tolower);
}
- (void)capitalize
{
[self of_convertWithWordStartFunction: of_ascii_toupper
wordMiddleFunction: of_ascii_tolower];
convert(self, of_ascii_toupper, of_ascii_tolower);
}
#endif
- (void)insertString: (OFString *)string
- (void)insertString: (OFString *)string atIndex: (size_t)idx
atIndex: (size_t)idx
{
[self replaceCharactersInRange: of_range(idx, 0)
[self replaceCharactersInRange: of_range(idx, 0) withString: string];
withString: string];
}
- (void)deleteCharactersInRange: (of_range_t)range
{
[self replaceCharactersInRange: range
[self replaceCharactersInRange: range withString: @""];
withString: @""];
}
- (void)replaceCharactersInRange: (of_range_t)range
withString: (OFString *)replacement
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
Modified src/OFMutableURL.m
from [990fa14b6b]
to [66f15c46f8].
︙ | | |
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
-
+
-
|
[copy makeImmutable];
return copy;
}
- (void)appendPathComponent: (OFString *)component
{
[self appendPathComponent: component
[self appendPathComponent: component isDirectory: false];
isDirectory: false];
#ifdef OF_HAVE_FILES
if ([_URLEncodedScheme isEqual: @"file"] &&
![_URLEncodedPath hasSuffix: @"/"] &&
[[OFFileManager defaultManager] directoryExistsAtURL: self]) {
void *pool = objc_autoreleasePoolPush();
OFString *path = [_URLEncodedPath
|
︙ | | |
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
-
+
-
|
done = false;
break;
}
}
}
[array insertObject: @""
[array insertObject: @"" atIndex: 0];
atIndex: 0];
if (endsWithEmpty)
[array addObject: @""];
path = [array componentsJoinedByString: @"/"];
if (path.length == 0)
path = @"/";
|
︙ | | |
Modified src/OFMutableUTF8String.m
from [0bce7a5121]
to [ae60bfdf29].
︙ | | |
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
|
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
|
-
+
-
+
-
-
+
+
-
+
|
return self;
}
- (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String
length: (size_t)UTF8StringLength
freeWhenDone: (bool)freeWhenDone
{
self = [self initWithUTF8String: UTF8String
self = [self initWithUTF8String: UTF8String length: UTF8StringLength];
length: UTF8StringLength];
if (freeWhenDone)
free(UTF8String);
return self;
}
#ifdef OF_HAVE_UNICODE_TABLES
- (void)of_convertWithWordStartTable: (const of_unichar_t *const[])startTable
wordMiddleTable: (const of_unichar_t *const[])middleTable
- (void)of_convertWithWordStartTable: (const of_unichar_t *const [])startTable
wordMiddleTable: (const of_unichar_t *const [])middleTable
wordStartTableSize: (size_t)startTableSize
wordMiddleTableSize: (size_t)middleTableSize OF_DIRECT
wordMiddleTableSize: (size_t)middleTableSize
{
of_unichar_t *unicodeString;
size_t unicodeLen, newCStringLength;
size_t i, j;
char *newCString;
bool isStart = true;
|
︙ | | |
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
+
-
+
-
|
_s->cStringLength = newCStringLength;
/*
* Even though cStringLength can change, length cannot, therefore no
* need to change it.
*/
}
#endif
- (void)setCharacter: (of_unichar_t)character
- (void)setCharacter: (of_unichar_t)character atIndex: (size_t)idx
atIndex: (size_t)idx
{
char buffer[4];
of_unichar_t c;
size_t lenNew;
ssize_t lenOld;
if (_s->isUTF8)
|
︙ | | |
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
-
+
-
|
}
- (void)appendCString: (const char *)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
{
if (encoding == OF_STRING_ENCODING_UTF_8)
[self appendUTF8String: cString
[self appendUTF8String: cString length: cStringLength];
length: cStringLength];
else {
void *pool = objc_autoreleasePoolPush();
[self appendString:
[OFString stringWithCString: cString
encoding: encoding
length: cStringLength]];
|
︙ | | |
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
-
+
-
-
+
-
|
if (isUTF8)
_s->isUTF8 = true;
} @finally {
free(tmp);
}
}
- (void)appendFormat: (OFConstantString *)format
- (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments
arguments: (va_list)arguments
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException exception];
if ((UTF8StringLength = of_vasprintf(&UTF8String, format.UTF8String,
arguments)) == -1)
@throw [OFInvalidFormatException exception];
@try {
[self appendUTF8String: UTF8String
[self appendUTF8String: UTF8String length: UTF8StringLength];
length: UTF8StringLength];
} @finally {
free(UTF8String);
}
}
- (void)reverse
{
|
︙ | | |
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
-
+
-
|
}
/* UTF-8 does not allow more than 4 bytes per character */
@throw [OFInvalidEncodingException exception];
}
}
- (void)insertString: (OFString *)string
- (void)insertString: (OFString *)string atIndex: (size_t)idx
atIndex: (size_t)idx
{
size_t newCStringLength;
if (idx > _s->length)
@throw [OFOutOfRangeException exception];
if (_s->isUTF8)
|
︙ | | |
Modified src/OFMutableZIPArchiveEntry.m
from [1228f4a633]
to [0b4e9c4fc9].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
-
|
@dynamic modificationDate, compressionMethod, compressedSize, uncompressedSize;
@dynamic CRC32, versionSpecificAttributes, generalPurposeBitFlag;
@dynamic of_localFileHeaderOffset;
- (id)copy
{
OFMutableZIPArchiveEntry *copy = [self mutableCopy];
[copy makeImmutable];
return copy;
}
- (void)setFileName: (OFString *)fileName
{
void *pool = objc_autoreleasePoolPush();
OFString *old;
|
︙ | | |
Modified src/OFNonretainedObjectValue.m
from [f7aa33cf32]
to [5a54c41595].
︙ | | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-
+
-
|
}
- (const char *)objCType
{
return @encode(id);
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
if (size != sizeof(_object))
@throw [OFOutOfRangeException exception];
memcpy(value, &_object, sizeof(_object));
}
- (void *)pointerValue
{
return _object;
}
@end
|
Modified src/OFNull.m
from [d43d138170]
to [dd4f67b6db].
︙ | | |
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
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
105
106
107
108
109
110
111
112
113
114
115
116
117
|
-
+
-
-
+
-
-
-
+
-
-
-
+
-
|
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
depth: 0];
}
- (OFString *)JSONRepresentationWithOptions: (int)options
{
return [self of_JSONRepresentationWithOptions: options
return [self of_JSONRepresentationWithOptions: options depth: 0];
depth: 0];
}
- (OFString *)of_JSONRepresentationWithOptions: (int)options
depth: (size_t)depth
{
return @"null";
}
- (OFData *)messagePackRepresentation
{
uint8_t type = 0xC0;
return [OFData dataWithItems: &type
return [OFData dataWithItems: &type count: 1];
count: 1];
}
- (OFData *)ASN1DERRepresentation
{
const unsigned char bytes[] = { OF_ASN1_TAG_NUMBER_NULL, 0 };
return [OFData dataWithItems: bytes
return [OFData dataWithItems: bytes count: sizeof(bytes)];
count: sizeof(bytes)];
}
- (instancetype)autorelease
{
return self;
}
|
︙ | | |
Modified src/OFNumber.m
from [92fb9ca7c6]
to [1b24e74726].
︙ | | |
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
|
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
|
-
+
-
|
}
- (const char *)objCType
{
return _typeEncoding;
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
switch (*self.objCType) {
#define CASE(enc, type, property) \
case enc: { \
type tmp = (type)self.property; \
\
if (size != sizeof(type)) \
|
︙ | | |
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
|
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"OFNumber"
namespace: OF_SERIALIZATION_NS
stringValue: self.description];
if (*self.objCType == 'B')
[element addAttributeWithName: @"type"
[element addAttributeWithName: @"type" stringValue: @"bool"];
stringValue: @"bool"];
else if (isFloat(self)) {
[element addAttributeWithName: @"type"
[element addAttributeWithName: @"type" stringValue: @"float"];
stringValue: @"float"];
element.stringValue = [OFString
stringWithFormat: @"%016" PRIx64,
OF_BSWAP64_IF_LE(OF_DOUBLE_TO_INT_RAW(OF_BSWAP_DOUBLE_IF_LE(
self.doubleValue)))];
} else if (isSigned(self))
[element addAttributeWithName: @"type"
[element addAttributeWithName: @"type" stringValue: @"signed"];
stringValue: @"signed"];
else if (isUnsigned(self))
[element addAttributeWithName: @"type"
stringValue: @"unsigned"];
else
@throw [OFInvalidFormatException exception];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
depth: 0];
}
- (OFString *)JSONRepresentationWithOptions: (int)options
{
return [self of_JSONRepresentationWithOptions: options
return [self of_JSONRepresentationWithOptions: options depth: 0];
depth: 0];
}
- (OFString *)of_JSONRepresentationWithOptions: (int)options
depth: (size_t)depth
{
double doubleValue;
|
︙ | | |
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
|
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
|
-
-
+
-
-
+
-
-
-
+
-
-
+
-
-
-
+
-
-
+
-
-
+
-
-
-
+
-
-
-
+
-
-
+
-
-
-
+
-
-
+
-
-
-
+
-
-
-
+
-
-
+
-
-
-
+
-
-
-
+
-
-
+
-
-
-
+
-
-
+
-
-
-
+
-
|
- (OFData *)messagePackRepresentation
{
OFMutableData *data;
const char *typeEncoding = self.objCType;
if (*typeEncoding == 'B') {
uint8_t type = (self.boolValue ? 0xC3 : 0xC2);
data = [OFMutableData dataWithItems: &type
data = [OFMutableData dataWithItems: &type count: 1];
count: 1];
} else if (*typeEncoding == 'f') {
uint8_t type = 0xCA;
float tmp = OF_BSWAP_FLOAT_IF_LE(self.floatValue);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 5];
capacity: 5];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (*typeEncoding == 'd') {
uint8_t type = 0xCB;
double tmp = OF_BSWAP_DOUBLE_IF_LE(self.doubleValue);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 9];
capacity: 9];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (isSigned(self)) {
long long value = self.longLongValue;
if (value >= -32 && value < 0) {
uint8_t tmp = 0xE0 | ((uint8_t)(value - 32) & 0x1F);
data = [OFMutableData dataWithItems: &tmp
data = [OFMutableData dataWithItems: &tmp count: 1];
count: 1];
} else if (value >= INT8_MIN && value <= INT8_MAX) {
uint8_t type = 0xD0;
int8_t tmp = (int8_t)value;
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 2];
capacity: 2];
[data addItem: &type];
[data addItem: &tmp];
} else if (value >= INT16_MIN && value <= INT16_MAX) {
uint8_t type = 0xD1;
int16_t tmp = OF_BSWAP16_IF_LE((int16_t)value);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 3];
capacity: 3];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (value >= INT32_MIN && value <= INT32_MAX) {
uint8_t type = 0xD2;
int32_t tmp = OF_BSWAP32_IF_LE((int32_t)value);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 5];
capacity: 5];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (value >= INT64_MIN && value <= INT64_MAX) {
uint8_t type = 0xD3;
int64_t tmp = OF_BSWAP64_IF_LE((int64_t)value);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 9];
capacity: 9];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
} else if (isUnsigned(self)) {
unsigned long long value = self.unsignedLongLongValue;
if (value <= 127) {
uint8_t tmp = ((uint8_t)value & 0x7F);
data = [OFMutableData dataWithItems: &tmp
data = [OFMutableData dataWithItems: &tmp count: 1];
count: 1];
} else if (value <= UINT8_MAX) {
uint8_t type = 0xCC;
uint8_t tmp = (uint8_t)value;
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 2];
capacity: 2];
[data addItem: &type];
[data addItem: &tmp];
} else if (value <= UINT16_MAX) {
uint8_t type = 0xCD;
uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)value);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 3];
capacity: 3];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (value <= UINT32_MAX) {
uint8_t type = 0xCE;
uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)value);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 5];
capacity: 5];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else if (value <= UINT64_MAX) {
uint8_t type = 0xCF;
uint64_t tmp = OF_BSWAP64_IF_LE((uint64_t)value);
data = [OFMutableData dataWithItemSize: 1
data = [OFMutableData dataWithCapacity: 9];
capacity: 9];
[data addItem: &type];
[data addItems: &tmp
[data addItems: &tmp count: sizeof(tmp)];
count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
} else
@throw [OFInvalidFormatException exception];
[data makeImmutable];
return data;
}
@end
|
Modified src/OFObject+KeyValueCoding.m
from [2a9a3f450d]
to [9c33438270].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
-
+
|
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (id)valueForUndefinedKey: (OFString *)key
{
@throw [OFUndefinedKeyException exceptionWithObject: self
@throw [OFUndefinedKeyException exceptionWithObject: self key: key];
key: key];
}
- (void)setValue: (id)value
- (void)setValue: (id)value forKey: (OFString *)key
forKey: (OFString *)key
{
void *pool = objc_autoreleasePoolPush();
size_t keyLength;
char *name;
SEL selector;
OFMethodSignature *methodSignature;
const char *valueType;
if ((keyLength = key.UTF8StringLength) < 1) {
objc_autoreleasePoolPop(pool);
[self setValue: value
forUndefinedKey: key];
[self setValue: value forUndefinedKey: key];
return;
}
name = of_alloc(keyLength + 5, 1);
@try {
memcpy(name, "set", 3);
memcpy(name + 3, key.UTF8String, keyLength);
|
︙ | | |
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
-
-
+
|
if (methodSignature == nil ||
methodSignature.numberOfArguments != 3 ||
*methodSignature.methodReturnType != 'v' ||
*[methodSignature argumentTypeAtIndex: 0] != '@' ||
*[methodSignature argumentTypeAtIndex: 1] != ':') {
objc_autoreleasePoolPop(pool);
[self setValue: value
forUndefinedKey: key];
[self setValue: value forUndefinedKey: key];
return;
}
valueType = [methodSignature argumentTypeAtIndex: 2];
if (*valueType != '@' && *valueType != '#' && value == nil) {
objc_autoreleasePoolPop(pool);
|
︙ | | |
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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
270
271
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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
|
-
-
+
-
+
-
-
+
-
-
+
-
|
CASE('L', unsigned long, unsignedLongValue)
CASE('Q', unsigned long long, unsignedLongLongValue)
CASE('f', float, floatValue)
CASE('d', double, doubleValue)
#undef CASE
default:
objc_autoreleasePoolPop(pool);
[self setValue: value
forUndefinedKey: key];
[self setValue: value forUndefinedKey: key];
return;
}
objc_autoreleasePoolPop(pool);
}
- (void)setValue: (id)value
- (void)setValue: (id)value forKeyPath: (OFString *)keyPath
forKeyPath: (OFString *)keyPath
{
void *pool = objc_autoreleasePoolPush();
OFArray *keys = [keyPath componentsSeparatedByString: @"."];
size_t keysCount = keys.count;
id object = self;
size_t i = 0;
for (OFString *key in keys) {
if (++i == keysCount)
[object setValue: value
[object setValue: value forKey: key];
forKey: key];
else
object = [object valueForKey: key];
}
objc_autoreleasePoolPop(pool);
}
- (void)setValue: (id)value
- (void)setValue: (id)value forUndefinedKey: (OFString *)key
forUndefinedKey: (OFString *)key
{
@throw [OFUndefinedKeyException exceptionWithObject: self
key: key
value: value];
}
- (void)setNilValueForKey: (OFString *)key
{
@throw [OFInvalidArgumentException exception];
}
@end
|
Modified src/OFObject+Serialization.m
from [fe806a8af4]
to [fe39eedbf9].
︙ | | |
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
-
+
-
|
}
pool = objc_autoreleasePoolPush();
element = ((id <OFSerialization>)self).XMLElementBySerializing;
root = [OFXMLElement elementWithName: @"serialization"
namespace: OF_SERIALIZATION_NS];
[root addAttributeWithName: @"version"
[root addAttributeWithName: @"version" stringValue: @"1"];
stringValue: @"1"];
[root addChild: element];
ret = [@"<?xml version='1.0' encoding='UTF-8'?>\n"
stringByAppendingString: [root XMLStringWithIndentation: 2]];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
@end
|
Modified src/OFObject.m
from [cef279c6b0]
to [ab465686e4].
︙ | | |
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
-
+
-
-
+
-
|
}
+ (OFString *)description
{
return [self className];
}
+ (IMP)replaceClassMethod: (SEL)selector
+ (IMP)replaceClassMethod: (SEL)selector withMethodFromClass: (Class)class
withMethodFromClass: (Class)class
{
IMP method = [class methodForSelector: selector];
if (method == NULL)
@throw [OFInvalidArgumentException exception];
return class_replaceMethod(object_getClass(self), selector, method,
typeEncodingForSelector(object_getClass(class), selector));
}
+ (IMP)replaceInstanceMethod: (SEL)selector
+ (IMP)replaceInstanceMethod: (SEL)selector withMethodFromClass: (Class)class
withMethodFromClass: (Class)class
{
IMP method = [class instanceMethodForSelector: selector];
if (method == NULL)
@throw [OFInvalidArgumentException exception];
return class_replaceMethod(self, selector, method,
|
︙ | | |
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
-
+
-
|
#elif defined(OF_APPLE_RUNTIME)
id (*imp)(id, SEL) = (id (*)(id, SEL))objc_msgSend;
#endif
return imp(self, selector);
}
- (id)performSelector: (SEL)selector
- (id)performSelector: (SEL)selector withObject: (id)object
withObject: (id)object
{
#if defined(OF_OBJFW_RUNTIME)
id (*imp)(id, SEL, id) =
(id (*)(id, SEL, id))objc_msg_lookup(self, selector);
#elif defined(OF_APPLE_RUNTIME)
id (*imp)(id, SEL, id) = (id (*)(id, SEL, id))objc_msgSend;
#endif
|
︙ | | |
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
|
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
|
-
+
-
|
id (*imp)(id, SEL, id, id, id, id) =
(id (*)(id, SEL, id, id, id, id))objc_msgSend;
#endif
return imp(self, selector, object1, object2, object3, object4);
}
- (void)performSelector: (SEL)selector
- (void)performSelector: (SEL)selector afterDelay: (of_time_interval_t)delay
afterDelay: (of_time_interval_t)delay
{
void *pool = objc_autoreleasePoolPush();
[OFTimer scheduledTimerWithTimeInterval: delay
target: self
selector: selector
repeats: false];
|
︙ | | |
Modified src/OFPointValue.m
from [6f05fc4f1d]
to [637e52428d].
︙ | | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
-
+
-
|
}
- (const char *)objCType
{
return @encode(of_point_t);
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
if (size != sizeof(_point))
@throw [OFOutOfRangeException exception];
memcpy(value, &_point, sizeof(_point));
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"<OFValue: of_point_t { %f, %f }>", _point.x, _point.y];
}
@end
|
Modified src/OFPointerValue.m
from [ff9ab4b9d5]
to [18e2836486].
︙ | | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-
+
-
|
}
- (const char *)objCType
{
return @encode(void *);
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
if (size != sizeof(_pointer))
@throw [OFOutOfRangeException exception];
memcpy(value, &_pointer, sizeof(_pointer));
}
- (id)nonretainedObjectValue
{
return _pointer;
}
@end
|
Modified src/OFPollKernelEventObserver.m
from [e93ed3c852]
to [f68dab1660].
︙ | | |
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
|
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
|
-
+
-
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
+
-
-
+
+
-
+
-
-
+
-
-
-
+
-
-
-
+
-
-
-
+
-
|
{
[_FDs release];
free(_FDToObject);
[super dealloc];
}
- (void)of_addObject: (id)object
static void
fileDescriptor: (int)fd
events: (short)events OF_DIRECT
addObject(OFPollKernelEventObserver *self, id object, int fd, short events)
{
struct pollfd *FDs;
size_t count;
bool found;
if (fd < 0)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EBADF];
FDs = _FDs.mutableItems;
count = _FDs.count;
FDs = self->_FDs.mutableItems;
count = self->_FDs.count;
found = false;
for (size_t i = 0; i < count; i++) {
if (FDs[i].fd == fd) {
FDs[i].events |= events;
found = true;
break;
}
}
if (!found) {
struct pollfd p = { fd, events, 0 };
if (fd > _maxFD) {
_maxFD = fd;
_FDToObject = of_realloc(_FDToObject,
(size_t)_maxFD + 1, sizeof(id));
if (fd > self->_maxFD) {
self->_maxFD = fd;
self->_FDToObject = of_realloc(self->_FDToObject,
(size_t)self->_maxFD + 1, sizeof(id));
}
_FDToObject[fd] = object;
[_FDs addItem: &p];
self->_FDToObject[fd] = object;
[self->_FDs addItem: &p];
}
}
- (void)of_removeObject: (id)object
static void
fileDescriptor: (int)fd
events: (short)events OF_DIRECT
removeObject(OFPollKernelEventObserver *self, id object, int fd, short events)
{
struct pollfd *FDs;
size_t nFDs;
if (fd < 0)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EBADF];
FDs = _FDs.mutableItems;
nFDs = _FDs.count;
FDs = self->_FDs.mutableItems;
nFDs = self->_FDs.count;
for (size_t i = 0; i < nFDs; i++) {
if (FDs[i].fd == fd) {
FDs[i].events &= ~events;
if (FDs[i].events == 0) {
/*
* TODO: Remove from and resize _FDToObject,
* adjust _maxFD.
*/
[_FDs removeItemAtIndex: i];
[self->_FDs removeItemAtIndex: i];
}
break;
}
}
}
- (void)addObjectForReading: (id <OFReadyForReadingObserving>)object
{
[self of_addObject: object
fileDescriptor: object.fileDescriptorForReading
addObject(self, object, object.fileDescriptorForReading, POLLIN);
events: POLLIN];
[super addObjectForReading: object];
}
- (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
[self of_addObject: object
fileDescriptor: object.fileDescriptorForWriting
addObject(self, object, object.fileDescriptorForWriting, POLLOUT);
events: POLLOUT];
[super addObjectForWriting: object];
}
- (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
[self of_removeObject: object
fileDescriptor: object.fileDescriptorForReading
removeObject(self, object, object.fileDescriptorForReading, POLLIN);
events: POLLIN];
[super removeObjectForReading: object];
}
- (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
[self of_removeObject: object
fileDescriptor: object.fileDescriptorForWriting
removeObject(self, object, object.fileDescriptorForWriting, POLLOUT);
events: POLLOUT];
[super removeObjectForWriting: object];
}
- (void)observeForTimeInterval: (of_time_interval_t)timeInterval
{
void *pool;
|
︙ | | |
Modified src/OFRIPEMD160Hash.m
from [ab4f0b95de]
to [00be784cc9].
︙ | | |
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
-
+
-
|
_iVars->state[0] = 0x67452301;
_iVars->state[1] = 0xEFCDAB89;
_iVars->state[2] = 0x98BADCFE;
_iVars->state[3] = 0x10325476;
_iVars->state[4] = 0xC3D2E1F0;
}
- (void)updateWithBuffer: (const void *)buffer_
- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length
length: (size_t)length
{
const unsigned char *buffer = buffer_;
if (_calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithObject: self];
|
︙ | | |
Modified src/OFRangeValue.m
from [a40dd0a04c]
to [4b2520185b].
︙ | | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
-
+
-
|
}
- (const char *)objCType
{
return @encode(of_range_t);
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
if (size != sizeof(_range))
@throw [OFOutOfRangeException exception];
memcpy(value, &_range, sizeof(_range));
}
|
︙ | | |
Modified src/OFRectangleValue.m
from [189e76f543]
to [7e7907dbd9].
︙ | | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
-
+
-
|
}
- (const char *)objCType
{
return @encode(of_rectangle_t);
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
if (size != sizeof(_rectangle))
@throw [OFOutOfRangeException exception];
memcpy(value, &_rectangle, sizeof(_rectangle));
}
|
︙ | | |
Modified src/OFRunLoop.m
from [a843dfe040]
to [392955f6f6].
︙ | | |
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
-
-
-
-
-
-
|
# ifdef OF_HAVE_THREADS
OFMutex *_execSignalsMutex;
# endif
#endif
}
@end
OF_DIRECT_MEMBERS
@interface OFRunLoop ()
- (OFRunLoopState *)of_stateForMode: (of_run_loop_mode_t)mode
create: (bool)create;
@end
#ifdef OF_HAVE_SOCKETS
@interface OFRunLoopQueueItem: OFObject
{
@public
id _delegate;
}
|
︙ | | |
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
-
+
-
|
@implementation OFRunLoopReadQueueItem
- (bool)handleObject: (id)object
{
size_t length;
id exception = nil;
@try {
length = [object readIntoBuffer: _buffer
length = [object readIntoBuffer: _buffer length: _length];
length: _length];
} @catch (id e) {
length = 0;
exception = e;
}
# ifdef OF_HAVE_BLOCKS
if (_block != NULL)
|
︙ | | |
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
|
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
|
-
-
+
-
|
timerWithTimeInterval: 0
target: _delegate
selector: @selector(of_socketDidConnect:
exception:)
object: object
object: exception
repeats: false];
[runLoop addTimer: timer
[runLoop addTimer: timer forMode: runLoop.currentMode];
forMode: runLoop.currentMode];
}
return false;
}
@end
# endif
|
︙ | | |
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
|
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
-
+
-
|
@implementation OFRunLoopPacketReceiveQueueItem
- (bool)handleObject: (id)object
{
size_t length;
id exception = nil;
@try {
length = [object receiveIntoBuffer: _buffer
length = [object receiveIntoBuffer: _buffer length: _length];
length: _length];
} @catch (id e) {
length = 0;
exception = e;
}
# ifdef OF_HAVE_BLOCKS
if (_block != NULL)
|
︙ | | |
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
|
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
|
-
+
-
-
+
-
|
mainRunLoop = [runLoop retain];
}
#ifdef OF_HAVE_SOCKETS
# define NEW_READ(type, object, mode) \
void *pool = objc_autoreleasePoolPush(); \
OFRunLoop *runLoop = [self currentRunLoop]; \
OFRunLoopState *state = [runLoop of_stateForMode: mode \
OFRunLoopState *state = stateForMode(runLoop, mode, true); \
create: true]; \
OFList *queue = [state->_readQueues objectForKey: object]; \
type *queueItem; \
\
if (queue == nil) { \
queue = [OFList list]; \
[state->_readQueues setObject: queue forKey: object]; \
} \
\
if (queue.count == 0) \
[state->_kernelEventObserver \
addObjectForReading: object]; \
\
queueItem = [[[type alloc] init] autorelease];
# define NEW_WRITE(type, object, mode) \
void *pool = objc_autoreleasePoolPush(); \
OFRunLoop *runLoop = [self currentRunLoop]; \
OFRunLoopState *state = [runLoop of_stateForMode: mode \
OFRunLoopState *state = stateForMode(runLoop, mode, true); \
create: true]; \
OFList *queue = [state->_writeQueues objectForKey: object]; \
type *queueItem; \
\
if (queue == nil) { \
queue = [OFList list]; \
[state->_writeQueues setObject: queue forKey: object]; \
} \
|
︙ | | |
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
|
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
|
-
+
-
|
# undef QUEUE_ITEM
+ (void)of_cancelAsyncRequestsForObject: (id)object
mode: (of_run_loop_mode_t)mode
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [self currentRunLoop];
OFRunLoopState *state = [runLoop of_stateForMode: mode
OFRunLoopState *state = stateForMode(runLoop, mode, false);
create: false];
OFList *queue;
if (state == nil)
return;
if ((queue = [state->_writeQueues objectForKey: object]) != nil) {
assert(queue.count > 0);
|
︙ | | |
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
|
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
|
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
#ifdef OF_HAVE_THREADS
[_statesMutex release];
#endif
[super dealloc];
}
- (OFRunLoopState *)of_stateForMode: (of_run_loop_mode_t)mode
create: (bool)create
static OFRunLoopState *
stateForMode(OFRunLoop *self, of_run_loop_mode_t mode, bool create)
{
OFRunLoopState *state;
#ifdef OF_HAVE_THREADS
[_statesMutex lock];
[self->_statesMutex lock];
@try {
#endif
state = [_states objectForKey: mode];
state = [self->_states objectForKey: mode];
if (create && state == nil) {
state = [[OFRunLoopState alloc] init];
@try {
[_states setObject: state forKey: mode];
[self->_states setObject: state forKey: mode];
} @finally {
[state release];
}
}
#ifdef OF_HAVE_THREADS
} @finally {
[_statesMutex unlock];
[self->_statesMutex unlock];
}
#endif
return state;
}
- (void)addTimer: (OFTimer *)timer
{
[self addTimer: timer
[self addTimer: timer forMode: of_run_loop_mode_default];
forMode: of_run_loop_mode_default];
}
- (void)addTimer: (OFTimer *)timer
- (void)addTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode
forMode: (of_run_loop_mode_t)mode
{
OFRunLoopState *state = [self of_stateForMode: mode
OFRunLoopState *state = stateForMode(self, mode, true);
create: true];
#ifdef OF_HAVE_THREADS
[state->_timersQueueMutex lock];
@try {
#endif
[state->_timersQueue insertObject: timer];
#ifdef OF_HAVE_THREADS
} @finally {
[state->_timersQueueMutex unlock];
}
#endif
[timer of_setInRunLoop: self
[timer of_setInRunLoop: self mode: mode];
mode: mode];
#if defined(OF_HAVE_SOCKETS)
[state->_kernelEventObserver cancel];
#elif defined(OF_HAVE_THREADS)
[state->_condition signal];
#endif
}
- (void)of_removeTimer: (OFTimer *)timer
- (void)of_removeTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode
forMode: (of_run_loop_mode_t)mode
{
OFRunLoopState *state = [self of_stateForMode: mode
OFRunLoopState *state = stateForMode(self, mode, false);
create: false];
if (state == nil)
return;
#ifdef OF_HAVE_THREADS
[state->_timersQueueMutex lock];
@try {
|
︙ | | |
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
|
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
|
-
+
-
-
-
+
-
|
} @finally {
[state->_timersQueueMutex unlock];
}
#endif
}
#ifdef OF_AMIGAOS
- (void)addExecSignal: (ULONG)signal
- (void)addExecSignal: (ULONG)signal target: (id)target selector: (SEL)selector
target: (id)target
selector: (SEL)selector
{
[self addExecSignal: signal
forMode: of_run_loop_mode_default
target: target
selector: selector];
}
- (void)addExecSignal: (ULONG)signal
forMode: (of_run_loop_mode_t)mode
target: (id)target
selector: (SEL)selector
{
OFRunLoopState *state = [self of_stateForMode: mode
OFRunLoopState *state = stateForMode(self, mode, true);
create: true];
# ifdef OF_HAVE_THREADS
[state->_execSignalsMutex lock];
@try {
# endif
[state->_execSignals addItem: &signal];
[state->_execSignalsTargets addObject: target];
|
︙ | | |
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
|
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
|
-
+
-
|
}
- (void)removeExecSignal: (ULONG)signal
forMode: (of_run_loop_mode_t)mode
target: (id)target
selector: (SEL)selector
{
OFRunLoopState *state = [self of_stateForMode: mode
OFRunLoopState *state = stateForMode(self, mode, false);
create: false];
if (state == nil)
return;
# ifdef OF_HAVE_THREADS
[state->_execSignalsMutex lock];
@try {
|
︙ | | |
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
|
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
|
-
+
-
-
+
-
-
+
-
|
- (void)runUntilDate: (OFDate *)deadline
{
_stop = false;
while (!_stop &&
(deadline == nil || deadline.timeIntervalSinceNow >= 0))
[self runMode: of_run_loop_mode_default
[self runMode: of_run_loop_mode_default beforeDate: deadline];
beforeDate: deadline];
}
- (void)runMode: (of_run_loop_mode_t)mode
- (void)runMode: (of_run_loop_mode_t)mode beforeDate: (OFDate *)deadline
beforeDate: (OFDate *)deadline
{
void *pool = objc_autoreleasePoolPush();
of_run_loop_mode_t previousMode = _currentMode;
OFRunLoopState *state = [self of_stateForMode: mode
OFRunLoopState *state = stateForMode(self, mode, false);
create: false];
if (state == nil)
return;
_currentMode = mode;
@try {
OFDate *nextTimer;
|
︙ | | |
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
|
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
|
-
+
-
|
fireDate].timeIntervalSinceNow <= 0) {
timer = [[listObject->object
retain] autorelease];
[state->_timersQueue
removeListObject: listObject];
[timer of_setInRunLoop: nil
[timer of_setInRunLoop: nil mode: nil];
mode: nil];
} else
break;
#ifdef OF_HAVE_THREADS
} @finally {
[state->_timersQueueMutex unlock];
}
#endif
|
︙ | | |
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
|
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
|
-
-
+
+
|
} @finally {
_currentMode = previousMode;
}
}
- (void)stop
{
OFRunLoopState *state = [self of_stateForMode: of_run_loop_mode_default
create: false];
OFRunLoopState *state =
stateForMode(self, of_run_loop_mode_default, false);
_stop = true;
if (state == nil)
return;
#if defined(OF_HAVE_SOCKETS)
[state->_kernelEventObserver cancel];
#elif defined(OF_HAVE_THREADS)
[state->_condition signal];
#endif
}
@end
|
Modified src/OFSCTPSocket.m
from [a0edfc0fdf]
to [f8cfb3a493].
︙ | | |
119
120
121
122
123
124
125
126
127
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
|
119
120
121
122
123
124
125
126
127
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
- (void)of_closeSocket
{
closesocket(_socket);
_socket = INVALID_SOCKET;
}
- (void)connectToHost: (OFString *)host
- (void)connectToHost: (OFString *)host port: (uint16_t)port
port: (uint16_t)port
{
void *pool = objc_autoreleasePoolPush();
id <OFSCTPSocketDelegate> delegate = _delegate;
OFSCTPSocketConnectDelegate *connectDelegate =
[[[OFSCTPSocketConnectDelegate alloc] init] autorelease];
OFRunLoop *runLoop = [OFRunLoop currentRunLoop];
self.delegate = connectDelegate;
[self asyncConnectToHost: host
port: port
runLoopMode: connectRunLoopMode];
while (!connectDelegate->_done)
[runLoop runMode: connectRunLoopMode
[runLoop runMode: connectRunLoopMode beforeDate: nil];
beforeDate: nil];
/* Cleanup */
[runLoop runMode: connectRunLoopMode
[runLoop runMode: connectRunLoopMode beforeDate: [OFDate date]];
beforeDate: [OFDate date]];
if (connectDelegate->_exception != nil)
@throw connectDelegate->_exception;
self.delegate = delegate;
objc_autoreleasePoolPop(pool);
}
- (void)asyncConnectToHost: (OFString *)host
- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port
port: (uint16_t)port
{
[self asyncConnectToHost: host
port: port
runLoopMode: of_run_loop_mode_default];
}
- (void)asyncConnectToHost: (OFString *)host
|
︙ | | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
-
+
-
|
block: block] autorelease]
startWithRunLoopMode: runLoopMode];
objc_autoreleasePoolPop(pool);
}
#endif
- (uint16_t)bindToHost: (OFString *)host
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port
port: (uint16_t)port
{
const int one = 1;
void *pool = objc_autoreleasePoolPush();
OFData *socketAddresses;
of_socket_address_t address;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
int flags;
|
︙ | | |
Modified src/OFSHA1Hash.m
from [dc358c1aca]
to [6dc47e8d09].
︙ | | |
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-
+
-
|
_iVars->state[0] = 0x67452301;
_iVars->state[1] = 0xEFCDAB89;
_iVars->state[2] = 0x98BADCFE;
_iVars->state[3] = 0x10325476;
_iVars->state[4] = 0xC3D2E1F0;
}
- (void)updateWithBuffer: (const void *)buffer_
- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length
length: (size_t)length
{
const unsigned char *buffer = buffer_;
if (_calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithObject: self];
|
︙ | | |
Modified src/OFSHA224Or256Hash.m
from [06995323d9]
to [e77f5555d4].
︙ | | |
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
-
+
-
|
copy->_iVars = copy->_iVarsData.mutableItems;
copy->_allowsSwappableMemory = _allowsSwappableMemory;
copy->_calculated = _calculated;
return copy;
}
- (void)updateWithBuffer: (const void *)buffer_
- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length
length: (size_t)length
{
const unsigned char *buffer = buffer_;
if (_calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithObject: self];
|
︙ | | |
Modified src/OFSHA384Or512Hash.m
from [e89cdc8f14]
to [d2d324bc83].
︙ | | |
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
-
+
-
|
copy->_iVars = copy->_iVarsData.mutableItems;
copy->_allowsSwappableMemory = _allowsSwappableMemory;
copy->_calculated = _calculated;
return copy;
}
- (void)updateWithBuffer: (const void *)buffer_
- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length
length: (size_t)length
{
const unsigned char *buffer = buffer_;
if (_calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithObject: self];
|
︙ | | |
Modified src/OFSPXSocket.m
from [2af60d4b14]
to [852f3cc78c].
︙ | | |
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
-
+
-
-
+
-
-
+
-
|
- (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode
{
of_socket_address_t address =
of_socket_address_ipx(_node, _network, _port);
id exception = nil;
int errNo;
if (![_socket of_createSocketForAddress: &address
if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
exception = [self of_connectionFailedExceptionForErrNo: errNo];
goto inform_delegate;
}
_socket.canBlock = false;
if (![_socket of_connectSocketToAddress: &address
if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
if (errNo == EINPROGRESS) {
[OFRunLoop of_addAsyncConnectForSocket: _socket
mode: runLoopMode
delegate: self];
return;
}
[_socket of_closeSocket];
exception = [self of_connectionFailedExceptionForErrNo: errNo];
}
inform_delegate:
[self performSelector: @selector(of_socketDidConnect:exception:)
withObject: _socket
withObject: exception
afterDelay: 0];
}
- (void)of_socketDidConnect: (id)sock
- (void)of_socketDidConnect: (id)sock exception: (id)exception
exception: (id)exception
{
id <OFSPXSocketDelegate> delegate = ((OFSPXSocket *)sock).delegate;
if (exception == nil)
((OFSPXSocket *)sock).canBlock = true;
#ifdef OF_HAVE_BLOCKS
|
︙ | | |
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
-
+
-
-
+
-
|
network: (uint32_t)network
port: (uint16_t)port
{
of_socket_address_t address =
of_socket_address_ipx(node, network, port);
int errNo;
if (![self of_createSocketForAddress: &address
if (![self of_createSocketForAddress: &address errNo: &errNo])
errNo: &errNo])
@throw [OFConnectionFailedException
exceptionWithNode: node
network: network
port: port
socket: self
errNo: errNo];
if (![self of_connectSocketToAddress: &address
if (![self of_connectSocketToAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
[self of_closeSocket];
@throw [OFConnectionFailedException
exceptionWithNode: node
network: network
port: port
socket: self
|
︙ | | |
Modified src/OFSPXStreamSocket.m
from [8baafe8070]
to [759cabd824].
︙ | | |
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
-
+
-
-
+
-
-
+
-
|
- (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode
{
of_socket_address_t address =
of_socket_address_ipx(_node, _network, _port);
id exception = nil;
int errNo;
if (![_socket of_createSocketForAddress: &address
if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
exception = [self of_connectionFailedExceptionForErrNo: errNo];
goto inform_delegate;
}
_socket.canBlock = false;
if (![_socket of_connectSocketToAddress: &address
if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
if (errNo == EINPROGRESS) {
[OFRunLoop of_addAsyncConnectForSocket: _socket
mode: runLoopMode
delegate: self];
return;
}
[_socket of_closeSocket];
exception = [self of_connectionFailedExceptionForErrNo: errNo];
}
inform_delegate:
[self performSelector: @selector(of_socketDidConnect:exception:)
withObject: _socket
withObject: exception
afterDelay: 0];
}
- (void)of_socketDidConnect: (id)sock
- (void)of_socketDidConnect: (id)sock exception: (id)exception
exception: (id)exception
{
id <OFSPXStreamSocketDelegate> delegate =
((OFSPXStreamSocket *)sock).delegate;
if (exception == nil)
((OFSPXStreamSocket *)sock).canBlock = true;
|
︙ | | |
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
-
+
-
-
+
-
|
network: (uint32_t)network
port: (uint16_t)port
{
of_socket_address_t address =
of_socket_address_ipx(node, network, port);
int errNo;
if (![self of_createSocketForAddress: &address
if (![self of_createSocketForAddress: &address errNo: &errNo])
errNo: &errNo])
@throw [OFConnectionFailedException
exceptionWithNode: node
network: network
port: port
socket: self
errNo: errNo];
if (![self of_connectSocketToAddress: &address
if (![self of_connectSocketToAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
[self of_closeSocket];
@throw [OFConnectionFailedException
exceptionWithNode: node
network: network
port: port
socket: self
|
︙ | | |
Modified src/OFSandbox.m
from [c9f40044df]
to [0adf8a4901].
︙ | | |
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
|
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
|
-
+
-
|
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
#endif
- (void)unveilPath: (OFString *)path
- (void)unveilPath: (OFString *)path permissions: (OFString *)permissions
permissions: (OFString *)permissions
{
void *pool = objc_autoreleasePoolPush();
[_unveiledPaths addObject: [OFPair pairWithFirstObject: path
secondObject: permissions]];
objc_autoreleasePoolPop(pool);
|
︙ | | |
Modified src/OFSecureData.m
from [3993fa04e8]
to [2689b5b4f2].
︙ | | |
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
-
+
|
return [[[self alloc] initWithCount: count
allowsSwappableMemory: allowsSwappableMemory]
autorelease];
}
+ (instancetype)dataWithCount: (size_t)count
itemSize: (size_t)itemSize
allowsSwappableMemory: (bool)allowsSwappableMemory
allowsSwappableMemory: (bool)allowsSwappableMemory
{
return [[[self alloc] initWithCount: count
itemSize: itemSize
allowsSwappableMemory: allowsSwappableMemory]
autorelease];
}
|
︙ | | |
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithItems: (const void *)items
- (instancetype)initWithItems: (const void *)items count: (size_t)count
count: (size_t)count
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithItems: (const void *)items
count: (size_t)count
itemSize: (size_t)itemSize
|
︙ | | |
Modified src/OFSequencedPacketSocket.m
from [b27451c5d4]
to [7bba0bbd14].
︙ | | |
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
-
+
-
|
_canBlock = canBlock;
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (size_t)receiveIntoBuffer: (void *)buffer
- (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
ssize_t ret;
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_WINDOWS
|
︙ | | |
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
-
+
-
|
requestedLength: length
errNo: of_socket_errno()];
#endif
return ret;
}
- (void)asyncReceiveIntoBuffer: (void *)buffer
- (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
[self asyncReceiveIntoBuffer: buffer
length: length
runLoopMode: of_run_loop_mode_default];
}
- (void)asyncReceiveIntoBuffer: (void *)buffer
|
︙ | | |
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
-
+
-
|
length: length
mode: runLoopMode
block: block
delegate: nil];
}
#endif
- (void)sendBuffer: (const void *)buffer
- (void)sendBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_WINDOWS
ssize_t bytesWritten;
|
︙ | | |
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
-
+
-
|
requestedLength: length
bytesWritten: bytesWritten
errNo: 0];
}
- (void)asyncSendData: (OFData *)data
{
[self asyncSendData: data
[self asyncSendData: data runLoopMode: of_run_loop_mode_default];
runLoopMode: of_run_loop_mode_default];
}
- (void)asyncSendData: (OFData *)data
runLoopMode: (of_run_loop_mode_t)runLoopMode
{
[OFRunLoop of_addAsyncSendForSequencedPacketSocket: self
data: data
|
︙ | | |
Modified src/OFSet.m
from [27e6d4b43c]
to [f23395a631].
︙ | | |
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
-
+
-
-
+
-
|
ret = [[OFMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
return (id)[[OFMapTableSet alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
return (id)[[OFMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
|
︙ | | |
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
-
+
-
|
ret = [[[self alloc] initWithObject: firstObject
arguments: arguments] autorelease];
va_end(arguments);
return ret;
}
+ (instancetype)setWithObjects: (id const *)objects
+ (instancetype)setWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
return [[[self alloc] initWithObjects: objects
count: count] autorelease];
}
- (instancetype)init
{
|
︙ | | |
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
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
193
194
195
196
197
198
199
|
-
+
-
-
+
-
-
+
-
|
}
- (instancetype)initWithArray: (OFArray *)array
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObjects: (id)firstObject, ...
{
id ret;
va_list arguments;
va_start(arguments, firstObject);
ret = [self initWithObject: firstObject
ret = [self initWithObject: firstObject arguments: arguments];
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
|
︙ | | |
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
-
+
-
-
+
-
|
}
[ret makeImmutable];
return ret;
}
- (void)setValue: (id)value
- (void)setValue: (id)value forKey: (OFString *)key
forKey: (OFString *)key
{
for (id object in self)
[object setValue: value
[object setValue: value forKey: key];
forKey: key];
}
- (bool)containsObject: (id)object
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
-
+
-
-
|
[ret appendString: [object description]];
if (++i < count)
[ret appendString: @",\n"];
objc_autoreleasePoolPop(pool2);
}
[ret replaceOccurrencesOfString: @"\n"
[ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"];
withString: @"\n\t"];
[ret appendString: @"\n)}"];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
|
︙ | | |
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
|
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
-
-
-
-
-
+
-
-
-
-
-
+
-
-
-
-
-
+
-
-
-
-
|
namespace: OF_SERIALIZATION_NS];
else
element = [OFXMLElement elementWithName: @"OFSet"
namespace: OF_SERIALIZATION_NS];
for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
[element addChild: object.XMLElementBySerializing];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFSet *)setBySubtractingSet: (OFSet *)set
{
OFMutableSet *new;
new = [[self mutableCopy] autorelease];
OFMutableSet *new = [[self mutableCopy] autorelease];
[new minusSet: set];
[new makeImmutable];
return new;
}
- (OFSet *)setByIntersectingWithSet: (OFSet *)set
{
OFMutableSet *new;
new = [[self mutableCopy] autorelease];
OFMutableSet *new = [[self mutableCopy] autorelease];
[new intersectSet: set];
[new makeImmutable];
return new;
}
- (OFSet *)setByAddingSet: (OFSet *)set
{
OFMutableSet *new;
new = [[self mutableCopy] autorelease];
OFMutableSet *new = [[self mutableCopy] autorelease];
[new unionSet: set];
[new makeImmutable];
return new;
}
- (OFArray *)allObjects
{
void *pool = objc_autoreleasePoolPush();
OFArray *ret = [[[self objectEnumerator] allObjects] retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (id)anyObject
{
void *pool = objc_autoreleasePoolPush();
id ret = [[[self objectEnumerator] nextObject] retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block
{
bool stop = false;
|
︙ | | |
Modified src/OFStdIOStream.m
from [4f22007bd2]
to [56aed5bccb].
︙ | | |
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
-
+
-
|
self = [super init];
_fd = fd;
return self;
}
#else
- (instancetype)of_initWithHandle: (BPTR)handle
- (instancetype)of_initWithHandle: (BPTR)handle closable: (bool)closable
closable: (bool)closable
{
self = [super init];
_handle = handle;
_closable = closable;
return self;
|
︙ | | |
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
-
+
-
|
if (_handle == 0)
#endif
@throw [OFNotOpenException exceptionWithObject: self];
return _atEndOfStream;
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
ssize_t ret;
#ifndef OF_AMIGAOS
if (_fd == -1)
@throw [OFNotOpenException exceptionWithObject: self];
|
︙ | | |
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
-
+
-
|
if (ret == 0)
_atEndOfStream = true;
return ret;
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
#ifndef OF_AMIGAOS
if (_fd == -1)
@throw [OFNotOpenException exceptionWithObject: self];
# ifndef OF_WINDOWS
ssize_t bytesWritten;
|
︙ | | |
Modified src/OFStream.m
from [0671a78655]
to [7e32841415].
︙ | | |
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
-
+
-
|
{
if (_readBufferLength > 0)
return false;
return [self lowlevelIsAtEndOfStream];
}
- (size_t)readIntoBuffer: (void *)buffer
- (size_t)readIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
if (_readBufferLength == 0) {
/*
* For small sizes, it is cheaper to read more and cache the
* remainder - even if that means more copying of data - than
* to do a syscall for every read.
*/
|
︙ | | |
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
|
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
-
|
[data addItems: buffer count: length];
}
} @finally {
free(buffer);
}
[data makeImmutable];
return data;
}
- (OFString *)readStringWithLength: (size_t)length
{
return [self readStringWithLength: length
encoding: OF_STRING_ENCODING_UTF_8];
|
︙ | | |
Modified src/OFStreamSocket.m
from [791405f855]
to [7f5d88caa9].
︙ | | |
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
+
-
|
{
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
return _atEndOfStream;
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
ssize_t ret;
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_WINDOWS
|
︙ | | |
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
-
+
-
|
if (ret == 0)
_atEndOfStream = true;
return ret;
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
if (_socket == INVALID_SOCKET)
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_WINDOWS
ssize_t bytesWritten;
|
︙ | | |
Modified src/OFString+CryptoHashing.m
from [0a23b41efc]
to [826ee219c6].
︙ | | |
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
-
+
-
|
void *pool = objc_autoreleasePoolPush();
id <OFCryptoHash> hash = [class
cryptoHashWithAllowsSwappableMemory: true];
size_t digestSize = [class digestSize];
const unsigned char *digest;
char cString[digestSize * 2];
[hash updateWithBuffer: self.UTF8String
[hash updateWithBuffer: self.UTF8String length: self.UTF8StringLength];
length: self.UTF8StringLength];
digest = hash.digest;
for (size_t i = 0; i < digestSize; i++) {
uint8_t high, low;
high = digest[i] >> 4;
low = digest[i] & 0x0F;
|
︙ | | |
Modified src/OFString+JSONParsing.m
from [0ac530152e]
to [c87ddb2735].
︙ | | |
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
|
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
-
+
-
|
if ((*pointer)[i] == '\n')
(*line)++;
break;
}
}
string = [[OFString alloc] initWithUTF8String: *pointer
string = [[OFString alloc] initWithUTF8String: *pointer length: i];
length: i];
*pointer += i;
@try {
if (hasDecimal)
number = [OFNumber numberWithDouble:
string.doubleValue];
else if ([string isEqual: @"Infinity"])
|
︙ | | |
Modified src/OFString+URLEncoding.m
from [e71fa29471]
to [6ddd187364].
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
methodForSelector: @selector(characterIsMember:)];
for (size_t i = 0; i < length; i++) {
of_unichar_t c = characters[i];
if (characterIsMember(allowedCharacters,
@selector(characterIsMember:), c))
[ret appendCharacters: &c
[ret appendCharacters: &c length: 1];
length: 1];
else {
char buffer[4];
size_t bufferLen;
if ((bufferLen = of_string_utf8_encode(c, buffer)) == 0)
@throw [OFInvalidEncodingException exception];
for (size_t j = 0; j < bufferLen; j++) {
unsigned char byte = buffer[j];
unsigned char high = byte >> 4;
unsigned char low = byte & 0x0F;
char escaped[3];
escaped[0] = '%';
escaped[1] =
(high > 9 ? high - 10 + 'A' : high + '0');
escaped[2] =
(low > 9 ? low - 10 + 'A' : low + '0');
[ret appendUTF8String: escaped
[ret appendUTF8String: escaped length: 3];
length: 3];
}
}
}
objc_autoreleasePoolPop(pool);
return ret;
|
︙ | | |
Modified src/OFString+XMLUnescaping.m
from [563c6e6449]
to [c09f1d107c].
︙ | | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
-
|
}
}
if ((i = of_string_utf8_encode(c, buffer)) == 0)
return nil;
buffer[i] = 0;
return [OFString stringWithUTF8String: buffer
return [OFString stringWithUTF8String: buffer length: i];
length: i];
}
static OFString *
parseEntities(OFString *self, id (*lookup)(void *, OFString *, OFString *),
void *context)
{
OFMutableString *ret;
|
︙ | | |
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
-
+
-
-
|
length = self.UTF8StringLength;
last = 0;
inEntity = false;
for (i = 0; i < length; i++) {
if (!inEntity && string[i] == '&') {
[ret appendUTF8String: string + last
[ret appendUTF8String: string + last length: i - last];
length: i - last];
last = i + 1;
inEntity = true;
} else if (inEntity && string[i] == ';') {
const char *entity = string + last;
size_t entityLength = i - last;
if (entityLength == 2 && memcmp(entity, "lt", 2) == 0)
|
︙ | | |
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
193
194
195
196
197
198
199
|
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
193
|
-
+
-
-
-
-
+
|
inEntity = false;
}
}
if (inEntity)
@throw [OFInvalidFormatException exception];
[ret appendUTF8String: string + last
[ret appendUTF8String: string + last length: i - last];
length: i - last];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
static id
lookupUsingDelegate(void *context, OFString *self, OFString *entity)
{
id <OFStringXMLUnescapingDelegate> delegate = context;
if (delegate == nil)
return nil;
return [delegate string: self
containsUnknownEntityNamed: entity];
return [delegate string: self containsUnknownEntityNamed: entity];
}
#ifdef OF_HAVE_BLOCKS
static id
lookupUsingBlock(void *context, OFString *self, OFString *entity)
{
of_string_xml_unescaping_block_t block = context;
|
︙ | | |
Modified src/OFString.m
from [cc999ec09b]
to [e6372d29b7].
︙ | | |
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
|
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
|
-
+
-
|
return ret;
}
- (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String
length: (size_t)UTF8StringLength
freeWhenDone: (bool)freeWhenDone
{
id ret = [self initWithUTF8String: UTF8String
id ret = [self initWithUTF8String: UTF8String length: UTF8StringLength];
length: UTF8StringLength];
if (freeWhenDone)
free(UTF8String);
return ret;
}
|
︙ | | |
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
|
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
|
-
|
*/
if (SIZE_MAX - (size_t)fileSize < 1)
@throw [OFOutOfRangeException exception];
tmp = of_alloc((size_t)fileSize + 1, 1);
@try {
file = [[OFFile alloc] initWithPath: path mode: @"r"];
[file readIntoBuffer: tmp
exactLength: (size_t)fileSize];
} @catch (id e) {
free(tmp);
@throw e;
} @finally {
[file release];
|
︙ | | |
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
|
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
size_t length;
length = self.UTF8StringLength;
if (length <= 31) {
uint8_t tmp = 0xA0 | ((uint8_t)length & 0x1F);
data = [OFMutableData dataWithItemSize: 1 capacity: length + 1];
data = [OFMutableData dataWithCapacity: length + 1];
[data addItem: &tmp];
} else if (length <= UINT8_MAX) {
uint8_t type = 0xD9;
uint8_t tmp = (uint8_t)length;
data = [OFMutableData dataWithItemSize: 1 capacity: length + 2];
data = [OFMutableData dataWithCapacity: length + 2];
[data addItem: &type];
[data addItem: &tmp];
} else if (length <= UINT16_MAX) {
uint8_t type = 0xDA;
uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)length);
data = [OFMutableData dataWithItemSize: 1 capacity: length + 3];
data = [OFMutableData dataWithCapacity: length + 3];
[data addItem: &type];
[data addItems: &tmp count: sizeof(tmp)];
} else if (length <= UINT32_MAX) {
uint8_t type = 0xDB;
uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)length);
data = [OFMutableData dataWithItemSize: 1 capacity: length + 5];
data = [OFMutableData dataWithCapacity: length + 5];
[data addItem: &type];
[data addItems: &tmp count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
[data addItems: self.UTF8String count: length];
return data;
}
- (of_range_t)rangeOfString: (OFString *)string
{
return [self rangeOfString: string
options: 0
range: of_range(0, self.length)];
}
- (of_range_t)rangeOfString: (OFString *)string
- (of_range_t)rangeOfString: (OFString *)string options: (int)options
options: (int)options
{
return [self rangeOfString: string
options: options
range: of_range(0, self.length)];
}
- (of_range_t)rangeOfString: (OFString *)string
|
︙ | | |
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
|
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
|
-
+
-
-
-
+
-
-
-
+
-
|
#ifdef OF_HAVE_FILES
- (void)writeToFile: (OFString *)path
{
[self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8];
}
- (void)writeToFile: (OFString *)path
- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding
encoding: (of_string_encoding_t)encoding
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [OFFile fileWithPath: path mode: @"w"];
[file writeString: self
[file writeString: self encoding: encoding];
encoding: encoding];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)writeToURL: (OFURL *)URL
{
[self writeToURL: URL encoding: OF_STRING_ENCODING_UTF_8];
}
- (void)writeToURL: (OFURL *)URL
- (void)writeToURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding
encoding: (of_string_encoding_t)encoding
{
void *pool = objc_autoreleasePoolPush();
OFURLHandler *URLHandler;
OFStream *stream;
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
|
︙ | | |
Modified src/OFSubarray.m
from [8ab33d1782]
to [a275f23615].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
-
+
-
-
+
-
-
+
-
|
#include "config.h"
#import "OFSubarray.h"
#import "OFOutOfRangeException.h"
@implementation OFSubarray
+ (instancetype)arrayWithArray: (OFArray *)array
+ (instancetype)arrayWithArray: (OFArray *)array range: (of_range_t)range
range: (of_range_t)range
{
return [[[self alloc] initWithArray: array
return [[[self alloc] initWithArray: array range: range] autorelease];
range: range] autorelease];
}
- (instancetype)initWithArray: (OFArray *)array
- (instancetype)initWithArray: (OFArray *)array range: (of_range_t)range
range: (of_range_t)range
{
self = [super init];
@try {
/* Should usually be retain, as it's useless with a copy */
_array = [array copy];
_range = range;
|
︙ | | |
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
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
-
+
-
-
+
-
|
{
if (idx >= _range.length)
@throw [OFOutOfRangeException exception];
return [_array objectAtIndex: idx + _range.location];
}
- (void)getObjects: (id *)buffer
- (void)getObjects: (id *)buffer inRange: (of_range_t)range
inRange: (of_range_t)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _range.length)
@throw [OFOutOfRangeException exception];
range.location += _range.location;
[_array getObjects: buffer
[_array getObjects: buffer inRange: range];
inRange: range];
}
- (size_t)indexOfObject: (id)object
{
size_t idx = [_array indexOfObject: object];
if (idx < _range.location)
|
︙ | | |
Modified src/OFSystemInfo.m
from [d40194da67]
to [6c63cf09e4].
︙ | | |
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
-
|
object: self];
[path deleteCharactersInRange: of_range(0, 1)];
[path prependString: home];
}
[path appendString: @"/Preferences"];
[path makeImmutable];
return path;
# elif defined(OF_WINDOWS)
OFDictionary *env = [OFApplication environment];
OFString *appData;
|
︙ | | |
Modified src/OFTCPSocket.m
from [49e1470816]
to [5cdf6dd0d8].
︙ | | |
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
-
+
-
-
+
-
-
+
-
-
+
-
|
- (void)of_closeSocket
{
closesocket(_socket);
_socket = INVALID_SOCKET;
}
- (void)connectToHost: (OFString *)host
- (void)connectToHost: (OFString *)host port: (uint16_t)port
port: (uint16_t)port
{
void *pool = objc_autoreleasePoolPush();
id <OFTCPSocketDelegate> delegate = _delegate;
OFTCPSocketConnectDelegate *connectDelegate =
[[[OFTCPSocketConnectDelegate alloc] init] autorelease];
OFRunLoop *runLoop = [OFRunLoop currentRunLoop];
self.delegate = connectDelegate;
[self asyncConnectToHost: host
port: port
runLoopMode: connectRunLoopMode];
while (!connectDelegate->_done)
[runLoop runMode: connectRunLoopMode
[runLoop runMode: connectRunLoopMode beforeDate: nil];
beforeDate: nil];
/* Cleanup */
[runLoop runMode: connectRunLoopMode
[runLoop runMode: connectRunLoopMode beforeDate: [OFDate date]];
beforeDate: [OFDate date]];
if (connectDelegate->_exception != nil)
@throw connectDelegate->_exception;
self.delegate = delegate;
objc_autoreleasePoolPop(pool);
}
- (void)asyncConnectToHost: (OFString *)host
- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port
port: (uint16_t)port
{
[self asyncConnectToHost: host
port: port
runLoopMode: of_run_loop_mode_default];
}
- (void)asyncConnectToHost: (OFString *)host
|
︙ | | |
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
-
+
-
|
block: (delegate == nil ? block : NULL)] autorelease]
startWithRunLoopMode: runLoopMode];
objc_autoreleasePoolPop(pool);
}
#endif
- (uint16_t)bindToHost: (OFString *)host
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port
port: (uint16_t)port
{
const int one = 1;
void *pool = objc_autoreleasePoolPush();
OFData *socketAddresses;
of_socket_address_t address;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
int flags;
|
︙ | | |
Modified src/OFTCPSocketSOCKS5Connector.m
from [9fddf9f0fe]
to [777126a470].
︙ | | |
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
-
+
|
#ifdef OF_HAVE_BLOCKS
if (_block != NULL)
_block(_exception);
else {
#endif
if ([_delegate respondsToSelector:
@selector(socket:didConnectToHost:port:exception:)])
[_delegate socket: _socket
[_delegate socket: _socket
didConnectToHost: _host
port: _port
exception: _exception];
#ifdef OF_HAVE_BLOCKS
}
#endif
}
|
︙ | | |
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
-
+
-
|
if (exception != nil) {
_exception = [exception retain];
[self didConnect];
return;
}
data = [OFData dataWithItems: "\x05\x01\x00"
data = [OFData dataWithItems: "\x05\x01\x00" count: 3];
count: 3];
_SOCKS5State = OF_SOCKS5_STATE_SEND_AUTHENTICATION;
[_socket asyncWriteData: data
runLoopMode: [OFRunLoop currentRunLoop].currentMode];
}
- (bool)stream: (OFStream *)sock
|
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
[self didConnect];
return false;
}
[_request release];
_request = [[OFMutableData alloc] init];
[_request addItems: "\x05\x01\x00\x03"
[_request addItems: "\x05\x01\x00\x03" count: 4];
count: 4];
hostLength = (uint8_t)_host.UTF8StringLength;
[_request addItem: &hostLength];
[_request addItems: _host.UTF8String
[_request addItems: _host.UTF8String count: hostLength];
count: hostLength];
port[0] = _port >> 8;
port[1] = _port & 0xFF;
[_request addItems: port
[_request addItems: port count: 2];
count: 2];
_SOCKS5State = OF_SOCKS5_STATE_SEND_REQUEST;
[_socket asyncWriteData: _request
[_socket asyncWriteData: _request runLoopMode: runLoopMode];
runLoopMode: runLoopMode];
return false;
case OF_SOCKS5_STATE_READ_RESPONSE:
response = buffer;
if (response[0] != 5 || response[2] != 0) {
_exception = [[OFConnectionFailedException alloc]
initWithHost: _host
|
︙ | | |
Modified src/OFTarArchive.m
from [a40561e369]
to [0481cd7f61].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry;
@end
@implementation OFTarArchive: OFObject
@synthesize encoding = _encoding;
+ (instancetype)archiveWithStream: (OFStream *)stream
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
mode: mode] autorelease];
}
#ifdef OF_HAVE_FILES
+ (instancetype)archiveWithPath: (OFString *)path
+ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode
mode: (OFString *)mode
{
return [[[self alloc] initWithPath: path
return [[[self alloc] initWithPath: path mode: mode] autorelease];
mode: mode] autorelease];
}
#endif
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithStream: (OFStream *)stream
- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
self = [super init];
@try {
_stream = [stream retain];
if ([mode isEqual: @"r"])
|
︙ | | |
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
-
+
-
|
bool empty = true;
if (![_stream isKindOfClass: [OFSeekableStream class]])
@throw [OFInvalidArgumentException exception];
[(OFSeekableStream *)_stream seekToOffset: -1024
whence: SEEK_END];
[_stream readIntoBuffer: buffer
[_stream readIntoBuffer: buffer exactLength: 1024];
exactLength: 1024];
for (size_t i = 0; i < 1024 / sizeof(uint32_t); i++)
if (buffer[i] != 0)
empty = false;
if (!empty)
@throw [OFInvalidFormatException exception];
|
︙ | | |
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
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
-
+
-
-
+
-
-
+
-
-
+
-
|
@throw e;
}
return self;
}
#ifdef OF_HAVE_FILES
- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode
mode: (OFString *)mode
{
OFFile *file;
if ([mode isEqual: @"a"])
file = [[OFFile alloc] initWithPath: path
file = [[OFFile alloc] initWithPath: path mode: @"r+"];
mode: @"r+"];
else
file = [[OFFile alloc] initWithPath: path
file = [[OFFile alloc] initWithPath: path mode: mode];
mode: mode];
@try {
self = [self initWithStream: file
self = [self initWithStream: file mode: mode];
mode: mode];
} @finally {
[file release];
}
return self;
}
#endif
|
︙ | | |
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
-
+
-
-
+
-
|
}
[_lastReturnedStream release];
_lastReturnedStream = nil;
if (_stream.atEndOfStream)
return nil;
[_stream readIntoBuffer: buffer
[_stream readIntoBuffer: buffer exactLength: 512];
exactLength: 512];
for (size_t i = 0; i < 512 / sizeof(uint32_t); i++)
if (buffer[i] != 0)
empty = false;
if (empty) {
[_stream readIntoBuffer: buffer
[_stream readIntoBuffer: buffer exactLength: 512];
exactLength: 512];
for (size_t i = 0; i < 512 / sizeof(uint32_t); i++)
if (buffer[i] != 0)
@throw [OFInvalidFormatException exception];
return nil;
}
|
︙ | | |
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
-
+
-
|
[_lastReturnedStream close];
} @catch (OFNotOpenException *e) {
/* Might have already been closed by the user - that's fine. */
}
[_lastReturnedStream release];
_lastReturnedStream = nil;
[entry of_writeToStream: _stream
[entry of_writeToStream: _stream encoding: _encoding];
encoding: _encoding];
_lastReturnedStream = [[OFTarArchiveFileWriteStream alloc]
of_initWithStream: _stream
entry: entry];
objc_autoreleasePoolPop(pool);
|
︙ | | |
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
-
+
-
-
|
if (length > UINT64_MAX)
@throw [OFOutOfRangeException exception];
#endif
if ((uint64_t)length > _toRead)
length = (size_t)_toRead;
ret = [_stream readIntoBuffer: buffer
ret = [_stream readIntoBuffer: buffer length: length];
length: length];
if (ret == 0)
_atEndOfStream = true;
_toRead -= ret;
return ret;
}
|
︙ | | |
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
|
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
-
+
-
|
seekToOffset: 512 - (size % 512)
whence: SEEK_CUR];
} else {
char buffer[512];
uint64_t size;
while (_toRead >= 512) {
[_stream readIntoBuffer: buffer
[_stream readIntoBuffer: buffer exactLength: 512];
exactLength: 512];
_toRead -= 512;
}
if (_toRead > 0) {
[_stream readIntoBuffer: buffer
exactLength: (size_t)_toRead];
_toRead = 0;
|
︙ | | |
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
-
+
-
|
[self close];
[_entry release];
[super dealloc];
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
size_t bytesWritten;
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if ((uint64_t)length > _toWrite)
|
︙ | | |
Modified src/OFTarArchiveEntry.m
from [e22a0061ae]
to [9e0aa08280].
︙ | | |
338
339
340
341
342
343
344
345
346
347
348
|
338
339
340
341
342
343
344
345
346
347
|
-
+
-
|
/* Fill in the checksum */
for (size_t i = 0; i < 500; i++)
checksum += buffer[i];
stringToBuffer(buffer + 148,
[OFString stringWithFormat: @"%06" PRIo16, checksum], 7,
OF_STRING_ENCODING_ASCII);
[stream writeBuffer: buffer
[stream writeBuffer: buffer length: sizeof(buffer)];
length: sizeof(buffer)];
}
@end
|
Modified src/OFThreadPool.m
from [1ccbdebec3]
to [1d33cef32f].
︙ | | |
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
+
-
|
- (void)perform
{
#ifdef OF_HAVE_BLOCKS
if (_block != NULL)
_block();
else
#endif
[_target performSelector: _selector
[_target performSelector: _selector withObject: _object];
withObject: _object];
}
@end
OF_DIRECT_MEMBERS
@interface OFThreadPoolThread: OFThread
{
OFList *_queue;
|
︙ | | |
Modified src/OFTimer.m
from [f2217d4a17]
to [8d739f9efc].
︙ | | |
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
|
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
-
+
-
|
@throw [OFInvalidArgumentException exception];
timer = (OFTimer *)object;
return [_fireDate compare: timer->_fireDate];
}
- (void)of_setInRunLoop: (OFRunLoop *)runLoop
- (void)of_setInRunLoop: (OFRunLoop *)runLoop mode: (of_run_loop_mode_t)mode
mode: (of_run_loop_mode_t)mode
{
OFRunLoop *oldInRunLoop = _inRunLoop;
of_run_loop_mode_t oldInRunLoopMode = _inRunLoopMode;
_inRunLoop = [runLoop retain];
[oldInRunLoop release];
|
︙ | | |
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
-
+
-
-
+
-
|
(missedIntervals + 1) * _interval;
[_fireDate release];
_fireDate = [[OFDate alloc]
initWithTimeIntervalSince1970: newFireDate];
runLoop = [OFRunLoop currentRunLoop];
[runLoop addTimer: self
[runLoop addTimer: self forMode: runLoop.currentMode];
forMode: runLoop.currentMode];
} else
[self invalidate];
#ifdef OF_HAVE_BLOCKS
if (_block != NULL)
_block(self);
else {
#endif
switch (_arguments) {
case 0:
[target performSelector: _selector];
break;
case 1:
[target performSelector: _selector
[target performSelector: _selector withObject: object1];
withObject: object1];
break;
case 2:
[target performSelector: _selector
withObject: object1
withObject: object2];
break;
case 3:
|
︙ | | |
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
-
+
-
|
[_inRunLoop of_removeTimer: self
forMode: _inRunLoopMode];
old = _fireDate;
_fireDate = [fireDate copy];
[old release];
[_inRunLoop addTimer: self
[_inRunLoop addTimer: self forMode: _inRunLoopMode];
forMode: _inRunLoopMode];
}
} @finally {
[self release];
}
}
- (void)invalidate
|
︙ | | |
Modified src/OFUDPSocket.m
from [26835c8d41]
to [ab91d5347a].
︙ | | |
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
193
194
195
196
197
198
199
|
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
193
194
195
196
197
|
-
+
-
-
+
-
|
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: EADDRNOTAVAIL];
#endif
}
- (uint16_t)bindToHost: (OFString *)host
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port
port: (uint16_t)port
{
void *pool = objc_autoreleasePoolPush();
OFData *socketAddresses;
of_socket_address_t address;
if (_socket != INVALID_SOCKET)
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
socketAddresses = [[OFThread DNSResolver]
resolveAddressesForHost: host
addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY];
address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0];
of_socket_address_set_port(&address, port);
port = [self of_bindToAddress: &address
port = [self of_bindToAddress: &address extraType: 0];
extraType: 0];
objc_autoreleasePoolPop(pool);
return port;
}
@end
|
Modified src/OFURL.m
from [a106091d83]
to [c6fcf8ea2f].
︙ | | |
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
|
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
-
+
-
|
} @finally {
free(UTF8String2);
}
return self;
}
- (instancetype)initWithString: (OFString *)string
- (instancetype)initWithString: (OFString *)string relativeToURL: (OFURL *)URL
relativeToURL: (OFURL *)URL
{
char *UTF8String, *UTF8String2 = NULL;
if ([string containsString: @"://"])
return [self initWithString: string];
self = [super init];
|
︙ | | |
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
|
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
-
-
-
+
-
|
#ifdef OF_HAVE_FILES
- (instancetype)initFileURLWithPath: (OFString *)path
{
bool isDirectory;
@try {
void *pool = objc_autoreleasePoolPush();
isDirectory = [path of_isDirectoryPath];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
self = [self initFileURLWithPath: path
self = [self initFileURLWithPath: path isDirectory: isDirectory];
isDirectory: isDirectory];
return self;
}
- (instancetype)initFileURLWithPath: (OFString *)path
isDirectory: (bool)isDirectory
{
|
︙ | | |
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
|
-
+
-
-
+
-
|
#ifdef OF_HAVE_FILES
if (isFile) {
OFString *path = [_URLEncodedPath
of_URLPathToPathWithURLEncodedHost: nil];
ret = [[path.pathComponents mutableCopy] autorelease];
if (![ret.firstObject isEqual: @"/"])
[ret insertObject: @"/"
[ret insertObject: @"/" atIndex: 0];
atIndex: 0];
} else
#endif
ret = [[[_URLEncodedPath componentsSeparatedByString: @"/"]
mutableCopy] autorelease];
count = ret.count;
if (count > 0 && [ret.firstObject length] == 0)
[ret replaceObjectAtIndex: 0
[ret replaceObjectAtIndex: 0 withObject: @"/"];
withObject: @"/"];
for (size_t i = 0; i < count; i++) {
OFString *component = [ret objectAtIndex: i];
#ifdef OF_HAVE_FILES
if (isFile)
component =
|
︙ | | |
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
|
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
|
-
-
-
-
+
-
-
-
-
|
return [path autorelease];
}
#endif
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component];
[URL makeImmutable];
return URL;
}
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
isDirectory: (bool)isDirectory
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component
[URL appendPathComponent: component isDirectory: isDirectory];
isDirectory: isDirectory];
[URL makeImmutable];
return URL;
}
- (OFURL *)URLByStandardizingPath
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL standardizePath];
[URL makeImmutable];
return URL;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@>",
self.class, self.string];
|
︙ | | |
Modified src/OFURLHandler.m
from [40d9847175]
to [227a2dfab0].
︙ | | |
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
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
-
+
-
-
+
-
-
+
-
-
+
-
|
handlers = [[OFMutableDictionary alloc] init];
#ifdef OF_HAVE_THREADS
mutex = [[OFMutex alloc] init];
atexit(releaseMutex);
#endif
#ifdef OF_HAVE_FILES
[self registerClass: [OFFileURLHandler class]
[self registerClass: [OFFileURLHandler class] forScheme: @"file"];
forScheme: @"file"];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
[self registerClass: [OFHTTPURLHandler class]
[self registerClass: [OFHTTPURLHandler class] forScheme: @"http"];
forScheme: @"http"];
[self registerClass: [OFHTTPURLHandler class]
[self registerClass: [OFHTTPURLHandler class] forScheme: @"https"];
forScheme: @"https"];
#endif
}
+ (bool)registerClass: (Class)class
+ (bool)registerClass: (Class)class forScheme: (OFString *)scheme
forScheme: (OFString *)scheme
{
#ifdef OF_HAVE_THREADS
[mutex lock];
@try {
#endif
OFURLHandler *handler;
|
︙ | | |
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
-
+
-
|
- (void)dealloc
{
[_scheme release];
[super dealloc];
}
- (OFStream *)openItemAtURL: (OFURL *)URL
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
mode: (OFString *)mode
{
OF_UNRECOGNIZED_SELECTOR
}
- (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL
{
OF_UNRECOGNIZED_SELECTOR
|
︙ | | |
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
-
+
-
-
+
-
-
+
-
|
}
- (void)removeItemAtURL: (OFURL *)URL
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)linkItemAtURL: (OFURL *)source
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)createSymbolicLinkAtURL: (OFURL *)destination
withDestinationPath: (OFString *)source
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)copyItemAtURL: (OFURL *)source
- (bool)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
return false;
}
- (bool)moveItemAtURL: (OFURL *)source
- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination
toURL: (OFURL *)destination
{
return false;
}
@end
|
Modified src/OFUTF8String.m
from [0d15ab4aab]
to [b5e6f95eb4].
︙ | | |
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
|
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
|
-
+
-
|
if (of_string_utf8_decode(_s->cString + idx,
_s->cStringLength - idx, &character) <= 0)
@throw [OFInvalidEncodingException exception];
return character;
}
- (void)getCharacters: (of_unichar_t *)buffer
- (void)getCharacters: (of_unichar_t *)buffer inRange: (of_range_t)range
inRange: (of_range_t)range
{
/* TODO: Could be slightly optimized */
void *pool = objc_autoreleasePoolPush();
const of_unichar_t *characters = self.characters;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _s->length)
|
︙ | | |
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
|
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
|
-
+
-
-
+
+
|
continue;
}
if (*cString == '\n' || *cString == '\r') {
pool = objc_autoreleasePoolPush();
block([OFString
block([OFString stringWithUTF8String: last
stringWithUTF8String: last
length: cString - last], &stop);
length: cString - last],
&stop);
last = cString + 1;
objc_autoreleasePoolPop(pool);
}
lastCarriageReturn = (*cString == '\r');
cString++;
|
︙ | | |
Modified src/OFValue.m
from [1c056221ee]
to [0c9f7f6c34].
︙ | | |
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
-
+
-
-
+
-
-
-
+
-
|
otherValue = of_alloc(1, size);
} @catch (id e) {
free(value);
@throw e;
}
@try {
[self getValue: value
[self getValue: value size: size];
size: size];
[object getValue: otherValue
[object getValue: otherValue size: size];
size: size];
ret = (memcmp(value, otherValue, size) == 0);
} @finally {
free(value);
free(otherValue);
}
return ret;
}
- (unsigned long)hash
{
size_t size = of_sizeof_type_encoding(self.objCType);
unsigned char *value;
uint32_t hash;
value = of_alloc(1, size);
@try {
[self getValue: value
[self getValue: value size: size];
size: size];
OF_HASH_INIT(hash);
for (size_t i = 0; i < size; i++)
OF_HASH_ADD(hash, value[i]);
OF_HASH_FINALIZE(hash);
|
︙ | | |
234
235
236
237
238
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
230
231
232
233
234
235
236
237
238
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
-
+
-
-
-
+
-
-
-
-
+
-
-
-
-
+
-
-
-
-
+
-
-
-
-
+
-
-
-
-
+
-
-
-
+
-
|
}
- (const char *)objCType
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)getValue: (void *)value
- (void)getValue: (void *)value size: (size_t)size
size: (size_t)size
{
OF_UNRECOGNIZED_SELECTOR
}
- (void *)pointerValue
{
void *ret;
[self getValue: &ret
[self getValue: &ret size: sizeof(ret)];
size: sizeof(ret)];
return ret;
}
- (id)nonretainedObjectValue
{
id ret;
[self getValue: &ret
[self getValue: &ret size: sizeof(ret)];
size: sizeof(ret)];
return ret;
}
- (of_range_t)rangeValue
{
of_range_t ret;
[self getValue: &ret
[self getValue: &ret size: sizeof(ret)];
size: sizeof(ret)];
return ret;
}
- (of_point_t)pointValue
{
of_point_t ret;
[self getValue: &ret
[self getValue: &ret size: sizeof(ret)];
size: sizeof(ret)];
return ret;
}
- (of_dimension_t)dimensionValue
{
of_dimension_t ret;
[self getValue: &ret
[self getValue: &ret size: sizeof(ret)];
size: sizeof(ret)];
return ret;
}
- (of_rectangle_t)rectangleValue
{
of_rectangle_t ret;
[self getValue: &ret
[self getValue: &ret size: sizeof(ret)];
size: sizeof(ret)];
return ret;
}
- (OFString *)description
{
OFMutableString *ret =
[OFMutableString stringWithString: @"<OFValue: "];
size_t size = of_sizeof_type_encoding(self.objCType);
unsigned char *value;
value = of_alloc(1, size);
@try {
[self getValue: value
[self getValue: value size: size];
size: size];
for (size_t i = 0; i < size; i++) {
if (i > 0)
[ret appendString: @" "];
[ret appendFormat: @"%02x", value[i]];
}
|
︙ | | |
Modified src/OFWin32ConsoleStdIOStream.m
from [fb543571fa]
to [0662c30238].
︙ | | |
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer_
- (size_t)lowlevelReadIntoBuffer: (void *)buffer_ length: (size_t)length
length: (size_t)length
{
void *pool = objc_autoreleasePoolPush();
char *buffer = buffer_;
of_char16_t *UTF16;
size_t j = 0;
if (length > UINT32_MAX)
|
︙ | | |
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
-
+
-
|
if (UTF8Len <= length) {
memcpy(buffer, UTF8, UTF8Len);
j += UTF8Len;
} else {
if (rest == nil)
rest = [OFMutableData data];
[rest addItems: UTF8
[rest addItems: UTF8 count: UTF8Len];
count: UTF8Len];
}
_incompleteUTF16Surrogate = 0;
i++;
}
for (; i < UTF16Len; i++) {
|
︙ | | |
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
270
271
272
273
274
275
276
|
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
270
271
|
-
+
-
-
+
-
-
+
-
|
if (j + UTF8Len <= length) {
memcpy(buffer + j, UTF8, UTF8Len);
j += UTF8Len;
} else {
if (rest == nil)
rest = [OFMutableData data];
[rest addItems: UTF8
[rest addItems: UTF8 count: UTF8Len];
count: UTF8Len];
}
}
if (rest != nil)
[self unreadFromBuffer: rest.items
[self unreadFromBuffer: rest.items length: rest.count];
length: rest.count];
} @finally {
free(UTF16);
}
objc_autoreleasePoolPop(pool);
return j;
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer_
- (size_t)lowlevelWriteBuffer: (const void *)buffer_ length: (size_t)length
length: (size_t)length
{
const char *buffer = buffer_;
of_char16_t *tmp;
size_t i = 0, j = 0;
if (length > SIZE_MAX / 2)
@throw [OFOutOfRangeException exception];
|
︙ | | |
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
|
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
-
+
-
-
-
|
if (!GetConsoleScreenBufferInfo(_handle, &csbi))
return;
csbi.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN |
FOREGROUND_BLUE | FOREGROUND_INTENSITY);
[color getRed: &red
[color getRed: &red green: &green blue: &blue alpha: NULL];
green: &green
blue: &blue
alpha: NULL];
if (red >= 0.25)
csbi.wAttributes |= FOREGROUND_RED;
if (green >= 0.25)
csbi.wAttributes |= FOREGROUND_GREEN;
if (blue >= 0.25)
csbi.wAttributes |= FOREGROUND_BLUE;
|
︙ | | |
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
|
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
|
-
+
-
-
-
|
if (!GetConsoleScreenBufferInfo(_handle, &csbi))
return;
csbi.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN |
BACKGROUND_BLUE | BACKGROUND_INTENSITY);
[color getRed: &red
[color getRed: &red green: &green blue: &blue alpha: NULL];
green: &green
blue: &blue
alpha: NULL];
if (red >= 0.25)
csbi.wAttributes |= BACKGROUND_RED;
if (green >= 0.25)
csbi.wAttributes |= BACKGROUND_GREEN;
if (blue >= 0.25)
csbi.wAttributes |= BACKGROUND_BLUE;
|
︙ | | |
Modified src/OFWindowsRegistryKey.m
from [a2f59b5b67]
to [8c15fe2a75].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
-
|
#import "OFInvalidFormatException.h"
#import "OFOpenWindowsRegistryKeyFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFSetWindowsRegistryValueFailedException.h"
OF_DIRECT_MEMBERS
@interface OFWindowsRegistryKey ()
- (instancetype)of_initWithHKey: (HKEY)hKey
- (instancetype)of_initWithHKey: (HKEY)hKey close: (bool)close;
close: (bool)close;
@end
@implementation OFWindowsRegistryKey
+ (instancetype)classesRootKey
{
return [[[self alloc] of_initWithHKey: HKEY_CLASSES_ROOT
close: false] autorelease];
|
︙ | | |
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
-
|
+ (instancetype)usersKey
{
return [[[self alloc] of_initWithHKey: HKEY_USERS
close: false] autorelease];
}
- (instancetype)of_initWithHKey: (HKEY)hKey
- (instancetype)of_initWithHKey: (HKEY)hKey close: (bool)close
close: (bool)close
{
self = [super init];
_hKey = hKey;
_close = close;
return self;
|
︙ | | |
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-
+
-
|
objc_autoreleasePoolPop(pool);
return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey
close: true]
autorelease];
}
- (OFData *)dataForValueNamed: (OFString *)name
- (OFData *)dataForValueNamed: (OFString *)name type: (DWORD *)type
type: (DWORD *)type
{
void *pool = objc_autoreleasePoolPush();
BYTE stackBuffer[256], *buffer = stackBuffer;
DWORD length = sizeof(stackBuffer);
OFMutableData *ret = nil;
bool winNT = [OFSystemInfo isWindowsNT];
LSTATUS status;
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
-
+
-
-
+
-
-
+
-
|
data: data
type: type
status: status];
}
- (OFString *)stringForValueNamed: (OFString *)name
{
return [self stringForValueNamed: name
return [self stringForValueNamed: name type: NULL];
type: NULL];
}
- (OFString *)stringForValueNamed: (OFString *)name
- (OFString *)stringForValueNamed: (OFString *)name type: (DWORD *)typeOut
type: (DWORD *)typeOut
{
void *pool = objc_autoreleasePoolPush();
DWORD type;
OFData *data = [self dataForValueNamed: name
OFData *data = [self dataForValueNamed: name type: &type];
type: &type];
OFString *ret;
if (data == nil)
return nil;
if (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_LINK)
@throw [OFInvalidEncodingException exception];
|
︙ | | |
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
-
+
-
-
-
+
-
-
+
-
-
-
+
-
|
*typeOut = type;
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (void)setString: (OFString *)string
- (void)setString: (OFString *)string forValueNamed: (OFString *)name
forValueNamed: (OFString *)name
{
[self setString: string
forValueNamed: name
[self setString: string forValueNamed: name type: REG_SZ];
type: REG_SZ];
}
- (void)setString: (OFString *)string
forValueNamed: (OFString *)name
type: (DWORD)type
{
void *pool = objc_autoreleasePoolPush();
OFData *data;
if ([OFSystemInfo isWindowsNT])
data = [OFData dataWithItems: string.UTF16String
count: string.UTF16StringLength + 1
itemSize: sizeof(of_char16_t)];
else {
of_string_encoding_t encoding = [OFLocale encoding];
const char *cString = [string cStringWithEncoding: encoding];
size_t length = [string cStringLengthWithEncoding: encoding];
data = [OFData dataWithItems: cString
data = [OFData dataWithItems: cString count: length + 1];
count: length + 1];
}
[self setData: data
forValueNamed: name
[self setData: data forValueNamed: name type: type];
type: type];
objc_autoreleasePoolPop(pool);
}
- (void)deleteValueNamed: (OFString *)name
{
void *pool = objc_autoreleasePoolPush();
|
︙ | | |
Modified src/OFXMLAttribute.m
from [29268ae3e9]
to [6ec2a305ed].
︙ | | |
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
-
-
+
-
|
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS];
[element addAttributeWithName: @"name"
[element addAttributeWithName: @"name" stringValue: _name];
stringValue: _name];
if (_namespace != nil)
[element addAttributeWithName: @"namespace"
stringValue: _namespace];
[element addAttributeWithName: @"stringValue"
stringValue: _stringValue];
|
︙ | | |
Modified src/OFXMLCDATA.m
from [f763238cef]
to [d5c3657cc1].
︙ | | |
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
-
+
|
- (OFString *)XMLStringWithIndentation: (unsigned int)indentation
{
return self.XMLString;
}
- (OFString *)XMLStringWithIndentation: (unsigned int)indentation
level: (unsigned int)level
level: (unsigned int)level
{
return self.XMLString;
}
- (OFString *)description
{
return self.XMLString;
|
︙ | | |
Modified src/OFXMLElement.m
from [96ecc2faed]
to [fe5473696c].
︙ | | |
121
122
123
124
125
126
127
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
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
-
+
-
-
-
+
-
-
|
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithName: (OFString *)name
{
return [self initWithName: name
return [self initWithName: name namespace: nil stringValue: nil];
namespace: nil
stringValue: nil];
}
- (instancetype)initWithName: (OFString *)name
stringValue: (OFString *)stringValue
{
return [self initWithName: name
namespace: nil
stringValue: stringValue];
}
- (instancetype)initWithName: (OFString *)name
namespace: (OFString *)namespace
{
return [self initWithName: name
return [self initWithName: name namespace: namespace stringValue: nil];
namespace: namespace
stringValue: nil];
}
- (instancetype)initWithName: (OFString *)name
namespace: (OFString *)namespace
stringValue: (OFString *)stringValue
{
self = [super of_init];
|
︙ | | |
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
|
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
-
+
-
|
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS];
if (_name != nil)
[element addAttributeWithName: @"name"
[element addAttributeWithName: @"name" stringValue: _name];
stringValue: _name];
if (_namespace != nil)
[element addAttributeWithName: @"namespace"
stringValue: _namespace];
if (_defaultNamespace != nil)
[element addAttributeWithName: @"defaultNamespace"
|
︙ | | |
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
|
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
[objects[i]->_name isEqual: attributeName]) {
[_attributes removeObjectAtIndex: i];
return;
}
}
}
- (void)setPrefix: (OFString *)prefix
- (void)setPrefix: (OFString *)prefix forNamespace: (OFString *)namespace
forNamespace: (OFString *)namespace
{
if (prefix.length == 0)
@throw [OFInvalidArgumentException exception];
if (namespace == nil)
namespace = @"";
[_namespaces setObject: prefix forKey: namespace];
}
- (void)bindPrefix: (OFString *)prefix
- (void)bindPrefix: (OFString *)prefix forNamespace: (OFString *)namespace
forNamespace: (OFString *)namespace
{
[self setPrefix: prefix
[self setPrefix: prefix forNamespace: namespace];
forNamespace: namespace];
[self addAttributeWithName: prefix
namespace: @"http://www.w3.org/2000/xmlns/"
stringValue: namespace];
}
- (void)addChild: (OFXMLNode *)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
if (_children == nil)
_children = [[OFMutableArray alloc] init];
[_children addObject: child];
}
- (void)insertChild: (OFXMLNode *)child
- (void)insertChild: (OFXMLNode *)child atIndex: (size_t)idx
atIndex: (size_t)idx
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
if (_children == nil)
_children = [[OFMutableArray alloc] init];
[_children insertObject: child
[_children insertObject: child atIndex: idx];
atIndex: idx];
}
- (void)insertChildren: (OFArray *)children
- (void)insertChildren: (OFArray *)children atIndex: (size_t)idx
atIndex: (size_t)idx
{
for (OFXMLNode *node in children)
if ([node isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children insertObjectsFromArray: children
[_children insertObjectsFromArray: children atIndex: idx];
atIndex: idx];
}
- (void)removeChild: (OFXMLNode *)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children removeObject: child];
}
- (void)removeChildAtIndex: (size_t)idx
{
[_children removeObjectAtIndex: idx];
}
- (void)replaceChild: (OFXMLNode *)child
- (void)replaceChild: (OFXMLNode *)child withNode: (OFXMLNode *)node
withNode: (OFXMLNode *)node
{
if ([node isKindOfClass: [OFXMLAttribute class]] ||
[child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children replaceObject: child
[_children replaceObject: child withObject: node];
withObject: node];
}
- (void)replaceChildAtIndex: (size_t)idx
- (void)replaceChildAtIndex: (size_t)idx withNode: (OFXMLNode *)node
withNode: (OFXMLNode *)node
{
if ([node isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children replaceObjectAtIndex: idx
[_children replaceObjectAtIndex: idx withObject: node];
withObject: node];
}
- (OFXMLElement *)elementForName: (OFString *)elementName
{
return [self elementsForName: elementName].firstObject;
}
|
︙ | | |
Modified src/OFXMLElementBuilder.m
from [ff12f91bf6]
to [fb50bb7b18].
︙ | | |
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
+
-
|
processingInstructionsWithString: pi];
OFXMLElement *parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
else if ([_delegate respondsToSelector:
@selector(elementBuilder:didBuildParentlessNode:)])
[_delegate elementBuilder: self
[_delegate elementBuilder: self didBuildParentlessNode: node];
didBuildParentlessNode: node];
}
- (void)parser: (OFXMLParser *)parser
didStartElement: (OFString *)name
prefix: (OFString *)prefix
namespace: (OFString *)namespace
attributes: (OFArray *)attributes
|
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
node = [OFXMLCharacters charactersWithString: characters];
parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
else if ([_delegate respondsToSelector:
@selector(elementBuilder:didBuildParentlessNode:)])
[_delegate elementBuilder: self
[_delegate elementBuilder: self didBuildParentlessNode: node];
didBuildParentlessNode: node];
}
- (void)parser: (OFXMLParser *)parser
foundCDATA: (OFString *)CDATA
{
OFXMLCDATA *node = [OFXMLCDATA CDATAWithString: CDATA];
OFXMLElement *parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
else if ([_delegate respondsToSelector:
@selector(elementBuilder:didBuildParentlessNode:)])
[_delegate elementBuilder: self
[_delegate elementBuilder: self didBuildParentlessNode: node];
didBuildParentlessNode: node];
}
- (void)parser: (OFXMLParser *)parser
foundComment: (OFString *)comment
{
OFXMLComment *node = [OFXMLComment commentWithString: comment];
OFXMLElement *parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
else if ([_delegate respondsToSelector:
@selector(elementBuilder:didBuildParentlessNode:)])
[_delegate elementBuilder: self
[_delegate elementBuilder: self didBuildParentlessNode: node];
didBuildParentlessNode: node];
}
- (OFString *)parser: (OFXMLParser *)parser
foundUnknownEntityNamed: (OFString *)entity
{
if ([_delegate respondsToSelector:
@selector(elementBuilder:foundUnknownEntityNamed:)])
return [_delegate elementBuilder: self
foundUnknownEntityNamed: entity];
return nil;
}
@end
|
Modified src/OFXMLNode.m
from [d7c9563cf3]
to [7f68e69172].
︙ | | |
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
105
106
107
108
109
|
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
105
106
107
|
-
+
-
-
+
-
-
+
|
- (double)doubleValue
{
return self.stringValue.doubleValue;
}
- (OFString *)XMLString
{
return [self XMLStringWithIndentation: 0
return [self XMLStringWithIndentation: 0 level: 0];
level: 0];
}
- (OFString *)XMLStringWithIndentation: (unsigned int)indentation
{
return [self XMLStringWithIndentation: 0
return [self XMLStringWithIndentation: 0 level: 0];
level: 0];
}
- (OFString *)XMLStringWithIndentation: (unsigned int)indentation
level: (unsigned int)level
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFString *)description
{
return [self XMLStringWithIndentation: 2];
return [self XMLStringWithIndentation: 2 level: 0];
}
- (OFXMLElement *)XMLElementBySerializing
{
OF_UNRECOGNIZED_SELECTOR
}
- (id)copy
{
return [self retain];
}
@end
|
Modified src/OFXMLParser.m
from [08bf6cc4f2]
to [e395ba83dc].
︙ | | |
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
-
+
-
-
+
-
|
};
static OF_INLINE void
appendToBuffer(OFMutableData *buffer, const char *string,
of_string_encoding_t encoding, size_t length)
{
if OF_LIKELY(encoding == OF_STRING_ENCODING_UTF_8)
[buffer addItems: string
[buffer addItems: string count: length];
count: length];
else {
void *pool = objc_autoreleasePoolPush();
OFString *tmp = [OFString stringWithCString: string
encoding: encoding
length: length];
[buffer addItems: tmp.UTF8String
[buffer addItems: tmp.UTF8String count: tmp.UTF8StringLength];
count: tmp.UTF8StringLength];
objc_autoreleasePoolPop(pool);
}
}
static OFString *
transformString(OFXMLParser *parser, OFMutableData *buffer, size_t cut,
bool unescape)
|
︙ | | |
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
-
+
-
|
length--;
} else
items[i] = '\n';
} else if (items[i] == '&')
hasEntities = true;
}
ret = [OFString stringWithUTF8String: items
ret = [OFString stringWithUTF8String: items length: length];
length: length];
if (unescape && hasEntities) {
@try {
return [ret stringByXMLUnescapingWithDelegate: parser];
} @catch (OFInvalidFormatException *e) {
@throw [OFMalformedXMLException
exceptionWithParser: parser];
|
︙ | | |
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
-
+
-
|
[_attributeName release];
[_attributePrefix release];
[_previous release];
[super dealloc];
}
- (void)parseBuffer: (const char *)buffer
- (void)parseBuffer: (const char *)buffer length: (size_t)length
length: (size_t)length
{
_data = buffer;
for (_i = _last = 0; _i < length; _i++) {
size_t j = _i;
lookupTable[_state](self);
|
︙ | | |
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
-
+
-
-
-
+
-
|
if (length - _last > 0 && _state != OF_XMLPARSER_IN_TAG)
appendToBuffer(_buffer, _data + _last, _encoding,
length - _last);
}
- (void)parseString: (OFString *)string
{
[self parseBuffer: string.UTF8String
[self parseBuffer: string.UTF8String length: string.UTF8StringLength];
length: string.UTF8StringLength];
}
- (void)parseStream: (OFStream *)stream
{
size_t pageSize = [OFSystemInfo pageSize];
char *buffer = of_alloc(1, pageSize);
@try {
while (!stream.atEndOfStream) {
size_t length = [stream readIntoBuffer: buffer
length: pageSize];
[self parseBuffer: buffer
[self parseBuffer: buffer length: length];
length: length];
}
} @finally {
free(buffer);
}
}
static void
|
︙ | | |
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
-
+
|
[PI hasPrefix: @"xml\n"])
if (!parseXMLProcessingInstructions(self, PI))
@throw [OFMalformedXMLException
exceptionWithParser: self];
if ([self->_delegate respondsToSelector:
@selector(parser:foundProcessingInstructions:)])
[self->_delegate parser: self
[self->_delegate parser: self
foundProcessingInstructions: PI];
objc_autoreleasePoolPop(pool);
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
|
︙ | | |
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
|
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
|
-
+
-
|
appendToBuffer(self->_buffer, self->_data + self->_last,
self->_encoding, self->_i - self->_last);
CDATA = transformString(self, self->_buffer, 2, false);
if ([self->_delegate respondsToSelector:
@selector(parser:foundCDATA:)])
[self->_delegate parser: self
[self->_delegate parser: self foundCDATA: CDATA];
foundCDATA: CDATA];
objc_autoreleasePoolPop(pool);
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
self->_state = OF_XMLPARSER_OUTSIDE_TAG;
|
︙ | | |
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
|
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
|
-
+
-
|
appendToBuffer(self->_buffer, self->_data + self->_last,
self->_encoding, self->_i - self->_last);
comment = transformString(self, self->_buffer, 2, false);
if ([self->_delegate respondsToSelector:
@selector(parser:foundComment:)])
[self->_delegate parser: self
[self->_delegate parser: self foundComment: comment];
foundComment: comment];
objc_autoreleasePoolPop(pool);
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
self->_state = OF_XMLPARSER_OUTSIDE_TAG;
|
︙ | | |
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
|
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
|
-
+
-
|
}
- (OFString *)string: (OFString *)string
containsUnknownEntityNamed: (OFString *)entity
{
if ([_delegate respondsToSelector:
@selector(parser:foundUnknownEntityNamed:)])
return [_delegate parser: self
return [_delegate parser: self foundUnknownEntityNamed: entity];
foundUnknownEntityNamed: entity];
return nil;
}
@end
|
Modified src/OFZIPArchive.m
from [c62bbdf049]
to [4c67ad00cf].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
}
static void
seekOrThrowInvalidFormat(OFSeekableStream *stream,
of_offset_t offset, int whence)
{
@try {
[stream seekToOffset: offset
[stream seekToOffset: offset whence: whence];
whence: whence];
} @catch (OFSeekFailedException *e) {
if (e.errNo == EINVAL)
@throw [OFInvalidFormatException exception];
@throw e;
}
}
@implementation OFZIPArchive
@synthesize archiveComment = _archiveComment;
+ (instancetype)archiveWithStream: (OFStream *)stream
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
mode: mode] autorelease];
}
#ifdef OF_HAVE_FILES
+ (instancetype)archiveWithPath: (OFString *)path
+ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode
mode: (OFString *)mode
{
return [[[self alloc] initWithPath: path
return [[[self alloc] initWithPath: path mode: mode] autorelease];
mode: mode] autorelease];
}
#endif
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithStream: (OFStream *)stream
- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode
mode: (OFString *)mode
{
self = [super init];
@try {
if ([mode isEqual: @"r"])
_mode = OF_ZIP_ARCHIVE_MODE_READ;
else if ([mode isEqual: @"w"])
|
︙ | | |
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
-
+
-
-
+
-
-
+
-
-
+
-
|
@throw e;
}
return self;
}
#ifdef OF_HAVE_FILES
- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode
mode: (OFString *)mode
{
OFFile *file;
if ([mode isEqual: @"a"])
file = [[OFFile alloc] initWithPath: path
file = [[OFFile alloc] initWithPath: path mode: @"r+"];
mode: @"r+"];
else
file = [[OFFile alloc] initWithPath: path
file = [[OFFile alloc] initWithPath: path mode: mode];
mode: mode];
@try {
self = [self initWithStream: file
self = [self initWithStream: file mode: mode];
mode: mode];
} @finally {
[file release];
}
return self;
}
#endif
|
︙ | | |
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
|
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
|
-
+
-
-
+
-
|
{
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
return _atEndOfStream;
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
size_t ret;
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
return 0;
if (_stream.atEndOfStream && !_decompressedStream.hasDataInReadBuffer)
@throw [OFTruncatedDataException exception];
#if SIZE_MAX >= UINT64_MAX
if (length > UINT64_MAX)
@throw [OFOutOfRangeException exception];
#endif
if ((uint64_t)length > _toRead)
length = (size_t)_toRead;
ret = [_decompressedStream readIntoBuffer: buffer
ret = [_decompressedStream readIntoBuffer: buffer length: length];
length: length];
_toRead -= ret;
_CRC32 = of_crc32(_CRC32, buffer, ret);
if (_toRead == 0) {
_atEndOfStream = true;
|
︙ | | |
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
|
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
|
-
+
-
-
+
-
|
[self close];
[_entry release];
[super dealloc];
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
size_t bytesWritten;
#if SIZE_MAX >= INT64_MAX
if (length > INT64_MAX)
@throw [OFOutOfRangeException exception];
#endif
if (INT64_MAX - _bytesWritten < (int64_t)length)
@throw [OFOutOfRangeException exception];
bytesWritten = [_stream writeBuffer: buffer
bytesWritten = [_stream writeBuffer: buffer length: length];
length: length];
_bytesWritten += (int64_t)bytesWritten;
_CRC32 = of_crc32(_CRC32, buffer, length);
return bytesWritten;
}
|
︙ | | |
Modified src/base64.m
from [042f7c96a2]
to [895a169025].
︙ | | |
145
146
147
148
149
150
151
152
153
154
155
156
157
|
145
146
147
148
149
150
151
152
153
154
155
156
|
-
+
-
|
sb |= tmp;
db[0] = (sb & 0xFF0000) >> 16;
db[1] = (sb & 0x00FF00) >> 8;
db[2] = sb & 0x0000FF;
[data addItems: db
[data addItems: db count: count];
count: count];
}
return true;
}
|
Modified src/bridge/OFException+Swift.h
from [565c9aa41a]
to [0fe4c6bbbc].
︙ | | |
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
+
-
|
* @brief Execute the specified try block and finally call the finally block.
*
* @note This is only useful for Swift.
*
* @param try The try block to execute
* @param finally The finally block to call at the end
*/
+ (void)try: (void (^)(void))try
+ (void)try: (void (^)(void))try finally: (void (^)(void))finally;
finally: (void (^)(void))finally;
/**
* @brief Execute the specified try block and call the catch block if an
* OFException occurred and finally call the finally block.
*
* @note This is only useful to catch OFExceptions in Swift.
*
|
︙ | | |
Modified src/exceptions/OFAcceptFailedException.m
from [262ff1ad4e]
to [2edba3e966].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize socket = _socket, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSocket: (id)socket
+ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithSocket: socket
return [[[self alloc] initWithSocket: socket errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSocket: (id)socket
- (instancetype)initWithSocket: (id)socket errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_socket = [socket retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFChangeCurrentDirectoryPathFailedException.m
from [4c59b51695]
to [8ebcf82a75].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize path = _path, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithPath: (OFString *)path
+ (instancetype)exceptionWithPath: (OFString *)path errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithPath: path
return [[[self alloc] initWithPath: path errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithPath: (OFString *)path errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
@try {
_path = [path copy];
_errNo = errNo;
} @catch (id e) {
|
︙ | | |
Modified src/exceptions/OFConditionBroadcastFailedException.m
from [b529ecf85c]
to [37d5470bb0].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
+
-
|
+ (instancetype)exceptionWithCondition: (OFCondition *)condition
errNo: (int)errNo
{
return [[[self alloc] initWithCondition: condition
errNo: errNo] autorelease];
}
- (instancetype)initWithCondition: (OFCondition *)condition
- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_condition = [condition retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFConditionSignalFailedException.m
from [3ded66a36b]
to [816e893d46].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
+
-
|
+ (instancetype)exceptionWithCondition: (OFCondition *)condition
errNo: (int)errNo
{
return [[[self alloc] initWithCondition: condition
errNo: errNo] autorelease];
}
- (instancetype)initWithCondition: (OFCondition *)condition
- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_condition = [condition retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFConditionWaitFailedException.m
from [ec7442c12c]
to [7ea539fb7f].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
+
-
|
+ (instancetype)exceptionWithCondition: (OFCondition *)condition
errNo: (int)errNo
{
return [[[self alloc] initWithCondition: condition
errNo: errNo] autorelease];
}
- (instancetype)initWithCondition: (OFCondition *)condition
- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_condition = [condition retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFCreateDirectoryFailedException.m
from [e59e1de340]
to [d2f15104e8].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize URL = _URL, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL
return [[[self alloc] initWithURL: URL errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_errNo = errNo;
} @catch (id e) {
|
︙ | | |
Modified src/exceptions/OFDNSQueryFailedException.m
from [a8cb654585]
to [824e018492].
︙ | | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
-
+
-
|
@implementation OFDNSQueryFailedException
@synthesize query = _query, error = _error;
+ (instancetype)exceptionWithQuery: (OFDNSQuery *)query
error: (of_dns_resolver_error_t)error
{
return [[[self alloc] initWithQuery: query
return [[[self alloc] initWithQuery: query error: error] autorelease];
error: error] autorelease];
}
- (instancetype)initWithQuery: (OFDNSQuery *)query
error: (of_dns_resolver_error_t)error
{
self = [super init];
|
︙ | | |
Modified src/exceptions/OFGetOptionFailedException.m
from [af5f02ec1a]
to [5a0bdd642f].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize object = _object, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithObject: (id)object
+ (instancetype)exceptionWithObject: (id)object errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithObject: object
return [[[self alloc] initWithObject: object errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_object = [object retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFInvalidJSONException.m
from [9fef81c79e]
to [6576de8b7b].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize string = _string, line = _line;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithString: (OFString *)string
+ (instancetype)exceptionWithString: (OFString *)string line: (size_t)line
line: (size_t)line
{
return [[[self alloc] initWithString: string
return [[[self alloc] initWithString: string line: line] autorelease];
line: line] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithString: (OFString *)string
- (instancetype)initWithString: (OFString *)string line: (size_t)line
line: (size_t)line
{
self = [super init];
@try {
_string = [string copy];
_line = line;
} @catch (id e) {
|
︙ | | |
Modified src/exceptions/OFLoadPluginFailedException.m
from [8b15607f59]
to [25e1a9ba80].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize path = _path, error = _error;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithPath: (OFString *)path
+ (instancetype)exceptionWithPath: (OFString *)path error: (OFString *)error
error: (OFString *)error
{
return [[[self alloc] initWithPath: path
return [[[self alloc] initWithPath: path error: error] autorelease];
error: error] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithPath: (OFString *)path error: (OFString *)error
error: (OFString *)error
{
self = [super init];
@try {
_path = [path copy];
_error = [error copy];
} @catch (id e) {
|
︙ | | |
Modified src/exceptions/OFLockFailedException.m
from [464bc473e0]
to [71085e6a43].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
-
-
+
-
-
+
-
|
#import "OFLockFailedException.h"
#import "OFString.h"
@implementation OFLockFailedException
@synthesize lock = _lock, errNo = _errNo;
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithLock: lock
return [[[self alloc] initWithLock: lock errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)initWithLock: (id <OFLocking>)lock
- (instancetype)initWithLock: (id <OFLocking>)lock errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_lock = [lock retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFMemoryNotPartOfObjectException.m
from [11976b53bf]
to [505924293a].
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
@synthesize pointer = _pointer, object = _object;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithPointer: (void *)pointer
+ (instancetype)exceptionWithPointer: (void *)pointer object: (id)object
object: (id)object
{
return [[[self alloc] initWithPointer: pointer
object: object] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithPointer: (void *)pointer
- (instancetype)initWithPointer: (void *)pointer object: (id)object
object: (id)object
{
self = [super init];
_pointer = pointer;
_object = [object retain];
return self;
|
︙ | | |
Modified src/exceptions/OFMoveItemFailedException.m
from [eb728a5a4c]
to [5859b5070e].
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-
+
|
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithSourceURL: sourceURL
destinationURL: destinationURL
errNo: errNo] autorelease];
}
- (instancetype)init
|
︙ | | |
Modified src/exceptions/OFNotImplementedException.m
from [21c9b375d3]
to [7ae6cd8f84].
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
@synthesize selector = _selector, object = _object;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSelector: (SEL)selector
+ (instancetype)exceptionWithSelector: (SEL)selector object: (id)object
object: (id)object
{
return [[[self alloc] initWithSelector: selector
object: object] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSelector: (SEL)selector
- (instancetype)initWithSelector: (SEL)selector object: (id)object
object: (id)object
{
self = [super init];
_selector = selector;
_object = [object retain];
return self;
|
︙ | | |
Modified src/exceptions/OFRemoveItemFailedException.m
from [2a6d0a2121]
to [998c78be5a].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize URL = _URL, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL
return [[[self alloc] initWithURL: URL errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_errNo = errNo;
} @catch (id e) {
|
︙ | | |
Modified src/exceptions/OFRetrieveItemAttributesFailedException.m
from [62a4e002af]
to [0ad1b990ce].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize URL = _URL, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL
return [[[self alloc] initWithURL: URL errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_errNo = errNo;
} @catch (id e) {
|
︙ | | |
Modified src/exceptions/OFSandboxActivationFailedException.m
from [2a85c28f4a]
to [2bc8a0bd80].
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
@synthesize sandbox = _sandbox, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox
+ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithSandbox: sandbox
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSandbox: (OFSandbox *)sandbox
- (instancetype)initWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_sandbox = [sandbox retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFSetOptionFailedException.m
from [463fe4cf45]
to [8e6ba356a0].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
|
@synthesize object = _object, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithObject: (id)object
+ (instancetype)exceptionWithObject: (id)object errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithObject: object
return [[[self alloc] initWithObject: object errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_object = [object retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFThreadJoinFailedException.m
from [9aa0b98405]
to [69fa9314a9].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
+
-
-
+
-
-
+
-
|
#import "OFThreadJoinFailedException.h"
#import "OFString.h"
#import "OFThread.h"
@implementation OFThreadJoinFailedException
@synthesize thread = _thread, errNo = _errNo;
+ (instancetype)exceptionWithThread: (OFThread *)thread
+ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithThread: thread
return [[[self alloc] initWithThread: thread errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)initWithThread: (OFThread *)thread
- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_thread = [thread retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFThreadStartFailedException.m
from [c02dc6c663]
to [1ba940b160].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
+
-
-
+
-
-
+
-
|
#import "OFThreadStartFailedException.h"
#import "OFString.h"
#import "OFThread.h"
@implementation OFThreadStartFailedException
@synthesize thread = _thread, errNo = _errNo;
+ (instancetype)exceptionWithThread: (OFThread *)thread
+ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithThread: thread
return [[[self alloc] initWithThread: thread errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)initWithThread: (OFThread *)thread
- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_thread = [thread retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/exceptions/OFUnboundPrefixException.m
from [f4a0e227c8]
to [636055adfc].
︙ | | |
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-
+
-
|
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithPrefix: (OFString *)prefix
- (instancetype)initWithPrefix: (OFString *)prefix parser: (OFXMLParser *)parser
parser: (OFXMLParser *)parser
{
self = [super init];
@try {
_prefix = [prefix copy];
_parser = [parser retain];
} @catch (id e) {
|
︙ | | |
Modified src/exceptions/OFUndefinedKeyException.m
from [c33af96db7]
to [a23aa824a4].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
-
+
-
-
|
@synthesize object = _object, key = _key, value = _value;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithObject: (id)object
+ (instancetype)exceptionWithObject: (id)object key: (OFString *)key
key: (OFString *)key
{
return [[[self alloc] initWithObject: object
return [[[self alloc] initWithObject: object key: key] autorelease];
key: key] autorelease];
}
+ (instancetype)exceptionWithObject: (id)object
key: (OFString *)key
value: (id)value
{
return [[[self alloc] initWithObject: object
key: key
value: value] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object key: (OFString *)key
key: (OFString *)key
{
return [self initWithObject: object
return [self initWithObject: object key: key value: nil];
key: key
value: nil];
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object key: (OFString *)key value: (id)value
key: (OFString *)key
value: (id)value
{
self = [super init];
@try {
_object = [object retain];
_key = [key copy];
_value = [value retain];
|
︙ | | |
Modified src/exceptions/OFUnlockFailedException.m
from [4450bdd3cc]
to [ae9174489f].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
-
-
+
-
-
+
-
|
#import "OFUnlockFailedException.h"
#import "OFString.h"
@implementation OFUnlockFailedException
@synthesize lock = _lock, errNo = _errNo;
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock errNo: (int)errNo
errNo: (int)errNo
{
return [[[self alloc] initWithLock: lock
return [[[self alloc] initWithLock: lock errNo: errNo] autorelease];
errNo: errNo] autorelease];
}
- (instancetype)initWithLock: (id <OFLocking>)lock
- (instancetype)initWithLock: (id <OFLocking>)lock errNo: (int)errNo
errNo: (int)errNo
{
self = [super init];
_lock = [lock retain];
_errNo = errNo;
return self;
|
︙ | | |
Modified src/platform/amiga/OFString+PathAdditions.m
from [770b7197d1]
to [173be0674b].
︙ | | |
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
-
+
-
|
count--;
i--;
continue;
}
if ([component isEqual: @".."])
[components replaceObjectAtIndex: i
[components replaceObjectAtIndex: i withObject: @"/"];
withObject: @"/"];
}
return [OFString pathWithComponents: components];
}
- (OFString *)of_pathComponentToURLPathComponent
{
return self;
}
@end
|
Modified src/platform/posix/OFString+PathAdditions.m
from [1b42dd0767]
to [456ec4e1f3].
︙ | | |
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
-
+
-
|
done = false;
break;
}
}
}
if (startsWithSlash)
[array insertObject: @""
[array insertObject: @"" atIndex: 0];
atIndex: 0];
if ([self hasSuffix: @"/"])
[array addObject: @""];
ret = [[array componentsJoinedByString: @"/"] retain];
objc_autoreleasePoolPop(pool);
|
︙ | | |
Modified src/platform/windows/OFProcess.m
from [5bdba7aa5b]
to [ed2642bf1e].
︙ | | |
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
-
+
-
-
+
-
-
+
-
-
+
-
|
env = [OFMutableData dataWithItemSize: sizeof(of_char16_t)];
keyEnumerator = [environment keyEnumerator];
objectEnumerator = [environment objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
[env addItems: key.UTF16String
[env addItems: key.UTF16String count: key.UTF16StringLength];
count: key.UTF16StringLength];
[env addItems: &equal
[env addItems: &equal count: 1];
count: 1];
[env addItems: object.UTF16String
count: object.UTF16StringLength];
[env addItems: &zero
[env addItems: &zero count: 1];
count: 1];
}
[env addItems: zero
[env addItems: zero count: 2];
count: 2];
return env.mutableItems;
}
- (char *)of_environmentForDictionary: (OFDictionary *)environment
{
of_string_encoding_t encoding = [OFLocale encoding];
|
︙ | | |
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
-
+
-
-
+
-
-
+
-
-
+
-
|
keyEnumerator = [environment keyEnumerator];
objectEnumerator = [environment objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
[env addItems: [key cStringWithEncoding: encoding]
count: [key cStringLengthWithEncoding: encoding]];
[env addItems: "="
[env addItems: "=" count: 1];
count: 1];
[env addItems: [object cStringWithEncoding: encoding]
count: [object cStringLengthWithEncoding: encoding]];
[env addItems: ""
[env addItems: "" count: 1];
count: 1];
}
[env addItems: "\0"
[env addItems: "\0" count: 2];
count: 2];
return env.mutableItems;
}
- (bool)lowlevelIsAtEndOfStream
{
if (_readPipe[0] == NULL)
@throw [OFNotOpenException exceptionWithObject: self];
return _atEndOfStream;
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
length: (size_t)length
{
DWORD ret;
if (length > UINT32_MAX)
@throw [OFOutOfRangeException exception];
if (_readPipe[0] == NULL)
|
︙ | | |
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
-
+
-
|
if (ret == 0)
_atEndOfStream = true;
return ret;
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
length: (size_t)length
{
DWORD bytesWritten;
if (length > UINT32_MAX)
@throw [OFOutOfRangeException exception];
if (_writePipe[1] == NULL)
|
︙ | | |
Modified tests/OFASN1DERRepresentationTests.m
from [2719fd4ef9]
to [dadc73d11b].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
- (void)ASN1DERRepresentationTests
{
void *pool = objc_autoreleasePoolPush();
OFData *data;
module = @"OFASN1BitString";
TEST(@"-[ASN1DERRepresentation]",
(data = [OFData dataWithItems: "\xFF\x00\xF8"
(data = [OFData dataWithItems: "\xFF\x00\xF8" count: 3]) &&
count: 3]) &&
[[[OFASN1BitString bitStringWithBitStringValue: data
bitStringLength: 21]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x04\x03\xFF\x00\xF8"
[OFData dataWithItems: "\x03\x04\x03\xFF\x00\xF8" count: 6]] &&
count: 6]] &&
(data = [OFData dataWithItems: "abcdefäöü"
(data = [OFData dataWithItems: "abcdefäöü" count: 12]) &&
count: 12]) &&
[[[OFASN1BitString bitStringWithBitStringValue: data
bitStringLength: 12 * 8]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x0D\x00" "abcdefäöü"
[OFData dataWithItems: "\x03\x0D\x00" "abcdefäöü" count: 15]] &&
count: 15]] &&
(data = [OFData dataWithItems: ""
(data = [OFData dataWithItems: "" count: 0]) &&
count: 0]) &&
[[[OFASN1BitString bitStringWithBitStringValue: data
bitStringLength: 0]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x01\x00"
[OFData dataWithItems: "\x03\x01\x00" count: 3]])
count: 3]])
module = @"OFASN1Boolean";
TEST(@"-[ASN1DERRepresentation]",
[[[OFASN1Boolean booleanWithBooleanValue: false]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x01\x01\x00"
[OFData dataWithItems: "\x01\x01\x00" count: 3]] &&
count: 3]] &&
[[[OFASN1Boolean booleanWithBooleanValue: true]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x01\x01\xFF"
[OFData dataWithItems: "\x01\x01\xFF" count: 3]])
count: 3]])
module = @"OFNull";
TEST(@"-[OFASN1DERRepresentation]",
[[[OFNull null] ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x05\x00"
[OFData dataWithItems: "\x05\x00" count: 2]])
count: 2]])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFArrayTests.m
from [2e6d46311e]
to [578f78bc93].
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)object
- (instancetype)initWithObject: (id)object arguments: (va_list)arguments
arguments: (va_list)arguments
{
self = [super init];
@try {
_array = [[OFMutableArray alloc] initWithObject: object
arguments: arguments];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
count: (size_t)count
{
self = [super init];
@try {
_array = [[OFMutableArray alloc] initWithObjects: objects
count: count];
} @catch (id e) {
|
︙ | | |
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-
+
-
-
+
-
-
+
-
-
+
-
|
@implementation SimpleMutableArray
+ (void)initialize
{
if (self == [SimpleMutableArray class])
[self inheritMethodsFromClass: [SimpleArray class]];
}
- (void)insertObject: (id)object
- (void)insertObject: (id)object atIndex: (size_t)idx
atIndex: (size_t)idx
{
[_array insertObject: object
[_array insertObject: object atIndex: idx];
atIndex: idx];
}
- (void)replaceObjectAtIndex: (size_t)idx
- (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object
withObject: (id)object
{
[_array replaceObjectAtIndex: idx
[_array replaceObjectAtIndex: idx withObject: object];
withObject: object];
}
- (void)removeObjectAtIndex: (size_t)idx
{
[_array removeObjectAtIndex: idx];
}
@end
|
︙ | | |
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
|
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
|
-
+
-
-
-
+
+
|
TEST(@"+[array]", (m[0] = [mutableArrayClass array]))
TEST(@"+[arrayWithObjects:]",
(a[0] = [arrayClass arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]))
TEST(@"+[arrayWithObjects:count:]",
(a[1] = [arrayClass arrayWithObjects: c_ary
(a[1] = [arrayClass arrayWithObjects: c_ary count: 3]) &&
count: 3]) &&
[a[1] isEqual: a[0]])
TEST(@"-[description]",
[a[0].description isEqual: @"(\n\tFoo,\n\tBar,\n\tBaz\n)"])
TEST(@"-[addObject:]", R([m[0] addObject: c_ary[0]]) &&
R([m[0] addObject: c_ary[2]]))
TEST(@"-[insertObject:atIndex:]", R([m[0] insertObject: c_ary[1]
atIndex: 1]))
TEST(@"-[insertObject:atIndex:]",
R([m[0] insertObject: c_ary[1] atIndex: 1]))
TEST(@"-[count]", m[0].count == 3 && a[0].count == 3 && a[1].count == 3)
TEST(@"-[isEqual:]", [m[0] isEqual: a[0]] && [a[0] isEqual: a[1]])
TEST(@"-[objectAtIndex:]",
[[m[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
|
︙ | | |
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
-
+
-
-
+
-
-
+
-
|
[a[1] indexOfObjectIdenticalTo: c_ary[1]] == 1)
TEST(@"-[objectsInRange:]",
[[a[0] objectsInRange: of_range(1, 2)] isEqual:
[arrayClass arrayWithObjects: c_ary[1], c_ary[2], nil]])
TEST(@"-[replaceObject:withObject:]",
R([m[0] replaceObject: c_ary[1]
R([m[0] replaceObject: c_ary[1] withObject: c_ary[0]]) &&
withObject: c_ary[0]]) &&
[[m[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
[[m[0] objectAtIndex: 1] isEqual: c_ary[0]] &&
[[m[0] objectAtIndex: 2] isEqual: c_ary[2]])
TEST(@"-[replaceObject:identicalTo:]",
R([m[0] replaceObjectIdenticalTo: c_ary[0]
R([m[0] replaceObjectIdenticalTo: c_ary[0] withObject: c_ary[1]]) &&
withObject: c_ary[1]]) &&
[[m[0] objectAtIndex: 0] isEqual: c_ary[1]] &&
[[m[0] objectAtIndex: 1] isEqual: c_ary[0]] &&
[[m[0] objectAtIndex: 2] isEqual: c_ary[2]])
TEST(@"-[replaceObjectAtIndex:withObject:]",
R([m[0] replaceObjectAtIndex: 0
R([m[0] replaceObjectAtIndex: 0 withObject: c_ary[0]]) &&
withObject: c_ary[0]]) &&
[[m[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
[[m[0] objectAtIndex: 1] isEqual: c_ary[0]] &&
[[m[0] objectAtIndex: 2] isEqual: c_ary[2]])
TEST(@"-[removeObject:]",
R([m[0] removeObject: c_ary[0]]) && m[0].count == 2)
|
︙ | | |
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
i = 0;
TEST(@"-[objectEnumerator]", (enumerator = [m[0] objectEnumerator]))
while ((obj = [enumerator nextObject]) != nil) {
if (![obj isEqual: c_ary[i]])
ok = false;
[m[0] replaceObjectAtIndex: i
[m[0] replaceObjectAtIndex: i withObject: @""];
withObject: @""];
i++;
}
if (m[0].count != i)
ok = false;
TEST(@"OFEnumerator's -[nextObject]", ok)
[m[0] removeObjectAtIndex: 0];
EXPECT_EXCEPTION(@"Detection of mutation during enumeration",
OFEnumerationMutationException, [enumerator nextObject])
m[0] = [[a[0] mutableCopy] autorelease];
ok = true;
i = 0;
for (OFString *s in m[0]) {
if (![s isEqual: c_ary[i]])
ok = false;
[m[0] replaceObjectAtIndex: i
[m[0] replaceObjectAtIndex: i withObject: @""];
withObject: @""];
i++;
}
if (m[0].count != i)
ok = false;
TEST(@"Fast Enumeration", ok)
[m[0] replaceObjectAtIndex: 0
[m[0] replaceObjectAtIndex: 0 withObject: c_ary[0]];
withObject: c_ary[0]];
[m[0] replaceObjectAtIndex: 1
[m[0] replaceObjectAtIndex: 1 withObject: c_ary[1]];
withObject: c_ary[1]];
[m[0] replaceObjectAtIndex: 2
[m[0] replaceObjectAtIndex: 2 withObject: c_ary[2]];
withObject: c_ary[2]];
ok = false;
i = 0;
@try {
for (OFString *s in m[0]) {
(void)s;
|
︙ | | |
Modified tests/OFDataTests.m
from [5b2a9f8f8f]
to [5c0a7f22cc].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
-
+
|
(mutable = [[immutable mutableCopy] autorelease]) &&
[mutable isEqual: immutable])
TEST(@"-[compare]", [mutable compare: immutable] == 0 &&
R([mutable removeLastItem]) &&
[immutable compare: mutable] == OF_ORDERED_DESCENDING &&
[mutable compare: immutable] == OF_ORDERED_ASCENDING &&
[[OFData dataWithItems: "aa"
[[OFData dataWithItems: "aa" count: 2] compare:
count: 2] compare:
[OFData dataWithItems: "z"
[OFData dataWithItems: "z" count: 1]] == OF_ORDERED_ASCENDING)
count: 1]] == OF_ORDERED_ASCENDING)
TEST(@"-[hash]", immutable.hash == 0x634A529F)
mutable = [OFMutableData dataWithItems: "abcdef"
mutable = [OFMutableData dataWithItems: "abcdef" count: 6];
count: 6];
TEST(@"-[removeLastItem]", R([mutable removeLastItem]) &&
mutable.count == 5 && memcmp(mutable.items, "abcde", 5) == 0)
TEST(@"-[removeItemsInRange:]",
R([mutable removeItemsInRange: of_range(1, 2)]) &&
mutable.count == 3 && memcmp(mutable.items, "ade", 3) == 0)
TEST(@"-[insertItems:atIndex:count:]",
R([mutable insertItems: "bc"
R([mutable insertItems: "bc" atIndex: 1 count: 2]) &&
atIndex: 1
count: 2]) && mutable.count == 5 &&
memcmp(mutable.items, "abcde", 5) == 0)
mutable.count == 5 && memcmp(mutable.items, "abcde", 5) == 0)
immutable = [OFData dataWithItems: "aaabaccdacaabb"
count: 7
itemSize: 2];
range = [immutable rangeOfData: [OFData dataWithItems: "aa"
count: 1
|
︙ | | |
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
-
+
-
-
+
-
|
[mutable.stringByBase64Encoding isEqual: @"YWJjZGU="])
TEST(@"+[dataWithBase64EncodedString:]",
memcmp([[OFData dataWithBase64EncodedString: @"YWJjZGU="]
items], "abcde", 5) == 0)
TEST(@"Building strings",
(mutable = [OFMutableData dataWithItems: str
(mutable = [OFMutableData dataWithItems: str count: 6]) &&
count: 6]) &&
R([mutable addItem: ""]) &&
strcmp(mutable.items, str) == 0)
EXPECT_EXCEPTION(@"Detect out of range in -[itemAtIndex:]",
OFOutOfRangeException, [mutable itemAtIndex: mutable.count])
EXPECT_EXCEPTION(@"Detect out of range in -[addItems:count:]",
OFOutOfRangeException, [mutable addItems: raw[0]
OFOutOfRangeException, [mutable addItems: raw[0] count: SIZE_MAX])
count: SIZE_MAX])
EXPECT_EXCEPTION(@"Detect out of range in -[removeItemsInRange:]",
OFOutOfRangeException,
[mutable removeItemsInRange: of_range(mutable.count, 1)])
free(raw[0]);
free(raw[1]);
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFDictionaryTests.m
from [403fe91187]
to [daa54d882b].
︙ | | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithKey: (id)key
- (instancetype)initWithKey: (id)key arguments: (va_list)arguments
arguments: (va_list)arguments
{
self = [super init];
@try {
_dictionary = [[OFMutableDictionary alloc]
initWithKey: key
arguments: arguments];
|
︙ | | |
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
-
+
-
-
+
-
|
@implementation SimpleMutableDictionary
+ (void)initialize
{
if (self == [SimpleMutableDictionary class])
[self inheritMethodsFromClass: [SimpleDictionary class]];
}
- (void)setObject: (id)object
- (void)setObject: (id)object forKey: (id)key
forKey: (id)key
{
bool existed = ([_dictionary objectForKey: key] == nil);
[_dictionary setObject: object
[_dictionary setObject: object forKey: key];
forKey: key];
if (existed)
_mutations++;
}
- (void)removeObjectForKey: (id)key
{
|
︙ | | |
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
193
194
195
|
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
|
-
+
-
-
+
-
-
+
-
|
{
void *pool = objc_autoreleasePoolPush();
OFMutableDictionary *mutDict = [mutableDictionaryClass dictionary];
OFDictionary *dict;
OFEnumerator *keyEnumerator, *objectEnumerator;
OFArray *keysArray, *valuesArray;
[mutDict setObject: values[0]
[mutDict setObject: values[0] forKey: keys[0]];
forKey: keys[0]];
[mutDict setValue: values[1]
[mutDict setValue: values[1] forKey: keys[1]];
forKey: keys[1]];
TEST(@"-[objectForKey:]",
[[mutDict objectForKey: keys[0]] isEqual: values[0]] &&
[[mutDict objectForKey: keys[1]] isEqual: values[1]] &&
[mutDict objectForKey: @"key3"] == nil)
TEST(@"-[valueForKey:]",
[[mutDict valueForKey: keys[0]] isEqual: values[0]] &&
[[mutDict valueForKey: @"@count"] isEqual:
[OFNumber numberWithInt: 2]])
EXPECT_EXCEPTION(@"Catching -[setValue:forKey:] on immutable "
@"dictionary", OFUndefinedKeyException,
[[dictionaryClass dictionary] setValue: @"x"
[[dictionaryClass dictionary] setValue: @"x" forKey: @"x"])
forKey: @"x"])
TEST(@"-[containsObject:]",
[mutDict containsObject: values[0]] &&
![mutDict containsObject: @"nonexistent"])
TEST(@"-[containsObjectIdenticalTo:]",
[mutDict containsObjectIdenticalTo: values[0]] &&
|
︙ | | |
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
-
+
-
-
+
-
-
-
+
-
|
[objectEnumerator nextObject] == nil)
[mutDict removeObjectForKey: keys[0]];
EXPECT_EXCEPTION(@"Detection of mutation during enumeration",
OFEnumerationMutationException, [keyEnumerator nextObject]);
[mutDict setObject: values[0]
[mutDict setObject: values[0] forKey: keys[0]];
forKey: keys[0]];
size_t i = 0;
bool ok = true;
for (OFString *key in mutDict) {
if (i > 1 || ![key isEqual: keys[i]]) {
ok = false;
break;
}
[mutDict setObject: [mutDict objectForKey: key]
[mutDict setObject: [mutDict objectForKey: key] forKey: key];
forKey: key];
i++;
}
TEST(@"Fast Enumeration", ok)
ok = false;
@try {
for (OFString *key in mutDict) {
(void)key;
[mutDict setObject: @""
[mutDict setObject: @"" forKey: @""];
forKey: @""];
}
} @catch (OFEnumerationMutationException *e) {
ok = true;
}
TEST(@"Detection of mutation during Fast Enumeration", ok)
|
︙ | | |
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
-
+
-
-
+
-
-
+
-
-
+
-
|
[[dict objectForKey: keys[1]] isEqual: values[1]])
TEST(@"-[mutableCopy]",
(mutDict = [[dict mutableCopy] autorelease]) &&
mutDict.count == dict.count &&
[[mutDict objectForKey: keys[0]] isEqual: values[0]] &&
[[mutDict objectForKey: keys[1]] isEqual: values[1]] &&
R([mutDict setObject: @"value3"
R([mutDict setObject: @"value3" forKey: @"key3"]) &&
forKey: @"key3"]) &&
[[mutDict objectForKey: @"key3"] isEqual: @"value3"] &&
[[mutDict objectForKey: keys[0]] isEqual: values[0]] &&
R([mutDict setObject: @"foo"
R([mutDict setObject: @"foo" forKey: keys[0]]) &&
forKey: keys[0]]) &&
[[mutDict objectForKey: keys[0]] isEqual: @"foo"])
TEST(@"-[removeObjectForKey:]",
R([mutDict removeObjectForKey: keys[0]]) &&
[mutDict objectForKey: keys[0]] == nil)
[mutDict setObject: @"foo"
[mutDict setObject: @"foo" forKey: keys[0]];
forKey: keys[0]];
TEST(@"-[isEqual:]", ![mutDict isEqual: dict] &&
R([mutDict removeObjectForKey: @"key3"]) &&
![mutDict isEqual: dict] &&
R([mutDict setObject: values[0]
R([mutDict setObject: values[0] forKey: keys[0]]) &&
forKey: keys[0]]) &&
[mutDict isEqual: dict])
objc_autoreleasePoolPop(pool);
}
- (void)dictionaryTests
{
|
︙ | | |
Modified tests/OFHMACTests.m
from [25a2a29ceb]
to [51628de7e9].
︙ | | |
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
-
+
-
|
"\x61\xB3\xF9\x1A\xE3\x09\x43\xA6\x5B\x85\xB1\x50\x5B\xCB\x1A\x2E"
"\xB7\xE8\x87\xC1\x73\x19\x63\xF6\xA2\x91\x8D\x7E\x2E\xCC\xEC\x99";
@implementation TestsAppDelegate (OFHMACTests)
- (void)HMACTests
{
void *pool = objc_autoreleasePoolPush();
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
OFHMAC *HMAC_MD5, *HMAC_SHA1, *HMAC_RMD160;
OFHMAC *HMAC_SHA256, *HMAC_SHA384, *HMAC_SHA512;
TEST(@"+[HMACWithHashClass:] with MD5",
(HMAC_MD5 = [OFHMAC HMACWithHashClass: [OFMD5Hash class]
allowsSwappableMemory: true]))
TEST(@"+[HMACWithHashClass:] with SHA-1",
|
︙ | | |
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
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
105
106
107
108
109
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
allowsSwappableMemory: true]))
EXPECT_EXCEPTION(@"Detection of missing key",
OFInvalidArgumentException, [HMAC_MD5 updateWithBuffer: ""
length: 0])
TEST(@"-[setKey:length:] with MD5",
R([HMAC_MD5 setKey: key
R([HMAC_MD5 setKey: key length: key_length]))
length: key_length]))
TEST(@"-[setKey:length:] with SHA-1",
R([HMAC_SHA1 setKey: key
R([HMAC_SHA1 setKey: key length: key_length]))
length: key_length]))
TEST(@"-[setKey:length:] with RIPEMD-160",
R([HMAC_RMD160 setKey: key
R([HMAC_RMD160 setKey: key length: key_length]))
length: key_length]))
TEST(@"-[setKey:length:] with SHA-256",
R([HMAC_SHA256 setKey: key
R([HMAC_SHA256 setKey: key length: key_length]))
length: key_length]))
TEST(@"-[setKey:length:] with SHA-384",
R([HMAC_SHA384 setKey: key
R([HMAC_SHA384 setKey: key length: key_length]))
length: key_length]))
TEST(@"-[setKey:length:] with SHA-512",
R([HMAC_SHA512 setKey: key
R([HMAC_SHA512 setKey: key length: key_length]))
length: key_length]))
while (!f.atEndOfStream) {
char buf[64];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 64];
length: 64];
[HMAC_MD5 updateWithBuffer: buf
[HMAC_MD5 updateWithBuffer: buf length: len];
length: len];
[HMAC_SHA1 updateWithBuffer: buf
[HMAC_SHA1 updateWithBuffer: buf length: len];
length: len];
[HMAC_RMD160 updateWithBuffer: buf
[HMAC_RMD160 updateWithBuffer: buf length: len];
length: len];
[HMAC_SHA256 updateWithBuffer: buf
[HMAC_SHA256 updateWithBuffer: buf length: len];
length: len];
[HMAC_SHA384 updateWithBuffer: buf
[HMAC_SHA384 updateWithBuffer: buf length: len];
length: len];
[HMAC_SHA512 updateWithBuffer: buf
[HMAC_SHA512 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[digest] with MD5",
memcmp(HMAC_MD5.digest, digest_md5, HMAC_MD5.digestSize) == 0)
TEST(@"-[digest] with SHA-1",
memcmp(HMAC_SHA1.digest, digest_sha1, HMAC_SHA1.digestSize) == 0)
|
︙ | | |
Modified tests/OFHTTPClientTests.m
from [18ee20c625]
to [2d2b40724b].
︙ | | |
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
+
-
|
{
OFTCPSocket *listener, *client;
char buffer[5];
[cond lock];
listener = [OFTCPSocket socket];
_port = [listener bindToHost: @"127.0.0.1"
_port = [listener bindToHost: @"127.0.0.1" port: 0];
port: 0];
[listener listen];
[cond signal];
[cond unlock];
client = [listener accept];
|
︙ | | |
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
-
+
-
|
if (![[client readLine] isEqual:
[OFString stringWithFormat: @"Host: 127.0.0.1:%" @PRIu16, _port]])
OF_ENSURE(0);
if (![[client readLine] isEqual: @""])
OF_ENSURE(0);
[client readIntoBuffer: buffer
[client readIntoBuffer: buffer exactLength: 5];
exactLength: 5];
if (memcmp(buffer, "Hello", 5) != 0)
OF_ENSURE(0);
[client writeString: @"HTTP/1.0 200 OK\r\n"
@"cONTeNT-lENgTH: 7\r\n"
@"\r\n"
@"foo\n"
|
︙ | | |
Modified tests/OFHTTPCookieManagerTests.m
from [c178740871]
to [8226ed0409].
︙ | | |
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
|
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
|
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
TEST(@"-[cookiesForURL:] #1",
[[manager cookiesForURL: URL[0]] isEqual:
[OFArray arrayWithObject: cookie[0]]])
cookie[1] = [OFHTTPCookie cookieWithName: @"test"
value: @"2"
domain: @"webkeks.org"];
TEST(@"-[addCookie:forURL:] #2", R([manager addCookie: cookie[1]
forURL: URL[0]]))
TEST(@"-[addCookie:forURL:] #2",
R([manager addCookie: cookie[1] forURL: URL[0]]))
TEST(@"-[cookiesForURL:] #2",
[[manager cookiesForURL: URL[0]] isEqual:
[OFArray arrayWithObject: cookie[0]]] &&
[[manager cookiesForURL: URL[3]] isEqual: [OFArray array]])
cookie[2] = [OFHTTPCookie cookieWithName: @"test"
value: @"3"
domain: @"nil.im"];
cookie[2].secure = true;
TEST(@"-[addCookie:forURL:] #3", R([manager addCookie: cookie[2]
forURL: URL[1]]))
TEST(@"-[addCookie:forURL:] #3",
R([manager addCookie: cookie[2] forURL: URL[1]]))
TEST(@"-[cookiesForURL:] #3",
[[manager cookiesForURL: URL[1]] isEqual:
[OFArray arrayWithObject: cookie[2]]] &&
[[manager cookiesForURL: URL[0]] isEqual: [OFArray array]])
cookie[2].expires = [OFDate dateWithTimeIntervalSinceNow: -1];
cookie[3] = [OFHTTPCookie cookieWithName: @"test"
value: @"4"
domain: @"nil.im"];
cookie[3].domain = @".nil.im";
TEST(@"-[addCookie:forURL:] #4", R([manager addCookie: cookie[3]
forURL: URL[1]]))
TEST(@"-[addCookie:forURL:] #4",
R([manager addCookie: cookie[3] forURL: URL[1]]))
TEST(@"-[cookiesForURL:] #4",
[[manager cookiesForURL: URL[1]] isEqual:
[OFArray arrayWithObject: cookie[3]]] &&
[[manager cookiesForURL: URL[2]] isEqual:
[OFArray arrayWithObject: cookie[3]]])
cookie[4] = [OFHTTPCookie cookieWithName: @"bar"
value: @"5"
domain: @"test.nil.im"];
TEST(@"-[addCookie:forURL:] #5", R([manager addCookie: cookie[4]
forURL: URL[0]]))
TEST(@"-[addCookie:forURL:] #5",
R([manager addCookie: cookie[4] forURL: URL[0]]))
TEST(@"-[cookiesForURL:] #5",
[[manager cookiesForURL: URL[0]] isEqual:
[OFArray arrayWithObject: cookie[3]]] &&
[[manager cookiesForURL: URL[2]] isEqual:
[OFArray arrayWithObjects: cookie[3], cookie[4], nil]])
|
︙ | | |
Modified tests/OFINIFileTests.m
from [ad2cd47828]
to [4cccd0237d].
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
-
-
+
+
-
-
+
+
|
[types boolForKey: @"bool" defaultValue: false] == true)
TEST(@"-[setBool:forKey:]", R([types setBool: false forKey: @"bool"]))
TEST(@"-[floatForKey:defaultValue:]",
[types floatForKey: @"float" defaultValue: 1] == 0.5f)
TEST(@"-[setFloat:forKey:]", R([types setFloat: 0.25f
forKey: @"float"]))
TEST(@"-[setFloat:forKey:]",
R([types setFloat: 0.25f forKey: @"float"]))
TEST(@"-[doubleForKey:defaultValue:]",
[types doubleForKey: @"double" defaultValue: 3] == 0.25)
TEST(@"-[setDouble:forKey:]", R([types setDouble: 0.75
forKey: @"double"]))
TEST(@"-[setDouble:forKey:]",
R([types setDouble: 0.75 forKey: @"double"]))
array = [OFArray arrayWithObjects: @"1", @"2", nil];
TEST(@"-[stringArrayForKey:]",
[[types stringArrayForKey: @"array1"] isEqual: array] &&
[[types stringArrayForKey: @"array2"] isEqual: array] &&
[[types stringArrayForKey: @"array3"] isEqual: [OFArray array]])
|
︙ | | |
Modified tests/OFIPXSocketTests.m
from [9fbe112566]
to [1c80cd9432].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
-
|
of_socket_address_t address1, address2;
char buffer[5];
TEST(@"+[socket]", (sock = [OFIPXSocket socket]))
@try {
TEST(@"-[bindToPort:packetType:]",
R(address1 = [sock bindToPort: 0
R(address1 = [sock bindToPort: 0 packetType: 0]))
packetType: 0]))
} @catch (OFBindFailedException *e) {
switch (e.errNo) {
case EAFNOSUPPORT:
[of_stdout setForegroundColor: [OFColor lime]];
[of_stdout writeLine:
@"[OFIPXSocket] -[bindToPort:packetType:]: "
@"IPX unsupported, skipping tests"];
|
︙ | | |
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-
+
-
-
-
+
-
-
|
}
objc_autoreleasePoolPop(pool);
return;
}
TEST(@"-[sendBuffer:length:receiver:]",
R([sock sendBuffer: "Hello"
R([sock sendBuffer: "Hello" length: 5 receiver: &address1]))
length: 5
receiver: &address1]))
TEST(@"-[receiveIntoBuffer:length:sender:]",
[sock receiveIntoBuffer: buffer
[sock receiveIntoBuffer: buffer length: 5 sender: &address2] == 5 &&
length: 5
sender: &address2] == 5 &&
memcmp(buffer, "Hello", 5) == 0 &&
of_socket_address_equal(&address1, &address2) &&
of_socket_address_hash(&address1) ==
of_socket_address_hash(&address2))
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFInvocationTests.m
from [78de2aee0d]
to [1df5434c9d].
︙ | | |
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
-
-
-
+
+
-
-
-
+
+
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
TEST(@"-[setReturnValue]", R([invocation setReturnValue: &st]))
TEST(@"-[getReturnValue]", R([invocation getReturnValue: &st2]) &&
memcmp(&st, &st2, sizeof(st)) == 0)
memset(&st2, '\0', sizeof(st2));
TEST(@"-[setArgument:atIndex:] #1", R([invocation setArgument: &c
atIndex: 2]))
TEST(@"-[setArgument:atIndex:] #1",
R([invocation setArgument: &c atIndex: 2]))
TEST(@"-[setArgument:atIndex:] #2", R([invocation setArgument: &i
atIndex: 3]))
TEST(@"-[setArgument:atIndex:] #2",
R([invocation setArgument: &i atIndex: 3]))
TEST(@"-[setArgument:atIndex:] #3", R([invocation setArgument: &stp
atIndex: 4]))
TEST(@"-[setArgument:atIndex:] #3",
R([invocation setArgument: &stp atIndex: 4]))
TEST(@"-[setArgument:atIndex:] #4", R([invocation setArgument: &st
atIndex: 5]))
TEST(@"-[setArgument:atIndex:] #4",
R([invocation setArgument: &st atIndex: 5]))
TEST(@"-[getArgument:atIndex:] #1", R([invocation getArgument: &c2
atIndex: 2]) &&
TEST(@"-[getArgument:atIndex:] #1",
R([invocation getArgument: &c2 atIndex: 2]) && c == c2)
c == c2)
TEST(@"-[getArgument:atIndex:] #2", R([invocation getArgument: &i2
atIndex: 3]) &&
TEST(@"-[getArgument:atIndex:] #2",
R([invocation getArgument: &i2 atIndex: 3]) && i == i2)
i == i2)
TEST(@"-[getArgument:atIndex:] #3", R([invocation getArgument: &stp2
atIndex: 4]) &&
TEST(@"-[getArgument:atIndex:] #3",
R([invocation getArgument: &stp2 atIndex: 4]) && stp == stp2)
stp == stp2)
TEST(@"-[getArgument:atIndex:] #4", R([invocation getArgument: &st2
atIndex: 5]) &&
TEST(@"-[getArgument:atIndex:] #4",
R([invocation getArgument: &st2 atIndex: 5]) &&
memcmp(&st, &st2, sizeof(st)) == 0)
#ifdef OF_INVOCATION_CAN_INVOKE
/* -[invoke] #1 */
selector = @selector(invocationTestMethod2:);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 2];
atIndex: 2];
TEST(@"-[invoke] #1", R([invocation invoke]))
/* -[invoke] #2 */
selector = @selector(invocationTestMethod3::::::::::::::::);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
for (int j = 1; j <= 16; j++)
[invocation setArgument: &j
[invocation setArgument: &j atIndex: j + 1];
atIndex: j + 1];
int intResult;
TEST(@"-[invoke] #2", R([invocation invoke]) &&
R([invocation getReturnValue: &intResult]) && intResult == 8)
/* -[invoke] #3 */
selector = @selector(invocationTestMethod4::::::::::::::::);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
for (int j = 1; j <= 16; j++) {
double d = j;
[invocation setArgument: &d
[invocation setArgument: &d atIndex: j + 1];
atIndex: j + 1];
}
double doubleResult;
TEST(@"-[invoke] #3", R([invocation invoke]) &&
R([invocation getReturnValue: &doubleResult]) &&
doubleResult == 8.5)
/* -[invoke] #4 */
selector = @selector(invocationTestMethod5::::::::::::::::);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
for (int j = 1; j <= 16; j++) {
float f = j;
double d = j;
if (j == 1 || j == 10)
[invocation setArgument: &d
[invocation setArgument: &d atIndex: j + 1];
atIndex: j + 1];
else
[invocation setArgument: &f
[invocation setArgument: &f atIndex: j + 1];
atIndex: j + 1];
}
float floatResult;
TEST(@"-[invoke] #4", R([invocation invoke]) &&
R([invocation getReturnValue: &floatResult]) && floatResult == 8.5)
/* Only when encoding long doubles is supported */
if (strcmp(@encode(double), @encode(long double)) != 0) {
/* -[invoke] #5 */
selector = @selector(invocationTestMethod6::::::::::::::::);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
for (int j = 1; j <= 16; j++) {
long double d = j;
[invocation setArgument: &d
[invocation setArgument: &d atIndex: j + 1];
atIndex: j + 1];
}
long double longDoubleResult;
TEST(@"-[invoke] #5", R([invocation invoke]) &&
R([invocation getReturnValue: &longDoubleResult]) &&
longDoubleResult == 8.5)
}
# if defined(HAVE_COMPLEX_H) && !defined(__STDC_NO_COMPLEX__)
/* -[invoke] #6 */
selector = @selector(invocationTestMethod7::::::::::::::::);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
for (int j = 1; j <= 16; j++) {
complex float cf = j + 0.5 * j * I;
complex double cd = j + 0.5 * j * I;
if (j & 1)
[invocation setArgument: &cf
[invocation setArgument: &cf atIndex: j + 1];
atIndex: j + 1];
else
[invocation setArgument: &cd
[invocation setArgument: &cd atIndex: j + 1];
atIndex: j + 1];
}
complex double complexDoubleResult;
TEST(@"-[invoke] #6", R([invocation invoke]) &&
R([invocation getReturnValue: &complexDoubleResult]) &&
complexDoubleResult == 8.5 + 4.25 * I)
/* Only when encoding complex long doubles is supported */
if (strcmp(@encode(complex double),
@encode(complex long double)) != 0) {
/* -[invoke] #7 */
selector = @selector(invocationTestMethod8::::::::::::::::);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
for (int j = 1; j <= 16; j++) {
complex double cd = j + 0.5 * j * I;
complex float cf = j + 0.5 * j * I;
complex long double cld = j + 0.5 * j * I;
switch (j % 3) {
case 0:
[invocation setArgument: &cld
[invocation setArgument: &cld atIndex: j + 1];
atIndex: j + 1];
break;
case 1:
[invocation setArgument: &cd
[invocation setArgument: &cd atIndex: j + 1];
atIndex: j + 1];
break;
case 2:
[invocation setArgument: &cf
[invocation setArgument: &cf atIndex: j + 1];
atIndex: j + 1];
break;
}
}
complex long double complexLongDoubleResult;
TEST(@"-[invoke] #7", R([invocation invoke]) &&
R([invocation getReturnValue: &complexLongDoubleResult]) &&
complexLongDoubleResult == 8.5 + 4.25 * I)
}
# endif
# ifdef __SIZEOF_INT128__
/* -[invoke] #8 */
selector = @selector(invocationTestMethod9::::::::::::::::);
invocation = [OFInvocation invocationWithMethodSignature:
[self methodSignatureForSelector: selector]];
[invocation setArgument: &self
[invocation setArgument: &self atIndex: 0];
atIndex: 0];
[invocation setArgument: &selector
[invocation setArgument: &selector atIndex: 1];
atIndex: 1];
for (int j = 1; j <= 16; j++) {
__extension__ __int128 i128 = 0xFFFFFFFFFFFFFFFF;
i128 <<= 64;
i128 |= j;
if (j == 1 || j == 5)
[invocation setArgument: &j
[invocation setArgument: &j atIndex: j + 1];
atIndex: j + 1];
else
[invocation setArgument: &i128
[invocation setArgument: &i128 atIndex: j + 1];
atIndex: j + 1];
}
__extension__ __int128 int128Result;
TEST(@"-[invoke] #8", R([invocation invoke]) &&
R([invocation getReturnValue: &int128Result]) &&
int128Result == __extension__ ((__int128)0xFFFFFFFFFFFFFFFF << 64) +
8)
# endif
#endif
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFKernelEventObserverTests.m
from [24325e2282]
to [decdd17638].
︙ | | |
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
-
+
-
-
+
-
-
-
+
-
|
@try {
uint16_t port;
_testsAppDelegate = testsAppDelegate;
_server = [[OFTCPSocket alloc] init];
port = [_server bindToHost: @"127.0.0.1"
port = [_server bindToHost: @"127.0.0.1" port: 0];
port: 0];
[_server listen];
_client = [[OFTCPSocket alloc] init];
[_client connectToHost: @"127.0.0.1"
[_client connectToHost: @"127.0.0.1" port: port];
port: port];
[_client writeBuffer: "0"
[_client writeBuffer: "0" length: 1];
length: 1];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
︙ | | |
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
|
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
|
-
+
-
-
+
-
|
[_testsAppDelegate
outputTesting: @"-[observe] with data ready to read"
inModule: module];
break;
case 1:
if (object == _accepted &&
[object readIntoBuffer: &buf
[object readIntoBuffer: &buf length: 1] == 1 && buf == '0')
length: 1] == 1 && buf == '0')
[_testsAppDelegate
outputSuccess: @"-[observe] with data ready to read"
inModule: module];
else {
[_testsAppDelegate
outputFailure: @"-[observe] with data ready to read"
inModule: module];
_fails++;
}
[_client close];
[_testsAppDelegate
outputTesting: @"-[observe] with closed connection"
inModule: module];
break;
case 2:
if (object == _accepted &&
[object readIntoBuffer: &buf
[object readIntoBuffer: &buf length: 1] == 0)
length: 1] == 0)
[_testsAppDelegate
outputSuccess: @"-[observe] with closed connection"
inModule: module];
else {
[_testsAppDelegate
outputFailure: @"-[observe] with closed connection"
inModule: module];
|
︙ | | |
Modified tests/OFMD5HashTests.m
from [7ba538ae71]
to [b161ec4641].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
"\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38";
@implementation TestsAppDelegate (OFMD5HashTests)
- (void)MD5HashTests
{
void *pool = objc_autoreleasePoolPush();
OFMD5Hash *md5, *copy;
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
TEST(@"+[cryptoHashWithAllowsSwappableMemory:]",
(md5 = [OFMD5Hash cryptoHashWithAllowsSwappableMemory: true]))
while (!f.atEndOfStream) {
char buf[64];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 64];
length: 64];
[md5 updateWithBuffer: buf
[md5 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[copy]", (copy = [[md5 copy] autorelease]))
TEST(@"-[digest]",
memcmp(md5.digest, testfile_md5, 16) == 0 &&
memcmp(copy.digest, testfile_md5, 16) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length]", OFHashAlreadyCalculatedException,
[md5 updateWithBuffer: ""
[md5 updateWithBuffer: "" length: 1])
length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFObjectTests.m
from [87d14c79b3]
to [15af30b63f].
︙ | | |
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
-
+
-
-
+
-
-
+
-
|
[[m valueForKey: @"classValue"] isEqual: m.class] &&
[[m valueForKey: @"class"] isEqual: m.class])
EXPECT_EXCEPTION(@"-[valueForKey:] with undefined key",
OFUndefinedKeyException, [m valueForKey: @"undefined"])
TEST(@"-[setValue:forKey:]",
R([m setValue: @"World"
R([m setValue: @"World" forKey: @"objectValue"]) &&
forKey: @"objectValue"]) &&
R([m setValue: [OFObject class]
R([m setValue: [OFObject class] forKey: @"classValue"]) &&
forKey: @"classValue"]) &&
[m.objectValue isEqual: @"World"] &&
[m.classValue isEqual: [OFObject class]])
EXPECT_EXCEPTION(@"-[setValue:forKey:] with undefined key",
OFUndefinedKeyException, [m setValue: @"x"
OFUndefinedKeyException, [m setValue: @"x" forKey: @"undefined"])
forKey: @"undefined"])
m.boolValue = 1;
m.charValue = 2;
m.shortValue = 3;
m.intValue = 4;
m.longValue = 5;
m.longLongValue = 6;
|
︙ | | |
Modified tests/OFPropertyListTests.m
from [b2a840a564]
to [f46fac19eb].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
-
+
-
|
@implementation TestsAppDelegate (OFPLISTParser)
- (void)propertyListTests
{
void *pool = objc_autoreleasePoolPush();
OFArray *array = [OFArray arrayWithObjects:
@"Hello",
[OFData dataWithItems: "World!"
[OFData dataWithItems: "World!" count: 6],
count: 6],
[OFDate dateWithTimeIntervalSince1970: 1521030896],
[OFNumber numberWithBool: true],
[OFNumber numberWithBool: false],
[OFNumber numberWithFloat: 12.25f],
[OFNumber numberWithInt: -10],
nil];
|
︙ | | |
Modified tests/OFRIPEMD160HashTests.m
from [35f25635b9]
to [1bef7d37d4].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
"\xE6\x08\x8B";
@implementation TestsAppDelegate (OFRIPEMD160HashTests)
- (void)RIPEMD160HashTests
{
void *pool = objc_autoreleasePoolPush();
OFRIPEMD160Hash *rmd160, *copy;
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
TEST(@"+[cryptoHashWithAllowsSwappableMemory:]",
(rmd160 = [OFRIPEMD160Hash
cryptoHashWithAllowsSwappableMemory: true]))
while (!f.atEndOfStream) {
char buf[64];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 64];
length: 64];
[rmd160 updateWithBuffer: buf
[rmd160 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[copy]", (copy = [[rmd160 copy] autorelease]))
TEST(@"-[digest]",
memcmp(rmd160.digest, testfile_rmd160, 20) == 0 &&
memcmp(copy.digest, testfile_rmd160, 20) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length]", OFHashAlreadyCalculatedException,
[rmd160 updateWithBuffer: ""
[rmd160 updateWithBuffer: "" length: 1])
length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSCTPSocketTests.m
from [5eb12e5159]
to [181fc2f46d].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
-
+
+
-
-
+
+
|
char buf[6];
TEST(@"+[socket]", (server = [OFSCTPSocket socket]) &&
(client = [OFSCTPSocket socket]))
@try {
TEST(@"-[bindToHost:port:]",
(port = [server bindToHost: @"127.0.0.1"
(port = [server bindToHost: @"127.0.0.1" port: 0]))
port: 0]))
} @catch (OFBindFailedException *e) {
switch (e.errNo) {
case EPROTONOSUPPORT:
[of_stdout setForegroundColor: [OFColor lime]];
[of_stdout writeLine:
@"[OFSCTPSocket] -[bindToHost:port:]: "
@"SCTP unsupported, skipping tests"];
break;
default:
@throw e;
}
objc_autoreleasePoolPop(pool);
return;
}
TEST(@"-[listen]", R([server listen]))
TEST(@"-[connectToHost:port:]",
R([client connectToHost: @"127.0.0.1"
R([client connectToHost: @"127.0.0.1" port: port]))
port: port]))
TEST(@"-[accept]", (accepted = [server accept]))
TEST(@"-[remoteAddress]",
[of_socket_address_ip_string(accepted.remoteAddress, NULL)
isEqual: @"127.0.0.1"])
TEST(@"-[sendBuffer:length:]", R([client sendBuffer: "Hello!"
length: 6]))
TEST(@"-[sendBuffer:length:]",
R([client sendBuffer: "Hello!" length: 6]))
TEST(@"-[receiveIntoBuffer:length:]", [accepted receiveIntoBuffer: buf
length: 6] &&
TEST(@"-[receiveIntoBuffer:length:]",
[accepted receiveIntoBuffer: buf length: 6] &&
!memcmp(buf, "Hello!", 6))
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSHA1HashTests.m
from [178723d8a9]
to [145fd9ade0].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
"\x94\xE7\x17";
@implementation TestsAppDelegate (SHA1HashTests)
- (void)SHA1HashTests
{
void *pool = objc_autoreleasePoolPush();
OFSHA1Hash *sha1, *copy;
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
TEST(@"+[cryptoHashWithAllowsSwappableMemory:]",
(sha1 = [OFSHA1Hash cryptoHashWithAllowsSwappableMemory: true]))
while (!f.atEndOfStream) {
char buf[64];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 64];
length: 64];
[sha1 updateWithBuffer: buf
[sha1 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[copy]", (copy = [[sha1 copy] autorelease]))
TEST(@"-[digest]",
memcmp(sha1.digest, testfile_sha1, 20) == 0 &&
memcmp(copy.digest, testfile_sha1, 20) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException,
[sha1 updateWithBuffer: ""
[sha1 updateWithBuffer: "" length: 1])
length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSHA224HashTests.m
from [b5e3284a33]
to [114b68c56f].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
"\x5F\x4F\x20\x02\x4D\x15\xED\x1C\x61\x1F\xF7";
@implementation TestsAppDelegate (SHA224HashTests)
- (void)SHA224HashTests
{
void *pool = objc_autoreleasePoolPush();
OFSHA224Hash *sha224, *copy;
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
TEST(@"+[cryptoHashWithAllowsSwappableMemory:]",
(sha224 = [OFSHA224Hash cryptoHashWithAllowsSwappableMemory: true]))
while (!f.atEndOfStream) {
char buf[64];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 64];
length: 64];
[sha224 updateWithBuffer: buf
[sha224 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[copy]", (copy = [[sha224 copy] autorelease]))
TEST(@"-[digest]",
memcmp(sha224.digest, testfile_sha224, 28) == 0 &&
memcmp(copy.digest, testfile_sha224, 28) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException,
[sha224 updateWithBuffer: ""
[sha224 updateWithBuffer: "" length: 1])
length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSHA256HashTests.m
from [301369bd01]
to [2b578b5f30].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
"\x67\x93\x8F\x0F\x44\x90\xB8\xF5\x35\x89\xF0\x5A\x23\x7F\x69";
@implementation TestsAppDelegate (SHA256HashTests)
- (void)SHA256HashTests
{
void *pool = objc_autoreleasePoolPush();
OFSHA256Hash *sha256, *copy;
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
TEST(@"+[cryptoHashWithAllowsSwappableMemory:]",
(sha256 = [OFSHA256Hash cryptoHashWithAllowsSwappableMemory: true]))
while (!f.atEndOfStream) {
char buf[64];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 64];
length: 64];
[sha256 updateWithBuffer: buf
[sha256 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[copy]", (copy = [[sha256 copy] autorelease]))
TEST(@"-[digest]",
memcmp(sha256.digest, testfile_sha256, 32) == 0 &&
memcmp(copy.digest, testfile_sha256, 32) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException,
[sha256 updateWithBuffer: ""
[sha256 updateWithBuffer: "" length: 1])
length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSHA384HashTests.m
from [dc27edd55b]
to [2c0ef0b0b7].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
"\xE9\x1A\xB3\x51\x70\x8C\x1F\x3F\x56\x12\x44\x01\x91\x54";
@implementation TestsAppDelegate (SHA384HashTests)
- (void)SHA384HashTests
{
void *pool = objc_autoreleasePoolPush();
OFSHA384Hash *sha384, *copy;
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
TEST(@"+[cryptoHashWithAllowsSwappableMemory:]",
(sha384 = [OFSHA384Hash cryptoHashWithAllowsSwappableMemory: true]))
while (!f.atEndOfStream) {
char buf[128];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 128];
length: 128];
[sha384 updateWithBuffer: buf
[sha384 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[copy]", (copy = [[sha384 copy] autorelease]))
TEST(@"-[digest]",
memcmp(sha384.digest, testfile_sha384, 48) == 0 &&
memcmp(copy.digest, testfile_sha384, 48) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException,
[sha384 updateWithBuffer: ""
[sha384 updateWithBuffer: "" length: 1])
length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSHA512HashTests.m
from [d42fcd68e6]
to [99450ee331].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
"\xA1\x8A\x41\x64\x33\x69\x21\x8C\x2A\x44\x6D\xF2\xA0";
@implementation TestsAppDelegate (SHA512HashTests)
- (void)SHA512HashTests
{
void *pool = objc_autoreleasePoolPush();
OFSHA512Hash *sha512, *copy;
OFFile *f = [OFFile fileWithPath: @"testfile.bin"
OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
mode: @"r"];
TEST(@"+[cryptoHashWithAllowsSwappableMemory:]",
(sha512 = [OFSHA512Hash cryptoHashWithAllowsSwappableMemory: true]))
while (!f.atEndOfStream) {
char buf[128];
size_t len = [f readIntoBuffer: buf
size_t len = [f readIntoBuffer: buf length: 128];
length: 128];
[sha512 updateWithBuffer: buf
[sha512 updateWithBuffer: buf length: len];
length: len];
}
[f close];
TEST(@"-[copy]", (copy = [[sha512 copy] autorelease]))
TEST(@"-[digest]",
memcmp(sha512.digest, testfile_sha512, 64) == 0 &&
memcmp(copy.digest, testfile_sha512, 64) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException,
[sha512 updateWithBuffer: ""
[sha512 updateWithBuffer: "" length: 1])
length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSPXSocketTests.m
from [ea2a79212c]
to [82404a3974].
︙ | | |
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
-
+
-
-
-
+
-
-
+
-
|
of_socket_address_get_ipx_node(&address1, node);
network = of_socket_address_get_ipx_network(&address1);
port = of_socket_address_get_port(&address1);
TEST(@"-[listen]", R([sockServer listen]))
TEST(@"-[connectToNode:network:port:]",
R([sockClient connectToNode: node
R([sockClient connectToNode: node network: network port: port]))
network: network
port: port]))
TEST(@"-[accept]", (sockAccepted = [sockServer accept]))
TEST(@"-[sendBuffer:length:]",
R([sockAccepted sendBuffer: "Hello"
R([sockAccepted sendBuffer: "Hello" length: 5]))
length: 5]))
TEST(@"-[receiveIntoBuffer:length:]",
[sockClient receiveIntoBuffer: buffer
[sockClient receiveIntoBuffer: buffer length: 5] == 5 &&
length: 5] == 5 &&
memcmp(buffer, "Hello", 5) == 0)
TEST(@"-[remoteAddress]",
(address2 = sockAccepted.remoteAddress) &&
R(of_socket_address_get_ipx_node(address2, node2)) &&
memcmp(node, node2, IPX_NODE_LEN) == 0 &&
of_socket_address_get_ipx_network(address2) == network)
|
︙ | | |
Modified tests/OFSPXStreamSocketTests.m
from [b2fe1b33a9]
to [c771c1b333].
︙ | | |
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
-
+
-
-
-
+
-
-
+
-
-
+
-
|
of_socket_address_get_ipx_node(&address1, node);
network = of_socket_address_get_ipx_network(&address1);
port = of_socket_address_get_port(&address1);
TEST(@"-[listen]", R([sockServer listen]))
TEST(@"-[connectToNode:network:port:]",
R([sockClient connectToNode: node
R([sockClient connectToNode: node network: network port: port]))
network: network
port: port]))
TEST(@"-[accept]", (sockAccepted = [sockServer accept]))
/* Test reassembly (this would not work with OFSPXSocket) */
TEST(@"-[writeBuffer:length:]",
R([sockAccepted writeBuffer: "Hello"
R([sockAccepted writeBuffer: "Hello" length: 5]))
length: 5]))
TEST(@"-[readIntoBuffer:length:]",
[sockClient readIntoBuffer: buffer
[sockClient readIntoBuffer: buffer length: 2] == 2 &&
length: 2] == 2 &&
memcmp(buffer, "He", 2) == 0 &&
[sockClient readIntoBuffer: buffer
[sockClient readIntoBuffer: buffer length: 3] == 3 &&
length: 3] == 3 &&
memcmp(buffer, "llo", 3) == 0)
TEST(@"-[remoteAddress]",
(address2 = sockAccepted.remoteAddress) &&
R(of_socket_address_get_ipx_node(address2, node2)) &&
memcmp(node, node2, IPX_NODE_LEN) == 0 &&
of_socket_address_get_ipx_network(address2) == network)
|
︙ | | |
Modified tests/OFSerializationTests.m
from [123b41888a]
to [5f6e7408a0].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
[a addObject: @"Qu\"xbar\ntest"];
[a addObject: [OFNumber numberWithInt: 1234]];
[a addObject: [OFNumber numberWithDouble: 1234.5678]];
[a addObject: [OFMutableString stringWithString: @"asd"]];
[a addObject: [OFDate dateWithTimeIntervalSince1970: 1234.5678]];
[d setObject: @"Hello"
[d setObject: @"Hello" forKey: a];
forKey: a];
[d setObject: @"B\"la"
[d setObject: @"B\"la" forKey: @"Blub"];
forKey: @"Blub"];
[l appendObject: @"Hello"];
[l appendObject: @"Wo\rld!\nHow are you?"];
[l appendObject: [OFURL URLWithString: @"https://objfw.nil.im/"]];
[l appendObject:
[OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]];
[l appendObject: [OFSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[l appendObject:
[OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[d setObject: @"list"
[d setObject: @"list" forKey: l];
forKey: l];
data = [OFData dataWithItems: "0123456789:;<ABCDEFGHJIKLMNOPQRSTUVWXYZ"
count: 39];
[d setObject: @"data"
[d setObject: @"data" forKey: data];
forKey: data];
TEST(@"-[stringBySerializing]",
(s = d.stringBySerializing) && [s isEqual:
[OFString stringWithContentsOfFile: @"serialization.xml"]])
TEST(@"-[objectByDeserializing]", [s.objectByDeserializing isEqual: d])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFSetTests.m
from [ac52690eae]
to [297b7fe674].
︙ | | |
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-
+
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
arguments: (va_list)arguments
{
self = [super init];
@try {
_set = [[OFMutableSet alloc] initWithObject: firstObject
arguments: arguments];
} @catch (id e) {
|
︙ | | |
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
-
+
-
|
state->mutationsPtr = &_mutations;
return ret;
}
@end
@implementation TestsAppDelegate (OFSetTests)
- (void)setTestsWithClass: (Class)setClass
- (void)setTestsWithClass: (Class)setClass mutableClass: (Class)mutableSetClass
mutableClass: (Class)mutableSetClass
{
void *pool = objc_autoreleasePoolPush();
OFSet *set1, *set2;
OFMutableSet *mutableSet;
bool ok;
size_t i;
|
︙ | | |
Modified tests/OFStreamTests.m
from [fdf2fcbee2]
to [fe454fc94f].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
+
-
|
@implementation StreamTester
- (bool)lowlevelIsAtEndOfStream
{
return (state > 1);
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer
- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)size
length: (size_t)size
{
size_t pageSize = [OFSystemInfo pageSize];
switch (state) {
case 0:
if (size < 1)
return 0;
|
︙ | | |
Modified tests/OFStringTests.m
from [72c5e8bd18]
to [e616a01e33].
︙ | | |
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
-
+
-
|
if (self == [SimpleMutableString class])
[self inheritMethodsFromClass: [SimpleString class]];
}
- (void)replaceCharactersInRange: (of_range_t)range
withString: (OFString *)string
{
[_string replaceCharactersInRange: range
[_string replaceCharactersInRange: range withString: string];
withString: string];
}
@end
@interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate>
@end
@implementation EntityHandler
|
︙ | | |
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
-
-
+
+
-
+
+
|
TEST(@"-[description]", [s[0].description isEqual: s[0]])
TEST(@"-[appendString:] and -[appendUTF8String:]",
R([s[1] appendUTF8String: "1𝄞"]) && R([s[1] appendString: @"3"]) &&
R([s[0] appendString: s[1]]) && [s[0] isEqual: @"täs€1𝄞3"])
TEST(@"-[appendCharacters:length:]",
R([s[1] appendCharacters: ucstr + 6
length: 2]) && [s[1] isEqual: @"1𝄞3r🀺"])
R([s[1] appendCharacters: ucstr + 6 length: 2]) &&
[s[1] isEqual: @"1𝄞3r🀺"])
TEST(@"-[length]", s[0].length == 7)
TEST(@"-[UTF8StringLength]", s[0].UTF8StringLength == 13)
TEST(@"-[hash]", s[0].hash == 0x705583C0)
TEST(@"-[characterAtIndex:]", [s[0] characterAtIndex: 0] == 't' &&
TEST(@"-[characterAtIndex:]",
[s[0] characterAtIndex: 0] == 't' &&
[s[0] characterAtIndex: 1] == 0xE4 &&
[s[0] characterAtIndex: 3] == 0x20AC &&
[s[0] characterAtIndex: 5] == 0x1D11E)
EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]",
OFOutOfRangeException, [s[0] characterAtIndex: 7])
|
︙ | | |
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
-
-
+
+
|
TEST(@"+[stringWithContentsOfURL:encoding]", (is = [stringClass
stringWithContentsOfURL: [OFURL fileURLWithPath: @"testfile.txt"]
encoding: OF_STRING_ENCODING_ISO_8859_1]) &&
[is isEqual: @"testäöü"])
#endif
TEST(@"-[appendUTFString:length:]",
R([s[0] appendUTF8String: "\xEF\xBB\xBF" "barqux"
length: 6]) && [s[0] isEqual: @"foobar"])
R([s[0] appendUTF8String: "\xEF\xBB\xBF" "barqux" length: 6]) &&
[s[0] isEqual: @"foobar"])
EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1",
OFInvalidEncodingException,
[stringClass stringWithUTF8String: "\xE0\x80"])
EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2",
OFInvalidEncodingException,
[stringClass stringWithUTF8String: "\xF0\x80\x80\xC0"])
|
︙ | | |
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
|
-
+
-
-
|
options: OF_STRING_SEARCH_BACKWARDS].location == 0 &&
[C(@"𝄞öö") rangeOfString: @"x"
options: OF_STRING_SEARCH_BACKWARDS].location == OF_NOT_FOUND)
EXPECT_EXCEPTION(
@"Detect out of range in -[rangeOfString:options:range:]",
OFOutOfRangeException,
[C(@"𝄞öö") rangeOfString: @"ö"
[C(@"𝄞öö") rangeOfString: @"ö" options: 0 range: of_range(3, 1)])
options: 0
range: of_range(3, 1)])
cs = [OFCharacterSet characterSetWithCharactersInString: @"cđ"];
TEST(@"-[indexOfCharacterFromSet:]",
[C(@"abcđabcđe") indexOfCharacterFromSet: cs] == 2 &&
[C(@"abcđabcđë")
indexOfCharacterFromSet: cs
options: OF_STRING_SEARCH_BACKWARDS] == 7 &&
|
︙ | | |
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
|
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
|
TEST(@"-[stringByURLDecoding]",
[C(@"foo%20bar%22+%24%F0%9F%8D%8C").stringByURLDecoding
isEqual: @"foo bar\"+$🍌"])
TEST(@"-[insertString:atIndex:]",
(s[0] = [mutableStringClass stringWithString: @"𝄞öööbä€"]) &&
R([s[0] insertString: @"äöü"
R([s[0] insertString: @"äöü" atIndex: 3]) &&
atIndex: 3]) &&
[s[0] isEqual: @"𝄞ööäöüöbä€"])
EXPECT_EXCEPTION(@"Detect invalid format in -[stringByURLDecoding] "
@"#1", OFInvalidFormatException,
[C(@"foo%xbar") stringByURLDecoding])
EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
@"#2", OFInvalidEncodingException,
[C(@"foo%FFbar") stringByURLDecoding])
TEST(@"-[setCharacter:atIndex:]",
(s[0] = [mutableStringClass stringWithString: @"abäde"]) &&
R([s[0] setCharacter: 0xF6
R([s[0] setCharacter: 0xF6 atIndex: 2]) &&
atIndex: 2]) &&
[s[0] isEqual: @"aböde"] &&
R([s[0] setCharacter: 'c'
R([s[0] setCharacter: 'c' atIndex: 2]) &&
atIndex: 2]) &&
[s[0] isEqual: @"abcde"] &&
R([s[0] setCharacter: 0x20AC
R([s[0] setCharacter: 0x20AC atIndex: 3]) &&
atIndex: 3]) &&
[s[0] isEqual: @"abc€e"] &&
R([s[0] setCharacter: 'x'
R([s[0] setCharacter: 'x' atIndex: 1]) && [s[0] isEqual: @"axc€e"])
atIndex: 1]) &&
[s[0] isEqual: @"axc€e"])
TEST(@"-[deleteCharactersInRange:]",
(s[0] = [mutableStringClass stringWithString: @"𝄞öööbä€"]) &&
R([s[0] deleteCharactersInRange: of_range(1, 3)]) &&
[s[0] isEqual: @"𝄞bä€"] &&
R([s[0] deleteCharactersInRange: of_range(0, 4)]) &&
[s[0] isEqual: @""])
|
︙ | | |
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
|
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
|
-
+
-
-
+
-
-
+
-
-
+
-
|
EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2",
OFOutOfRangeException,
[s[0] deleteCharactersInRange: of_range(4, 0)])
EXPECT_EXCEPTION(@"Detect OoR in "
@"-[replaceCharactersInRange:withString:] #1",
OFOutOfRangeException,
[s[0] replaceCharactersInRange: of_range(2, 2)
[s[0] replaceCharactersInRange: of_range(2, 2) withString: @""])
withString: @""])
EXPECT_EXCEPTION(@"Detect OoR in "
@"-[replaceCharactersInRange:withString:] #2",
OFOutOfRangeException,
[s[0] replaceCharactersInRange: of_range(4, 0)
[s[0] replaceCharactersInRange: of_range(4, 0) withString: @""])
withString: @""])
TEST(@"-[replaceOccurrencesOfString:withString:]",
(s[0] = [mutableStringClass stringWithString:
@"asd fo asd fofo asd"]) &&
R([s[0] replaceOccurrencesOfString: @"fo"
R([s[0] replaceOccurrencesOfString: @"fo" withString: @"foo"]) &&
withString: @"foo"]) &&
[s[0] isEqual: @"asd foo asd foofoo asd"] &&
(s[0] = [mutableStringClass stringWithString: @"XX"]) &&
R([s[0] replaceOccurrencesOfString: @"X"
R([s[0] replaceOccurrencesOfString: @"X" withString: @"XX"]) &&
withString: @"XX"]) &&
[s[0] isEqual: @"XXXX"])
TEST(@"-[replaceOccurrencesOfString:withString:options:range:]",
(s[0] = [mutableStringClass stringWithString:
@"foofoobarfoobarfoo"]) &&
R([s[0] replaceOccurrencesOfString: @"oo"
withString: @"óò"
|
︙ | | |
Modified tests/OFTCPSocketTests.m
from [9caf5227b3]
to [da7e6e6092].
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
-
+
+
|
uint16_t port;
char buf[6];
TEST(@"+[socket]", (server = [OFTCPSocket socket]) &&
(client = [OFTCPSocket socket]))
TEST(@"-[bindToHost:port:]",
(port = [server bindToHost: @"127.0.0.1"
(port = [server bindToHost: @"127.0.0.1" port: 0]))
port: 0]))
TEST(@"-[listen]", R([server listen]))
TEST(@"-[connectToHost:port:]",
R([client connectToHost: @"127.0.0.1"
R([client connectToHost: @"127.0.0.1" port: port]))
port: port]))
TEST(@"-[accept]", (accepted = [server accept]))
TEST(@"-[remoteAddress]",
[of_socket_address_ip_string(accepted.remoteAddress, NULL)
isEqual: @"127.0.0.1"])
TEST(@"-[writeString:]", [client writeString: @"Hello!"])
TEST(@"-[readIntoBuffer:length:]", [accepted readIntoBuffer: buf
length: 6] &&
TEST(@"-[readIntoBuffer:length:]",
[accepted readIntoBuffer: buf length: 6] &&
!memcmp(buf, "Hello!", 6))
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFThreadTests.m
from [7689fdb7c9]
to [61a0609ec2].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
-
+
-
|
@interface TestThread: OFThread
@end
@implementation TestThread
- (id)main
{
[[OFThread threadDictionary] setObject: @"bar"
[[OFThread threadDictionary] setObject: @"bar" forKey: @"foo"];
forKey: @"foo"];
return @"success";
}
@end
@implementation TestsAppDelegate (OFThreadTests)
- (void)threadTests
|
︙ | | |
Modified tests/OFUDPSocketTests.m
from [874d662a72]
to [29ec231a7f].
︙ | | |
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
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
-
+
-
-
+
-
-
-
+
-
-
|
of_socket_address_t addr1, addr2, addr3;
char buf[6];
OFString *host;
TEST(@"+[socket]", (sock = [OFUDPSocket socket]))
TEST(@"-[bindToHost:port:]",
(port1 = [sock bindToHost: @"127.0.0.1"
(port1 = [sock bindToHost: @"127.0.0.1" port: 0]))
port: 0]))
addr1 = of_socket_address_parse_ip(@"127.0.0.1", port1);
TEST(@"-[sendBuffer:length:receiver:]",
R([sock sendBuffer: "Hello"
R([sock sendBuffer: "Hello" length: 6 receiver: &addr1]))
length: 6
receiver: &addr1]))
TEST(@"-[receiveIntoBuffer:length:sender:]",
[sock receiveIntoBuffer: buf
[sock receiveIntoBuffer: buf length: 6 sender: &addr2] == 6 &&
length: 6
sender: &addr2] == 6 &&
!memcmp(buf, "Hello", 6) &&
(host = of_socket_address_ip_string(&addr2, &port2)) &&
[host isEqual: @"127.0.0.1"] && port2 == port1)
addr3 = of_socket_address_parse_ip(@"127.0.0.1", port1 + 1);
/*
|
︙ | | |
Modified tests/OFURLTests.m
from [409cce205c]
to [a23bc7aa5e].
︙ | | |
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
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
105
106
107
108
109
110
111
112
113
114
115
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
[OFURL URLWithString: @"https://[f]:/"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #8",
OFInvalidFormatException,
[OFURL URLWithString: @"https://[f]:f/"])
TEST(@"+[URLWithString:relativeToURL:]",
[[[OFURL URLWithString: @"/foo"
[[[OFURL URLWithString: @"/foo" relativeToURL: u1] string] isEqual:
relativeToURL: u1] string] isEqual:
@"ht%3atp://us%3Aer:p%40w@ho%3Ast:1234/foo"] &&
[[[OFURL URLWithString: @"foo/bar?q"
relativeToURL: [OFURL URLWithString: @"http://h/qux/quux"]]
string] isEqual: @"http://h/qux/foo/bar?q"] &&
[[[OFURL URLWithString: @"foo/bar"
relativeToURL: [OFURL URLWithString: @"http://h/qux/?x"]]
string] isEqual: @"http://h/qux/foo/bar"] &&
[[[OFURL URLWithString: @"http://foo/?q"
relativeToURL: u1] string] isEqual: @"http://foo/?q"] &&
[[[OFURL URLWithString: @"foo"
relativeToURL: [OFURL URLWithString: @"http://foo/bar"]]
string] isEqual: @"http://foo/foo"] &&
[[[OFURL URLWithString: @"foo"
relativeToURL: [OFURL URLWithString: @"http://foo"]]
string] isEqual: @"http://foo/foo"])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #1",
OFInvalidFormatException,
[OFURL URLWithString: @"`"
[OFURL URLWithString: @"`" relativeToURL: u1])
relativeToURL: u1])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #2",
OFInvalidFormatException,
[OFURL URLWithString: @"/`"
[OFURL URLWithString: @"/`" relativeToURL: u1])
relativeToURL: u1])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #3",
OFInvalidFormatException,
[OFURL URLWithString: @"?`"
[OFURL URLWithString: @"?`" relativeToURL: u1])
relativeToURL: u1])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #4",
OFInvalidFormatException,
[OFURL URLWithString: @"#`"
[OFURL URLWithString: @"#`" relativeToURL: u1])
relativeToURL: u1])
#ifdef OF_HAVE_FILES
TEST(@"+[fileURLWithPath:]",
[[[OFURL fileURLWithPath: @"testfile.txt"] fileSystemRepresentation]
isEqual: [[OFFileManager defaultManager].currentDirectoryPath
stringByAppendingPathComponent: @"testfile.txt"]])
|
︙ | | |
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
-
+
-
-
+
-
-
+
-
-
+
-
|
EXPECT_EXCEPTION(
@"-[setURLEncodedFragment:] with invalid characters fails",
OFInvalidFormatException, mu.URLEncodedFragment = @"`")
TEST(@"-[URLByAppendingPathComponent:isDirectory:]",
[[[OFURL URLWithString: @"file:///foo/bar"]
URLByAppendingPathComponent: @"qux"
URLByAppendingPathComponent: @"qux" isDirectory: false] isEqual:
isDirectory: false] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qux"]] &&
[[[OFURL URLWithString: @"file:///foo/bar/"]
URLByAppendingPathComponent: @"qux"
URLByAppendingPathComponent: @"qux" isDirectory: false] isEqual:
isDirectory: false] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qux"]] &&
[[[OFURL URLWithString: @"file:///foo/bar/"]
URLByAppendingPathComponent: @"qu?x"
URLByAppendingPathComponent: @"qu?x" isDirectory: false] isEqual:
isDirectory: false] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qu%3Fx"]] &&
[[[OFURL URLWithString: @"file:///foo/bar/"]
URLByAppendingPathComponent: @"qu?x"
URLByAppendingPathComponent: @"qu?x" isDirectory: true] isEqual:
isDirectory: true] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qu%3Fx/"]])
TEST(@"-[URLByStandardizingPath]",
[[[OFURL URLWithString: @"http://foo/bar/.."]
URLByStandardizingPath] isEqual:
[OFURL URLWithString: @"http://foo/"]] &&
[[[OFURL URLWithString: @"http://foo/bar/%2E%2E/../qux/"]
|
︙ | | |
Modified tests/OFValueTests.m
from [eefd2c428a]
to [dd07d710ca].
︙ | | |
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
+
-
-
+
-
|
TEST(@"+[valueWithBytes:objCType:]",
(value = [OFValue valueWithBytes: &range
objCType: @encode(of_range_t)]))
TEST(@"-[objCType]", strcmp(value.objCType, @encode(of_range_t)) == 0)
TEST(@"-[getValue:size:]",
R([value getValue: &range2
R([value getValue: &range2 size: sizeof(of_range_t)]) &&
size: sizeof(of_range_t)]) &&
of_range_equal(range2, range))
EXPECT_EXCEPTION(@"-[getValue:size:] with wrong size throws",
OFOutOfRangeException,
[value getValue: &range
[value getValue: &range size: sizeof(of_range_t) - 1])
size: sizeof(of_range_t) - 1])
TEST(@"+[valueWithPointer:]",
(value = [OFValue valueWithPointer: pointer]))
TEST(@"-[pointerValue]",
value.pointerValue == pointer &&
[[OFValue valueWithBytes: &pointer
|
︙ | | |
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
|
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
|
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
|
of_range_equal(value.rangeValue, range) &&
(value = [OFValue valueWithBytes: &range
objCType: @encode(of_range_t)]) &&
of_range_equal(value.rangeValue, range))
TEST(@"-[getValue:size:] for OFRangeValue",
(value = [OFValue valueWithRange: range]) &&
R([value getValue: &range2
R([value getValue: &range2 size: sizeof(range2)]) &&
size: sizeof(range2)]) &&
of_range_equal(range2, range))
EXPECT_EXCEPTION(@"-[rangeValue] with wrong size throws",
OFOutOfRangeException,
[[OFValue valueWithBytes: "a"
objCType: @encode(char)] rangeValue])
TEST(@"+[valueWithPoint:]",
(value = [OFValue valueWithPoint: point]))
TEST(@"-[pointValue]",
of_point_equal(value.pointValue, point) &&
(value = [OFValue valueWithBytes: &point
objCType: @encode(of_point_t)]) &&
of_point_equal(value.pointValue, point))
TEST(@"-[getValue:size:] for OFPointValue",
(value = [OFValue valueWithPoint: point]) &&
R([value getValue: &point2
R([value getValue: &point2 size: sizeof(point2)]) &&
size: sizeof(point2)]) &&
of_point_equal(point2, point))
EXPECT_EXCEPTION(@"-[pointValue] with wrong size throws",
OFOutOfRangeException,
[[OFValue valueWithBytes: "a"
objCType: @encode(char)] pointValue])
TEST(@"+[valueWithDimension:]",
(value = [OFValue valueWithDimension: dimension]))
TEST(@"-[dimensionValue]",
of_dimension_equal(value.dimensionValue, dimension) &&
(value = [OFValue valueWithBytes: &dimension
objCType: @encode(of_dimension_t)]) &&
of_dimension_equal(value.dimensionValue, dimension))
TEST(@"-[getValue:size:] for OFDimensionValue",
(value = [OFValue valueWithDimension: dimension]) &&
R([value getValue: &dimension2
R([value getValue: &dimension2 size: sizeof(dimension2)]) &&
size: sizeof(dimension2)]) &&
of_dimension_equal(dimension2, dimension))
EXPECT_EXCEPTION(@"-[dimensionValue] with wrong size throws",
OFOutOfRangeException,
[[OFValue valueWithBytes: "a"
objCType: @encode(char)] dimensionValue])
TEST(@"+[valueWithRectangle:]",
(value = [OFValue valueWithRectangle: rectangle]))
TEST(@"-[rectangleValue]",
of_rectangle_equal(value.rectangleValue, rectangle) &&
(value = [OFValue valueWithBytes: &rectangle
objCType: @encode(of_rectangle_t)]) &&
of_rectangle_equal(value.rectangleValue, rectangle))
TEST(@"-[getValue:size:] for OFRectangleValue",
(value = [OFValue valueWithRectangle: rectangle]) &&
R([value getValue: &rectangle2
R([value getValue: &rectangle2 size: sizeof(rectangle2)]) &&
size: sizeof(rectangle2)]) &&
of_rectangle_equal(rectangle2, rectangle))
EXPECT_EXCEPTION(@"-[rectangleValue] with wrong size throws",
OFOutOfRangeException,
[[OFValue valueWithBytes: "a"
objCType: @encode(char)] rectangleValue])
TEST(@"-[isEqual:]",
[[OFValue valueWithRectangle: rectangle]
isEqual: [OFValue valueWithBytes: &rectangle
objCType: @encode(of_rectangle_t)]] &&
![[OFValue valueWithBytes: "a"
![[OFValue valueWithBytes: "a" objCType: @encode(signed char)]
objCType: @encode(signed char)]
isEqual: [OFValue valueWithBytes: "a"
objCType: @encode(unsigned char)]] &&
![[OFValue valueWithBytes: "a"
![[OFValue valueWithBytes: "a" objCType: @encode(char)]
objCType: @encode(char)]
isEqual: [OFValue valueWithBytes: "b"
isEqual: [OFValue valueWithBytes: "b" objCType: @encode(char)]])
objCType: @encode(char)]])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFWindowsRegistryKeyTests.m
from [bd808fe76b]
to [5df411ba49].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
+
-
|
static OFString *module = @"OFWindowsRegistryKey";
@implementation TestsAppDelegate (OFWindowsRegistryKeyTests)
- (void)windowsRegistryKeyTests
{
void *pool = objc_autoreleasePoolPush();
OFData *data = [OFData dataWithItems: "abcdef"
OFData *data = [OFData dataWithItems: "abcdef" count: 6];
count: 6];
OFWindowsRegistryKey *softwareKey, *ObjFWKey;
DWORD type;
TEST(@"+[OFWindowsRegistryKey classesRootKey]",
[OFWindowsRegistryKey classesRootKey])
TEST(@"+[OFWindowsRegistryKey currentConfigKey]",
|
︙ | | |
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
|
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
|
-
+
-
-
-
+
-
-
+
-
-
-
+
+
|
securityAndAccessRights: KEY_ALL_ACCESS] == nil)
TEST(@"-[createSubkeyAtPath:securityAndAccessRights:]",
(ObjFWKey = [softwareKey createSubkeyAtPath: @"ObjFW"
securityAndAccessRights: KEY_ALL_ACCESS]))
TEST(@"-[setData:forValueNamed:type:]",
R([ObjFWKey setData: data
R([ObjFWKey setData: data forValueNamed: @"data" type: REG_BINARY]))
forValueNamed: @"data"
type: REG_BINARY]))
TEST(@"-[dataForValueNamed:subkeyPath:flags:type:]",
[[ObjFWKey dataForValueNamed: @"data"
[[ObjFWKey dataForValueNamed: @"data" type: &type] isEqual: data] &&
type: &type] isEqual: data] &&
type == REG_BINARY)
TEST(@"-[setString:forValueNamed:type:]",
R([ObjFWKey setString: @"foobar"
R([ObjFWKey setString: @"foobar" forValueNamed: @"string"]) &&
forValueNamed: @"string"]) &&
R([ObjFWKey setString: @"%PATH%;foo"
forValueNamed: @"expand"
type: REG_EXPAND_SZ]))
TEST(@"-[stringForValue:subkeyPath:]",
[[ObjFWKey stringForValueNamed: @"string"] isEqual: @"foobar"] &&
[[ObjFWKey stringForValueNamed: @"expand"
type: &type] isEqual: @"%PATH%;foo"] &&
[[ObjFWKey stringForValueNamed: @"expand" type: &type]
isEqual: @"%PATH%;foo"] &&
type == REG_EXPAND_SZ)
TEST(@"-[deleteValueNamed:]", R([ObjFWKey deleteValueNamed: @"data"]))
TEST(@"-[deleteSubkeyAtPath:]",
R([softwareKey deleteSubkeyAtPath: @"ObjFW"]))
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFXMLNodeTests.m
from [8eafe93c0b]
to [bd9f707bbe].
︙ | | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
-
+
-
-
+
-
|
(nodes[1] = [OFXMLElement elementWithName: @"foo"
stringValue: @"b&ar"]) &&
[[nodes[1] XMLString] isEqual: @"<foo>b&ar</foo>"])
TEST(@"+[elementWithName:namespace:]",
(nodes[2] = [OFXMLElement elementWithName: @"foo"
namespace: @"urn:objfw:test"]) &&
R([nodes[2] addAttributeWithName: @"test"
R([nodes[2] addAttributeWithName: @"test" stringValue: @"test"]) &&
stringValue: @"test"]) &&
R([nodes[2] setPrefix: @"objfw-test"
forNamespace: @"urn:objfw:test"]) &&
[[nodes[2] XMLString] isEqual: @"<objfw-test:foo test='test'/>"] &&
(nodes[3] = [OFXMLElement elementWithName: @"foo"
namespace: @"urn:objfw:test"]) &&
R([nodes[3] addAttributeWithName: @"test"
R([nodes[3] addAttributeWithName: @"test" stringValue: @"test"]) &&
stringValue: @"test"]) &&
[[nodes[3] XMLString] isEqual:
@"<foo xmlns='urn:objfw:test' test='test'/>"])
TEST(@"+[elementWithName:namespace:stringValue:]",
(nodes[3] = [OFXMLElement elementWithName: @"foo"
namespace: @"urn:objfw:test"
stringValue: @"x"]) &&
|
︙ | | |
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-
+
-
-
+
-
|
TEST(@"+[commentWithString:]",
(nodes[3] = [OFXMLComment commentWithString: @" comment "]) &&
[[nodes[3] XMLString] isEqual: @"<!-- comment -->"])
module = @"OFXMLElement";
TEST(@"-[addAttributeWithName:stringValue:]",
R([nodes[0] addAttributeWithName: @"foo"
R([nodes[0] addAttributeWithName: @"foo" stringValue: @"b&ar"]) &&
stringValue: @"b&ar"]) &&
[[nodes[0] XMLString] isEqual: @"<foo foo='b&ar'/>"] &&
R([nodes[1] addAttributeWithName: @"foo"
R([nodes[1] addAttributeWithName: @"foo" stringValue: @"b&ar"]) &&
stringValue: @"b&ar"]) &&
[[nodes[1] XMLString] isEqual:
@"<foo foo='b&ar'>b&ar</foo>"])
TEST(@"-[setPrefix:forNamespace:]",
R([nodes[1] setPrefix: @"objfw-test"
forNamespace: @"urn:objfw:test"]))
|
︙ | | |
Modified tests/OFXMLParserTests.m
from [faffb42f7b]
to [c56cc9efc9].
︙ | | |
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
-
+
-
-
+
-
-
+
-
|
name: name
prefix: prefix
namespace: ns
attributes: nil
string: nil];
}
- (void)parser: (OFXMLParser *)parser
- (void)parser: (OFXMLParser *)parser foundCharacters: (OFString *)string
foundCharacters: (OFString *)string
{
[self parser: parser
didCreateEvent: STRING
name: nil
prefix: nil
namespace: nil
attributes: nil
string: string];
}
- (void)parser: (OFXMLParser *)parser
- (void)parser: (OFXMLParser *)parser foundCDATA: (OFString *)cdata
foundCDATA: (OFString *)cdata
{
[self parser: parser
didCreateEvent: CDATA
name: nil
prefix: nil
namespace: nil
attributes: nil
string: cdata];
}
- (void)parser: (OFXMLParser *)parser
- (void)parser: (OFXMLParser *)parser foundComment: (OFString *)comment
foundComment: (OFString *)comment
{
[self parser: parser
didCreateEvent: COMMENT
name: nil
prefix: nil
namespace: nil
attributes: nil
|
︙ | | |
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
-
+
-
-
+
-
|
len = strlen(str);
for (j = 0; j < len; j+= 2) {
if (parser.hasFinishedParsing)
abort();
if (j + 2 > len)
[parser parseBuffer: str + j
[parser parseBuffer: str + j length: 1];
length: 1];
else
[parser parseBuffer: str + j
[parser parseBuffer: str + j length: 2];
length: 2];
}
TEST(@"Checking if everything was parsed",
i == 32 && parser.lineNumber == 18)
TEST(@"-[hasFinishedParsing]", parser.hasFinishedParsing)
|
︙ | | |
Modified tests/TestsAppDelegate.h
from [df50ba0832]
to [c79591610e].
︙ | | |
11
12
13
14
15
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
|
11
12
13
14
15
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
|
-
-
-
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
-
-
+
+
-
+
-
-
+
-
-
+
-
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "ObjFW.h"
#define TEST(test, ...) \
{ \
[self outputTesting: test \
#define TEST(test, ...) \
{ \
[self outputTesting: test inModule: module]; \
inModule: module]; \
\
if (__VA_ARGS__) \
[self outputSuccess: test \
\
if (__VA_ARGS__) \
[self outputSuccess: test inModule: module]; \
inModule: module]; \
else { \
[self outputFailure: test \
else { \
[self outputFailure: test inModule: module]; \
inModule: module]; \
_fails++; \
} \
_fails++; \
} \
}
#define EXPECT_EXCEPTION(test, exception, code) \
{ \
bool caught = false; \
\
[self outputTesting: test \
#define EXPECT_EXCEPTION(test, exception, code) \
{ \
bool caught = false; \
\
[self outputTesting: test inModule: module]; \
inModule: module]; \
\
@try { \
code; \
} @catch (exception *e) { \
caught = true; \
} \
\
if (caught) \
[self outputSuccess: test \
\
@try { \
code; \
} @catch (exception *e) { \
caught = true; \
} \
\
if (caught) \
[self outputSuccess: test inModule: module]; \
inModule: module]; \
else { \
[self outputFailure: test \
else { \
[self outputFailure: test inModule: module]; \
inModule: module]; \
_fails++; \
} \
_fails++; \
} \
}
#define R(...) (__VA_ARGS__, 1)
@class OFString;
@interface TestsAppDelegate: OFObject <OFApplicationDelegate>
{
int _fails;
}
- (void)outputTesting: (OFString *)test
- (void)outputTesting: (OFString *)test inModule: (OFString *)module;
inModule: (OFString *)module;
- (void)outputSuccess: (OFString *)test
- (void)outputSuccess: (OFString *)test inModule: (OFString *)module;
inModule: (OFString *)module;
- (void)outputFailure: (OFString *)test
- (void)outputFailure: (OFString *)test inModule: (OFString *)module;
inModule: (OFString *)module;
@end
@interface TestsAppDelegate (OFASN1DERParsingTests)
- (void)ASN1DERParsingTests;
@end
@interface TestsAppDelegate (OFASN1DERRepresentationTests)
|
︙ | | |
Modified utils/ofarc/GZIPArchive.m
from [a9786ac1f4]
to [c5bd2c7c25].
︙ | | |
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
-
+
-
-
+
-
|
.stringByDeletingPathExtension;
if (app->_outputLevel >= 0)
[of_stdout writeString: OF_LOCALIZED(@"extracting_file",
@"Extracting %[file]...",
@"file", fileName)];
if (![app shouldExtractFile: fileName
if (![app shouldExtractFile: fileName outFileName: fileName])
outFileName: fileName])
return;
output = [OFFile fileWithPath: fileName
output = [OFFile fileWithPath: fileName mode: @"w"];
mode: @"w"];
setPermissions(fileName, app->_archivePath);
while (!_stream.atEndOfStream) {
ssize_t length = [app copyBlockFromStream: _stream
toStream: output
fileName: fileName];
|
︙ | | |
Modified utils/ofarc/LHAArchive.m
from [3021725523]
to [a0cfa6c4ee].
︙ | | |
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
-
+
-
-
+
-
|
}
directory = outFileName.stringByDeletingLastPathComponent;
if (![fileManager directoryExistsAtPath: directory])
[fileManager createDirectoryAtPath: directory
createParents: true];
if (![app shouldExtractFile: fileName
if (![app shouldExtractFile: fileName outFileName: outFileName])
outFileName: outFileName])
goto outer_loop_end;
stream = [_archive streamForReadingCurrentEntry];
output = [OFFile fileWithPath: outFileName
output = [OFFile fileWithPath: outFileName mode: @"w"];
mode: @"w"];
setPermissions(outFileName, entry);
while (!stream.atEndOfStream) {
ssize_t length = [app copyBlockFromStream: stream
toStream: output
fileName: fileName];
|
︙ | | |
Modified utils/ofarc/OFArc.m
from [a6b651554f]
to [20902865a7].
︙ | | |
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
-
+
-
|
#ifdef OF_HAVE_SANDBOX
if (![remainingArguments.firstObject isEqual: @"-"])
[sandbox unveilPath: remainingArguments.firstObject
permissions: (mode == 'a' ? @"rwc" : @"wc")];
for (OFString *path in files)
[sandbox unveilPath: path
[sandbox unveilPath: path permissions: @"r"];
permissions: @"r"];
sandbox.allowsUnveil = false;
[OFApplication activateSandbox: sandbox];
#endif
archive = [self
openArchiveWithPath: remainingArguments.firstObject
|
︙ | | |
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
-
+
-
-
+
-
|
#ifdef OF_HAVE_SANDBOX
if (![remainingArguments.firstObject isEqual: @"-"])
[sandbox unveilPath: remainingArguments.firstObject
permissions: @"r"];
if (files.count > 0)
for (OFString *path in files)
[sandbox unveilPath: path
[sandbox unveilPath: path permissions: @"wc"];
permissions: @"wc"];
else {
OFString *path = (outputDir != nil
? outputDir : OF_PATH_CURRENT_DIRECTORY);
/* We need 'r' to change the directory to it. */
[sandbox unveilPath: path
[sandbox unveilPath: path permissions: @"rwc"];
permissions: @"rwc"];
}
sandbox.allowsUnveil = false;
[OFApplication activateSandbox: sandbox];
#endif
archive = [self
|
︙ | | |
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
-
+
-
|
file = of_stdin;
break;
default:
@throw [OFInvalidArgumentException exception];
}
} else {
@try {
file = [OFFile fileWithPath: path
file = [OFFile fileWithPath: path mode: fileModeString];
mode: fileModeString];
} @catch (OFOpenItemFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stderr writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(
@"failed_to_open_file",
|
︙ | | |
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
-
+
-
-
+
-
|
toStream: (OFStream *)output
fileName: (OFString *)fileName
{
char buffer[BUFFER_SIZE];
size_t length;
@try {
length = [input readIntoBuffer: buffer
length = [input readIntoBuffer: buffer length: BUFFER_SIZE];
length: BUFFER_SIZE];
} @catch (OFReadFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stdout writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(@"failed_to_read_file",
@"Failed to read file %[file]: %[error]",
@"file", fileName,
@"error", error)];
return -1;
}
@try {
[output writeBuffer: buffer
[output writeBuffer: buffer length: length];
length: length];
} @catch (OFWriteFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stdout writeString: @"\r"];
[of_stderr writeLine: OF_LOCALIZED(@"failed_to_write_file",
@"Failed to write file %[file]: %[error]",
|
︙ | | |
Modified utils/ofarc/TarArchive.m
from [5f80d4f8b1]
to [c4cfac3bfa].
︙ | | |
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
-
+
-
-
+
-
|
}
directory = outFileName.stringByDeletingLastPathComponent;
if (![fileManager directoryExistsAtPath: directory])
[fileManager createDirectoryAtPath: directory
createParents: true];
if (![app shouldExtractFile: fileName
if (![app shouldExtractFile: fileName outFileName: outFileName])
outFileName: outFileName])
goto outer_loop_end;
stream = [_archive streamForReadingCurrentEntry];
output = [OFFile fileWithPath: outFileName
output = [OFFile fileWithPath: outFileName mode: @"w"];
mode: @"w"];
setPermissions(outFileName, entry);
while (!stream.atEndOfStream) {
ssize_t length = [app copyBlockFromStream: stream
toStream: output
fileName: fileName];
|
︙ | | |
Modified utils/ofarc/ZIPArchive.m
from [c58060c45a]
to [a469b7585b].
︙ | | |
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
-
+
+
-
|
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
if ((entry.versionMadeBy >> 8) ==
OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_UNIX) {
OFNumber *mode = [OFNumber numberWithUnsignedShort:
(entry.versionSpecificAttributes >> 16) & 0777];
of_file_attribute_key_t key =
of_file_attribute_key_posix_permissions;
of_file_attributes_t attributes = [OFDictionary
dictionaryWithObject: mode
of_file_attributes_t attributes =
[OFDictionary dictionaryWithObject: mode forKey: key];
forKey: key];
[[OFFileManager defaultManager] setAttributes: attributes
ofItemAtPath: path];
}
#endif
}
|
︙ | | |
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
-
+
-
-
+
-
|
}
directory = outFileName.stringByDeletingLastPathComponent;
if (![fileManager directoryExistsAtPath: directory])
[fileManager createDirectoryAtPath: directory
createParents: true];
if (![app shouldExtractFile: fileName
if (![app shouldExtractFile: fileName outFileName: outFileName])
outFileName: outFileName])
goto outer_loop_end;
stream = [_archive streamForReadingFile: fileName];
output = [OFFile fileWithPath: outFileName
output = [OFFile fileWithPath: outFileName mode: @"w"];
mode: @"w"];
setPermissions(outFileName, entry);
while (!stream.atEndOfStream) {
ssize_t length = [app copyBlockFromStream: stream
toStream: output
fileName: fileName];
|
︙ | | |
Modified utils/ofdns/OFDNS.m
from [bf05d8854e]
to [4968c2b49d].
︙ | | |
197
198
199
200
201
202
203
204
205
206
207
208
209
|
197
198
199
200
201
202
203
204
205
206
207
208
|
-
+
-
|
of_dns_record_type_parse(recordTypeString);
OFDNSQuery *query =
[OFDNSQuery queryWithDomainName: domainName
DNSClass: DNSClass
recordType: recordType];
_inFlight++;
[resolver asyncPerformQuery: query
[resolver asyncPerformQuery: query delegate: self];
delegate: self];
}
}
}
@end
|
Modified utils/ofhash/OFHash.m
from [aa03d9ef76]
to [fe019671c9].
︙ | | |
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
-
+
-
-
+
-
|
OFSandbox *sandbox = [OFSandbox sandbox];
@try {
sandbox.allowsStdIO = true;
sandbox.allowsReadingFiles = true;
sandbox.allowsUserDatabaseReading = true;
for (OFString *path in optionsParser.remainingArguments)
[sandbox unveilPath: path
[sandbox unveilPath: path permissions: @"r"];
permissions: @"r"];
[sandbox unveilPath: @LANGUAGE_DIR
[sandbox unveilPath: @LANGUAGE_DIR permissions: @"r"];
permissions: @"r"];
[OFApplication activateSandbox: sandbox];
} @finally {
[sandbox release];
}
#endif
|
︙ | | |
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
-
+
-
|
void *pool = objc_autoreleasePoolPush();
OFStream *file;
if ([path isEqual: @"-"])
file = of_stdin;
else {
@try {
file = [OFFile fileWithPath: path
file = [OFFile fileWithPath: path mode: @"r"];
mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[of_stderr writeLine: OF_LOCALIZED(
@"failed_to_open_file",
|
︙ | | |
Modified utils/ofhttp/OFHTTP.m
from [9525086526]
to [3f5985320f].
︙ | | |
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
-
+
-
-
+
-
|
name = [header substringToIndex: pos]
.stringByDeletingEnclosingWhitespaces;
value = [header substringFromIndex: pos + 1]
.stringByDeletingEnclosingWhitespaces;
[_clientHeaders setObject: value
[_clientHeaders setObject: value forKey: name];
forKey: name];
}
- (void)setBody: (OFString *)path
{
OFString *contentLength = nil;
[_body release];
_body = nil;
if ([path isEqual: @"-"])
_body = [of_stdin copy];
else {
_body = [[OFFile alloc] initWithPath: path
_body = [[OFFile alloc] initWithPath: path mode: @"r"];
mode: @"r"];
@try {
unsigned long long fileSize =
[[OFFileManager defaultManager]
attributesOfItemAtPath: path].fileSize;
contentLength =
|
︙ | | |
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
|
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
-
+
-
|
}
#ifdef OF_HAVE_SANDBOX
[sandbox unveilPath: (outputPath != nil
? outputPath : OF_PATH_CURRENT_DIRECTORY)
permissions: (_continue ? @"rwc" : @"wc")];
/* In case we use ObjOpenSSL for https later */
[sandbox unveilPath: @"/etc/ssl"
[sandbox unveilPath: @"/etc/ssl" permissions: @"r"];
permissions: @"r"];
sandbox.allowsUnveil = false;
[OFApplication activateSandbox: sandbox];
#endif
_outputPath = [outputPath copy];
_URLs = [optionsParser.remainingArguments copy];
|
︙ | | |
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
|
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
-
+
-
-
-
-
+
-
-
+
-
-
+
-
|
}
if (_insecure)
_HTTPClient.allowsInsecureRedirects = true;
_useUnicode = ([OFLocale encoding] == OF_STRING_ENCODING_UTF_8);
[self performSelector: @selector(downloadNextURL)
[self performSelector: @selector(downloadNextURL) afterDelay: 0];
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didCreateSocket: (OFTCPSocket *)sock
request: (OFHTTPRequest *)request
{
if (_insecure && [sock respondsToSelector:
@selector(setVerifiesCertificates:)])
((id <OFTLSSocket>)sock).verifiesCertificates = false;
}
- (void)client: (OFHTTPClient *)client
wantsRequestBody: (OFStream *)body
request: (OFHTTPRequest *)request
{
/* TODO: Do asynchronously and print status */
while (!_body.atEndOfStream) {
char buffer[4096];
size_t length;
length = [_body readIntoBuffer: buffer
size_t length = [_body readIntoBuffer: buffer length: 4096];
length: 4096];
[body writeBuffer: buffer
[body writeBuffer: buffer length: length];
length: length];
}
}
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirect: (OFURL *)URL
statusCode: (short)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
{
if (_verbose) {
void *pool = objc_autoreleasePoolPush();
OFDictionary OF_GENERIC(OFString *, OFString *) *headers =
response.headers;
OFEnumerator *keyEnumerator = [headers keyEnumerator];
OFEnumerator *objectEnumerator = [headers objectEnumerator];
OFString *key, *object;
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
[of_stdout writeFormat: @" %@: %@\n",
[of_stdout writeFormat: @" %@: %@\n", key, object];
key, object];
objc_autoreleasePoolPop(pool);
}
if (!_quiet) {
if (_useUnicode)
[of_stdout writeFormat: @"☇ %@", URL.string];
|
︙ | | |
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
|
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
|
-
-
-
+
-
+
|
_errorCode = 1;
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
return false;
}
_received += length;
[_output writeBuffer: buffer
[_output writeBuffer: buffer length: length];
length: length];
_received += length;
[_progressBar setReceived: _received];
if (response.atEndOfStream) {
[_progressBar stop];
[_progressBar draw];
[_progressBar release];
_progressBar = nil;
|
︙ | | |
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
|
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
|
-
+
-
-
+
-
|
[_progressBar draw];
}
[_currentFileName release];
_currentFileName = nil;
response.delegate = self;
[response asyncReadIntoBuffer: _buffer
[response asyncReadIntoBuffer: _buffer length: [OFSystemInfo pageSize]];
length: [OFSystemInfo pageSize]];
return;
next:
[_currentFileName release];
_currentFileName = nil;
[self performSelector: @selector(downloadNextURL)
[self performSelector: @selector(downloadNextURL) afterDelay: 0];
afterDelay: 0];
}
- (void)downloadNextURL
{
OFString *URLString = nil;
OFURL *URL;
OFMutableDictionary *clientHeaders;
|
︙ | | |
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
|
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
|
-
+
-
-
+
-
|
if (size > ULLONG_MAX)
@throw [OFOutOfRangeException exception];
_resumedFrom = (unsigned long long)size;
range = [OFString stringWithFormat: @"bytes=%jd-",
_resumedFrom];
[clientHeaders setObject: range
[clientHeaders setObject: range forKey: @"Range"];
forKey: @"Range"];
} @catch (OFRetrieveItemAttributesFailedException *e) {
}
}
if (!_quiet) {
if (_useUnicode)
[of_stdout writeFormat: @"⇣ %@", URL.string];
else
[of_stdout writeFormat: @"< %@", URL.string];
}
request = [OFHTTPRequest requestWithURL: URL];
request.headers = clientHeaders;
request.method = _method;
_detectFileNameRequest = false;
[_HTTPClient asyncPerformRequest: request];
return;
next:
[self performSelector: @selector(downloadNextURL)
[self performSelector: @selector(downloadNextURL) afterDelay: 0];
afterDelay: 0];
}
@end
|
Modified utils/ofsock/OFSock.m
from [913104ae86]
to [1838a7f311].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
-
+
-
-
-
+
-
|
OFTCPSocket *sock = [OFTCPSocket socket];
if (URL.port == nil) {
[of_stderr writeLine: @"Need a port!"];
[OFApplication terminateWithStatus: 1];
}
[sock connectToHost: URL.host
[sock connectToHost: URL.host port: URL.port.shortValue];
port: URL.port.shortValue];
return [OFPair pairWithFirstObject: sock
return [OFPair pairWithFirstObject: sock secondObject: sock];
secondObject: sock];
}
[of_stderr writeFormat: @"Invalid protocol: %@\n", scheme];
[OFApplication terminateWithStatus: 1];
abort();
}
|
︙ | | |
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
134
135
136
137
138
139
140
141
142
143
144
145
146
|
-
+
-
|
return false;
}
for (OFPair *pair in _streams) {
if (pair.firstObject == stream)
continue;
[pair.secondObject writeBuffer: buffer
[pair.secondObject writeBuffer: buffer length: length];
length: length];
}
return true;
}
@end
|