summaryrefslogtreecommitdiff
path: root/ot_fmt.h
blob: 851b2d816523791c05963e9d80af2a99db288bae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
   It is considered beerware. Prost. Skol. Cheers or whatever.

   $id$ */

#ifndef OT_FMT_H__
#define OT_FMT_H__

#include <stddef.h>

/* Appending to a cursor that walks a fixed buffer. Both take the cursor by
   reference and advance it, so a reply is written as a run of statements and
   no caller does pointer arithmetic of its own. */

void fmt_append(char **cursor, const char *end, const char *format, ...) __attribute__((format(printf, 3, 4)));

/* Append raw bytes for the binary stretches of a bencoded reply.
   Either everything is appended or nothing at all */
void fmt_bytes(char **cursor, const char *end, const void *bytes, size_t length);

#endif