summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <juyung.seo@samsung.com>2013-10-23 22:26:36 +0900
committerDaniel Juyung Seo <juyung.seo@samsung.com>2013-10-23 22:26:36 +0900
commitf061d07f73576fd5f9c3fefadd81098c25935859 (patch)
tree066e79850c1c3ba7984e76edf092ea34dd49e48e
parent26b9a4a15b30d330eacd311e1546cbb28cb5a943 (diff)
ecore/ecore_pipe: added ecore_pipe sample.
-rw-r--r--.gitignore1
-rw-r--r--ecore/Makefile5
-rw-r--r--ecore/ecore_pipe.c53
3 files changed, 58 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 9799e7b..b617fee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ ecore/file-ls
24ecore/glib 24ecore/glib
25ecore/cursor 25ecore/cursor
26ecore/thread 26ecore/thread
27ecore/ecore_pipe
27edje/propagate-event 28edje/propagate-event
28edje/onhold 29edje/onhold
29evas/premultiplied-color 30evas/premultiplied-color
diff --git a/ecore/Makefile b/ecore/Makefile
index 7e1c9b0..75e61d0 100644
--- a/ecore/Makefile
+++ b/ecore/Makefile
@@ -1,4 +1,4 @@
1all: shutdown-timer idler-null file-ls loop-iterate glib cursor thread 1all: shutdown-timer idler-null file-ls loop-iterate glib cursor thread ecore_pipe
2 2
3shutdown-timer: shutdown-timer.c 3shutdown-timer: shutdown-timer.c
4 gcc shutdown-timer.c -o shutdown-timer `pkg-config --cflags --libs elementary` -g 4 gcc shutdown-timer.c -o shutdown-timer `pkg-config --cflags --libs elementary` -g
@@ -20,3 +20,6 @@ cursor: cursor.c
20 20
21thread: thread.c 21thread: thread.c
22 gcc thread.c -o thread `pkg-config --cflags --libs elementary` -g 22 gcc thread.c -o thread `pkg-config --cflags --libs elementary` -g
23
24ecore_pipe: ecore_pipe.c
25 gcc ecore_pipe.c -o ecore_pipe `pkg-config --cflags --libs elementary` -g
diff --git a/ecore/ecore_pipe.c b/ecore/ecore_pipe.c
new file mode 100644
index 0000000..77f45e4
--- /dev/null
+++ b/ecore/ecore_pipe.c
@@ -0,0 +1,53 @@
1/*
2 * gcc pipe.c -o pipe `pkg-config --cflags --libs elementary` -g
3 */
4#include <unistd.h>
5#include <Elementary.h>
6
7static void
8_pipe_handler_cb(void *data, void *buffer, unsigned int nbyte)
9{
10 char buf[BUFSIZ +1] = { 0 };
11 if (!buffer) return;
12 snprintf(buf, nbyte, "%s", (char *)buffer);
13 printf("read : %s\n", buf);
14}
15
16static Eina_Bool
17_timer_cb(void *data)
18{
19 Ecore_Pipe *pipe = data;
20 static int count = 1;
21 char buf[BUFSIZ + 1] = { 0 };
22
23 snprintf(buf, BUFSIZ, "pipe data %d", count++);
24 ecore_pipe_write(pipe, buf, strlen(buf));
25 printf("write : %s\n", buf);
26
27 return ECORE_CALLBACK_RENEW;
28}
29
30EAPI_MAIN int
31elm_main(int argc, char **argv)
32{
33 Evas_Object *win = NULL;
34
35 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
36
37 win = elm_win_util_standard_add("main", "Main");
38 elm_win_autodel_set(win, EINA_TRUE);
39 evas_object_resize(win, 300, 400);
40 evas_object_show(win);
41
42 Ecore_Pipe *pipe;
43
44 pipe = ecore_pipe_add(_pipe_handler_cb, NULL);
45
46 ecore_timer_add(0.1, _timer_cb, pipe);
47
48 elm_run();
49 elm_shutdown();
50
51 return 0;
52}
53ELM_MAIN()