summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2013-03-14 14:33:40 +0200
committerDaniel Stone <daniel@fooishbar.org>2013-04-01 18:20:56 +0100
commite4bceec8809f2563af6786678442fa70d4cd728c (patch)
tree0f88944082cd39e844231904527a8c1abb8777af /src/utils.h
parent99f6e6fc28d91907203f9a19feb4d48878f28cad (diff)
downloadxorg-lib-libxkbcommon-e4bceec8809f2563af6786678442fa70d4cd728c.tar.gz
utils: add {un,}map_file to read an entire file
This wraps the current mmap call and adds a fallback implementation for systems which do not have mmap (e.g. mingw). Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index b4daadd..160bc42 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -24,8 +24,10 @@
#ifndef UTILS_H
#define UTILS_H 1
+#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
+#include <stdio.h>
#include <string.h>
#include <strings.h>
@@ -91,6 +93,12 @@ memdup(const void *mem, size_t nmemb, size_t size)
return p;
}
+bool
+map_file(FILE *file, const char **string_out, size_t *size_out);
+
+void
+unmap_file(const char *str, size_t size);
+
#define ARRAY_SIZE(arr) ((sizeof(arr) / sizeof(*(arr))))
#define MIN(a, b) ((a) < (b) ? (a) : (b))