signed types: add handlers for signed types

We're adding signed types to the spec! This adds the support mechanisms
for them.
This commit is contained in:
Dustin Dettmer
2023-05-05 15:10:53 -04:00
committed by Rusty Russell
parent ad592d8b0d
commit aba4d18ed1
19 changed files with 266 additions and 77 deletions

View File

@@ -8,7 +8,7 @@ DEVTOOLS_TOOL_OBJS := $(DEVTOOLS_TOOL_SRC:.c=.o)
# Make sure these depend on everything.
ALL_C_SOURCES += $(DEVTOOLS_TOOL_SRC)
ALL_C_HEADERS +=
ALL_C_HEADERS +=
ALL_PROGRAMS += $(DEVTOOLS)
DEVTOOLS_COMMON_OBJS := \

View File

@@ -51,6 +51,50 @@ bool printwire_u64(const char *fieldname, const u8 **cursor, size_t *plen)
return true;
}
bool printwire_s8(const char *fieldname, const u8 **cursor, size_t *plen)
{
s8 v = fromwire_s8(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED s64 %s**\n", fieldname);
return false;
}
printf("%d\n", v);
return true;
}
bool printwire_s16(const char *fieldname, const u8 **cursor, size_t *plen)
{
s16 v = fromwire_s16(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED s64 %s**\n", fieldname);
return false;
}
printf("%d\n", v);
return true;
}
bool printwire_s32(const char *fieldname, const u8 **cursor, size_t *plen)
{
s32 v = fromwire_s32(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED s64 %s**\n", fieldname);
return false;
}
printf("%d\n", v);
return true;
}
bool printwire_s64(const char *fieldname, const u8 **cursor, size_t *plen)
{
s64 v = fromwire_s64(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED s64 %s**\n", fieldname);
return false;
}
printf("%ld\n", v);
return true;
}
bool printwire_tu16(const char *fieldname, const u8 **cursor, size_t *plen)
{
u16 v = fromwire_tu16(cursor, plen);

View File

@@ -20,6 +20,10 @@ bool printwire_u8(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_u16(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_u32(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_u64(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_s8(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_s16(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_s32(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_s64(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_tu16(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_tu32(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_tu64(const char *fieldname, const u8 **cursor, size_t *plen);