2016-01-21 21:11:46 +01:00
|
|
|
#include "names.h"
|
2016-08-18 06:55:13 +02:00
|
|
|
#include <ccan/str/str.h>
|
2016-01-21 21:11:46 +01:00
|
|
|
/* Indented for 'check-source' because it has to be included after names.h */
|
2016-11-08 22:34:27 +01:00
|
|
|
#include "daemon/gen_state_names.h"
|
|
|
|
#include "daemon/gen_pkt_names.h"
|
2016-01-21 21:11:46 +01:00
|
|
|
|
|
|
|
const char *state_name(enum state s)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; enum_state_names[i].name; i++)
|
|
|
|
if (enum_state_names[i].v == s)
|
|
|
|
return enum_state_names[i].name;
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2016-08-18 06:55:13 +02:00
|
|
|
enum state name_to_state(const char *name)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; enum_state_names[i].name; i++)
|
|
|
|
if (streq(name, enum_state_names[i].name))
|
|
|
|
return enum_state_names[i].v;
|
|
|
|
|
|
|
|
return STATE_MAX;
|
|
|
|
}
|
|
|
|
|
2016-05-26 07:55:24 +02:00
|
|
|
const char *pkt_name(Pkt__PktCase pkt)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; enum_PktCase_names[i].name; i++)
|
|
|
|
if (enum_PktCase_names[i].v == pkt)
|
|
|
|
return enum_PktCase_names[i].name;
|
|
|
|
return "unknown";
|
|
|
|
}
|