aboutsummaryrefslogtreecommitdiffstats
path: root/libpatch_parse_patch.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-01-09 22:04:24 +0100
committerMattias Andrée <maandree@kth.se>2024-01-09 22:04:24 +0100
commitae850b1ac755f471beac4dbfef4654fe3fbaaae9 (patch)
tree319e7f7f1b99cd1ee75e100f0a29b0f7c827ccea /libpatch_parse_patch.c
downloadlibpatch-ae850b1ac755f471beac4dbfef4654fe3fbaaae9.tar.gz
libpatch-ae850b1ac755f471beac4dbfef4654fe3fbaaae9.tar.bz2
libpatch-ae850b1ac755f471beac4dbfef4654fe3fbaaae9.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libpatch_parse_patch.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libpatch_parse_patch.c b/libpatch_parse_patch.c
new file mode 100644
index 0000000..526b197
--- /dev/null
+++ b/libpatch_parse_patch.c
@@ -0,0 +1,26 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+int
+libpatch_parse_patch(const char *text, size_t textlen, size_t *textend,
+ struct libpatch_patch **patch, size_t *patchlen, enum libpatch_style style)
+{
+ switch (style) {
+ case LIBPATCH_STYLE_NORMAL:
+ return libpatch_parse_normal_patch(text, textlen, textend, patch, patchlen);
+ case LIBPATCH_STYLE_COPIED:
+ return libpatch_parse_copied_patch(text, textlen, textend, patch, patchlen);
+ case LIBPATCH_STYLE_UNIFIED:
+ return libpatch_parse_unified_patch(text, textlen, textend, patch, patchlen);
+ case LIBPATCH_STYLE_ED:
+ return libpatch_parse_ed_patch(text, textlen, textend, patch, patchlen);
+ case LIBPATCH_STYLE_RCS:
+ return libpatch_parse_rcs_patch(text, textlen, textend, patch, patchlen);
+ default:
+ case LIBPATCH_STYLE_ED_ALTERNATIVE:
+ case LIBPATCH_STYLE_GARBAGE:
+ errno = EINVAL;
+ return -1;
+ }
+}