add function local_host_ip_addrs_to_string

pull/37/head V1.0.41
YuQing 2019-10-15 21:47:13 +08:00
parent 325946a3be
commit bb0a1f0da6
2 changed files with 13 additions and 6 deletions

View File

@ -56,22 +56,28 @@ int insert_into_local_host_ip(const char *client_ip)
return 1;
}
void log_local_host_ip_addrs()
const char *local_host_ip_addrs_to_string(char *buff, const int size)
{
char *p;
char *pEnd;
char buff[512];
int len;
len = sprintf(buff, "local_host_ip_count: %d,", g_local_host_ip_count);
pEnd = g_local_host_ip_addrs + \
len = snprintf(buff, size, "local_host_ip_count: %d,",
g_local_host_ip_count);
pEnd = g_local_host_ip_addrs +
IP_ADDRESS_SIZE * g_local_host_ip_count;
for (p=g_local_host_ip_addrs; p<pEnd; p+=IP_ADDRESS_SIZE)
{
len += sprintf(buff + len, " %s", p);
len += snprintf(buff + len, size - len, " %s", p);
}
logInfo("%s", buff);
return buff;
}
void log_local_host_ip_addrs()
{
char buff[512];
logInfo("%s", local_host_ip_addrs_to_string(buff, sizeof(buff)));
}
void load_local_host_ip_addrs()

View File

@ -42,6 +42,7 @@ const char *get_first_local_private_ip();
int insert_into_local_host_ip(const char *client_ip);
void log_local_host_ip_addrs();
void print_local_host_ip_addrs();
const char *local_host_ip_addrs_to_string(char *buff, const int size);
#ifdef __cplusplus
}