Remove connector implementations.
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 18 Jun 2012 07:16:12 +0000 (16:16 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 19 Jun 2012 02:23:31 +0000 (11:23 +0900)
It is replaced with the libconnector library

Change-Id: I977f996282417bd100a5f5fcb3364bee4860c132

25 files changed:
CMakeLists.txt
debian/control
include/connector.h [deleted file]
include/connector_packet.h [deleted file]
include/dlist.h [deleted file]
include/packet.h [deleted file]
include/secom_socket.h [deleted file]
packaging/com.samsung.data-provider-master.spec
src/client_life.c
src/client_rpc.c
src/connector.c [deleted file]
src/connector_packet.c [deleted file]
src/ctx_client.c
src/dead_monitor.c
src/dlist.c [deleted file]
src/fault_manager.c
src/instance.c
src/main.c
src/package.c
src/packet.c [deleted file]
src/script_handler.c
src/secom_socket.c [deleted file]
src/server.c
src/slave_life.c
src/slave_rpc.c

index 0232b52..5e114bc 100644 (file)
@@ -17,6 +17,7 @@ pkg_check_modules(pkg REQUIRED
        evas
        ecore-evas
        capi-context-engine
+       connector
 )
 
 SET(PACKAGE "${PROJECT_NAME}")
@@ -75,11 +76,6 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        src/setting.c
        src/package.c
        src/instance.c
-       src/secom_socket.c
-       src/packet.c
-       src/connector.c
-       src/connector_packet.c
-       src/dlist.c
        src/server.c
 )
 
index 6b99345..ba2540d 100755 (executable)
@@ -2,7 +2,7 @@ Source: data-provider-master
 Section: utils
 Priority: extra
 Maintainer: Sung-jae Park <nicesj.park@samsung.com>, Youngjoo Park <yjoo93.park@samsung.com>
-Build-Depends: debhelper (>= 5), libail-0-dev, dlog-dev, libaul-1-dev, libglib2.0-dev, libbundle-dev, libecore-dev, libslp-setting-dev, libecore-dev, libevas-dev, libcontext-engine-dev
+Build-Depends: debhelper (>= 5), libail-0-dev, dlog-dev, libaul-1-dev, libglib2.0-dev, libbundle-dev, libecore-dev, libslp-setting-dev, libecore-dev, libevas-dev, libcontext-engine-dev, libconnector-dev
 Standards-Version: 0.1.0
 
 Package: com.samsung.data-provider-master
diff --git a/include/connector.h b/include/connector.h
deleted file mode 100644 (file)
index 1fbc8fb..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-enum connector_event_type {
-       CONNECTOR_CONNECTED,
-       CONNECTOR_DISCONNECTED,
-};
-
-extern int connector_server_create(const char *addr, int is_sync, int (*service_cb)(int fd, int readsize, void *data), void *data);
-extern int connector_client_create(const char *addr, int is_sync, int (*service_cb)(int fd, int readsize, void *data), void *data);
-extern int connector_server_destroy(int handle);
-extern int connector_client_destroy(int handle);
-
-extern int connector_add_event_callback(enum connector_event_type type, int (*service_cb)(int handle, void *data), void *data);
-extern void *connector_del_event_callback(enum connector_event_type type, int (*service_cb)(int handle, void *data), void *data);
-
-/* End of a file */
diff --git a/include/connector_packet.h b/include/connector_packet.h
deleted file mode 100644 (file)
index 12b4c49..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-struct method {
-       const char *cmd;
-       struct packet *(*handler)(pid_t pid, int handle, struct packet *packet);
-};
-
-extern int connector_packet_async_send(int handle, struct packet *packet, int (*recv_cb)(pid_t, int handle, const struct packet *packet, void *data), void *data);
-extern int connector_packet_send_only(int handle, struct packet *packet);
-extern struct packet *connector_packet_oneshot_send(const char *addr, struct packet *packet);
-
-extern int connector_packet_client_init(const char *addr, int is_sync, struct method *table);
-extern int connector_packet_client_fini(int handle);
-extern int connector_packet_server_init(const char *addr, struct method *table);
-extern int connector_packet_server_fini(int handle);
-
-/* End of a file */
diff --git a/include/dlist.h b/include/dlist.h
deleted file mode 100644 (file)
index 5c583e6..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#define dlist_remove_data(list, data) do { \
-       struct dlist *l; \
-       l = dlist_find_data(list, data); \
-       list = dlist_remove(list, l); \
-} while (0)
-
-#define dlist_foreach(list, l, data) \
-       for ((l) = (list); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l))
-
-#define dlist_foreach_safe(list, l, n, data) \
-       for ((l) = (list), (n) = dlist_next(l); \
-               (l) && ((data) = dlist_data(l)); \
-               (l) = (n), (n) = dlist_next(l))
-
-struct dlist;
-
-extern struct dlist *dlist_append(struct dlist *list, void *data);
-extern struct dlist *dlist_prepend(struct dlist *list, void *data);
-extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l);
-extern struct dlist *dlist_find_data(struct dlist *list, void *data);
-extern void *dlist_data(struct dlist *l);
-extern struct dlist *dlist_next(struct dlist *l);
-extern struct dlist *dlist_prev(struct dlist *l);
-extern int dlist_count(struct dlist *l);
-extern struct dlist *dlist_nth(struct dlist *l, int nth);
-
-/* End of a file */
diff --git a/include/packet.h b/include/packet.h
deleted file mode 100644 (file)
index 475c4be..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-
-struct packet;
-
-enum packet_type {
-       PACKET_REQ,
-       PACKET_ACK,
-       PACKET_REQ_NOACK,
-};
-
-#define PACKET_VERSION 1
-#define PACKET_MAX_CMD 24
-
-extern struct packet *packet_create(const char *command, const char *fmt, ...);
-extern struct packet *packet_create_noack(const char *command, const char *fmt, ...);
-extern struct packet *packet_create_reply(struct packet *packet, const char *fmt, ...);
-extern int packet_get(const struct packet *packet, const char *fmt, ...);
-extern int packet_destroy(struct packet *packet);
-extern struct packet *packet_ref(struct packet *packet);
-extern struct packet *packet_unref(struct packet *packet);
-
-extern const void * const packet_data(const struct packet *packet);
-extern const unsigned long const packet_seq(const struct packet *packet);
-extern const enum packet_type const packet_type(const struct packet *packet);
-extern const int const packet_version(const struct packet *packet);
-extern const int const packet_payload_size(const struct packet *packet);
-extern const char * const packet_command(const const struct packet *packet);
-extern const int const packet_header_size(void);
-extern const int const packet_size(const struct packet *packet);
-
-extern struct packet *packet_build(struct packet *packet, int offset, void *data, int size);
-
-/* End of a file */
diff --git a/include/secom_socket.h b/include/secom_socket.h
deleted file mode 100644 (file)
index cf994de..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * com.samsung.live-magazine
- *
- * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Sung-jae Park <nicesj.park@samsung.com>, Youngjoo Park <yjoo93.park@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.
- *
- */
-
-
-/*
- * Create client connection
- */
-extern int secom_create_client(const char *peer);
-
-/*
- * Create server connection
- */
-extern int secom_create_server(const char *peer);
-
-/*
- * Get the raw handle to use it for non-blocking mode.
- */
-extern int secom_get_connection_handle(int server_handle);
-extern int secom_put_connection_handle(int conn_handle);
-
-/*
- * Send data to the connected peer.
- */
-extern int secom_send(int conn, const char *buffer, int size);
-
-/*
- * Recv data from the connected peer. and its PID value
- */
-extern int secom_recv(int conn, char *buffer, int size, int *sender_pid);
-
-/*
- * Destroy a connection
- */
-extern int secom_destroy(int conn);
-
-/* End of a file */
index 22c64bf..d14ae82 100644 (file)
@@ -20,6 +20,7 @@ BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(evas)
 BuildRequires: pkgconfig(ecore-evas)
 BuildRequires: pkgconfig(capi-context-engine)
