Source
/*
** 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/>.
**/
/* QueryServiceConfig() and QueryServiceConfig2() maximum output buffer size */
/* as documented by Microsoft */
typedef enum
{
STARTUP_TYPE_AUTO,
STARTUP_TYPE_AUTO_DELAYED,
STARTUP_TYPE_MANUAL,
STARTUP_TYPE_DISABLED,
STARTUP_TYPE_UNKNOWN,
STARTUP_TYPE_AUTO_TRIGGER,
STARTUP_TYPE_AUTO_DELAYED_TRIGGER,
STARTUP_TYPE_MANUAL_TRIGGER
}
zbx_startup_type_t;
/******************************************************************************
* *
* Purpose: converts service state code from value used in Microsoft Windows *
* to value used in Zabbix *
* *
* Parameters: state - [IN] service state code (e.g. obtained via *
* QueryServiceStatus() function) *
* *
* Return value: service state code used in Zabbix or 7 if service state code *
* is not recognized by this function *
* *
******************************************************************************/
static zbx_uint64_t get_state_code(DWORD state)
{
/* these are called "Status" in MS Windows "Services" program and */
/* "States" in EnumServicesStatusEx() function documentation */
static const DWORD service_states[7] = {SERVICE_RUNNING, SERVICE_PAUSED, SERVICE_START_PENDING,
SERVICE_PAUSE_PENDING, SERVICE_CONTINUE_PENDING, SERVICE_STOP_PENDING, SERVICE_STOPPED};
DWORD i;
for (i = 0; i < ARRSIZE(service_states) && state != service_states[i]; i++)
;
return i;
}
static const char *get_state_string(DWORD state)