142660Smarkm/* search.h -- Structure used to search large bodies of text, with bounds. 2146515Sru $Id: search.h,v 1.3 2004/04/11 17:56:46 karl Exp $ 321495Sjmacd 4146515Sru Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc. 521495Sjmacd 621495Sjmacd This program is free software; you can redistribute it and/or modify 721495Sjmacd it under the terms of the GNU General Public License as published by 821495Sjmacd the Free Software Foundation; either version 2, or (at your option) 921495Sjmacd any later version. 1021495Sjmacd 1121495Sjmacd This program is distributed in the hope that it will be useful, 1221495Sjmacd but WITHOUT ANY WARRANTY; without even the implied warranty of 1321495Sjmacd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1421495Sjmacd GNU General Public License for more details. 1521495Sjmacd 1621495Sjmacd You should have received a copy of the GNU General Public License 1721495Sjmacd along with this program; if not, write to the Free Software 1821495Sjmacd Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 1921495Sjmacd 2021495Sjmacd Written by Brian Fox (bfox@ai.mit.edu). */ 2121495Sjmacd 2221495Sjmacd/* The search functions take two arguments: 2321495Sjmacd 2421495Sjmacd 1) a string to search for, and 2521495Sjmacd 2621495Sjmacd 2) a pointer to a SEARCH_BINDING which contains the buffer, start, 2721495Sjmacd and end of the search. 2821495Sjmacd 2921495Sjmacd They return a long, which is the offset from the start of the buffer 3021495Sjmacd at which the match was found. An offset of -1 indicates failure. */ 3121495Sjmacd 3242660Smarkm#ifndef INFO_SEARCH_H 3342660Smarkm#define INFO_SEARCH_H 3421495Sjmacd 3521495Sjmacdtypedef struct { 3642660Smarkm char *buffer; /* The buffer of text to search. */ 3742660Smarkm long start; /* Offset of the start of the search. */ 3842660Smarkm long end; /* Offset of the end of the searh. */ 3942660Smarkm int flags; /* Flags controlling the type of search. */ 4021495Sjmacd} SEARCH_BINDING; 4121495Sjmacd 4242660Smarkm#define S_FoldCase 0x01 /* Set means fold case in searches. */ 4342660Smarkm#define S_SkipDest 0x02 /* Set means return pointing after the dest. */ 4421495Sjmacd 45146515SruSEARCH_BINDING *make_binding (char *buffer, long int start, long int end); 46146515SruSEARCH_BINDING *copy_binding (SEARCH_BINDING *binding); 47146515Sruextern long search_forward (char *string, SEARCH_BINDING *binding); 48146515Sruextern long search_backward (char *input_string, SEARCH_BINDING *binding); 49146515Sruextern long search (char *string, SEARCH_BINDING *binding); 50146515Sruextern int looking_at (char *string, SEARCH_BINDING *binding); 5121495Sjmacd 5221495Sjmacd/* Note that STRING_IN_LINE () always returns the offset of the 1st character 5321495Sjmacd after the string. */ 54146515Sruextern int string_in_line (char *string, char *line); 5521495Sjmacd 5621495Sjmacd/* Function names that start with "skip" are passed a string, and return 5721495Sjmacd an offset from the start of that string. Function names that start 5821495Sjmacd with "find" are passed a SEARCH_BINDING, and return an absolute position 5921495Sjmacd marker of the item being searched for. "Find" functions return a value 6021495Sjmacd of -1 if the item being looked for couldn't be found. */ 61146515Sruextern int skip_whitespace (char *string); 62146515Sruextern int skip_non_whitespace (char *string); 63146515Sruextern int skip_whitespace_and_newlines (char *string); 64146515Sruextern int skip_line (char *string); 65146515Sruextern int skip_node_characters (char *string, int newlines_okay); 66146515Sruextern int skip_node_separator (char *body); 67146515Sru 6821495Sjmacd#define DONT_SKIP_NEWLINES 0 6921495Sjmacd#define SKIP_NEWLINES 1 7021495Sjmacd 71146515Sruextern long find_node_separator (SEARCH_BINDING *binding); 72146515Sruextern long find_tags_table (SEARCH_BINDING *binding); 73146515Sruextern long find_node_in_binding (char *nodename, SEARCH_BINDING *binding); 7421495Sjmacd 7542660Smarkm#endif /* not INFO_SEARCH_H */ 76