12dd076b8SGabor Kovesdan /*- 22dd076b8SGabor Kovesdan * Copyright 1986, Larry Wall 32dd076b8SGabor Kovesdan * 42dd076b8SGabor Kovesdan * Redistribution and use in source and binary forms, with or without 52dd076b8SGabor Kovesdan * modification, are permitted provided that the following condition is met: 62dd076b8SGabor Kovesdan * 1. Redistributions of source code must retain the above copyright notice, 72dd076b8SGabor Kovesdan * this condition and the following disclaimer. 82dd076b8SGabor Kovesdan * 92dd076b8SGabor Kovesdan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY 102dd076b8SGabor Kovesdan * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 112dd076b8SGabor Kovesdan * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 122dd076b8SGabor Kovesdan * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 132dd076b8SGabor Kovesdan * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 142dd076b8SGabor Kovesdan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 152dd076b8SGabor Kovesdan * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 162dd076b8SGabor Kovesdan * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 172dd076b8SGabor Kovesdan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 182dd076b8SGabor Kovesdan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 192dd076b8SGabor Kovesdan * SUCH DAMAGE. 202dd076b8SGabor Kovesdan * 212dd076b8SGabor Kovesdan * patch - a program to apply diffs to original files 222dd076b8SGabor Kovesdan * 232dd076b8SGabor Kovesdan * -C option added in 1998, original code by Marc Espie, based on FreeBSD 242dd076b8SGabor Kovesdan * behaviour 252dd076b8SGabor Kovesdan * 262dd076b8SGabor Kovesdan * $OpenBSD: pch.h,v 1.9 2003/10/31 20:20:45 millert Exp $ 272dd076b8SGabor Kovesdan */ 282dd076b8SGabor Kovesdan 292dd076b8SGabor Kovesdan #define OLD_FILE 0 302dd076b8SGabor Kovesdan #define NEW_FILE 1 312dd076b8SGabor Kovesdan #define INDEX_FILE 2 322dd076b8SGabor Kovesdan #define MAX_FILE 3 332dd076b8SGabor Kovesdan 342dd076b8SGabor Kovesdan struct file_name { 352dd076b8SGabor Kovesdan char *path; 362dd076b8SGabor Kovesdan bool exists; 372dd076b8SGabor Kovesdan }; 382dd076b8SGabor Kovesdan 3950dacbf6SKyle Evans extern char *source_file; 4050dacbf6SKyle Evans 412dd076b8SGabor Kovesdan void re_patch(void); 422dd076b8SGabor Kovesdan void open_patch_file(const char *); 432dd076b8SGabor Kovesdan void set_hunkmax(void); 442dd076b8SGabor Kovesdan bool there_is_another_patch(void); 452dd076b8SGabor Kovesdan bool another_hunk(void); 462dd076b8SGabor Kovesdan bool pch_swap(void); 472dd076b8SGabor Kovesdan char *pfetch(LINENUM); 48*851a9da3SDag-Erling Smørgrav size_t pch_line_len(LINENUM); 492dd076b8SGabor Kovesdan LINENUM pch_first(void); 502dd076b8SGabor Kovesdan LINENUM pch_ptrn_lines(void); 512dd076b8SGabor Kovesdan LINENUM pch_newfirst(void); 522dd076b8SGabor Kovesdan LINENUM pch_repl_lines(void); 532dd076b8SGabor Kovesdan LINENUM pch_end(void); 542dd076b8SGabor Kovesdan LINENUM pch_context(void); 552dd076b8SGabor Kovesdan LINENUM pch_hunk_beg(void); 562dd076b8SGabor Kovesdan char pch_char(LINENUM); 572dd076b8SGabor Kovesdan void do_ed_script(void); 58