diff options
author | Brad King <brad.king@kitware.com> | 2017-10-04 11:28:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-10-10 15:15:16 (GMT) |
commit | 9e3ef40edb6eae36e822c129bec5d4ee9de0dd57 (patch) | |
tree | c739e929f90b5e6c4e26d4f5fea7f17d3772aefb /Utilities/cmcurl/lib/smb.c | |
parent | 2fad0e20b6b2b4c3cfc177267cf9689658f50c23 (diff) | |
parent | de7c21d677db1ddaeece03c19e13e448f4031511 (diff) | |
download | CMake-9e3ef40edb6eae36e822c129bec5d4ee9de0dd57.zip CMake-9e3ef40edb6eae36e822c129bec5d4ee9de0dd57.tar.gz CMake-9e3ef40edb6eae36e822c129bec5d4ee9de0dd57.tar.bz2 |
Merge branch 'upstream-curl' into update-curl
* upstream-curl:
curl 2017-10-04 (3ea76790)
Diffstat (limited to 'Utilities/cmcurl/lib/smb.c')
-rw-r--r-- | Utilities/cmcurl/lib/smb.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Utilities/cmcurl/lib/smb.c b/Utilities/cmcurl/lib/smb.c index 5b1ffa9..13dfd51 100644 --- a/Utilities/cmcurl/lib/smb.c +++ b/Utilities/cmcurl/lib/smb.c @@ -34,7 +34,7 @@ #include <process.h> #ifdef CURL_WINDOWS_APP #define getpid GetCurrentProcessId -#else +#elif !defined(MSDOS) #define getpid _getpid #endif #endif @@ -85,6 +85,7 @@ const struct Curl_handler Curl_handler_smb = { ZERO_NULL, /* perform_getsock */ smb_disconnect, /* disconnect */ ZERO_NULL, /* readwrite */ + ZERO_NULL, /* connection_check */ PORT_SMB, /* defport */ CURLPROTO_SMB, /* protocol */ PROTOPT_NONE /* flags */ @@ -109,6 +110,7 @@ const struct Curl_handler Curl_handler_smbs = { ZERO_NULL, /* perform_getsock */ smb_disconnect, /* disconnect */ ZERO_NULL, /* readwrite */ + ZERO_NULL, /* connection_check */ PORT_SMBS, /* defport */ CURLPROTO_SMBS, /* protocol */ PROTOPT_SSL /* flags */ @@ -713,6 +715,23 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done) return CURLE_OK; } +/* + * Convert a timestamp from the Windows world (100 nsec units from + * 1 Jan 1601) to Posix time. + */ +static void get_posix_time(long *_out, const void *_in) +{ +#ifdef HAVE_LONGLONG + long long timestamp = *(long long *) _in; +#else + unsigned __int64 timestamp = *(unsigned __int64 *) _in; +#endif + + timestamp -= 116444736000000000ULL; + timestamp /= 10000000; + *_out = (long) timestamp; +} + static CURLcode smb_request_state(struct connectdata *conn, bool *done) { struct smb_request *req = conn->data->req.protop; @@ -723,6 +742,7 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done) unsigned short off; CURLcode result; void *msg = NULL; + const struct smb_nt_create_response *smb_m; /* Start the request */ if(req->state == SMB_REQUESTING) { @@ -765,7 +785,8 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done) next_state = SMB_TREE_DISCONNECT; break; } - req->fid = smb_swap16(((struct smb_nt_create_response *)msg)->fid); + smb_m = (const struct smb_nt_create_response*) msg; + req->fid = smb_swap16(smb_m->fid); conn->data->req.offset = 0; if(conn->data->set.upload) { conn->data->req.size = conn->data->state.infilesize; @@ -773,9 +794,11 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done) next_state = SMB_UPLOAD; } else { - conn->data->req.size = - smb_swap64(((struct smb_nt_create_response *)msg)->end_of_file); + smb_m = (const struct smb_nt_create_response*) msg; + conn->data->req.size = smb_swap64(smb_m->end_of_file); Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size); + if(conn->data->set.get_filetime) + get_posix_time(&conn->data->info.filetime, &smb_m->last_change_time); next_state = SMB_DOWNLOAD; } break; |