Greenbone Vulnerability Manager 22.5.2
manage_utils.h
1/* Copyright (C) 2014-2022 Greenbone AG
2 *
3 * SPDX-License-Identifier: AGPL-3.0-or-later
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
20 * @file manage_utils.h
21 * @brief Module for Greenbone Vulnerability Manager: Manage library utilities.
22 */
23
24#ifndef _GVMD_MANAGE_UTILS_H
25#define _GVMD_MANAGE_UTILS_H
26
27/* For strptime in time.h. */
28#undef _XOPEN_SOURCE
29#define _XOPEN_SOURCE
30#include <glib.h>
31#include <libical/ical.h>
32#include <time.h>
33
34// Log message severity constant
35#define SEVERITY_LOG 0.0
36// False positive severity constant
37#define SEVERITY_FP -1.0
38// Error message severity constant
39#define SEVERITY_ERROR -3.0
40// Constant for missing or invalid severity
41#define SEVERITY_MISSING -99.0
42// Constant for undefined severity (for ranges)
43#define SEVERITY_UNDEFINED -98.0
44// Maximum possible severity
45#define SEVERITY_MAX 10.0
46// Number of subdivisions for 1 severity point (10 => step size 0.1)
47#define SEVERITY_SUBDIVISIONS 10
48
49long
50current_offset (const char *);
51
52time_t
53add_months (time_t, int);
54
55time_t
56next_time (time_t, int, int, int, const char *, int);
57
58int
59manage_count_hosts_max (const char *, const char *, int);
60
61double
62level_min_severity (const char *);
63
64double
65level_max_severity (const char *);
66
67int
68valid_db_resource_type (const char *);
69
70int
71hosts_str_contains (const char *, const char *, int);
72
73void
74blank_control_chars (char *);
75
76icaltimezone *
78
79icalcomponent *
80icalendar_from_old_schedule_data (time_t, time_t, time_t, time_t, int);
81
82icalcomponent *
83icalendar_from_string (const char *, icaltimezone *, gchar **);
84
85int
86icalendar_approximate_rrule_from_vcalendar (icalcomponent *, time_t *, time_t *,
87 int *);
88
89time_t
90icalendar_next_time_from_vcalendar (icalcomponent *, time_t, const char *, int);
91
92time_t
93icalendar_next_time_from_string (const char *, time_t, const char *, int);
94
95int
96icalendar_duration_from_vcalendar (icalcomponent *);
97
98time_t
99icalendar_first_time_from_vcalendar (icalcomponent *, icaltimezone *);
100
101gchar *
102clean_hosts_string (const char *);
103
104#endif /* not _GVMD_MANAGE_UTILS_H */
icalcomponent * icalendar_from_old_schedule_data(time_t first_time, time_t period, time_t period_months, time_t duration, int byday_mask)
Create an iCalendar component from old schedule data.
Definition: manage_utils.c:383
long current_offset(const char *zone)
Get the current offset from UTC of a timezone.
Definition: manage_utils.c:61
double level_min_severity(const char *level)
Get the minimum severity for a severity level.
Definition: manage_utils.c:205
icalcomponent * icalendar_from_string(const char *ical_string, icaltimezone *zone, gchar **error)
Creates a new, simplified VCALENDAR component from a string.
Definition: manage_utils.c:690
int icalendar_approximate_rrule_from_vcalendar(icalcomponent *vcalendar, time_t *period, time_t *period_months, int *byday_mask)
Approximate the recurrence of a VCALENDAR as classic schedule data. The VCALENDAR must have simplifie...
Definition: manage_utils.c:855
int icalendar_duration_from_vcalendar(icalcomponent *vcalendar)
Get the duration VCALENDAR component. The VCALENDAR must have simplified with icalendar_from_string f...
Definition: manage_utils.c:1333
gchar * clean_hosts_string(const char *hosts)
Cleans up a hosts string, removing extra zeroes from IPv4 addresses.
Definition: manage_utils.c:1408
int manage_count_hosts_max(const char *given_hosts, const char *exclude_hosts, int max_hosts)
Return number of hosts described by a hosts string.
Definition: manage_utils.c:154
time_t icalendar_next_time_from_string(const char *ical_string, time_t reference_time, const char *default_tzid, int periods_offset)
Get the next or previous due time from a VCALENDAR string. The string must be a VCALENDAR simplified ...
Definition: manage_utils.c:1306
icaltimezone * icalendar_timezone_from_string(const char *tzid)
Try to get a built-in libical timezone from a tzid or city name.
Definition: manage_utils.c:356
void blank_control_chars(char *string)
Replace any control characters in string with spaces.
Definition: manage_utils.c:336
int hosts_str_contains(const char *hosts_str, const char *find_host_str, int max_hosts)
Returns whether a host has an equal host in a hosts string.
Definition: manage_utils.c:267
time_t icalendar_first_time_from_vcalendar(icalcomponent *vcalendar, icaltimezone *default_tz)
Get the first time from a VCALENDAR component. The VCALENDAR must have simplified with icalendar_from...
Definition: manage_utils.c:1368
time_t add_months(time_t time, int months)
Add months to a time.
Definition: manage_utils.c:131
double level_max_severity(const char *level)
Get the maximum severity for a severity level.
Definition: manage_utils.c:235
time_t icalendar_next_time_from_vcalendar(icalcomponent *vcalendar, time_t reference_time, const char *default_tzid, int periods_offset)
Get the next or previous due time from a VCALENDAR component. The VCALENDAR must have simplified with...
Definition: manage_utils.c:1212
int valid_db_resource_type(const char *type)
Check whether a resource type table name is valid.
Definition: manage_utils.c:296