+BuildRequires: pkgconfig(connector)
 
 %description
 Manage the slave data provider and communicate with client applications.
index 787eea9..9b35253 100644 (file)
@@ -4,8 +4,8 @@
 #include <Eina.h>
 
 #include <dlog.h>
+#include <packet.h>
 
-#include "packet.h"
 #include "client_life.h"
 #include "client_rpc.h"
 #include "debug.h"
index eb19900..0649e86 100644 (file)
@@ -5,9 +5,9 @@
 #include <Ecore.h>
 
 #include <dlog.h>
+#include <connector_packet.h>
+#include <packet.h>
 
-#include "connector_packet.h"
-#include "packet.h"
 #include "client_life.h"
 #include "client_rpc.h"
 #include "debug.h"
diff --git a/src/connector.c b/src/connector.c
deleted file mode 100644 (file)
index 9b592c4..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-
-#include <glib.h>
-
-#include <dlog.h>
-
-#include "dlist.h"
-#include "secom_socket.h"
-#include "packet.h"
-#include "debug.h"
-#include "connector.h"
-#include "util.h"
-
-static struct {
-       struct dlist *conn_cb_list;
-       struct dlist *disconn_cb_list;
-} s_info = {
-       .conn_cb_list = NULL,
-       .disconn_cb_list = NULL,
-};
-
-struct cbdata {
-       int (*service_cb)(int fd, int readsize, void *data);
-       void *data;
-};
-
-struct evtdata {
-       int (*evt_cb)(int fd, void *data);
-       void *data;
-};
-
-static inline void invoke_con_cb_list(int handle)
-{
-       struct dlist *l;
-       struct dlist *n;
-       struct evtdata *cbdata;
-
-       dlist_foreach_safe(s_info.conn_cb_list, l, n, cbdata) {
-               if (cbdata->evt_cb(handle, cbdata->data) < 0) {
-                       s_info.conn_cb_list = dlist_remove(s_info.conn_cb_list, l);
-                       free(cbdata);
-               }
-       }
-}
-
-static inline void invoke_disconn_cb_list(int handle)
-{
-       struct dlist *l;
-       struct dlist *n;
-       struct evtdata *cbdata;
-
-       dlist_foreach_safe(s_info.disconn_cb_list, l, n, cbdata) {
-               if (cbdata->evt_cb(handle, cbdata->data) < 0) {
-                       s_info.disconn_cb_list = dlist_remove(s_info.disconn_cb_list, l);
-                       free(cbdata);
-               }
-       }
-}
-
-static gboolean client_cb(GIOChannel *src, GIOCondition cond, gpointer data)
-{
-       int client_fd;
-       struct cbdata *cbdata = data;
-       int ret;
-       int readsize;
-
-       client_fd = g_io_channel_unix_get_fd(src);
-
-       if (!(cond & G_IO_IN)) {
-               DbgPrint("Client is disconencted\n");
-               invoke_disconn_cb_list(client_fd);
-               secom_put_connection_handle(client_fd);
-               return FALSE;
-       }
-
-       if (ioctl(client_fd, FIONREAD, &readsize) < 0 || readsize == 0) {
-               DbgPrint("Client is disconencted (readsize: %d)\n", readsize);
-               invoke_disconn_cb_list(client_fd);
-               secom_put_connection_handle(client_fd);
-               return FALSE;
-       }
-
-       ret = cbdata->service_cb(client_fd, readsize, cbdata->data);
-       if (ret < 0) {
-               DbgPrint("service callback returns < 0\n");
-               invoke_disconn_cb_list(client_fd);
-               secom_put_connection_handle(client_fd);
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static gboolean accept_cb(GIOChannel *src, GIOCondition cond, gpointer data)
-{
-       int socket_fd;
-       int client_fd;
-       GIOChannel *gio;
-       guint id;
-
-       socket_fd = g_io_channel_unix_get_fd(src);
-       if (!(cond & G_IO_IN)) {
-               ErrPrint("Accept socket closed\n");
-               free(data);
-               return FALSE;
-       }
-
-       client_fd = secom_get_connection_handle(socket_fd);
-       if (client_fd < 0) {
-               free(data);
-               return FALSE;
-       }
-
-       if (fcntl(client_fd, F_SETFD, FD_CLOEXEC) < 0)
-               ErrPrint("Error: %s\n", strerror(errno));
-
-       if (fcntl(client_fd, F_SETFL, O_NONBLOCK) < 0)
-               ErrPrint("Error: %s\n", strerror(errno));
-
-       gio = g_io_channel_unix_new(client_fd);
-       if (!gio) {
-               ErrPrint("Failed to get gio\n");
-               secom_put_connection_handle(client_fd);
-               free(data);
-               return FALSE;
-       }
-
-       id = g_io_add_watch(gio, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, client_cb, data);
-       if (id < 0) {
-               GError *err = NULL;
-               g_io_channel_unref(gio);
-               g_io_channel_shutdown(gio, TRUE, &err);
-               secom_put_connection_handle(client_fd);
-               free(data);
-               return FALSE;
-       }
-
-       g_io_channel_unref(gio);
-
-       invoke_con_cb_list(client_fd);
-       DbgPrint("New client is connected with %d\n", client_fd);
-       return TRUE;
-}
-
-int connector_server_create(const char *addr, int is_sync, int (*service_cb)(int fd, int readsize, void *data), void *data)
-{
-       GIOChannel *gio;
-       guint id;
-       int fd;
-       struct cbdata *cbdata;
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return -ENOMEM;
-       }
-
-       cbdata->service_cb = service_cb;
-       cbdata->data = data;
-
-       fd = secom_create_server(addr);
-       if (fd < 0) {
-               free(cbdata);
-               return fd;
-       }
-
-       if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
-               ErrPrint("fcntl: %s\n", strerror(errno));
-
-       if (!is_sync) {
-               if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
-                       ErrPrint("fcntl: %s\n", strerror(errno));
-       }
-
-       gio = g_io_channel_unix_new(fd);
-       if (!gio) {
-               free(cbdata);
-               close(fd);
-               return -EIO;
-       }
-
-       id = g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, (GIOFunc)accept_cb, cbdata);
-       if (id < 0) {
-               GError *err = NULL;
-               free(cbdata);
-               g_io_channel_unref(gio);
-               g_io_channel_shutdown(gio, TRUE, &err);
-               close(fd);
-               return -EIO;
-       }
-
-       g_io_channel_unref(gio);
-       return fd;
-}
-
-int connector_client_create(const char *addr, int is_sync, int (*service_cb)(int fd, int readsize, void *data), void *data)
-{
-       GIOChannel *gio;
-       guint id;
-       int client_fd;
-       struct cbdata *cbdata;
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return -ENOMEM;
-       }
-
-       cbdata->service_cb = service_cb;
-       cbdata->data = data;
-
-       client_fd = secom_create_client(addr);
-       if (client_fd < 0) {
-               free(cbdata);
-               return client_fd;
-       }
-
-       if (fcntl(client_fd, F_SETFD, FD_CLOEXEC) < 0)
-               ErrPrint("Error: %s\n", strerror(errno));
-
-       if (!is_sync) {
-               if (fcntl(client_fd, F_SETFL, O_NONBLOCK) < 0)
-                       ErrPrint("Error: %s\n", strerror(errno));
-       }
-
-       gio = g_io_channel_unix_new(client_fd);
-       if (!gio) {
-               free(cbdata);
-               close(client_fd);
-               return -EIO;
-       }
-
-       id = g_io_add_watch(gio, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, (GIOFunc)client_cb, cbdata);
-       if (id < 0) {
-               GError *err = NULL;
-               free(cbdata);
-               g_io_channel_unref(gio);
-               g_io_channel_shutdown(gio, TRUE, &err);
-               close(client_fd);
-               return -EIO;
-       }
-
-       g_io_channel_unref(gio);
-       invoke_con_cb_list(client_fd);
-       return client_fd;
-}
-
-int connector_add_event_callback(enum connector_event_type type, int (*evt_cb)(int handle, void *data), void *data)
-{
-       struct evtdata *cbdata;
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return -ENOMEM;
-       }
-
-       cbdata->evt_cb = evt_cb;
-       cbdata->data = data;
-
-       if (type == CONNECTOR_CONNECTED)
-               s_info.conn_cb_list = dlist_append(s_info.conn_cb_list, cbdata);
-       else
-               s_info.disconn_cb_list = dlist_append(s_info.disconn_cb_list, cbdata);
-       return 0;
-}
-
-void *connector_del_event_callback(enum connector_event_type type, int (*cb)(int handle, void *data), void *data)
-{
-       struct dlist *l;
-       struct dlist *n;
-       struct evtdata *cbdata;
-
-       if (type == CONNECTOR_CONNECTED) {
-               dlist_foreach_safe(s_info.conn_cb_list, l, n, cbdata) {
-                       if (cbdata->evt_cb == cb && cbdata->data == data) {
-                               void *data;
-                               data = cbdata->data;
-                               dlist_remove_data(s_info.conn_cb_list, cbdata);
-                               free(cbdata);
-                               return data;
-                       }
-               }
-       } else {
-               dlist_foreach_safe(s_info.disconn_cb_list, l, n, cbdata) {
-                       if (cbdata->evt_cb == cb && cbdata->data == data) {
-                               void *data;
-                               data = cbdata->data;
-                               dlist_remove_data(s_info.disconn_cb_list, cbdata);
-                               free(cbdata);
-                               return data;
-                       }
-               }
-       }
-
-       return NULL;
-}
-
-int connector_server_destroy(int handle)
-{
-       close(handle);
-       return 0;
-}
-
-int connector_client_destroy(int handle)
-{
-       close(handle);
-       return 0;
-}
-
-/* End of a file */
diff --git a/src/connector_packet.c b/src/connector_packet.c
deleted file mode 100644 (file)
index ff45f37..0000000
+++ /dev/null
@@ -1,486 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-
-#include <dlog.h>
-
-#include "debug.h"
-#include "connector.h"
-#include "packet.h"
-#include "secom_socket.h"
-#include "dlist.h"
-#include "connector_packet.h"
-#include "util.h"
-
-static struct info {
-       struct dlist *recv_list;
-       struct dlist *request_list;
-       char *addr;
-} s_info = {
-       .recv_list = NULL,
-       .request_list = NULL,
-       .addr = NULL,
-};
-
-struct request_ctx {
-       pid_t pid;
-       int handle;
-
-       struct packet *packet;
-       int (*recv_cb)(pid_t pid, int handle, const struct packet *packet, void *data);
-       void *data;
-};
-
-struct recv_ctx {
-       enum {
-               RECV_STATE_INIT,
-               RECV_STATE_HEADER,
-               RECV_STATE_BODY,
-               RECV_STATE_READY,
-       } state;
-       int handle;
-       int offset;
-       pid_t pid;
-       struct packet *packet;
-};
-
-static inline struct request_ctx *find_request_ctx(int handle, unsigned long seq)
-{
-       struct request_ctx *ctx;
-       struct dlist *l;
-
-       dlist_foreach(s_info.request_list, l, ctx) {
-               if (ctx->handle == handle && packet_seq(ctx->packet) == seq) {
-                       return ctx;
-               }
-       }
-
-       return NULL;
-}
-
-static inline void destroy_request_ctx(struct request_ctx *ctx)
-{
-       packet_unref(ctx->packet);
-       dlist_remove_data(s_info.request_list, ctx);
-       free(ctx);
-}
-
-static inline struct request_ctx *create_request_ctx(int handle)
-{
-       struct request_ctx *ctx;
-
-       ctx = malloc(sizeof(*ctx));
-       if (!ctx) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return NULL;
-       }
-
-       ctx->handle = handle;
-       ctx->pid = (pid_t)-1;
-       ctx->packet = NULL;
-       ctx->recv_cb = NULL;
-       ctx->data = NULL;
-
-       s_info.request_list = dlist_append(s_info.request_list, ctx);
-       return ctx;
-}
-
-static inline struct recv_ctx *find_recv_ctx(int handle)
-{
-       struct recv_ctx *ctx;
-       struct dlist *l;
-
-       dlist_foreach(s_info.recv_list, l, ctx) {
-               if (ctx->handle == handle)
-                       return ctx;
-       }
-
-       return NULL;
-}
-
-static inline void destroy_recv_ctx(struct recv_ctx *ctx)
-{
-       dlist_remove_data(s_info.recv_list, ctx);
-       packet_destroy(ctx->packet);
-       free(ctx);
-}
-
-static inline struct recv_ctx *create_recv_ctx(int handle)
-{
-       struct recv_ctx *ctx;
-
-       ctx = malloc(sizeof(*ctx));
-       if (!ctx) {
-               ErrPrint("heap: %s\n", strerror(errno));
-               return NULL;
-       }
-
-       ctx->state = RECV_STATE_INIT,
-       ctx->offset = 0;
-       ctx->packet = NULL;
-       ctx->handle = handle;
-       ctx->pid = (pid_t)-1;
-
-       s_info.recv_list = dlist_append(s_info.recv_list, ctx);
-       return ctx;
-}
-
-static inline void packet_ready(int handle, const struct recv_ctx *receive, struct method *table)
-{
-       struct request_ctx *request;
-       unsigned long sequence;
-       struct packet *result;
-       register int i;
-
-       /*!
-        * \note
-        * Is this ack packet?
-        */
-       switch (packet_type(receive->packet)) {
-       case PACKET_ACK:
-               sequence = packet_seq(receive->packet);
-               request = find_request_ctx(handle, sequence);
-               if (!request) {
-                       ErrPrint("This is not requested packet (%s)\n", packet_command(receive->packet));
-                       break;
-               }
-
-               if (request->recv_cb)
-                       request->recv_cb(receive->pid, handle, receive->packet, request->data);
-
-               destroy_request_ctx(request);
-               break;
-       case PACKET_REQ:
-               for (i = 0; table[i].cmd; i++) {
-                       if (strcmp(table[i].cmd, packet_command(receive->packet)))
-                               continue;
-
-                       result = table[i].handler(receive->pid, handle, receive->packet);
-                       if (result) {
-                               int ret;
-                               ret = secom_send(handle, (void *)packet_data(result), packet_size(result));
-                               if (ret < 0)
-                                       ErrPrint("Failed to send an ack packet\n");
-                               packet_destroy(result);
-                       }
-                       break;
-               }
-
-               break;
-       case PACKET_REQ_NOACK:
-               for (i = 0; table[i].cmd; i++) {
-                       if (strcmp(table[i].cmd, packet_command(receive->packet)))
-                               continue;
-
-                       result = table[i].handler(receive->pid, handle, receive->packet);
-                       if (result)
-                               packet_destroy(result);
-               }
-               break;
-       default:
-               break;
-       }
-
-       return;
-}
-
-static int client_disconnected_cb(int handle, void *data)
-{
-       struct recv_ctx *receive;
-       struct request_ctx *request;
-       struct dlist *l;
-       struct dlist *n;
-       pid_t pid = (pid_t)-1;
-
-       DbgPrint("Clean up all requests and a receive context\n");
-
-       receive = find_recv_ctx(handle);
-       if (receive) {
-               pid = receive->pid;
-               destroy_recv_ctx(receive);
-       }
-
-       dlist_foreach_safe(s_info.request_list, l, n, request) {
-               if (request->handle == handle) {
-                       if (request->recv_cb)
-                               request->recv_cb(pid, handle, NULL, request->data);
-
-                       destroy_request_ctx(request);
-               }
-       }
-
-       return 0;
-}
-
-static int service_cb(int handle, int readsize, void *data)
-{
-       struct recv_ctx *receive;
-       pid_t pid;
-       int ret;
-       int size;
-       char *ptr;
-
-       receive = find_recv_ctx(handle);
-       if (!receive)
-               receive = create_recv_ctx(handle);
-
-       if (!receive) {
-               ErrPrint("Couldn't find or create a receive context\n");
-               return -EIO;
-       }
-
-       while (readsize > 0) {
-               switch (receive->state) {
-               case RECV_STATE_INIT:
-                       receive->state = RECV_STATE_HEADER;
-                       receive->offset = 0;
-               case RECV_STATE_HEADER:
-                       size = packet_header_size() - receive->offset;
-                       /*!
-                        * \note
-                        * Getting header
-                        */
-                       ptr = malloc(size);
-                       if (!ptr) {
-                               ErrPrint("Heap: %s\n", strerror(errno));
-                               destroy_recv_ctx(receive);
-                               return -ENOMEM;
-                       }
-
-                       ret = secom_recv(handle, ptr, size, &pid);
-                       if (ret < 0 || (receive->pid != -1 && receive->pid != pid)) {
-                               ErrPrint("Recv[%d], pid[%d :: %d]\n", ret, receive->pid, pid);
-                               free(ptr);
-                               destroy_recv_ctx(receive);
-                               return -EIO;
-                       }
-
-                       receive->pid = pid;
-                       receive->packet = packet_build(receive->packet, receive->offset, ptr, ret);
-                       free(ptr);
-
-                       if (!receive->packet) {
-                               ErrPrint("Built packet is not valid\n");
-                               destroy_recv_ctx(receive);
-                               return -EFAULT;
-                       }
-
-                       receive->offset += ret;
-                       readsize -= ret;
-                       if (receive->offset == packet_header_size()) {
-                               if (packet_size(receive->packet) == receive->offset)
-                                       receive->state = RECV_STATE_READY;
-                               else
-                                       receive->state = RECV_STATE_BODY;
-                       }
-                       break;
-               case RECV_STATE_BODY:
-                       size = packet_size(receive->packet) - receive->offset;
-                       if (size == 0) {
-                               receive->state = RECV_STATE_READY;
-                               break;
-                       }
-                       /*!
-                        * \note
-                        * Getting body
-                        */
-                       ptr = malloc(size);
-                       if (!ptr) {
-                               ErrPrint("Heap: %s\n", strerror(errno));
-                               destroy_recv_ctx(receive);
-                               return -ENOMEM;
-                       }
-
-                       ret = secom_recv(handle, ptr, size, &pid);
-                       if (ret < 0 || receive->pid != pid) {
-                               ErrPrint("Recv[%d], pid[%d :: %d]\n", ret, receive->pid, pid);
-                               free(ptr);
-                               destroy_recv_ctx(receive);
-                               return -EIO;
-                       }
-
-                       receive->packet = packet_build(receive->packet, receive->offset, ptr, ret);
-                       free(ptr);
-
-                       if (!receive->packet) {
-                               destroy_recv_ctx(receive);
-                               return -EFAULT;
-                       }
-
-                       receive->offset += ret;
-                       readsize -= ret;
-                       if (receive->offset == packet_size(receive->packet))
-                               receive->state = RECV_STATE_READY;
-                       break;
-               case RECV_STATE_READY:
-               default:
-                       break;
-               }
-
-               if (receive->state == RECV_STATE_READY) {
-                       packet_ready(handle, receive, data);
-                       destroy_recv_ctx(receive);
-                       /*!
-                        * \note
-                        * Just quit from this function
-                        * Even if we have read size
-                        * Next time is comming soon ;)
-                        */
-                       break;
-               }
-       }
-
-       return 0;
-}
-
-int connector_packet_async_send(int handle, struct packet *packet, int (*recv_cb)(pid_t pid, int handle, const struct packet *packet, void *data), void *data)
-{
-       int ret;
-       struct request_ctx *ctx;
-
-       ctx = create_request_ctx(handle);
-       if (!ctx)
-               return -ENOMEM;
-
-       ctx->recv_cb = recv_cb;
-       ctx->data = data;
-       ctx->packet = packet_ref(packet);
-
-       ret = secom_send(handle, (void *)packet_data(packet), packet_size(packet));
-       if (ret != packet_size(packet)) {
-               ErrPrint("Send failed. %d <> %d (handle: %d)\n", ret, packet_size(packet), handle);
-               destroy_request_ctx(ctx);
-               return -EIO;
-       }
-
-       return 0;
-}
-
-int connector_packet_send_only(int handle, struct packet *packet)
-{
-       int ret;
-
-       ret = secom_send(handle, (void *)packet_data(packet), packet_size(packet));
-       if (ret != packet_size(packet))
-               return -EIO;
-
-       return 0;
-}
-
-struct packet *connector_packet_oneshot_send(const char *addr, struct packet *packet)
-{
-       int ret;
-       int fd;
-       pid_t pid;
-       int offset;
-       struct packet *result = NULL;
-       void *ptr;
-
-       fd = secom_create_client(addr);
-       if (fd < 0)
-               return NULL;
-
-       if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
-               ErrPrint("fcntl: %s\n", strerror(errno));
-
-       ret = secom_send(fd, (void *)packet_data(packet), packet_size(packet));
-       if (ret != packet_size(packet)) {
-               secom_destroy(fd);
-               return NULL;
-       }
-
-       offset = 0;
-       ptr = malloc(packet_header_size());
-       if (!ptr) {
-               secom_destroy(fd);
-               return NULL;
-       }
-
-       ret = secom_recv(fd, ptr, packet_header_size(), &pid);
-       if (ret < 0) {
-               free(ptr);
-               secom_destroy(fd);
-               return NULL;
-       }
-       result = packet_build(result, offset, ptr, ret);
-       offset += ret;
-       free(ptr);
-
-       ptr = malloc(packet_payload_size(result));
-       if (!ptr) {
-               secom_destroy(fd);
-               return NULL;
-       }
-
-       ret = secom_recv(fd, ptr, packet_payload_size(result), &pid);
-       if (ret < 0) {
-               free(ptr);
-               secom_destroy(fd);
-               return NULL;
-       }
-       result = packet_build(result, offset, ptr, ret);
-       offset += ret;
-       free(ptr);
-       secom_destroy(fd);
-       return result;
-}
-
-static inline int connector_packet_init(void)
-{
-       return connector_add_event_callback(CONNECTOR_DISCONNECTED, client_disconnected_cb, NULL);
-}
-
-static inline int connector_packet_fini(void)
-{
-       connector_del_event_callback(CONNECTOR_DISCONNECTED, client_disconnected_cb, NULL);
-       return 0;
-}
-
-int connector_packet_client_init(const char *addr, int is_sync, struct method *table)
-{
-       int ret;
-
-       ret = connector_packet_init();
-       if (ret < 0)
-               return ret;
-
-       ret = connector_client_create(addr, 0, service_cb, table);
-       if (ret < 0)
-               connector_packet_fini();
-
-       return ret;
-}
-
-int connector_packet_client_fini(int handle)
-{
-       connector_client_destroy(handle);
-       connector_packet_fini();
-       return 0;
-}
-
-int connector_packet_server_init(const char *addr, struct method *table)
-{
-       int ret;
-
-       ret = connector_packet_init();
-       if (ret < 0)
-               return ret;
-
-       ret = connector_server_create(addr, 0, service_cb, table);
-       if (ret < 0)
-               connector_packet_fini();
-
-       return ret;
-}
-
-int connector_packet_server_fini(int handle)
-{
-       connector_server_destroy(handle);
-       connector_packet_fini();
-       return 0;
-}
-
-/* End of a file */
index d5371f0..225ca6a 100644 (file)
@@ -8,9 +8,9 @@
 #include <dlog.h>
 #include <vconf.h>
 #include <context_subscribe.h>
