Removing KeyCombination code,Used to lookup for a particular combination. 39/102639/4
authorSanjeev Kumar <sanjeev1.k@samsung.com>
Tue, 6 Dec 2016 08:32:16 +0000 (14:02 +0530)
committerJengHyun Kang <jhyuni.kang@samsung.com>
Fri, 17 Mar 2017 07:17:39 +0000 (16:17 +0900)
Change-Id: Icafde34d2afaa0ce4985017bcdf96f95cfa3750f
Signed-off-by: Sanjeev Kumar <sanjeev1.k@samsung.com>
configure.ac
packaging/e-mod-tizen-keyrouter.spec
src/Makefile.am
src/e_mod_keyrouter_combination.c [deleted file]
src/e_mod_keyrouter_events.c
src/e_mod_main_wl.c
src/e_mod_main_wl.h
src/ini.c [deleted file]
src/ini.h [deleted file]

index b90fafd..a79e004 100644 (file)
@@ -40,8 +40,6 @@ dnl ========================================================================
 #AC_HEADER_STDC
 AC_CHECK_HEADERS([math.h fcntl.h stdlib.h string.h unistd.h])
 
-COMBINATION_FILE_PATH="$TZ_SYS_RO_APP/keyrouter/key_combination_list.ini"
-AC_DEFINE_UNQUOTED(COMBINATION_FILE_PATH, "$COMBINATION_FILE_PATH", [Path to Key Combination File])
 dnl ========================================================================
 # checks for typedefs, structures, and compiler characteristics
 AC_C_CONST
index 2c0a866..4f4c7d8 100644 (file)
@@ -14,7 +14,6 @@ BuildRequires:  pkgconfig(tizen-extension-server)
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-creds-socket)
 BuildRequires:  pkgconfig(capi-system-device)
-BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(libtzplatform-config)
 
 %description
index 6a0ff79..3d59d98 100644 (file)
@@ -9,10 +9,7 @@ if WAYLAND_ONLY
 module_la_SOURCES      = e_mod_main_wl.c \
                          e_mod_keyrouter_list.c \
                          e_mod_keyrouter_events.c \
-                         e_mod_keyrouter_conf.c \
-                         e_mod_keyrouter_combination.c \
-                         ini.c \
-                         ini.h
+                         e_mod_keyrouter_conf.c
 module_la_CFLAGS       = @ENLIGHTENMENT_CFLAGS@ @WAYLAND_CFLAGS@ -DHAVE_WAYLAND_ONLY @CYNARA_CFLAGS@ @TTRACE_CFLAGS@
 module_la_LDFLAGS      = -module -avoid-version @WAYLAND_LIBS@ @ENLIGHTENMENT_LIBS@ @CYNARA_LIBS@ @TTRACE_LIBS@
 endif
