xref: /openbsd-src/gnu/usr.bin/cvs/diff/diffrun.h (revision c71bc7e269286e43816004eb0fcd7a55f036cd69)
1b2346922Stholo /* Interface header file for GNU DIFF library.
2b2346922Stholo    Copyright (C) 1998 Free Software Foundation, Inc.
3b2346922Stholo 
4b2346922Stholo This file is part of GNU DIFF.
5b2346922Stholo 
6b2346922Stholo GNU DIFF is free software; you can redistribute it and/or modify
7b2346922Stholo it under the terms of the GNU General Public License as published by
8b2346922Stholo the Free Software Foundation; either version 2, or (at your option)
9b2346922Stholo any later version.
10b2346922Stholo 
11b2346922Stholo GNU DIFF is distributed in the hope that it will be useful,
12b2346922Stholo but WITHOUT ANY WARRANTY; without even the implied warranty of
13b2346922Stholo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14b2346922Stholo GNU General Public License for more details.
15b2346922Stholo 
16*c71bc7e2Stholo */
17b2346922Stholo 
18b2346922Stholo #ifndef DIFFRUN_H
19b2346922Stholo #define DIFFRUN_H
20b2346922Stholo 
21b2346922Stholo /* This header file defines the interfaces used by the diff library.
22b2346922Stholo    It should be included by programs which use the diff library.  */
23b2346922Stholo 
24b2346922Stholo #include <sys/types.h>
25b2346922Stholo 
26b2346922Stholo #if defined __STDC__ && __STDC__
27b2346922Stholo #define DIFFPARAMS(args) args
28b2346922Stholo #else
29b2346922Stholo #define DIFFPARAMS(args) ()
30b2346922Stholo #endif
31b2346922Stholo 
32b2346922Stholo /* The diff_callbacks structure is used to handle callbacks from the
33b2346922Stholo    diff library.  All output goes through these callbacks.  When a
34b2346922Stholo    pointer to this structure is passed in, it may be NULL.  Also, any
35b2346922Stholo    of the individual callbacks may be NULL.  This means that the
36b2346922Stholo    default action should be taken.  */
37b2346922Stholo 
38b2346922Stholo struct diff_callbacks
39b2346922Stholo {
40b2346922Stholo   /* Write output.  This function just writes a string of a given
41b2346922Stholo      length to the output file.  The default is to fwrite to OUTFILE.
42*c71bc7e2Stholo      If this callback is defined, flush_output must also be defined.
43*c71bc7e2Stholo      If the length is zero, output zero bytes.  */
44b2346922Stholo   void (*write_output) DIFFPARAMS((char const *, size_t));
45b2346922Stholo   /* Flush output.  The default is to fflush OUTFILE.  If this
46b2346922Stholo      callback is defined, write_output must also be defined.  */
47b2346922Stholo   void (*flush_output) DIFFPARAMS((void));
48*c71bc7e2Stholo   /* Write a '\0'-terminated string to stdout.
49*c71bc7e2Stholo      This is called for version and help messages.  */
50b2346922Stholo   void (*write_stdout) DIFFPARAMS((char const *));
51b2346922Stholo   /* Print an error message.  The first argument is a printf format,
52b2346922Stholo      and the next two are parameters.  The default is to print a
53b2346922Stholo      message on stderr.  */
54b2346922Stholo   void (*error) DIFFPARAMS((char const *, char const *, char const *));
55b2346922Stholo };
56b2346922Stholo 
57b2346922Stholo /* Run a diff.  */
58b2346922Stholo 
59b2346922Stholo extern int diff_run DIFFPARAMS((int, char **, char *,
60b2346922Stholo 				const struct diff_callbacks *));
61b2346922Stholo 
62b2346922Stholo /* Run a diff3.  */
63b2346922Stholo 
64b2346922Stholo extern int diff3_run DIFFPARAMS((int, char **, char *,
65b2346922Stholo 				 const struct diff_callbacks *));
66b2346922Stholo 
67b2346922Stholo #undef DIFFPARAMS
68b2346922Stholo 
69b2346922Stholo #endif /* DIFFRUN_H */
70