Permalink
Browse files

- fix errno function, used wrong one

- bump version to 0.4
  • Loading branch information...
1 parent 4f6a1a8 commit e09e81afe6e6ddd0a1e50404d620a37f58685416 @dimok789 dimok789 committed Nov 1, 2016
Showing with 21 additions and 17 deletions.
  1. +2 −2 meta/meta.xml
  2. +2 −4 src/dynamic_libs/socket_functions.c
  3. +2 −3 src/dynamic_libs/socket_functions.h
  4. +1 −1 src/main.c
  5. +14 −7 src/net.c
View
@@ -2,8 +2,8 @@
<app version="1">
<name>FTPiiU</name>
<coder>joedj</coder>
- <version>0.3</version>
- <release_date>20160331200000</release_date>
+ <version>0.4</version>
+ <release_date>20161101200000</release_date>
<short_description>An FTP server</short_description>
<long_description>ftpiiU is an FTP server for WiiU.
@@ -39,8 +39,7 @@ EXPORT_DECL(int, sendto, int s, const void *buffer, int size, int flags, const s
EXPORT_DECL(int, setsockopt, int s, int level, int optname, void *optval, int optlen);
EXPORT_DECL(char *, inet_ntoa, struct in_addr in);
EXPORT_DECL(int, inet_aton, const char *cp, struct in_addr *inp);
-EXPORT_DECL(int*, get_h_errno, void);
-EXPORT_DECL(const char*, gai_strerror, int);
+EXPORT_DECL(int, socketlasterr, void);
void InitSocketFunctionPointers(void)
{
@@ -72,8 +71,7 @@ void InitSocketFunctionPointers(void)
OS_FIND_EXPORT(nsysnet_handle, setsockopt);
OS_FIND_EXPORT(nsysnet_handle, inet_ntoa);
OS_FIND_EXPORT(nsysnet_handle, inet_aton);
- OS_FIND_EXPORT(nsysnet_handle, get_h_errno);
- OS_FIND_EXPORT(nsysnet_handle, gai_strerror);
+ OS_FIND_EXPORT(nsysnet_handle, socketlasterr);
unsigned int nn_startupid;
ACInitialize();
@@ -97,10 +97,9 @@ extern int (*setsockopt)(int s, int level, int optname, void *optval, int optlen
extern char * (*inet_ntoa)(struct in_addr in);
extern int (*inet_aton)(const char *cp, struct in_addr *inp);
-extern int *(*get_h_errno)(void);
-extern const char *(*gai_strerror)(int errno); // huh, gai o.O
+extern int (*socketlasterr)(void);
-#define geterrno() (*(get_h_errno()))
+#define geterrno() (socketlasterr())
#ifdef __cplusplus
}
View
@@ -137,7 +137,7 @@ int Menu_Main(void)
OSScreenFlipBuffersEx(0);
OSScreenFlipBuffersEx(1);
- console_printf("FTPiiU v0.3 is listening on %u.%u.%u.%u:%i", (network_gethostip() >> 24) & 0xFF, (network_gethostip() >> 16) & 0xFF, (network_gethostip() >> 8) & 0xFF, (network_gethostip() >> 0) & 0xFF, PORT);
+ console_printf("FTPiiU v0.4 is listening on %u.%u.%u.%u:%i", (network_gethostip() >> 24) & 0xFF, (network_gethostip() >> 16) & 0xFF, (network_gethostip() >> 8) & 0xFF, (network_gethostip() >> 0) & 0xFF, PORT);
MountVirtualDevices();
View
@@ -71,7 +71,8 @@ s32 network_socket(u32 domain,u32 type,u32 protocol)
int sock = socket(domain, type, protocol);
if(sock < 0)
{
- return -geterrno();
+ int err = -geterrno();
+ return (err < 0) ? err : sock;
}
return sock;
}
@@ -81,7 +82,8 @@ s32 network_bind(s32 s,struct sockaddr *name,s32 namelen)
int res = bind(s, name, namelen);
if(res < 0)
{
- return -geterrno();
+ int err = -geterrno();
+ return (err < 0) ? err : res;
}
return res;
}
@@ -91,7 +93,8 @@ s32 network_listen(s32 s,u32 backlog)
int res = listen(s, backlog);
if(res < 0)
{
- return -geterrno();
+ int err = -geterrno();
+ return (err < 0) ? err : res;
}
return res;
}
@@ -101,7 +104,8 @@ s32 network_accept(s32 s,struct sockaddr *addr,s32 *addrlen)
int res = accept(s, addr, addrlen);
if(res < 0)
{
- return -geterrno();
+ int err = -geterrno();
+ return (err < 0) ? err : res;
}
return res;
}
@@ -111,7 +115,8 @@ s32 network_connect(s32 s,struct sockaddr *addr, s32 addrlen)
int res = connect(s, addr, addrlen);
if(res < 0)
{
- return -geterrno();
+ int err = -geterrno();
+ return (err < 0) ? err : res;
}
return res;
}
@@ -121,7 +126,8 @@ s32 network_read(s32 s,void *mem,s32 len)
int res = recv(s, mem, len, 0);
if(res < 0)
{
- return -geterrno();
+ int err = -geterrno();
+ return (err < 0) ? err : res;
}
return res;
}
@@ -140,7 +146,8 @@ s32 network_write(s32 s, const void *mem,s32 len)
int ret = send(s, mem, len, 0);
if(ret < 0)
{
- transfered = -geterrno();
+ int err = -geterrno();
+ transfered = (err < 0) ? err : ret;
break;
}

0 comments on commit e09e81a

Please sign in to comment.