dic.c File Reference


Detailed Description

Dawg dictionary.

Author:
Antoine Fraboulet
Date:
2002

Definition in file dic.c.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "dic_internals.h"
#include "dic.h"

Go to the source code of this file.

Functions

static int check_header (FILE *file, Dict_header *header)
int Dic_load (Dictionary *dic, const char *path)
 Dictionary creation and loading from a file.
int Dic_destroy (Dictionary dic)
 Destroy a dictionary.
dic_elt_t Dic_next (Dictionary d, dic_elt_t e)
 Returns the next available neighbor (see Dic_last).
dic_elt_t Dic_succ (Dictionary d, dic_elt_t e)
 Returns the first element available at the next depth in the dictionary dic : dictionary elt : current dictionary element.
dic_elt_t Dic_root (Dictionary d)
 Returns the root of the dictionary.
char Dic_chr (Dictionary d, dic_elt_t e)
 Dic_chr returns the character associated with an element (in the range ['A'-'Z']), or the null character ('').
int Dic_last (Dictionary d, dic_elt_t e)
 Returns a boolean to show if there is another available character in the current depth (a neighbor in the tree).
int Dic_word (Dictionary d, dic_elt_t e)
 Returns a boolean to show if we are at the end of a word (see Dic_next).
unsigned int Dic_lookup (Dictionary d, dic_elt_t root, char *s)
 Find the dictionary element matching the pattern starting from the given root node by walking the dictionary tree dic : valid dictionary root : starting dictionary node for the search pattern : string made of uppercase characters in the range ['A'-'Z'].


Function Documentation

static int check_header FILE *  file,
Dict_header header
[static]
 

Definition at line 37 of file dic.c.

References _COMPIL_KEYWORD_, and _Dict_header::ident.

Referenced by Dic_load().

char Dic_chr Dictionary  dic,
dic_elt_t  elt
 

Dic_chr returns the character associated with an element (in the range ['A'-'Z']), or the null character ('').

Returns:
ASCII code for the character

Definition at line 128 of file dic.c.

References _Dictionary::dawg.

Referenced by Board_checkout_tile(), Dic_lookup(), ExtendRight(), and LeftPart().

int Dic_destroy Dictionary  dic  ) 
 

Destroy a dictionary.

Definition at line 84 of file dic.c.

References _Dictionary::dawg.

Referenced by main(), print_dic_hex(), print_dic_list(), and MainFrame::~MainFrame().

int Dic_last Dictionary  dic,
dic_elt_t  elt
 

Returns a boolean to show if there is another available character in the current depth (a neighbor in the tree).

Returns:
0 or 1 (true)

Definition at line 139 of file dic.c.

References _Dictionary::dawg.

Referenced by Board_checkout_tile(), Dic_lookup(), and Dic_next().

int Dic_load Dictionary dic,
const char *  path
 

Dictionary creation and loading from a file.

Parameters:
dic : pointer to a dictionary
path : compressed dictionary path
Returns:
0 ok, 1 error

Definition at line 46 of file dic.c.

References check_header(), _Dict_header::edgesused, _Dict_header::nodesused, _Dict_header::nwords, _Dictionary::root, and _Dict_header::root.

Referenced by GameFactory::createFromCmdLine(), dic_load(), EVT_TEXT_ENTER(), and main().

unsigned int Dic_lookup Dictionary  dic,
dic_elt_t  root,
char *  pattern
 

Find the dictionary element matching the pattern starting from the given root node by walking the dictionary tree dic : valid dictionary root : starting dictionary node for the search pattern : string made of uppercase characters in the range ['A'-'Z'].

The pattern must be null ('') terminated

Returns:
0 if the string cannot be matched otherwise returns the element that results from walking the dictionary according to the pattern

Definition at line 153 of file dic.c.

References Dic_chr(), Dic_last(), Dic_next(), and Dic_succ().

Referenced by Board_checkout_tile().

dic_elt_t Dic_next Dictionary  dic,
dic_elt_t  elt
 

Returns the next available neighbor (see Dic_last).

Returns:
next dictionary element at the same depth

Definition at line 105 of file dic.c.

References Dic_last().

Referenced by Board_checkout_tile(), Dic_lookup(), ExtendRight(), and LeftPart().

dic_elt_t Dic_root Dictionary  dic  ) 
 

Returns the root of the dictionary.

Returns:
root element

Definition at line 121 of file dic.c.

References _Dictionary::root.

Referenced by Board_checkout_tile(), BoardSearchAux(), and Board::searchFirst().

dic_elt_t Dic_succ Dictionary  dic,
dic_elt_t  elt
 

Returns the first element available at the next depth in the dictionary dic : dictionary elt : current dictionary element.

Returns:
next element (successor)

Definition at line 114 of file dic.c.

References _Dictionary::dawg.

Referenced by Board_checkout_tile(), Dic_lookup(), ExtendRight(), and LeftPart().

int Dic_word Dictionary  dic,
dic_elt_t  elt
 

Returns a boolean to show if we are at the end of a word (see Dic_next).

Returns:
0 or 1 (true)

Definition at line 146 of file dic.c.

References _Dictionary::dawg.

Referenced by Board_checkout_tile(), and ExtendRight().


Generated on Thu Dec 29 02:01:15 2005 for Eliot by  doxygen 1.4.5