On Wed, Mar 01, 2006 at 10:04:41PM +0100, Lennart Poettering wrote:
> Currently ne_get_range() is unusable with 64bit file offsets. There is
> no 64bit counterpart of this specific function. The structure
> ne_content_range contains variables of type "off_t" whose size differs
> depending on _FILE_OFFSET_BITS. This creates all kinds of strange bugs
> when linking different libs where some have been compiled with that
> define and others have not. (And most modern software defines
> _FILE_OFFSET_BITS to 64 these days)
If you compile everything, including neon, with _FILE_OFFSET_BITS=64,
then everything works fine (at least from neon's perspective). If you
mix and match apps and libraries built with _F_O_B=64, then yes, you'll
have lots of strange and horrible problems. So... don't do that!
Having neon export _F_O_B=64 by default would cause similar problems for
apps which *don't* build using that flag. Really, just avoiding _F_O_B
definitions completely is the only safe bet.
It is simple enough to add an LFS-style ne_get_range64 to neon to allow
taking off64_t offsets; e.g. as below. If you want to mix'n'match
apps+libs using differently sized off_t, then you can do that safely
with neon so long as you stick to using the LFS interfaces.
Index: src/ne_basic.c
===================================================================
--- src/ne_basic.c (revision 980)
+++ src/ne_basic.c (working copy)
@@ -150,24 +150,14 @@
return ret;
}
-int ne_get_range(ne_session *sess, const char *uri,
- ne_content_range *range, int fd)
+static int get_range_common(ne_session *sess, const char *uri,
+ const char *brange, int fd)
+
{
ne_request *req = ne_request_create(sess, "GET", uri);
const ne_status *status;
int ret;
- char brange[64];
- if (range->end == -1) {
- ne_snprintf(brange, sizeof brange, "bytes=%" NE_FMT_OFF_T "-",
- range->start);
- }
- else {
- ne_snprintf(brange, sizeof brange,
- "bytes=%" NE_FMT_OFF_T "-%" NE_FMT_OFF_T,
- range->start, range->end);
- }
-
ne_add_request_header(req, "Range", brange);
ne_add_request_header(req, "Accept-Ranges", "bytes");
@@ -196,7 +186,44 @@
return ret;
}
+int ne_get_range(ne_session *sess, const char *uri,
+ ne_content_range *range, int fd)
+{
+ char brange[64];
+ if (range->end == -1) {
+ ne_snprintf(brange, sizeof brange, "bytes=%" NE_FMT_OFF_T "-",
+ range->start);
+ }
+ else {
+ ne_snprintf(brange, sizeof brange,
+ "bytes=%" NE_FMT_OFF_T "-%" NE_FMT_OFF_T,
+ range->start, range->end);
+ }
+
+ return get_range_common(sess, uri, brange, fd);
+}
+
+#ifdef NE_LFS
+int ne_get_range64(ne_session *sess, const char *uri,
+ ne_content_range64 *range, int fd)
+{
+ char brange[64];
+
+ if (range->end == -1) {
+ ne_snprintf(brange, sizeof brange, "bytes=%" NE_FMT_OFF64_T "-",
+ range->start);
+ }
+ else {
+ ne_snprintf(brange, sizeof brange,
+ "bytes=%" NE_FMT_OFF64_T "-%" NE_FMT_OFF64_T,
+ range->start, range->end);
+ }
+
+ return get_range_common(sess, uri, brange, fd);
+}
+#endif
+
/* Get to given fd */
int ne_get(ne_session *sess, const char *uri, int fd)
{
Index: src/ne_basic.h
===================================================================
--- src/ne_basic.h (revision 980)
+++ src/ne_basic.h (working copy)
@@ -1,6 +1,6 @@
/*
HTTP/1.1 methods
- Copyright (C) 1999-2005, Joe Orton <[EMAIL PROTECTED]>
+ Copyright (C) 1999-2006, Joe Orton <[EMAIL PROTECTED]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -120,6 +120,16 @@
int ne_get_range(ne_session *sess, const char *path,
ne_content_range *range, int fd);
+#ifdef NE_LFS
+typedef struct {
+ off64_t start, end, total;
+} ne_content_range64;
+
+/* LFS-compatible version of ne_get_range. */
+int ne_get_range64(ne_session *sess, const char *path,
+ ne_content_range64 *range, int fd);
+#endif
+
/* Post using buffer as request-body: stream response into f */
int ne_post(ne_session *sess, const char *path, int fd, const char *buffer);
_______________________________________________
neon mailing list
[email protected]
http://mailman.webdav.org/mailman/listinfo/neon