aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'common.h')
-rw-r--r--common.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/common.h b/common.h
new file mode 100644
index 0000000..21e9ad8
--- /dev/null
+++ b/common.h
@@ -0,0 +1,54 @@
+/* See LICENSE file for copyright and license details. */
+#include "libpatch.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#define MIN(A, B) ((A) < (B) ? (A) : (B))
+#define MAX(A, B) ((A) > (B) ? (A) : (B))
+
+#define IS_LINE(T) ((T) >= LIBPATCH_PATCH_CONTEXT && (T) <= LIBPATCH_PATCH_POSTCHANGE)
+
+
+struct printer_internals {
+ void (*put)(struct libpatch_diff2_printer *this, const char *text, size_t len);
+ union {
+ FILE *stream;
+ int fd;
+ } f;
+};
+
+
+void libpatch_plain_diff2_printer__(struct libpatch_diff2_printer *printer);
+struct libpatch_diff2_printer *libpatch_stream_diff2_printer__(FILE *output);
+struct libpatch_diff2_printer *libpatch_fd_diff2_printer__(int output);
+
+size_t libpatch_next_line__(const char **text, size_t *textlen, size_t lastlen);
+
+int libpatch_reverse_hunks__(struct libpatch_patch *patch, size_t patchlen,
+ const size_t *hunks, size_t nhunks,
+ struct libpatch_patch **patchcopy, size_t *patchcopysize);
+
+size_t libpatch_get_zu__(const char *text, size_t len, size_t *out);
+
+int libpatch_append_to_patch__(struct libpatch_patch **patch, size_t *patchlen, size_t *size,
+ size_t stroff, size_t strlen, int type);
+
+#define APPEND_STRING(OFF, TYPE)\
+ do {\
+ if (libpatch_append_to_patch__(patch, patchlen, &size,\
+ (size_t)(&text[OFF] - patchtext),\
+ len - (size_t)(OFF), (TYPE)))\
+ goto fail;\
+ } while (0)
+
+#define APPEND_OPTSTRING(OFF, TYPE)\
+ APPEND_STRING((OFF) + ((OFF) < len && text[OFF] == ' '), (TYPE))
+
+#define APPEND_NO_TEXT(TYPE)\
+ APPEND_STRING(len, TYPE)