1 /* search.h -- Structure used to search large bodies of text, with bounds.
2 $Id: search.h,v 1.8 2008/06/11 09:02:11 gray Exp $
4 Copyright (C) 1993, 1997, 1998, 2002, 2004, 2007
5 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 Originally written by Brian Fox (bfox@ai.mit.edu). */
22 /* The search functions take two arguments:
24 1) a string to search for, and
26 2) a pointer to a SEARCH_BINDING which contains the buffer, start,
27 and end of the search.
29 They return a long, which is the offset from the start of the buffer
30 at which the match was found. An offset of -1 indicates failure. */
36 char *buffer; /* The buffer of text to search. */
37 long start; /* Offset of the start of the search. */
38 long end; /* Offset of the end of the searh. */
39 int flags; /* Flags controlling the type of search. */
42 #define S_FoldCase 0x01 /* Set means fold case in searches. */
43 #define S_SkipDest 0x02 /* Set means return pointing after the dest. */
45 SEARCH_BINDING *make_binding (char *buffer, long int start, long int end);
46 SEARCH_BINDING *copy_binding (SEARCH_BINDING *binding);
47 extern long search_forward (char *string, SEARCH_BINDING *binding);
48 extern long search_backward (char *input_string, SEARCH_BINDING *binding);
49 extern long search (char *string, SEARCH_BINDING *binding);
50 extern long regexp_search (char *regexp, SEARCH_BINDING *binding, long length,
51 SEARCH_BINDING *pret);
52 extern int looking_at (char *string, SEARCH_BINDING *binding);
54 /* Note that STRING_IN_LINE () always returns the offset of the 1st character
56 extern int string_in_line (char *string, char *line);
58 /* Function names that start with "skip" are passed a string, and return
59 an offset from the start of that string. Function names that start
60 with "find" are passed a SEARCH_BINDING, and return an absolute position
61 marker of the item being searched for. "Find" functions return a value
62 of -1 if the item being looked for couldn't be found. */
63 extern int skip_whitespace (char *string);
64 extern int skip_non_whitespace (char *string);
65 extern int skip_whitespace_and_newlines (char *string);
66 extern int skip_line (char *string);
67 extern int skip_node_characters (char *string, int newlines_okay);
68 extern int skip_node_separator (char *body);
70 #define DONT_SKIP_NEWLINES 0
71 #define SKIP_NEWLINES 1
73 extern long find_node_separator (SEARCH_BINDING *binding);
74 extern long find_tags_table (SEARCH_BINDING *binding);
75 extern long find_node_in_binding (char *nodename, SEARCH_BINDING *binding);
77 #endif /* not INFO_SEARCH_H */