diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -139,22 +139,24 @@ size_t curl_writetodisk(void *ptr, size_ } /** Helper function for cURL's progress display */ -int curl_progress( char *Bar,double t,double d,double ultotal,double ulnow) +int curl_progress(char *Bar, double t, double d, double ultotal, double ulnow) { fprintf(stderr,"Downloading: %f%% complete\r",d/t*100); return 0; } /** Retrieves a URL with cURL and saves it to disk */ -int curlget(char *url, char *out){ +CURLcode curlget(char *url, char *out){ fprintf(stderr,"Preparing to download %s\n",url); double *Bar; // Stores cURL progress display info CURL *curl; CURLcode res; FILE *outfile; + res = CURLE_FAILED_INIT; curl = curl_easy_init(); - if(curl) { + if(curl) + { outfile = fopen(out, "w"); // Open where we're writing to if(outfile == NULL) return 2; // Output dir doesn't exist @@ -162,19 +164,19 @@ int curlget(char *url, char *out){ curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writetodisk); // this MUST be set for win32 compat. curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress); + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)&curl_progress); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &Bar); res = curl_easy_perform(curl); curl_easy_cleanup(curl); + fclose(outfile); } fprintf(stderr,"\n"); // Clears out he progressbar's carriage return - fclose(outfile); return res; // 0 is OK, 1 is 404 or other error } /** Posts a file to a url with cUrl */ -int curlpost(char *filename, char *url, int jobnum, int framenum, int slavekey){ - fprintf(stderr,"Uploading to %s\n", url); +CURLcode curlpost(char *filename, char *url, int jobnum, int framenum, int slavekey) +{ char *targetname = "uploadedfile"; // Name of the target in the php file on the server (Don't change me unless you have different PHP code) CURL *curl; CURLcode res; @@ -186,6 +188,9 @@ int curlpost(char *filename, char *url, char *sjobnum; char *sframenum; char *sslavekey; + + fprintf(stderr,"Uploading to %s\n", url); + _distren_asprintf(&sjobnum,"%d",jobnum); _distren_asprintf(&sframenum,"%d",framenum); _distren_asprintf(&sslavekey,"%d",slavekey); @@ -226,9 +231,11 @@ int curlpost(char *filename, char *url, CURLFORM_COPYCONTENTS, "send", CURLFORM_END); + res = CURLE_FAILED_INIT; curl = curl_easy_init(); headerlist = curl_slist_append(headerlist, buf); - if(curl) { + if(curl) + { /* Setting the URL to get the post, and the contents of the post */ curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); @@ -241,7 +248,7 @@ int curlpost(char *filename, char *url, free(sjobnum); free(sframenum); free(sslavekey); - } + } return res; } @@ -634,9 +641,9 @@ struct _web_memorystruct { size_t size; }; -static void *_web_myrealloc(void *ptr, size_t size); +void *_web_myrealloc(void *ptr, size_t size); -static void *_web_myrealloc(void *ptr, size_t size) +void *_web_myrealloc(void *ptr, size_t size) { /* There might be a realloc() out there that doesn't like reallocing NULL pointers, so we take care of it here */ @@ -646,7 +653,7 @@ static void *_web_myrealloc(void *ptr, s return malloc(size); } -static size_t _web_writememorycallback(void *ptr, size_t size, size_t nmemb, void *data) +size_t _web_writememorycallback(void *ptr, size_t size, size_t nmemb, void *data) { size_t realsize = size * nmemb; struct _web_memorystruct *mem = (struct _web_memorystruct *)data;