--- /dev/null
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*.ipk
+*~
--- /dev/null
+Hakjoo Ko <hakjoo.ko@samsung.com>\r
+Hyungdeuk Kim <hd3.kim@samsung.com>\r
+\r
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(SLP-db-util)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include/db-util")
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
+
+SET(SRCS util_func.c collation.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ sqlite3
+ dlog
+ glib-2.0
+ icu-i18n
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -ldl -g")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DDB_UTIL_USING_PLATFORM_DBG")
+ADD_DEFINITIONS("-DDB_UTIL_ENABLE_TRACE")
+##ADD_DEFINITIONS("-DDB_UTIL_ENABLE_DEVDEBUG")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+
+CONFIGURE_FILE(db-util.pc.in db-util.pc @ONLY)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/db-util.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/db-util.h DESTINATION include/db-util)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/db-util-common.h DESTINATION include/db-util)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/util-func.h DESTINATION include/db-util)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/collation.h DESTINATION include/db-util)
+
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
--- /dev/null
+#!/bin/sh
+
+export TET_INSTALL_PATH=/home/deuk/repository/tetware/TETware # local tetware path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/tetware/TETware
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+33 "INSPECT"
--- /dev/null
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/unit/tslist
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
--- /dev/null
+TET_OUTPUT_CAPTURE=False
--- /dev/null
+CC ?= gcc
+
+TARGETS = utc_ApplicationFW_db_util_close \
+ utc_ApplicationFW_db_util_open \
+ utc_ApplicationFW_db_util_open_with_options \
+
+PKGS = sqlite3 dlog db-util
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+LDFLAGS += -pthread
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TARGETS)
--- /dev/null
+#!/bin/sh
+
+TMPSTR=$0
+SCRIPT=${TMPSTR##*/}
+
+if [ $# -lt 2 ]; then
+ echo "Usage) $SCRIPT module_name api_name"
+ exit 1
+fi
+
+MODULE=$1
+API=$2
+TEMPLATE=utc_MODULE_API_func.c.in
+TESTCASE=utc_${MODULE}_${API}_func
+
+sed -e '
+ s^@API@^'"$API"'^g
+ s^@MODULE@^'"$MODULE"'^g
+ ' $TEMPLATE > $TESTCASE.c
+
+if [ ! -e "$TESTCASE.c" ]; then
+ echo "Failed"
+ exit 1
+fi
+echo "Testcase file is $TESTCASE.c"
+echo "Done"
+echo "please put \"$TESTCASE\" as Target in Makefile"
+echo "please put \"/unit/$TESTCASE\" in tslist"
--- /dev/null
+/unit/utc_ApplicationFW_db_util_close
+/unit/utc_ApplicationFW_db_util_open
+/unit/utc_ApplicationFW_db_util_open_with_options
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <tet_api.h>
+#include <db-util.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_db_util_close_func_01(void);
+static void utc_ApplicationFW_db_util_close_func_02(void);
+
+static sqlite3* db_hd = NULL;
+char* db_path = "/opt/test.db";
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_db_util_close_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_db_util_close_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of db_util_close()
+ */
+static void utc_ApplicationFW_db_util_close_func_01(void)
+{
+ int r = 0;
+
+ r = db_util_open(db_path, &db_hd, 0);
+ if (r != SQLITE_OK) {
+ tet_infoline("db_util_close() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = db_util_close(db_hd);
+ if (r != SQLITE_OK) {
+ tet_infoline("db_util_close() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ db_hd = NULL;
+
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init db_util_close()
+ */
+static void utc_ApplicationFW_db_util_close_func_02(void)
+{
+ int r = 0;
+ sqlite3_stmt *db_stmt = NULL;
+
+ db_hd = NULL;
+
+ r = db_util_open(db_path, &db_hd, 0);
+ if (r != SQLITE_OK) {
+ tet_infoline("db_util_close() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = sqlite3_prepare(db_hd, "create table test(id int);", -1, &db_stmt, NULL);
+ if (r != SQLITE_OK) {
+ tet_infoline("db_util_close() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = db_util_close(db_hd);
+ if (r == SQLITE_OK) {
+ tet_infoline("db_util_close() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
+
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <tet_api.h>
+#include <db-util.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_db_util_open_func_01(void);
+static void utc_ApplicationFW_db_util_open_func_02(void);
+
+static sqlite3* db_hd = NULL;
+char* db_path = "test.db";
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_db_util_open_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_db_util_open_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+ db_util_close(db_hd);
+}
+
+/**
+ * @brief Positive test case of db_util_open()
+ */
+static void utc_ApplicationFW_db_util_open_func_01(void)
+{
+ int r = 0;
+
+ r = db_util_open(db_path, &db_hd, 0);
+ if (r != SQLITE_OK) {
+ tet_infoline("db_util_open() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init db_util_open()
+ */
+static void utc_ApplicationFW_db_util_open_func_02(void)
+{
+ int r = 0;
+
+ r = db_util_open(NULL, &db_hd, 0);
+ if (r == SQLITE_OK) {
+ tet_infoline("db_util_open() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = db_util_open(db_path, NULL, 0);
+ if (r == SQLITE_OK) {
+ tet_infoline("db_util_open() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <tet_api.h>
+#include <db-util.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_db_util_open_with_options_func_01(void);
+static void utc_ApplicationFW_db_util_open_with_options_func_02(void);
+
+static sqlite3* db_hd = NULL;
+char* db_path = "/opt/test.db";
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_db_util_open_with_options_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_db_util_open_with_options_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+ db_util_close(db_hd);
+}
+
+/**
+ * @brief Positive test case of db_util_open_with_options()
+ */
+static void utc_ApplicationFW_db_util_open_with_options_func_01(void)
+{
+ int r = 0;
+
+ r = db_util_open_with_options(db_path, &db_hd, SQLITE_OPEN_READWRITE, NULL);
+ if (r != SQLITE_OK) {
+ tet_infoline("db_util_open() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init db_util_open_with_options()
+ */
+static void utc_ApplicationFW_db_util_open_with_options_func_02(void)
+{
+ int r = 0;
+
+ r = db_util_open_with_options(NULL, &db_hd, SQLITE_OPEN_READWRITE, NULL);
+ if (r == SQLITE_OK) {
+ tet_infoline("db_util_open() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = db_util_open_with_options(db_path, NULL, SQLITE_OPEN_READWRITE, NULL);
+ if (r == SQLITE_OK) {
+ tet_infoline("db_util_open() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = db_util_open_with_options(db_path, &db_hd, 0, NULL);
+ if (r == SQLITE_OK) {
+ tet_infoline("db_util_open() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ unlink(db_path);
+
+ r = db_util_open_with_options(db_path, &db_hd, SQLITE_OPEN_READONLY, NULL);
+ if (r == SQLITE_OK) {
+ tet_infoline("db_util_open() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
+
+
--- /dev/null
+#include <tet_api.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_@MODULE@_@API@_func_01(void);
+static void utc_@MODULE@_@API@_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX },
+ { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+ int r = 0;
+
+ r = @API@(...);
+
+ if (r<0) {
+ tet_infoline("@API@() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init @API@()
+ */
+static void utc_@MODULE@_@API@_func_02(void)
+{
+ int r = 0;
+
+ r = @API@(...);
+
+ if (r>=0) {
+ tet_infoline("@API@() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <string.h>
+#include <math.h>
+#include <wchar.h>
+#include <wctype.h>
+
+#include <unistd.h>
+#include <glib.h>
+
+#include <dlfcn.h>
+
+#include <unicode/utypes.h>
+#include <unicode/ucol.h>
+#include <unicode/uiter.h>
+#include <unicode/ustring.h>
+
+#include "collation.h"
+
+#include "db-util-debug.h"
+
+#define DB_UTIL_RETV_IF(cond,ret) \
+ do {\
+ if(cond) {\
+ DB_UTIL_TRACE_WARNING("\x1b[33m[%s()][RET_IF]\x1b[0m",__FUNCTION__);\
+ return ret;\
+ }\
+ }while(0)
+
+#define DB_UTIL_RET_IF(cond) \
+ do {\
+ if(cond) {\
+ DB_UTIL_TRACE_WARNING("\x1b[33m[%s()][RET_IF]\x1b[0m",__FUNCTION__);\
+ return;\
+ }\
+ }while(0)
+
+#define DB_UTIL_ERR_COL_FUNC_RET DB_UTIL_ERROR
+
+enum {
+ DB_UTIL_ERR_DLOPEN = -10,
+ DB_UTIL_ERR_DLSYM,
+ DB_UTIL_ERR_ENV,
+ DB_UTIL_ERR_ICU,
+ DB_UTIL_ERR_PARAM
+};
+
+enum {
+ DB_UTIL_CMP_SC,
+ /* Loop comparison */
+ DB_UTIL_CMP_LC
+};
+
+#define ICU_FUNC_CNT 8
+
+typedef UCollator* (*ICU_UCOL_OPEN)(const char *, UErrorCode *);
+typedef void (*ICU_UCOL_CLOSE)(UCollator *);
+typedef void (*ICU_UCOL_SETSTRENGTH)(UCollator *, UCollationStrength);
+typedef UCollationResult (*ICU_UCOL_STRCOLL)(const UCollator *, const UChar *, int32_t, const UChar *, int32_t);
+typedef UCollationResult (*ICU_UCOL_STRCOLLITER)(const UCollator *, UCharIterator *, UCharIterator *, UErrorCode *);
+typedef void (*ICU_UITER_SETUTF8)(UCharIterator *, const char *, int32_t);
+typedef void (*ICU_ULOC_SETDEFAULT)(const char* localeID, UErrorCode* status);
+typedef const char* (*ICU_ULOC_GETDEFAULT)(void);
+
+typedef struct {
+ ICU_UCOL_OPEN icu_ucol_open;
+ ICU_UCOL_CLOSE icu_ucol_close;
+ ICU_UCOL_STRCOLL icu_ucol_strcoll;
+ ICU_UCOL_STRCOLLITER icu_ucol_strcollIter;
+ ICU_UCOL_SETSTRENGTH icu_ucol_setStrength;
+ ICU_UITER_SETUTF8 icu_uiter_setUTF8;
+ ICU_ULOC_SETDEFAULT icu_uloc_setDefault;
+ ICU_ULOC_GETDEFAULT icu_uloc_getDefault;
+} db_util_icu_func_t;
+
+db_util_icu_func_t icu_symbol;
+
+void *g_dl_icu_handle = NULL;
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+static char *strtoutf8(const UChar * unichars, int len);
+#endif
+
+static int __db_util_dl_load_icu()
+{
+ void *handle = NULL;
+ void *icu_handle[ICU_FUNC_CNT] = { 0 };
+ char *dl_error;
+ int i = 0;
+
+ const char *ICU_API[] = {
+ "ucol_open",
+ "ucol_close",
+ "ucol_strcoll",
+ "ucol_strcollIter",
+ "ucol_setStrength",
+ "uiter_setUTF8",
+ "uloc_setDefault",
+ "uloc_getDefault"
+ };
+
+ if(g_dl_icu_handle == NULL) {
+ g_dl_icu_handle = dlopen("libicui18n.so", RTLD_LAZY | RTLD_GLOBAL);
+ if(g_dl_icu_handle == NULL) {
+ DB_UTIL_TRACE_WARNING("dlopen icu so fail");
+ return DB_UTIL_ERR_DLOPEN;
+ }
+ }
+
+ for (i = 0; i < ICU_FUNC_CNT; i++) {
+ handle = dlsym(g_dl_icu_handle, ICU_API[i]);
+ if ((dl_error = dlerror()) != NULL) {
+ DB_UTIL_TRACE_WARNING("dlsym(%s) is failed for %s",
+ dl_error, ICU_API[i]);
+ return DB_UTIL_ERR_DLSYM;
+ }
+ icu_handle[i] = handle;
+ }
+
+ memcpy((void*)&icu_symbol, (const void*)icu_handle, sizeof(icu_handle));
+
+ return DB_UTIL_OK;
+}
+
+/* The collating function must return an integer that is negative, zero or positive */
+static int __db_util_collate_icu_16(void *ucol, int str1_len, const void *str1, int str2_len, const void *str2)
+{
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ DB_UTIL_TRACE_DEBUG("__db_util_collate_icu_16 func start \n");
+
+ UChar* tmp_v1 = (UChar *)str1;
+ UChar* tmp_v2 = (UChar *)str2;
+ char* utf8_v1 = strtoutf8(tmp_v1, str1_len);
+ char* utf8_v2 = strtoutf8(tmp_v2, str2_len);
+
+ DB_UTIL_TRACE_DEBUG("v1(%d) : %s\n", str1_len, utf8_v1);
+ DB_UTIL_TRACE_DEBUG("v2(%d) : %s\n", str2_len, utf8_v2);
+#endif
+
+ DB_UTIL_RETV_IF(icu_symbol.icu_ucol_strcoll == NULL, DB_UTIL_ERR_COL_FUNC_RET);
+
+ UCollationResult result = icu_symbol.icu_ucol_strcoll(
+ (UCollator *) ucol,
+ (const UChar *) str1, str1_len,
+ (const UChar *) str2, str2_len);
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ if(utf8_v1)
+ free(utf8_v1);
+ if(utf8_v2)
+ free(utf8_v2);
+
+ if (result == UCOL_LESS) {
+ DB_UTIL_TRACE_DEBUG("less \n");
+ } else if (result == UCOL_GREATER) {
+ DB_UTIL_TRACE_DEBUG("greater \n");
+ } else {
+ DB_UTIL_TRACE_DEBUG("equal \n");
+ }
+#endif
+
+ return result;
+}
+
+/* The collating function must return an integer that is negative, zero or positive */
+static int __db_util_collate_icu_16_lc(void *ucol, int str1_len, const void *str1, int str2_len, const void *str2)
+{
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ DB_UTIL_TRACE_DEBUG("__db_util_collate_icu_16_lc func start \n");
+
+ UChar* tmp_v1 = (UChar *)str1;
+ UChar* tmp_v2 = (UChar *)str2;
+
+ char* utf8_v1 = strtoutf8(tmp_v1, str1_len);
+ char* utf8_v2 = strtoutf8(tmp_v2, str2_len);
+
+ DB_UTIL_TRACE_DEBUG("v1(%d) : %s\n", str1_len, utf8_v1);
+ DB_UTIL_TRACE_DEBUG("v2(%d) : %s\n", str2_len, utf8_v2);
+
+ if(utf8_v1)
+ free(utf8_v1);
+ if(utf8_v2)
+ free(utf8_v2);
+#endif
+
+ UCollationResult result = 0;
+
+ UChar* str_to = (UChar *)str1;
+ UChar* str_from = (UChar *)str1;
+
+ int i;
+
+ DB_UTIL_RETV_IF(icu_symbol.icu_ucol_strcoll == NULL, DB_UTIL_ERR_COL_FUNC_RET);
+
+ if(str1_len> str2_len) {
+ for(i=0;i<str2_len;i=i+2) {
+ str_to++;
+ }
+
+ while((int)(str_to-(UChar*)str1) <= str1_len) {
+ result = icu_symbol.icu_ucol_strcoll(
+ (UCollator *) ucol,
+ (UChar *) str_from, str_to-str_from,
+ (const UChar *) str2, str2_len);
+
+ if (result == UCOL_EQUAL)
+ {
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ DB_UTIL_TRACE_DEBUG("equal \n");
+#endif
+ return UCOL_EQUAL;
+ }
+
+ str_to++;
+ str_from++;
+ }
+ } else {
+ result = icu_symbol.icu_ucol_strcoll(
+ (UCollator *) ucol,
+ (const UChar *) str1, str1_len,
+ (const UChar *) str2, str2_len);
+ }
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ if (result == UCOL_LESS) {
+ DB_UTIL_TRACE_DEBUG("less \n");
+ } else if (result == UCOL_GREATER) {
+ DB_UTIL_TRACE_DEBUG("greater \n");
+ } else if (result == UCOL_EQUAL) {
+ DB_UTIL_TRACE_DEBUG("equal \n");
+ } else {
+ DB_UTIL_TRACE_DEBUG("compare error : %d \n", result);
+ }
+#endif
+
+ return result;
+}
+
+/* The collating function must return an integer that is negative, zero or positive */
+static int __db_util_collate_icu_8(void *ucol, int str1_len, const void *str1, int str2_len, const void *str2)
+{
+ UCharIterator uiter1, uiter2;
+ UErrorCode error = U_ZERO_ERROR;
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ DB_UTIL_TRACE_DEBUG("__db_util_collate_icu_8 func start \n");
+ DB_UTIL_TRACE_DEBUG("v1(%d) : %s, v2(%d) : %s \n", str1_len, (char*)str1, str2_len, (char*)str2);
+#endif
+
+ DB_UTIL_RETV_IF(icu_symbol.icu_uiter_setUTF8 == NULL, DB_UTIL_ERR_COL_FUNC_RET);
+ DB_UTIL_RETV_IF(icu_symbol.icu_ucol_strcollIter == NULL, DB_UTIL_ERR_COL_FUNC_RET);
+
+ icu_symbol.icu_uiter_setUTF8(&uiter1, (const char *) str1, str1_len);
+ icu_symbol.icu_uiter_setUTF8(&uiter2, (const char *) str2, str2_len);
+
+ UCollationResult result = icu_symbol.icu_ucol_strcollIter(
+ (UCollator *) ucol,
+ &uiter1,
+ &uiter2,
+ &error);
+ if(U_FAILURE(error)) {
+ DB_UTIL_TRACE_ERROR("__db_util_collate_icu_8 ucol_strcollIter error: %d\n", error);
+ return DB_UTIL_ERR_COL_FUNC_RET;
+ }
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ if (result == UCOL_LESS) {
+ DB_UTIL_TRACE_DEBUG("less \n");
+ } else if (result == UCOL_GREATER) {
+ DB_UTIL_TRACE_DEBUG("greater \n");
+ } else {
+ DB_UTIL_TRACE_DEBUG("equal \n");
+ }
+#endif
+
+ return result;
+}
+
+static int __db_util_collate_icu_8_lc(void *ucol, int str1_len, const void *str1, int str2_len, const void *str2)
+{
+ UCharIterator uiter1, uiter2;
+ UErrorCode error = U_ZERO_ERROR;
+ UCollationResult result = 0;
+ char* str_from = (char*)str1;
+ char* str_to = (char*)str1;
+ glong v1_char_len, v2_char_len;
+ int i;
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ DB_UTIL_TRACE_DEBUG("__db_util_collate_icu_8_lc func start \n");
+ DB_UTIL_TRACE_DEBUG("v1(%d) : %s, v2(%d) : %s \n", str1_len, (char*)str1, str2_len, (char*)str2);
+#endif
+
+ DB_UTIL_RETV_IF(icu_symbol.icu_uiter_setUTF8 == NULL, DB_UTIL_ERR_COL_FUNC_RET);
+ DB_UTIL_RETV_IF(icu_symbol.icu_ucol_strcollIter == NULL, DB_UTIL_ERR_COL_FUNC_RET);
+
+ icu_symbol.icu_uiter_setUTF8(&uiter2, (const char *) str2, str2_len);
+
+ v1_char_len = g_utf8_strlen((gchar *)str1,-1);
+ v2_char_len = g_utf8_strlen((gchar *)str2,-1);
+
+ if(v1_char_len > v2_char_len) {
+ for(i=0;i<v2_char_len;i++) {
+ str_to = g_utf8_next_char(str_to);
+ }
+
+ while((int)(str_to-(char*)str1) <= str1_len) {
+ icu_symbol.icu_uiter_setUTF8(
+ &uiter1,
+ (const char *) str_from,
+ str_to - str_from);
+
+ result = icu_symbol.icu_ucol_strcollIter(
+ (UCollator *) ucol,
+ &uiter1,
+ &uiter2,
+ &error);
+ if (U_FAILURE(error)) {
+ DB_UTIL_TRACE_ERROR("__db_util_collate_icu_8_lc ucol_strcollIter error: %d\n", error);
+ return DB_UTIL_ERR_COL_FUNC_RET;
+ }
+
+ if(result == UCOL_EQUAL)
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ {
+ DB_UTIL_TRACE_DEBUG("equal \n");
+ return UCOL_EQUAL;
+ }
+#else
+ return UCOL_EQUAL;
+#endif
+
+ str_to = g_utf8_next_char(str_to);
+ str_from = g_utf8_next_char(str_from);
+ }
+ }
+ else
+ {
+ icu_symbol.icu_uiter_setUTF8(
+ &uiter1,
+ (const char *) str1,
+ str1_len);
+
+ result = icu_symbol.icu_ucol_strcollIter(
+ (UCollator *) ucol,
+ &uiter1,
+ &uiter2,
+ &error);
+ if (U_FAILURE(error)) {
+ DB_UTIL_TRACE_ERROR("__db_util_collate_icu_8_lc ucol_strcollIter error: %d\n", error);
+ return DB_UTIL_ERR_COL_FUNC_RET;
+ }
+ }
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ if (result == UCOL_LESS)
+ {
+ DB_UTIL_TRACE_DEBUG("less \n");
+ }
+ else if (result == UCOL_GREATER)
+ {
+ DB_UTIL_TRACE_DEBUG("greater \n");
+ }
+ else if(result == UCOL_EQUAL)
+ {
+ DB_UTIL_TRACE_DEBUG("equal \n");
+ }
+ else
+ {
+ DB_UTIL_TRACE_DEBUG("compare error : %d\n", result);
+ }
+#endif
+
+ return result;
+}
+
+static void __db_util_collate_icu_close(void* ucol)
+{
+ DB_UTIL_TRACE_DEBUG("close icu collator\n");
+
+ DB_UTIL_RET_IF(icu_symbol.icu_ucol_close == NULL);
+
+ icu_symbol.icu_ucol_close((UCollator *) ucol);
+}
+
+static int __db_util_collation_create(sqlite3* db_handle, char* locale, char* collator_name, UCollationStrength ucol_strength_value, int utf_type, int cmp_type)
+{
+ int err;
+ UErrorCode status = U_ZERO_ERROR;
+
+ DB_UTIL_RETV_IF(icu_symbol.icu_ucol_open == NULL, DB_UTIL_ERR_DLSYM);
+ DB_UTIL_RETV_IF(icu_symbol.icu_ucol_setStrength == NULL, DB_UTIL_ERR_DLSYM);
+
+ UCollator* ucol = icu_symbol.icu_ucol_open(locale, &status);
+ if(status == U_USING_DEFAULT_WARNING) {
+ DB_UTIL_TRACE_ERROR("ucol_open success with default collate option\n");
+ } else if (U_FAILURE(status)) {
+ DB_UTIL_TRACE_ERROR("ucol_open fail : %d \n", status);
+ return DB_UTIL_ERR_ICU;
+ }
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+ else
+ {
+ DB_UTIL_TRACE_DEBUG("ucol_open success : %d \n", status);
+ }
+#endif
+
+ icu_symbol.icu_ucol_setStrength(ucol, ucol_strength_value);
+ if (U_FAILURE(status)) {
+ DB_UTIL_TRACE_ERROR("ucol_setStrength fail : %d \n", status);
+ return DB_UTIL_ERR_ICU;
+ } else {
+ DB_UTIL_TRACE_DEBUG("ucol_setStrength success \n");
+ }
+
+ if(utf_type == DB_UTIL_COL_UTF8) {
+ if(cmp_type == DB_UTIL_CMP_LC) {
+ err = sqlite3_create_collation_v2(db_handle, collator_name, SQLITE_UTF8, ucol,
+ __db_util_collate_icu_8_lc, (void(*)(void*))__db_util_collate_icu_close);
+ } else {
+ err = sqlite3_create_collation_v2(db_handle, collator_name, SQLITE_UTF8, ucol,
+ __db_util_collate_icu_8, (void(*)(void*))__db_util_collate_icu_close);
+ }
+ } else if(utf_type == DB_UTIL_COL_UTF16) {
+ if(cmp_type == DB_UTIL_CMP_LC) {
+ err = sqlite3_create_collation_v2(db_handle, collator_name, SQLITE_UTF16, ucol,
+ __db_util_collate_icu_16_lc, (void(*)(void*))__db_util_collate_icu_close);
+ } else {
+ err = sqlite3_create_collation_v2(db_handle, collator_name, SQLITE_UTF16, ucol,
+ __db_util_collate_icu_16, (void(*)(void*))__db_util_collate_icu_close);
+ }
+ } else {
+ DB_UTIL_TRACE_ERROR("wrong utf_type param value : %d\n", utf_type);
+ return DB_UTIL_ERR_PARAM;
+ }
+
+ if (err != SQLITE_OK) {
+ DB_UTIL_TRACE_ERROR("sqlite3_create_collation_v2 fail : %d \n", err);
+ __db_util_collate_icu_close((void*)ucol);
+ return err;
+ } else {
+ DB_UTIL_TRACE_DEBUG("sqlite3_create_collation_v2 success \n");
+ return DB_UTIL_OK;
+ }
+}
+
+int db_util_create_collation(
+ PARAM_IN sqlite3 *db_handle,
+ PARAM_IN db_util_collate_type type,
+ PARAM_IN db_util_collate_textrep text_type,
+ PARAM_IN char* col_name)
+{
+ int ret = DB_UTIL_OK;
+ UErrorCode status = U_ZERO_ERROR;
+ const char* locale = NULL;
+
+ DB_UTIL_TRACE_DEBUG("db_util_create_collation start");
+
+ ret = __db_util_dl_load_icu();
+ DB_UTIL_RETV_IF(ret != DB_UTIL_OK, DB_UTIL_ERROR);
+
+ /* get current locale */
+ icu_symbol.icu_uloc_setDefault((const char*)getenv("LANG"), &status);
+ locale = icu_symbol.icu_uloc_getDefault();
+ if(locale == NULL) {
+ DB_UTIL_TRACE_WARNING("Fail to get current locale : %d", DB_UTIL_ERR_ENV);
+ return DB_UTIL_ERROR;
+ }
+ DB_UTIL_TRACE_DEBUG("locale : %s", locale);
+
+#ifdef ENABLE_COL_KO_IC
+ if((db_util_collate_type == DB_UTIL_COL_KO_IC) ||
+ (db_util_collate_type == DB_UTIL_COL_KO_IC_LC)) {
+ if(strncmp(locale, "ko", 2) != 0) {
+ DB_UTIL_TRACE_WARNING("collate type is not match with current locale : %d", DB_UTIL_ERR_ENV);
+ return DB_UTIL_ERROR;
+ }
+ }
+#endif
+
+ switch(type) {
+ case DB_UTIL_COL_UCA :
+ ret = __db_util_collation_create(db_handle, NULL, col_name, UCOL_SECONDARY, text_type, DB_UTIL_CMP_SC);
+ break;
+ case DB_UTIL_COL_LS_AS_CI :
+ ret = __db_util_collation_create(db_handle, (char*)locale, col_name, UCOL_SECONDARY, text_type, DB_UTIL_CMP_SC);
+ break;
+ case DB_UTIL_COL_LS_AI_CI :
+ ret = __db_util_collation_create(db_handle, (char*)locale, col_name, UCOL_PRIMARY, text_type, DB_UTIL_CMP_SC);
+ break;
+ case DB_UTIL_COL_LS_AI_CI_LC :
+ ret = __db_util_collation_create(db_handle, (char*)locale, col_name, UCOL_PRIMARY, text_type, DB_UTIL_CMP_LC);
+ break;
+#ifdef ENABLE_COL_KO_IC
+ case DB_UTIL_COL_KO_IC :
+ ret = __db_util_collation_create(db_handle, (char*)locale, col_name, UCOL_PRIMARY, text_type, DB_UTIL_CMP_SC);
+ break;
+ case DB_UTIL_COL_KO_IC_LC :
+ ret = __db_util_collation_create(db_handle, (char*)locale, col_name, UCOL_PRIMARY, text_type, DB_UTIL_CMP_LC);
+ break;
+#endif
+ default :
+ DB_UTIL_TRACE_WARNING("wrong collate input type");
+ }
+
+ if(ret != DB_UTIL_OK)
+ ret = DB_UTIL_ERROR;
+
+ return ret;
+}
+
+#ifdef DB_UTIL_ENABLE_DEVDEBUG
+
+static char *strtoutf8(const UChar * unichars, int len)
+{
+ DB_UTIL_TRACE_WARNING("strtoutf8 start");
+
+ int lenstr, lenutf8;
+ char *pstr = NULL;
+ UErrorCode status = U_ZERO_ERROR;
+
+ lenstr = lenutf8 = 0;
+ lenstr = sizeof(char) * 4 * (len + 1);
+ pstr = (char *)malloc(lenstr);
+ if (!pstr)return NULL;
+ u_strToUTF8(pstr, lenstr, &lenutf8, unichars, len, &status);
+ if (U_FAILURE(status)) {
+ DB_UTIL_TRACE_WARNING("u_strToUTF8 failed in strtoutf8 :%s\n",
+ u_errorName(status));
+ return NULL;
+ }
+ DB_UTIL_TRACE_WARNING("strtoutf8 out : %s", pstr);
+ return pstr;
+}
+
+#endif
+
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: db-util
+Description: DB Utility
+Version: @VERSION@
+Requires: sqlite3 dlog glib-2.0 icu-i18n
+Libs: -L${libdir} -lSLP-db-util
+Cflags: -I${includedir}
--- /dev/null
+libslp-db-util (0.1.0-52) unstable; urgency=low
+
+ * disable return err for collation function
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-52
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Tue, 5 Jun 2012 19:00:37 +0900
+
+libslp-db-util (0.1.0-51) unstable; urgency=low
+
+ * match spec file for obs
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-51
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Mon, 28 May 2012 11:00:37 +0900
+
+libslp-db-util (0.1.0-50) unstable; urgency=low
+
+ * add collation api
+ * set localized collator at db_util_open api
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-50
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Sun, 27 May 2012 17:00:37 +0900
+
+libslp-db-util (0.1.0-49) unstable; urgency=low
+
+ * add export api define
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-49
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Thu, 15 Mar 2012 20:00:37 +0900
+
+libslp-db-util (0.1.0-48) unstable; urgency=low
+
+ * remove unused apis and header file
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-48
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Thu, 15 Mar 2012 17:00:37 +0900
+
+libslp-db-util (0.1.0-47) unstable; urgency=low
+
+ * deprecate unused apis
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-47
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Mon, 12 Mar 2012 16:40:37 +0900
+
+libslp-db-util (0.1.0-46) unstable; urgency=low
+
+ * add TC files
+ * insert code to check input param
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-46
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Wed, 15 Feb 2012 14:40:37 +0900
+
+libslp-db-util (0.1.0-45) unstable; urgency=low
+
+ * remove unnecessary files
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-45
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Fri, 02 Dec 2011 16:40:37 +0900
+
+libslp-db-util (0.1.0-44) unstable; urgency=low
+
+ * change busy handler time loop logic
+ * disable change journal mode option
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-44
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Tue, 15 Nov 2011 17:40:37 +0900
+
+libslp-db-util (0.1.0-43) unstable; urgency=low
+
+ * change busy handler time from 100ms to 1.5s
+ * disable change journal mode option
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-43
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Thu, 11 Nov 2011 17:40:37 +0900
+
+libslp-db-util (0.1.0-42) unstable; urgency=low
+
+ * change boilerplate
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-42
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Thu, 3 Nov 2011 17:40:37 +0900
+
+libslp-db-util (0.1.0-41) unstable; urgency=low
+
+ * apply indent & checkpath
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-41
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Tue, 26 May 2011 17:40:37 +0900
+
+libslp-db-util (0.1.0-40) unstable; urgency=low
+
+ * edit boilerplate
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-40
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Wed, 13 May 2011 17:40:37 +0900
+
+libslp-db-util (0.1.0-39) unstable; urgency=low
+
+ * add boilerplate to code
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-39
+
+ -- Hyungdeuk Kim <hd3.kim@samsung.com> Wed, 13 May 2011 16:40:37 +0900
+
+libslp-db-util (0.1.0-38) unstable; urgency=low
+
+ * change the procedure for db conection
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-38
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Wed, 04 May 2011 10:40:37 +0900
+
+libslp-db-util (0.1.0-37) unstable; urgency=low
+
+ * change == to =
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-37
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Wed, 15 Dec 2010 10:18:37 +0900
+
+libslp-db-util (0.1.0-36) unstable; urgency=low
+
+ * modify postinst
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-36
+
+ -- Jinkun.jang <jinkun.jang@samsung.com> Wed, 08 Dec 2010 20:04:32 +0900
+
+libslp-db-util (0.1.0-35) unstable; urgency=low
+
+ * add postinst
+ * Git: 165.213.180.234:slp/pkgs/l/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-35
+
+ -- Jinkun.jang <jinkun.jang@samsung.com> Wed, 08 Dec 2010 19:00:58 +0900
+
+libslp-db-util (0.1.0-34) unstable; urgency=low
+
+ * add dependency for SQLite3 command package
+ * Git: 165.213.180.234:/git/slp/pkgs/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-34
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Fri, 12 Nov 2010 10:20:03 +0900
+
+libslp-db-util (0.1.0-33) unstable; urgency=low
+
+ * add copyright
+ * Git: 165.213.180.234:/git/slp/pkgs/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-33
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Wed, 27 Oct 2010 13:49:59 +0900
+
+libslp-db-util (0.1.0-32) unstable; urgency=low
+
+ * modified CMakeLists.txt for renaming so files
+ * Git: 165.213.180.234:/git/slp/pkgs/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-32
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Thu, 21 Oct 2010 15:52:46 +0900
+
+libslp-db-util (0.1.0-31) unstable; urgency=low
+
+ * remove lucene trriger
+ * Git: 165.213.180.234:/git/slp/pkgs/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-31
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Mon, 30 Aug 2010 16:01:53 +0900
+
+libslp-db-util (0.1.0-30) unstable; urgency=low
+
+ * remove @internal tag from header files
+ * Git: 165.213.180.234:/git/slp/pkgs/libslp-db-util
+ * Tag: libslp-db-util_0.1.0-30
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Thu, 22 Jul 2010 20:04:15 +0900
+
+libslp-db-util (0.1.0-29) unstable; urgency=low
+
+ * modify debian control file for "XB-Public-Package: no"
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-29
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Mon, 12 Jul 2010 14:50:52 +0900
+
+libslp-db-util (0.1.0-28) unstable; urgency=low
+
+ * add maintainer
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-28
+
+ -- Jinkun Jang <jinkun.jang@samsung.com> Thu, 08 Jul 2010 15:41:29 +0900
+
+libslp-db-util (0.1.0-27) unstable; urgency=low
+
+ * move header files to /usr/include/db-util
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-27
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Thu, 17 Jun 2010 12:59:35 +0900
+
+libslp-db-util (0.1.0-26) unstable; urgency=low
+
+ * modify db-util.pc for dependency information
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-26
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Tue, 01 Jun 2010 20:57:04 +0900
+
+libslp-db-util (0.1.0-25) unstable; urgency=low
+
+ * add samsung copyright
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-25
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Thu, 27 May 2010 12:39:42 +0900
+
+libslp-db-util (0.1.0-24) unstable; urgency=low
+
+ * remove libslp-db-util-0.postinst for file owner & permission
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-24
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Tue, 11 May 2010 11:27:33 +0900
+
+libslp-db-util (0.1.0-23) unstable; urgency=low
+
+ * add libslp-db-util-0.postinst for file owner & permission
+ * add EXPORT_API for db_util_open_with_options()
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-23
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Thu, 15 Apr 2010 09:22:41 +0900
+
+libslp-db-util (0.1.0-22) unstable; urgency=low
+
+ * add db_util_open_with_options() interface for sqlite3_open_v2()
+ * add SET_TARGET_PROPERTIES()
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-22
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Tue, 13 Apr 2010 09:01:01 +0900
+
+libslp-db-util (0.1.0-21) unstable; urgency=low
+
+ * modify header files for c++ guard & hardcoded constants
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-21
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Tue, 06 Apr 2010 11:18:18 +0900
+
+libslp-db-util (0.1.0-20) unstable; urgency=low
+
+ * remove DOS style lin endings
+ * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-db-util-0
+ * Tag: libslp-db-util_0.1.0-20
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Mon, 05 Apr 2010 14:03:35 +0900
+
+libslp-db-util (0.1.0-19) unstable; urgency=low
+
+ * upgrade toochain
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Thu, 25 Mar 2010 15:48:13 +0900
+
+libslp-db-util (0.1.0-18) unstable; urgency=low
+
+ * add Busy handler for db_util_open()
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Mon, 08 Mar 2010 17:09:31 +0900
+
+libslp-db-util (0.1.0-17) unstable; urgency=low
+
+ * chage section from non-free to main
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Mon, 08 Mar 2010 09:25:38 +0900
+
+libslp-db-util (0.1.0-16) unstable; urgency=low
+
+ * change section to non-free
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Fri, 26 Feb 2010 10:57:46 +0900
+
+libslp-db-util (0.1.0-15) unstable; urgency=low
+
+ * add '\0' to last character of _szDBPath in util_func.c
+
+ -- jinkun.jang <jinkun.jang@samsung.com> Tue, 23 Feb 2010 21:10:20 +0900
+
+libslp-db-util (0.1.0-14) unstable; urgency=low
+
+ * Enable PERSIST journal mode
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Wed, 3 Feb 2010 19:37:24 +0900
+
+libslp-db-util (0.1.0-13) unstable; urgency=low
+
+ * Add lucene-index-trigger function
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Tue, 2 Feb 2010 20:37:24 +0900
+
+libslp-db-util (0.1.0-12) unstable; urgency=low
+
+ * Add Doxygen comments
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Tue, 2 Feb 2010 16:37:24 +0900
+
+libslp-db-util (0.1.0-11) unstable; urgency=low
+
+ * Modify control file for dependency with other package
+
+ -- jinkun jang <jinkun.jang@samsung.com> Wed, 27 Jan 2010 14:37:24 +0900
+
+libslp-db-util (0.1.0-10) unstable; urgency=low
+
+ * Modify db_util_close() function
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Wed, 27 Jan 2010 10:00:51 +0900
+
+libslp-db-util (0.1.0-9) unstable; urgency=low
+
+ * PC file changed from SLP-db-util.pc to db-util.pc
+
+ -- jinkun jang <jinkun.jang@samsung.com> Tue, 26 Jan 2010 18:33:51 +0900
+
+libslp-db-util (0.1.0-4) unstable; urgency=low
+
+ * Add debug package
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Thu, 21 Dec 2009 12:00:03 +0900
+
+libslp-db-util (0.1.0-3) unstable; urgency=low
+
+ * Add db_util_open() and db_util_close()
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Wen, 20 Dec 2009 17:22:03 +0900
+
+libslp-db-util (0.1.0-2) unstable; urgency=low
+
+ * Rollbacked.
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Thur, 19 Dec 2009 10:22:03 +0900
+
+libslp-db-util (0.1.0) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Thur, 10 Dec 2009 10:22:03 +0900
--- /dev/null
+Source: libslp-db-util
+Section: main
+Priority: optional
+Maintainer: Hyungdeuk Kim <hd3.kim@samsung.com> Hakjoo ko <hakjoo.ko@samsung.com>
+Uploaders: Hyungdeuk Kim <hd3.kim.@smasung.com> Hakjoo Ko <hakjoo.ko@samsung.com>
+Build-Depends: debhelper (>= 5), autotools-dev, libsqlite3-dev, dlog-dev, libglib2.0-dev, libicu-dev
+Standards-Version: 0.1.0
+
+Package: libslp-db-util-dev
+Section: main
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libslp-db-util-0 (= ${Source-Version}), libsqlite3-dev, dlog-dev, libglib2.0-dev, libicu-dev
+Description: libslp-db-util-dev package
+
+Package: libslp-db-util-0
+Section: main
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libsqlite3-0, sqlite3, libdlog-0, libglib2.0-0
+Description: libslp-db-util package
+
+Package: libslp-db-util-dbg
+Section: main
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libslp-db-util-0 (= ${Source-Version})
+Description: libslp-db-util debug package (unstripped)
--- /dev/null
+usr/bin
+usr/sbin
--- /dev/null
+CMakeLists.txt
--- /dev/null
+@PREFIX@/lib/*.so*
--- /dev/null
+#!/bin/sh
+
+if [ ! -d /opt/dbspace ]
+then
+ mkdir -p /opt/dbspace
+fi
+
+if [ ${USER} = "root" ]
+then
+ chown :5000 /opt/dbspace
+fi
+chmod 775 /opt/dbspace
+
--- /dev/null
+@PREFIX@/include/*
+@PREFIX@/lib/pkgconfig/*.pc
+
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+CXXFLAGS ?= -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+ CXXFLAGS += -O0
+else
+ CFLAGS += -O2
+ CXXFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+ #docbook-to-man debian/wavplayer.sgml > wavplayer.1
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+ rm -rf CMakeCache.txt
+ rm -rf CMakeFiles
+ rm -rf cmake_install.cmake
+ rm -rf Makefile
+ rm -rf install_manifest.txt
+ rm -rf *.so
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+# dh_installchangelogs
+# dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=libslp-db-util-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __DBUTIL_COLLATION_H__
+#define __DBUTIL_COLLATION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <db-util-common.h>
+
+/*
+ * Collations Types
+ *
+ * These types are intended for use in the
+ * 2nd parameter to the [db_util_create_collation()] interface.
+ * The meanings of the various types is shown below.
+ *
+ * [DB_UTIL_COL_UCA]
+ * Unicode Collation Algorithm / Locale InSensitive / Accent Sensitive / Case Insensitive
+ * This type will be mostly used in 'ORDER BY' clause of sql for sorted list.
+ *
+ * [DB_UTIL_COL_LS_AS_CI]
+ * Locale Sensitive / Accent Sensitive / Case Insensitive
+ * This type will be mostly used in 'ORDER BY' clause of sql for sorted list.
+ *
+ * [DB_UTIL_COL_LS_AI_CI]
+ * Locale Sensitive / Accent Insensitive / Case Insensitive
+ * This type will be mostly used for '=' operator comparison in 'WHERE' clause.
+
+ * [DB_UTIL_COL_LS_AI_CI_LC]
+ * Locale Sensitive / Accent Insensitive / Loop Comparison
+ * This type will be mostly used for 'LIKE' operator comparison in 'WHERE' clause.
+ *
+ * [DB_UTIL_COL_KR_IC] ##deprecated
+ * Locale Sensitive / Korea / Initial(leading) Consonant
+ * Compares string data using initial(leading) consonant for korea locale.
+ * This type will be mostly used for '=' operator comparison in 'WHERE' clause.
+ *
+ * [DB_UTIL_COL_KR_IC_LC] ##deprecated
+ * Locale Sensitive / Korea / Initial(leading) Consonant / Loop Comparison
+ * Compares string data using initial(leading) consonant for korea locale.
+ * This type will be mostly used for 'LIKE' operator comparison in 'WHERE' clause.
+ */
+
+typedef enum {
+ DB_UTIL_COL_UCA,
+ DB_UTIL_COL_LS_AS_CI,
+ DB_UTIL_COL_LS_AI_CI,
+ DB_UTIL_COL_LS_AI_CI_LC,
+ DB_UTIL_COL_KO_IC, //deprecated
+ DB_UTIL_COL_KO_IC_LC //deprecated
+} db_util_collate_type;
+
+/*
+ * Text Encodings
+ *
+ * These encodings are intended for use in the
+ * 3rd parameter to the [db_util_create_collation()] interface.
+ */
+typedef enum {
+ DB_UTIL_COL_UTF8 = SQLITE_UTF8,
+ DB_UTIL_COL_UTF16 = SQLITE_UTF16
+} db_util_collate_textrep;
+
+
+/**
+ * @defgroup DB_UTIL
+ * @ingroup StorageFW
+ * @{
+ */
+
+/**
+ * @fn int db_util_create_collation(sqlite3 *db_handle, db_util_collate_type type, db_util_collate_textrep text_type, char* col_name);
+ * This function defines a new collating sequences with the database connection specified as the firtst argument.
+ * This function is needed to be invoked after [db_util_open()].
+ *
+ * @param[in] Db connection handle to create collation with
+ * @param[in] Collation type. This value must be one of the [db_util_collate_type]
+ * @param[in] Encoding of text passed to the collating function callback
+ * @param[in] The name of collation(UTF-8 string)
+ * return This function returns DB_UTIL_OK or error code on failure
+ * @exception None
+ * @remarks None
+ * @pre Database connected
+ * @post None
+ * @code
+ */
+EXPORT_API int db_util_create_collation(
+ PARAM_IN sqlite3 *db_handle,
+ PARAM_IN db_util_collate_type type,
+ PARAM_IN db_util_collate_textrep text_type,
+ PARAM_IN char* col_name
+);
+
+/**
+*@}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __DBUTIL_COLLATION_H__ */
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __DB_UTIL_FUNC_H__
+#define __DB_UTIL_FUNC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <sqlite3.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef PARAM_IN
+#define PARAM_IN
+#endif
+
+#ifndef PARAM_OUT
+#define PARAM_OUT
+#endif
+
+typedef enum {
+ DB_UTIL_ERROR = SQLITE_ERROR,
+ DB_UTIL_OK = SQLITE_OK,
+} db_util_err;
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __DB_UTIL_FUNC_H__ */
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __DB_UTIL_DEBUG_H_
+#define __DB_UTIL_DEBUG_H_
+#include <stdio.h>
+
+#ifdef DB_UTIL_USING_PLATFORM_DBG
+ #include <dlog.h>
+ #ifdef LOG_TAG
+ #undef LOG_TAG
+ #endif
+ #define LOG_TAG "DBUTIL"
+#endif
+
+#ifdef DB_UTIL_ENABLE_TRACE
+
+ #ifdef DB_UTIL_USING_PLATFORM_DBG
+
+ #define DB_UTIL_TRACE_DEBUG LOGD
+ #define DB_UTIL_TRACE_WARNING LOGW
+ #define DB_UTIL_TRACE_ERROR LOGE
+
+ #else
+
+ #define DB_UTIL_TRACE_DEBUG(fmt, arg...) \
+ do {\
+ fprintf(stderr,"[DBUTIL]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", ##arg, strrchr(__FILE__, '/')+1, __LINE__);\
+ }while(0);
+
+ #define DB_UTIL_TRACE_WARNING(fmt, arg...) \
+ do {\
+ fprintf(stderr,"[DBUTIL]\033[0;33mWARRING: " fmt "\033[0m\t%s:%d\n", ##arg, strrchr(__FILE__, '/')+1, __LINE__);\
+ }while(0);
+
+ #define DB_UTIL_TRACE_ERROR(fmt, arg...) \
+ do {\
+ fprintf(stderr, "[DBUTIL]\033[0;31mERROR: " fmt "\033[0m\t%s:%d\n", ##arg, strrchr(__FILE__, '/')+1, __LINE__);\
+ }while(0);
+
+ #endif
+
+#else
+
+ #define DB_UTIL_TRACE_DEBUG(fmt, arg...)
+ #define DB_UTIL_TRACE_WARNING(fmt, arg...)
+ #define DB_UTIL_TRACE_ERROR(fmt, arg...)
+
+#endif
+#endif /* __DB_UTIL_DEBUG_H_ */
+
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __DB_UTIL_H__
+#define __DB_UTIL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "util-func.h"
+#include "collation.h"
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __DB_UTIL_H__ */
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __UTIL_FUNC_H__
+#define __UTIL_FUNC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <db-util-common.h>
+
+#define DB_UTIL_REGISTER_HOOK_METHOD 0x00000001
+#define DB_UTIL_LUCENE_INDEX 0x00000002
+
+/**
+* @defgroup StorageFW Storage Framework
+* In order to support applications using DB
+*/
+
+/**
+ * @defgroup DB_UTIL
+ * @ingroup StorageFW
+ * @{
+ */
+
+
+
+/**
+ * @brief invoke sqlite3_open with platform common configuration
+ * @details register busy handler, create localized collation
+ * @param [in] database file name (UTF-8)
+ * @param [out] SQLite database handle
+ * @param [in] option value
+ * @return sqlite3 function return value will be returned
+ * @see db_util_open_with_options()
+ * @see db_util_close()
+ *
+ */
+EXPORT_API int db_util_open(const char *pszFilePath, sqlite3 **ppDB,
+ int nOption);
+
+/**
+ * @brief invoke sqlite3_open_v2 with platform common configuration
+ * @details register busy handler, create localized collation
+ * @param [in] database file name (UTF-8)
+ * @param [out] SQLite database handle
+ * @param [in] sqlite3_open_v2 flags
+ * @param [in] Name of VFS module to use
+ * @return sqlite3 function return value will be returned
+ * @see db_util_open()
+ * @see db_util_close()
+ *
+ */
+EXPORT_API int db_util_open_with_options(const char *pszFilePath,
+ sqlite3 **ppDB, int flags,
+ const char *zVfs);
+
+/**
+ * @brief closing a database connection
+ * @param [in] SQLite database handle
+ * @return sqlite3_close function return value will be returned
+ * @see db_util_open()
+ * @see db_util_open_with_options()
+ *
+ */
+EXPORT_API int db_util_close(sqlite3 *ppDB);
+
+/**
+*@}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __UTIL_FUNC_H__ */
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: libslp-db-util
+Summary: DB Utility
+Version: 0.1.5
+Release: 1
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: cmake
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(icu-i18n)
+
+%description
+
+%package devel
+Summary: Devel package for libslp-db-util (devel)
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}/usr/share/license
+install LICENSE %{buildroot}/usr/share/license/%{name}
+
+%post
+/sbin/ldconfig
+if [ ! -d /opt/dbspace ]
+then
+ mkdir -p /opt/dbspace
+fi
+if [ ! -d /opt/usr/dbspace ]
+then
+ mkdir -p /opt/usr/dbspace
+fi
+chown :5000 /opt/dbspace
+chmod 775 /opt/dbspace
+chown :5000 /opt/usr/dbspace
+chmod 775 /opt/usr/dbspace
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest libSLP-db-util.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libSLP-db-util.so
+%{_libdir}/libSLP-db-util.so.0
+%{_libdir}/libSLP-db-util.so.0.1.0
+/usr/share/license/%{name}
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/db-util/*.h
+%{_libdir}/pkgconfig/db-util.pc
+
--- /dev/null
+/*
+ * libslp-db-util
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "util-func.h"
+#include "collation.h"
+#include "db-util-debug.h"
+
+static int __db_util_busyhandler(void *pData, int count)
+{
+ if(5 - count > 0) {
+ DB_UTIL_TRACE_DEBUG("Busy Handler Called! : PID(%d) / CNT(%d)\n", getpid(), count+1);
+ usleep((count+1)*100000);
+ return 1;
+ } else {
+ DB_UTIL_TRACE_WARNING("Busy Handler will be returned SQLITE_BUSY error : PID(%d) \n", getpid());
+ return 0;
+ }
+}
+
+void __db_util_collation_cb(void* pArg, sqlite3* pDB, int eTextRep, const char* szName)
+{
+ if (eTextRep == SQLITE_UTF8 && !sqlite3_stricmp(szName, "localized"))
+ db_util_create_collation(pDB, DB_UTIL_COL_LS_AI_CI,
+ DB_UTIL_COL_UTF8, "localized");
+ else
+ DB_UTIL_TRACE_WARNING("No matching collator for %s", szName);
+}
+
+static int __db_util_open(sqlite3 *pDB)
+{
+ int rc = 0;
+
+ if(pDB == NULL) {
+ DB_UTIL_TRACE_WARNING("Invalid input param error");
+ return DB_UTIL_ERROR;
+ }
+
+ /* Register Busy handler */
+ rc = sqlite3_busy_handler(pDB, __db_util_busyhandler, NULL);
+ if (SQLITE_OK != rc) {
+ DB_UTIL_TRACE_WARNING("Fail to register busy handler\n");
+ sqlite3_close(pDB);
+ return rc;
+ }
+
+#ifdef SET_PERSIST_JOURNAL_MODE
+ /* Code to change default journal mode of sqlite3 is enabled so this option is disabled */
+ /* Enable persist journal mode */
+ rc = sqlite3_exec(pDB, "PRAGMA journal_mode = PERSIST",
+ NULL, NULL, &pszErrorMsg);
+ if (SQLITE_OK != rc) {
+ DB_UTIL_TRACE_WARNING("Fail to change journal mode: %d, %d, %s, %s\n",
+ sqlite3_errcode(pDB),
+ sqlite3_extended_errcode(pDB),
+ pszErrorMsg,
+ sqlite3_errmsg(pDB));
+ sqlite3_free(pszErrorMsg);
+ sqlite3_close(pDB);
+ return rc;
+ }
+#endif
+
+ sqlite3_collation_needed(pDB, NULL, __db_util_collation_cb);
+
+#if 0
+ if (DB_UTIL_OK != rc) {
+ DB_UTIL_TRACE_WARNING("Fail to create collation");
+ return rc;
+ }
+#endif
+
+ return DB_UTIL_OK;
+}
+
+int db_util_open(const char *pszFilePath, sqlite3 **ppDB, int nOption)
+{
+ if((pszFilePath == NULL) || (ppDB == NULL)) {
+ DB_UTIL_TRACE_WARNING("Invalid input param error");
+ return DB_UTIL_ERROR;
+ }
+
+ if(access(pszFilePath, R_OK)) {
+ if(errno == EACCES) {
+ DB_UTIL_TRACE_ERROR("file access permission error");
+ return SQLITE_PERM;
+ }
+ }
+
+ /* Open DB */
+ int rc = sqlite3_open(pszFilePath, ppDB);
+ if (SQLITE_OK != rc) {
+ DB_UTIL_TRACE_ERROR("sqlite3_open error(%d), ");
+ return rc;
+ }
+
+ rc = __db_util_open(*ppDB);
+
+ return rc;
+}
+
+int db_util_open_with_options(const char *pszFilePath, sqlite3 **ppDB,
+ int flags, const char *zVfs)
+{
+ int mode;
+
+ if((pszFilePath == NULL) || (ppDB == NULL)) {
+ DB_UTIL_TRACE_WARNING("sqlite3 handle null error");
+ return DB_UTIL_ERROR;
+ }
+
+#if 0
+ if(flags == SQLITE_OPEN_READONLY)
+ mode = R_OK;
+ else
+ mode = R_OK|W_OK;
+#else
+ mode = R_OK;
+#endif
+
+ if(access(pszFilePath, mode)) {
+ if(errno == EACCES) {
+ DB_UTIL_TRACE_ERROR("file access permission error");
+ return SQLITE_PERM;
+ }
+ }
+
+ /* Open DB */
+ int rc = sqlite3_open_v2(pszFilePath, ppDB, flags, zVfs);
+ if (SQLITE_OK != rc) {
+ DB_UTIL_TRACE_ERROR("sqlite3_open_v2 error(%d), ");
+ return rc;
+ }
+
+ rc = __db_util_open(*ppDB);
+
+ return rc;
+}
+
+int db_util_close(sqlite3 *pDB)
+{
+ char *pszErrorMsg = NULL;
+
+ /* Close DB */
+ int rc = sqlite3_close(pDB);
+ if (SQLITE_OK != rc) {
+ DB_UTIL_TRACE_WARNING("Fail to change journal mode: %s\n", pszErrorMsg);
+ sqlite3_free(pszErrorMsg);
+ return rc;
+ }
+
+ return DB_UTIL_OK;
+}
+
+