@@ -38,15 +38,15 @@ void idrnet_free(void* ptr) {
3838}
3939
4040// We call this from quite a few functions. Given a textual host and an int port,
41−// populates a struct addrinfo.
42−int idrnet_getaddrinfo(struct addrinfo** address_res, char* host, int port,
41+// populates a struct addrinfo.
42+int idrnet_getaddrinfo(struct addrinfo** address_res, char* host, int port,
4343 int family, int socket_type) {
4444
4545 struct addrinfo hints;
4646 // Convert port into string
4747 char str_port[8];
4848 sprintf(str_port, "%d", port);
49−
49+
5050 // Set up hints structure
5151 memset(&hints, 0, sizeof(hints)); // zero out hints
5252 hints.ai_family = family;
@@ -57,7 +57,7 @@ int idrnet_getaddrinfo(struct addrinfo** address_res, char* host, int port,
5757 if (strlen(host) == 0) {
5858 hints.ai_flags = AI_PASSIVE; // fill in IP automatically
5959 return getaddrinfo(NULL, str_port, &hints, address_res);
60− }
60+ }
6161 return getaddrinfo(host, str_port, &hints, address_res);
6262
6363}
@@ -75,7 +75,7 @@ int idrnet_bind(int sockfd, int family, int socket_type, char* host, int port) {
7575 //freeaddrinfo(address_res);
7676 //printf("Lib err: bind\n");
7777 return -1;
78− }
78+ }
7979 return 0;
8080}
8181
@@ -111,7 +111,7 @@ char* idrnet_sockaddr_ipv4(void* sockaddr) {
111111
112112int idrnet_sockaddr_ipv4_port(void* sockaddr) {
113113 struct sockaddr_in* addr = (struct sockaddr_in*) sockaddr;
114− return ((int) ntohs(addr->sin_port));
114+ return ((int) ntohs(addr->sin_port));
115115}
116116
117117void* idrnet_create_sockaddr() {
@@ -141,13 +141,13 @@ int idrnet_send_buf(int sockfd, void* data, int len) {
141141}
142142
143143void* idrnet_recv(int sockfd, int len) {
144− idrnet_recv_result* res_struct =
144+ idrnet_recv_result* res_struct =
145145 (idrnet_recv_result*) malloc(sizeof(idrnet_recv_result));
146146 char* buf = malloc(len + 1);
147147 memset(buf, 0, len + 1);
148148 int recv_res = recv(sockfd, buf, len, 0);
149149 res_struct->result = recv_res;
150−
150+
151151 if (recv_res > 0) { // Data was received
152152 buf[recv_res + 1] = 0x00; // Null-term, so Idris can interpret it
153153 }
@@ -172,7 +172,7 @@ char* idrnet_get_recv_payload(void* res_struct) {
172172}
173173
174174void idrnet_free_recv_struct(void* res_struct) {
175− idrnet_recv_result* i_res_struct =
175+ idrnet_recv_result* i_res_struct =
176176 (idrnet_recv_result*) res_struct;
177177 if (i_res_struct->payload != NULL) {
178178 free(i_res_struct->payload);
@@ -191,9 +191,9 @@ int idrnet_sendto(int sockfd, char* data, char* host, int port, int family) {
191191 int addr_res = idrnet_getaddrinfo(&remote_host, host, port, family, SOCK_DGRAM);
192192 if (addr_res == -1) {
193193 return -1;
194− }
194+ }
195195
196− int send_res = sendto(sockfd, data, strlen(data), 0,
196+ int send_res = sendto(sockfd, data, strlen(data), 0,
197197 remote_host->ai_addr, remote_host->ai_addrlen);
198198 freeaddrinfo(remote_host);
199199 return send_res;
@@ -206,11 +206,11 @@ int idrnet_sendto_buf(int sockfd, void* buf, int buf_len, char* host, int port,
206206 if (addr_res == -1) {
207207 //printf("lib err: sendto getaddrinfo \n");
208208 return -1;
209− }
209+ }
210210
211211 buf_htonl(buf, buf_len);
212212
213− int send_res = sendto(sockfd, buf, buf_len, 0,
213+ int send_res = sendto(sockfd, buf, buf_len, 0,
214214 remote_host->ai_addr, remote_host->ai_addrlen);
215215 if (send_res == -1) {
216216 perror("lib err: sendto \n");
@@ -224,13 +224,13 @@ int idrnet_sendto_buf(int sockfd, void* buf, int buf_len, char* host, int port,
224224void* idrnet_recvfrom(int sockfd, int len) {
225225/*
226226 * int recvfrom(int sockfd, void *buf, int len, unsigned int flags,
227− struct sockaddr *from, int *fromlen);
227+ struct sockaddr *from, int *fromlen);
228228*/
229229 // Allocate the required structures, and nuke them
230− struct sockaddr_storage* remote_addr =
230+ struct sockaddr_storage* remote_addr =
231231 (struct sockaddr_storage*) malloc(sizeof(struct sockaddr_storage));
232232 char* buf = (char*) malloc(len + 1);
233− idrnet_recvfrom_result* ret =
233+ idrnet_recvfrom_result* ret =
234234 (idrnet_recvfrom_result*) malloc(sizeof(idrnet_recvfrom_result));
235235 memset(remote_addr, 0, sizeof(struct sockaddr_storage));
236236 memset(buf, 0, len + 1);
@@ -240,7 +240,7 @@ void* idrnet_recvfrom(int sockfd, int len) {
240240 int recv_res = recvfrom(sockfd, buf, len, 0, (struct sockaddr*) remote_addr, &fromlen);
241241 ret->result = recv_res;
242242 // Check for failure...
243− if (recv_res == -1) {
243+ if (recv_res == -1) {
244244 free(buf);
245245 free(remote_addr);
246246 } else {
@@ -255,12 +255,11 @@ void* idrnet_recvfrom(int sockfd, int len) {
255255 return ret;
256256}
257257
258−
259258void* idrnet_recvfrom_buf(int sockfd, void* buf, int len) {
260259 // Allocate the required structures, and nuke them
261− struct sockaddr_storage* remote_addr =
260+ struct sockaddr_storage* remote_addr =
262261 (struct sockaddr_storage*) malloc(sizeof(struct sockaddr_storage));
263− idrnet_recvfrom_result* ret =
262+ idrnet_recvfrom_result* ret =
264263 (idrnet_recvfrom_result*) malloc(sizeof(idrnet_recvfrom_result));
265264 memset(remote_addr, 0, sizeof(struct sockaddr_storage));
266265 memset(ret, 0, sizeof(idrnet_recvfrom_result));
@@ -269,7 +268,7 @@ void* idrnet_recvfrom_buf(int sockfd, void* buf, int len) {
269268 int recv_res = recvfrom(sockfd, buf, len, 0, (struct sockaddr*) remote_addr, &fromlen);
270269 // Check for failure... But don't free the buffer! Not our job.
271270 ret->result = recv_res;
272− if (recv_res == -1) {
271+ if (recv_res == -1) {
273272 free(remote_addr);
274273 }
275274 // Payload will be NULL -- since it's been put into the user-specified buffer. We
@@ -298,7 +297,7 @@ void* idrnet_get_recvfrom_sockaddr(void* res_struct) {
298297int idrnet_get_recvfrom_port(void* res_struct) {
299298 idrnet_recvfrom_result* recv_struct = (idrnet_recvfrom_result*) res_struct;
300299 if (recv_struct->remote_addr != NULL) {
301− struct sockaddr_in* remote_addr_in =
300+ struct sockaddr_in* remote_addr_in =
302301 (struct sockaddr_in*) recv_struct->remote_addr;
303302 return ((int) ntohs(remote_addr_in->sin_port));
304303 }
@@ -316,5 +315,3 @@ void idrnet_free_recvfrom_struct(void* res_struct) {
316315 }
317316 }
318317}
319−
320−