From bb0a1f0da6c71c00630fb25e62f94c79a9c71bdf Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Tue, 15 Oct 2019 21:47:13 +0800 Subject: [PATCH] add function local_host_ip_addrs_to_string --- src/local_ip_func.c | 18 ++++++++++++------ src/local_ip_func.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/local_ip_func.c b/src/local_ip_func.c index 7acf8fb..25c39fc 100644 --- a/src/local_ip_func.c +++ b/src/local_ip_func.c @@ -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