︙ | | |
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
-
+
+
-
+
+
|
self = [super init];
@try {
const char *cString;
size_t i;
itemSize = 1;
count = [string UTF8StringLength];
count = [string
lengthOfBytesUsingEncoding: OF_STRING_ENCODING_ASCII];
if (count & 1)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
count >>= 1;
cString = [string UTF8String];
cString = [string
cStringUsingEncoding: OF_STRING_ENCODING_ASCII];
items = [self allocMemoryWithSize: count];
for (i = 0; i < count; i++) {
uint8_t c1 = cString[2 * i];
uint8_t c2 = cString[2 * i + 1];
uint8_t byte;
|
︙ | | |
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
-
+
-
+
|
- initWithBase64EncodedString: (OFString*)string
{
self = [super init];
@try {
itemSize = 1;
if (!of_base64_decode(self, [string cStringWithEncoding:
if (!of_base64_decode(self, [string cStringUsingEncoding:
OF_STRING_ENCODING_ASCII], [string
cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) {
lengthOfBytesUsingEncoding: OF_STRING_ENCODING_ASCII])) {
Class c = [self class];
[self release];
@throw [OFInvalidFormatException exceptionWithClass: c];
}
} @catch (id e) {
[self release];
@throw e;
|
︙ | | |
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
-
-
-
+
+
+
|
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
stringValue = [element stringValue];
if (!of_base64_decode(self,
[stringValue cStringWithEncoding: OF_STRING_ENCODING_ASCII],
[stringValue cStringLengthWithEncoding:
if (!of_base64_decode(self, [stringValue
cStringUsingEncoding: OF_STRING_ENCODING_ASCII],
[stringValue lengthOfBytesUsingEncoding:
OF_STRING_ENCODING_ASCII]))
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
|
︙ | | |
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
return ret;
}
+ (BOOL)fileExistsAtPath: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
return NO;
if (S_ISREG(s.st_mode))
return YES;
return NO;
}
+ (BOOL)directoryExistsAtPath: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
return NO;
if (S_ISDIR(s.st_mode))
return YES;
return NO;
}
+ (void)createDirectoryAtPath: (OFString*)path
{
#ifndef _WIN32
if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (mkdir([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
DIR_MODE))
#else
if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
if (mkdir([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
@throw [OFCreateDirectoryFailedException
exceptionWithClass: self
path: path];
}
+ (void)createDirectoryAtPath: (OFString*)path
|
︙ | | |
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
-
+
|
{
OFMutableArray *files = [OFMutableArray array];
#ifndef _WIN32
DIR *dir;
struct dirent *dirent;
if ((dir = opendir([path cStringWithEncoding:
if ((dir = opendir([path cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL)
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
@try {
while ((dirent = readdir(dir)) != NULL) {
|
︙ | | |
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
-
+
|
#else
void *pool = objc_autoreleasePoolPush();
HANDLE handle;
WIN32_FIND_DATA fd;
path = [path stringByAppendingString: @"\\*"];
if ((handle = FindFirstFile([path cStringWithEncoding:
if ((handle = FindFirstFile([path cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE], &fd)) == INVALID_HANDLE_VALUE)
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
@try {
do {
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
[files makeImmutable];
return files;
}
+ (void)changeToDirectoryAtPath: (OFString*)path
{
if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
if (chdir([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
@throw [OFChangeDirectoryFailedException
exceptionWithClass: self
path: path];
}
#ifndef _PSP
+ (void)changeModeOfFileAtPath: (OFString*)path
mode: (mode_t)mode
{
# ifndef _WIN32
if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode))
if (chmod([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE], mode))
@throw [OFChangeFileModeFailedException
exceptionWithClass: self
path: path
mode: mode];
# else
DWORD attributes = GetFileAttributes(
[path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]);
[path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]);
if (attributes == INVALID_FILE_ATTRIBUTES)
@throw [OFChangeFileModeFailedException
exceptionWithClass: self
path: path
mode: mode];
if ((mode / 100) & 2)
attributes &= ~FILE_ATTRIBUTE_READONLY;
else
attributes |= FILE_ATTRIBUTE_READONLY;
if (!SetFileAttributes([path cStringWithEncoding:
if (!SetFileAttributes([path cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE], attributes))
@throw [OFChangeFileModeFailedException
exceptionWithClass: self
path: path
mode: mode];
# endif
}
#endif
+ (off_t)sizeOfFileAtPath: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
return s.st_size;
}
+ (OFDate*)modificationDateOfFileAtPath: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
/* FIXME: We could be more precise on some OSes */
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
@throw [OFLockFailedException exceptionWithClass: self];
@try {
# endif
if (owner != nil) {
struct passwd *passwd;
if ((passwd = getpwnam([owner cStringWithEncoding:
if ((passwd = getpwnam([owner cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL)
@throw [OFChangeFileOwnerFailedException
exceptionWithClass: self
path: path
owner: owner
group: group];
uid = passwd->pw_uid;
}
if (group != nil) {
struct group *group_;
if ((group_ = getgrnam([group cStringWithEncoding:
if ((group_ = getgrnam([group cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL)
@throw [OFChangeFileOwnerFailedException
exceptionWithClass: self
path: path
owner: owner
group: group];
gid = group_->gr_gid;
}
# ifdef OF_THREADS
} @finally {
if (!of_mutex_unlock(&mutex))
@throw [OFUnlockFailedException
exceptionWithClass: self];
}
# endif
if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (chown([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
uid, gid))
@throw [OFChangeFileOwnerFailedException
exceptionWithClass: self
path: path
owner: owner
group: group];
}
|
︙ | | |
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
|
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
|
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
|
if ([self directoryExistsAtPath: destination]) {
OFString *filename = [source lastPathComponent];
destination = [OFString stringWithPath: destination, filename,
nil];
}
#ifndef _WIN32
if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
if (rename([source cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
#else
if (!MoveFile([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
if (!MoveFile([source cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
@throw [OFRenameFileFailedException
exceptionWithClass: self
sourcePath: source
destinationPath: destination];
objc_autoreleasePoolPop(pool);
}
+ (void)deleteFileAtPath: (OFString*)path
{
#ifndef _WIN32
if (unlink([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
if (unlink([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
#else
if (!DeleteFile([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
if (!DeleteFile([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
@throw [OFDeleteFileFailedException exceptionWithClass: self
path: path];
}
+ (void)deleteDirectoryAtPath: (OFString*)path
{
if (rmdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
if (rmdir([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
@throw [OFDeleteDirectoryFailedException
exceptionWithClass: self
path: path];
}
#ifndef _WIN32
+ (void)linkFileAtPath: (OFString*)source
toPath: (OFString*)destination
{
void *pool = objc_autoreleasePoolPush();
if ([self directoryExistsAtPath: destination]) {
OFString *filename = [source lastPathComponent];
destination = [OFString stringWithPath: destination, filename,
nil];
}
if (link([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
if (link([source cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
@throw [OFLinkFailedException exceptionWithClass: self
sourcePath: source
destinationPath: destination];
objc_autoreleasePoolPop(pool);
}
#endif
#if !defined(_WIN32) && !defined(_PSP)
+ (void)symlinkFileAtPath: (OFString*)source
toPath: (OFString*)destination
{
void *pool = objc_autoreleasePoolPush();
if ([self directoryExistsAtPath: destination]) {
OFString *filename = [source lastPathComponent];
destination = [OFString stringWithPath: destination, filename,
nil];
}
if (symlink([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
if (symlink([source cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
@throw [OFSymlinkFailedException
exceptionWithClass: self
sourcePath: source
destinationPath: destination];
objc_autoreleasePoolPop(pool);
}
|
︙ | | |
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
-
+
-
+
|
mode: (OFString*)mode
{
self = [super init];
@try {
int flags;
if ((flags = parse_mode([mode cStringWithEncoding:
if ((flags = parse_mode([mode cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE])) == -1)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if ((fd = open([path cStringWithEncoding:
if ((fd = open([path cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1)
@throw [OFOpenFileFailedException
exceptionWithClass: [self class]
path: path
mode: mode];
closable = YES;
|
︙ | | |
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
OFString **objects = [arguments objects];
size_t i, count = [arguments count];
char **argv;
argv = [self allocMemoryWithSize: sizeof(char*)
count: count + 2];
argv[0] = (char*)[programName cStringWithEncoding:
argv[0] = (char*)[programName cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE];
for (i = 0; i < count; i++)
argv[i + 1] = (char*)[objects[i]
cStringWithEncoding:
cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE];
argv[i + 1] = NULL;
close(readPipe[0]);
close(writePipe[1]);
dup2(writePipe[0], 0);
dup2(readPipe[1], 1);
execvp([program cStringWithEncoding:
execvp([program cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE], argv);
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
case -1:
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
|
︙ | | |
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
-
+
-
+
|
[argumentsString appendString: tmp];
if (containsSpaces)
[argumentsString appendString: @"\""];
}
argumentsCString = strdup([argumentsString
cStringWithEncoding: OF_STRING_ENCODING_NATIVE]);
cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]);
@try {
if (!CreateProcess([program cStringWithEncoding:
if (!CreateProcess([program cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE], argumentsCString, NULL,
NULL, TRUE, 0, NULL, NULL, &si, &pi))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
} @finally {
free(argumentsString);
}
|
︙ | | |
︙ | | |
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
|
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
|
-
+
|
{
char *tmp;
struct stat st;
@try {
OFFile *file;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
&st) == -1)
@throw [OFOpenFileFailedException
exceptionWithClass: [self class]
path: path
mode: @"rb"];
if (st.st_size > SIZE_MAX)
|
︙ | | |
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
|
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
|
-
+
-
+
-
+
+
+
+
+
+
+
+
+
|
[self release];
@throw e;
}
return self;
}
- (const char*)UTF8String
- (const char*)cStringUsingEncoding: (of_string_encoding_t)encoding
{
const of_unichar_t *unicodeString = [self unicodeString];
char *UTF8String;
size_t i, j = 0, length = [self length];
size_t i, j = 0, length, UTF8StringLength;
size_t UTF8StringLength = length;
OFObject *object;
if (encoding != OF_STRING_ENCODING_UTF_8)
/* TODO: Implement! */
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
unicodeString = [self unicodeString];
length = [self length];
object = [[[OFObject alloc] init] autorelease];
UTF8String = [object allocMemoryWithSize: (length * 4) + 1];
UTF8StringLength = length;
for (i = 0; i < length; i++) {
char buffer[4];
size_t len = of_string_utf8_encode(unicodeString[i], buffer);
switch (len) {
case 1:
|
︙ | | |
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
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
|
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
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
|
-
+
-
+
-
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
-
+
-
-
-
-
-
|
} @catch (OFOutOfMemoryException *e) {
/* We don't care, as we only tried to make it smaller */
}
return UTF8String;
}
- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
- (const char*)UTF8String
{
if (encoding == OF_STRING_ENCODING_UTF_8)
return [self cStringUsingEncoding: OF_STRING_ENCODING_UTF_8];
return [self UTF8String];
/* TODO: Implement! */
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (size_t)lengthOfBytesUsingEncoding: (of_string_encoding_t)encoding
{
const of_unichar_t *unicodeString;
- (size_t)UTF8StringLength
{
const of_unichar_t *unicodeString = [self unicodeString];
size_t length = [self length];
size_t i, length, UTF8StringLength = 0;
if (encoding != OF_STRING_ENCODING_UTF_8)
/* TODO: Implement! */
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
unicodeString = [self unicodeString];
length = [self length];
size_t i, UTF8StringLength = 0;
for (i = 0; i < length; i++) {
char buffer[4];
size_t len = of_string_utf8_encode(unicodeString[i], buffer);
if (len == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
UTF8StringLength += len;
}
return UTF8StringLength;
}
- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
- (size_t)UTF8StringLength
{
if (encoding == OF_STRING_ENCODING_UTF_8)
return [self lengthOfBytesUsingEncoding: OF_STRING_ENCODING_UTF_8];
return [self UTF8StringLength];
/* TODO: Implement! */
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (of_unichar_t)characterAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
|
︙ | | |
︙ | | |
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
-
+
|
char portCString[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (getaddrinfo([host cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
portCString, &hints, &res0))
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
host: host];
for (res = res0; res != NULL; res = res->ai_next) {
|
︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
-
+
|
# ifdef OF_THREADS
OFDataArray *addrlist;
addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)];
[mutex lock];
# endif
if ((he = gethostbyname([host cStringWithEncoding:
if ((he = gethostbyname([host cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[addrlist release];
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
|
︙ | | |
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
|
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
|
-
+
|
char portCString[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
if (getaddrinfo([host cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
portCString, &hints, &res))
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
host: host];
if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
|
︙ | | |
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
|
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
|
-
+
|
#else
struct hostent *he;
# ifdef OF_THREADS
[mutex lock];
# endif
if ((he = gethostbyname([host cStringWithEncoding:
if ((he = gethostbyname([host cStringUsingEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
|
︙ | | |