Differences From Artifact [fb89efec65]:
- File src/socket.m — part of check-in [6a6f7fb146] at 2020-05-02 15:25:54 on branch trunk — OFSPXSocket: Make async connect work (user: js, size: 20756) [annotate] [blame] [check-ins using] [more...]
To Artifact [0757bca949]:
- File
src/socket.m
— part of check-in
[b6ee372b98]
at
2020-08-11 19:45:36
on branch trunk
— OFString: Rework number parsing API
This solves the old signed vs. unsigned problem and allows for more
bases than just 8, 10 and 16, as well as auto-detection of the base (if
base is 0). (user: js, size: 20789) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
372 373 374 375 376 377 378 | if (components.count != 4) @throw [OFInvalidFormatException exception]; addr = 0; for (OFString *component in components) { | | | | | | | 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 | if (components.count != 4) @throw [OFInvalidFormatException exception]; addr = 0; for (OFString *component in components) { unsigned long long number; if (component.length == 0) @throw [OFInvalidFormatException exception]; if ([component indexOfCharacterFromSet: whitespaceCharacterSet] != OF_NOT_FOUND) @throw [OFInvalidFormatException exception]; number = component.unsignedLongLongValue; if (number > UINT8_MAX) @throw [OFInvalidFormatException exception]; addr = (addr << 8) | (number & 0xFF); } addrIn->sin_addr.s_addr = OF_BSWAP32_IF_LE(addr); objc_autoreleasePoolPop(pool); return ret; } static uint16_t parseIPv6Component(OFString *component) { unsigned long long number; if ([component indexOfCharacterFromSet: [OFCharacterSet whitespaceCharacterSet]] != OF_NOT_FOUND) @throw [OFInvalidFormatException exception]; number = [component unsignedLongLongValueWithBase: 16]; if (number > UINT16_MAX) @throw [OFInvalidFormatException exception]; return (uint16_t)number; } |
︙ | ︙ |