diff --git a/src/e_mod_keyrouter_combination.c b/src/e_mod_keyrouter_combination.c
deleted file mode 100644 (file)
index 86a3428..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-/*\r
- *   @file     e_mod_keyrouter_combination.c\r
- *   @brief    Implementation of e_mod_keyrouter_combination.c\r
- *   @author   Shubham Shrivastav shubham.sh@samsung.com\r
- *   @date     25th Feb 2016\r
- *   Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved\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
-\r
-#define E_COMP_WL\r
-#include "e_mod_main_wl.h"\r
-#include <dbus/dbus-glib.h>\r
-#include <dbus/dbus.h>\r
-#include "ini.h"\r
-\r
-#define MAX_LEN 64\r
-#define DBUS_PATH "/com/burtonini/dbus/ping"\r
-#define DBUS_IFACE "keyrouter.dbus.Signal"\r
-#define DBUS_MSG_NAME "KEY_COMBINATION"\r
-#define COMBINATION_TIME_OUT 4000\r
-#define MAX_SUPPORTED_COMBINATION 255\r
-#define DBUS_CONN_RETRY_TIMEOUT 0.2\r
-#define DBUS_CONN_MAX_RETRY_COUNT 20\r
-#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0\r
-\r
-typedef unsigned long Time;\r
-typedef struct _DbusConf\r
-{\r
-    char path[MAX_LEN];\r
-    char interface[MAX_LEN];\r
-    char msg[MAX_LEN];\r
-} DbusConf;\r
-typedef struct _KeyCombination\r
-{\r
-    DBusConnection * keyrouter_dbus_conn;\r
-    DbusConf dbusconf;\r
-    DBusError DBus_error;\r
-    char combinationFilePath[MAX_LEN];\r
-    GArray* _master_combinations;\r
-    GArray* _current_matched_combinations;\r
-    Time combination_timeout;\r
-} KeyCombination;\r
-\r
-static int keyCombinationInitialize = 0;\r
-static int dbus_connection_init_retry_count = 0;\r
-static Ecore_Timer *dbus_conn_timer = NULL;\r
-KeyCombination g_key_combination;\r
-\r
-static Eina_Bool _e_keyrouter_dbus_connection_init();\r
-static int _e_keyrouter_search_key_combination(int keycode, Time timestamp);\r
-static int _e_keyrouter_send_dbus_message(DBusConnection *bus, int Input);\r
-static char * _e_keyrouter_substring(char *string, int position);\r
-static int _e_keyrouter_parse_ini_config(void* user, const char* section, const char* name, const char* value);\r
-\r
-static Eina_Bool\r
-_e_keyrouter_dbus_connection_init()\r
-{\r
-   DBusError dBus_error;\r
-\r
-   KLINF("_e_keyrouter_dbus_connection_init()");\r
-\r
-   dbus_error_init(&dBus_error);\r
-   g_key_combination.keyrouter_dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dBus_error);\r
-   if (!g_key_combination.keyrouter_dbus_conn)\r
-     {\r
-        KLWRN("[DBUS-CONNECTION-FAIL] DBUS connection is failed");\r
-        if (dbus_error_is_set(&dBus_error))\r
-          {\r
-             KLWRN("[DBUS-ERROR] %s",dBus_error.message);\r
-             dbus_error_free(&dBus_error);\r
-          }\r
-        return EINA_FALSE;\r
-     }\r
-   return EINA_TRUE;\r
-}\r
-\r
-static Eina_Bool\r
-dbus_connection_init_retry_timercb()\r
-{\r
-   if (_e_keyrouter_dbus_connection_init())\r
-     {\r
-        keyCombinationInitialize = 1;\r
-        dbus_conn_timer = NULL;\r
-        return ECORE_CALLBACK_CANCEL;\r
-     }\r
-   else\r
-     {\r
-        if (dbus_connection_init_retry_count < DBUS_CONN_MAX_RETRY_COUNT)\r
-          {\r
-             dbus_connection_init_retry_count++;\r
-             KLWRN("Failed to init dbus conn trying again, try count %d",dbus_connection_init_retry_count);\r
-             return ECORE_CALLBACK_RENEW;\r
-          }\r
-        else\r
-          {\r
-             KLERR("Failed to init dbus connection for key combination after multiple tries");\r
-             dbus_conn_timer = NULL;\r
-             return ECORE_CALLBACK_CANCEL;\r
-          }\r
-     }\r
-}\r
-\r
-void\r
-e_keyrouter_key_combination_init()\r
-{\r
-   memset(&g_key_combination, 0, sizeof(g_key_combination));\r
-   g_key_combination.keyrouter_dbus_conn = NULL;\r
-   dbus_conn_timer = NULL;\r
-   snprintf(g_key_combination.dbusconf.path, strlen(DBUS_PATH)+1, DBUS_PATH);\r
-   snprintf(g_key_combination.dbusconf.interface, strlen(DBUS_IFACE)+1, DBUS_IFACE);\r
-   snprintf(g_key_combination.dbusconf.msg, strlen(DBUS_MSG_NAME)+1, DBUS_MSG_NAME);\r
-   snprintf(g_key_combination.combinationFilePath, strlen(COMBINATION_FILE_PATH)+1, COMBINATION_FILE_PATH);\r
-\r
-   g_key_combination._master_combinations = g_array_new(FALSE, FALSE, sizeof(GArray*));\r
-   if (ini_parse((const char *) g_key_combination.combinationFilePath, _e_keyrouter_parse_ini_config, g_key_combination._master_combinations) < 0)\r
-     {\r
-        KLWRN("Can't load %s file", g_key_combination.combinationFilePath);\r
-     }\r
-\r
-   g_key_combination.combination_timeout = COMBINATION_TIME_OUT;\r
-   if (_e_keyrouter_dbus_connection_init())\r
-     {\r
-        keyCombinationInitialize = 1;\r
-     }\r
-   else\r
-     {\r
-        dbus_conn_timer = ecore_timer_add(DBUS_CONN_RETRY_TIMEOUT, dbus_connection_init_retry_timercb, NULL);\r
-        if (dbus_conn_timer != NULL)\r
-          {\r
-             KLWRN("Ecore Timer added for dbus init retry ");\r
-          }\r
-        else\r
-          {\r
-             KLERR("dbus connection init failed and unable to add ecore timer callback for init retry");\r
-          }\r
-     }\r
-}\r
-\r
-static char *\r
-_e_keyrouter_substring(char *string, int position)\r
-{\r
-   char *pointer;\r
-   int c;\r
-\r
-   if (!string) return NULL;\r
-\r
-   for (c = 0; c < position - 1; c++)\r
-     string++;\r
-\r
-   pointer = malloc(strlen(string) + 1);\r
-   if (pointer == NULL)\r
-     {\r
-        KLWRN("Unable to allocate memory.");\r
-        return NULL;\r
-     }\r
-\r
-   for (c = 0; *string != '\0'; c++)\r
-     {\r
-        *(pointer + c) = *string;\r
-        string++;\r
-     }\r
-   *(pointer + c) = '\0';\r
-\r
-   return pointer;\r
-}\r
-\r
-static int\r
-_e_keyrouter_parse_ini_config(void* user, const char* section, const char* name, const char* value)\r
-{\r
-   int section_number, val;\r
-   size_t needed;\r
-   char *local_section, *c_num, *dup = NULL;\r
-   GArray *masterArray, *childArray;\r
-\r
-   if (!section) return -1;\r
-\r
-   dup = strdup(section);\r
-   c_num = _e_keyrouter_substring(dup, 12/*"Combination"*/);\r
-   if (c_num == NULL)\r
-     {\r
-        KLWRN(" Unable to read config. substring is null.");\r
-        return -1;\r
-     }\r
-\r
-   section_number = atoi(c_num);\r
-   free(c_num);\r
-   free(dup);\r
-   if (section_number <= 0 || section_number > MAX_SUPPORTED_COMBINATION)\r
-     {\r
-        KLWRN("^[[36m Unable to read config. section_number is invalid. ^[[0m");\r
-        return -1;\r
-     }\r
-   section_number--;\r
-\r
-   masterArray = (GArray*) user;\r
-   if (masterArray->len <= (unsigned int) section_number)\r
-     {\r
-        childArray = g_array_new(FALSE, FALSE, sizeof(int));\r
-        g_array_insert_val(masterArray, section_number, childArray);\r
-     }\r
-\r
-   needed = snprintf(NULL, 0, "%s%d", "Combination", section_number + 1);\r
-   local_section = malloc(needed + 1);\r
-   if (local_section == NULL)\r
-     {\r
-        KLWRN("^[[36m Failed to allocate memory for local_section ^[[0m");\r
-        return -1;\r
-     }\r
-   snprintf(local_section, needed + 1, "%s%d", "Combination", section_number + 1);\r
-\r
-   if (MATCH(local_section, "1"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 0, val);\r
-     }\r
-   else if (MATCH(local_section, "2"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 1, val);\r
-     }\r
-   else if (MATCH(local_section, "3"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 2, val);\r
-     }\r
-   else if (MATCH(local_section, "4"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 3, val);\r
-     }\r
-   else if (MATCH(local_section, "5"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 4, val);\r
-     }\r
-   else if (MATCH(local_section, "6"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 5, val);\r
-     }\r
-   else if (MATCH(local_section, "7"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 6, val);\r
-     }\r
-   else if (MATCH(local_section, "8"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 7, val);\r
-     }\r
-   else if (MATCH(local_section, "9"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 8, val);\r
-     }\r
-   else if (MATCH(local_section, "10"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 9, val);\r
-     }\r
-   else if (MATCH(local_section, "11"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 10, val);\r
-     }\r
-   else if (MATCH(local_section, "12"))\r
-     {\r
-        val = atoi(value);\r
-        childArray = g_array_index(masterArray,GArray*,section_number);\r
-        g_array_insert_val(childArray, 11, val);\r
-     }\r
-   else\r
-     {\r
-        free(local_section);\r
-        return 0; /* unknown section/name, error */\r
-     }\r
-    free(local_section);\r
-    return 1;\r
-}\r
-\r
-void\r
-e_keyrouter_process_key_combination(Time cur_time, int keycode, int state)\r
-{\r
-   int ret;\r
-\r
-   if (!keyCombinationInitialize)\r
-     {\r
-        KLWRN("KeyCombinatioin support is not initiazlied yet");\r
-        return ;\r
-     }\r
-   if (g_key_combination._master_combinations == NULL)\r
-     {\r
-        KLDBG(" Not searching key combination as Master combination is NULL");\r
-     }\r
-   if (state == ECORE_EVENT_KEY_UP)\r
-     {\r
-        ret = _e_keyrouter_search_key_combination(keycode, cur_time);\r
-\r
-        if(ret > 0)\r
-          {\r
-             _e_keyrouter_send_dbus_message(g_key_combination.keyrouter_dbus_conn, ret);\r
-          }\r
-     }\r
-}\r
-\r
-static int\r
-_e_keyrouter_send_dbus_message(DBusConnection *bus, int Input)\r
-{\r
-   DBusMessage *message = NULL;\r
-\r
-   message = dbus_message_new_signal(g_key_combination.dbusconf.path, g_key_combination.dbusconf.interface, g_key_combination.dbusconf.msg);\r
-   dbus_message_append_args(message, DBUS_TYPE_INT32, &Input, DBUS_TYPE_INVALID);\r
-\r
-   if (!dbus_connection_send(bus, message, NULL))\r
-     KLWRN( "DBUS sending MSG  FAILED!!");\r
-\r
-   dbus_message_unref(message);\r
-   return 1;\r
-}\r
-\r
-static int\r
-_e_keyrouter_search_key_combination(int keycode, Time timestamp)\r
-{\r
-   static Time t = 0;\r
-   unsigned int i, j = 0;\r
-   int matchedIdx = 0, foundAt = 0;\r
-   static int keyIdx = 0;\r
-   static GArray *_source_Search_Array = NULL;\r
-   GArray *childArray, *matched;\r
-\r
-   if (timestamp - t >= g_key_combination.combination_timeout && keyIdx != 0)\r
-     {\r
-        t = timestamp;\r
-        keyIdx = 0;\r
-        g_array_free(_source_Search_Array, FALSE);\r
-\r
-          {\r
-             g_key_combination._current_matched_combinations = g_array_new(FALSE, FALSE, sizeof(GArray*));\r
-             _source_Search_Array = g_key_combination._master_combinations;/*now update _current_matched_combinations assuming last key that invalidated as first key*/\r
-             matchedIdx = 0;\r
-             for (i = 0; i < _source_Search_Array->len; i++)\r
-               {\r
-                  GArray * childArray = g_array_index(_source_Search_Array,GArray*,i);\r
-                  if (keycode == g_array_index(childArray,int,0))\r
-                    {\r
-                       g_array_insert_val(g_key_combination._current_matched_combinations, matchedIdx, childArray);\r
-                       matchedIdx++;\r
-                    }\r
-               }\r
-\r
-             if (g_key_combination._current_matched_combinations->len > 0)\r
-               {\r
-                  keyIdx = 1;/*assumed that first key is the last key that invalidated the combinaton.*/\r
-                  _source_Search_Array = g_key_combination._current_matched_combinations;/*start next key combination matching from this assumed _current_matched_combinations*/\r
-                  t = timestamp;\r
-               }\r
-             else /* the key that invalidated is unavailable in any master_combinations as first element*/\r
-               {\r
-                  keyIdx = 0;\r
-                  t = timestamp;\r
-                  g_array_free(g_key_combination._current_matched_combinations, FALSE);\r
-               }\r
-          }\r
-        return -1;\r
-     }\r
-\r
-   g_key_combination._current_matched_combinations = g_array_new(FALSE, FALSE, sizeof(GArray*));\r
-   if (keyIdx == 0) _source_Search_Array = g_key_combination._master_combinations;\r
-\r
-   for (i = 0; i < _source_Search_Array->len; i++)\r
-     {\r
-        childArray = g_array_index(_source_Search_Array,GArray*,i);\r
-        if (keycode == g_array_index(childArray,int,keyIdx))\r
-          {\r
-             g_array_insert_val(g_key_combination._current_matched_combinations, matchedIdx, childArray);\r
-             matchedIdx++;\r
-          }\r
-     }\r
-\r
-   if (keyIdx > 0)/* this needs to be freed for count > 0 as for keyIdx== 0 it will point to master_combinations!*/\r
-     {\r
-        g_array_free(_source_Search_Array, FALSE);/* this actually frees "last" current_matched_combinations*/\r
-     }\r
-   if (g_key_combination._current_matched_combinations->len < 1)/* the incoming key has invalidated the combination sequence*/\r
-     {\r
-        _source_Search_Array = g_key_combination._master_combinations;/*now update _current_matched_combinations assuming last key that invalidated as first key*/\r
-        matchedIdx = 0;\r
-\r
-        for (i = 0; i < _source_Search_Array->len; i++)\r
-          {\r
-             childArray = g_array_index(_source_Search_Array,GArray*,i);\r
-             if (keycode == g_array_index(childArray,int,0))\r
-               {\r
-                  g_array_insert_val(g_key_combination._current_matched_combinations, matchedIdx, childArray);\r
-                  matchedIdx++;\r
-               }\r
-          }\r
-\r
-        if (g_key_combination._current_matched_combinations->len > 0)\r
-          {\r
-             keyIdx = 1;/*assumed that first key is the last key that invalidated the combinaton.*/\r
-             _source_Search_Array = g_key_combination._current_matched_combinations;/*start next key combination matching from this assumed _current_matched_combinations*/\r
-             t = timestamp;\r
-          }\r
-        else/* the key that invalidated is unavailable in any master_combinations as first element*/\r
-          {\r
-             keyIdx = 0;\r
-             t = timestamp;\r
-             g_array_free(g_key_combination._current_matched_combinations, FALSE);\r
-          }\r
-     }\r
-   else\r
-     {\r
-        if (g_key_combination._current_matched_combinations->len == 1 && (unsigned int)(keyIdx+1) == g_array_index(g_key_combination._current_matched_combinations,GArray*,0)->len)\r
-          {\r
-             keyIdx = 0;\r
-             t = timestamp;\r
-             matched = g_array_index(g_key_combination._current_matched_combinations,GArray*,0);\r
-\r
-             for (i = 0; i < matched->len; i++)\r
-               KLDBG("[32m Matched Combination:|%d| [0m", g_array_index(matched,int,i));\r
-             foundAt = 0;\r
-\r
-             for (i = 0; i < g_key_combination._master_combinations->len; i++)\r
-               {\r
-                  childArray=g_array_index(g_key_combination._master_combinations,GArray*,i);\r
-                  for (j = 0; j < childArray->len; j++)\r
-                    {\r
-                       if (childArray->len == matched->len && g_array_index(childArray,int,j) == g_array_index(matched,int,j))\r
-                         {\r
-                            foundAt = i + 1;\r
-                         }\r
-                       else\r
-                         {\r
-                            foundAt = FALSE;\r
-                            break;\r
-                         }\r
-                    }\r
-                  if (foundAt)\r
-                    {\r
-                       KLDBG("[32m COMBINATION FOUND AT : %d  [0m", foundAt);\r
-                       break;\r
-                    }\r
-               }\r
-             g_array_free(g_key_combination._current_matched_combinations, FALSE);/* we free this as combination is found and we need to start fresh for next key.*/\r
-             return foundAt;\r
-          }\r
-        else/*continue search for next key*/\r
-          {\r
-             t = timestamp;\r
-             keyIdx++;\r
-             _source_Search_Array = g_key_combination._current_matched_combinations;\r
-          }\r
-     }\r
-\r
-   return -1;\r
-}\r
index ec7c72b..62f8a36 100644 (file)
@@ -99,8 +99,6 @@ e_keyrouter_process_key_event(void *event, int type)
      }
 
    //KLDBG("The key(%d) is going to be sent to the proper wl client(s) !", ev->keycode);
