-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi devs, the attached patchfile contains my latest work on ftp
upload side of ecore_con.
Changes
* Modified last parameter on ecore_con_ftp_upload, now we can prepend a
path to uploaded file: if you're uploading to ftp://server.com,
setting prepend_dir to "other/dir" you can upload your file to
ftp://server.com/other/dir
* New function, ecore_con_url_verbose_set: you can enable or disable
libcurl's verbose output (useful for debug)
* New function, ecore_con_url_ftp_use_epsv_set: you can enable or
disable the EPSV command
* Some typo changes on examples at the top of ecore_con_url.c
Regards
Massimiliano
- --
Massimiliano Calamelli
http://mcalamelli.netsons.org
[EMAIL PROTECTED]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
iD8DBQFIVnxKleGEL56NNP4RAiCcAJ4xzvjuyyI8StopnbOmq7PP7ejKpwCfXFHI
9ND6nj0LLk0HdiLvvR5ehhc=
=/Eo0
-----END PGP SIGNATURE-----
? SciTE.properties
Index: Ecore_Con.h
===================================================================
RCS file: /var/cvs/e/e17/libs/ecore/src/lib/ecore_con/Ecore_Con.h,v
retrieving revision 1.40
diff -u -r1.40 Ecore_Con.h
--- Ecore_Con.h 14 Jun 2008 10:18:00 -0000 1.40
+++ Ecore_Con.h 16 Jun 2008 14:18:00 -0000
@@ -215,7 +215,9 @@
void *data);
#endif
- EAPI int ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, char
*filename, char *user, char *pass, char *uploadas);
+ EAPI int ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, char
*filename, char *user, char *pass, char *prepend_dir);
+ EAPI void ecore_con_url_verbose_set(Ecore_Con_Url *url_con, int
verbose);
+ EAPI void ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url
*url_con, int use_epsv);
#ifdef __cplusplus
}
Index: ecore_con_url.c
===================================================================
RCS file: /var/cvs/e/e17/libs/ecore/src/lib/ecore_con/ecore_con_url.c,v
retrieving revision 1.22
diff -u -r1.22 ecore_con_url.c
--- ecore_con_url.c 28 May 2008 09:02:39 -0000 1.22
+++ ecore_con_url.c 16 Jun 2008 14:18:01 -0000
@@ -23,15 +23,23 @@
*
* Example Usage 1 (HTTP GET):
* ecore_con_url_url_set(url_con, "http://www.google.com");
- * ecore_con_url_send(url, NULL, 0, NULL);
+ * ecore_con_url_send(url_con, NULL, 0, NULL);
*
* Example usage 2 (HTTP POST):
* ecore_con_url_url_set(url_con, "http://www.example.com/post_handler.cgi");
- * ecore_con_url_send(url, data, data_length, "multipart/form-data");
+ * ecore_con_url_send(url_con, data, data_length, "multipart/form-data");
*
* Example Usage 3 (FTP download):
* ecore_con_url_url_set(url_con, "ftp://ftp.example.com/pub/myfile");
- * ecore_con_url_send(url, NULL, 0, NULL);
+ * ecore_con_url_send(url_con, NULL, 0, NULL);
+ *
+ * Example Usage 4 (FTP upload as ftp://ftp.example.com/file):
+ * ecore_con_url_url_set(url_con, "ftp://ftp.example.com");
+ * ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass", NULL);
+ *
+ * Example Usage 5 (FTP upload as ftp://ftp.example.com/dir/file):
+ * ecore_con_url_url_set(url_con, "ftp://ftp.example.com");
+ * ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass","dir");
*
* FIXME: Support more CURL features: Authentication, Progress callbacks and
more...
*/
@@ -42,6 +50,7 @@
#include <errno.h>
#include <sys/stat.h>
+#include <sys/types.h>
/**
* @defgroup Ecore_Con_Url_Group Ecore URL Connection Functions
@@ -60,6 +69,7 @@
static int _ecore_con_url_perform(Ecore_Con_Url *url_con);
static size_t _ecore_con_url_data_cb(void *buffer, size_t size, size_t nmemb,
void *userp);
static int _ecore_con_url_progress_cb(void *clientp, double dltotal, double
dlnow, double ultotal, double ulnow);
+static size_t _ecore_con_url_read_cb(void *ptr, size_t size, size_t nmemb,
void *stream);
static void _ecore_con_event_url_free(void *data __UNUSED__, void *ev);
static int _ecore_con_url_process_completed_jobs(Ecore_Con_Url
*url_con_to_match);
@@ -495,17 +505,17 @@
/**
* Makes a FTP upload
- * @return FIXME: To be documented.
+ * @return FIXME: To be more documented.
* @ingroup Ecore_Con_Url_Group
*/
EAPI int
-ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, char *filename, char *user,
char *pass, char *uploadas)
+ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, char *filename, char *user,
char *pass, char *prepend_dir)
{
#ifdef HAVE_CURL
char url[4096];
char userpwd[4096];
FILE *fd;
- struct stat file_info;
+ struct stat file_info;
if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
{
@@ -515,16 +525,19 @@
if (url_con->active) return 0;
if (!url_con->url) return 0;
-
if (filename)
{
if (stat(filename, &file_info)) return 0;
fd = fopen(filename, "rb");
- snprintf(url, sizeof(url), "ftp://%s/%s", url_con->url,
basename(filename));
+ if (prepend_dir)
+ snprintf(url, sizeof(url), "ftp://%s/%s/%s", url_con->url,
prepend_dir, basename(filename));
+ else
+ snprintf(url, sizeof(url), "ftp://%s/%s", url_con->url,
basename(filename));
snprintf(userpwd, sizeof(userpwd), "%s:%s", user, pass);
- curl_easy_setopt(url_con->curl_easy, CURLOPT_VERBOSE, 1);
+ curl_easy_setopt(url_con->curl_easy, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);
curl_easy_setopt(url_con->curl_easy, CURLOPT_USERPWD, userpwd);
curl_easy_setopt(url_con->curl_easy, CURLOPT_UPLOAD, 1);
+ curl_easy_setopt(url_con->curl_easy, CURLOPT_READFUNCTION,
_ecore_con_url_read_cb);
curl_easy_setopt(url_con->curl_easy, CURLOPT_READDATA, fd);
ecore_con_url_url_set(url_con, url);
@@ -541,6 +554,57 @@
#endif
}
+/**
+ * Enable or disable libcurl verbose output, useful for debug
+ * @return FIXME: To be more documented.
+ * @ingroup Ecore_Con_Url_Group
+ */
+EAPI void
+ecore_con_url_verbose_set(Ecore_Con_Url *url_con, int verbose)
+{
+#ifdef HAVE_CURL
+ if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
+ {
+ ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL,
"ecore_con_url_verbose_set");
+ return;
+ }
+
+ if (url_con->active) return;
+ if (!url_con->url) return;
+ if (verbose == TRUE)
+ curl_easy_setopt(url_con->curl_easy, CURLOPT_VERBOSE, 1);
+ else
+ curl_easy_setopt(url_con->curl_easy, CURLOPT_VERBOSE, 0);
+#else
+ return;
+#endif
+}
+
+/**
+ * Enable or disable EPSV extension
+ * @return FIXME: To be more documented.
+ * @ingroup Ecore_Con_Url_Group
+ */
+EAPI void
+ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, int use_epsv)
+{
+#ifdef HAVE_CURL
+ if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
+ {
+ ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL,
"ecore_con_url_ftp_use_epsv_set");
+ return;
+ }
+
+ if (url_con->active) return;
+ if (!url_con->url) return;
+ if (use_epsv == TRUE)
+ curl_easy_setopt(url_con->curl_easy, CURLOPT_FTP_USE_EPSV, 1);
+ else
+ curl_easy_setopt(url_con->curl_easy, CURLOPT_FTP_USE_EPSV, 0);
+#else
+ return;
+#endif
+}
#ifdef HAVE_CURL
static int
@@ -687,6 +751,14 @@
return 0;
}
+static size_t
+_ecore_con_url_read_cb(void *ptr, size_t size, size_t nmemb, void *stream)
+{
+ size_t retcode = fread(ptr, size, nmemb, stream);
+ fprintf(stderr, "*** We read %d bytes from file\n", retcode);
+ return retcode;
+}
+
static int
_ecore_con_url_perform(Ecore_Con_Url *url_con)
{
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel