-
Notifications
You must be signed in to change notification settings - Fork 9
/
bigsize.h
31 lines (22 loc) · 901 Bytes
/
bigsize.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef LNSOCKET_BIGSIZE_H
#define LNSOCKET_BIGSIZE_H
#include "config.h"
#include "cursor.h"
#include <stddef.h>
/* typedef for clarity. */
typedef u64 bigsize_t;
#define BIGSIZE_MAX_LEN 9
/* Returns length of buf used. */
size_t bigsize_put(unsigned char buf[BIGSIZE_MAX_LEN], bigsize_t v);
/* Returns 0 on failure, otherwise length (<= max) used. */
size_t bigsize_get(const unsigned char *p, size_t max, bigsize_t *val);
/* How many bytes does it take to encode v? */
size_t bigsize_len(bigsize_t v);
/* Used for wire generation */
typedef bigsize_t bigsize;
/* marshal/unmarshal functions */
void towire_bigsize(unsigned char **pptr, const bigsize_t val);
bigsize_t fromwire_bigsize(const unsigned char **cursor, size_t *max);
int cursor_pull_bigsize(struct cursor *cur, bigsize_t *out);
int cursor_push_bigsize(struct cursor *cur, const bigsize_t val);
#endif /* LNSOCKET_BIGSIZE_H */