forked from jleffler/scc-snapshots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter.h
89 lines (74 loc) · 3.19 KB
/
filter.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
@(#)File: $RCSfile: filter.h,v $
@(#)Version: $Revision: 2015.2 $
@(#)Last changed: $Date: 2015/02/17 04:51:48 $
@(#)Purpose: Header for filter functions
@(#)Author: J Leffler
@(#)Copyright: (C) JLSS 1993,1995-98,2003-04,2006,2008,2014-15
@(#)Product: SCC Version 8.0.3 (2022-05-30)
*/
/*TABSTOP=4*/
#ifndef FILTER_H
#define FILTER_H
#ifdef MAIN_PROGRAM
#ifndef lint
/* Prevent over-aggressive optimizers from eliminating ID string */
extern const char jlss_id_filter_h[];
const char jlss_id_filter_h[] = "@(#)$Id: filter.h,v 2015.2 2015/02/17 04:51:48 jleffler Exp $";
#endif /* lint */
#endif /* MAIN_PROGRAM */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
/* Classic mode - not recommended for new programs */
/* Non-const file name; no error status feedback */
/* Source: filter.c */
typedef void (*ClassicFilter)(FILE *ifp, char *fn);
extern void filter(int argc, char **argv, int optnum, ClassicFilter function);
/* No file name at all; no error status feedback */
/* Source: filtera.c */
typedef void (*ClassicFilterAnon)(FILE *ifp);
extern void filter_anon(int argc, char **argv, int optnum, ClassicFilterAnon function);
/* Modern mode 1 - without output file specified */
/* Source: stdfilter.c */
typedef int (*StdoutFilter)(FILE *ifp, const char *fn);
extern int filter_stdout(int argc, char **argv, int optnum, StdoutFilter function);
/* Modern mode 1 - without output file specified */
/* Source: stdfiltera.c */
typedef int (*StdoutFilterAnon)(FILE *ifp);
extern int filter_stdout_anon(int argc, char **argv, int optnum, StdoutFilterAnon function);
/* Modern mode 2 - with output file specified */
/* NB: OutputFilter is compatible with AFF code */
/* Source: outfilter.c */
typedef int (*OutputFilter)(FILE *ifp, const char *fn, FILE *ofp);
extern int filter_output(int argc, char **argv, int optnum, OutputFilter function);
/* Modern mode 2 - with output file specified */
/* Source: outfiltera.c */
typedef int (*OutputFilterAnon)(FILE *ifp, FILE *ofp);
extern int filter_output_anon(int argc, char **argv, int optnum, OutputFilterAnon function);
/* Set output file for filter_output() and filter_output_anon() */
/* Returns previous value of the file (does not set new value if passed null pointer). */
/* Source: outfilterso.c */
extern FILE *filter_setoutput(FILE *out);
/* Standard I/O error check code */
/* Used internally by filter_stdout(), filter_stdout_anon(), filter_output() and filter_output_anon(). */
/* Not normally used by client programs. */
/* Source: filterio.c */
extern int filter_io_check(FILE *ifp, const char *ifn, FILE *ofp);
/*
** Number of files to process: enables support for grep-like prefixing
** of output with file name - or not.
** To print file names before output lines, use:
** if (filter_numfiles() > 1)
** printf("%s:%s\n", filename, line);
** else
** puts(line);
** Call filter_setnumfiles(0) to reset to default state (seldom needed).
** Call filter_setnumfiles(1) to suppress headings (grep -h).
** Call filter_setnumfiles(2) to force headings (grep -H).
** Source: filterio.c
*/
extern int filter_numfiles(void);
extern void filter_setnumfiles(int num);
#endif /* FILTER_H */