+#include <packet.h>
 
 #include "debug.h"
-#include "packet.h"
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
index 576cb0c..bd03eb4 100644 (file)
@@ -4,9 +4,9 @@
 #include <dlog.h>
 
 #include <gio/gio.h>
+#include <packet.h>
+#include <connector.h>
 
-#include "packet.h"
-#include "connector.h"
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
diff --git a/src/dlist.c b/src/dlist.c
deleted file mode 100644 (file)
index 5576b1b..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "dlist.h"
-
-/*!
- * \brief
- * This dlist is called Modified Doubly Linked List.
- *
- * Noramlly, The dobule linked list contains address of previous and next element.
- * This dlist also contains them, but the tail element only contains prev address.
- *
- * The head element's prev pointer indicates the last element.
- * But the last element's next pointer indicates NIL.
- *
- * So we can find the last element while crawling this DList
- * But we have to remember the address of the head element.
- */
-
-struct dlist {
-       struct dlist *next;
-       struct dlist *prev;
-       void *data;
-};
-
-struct dlist *dlist_append(struct dlist *list, void *data)
-{
-       struct dlist *item;
-
-       item = malloc(sizeof(*item));
-       if (!item)
-               return NULL;
-
-       item->next = NULL;
-       item->data = data;
-
-       if (!list) {
-               item->prev = item;
-
-               list = item;
-       } else {
-               item->prev = list->prev;
-               item->prev->next = item;
-               list->prev = item;
-       }
-
-       assert(!list->prev->next && "item NEXT");
-
-       return list;
-}
-
-struct dlist *dlist_prepend(struct dlist *list, void *data)
-{
-       struct dlist *item;
-
-       item = malloc(sizeof(*item));
-       if (!item)
-               return NULL;
-
-       item->data = data;
-
-       if (!list) {
-               item->prev = item;
-               item->next = NULL;
-       } else {
-               if (list->prev->next)
-                       list->prev->next = item;
-
-               item->prev = list->prev;
-               item->next = list;
-
-               list->prev = item;
-
-       }
-
-       return item;
-}
-
-struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
-{
-       if (!list || !l)
-               return NULL;
-
-       if (l == list)
-               list = l->next;
-       else
-               l->prev->next = l->next;
-
-       if (l->next)
-               l->next->prev = l->prev;
-       /*!
-        * \note
-        * If the removed entry 'l' has no next element, it is the last element.
-        * In this case, check the existence of the list first,
-        * and if the list is not empty, update the 'prev' of the list (which is a head element of the list) 
-        *
-        * If we didn't care about this, the head element(list) can indicates the invalid element.
-        */
-       else if (list)
-               list->prev = l->prev;
-
-       free(l);
-       return list;
-}
-
-struct dlist *dlist_find_data(struct dlist *list, void *data)
-{
-       struct dlist *l;
-       void *_data;
-
-       dlist_foreach(list, l, _data) {
-               if (data == _data)
-                       return l;
-       }
-
-       return NULL;
-}
-
-void *dlist_data(struct dlist *l)
-{
-       return l ? l->data : NULL;
-}
-
-struct dlist *dlist_next(struct dlist *l)
-{
-       return l ? l->next : NULL;
-}
-
-struct dlist *dlist_prev(struct dlist *l)
-{
-       return l ? l->prev : NULL;
-}
-
-int dlist_count(struct dlist *l)
-{
-       register int i;
-       struct dlist *n;
-       void *data;
-
-       i = 0;
-       dlist_foreach(l, n, data) {
-               i++;
-       }
-
-       return i;
-}
-
-struct dlist *dlist_nth(struct dlist *l, int nth)
-{
-       register int i;
-       struct dlist *n;
-
-       i = 0;
-       for (n = l; n; n = n->next) {
-               if (i == nth)
-                       return n;
-               i++;
-       }
-
-       return NULL;
-}
-
-/* End of a file */
index 6d51eca..145c7e3 100644 (file)
@@ -6,10 +6,10 @@
 
 #include <dlog.h>
 #include <Eina.h>
