Differences From Artifact [d36d90a400]:
- File
src/OFSocket.m
— part of check-in
[6235989999]
at
2022-11-05 10:01:08
on branch trunk
— Don't include <net/if.h> on MorphOS
MorphOS has the header, but it's broken and including it makes the
compiler fail. (user: js, size: 27529) [annotate] [blame] [check-ins using]
To Artifact [3facc57fe7]:
- File src/OFSocket.m — part of check-in [df7580d5e1] at 2022-11-05 19:47:32 on branch trunk — Always support IPv6 addresses with numeric scope (user: js, size: 26808) [annotate] [blame] [check-ins using] [more...]
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | #ifdef OF_NINTENDO_3DS # include <malloc.h> /* For memalign() */ #endif #include <errno.h> | < < < < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #ifdef OF_NINTENDO_3DS # include <malloc.h> /* For memalign() */ #endif #include <errno.h> #import "OFArray.h" #import "OFCharacterSet.h" #import "OFLocale.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFOnce.h" |
| ︙ | ︙ | |||
49 50 51 52 53 54 55 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFLockFailedException.h" #import "OFOutOfRangeException.h" #import "OFUnlockFailedException.h" | | < | < | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFLockFailedException.h" #import "OFOutOfRangeException.h" #import "OFUnlockFailedException.h" #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef OF_AMIGAOS # include <proto/exec.h> #endif #ifdef OF_NINTENDO_3DS |
| ︙ | ︙ | |||
97 98 99 100 101 102 103 | struct Library *SocketBase; # ifdef OF_AMIGAOS4 struct SocketIFace *ISocket = NULL; # endif # endif #endif | < < < < < < < < < < < < < | 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 |
struct Library *SocketBase;
# ifdef OF_AMIGAOS4
struct SocketIFace *ISocket = NULL;
# endif
# endif
#endif
#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
OF_CONSTRUCTOR()
{
if (OFTLSKeyNew(&OFSocketBaseKey) != 0)
@throw [OFInitializationFailedException exception];
# ifdef OF_AMIGAOS4
if (OFTLSKeyNew(&OFSocketInterfaceKey) != 0)
@throw [OFInitializationFailedException exception];
# endif
}
#endif
#if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS)
static void
init(void)
{
# if defined(OF_WINDOWS)
WSADATA wsa;
if (WSAStartup(MAKEWORD(2, 0), &wsa))
return;
# elif defined(OF_AMIGAOS)
if ((SocketBase = OpenLibrary("bsdsocket.library", 4)) == NULL)
return;
# ifdef OF_AMIGAOS4
if ((ISocket = (struct SocketIFace *)
GetInterface(SocketBase, "main", 1, NULL)) == NULL) {
|
| ︙ | ︙ | |||
467 468 469 470 471 472 473 |
addrIn6->sin6_family = AF_INET6;
#else
addrIn6->sin6_family = AF_UNSPEC;
#endif
addrIn6->sin6_port = OFToBigEndian16(port);
if ((percent = [IPv6 rangeOfString: @"%"].location) != OFNotFound) {
| < < < | | | > | | | > > > > | 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 |
addrIn6->sin6_family = AF_INET6;
#else
addrIn6->sin6_family = AF_UNSPEC;
#endif
addrIn6->sin6_port = OFToBigEndian16(port);
if ((percent = [IPv6 rangeOfString: @"%"].location) != OFNotFound) {
OFString *interface = [IPv6 substringFromIndex: percent + 1];
IPv6 = [IPv6 substringToIndex: percent];
@try {
addrIn6->sin6_scope_id = (uint32_t)[interface
unsignedLongLongValueWithBase: 10];
} @catch (OFInvalidFormatException *e) {
#if defined(HAVE_IF_NAMETOINDEX) && !defined(OF_WINDOWS)
addrIn6->sin6_scope_id = if_nametoindex([interface
cStringWithEncoding: [OFLocale encoding]]);
#endif
}
if (addrIn6->sin6_scope_id == 0)
@throw [OFInvalidArgumentException exception];
}
doubleColon = [IPv6 rangeOfString: @"::"].location;
if (doubleColon != OFNotFound) {
OFString *left = [IPv6 substringToIndex: doubleColon];
OFString *right = [IPv6 substringFromIndex: doubleColon + 2];
OFArray OF_GENERIC(OFString *) *leftComponents;
|
| ︙ | ︙ | |||
905 906 907 908 909 910 911 | (first ? @"%x" : @":%x"), (addrIn6->sin6_addr.s6_addr[i] << 8) | addrIn6->sin6_addr.s6_addr[i + 1]]; first = false; } } | < < < | < < < < > < | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 |
(first ? @"%x" : @":%x"),
(addrIn6->sin6_addr.s6_addr[i] << 8) |
addrIn6->sin6_addr.s6_addr[i + 1]];
first = false;
}
}
if (addrIn6->sin6_scope_id != 0) {
#if defined(HAVE_IF_INDEXTONAME) && !defined(OF_WINDOWS)
char interface[IF_NAMESIZE];
if (if_indextoname(addrIn6->sin6_scope_id, interface) != NULL)
[string appendFormat: @"%%%s", interface];
else
# endif
[string appendFormat: @"%%%u", addrIn6->sin6_scope_id];
}
[string makeImmutable];
return string;
}
OFString *
|
| ︙ | ︙ |