Skip to content

Commit

Permalink
Add gethostbyaddr to header (#55)
Browse files Browse the repository at this point in the history
* Add gethostbyaddr to header

* Remove Underscores

* Remove Underscores

* Fix Underscores in body
  • Loading branch information
SonicMastr authored Jul 26, 2021
1 parent 7c70649 commit 5aff4aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions newlib/libc/sys/vita/include/netdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ struct addrinfo {
#define NI_WITHSCOPEID 0x00000020

struct hostent *gethostbyname(const char *name);
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type);
struct servent *getservbyname(const char *name, const char *proto);
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
void freeaddrinfo(struct addrinfo *res);
Expand Down
10 changes: 5 additions & 5 deletions newlib/libc/sys/vita/net/gethostbyaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

#define SCE_ERRNO_MASK 0xFF

struct hostent *gethostbyaddr(const void *__addr, socklen_t __len, int __type) {
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
static struct hostent ent;
char name[NI_MAXHOST];
static char sname[NI_MAXHOST] = "";
static char *addrlist[2] = { NULL, NULL };

if (__type != SCE_NET_AF_INET) {
if (type != SCE_NET_AF_INET) {
errno = SCE_NET_ERROR_RESOLVER_ENOSUPPORT;
return NULL;
}
Expand All @@ -24,19 +24,19 @@ struct hostent *gethostbyaddr(const void *__addr, socklen_t __len, int __type) {
return NULL;
}

int err = sceNetResolverStartAton(rid, __addr, name, sizeof(name), 0, 0, 0);
int err = sceNetResolverStartAton(rid, addr, name, sizeof(name), 0, 0, 0);
sceNetResolverDestroy(rid);
if (err < 0) {
errno = err & SCE_ERRNO_MASK;
return NULL;
}

strncpy(sname, name, NI_MAXHOST - 1);
addrlist[0] = (char *) __addr;
addrlist[0] = (char *) addr;

ent.h_name = sname;
ent.h_aliases = 0;
ent.h_addrtype = __type;
ent.h_addrtype = type;
ent.h_length = sizeof(struct SceNetInAddr);
ent.h_addr_list = addrlist;
ent.h_addr = addrlist[0];
Expand Down

0 comments on commit 5aff4aa

Please sign in to comment.