1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#ifndef _DICTDPLUGIN_H_
#define _DICTDPLUGIN_H_
#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS
# define __END_DECLS
#endif
__BEGIN_DECLS
/*
The following mask is added to the search strategy
and passed to plugin
if search type is 'match'
*/
#define DICT_MATCH_MASK 0x8000
/*
EACH FUNCTION RETURNS ZERO IF SUCCESS
*/
typedef struct dictPluginData {
int id; /* DICT_PLUGIN_INITDATA_XXX constant */
int size;
const void *data;
} dictPluginData;
typedef struct dictPluginData_strategy {
int number;
char name [20];
} dictPluginData_strategy;
/*
Initializes dictionary and returns zero if success.
*/
typedef int (*dictdb_open_type)
(
const dictPluginData *init_data, /* in: data for initializing dictionary */
int init_data_size, /* in: a number of dictPluginData strctures */
int *version, /* out: version of plugin's interface*/
void ** dict_data /* out: plugin's global data */
);
enum {
DICT_PLUGIN_INITDATA_DICT, /* data from .dict or configuration file */
DICT_PLUGIN_INITDATA_DBNAME, /* database name */
DICT_PLUGIN_INITDATA_STRATEGY, /* search strategy */
DICT_PLUGIN_INITDATA_DEFDBDIR, /* default directory for databases */
DICT_PLUGIN_INITDATA_ALPHABET_8BIT, /* alphanumeric and space characters for 8bit charset*/
DICT_PLUGIN_INITDATA_ALPHABET_ASCII, /* alphanumeric and space characters for ASCII*/
/* this list can be enlarged*/
};
enum {
DICT_PLUGIN_SETDATA_MATCHESCOUNT,
/* this list can be enlarged*/
};
/*
* Returns error message or NULL if last operation returned success.
*/
typedef const char *(*dictdb_error_type) (
void * dict_data /* in: plugin's global data */
);
/*
* Deinitializes dictionary and returns zero if success.
* This function MUST ALWAYS BE called after dictdb_init.
*/
typedef int (*dictdb_close_type) (
void * dict_data /* in: plugin's global data */
);
enum {
/* the requested word has not been found */
DICT_PLUGIN_RESULT_NOTFOUND,
/* definitions/matches have been found */
DICT_PLUGIN_RESULT_FOUND,
/* don't search any other databases */
DICT_PLUGIN_RESULT_EXIT,
/*
requested word has been preprocessed and the result should be
used for search in the following databases
*/
DICT_PLUGIN_RESULT_PREPROCESS,
/* this list can be enlarged */
};
/*
* Frees data allocated by dictdb_search
*/
typedef int (*dictdb_free_type) (
void * dict_data /* in: plugin's global data */
);
/*
*
*/
typedef int (*dictdb_set_type) (
void * dict_data, /* in: plugin's global data */
const dictPluginData *data,
int data_size
);
/*
*
*
*/
typedef int (*dictdb_search_type) (
void *dict_data, /* in: plugin's global data */
const char *word, /* in: word */
int word_size, /* in: wordsize or -1 for 0-terminated string */
int search_strategy, /* in: search strategy */
int *ret, /* out: result type - DICT_PLUGIN_RESULT_XXX */
const dictPluginData **result_extra, /* out: extra information */
int *result_extra_size, /* out: extra information size */
const char * const* *definitions,/* out: definitions */
const int * *definitions_sizes, /* out: sizes of definitions */
int *definitions_count); /* out: a number of found definitions */
__END_DECLS
#endif /* _DICTDPLUGIN_H_ */
|