* - first step of bookmark code review (header only, and start of code)
authorstranger <dariusz.wiechecki@gmail.com>
Thu, 10 Jan 2008 10:26:51 +0000 (10:26 +0000)
committerstranger <dariusz.wiechecki@gmail.com>
Thu, 10 Jan 2008 10:26:51 +0000 (10:26 +0000)
git-svn-id: file:///svnroot/mdictionary/trunk@229 5bde0345-f819-0410-ac75-e5045f9217cc

src/bookmarks/bdb/include/engine_bookmark.h
src/bookmarks/bdb/src/engine_bookmark.c

index df3bc7a..0f75000 100755 (executable)
@@ -15,8 +15,23 @@ You should have received a copy of the GNU General Public License
 along with mdictionary; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Copyright 2006 ComArch S.A.
+Copyright 2006-2008 ComArch S.A.
 *******************************************************************************/
+/** \defgroup BookmarkEngine Dictionary Engine - Bookmark format
+ * \brief Bookmark Dictionary Engine.
+ *
+ * This is library with dictionary engine supporting bookmarks. It uses Berkeley
+ * DB as a storage method.
+ *
+ * TODO: currently bookmark engine does not support all function from engine
+ * API! It need implementation of API version 0.2 function, like getting icon
+ * path etc.
+ */
+/*@{*/
+/** \file engine_bookmark.h
+ * \brief Header for bookmark dictionary engine.
+ */
+
 #ifndef _DICTIONARY_ENGINE_BOOKMARK
 #define _DICTIONARY_ENGINE_BOOKMARK
 
