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/>.
**/
/*
* 2.2 development database patches
*/
static int DBmodify_proxy_table_id_field(const char *table_name)
{
const zbx_db_field_t field = {"id", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0};
return DBmodify_field_type(table_name, &field, NULL);
ZBX_UNUSED(table_name);
return SUCCEED;
}
/*********************************************************************************
* *
* Purpose: parse database monitor item params string "user=<user> password= *
* <password> DSN=<dsn> sql=<sql>" into parameter values. *
* *
* Parameters: params - [IN] the params string *
* dsn - [OUT] the ODBC DSN output buffer *
* user - [OUT] the user name output buffer *
* password - [OUT] the password output buffer *
* sql - [OUT] the sql query output buffer *
* *
* Comments: This function allocated memory to store parsed parameters, which *
* must be freed later by the caller. *
* Failed (or absent) parameters will contain empty string "". *
* *
*********************************************************************************/
static void parse_db_monitor_item_params(const char *params, char **dsn, char **user, char **password, char **sql)
{
const char *pvalue, *pnext, *pend;
char **var;
for (; '\0' != *params; params = pnext)
{
while (0 != isspace(*params))
params++;
pvalue = strchr(params, '=');
pnext = strchr(params, '\n');
if (NULL == pvalue)
break;
if (NULL == pnext)
pnext = params + strlen(params);
if (pvalue > pnext || pvalue == params)
continue;
for (pend = pvalue - 1; 0 != isspace(*pend); pend--)
;
pend++;
if (0 == strncmp(params, "user", pend - params))
var = user;
else if (0 == strncmp(params, "password", pend - params))
var = password;
else if (0 == strncmp(params, "DSN", pend - params))
var = dsn;