From 109adc679e7fbaace7dbf2445661ac22f6b3f539 Mon Sep 17 00:00:00 2001 From: wcc0 <917033401@qq.com> Date: Thu, 29 Jul 2021 17:49:04 +0800 Subject: [PATCH] fix: add misc fix porting Change-Id: Ic1bd1cdcc5db6bc368c7a0860cd9565a21f7f21c --- .../liteos_a/user/src/network/gethostbyname.c | 11 --- .../user/src/network/gethostbyname2_r.c | 81 ------------------- .../liteos_a/user/src/unistd/gethostname.c | 14 ---- 3 files changed, 106 deletions(-) delete mode 100644 porting/liteos_a/user/src/network/gethostbyname.c delete mode 100644 porting/liteos_a/user/src/network/gethostbyname2_r.c delete mode 100644 porting/liteos_a/user/src/unistd/gethostname.c diff --git a/porting/liteos_a/user/src/network/gethostbyname.c b/porting/liteos_a/user/src/network/gethostbyname.c deleted file mode 100644 index bfedf52a..00000000 --- a/porting/liteos_a/user/src/network/gethostbyname.c +++ /dev/null @@ -1,11 +0,0 @@ -#define _GNU_SOURCE - -#include -#include -#include -#include - -struct hostent *gethostbyname(const char *name) -{ - return gethostbyname2(name, AF_INET); -} diff --git a/porting/liteos_a/user/src/network/gethostbyname2_r.c b/porting/liteos_a/user/src/network/gethostbyname2_r.c deleted file mode 100644 index d091d96a..00000000 --- a/porting/liteos_a/user/src/network/gethostbyname2_r.c +++ /dev/null @@ -1,81 +0,0 @@ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include "lookup.h" - -int gethostbyname2_r(const char *name, int af, - struct hostent *h, char *buf, size_t buflen, - struct hostent **res, int *err) -{ - struct address addrs[MAXADDRS]; - char canon[256]; - int i, cnt; - size_t align, need; - - *res = 0; - - cnt = __lookup_name(addrs, canon, name, af, AI_CANONNAME); - if (cnt<0) switch (cnt) { - case EAI_NONAME: - *err = HOST_NOT_FOUND; - return ENOENT; - case EAI_AGAIN: - *err = TRY_AGAIN; - return EAGAIN; - default: - case EAI_FAIL: - *err = NO_RECOVERY; - return EBADMSG; - case EAI_MEMORY: - case EAI_SYSTEM: - *err = NO_RECOVERY; - return errno; - } - - h->h_addrtype = af; - h->h_length = af==AF_INET6 ? 16 : 4; - - /* Align buffer */ - align = -(uintptr_t)buf & sizeof(char *)-1; - - need = 4*sizeof(char *); - need += (cnt + 1) * (sizeof(char *) + h->h_length); - need += strlen(name)+1; - need += strlen(canon)+1; - need += align; - - if (need > buflen) return ERANGE; - - buf += align; - h->h_aliases = (void *)buf; - buf += 3*sizeof(char *); - h->h_addr_list = (void *)buf; - buf += (cnt+1)*sizeof(char *); - - for (i=0; ih_addr_list[i] = (void *)buf; - buf += h->h_length; - memcpy(h->h_addr_list[i], addrs[i].addr, h->h_length); - } - h->h_addr_list[i] = 0; - - h->h_name = h->h_aliases[0] = buf; - strcpy(h->h_name, canon); - buf += strlen(h->h_name)+1; - - if (strcmp(h->h_name, name)) { - h->h_aliases[1] = buf; - strcpy(h->h_aliases[1], name); - buf += strlen(h->h_aliases[1])+1; - } else h->h_aliases[1] = 0; - - h->h_aliases[2] = 0; - - *res = h; - return 0; -} diff --git a/porting/liteos_a/user/src/unistd/gethostname.c b/porting/liteos_a/user/src/unistd/gethostname.c deleted file mode 100644 index 7770a17b..00000000 --- a/porting/liteos_a/user/src/unistd/gethostname.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -int gethostname(char *name, size_t len) -{ - size_t i; - struct utsname uts; - - if (uname(&uts)) return -1; - if (len > sizeof uts.nodename) len = sizeof uts.nodename; - for (i=0; i