groff: update vendor branch to v1.20.1
[dragonfly.git] / contrib / groff / src / include / search.h
CommitLineData
92d0a6a6 1// -*- C++ -*-
4d3e9548
JL
2/* Copyright (C) 1989, 1990, 1991, 1992, 2004, 2009
3 Free Software Foundation, Inc.
92d0a6a6
JR
4 Written by James Clark (jjc@jclark.com)
5
6This file is part of groff.
7
8groff is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
4d3e9548
JL
10Software Foundation, either version 3 of the License, or
11(at your option) any later version.
92d0a6a6
JR
12
13groff is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
4d3e9548
JL
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>. */
92d0a6a6
JR
20
21class search_item;
22class search_item_iterator;
23
24class search_list {
25public:
26 search_list();
27 ~search_list();
28 void add_file(const char *fn, int silent = 0);
29 int nfiles() const;
30private:
31 search_item *list;
32 int niterators;
33 int next_fid;
34 friend class search_list_iterator;
35};
36
37class bmpattern;
38
39class linear_searcher {
40 const char *ignore_fields;
41 int truncate_len;
42 bmpattern **keys;
43 int nkeys;
44 const char *search_and_check(const bmpattern *key, const char *buf,
45 const char *bufend, const char **start = 0)
46 const;
47 int check_match(const char *buf, const char *bufend, const char *match,
48 int matchlen, const char **cont, const char **start)
49 const;
50public:
51 linear_searcher(const char *query, int query_len,
52 const char *ign, int trunc);
53 ~linear_searcher();
54 int search(const char *buf, const char *bufend,
55 const char **startp, int *lengthp) const;
56};
57
58class search_list_iterator {
59 search_list *list;
60 search_item *ptr;
61 search_item_iterator *iter;
62 char *query;
63 linear_searcher searcher;
64public:
65 search_list_iterator(search_list *, const char *query);
66 ~search_list_iterator();
67 int next(const char **, int *, reference_id * = 0);
68};
69
70class search_item {
71protected:
72 char *name;
73 int filename_id;
74public:
75 search_item *next;
76 search_item(const char *nm, int fid);
77 virtual search_item_iterator *make_search_item_iterator(const char *) = 0;
78 virtual ~search_item();
79 int is_named(const char *) const;
80 virtual int next_filename_id() const;
81};
82
83class search_item_iterator {
84 char shut_g_plus_plus_up;
85public:
86 virtual ~search_item_iterator();
87 virtual int next(const linear_searcher &, const char **ptr, int *lenp,
88 reference_id *) = 0;
89};
90
91search_item *make_index_search_item(const char *filename, int fid);
92search_item *make_linear_search_item(int fd, const char *filename, int fid);
93
94extern int linear_truncate_len;
95extern const char *linear_ignore_fields;
96extern int verify_flag;