diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
commit | f7d30133221896638f7bf4f66c504255c4b14f48 (patch) | |
tree | 5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/pr/tests/sockopt.c | |
parent | 26b297510a11758727438df4669357a2a2bc42ce (diff) | |
download | UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.lz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.xz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.zip |
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/pr/tests/sockopt.c')
-rw-r--r-- | nsprpub/pr/tests/sockopt.c | 111 |
1 files changed, 59 insertions, 52 deletions
diff --git a/nsprpub/pr/tests/sockopt.c b/nsprpub/pr/tests/sockopt.c index b9b2f6dd3..540a19b90 100644 --- a/nsprpub/pr/tests/sockopt.c +++ b/nsprpub/pr/tests/sockopt.c @@ -20,7 +20,9 @@ static PRBool failed = PR_FALSE; static void Failed(const char *msg1, const char *msg2) { - if (NULL != msg1) PR_fprintf(err, "%s ", msg1); + if (NULL != msg1) { + PR_fprintf(err, "%s ", msg1); + } PL_FPrintError(err, msg2); failed = PR_TRUE; } /* Failed */ @@ -65,8 +67,12 @@ int main(int argc, char **argv) err = PR_GetSpecialFD(PR_StandardError); PR_STDIO_INIT(); - if (NULL == udp) Failed("PR_NewUDPSocket()", NULL); - else if (NULL == tcp) Failed("PR_NewTCPSocket()", NULL); + if (NULL == udp) { + Failed("PR_NewUDPSocket()", NULL); + } + else if (NULL == tcp) { + Failed("PR_NewTCPSocket()", NULL); + } else { PRSockOption option; @@ -74,9 +80,13 @@ int main(int argc, char **argv) PRNetAddr addr; rv = PR_InitializeNetAddr(PR_IpAddrAny, 0, &addr); - if (PR_FAILURE == rv) Failed("PR_InitializeNetAddr()", NULL); + if (PR_FAILURE == rv) { + Failed("PR_InitializeNetAddr()", NULL); + } rv = PR_Bind(udp, &addr); - if (PR_FAILURE == rv) Failed("PR_Bind()", NULL); + if (PR_FAILURE == rv) { + Failed("PR_Bind()", NULL); + } for(option = PR_SockOpt_Linger; option < PR_SockOpt_Last; Incr(&option)) { PRSocketOptionData data; @@ -86,55 +96,49 @@ int main(int argc, char **argv) { case PR_SockOpt_Nonblocking: data.value.non_blocking = PR_TRUE; - break; -#ifndef SYMBIAN + break; case PR_SockOpt_Linger: data.value.linger.polarity = PR_TRUE; - data.value.linger.linger = PR_SecondsToInterval(2); - break; -#endif + data.value.linger.linger = PR_SecondsToInterval(2); + break; case PR_SockOpt_Reuseaddr: - data.value.reuse_addr = PR_TRUE; - break; - case PR_SockOpt_Keepalive: - data.value.keep_alive = PR_TRUE; - break; + data.value.reuse_addr = PR_TRUE; + break; + case PR_SockOpt_Keepalive: + data.value.keep_alive = PR_TRUE; + break; case PR_SockOpt_RecvBufferSize: - data.value.recv_buffer_size = segment; - break; - case PR_SockOpt_SendBufferSize: - data.value.send_buffer_size = segment; - break; -#ifndef SYMBIAN + data.value.recv_buffer_size = segment; + break; + case PR_SockOpt_SendBufferSize: + data.value.send_buffer_size = segment; + break; case PR_SockOpt_IpTimeToLive: - data.value.ip_ttl = 64; - break; + data.value.ip_ttl = 64; + break; case PR_SockOpt_IpTypeOfService: - data.value.tos = 0; - break; + data.value.tos = 0; + break; case PR_SockOpt_McastTimeToLive: - fd = udp; - data.value.mcast_ttl = 4; - break; + fd = udp; + data.value.mcast_ttl = 4; + break; case PR_SockOpt_McastLoopback: - fd = udp; - data.value.mcast_loopback = PR_TRUE; - break; -#endif + fd = udp; + data.value.mcast_loopback = PR_TRUE; + break; case PR_SockOpt_NoDelay: - data.value.no_delay = PR_TRUE; - break; + data.value.no_delay = PR_TRUE; + break; #ifndef WIN32 case PR_SockOpt_MaxSegment: - data.value.max_segment = segment; - break; + data.value.max_segment = segment; + break; #endif -#ifndef SYMBIAN case PR_SockOpt_Broadcast: - fd = udp; - data.value.broadcast = PR_TRUE; - break; -#endif + fd = udp; + data.value.broadcast = PR_TRUE; + break; #ifdef SO_REUSEPORT case PR_SockOpt_Reuseport: data.value.reuse_port = PR_TRUE; @@ -143,22 +147,25 @@ int main(int argc, char **argv) default: continue; } - /* - * TCP_MAXSEG can only be read, not set - */ + /* + * TCP_MAXSEG can only be read, not set + */ if (option != PR_SockOpt_MaxSegment) { #ifdef WIN32 - if (option != PR_SockOpt_McastLoopback) + if (option != PR_SockOpt_McastLoopback) #endif - { - rv = PR_SetSocketOption(fd, &data); - if (PR_FAILURE == rv) - Failed("PR_SetSocketOption()", tag[option]); - } - } + { + rv = PR_SetSocketOption(fd, &data); + if (PR_FAILURE == rv) { + Failed("PR_SetSocketOption()", tag[option]); + } + } + } rv = PR_GetSocketOption(fd, &data); - if (PR_FAILURE == rv) Failed("PR_GetSocketOption()", tag[option]); + if (PR_FAILURE == rv) { + Failed("PR_GetSocketOption()", tag[option]); + } } PR_Close(udp); PR_Close(tcp); |