cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: FTP large file support patch

From: David J Meyer <djm_at_cs.hmc.edu>
Date: Sun, 4 Jan 2004 22:35:16 -0800 (PST)

> Still left to do:
>
> * verify/fix that the %lld in the printf lines works on platforms with a
> 32bit off_t
> * don't blindly use strtoll() in libcurl code to convert string numbers to
> off_t, as all platforms may not have it. Platforms with 32bit off_t can
> use strtol() while platforms WITH >32bit off_t but without strtoll()
> (I can't name any but I bet they exist) need a separate implementation.

"I'll work on it over the holidays" -- ha! I should never fall into the
trap of believing I can convince myself to work on things like this while
I'm on vacation...

I finally have another patch for the large file stuff. In short, I've
fixed the off_t size vs. strtol vs. strtoll bit by defining 'strtoofft'
which converts a string to an off_t as strtol works on strings and longs.
I've also modified mprintf.c to support a 'O' modifier to print off_t's,
analogous to the 'Z' modifier for size_t's. Finally, I've changed the
_BIG functions to _LARGE instead, since I completely agree with David
Boyce about files over 2 GB being known as "large files". I should have
thought of that earlier.

'strtofft' is defined to strtol for 4-byte off_t's, strtoll for 8-byte
off_t's where strtoll is present, and Curl_strtoofft (in a new file with
header, both included along with the patch in the attached tar) in the
event of an 8-byte off_t with no included strtoll.

I also fixed a slight unrelated bug which was causing all of my file
download sizes to be listed as -1, rather than the size of the data to
get. That portion of the patch was in the ftp.c file, where the size is
reset to conn->maxdownload. As far as I can tell, it looks like
conn->maxdownload is set to -1 when it's not being used, but the
comparison to force size <= conn->maxdownload doesn't check for that. I
just added a bit to make sure that conn->maxdownload is larger than 0
before resetting the size...

I've done as best of testing as I can conveniently do with different off_t
and strtoll support by changing settings in config.h (SIZEOF_OFF_T to 4
and HAVE_STRTOLL to 0), but I don't actually have a system with a 32-bit
off_t.

I've patched Makefile.am to hopefully include strtoofft.[ch]
appropriately, although I noticed that making a change to config.h which
should have necessitated rebuilding strtoofft.o didn't cause that to
happen. Someone with more auto{make,conf,build,whatever} experience might
want to check my work there. I've also attempted to patch some of the
other build files to support the added strtoofft.[ch] files, but I'm not
sure I fixed all of them, or fixed things properly, since I don't have any
of these other build systems.

This patch is against the CVS version as of about 2 weeks ago. I've
compiled with -Wall and killed all the warnings I found, so hopefully it
should integrate pretty cleanly...

Thanks,

Dave

-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click

Received on 2004-01-05