+#include <packet.h>
 
 #include "util.h"
 #include "debug.h"
-#include "packet.h"
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
index 0bc0877..753b137 100644 (file)
@@ -7,10 +7,12 @@
 #include <Eina.h>
 #include <gio/gio.h>
 
+#include <packet.h>
+#include <connector_packet.h>
+
 #include "conf.h"
 #include "util.h"
 #include "debug.h"
-#include "packet.h"
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
@@ -19,7 +21,6 @@
 #include "instance.h"
 #include "fb.h"
 #include "script_handler.h"
-#include "connector_packet.h"
 
 int errno;
 
index 2a4867a..4476ae5 100644 (file)
@@ -12,7 +12,8 @@
 
 #include <dlog.h>
 
-#include "packet.h"
+#include <packet.h>
+
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
index 8d22f6c..90901c1 100644 (file)
@@ -7,11 +7,12 @@
 #include <Eina.h>
 #include <Ecore_Evas.h>
 
+#include <packet.h>
+
 #include "debug.h"
 #include "util.h"
 #include "parser.h"
 #include "conf.h"
-#include "packet.h"
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
diff --git a/src/packet.c b/src/packet.c
deleted file mode 100644 (file)
index 7cc160a..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include <dlog.h>
-
-#include "debug.h"
-#include "packet.h"
-#include "util.h"
-
-int errno;
-
-struct {
-       unsigned long seq;
-} s_info = {
-       .seq = 0lu,
-};
-
-struct data {
-       struct {
-               int version;
-               int payload_size;
-               char command[PACKET_MAX_CMD];
-               enum packet_type type;
-               unsigned long seq;
-       } head;
-
-       char payload[];
-};
-
-struct packet {
-       int refcnt;
-       struct data *data;
-};
-
-const enum packet_type const packet_type(const struct packet *packet)
-{
-       return packet->data->head.type;
-}
-
-const int const packet_version(const struct packet *packet)
-{
-       return packet->data->head.version;
-}
-
-const int const packet_header_size(void)
-{
-       struct data packet; /* Only for getting the size of header of packet */
-
-       return sizeof(packet.head);
-}
-
-const int const packet_size(const struct packet *packet)
-{
-       return sizeof(*packet->data) + packet->data->head.payload_size;
-}
-
-const unsigned long const packet_seq(const struct packet *packet)
-{
-       return packet->data->head.seq;
-}
-
-const int const packet_payload_size(const struct packet *packet)
-{
-       return packet->data->head.payload_size;
-}
-
-const char * const packet_command(const struct packet *packet)
-{
-       return packet->data->head.command;
-}
-
-const void * const packet_data(const struct packet *packet)
-{
-       return packet->data;
-}
-
-static inline struct data *check_and_expand_packet(struct data *packet, int *payload_size)
-{
-       struct data *new_packet;
-
-       if (packet->head.payload_size < *payload_size)
-               return packet;
-
-       new_packet = realloc(packet, sizeof(*packet) + *payload_size + BUFSIZ); /*!< Expanding to +BUFSIZ */
-       if (!new_packet) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               free(packet);
-               return NULL;
-       }
-
-       *payload_size += BUFSIZ;
-       return new_packet;
-}
-
-static inline struct packet *packet_body_filler(struct packet *packet, int payload_size, const char *ptr, va_list va)
-{
-       char *payload;
-       char *str;
-
-       while (*ptr) {
-               payload = packet->data->payload + packet->data->head.payload_size;
-
-               switch (*ptr) {
-               case 'i':
-               case 'I':
-                       packet->data->head.payload_size += sizeof(int);
-                       packet->data = check_and_expand_packet(packet->data, &payload_size);
-                       if (!packet->data) {
-                               free(packet);
-                               packet = NULL;
-                               goto out;
-                       }
-
-                       *((int *)payload) = (int)va_arg(va, int);
-                       break;
-               case 's':
-               case 'S':
-                       str = (char *)va_arg(va, char *);
-
-                       packet->data->head.payload_size += strlen(str) + 1; /*!< Including NIL */
-                       packet->data = check_and_expand_packet(packet->data, &payload_size);
-                       if (!packet->data) {
-                               free(packet);
-                               packet = NULL;
-                               goto out;
-                       }
-
-                       strcpy(payload, str); /*!< Including NIL */
-                       break;
-               case 'd':
-               case 'D':
-                       packet->data->head.payload_size += sizeof(double);
-                       packet->data = check_and_expand_packet(packet->data, &payload_size);
-                       if (!packet->data) {
-                               free(packet);
-                               packet = NULL;
-                               goto out;
-                       }
-
-                       *((double *)payload) = (double)va_arg(va, double);
-                       break;
-               default:
-                       ErrPrint("Invalid type [%c]\n", *ptr);
-                       free(packet->data);
-                       free(packet);
-                       packet = NULL;
-                       goto out;
-               }
-
-               ptr++;
-       }
-
-out:
-       return packet;
-}
-
-struct packet *packet_create_reply(struct packet *packet, const char *fmt, ...)
-{
-       int payload_size;
-       struct packet *result;
-       va_list va;
-
-       result = malloc(sizeof(*result));
-       if (!result) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return NULL;
-       }
-
-       payload_size = sizeof(*result) + BUFSIZ;
-       result->refcnt = 0;
-       result->data = malloc(payload_size);
-       if (!packet->data) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return NULL;
-       }
-
-       result->data->head.seq = packet->data->head.seq;
-       result->data->head.type = PACKET_ACK;
-       result->data->head.version = packet->data->head.version;
-       strcpy(result->data->head.command, packet->data->head.command);
-       result->data->head.payload_size = 0;
-       payload_size -= sizeof(*result->data);
-
-       va_start(va, fmt);
-       result = packet_body_filler(result, payload_size, fmt, va);
-       va_end(va);
-
-       return packet_ref(result);
-}
-
-struct packet *packet_create(const char *cmd, const char *fmt, ...)
-{
-       struct packet *packet;
-       int payload_size;
-       va_list va;
-
-       if (strlen(cmd) >= PACKET_MAX_CMD) {
-               ErrPrint("Command is too long\n");
-               return NULL;
-       }
-
-       packet = malloc(sizeof(*packet));
-       if (!packet) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return NULL;
-       }
-
-       payload_size = sizeof(*packet) + BUFSIZ;
-       packet->refcnt = 0;
-       packet->data = malloc(payload_size);
-       if (!packet->data) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               free(packet);
-               return NULL;
-       }
-
-       packet->data->head.seq = s_info.seq++;
-       packet->data->head.type = PACKET_REQ;
-       packet->data->head.version = PACKET_VERSION;
-       strcpy(packet->data->head.command, cmd);
-       packet->data->head.payload_size = 0;
-       payload_size -= sizeof(*packet->data); /*!< Usable payload size (except head size) */
-
-       va_start(va, fmt);
-       packet = packet_body_filler(packet, payload_size, fmt, va);
-       va_end(va);
-
-       return packet_ref(packet);
-}
-
-struct packet *packet_create_noack(const char *cmd, const char *fmt, ...)
-{
-       int payload_size;
-       struct packet *result;
-       va_list va;
-
-       if (strlen(cmd) >= PACKET_MAX_CMD) {
-               ErrPrint("Command is too long\n");
-               return NULL;
-       }
-
-       result = malloc(sizeof(*result));
-       if (!result) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return NULL;
-       }
-
-       payload_size = sizeof(*result) + BUFSIZ;
-       result->refcnt = 0;
-       result->data = malloc(payload_size);
-       if (!result->data) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               free(result);
-               return NULL;
-       }
-
-       result->data->head.seq = s_info.seq++;
-       result->data->head.type = PACKET_REQ_NOACK;
-       result->data->head.version = PACKET_VERSION;
-       strcpy(result->data->head.command, cmd);
-       result->data->head.payload_size = 0;
-       payload_size -= sizeof(*result->data);
-
-       va_start(va, fmt);
-       result = packet_body_filler(result, payload_size, fmt, va);
-       va_end(va);
-
-       return packet_ref(result);
-}
-
-int packet_get(const struct packet *packet, const char *fmt, ...)
-{
-       const char *ptr;
-       va_list va;
-       int ret = 0;
-       char *payload;
-       int offset = 0;
-       int *int_ptr;
-       double *double_ptr;
-       char **str_ptr;
-
-       va_start(va, fmt);
-
-       ptr = fmt;
-       while (*ptr) {
-               payload = packet->data->payload + offset;
-               switch (*ptr) {
-               case 'i':
-               case 'I':
-                       int_ptr = (int *)va_arg(va, int *);
-                       *int_ptr = *((int *)payload);
-                       offset += sizeof(int);
-                       ret++;
-                       break;
-               case 'd':
-               case 'D':
-                       double_ptr = (double *)va_arg(va, double *);
-                       *double_ptr = *((double *)payload);
-                       offset += sizeof(double);
-                       ret++;
-                       break;
-               case 's':
-               case 'S':
-                       str_ptr = (char **)va_arg(va, char **);
-                       *str_ptr = payload;
-                       offset += (strlen(*str_ptr) + 1); /*!< Including NIL */
-                       ret++;
-                       break;
-               default:
-                       ret = -EINVAL;
-                       goto out;
-               }
-               ptr++;
-       }
-
-out:
-       va_end(va);
-       return ret;
-}
-
-struct packet *packet_ref(struct packet *packet)
-{
-       if (!packet)
-               return NULL;
-
-       packet->refcnt++;
-       return packet;
-}
-
-struct packet *packet_unref(struct packet *packet)
-{
-       if (!packet)
-               return NULL;
-
-       packet->refcnt--;
-       if (packet->refcnt < 0) {
-               ErrPrint("Invalid refcnt\n");
-               return NULL;
-       }
-
-       if (packet->refcnt == 0) {
-               free(packet->data);
-               free(packet);
-               return NULL;
-       }
-
-       return packet;
-}
-
-int packet_destroy(struct packet *packet)
-{
-       packet_unref(packet);
-       return 0;
-}
-
-struct packet *packet_build(struct packet *packet, int offset, void *data, int size)
-{
-       char *ptr;
-
-       if (packet == NULL) {
-               if (offset) {
-                       ErrPrint("Invalid argument\n");
-                       return NULL;
-               }
-
-               packet = malloc(sizeof(*packet));
-               if (!packet) {
-                       ErrPrint("Heap: %s\n", strerror(errno));
-                       return NULL;
-               }
-
-               packet->refcnt = 1;
-               packet->data = malloc(size);
-               if (!packet->data) {
-                       ErrPrint("Heap: %s\n", strerror(errno));
-                       free(packet);
-                       return NULL;
-               }
-
-               memcpy(packet->data, data, size);
-               return packet;
-       }
-
-       ptr = realloc(packet->data, offset + size);
-       if (!ptr) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               free(packet->data);
-               free(packet);
-               return NULL;
-       }
-
-       packet->data = (struct data *)ptr;
-       memcpy(ptr + offset, data, size);
-
-       return packet;
-}
-
-/* End of a file */
index 44c9930..52a1fdd 100644 (file)
@@ -12,9 +12,9 @@
 #include <Evas.h>
 
 #include <dlog.h>
