Source
if (NULL != (pGNSI = (PGNSI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo")))
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/********************************************************************************
* *
* Purpose: joins strings into one, placing separator in between them, *
* skipping empty strings *
* *
* Parameters: separator - [IN] separator to place in between strings *
* count - [IN] number of strings *
* ... - [IN] strings to join (strings can be empty or NULL) *
* *
********************************************************************************/
static char *join_nonempty_strs(const char *separator, size_t count, ...)
{
char *arg;
va_list args;
char **nonempty_strs;
char *res = NULL;
size_t num_nonempty = 0, str_size = 0;
nonempty_strs = zbx_malloc(NULL, sizeof(char *) * count);
va_start(args, count);
for (size_t i = 0; i < count; i++)
{
arg = va_arg(args, char *);
if (NULL != arg && 0 < strlen(arg))
{
str_size += strlen(arg) + strlen(separator);
nonempty_strs[num_nonempty++] = arg;
}
}
va_end(args);
if (0 < num_nonempty)
{
res = zbx_malloc(NULL, str_size * sizeof(char));
res[0] = '\0';
strcat(res, nonempty_strs[0]);
for (size_t i = 1; i < num_nonempty; i++) {
strcat(res, separator);
strcat(res, nonempty_strs[i]);
}
}
zbx_free(nonempty_strs);
return res;
}
static WORD get_processor_architecture(void)
{
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
SYSTEM_INFO si;
PGNSI pGNSI;