@@ -24,215 +39,260 @@ Copyright 2006 ComArch S.A.
         extern "C" {
 #endif
 
-//______________________________________________________________________________
-// *****************************************************************************
-//************************************************************* HEADERS SECTION:
-//------------------------------------------------------------------------------
-// headers with unix types/functions - only for timers
+
+/* headers with unix types/functions - only for timers */
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include <fcntl.h>     
-#include <unistd.h>   
-//------------------------------------------------------------------------------
-// header with GLIB definitions/functions/types
+#include <fcntl.h>
+#include <unistd.h>
+
+/* header with GLIB definitions/functions/types */
 #include <glib.h>
-//------------------------------------------------------------------------------
-// header wit engine API
-#include "dictionary_engine.h"
-//------------------------------------------------------------------------------
-// header wit sqlite 2.x API
+
+/* header wit engine API */
+#include <dictionary_engine.h>
+
+/* header with Berkeley DB API */
 #include <db/db.h>
-//------------------------------------------------------------------------------
+
+/* operation on strings */
 #include <string.h>
 
-//______________________________________________________________________________
-// *****************************************************************************
-//********************************************************* DEFINITIONS SECTION:
-//------------------------------------------------------------------------------
-// definitions for timer function - flag telling if we want to start or stop
-// timing
+
+/** \name Timers */
+/*@{*/
+/** \brief Flags telling that we want to start timer. */
 #define TIMER_START     TRUE
+/** \brief Flags telling that we want to stop timer. */
 #define TIMER_STOP      FALSE
-//------------------------------------------------------------------------------
-// definitions of version and format which engine handles
+
+/** \brief Start/stop timers.
+ *
+ * \param start do we want start new timer or end the last one
+ * \param message string which shoul be printed by function while debbuging
+ * \return -1.0 if we start or seconds passed from start if we want to 
+ * stop timer
+ */
+/* in final releases timer capapilities should be removed for increase
+ * performance */
+/* static double bm_timer(gboolean start, gchar* message); */
+
+/*@}*/
+
+/** \brief Version of bookmark engine. */
 static const gchar* DIC_ENG_VERSION = "0.2";
+
+/** \brief Short description of format supported by the current engine. */
 static const gchar* DIC_ENG_FORMAT = "Users' Bookmarks";
-static const gchar* DIC_ENG_DESCRIPTION = "This module handles users' "
-                                          "bookmarks. Based on Berkeley DB 1.85";
-                           
-//------------------------------------------------------------------------------
-// macro for "printing" gboolean statement - "TRUE" or "FALSE"
+
+/** \brief Short description of engine */
+static const gchar* DIC_ENG_DESCRIPTION = "This module handles users' book"
+                                          "marks. Based on Berkeley DB 1.85";
+
+/** \brief Translate boolean value into string. */
 #define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
-//------------------------------------------------------------------------------
 
 
-//______________________________________________________________________________
-// *****************************************************************************
-//****************************************** DATA STRUCTURE DEFINITIONS SECTION:
-//------------------------------------------------------------------------------
-/** \brief Internal data structure of XDXF Engine.
+/** \brief Internal data structure of Bookmark Engine.
  */
 struct _BookData {
-        DB*            db_words;
-       DB*             db_trans;
-        BTREEINFO      info_words;
-       BTREEINFO       info_trans;
-       guint           freeID;
+       DB*                     db_words;
+       /**< \brief Pointer to the database with words */
 
+       DB*                     db_trans;
+       /**< \brief Pointer to the database with translations */
 
+       BTREEINFO               info_words;
+       /**< \brief Structure describing search method in words database */
 
-        gchar*                  dict_path;
-        EngineStatus            last_error;
-        gboolean                auto_free;
+       BTREEINFO               info_trans;
+       /**<\brief Structure describing search method in translations database*/
 
-        cb_progress             cb_progress_caching;
-        gpointer                cb_progress_caching_data;
-        gdouble                 cb_progress_caching_seed;
+       guint                   freeID;
+       /**< \brief next free available id for word */
 
-        cb_progress             cb_progress_word_list;
-        gpointer                cb_progress_word_list_data;
-        gdouble                 cb_progress_word_list_seed;
+       /**< \brief pointer to cache file */
+       gchar*                  dict_path;
+       /**< \brief path to dictionary */
+       EngineStatus            last_error;
+       /**< \brief status of last taken action */
+       gboolean                auto_free;
+       /**< \brief auto free mechanism status: FALSE - off, TRUE - on */
 
-        cb_progress             cb_progress_word_trans;
-        gpointer                cb_progress_word_trans_data;
-        gdouble                 cb_progress_word_trans_seed;
+       cb_progress             cb_progress_caching;
+       /**< \brief pointer to callback function called while informing about 
+        * caching progress */
+       gpointer                cb_progress_caching_data;
+       /**< \brief pointer to data passed to callback function called while
+        * informing about caching progress */
+       gdouble                 cb_progress_caching_seed;
+       /**< \brief how often progress callback should be called. 0.01 mean 
+        * that after each 1% of work callback shoul be called */
 
-        cb_word_list            cb_search_word_list;
-        gpointer                cb_search_word_list_data;
+       cb_progress             cb_progress_word_list;
+       /**< \brief pointer to callback function called while informing about
+        * words list searching progress */
+       gpointer                cb_progress_word_list_data;
+       /**< \brief pointer to data passed to callback function called while
+        * informing about words list searching progress */
+       gdouble                 cb_progress_word_list_seed;
+       /**< \brief how often progress callback should be called. 0.01 mean
+        * that after each 1% of work callback shoul be called */
 
-        cb_word_translation     cb_search_word_trans;
-        gpointer                cb_search_word_trans_data;      
+       cb_progress             cb_progress_word_trans;
+       /**< \brief pointer to callback function called while informing about
+        * word's translation searching progress */
+       gpointer                cb_progress_word_trans_data;
+       /**< \brief pointer to data passed to callback function called while
+        * informing about word's translation searching progress */
+       gdouble                 cb_progress_word_trans_seed;
+       /**< \brief how often progress callback should be called. 0.01 mean
+        * that after each 1% of work callback shoul be called */
+
+       cb_word_list            cb_search_word_list;
+       /**< \brief pointer to callback function called after words list is
+        * found */
+       gpointer                cb_search_word_list_data;
+       /**< \brief pointer to data passed to callback function called after
+        * words list is found */
+
+       cb_word_translation     cb_search_word_trans;
+       /**< \brief pointer to callback function called after word's translation
+        * is found */
+       gpointer                cb_search_word_trans_data;
+       /**< \brief pointer to data passed to callback function called after
+        * word's translation is found */
 };
 typedef struct _BookData        BookData;
-//------------------------------------------------------------------------------
-
-
-//______________________________________________________________________________
-// *****************************************************************************
-//************************************************ ADDITIONAL FUNCTIONS SECTION:
-//------------------------------------------------------------------------------
-// returning concrete part of file
-//static gchar*           read_file_part(FilePart* part, GnomeVFSHandle* file);
-//------------------------------------------------------------------------------
-// convert string to proper path name (no filename, no "/" at the ned, file
-// exist)
-static gchar*           string_to_path(gchar** string);
-//------------------------------------------------------------------------------
-// tells if file is in Bookark Berkeley DB format (file should exist)
-static gboolean        is_Bookmark_db_file(gchar* file); 
-//------------------------------------------------------------------------------
-// start/stop timers -  returnet -1.0 if we start or seconds passed from start 
-// if we want to stop timer
-static double           bm_timer(gboolean start, gchar* message);
-//------------------------------------------------------------------------------
-// create and add new entry to databases
-static gboolean        bm_add_new_entry(gchar* word,
-                                        gchar* translation,
-                                        BookData* data);
-//------------------------------------------------------------------------------
-// load current minimal available free ID fortranslations
+
+
+/** \brief Convert string to proper path name. */
+static gchar* string_to_path(gchar** string);
+
+/** \brief Tells if file is in Bookmarks format (file should exist). */
+static gboolean is_Bookmark_db_file(gchar* file);
+
+/** \brief Add new translation for word */
+static gboolean bm_add_new_entry( gchar* word,
+                                  gchar* translation,
+                                  BookData* data );
+
+/** \brief Get minimal free value available for word's id */
 static void bm_load_freeID(BookData* data);
-//------------------------------------------------------------------------------
-// save current minimal available free ID fortranslations
+
+/** \brief Get minimal free value available for word's id */
 static void bm_save_freeID(BookData* data);
-//------------------------------------------------------------------------------
-// save translation in database under id
-static gboolean bm_add_only_translation(BookData* data,
-                                       gchar* translation,
-                                       guint id);
-//------------------------------------------------------------------------------
+
+/** \brief Add only new translation with id */
+static gboolean bm_add_only_translation( BookData* data,
+                                         gchar* translation,
+                                         guint id );
+
+/** \brief Compare method for searching in translation file */
 static gint bm_compare_key_trans(const DBT *a, const DBT *b);
+
+/** \brief Compare method for searching in words file */
 static gint bm_compare_key_words(const DBT *a, const DBT *b);
-//______________________________________________________________________________
-// *****************************************************************************
-//****************************************************** MAIN FUNCTIONS SECTION:
-//------------------------------------------------------------------------------
-gboolean        bm_engine_add_word(Engine* engine,
-                                 gchar*  word,
-                                 gchar*  translation);
-//------------------------------------------------------------------------------
-gboolean        bm_engine_remove_word(Engine* engine,
-                                     gchar*  word);  
-//------------------------------------------------------------------------------      
-gchar*          bm_engine_get_lang_from(Engine* engine);
-//------------------------------------------------------------------------------
-gchar*          bm_engine_get_lang_to(Engine* engine);
-//------------------------------------------------------------------------------
-gchar*          bm_engine_get_title(Engine* engine);
-//------------------------------------------------------------------------------
-gchar*          bm_engine_get_icon_path(Engine* engine);
 
 
+/** \name Module functions */
+/*@{*/
 
-//------------------------------------------------------------------------------
-// implementation of dict_eng_module_check(module,location) function
+/** \brief dict_eng_module_check() function implementation. */
 gboolean        bm_engine_check(gchar* location);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_module_get_description(module) function
+
+/** \brief dict_eng_module_get_description() function implementation. */
 gchar*          bm_engine_description();
-//------------------------------------------------------------------------------
-// implementation of dict_eng_module_get_format(module) function
+
+/** \brief dict_eng_module_get_format() function implementation. */
 gchar*          bm_engine_format();
-//------------------------------------------------------------------------------
-// implementation of dict_eng_module_get_version(module) function
+
+/** \brief dict_eng_module_get_version() function implementation. */
 gchar*          bm_engine_version();
-//------------------------------------------------------------------------------
-// implementation of dict_eng_module_create(module,location,flags) and
-// dict_eng_module_create_ext(module,location,flags) functions
-Engine*         bm_engine_create(gchar* location, 
-                              EngineOptimizationFlag flags,
-                              cb_progress progress_handler,
-                              gpointer progress_data,
-                              gdouble seed);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_destroy(engine) function
+
+/** \brief dict_eng_module_create() function implementation. */
+Engine*         bm_engine_create( gchar* location, 
+                                  EngineOptimizationFlag flags,
+                                  cb_progress progress_handler,
+                                  gpointer progress_data,
+                                  gdouble seed );
+/*@}*/
+
+/** \name Particular dictionary function */
+/*@{*/
+
+/** \brief dict_eng_add_word() function implementation. */
+gboolean        bm_engine_add_word( Engine* engine,
+                                    gchar*  word,
+                                    gchar*  translation );
+
+/** \brief dict_eng_remove_word() function implementation. */
+gboolean        bm_engine_remove_word( Engine* engine, gchar*  word );
+
+/** \brief dict_eng_get_lang_from() function implementation. */
+gchar*          bm_engine_get_lang_from(Engine* engine);
+
+/** \brief dict_eng_get_lang_to() function implementation. */
+gchar*          bm_engine_get_lang_to(Engine* engine);
+
+/** \brief dict_eng_get_title() function implementation. */
+gchar*          bm_engine_get_title(Engine* engine);
+
+/** \brief dict_eng_get_icon_path() function implementation. */
+gchar*          bm_engine_get_icon_path(Engine* engine);
+
+/** \brief dict_eng_destroy() function implementation. */
 void            bm_engine_close(Engine* engine);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_get_location(engine) function
+
+/** \brief dict_eng_get_location() function implementation. */
 gchar*          bm_engine_location(Engine* engine);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_optimize(engine) function
+
+/** \brief dict_eng_optimize() function implementation. */
 void            bm_engine_optimize(Engine* engine);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_is_optimized( engine ) function
+
+/** \brief dict_eng_is_optimized() function implementation. */
 gboolean        bm_engine_is_optimized(Engine* engine);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_set_auto_free(engine, state) function
+
+/** \brief dict_eng_set_auto_free() function implementation. */
 void            bm_engine_set_auto_free(Engine* engine, gboolean state);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_set_callback(engine,signal,c_handler,data) 
-// function
-gpointer        bm_engine_set_callback(Engine* engine,
-                                     gchar* event,
-                                     gpointer c_handler,
-                                     gpointer user_data);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_set_progress_seed(engine, signal, val) function
-void            bm_engine_set_progress_seed(Engine* engine,
-                                         gchar* signal,
-                                         gdouble seed);
-//------------------------------------------------------------------------------
-// implementation ofdict_eng_search_word_list(engine,pattern) function
-void            bm_engine_search_word_list(Engine* engine,
-                                           gchar* pattern,
-                                           gpointer data);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_search_word_translation(engine,word) function
-void            bm_engine_search_word_translation(Engine* engine,
-                                                  gchar* word,
-                                                  gpointer data);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_get_last_state(engine) function
+
+/** \brief dict_eng_set_callback() function implementation. */
+gpointer        bm_engine_set_callback( Engine* engine,
+                                        gchar* event,
+                                        gpointer c_handler,
+                                        gpointer user_data );
+
+/** \brief dict_eng_set_progress_seed() function implementation. */
+void            bm_engine_set_progress_seed( Engine* engine,
+                                             gchar* signal,
+                                             gdouble seed );
+
+/** \brief dict_eng_search_word_list() function implementation. */
+void            bm_engine_search_word_list( Engine* engine,
+                                            gchar* pattern,
+                                            gpointer data );
+
+/** \brief dict_eng_search_word_translation() function implementation. */
+void            bm_engine_search_word_translation( Engine* engine,
+                                                   gchar* word,
+                                                   gpointer data );
+
+/** \brief dict_eng_get_last_status() function implementation. */
 EngineStatus    bm_engine_status(Engine* engine);
-//------------------------------------------------------------------------------
-// implementation of dict_eng_state_message(error) function
+
+
+/** \brief dict_eng_status_message() function implementation. */
 gchar*          bm_engine_status_message(EngineStatus error);
-//------------------------------------------------------------------------------
-// implementation of engine_global_functions(void) function
+
+/*@}*/
+
+/** \brief implementation of engine_global_functions(void) function. */
 EngineModule    engine_global_functions();
 
 #ifdef __cplusplus
 }
 #endif
 #endif /* #ifndef _DICTIONARY_ENGINE_STARDICT */
