Source
void zbx_print_help(const char *progname, const char **help_message, const char **usage_message, const char *param)
/*
** Copyright (C) 2001-2025 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: prints application parameters on stdout with layout suitable for *
* 80-column terminal *
* *
* Parameters: progname - [IN] *
* usage_message - [IN] *
* *
******************************************************************************/
void zbx_print_usage(const char *progname, const char **usage_message)
{
/* left margin for the first line */
/* left margin for subsequent lines */
const char **p = usage_message;
if (NULL != *p)
printf("Usage:\n");
while (NULL != *p)
{
size_t pos;
printf("%s%s", ZBX_SPACE1, progname);
pos = ZBX_CONST_STRLEN(ZBX_SPACE1) + strlen(progname);
while (NULL != *p)
{
size_t len;
len = strlen(*p);
if (ZBX_MAXCOL > pos + len)
{
pos += len + 1;
printf(" %s", *p);
}
else
{
pos = ZBX_CONST_STRLEN(ZBX_SPACE2) + len + 1;
printf("\n%s %s", ZBX_SPACE2, *p);
}
p++;
}