summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2012-06-18 15:50:48 +0900
committerSung-jae Park <nicesj.park@samsung.com>2012-06-18 16:12:52 +0900
commit61a48864946378dd860252c037d576eaca21792e (patch)
tree00884f246e57b0271308719357b0af200a5867e0 /include
parente598fb476c8fd95957c06f6bf7c1724fd45dca30 (diff)
downloadcom-core-61a48864946378dd860252c037d576eaca21792e.tar.gz
com-core-61a48864946378dd860252c037d576eaca21792e.tar.bz2
com-core-61a48864946378dd860252c037d576eaca21792e.zip
Initiate the project
Change-Id: I633039acae13b95af2ee3aa83cd6eeb17cdeb9dd
Diffstat (limited to 'include')
-rw-r--r--include/connector.h22
-rw-r--r--include/connector_packet.h23
-rw-r--r--include/debug.h13
-rw-r--r--include/dlist.h27
-rw-r--r--include/packet.h39
-rw-r--r--include/secom_socket.h62
-rw-r--r--include/util.h3
7 files changed, 189 insertions, 0 deletions
diff --git a/include/connector.h b/include/connector.h
new file mode 100644
index 0000000..890986a
--- /dev/null
+++ b/include/connector.h
@@ -0,0 +1,22 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of a file */
diff --git a/include/connector_packet.h b/include/connector_packet.h
new file mode 100644
index 0000000..e9bdd20
--- /dev/null
+++ b/include/connector_packet.h
@@ -0,0 +1,23 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of a file */
diff --git a/include/debug.h b/include/debug.h
new file mode 100644
index 0000000..21deda9
--- /dev/null
+++ b/include/debug.h
@@ -0,0 +1,13 @@
+#if !defined(FLOG)
+#define DbgPrint(format, arg...) LOGD("[%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrint(format, arg...) LOGE("[%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
+#else
+extern FILE *__file_log_fp;
+#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
+
+#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
+#endif
+
+#define EAPI __attribute__((visibility("default")))
+
+/* End of a file */
diff --git a/include/dlist.h b/include/dlist.h
new file mode 100644
index 0000000..5c583e6
--- /dev/null
+++ b/include/dlist.h
@@ -0,0 +1,27 @@
+#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
new file mode 100644
index 0000000..ccac86a
--- /dev/null
+++ b/include/packet.h
@@ -0,0 +1,39 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of a file */
diff --git a/include/secom_socket.h b/include/secom_socket.h
new file mode 100644
index 0000000..dfdca53
--- /dev/null
+++ b/include/secom_socket.h
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of a file */
diff --git a/include/util.h b/include/util.h
new file mode 100644
index 0000000..9185d6a
--- /dev/null
+++ b/include/util.h
@@ -0,0 +1,3 @@
+extern const char *util_basename(const char *name);
+
+/* End of a file */