|
|
|
|
|
|
|
<HTML> |
|
<HEAD> |
|
<TITLE>BINSRCH(3WN) manual page</TITLE> |
|
</HEAD> |
|
<BODY> |
|
<A HREF="#toc">Table of Contents</A><P> |
|
|
|
<H2><A NAME="sect0" HREF="#toc0">NAME </A></H2> |
|
bin_search, copyfile, replace_line, insert_line |
|
<H2><A NAME="sect1" HREF="#toc1">SYNOPSIS </A></H2> |
|
<P> |
|
<B>char *bin_search(char |
|
*key, FILE *fp); </B> <P> |
|
<B>void copyfile(FILE *fromfp, FILE *tofp); </B> <P> |
|
<B>char *replace_line(char |
|
*new_line, char *key, FILE *fp); </B> <P> |
|
<B>char *insert_line(char *new_line, char |
|
*key, FILE *fp); </B> |
|
<H2><A NAME="sect2" HREF="#toc2">DESCRIPTION </A></H2> |
|
<P> |
|
The WordNet library contains several general |
|
purpose functions for performing a binary search and modifying sorted |
|
files. <P> |
|
<B>bin_search()</B> is the primary binary search algorithm to search for |
|
<I>key </I> as the first item on a line in the file pointed to by <I>fp </I>. The delimiter |
|
between the key and the rest of the fields on the line, if any, must be |
|
a space. A pointer to a static variable containing the entire line is |
|
returned. <FONT SIZE=-1><B>NULL </B></FONT> |
|
is returned if a match is not found. <P> |
|
The remaining functions |
|
are not used by WordNet, and are only briefly described. <P> |
|
<B>copyfile()</B> copies |
|
the contents of one file to another. <P> |
|
<B>replace_line()</B> replaces a line in |
|
a file having searchkey <I>key </I> with the contents of <I>new_line </I>. It returns |
|
the original line or <FONT SIZE=-1><B>NULL </B></FONT> |
|
in case of error. <P> |
|
<B>insert_line()</B> finds the proper |
|
place to insert the contents of <I>new_line </I>, having searchkey <I>key </I> in the |
|
sorted file pointed to by <I>fp </I>. It returns <FONT SIZE=-1><B>NULL </B></FONT> |
|
if a line with this searchkey |
|
is already in the file. |
|
<H2><A NAME="sect3" HREF="#toc3">NOTES </A></H2> |
|
The maximum length of <I>key </I> is 1024. <P> |
|
The |
|
maximum line length in a file is 25K. <P> |
|
If there are no additional fields |
|
after the search key, the key must be followed by at least one space before |
|
the newline character. |
|
<H2><A NAME="sect4" HREF="#toc4">SEE ALSO </A></H2> |
|
<B><A HREF="wnintro.3WN.html">wnintro</B>(3WN)</A> |
|
, <B><A HREF="morph.3WN.html">morph</B>(3WN)</A> |
|
, <B><A HREF="wnsearch.3WN.html">wnsearch</B>(3WN)</A> |
|
, |
|
<B><A HREF="wnutil.3WN.html">wnutil</B>(3WN)</A> |
|
, <B><A HREF="wnintro.5WN.html">wnintro</B>(5WN)</A> |
|
. |
|
<H2><A NAME="sect5" HREF="#toc5">WARNINGS </A></H2> |
|
<B>binsearch() </B> returns a pointer to |
|
a static character buffer. The returned string should be copied by the |
|
caller if the results need to be saved, as a subsequent call will replace |
|
the contents of the static buffer. <P> |
|
<P> |
|
|
|
<HR><P> |
|
<A NAME="toc"><B>Table of Contents</B></A><P> |
|
<UL> |
|
<LI><A NAME="toc0" HREF="#sect0">NAME</A></LI> |
|
<LI><A NAME="toc1" HREF="#sect1">SYNOPSIS</A></LI> |
|
<LI><A NAME="toc2" HREF="#sect2">DESCRIPTION</A></LI> |
|
<LI><A NAME="toc3" HREF="#sect3">NOTES</A></LI> |
|
<LI><A NAME="toc4" HREF="#sect4">SEE ALSO</A></LI> |
|
<LI><A NAME="toc5" HREF="#sect5">WARNINGS</A></LI> |
|
</UL> |
|
</BODY></HTML> |
|
|