1BINSRCH(3) WordNet™ Library Functions BINSRCH(3)
2
3
4
6 bin_search, copyfile, replace_line, insert_line - general purpose func‐
7 tions for performing a binary search
8
10 char *bin_search(char *key, FILE *fp);
11
12 void copyfile(FILE *fromfp, FILE *tofp);
13
14 char *replace_line(char *new_line, char *key, FILE *fp);
15
16 char *insert_line(char *new_line, char *key, FILE *fp);
17
19 The WordNet library contains several general purpose functions for per‐
20 forming a binary search and modifying sorted files.
21
22 bin_search() is the primary binary search algorithm to search for key
23 as the first item on a line in the file pointed to by fp. The delim‐
24 iter between the key and the rest of the fields on the line, if any,
25 must be a space. A pointer to a static variable containing the entire
26 line is returned. NULL is returned if a match is not found.
27
28 The remaining functions are not used by WordNet, and are only briefly
29 described.
30
31 copyfile() copies the contents of one file to another.
32
33 replace_line() replaces a line in a file having searchkey key with the
34 contents of new_line. It returns the original line or NULL in case of
35 error.
36
37 insert_line() finds the proper place to insert the contents of
38 new_line, having searchkey key in the sorted file pointed to by fp. It
39 returns NULL if a line with this searchkey is already in the file.
40
42 The maximum length of key is 1024.
43
44 The maximum line length in a file is 25K.
45
46 If there are no additional fields after the search key, the key must be
47 followed by at least one space before the newline character.
48
50 wnintro(3), morph(3), wnsearch(3), wnutil(3), wnintro(5).
51
53 binsearch() returns a pointer to a static character buffer. The
54 returned string should be copied by the caller if the results need to
55 be saved, as a subsequent call will replace the contents of the static
56 buffer.
57
58
59
60
61WordNet 3.0 Dec 2006 BINSRCH(3)