Next: Strategy Selectors, Up: Strategies [Contents][Index]
The dico_key_t
is defined as a pointer to the structure
dico_key
:
struct dico_key { char *word; void *call_data; dico_strategy_t strat; int flags; };
The structure represents a search key for matching algorithms. Its members are:
char *
word ¶The search word or expression.
void *
call_data ¶A pointer to selector-specific data. If necessary, it can be initialized by the selector when called with the ‘DICO_SELECT_BEGIN’ opcode and deallocated when called with the ‘DICO_SELECT_END’ opcode.
A pointer to the strategy structure.
Key-specific flags. These are used by the server.
The following functions are defined to operate on search keys:
Initialize the key structure key with the given strategy strat and search word word. If strat has a selector function, it will be called with the ‘DICO_SELECT_BEGIN’ opcode (see DICO_SELECT_BEGIN) to carry out the necessary initializations.
The key itself may point to any kind of memory storage.
Deinitialize the dico_key
structure initialized by a prior call
to dico_key_init
. If the key strategy has a selector, it will
be called with the ‘DICO_SELECT_END’ opcode.
Note that this function makes no assumptions about the storage type of key. If it points to a dynamically allocated memory, it is the caller responsibility to free it.
Match headword and key. Return 1 if they match, 0 if they don’t match and -1 in case of error. This function calls the strategy selector with the ‘DICO_SELECT_RUN’ opcode (see DICO_SELECT_RUN). It is an error if the strategy selector is not defined.
Next: Strategy Selectors, Up: Strategies [Contents][Index]