Greenbone Vulnerability Manager  9.0.1
manage_utils.h
1 /* Copyright (C) 2014-2018 Greenbone Networks GmbH
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the 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 General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 /*
21  * @file manage_utils.h
22  * @brief Module for Greenbone Vulnerability Manager: Manage library utilities.
23  */
24 
25 #ifndef _GVMD_MANAGE_UTILS_H
26 #define _GVMD_MANAGE_UTILS_H
27 
28 /* For strptime in time.h. */
29 #undef _XOPEN_SOURCE
30 #define _XOPEN_SOURCE
31 #include <glib.h>
32 #include <libical/ical.h>
33 #include <time.h>
34 
35 // Log message severity constant
36 #define SEVERITY_LOG 0.0
37 // False positive severity constant
38 #define SEVERITY_FP -1.0
39 // Debug message severity constant
40 #define SEVERITY_DEBUG -2.0
41 // Error message severity constant
42 #define SEVERITY_ERROR -3.0
43 // Constant for missing or invalid severity
44 #define SEVERITY_MISSING -99.0
45 // Constant for undefined severity (for ranges)
46 #define SEVERITY_UNDEFINED -98.0
47 // Maximum possible severity
48 #define SEVERITY_MAX 10.0
49 // Number of subdivisions for 1 severity point (10 => step size 0.1)
50 #define SEVERITY_SUBDIVISIONS 10
51 
52 long
53 current_offset (const char *);
54 
55 time_t
56 add_months (time_t, int);
57 
58 time_t
59 next_time (time_t, int, int, int, const char *, int);
60 
61 int
62 manage_count_hosts_max (const char *, const char *, int);
63 
64 double
65 level_min_severity (const char *, const char *);
66 
67 double
68 level_max_severity (const char *, const char *);
69 
70 int
71 valid_db_resource_type (const char *);
72 
73 int
74 hosts_str_contains (const char *, const char *, int);
75 
76 void
77 blank_control_chars (char *);
78 
79 icalcomponent *
80 icalendar_from_old_schedule_data (time_t, time_t, time_t, time_t, int);
81 
82 icalcomponent *
83 icalendar_from_string (const char *, gchar **);
84 
85 int
86 icalendar_approximate_rrule_from_vcalendar (icalcomponent *, time_t *, time_t *,
87  int *);
88 
89 time_t
90 icalendar_next_time_from_vcalendar (icalcomponent *, const char *, int);
91 
92 time_t
93 icalendar_next_time_from_string (const char *, const char *, int);
94 
95 int
96 icalendar_duration_from_vcalendar (icalcomponent *);
97 
98 time_t
99 icalendar_first_time_from_vcalendar (icalcomponent *, const char *);
100 
101 #endif /* not _GVMD_MANAGE_UTILS_H */
time_t add_months(time_t time, int months)
Add months to a time.
Definition: manage_utils.c:303
void blank_control_chars(char *string)
Replace any control characters in string with spaces.
Definition: manage_utils.c:698
long current_offset(const char *zone)
Get the current offset from UTC of a timezone.
Definition: manage_utils.c:140
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:627
time_t icalendar_next_time_from_string(const char *ical_string, 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:1658
time_t next_time(time_t first, int period, int period_months, int byday, const char *zone, int periods_offset)
Calculate the next time from now given a start time and a period.
Definition: manage_utils.c:386
time_t icalendar_first_time_from_vcalendar(icalcomponent *vcalendar, const char *default_tzid)
Get the first time from a VCALENDAR component. The VCALENDAR must have simplified with icalendar_from...
Definition: manage_utils.c:1717
double level_max_severity(const char *level, const char *class)
Get the minimum severity for a severity level and class.
Definition: manage_utils.c:583
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:509
double level_min_severity(const char *level, const char *class)
Get the minimum severity for a severity level and class.
Definition: manage_utils.c:543
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:1682
icalcomponent * icalendar_from_string(const char *ical_string, gchar **error)
Creates a new, simplified VCALENDAR component from a string.
Definition: manage_utils.c:1063
int valid_db_resource_type(const char *type)
Check whether a resource type table name is valid.
Definition: manage_utils.c:656
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:753
time_t icalendar_next_time_from_vcalendar(icalcomponent *vcalendar, 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:1572
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:1221