#include "basic.h"
#include "error.h"
+#include "integer.h"
#define BUF_SIZE_MAX 1000000
return buf_write(dest, &u32, sizeof(uint32_t));
}
+static inline bool
+buf_write_u64(struct buffer *dest, uint64_t data)
+{
+ uint64_t u64 = htonll(data);
+ return buf_write(dest, &u64, sizeof(uint64_t));
+}
+
static inline bool
buf_copy(struct buffer *dest, const struct buffer *src)
{
}
}
+/* Read a 64-bit big-endian value (see buf_write_u64()). Sets *good to indicate
+ * success, like buf_read_u32(). */
+static inline uint64_t
+buf_read_u64(struct buffer *buf, bool *good)
+{
+ uint64_t ret;
+ if (!buf_read(buf, &ret, sizeof(uint64_t)))
+ {
+ if (good)
+ {
+ *good = false;
+ }
+ return 0;
+ }
+ else
+ {
+ if (good)
+ {
+ *good = true;
+ }
+ return ntohll(ret);
+ }
+}
+
/** Return true if buffer contents are equal */
static inline bool
buf_equal(const struct buffer *a, const struct buffer *b)