xref: /minix3/usr.bin/patch/pch.h (revision 757e83288ac54fa2d663d17e4a302156fdb3650a)
1*757e8328SLionel Sambuc /*
2*757e8328SLionel Sambuc  * $OpenBSD: pch.h,v 1.9 2003/10/31 20:20:45 millert Exp $
3*757e8328SLionel Sambuc  * $DragonFly: src/usr.bin/patch/pch.h,v 1.1 2004/09/24 18:44:28 joerg Exp $
4*757e8328SLionel Sambuc  * $NetBSD: pch.h,v 1.10 2008/09/19 18:33:34 joerg Exp $
5*757e8328SLionel Sambuc  */
6*757e8328SLionel Sambuc 
7*757e8328SLionel Sambuc /*
8*757e8328SLionel Sambuc  * patch - a program to apply diffs to original files
9*757e8328SLionel Sambuc  *
10*757e8328SLionel Sambuc  * Copyright 1986, Larry Wall
11*757e8328SLionel Sambuc  *
12*757e8328SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
13*757e8328SLionel Sambuc  * modification, are permitted provided that the following condition is met:
14*757e8328SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright notice,
15*757e8328SLionel Sambuc  * this condition and the following disclaimer.
16*757e8328SLionel Sambuc  *
17*757e8328SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
18*757e8328SLionel Sambuc  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19*757e8328SLionel Sambuc  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20*757e8328SLionel Sambuc  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21*757e8328SLionel Sambuc  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*757e8328SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23*757e8328SLionel Sambuc  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24*757e8328SLionel Sambuc  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*757e8328SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*757e8328SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*757e8328SLionel Sambuc  * SUCH DAMAGE.
28*757e8328SLionel Sambuc  *
29*757e8328SLionel Sambuc  * -C option added in 1998, original code by Marc Espie, based on FreeBSD
30*757e8328SLionel Sambuc  * behaviour
31*757e8328SLionel Sambuc  */
32*757e8328SLionel Sambuc 
33*757e8328SLionel Sambuc #define OLD_FILE	0
34*757e8328SLionel Sambuc #define NEW_FILE	1
35*757e8328SLionel Sambuc #define INDEX_FILE	2
36*757e8328SLionel Sambuc #define MAX_FILE	3
37*757e8328SLionel Sambuc 
38*757e8328SLionel Sambuc struct file_name {
39*757e8328SLionel Sambuc 	char *path;
40*757e8328SLionel Sambuc 	bool exists;
41*757e8328SLionel Sambuc };
42*757e8328SLionel Sambuc 
43*757e8328SLionel Sambuc void		re_patch(void);
44*757e8328SLionel Sambuc void		open_patch_file(const char *);
45*757e8328SLionel Sambuc void		set_hunkmax(void);
46*757e8328SLionel Sambuc bool		there_is_another_patch(void);
47*757e8328SLionel Sambuc bool		another_hunk(void);
48*757e8328SLionel Sambuc bool		pch_swap(void);
49*757e8328SLionel Sambuc char		*pfetch(LINENUM);
50*757e8328SLionel Sambuc short		pch_line_len(LINENUM);
51*757e8328SLionel Sambuc LINENUM		pch_first(void);
52*757e8328SLionel Sambuc LINENUM		pch_ptrn_lines(void);
53*757e8328SLionel Sambuc LINENUM		pch_newfirst(void);
54*757e8328SLionel Sambuc LINENUM		pch_repl_lines(void);
55*757e8328SLionel Sambuc LINENUM		pch_end(void);
56*757e8328SLionel Sambuc LINENUM		pch_context(void);
57*757e8328SLionel Sambuc LINENUM		pch_hunk_beg(void);
58*757e8328SLionel Sambuc char		pch_char(LINENUM);
59*757e8328SLionel Sambuc void		do_ed_script(void);
60