cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: uploaded unaligned file size

From: Mark Lively <mongothegeek_at_gmail.com>
Date: Mon, 11 Apr 2011 15:05:11 -0400

On Mon, Apr 11, 2011 at 9:33 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Mon, 11 Apr 2011, Mark Lively wrote:
>
>>> So, can you please write up a small example that can repeat this problem
>>> and show us? It sounds really odd and I can't explain why libcurl to act
>>> like that, but perhaps I'm missing something that a full example would
>>> reveal...
>>>
>> Since I am working on Macs I wrapped libcurl with a cocoa object.
>
> I was hoping for a complete program in plain C, as I don't work with Mac and
> I don't have cocoa...

In the process of making this into a generic C I found *part* of the
issue. I had an old version of libcurl linked in statically(7.10.2)
the IDE I was using also linked in the dynamic libraries so when I ran
it on machines with newer compatible libcurl it used that. Machines
without a valid libcurl.4.dylib fell back to the static version that
was linked in.

The hinkyness with some machines working and other not has been
figured out at least partially.

The below crashed on a missing dylib on the machines where the
transfer was successful and had errors where my program had errors.
Building against the old static library it worked on every machine.

Thank you for your help.

-Mark

#include <stdio.h>
#include <curl/curl.h>

int main (int argc, const char * argv[]) {
    CURL * curlHandle;
    curlHandle = curl_easy_init();
    curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
    printf("%s\n",data->version);
    curl_easy_setopt(curlHandle, CURLOPT_UPLOAD, 1);
    curl_easy_setopt(curlHandle, CURLOPT_FTP_RESPONSE_TIMEOUT, 25);
    curl_easy_setopt(curlHandle, CURLOPT_FORBID_REUSE, 1);
    curl_easy_setopt(curlHandle, CURLOPT_TRANSFERTEXT,1);
    curl_easy_setopt(curlHandle, CURLOPT_USERPWD, argv[1]);
    FILE * filePtr = fopen(argv[2], "r+");
    curl_easy_setopt(curlHandle, CURLOPT_URL, argv[3]);
    curl_easy_setopt(curlHandle, CURLOPT_READDATA, filePtr);
    curl_easy_setopt(curlHandle, CURLOPT_VERBOSE, 1);
    int anErr = curl_easy_perform(curlHandle);
    if (anErr!=0) {
        printf("Error: %u",anErr);
    }
    fclose (filePtr);
    curl_easy_cleanup(curlHandle);
    return anErr;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-04-11