+
+/*@}*/
index 114c105..ea2d31d 100755 (executable)
@@ -15,13 +15,15 @@ You should have received a copy of the GNU General Public License
 along with mdictionary; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
-Copyright 2006 ComArch S.A.
+Copyright 2006-2008 ComArch S.A.
 ******************************************************************************/
-
-// header with data structure and function definition for XDXF engine.
-// Also Engine API. 
+/** \addtogroup BookmarkEngine
+ */
+/*@{*/
+/** \file engine_bookmark.c
+ * \brief Code of bookmark dictionary engine.
+ */
 #include "engine_bookmark.h"
-//------------------------------------------------------------------------------
 
 #ifndef NOLOGS
        #include <glib/gstdio.h>
@@ -31,8 +33,8 @@ Copyright 2006 ComArch S.A.
 #endif
 
 
-//------------------------------------------------------------------------------
-static gint bm_compare_key_trans(const DBT *a, const DBT *b) {
+static gint bm_compare_key_trans(const DBT *a, const DBT *b)
+{
        guint tmpa;// = (guint*)(a->data);
        guint tmpb;// = (guint*)(b->data);
        memcpy(&tmpa, a->data, sizeof(guint));
@@ -42,8 +44,9 @@ static gint bm_compare_key_trans(const DBT *a, const DBT *b) {
        if(tmpa  > tmpb) return 1;
        else return -1;
 }
-//------------------------------------------------------------------------------
-static gint bm_compare_key_words(const DBT *a, const DBT *b) {
+
+static gint bm_compare_key_words(const DBT *a, const DBT *b)
+{
        gchar* tmpa = g_utf8_casefold((gchar*)(a->data),-1);
        gchar* tmpb = g_utf8_casefold((gchar*)(b->data),-1);
        gint result = g_utf8_collate(tmpa,tmpb);
@@ -51,8 +54,9 @@ static gint bm_compare_key_words(const DBT *a, const DBT *b) {
        g_free(tmpb); tmpb = NULL;
        return result;
 }
-//------------------------------------------------------------------------------
-static void bm_save_freeID(BookData* data) {
+
+static void bm_save_freeID(BookData* data)
+{
        LOGS("Saveing new freeID=%u...\n",data->freeID);
        guint temp = 0;
        DBT key = {     &temp       , sizeof(guint)};
@@ -65,7 +69,8 @@ static void bm_save_freeID(BookData* data) {
                LOGS("Error while trying to delete old freeID!\n");
                return;
        }
-       else {
+       else
+       {
                LOGS("Old freeID=%u deleted successfully!\n",data->freeID-1);
        }
 
@@ -75,7 +80,8 @@ static void bm_save_freeID(BookData* data) {
                data->last_error = ENGINE_INTERNAL_ERROR;
                LOGS("Error while trying to write new value for freeID!\n");
        }
-       else {
+       else
+       {
                LOGS("New freeID=%u written successfully!\n",data->freeID);
        }
 
@@ -85,12 +91,14 @@ static void bm_save_freeID(BookData* data) {
                data->last_error = ENGINE_INTERNAL_ERROR;
                LOGS("Error while trying to write data to fuile!\n");
        }
-       else {
+       else
+       {
                LOGS("New data saved successfully to file!\n");
        }       
 }
-//------------------------------------------------------------------------------
-static void bm_load_freeID(BookData* data) {
+
+static void bm_load_freeID(BookData* data)
+{
        guint temp = 0;
        DBT key = { &temp , sizeof(guint) };
        DBT val = { NULL  , 0 };
@@ -129,15 +137,10 @@ static void bm_load_freeID(BookData* data) {
 
 
 
-//==============================================================================
-//==============================================================================
-//==============================================================================
-//-------------------------------------- FUNCTION FROM API 0.2 !!!
-//==============================================================================
-
-gboolean bm_engine_add_word(Engine* engine,
-                         gchar*  word,
-                         gchar*  translation) {
+gboolean bm_engine_add_word( Engine* engine,
+                             gchar*  word,
+                             gchar*  translation)
+{
         LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
              "word: %s\ntranslation address: %p\n",
              (gchar*)__FILE__,
@@ -150,8 +153,8 @@ gboolean bm_engine_add_word(Engine* engine,
         g_assert(word != NULL);
         g_assert(translation != NULL);
 
-        // start bm_timer for this function
-        bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+        /* start bm_timer for this function */
+        /* bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__); */
 
        gboolean result = TRUE;
        BookData* data = (BookData*)(engine->engine_data);
@@ -264,10 +267,10 @@ gboolean bm_engine_add_word(Engine* engine,
                result = FALSE;
        }
 
-        bm_timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__); */
         return result;
 }
-//------------------------------------------------------------------------------
+
 static gboolean bm_add_only_translation(BookData* data,
                                        gchar* translation,
                                        guint id)
@@ -289,7 +292,7 @@ static gboolean bm_add_only_translation(BookData* data,
        }
        return TRUE;
 }
-//------------------------------------------------------------------------------
+
 static gboolean bm_add_new_entry(gchar* word,gchar* translation,BookData* data)
 {
        guint hash = g_str_hash(translation);
@@ -351,16 +354,17 @@ static gboolean bm_add_new_entry(gchar* word,gchar* translation,BookData* data)
        }
        return result;  
 }
-//------------------------------------------------------------------------------
+
 gboolean bm_engine_remove_word(Engine* engine,
-                             gchar*  word) {
+                             gchar*  word)
+{
         gboolean result = TRUE;
 
         LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
              "word: %s\n",(gchar*)__FILE__,(gchar*)__FUNCTION__,engine,word);
         g_assert(engine != NULL);
         g_assert(word != NULL);
-        bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__); */
 
         BookData* data = (BookData*)(engine->engine_data);
 
@@ -436,15 +440,16 @@ gboolean bm_engine_remove_word(Engine* engine,
        }
 
 
-        bm_timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__); */
         LOGS("Bookmark/%s->%s() finished work.\n",
                 (gchar*)__FILE__,
                 (gchar*)__FUNCTION__
                );
         return result;
 }
-//------------------------------------------------------------------------------      
-gchar* bm_engine_get_lang_from(Engine* engine) {
+
+gchar* bm_engine_get_lang_from(Engine* engine)
+{
         LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
         gchar* result = g_strdup("any");
         LOGS("Bookmark/%s->%s() return string=%s\n",
@@ -454,8 +459,9 @@ gchar* bm_engine_get_lang_from(Engine* engine) {
                );
         return result;
 }
-//------------------------------------------------------------------------------
-gchar* bm_engine_get_lang_to(Engine* engine) {
+
+gchar* bm_engine_get_lang_to(Engine* engine)
+{
         LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
         gchar* result = g_strdup("any");
         LOGS("Bookmark/%s->%s() return string=%s\n",
@@ -465,8 +471,9 @@ gchar* bm_engine_get_lang_to(Engine* engine) {
                );
         return result;
 }
-//------------------------------------------------------------------------------
-gchar* bm_engine_get_title(Engine* engine) {
+
+gchar* bm_engine_get_title(Engine* engine)
+{
         LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
         gchar* result = g_strconcat(g_get_user_name(),"s' bookmarks",NULL);
         LOGS("Bookmark/%s->%s() return string=%s\n",
@@ -476,8 +483,9 @@ gchar* bm_engine_get_title(Engine* engine) {
                );
         return result;
 }
-//------------------------------------------------------------------------------
-gchar* bm_engine_get_icon_path(Engine* engine) {
+
+gchar* bm_engine_get_icon_path(Engine* engine)
+{
         LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
         gchar* result = g_strdup("/usr/share/pixmaps/ws_eng_bookmark_icon.png");
         LOGS("Bookmark/%s->%s() return string=%s\n",
@@ -488,14 +496,6 @@ gchar* bm_engine_get_icon_path(Engine* engine) {
         return result;
 }
 
-//==============================================================================
-//==============================================================================
-//==============================================================================
-//-------------------------------------- FUNCTION TO WRITE (NOT IMPLEMENTED YET)
-//==============================================================================
-
-//------------------------------------------------------------------------------
-// searching word by concrete engine
 void bm_engine_search_word_translation(Engine* engine,
                                        gchar* word,
                                        gpointer cb_data)
@@ -510,7 +510,7 @@ void bm_engine_search_word_translation(Engine* engine,
         g_assert(engine != NULL);
         g_assert(word != NULL);
         // start bm_timer for this function
-        bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__); */
        BookData* data = (BookData*)(engine->engine_data);
 
        gchar* down_word = g_utf8_strdown(word,-1);
@@ -558,8 +558,9 @@ void bm_engine_search_word_translation(Engine* engine,
                }
        };
        g_free(down_word);
-        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
         bm_timer(TIMER_START,"callback for returning word's translation START");
+       */
         // calling callback for word translation
 
        if ( NULL == cb_data )
@@ -568,7 +569,8 @@ void bm_engine_search_word_translation(Engine* engine,
        }
         data->cb_search_word_trans(tran, word, cb_data, ENGINE_NO_ERROR);
                
-        bm_timer(TIMER_STOP,"callback for returning word's translation END");
+        /* bm_timer(TIMER_STOP,"callback for returning word's translation END");
+       */
 //         if(data->auto_free) {
 //                 LOGS("Bookmark/%s->%s() deleting all dynamic data because "
 //                      "AUTO_FREE=TRUE\n",
@@ -581,7 +583,6 @@ void bm_engine_search_word_translation(Engine* engine,
         tran = NULL;
 }
 
-//------------------------------------------------------------------------------
 void bm_engine_close(Engine* engine)
 {
         LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
@@ -589,11 +590,11 @@ void bm_engine_close(Engine* engine)
                 (gchar*)__FUNCTION__,
                 engine);
         g_assert(engine != NULL);
-        
+
         BookData* data = (BookData*)(engine->engine_data);
         data->db_words->close(data->db_words);
        data->db_trans->close(data->db_trans);
-        
+
         LOGS("Bookmark/%s->%s() engine at adress=%p is deleted.\n",
                 (gchar*)__FILE__,
                 (gchar*)__FUNCTION__,
@@ -604,7 +605,6 @@ void bm_engine_close(Engine* engine)
         g_free(engine);
         engine = NULL;
 }
-//------------------------------------------------------------------------------
 
 Engine* bm_engine_create(gchar* location,
                       EngineOptimizationFlag auto_cache,
@@ -620,7 +620,7 @@ Engine* bm_engine_create(gchar* location,
              location,
              (guint)auto_cache
             );
-        bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);        
+        /* bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__); */
 
         gchar* tmp = g_strdup(location);
         string_to_path(&tmp);
@@ -741,7 +741,7 @@ Engine* bm_engine_create(gchar* location,
         }
         g_free(tmp); tmp = NULL;
         
-        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__); */
         LOGS("Bookmark/%s->%s() returned Engine at adress=%p\n",
              (gchar*)__FILE__,
              (gchar*)__FUNCTION__,
@@ -749,11 +749,10 @@ Engine* bm_engine_create(gchar* location,
             );
         return result;
 }
-//------------------------------------------------------------------------------
-
 
 
-static gboolean is_Bookmark_db_file(gchar* file) {
+static gboolean is_Bookmark_db_file(gchar* file)
+{
         LOGS("Bookmark/%s->%s() called.\n\
                  -->PARAM:file=\'%s\'\n",
                  (gchar*)__FILE__,
@@ -784,7 +783,6 @@ static gboolean is_Bookmark_db_file(gchar* file) {
         };
         return TRUE;
 }
-//------------------------------------------------------------------------------
 
 
 void bm_engine_optimize(Engine* engine)
@@ -797,20 +795,20 @@ void bm_engine_optimize(Engine* engine)
         LOGS("Unsupported optimization mechanizm for this engine!\n");
         LOGS("Bookmark/%s->%s()'s work finished.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
 }
-//------------------------------------------------------------------------------
+
 gboolean bm_engine_check(gchar* location) 
-{        
+{
         LOGS("Bookmark/%s->%s() called.\n-->PARAM:location=\'%s\'\n",
              (gchar*)__FILE__,
              (gchar*)__FUNCTION__,
              location
             );
-        bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__); */
         gboolean result = TRUE;
         gchar* filepath = g_strdup(location);
         gchar* tmp = NULL;
        gchar* tmp2 = NULL;
-        
+
         string_to_path(&filepath);
         if (filepath == NULL) {
                 result = FALSE;
@@ -821,7 +819,8 @@ gboolean bm_engine_check(gchar* location)
                      location
                     );
         }
-        else {
+        else
+       {
                 tmp = g_strconcat(filepath,"/bm_words.db",NULL);
                tmp2 = g_strconcat(filepath,"/bm_trans.db",NULL);
                 g_free(filepath);
@@ -851,7 +850,7 @@ gboolean bm_engine_check(gchar* location)
 
         g_free(filepath);  filepath = NULL;
        g_free(tmp2);      tmp2 = NULL;
-        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__); */
         LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
              (gchar*)__FILE__,
              (gchar*)__FUNCTION__,
@@ -860,7 +859,6 @@ gboolean bm_engine_check(gchar* location)
         return result;
 }
 
-//------------------------------------------------------------------------------
 gboolean bm_engine_is_optimized(Engine* engine) 
 {
         LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
@@ -868,7 +866,7 @@ gboolean bm_engine_is_optimized(Engine* engine)
              (gchar*)__FUNCTION__,
              engine
             );
-        g_assert(engine != NULL);                
+        g_assert(engine != NULL);
         gboolean result = FALSE;
         LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
              (gchar*)__FILE__,
@@ -877,7 +875,6 @@ gboolean bm_engine_is_optimized(Engine* engine)
             );
         return result;
 }
-//------------------------------------------------------------------------------
 
 void bm_engine_search_word_list(Engine* engine,
                                 gchar* pattern,
@@ -894,7 +891,7 @@ void bm_engine_search_word_list(Engine* engine,
         g_assert(engine != NULL);
         g_assert(pattern != NULL);
 
-        bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__); */
         BookData* data = (BookData*)(engine->engine_data);
         if(data->cb_search_word_list == NULL) {
                 LOGS("Bookmark/%s->%s() callback for Word List not set. "
@@ -902,7 +899,7 @@ void bm_engine_search_word_list(Engine* engine,
                      (gchar*)__FILE__,
                      (gchar*)__FUNCTION__
                     );
-                bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+                /* bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__); */
                 return;
         };
 
@@ -955,11 +952,11 @@ void bm_engine_search_word_list(Engine* engine,
                code = data->db_words->seq(data->db_words, &search, &reply, R_NEXT);
        }
        
-        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        /* bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__); */
        g_pattern_spec_free (regex);
 
 
-        bm_timer(TIMER_START,"callback for returning words LIST START");
+        /* bm_timer(TIMER_START,"callback for returning words LIST START"); */
         // calling callback for word translation
 
        if ( NULL == cb_data )
@@ -989,15 +986,9 @@ void bm_engine_search_word_list(Engine* engine,
                g_free(tmp); tmp = NULL;
        }
        g_array_free(result, TRUE);
-       bm_timer(TIMER_STOP,"callback for returning word LIST END");
+       /* bm_timer(TIMER_STOP,"callback for returning word LIST END"); */
 }
 
-//==============================================================================
-//==============================================================================
-//==============================================================================
-//---------------------------------------------------------- COMPLETED FUNCTIONS
-//==============================================================================
-// global functions
 EngineModule engine_global_functions()
 {
        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
@@ -1014,8 +1005,7 @@ EngineModule engine_global_functions()
            );
        return result;
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_status_message(error)
+
 gchar* bm_engine_status_message(EngineStatus error) 
 {
        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
@@ -1034,8 +1024,7 @@ gchar* bm_engine_status_message(EngineStatus error)
                        return "Wrong engine's status identifier!";
        }
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_module_get_version(module)
+
 gchar* bm_engine_version() 
 {
        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
@@ -1047,8 +1036,7 @@ gchar* bm_engine_version()
               );
        return result;
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_module_get_format(module)
+
 gchar* bm_engine_format() 
 {
        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
@@ -1060,8 +1048,7 @@ gchar* bm_engine_format()
            );
        return result;
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_module_get_description(module)
+
 gchar* bm_engine_description() 
 {
        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
@@ -1073,8 +1060,7 @@ gchar* bm_engine_description()
            );
        return result;
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_get_location(engine)
+
 gchar* bm_engine_location(Engine* engine)
 {
        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
@@ -1100,8 +1086,7 @@ gchar* bm_engine_location(Engine* engine)
            );
        return result;
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_set_auto_free(engine, state)
+
 void bm_engine_set_auto_free(Engine* engine, gboolean state) 
 {
        LOGS("Bookmark/%s->%s() called.\n"
@@ -1122,8 +1107,7 @@ void bm_engine_set_auto_free(Engine* engine, gboolean state)
             PRINT_STATE(data->auto_free)
            );
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_get_last_status(engine)
+
 EngineStatus bm_engine_status(Engine* engine) 
 {
        LOGS("Bookmark/%s->%s() called.\n"
@@ -1140,8 +1124,7 @@ EngineStatus bm_engine_status(Engine* engine)
            );
        return data->last_error;
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_set_progress_seed(engine, signal, val)
+
 void bm_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
        BookData* data = (BookData*)(engine->engine_data);
@@ -1163,8 +1146,7 @@ void bm_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
                    );
        };
 }
-//------------------------------------------------------------------------------
-// for macro: dict_eng_set_callback(engine,signal,c_handler,data)
+
 gpointer bm_engine_set_callback(Engine* engine,
                             gchar* signal,
                             gpointer c_handler,
@@ -1248,73 +1230,91 @@ gpointer bm_engine_set_callback(Engine* engine,
                        return NULL;
                }
 }
+/**
+* Translate given string to proper full file path. Function works "in-situ".
+* It means that string is translated and replaced by proper full file path if
+* this file path exists, or this string is cleared and setted to NULL, if string
+* was representing wrong path. This function is static - to use only 
+* within this module.
+*
+* @param string pointer to to string 
+*       representing file path - it will be replaced by a proper filepath.
+*       It should be path to directory or file, ended with "/" or not, absolute 
+*       or not
+* @return pointer to new full file path, it is the same
+*       as string[0] in fact and it is returned only for abillity of nesting of
+* functions by pointer to string identyfying full file path
+*/
+static gchar* string_to_path(gchar** string) {
+       g_debug("XDXF/%s->%s() called.\n"
+               "-->PARAM:string=\'%s\'\n",
+               __FILE__,
+               __FUNCTION__,
+               string[0] );
+       gchar* arg = string[0];
+       gchar* new = NULL;
+
+       /* cleaning from leading and trailing whitespaces */
+       g_strstrip(arg);
+
+       /* add current directory if this is not absolute directory */
+       if (!g_path_is_absolute(arg))
+       {
+               gchar* tmp = g_get_current_dir();
+               new = g_strconcat(tmp,"/",arg,NULL);
+               g_free(arg); arg = new; new = NULL;
+       };
 
+       /* this is not a directory */
+       if (!g_file_test(arg, G_FILE_TEST_IS_DIR))
+       {
+               /* if this is wrong filepath, string was wrong */
+               if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR))
+               {
+                       g_free(arg);
+                       new = NULL;
+               }
+               else
+               {
+                       /* if this is a file, remove filename */
+                       new = g_path_get_dirname (arg);
+                       g_free(arg);
+               }
+       }
+       else
+       {
+               /* this is a directory ... */
+               /* remove suffix "/" if neded... */
+               if (g_str_has_suffix(arg,"/") )
+               {
+                       new = g_path_get_dirname (arg);
+                       g_free(arg);
+               }
+               else
+               {
+                       new = arg;
+               }
+       };
 
-//==============================================================================
-//==============================================================================
-//==============================================================================
-//---------------------------------------------------------- HELPFULLY FUNCTIONS
-//==============================================================================
+       /* now in new should be proper filepath, if not, string was wrong */
+       if (!g_file_test(new, G_FILE_TEST_IS_DIR))
+       {
+               /* if that directory does not exist, passed string wasn't proper
+                */
+               g_free(new);
+               new = NULL;
+       };
 
-//------------------------------------------------------------------------------
-static gchar* string_to_path(gchar** string) {
-        LOGS("Bookmark/%s->%s() called.\n\
-                 -->PARAM:string=\'%s\'\n",
-                 (gchar*)__FILE__,
-                 (gchar*)__FUNCTION__,
-                 string[0]
-               );
-        gchar* arg = string[0];
-        gchar* new = NULL;
-        // cleaning from leading and trailing whitespaces
-        g_strstrip(arg);        
-         // add current directory if this is not absolute directory
-        if (!g_path_is_absolute(arg)) {
-                gchar* tmp = g_get_current_dir();
-                new = g_strconcat(tmp,"/",arg,NULL);
-                g_free(arg); arg = new; new = NULL;
-        };
-        // this is not a directory
-        if (!g_file_test(arg, G_FILE_TEST_IS_DIR)) {        
-                // if this is wrong filepath, string was wrong
-                if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR)) {        
-                        g_free(arg);
-                        new = NULL;
-                }
-                //if this is a file, remove filename
-                else
-                {   
-                        new = g_path_get_dirname (arg);
-                        g_free(arg);
-                }
-        }
-        // this is a directory
-        else {   
-                // remove suffix "/" if neded...     
-                if (g_str_has_suffix(arg,"/") ) {        
-                        new = g_path_get_dirname (arg);
-                        g_free(arg);
-                }
-                else {
-                        new = arg;
-                }
-        };
-        // now in new should be proper filepath, if not, string was wrong
-        if (!g_file_test(new, G_FILE_TEST_IS_DIR))  {        
-                // if that directory does not exist, passed string wasn't proper       
-                g_free(new);
-                new = NULL;
-        };
-        // replace string under passed address
-        string[0] = new;
-        LOGS("Bookmark/%s->%s() returned string=\'%s\'\n",
-                (gchar*)__FILE__,
-                (gchar*)__FUNCTION__,
-                string[0]
-               );
-        return new;
+       /* replace string under passed address */
+       string[0] = new;
+       g_debug("XDXF/%s->%s() returned string=\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                string[0] );
+       return new;
 }
-//------------------------------------------------------------------------------
+
+/*
 static double bm_timer(gboolean start, gchar* message)
 {
        static GArray* stack = NULL;
@@ -1326,7 +1326,7 @@ static double bm_timer(gboolean start, gchar* message)
        if(first_run) {
                first_run = FALSE;
                stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
-       };        
+       };
 
        if (start) {
                LOGS("Bookmark->%s() start bm_timer for function '%s()'.\n",
@@ -1337,9 +1337,8 @@ static double bm_timer(gboolean start, gchar* message)
                gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
                return -1.0;
        }
-        // we just want to end some bm_timer - print some information about 
-        // working time;
-       else {          
+       else
+       {
                gettimeofday(&actual_time,NULL);
                last_time = g_array_index(stack, struct timeval, 0);
                g_array_remove_index(stack, 0);
@@ -1359,17 +1358,15 @@ static double bm_timer(gboolean start, gchar* message)
                result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
                result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
                seconds = (((double)(result.tv_usec)) / 1e6) +
-                               ((double)(result.tv_sec));
+                          ((double)(result.tv_sec));
 
                LOGS("Bookmark->%s() function \'%s()\' was working for: %g "
-                               "[s] or %ld [us].\n",
-               (gchar*)__FUNCTION__,
-               message,
-               seconds,
-               ((long)(result.tv_sec*1e6)+(result.tv_usec))
-                      );
-                // stack is empty so we delete everything
-               if(stack->len == 0)   
+                    "[s] or %ld [us].\n",
+                    (gchar*)__FUNCTION__,
+                    message,
+                    seconds,
+                    ((long)(result.tv_sec*1e6)+(result.tv_usec)) );
+               if(stack->len == 0)
                {
                        g_array_free(stack, TRUE);
                        first_run = TRUE;
@@ -1377,4 +1374,4 @@ static double bm_timer(gboolean start, gchar* message)
        }
        return seconds;
 }
-//------------------------------------------------------------------------------
+*/