bin_search, copyfile, replace_line, insert_line
char *bin_search(char *key, FILE *fp);
void copyfile(FILE *fromfp, FILE *tofp);
char *replace_line(char *new_line, char *key, FILE *fp);
char *insert_line(char *new_line, char *key, FILE *fp);
The WordNet library contains several general purpose functions for performing a
binary search and modifying sorted files.
is the primary binary search algorithm to search for
as the first item on a line in the file pointed to by fp
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
is returned if a match is not found.
The remaining functions are not used by WordNet, and are only briefly described.
copies the contents of one file to another.
replaces a line in a file having searchkey key
the contents of new_line
. It returns the original line or
in case of error.
finds the proper place to insert the contents of
, having searchkey key
in the sorted file pointed to by
. It returns NULL
if a line with this searchkey
is already in the file.
The maximum length of key
The maximum line length in a file is 25K.
If there are no additional fields after the search key, the key must be followed
by at least one space before the newline character.
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.