/*
 * word.h	This defines the interface for using words in 1down.
 *
 * Copyright (C) 1990 Rob Mayoff.
 */

/*
 * There must be files word3 - word20, each containing a sorted list of words
 * of the length defined by the filename.  For example, word7 must be an
 * alphabetically-sorted list of seven-letter words.  There must be no
 * whitespace or NULLs separating the words.  These files should be
 * generated with the partition program.
 *
 * The fd[] array will be the array of file descriptors on these files.
 * fd[3] is the file descriptor for word3, and fd[20] is the file descriptor
 * for word20.
 */
extern
int	fd[21];

/*
 * Each file will be memory-mapped as a large array of characters; hence, we
 * need a pointer to the begin of each file's memory segment.
 */
extern
char	*word[21];

/*
 * Of course, we need to know how many words there are of each length.
 */
extern
int	numWords[21];

/*
 * We will define a macro that will let us treat the mmap-ed files as an array
 * of arrays (of characters).  Hence, WORD(14, 72) will be the seventy-second
 * word in the 14-character word list.
 */
#define WORD(l,i)	(word[(l)]+(i)*(l))

/*
 * How about a 26x26 array for each word-length.  Each array will store the
 * offsets of the first word beginning with those two letters (or the next
 * word in the list after where said word should be, if there isn't one.)
 */
extern
int	wordOffset[21][26][26];

/*
 * initWords will open and memory-map the word files.
 */
extern
void initWords(void);
