mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-11 10:04:28 +01:00
print_wire: hand field names to print routines.
This lets us override how we print them. Also, add dependency on header for devtools/Makefile. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
2639b1e9a9
commit
c02ff11506
@@ -29,7 +29,7 @@ devtools/onion.c: ccan/config.h
|
||||
devtools/onion: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/onion.o common/sphinx.o
|
||||
|
||||
$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h devtools/gen_print_wire.h
|
||||
devtools/gen_print_wire.o: devtools/gen_print_wire.h wire/gen_peer_wire.h
|
||||
devtools/gen_print_wire.o: devtools/gen_print_wire.h wire/gen_peer_wire.h devtools/print_wire.h
|
||||
|
||||
# Make sure these depend on everything.
|
||||
ALL_PROGRAMS += devtools/bolt11-cli devtools/decodemsg devtools/onion
|
||||
|
||||
@@ -3,27 +3,27 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void printwire_u8(const u8 *v)
|
||||
void printwire_u8(const char *fieldname, const u8 *v)
|
||||
{
|
||||
printf("%u\n", *v);
|
||||
}
|
||||
|
||||
void printwire_u16(const u16 *v)
|
||||
void printwire_u16(const char *fieldname, const u16 *v)
|
||||
{
|
||||
printf("%u\n", *v);
|
||||
}
|
||||
|
||||
void printwire_u32(const u32 *v)
|
||||
void printwire_u32(const char *fieldname, const u32 *v)
|
||||
{
|
||||
printf("%u\n", *v);
|
||||
}
|
||||
|
||||
void printwire_u64(const u64 *v)
|
||||
void printwire_u64(const char *fieldname, const u64 *v)
|
||||
{
|
||||
printf("%"PRIu64"\n", *v);
|
||||
}
|
||||
|
||||
void printwire_u8_array(const u8 **cursor, size_t *plen, size_t len)
|
||||
void printwire_u8_array(const char *fieldname, const u8 **cursor, size_t *plen, size_t len)
|
||||
{
|
||||
printf("[");
|
||||
while (len) {
|
||||
@@ -40,7 +40,7 @@ void printwire_u8_array(const u8 **cursor, size_t *plen, size_t len)
|
||||
}
|
||||
|
||||
#define PRINTWIRE_TYPE_TO_STRING(T, N) \
|
||||
void printwire_##N(const T *v) \
|
||||
void printwire_##N(const char *fieldname, const T *v) \
|
||||
{ \
|
||||
const char *s = type_to_string(NULL, T, v); \
|
||||
printf("%s\n", s); \
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
#include <bitcoin/tx.h>
|
||||
#include <wire/gen_peer_wire.h>
|
||||
|
||||
void printwire_u8(const u8 *v);
|
||||
void printwire_u16(const u16 *v);
|
||||
void printwire_u32(const u32 *v);
|
||||
void printwire_u64(const u64 *v);
|
||||
void printwire_u8_array(const u8 **cursor, size_t *plen, size_t len);
|
||||
void printwire_u8(const char *fieldname, const u8 *v);
|
||||
void printwire_u16(const char *fieldname, const u16 *v);
|
||||
void printwire_u32(const char *fieldname, const u32 *v);
|
||||
void printwire_u64(const char *fieldname, const u64 *v);
|
||||
void printwire_u8_array(const char *fieldname, const u8 **cursor, size_t *plen, size_t len);
|
||||
|
||||
void printwire_bitcoin_blkid(const struct bitcoin_blkid *bitcoin_blkid);
|
||||
void printwire_bitcoin_txid(const struct bitcoin_txid *bitcoin_txid);
|
||||
void printwire_channel_id(const struct channel_id *channel_id);
|
||||
void printwire_preimage(const struct preimage *preimage);
|
||||
void printwire_pubkey(const struct pubkey *pubkey);
|
||||
void printwire_secp256k1_ecdsa_signature(const secp256k1_ecdsa_signature *);
|
||||
void printwire_sha256(const struct sha256 *sha256);
|
||||
void printwire_short_channel_id(const struct short_channel_id *short_channel_id);
|
||||
void printwire_bitcoin_blkid(const char *fieldname, const struct bitcoin_blkid *bitcoin_blkid);
|
||||
void printwire_bitcoin_txid(const char *fieldname, const struct bitcoin_txid *bitcoin_txid);
|
||||
void printwire_channel_id(const char *fieldname, const struct channel_id *channel_id);
|
||||
void printwire_preimage(const char *fieldname, const struct preimage *preimage);
|
||||
void printwire_pubkey(const char *fieldname, const struct pubkey *pubkey);
|
||||
void printwire_secp256k1_ecdsa_signature(const char *fieldname, const secp256k1_ecdsa_signature *);
|
||||
void printwire_sha256(const char *fieldname, const struct sha256 *sha256);
|
||||
void printwire_short_channel_id(const char *fieldname, const struct short_channel_id *short_channel_id);
|
||||
|
||||
#endif /* LIGHTNING_DEVTOOLS_PRINT_WIRE_H */
|
||||
|
||||
Reference in New Issue
Block a user