summaryrefslogtreecommitdiff
path: root/examples/common.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-08-01 12:40:51 +0200
committerGitHub <noreply@github.com>2019-08-01 12:40:51 +0200
commit56e7aaf0440fc542f70b392ffadacc65038cddf9 (patch)
tree88952ea4c9657abb25746072d586c652ff20327f /examples/common.h
parenteea128b5509e333abf80d44ccef2312e5bf89708 (diff)
parent960d2a070f2d1647026d883fd04d8e0a040d07dd (diff)
downloadlibgit2-56e7aaf0440fc542f70b392ffadacc65038cddf9.tar.gz
Merge pull request #5125 from albfan/wip/albfan/diff_buffers
Compare buffers in diff example
Diffstat (limited to 'examples/common.h')
-rw-r--r--examples/common.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/examples/common.h b/examples/common.h
index 724a5c04f..bba83217b 100644
--- a/examples/common.h
+++ b/examples/common.h
@@ -12,10 +12,25 @@
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
+#include <sys/types.h>
+#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <git2.h>
+#include <fcntl.h>
+
+#ifdef _WIN32
+# include <io.h>
+# include <Windows.h>
+# define open _open
+# define read _read
+# define close _close
+# define ssize_t int
+# define sleep(a) Sleep(a * 1000)
+#else
+# include <unistd.h>
+#endif
#ifndef PRIuZ
/* Define the printf format specifer to use for size_t output */
@@ -65,6 +80,14 @@ extern int lg2_tag(git_repository *repo, int argc, char **argv);
extern void check_lg2(int error, const char *message, const char *extra);
/**
+ * Read a file into a buffer
+ *
+ * @param path The path to the file that shall be read
+ * @return NUL-terminated buffer if the file was successfully read, NULL-pointer otherwise
+ */
+extern char *read_file(const char *path);
+
+/**
* Exit the program, printing error to stderr
*/
extern void fatal(const char *message, const char *extra);
@@ -90,7 +113,7 @@ struct args_info {
/**
* Check current `args` entry against `opt` string. If it matches
* exactly, take the next arg as a string; if it matches as a prefix with
- * an equal sign, take the remainder as a string; if value not supplied,
+ * an equal sign, take the remainder as a string; if value not supplied,
* default value `def` will be given. otherwise return 0.
*/
extern int optional_str_arg(