1 /* Copyright (C) 2012-2020 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 19 /** 20 * @file utils.h 21 * @brief Headers for Greenbone Vulnerability Manager: General utilities. 22 */ 23 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 58 /** 59 * @brief Lockfile. 60 */ 61 typedef struct 62 { 63 int fd; ///< File descriptor. 64 gchar *name; ///< 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 80 lockfile_unlock (lockfile_t *); 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 98 fork_with_handlers (); 99 100 #endif /* not _GVMD_UTILS_H */ 101