lnsocket

A minimal C library for connecting to the lightning network
git clone git://jb55.com/lnsocket
Log | Files | Refs | Submodules | README | LICENSE

bigsize.h (901B)


      1 #ifndef LNSOCKET_BIGSIZE_H
      2 #define LNSOCKET_BIGSIZE_H
      3 #include "config.h"
      4 #include "cursor.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(unsigned char buf[BIGSIZE_MAX_LEN], bigsize_t v);
     14 
     15 /* Returns 0 on failure, otherwise length (<= max) used.  */
     16 size_t bigsize_get(const unsigned char *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(unsigned char **pptr, const bigsize_t val);
     26 bigsize_t fromwire_bigsize(const unsigned char **cursor, size_t *max);
     27 
     28 int cursor_pull_bigsize(struct cursor *cur, bigsize_t *out);
     29 int cursor_push_bigsize(struct cursor *cur, const bigsize_t val);
     30 
     31 #endif /* LNSOCKET_BIGSIZE_H */