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 __UTIL_MISC_H__
25 #define __UTIL_MISC_H__
26 
27 
28 /**
29  * \brief Generic API that can be used by all to log an
30  * invalid conf entry.
31  * \param param_name A string specifying the param name.
32  * \param format Format for the below value. For example "%s", "%"PRIu32,
33  etc.
34  * \param value Default value to be printed.
35  */
36 #define WarnInvalidConfEntry(param_name, format, value) do { \
37  SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, \
38  "Invalid conf entry found for " \
39  "\"%s\". Using default value of \"" format "\".", \
40  param_name, value); \
41  } while (0)
42 
43 /* size string parsing API */
44 
45 int ParseSizeStringU8(const char *, uint8_t *);
46 int ParseSizeStringU16(const char *, uint16_t *);
47 int ParseSizeStringU32(const char *, uint32_t *);
48 int ParseSizeStringU64(const char *, uint64_t *);
49 
50 #ifdef UNITTESTS
51 void UtilMiscRegisterTests(void);
52 #endif /* UNITTESTS */
53 
54 void ParseSizeInit(void);
55 void ParseSizeDeinit(void);
56 
57 void ShortenString(const char *input,
58  char *output, size_t output_size, char c);
59 
60 #endif /* __UTIL_MISC_H__ */
ShortenString
void ShortenString(const char *input, char *output, size_t output_size, char c)
Definition: util-misc.c:217
ParseSizeStringU16
int ParseSizeStringU16(const char *, uint16_t *)
Definition: util-misc.c:166
ParseSizeStringU8
int ParseSizeStringU8(const char *, uint8_t *)
Definition: util-misc.c:149
ParseSizeDeinit
void ParseSizeDeinit(void)
Definition: util-misc.c:55
ParseSizeStringU32
int ParseSizeStringU32(const char *, uint32_t *)
Definition: util-misc.c:183
ParseSizeStringU64
int ParseSizeStringU64(const char *, uint64_t *)
Definition: util-misc.c:200
ParseSizeInit
void ParseSizeInit(void)
Definition: util-misc.c:35
UtilMiscRegisterTests
void UtilMiscRegisterTests(void)
Definition: util-misc.c:1169