summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2015-03-31 14:26:47 +0900
committerSung-jae Park <nicesj.park@samsung.com>2015-03-31 14:36:34 +0900
commit68e0d1912f10fcf4f28653ee953abacc116ca5c5 (patch)
tree76a0b93a3fba6a9773b5ca74050bd8604773dcb6 /src
parent92706a3fb3abf08d63088128253759f2150c07d1 (diff)
downloadwidget-service-68e0d1912f10fcf4f28653ee953abacc116ca5c5.tar.gz
widget-service-68e0d1912f10fcf4f28653ee953abacc116ca5c5.tar.bz2
widget-service-68e0d1912f10fcf4f28653ee953abacc116ca5c5.zip
ABI parser is moved from data-provider-master
ABI parser can be used commonly [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: I0f5a42c40f198c0ca84282df70a416a7484f8dc0
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x]src/util.c0
-rw-r--r--[-rwxr-xr-x]src/util_wayland.c0
-rw-r--r--[-rwxr-xr-x]src/util_x11.c0
-rw-r--r--src/widget_abi.c296
-rw-r--r--[-rwxr-xr-x]src/widget_conf.c0
-rw-r--r--[-rwxr-xr-x]src/widget_service.c0
6 files changed, 296 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index bec4eaf..bec4eaf 100755..100644
--- a/src/util.c
+++ b/src/util.c
diff --git a/src/util_wayland.c b/src/util_wayland.c
index 62aa894..62aa894 100755..100644
--- a/src/util_wayland.c
+++ b/src/util_wayland.c
diff --git a/src/util_x11.c b/src/util_x11.c
index 3532e80..3532e80 100755..100644
--- a/src/util_x11.c
+++ b/src/util_x11.c
diff --git a/src/widget_abi.c b/src/widget_abi.c
new file mode 100644
index 0000000..6fd8f3c
--- /dev/null
+++ b/src/widget_abi.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2013 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <sqlite3.h>
+#include <unicode/uloc.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <dlog.h>
+#include <widget_errno.h>
+
+#include "util.h"
+#include "debug.h"
+#include "dlist.h"
+
+int errno;
+
+#define MAX_ABI 256
+#define MAX_PKGNAME 512
+
+struct item {
+ char *abi;
+ char *pkgname; /*!< Slave package name */
+};
+
+static struct {
+ struct dlist *list;
+} s_abi = {
+ .list = NULL,
+};
+
+static int abi_add_entry(const char *abi, const char *pkgname)
+{
+ struct item *item;
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ ErrPrint("Failed to add a new entry for abi[%s - %s]\n", abi, pkgname);
+ return WIDGET_ERROR_OUT_OF_MEMORY;
+ }
+
+ item->abi = strdup(abi);
+ if (!item->abi) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ free(item);
+ return WIDGET_ERROR_OUT_OF_MEMORY;
+ }
+
+ item->pkgname = strdup(pkgname);
+ if (!item->pkgname) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ free(item->abi);
+ free(item);
+ return WIDGET_ERROR_OUT_OF_MEMORY;
+ }
+
+ s_abi.list = dlist_append(s_abi.list, item);
+ return WIDGET_ERROR_NONE;
+}
+
+static int abi_load_table(void)
+{
+ FILE *fp;
+ int ch;
+ int idx = 0;
+ int tag_id = 0;
+ enum {
+ INIT = 0x0,
+ GROUP = 0x1,
+ TAG = 0x02,
+ VALUE = 0x03,
+ ERROR = 0x05
+ } state;
+ enum {
+ PKGNAME = 0x0,
+ };
+ static const char *field[] = {
+ "package",
+ NULL,
+ };
+ const char *ptr = NULL;
+
+ char group[MAX_ABI + 1];
+ char pkgname[MAX_PKGNAME + 1];
+
+ fp = fopen("/usr/share/data-provider-master/abi.ini", "rt");
+ if (!fp) {
+ return WIDGET_ERROR_IO_ERROR;
+ }
+
+ state = INIT;
+ while ((ch = getc(fp)) != EOF && state != ERROR) {
+ switch (state) {
+ case INIT:
+ if (isspace(ch)) {
+ continue;
+ }
+ if (ch == '[') {
+ state = GROUP;
+ idx = 0;
+ } else {
+ state = ERROR;
+ }
+ break;
+ case GROUP:
+ if (ch == ']') {
+ if (idx == 0) {
+ state = ERROR;
+ } else {
+ group[idx] = '\0';
+ state = TAG;
+ idx = 0;
+ ptr = NULL;
+ }
+ } else if (idx < MAX_ABI) {
+ group[idx++] = ch;
+ } else {
+ ErrPrint("Overflow\n");
+ state = ERROR;
+ }
+ break;
+ case TAG:
+ if (ptr == NULL) {
+ if (idx == 0) {
+ if (isspace(ch)) {
+ continue;
+ }
+
+ /* New group started */
+ if (ch == '[') {
+ ungetc(ch, fp);
+ state = INIT;
+ continue;
+ }
+ }
+
+ ptr = field[idx];
+ }
+
+ if (ptr == NULL) {
+ ErrPrint("unknown tag\n");
+ state = ERROR;
+ continue;
+ }
+
+ if (*ptr == '\0' && ch == '=') {
+ /* MATCHED */
+ state = VALUE;
+ tag_id = idx;
+ idx = 0;
+ ptr = NULL;
+ } else if (*ptr == ch) {
+ ptr++;
+ } else {
+ ungetc(ch, fp);
+ ptr--;
+ while (ptr >= field[idx]) {
+ ungetc(*ptr, fp);
+ ptr--;
+ }
+ ptr = NULL;
+ idx++;
+ }
+ break;
+ case VALUE:
+ switch (tag_id) {
+ case PKGNAME:
+ if (idx == 0) { /* LTRIM */
+ if (isspace(ch)) {
+ continue;
+ }
+
+ pkgname[idx] = ch;
+ idx++;
+ } else if (isspace(ch)) {
+ int ret;
+ pkgname[idx] = '\0';
+
+ ret = abi_add_entry(group, pkgname);
+ if (ret != 0) {
+ ErrPrint("Failed to add %s for %s\n", pkgname, group);
+ }
+
+ state = TAG;
+ idx = 0;
+ } else if (idx < MAX_PKGNAME) {
+ pkgname[idx] = ch;
+ idx++;
+ } else {
+ ErrPrint("Overflow\n");
+ state = ERROR;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ case ERROR:
+ default:
+ break;
+ }
+ }
+
+ if (state == VALUE) {
+ switch (tag_id) {
+ case PKGNAME:
+ if (idx) {
+ int ret;
+ pkgname[idx] = '\0';
+ ret = abi_add_entry(group, pkgname);
+ if (ret != 0) {
+ ErrPrint("Failed to add %s for %s\n", pkgname, group);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (fclose(fp) != 0) {
+ ErrPrint("fclose: %s\n", strerror(errno));
+ }
+ return WIDGET_ERROR_NONE;
+}
+
+static void abi_del_all(void)
+{
+ struct item *item;
+ struct dlist *l;
+ struct dlist *n;
+
+ dlist_foreach_safe(s_abi.list, l, n, item) {
+ s_abi.list = dlist_remove(s_abi.list, l);
+ free(item->abi);
+ free(item->pkgname);
+ free(item);
+ }
+}
+
+EAPI int widget_abi_init(void)
+{
+ return abi_load_table();
+}
+
+EAPI int widget_abi_fini(void)
+{
+ abi_del_all();
+ return WIDGET_ERROR_NONE;
+}
+
+EAPI const char *widget_abi_get_pkgname_by_abi(const char *abi)
+{
+ struct dlist *l;
+ struct item *item;
+
+ dlist_foreach(s_abi.list, l, item) {
+ if (!strcasecmp(item->abi, abi)) {
+ return item->pkgname;
+ }
+ }
+
+ return NULL;
+}
+
+EAPI const char *widget_abi_get_abi_by_pkgname(const char *pkgname)
+{
+ struct dlist *l;
+ struct item *item;
+
+ dlist_foreach(s_abi.list, l, item) {
+ if (!strcmp(item->pkgname, pkgname)) {
+ return item->abi;
+ }
+ }
+
+ return NULL;
+}
+
+/* End of a file */
diff --git a/src/widget_conf.c b/src/widget_conf.c
index 6e42598..6e42598 100755..100644
--- a/src/widget_conf.c
+++ b/src/widget_conf.c
diff --git a/src/widget_service.c b/src/widget_service.c
index 24734f9..24734f9 100755..100644
--- a/src/widget_service.c
+++ b/src/widget_service.c