diff options
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 15 |
1 files changed, 15 insertions, 0 deletions
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); |