- if ((p = buf_getmem##suff(b, &n)) == 0) \
- return (-1); \
- buf_init(bb, p, n); \
- return (0); \
-}
-DOSUFFIXES(GETBUF)
-
-/* --- @buf_putbuf{8,16,32,z}@ --- *
- *
- * Arguments: @buf *b@ = pointer to a buffer block
- * @buf *bb@ = buffer to write
- *
- * Returns: Zero if it worked, nonzero if there wasn't enough space.
- *
- * Use: Puts the contents of a buffer to a buffer. The number, @16@
- * or @32@, is the width of the length; @z@ means null-
- * terminated.
- */
-
-#define PUTBUF(suff) int buf_putbuf##suff(buf *b, buf *bb) \
- { return (buf_putmem##suff(b, BBASE(bb), BLEN(bb))); }
-DOSUFFIXES(PUTBUF)
-
-/* --- @buf_getstr{8,16,32,z}@ --- *
- *
- * Arguments: @buf *b@ = pointer to a buffer block
- * @dstr *d@ = where to put the result
- *
- * Returns: Zero if it worked, nonzero if there wasn't enough space.
- *
- * Use: Gets a block of data from a buffer, and writes its contents
- * to a string. The number, @16@ or @32@, is the width of the
- * length; @z@ means null-terminated.
- */
-
-#define GETSTR(suff) int buf_getstr##suff(buf *b, dstr *d) \
-{ \
- void *p; \
- size_t n; \
- \
- if ((p = buf_getmem##suff(b, &n)) == 0) \
- return (-1); \
- DPUTM(d, p, n); \
- return (0); \
-}
-DOSUFFIXES(GETSTR)
-
-/* --- @buf_putstr{8,16,32,z}@ --- *
- *
- * Arguments: @buf *b@ = pointer to a buffer block
- * @dstr *d@ = string to write
- *
- * Returns: Zero if it worked, nonzero if there wasn't enough space.
- *
- * Use: Puts a string to a buffer, and writes its bounds to
- * another buffer. The number, @16@ or @32@, is the width of
- * the length; @z@ means null-terminated.
- */
-
-#define PUTSTR(suff) int buf_putstr##suff(buf *b, dstr *d) \
- { return (buf_putmem##suff(b, d->buf, d->len)); }
-DOSUFFIXES(PUTSTR)
-
-/* --- @buf_getmp@ --- *
- *
- * Arguments: @buf *b@ = pointer to a buffer block
- *
- * Returns: A multiprecision integer, or null if there wasn't one there.
- *
- * Use: Gets a multiprecision integer from a buffer.
- */
-
-mp *buf_getmp(buf *b)
-{
- uint16 sz;
- size_t n;
- mp *m;
- if (buf_getu16(b, &sz) || buf_ensure(b, sz))
- return (0);
- m = mp_loadb(MP_NEW, BCUR(b), sz);
- n = mp_octets(m);
- if (n != sz && n != 0 && sz != 1) {
- mp_drop(m);
- return (0);