Debian Codegraph @

include/util.h

raw symbols SCIP
1 /*
2 * AIDE (Advanced Intrusion Detection Environment)
3 *
4 * Copyright (C) 1999-2002, 2006, 2013, 2020-2024 Rami Lehti, Pablo Virolainen,
5 * Richard van den Berg, Hannes von Haugwitz
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #ifndef _UTIL_H_INCLUDED
23 #define _UTIL_H_INCLUDED
24 #include "config.h"
25 #include <string.h>
26 #include <stdbool.h>
27 #include <inttypes.h>
28 #include <sys/types.h>
29 #include <stdarg.h>
30 #include <time.h>
31 #include "url.h"
32
33 #define HEXD2ASC(x) (((x) < 10) ? ((x) + '0') : ((x) - 10 + 'A'))
34
35 #define ASC2HEXD(x) (((x) >= '0' && (x) <= '9') ? \
36 ((x) - '0') : (toupper(x) - 'A' + 10))
37
38 #define ISXDIGIT(x) isxdigit ((unsigned char)(x))
39
40 #ifndef HAVE_STRICMP
41 # define stricmp(a,b) strcasecmp( (a), (b) )
42 #endif
43
44 #ifndef HAVE_BYTE
45 typedef uint8_t byte;
46 #endif
47
48 #define COLOR_L_BLACK "\x1B[0;30m"
49 #define COLOR_L_RED "\x1B[0;31m"
50 #define COLOR_L_GREEN "\x1B[0;32m"
51 #define COLOR_L_ORANGE "\x1B[0;33m"
52 #define COLOR_L_BLUE "\x1B[0;34m"
53 #define COLOR_L_PURPLE "\x1B[0;35m"
54 #define COLOR_L_CYAN "\x1B[0;36m"
55 #define COLOR_L_GRAY "\x1B[0;37m"
56
57 #define COLOR_B_GRAY "\x1B[1;30m"
58 #define COLOR_B_RED "\x1B[1;31m"
59 #define COLOR_B_GREEN "\x1B[1;32m"
60 #define COLOR_B_YELLOW "\x1B[1;33m"
61 #define COLOR_B_BLUE "\x1B[1;34m"
62 #define COLOR_B_PURPLE "\x1B[1;35m"
63 #define COLOR_B_CYAN "\x1B[1;36m"
64 #define COLOR_B_WHITE "\x1B[1;37m"
65
66 #define COLOR_RESET "\x1B[0m"
67
68 void stderr_msg(const char* format, ...)
69 #ifdef __GNUC__
70 __attribute__ ((format (printf, 1, 2)))
71 #endif
72 ;
73 void vstderr_prefix_line(const char*, const char*, va_list)
74 #ifdef __GNUC__
75 __attribute__ ((format (printf, 1, 0)))
76 #endif
77 ;
78 void stderr_set_line_erasure(bool);
79
80 const char* btoa(bool);
81
82 void* checked_malloc(size_t);
83 void* checked_calloc(size_t, size_t);
84 void* checked_strdup(const char *);
85 void* checked_strndup(const char *, size_t);
86 void* checked_realloc(void *, size_t);
87
88 int cmpurl(url_t*, url_t*);
89
90 int contains_unsafe(const char*);
91
92 char *strnesc(const char *, size_t);
93 char *stresc(const char *);
94
95 void decode_string(char*);
96
97 char* encode_string(const char*);
98
99 char *get_progress_bar_string(const char *, const char *, long unsigned, long unsigned, int, int);
100
101 char* perm_to_char(mode_t perm);
102
103 char *expand_tilde(char * path);
104
105 char* byte_to_base16(const byte*, size_t);
106
107 char* pipe2string(int);
108
109 char* get_time_string(const time_t *);
110
111 void mask_sig(const char*);
112
113 #ifndef HAVE_STRNSTR
114 char* strnstr(char* haystack,char* needle,int n);
115 #endif
116
117 #ifndef HAVE_STRNLEN
118 size_t strnlen(const char *s, size_t maxlen);
119 #endif
120
121 #ifdef HAVE_SYSLOG
122 int syslog_facility_lookup(char *);
123 #endif
124
125 #endif