#ifndef _DICTIONARY_H_

#define _DICTIONARY_H_

#include <sys/types.h>

#define MAXENTRIES		9
#define DICTIONARYDIR		"/mit/dictionary"
#define FILELIST		"Filelist"
#define INDEXNAME		"Index"
/*
 * The lines aren't supposed to exceed 80 characters, but we use 100
 * just to be safe.
 */
#define DICTIONARYLINELENGTH	100
#define SOUNDEX_LENGTH		9
/*
 * % matches one character, * matches 0 or more characters
 */
#define DICT_WILD_ONE		'%'
#define DICT_WILD_ANY		'*'
#define DICT_WILD_MAX_MATCHES	100

/*
 * fileNumber_t contains the subscript into the array of filenames of
 * the data files in the dictionary.
 * 
 * fileLocation_t contains a value that can be used with lseek to go
 * to the beginning of the definition in the file.  entryType_t
 * represents either 'F' for a definition of the word, 'V' for a
 * variant on the word, or 'R' for an alternate form of the same word.
 */

typedef int	fileNumber_t;
typedef daddr_t fileLocation_t;
typedef char	entryType_t;
typedef char	boolean_t;

/*
 * The index of the dictionary contains data of type indexEntry_t.
 * Since the indexEntra_t data are stored using the word as the key,
 * there can be only one indexEntry_t per word, and it is not
 * necessary to store the word as part of the indexEntry_t.
 * 
 * Each definition_t contains enough information to actually find the
 * text of the definition in question in the dictionary data files.
 */

typedef struct _definition {
     fileNumber_t	file;
     fileLocation_t	file_position;
} definition_t;

typedef struct	_entry {
     entryType_t	type;
     definition_t	definition;
} entry_t;

typedef struct _indexEntry {
     int	num_entries;
     entry_t	entry[MAXENTRIES];
} indexEntry_t;

extern int	dictInitializePaths();
extern int	dictClearDatabase();
extern int	dictOpenNewDatabase();
extern int	dictOpenDatabaseRead();
extern int	dictOpenDatabaseWrite();
extern int	dictFetchIndexEntry();
extern int	dictFetchDefinition();
extern int	dictSpell();
extern int	dictSearch();
extern int	dictPatternMatches();
extern int	dictMatch();
extern int	dictColumnOutput();

extern char *	dictSoundex();

#endif /* ! _DICTIONARY_H_ */
