Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tag_value() #825

Merged
merged 3 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Removed
- Remove support for "All SecInfo": removal of "allinfo" for type in get_info [#790](https://github.com/greenbone/gvmd/pull/790)
- Removed tag_value() by using nvti_get_tag() [#825](https://github.com/greenbone/gvmd/pull/825)

[20.4]: https://github.com/greenbone/gvmd/compare/v9.0.0...master

Expand Down
46 changes: 4 additions & 42 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,44 +1151,6 @@ vector_find_filter (const gchar **vector, const gchar *string)
return 0;
}

/**
* @brief Extract a tag from a pipe separated tag list.
*
* @param[in] tags Tag list.
* @param[out] tag Tag name.
*
* @return Newly allocated tag value.
*/
gchar *
tag_value (const gchar *tags, const gchar *tag)
{
gchar **split, **point;

/* creation_date=2009-04-09 14:18:58 +0200 (Thu, 09 Apr 2009)|... */

if (tags == NULL)
return g_strdup ("");

split = g_strsplit (tags, "|", 0);
point = split;

while (*point)
{
if ((strlen (*point) > strlen (tag))
&& (strncmp (*point, tag, strlen (tag)) == 0)
&& ((*point)[strlen (tag)] == '='))
{
gchar *ret;
ret = g_strdup (*point + strlen (tag) + 1);
g_strfreev (split);
return ret;
}
point++;
}
g_strfreev (split);
return g_strdup ("");
}

/**
* @brief Get last time NVT alerts were checked.
*
Expand Down Expand Up @@ -21074,8 +21036,8 @@ make_result (task_t task, const char* host, const char *hostname,
if (nvti)
{
gchar *qod_str, *qod_type;
qod_str = tag_value (nvti_tag (nvti), "qod");
qod_type = tag_value (nvti_tag (nvti), "qod_type");
qod_str = nvti_get_tag (nvti, "qod");
qod_type = nvti_get_tag (nvti, "qod_type");

if (qod_str == NULL || sscanf (qod_str, "%d", &qod) != 1)
qod = qod_from_type (qod_type);
Expand Down Expand Up @@ -48909,8 +48871,8 @@ buffer_insert (GString *buffer, task_t task, const char* host,
if (nvti)
{
gchar *qod_str, *qod_type;
qod_str = tag_value (nvti_tag (nvti), "qod");
qod_type = tag_value (nvti_tag (nvti), "qod_type");
qod_str = nvti_get_tag (nvti, "qod");
qod_type = nvti_get_tag (nvti, "qod_type");

if (qod_str == NULL || sscanf (qod_str, "%d", &qod) != 1)
qod = qod_from_type (qod_type);
Expand Down
2 changes: 0 additions & 2 deletions src/manage_sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ host_nthlast_report_host (const char *, report_host_t *, int);
char*
report_host_ip (const char *);

gchar *tag_value (const gchar *, const gchar *);

void trim_report (report_t);

int delete_report_internal (report_t);
Expand Down
2 changes: 1 addition & 1 deletion src/manage_sql_nvts.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ insert_nvt (const nvti_t *nvti)

quoted_cvss_base = sql_quote (nvti_cvss_base (nvti) ? nvti_cvss_base (nvti) : "");

qod_str = tag_value (nvti_tag (nvti), "qod");
qod_str = nvti_get_tag (nvti, "qod");
qod_type = nvti_qod_type (nvti);

if (qod_str == NULL || sscanf (qod_str, "%d", &qod) != 1)
Expand Down