Greenbone Vulnerability Manager  22.4.0~dev1
utils.h
Go to the documentation of this file.
1 /* Copyright (C) 2012-2022 Greenbone Networks GmbH
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 
31 int
32 gvm_usleep (unsigned int);
33 
34 int
35 gvm_sleep (unsigned int);
36 
37 int
38 parse_utc_ctime (const char *);
39 
40 int
41 parse_feed_timestamp (const char *);
42 
43 int
44 parse_ctime (const char *);
45 
46 int
47 days_from_now (time_t *);
48 
49 time_t
50 parse_iso_time_tz (const char *, const char *);
51 
52 char *
53 iso_time (time_t *);
54 
55 char *
56 iso_time_tz (time_t *, const char *, const char **);
57 
61 typedef struct
62 {
63  int fd;
64  gchar *name;
65 } lockfile_t;
66 
67 int
68 lockfile_lock (lockfile_t *, const gchar *);
69 
70 int
71 lockfile_lock_nb (lockfile_t *, const gchar *);
72 
73 int
74 lockfile_lock_path_nb (lockfile_t *, const gchar *);
75 
76 int
77 lockfile_lock_shared_nb (lockfile_t *, const gchar *);
78 
79 int
81 
82 int
83 lockfile_locked (const gchar *);
84 
85 int
86 is_uuid (const char *);
87 
88 int
89 parse_xml_file (const gchar *, entity_t *);
90 
91 void
92 setup_signal_handler (int, void (*) (int), int);
93 
94 void
95 setup_signal_handler_info (int, void (*) (int, siginfo_t *, void *), int);
96 
97 int
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
char * iso_time(time_t *)
Create an ISO time from seconds since epoch.
Definition: utils.c:491
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
int parse_ctime(const char *)
Convert a ctime into seconds since epoch.
Definition: utils.c:280