Greenbone Vulnerability Manager  9.0.1
utils.h
Go to the documentation of this file.
1 /* Copyright (C) 2012-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 
25 #ifndef _GVMD_UTILS_H
26 #define _GVMD_UTILS_H
27 
28 #include <glib.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 char *
50 iso_time (time_t *);
51 
52 char *
53 iso_time_tz (time_t *, const char *, const char **);
54 
58 typedef struct
59 {
60  int fd;
61  gchar *name;
62 } lockfile_t;
63 
64 int
65 lockfile_lock (lockfile_t *, const gchar *);
66 
67 int
68 lockfile_lock_nb (lockfile_t *, const gchar *);
69 
70 int
71 lockfile_lock_shared_nb (lockfile_t *, const gchar *);
72 
73 int
75 
76 int
77 lockfile_locked (const gchar *);
78 
79 #endif /* not _GVMD_UTILS_H */
Lockfile.
Definition: utils.h:59
int fd
File descriptor.
Definition: utils.h:60
gchar * name
Name.
Definition: utils.h:61
int gvm_sleep(unsigned int)
Sleep for some number of seconds, handling interrupts.
Definition: utils.c:100
char * iso_time(time_t *)
Create an ISO time from seconds since epoch.
Definition: utils.c:313
int lockfile_lock(lockfile_t *, const gchar *)
Lock a file exclusively.
Definition: utils.c:440
char * iso_time_tz(time_t *, const char *, const char **)
Create an ISO time from seconds since epoch, given a timezone.
Definition: utils.c:328
int parse_utc_ctime(const char *)
Convert a UTC ctime string into seconds since the epoch.
Definition: utils.c:181
int lockfile_unlock(lockfile_t *)
Unlock a file.
Definition: utils.c:484
int gvm_usleep(unsigned int)
Sleep for some number of microseconds, handling interrupts.
Definition: utils.c:69
int days_from_now(time_t *)
Calculate difference between now and epoch_time in days.
Definition: utils.c:241
int lockfile_lock_nb(lockfile_t *, const gchar *)
Lock a file exclusively, without blocking.
Definition: utils.c:455
int lockfile_locked(const gchar *)
Check if a file is locked.
Definition: utils.c:519
int lockfile_lock_shared_nb(lockfile_t *, const gchar *)
Lock a file with a shared lock.
Definition: utils.c:470
int parse_feed_timestamp(const char *)
Convert a feed timestamp into seconds since epoch.
Definition: utils.c:194
int parse_ctime(const char *)
Convert a ctime into seconds since epoch.
Definition: utils.c:209