+#include <packet.h>
 
 #include "slave_life.h"
-#include "packet.h"
 #include "slave_rpc.h"
 #include "client_life.h"
 #include "package.h"
@@ -124,11 +124,11 @@ static void render_post_cb(void *data, Evas *e, void *event_info)
 
        inst = data;
 
-       DbgPrint("Render post invoked (%s)[%s]\n", package_name(instance_package(inst)), util_basename(instance_id(inst)));
        evas_image_cache_flush(e);
        evas_font_cache_flush(e);
        evas_render_dump(e);
 
+       DbgPrint("Render post invoked (%s)[%s]\n", package_name(instance_package(inst)), util_basename(instance_id(inst)));
        info = instance_lb_handle(inst);
        if (info && script_handler_evas(info) == e) {
                fb_sync(script_handler_fb(info));
diff --git a/src/secom_socket.c b/src/secom_socket.c
deleted file mode 100644 (file)
index 0a5727a..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <errno.h>
-
-#include <secom_socket.h>
-#include <dlog.h>
-
-int errno;
-
-static inline int create_socket(const char *peer, struct sockaddr_un *addr)
-{
-       int len;
-       int handle;
-
-       len = sizeof(*addr);
-       bzero(addr, len);
-
-       if (strlen(peer) >= sizeof(addr->sun_path)) {
-               LOGE("peer %s is too long to remember it\\n", peer);
-               return -1;
-       }
-
-       /* We can believe this has no prob, because
-        * we already check the size of add.rsun_path
-        */
-       strcpy(addr->sun_path, peer);
-       addr->sun_family = AF_UNIX;
-
-       handle = socket(PF_UNIX, SOCK_STREAM, 0);
-       if (handle < 0) {
-               LOGE("Failed to create a socket %s\n", strerror(errno));
-               return -1;
-       }
-
-       return handle;
-}
-
-int secom_create_client(const char *peer)
-{
-       struct sockaddr_un addr;
-       int handle;
-       int state;
-       int on = 1;
-
-       handle = create_socket(peer, &addr);
-       if (handle < 0)
-               return handle;
-
-       state = connect(handle, (struct sockaddr *)&addr, sizeof(addr));
-       if (state < 0) {
-               LOGE("Failed to connect to server [%s] %s\n",
-                                                       peer, strerror(errno));
-               if (close(handle) < 0)
-                       LOGE("close a handle: %s\n", strerror(errno));
-
-               return -1;
-       }
-
-       if (setsockopt(handle, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0)
-               LOGE("Failed to change sock opt : %s\n", strerror(errno));
-
-       return handle;
-}
-
-int secom_create_server(const char *peer)
-{
-       int handle;
-       int state;
-       struct sockaddr_un addr;
-
-       handle = create_socket(peer, &addr);
-       if (handle < 0)
-               return handle;
-
-       state = bind(handle, &addr, sizeof(addr));
-       if (state < 0) {
-               LOGE("Failed to bind a socket %s\n", strerror(errno));
-               if (close(handle) < 0)
-                       LOGE("Close a handle : %s\n", strerror(errno));
-
-               return -1;
-       }
-
-       state = listen(handle, 10); /* BACKLOG 10 */
-       if (state < 0) {
-               LOGE("Failed to listen a socket %s\n", strerror(errno));
-
-               if (close(handle) < 0)
-                       LOGE("Close a handle : %s\n", strerror(errno));
-
-               return -1;
-       }
-
-       if (chmod(peer, 0666) < 0)
-               LOGE("Failed to change the permission of a socket (%s)\n",
-                                                       strerror(errno));
-
-       return handle;
-}
-
-int secom_get_connection_handle(int server_handle)
-{
-       struct sockaddr_un addr;
-       int handle;
-       int on = 1;
-       socklen_t size = sizeof(addr);
-
-       handle = accept(server_handle, (struct sockaddr *)&addr, &size);
-       if (handle < 0) {
-               LOGE("Failed to accept a new client %s\n", strerror(errno));
-               return -1;
-       }
-
-       if (setsockopt(handle, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0)
-               LOGE("Failed to change sock opt : %s\n", strerror(errno));
-
-       return handle;
-}
-
-int secom_put_connection_handle(int conn_handle)
-{
-       if (close(conn_handle) < 0) {
-               LOGE("Close a handle: %s\n", strerror(errno));
-               return -1;
-       }
-
-       return 0;
-}
-
-int secom_send(int handle, const char *buffer, int size)
-{
-       struct msghdr msg;
-       struct iovec iov;
-       int ret;
-
-       memset(&msg, 0, sizeof(msg));
-       iov.iov_base = (char *)buffer;
-       iov.iov_len = size;
-       msg.msg_iov = &iov;
-       msg.msg_iovlen = 1;
-
-       ret = sendmsg(handle, &msg, 0);
-       if (ret < 0) {
-               LOGE("Failed to send message [%s]\n", strerror(errno));
-               return -1;
-       }
-
-       return iov.iov_len;
-}
-
-int secom_recv(int handle, char *buffer, int size, int *sender_pid)
-{
-       struct msghdr msg;
-       struct cmsghdr *cmsg;
-       struct iovec iov;
-       char control[1024];
-
-       if (!sender_pid)
-               return -1;
-
-       memset(&msg, 0, sizeof(msg));
-       iov.iov_base = buffer;
-       iov.iov_len = size;
-       msg.msg_iov = &iov;
-       msg.msg_iovlen = 1;
-       msg.msg_control = control;
-       msg.msg_controllen = sizeof(control);
-
-       if (recvmsg(handle, &msg, 0) < 0) {
-               LOGE("Failed to recvmsg [%s]\n", strerror(errno));
-               return -1;
-       }
-
-       cmsg = CMSG_FIRSTHDR(&msg);
-       while (cmsg) {
-               if (cmsg->cmsg_level == SOL_SOCKET
-                       && cmsg->cmsg_type == SCM_CREDENTIALS)  {
-                       struct ucred *cred;
-                       cred = (struct ucred *)CMSG_DATA(cmsg);
-                       *sender_pid = cred->pid;
-               }
-
-               cmsg = CMSG_NXTHDR(&msg, cmsg);
-       }
-
-       return iov.iov_len;
-}
-
-int secom_destroy(int handle)
-{
-       if (close(handle) < 0) {
-               LOGE("Failed to close a handle\n");
-               return -1;
-       }
-       return 0;
-}
-
-#undef _GNU_SOURCE
-/* End of a file */
index 7c4dae9..b5f32d4 100644 (file)
@@ -5,11 +5,12 @@
 #include <dlog.h>
 #include <Evas.h>
 
+#include <packet.h>
+#include <connector_packet.h>
+
 #include "conf.h"
 #include "debug.h"
 #include "server.h"
-#include "packet.h"
-#include "connector_packet.h"
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
index af50167..e19a785 100644 (file)
@@ -14,7 +14,8 @@
 
 #include <gio/gio.h> /* GDBusProxy */
 
-#include "packet.h"
+#include <packet.h>
+
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
index e975145..ca983d0 100644 (file)
@@ -9,8 +9,10 @@
 
 #include <dlog.h>
 
+#include <packet.h>
+#include <connector_packet.h>
+
 #include "debug.h"
-#include "packet.h"
 #include "slave_life.h"
 #include "slave_rpc.h"
 #include "client_life.h"
@@ -18,7 +20,6 @@
 #include "fault_manager.h"
 #include "util.h"
 #include "conf.h"
-#include "connector_packet.h"
 
 struct slave_rpc {
        Ecore_Timer *pong_timer;