summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-03-25 19:26:41 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-25 19:40:41 +0100
commitcf27288b505b5745493c01caa85b0103749c96d7 (patch)
tree9126fee0f236bb5fcfba9c486b273adc565321b2 /src/examples
parent6bd9255191e054fc0442befecd4198bb99e5ea73 (diff)
ecore_con: add example for ftp upload.
Summary: Added example for ftp upload. In the .gitignore only 2 files added which were missing. The differences it is showing is cos of reordering. I did ls and redirected the file to gitignore. So the files got reordered. Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2223 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/ecore/.gitignore20
-rw-r--r--src/examples/ecore/ecore_con_url_ftp_example.c83
2 files changed, 94 insertions, 9 deletions
diff --git a/src/examples/ecore/.gitignore b/src/examples/ecore/.gitignore
index 497f0f3..700be32 100644
--- a/src/examples/ecore/.gitignore
+++ b/src/examples/ecore/.gitignore
@@ -3,39 +3,41 @@
3/ecore_audio_playback 3/ecore_audio_playback
4/ecore_audio_to_ogg 4/ecore_audio_to_ogg
5/ecore_client_bench 5/ecore_client_bench
6/ecore_compose_get_example
7/ecore_con_client_example
6/ecore_con_client_simple_example 8/ecore_con_client_simple_example
7/ecore_con_lookup_example 9/ecore_con_lookup_example
10/ecore_con_server_example
8/ecore_con_server_http_example 11/ecore_con_server_http_example
9/ecore_con_server_simple_example 12/ecore_con_server_simple_example
10/ecore_con_url_cookies_example 13/ecore_con_url_cookies_example
11/ecore_con_url_download_example 14/ecore_con_url_download_example
15/ecore_con_url_ftp_example
12/ecore_con_url_headers_example 16/ecore_con_url_headers_example
13/ecore_evas_basics_example 17/ecore_evas_basics_example
14/ecore_evas_buffer_example_01 18/ecore_evas_buffer_example_01
15/ecore_evas_buffer_example_02 19/ecore_evas_buffer_example_02
16/ecore_evas_callbacks 20/ecore_evas_callbacks
17/ecore_evas_ews_example 21/ecore_evas_ews_example
18/ecore_evas_object_example
19/ecore_evas_window_sizes_example
20/ecore_evas_extn_plug_example 22/ecore_evas_extn_plug_example
21/ecore_evas_extn_socket_example 23/ecore_evas_extn_socket_example
24/ecore_evas_object_example
25/ecore_evas_window_sizes_example
22/ecore_event_example_01 26/ecore_event_example_01
23/ecore_event_example_02 27/ecore_event_example_02
24/ecore_exe_example 28/ecore_exe_example
25/ecore_exe_example_child 29/ecore_exe_example_child
26/ecore_fd_handler_example 30/ecore_fd_handler_example
31/ecore_fd_handler_gnutls_example
32/ecore_file_download_example
33/ecore_getopt_example
27/ecore_idler_example 34/ecore_idler_example
35/ecore_imf_example
28/ecore_job_example 36/ecore_job_example
37/ecore_pipe_gstreamer_example
29/ecore_pipe_simple_example 38/ecore_pipe_simple_example
30/ecore_poller_example 39/ecore_poller_example
31/ecore_server_bench 40/ecore_server_bench
32/ecore_thread_example 41/ecore_thread_example
33/ecore_time_functions_example 42/ecore_time_functions_example
34/ecore_timer_example 43/ecore_timer_example
35/ecore_con_client_example
36/ecore_con_server_example
37/ecore_file_download_example
38/ecore_imf_example
39/ecore_pipe_gstreamer_example
40/ecore_getopt_example
41/ecore_compose_get_example
diff --git a/src/examples/ecore/ecore_con_url_ftp_example.c b/src/examples/ecore/ecore_con_url_ftp_example.c
new file mode 100644
index 0000000..d3a1488
--- /dev/null
+++ b/src/examples/ecore/ecore_con_url_ftp_example.c
@@ -0,0 +1,83 @@
1//Compile with:
2// gcc -o ecore_con_url_ftp_example ecore_con_url_ftp_example.c `pkg-config --libs --cflags ecore ecore-con eina`
3
4#include <stdio.h>
5#include <Eina.h>
6#include <Ecore.h>
7#include <Ecore_Con.h>
8
9static Eina_Bool
10_url_data_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info)
11{
12 Ecore_Con_Event_Url_Data *url_data = event_info;
13 int i;
14
15 for (i = 0; i < url_data->size; i++)
16 printf("%c", url_data->data[i]);
17
18 return EINA_TRUE;
19}
20
21static Eina_Bool
22_url_complete_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info)
23{
24 Ecore_Con_Event_Url_Complete *url_complete = event_info;
25
26 printf("\n");
27 printf("upload completed with status code: %d\n", url_complete->status);
28
29 ecore_main_loop_quit();
30
31 return EINA_TRUE;
32}
33
34int
35main(int argc, const char *argv[])
36{
37 Ecore_Con_Url *ec_url = NULL;
38 const char *file, *user, *passwd, *dir;
39
40 if (argc < 5)
41 {
42 printf("./ecore_con_url_ftp <ftp_server_address> <username> <password> <file> <directory(optional)>\n");
43 return -1;
44 }
45
46 ecore_con_init();
47 ecore_con_url_init();
48
49 ec_url = ecore_con_url_new(argv[1]);
50 if (!ec_url)
51 {
52 printf("error when creating ecore con url object.\n");
53 goto end;
54 }
55
56 user = argv[2];
57 passwd = argv[3];
58 file = argv[4];
59 dir = argv[5];
60
61 ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL);
62 ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_complete_cb, NULL);
63
64 ecore_con_url_verbose_set(ec_url, EINA_TRUE);
65 ecore_con_url_ftp_use_epsv_set(ec_url, EINA_TRUE);
66
67 if( !ecore_con_url_ftp_upload(ec_url, file, user, passwd, dir))
68 {
69 printf("could not realize request.\n");
70 goto free_ec_url;
71 }
72
73 ecore_main_loop_begin();
74
75free_ec_url:
76 ecore_con_url_free(ec_url);
77end:
78 ecore_con_url_shutdown();
79 ecore_con_shutdown();
80
81 return 0;
82}
83