Wiggle 0.6 - first release
[wiggle/upstream.git] / wiggle.h
blob124be296d7dc80382bb78bd73219163150809de8
1 /*
2 * wiggle - apply rejected patches
4 * Copyright (C) 2003 Neil Brown <neilb@cse.unsw.edu.au>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Author: Neil Brown
22 * Email: <neilb@cse.unsw.edu.au>
23 * Paper: Neil Brown
24 * School of Computer Science and Engineering
25 * The University of New South Wales
26 * Sydney, 2052
27 * Australia
30 #include <stdio.h>
31 #include <memory.h>
32 #include <getopt.h>
34 struct stream {
35 char *body;
36 int len;
40 struct elmnt {
41 int hash;
42 char *start;
43 int len;
46 static inline int match(struct elmnt *a, struct elmnt *b)
48 return
49 a->hash == b->hash &&
50 a->len == b->len &&
51 strncmp(a->start, b->start, a->len)==0;
54 static inline int ends_line(struct elmnt e)
56 return e.len && e.start[e.len-1] == '\n';
59 struct csl {
60 int a,b;
61 int len;
64 struct file {
65 struct elmnt *list;
66 int elcnt;
69 extern struct stream load_file(char *name);
70 extern int split_patch(struct stream, struct stream*, struct stream*);
71 extern int split_merge(struct stream, struct stream*, struct stream*, struct stream*);
72 extern struct file split_stream(struct stream s, int type, int reverse);
73 extern struct csl *pdiff(struct file a, struct file b, int chunks);
74 extern struct csl *diff(struct file a, struct file b);
75 extern struct csl *diff_partial(struct file a, struct file b,
76 int alo, int ahi, int blo, int bhi);
77 extern struct csl *worddiff(struct stream f1, struct stream f2,
78 struct file *fl1p, struct file *fl2p);
80 struct ci { int conflicts; int ignored; };
81 extern struct ci print_merge(FILE *out, struct file *a, struct file *b, struct file *c,
82 struct csl *c1, struct csl *c2,
83 int words);
84 extern void printword(FILE *f, struct elmnt e);
86 extern void die(void);
88 extern char Version[];
89 extern char short_options[];
90 extern struct option long_options[];
91 extern char Usage[];
92 extern char Help[];
93 extern char HelpExtract[];
94 extern char HelpDiff[];
95 extern char HelpMerge[];
98 #define ByLine 0
99 #define ByWord 1
100 #define ApproxWord 2