mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 01:37:19 +00:00
Formatting
This commit is contained in:
parent
88d0c2ca0f
commit
68c35feaea
@ -912,14 +912,14 @@ JANET_CORE_FN(cfun_net_setsockopt,
|
|||||||
JanetKeyword optstr = janet_getkeyword(argv, 1);
|
JanetKeyword optstr = janet_getkeyword(argv, 1);
|
||||||
|
|
||||||
const struct sockopt_type *st = sockopt_type_list;
|
const struct sockopt_type *st = sockopt_type_list;
|
||||||
while(st->name) {
|
while (st->name) {
|
||||||
if (janet_cstrcmp(optstr, st->name) == 0) {
|
if (janet_cstrcmp(optstr, st->name) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
st++;
|
st++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(st->name == NULL) {
|
if (st->name == NULL) {
|
||||||
janet_panicf("unknown socket option %q", argv[1]);
|
janet_panicf("unknown socket option %q", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,19 +932,19 @@ JANET_CORE_FN(cfun_net_setsockopt,
|
|||||||
void *optval = (void *)&val;
|
void *optval = (void *)&val;
|
||||||
socklen_t optlen = 0;
|
socklen_t optlen = 0;
|
||||||
|
|
||||||
if(st->type == JANET_BOOLEAN) {
|
if (st->type == JANET_BOOLEAN) {
|
||||||
val.v_int = janet_getboolean(argv, 2);
|
val.v_int = janet_getboolean(argv, 2);
|
||||||
optlen = sizeof(val.v_int);
|
optlen = sizeof(val.v_int);
|
||||||
} else if(st->type == JANET_NUMBER) {
|
} else if (st->type == JANET_NUMBER) {
|
||||||
val.v_int = janet_getinteger(argv, 2);
|
val.v_int = janet_getinteger(argv, 2);
|
||||||
optlen = sizeof(val.v_int);
|
optlen = sizeof(val.v_int);
|
||||||
} else if(st->optname == IP_ADD_MEMBERSHIP || st->optname == IP_DROP_MEMBERSHIP) {
|
} else if (st->optname == IP_ADD_MEMBERSHIP || st->optname == IP_DROP_MEMBERSHIP) {
|
||||||
const char *addr = janet_getcstring(argv, 2);
|
const char *addr = janet_getcstring(argv, 2);
|
||||||
memset(&val.v_mreq, 0, sizeof val.v_mreq);
|
memset(&val.v_mreq, 0, sizeof val.v_mreq);
|
||||||
val.v_mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
val.v_mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||||
val.v_mreq.imr_multiaddr.s_addr = inet_addr(addr);
|
val.v_mreq.imr_multiaddr.s_addr = inet_addr(addr);
|
||||||
optlen = sizeof(val.v_mreq);
|
optlen = sizeof(val.v_mreq);
|
||||||
} else if(st->optname == IPV6_JOIN_GROUP || st->optname == IPV6_LEAVE_GROUP) {
|
} else if (st->optname == IPV6_JOIN_GROUP || st->optname == IPV6_LEAVE_GROUP) {
|
||||||
const char *addr = janet_getcstring(argv, 2);
|
const char *addr = janet_getcstring(argv, 2);
|
||||||
memset(&val.v_mreq6, 0, sizeof val.v_mreq6);
|
memset(&val.v_mreq6, 0, sizeof val.v_mreq6);
|
||||||
val.v_mreq6.ipv6mr_interface = 0;
|
val.v_mreq6.ipv6mr_interface = 0;
|
||||||
@ -957,7 +957,7 @@ JANET_CORE_FN(cfun_net_setsockopt,
|
|||||||
janet_assert(optlen != 0, "invalid socket option value");
|
janet_assert(optlen != 0, "invalid socket option value");
|
||||||
|
|
||||||
int r = setsockopt((JSock) stream->handle, st->level, st->optname, optval, optlen);
|
int r = setsockopt((JSock) stream->handle, st->level, st->optname, optval, optlen);
|
||||||
if(r == -1) {
|
if (r == -1) {
|
||||||
janet_panicf("setsockopt(%q): %s", argv[1], strerror(errno));
|
janet_panicf("setsockopt(%q): %s", argv[1], strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user