]> git.ipfire.org Git - thirdparty/git.git/blobdiff - http.c
http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
[thirdparty/git.git] / http.c
diff --git a/http.c b/http.c
index 8a5ba3f47769424e8315658b1f14903cc4957ecf..ca0fe80ddb86b365c09275e2009cfdf460e010d1 100644 (file)
--- a/http.c
+++ b/http.c
@@ -157,21 +157,19 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
        return size / eltsize;
 }
 
-curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)
+int seek_buffer(void *clientp, curl_off_t offset, int origin)
 {
        struct buffer *buffer = clientp;
 
-       switch (cmd) {
-       case CURLIOCMD_NOP:
-               return CURLIOE_OK;
-
-       case CURLIOCMD_RESTARTREAD:
-               buffer->posn = 0;
-               return CURLIOE_OK;
-
-       default:
-               return CURLIOE_UNKNOWNCMD;
+       if (origin != SEEK_SET)
+               BUG("seek_buffer only handles SEEK_SET");
+       if (offset < 0 || offset >= buffer->buf.len) {
+               error("curl seek would be outside of buffer");
+               return CURL_SEEKFUNC_FAIL;
        }
+
+       buffer->posn = offset;
+       return CURL_SEEKFUNC_OK;
 }
 
 size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)