-   /* Call process key combination to lookup for any particular combinaton */
-   e_keyrouter_process_key_combination(ev->timestamp, ev->keycode, type);
    KLDBG("[%s] keyname: %s, key: %s, keycode: %d", (type == ECORE_EVENT_KEY_DOWN) ? "KEY_PRESS" : "KEY_RELEASE", ev->keyname, ev->key, ev->keycode);
    if (_e_keyrouter_send_key_events(type, ev))
      res = EINA_FALSE;
index 9ff728a..1d81b95 100644 (file)
@@ -1157,8 +1157,6 @@ _e_keyrouter_init(E_Module *m)
    krt->conf = kconfig;
    krt->pictureoff_disabled = !!kconfig->conf->pictureoff_disabled;
 
-   e_keyrouter_key_combination_init();
-
    /* Get keyname and keycode pair from Tizen Key Layout file */
    res = _e_keyrouter_query_tizen_key_table();
    EINA_SAFETY_ON_FALSE_GOTO(res, err);
index 87536fb..990b055 100644 (file)
@@ -211,8 +211,6 @@ const char *e_keyrouter_mode_to_string(uint32_t mode);
 
 void e_keyrouter_conf_init(E_Keyrouter_Config_Data *kconfig);
 void e_keyrouter_conf_deinit(E_Keyrouter_Config_Data *kconfig);
