• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 22550237931

01 Mar 2026 06:56PM UTC coverage: 64.812% (-8.9%) from 73.687%
22550237931

Pull #14920

github

web-flow
Merge e05854a6d into 90823fa90
Pull Request #14920: draft: rust based configuration file parser and loader - v4

561 of 789 new or added lines in 4 files covered. (71.1%)

23225 existing lines in 498 files now uncovered.

131605 of 203055 relevant lines covered (64.81%)

2328818.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.08
/src/util-enum.c
1
/* Copyright (C) 2007-2010 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
#include "suricata-common.h"
25

26
#include "util-enum.h"
27
#include "util-debug.h"
28

29
/**
30
 * \brief Maps a string name to an enum value from the supplied table.  Please
31
 *        specify the last element of any map table with a {NULL, -1}.  If
32
 *        missing, you will be welcomed with a segfault :)
33
 *
34
 * \param enum_name Character string that has to be mapped to an enum value
35
 *                  from the table
36
 * \param table     Enum-Char table, from which the mapping is retrieved
37
 *
38
 * \retval result The enum_value for the enum_name string or -1 on failure
39
 */
40
int SCMapEnumNameToValue(const char *enum_name, SCEnumCharMap *table)
41
{
47,142✔
42
    int result = -1;
47,142✔
43

44
    if (enum_name == NULL || table == NULL) {
47,142✔
45
        SCLogDebug("Invalid argument(s) passed into SCMapEnumNameToValue");
×
46
        return -1;
×
47
    }
×
48

49
    for (; table->enum_name != NULL; table++) {
667,591✔
50
        if (strcasecmp(table->enum_name, enum_name) == 0) {
663,164✔
51
            result = table->enum_value;
42,715✔
52
            break;
42,715✔
53
        }
42,715✔
54
    }
663,164✔
55

56
    return result;
47,142✔
57
}
47,142✔
58

59
/**
60
 * \brief Maps an enum value to a string name, from the supplied table
61
 *
62
 * \param enum_value Enum_value that has to be mapped to a string_value
63
 *                   from the table
64
 * \param table      Enum-Char table, from which the mapping is retrieved
65
 *
66
 * \retval result The enum_name for the enum_value supplied or NULL on failure
67
 */
68
const char * SCMapEnumValueToName(int enum_value, SCEnumCharMap *table)
69
{
10,336,352✔
70
    if (table == NULL) {
10,336,352✔
71
        SCLogDebug("Invalid argument(s) passed into SCMapEnumValueToName");
×
72
        return NULL;
×
73
    }
×
74

75
    for (; table->enum_name != NULL; table++) {
32,129,054✔
76
        if (table->enum_value == enum_value) {
32,129,054✔
77
            return table->enum_name;
10,336,352✔
78
        }
10,336,352✔
79
    }
32,129,054✔
80

UNCOV
81
    SCLogDebug("A enum by the value %d doesn't exist in this table", enum_value);
×
82

83
    return NULL;
84
}
10,336,352✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc