aboutsummaryrefslogtreecommitdiffstats
path: root/libpatch_parse_patch.c
blob: 526b197c86113eed110344272d963923c897148a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
	}
}