Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ search(3) — NEXTSTEP 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

text(3)

fileutil(3)

search(3)  —  UNIX Programmer’s Manual

NAME

search - searching utilities

SYNOPSIS

#include <text/search.h>

DESCRIPTION

These functions support non-indexed searching.  They constitute the searching utilities of the text library, libtext.  The link editor searches this library under the "-ltext" option.  Declarations for these functions may be obtained either from the include file <text/search.h>, or from the master include file <text/text.h>. 

SUMMARY

long findWord(FILE ∗f, char ∗word);

Looks up word in the sorted file f, and returns its absolute offset, or -1 if word is not found. 

char ∗ BinarySearch(FILE ∗f, char ∗word);

Searches for word in sorted file f.  Returns the first line containing word, or zero if fIword is not found.  Lines in f are assumed to be at most 1024 bytes long. 

char ∗ binarySearch(FILE ∗f, char ∗word, char ∗s, int (∗compare) ());

Searches for word in f and return the first line containing fIword.  f is presumed to be a sorted file with words beginning in the leftmost column.  s is a string of s_len bytes used to buffer lines in f.  Returns the matching line, or zero if fIword is not found.  f is left pointing to the line immediately following the first line containing all of w.  compare() is called with arguments (word, line), and returns:

 0 if word and line match exactly
-1 if word is a prefix of line
-2 if word precedes line in lexicographical order
1  if line is a prefix of word
2  if line precedes word in lexicographical order
 

The default comparison routine uses literal character comparisons unless the global binarySearchIgnoreCase is non-zero.  Whether or not this flag is used depends on how the index was built. 

void bm_compile(char ∗s);

Compiles a Boyer-Moore skip table for s.  If ignore_case is true, and if s is entirely lower case, the comparison will be case-insensitive. 

char ∗ bm_match(char ∗big, char ∗small, int big_len);

Returns a pointer to where small starts in big, or zero if small was not found.  Initialized with bm_Compile(small). 

uselessToGrep(char ∗file, int fd, struct stat ∗statbuf);

True if file is not usefully greppable ASCII.  If either of fd and statbuf is not supplied, it will be created.  See also filetype(). 

SEE ALSO

text(3), fileutil(3)

NeXT, Inc.  —  July 7, 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026