curl-library
[PATCH] curl_formget()
Date: Tue, 20 Jun 2006 15:55:58 +0200
Hi,
as Debian has already begun to hide internal libcurl symbols and it
seems that this even becomes an option in the mainstream code base,
I'd like to ask if a patch to add a curl_formget() function would
be considered for inclusion. I actually used Curl_getFormData()
in my code which won't be available any longer.
Regards,
-- Michael
? CURLOPT_COOKIELIST--SESS.diff.txt
? curl_formget.diff
Index: include/curl/curl.h
===================================================================
RCS file: /cvsroot/curl/curl/include/curl/curl.h,v
retrieving revision 1.298
diff -u -p -d -r1.298 curl.h
--- include/curl/curl.h 12 Jun 2006 20:33:05 -0000 1.298
+++ include/curl/curl.h 20 Jun 2006 13:46:52 -0000
@@ -1154,6 +1154,12 @@ CURL_EXTERN CURLFORMcode curl_formadd(st
...);
/*
+ * NAME curl_formstr()
+ */
+CURL_EXTERN int curl_fromget(struct curl_httppost *form,
+ void *arg,
+ size_t (*append)(void *arg, const char *buf, size_t len));
+/*
* NAME curl_formfree()
*
* DESCRIPTION
Index: lib/formdata.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/formdata.c,v
retrieving revision 1.90
diff -u -p -d -r1.90 formdata.c
--- lib/formdata.c 26 Apr 2006 17:26:22 -0000 1.90
+++ lib/formdata.c 20 Jun 2006 13:46:52 -0000
@@ -137,6 +137,8 @@ Content-Disposition: form-data; name="FI
char *basename(char *path);
#endif
+static size_t readfromfile(struct Form *form, char *buffer, size_t size);
+
/* What kind of Content-Type to use on un-specified files with unrecognized
extensions. */
#define HTTPPOST_CONTENTTYPE_DEFAULT "application/octet-stream"
@@ -886,6 +888,46 @@ void Curl_formclean(struct FormData *for
}
/*
+ * curl_formget()
+ */
+int curl_formget(struct curl_httppost *form, void *arg,
+ size_t (*append)(void *arg, const char *buf, size_t len))
+{
+ CURLFORMcode rc;
+ curl_off_t size;
+ struct FormData *data, *ptr;
+
+ if (CURL_FORMADD_OK != (rc = Curl_getFormData(&data, form, &size))) {
+ return rc;
+ }
+
+ for (ptr = data; ptr; ptr = ptr->next) {
+ if (ptr->type == FORM_FILE) {
+ char buffer[8192];
+ size_t read;
+ struct Form temp;
+
+ Curl_FormInit(&temp, ptr);
+
+ do {
+ read = readfromfile(&temp, buffer, sizeof(buffer));
+ if ((read == (size_t) -1) || (read != append(arg, buffer, read))) {
+ Curl_formclean(data);
+ return -1; /* rc? */
+ }
+ } while (read == sizeof(buffer));
+ } else {
+ if (ptr->length != append(arg, ptr->line, ptr->length)) {
+ Curl_formclean(data);
+ return -1; /* rc? */
+ }
+ }
+ }
+ Curl_formclean(data);
+ return 0; /* rc? */
+}
+
+/*
* curl_formfree() is an external function to free up a whole form post
* chain
*/
@@ -1527,6 +1569,15 @@ CURLFORMcode curl_formadd(struct curl_ht
return CURL_FORMADD_DISABLED;
}
+CURLFORMCode curl_formstr(struct curl_httppost *post, void *arg,
+ int (append*)(void *arg, const char *buf, size_t len))
+{
+ (void) post;
+ (void) arg;
+ (void) append;
+ return CURL_FORMADD_DISABLED;
+}
+
void curl_formfree(struct curl_httppost *form)
{
(void)form;
Received on 2006-06-20