mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Genera refactor and cleanup.
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
int PrintNetworkAddresses()
|
||||
{
|
||||
int ret;
|
||||
struct ifaddrs* ifa;
|
||||
struct ifaddrs* ifa_start;
|
||||
struct ifaddrs *ifa;
|
||||
struct ifaddrs *ifa_start;
|
||||
char ipv4_address[INET_ADDRSTRLEN];
|
||||
|
||||
ret = getifaddrs(&ifa);
|
||||
@@ -43,7 +43,7 @@ int PrintNetworkAddresses()
|
||||
{
|
||||
if(ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET)
|
||||
{
|
||||
inet_ntop(AF_INET, &((struct sockaddr_in*)ifa->ifa_addr)->sin_addr, ipv4_address, INET_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr, ipv4_address, INET_ADDRSTRLEN);
|
||||
printf("%s port %d\n", ipv4_address, AARUREMOTE_PORT);
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ int PrintNetworkAddresses()
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
|
||||
char *PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
|
||||
|
||||
void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
void *NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
{
|
||||
NetworkContext* ctx;
|
||||
NetworkContext *ctx;
|
||||
|
||||
ctx = malloc(sizeof(NetworkContext));
|
||||
|
||||
@@ -76,28 +76,28 @@ void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int32_t NetBind(void* net_ctx, struct sockaddr* addr, socklen_t addrlen)
|
||||
int32_t NetBind(void *net_ctx, struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return bind(ctx->fd, addr, addrlen);
|
||||
}
|
||||
|
||||
int32_t NetListen(void* net_ctx, uint32_t backlog)
|
||||
int32_t NetListen(void *net_ctx, uint32_t backlog)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return listen(ctx->fd, backlog);
|
||||
}
|
||||
|
||||
void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
|
||||
void *NetAccept(void *net_ctx, struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext* cli_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
NetworkContext *cli_ctx;
|
||||
|
||||
if(!ctx) return NULL;
|
||||
|
||||
@@ -116,9 +116,9 @@ void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
|
||||
return cli_ctx;
|
||||
}
|
||||
|
||||
int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
|
||||
int32_t NetRecv(void *net_ctx, void *buf, int32_t len, uint32_t flags)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -139,19 +139,19 @@ int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
|
||||
return got_total;
|
||||
}
|
||||
|
||||
int32_t NetWrite(void* net_ctx, const void* buf, int32_t size)
|
||||
int32_t NetWrite(void *net_ctx, const void *buf, int32_t size)
|
||||
{
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
return write(ctx->fd, buf, size);
|
||||
}
|
||||
|
||||
int32_t NetClose(void* net_ctx)
|
||||
int32_t NetClose(void *net_ctx)
|
||||
{
|
||||
int ret;
|
||||
NetworkContext* ctx = net_ctx;
|
||||
NetworkContext *ctx = net_ctx;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user