#include "../curl_setup.h"
+#include "fopen.h"
+
+int curlx_fseek(void *stream, curl_off_t offset, int whence)
+{
+#if defined(_WIN32) && defined(USE_WIN32_LARGE_FILES)
+ return _fseeki64(stream, (__int64)offset, whence);
+#elif defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO)
+ return fseeko(stream, (off_t)offset, whence);
+#else
+ if(offset > LONG_MAX)
+ return -1;
+ return fseek(stream, (long)offset, whence);
+#endif
+}
+
#if defined(_WIN32) && !defined(UNDER_CE)
-#include "fopen.h"
#include "multibyte.h"
/* declare GetFullPathNameW for mingw-w64 UWP builds targeting old windows */
#include <fcntl.h> /* for open() and attributes */
#endif
+int curlx_fseek(void *stream, curl_off_t offset, int whence);
+
#if defined(_WIN32) && !defined(UNDER_CE)
FILE *curlx_win32_fopen(const char *filename, const char *mode);
int curlx_win32_stat(const char *path, struct_stat *buffer);
#include "sendf.h"
#include "strdup.h"
#include "rand.h"
+#include "curlx/fopen.h"
#include "curlx/warnless.h"
/* The last 2 #include files should be in this order */
#endif
result = curl_mime_data_cb(part, (curl_off_t) -1,
(curl_read_callback) fread,
- Curl_fseeko,
+ curlx_fseek,
NULL, (void *) stdin);
#if defined(__clang__) && __clang_major__ >= 16
#pragma clang diagnostic pop
#define basename(x) Curl_basename((x))
#endif
-int Curl_fseeko(void *stream, curl_off_t offset, int whence)
-{
-#if defined(_WIN32) && defined(USE_WIN32_LARGE_FILES)
- return _fseeki64(stream, (__int64)offset, whence);
-#elif defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO)
- return fseeko(stream, (off_t)offset, whence);
-#else
- if(offset > LONG_MAX)
- return -1;
- return fseek(stream, (long)offset, whence);
-#endif
-}
-
/* Set readback state. */
static void mimesetstate(struct mime_state *state,
if(mime_open_file(part))
return CURL_SEEKFUNC_FAIL;
- return Curl_fseeko(part->fp, offset, whence) ?
+ return curlx_fseek(part->fp, offset, whence) ?
CURL_SEEKFUNC_CANTSEEK : CURL_SEEKFUNC_OK;
}
!defined(CURL_DISABLE_IMAP))
/* Prototypes. */
-int Curl_fseeko(void *stream, curl_off_t offset, int whence);
void Curl_mime_initpart(struct curl_mimepart *part);
void Curl_mime_cleanpart(struct curl_mimepart *part);
CURLcode Curl_mime_duppart(struct Curl_easy *data,
if(offset < 0)
return CURL_SEEKFUNC_CANTSEEK;
if(!sip->data) {
- if(fseek(stdin, (long) (offset + sip->origin), SEEK_SET))
+ if(curlx_fseek(stdin, offset + sip->origin, SEEK_SET))
return CURL_SEEKFUNC_CANTSEEK;
}
sip->curpos = offset;
rc = fseek(outs->stream, 0, SEEK_END);
#else
/* ftruncate is not available, so just reposition the file
- to the location we would have truncated it. This will not
- work properly with large files on 32-bit systems, but
- most of those will have ftruncate. */
- rc = fseek(outs->stream, (long)outs->init, SEEK_SET);
+ to the location we would have truncated it. */
+ rc = curlx_fseek(outs->stream, outs->init, SEEK_SET);
#endif
if(rc) {
errorf("Failed seeking to end of file");
return PARAM_OK;
}
-static int myfseek(void *stream, curl_off_t offset, int whence)
-{
-#if defined(_WIN32) && defined(USE_WIN32_LARGE_FILES)
- return _fseeki64(stream, (__int64)offset, whence);
-#elif defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO)
- return fseeko(stream, (off_t)offset, whence);
-#else
- if(offset > LONG_MAX)
- return -1;
- return fseek(stream, (long)offset, whence);
-#endif
-}
-
ParameterError file2memory_range(char **bufp, size_t *size, FILE *file,
curl_off_t starto, curl_off_t endo)
{
if(starto) {
if(file != stdin) {
- if(myfseek(file, starto, SEEK_SET))
+ if(curlx_fseek(file, starto, SEEK_SET))
return PARAM_READ_ERROR;
offset = starto;
}