mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-01 13:10:43 +00:00
Make tests work on public repo as well
PUBLISHED_FROM=78acb18d597b6f47f31da13087fa6685f21ce445
This commit is contained in:
1 parent
3eb4eb8074
commit
7bf5144e62
145 files changed
+30660
-16
No files matched your search
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2014-2016 Cesanta Software Limited
|
||||
* All rights reserved
|
||||
*/
|
||||
|
||||
#if MG_NET_IF == MG_NET_IF_SIMPLELINK
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common/platform.h"
|
||||
|
||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) {
|
||||
int res;
|
||||
struct in_addr *in = (struct in_addr *) src;
|
||||
if (af != AF_INET) {
|
||||
errno = ENOTSUP;
|
||||
return NULL;
|
||||
}
|
||||
res = snprintf(dst, size, "%lu.%lu.%lu.%lu", SL_IPV4_BYTE(in->s_addr, 0),
|
||||
SL_IPV4_BYTE(in->s_addr, 1), SL_IPV4_BYTE(in->s_addr, 2),
|
||||
SL_IPV4_BYTE(in->s_addr, 3));
|
||||
return res > 0 ? dst : NULL;
|
||||
}
|
||||
|
||||
char *inet_ntoa(struct in_addr n) {
|
||||
static char a[16];
|
||||
return (char *) inet_ntop(AF_INET, &n, a, sizeof(a));
|
||||
}
|
||||
|
||||
int inet_pton(int af, const char *src, void *dst) {
|
||||
uint32_t a0, a1, a2, a3;
|
||||
uint8_t *db = (uint8_t *) dst;
|
||||
if (af != AF_INET) {
|
||||
errno = ENOTSUP;
|
||||
return 0;
|
||||
}
|
||||
if (sscanf(src, "%lu.%lu.%lu.%lu", &a0, &a1, &a2, &a3) != 4) {
|
||||
return 0;
|
||||
}
|
||||
*db = a3;
|
||||
*(db + 1) = a2;
|
||||
*(db + 2) = a1;
|
||||
*(db + 3) = a0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK */
|
||||
Reference in new issue
Block a user