| Commit | Line | Data |
|---|---|---|
| 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 | ||
| 6 | This file is part of groff. | |
| 7 | ||
| 8 | groff is free software; you can redistribute it and/or modify it under | |
| 9 | the terms of the GNU General Public License as published by the Free | |
| 4d3e9548 JL |
10 | Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. | |
| 92d0a6a6 JR |
12 | |
| 13 | groff is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 16 | for more details. | |
| 17 | ||
| 4d3e9548 JL |
18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
| 92d0a6a6 JR |
20 | |
| 21 | class search_item; | |
| 22 | class search_item_iterator; | |
| 23 | ||
| 24 | class search_list { | |
| 25 | public: | |
| 26 | search_list(); | |
| 27 | ~search_list(); | |
| 28 | void add_file(const char *fn, int silent = 0); | |
| 29 | int nfiles() const; | |
| 30 | private: | |
| 31 | search_item *list; | |
| 32 | int niterators; | |
| 33 | int next_fid; | |
| 34 | friend class search_list_iterator; | |
| 35 | }; | |
| 36 | ||
| 37 | class bmpattern; | |
| 38 | ||
| 39 | class 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; | |
| 50 | public: | |
| 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 | ||
| 58 | class search_list_iterator { | |
| 59 | search_list *list; | |
| 60 | search_item *ptr; | |
| 61 | search_item_iterator *iter; | |
| 62 | char *query; | |
| 63 | linear_searcher searcher; | |
| 64 | public: | |
| 65 | search_list_iterator(search_list *, const char *query); | |
| 66 | ~search_list_iterator(); | |
| 67 | int next(const char **, int *, reference_id * = 0); | |
| 68 | }; | |
| 69 | ||
| 70 | class search_item { | |
| 71 | protected: | |
| 72 | char *name; | |
| 73 | int filename_id; | |
| 74 | public: | |
| 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 | ||
| 83 | class search_item_iterator { | |
| 84 | char shut_g_plus_plus_up; | |
| 85 | public: | |
| 86 | virtual ~search_item_iterator(); | |
| 87 | virtual int next(const linear_searcher &, const char **ptr, int *lenp, | |
| 88 | reference_id *) = 0; | |
| 89 | }; | |
| 90 | ||
| 91 | search_item *make_index_search_item(const char *filename, int fid); | |
| 92 | search_item *make_linear_search_item(int fd, const char *filename, int fid); | |
| 93 | ||
| 94 | extern int linear_truncate_len; | |
| 95 | extern const char *linear_ignore_fields; | |
| 96 | extern int verify_flag; |