Skip to content

Commit

Permalink
- fix errno function, used wrong one
Browse files Browse the repository at this point in the history
- bump version to 0.4
  • Loading branch information
dimok789 committed Nov 1, 2016
1 parent 4f6a1a8 commit e09e81a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions meta/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 2 additions & 4 deletions src/dynamic_libs/socket_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions src/dynamic_libs/socket_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
21 changes: 14 additions & 7 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand Down

0 comments on commit e09e81a

Please sign in to comment.