static int sa_getremote(struct sockaddr_in *u, struct sockaddr_in *k) { if (sa_get(u, k)) return -1; if (ntohs(k->sin_port) >= 512 && ntohs(k->sin_port) < 1024 && !super()) { udata.u_error = EACCES; return -1; } return 0; }
static int sa_getlocal(struct sockaddr_in *u, struct sockaddr_in *k) { if (sa_get(u, k)) return -1; if (ntohs(k->sin_port) < 1024 && !super()) { udata.u_error = EACCES; return -1; } if (k->sin_addr.s_addr != INADDR_ANY && !IN_LOOPBACK(k->sin_addr.s_addr) && k->sin_addr.s_addr != our_address) { udata.u_error = EADDRNOTAVAIL; return -1; } return 0; }
void sa_free(Array array) { if (array != NULL) { sa_assert_element_size(array); if (array->a != NULL) { for (int i = 0; i < array->n; i++) { String s = sa_get(array, i); s_free(s); } free(array->a); array->a = NULL; } array->n = 0; array->s = 0; a_free(array); } }