From 260fc47f01ef64368721ec93de4cbd988357b32b Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Tue, 17 May 2022 17:31:48 +0100 Subject: Add ability to read Format 1 metadata files --- src/utils.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index ef21b22..f920455 100644 --- a/src/utils.h +++ b/src/utils.h @@ -50,6 +50,9 @@ int msg(int level, const char *fmt, ...); /* Malloc which either succeeds or exits */ void *xmalloc(size_t size); +/* Ditto for realloc */ +void *xrealloc(void *ptr, size_t size); + /* Ditto for strdup */ char *xstrdup(const char *s); @@ -77,15 +80,27 @@ void write_binary_url(const char *string, size_t len, FILE *to); /* Writes a normal C string to a file, URL-encoding any chars if necessary */ void write_string_url(const char *string, FILE *to); +/* Reads a single char from a file */ +int read_char(const char **from, const char *max); + /* Reads an int from a file, using len bytes, in little-endian order */ uint64_t read_int(const char **from, size_t len, const char *max); +/* Reads an int from a file, stored as an ASCII string, to the first non-digit */ +long read_int_string(const char **from, const char *max, int base); + /* Reads a binary string from a file */ char *read_binary_string(const char **from, size_t len, const char *max); +/* Reads binary data from a file, which was stored URL-encoded */ +char *read_binary_url(const char **from, const char *max, ssize_t *len); + /* Reads a normal C string from a file */ char *read_string(const char **from, const char *max); +/* Reads a normal C string from a file, which was stored URL-encoded */ +char *read_string_url(const char **from, const char *max); + /* Caching version of getgrnam */ struct group *xgetgrnam(const char *name); -- cgit v1.2.1