#include "url.h"
#include "parsedate.h" /* for the week day and month names */
#include "warnless.h"
+/* The last 3 #include files should be in this order */
#include "curl_printf.h"
-
-/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"
curl_off_t totalsize=-1;
char *ptr;
char *ptr2;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
if(data->state.use_range && data->state.range) {
from=curlx_strtoofft(data->state.range, &ptr, 0);
*/
static CURLcode file_connect(struct connectdata *conn, bool *done)
{
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
char *real_path;
struct FILEPROTO *file = data->req.protop;
int fd;
for(i=0; i < real_path_len; ++i)
if(actual_path[i] == '/')
actual_path[i] = '\\';
- else if(!actual_path[i]) /* binary zero */
+ else if(!actual_path[i]) { /* binary zero */
+ Curl_safefree(real_path);
return CURLE_URL_MALFORMAT;
+ }
fd = open_readonly(actual_path, O_RDONLY|O_BINARY);
file->path = actual_path;
#else
- if(memchr(real_path, 0, real_path_len))
+ if(memchr(real_path, 0, real_path_len)) {
/* binary zeroes indicate foul play */
+ Curl_safefree(real_path);
return CURLE_URL_MALFORMAT;
+ }
fd = open_readonly(real_path, O_RDONLY);
file->path = real_path;
int fd;
int mode;
CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
char *buf = data->state.buffer;
size_t nread;
size_t nwrite;
/*skip bytes before resume point*/
if(data->state.resume_from) {
- if((curl_off_t)nread <= data->state.resume_from ) {
+ if((curl_off_t)nread <= data->state.resume_from) {
data->state.resume_from -= nread;
nread = 0;
buf2 = buf;
bool size_known;
bool fstated=FALSE;
ssize_t nread;
- struct SessionHandle *data = conn->data;
+ struct Curl_easy *data = conn->data;
char *buf = data->state.buffer;
curl_off_t bytecount = 0;
int fd;
information. Which for FILE can't be much more than the file size and
date. */
if(data->set.opt_no_body && data->set.include_header && fstated) {
+ time_t filetime;
+ struct tm buffer;
+ const struct tm *tm = &buffer;
snprintf(buf, sizeof(data->state.buffer),
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
if(result)
return result;
- if(fstated) {
- time_t filetime = (time_t)statbuf.st_mtime;
- struct tm buffer;
- const struct tm *tm = &buffer;
- result = Curl_gmtime(filetime, &buffer);
- if(result)
- return result;
-
- /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
- snprintf(buf, BUFSIZE-1,
- "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
- Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
- tm->tm_mday,
- Curl_month[tm->tm_mon],
- tm->tm_year + 1900,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
- result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
- }
- /* if we fstat()ed the file, set the file size to make it available post-
- transfer */
- if(fstated)
+ filetime = (time_t)statbuf.st_mtime;
+ result = Curl_gmtime(filetime, &buffer);
+ if(result)
+ return result;
+
+ /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
+ snprintf(buf, BUFSIZE-1,
+ "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
+ Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+ tm->tm_mday,
+ Curl_month[tm->tm_mon],
+ tm->tm_year + 1900,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
+ result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
+ if(!result)
+ /* set the file size to make it available post transfer */
Curl_pgrsSetDownloadSize(data, expected_size);
return result;
}