Back to index

tetex-bin  3.0
search.h
Go to the documentation of this file.
00001 /* search.h -- Structure used to search large bodies of text, with bounds.
00002    $Id: search.h,v 1.3 2004/04/11 17:56:46 karl Exp $
00003 
00004    Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2, or (at your option)
00009    any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 
00020    Written by Brian Fox (bfox@ai.mit.edu). */
00021 
00022 /* The search functions take two arguments:
00023 
00024      1) a string to search for, and
00025 
00026      2) a pointer to a SEARCH_BINDING which contains the buffer, start,
00027         and end of the search.
00028 
00029    They return a long, which is the offset from the start of the buffer
00030    at which the match was found.  An offset of -1 indicates failure. */
00031 
00032 #ifndef INFO_SEARCH_H
00033 #define INFO_SEARCH_H
00034 
00035 typedef struct {
00036   char *buffer;                 /* The buffer of text to search. */
00037   long start;                   /* Offset of the start of the search. */
00038   long end;                     /* Offset of the end of the searh. */
00039   int flags;                    /* Flags controlling the type of search. */
00040 } SEARCH_BINDING;
00041 
00042 #define S_FoldCase      0x01    /* Set means fold case in searches. */
00043 #define S_SkipDest      0x02    /* Set means return pointing after the dest. */
00044 
00045 SEARCH_BINDING *make_binding (char *buffer, long int start, long int end);
00046 SEARCH_BINDING *copy_binding (SEARCH_BINDING *binding);
00047 extern long search_forward (char *string, SEARCH_BINDING *binding);
00048 extern long search_backward (char *input_string, SEARCH_BINDING *binding);
00049 extern long search (char *string, SEARCH_BINDING *binding);
00050 extern int looking_at (char *string, SEARCH_BINDING *binding);
00051 
00052 /* Note that STRING_IN_LINE () always returns the offset of the 1st character
00053    after the string. */
00054 extern int string_in_line (char *string, char *line);
00055 
00056 /* Function names that start with "skip" are passed a string, and return
00057    an offset from the start of that string.  Function names that start
00058    with "find" are passed a SEARCH_BINDING, and return an absolute position
00059    marker of the item being searched for.  "Find" functions return a value
00060    of -1 if the item being looked for couldn't be found. */
00061 extern int skip_whitespace (char *string);
00062 extern int skip_non_whitespace (char *string);
00063 extern int skip_whitespace_and_newlines (char *string);
00064 extern int skip_line (char *string);
00065 extern int skip_node_characters (char *string, int newlines_okay);
00066 extern int skip_node_separator (char *body);
00067 
00068 #define DONT_SKIP_NEWLINES 0
00069 #define SKIP_NEWLINES 1
00070 
00071 extern long find_node_separator (SEARCH_BINDING *binding);
00072 extern long find_tags_table (SEARCH_BINDING *binding);
00073 extern long find_node_in_binding (char *nodename, SEARCH_BINDING *binding);
00074 
00075 #endif /* not INFO_SEARCH_H */