Changeset: 01c11a44a859 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=01c11a44a859
Modified Files:
        monetdb5/modules/atoms/Tests/All
        monetdb5/modules/atoms/mcurl.c
Branch: default
Log Message:

Merge with Aug2018 branch.


diffs (truncated from 374 to 300 lines):

diff --git a/monetdb5/modules/atoms/Tests/All b/monetdb5/modules/atoms/Tests/All
--- a/monetdb5/modules/atoms/Tests/All
+++ b/monetdb5/modules/atoms/Tests/All
@@ -33,5 +33,4 @@ json15
 jsonrender
 
 uuid00
-#curl00
 strappend
diff --git a/monetdb5/modules/atoms/mcurl.c b/monetdb5/modules/atoms/mcurl.c
--- a/monetdb5/modules/atoms/mcurl.c
+++ b/monetdb5/modules/atoms/mcurl.c
@@ -20,313 +20,6 @@
 #include <unistd.h>
 #include <string.h>
 
-struct MemoryStruct {
-       char *memory;
-       size_t size;
-};
-
-#ifdef HAVE_CURL
-#include <curl/curl.h>
-
-static size_t
-WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
-{
-       size_t realsize = size * nmemb;
-       struct MemoryStruct *mem = (struct MemoryStruct *)userp;
-       char *nmem;
-
-       nmem = realloc(mem->memory, mem->size + realsize + 1);
-       if(nmem == NULL) {
-               /* out of memory! */
-               free(mem->memory);
-               mem->memory = NULL;
-               fprintf(stderr, "mcurl module: not enough memory (realloc 
returned NULL)\n");
-               return 0;
-       }
-       mem->memory = nmem;
-
-       memcpy(&(mem->memory[mem->size]), contents, realsize);
-       mem->size += realsize;
-       mem->memory[mem->size] = 0;
-
-       return realsize;
-}
-
-static str
-handle_get_request(str *retval, str *url)
-{
-       str d = NULL;
-       str msg = MAL_SUCCEED;
-
-       CURL *curl_handle;
-       CURLcode res = CURLE_OK;
-
-       struct MemoryStruct chunk;
-
-       chunk.memory = malloc(1);  /* will be grown as needed by the realloc 
above */
-       if (chunk.memory == NULL)
-               throw(MAL, "mcurl.getrequest", SQLSTATE(HY001) MAL_MALLOC_FAIL);
-       chunk.size = 0;    /* no data at this point */
-
-       curl_global_init(CURL_GLOBAL_ALL);
-       /* init the curl session */
-       curl_handle = curl_easy_init();
-       curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1);
-       /* set URL to get */
-
-       curl_easy_setopt(curl_handle, CURLOPT_URL, *url);
-
-       /* no progress meter please */
-       curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
-
-       /* send all data to this function  */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, 
WriteMemoryCallback);
-
-       /* we want the body be written to this file handle instead of stdout */
-       /* coverity[bad_sizeof] */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
-
-       /* get it! */
-       res = curl_easy_perform(curl_handle);
-
-       /* check for errors */
-       if(res != CURLE_OK) {
-               msg = createException(MAL, "mcurl.getrequest",
-                                                         "curl_easy_perform() 
failed: %s\n", curl_easy_strerror(res));
-       } else {
-               /*
-                * Now, our chunk.memory points to a memory block that is
-                * chunk.size bytes big and contains the remote file.
-                *
-                * Do something nice with it!
-                *
-                * You should be aware of the fact that at this point we might
-                * have an allocated data block, and nothing has yet
-                * deallocated that data. So when you're done with it, you
-                * should free() it as a nice application.
-                */
-
-               //printf("%zu bytes retrieved\n", chunk.size);
-       }
-       if (chunk.size) {
-               d = GDKstrdup(chunk.memory);
-               if(chunk.memory)
-                       free(chunk.memory);
-       }
-       /* cleanup curl stuff */
-       curl_easy_cleanup(curl_handle);
-
-       *retval = d;
-       return msg;
-}
-
-static str
-handle_put_request(str *retval, str *url)
-{
-       str d = NULL;
-       str msg = MAL_SUCCEED;
-
-       CURL *curl_handle;
-       CURLcode res = CURLE_OK;
-
-       struct MemoryStruct chunk;
-
-       chunk.memory = malloc(1);  /* will be grown as needed by the realloc 
above */
-       if (chunk.memory == NULL)
-               throw(MAL, "mcurl.putrequest", SQLSTATE(HY001) MAL_MALLOC_FAIL);
-       chunk.size = 0;    /* no data at this point */
-
-       curl_global_init(CURL_GLOBAL_ALL);
-       /* init the curl session */
-       curl_handle = curl_easy_init();
-       curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
-       /* set URL to get */
-
-       curl_easy_setopt(curl_handle, CURLOPT_URL, *url);
-
-       /* no progress meter please */
-       curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
-
-       /* send all data to this function  */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, 
WriteMemoryCallback);
-
-       /* we want the body be written to this file handle instead of stdout */
-       /* coverity[bad_sizeof] */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
-
-       /* get it! */
-       res = curl_easy_perform(curl_handle);
-
-       /* check for errors */
-       if(res != CURLE_OK) {
-               msg = createException(MAL, "mcurl.putrequest",
-                                                         "curl_easy_perform() 
failed: %s\n", curl_easy_strerror(res));
-       } else {
-               /*
-                * Now, our chunk.memory points to a memory block that is
-                * chunk.size bytes big and contains the remote file.
-                *
-                * Do something nice with it!
-                *
-                * You should be aware of the fact that at this point we might
-                * have an allocated data block, and nothing has yet
-                * deallocated that data. So when you're done with it, you
-                * should free() it as a nice application.
-                */
-
-               //printf("%zu bytes retrieved\n", chunk.size);
-       }
-       if (chunk.size) {
-               d = GDKstrdup(chunk.memory);
-               if(chunk.memory)
-                       free(chunk.memory);
-       }
-       /* cleanup curl stuff */
-       curl_easy_cleanup(curl_handle);
-
-       *retval = d;
-       return msg;
-}
-
-static str
-handle_post_request(str *retval, str *url)
-{
-       str d = NULL;
-       str msg = MAL_SUCCEED;
-
-       CURL *curl_handle;
-       CURLcode res = CURLE_OK;
-
-       struct MemoryStruct chunk;
-
-       chunk.memory = malloc(1);  /* will be grown as needed by the realloc 
above */
-       if (chunk.memory == NULL)
-               throw(MAL, "mcurl.postrequest", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
-       chunk.size = 0;    /* no data at this point */
-
-       curl_global_init(CURL_GLOBAL_ALL);
-       /* init the curl session */
-       curl_handle = curl_easy_init();
-       curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
-       /* set URL to get */
-
-       curl_easy_setopt(curl_handle, CURLOPT_URL, *url);
-
-       /* no progress meter please */
-       curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
-
-       /* send all data to this function  */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, 
WriteMemoryCallback);
-
-       /* we want the body be written to this file handle instead of stdout */
-       /* coverity[bad_sizeof] */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
-
-       /* get it! */
-       res = curl_easy_perform(curl_handle);
-
-       /* check for errors */
-       if(res != CURLE_OK) {
-               msg = createException(MAL, "mcurl.postrequest",
-                                                         "curl_easy_perform() 
failed: %s\n", curl_easy_strerror(res));
-       } else {
-               /*
-                * Now, our chunk.memory points to a memory block that is
-                * chunk.size bytes big and contains the remote file.
-                *
-                * Do something nice with it!
-                *
-                * You should be aware of the fact that at this point we might
-                * have an allocated data block, and nothing has yet
-                * deallocated that data. So when you're done with it, you
-                * should free() it as a nice application.
-                */
-
-               //printf("%zu bytes retrieved\n", chunk.size);
-       }
-       if (chunk.size) {
-               d = GDKstrdup(chunk.memory);
-               if(chunk.memory)
-                       free(chunk.memory);
-       }
-       /* cleanup curl stuff */
-       curl_easy_cleanup(curl_handle);
-
-       *retval = d;
-       return msg;
-}
-
-static str
-handle_delete_request(str *retval, str *url)
-{
-       str d = NULL;
-       str msg = MAL_SUCCEED;
-
-       CURL *curl_handle;
-       CURLcode res = CURLE_OK;
-       char * delete_request = "DELETE";
-
-       struct MemoryStruct chunk;
-
-       chunk.memory = malloc(1);  /* will be grown as needed by the realloc 
above */
-       if (chunk.memory == NULL)
-               throw(MAL, "mcurl.deleterequest", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
-       chunk.size = 0;    /* no data at this point */
-
-       curl_global_init(CURL_GLOBAL_ALL);
-       /* init the curl session */
-       curl_handle = curl_easy_init();
-       curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, delete_request);
-       /* set URL to get */
-
-       curl_easy_setopt(curl_handle, CURLOPT_URL, *url);
-
-       /* no progress meter please */
-       curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
-
-       /* send all data to this function  */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, 
WriteMemoryCallback);
-
-       /* we want the body be written to this file handle instead of stdout */
-       /* coverity[bad_sizeof] */
-       curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
-
-       /* get it! */
-       res = curl_easy_perform(curl_handle);
-
-       /* check for errors */
-       if(res != CURLE_OK) {
-               msg = createException(MAL, "mcurl.deleterequest",
-                                                         "curl_easy_perform() 
failed: %s\n", curl_easy_strerror(res));
-       } else {
-               /*
-                * Now, our chunk.memory points to a memory block that is
-                * chunk.size bytes big and contains the remote file.
-                *
-                * Do something nice with it!
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to