summaryrefslogtreecommitdiff
path: root/src/examples/eio
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-12-05 18:10:43 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-12-05 18:10:43 +0000
commit1a2daa057d5872d3c587791fe2f7c6bb86bbc202 (patch)
tree28ddb92ef4b8b3ec4ad1de30aec3155977fa7be1 /src/examples/eio
parent8ea3c291325cf77bd2a54172778e65912525e11a (diff)
add eio example and fix ecore_fb linking
SVN revision: 80273
Diffstat (limited to 'src/examples/eio')
-rw-r--r--src/examples/eio/Makefile.am40
-rw-r--r--src/examples/eio/eio_file_ls.c74
2 files changed, 114 insertions, 0 deletions
diff --git a/src/examples/eio/Makefile.am b/src/examples/eio/Makefile.am
new file mode 100644
index 0000000000..bd34825f7c
--- /dev/null
+++ b/src/examples/eio/Makefile.am
@@ -0,0 +1,40 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib/eina \
5-I$(top_srcdir)/src/lib/eo \
6-I$(top_srcdir)/src/lib/eet \
7-I$(top_srcdir)/src/lib/ecore \
8-I$(top_srcdir)/src/lib/eio \
9-I$(top_builddir)/src/lib/eina \
10-I$(top_builddir)/src/lib/eo \
11-I$(top_builddir)/src/lib/eet \
12-I$(top_builddir)/src/lib/ecore \
13-I$(top_builddir)/src/lib/eio
14
15EXTRA_PROGRAMS = eio_file_ls
16
17eio_file_ls_SOURCES = eio_file_ls.c
18eio_file_ls_LDADD = \
19$(top_builddir)/src/lib/eio/libeio.la \
20$(top_builddir)/src/lib/ecore/libecore.la \
21$(top_builddir)/src/lib/eet/libeet.la \
22$(top_builddir)/src/lib/eina/libeina.la \
23@EIO_LIBS@
24
25SRCS = \
26eio_file_ls
27
28examples: $(EXTRA_PROGRAMS)
29
30clean-local:
31 rm -f $(EXTRA_PROGRAMS)
32
33install-examples:
34 mkdir -p $(datadir)/eio/examples
35 $(install_sh_DATA) -c $(SRCS) $(datadir)/eio/examples
36
37uninstall-local:
38 for f in $(SRCS) ; do \
39 rm -f $(datadir)/io/examples/$$f ; \
40 done
diff --git a/src/examples/eio/eio_file_ls.c b/src/examples/eio/eio_file_ls.c
new file mode 100644
index 0000000000..7a9e7f548b
--- /dev/null
+++ b/src/examples/eio/eio_file_ls.c
@@ -0,0 +1,74 @@
1/**
2 * Compile with gcc -o eio_file_ls eio_file_ls.c `pkg-config --cflags --libs ecore eio`
3 */
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8#include <Eio.h>
9#include <Ecore.h>
10
11static Eina_Bool
12_filter_cb(void *data, Eio_File *handler, const char *file)
13{
14 char *last_slash = strrchr(file, '/');
15
16 //Check if it is a hidden file
17 if (last_slash != NULL && strlen(last_slash) > 1 && last_slash[1] == '.')
18 return EINA_FALSE;
19
20 return EINA_TRUE;
21}
22
23static void
24_main_cb(void *data, Eio_File *handler, const char *file)
25{
26 int *number_of_listed_files = (int *)data;
27
28 fprintf(stdout, "Processing file:%s\n", file);
29
30 (*number_of_listed_files)++;
31}
32
33static void
34_done_cb(void *data, Eio_File *handler)
35{
36 int *number_of_listed_files = (int *)data;
37
38 fprintf(stdout, "Number of listed files:%d\n" \
39 "ls operation is done, quitting.\n", *number_of_listed_files);
40
41 ecore_main_loop_quit();
42}
43
44static void
45_error_cb(void *data, Eio_File *handler, int error)
46{
47 fprintf(stderr, "Something wrong has happend:%s\n", strerror(error));
48 ecore_main_loop_quit();
49}
50
51int
52main(int argc, char **argv)
53{
54 int number_of_listed_files = 0;
55
56 ecore_init();
57 eio_init();
58
59 if (argc < 2)
60 {
61 fprintf(stderr, "You must pass a path to execute the command.\n");
62 return -1;
63 }
64
65 eio_file_ls(argv[1], _filter_cb, _main_cb, _done_cb, _error_cb,
66 &number_of_listed_files);
67
68 ecore_main_loop_begin();
69
70 eio_shutdown();
71 ecore_shutdown();
72
73 return 0;
74}