mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
names.h/names.c: wrappers to get name for states/inputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e6dfff3ba8
commit
caa27f1d93
1
Makefile
1
Makefile
@ -166,6 +166,7 @@ CORE_HEADERS := close_tx.h \
|
||||
commit_tx.h \
|
||||
find_p2sh_out.h \
|
||||
funding.h \
|
||||
names.h \
|
||||
opt_bits.h \
|
||||
overflows.h \
|
||||
permute_tx.h \
|
||||
|
23
names.c
Normal file
23
names.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include "names.h"
|
||||
/* Indented for 'check-source' because it has to be included after names.h */
|
||||
#include "gen_state_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";
|
||||
}
|
||||
|
||||
const char *input_name(enum state_input in)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; enum_state_input_names[i].name; i++)
|
||||
if (enum_state_input_names[i].v == in)
|
||||
return enum_state_input_names[i].name;
|
||||
return "unknown";
|
||||
}
|
8
names.h
Normal file
8
names.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef LIGHTNING_NAMES_H
|
||||
#define LIGHTNING_NAMES_H
|
||||
#include "config.h"
|
||||
#include "state_types.h"
|
||||
|
||||
const char *state_name(enum state s);
|
||||
const char *input_name(enum state_input in);
|
||||
#endif /* LIGHTNING_NAMES_H */
|
@ -18,7 +18,7 @@ static bool record_input_mapping(int b);
|
||||
do { if (record_input_mapping(b)) return false; } while(0)
|
||||
|
||||
#include "state.h"
|
||||
#include "gen_state_names.h"
|
||||
#include "names.c"
|
||||
|
||||
static bool quick = false;
|
||||
static bool dot_simplify = false;
|
||||
@ -448,26 +448,6 @@ static bool fail(const struct peer *peer, enum failure which_fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
static 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";
|
||||
}
|
||||
|
||||
static const char *input_name(enum state_input in)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; enum_state_input_names[i].name; i++)
|
||||
if (enum_state_input_names[i].v == in)
|
||||
return enum_state_input_names[i].name;
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static enum state_input input_by_name(const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
Loading…
Reference in New Issue
Block a user