︙ | | |
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
-
+
-
+
|
@try {
const char *cString;
size_t i;
itemSize = 1;
count = [string
lengthOfBytesUsingEncoding: OF_STRING_ENCODING_ASCII];
cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII];
if (count & 1)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
count >>= 1;
cString = [string
cStringUsingEncoding: OF_STRING_ENCODING_ASCII];
cStringWithEncoding: 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;
|
︙ | | |
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
-
+
-
+
|
- initWithBase64EncodedString: (OFString*)string
{
self = [super init];
@try {
itemSize = 1;
if (!of_base64_decode(self, [string cStringUsingEncoding:
if (!of_base64_decode(self, [string cStringWithEncoding:
OF_STRING_ENCODING_ASCII], [string
lengthOfBytesUsingEncoding: OF_STRING_ENCODING_ASCII])) {
cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) {
Class c = [self class];
[self release];
@throw [OFInvalidFormatException exceptionWithClass: c];
}
} @catch (id e) {
[self release];
@throw e;
|
︙ | | |
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
-
-
+
+
|
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
stringValue = [element stringValue];
if (!of_base64_decode(self, [stringValue
cStringUsingEncoding: OF_STRING_ENCODING_ASCII],
[stringValue lengthOfBytesUsingEncoding:
cStringWithEncoding: OF_STRING_ENCODING_ASCII],
[stringValue cStringLengthWithEncoding:
OF_STRING_ENCODING_ASCII]))
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
|
︙ | | |
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
}
+ (BOOL)fileExistsAtPath: (OFString*)path
{
#ifndef _WIN32
struct stat s;
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
return NO;
#else
struct _stat s;
if (_wstat([path UTF16String], &s) == -1)
return NO;
#endif
if (S_ISREG(s.st_mode))
return YES;
return NO;
}
+ (BOOL)directoryExistsAtPath: (OFString*)path
{
#ifndef _WIN32
struct stat s;
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
return NO;
#else
struct _stat s;
if (_wstat([path UTF16String], &s) == -1)
return NO;
#endif
if (S_ISDIR(s.st_mode))
return YES;
return NO;
}
+ (void)createDirectoryAtPath: (OFString*)path
{
#ifndef _WIN32
if (mkdir([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
DIR_MODE))
#else
if (_wmkdir([path UTF16String]))
#endif
@throw [OFCreateDirectoryFailedException
exceptionWithClass: self
path: path];
|
︙ | | |
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
-
+
|
{
OFMutableArray *files = [OFMutableArray array];
#ifndef _WIN32
DIR *dir;
struct dirent *dirent;
if ((dir = opendir([path cStringUsingEncoding:
if ((dir = opendir([path cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL)
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
@try {
while ((dirent = readdir(dir)) != NULL) {
|
︙ | | |
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
|
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
|
-
+
-
+
|
return files;
}
+ (void)changeToDirectoryAtPath: (OFString*)path
{
#ifndef _WIN32
if (chdir([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
if (_wchdir([path UTF16String]))
#endif
@throw [OFChangeDirectoryFailedException
exceptionWithClass: self
path: path];
}
#ifndef _PSP
+ (void)changeModeOfFileAtPath: (OFString*)path
mode: (mode_t)mode
{
# ifndef _WIN32
if (chmod([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE], mode))
if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode))
@throw [OFChangeFileModeFailedException
exceptionWithClass: self
path: path
mode: mode];
# else
DWORD attributes = GetFileAttributesW([path UTF16String]);
|
︙ | | |
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
|
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
|
-
+
-
+
|
#endif
+ (off_t)sizeOfFileAtPath: (OFString*)path
{
#ifndef _WIN32
struct stat s;
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
#else
struct _stat s;
if (_wstat([path UTF16String], &s) == -1)
#endif
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
return s.st_size;
}
+ (OFDate*)modificationDateOfFileAtPath: (OFString*)path
{
#ifndef _WIN32
struct stat s;
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
#else
struct _stat s;
if (_wstat([path UTF16String], &s) == -1)
#endif
/* FIXME: Maybe use another exception? */
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
@throw [OFLockFailedException exceptionWithClass: self];
@try {
# endif
if (owner != nil) {
struct passwd *passwd;
if ((passwd = getpwnam([owner cStringUsingEncoding:
if ((passwd = getpwnam([owner cStringWithEncoding:
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 cStringUsingEncoding:
if ((group_ = getgrnam([group cStringWithEncoding:
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 cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
uid, gid))
@throw [OFChangeFileOwnerFailedException
exceptionWithClass: self
path: path
owner: owner
group: group];
}
|
︙ | | |
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
|
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
|
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
|
if ([self directoryExistsAtPath: destination]) {
OFString *filename = [source lastPathComponent];
destination = [OFString stringWithPath: destination, filename,
nil];
}
#ifndef _WIN32
if (rename([source cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
if (!MoveFileW([source UTF16String], [destination UTF16String]))
#endif
@throw [OFRenameFileFailedException
exceptionWithClass: self
sourcePath: source
destinationPath: destination];
objc_autoreleasePoolPop(pool);
}
+ (void)deleteFileAtPath: (OFString*)path
{
#ifndef _WIN32
if (unlink([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
if (unlink([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
if (_wunlink([path UTF16String]))
#endif
@throw [OFDeleteFileFailedException exceptionWithClass: self
path: path];
}
+ (void)deleteDirectoryAtPath: (OFString*)path
{
#ifndef _WIN32
if (rmdir([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]))
if (rmdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
if (_wrmdir([path UTF16String]))
#endif
@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 cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
if (link([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringWithEncoding: 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 cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringUsingEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
if (symlink([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
[destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
@throw [OFSymlinkFailedException
exceptionWithClass: self
sourcePath: source
destinationPath: destination];
objc_autoreleasePoolPop(pool);
}
|
︙ | | |
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
-
+
|
if ((flags = parse_mode([mode UTF8String])) == -1)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
#ifndef _WIN32
if ((fd = open([path cStringUsingEncoding:
if ((fd = open([path cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1)
#else
if ((fd = _wopen([path UTF16String], flags,
DEFAULT_MODE)) == -1)
#endif
@throw [OFOpenFileFailedException
exceptionWithClass: [self class]
|
︙ | | |
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
OFString **objects = [arguments objects];
size_t i, count = [arguments count];
char **argv;
argv = [self allocMemoryWithSize: sizeof(char*)
count: count + 2];
argv[0] = (char*)[programName cStringUsingEncoding:
argv[0] = (char*)[programName cStringWithEncoding:
OF_STRING_ENCODING_NATIVE];
for (i = 0; i < count; i++)
argv[i + 1] = (char*)[objects[i]
cStringUsingEncoding:
cStringWithEncoding:
OF_STRING_ENCODING_NATIVE];
argv[i + 1] = NULL;
if (environment != nil) {
#ifdef __MACH__
*_NSGetEnviron() = [self
OF_environmentForDictionary: environment];
#else
environ = [self
OF_environmentForDictionary: environment];
#endif
}
close(readPipe[0]);
close(writePipe[1]);
dup2(writePipe[0], 0);
dup2(readPipe[1], 1);
execvp([program cStringUsingEncoding:
execvp([program cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], argv);
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
case -1:
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
OFString *key;
OFString *object;
size_t keyLen, objectLen;
key = [keyEnumerator nextObject];
object = [objectEnumerator nextObject];
keyLen = [key lengthOfBytesUsingEncoding:
keyLen = [key cStringLengthWithEncoding:
OF_STRING_ENCODING_NATIVE];
objectLen = [object lengthOfBytesUsingEncoding:
objectLen = [object cStringLengthWithEncoding:
OF_STRING_ENCODING_NATIVE];
envp[i] = [self allocMemoryWithSize: keyLen + objectLen + 2];
memcpy(envp[i], [key cStringUsingEncoding:
memcpy(envp[i], [key cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], keyLen);
envp[i][keyLen] = '=';
memcpy(envp[i] + keyLen + 1, [object cStringUsingEncoding:
memcpy(envp[i] + keyLen + 1, [object cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], objectLen);
envp[i][keyLen + objectLen + 1] = '\0';
}
envp[i] = NULL;
return envp;
|
︙ | | |
︙ | | |
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
|
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
|
-
-
+
+
|
encoding: (of_string_encoding_t)encoding
{
const char *delimiterCString;
size_t i, j, delimiterLength, pageSize, bufferLength, retLength;
char *retCString, *buffer, *newCache;
OFString *ret;
delimiterCString = [delimiter cStringUsingEncoding: encoding];
delimiterLength = [delimiter lengthOfBytesUsingEncoding: encoding];
delimiterCString = [delimiter cStringWithEncoding: encoding];
delimiterLength = [delimiter cStringLengthWithEncoding: encoding];
j = 0;
if (delimiterLength == 0)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
return [self writeString: string
usingEncoding: OF_STRING_ENCODING_UTF_8];
}
- (size_t)writeString: (OFString*)string
usingEncoding: (of_string_encoding_t)encoding
{
size_t length = [string lengthOfBytesUsingEncoding: encoding];
size_t length = [string cStringLengthWithEncoding: encoding];
[self writeBuffer: [string cStringUsingEncoding: encoding]
[self writeBuffer: [string cStringWithEncoding: encoding]
length: length];
return length;
}
- (size_t)writeLine: (OFString*)string
{
return [self writeLine: string
usingEncoding: OF_STRING_ENCODING_UTF_8];
}
- (size_t)writeLine: (OFString*)string
usingEncoding: (of_string_encoding_t)encoding
{
size_t stringLength = [string lengthOfBytesUsingEncoding: encoding];
size_t stringLength = [string cStringLengthWithEncoding: encoding];
char *buffer;
buffer = [self allocMemoryWithSize: stringLength + 1];
@try {
memcpy(buffer, [string cStringUsingEncoding: encoding],
memcpy(buffer, [string cStringWithEncoding: encoding],
stringLength);
buffer[stringLength] = '\n';
[self writeBuffer: buffer
length: stringLength + 1];
} @finally {
[self freeMemory: buffer];
|
︙ | | |
︙ | | |
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
|
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
|
-
+
|
{
char *tmp;
struct stat st;
@try {
OFFile *file;
if (stat([path cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&st) == -1)
@throw [OFOpenFileFailedException
exceptionWithClass: [self class]
path: path
mode: @"rb"];
if (st.st_size > SIZE_MAX)
|
︙ | | |
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
|
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
|
-
+
|
[self release];
@throw e;
}
return self;
}
- (const char*)cStringUsingEncoding: (of_string_encoding_t)encoding
- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
const of_unichar_t *characters = [self characters];
size_t i, length = [self length];
OFObject *object = [[[OFObject alloc] init] autorelease];
char *cString;
switch (encoding) {
|
︙ | | |
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
|
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
|
-
+
-
+
|
}
return cString;
}
- (const char*)UTF8String
{
return [self cStringUsingEncoding: OF_STRING_ENCODING_UTF_8];
return [self cStringWithEncoding: OF_STRING_ENCODING_UTF_8];
}
- (size_t)length
{
[self doesNotRecognizeSelector: _cmd];
abort();
}
- (size_t)lengthOfBytesUsingEncoding: (of_string_encoding_t)encoding
- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
{
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:;
const of_unichar_t *characters;
size_t i, length, UTF8StringLength = 0;
characters = [self characters];
|
︙ | | |
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
|
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
|
-
+
|
exceptionWithClass: [self class]
selector: _cmd];
}
}
- (size_t)UTF8StringLength
{
return [self lengthOfBytesUsingEncoding: OF_STRING_ENCODING_UTF_8];
return [self cStringLengthWithEncoding: OF_STRING_ENCODING_UTF_8];
}
- (of_unichar_t)characterAtIndex: (size_t)index
{
[self doesNotRecognizeSelector: _cmd];
abort();
}
|
︙ | | |
︙ | | |
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
-
+
|
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (getaddrinfo([host cStringWithEncoding: 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) {
|
︙ | | |
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
-
+
|
# ifdef OF_THREADS
OFDataArray *addrlist;
addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)];
[mutex lock];
# endif
if ((he = gethostbyname([host cStringUsingEncoding:
if ((he = gethostbyname([host cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[addrlist release];
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
|
︙ | | |
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
-
+
|
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG | AI_PASSIVE;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
if (getaddrinfo([host cStringWithEncoding: 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)
|
︙ | | |
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
|
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
|
-
+
|
#else
struct hostent *he;
# ifdef OF_THREADS
[mutex lock];
# endif
if ((he = gethostbyname([host cStringUsingEncoding:
if ((he = gethostbyname([host cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
|
︙ | | |