1 #ifndef LIGHTNING_COMMON_BIGSIZE_H 2 #define LIGHTNING_COMMON_BIGSIZE_H 3 #include "config.h" 4 #include <ccan/short_types/short_types.h> 5 #include <stddef.h> 6 7 /* typedef for clarity. */ 8 typedef u64 bigsize_t; 9 10 #define BIGSIZE_MAX_LEN 9 11 12 /* Returns length of buf used. */ 13 size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN], bigsize_t v); 14 15 /* Returns 0 on failure, otherwise length (<= max) used. */ 16 size_t bigsize_get(const u8 *p, size_t max, bigsize_t *val); 17 18 /* How many bytes does it take to encode v? */ 19 size_t bigsize_len(bigsize_t v); 20 21 /* Used for wire generation */ 22 typedef bigsize_t bigsize; 23 24 /* marshal/unmarshal functions */ 25 void towire_bigsize(u8 **pptr, const bigsize_t val); 26 bigsize_t fromwire_bigsize(const u8 **cursor, size_t *max); 27 #endif /* LIGHTNING_COMMON_BIGSIZE_H */ 28