Greenbone Vulnerability Manager 22.5.2
utils.h
Go to the documentation of this file.
1/* Copyright (C) 2012-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
24#ifndef _GVMD_UTILS_H
25#define _GVMD_UTILS_H
26
27#include <glib.h>
28#include <gvm/util/xmlutils.h>
29#include <time.h>
30
31int
32gvm_usleep (unsigned int);
33
34int
35gvm_sleep (unsigned int);
36
37int
38parse_utc_ctime (const char *);
39
40int
41parse_feed_timestamp (const char *);
42
43int
44parse_ctime (const char *);
45
46int
47days_from_now (time_t *);
48
49time_t
50parse_iso_time_tz (const char *, const char *);
51
52char *
53iso_time (time_t *);
54
55char *
56iso_time_tz (time_t *, const char *, const char **);
57
61typedef struct
62{
63 int fd;
64 gchar *name;
66
67int
68lockfile_lock (lockfile_t *, const gchar *);
69
70int
71lockfile_lock_nb (lockfile_t *, const gchar *);
72
73int
74lockfile_lock_path_nb (lockfile_t *, const gchar *);
75
76int
77lockfile_lock_shared_nb (lockfile_t *, const gchar *);
78
79int
81
82int
83lockfile_locked (const gchar *);
84
85int
86is_uuid (const char *);
87
88int
89parse_xml_file (const gchar *, entity_t *);
90
91void
92setup_signal_handler (int, void (*) (int), int);
93
94void
95setup_signal_handler_info (int, void (*) (int, siginfo_t *, void *), int);
96
97int
99
100#endif /* not _GVMD_UTILS_H */
Lockfile.
Definition: utils.h:62
int fd
File descriptor.
Definition: utils.h:63
gchar * name
Name.
Definition: utils.h:64
int fork_with_handlers()
Fork, setting default handlers for TERM, INT and QUIT in child.
Definition: utils.c:874
int gvm_sleep(unsigned int)
Sleep for some number of seconds, handling interrupts.
Definition: utils.c:102
int lockfile_lock_path_nb(lockfile_t *, const gchar *)
Lock a file exclusively, without blocking, given a full path.
Definition: utils.c:656
int is_uuid(const char *)
Check whether a string is a UUID.
Definition: utils.c:744
int lockfile_lock(lockfile_t *, const gchar *)
Lock a file exclusively.
Definition: utils.c:626
char * iso_time_tz(time_t *, const char *, const char **)
Create an ISO time from seconds since epoch, given a timezone.
Definition: utils.c:506
void setup_signal_handler(int, void(*)(int), int)
Setup signal handler.
Definition: utils.c:810
time_t parse_iso_time_tz(const char *, const char *)
Convert an ISO time into seconds since epoch.
Definition: utils.c:332
int parse_utc_ctime(const char *)
Convert a UTC ctime string into seconds since the epoch.
Definition: utils.c:252
int lockfile_unlock(lockfile_t *)
Unlock a file.
Definition: utils.c:685
int parse_xml_file(const gchar *, entity_t *)
Create entity from XML file.
Definition: utils.c:762
int gvm_usleep(unsigned int)
Sleep for some number of microseconds, handling interrupts.
Definition: utils.c:71
void setup_signal_handler_info(int, void(*)(int, siginfo_t *, void *), int)
Setup signal handler.
Definition: utils.c:839
int days_from_now(time_t *)
Calculate difference between now and epoch_time in days.
Definition: utils.c:312
int lockfile_lock_nb(lockfile_t *, const gchar *)
Lock a file exclusively, without blocking.
Definition: utils.c:641
int lockfile_locked(const gchar *)
Check if a file is locked.
Definition: utils.c:720
int lockfile_lock_shared_nb(lockfile_t *, const gchar *)
Lock a file with a shared lock.
Definition: utils.c:671
int parse_feed_timestamp(const char *)
Convert a feed timestamp into seconds since epoch.
Definition: utils.c:265
char * iso_time(time_t *)
Create an ISO time from seconds since epoch.
Definition: utils.c:491
int parse_ctime(const char *)
Convert a ctime into seconds since epoch.
Definition: utils.c:280