xref: /netbsd/external/gpl2/texinfo/dist/info/search.h (revision dc174305)
1*dc174305Schristos /*	$NetBSD: search.h,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $	*/
2*dc174305Schristos 
3*dc174305Schristos /* search.h -- Structure used to search large bodies of text, with bounds.
4*dc174305Schristos    Id: search.h,v 1.3 2004/04/11 17:56:46 karl Exp
5*dc174305Schristos 
6*dc174305Schristos    Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc.
7*dc174305Schristos 
8*dc174305Schristos    This program is free software; you can redistribute it and/or modify
9*dc174305Schristos    it under the terms of the GNU General Public License as published by
10*dc174305Schristos    the Free Software Foundation; either version 2, or (at your option)
11*dc174305Schristos    any later version.
12*dc174305Schristos 
13*dc174305Schristos    This program is distributed in the hope that it will be useful,
14*dc174305Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
15*dc174305Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*dc174305Schristos    GNU General Public License for more details.
17*dc174305Schristos 
18*dc174305Schristos    You should have received a copy of the GNU General Public License
19*dc174305Schristos    along with this program; if not, write to the Free Software
20*dc174305Schristos    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*dc174305Schristos 
22*dc174305Schristos    Written by Brian Fox (bfox@ai.mit.edu). */
23*dc174305Schristos 
24*dc174305Schristos /* The search functions take two arguments:
25*dc174305Schristos 
26*dc174305Schristos      1) a string to search for, and
27*dc174305Schristos 
28*dc174305Schristos      2) a pointer to a SEARCH_BINDING which contains the buffer, start,
29*dc174305Schristos         and end of the search.
30*dc174305Schristos 
31*dc174305Schristos    They return a long, which is the offset from the start of the buffer
32*dc174305Schristos    at which the match was found.  An offset of -1 indicates failure. */
33*dc174305Schristos 
34*dc174305Schristos #ifndef INFO_SEARCH_H
35*dc174305Schristos #define INFO_SEARCH_H
36*dc174305Schristos 
37*dc174305Schristos typedef struct {
38*dc174305Schristos   char *buffer;                 /* The buffer of text to search. */
39*dc174305Schristos   long start;                   /* Offset of the start of the search. */
40*dc174305Schristos   long end;                     /* Offset of the end of the searh. */
41*dc174305Schristos   int flags;                    /* Flags controlling the type of search. */
42*dc174305Schristos } SEARCH_BINDING;
43*dc174305Schristos 
44*dc174305Schristos #define S_FoldCase      0x01    /* Set means fold case in searches. */
45*dc174305Schristos #define S_SkipDest      0x02    /* Set means return pointing after the dest. */
46*dc174305Schristos 
47*dc174305Schristos SEARCH_BINDING *make_binding (char *buffer, long int start, long int end);
48*dc174305Schristos SEARCH_BINDING *copy_binding (SEARCH_BINDING *binding);
49*dc174305Schristos extern long search_forward (char *string, SEARCH_BINDING *binding);
50*dc174305Schristos extern long search_backward (char *input_string, SEARCH_BINDING *binding);
51*dc174305Schristos extern long search (char *string, SEARCH_BINDING *binding);
52*dc174305Schristos extern int looking_at (char *string, SEARCH_BINDING *binding);
53*dc174305Schristos 
54*dc174305Schristos /* Note that STRING_IN_LINE () always returns the offset of the 1st character
55*dc174305Schristos    after the string. */
56*dc174305Schristos extern int string_in_line (char *string, char *line);
57*dc174305Schristos 
58*dc174305Schristos /* Function names that start with "skip" are passed a string, and return
59*dc174305Schristos    an offset from the start of that string.  Function names that start
60*dc174305Schristos    with "find" are passed a SEARCH_BINDING, and return an absolute position
61*dc174305Schristos    marker of the item being searched for.  "Find" functions return a value
62*dc174305Schristos    of -1 if the item being looked for couldn't be found. */
63*dc174305Schristos extern int skip_whitespace (char *string);
64*dc174305Schristos extern int skip_non_whitespace (char *string);
65*dc174305Schristos extern int skip_whitespace_and_newlines (char *string);
66*dc174305Schristos extern int skip_line (char *string);
67*dc174305Schristos extern int skip_node_characters (char *string, int newlines_okay);
68*dc174305Schristos extern int skip_node_separator (char *body);
69*dc174305Schristos 
70*dc174305Schristos #define DONT_SKIP_NEWLINES 0
71*dc174305Schristos #define SKIP_NEWLINES 1
72*dc174305Schristos 
73*dc174305Schristos extern long find_node_separator (SEARCH_BINDING *binding);
74*dc174305Schristos extern long find_tags_table (SEARCH_BINDING *binding);
75*dc174305Schristos extern long find_node_in_binding (char *nodename, SEARCH_BINDING *binding);
76*dc174305Schristos 
77*dc174305Schristos #endif /* not INFO_SEARCH_H */
78