core-lightning/daemon/names.c
Rusty Russell fd6c3ce5a3 names: move into daemon/
It was already only referred from that Makefile.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30

37 lines
783 B
C

#include "names.h"
#include <ccan/str/str.h>
/* Indented for 'check-source' because it has to be included after names.h */
#include "daemon/gen_state_names.h"
#include "daemon/gen_pkt_names.h"
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";
}
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;
}
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";
}