curl-library
Problems with libcurl, OS X, and curl_off_t (or : What's My Size?)
Date: Fri, 13 Aug 2004 11:51:33 -0400
HI folks,
I'm trying to use libcurl on OS X and I've ran across some problems. The short
of it is: When doing HTTP Posts by Content-Length == 0 when I'm posting data.
The Problem In detail:
The number used for Content-Length, around line 1883 in http.c (Curl_http())
is a sane number. Then it goes into add_bufferf() and the vaprintf returns
a string "Content-Length: 0". Which, of course, is no good.
_______________________________
About My Setup:
_______________________________
First of all, I'm using the config-mac.h file, instead of building it using
straight configure/make/GCC. This is for two reasons:
#1: I need the latest and greatest libcurl, so I can't depend on what
the user has on their machine. I checked out libcurl from CVS
2 days ago.
#2: This is actually part of a larger project, where we're using Apple's
XCode IDE, along with compiling with Codewarrior occasionally, as
well as Windows using Dev-CPP.
#3: CVS HEAD is awfully hard to build on OS X... I had to get a new
automake, libtool, and several other things. Then automake
complained that the aclocal files were too old.
So I'm using configure-mac.h, and including the libcurl sources in my Project
files, where I have it build with my project.
In order to make this work I had to make the following modifications to
configure-mac.h (which I will verify for Codewarrior, then submit a patch in the
formal manner)
! #define HAVE_FIONBIO 1
! #include <extra/stricmp.h>
! #include <extra/strdup.h>
--- 39,50 ----
#define HAVE_RAND_STATUS 1
#define HAVE_RAND_EGD 1
! //#define HAVE_FIONBIO 1
! #define HAVE_O_NONBLOCK 1
! #define HAVE_SYS_SOCKIO_H 1
! #ifndef __MWERKS__
! #define SIZEOF_CURL_OFF_T 8
! #else
! #error "spelling mistake!"
! #endif
(As you see, it won't compile on Codewarrior right now, again, that's To Be
Done.)
_______________________________
My Problem, In Far More Detail
_______________________________
You'll also notice SIZEOF_CURL_OFF_T is 8. It's 8 because OS X, like a normal
POSIX system has curl_off_t defined as off_t. On OS X sizeof(off_t) == 8.
Ok, that's grand. On OS X off_t seems to be a weird type. In thread entitled
"libcurl putting an empty file on OS X", specifically this post
(http://curl.haxx.se/mail/lib-2003-12/0237.html) seems to say that off_t may be
"oddly" defined on OS X, but that casting your postSize parameter to a long
solves the problem.
To me this is weird, seemingly wrong, and doesn't work for large files (although
sending 2GB files through HTTP isn't *my* idea of a good time.) Although it DOES
work for me.
So, this morning I played around with setting curl_off_t to a long long instead,
using the define for GCC + Windows (I simply removed the Windows bit -- just for
testing.). No go. My Content-Length was still == 0. I even redefined
CURL_FORMAT_OFF_T to be "%lld" instead of "%l64d", as it is with GCC + Windows,
with no luck.
So, it doesn't make sense. I really don't want to have to remember to cast
things to longs every time I interact with curl_off_t, and it would be great if
I could set curl_off_t to be long long (or another 64bit integer value - I'm not
picky) on OS X.
So I don't know what to do.
_______________________________
My Thoughts On Answers
_______________________________
As I see it, I have several options:
#1: Just define curl_off_t to be a long on OS X, and set a compiler flag
to turn off large file support (anybody happen to know that flag?)
#2: Find out, via the helpful folk on the libcurl list, why my plan with
long long is either wrong, or "It's not working because you need
to...".
#3: Make a sane format string for the OS X "different" implementation of
off_t, if it really is "different".
So that's my story. I'm wondering if anybody has any thoughts on the matter (any
point of the matter at all, really). I know people have used libcurl on OS X
(Dan Wood, I'm looking at you ;) ). I'm kind of curious what kind of problems
(like this) they have run into... or, perhaps just their ./configure generated
configure.h file, and how that's different from my configure-mac.h.
Thanks In Advance,
_Ryan Wilcox
================================================================
Wilcox Development Solutions: http://www.wilcoxd.com
Toolsmiths for the Internet Age PGP: 0x2F4E9C31
Received on 2004-08-13