suricata
util-misc.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2022 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Anoop Saldanha <anoopsaldanha@gmail.com>
22  */
23 
24 #ifndef SURICATA_UTIL_MISC_H
25 #define SURICATA_UTIL_MISC_H
26 
27 /**
28  * \brief Generic API that can be used by all to log an
29  * invalid conf entry.
30  * \param param_name A string specifying the param name.
31  * \param format Format for the below value. For example "%s", "%"PRIu32,
32  etc.
33  * \param value Default value to be printed.
34  */
35 #define WarnInvalidConfEntry(param_name, format, value) \
36  do { \
37  SCLogWarning("Invalid conf entry found for " \
38  "\"%s\". Using default value of \"" format "\".", \
39  param_name, value); \
40  } while (0)
41 
42 /* size string parsing API */
43 
44 int ParseSizeStringU8(const char *, uint8_t *);
45 int ParseSizeStringU16(const char *, uint16_t *);
46 int ParseSizeStringU32(const char *, uint32_t *);
47 int ParseSizeStringU64(const char *, uint64_t *);
48 
49 #ifdef UNITTESTS
50 void UtilMiscRegisterTests(void);
51 #endif /* UNITTESTS */
52 
53 void ParseSizeInit(void);
54 void ParseSizeDeinit(void);
55 
56 void ShortenString(const char *input,
57  char *output, size_t output_size, char c);
58 
59 #endif /* SURICATA_UTIL_MISC_H */
ShortenString
void ShortenString(const char *input, char *output, size_t output_size, char c)
Definition: util-misc.c:207
ParseSizeStringU16
int ParseSizeStringU16(const char *, uint16_t *)
Definition: util-misc.c:156
ParseSizeStringU8
int ParseSizeStringU8(const char *, uint8_t *)
Definition: util-misc.c:139
ParseSizeDeinit
void ParseSizeDeinit(void)
Definition: util-misc.c:54
ParseSizeStringU32
int ParseSizeStringU32(const char *, uint32_t *)
Definition: util-misc.c:173
ParseSizeStringU64
int ParseSizeStringU64(const char *, uint64_t *)
Definition: util-misc.c:190
ParseSizeInit
void ParseSizeInit(void)
Definition: util-misc.c:35
UtilMiscRegisterTests
void UtilMiscRegisterTests(void)
Definition: util-misc.c:809