[Groonga-commit] groonga/groonga [master] Add a wrapper of grn_win32_base_dir() for plugin

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Oct 11 18:10:27 JST 2012


Kouhei Sutou	2012-10-11 18:10:27 +0900 (Thu, 11 Oct 2012)

  New Revision: 0a55a6b23181d33903e57532cc851ec1c35f5ef8
  https://github.com/groonga/groonga/commit/0a55a6b23181d33903e57532cc851ec1c35f5ef8

  Log:
    Add a wrapper of grn_win32_base_dir() for plugin
    
    grn_plugin_win32_base_dir() is added.

  Modified files:
    include/groonga/plugin.h
    lib/plugin.c
    plugins/query_expanders/tsv.c

  Modified: include/groonga/plugin.h (+10 -0)
===================================================================
--- include/groonga/plugin.h    2012-10-11 18:04:22 +0900 (94ed076)
+++ include/groonga/plugin.h    2012-10-11 18:10:27 +0900 (bea8d48)
@@ -158,6 +158,16 @@ void grn_plugin_mutex_unlock(grn_ctx *ctx, grn_plugin_mutex *mutex);
 grn_obj *grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
                                grn_id domain, grn_obj_flags flags);
 
+/*
+  grn_plugin_win32_base_dir() returns the groonga install directory.
+  The install directory is computed from the directory that has
+  `groonga.dll`. You can use the directory to generate install
+  directory aware path.
+
+  It only works on Windows. It returns `NULL` on other platforms.
+ */
+const char *grn_plugin_win32_base_dir(void);
+
 
 #ifdef __cplusplus
 }

  Modified: lib/plugin.c (+10 -0)
===================================================================
--- lib/plugin.c    2012-10-11 18:04:22 +0900 (20da194)
+++ lib/plugin.c    2012-10-11 18:10:27 +0900 (0cf1a1c)
@@ -530,3 +530,13 @@ grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
 {
   return grn_proc_alloc(ctx, user_data, domain, flags);
 }
+
+const char *
+grn_plugin_win32_base_dir(void)
+{
+#ifdef WIN32
+  return grn_win32_base_dir();
+#else /* WIN32 */
+  return NULL;
+#endif /* WIN32 */
+}

  Modified: plugins/query_expanders/tsv.c (+1 -3)
===================================================================
--- plugins/query_expanders/tsv.c    2012-10-11 18:04:22 +0900 (2e501a6)
+++ plugins/query_expanders/tsv.c    2012-10-11 18:10:27 +0900 (f74c7e7)
@@ -20,8 +20,6 @@
 /* groonga's internal headers: They should be removed. */
 /* for grn_text_fgets() */
 #include <str.h>
-/* for grn_win32_base_dir() */
-#include <util.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -42,7 +40,7 @@ get_system_synonyms_file(void)
     char *path;
     size_t base_dir_length;
 
-    base_dir = grn_win32_base_dir();
+    base_dir = grn_plugin_win32_base_dir();
     base_dir_length = strlen(base_dir);
     synonyms_file =
       malloc(base_dir_length + strlen("/") + strlen(relative_path) + 1);
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index