suricata
util-enum.c File Reference
#include "suricata-common.h"
#include "util-enum.h"
#include "util-debug.h"
Include dependency graph for util-enum.c:

Go to the source code of this file.

Functions

int SCMapEnumNameToValue (const char *enum_name, SCEnumCharMap *table)
 Maps a string name to an enum value from the supplied table. Please specify the last element of any map table with a {NULL, -1}. If missing, you will be welcomed with a segfault :) More...
 
const char * SCMapEnumValueToName (int enum_value, SCEnumCharMap *table)
 Maps an enum value to a string name, from the supplied table. More...
 

Detailed Description

Function Documentation

◆ SCMapEnumNameToValue()

int SCMapEnumNameToValue ( const char *  enum_name,
SCEnumCharMap table 
)

Maps a string name to an enum value from the supplied table. Please specify the last element of any map table with a {NULL, -1}. If missing, you will be welcomed with a segfault :)

Parameters
enum_nameCharacter string that has to be mapped to an enum value from the table
tableEnum-Char table, from which the mapping is retrieved
Return values
resultThe enum_value for the enum_name string or -1 on failure

Definition at line 40 of file util-enum.c.

References SCEnumCharMap_::enum_name, SCEnumCharMap_::enum_value, and SCLogDebug.

Referenced by AppLayerGetPktEventInfo(), DetectEngineGetEventInfo(), SCLogInitOPIfaceCtx(), and SCLogLoadConfig().

Here is the caller graph for this function:

◆ SCMapEnumValueToName()

const char* SCMapEnumValueToName ( int  enum_value,
SCEnumCharMap table 
)

Maps an enum value to a string name, from the supplied table.

Parameters
enum_valueEnum_value that has to be mapped to a string_value from the table
tableEnum-Char table, from which the mapping is retrieved
Return values
resultThe enum_name for the enum_value supplied or NULL on failure

Definition at line 68 of file util-enum.c.

References SCEnumCharMap_::enum_name, SCEnumCharMap_::enum_value, and SCLogDebug.

Referenced by AppLayerGetEventInfoById(), and SCRuleVarsGetConfVar().

Here is the caller graph for this function: