1 /*******************************************************************************
2 This file is part of WhiteStork.
4 WhiteStork is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 WhiteStork is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with WhiteStork; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 Copyright 2006 ComArch S.A.
19 *******************************************************************************/
23 #include <dictionary_engine.h>
26 getting_additional get_functions; // additinal functions for concrete module (e.g. XDXF)
28 void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
29 printf((gchar*)user_data,pattern);
31 while(g_array_index(list, gchar*, i) != NULL)
33 printf(" %d. : %s\n",i+1,g_array_index(list, gchar*, i));
36 printf("--------------------------------------------------\n");
39 void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
40 printf((gchar*)user_data,word);
41 printf("%s\n\nTRANSLATION ENDS.\n",translation);
44 void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
45 printf((gchar*)user_data,value);
48 int main(int argc, char** argv)
50 char* nameApp = "StarDictEngine test: ";
51 printf("%sStarting test program of module: dictionary_engine.\n",nameApp);
54 gchar* current_directory = g_get_current_dir();
55 printf("%sCurrent directory: %s\n",nameApp,current_directory);
56 gchar* library_to_path = g_strconcat(current_directory, "/ws_bookmark.so", NULL);
57 printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
59 GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
61 printf("%sLoading module failed. \nReason: %s\n",nameApp,g_module_error());
65 //dict_eng_module_get_global_functions(library,get_functions);
66 g_module_symbol ( (library),_GLOBAL_FUNCTIONS_NAME_, (gpointer)&get_functions);
67 if(get_functions == NULL) {
68 printf("%sLoading function failed\n",nameApp);
71 else printf("%sLoading function OK\n",nameApp);
73 EngineModule module = get_functions();
74 printf("Module description: %s\n",dict_eng_module_get_description(module));
77 gboolean is_compatible = dict_eng_module_check(module,"/home/str/whitestork/engines/bookmark/ws_bookmarks");
78 if(is_compatible == TRUE)
80 printf("Location is compatible with enigne!\n");
83 printf("Location is not compatible with enigne!\n");
87 //printf("%sCheck OK. Module description: %s\n", nameApp, dict_eng_module_get_description(module));
89 //xdxf = dict_eng_module_create_ext(module, "/home/lukasz/MyDocs/repo/WhiteStork/trunk/engine/bin" , ENGINE_CREATE, caching_progress, "Current progress of caching is: %0.2f.\n", 0.03 );
90 //home/stranger/whitestork/engine0.2/
91 // xdxf = dict_eng_module_create(module, "/home/stranger/whitestork/engine0.2/" , ENGINE_NO);
92 // dict_eng_set_callback(xdxf, ENGINE_PROGRESS_CACHING, caching_progress, "Current progress of caching is: %0.2f.\n");
93 // dict_eng_set_progress_seed(xdxf, ENGINE_PROGRESS_CACHING, 0.02);
95 /* if(dict_eng_is_optimized(xdxf) == FALSE)
97 printf("Dictionary has no cache!\nCreating cache file....\n");
98 dict_eng_optimize(xdxf);
101 printf("Dictionary has already cache file!\n");
103 sd = dict_eng_module_create(module,
104 "/home/str/whitestork/engines/bookmark/ws_bookmarks" ,
106 printf("Lokacja: %s\n",dict_eng_get_location(sd));
108 dict_eng_set_callback(sd,
109 ENGINE_WORD_LIST_SIGNAL,
111 "Word list matches to pattern: %s\n"
113 dict_eng_set_callback(sd,
114 ENGINE_WORD_TRANSLATION_SIGNAL ,
116 "Translation for word\'%s\':\n");
118 dict_eng_search_word_list(sd,"12");
119 //dict_eng_search_word_translation(sd,"1 word");
121 dict_eng_remove_word(sd, "stranger");
122 dict_eng_remove_word(sd, "gandzia");
123 dict_eng_remove_word(sd, "lukas");
124 dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
125 dict_eng_add_word(sd, "gandzia", "rulez");
126 dict_eng_add_word(sd, "lukas", "pawlik");
127 dict_eng_remove_word(sd, "stranger");
129 dict_eng_search_word_translation(sd,"stranger");
131 dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
132 dict_eng_search_word_translation(sd,"stranger");
133 dict_eng_search_word_list(sd,"gandzia");
135 printf("Lang FROM:%s\n",dict_eng_get_lang_from(sd));
136 printf(" Lang TO:%s\n",dict_eng_get_lang_to(sd));
137 printf(" Title:%s\n",dict_eng_get_title(sd));
138 printf("Icon path:%s\n",dict_eng_get_icon_path(sd));
140 dict_eng_destroy(sd);
141 printf("%sClosed.\n",nameApp);