libc/netdb: Add hostent_s to avoid the change of hostent

and let other function call the new internal function gethostentbyname_r

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic6137d6cf03f75d6ed33e23bf04ae74b7264e682
This commit is contained in:
Xiang Xiao
2020-04-01 02:21:04 +08:00
committed by patacongo
parent 99dc8bf4e9
commit 0b662d60fc
16 changed files with 1210 additions and 872 deletions
+25
View File
@@ -43,6 +43,7 @@
#include <nuttx/config.h>
#include <netdb.h>
#include <stdio.h>
#ifdef CONFIG_LIBC_NETDB
@@ -78,6 +79,20 @@
* Public Types
****************************************************************************/
struct hostent_s
{
FAR char *h_name; /* Official name of the host. */
FAR char **h_aliases; /* A pointer to an array of pointers to the
* alternative host names, terminated by a
* null pointer. */
FAR int *h_addrtypes; /* A pointer to an array of address type. */
FAR int *h_lengths; /* A pointer to an array of the length, in bytes,
* of the address. */
FAR char **h_addr_list; /* A pointer to an array of pointers to network
* addresses (in network byte order) for the host,
* terminated by a null pointer. */
};
struct services_db_s
{
FAR const char *s_name;
@@ -105,6 +120,16 @@ EXTERN const struct services_db_s g_services_db[];
* Public Function Prototypes
****************************************************************************/
bool convert_hostent(const FAR struct hostent_s *in,
int type, FAR struct hostent *out);
ssize_t parse_hostfile(FAR FILE *stream, FAR struct hostent_s *host,
FAR char *buf, size_t buflen);
int gethostentbyname_r(FAR const char *name,
FAR struct hostent_s *host, FAR char *buf,
size_t buflen, FAR int *h_errnop);
#undef EXTERN
#ifdef __cplusplus
}