null+****@clear*****
null+****@clear*****
2012年 4月 9日 (月) 17:06:05 JST
Kouhei Sutou 2012-04-09 17:06:05 +0900 (Mon, 09 Apr 2012) New Revision: d2fbca5165c18681cefcfaea99f285b1cecf7e3d Log: mrn_sys.c -> mrn_sys.cpp, mrn_sys.h -> mrn_sys.hpp Removed files: mrn_sys.c mrn_sys.h Modified files: Makefile.am ha_mroonga.h lib/mrn_path_mapper.hpp mrn_table.cc test/unit/Makefile.am test/unit/test_mrn_sys.cpp Modified: Makefile.am (+2 -2) =================================================================== --- Makefile.am 2012-04-09 16:47:27 +0900 (6c01e78) +++ Makefile.am 2012-04-09 17:06:05 +0900 (4feb8fb) @@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = $$ACLOCAL_ARGS noinst_HEADERS = \ mrn_macro.h \ - mrn_sys.h \ + mrn_sys.hpp \ ha_mroonga.h \ mrn_table.h \ mrn_err.h \ @@ -16,7 +16,7 @@ noinst_HEADERS = \ sources = \ ha_mroonga.cc \ - mrn_sys.c \ + mrn_sys.cpp \ mrn_table.cc libraries = \ Modified: ha_mroonga.h (+1 -1) =================================================================== --- ha_mroonga.h 2012-04-09 16:47:27 +0900 (01bbabe) +++ ha_mroonga.h 2012-04-09 17:06:05 +0900 (75cc9e8) @@ -31,7 +31,7 @@ extern "C" { #endif #include <groonga.h> -#include "mrn_sys.h" +#include "mrn_sys.hpp" #include "mrn_mysql_compat.h" #if (MYSQL_VERSION_ID >= 50603) || \ Modified: lib/mrn_path_mapper.hpp (+1 -1) =================================================================== --- lib/mrn_path_mapper.hpp 2012-04-09 16:47:27 +0900 (f821df5) +++ lib/mrn_path_mapper.hpp 2012-04-09 17:06:05 +0900 (0416a02) @@ -22,7 +22,7 @@ #ifndef MRN_PATH_MAPPER_HPP_ #define MRN_PATH_MAPPER_HPP_ -#include "mrn_sys.h" +#include "mrn_sys.hpp" namespace mrn { class PathMapper { Deleted: mrn_sys.c (+0 -95) 100644 =================================================================== --- mrn_sys.c 2012-04-09 16:47:27 +0900 (a1e3107) +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- c-basic-offset: 2 -*- */ -/* - Copyright(C) 2010 Tetsuro IKEDA - Copyright(C) 2011-2012 Kentoku SHIBA - Copyright(C) 2011 Kouhei Sutou <kou****@clear*****> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "mrn_sys.h" - -int mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value) -{ - int added, res=0; - void *buf; - grn_hash_add(ctx, hash, (const char *)key, strlen(key), &buf, &added); - // duplicate check - if (added == 0) { - GRN_LOG(ctx, GRN_LOG_WARNING, "hash put duplicated (key=%s)", key); - res = -1; - } else { - // store address of value - memcpy(buf, &value, sizeof(grn_obj *)); - GRN_LOG(ctx, GRN_LOG_DEBUG, "hash put (key=%s)", key); - } - return res; -} - -int mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value) -{ - int res = 0; - grn_id id; - void *buf; - id = grn_hash_get(ctx, hash, (const char *)key, strlen(key), &buf); - // key not found - if (id == GRN_ID_NIL) { - GRN_LOG(ctx, GRN_LOG_DEBUG, "hash get not found (key=%s)", key); - res = -1; - } else { - // restore address of value - memcpy(value, buf, sizeof(grn_obj *)); - } - return res; -} - -int mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key) -{ - int res = 0; - grn_rc rc; - grn_id id; - id = grn_hash_get(ctx, hash, (const char*) key, strlen(key), NULL); - if (id == GRN_ID_NIL) { - GRN_LOG(ctx, GRN_LOG_WARNING, "hash remove not found (key=%s)", key); - res = -1; - } else { - rc = grn_hash_delete_by_id(ctx, hash, id, NULL); - if (rc != GRN_SUCCESS) { - GRN_LOG(ctx, GRN_LOG_ERROR, "hash remove error (key=%s)", key); - res = -1; - } else { - GRN_LOG(ctx, GRN_LOG_DEBUG, "hash remove (key=%s)", key); - } - } - return res; -} - -/** - * "${table}" ==> "${table}-${index_name}" - */ -char *mrn_index_table_name_gen(const char *table_name, - const char *index_name, - char *dest) -{ - snprintf(dest, MRN_MAX_PATH_SIZE, "%s-%s", table_name, index_name); - return dest; -} Deleted: mrn_sys.h (+0 -59) 100644 =================================================================== --- mrn_sys.h 2012-04-09 16:47:27 +0900 (08b8cab) +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright(C) 2010 Tetsuro IKEDA - Copyright(C) 2011 Kentoku SHIBA - Copyright(C) 2011-2012 Kouhei Sutou <kou****@clear*****> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef _mrn_sys_h -#define _mrn_sys_h - -#include <groonga.h> -#include "mrn_macro.h" - -MRN_BEGIN_DECLS - -/* constants */ -#define MRN_BUFFER_SIZE 1024 -#define MRN_MAX_KEY_SIZE GRN_TABLE_MAX_KEY_SIZE -#if defined(MAX_PATH) -# define MRN_MAX_PATH_SIZE (MAX_PATH + 1) -#elif defined(PATH_MAX) -# define MRN_MAX_PATH_SIZE (PATH_MAX) -#elif defined(MAXPATHLEN) -# define MRN_MAX_PATH_SIZE (MAXPATHLEN) -#else -# define MRN_MAX_PATH_SIZE (256) -#endif -#define MRN_DB_FILE_SUFFIX ".mrn" -#define MRN_LOG_FILE_PATH "groonga.log" -#define MRN_COLUMN_NAME_ID "_id" -#define MRN_COLUMN_NAME_KEY "_key" -#define MRN_COLUMN_NAME_SCORE "_score" -#ifndef MRN_PARSER_DEFAULT -# define MRN_PARSER_DEFAULT "TokenBigram" -#endif - -/* functions */ -int mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value); -int mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value); -int mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key); - -char *mrn_index_table_name_gen(const char *arg, const char *idx_name, char *dest); - -MRN_END_DECLS - -#endif /* _mrn_sys_h */ Modified: mrn_table.cc (+1 -1) =================================================================== --- mrn_table.cc 2012-04-09 16:47:27 +0900 (c5ca473) +++ mrn_table.cc 2012-04-09 17:06:05 +0900 (bab1620) @@ -25,7 +25,7 @@ # include <sql_base.h> #endif #include "mrn_err.h" -#include "mrn_sys.h" +#include "mrn_sys.hpp" #include "mrn_table.h" #include "mrn_mysql_compat.h" Modified: test/unit/Makefile.am (+1 -1) =================================================================== --- test/unit/Makefile.am 2012-04-09 16:47:27 +0900 (f958fbc) +++ test/unit/Makefile.am 2012-04-09 17:06:05 +0900 (320e673) @@ -23,7 +23,7 @@ LIBS = \ $(GROONGA_LIBS) \ $(MECAB_LIBS) -EXTERNAL_SRC = ../../mrn_sys.c +EXTERNAL_SRC = ../../mrn_sys.cpp test_mrn_sys_la_SOURCES = \ $(EXTERNAL_SRC) \ Modified: test/unit/test_mrn_sys.cpp (+1 -1) =================================================================== --- test/unit/test_mrn_sys.cpp 2012-04-09 16:47:27 +0900 (952e239) +++ test/unit/test_mrn_sys.cpp 2012-04-09 17:06:05 +0900 (053d5c5) @@ -21,7 +21,7 @@ #include <string.h> #include <cppcutter.h> -#include <mrn_sys.h> +#include <mrn_sys.hpp> static grn_ctx *ctx; static grn_obj *db;