From 9c1e447dbe876bbf4466022a1fc972cf616d8c40 Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Fri, 3 Mar 2023 09:21:13 -0600 Subject: [PATCH] Replaced exit codes with values that aren't taken by errno --- easysock.c | 6 +++--- easysock.h | 6 +++--- main.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/easysock.c b/easysock.c index 2336e9d..b167cf5 100644 --- a/easysock.c +++ b/easysock.c @@ -44,7 +44,7 @@ void create_addr(int network, char* address, int port,struct sockaddr* dest) { return; } else { - exit(2); + exit(202); } } @@ -61,7 +61,7 @@ int create_local (int network, char transport, char* address, int port,struct so } else if (network == 6) { addrlen = sizeof(struct sockaddr_in6); } else { - exit(7); + exit(207); } /* The value of addrlen should be the size of the 'sockaddr'. @@ -89,7 +89,7 @@ int create_remote (int network,char transport,char* address,int port,struct sock } else if (network == 6) { addrlen = sizeof(struct sockaddr_in6); } else { - exit(7); + exit(207); } /* The value of addrlen should be the size of the 'sockaddr'. diff --git a/easysock.h b/easysock.h index b169032..105b19e 100644 --- a/easysock.h +++ b/easysock.h @@ -26,7 +26,7 @@ int create_socket(int network, char transport); port is self-explanatory; and dest is a pointer to the sockaddr struct that will be filled in. -The function exits with error code 2 if the network parameter contained neither '4' +The function exits with error code 202 if the network parameter contained neither '4' nor '6'. */ void create_addr(int network, char* address, int port,struct sockaddr* dest); @@ -37,7 +37,7 @@ void create_addr(int network, char* address, int port,struct sockaddr* dest); _binds_ the addresses. It is used for local sockets (server sockets). Parameters are same as above. -It prints the error returned by 'bind' if something went wrong, and exits with error code '3'.*/ +It prints the error returned by 'bind' if something went wrong, and exits with errno.*/ int create_local (int network, char transport, char* address, int port,struct sockaddr* addr_struct); @@ -46,7 +46,7 @@ int create_local (int network, char transport, char* address, int port,struct so requested address. It is used for remote sockets (client sockets). The paramters are same as above. This function needs an empty 'sockaddr *' structure passed to it, which it will fill. -It prints the error returned by 'connect' if something went wrong, and exits with error code '3'.*/ +It prints the error returned by 'connect' if something went wrong, and exits with errno.*/ int create_remote (int network,char transport,char* address,int port,struct sockaddr* remote_addr_struct); diff --git a/main.c b/main.c index b211091..9b10519 100644 --- a/main.c +++ b/main.c @@ -62,7 +62,7 @@ int main(int argc,char* argv[]) { if (argc != 5) { print_prog_info(); - exit(30); + exit(230); } @@ -76,7 +76,7 @@ int main(int argc,char* argv[]) { printf("Using %d for local\nUsing %d for remote\n",preferred_local_network,preferred_remote_network); if ((preferred_local_network == -1) || (preferred_remote_network == -1)) { - exit(7); + exit(207); } char preferred_transport = 'T'; @@ -88,7 +88,7 @@ int main(int argc,char* argv[]) { } else if (check_ip_ver(local_addr) == 6) { addrlen = sizeof(struct sockaddr_in6); } else { - exit(7); + exit(207); } listen(server_sock,50); /* Arbitrary number, change later */