aboutsummaryrefslogtreecommitdiffstats
path: root/libpatch_format_patch.c
blob: 22df90656ffe43cf01adc5312c2f5a582bd97878 (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
27
/* See LICENSE file for copyright and license details. */
#include "common.h"


int
libpatch_format_patch(struct libpatch_diff2_printer *printer, struct libpatch_diff2 *diff, size_t difflen,
                      const struct libpatch_file *file1, const struct libpatch_file *file2, enum libpatch_style style)
{
	switch (style) {
	case LIBPATCH_STYLE_NORMAL:
		return libpatch_format_normal_patch(printer, diff, difflen, file1, file2);
	case LIBPATCH_STYLE_COPIED:
		return libpatch_format_copied_patch(printer, diff, difflen, file1, file2);
	case LIBPATCH_STYLE_UNIFIED:
		return libpatch_format_unified_patch(printer, diff, difflen, file1, file2);
	case LIBPATCH_STYLE_ED:
		return libpatch_format_ed_patch(printer, diff, difflen, file1, file2);
	case LIBPATCH_STYLE_ED_ALTERNATIVE:
		return libpatch_format_ed_alternative_patch(printer, diff, difflen, file1, file2);
	case LIBPATCH_STYLE_RCS:
		return libpatch_format_rcs_patch(printer, diff, difflen, file1, file2);
	default:
	case LIBPATCH_STYLE_GARBAGE:
		errno = EINVAL;
		return -1;
	}
}