diff options
-rw-r--r-- | include/zbxtypes.h | 8 | ||||
-rw-r--r-- | src/libs/zbxlog/log.c | 2 | ||||
-rw-r--r-- | src/libs/zbxwin32/service.c | 16 | ||||
-rw-r--r-- | src/zabbix_agent/cpustat.c | 2 | ||||
-rw-r--r-- | src/zabbix_agent/eventlog.c | 10 |
5 files changed, 16 insertions, 22 deletions
diff --git a/include/zbxtypes.h b/include/zbxtypes.h index 77f9933aae7..7c7b5c3dda4 100644 --- a/include/zbxtypes.h +++ b/include/zbxtypes.h @@ -26,17 +26,11 @@ #define ZBX_PTR_SIZE sizeof(void *) #if defined(_WINDOWS) +# include <strsafe.h> # define zbx_stat(path, buf) __zbx_stat(path, buf) # define zbx_open(pathname, flags) __zbx_open(pathname, flags | O_BINARY) -# include <strsafe.h> -# define zbx_wsnprintf StringCchPrintf -# define zbx_strlen wcslen -# define zbx_strchr wcschr -# define zbx_strstr wcsstr -# define zbx_fullpath _wfullpath - # ifndef __UINT64_C # define __UINT64_C(x) x # endif diff --git a/src/libs/zbxlog/log.c b/src/libs/zbxlog/log.c index 1810d5f5228..6bda514fb17 100644 --- a/src/libs/zbxlog/log.c +++ b/src/libs/zbxlog/log.c @@ -355,7 +355,7 @@ void __zbx_zabbix_log(int level, const char *fmt, ...) break; } - zbx_wsnprintf(thread_id, ARRSIZE(thread_id), TEXT("[%li]: "), zbx_get_thread_id()); + StringCchPrintf(thread_id, ARRSIZE(thread_id), TEXT("[%li]: "), zbx_get_thread_id()); strings[0] = thread_id; strings[1] = zbx_utf8_to_unicode(message); diff --git a/src/libs/zbxwin32/service.c b/src/libs/zbxwin32/service.c index 72f91541f79..30dfba1de8b 100644 --- a/src/libs/zbxwin32/service.c +++ b/src/libs/zbxwin32/service.c @@ -170,7 +170,7 @@ static void svc_get_fullpath(const char *path, wchar_t *fullpath, size_t max_ful wchar_t *wpath; wpath = zbx_acp_to_unicode(path); - zbx_fullpath(fullpath, wpath, max_fullpath); + wcschr(fullpath, wpath, max_fullpath); zbx_free(wpath); } @@ -180,21 +180,21 @@ static void svc_get_command_line(const char *path, int multiple_agents, wchar_t svc_get_fullpath(path, path2, MAX_PATH); - if (NULL == zbx_strstr(path2, TEXT(".exe"))) - zbx_wsnprintf(path1, MAX_PATH, TEXT("%s.exe"), path2); + if (NULL == wcsstr(path2, TEXT(".exe"))) + StringCchPrintf(path1, MAX_PATH, TEXT("%s.exe"), path2); else - zbx_wsnprintf(path1, MAX_PATH, path2); + StringCchPrintf(path1, MAX_PATH, path2); if (NULL != CONFIG_FILE) { svc_get_fullpath(CONFIG_FILE, path2, MAX_PATH); - zbx_wsnprintf(cmdLine, max_cmdLine, TEXT("\"%s\" %s--config \"%s\""), + StringCchPrintf(cmdLine, max_cmdLine, TEXT("\"%s\" %s--config \"%s\""), path1, (0 == multiple_agents) ? TEXT("") : TEXT("--multiple-agents "), path2); } else - zbx_wsnprintf(cmdLine, max_cmdLine, TEXT("\"%s\""), path1); + StringCchPrintf(cmdLine, max_cmdLine, TEXT("\"%s\""), path1); } static int svc_install_event_source(const char *path) @@ -207,7 +207,7 @@ static int svc_install_event_source(const char *path) svc_get_fullpath(path, execName, MAX_PATH); wevent_source = zbx_utf8_to_unicode(ZABBIX_EVENT_SOURCE); - zbx_wsnprintf(regkey, ARRSIZE(regkey), EVENTLOG_REG_PATH TEXT("System\\%s"), wevent_source); + StringCchPrintf(regkey, ARRSIZE(regkey), EVENTLOG_REG_PATH TEXT("System\\%s"), wevent_source); zbx_free(wevent_source); if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, NULL, REG_OPTION_NON_VOLATILE, @@ -284,7 +284,7 @@ static int svc_RemoveEventSource() int ret = FAIL; wevent_source = zbx_utf8_to_unicode(ZABBIX_EVENT_SOURCE); - zbx_wsnprintf(regkey, ARRSIZE(regkey), EVENTLOG_REG_PATH TEXT("System\\%s"), wevent_source); + StringCchPrintf(regkey, ARRSIZE(regkey), EVENTLOG_REG_PATH TEXT("System\\%s"), wevent_source); zbx_free(wevent_source); if (ERROR_SUCCESS == RegDeleteKey(HKEY_LOCAL_MACHINE, regkey)) diff --git a/src/zabbix_agent/cpustat.c b/src/zabbix_agent/cpustat.c index f721b4dedbe..5fbafccb1e2 100644 --- a/src/zabbix_agent/cpustat.c +++ b/src/zabbix_agent/cpustat.c @@ -131,7 +131,7 @@ int init_cpu_collector(ZBX_CPUS_STAT_DATA *pcpus) for (cpu_num = 0; cpu_num <= pcpus->count; cpu_num++) { if (0 == cpu_num) - zbx_wsnprintf(cpu, ARRSIZE(cpu), TEXT("_Total")); + StringCchPrintf(cpu, ARRSIZE(cpu), TEXT("_Total")); else _itow_s(cpu_num - 1, cpu, ARRSIZE(cpu), 10); diff --git a/src/zabbix_agent/eventlog.c b/src/zabbix_agent/eventlog.c index bba013a5df6..2309343af35 100644 --- a/src/zabbix_agent/eventlog.c +++ b/src/zabbix_agent/eventlog.c @@ -62,7 +62,7 @@ static int zbx_open_eventlog(const wchar_t *wsource, HANDLE *eventlog_handle, zb *pLatestRecord = 0; /* Get path to eventlog */ - zbx_wsnprintf(reg_path, MAX_PATH, EVENTLOG_REG_PATH TEXT("%s"), wsource); + StringCchPrintf(reg_path, MAX_PATH, EVENTLOG_REG_PATH TEXT("%s"), wsource); if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_path, 0, KEY_READ, &hk)) goto out; @@ -117,7 +117,7 @@ static void zbx_get_message_files(const wchar_t *szLogName, const wchar_t *szSou DWORD szData; /* Get path to message dll */ - zbx_wsnprintf(buf, MAX_PATH, EVENTLOG_REG_PATH TEXT("%s\\%s"), szLogName, szSourceName); + StringCchPrintf(buf, MAX_PATH, EVENTLOG_REG_PATH TEXT("%s\\%s"), szLogName, szSourceName); if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, KEY_READ, &hKey)) return; @@ -300,7 +300,7 @@ static int zbx_get_eventlog_message(const wchar_t *wsource, HANDLE eventlog_hand for (i = 0; i < pELR->NumStrings; i++) { pInsertStrings[i] = pCh; - pCh += zbx_strlen(pCh) + 1; + pCh += wcslen(pCh) + 1; } } @@ -308,7 +308,7 @@ static int zbx_get_eventlog_message(const wchar_t *wsource, HANDLE eventlog_hand for (pFile = pEventMessageFile; NULL != pFile && err != SUCCEED; pFile = pNextFile) { - if (NULL != (pNextFile = zbx_strchr(pFile, TEXT(';')))) + if (NULL != (pNextFile = wcschr(pFile, TEXT(';')))) { *pNextFile = '\0'; pNextFile++; @@ -351,7 +351,7 @@ static int zbx_get_eventlog_message(const wchar_t *wsource, HANDLE eventlog_hand for (i = 0, pCh = (wchar_t *)((unsigned char *)pELR + pELR->StringOffset); i < pELR->NumStrings; - i++, pCh += zbx_strlen(pCh) + 1) + i++, pCh += wcslen(pCh) + 1) { if (0 < i) *out_message = zbx_strdcat(*out_message, "; "); |