summaryrefslogtreecommitdiff
path: root/ot_fmt.h
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-26 22:32:52 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-10-26 22:32:52 +0100
commit1f9494979268b62ed4b4588fb7d9e790c0e12100 (patch)
treeed4f78369fe610b5c9188cb4159a23370d50a799 /ot_fmt.h
parent6d5485b97cd46f81512e9198ac7c59c7ba1d9247 (diff)
replace all calls to sprintf with a format helper that advances a cursor. Also convert the meta-formatter (i.e. results printer) to this scheme
Diffstat (limited to 'ot_fmt.h')
-rw-r--r--ot_fmt.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/ot_fmt.h b/ot_fmt.h
new file mode 100644
index 0000000..851b2d8
--- /dev/null
+++ b/ot_fmt.h
@@ -0,0 +1,21 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
3
4 $id$ */
5
6#ifndef OT_FMT_H__
7#define OT_FMT_H__
8
9#include <stddef.h>
10
11/* Appending to a cursor that walks a fixed buffer. Both take the cursor by
12 reference and advance it, so a reply is written as a run of statements and
13 no caller does pointer arithmetic of its own. */
14
15void fmt_append(char **cursor, const char *end, const char *format, ...) __attribute__((format(printf, 3, 4)));
16
17/* Append raw bytes for the binary stretches of a bencoded reply.
18 Either everything is appended or nothing at all */
19void fmt_bytes(char **cursor, const char *end, const void *bytes, size_t length);
20
21#endif