Greenbone Vulnerability Manager
22.4.0~dev1
|
Headers for Greenbone Vulnerability Manager: General utilities. More...
#include <glib.h>
#include <gvm/util/xmlutils.h>
#include <time.h>
Go to the source code of this file.
Data Structures | |
struct | lockfile_t |
Lockfile. More... | |
Functions | |
int | gvm_usleep (unsigned int) |
Sleep for some number of microseconds, handling interrupts. More... | |
int | gvm_sleep (unsigned int) |
Sleep for some number of seconds, handling interrupts. More... | |
int | parse_utc_ctime (const char *) |
Convert a UTC ctime string into seconds since the epoch. More... | |
int | parse_feed_timestamp (const char *) |
Convert a feed timestamp into seconds since epoch. More... | |
int | parse_ctime (const char *) |
Convert a ctime into seconds since epoch. More... | |
int | days_from_now (time_t *) |
Calculate difference between now and epoch_time in days. More... | |
time_t | parse_iso_time_tz (const char *, const char *) |
Convert an ISO time into seconds since epoch. More... | |
char * | iso_time (time_t *) |
Create an ISO time from seconds since epoch. More... | |
char * | iso_time_tz (time_t *, const char *, const char **) |
Create an ISO time from seconds since epoch, given a timezone. More... | |
int | lockfile_lock (lockfile_t *, const gchar *) |
Lock a file exclusively. More... | |
int | lockfile_lock_nb (lockfile_t *, const gchar *) |
Lock a file exclusively, without blocking. More... | |
int | lockfile_lock_path_nb (lockfile_t *, const gchar *) |
Lock a file exclusively, without blocking, given a full path. More... | |
int | lockfile_lock_shared_nb (lockfile_t *, const gchar *) |
Lock a file with a shared lock. More... | |
int | lockfile_unlock (lockfile_t *) |
Unlock a file. More... | |
int | lockfile_locked (const gchar *) |
Check if a file is locked. More... | |
int | is_uuid (const char *) |
Check whether a string is a UUID. More... | |
int | parse_xml_file (const gchar *, entity_t *) |
Create entity from XML file. More... | |
void | setup_signal_handler (int, void(*)(int), int) |
Setup signal handler. More... | |
void | setup_signal_handler_info (int, void(*)(int, siginfo_t *, void *), int) |
Setup signal handler. More... | |
int | fork_with_handlers () |
Fork, setting default handlers for TERM, INT and QUIT in child. More... | |
Headers for Greenbone Vulnerability Manager: General utilities.
int days_from_now | ( | time_t * | epoch_time | ) |
Calculate difference between now and epoch_time in days.
[in] | epoch_time | Time in seconds from epoch. |
int fork_with_handlers | ( | ) |
Fork, setting default handlers for TERM, INT and QUIT in child.
This should be used for pretty much all processes forked directly from the main gvmd process, because the main process's signal handlers will not longer work, because the child does not use the pselect loop.
int gvm_sleep | ( | unsigned int | seconds | ) |
Sleep for some number of seconds, handling interrupts.
[in] | seconds | Number of seconds. |
int gvm_usleep | ( | unsigned int | microseconds | ) |
Sleep for some number of microseconds, handling interrupts.
[in] | microseconds | Number of microseconds. |
int is_uuid | ( | const char * | uuid | ) |
Check whether a string is a UUID.
[in] | uuid | Potential UUID. |
char* iso_time | ( | time_t * | epoch_time | ) |
Create an ISO time from seconds since epoch.
[in] | epoch_time | Time in seconds from epoch. |
char* iso_time_tz | ( | time_t * | epoch_time, |
const char * | zone, | ||
const char ** | abbrev | ||
) |
Create an ISO time from seconds since epoch, given a timezone.
[in] | epoch_time | Time in seconds from epoch. |
[in] | zone | Timezone. |
[out] | abbrev | Timezone abbreviation. |
int lockfile_lock | ( | lockfile_t * | lockfile, |
const gchar * | lockfile_basename | ||
) |
Lock a file exclusively.
Block until file is locked.
[in] | lockfile | Lockfile. |
[in] | lockfile_basename | Basename of lock file. |
int lockfile_lock_nb | ( | lockfile_t * | lockfile, |
const gchar * | lockfile_basename | ||
) |
Lock a file exclusively, without blocking.
[in] | lockfile | Lockfile. |
[in] | lockfile_basename | Basename of lock file. |
int lockfile_lock_path_nb | ( | lockfile_t * | lockfile, |
const gchar * | lockfile_path | ||
) |
Lock a file exclusively, without blocking, given a full path.
[in] | lockfile | Lockfile. |
[in] | lockfile_path | Full path of lock file. |
int lockfile_lock_shared_nb | ( | lockfile_t * | lockfile, |
const gchar * | lockfile_basename | ||
) |
Lock a file with a shared lock.
[in] | lockfile | Lockfile. |
[in] | lockfile_basename | Basename of lock file. |
int lockfile_locked | ( | const gchar * | lockfile_basename | ) |
Check if a file is locked.
[in] | lockfile_basename | Basename of lock file. |
int lockfile_unlock | ( | lockfile_t * | lockfile | ) |
Unlock a file.
[in] | lockfile | Lockfile. |
int parse_ctime | ( | const char * | text_time | ) |
Convert a ctime into seconds since epoch.
Use the current timezone.
[in] | text_time | Time as text in ctime format. |
int parse_feed_timestamp | ( | const char * | text_time | ) |
Convert a feed timestamp into seconds since epoch.
[in] | text_time | Time as text in ctime format. |
time_t parse_iso_time_tz | ( | const char * | text_time, |
const char * | fallback_tz | ||
) |
Convert an ISO time into seconds since epoch.
If no offset is specified, the given timezone is used (UTC in case of NULL).
[in] | text_time | Time as text in ISO format: 2011-11-03T09:23:28+02:00. |
[in] | fallback_tz | The fallback timezone if offset is missing. |
int parse_utc_ctime | ( | const char * | text_time | ) |
Convert a UTC ctime string into seconds since the epoch.
[in] | text_time | Time as text in ctime format. |
int parse_xml_file | ( | const gchar * | path, |
entity_t * | config | ||
) |
Create entity from XML file.
[in] | path | Path to XML. |
[out] | config | Config tree. |
void setup_signal_handler | ( | int | signal, |
void(*)(int) | handler, | ||
int | block | ||
) |
Setup signal handler.
Exit on failure.
[in] | signal | Signal. |
[in] | handler | Handler. |
[in] | block | Whether to block all other signals during handler. |
void setup_signal_handler_info | ( | int | signal, |
void(*)(int, siginfo_t *, void *) | handler, | ||
int | block | ||
) |
Setup signal handler.
Exit on failure.
[in] | signal | Signal. |
[in] | handler | Handler. |
[in] | block | Whether to block all other signals during handler. |