Index: include/curl/curl.h
===================================================================
RCS file: /cvsroot/curl/curl/include/curl/curl.h,v
retrieving revision 1.339
diff -r1.339 curl.h
246a247,250
> typedef int (*curl_seek_callback)(void *instream,
>                                   curl_off_t offset,
> 				  int origin);
> 
1177a1182,1185
>   /* Callback function for seeking input */
>   CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167),
>   CINIT(SEEKDATA, OBJECTPOINT, 168),
> 
Index: lib/ftp.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/ftp.c,v
retrieving revision 1.461
diff -r1.461 ftp.c
1528d1527
<   curl_off_t passed=0;
1555,1576c1554,1560
<     /* Let's read off the proper amount of bytes from the input. If we knew it
<        was a proper file we could've just fseek()ed but we only have a stream
<        here */
< 
<     /* TODO: allow the ioctlfunction to provide a fast forward function that
<        can be used here and use this method only as a fallback! */
<     do {
<       curl_off_t readthisamountnow = (data->state.resume_from - passed);
<       curl_off_t actuallyread;
< 
<       if(readthisamountnow > BUFSIZE)
<         readthisamountnow = BUFSIZE;
< 
<       actuallyread = (curl_off_t)
<         conn->fread_func(data->state.buffer, 1, (size_t)readthisamountnow,
<                     conn->fread_in);
< 
<       passed += actuallyread;
<       if((actuallyread <= 0) || (actuallyread > readthisamountnow)) {
<         /* this checks for greater-than only to make sure that the
<            CURL_READFUNC_ABORT return code still aborts */
<         failf(data, "Failed to read data");
---
>     /* Let's read off the proper amount of bytes from the input. */
>     if(conn->seek_func) {
>       curl_off_t readthisamountnow = data->state.resume_from;
> 
>       if(conn->seek_func(conn->seek_client,
> 			 readthisamountnow, SEEK_SET) != 0) {
>         failf(data, "Could not seek stream");
1579c1563,1586
<     } while(passed < data->state.resume_from);
---
>     }
> 
>     else {
>       curl_off_t passed=0;
>       do {
>         curl_off_t readthisamountnow = (data->state.resume_from - passed);
>         curl_off_t actuallyread;
> 
>         if(readthisamountnow > BUFSIZE)
>           readthisamountnow = BUFSIZE;
> 
>         actuallyread = (curl_off_t)
>           conn->fread_func(data->state.buffer, 1, (size_t)readthisamountnow,
>                       conn->fread_in);
> 
>         passed += actuallyread;
>         if((actuallyread <= 0) || (actuallyread > readthisamountnow)) {
>           /* this checks for greater-than only to make sure that the
>              CURL_READFUNC_ABORT return code still aborts */
>           failf(data, "Failed to read data");
>           return CURLE_FTP_COULDNT_USE_REST;
>         }
>       } while(passed < data->state.resume_from);
>     }
Index: lib/http.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/http.c,v
retrieving revision 1.355
diff -r1.355 http.c
1795a1796,1797
>   conn->seek_func = data->set.seek_func; /* restore */
>   conn->seek_client = data->set.seek_client; /* restore */
2189d2190
<       curl_off_t passed=0;
2192,2196c2193,2208
<          input. If we knew it was a proper file we could've just
<          fseek()ed but we only have a stream here */
<       do {
<         size_t readthisamountnow = (size_t)(data->state.resume_from - passed);
<         size_t actuallyread;
---
>          input. */
>       if(conn->seek_func) {
>         curl_off_t readthisamountnow = data->state.resume_from;
> 
>         if(conn->seek_func(conn->seek_client,
> 			   readthisamountnow, SEEK_SET) != 0) {
>           failf(data, "Could not seek stream");
>           return CURLE_READ_ERROR;
>         }
>       }
> 
>       else {
> 	curl_off_t passed=0;
>         do {
> 	  size_t readthisamountnow = (size_t)(data->state.resume_from - passed);
>           size_t actuallyread;
2198,2199c2210,2211
<         if(readthisamountnow > BUFSIZE)
<           readthisamountnow = BUFSIZE;
---
>           if(readthisamountnow > BUFSIZE)
>             readthisamountnow = BUFSIZE;
2201,2202c2213,2214
<         actuallyread =
<           data->set.fread_func(data->state.buffer, 1, (size_t)readthisamountnow,
---
>           actuallyread =
>             data->set.fread_func(data->state.buffer, 1, (size_t)readthisamountnow,
2205,2212c2217,2225
<         passed += actuallyread;
<         if(actuallyread != readthisamountnow) {
<           failf(data, "Could only read %" FORMAT_OFF_T
<                 " bytes from the input",
<                 passed);
<           return CURLE_READ_ERROR;
<         }
<       } while(passed != data->state.resume_from); /* loop until done */
---
>           passed += actuallyread;
>           if(actuallyread != readthisamountnow) {
>             failf(data, "Could only read %" FORMAT_OFF_T
>                   " bytes from the input",
>                   passed);
>             return CURLE_READ_ERROR;
>           }
>         } while(passed != data->state.resume_from); /* loop until done */
>       }
Index: lib/transfer.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/transfer.c,v
retrieving revision 1.375
diff -r1.375 transfer.c
240c240,251
<     if(data->set.ioctl_func) {
---
>     if(data->set.seek_func) {
>       int err;
> 
>       err = (data->set.seek_func) (data->set.seek_client, 0,
> 			    SEEK_SET);
> 
>       if(err) {
> 	failf(data, "seek callback returned error %d\n", (int)err);
>         return CURLE_SEND_FAIL_REWIND;
>       }
>     }
>     else if(data->set.ioctl_func) {
Index: lib/url.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/url.c,v
retrieving revision 1.690
diff -r1.690 url.c
687a688,691
>     /* don't use a seek function by default */
>     data->set.seek_func = ZERO_NULL;
>     data->set.seek_client = ZERO_NULL;
> 
1629a1634,1645
>   case CURLOPT_SEEKFUNCTION:
>     /*
>      * Seek callback. Might be NULL.
>      */
>     data->set.seek_func = va_arg(param, curl_seek_callback);
>     break;
>   case CURLOPT_SEEKDATA:
>     /*
>      * Seek control callback. Might be NULL.
>      */
>     data->set.seek_client = va_arg(param, void *);
>     break;
4040a4057,4058
>   conn->seek_func = data->set.seek_func;
>   conn->seek_client = data->set.seek_client;
Index: lib/urldata.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/urldata.h,v
retrieving revision 1.365
diff -r1.365 urldata.h
963a964,966
>   curl_seek_callback seek_func; /* function that seeks the input */
>   void *seek_client;            /* pointer to pass to the seek() above */
> 
1326a1330
>   curl_seek_callback seek_func;      /* function that seeks the input */
1344a1349
>   void *seek_client;    /* pointer to pass to the seek callback */

