Browse Source

names: generate names for command_status and state_peercond.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
c1dc7137ba
  1. 20
      names.c
  2. 2
      names.h
  3. 22
      state.h
  4. 23
      state_types.h

20
names.c

@ -21,3 +21,23 @@ const char *input_name(enum state_input in)
return enum_state_input_names[i].name;
return "unknown";
}
const char *cstatus_name(enum command_status cstatus)
{
size_t i;
for (i = 0; enum_command_status_names[i].name; i++)
if (enum_command_status_names[i].v == cstatus)
return enum_command_status_names[i].name;
return "unknown";
}
const char *peercond_name(enum state_peercond peercond)
{
size_t i;
for (i = 0; enum_state_peercond_names[i].name; i++)
if (enum_state_peercond_names[i].v == peercond)
return enum_state_peercond_names[i].name;
return "unknown";
}

2
names.h

@ -5,4 +5,6 @@
const char *state_name(enum state s);
const char *input_name(enum state_input in);
const char *cstatus_name(enum command_status cstatus);
const char *peercond_name(enum state_peercond peercond);
#endif /* LIGHTNING_NAMES_H */

22
state.h

@ -6,17 +6,6 @@
#include <state_types.h>
#include <stdbool.h>
enum state_peercond {
/* Ready to accept a new command. */
PEER_CMD_OK,
/* Don't send me commands, I'm busy. */
PEER_BUSY,
/* No more commands, I'm closing. */
PEER_CLOSING,
/* No more packets, I'm closed. */
PEER_CLOSED
};
enum state_effect_type {
STATE_EFFECT_broadcast_tx,
STATE_EFFECT_send_pkt,
@ -111,17 +100,6 @@ union input {
struct htlc_progress *htlc_prog;
};
enum command_status {
/* Nothing changed. */
CMD_NONE,
/* Command succeeded. */
CMD_SUCCESS,
/* HTLC-command needs re-issuing (theirs takes preference) */
CMD_REQUEUE,
/* Failed. */
CMD_FAIL
};
enum command_status state(const tal_t *ctx,
struct peer *peer,
const enum state_input input,

23
state_types.h

@ -279,4 +279,27 @@ enum state_input {
INPUT_MAX
};
enum state_peercond {
/* Ready to accept a new command. */
PEER_CMD_OK,
/* Don't send me commands, I'm busy. */
PEER_BUSY,
/* No more commands, I'm closing. */
PEER_CLOSING,
/* No more packets, I'm closed. */
PEER_CLOSED
};
enum command_status {
/* Nothing changed. */
CMD_NONE,
/* Command succeeded. */
CMD_SUCCESS,
/* HTLC-command needs re-issuing (theirs takes preference) */
CMD_REQUEUE,
/* Failed. */
CMD_FAIL
};
#endif /* LIGHTNING_STATE_TYPES_H */

Loading…
Cancel
Save