-void e_keyrouter_key_combination_init();
-void e_keyrouter_process_key_combination(Time cur_time, int keycode, int state);
 int e_keyrouter_cb_picture_off(const int option, void *data);
 
 #endif
diff --git a/src/ini.c b/src/ini.c
deleted file mode 100644 (file)
index a4e79c3..0000000
--- a/src/ini.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/* inih -- simple .INI file parser
-
-inih is released under the New BSD license (see LICENSE.txt). Go to the project
-home page for more info:
-
-
-*/
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-#include "ini.h"
-#include "errno.h"
-
-#if !INI_USE_STACK
-#include <stdlib.h>
-#endif
-
-#define MAX_SECTION 50
-#define MAX_NAME 50
-
-static char *
-rstrip(char* s)
-{
-   char* p = s + strlen(s);
-   while (p > s && isspace((unsigned char)(*--p)))
-     *p = '\0';
-   return s;
-}
-
-static char *
-lskip(char* s)
-{
-   while (*s && isspace((unsigned char)(*s)))
-     s++;
-   return (char*)s;
-}
-
-static char *
-find_char_or_comment(char* s, char c)
-{
-   int was_whitespace = 0;
-   while (*s && *s != c && !(was_whitespace && *s == ';'))
-     {
-        was_whitespace = isspace((unsigned char)(*s));
-        s++;
-     }
-   return (char*)s;
-}
-
-static char *
-strncpy0(char* dest, const char* src, size_t size)
-{
-   strncpy(dest, src, size);
-   dest[size - 1] = '\0';
-   return dest;
-}
-
-int
-ini_parse_file(FILE* file,
-               int (*handler)(void*, const char*, const char*, const char*),
-               void* user)
-{
-#if INI_USE_STACK
-   char line[INI_MAX_LINE];
-#else
-   char* line;
-#endif
-   char section[MAX_SECTION] = "";
-   char prev_name[MAX_NAME] = "";
-
-   char* start;
-   char* end;
-   char* name;
-   char* value;
-   int lineno = 0;
-   int error = 0;
-
-#if !INI_USE_STACK
-   line = (char*)malloc(INI_MAX_LINE);
-   if (!line)
-     {
-        return -2;
-     }
-#endif
-
-   while (fgets(line, INI_MAX_LINE, file) != NULL)
-     {
-        lineno++;
-
-        start = line;
-#if INI_ALLOW_BOM
-        if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
-           (unsigned char)start[1] == 0xBB &&
-           (unsigned char)start[2] == 0xBF)
-          {
-             start += 3;
-          }
-#endif
-        start = lskip(rstrip(start));
-
-        if (*start == ';' || *start == '#')
-          {
-             ;
-          }
-#if INI_ALLOW_MULTILINE
-        else if (*prev_name && *start && start > line)
-          {
-             if (!handler(user, section, prev_name, start) && !error)
-               error = lineno;
-          }
-#endif
-        else if (*start == '[')
-          {
-             end = find_char_or_comment(start + 1, ']');
-             if (*end == ']')
-               {
-                  *end = '\0';
-                  strncpy0(section, start + 1, sizeof(section));
-                  *prev_name = '\0';
-               }
-             else if (!error)
-               {
-                  error = lineno;
-               }
-          }
-        else if (*start && *start != ';')
-          {
-             end = find_char_or_comment(start, '=');
-             if (*end != '=')
-               {
-                  end = find_char_or_comment(start, ':');
-               }
-             if (*end == '=' || *end == ':')
-               {
-                  *end = '\0';
-                  name = rstrip(start);
-                  value = lskip(end + 1);
-                  end = find_char_or_comment(value, '\0');
-
-                  if (*end == ';')
-                    *end = '\0';
-                  rstrip(value);
-
-                  strncpy0(prev_name, name, sizeof(prev_name));
-
-                  if (!handler(user, section, name, value) && !error)
-                    error = lineno;
-               }
-             else if (!error)
-               {
-                  error = lineno;
-               }
-          }
-
-#if INI_STOP_ON_FIRST_ERROR
-        if (error)
-          break;
-#endif
-     }
-
-#if !INI_USE_STACK
-   free(line);
-#endif
-
-   return error;
-}
-
-
-int
-ini_parse(const char* filename,
-          int (*handler)(void*, const char*, const char*, const char*),
-          void* user)
-{
-   FILE* file;
-   int error;
-
-   file = fopen(filename, "r");
-   if (!file)
-     return -1;
-   error = ini_parse_file(file, handler, user);
-   fclose(file);
-   return error;
-}
diff --git a/src/ini.h b/src/ini.h
deleted file mode 100644 (file)
index 0411663..0000000
--- a/src/ini.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* inih -- simple .INI file parser
-
-inih is released under the New BSD license (see LICENSE.txt). Go to the project
-home page for more info:
-
-
-*/
-
-#ifndef __INI_H__
-#define __INI_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-
-int ini_parse(const char* filename,
-              int (*handler)(void* user, const char* section,
-                             const char* name, const char* value),
-              void* user);
-
-int ini_parse_file(FILE* file,
-                   int (*handler)(void* user, const char* section,
-                                  const char* name, const char* value),
-                   void* user);
-
-#ifndef INI_ALLOW_MULTILINE
-#define INI_ALLOW_MULTILINE 1
-#endif
-
-#ifndef INI_ALLOW_BOM
-#define INI_ALLOW_BOM 1
-#endif
-
-#ifndef INI_USE_STACK
-#define INI_USE_STACK 1
-#endif
-
-#ifndef INI_STOP_ON_FIRST_ERROR
-#define INI_STOP_ON_FIRST_ERROR 0
-#endif
-
-#ifndef INI_MAX_LINE
-#define INI_MAX_LINE 200
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __INI_H__ */