Compare commits
235 Commits
curl-7_34_
...
curl-7_35_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bf90d0710 | ||
|
|
9873fd5317 | ||
|
|
d735d3e803 | ||
|
|
1a20f59237 | ||
|
|
f00899d73e | ||
|
|
00b1e52823 | ||
|
|
31860ab8c8 | ||
|
|
2070a140fd | ||
|
|
bcb19883a8 | ||
|
|
f2e42dd056 | ||
|
|
5a47062cad | ||
|
|
0f46b3b3dd | ||
|
|
23a04863aa | ||
|
|
33f9c05082 | ||
|
|
00787f94b2 | ||
|
|
49b63cf30d | ||
|
|
f55f8d4c18 | ||
|
|
88b074df3f | ||
|
|
f5860fd5fc | ||
|
|
e17446b097 | ||
|
|
0d959c64b2 | ||
|
|
606e67c812 | ||
|
|
b4b28c7001 | ||
|
|
e6130c0310 | ||
|
|
da9864fb72 | ||
|
|
755dc2f058 | ||
|
|
6c014e4283 | ||
|
|
4013a2aa64 | ||
|
|
0b5b52ff2d | ||
|
|
251305cd7f | ||
|
|
852a018e78 | ||
|
|
82de54dd38 | ||
|
|
12ecd56da7 | ||
|
|
6217cf6ba3 | ||
|
|
afd288b28f | ||
|
|
39f7e80a52 | ||
|
|
b0fa530c98 | ||
|
|
4f334ba017 | ||
|
|
33b8960dc8 | ||
|
|
de966b403a | ||
|
|
2cac75c4e4 | ||
|
|
aba98991a5 | ||
|
|
db1beab1d7 | ||
|
|
93ca1d2065 | ||
|
|
e35ffda0b3 | ||
|
|
d2671340a6 | ||
|
|
ecaf2f02f1 | ||
|
|
d4296f6f06 | ||
|
|
eb02a99c61 | ||
|
|
3f5546b2be | ||
|
|
345891edba | ||
|
|
821094ba72 | ||
|
|
7e0c2c47ab | ||
|
|
7b774482e7 | ||
|
|
27ecc22649 | ||
|
|
7f807f394f | ||
|
|
9520c62049 | ||
|
|
ce82a1be0d | ||
|
|
c7a76bb056 | ||
|
|
8b984641f2 | ||
|
|
5b591829b6 | ||
|
|
9d497c6afe | ||
|
|
89dbb6a0da | ||
|
|
2d15958711 | ||
|
|
bbc1705fa9 | ||
|
|
87ade5f0eb | ||
|
|
a33e7edcec | ||
|
|
0fea86afe3 | ||
|
|
3a4cd2ad8d | ||
|
|
82c472228e | ||
|
|
0089e65008 | ||
|
|
2492fd30e5 | ||
|
|
190e41f840 | ||
|
|
5d25d626b1 | ||
|
|
e473a4d2f3 | ||
|
|
7e85964080 | ||
|
|
9bd2fdb8e2 | ||
|
|
3b5c75ef3d | ||
|
|
3b183df9cc | ||
|
|
7cd45b297e | ||
|
|
9362603f05 | ||
|
|
980659a2ca | ||
|
|
041d1e14d6 | ||
|
|
21aa79f463 | ||
|
|
28933f9d30 | ||
|
|
5b2342d377 | ||
|
|
31075a8897 | ||
|
|
2d435c7fb5 | ||
|
|
0151316183 | ||
|
|
aa1ee9e7a2 | ||
|
|
f61e0a34ea | ||
|
|
e35458bc08 | ||
|
|
e96b67a70f | ||
|
|
8ae35102c4 | ||
|
|
fc0b4b0d31 | ||
|
|
619d1704ae | ||
|
|
d5f1590d5c | ||
|
|
fca7930dfa | ||
|
|
e9c0f1f658 | ||
|
|
279c95b5b3 | ||
|
|
61312fe66f | ||
|
|
149e0c8d10 | ||
|
|
0f4bf77bd3 | ||
|
|
ecb0dc4c90 | ||
|
|
a6742a1c12 | ||
|
|
e209d60713 | ||
|
|
91d62e9abd | ||
|
|
3e17db4882 | ||
|
|
ef2d7cb44b | ||
|
|
e948b9c6e3 | ||
|
|
afb65c6cf3 | ||
|
|
5be92d03b0 | ||
|
|
3bc349b53b | ||
|
|
ad39e7ec01 | ||
|
|
98b7fc0195 | ||
|
|
f9797871aa | ||
|
|
d718abd968 | ||
|
|
190bb785d8 | ||
|
|
5c0eae136b | ||
|
|
5220c1d692 | ||
|
|
84a9f092dc | ||
|
|
4fc8d83f5f | ||
|
|
8fc4abedf1 | ||
|
|
c216179af4 | ||
|
|
4c51f2b578 | ||
|
|
2b026784a8 | ||
|
|
3c1519117a | ||
|
|
602d28a210 | ||
|
|
404794e97a | ||
|
|
3b6420c0a5 | ||
|
|
62da1e7458 | ||
|
|
bf24b64e83 | ||
|
|
d28b70d152 | ||
|
|
231b23acbb | ||
|
|
3529162405 | ||
|
|
d237828ebc | ||
|
|
c50d3ed075 | ||
|
|
61288cbdef | ||
|
|
42100cdead | ||
|
|
4bb7400529 | ||
|
|
303172d220 | ||
|
|
0f340f0572 | ||
|
|
f063773b83 | ||
|
|
e9b9e287c1 | ||
|
|
030303fa99 | ||
|
|
5f8f512719 | ||
|
|
6bc9e46bf1 | ||
|
|
db11750cfa | ||
|
|
1f47a77b29 | ||
|
|
0757a9b941 | ||
|
|
83ae98c6c6 | ||
|
|
2658da7604 | ||
|
|
c16e5dfbc8 | ||
|
|
7de2e03258 | ||
|
|
ab71241c88 | ||
|
|
e9625c5bc6 | ||
|
|
18a6467c8c | ||
|
|
7b368e7f94 | ||
|
|
34365e4b03 | ||
|
|
60bd22620a | ||
|
|
6e4d4a9b51 | ||
|
|
c68758b621 | ||
|
|
73a894170b | ||
|
|
0aafd77fa4 | ||
|
|
9f96f8a5c5 | ||
|
|
01aaad7442 | ||
|
|
610a55388b | ||
|
|
5107d66b2e | ||
|
|
4e1ece2e44 | ||
|
|
28dd47d4d4 | ||
|
|
147b2a546e | ||
|
|
95b5036a59 | ||
|
|
263616202b | ||
|
|
c9dd4022f4 | ||
|
|
f2d234a4dd | ||
|
|
2a4ee0d221 | ||
|
|
f88f9bed00 | ||
|
|
9aa6e4357a | ||
|
|
7b057f53fd | ||
|
|
2dd9bfc5d9 | ||
|
|
0ff0a994ad | ||
|
|
e8b57d1e84 | ||
|
|
7fd490732a | ||
|
|
0c762f1c92 | ||
|
|
15bf9389ce | ||
|
|
2618e4caae | ||
|
|
08e57f916c | ||
|
|
6f2d5f0562 | ||
|
|
82bf8edff3 | ||
|
|
cd492a3ba8 | ||
|
|
50aac1a37d | ||
|
|
574db1a6fd | ||
|
|
7246255416 | ||
|
|
f763d1b1bb | ||
|
|
48cd1292e2 | ||
|
|
f718415bc7 | ||
|
|
2715d7f948 | ||
|
|
3db1f3dd81 | ||
|
|
7da9c95bcf | ||
|
|
95ae389e17 | ||
|
|
91735102ac | ||
|
|
248967e300 | ||
|
|
cf2051764c | ||
|
|
3ce2a3991b | ||
|
|
195b63f99c | ||
|
|
1deac31eba | ||
|
|
bf468fb589 | ||
|
|
ca4506b46a | ||
|
|
727d798d68 | ||
|
|
3917d73b36 | ||
|
|
812c5ace75 | ||
|
|
c3a02c3e54 | ||
|
|
565c5b3dc3 | ||
|
|
11e8066ef9 | ||
|
|
92b9ae5c5d | ||
|
|
a47c142a88 | ||
|
|
eccf4fb7ee | ||
|
|
9f260b5d66 | ||
|
|
0452976711 | ||
|
|
94d820b4cb | ||
|
|
1cfb436a2f | ||
|
|
fae7db8a31 | ||
|
|
0a898655e8 | ||
|
|
48043f87b6 | ||
|
|
b7b126ee41 | ||
|
|
91c8f81d72 | ||
|
|
74476609c3 | ||
|
|
6c62d84232 | ||
|
|
c93bd31336 | ||
|
|
933e6c9d16 | ||
|
|
da24fbbc00 | ||
|
|
367648d24a | ||
|
|
bd3a59ad41 | ||
|
|
c0245cc591 | ||
|
|
13c696f37f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -46,3 +46,4 @@ CHANGES.dist
|
||||
.cproject
|
||||
.settings
|
||||
/[0-9]*.patch
|
||||
.dirstamp
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
###########################################################################
|
||||
# cURL/libcurl CMake script
|
||||
# by Tetetest and Sukender (Benoit Neil)
|
||||
|
||||
@@ -23,6 +44,8 @@ include(Utilities)
|
||||
|
||||
project( CURL C )
|
||||
|
||||
message(WARNING "the curl cmake build system is poorly maintained. Be aware")
|
||||
|
||||
file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
|
||||
string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)"
|
||||
LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS})
|
||||
|
||||
2
COPYING
2
COPYING
@@ -1,6 +1,6 @@
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright (c) 1996 - 2013, Daniel Stenberg, <daniel@haxx.se>.
|
||||
Copyright (c) 1996 - 2014, Daniel Stenberg, <daniel@haxx.se>.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
@@ -136,12 +136,36 @@ vc-zlib: $(VC)
|
||||
cd ..\src
|
||||
nmake /f Makefile.$(VC) cfg=release-zlib
|
||||
|
||||
vc-x64-zlib: $(VC)
|
||||
cd lib
|
||||
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-zlib
|
||||
cd ..\src
|
||||
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-zlib
|
||||
|
||||
vc-ssl: $(VC)
|
||||
cd lib
|
||||
nmake /f Makefile.$(VC) cfg=release-ssl
|
||||
cd ..\src
|
||||
nmake /f Makefile.$(VC) cfg=release-ssl
|
||||
|
||||
vc-winssl: $(VC)
|
||||
cd lib
|
||||
nmake /f Makefile.$(VC) cfg=release-winssl WINDOWS_SSPI=1
|
||||
cd ..\src
|
||||
nmake /f Makefile.$(VC) cfg=release-winssl WINDOWS_SSPI=1
|
||||
|
||||
vc-x64-ssl: $(VC)
|
||||
cd lib
|
||||
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-ssl
|
||||
cd ..\src
|
||||
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-ssl
|
||||
|
||||
vc-x64-winssl: $(VC)
|
||||
cd lib
|
||||
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-winssl WINDOWS_SSPI=1
|
||||
cd ..\src
|
||||
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-winssl WINDOWS_SSPI=1
|
||||
|
||||
vc-ssl-zlib: $(VC)
|
||||
cd lib
|
||||
nmake /f Makefile.$(VC) cfg=release-ssl-zlib
|
||||
@@ -266,6 +290,18 @@ linux-ssl: ssl
|
||||
# We don't need to do anything for vc6.
|
||||
vc6:
|
||||
|
||||
# VC7 makefiles are for use with VS.NET and VS.NET 2003
|
||||
vc7: lib/Makefile.vc7 src/Makefile.vc7
|
||||
|
||||
lib/Makefile.vc7: lib/Makefile.vc6
|
||||
@echo "generate $@"
|
||||
@sed -e "s/VC6/VC7/g" lib/Makefile.vc6 > lib/Makefile.vc7
|
||||
|
||||
src/Makefile.vc7: src/Makefile.vc6
|
||||
@echo "generate $@"
|
||||
@sed -e "s/VC6/VC7/g" src/Makefile.vc6 > src/Makefile.vc7
|
||||
|
||||
# VC8 makefiles are for use with VS2005
|
||||
vc8: lib/Makefile.vc8 src/Makefile.vc8
|
||||
|
||||
lib/Makefile.vc8: lib/Makefile.vc6
|
||||
@@ -298,6 +334,28 @@ src/Makefile.vc10: src/Makefile.vc6
|
||||
@echo "generate $@"
|
||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/ws2_32.lib/ws2_32.lib/g" -e "s/vc6/vc10/g" -e "s/VC6/VC10/g" src/Makefile.vc6 > src/Makefile.vc10
|
||||
|
||||
# VC11 makefiles are for use with VS2012
|
||||
vc11: lib/Makefile.vc11 src/Makefile.vc11
|
||||
|
||||
lib/Makefile.vc11: lib/Makefile.vc6
|
||||
@echo "generate $@"
|
||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/ws2_32.lib/ws2_32.lib/g" -e "s/vc6/vc11/g" -e "s/VC6/VC11/g" lib/Makefile.vc6 > lib/Makefile.vc11
|
||||
|
||||
src/Makefile.vc11: src/Makefile.vc6
|
||||
@echo "generate $@"
|
||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/ws2_32.lib/ws2_32.lib/g" -e "s/vc6/vc11/g" -e "s/VC6/VC11/g" src/Makefile.vc6 > src/Makefile.vc11
|
||||
|
||||
# VC12 makefiles are for use with VS2013
|
||||
vc12: lib/Makefile.vc12 src/Makefile.vc12
|
||||
|
||||
lib/Makefile.vc12: lib/Makefile.vc6
|
||||
@echo "generate $@"
|
||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/ws2_32.lib/ws2_32.lib/g" -e "s/vc6/vc12/g" -e "s/VC6/VC12/g" lib/Makefile.vc6 > lib/Makefile.vc12
|
||||
|
||||
src/Makefile.vc12: src/Makefile.vc6
|
||||
@echo "generate $@"
|
||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/ws2_32.lib/ws2_32.lib/g" -e "s/vc6/vc12/g" -e "s/VC6/VC12/g" src/Makefile.vc6 > src/Makefile.vc12
|
||||
|
||||
ca-bundle: lib/mk-ca-bundle.pl
|
||||
@echo "generate a fresh ca-bundle.crt"
|
||||
@perl $< -b -l -u lib/ca-bundle.crt
|
||||
|
||||
175
RELEASE-NOTES
175
RELEASE-NOTES
@@ -1,71 +1,68 @@
|
||||
Curl and libcurl 7.34.0
|
||||
Curl and libcurl 7.35.0
|
||||
|
||||
Public curl releases: 136
|
||||
Public curl releases: 137
|
||||
Command line options: 161
|
||||
curl_easy_setopt() options: 206
|
||||
Public functions in libcurl: 58
|
||||
Known libcurl bindings: 42
|
||||
Contributors: 1104
|
||||
|
||||
This release includes the following security fix:
|
||||
o gtls: respect *VERIFYHOST independently of *VERIFYPEER [26]
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o SSL: protocol version can be specified more precisely [1]
|
||||
o imap/pop3/smtp: Added graceful cancellation of SASL authentication
|
||||
o Add "Happy Eyeballs" for IPv4/IPv6 dual connect attempts
|
||||
o base64: Added validation of base64 input strings when decoding [8]
|
||||
o curl_easy_setopt: Added the ability to set the login options separately
|
||||
o smtp: Added support for additional SMTP commands
|
||||
o curl_easy_getinfo: Added CURLINFO_TLS_SESSION for accessing TLS internals
|
||||
o nss: allow to use TLS > 1.0 if built against recent NSS [18]
|
||||
o SECURITY: added this document to describe our security processes [22]
|
||||
o parseconfig: warn if unquoted white spaces are detected
|
||||
o imap/pop3/smtp: Added support for SASL authentication downgrades
|
||||
o imap/pop3/smtp: Extended the login options to support multiple auth mechanisms
|
||||
o TheArtOfHttpScripting: major update, converted layout and more
|
||||
o mprintf: Added support for I, I32 and I64 size specifiers
|
||||
o makefile: Added support for VC7, VC11 and VC12
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o darwinssl: un-break iOS build after PKCS#12 feature added
|
||||
o tool: use XFERFUNCTION to save some casts [2]
|
||||
o usercertinmem: fix memory leaks
|
||||
o ssh: Handle successful SSH_USERAUTH_NONE [3]
|
||||
o NSS: acknowledge the --no-sessionid/CURLOPT_SSL_SESSIONID_CACHE option [4]
|
||||
o test906: Fixed failing test on some platforms [5]
|
||||
o sasl: initialize NSS before using NTLM crypto
|
||||
o sasl: Fixed memory leak in OAUTH2 message creation
|
||||
o imap/pop3/smtp: Fixed QUIT / LOGOUT being sent when SSL connect fails
|
||||
o cmake: unbreak for non-Windows platforms [6]
|
||||
o ssh: initialize per-handle data in ssh_connect()
|
||||
o glob: fix broken URLs
|
||||
o configure: check for long long when building with cyassl
|
||||
o CURLOPT_RESOLVE: mention they don't time-out [7]
|
||||
o docs/examples/httpput.c: fix build for MSVC
|
||||
o FTP: make the data connection work when going through proxy
|
||||
o NSS: support for CERTINFO feature
|
||||
o curl_multi_wait: accept 0 from multi_timeout() as valid timeout
|
||||
o glob_range: pass the closing bracket for a-z ranges
|
||||
o tool_help: Updated --list-only description to include POP3
|
||||
o Curl_ssl_push_certinfo_len: don't %.*s non-zero-terminated string [9]
|
||||
o cmake: fix Windows build with IPv6 support [10]
|
||||
o ares: Fixed compilation under Visual Studio 2012 [11]
|
||||
o curl_easy_setopt.3: clarify CURLOPT_SSL_VERIFYHOST documentation [12]
|
||||
o curl.1: mention that -O does no URL decoding [13]
|
||||
o darwinssl: PKCS#12 import feature now requires Lion or later [14]
|
||||
o darwinssl: check for SSLSetSessionOption() presence when toggling BEAST
|
||||
o configure: Fix test with -Werror=implicit-function-declaration [15]
|
||||
o sigpipe: factor out sigpipe_reset from easy.c
|
||||
o curl_multi_cleanup: ignore SIGPIPE
|
||||
o globbing: curl glob counter mismatch with {} list use [16]
|
||||
o parseconfig: dash options can't specified with colon or equals [17]
|
||||
o digest: fix CURLAUTH_DIGEST_IE [19]
|
||||
o curl.h: <sys/select.h> for OpenBSD [20]
|
||||
o darwinssl: Fix #if 10.6.0 for SecKeychainSearch
|
||||
o TFTP: fix return codes for connect timeout [21]
|
||||
o login options: remove the ;[options] support from CURLOPT_USERPWD [23]
|
||||
o imap: Fixed incorrect fallback to clear text authentication
|
||||
o parsedate: avoid integer overflow
|
||||
o curl.1: document -J doesn't %-decode [25]
|
||||
o multi: add timer inaccuracy margin to timeout/connecttimeout [24]
|
||||
o SECURITY ADVISORY: re-use of wrong HTTP NTLM connection [25]
|
||||
|
||||
o curl_easy_setopt: Fixed OAuth 2.0 Bearer option name [1]
|
||||
o pop3: Fixed APOP being determined by CAPA response rather than by timestamp
|
||||
o Curl_pp_readresp: zero terminate line [2]
|
||||
o FILE: don't wait due to CURLOPT_MAX_RECV_SPEED_LARGE [3]
|
||||
o docs: mention CURLOPT_MAX_RECV/SEND_SPEED_LARGE don't work for FILE://
|
||||
o pop3: Fixed auth preference not being honored when CAPA not supported
|
||||
o imap: Fixed auth preference not being honored when CAPABILITY not supported
|
||||
o threaded resolver: Use pthread_t * for curl_thread_t [4]
|
||||
o FILE: we don't support paused transfers using this protocol [5]
|
||||
o connect: Try all addresses in first connection attempt [6]
|
||||
o curl_easy_setopt.3: Added SMTP information to CURLOPT_INFILESIZE_LARGE
|
||||
o OpenSSL: Fix forcing SSLv3 connections [7]
|
||||
o openssl: allow explicit sslv2 selection [8]
|
||||
o FTP parselist: fix "total" parser [9]
|
||||
o conncache: fix possible dereference of null pointer
|
||||
o multi.c: fix possible dereference of null pointer
|
||||
o mk-ca-bundle: introduces -d and warns about using this script
|
||||
o ConnectionExists: fix NTLM check for new connection [10]
|
||||
o trynextip: fix build for non-IPV6 capable systems [11]
|
||||
o Curl_updateconninfo: don't do anything for UDP "connections" [12]
|
||||
o darwinssl: un-break Leopard build after PKCS#12 change [13]
|
||||
o threaded-resolver: never use NULL hints with getaddrinf [14]
|
||||
o multi_socket: remind app if timeout didn't run
|
||||
o OpenSSL: deselect weak ciphers by default [15]
|
||||
o error message: Sensible message on timeout when transfer size unknown [16]
|
||||
o curl_easy_setopt.3: mention how to unset CURLOPT_INFILESIZE*
|
||||
o win32: Fixed use of deprecated function 'GetVersionInfoEx' for VC12 [17]
|
||||
o configure: fix gssapi linking on HP-UX [18]
|
||||
o chunked-parser: abort on overflows, allow 64 bit chunks
|
||||
o chunked parsing: relax the CR strictness [19]
|
||||
o cookie: max-age fixes [20]
|
||||
o progress bar: always update when at 100%
|
||||
o progress bar: increase update frequency to 10Hz
|
||||
o tool: Fixed incorrect return code if command line parser runs out of memory
|
||||
o tool: Fixed incorrect return code if password prompting runs out of memory
|
||||
o HTTP POST: omit Content-Length if data size is unknown [21]
|
||||
o GnuTLS: disable insecure ciphers
|
||||
o GnuTLS: honor --slv2 and the --tlsv1[.N] switches
|
||||
o multi: Fixed a memory leak on OOM condition
|
||||
o netrc: Fixed a memory and file descriptor leak on OOM
|
||||
o getpass: fix password parsing from console [22]
|
||||
o TFTP: fix crash on time-out [23]
|
||||
o hostip: don't remove DNS entries that are in use [24]
|
||||
o tests: lots of tests fixed to pass the OOM torture tests
|
||||
|
||||
This release includes the following known bugs:
|
||||
|
||||
@@ -74,42 +71,40 @@ This release includes the following known bugs:
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Alessandro Ghedini, Andreas Rieke, Björn Stenberg, Chris Conlon,
|
||||
Christian Grothoff, Christian Weisgerber, Dave Reisner, David Walser,
|
||||
Dima Tisnek, Fabian Keil, Felix Yan, Gergely Nagy, Gisle Vanem,
|
||||
Ishan SinghLevett, James Dury, Javier Barroso, Jeff King, Kamil Dudka,
|
||||
Kim Vandry, Marcin Gryszkalis, Melissa Mears, Michael Osipov, Nick Zitzmann,
|
||||
Oliver Kuckertz, Patrick Monnerat, Paul Donohue, Paul Marks, Romulo A. Ceccon,
|
||||
Rémy Léone, Sergey Tatarincev, Steve Holme, Tomas Hoger, Tyler Hall,
|
||||
Yaakov Selkowitz, Eric Lubin, Petr Bahula, He Qin, Marc Deslauriers
|
||||
Abram Pousada, Barry Abrahamson, Björn Stenberg, Cédric Deltheil, Chen Prog,
|
||||
Christian Weisgerber, Colin Hogben, Dan Fandrich, Daniel Stenberg,
|
||||
Fabian Frank, Glenn Sheridan, Guenter Knauf, He Qin, Iida Yosiaki,
|
||||
Jeff Hodges, Justin Maggard, Leif W, Luke Dashjr, Maks Naumov, Marc Hoersken,
|
||||
Michael Osipov, Michal Górny and Anthony G. Basile, Mohammad AlSaleh,
|
||||
Nick Zitzmann, Paras Sethia, Petr Novak, Priyanka Shah, Romulo A. Ceccon,
|
||||
Steve Holme, Tobias Markus, Viktor Szakáts, Yehezkel Horowitz, Yingwei Liu
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
||||
References to bug reports and discussions on issues:
|
||||
|
||||
[1] = https://github.com/bagder/curl/pull/79
|
||||
[2] = http://curl.haxx.se/mail/lib-2013-10/0089.html
|
||||
[3] = http://curl.haxx.se/mail/lib-2013-10/0096.html
|
||||
[4] = http://curl.haxx.se/mail/lib-2013-10/0113.html
|
||||
[5] = http://sourceforge.net/p/curl/bugs/1291
|
||||
[6] = http://sourceforge.net/p/curl/bugs/1292
|
||||
[7] = http://curl.haxx.se/mail/lib-2013-10/0062.html
|
||||
[8] = http://curl.haxx.se/mail/lib-2013-10/0242.html
|
||||
[9] = http://curl.haxx.se/bug/view.cgi?id=1295
|
||||
[10] = http://sourceforge.net/p/curl/bugs/1064
|
||||
[11] = http://curl.haxx.se/mail/lib-2013-11/0057.html
|
||||
[12] = https://github.com/bagder/curl/pull/83
|
||||
[13] = http://sourceforge.net/p/curl/bugs/1299
|
||||
[14] = http://curl.haxx.se/mail/lib-2013-11/0076.html
|
||||
[15] = http://curl.haxx.se/bug/view.cgi?id=1304
|
||||
[16] = http://curl.haxx.se/bug/view.cgi?id=1305
|
||||
[17] = http://curl.haxx.se/bug/view.cgi?id=1297
|
||||
[18] = http://curl.haxx.se/mail/lib-2013-11/0162.html
|
||||
[19] = http://curl.haxx.se/bug/view.cgi?id=1308
|
||||
[20] = http://curl.haxx.se/mail/lib-2013-12/0017.html
|
||||
[21] = http://curl.haxx.se/bug/view.cgi?id=1310
|
||||
[22] = http://curl.haxx.se/dev/security.html
|
||||
[23] = http://curl.haxx.se/bug/view.cgi?id=1311
|
||||
[24] = http://curl.haxx.se/bug/view.cgi?id=1298
|
||||
[25] = http://curl.haxx.se/bug/view.cgi?id=1294
|
||||
[26] = http://curl.haxx.se/docs/adv_20131217.html
|
||||
[1] = http://curl.haxx.se/bug/view.cgi?id=1313
|
||||
[2] = http://curl.haxx.se/mail/lib-2013-12/0113.html
|
||||
[3] = http://curl.haxx.se/bug/view.cgi?id=1312
|
||||
[4] = http://curl.haxx.se/bug/view.cgi?id=1314
|
||||
[5] = http://curl.haxx.se/bug/view.cgi?id=1286
|
||||
[6] = http://curl.haxx.se/bug/view.cgi?id=1315
|
||||
[7] = http://curl.haxx.se/mail/lib-2014-01/0002.html
|
||||
[8] = http://curl.haxx.se/mail/lib-2014-01/0013.html
|
||||
[9] = http://curl.haxx.se/mail/lib-2014-01/0019.html
|
||||
[10] = http://curl.haxx.se/mail/lib-2014-01/0046.html
|
||||
[11] = http://curl.haxx.se/bug/view.cgi?id=1322
|
||||
[12] = http://curl.haxx.se/mail/archive-2014-01/0016.html
|
||||
[13] = http://curl.haxx.se/mail/lib-2013-12/0150.html
|
||||
[14] = http://curl.haxx.se/mail/lib-2014-01/0061.html
|
||||
[15] = http://curl.haxx.se/bug/view.cgi?id=1323
|
||||
[16] = http://curl.haxx.se/mail/lib-2014-01/0115.html
|
||||
[17] = http://curl.haxx.se/mail/lib-2014-01/0134.html
|
||||
[18] = http://curl.haxx.se/bug/view.cgi?id=1321
|
||||
[19] = http://curl.haxx.se/mail/archive-2014-01/0000.html
|
||||
[20] = http://curl.haxx.se/mail/lib-2014-01/0130.html
|
||||
[21] = http://curl.haxx.se/mail/lib-2014-01/0103.html
|
||||
[22] = https://github.com/bagder/curl/pull/87
|
||||
[23] = http://curl.haxx.se/mail/lib-2014-01/0246.html
|
||||
[24] = http://curl.haxx.se/bug/view.cgi?id=1327
|
||||
[25] = http://curl.haxx.se/docs/adv_20140129.html
|
||||
|
||||
19
configure.ac
19
configure.ac
@@ -5,7 +5,7 @@
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
@@ -31,7 +31,7 @@ XC_OVR_ZZ60
|
||||
CURL_OVERRIDE_AUTOCONF
|
||||
|
||||
dnl configure script copyright
|
||||
AC_COPYRIGHT([Copyright (c) 1998 - 2013 Daniel Stenberg, <daniel@haxx.se>
|
||||
AC_COPYRIGHT([Copyright (c) 1998 - 2014 Daniel Stenberg, <daniel@haxx.se>
|
||||
This configure script may be copied, distributed and modified under the
|
||||
terms of the curl license; see COPYING for more details])
|
||||
|
||||
@@ -1294,6 +1294,12 @@ if test x"$want_gss" = xyes; then
|
||||
*-*-darwin*)
|
||||
LIBS="-lgssapi_krb5 -lresolv $LIBS"
|
||||
;;
|
||||
*-hp-hpux*)
|
||||
if test "$GSSAPI_ROOT" != "yes"; then
|
||||
LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
|
||||
fi
|
||||
LIBS="-lgss $LIBS"
|
||||
;;
|
||||
*)
|
||||
if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
|
||||
dnl krb5-config doesn't have --libs-only-L or similar, put everything
|
||||
@@ -1310,7 +1316,14 @@ if test x"$want_gss" = xyes; then
|
||||
esac
|
||||
else
|
||||
LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
|
||||
LIBS="-lgssapi $LIBS"
|
||||
case $host in
|
||||
*-hp-hpux*)
|
||||
LIBS="-lgss $LIBS"
|
||||
;;
|
||||
*)
|
||||
LIBS="-lgssapi $LIBS"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
# Copyright (C) 2013-2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
@@ -37,10 +37,29 @@ fi
|
||||
# cut off spaces first and last on the line
|
||||
# only count names with a space (ie more than one word)
|
||||
# sort all unique names
|
||||
# awk them into RELEASE-NOTES format
|
||||
git log $start..HEAD | \
|
||||
egrep '(Author|Commit|by):' | \
|
||||
cut -d: -f2- | \
|
||||
cut '-d<' -f1 | \
|
||||
sed -e 's/^ //' -e 's/ $//g' | \
|
||||
grep ' ' | \
|
||||
sort -u
|
||||
sort -u |
|
||||
awk '{
|
||||
num++;
|
||||
n = sprintf("%s%s%s,", n, length(n)?" ":"", $0);
|
||||
#print n;
|
||||
if(length(n) > 78) {
|
||||
printf(" %s\n", p);
|
||||
n=sprintf("%s,", $0);
|
||||
}
|
||||
p=n;
|
||||
|
||||
}
|
||||
|
||||
END {
|
||||
printf(" %s\n", p);
|
||||
printf(" (%d contributors)\n", num);
|
||||
}
|
||||
|
||||
'
|
||||
|
||||
2
docs/FAQ
2
docs/FAQ
@@ -422,7 +422,7 @@ FAQ
|
||||
|
||||
curl can be built to use one of the following SSL alternatives: OpenSSL,
|
||||
GnuTLS, yassl, NSS, PolarSSL, axTLS, Secure Transport (native iOS/OS X),
|
||||
schannel (native Windows) or qssl (native IBM i). They all have their pros
|
||||
WinSSL (native Windows) or qssl (native IBM i). They all have their pros
|
||||
and cons, and we try to maintain a comparison of them here:
|
||||
http://curl.haxx.se/docs/ssl-compared.html
|
||||
|
||||
|
||||
@@ -176,14 +176,14 @@ IMAPS (*1)
|
||||
FOOTNOTES
|
||||
=========
|
||||
|
||||
*1 = requires OpenSSL, GnuTLS, NSS, yassl, axTLS, PolarSSL, schannel (native
|
||||
*1 = requires OpenSSL, GnuTLS, NSS, yassl, axTLS, PolarSSL, WinSSL (native
|
||||
Windows), Secure Transport (native iOS/OS X) or qssl (native IBM i)
|
||||
*2 = requires OpenLDAP
|
||||
*3 = requires a GSSAPI-compliant library, such as Heimdal or similar
|
||||
*4 = requires FBopenssl
|
||||
*5 = requires a krb4 library, such as the MIT one or similar
|
||||
*6 = requires c-ares
|
||||
*7 = requires OpenSSL, NSS, qssl, schannel or Secure Transport; GnuTLS, for
|
||||
*7 = requires OpenSSL, NSS, qssl, WinSSL or Secure Transport; GnuTLS, for
|
||||
example, only supports SSLv3 and TLSv1
|
||||
*8 = requires libssh2
|
||||
*9 = requires OpenSSL, GnuTLS, NSS, yassl, Secure Transport or SSPI (native
|
||||
|
||||
@@ -993,6 +993,7 @@ REDUCING SIZE
|
||||
--disable-verbose (eliminates debugging strings and error code strings)
|
||||
--enable-hidden-symbols (eliminates unneeded symbols in the shared library)
|
||||
--without-libidn (disables support for the libidn DNS library)
|
||||
--without-librtmp (disables support for RTMP)
|
||||
--without-ssl (disables support for SSL/TLS)
|
||||
--without-zlib (disables support for on-the-fly decompression)
|
||||
|
||||
@@ -1011,9 +1012,9 @@ REDUCING SIZE
|
||||
.comment section).
|
||||
|
||||
Using these techniques it is possible to create a basic HTTP-only shared
|
||||
libcurl library for i386 Linux platforms that is only 106 KiB in size, and
|
||||
an FTP-only library that is 108 KiB in size (as of libcurl version 7.27.0,
|
||||
using gcc 4.6.3).
|
||||
libcurl library for i386 Linux platforms that is only 114 KiB in size, and
|
||||
an FTP-only library that is 115 KiB in size (as of libcurl version 7.34.1,
|
||||
using gcc 4.8.2).
|
||||
|
||||
You may find that statically linking libcurl to your application will
|
||||
result in a lower total size than dynamically linking.
|
||||
|
||||
@@ -337,10 +337,10 @@ SSL libraries
|
||||
in future libcurl versions.
|
||||
|
||||
To deal with this internally in the best way possible, we have a generic SSL
|
||||
function API as provided by the sslgen.[ch] system, and they are the only SSL
|
||||
functions we must use from within libcurl. sslgen is then crafted to use the
|
||||
function API as provided by the vtls.[ch] system, and they are the only SSL
|
||||
functions we must use from within libcurl. vtls is then crafted to use the
|
||||
appropriate lower-level function calls to whatever SSL library that is in
|
||||
use.
|
||||
use. For example vtls/openssl.[ch] for the OpenSSL library.
|
||||
|
||||
Library Symbols
|
||||
===============
|
||||
|
||||
@@ -69,12 +69,12 @@ may have been fixed since this was written!
|
||||
option as for all other operating systems.
|
||||
|
||||
75. NTLM authentication involving unicode user name or password only works
|
||||
properly if built with UNICODE defined together with the schannel/winssl
|
||||
properly if built with UNICODE defined together with the WinSSL/schannel
|
||||
backend. The original problem was mentioned in:
|
||||
http://curl.haxx.se/mail/lib-2009-10/0024.html
|
||||
http://curl.haxx.se/bug/view.cgi?id=896
|
||||
|
||||
The schannel version verified to work as mentioned in
|
||||
The WinSSL/schannel version verified to work as mentioned in
|
||||
http://curl.haxx.se/mail/lib-2012-07/0073.html
|
||||
|
||||
73. if a connection is made to a FTP server but the server then just never
|
||||
|
||||
@@ -37,7 +37,7 @@ EXTRA_DIST = MANUAL BUGS CONTRIBUTE FAQ FEATURES INTERNALS SSLCERTS \
|
||||
README.win32 RESOURCES TODO TheArtOfHttpScripting THANKS VERSIONS \
|
||||
KNOWN_BUGS BINDINGS $(man_MANS) $(HTMLPAGES) HISTORY INSTALL \
|
||||
$(PDFPAGES) LICENSE-MIXING README.netware DISTRO-DILEMMA INSTALL.devcpp \
|
||||
MAIL-ETIQUETTE HTTP-COOKIES LIBCURL-STRUCTS SECURITY
|
||||
MAIL-ETIQUETTE HTTP-COOKIES LIBCURL-STRUCTS SECURITY RELEASE-PROCEDURE
|
||||
|
||||
MAN2HTML= roffit < $< >$@
|
||||
|
||||
|
||||
53
docs/RELEASE-PROCEDURE
Normal file
53
docs/RELEASE-PROCEDURE
Normal file
@@ -0,0 +1,53 @@
|
||||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
curl release procedure - how to do a release
|
||||
============================================
|
||||
|
||||
[in the source code repo]
|
||||
|
||||
- edit RELEASE-NOTES to be accurate
|
||||
|
||||
- update docs/THANKS
|
||||
|
||||
- make sure all relevant changes are committed on the master branch
|
||||
|
||||
- tag the git repo in this style: 'git tag -a curl-7_34_0'. -a annotates the
|
||||
tag and we use underscores instead of dots in the version number.
|
||||
|
||||
- run "./maketgz 7.34.0" to build the release tarballs. It is important that
|
||||
you run this on a machine with the correct set of autotools etc installed
|
||||
as this is what then will be shipped and used by most users on *nix like
|
||||
systems.
|
||||
|
||||
- push the git commits and the new tag
|
||||
|
||||
- gpg sign the 4 tarballs as maketgz suggests
|
||||
|
||||
- upload the 8 resulting files to the primary download directory
|
||||
|
||||
[data in the curl-www repo]
|
||||
|
||||
- edit Makefile (version number and date),
|
||||
_newslog.html (announce the new release) and
|
||||
_changes.html (insert changes+bugfixes from RELEASE-NOTES)
|
||||
|
||||
- commit all local changes
|
||||
|
||||
- tag the repo with the same tag as used for the source repo
|
||||
|
||||
- make sure all relevant changes are committed and pushed on the master branch
|
||||
|
||||
(the web site then updates its contents automatically)
|
||||
|
||||
[inform]
|
||||
|
||||
- send an email to curl-users, curl-announce and curl-library. Insert the
|
||||
RELEASE-NOTES into the mail.
|
||||
|
||||
[celebrate]
|
||||
|
||||
- suitable beverage intake is encouraged for the festivities
|
||||
39
docs/TODO
39
docs/TODO
@@ -17,6 +17,8 @@
|
||||
1.4 signal-based resolver timeouts
|
||||
1.5 get rid of PATH_MAX
|
||||
1.6 Modified buffer size approach
|
||||
1.7 Detect when called from witin callbacks
|
||||
1.8 Allow SSL (HTTPS) to proxy
|
||||
|
||||
2. libcurl - multi interface
|
||||
2.1 More non-blocking
|
||||
@@ -30,8 +32,7 @@
|
||||
4.2 Alter passive/active on failure and retry
|
||||
4.3 Earlier bad letter detection
|
||||
4.4 REST for large files
|
||||
4.5 FTP proxy support
|
||||
4.6 ASCII support
|
||||
4.5 ASCII support
|
||||
|
||||
5. HTTP
|
||||
5.1 Better persistency for HTTP 1.0
|
||||
@@ -70,9 +71,8 @@
|
||||
12.4 Cache OpenSSL contexts
|
||||
12.5 Export session ids
|
||||
12.6 Provide callback for cert verification
|
||||
12.7 Support other SSL libraries
|
||||
12.8 improve configure --with-ssl
|
||||
12.9 Support DANE
|
||||
12.7 improve configure --with-ssl
|
||||
12.8 Support DANE
|
||||
|
||||
13. GnuTLS
|
||||
13.1 SSL engine stuff
|
||||
@@ -175,6 +175,18 @@
|
||||
Dynamically allocate buffer size depending on protocol in use in combination
|
||||
with freeing it after each individual transfer? Other suggestions?
|
||||
|
||||
1.7 Detect when called from witin callbacks
|
||||
|
||||
We should set a state variable before calling callbacks, so that we
|
||||
subsequently can add code within libcurl that returns error if called within
|
||||
callbacks for when that's not supported.
|
||||
|
||||
1.8 Allow SSL (HTTPS) to proxy
|
||||
|
||||
To prevent local users from snooping on your traffic to the proxy. Supported
|
||||
by Chrome already:
|
||||
http://www.chromium.org/developers/design-documents/secure-web-proxy
|
||||
|
||||
|
||||
2. libcurl - multi interface
|
||||
|
||||
@@ -231,13 +243,7 @@
|
||||
the server doesn't set the pointer to the requested index. The tricky
|
||||
(impossible?) part is to figure out if the server did the right thing or not.
|
||||
|
||||
4.5 FTP proxy support
|
||||
|
||||
Support the most common FTP proxies, Philip Newton provided a list allegedly
|
||||
from ncftp. This is not a subject without debate, and is probably not really
|
||||
suitable for libcurl. http://curl.haxx.se/mail/archive-2003-04/0126.html
|
||||
|
||||
4.6 ASCII support
|
||||
4.5 ASCII support
|
||||
|
||||
FTP ASCII transfers do not follow RFC959. They don't convert the data
|
||||
accordingly.
|
||||
@@ -409,17 +415,12 @@ to provide the data to send.
|
||||
certificate, but this doesn't seem to be exposed in the libcurl APIs. Could
|
||||
it be? There's so much that could be done if it were!
|
||||
|
||||
12.7 Support other SSL libraries
|
||||
|
||||
Make curl's SSL layer capable of using other free SSL libraries. Such as
|
||||
MatrixSSL (http://www.matrixssl.org/).
|
||||
|
||||
12.8 improve configure --with-ssl
|
||||
12.7 improve configure --with-ssl
|
||||
|
||||
make the configure --with-ssl option first check for OpenSSL, then GnuTLS,
|
||||
then NSS...
|
||||
|
||||
12.9 Support DANE
|
||||
12.8 Support DANE
|
||||
|
||||
DNS-Based Authentication of Named Entities (DANE) is a way to provide SSL
|
||||
keys and certs over DNS using DNSSEC as an alternative to the CA model.
|
||||
|
||||
@@ -1,16 +1,72 @@
|
||||
Online: http://curl.haxx.se/docs/httpscripting.html
|
||||
Date: Jan 19, 2011
|
||||
Updated: Dec 24, 2013 (http://curl.haxx.se/docs/httpscripting.html)
|
||||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
The Art Of Scripting HTTP Requests Using Curl
|
||||
=============================================
|
||||
|
||||
This document will assume that you're familiar with HTML and general
|
||||
networking.
|
||||
The Art Of Scripting HTTP Requests Using Curl
|
||||
|
||||
The possibility to write scripts is essential to make a good computer
|
||||
system. Unix' capability to be extended by shell scripts and various tools to
|
||||
run various automated commands and scripts is one reason why it has succeeded
|
||||
so well.
|
||||
1. HTTP Scripting
|
||||
1.1 Background
|
||||
1.2 The HTTP Protocol
|
||||
1.3 See the Protocol
|
||||
1.4 See the Timing
|
||||
1.5 See the Response
|
||||
2. URL
|
||||
2.1 Spec
|
||||
2.2 Host
|
||||
2.3 Port number
|
||||
2.4 User name and password
|
||||
2.5 Path part
|
||||
3. Fetch a page
|
||||
3.1 GET
|
||||
3.2 HEAD
|
||||
4. HTML forms
|
||||
4.1 Forms explained
|
||||
4.2 GET
|
||||
4.3 POST
|
||||
4.4 File Upload POST
|
||||
4.5 Hidden Fields
|
||||
4.6 Figure Out What A POST Looks Like
|
||||
5. HTTP upload
|
||||
5.1 PUT
|
||||
6. HTTP Authentication
|
||||
6.1 Basic Authentication
|
||||
6.2 Other Authentication
|
||||
6.3 Proxy Authentication
|
||||
6.4 Hiding credentials
|
||||
7. More HTTP Headers
|
||||
7.1 Referer
|
||||
7.2 User Agent
|
||||
8. Redirects
|
||||
8.1 Location header
|
||||
8.2 Other redirects
|
||||
9. Cookies
|
||||
9.1 Cookie Basics
|
||||
9.2 Cookie options
|
||||
10. HTTPS
|
||||
10.1 HTTPS is HTTP secure
|
||||
10.2 Certificates
|
||||
11. Custom Request Elements
|
||||
11.1 Modify method and headers
|
||||
11.2 More on changed methods
|
||||
12. Web Login
|
||||
12.1 Some login tricks
|
||||
13. Debug
|
||||
13.1 Some debug tricks
|
||||
14. References
|
||||
14.1 Standards
|
||||
14.2 Sites
|
||||
|
||||
==============================================================================
|
||||
|
||||
1. HTTP Scripting
|
||||
|
||||
1.1 Background
|
||||
|
||||
This document assumes that you're familiar with HTML and general networking.
|
||||
|
||||
The increasing amount of applications moving to the web has made "HTTP
|
||||
Scripting" more frequently requested and wanted. To be able to automatically
|
||||
@@ -27,7 +83,7 @@ Date: Jan 19, 2011
|
||||
to glue everything together using some kind of script language or repeated
|
||||
manual invokes.
|
||||
|
||||
1. The HTTP Protocol
|
||||
1.2 The HTTP Protocol
|
||||
|
||||
HTTP is the protocol used to fetch data from web servers. It is a very simple
|
||||
protocol that is built upon TCP/IP. The protocol also allows information to
|
||||
@@ -44,7 +100,7 @@ Date: Jan 19, 2011
|
||||
well), response headers and most often also a response body. The "body" part
|
||||
is the plain data you requested, like the actual HTML or the image etc.
|
||||
|
||||
1.1 See the Protocol
|
||||
1.3 See the Protocol
|
||||
|
||||
Using curl's option --verbose (-v as a short option) will display what kind
|
||||
of commands curl sends to the server, as well as a few other informational
|
||||
@@ -59,13 +115,88 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --trace-ascii debugdump.txt http://www.example.com/
|
||||
|
||||
1.4 See the Timing
|
||||
|
||||
Many times you may wonder what exactly is taking all the time, or you just
|
||||
want to know the amount of milliseconds between two points in a
|
||||
transfer. For those, and other similar situations, the --trace-time option
|
||||
is what you need. It'll prepend the time to each trace output line:
|
||||
|
||||
curl --trace-ascii d.txt --trace-time http://example.com/
|
||||
|
||||
1.5 See the Response
|
||||
|
||||
By default curl sends the response to stdout. You need to redirect it
|
||||
somewhere to avoid that, most often that is done with -o or -O.
|
||||
|
||||
2. URL
|
||||
|
||||
2.1 Spec
|
||||
|
||||
The Uniform Resource Locator format is how you specify the address of a
|
||||
particular resource on the Internet. You know these, you've seen URLs like
|
||||
http://curl.haxx.se or https://yourbank.com a million times.
|
||||
http://curl.haxx.se or https://yourbank.com a million times. RFC 3986 is the
|
||||
canonical spec.
|
||||
|
||||
3. GET a page
|
||||
2.2 Host
|
||||
|
||||
The host name is usually resolved using DNS or your /etc/hosts file to an IP
|
||||
address and that's what curl will communicate with. Alternatively you specify
|
||||
the IP address directly in the URL instead of a name.
|
||||
|
||||
For development and other trying out situation, you can point out a different
|
||||
IP address for a host name than what would otherwise be used, by using curl's
|
||||
--resolve option:
|
||||
|
||||
curl --resolve www.example.org:80:127.0.0.1 http://www.example.org/
|
||||
|
||||
2.3 Port number
|
||||
|
||||
Each protocol curl supports operate on a default port number, be it over TCP
|
||||
or in some cases UDP. Normally you don't have to take that into
|
||||
consideration, but at times you run test servers on other ports or
|
||||
similar. Then you can specify the port number in the URL with a colon and a
|
||||
number immediately following the host name. Like when doing HTTP to port
|
||||
1234:
|
||||
|
||||
curl http://www.example.org:1234/
|
||||
|
||||
The port number you specify in the URL is the number that the server uses to
|
||||
offer its services. Sometimes you may use a local proxy, and then you may
|
||||
need to specify that proxy's port number separate on what curl needs to
|
||||
connect to locally. Like when using a HTTP proxy on port 4321:
|
||||
|
||||
curl --proxy http://proxy.example.org:4321 http://remote.example.org/
|
||||
|
||||
2.4 User name and password
|
||||
|
||||
Some services are setup to require HTTP authentication and then you need to
|
||||
provide name and password which then is transfered to the remote site in
|
||||
various ways depending on the exact authentication protocol used.
|
||||
|
||||
You can opt to either insert the user and password in the URL or you can
|
||||
provide them separately:
|
||||
|
||||
curl http://user:password@example.org/
|
||||
|
||||
or
|
||||
|
||||
curl -u user:password http://example.org/
|
||||
|
||||
You need to pay attention that this kind of HTTP authentication is not what
|
||||
is usually done and requested by user-oriented web sites these days. They
|
||||
tend to use forms and cookies instead.
|
||||
|
||||
2.5 Path part
|
||||
|
||||
The path part is just sent off to the server to request that it sends back
|
||||
the associated response. The path is what is to the right side of the slash
|
||||
that follows the host name and possibly port number.
|
||||
|
||||
|
||||
3. Fetch a page
|
||||
|
||||
3.1 GET
|
||||
|
||||
The simplest and most common request/operation made using HTTP is to get a
|
||||
URL. The URL could itself refer to a web page, an image or a file. The client
|
||||
@@ -79,10 +210,23 @@ Date: Jan 19, 2011
|
||||
|
||||
All HTTP replies contain a set of response headers that are normally hidden,
|
||||
use curl's --include (-i) option to display them as well as the rest of the
|
||||
document. You can also ask the remote server for ONLY the headers by using
|
||||
the --head (-I) option (which will make curl issue a HEAD request).
|
||||
document.
|
||||
|
||||
4. Forms
|
||||
3.2 HEAD
|
||||
|
||||
You can ask the remote server for ONLY the headers by using the --head (-I)
|
||||
option which will make curl issue a HEAD request. In some special cases
|
||||
servers deny the HEAD method while others still work, which is a particular
|
||||
kind of annoyance.
|
||||
|
||||
The HEAD method is defined and made so that the server returns the headers
|
||||
exactly the way it would do for a GET, but without a body. It means that you
|
||||
may see a Content-Length: in the response headers, but there must not be an
|
||||
actual body in the HEAD response.
|
||||
|
||||
4. HTML forms
|
||||
|
||||
4.1 Forms explained
|
||||
|
||||
Forms are the general way a web site can present a HTML page with fields for
|
||||
the user to enter data in, and then press some kind of 'OK' or 'submit'
|
||||
@@ -95,7 +239,7 @@ Date: Jan 19, 2011
|
||||
Of course there has to be some kind of program in the server end to receive
|
||||
the data you send. You cannot just invent something out of the air.
|
||||
|
||||
4.1 GET
|
||||
4.2 GET
|
||||
|
||||
A GET-form uses the method GET, as specified in HTML like:
|
||||
|
||||
@@ -121,7 +265,7 @@ Date: Jan 19, 2011
|
||||
|
||||
curl "http://www.hotmail.com/when/junk.cgi?birthyear=1905&press=OK"
|
||||
|
||||
4.2 POST
|
||||
4.3 POST
|
||||
|
||||
The GET method makes all input field names get displayed in the URL field of
|
||||
your browser. That's generally a good thing when you want to be able to
|
||||
@@ -158,7 +302,7 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --data-urlencode "name=I am Daniel" http://www.example.com
|
||||
|
||||
4.3 File Upload POST
|
||||
4.4 File Upload POST
|
||||
|
||||
Back in late 1995 they defined an additional way to post data over HTTP. It
|
||||
is documented in the RFC 1867, why this method sometimes is referred to as
|
||||
@@ -179,7 +323,7 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --form upload=@localfilename --form press=OK [URL]
|
||||
|
||||
4.4 Hidden Fields
|
||||
4.5 Hidden Fields
|
||||
|
||||
A very common way for HTML based application to pass state information
|
||||
between pages is to add hidden fields to the forms. Hidden fields are
|
||||
@@ -200,7 +344,7 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --data "birthyear=1905&press=OK&person=daniel" [URL]
|
||||
|
||||
4.5 Figure Out What A POST Looks Like
|
||||
4.6 Figure Out What A POST Looks Like
|
||||
|
||||
When you're about fill in a form and send to a server by using curl instead
|
||||
of a browser, you're of course very interested in sending a POST exactly the
|
||||
@@ -213,7 +357,9 @@ Date: Jan 19, 2011
|
||||
You will then clearly see the data get appended to the URL, separated with a
|
||||
'?'-letter as GET forms are supposed to.
|
||||
|
||||
5. PUT
|
||||
5. HTTP upload
|
||||
|
||||
5.1 PUT
|
||||
|
||||
The perhaps best way to upload data to a HTTP server is to use PUT. Then
|
||||
again, this of course requires that someone put a program or script on the
|
||||
@@ -225,6 +371,8 @@ Date: Jan 19, 2011
|
||||
|
||||
6. HTTP Authentication
|
||||
|
||||
6.1 Basic Authentication
|
||||
|
||||
HTTP Authentication is the ability to tell the server your username and
|
||||
password so that it can verify that you're allowed to do the request you're
|
||||
doing. The Basic authentication used in HTTP (which is the type curl uses by
|
||||
@@ -236,10 +384,14 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --user name:password http://www.example.com
|
||||
|
||||
6.2 Other Authentication
|
||||
|
||||
The site might require a different authentication method (check the headers
|
||||
returned by the server), and then --ntlm, --digest, --negotiate or even
|
||||
--anyauth might be options that suit you.
|
||||
|
||||
6.3 Proxy Authentication
|
||||
|
||||
Sometimes your HTTP access is only available through the use of a HTTP
|
||||
proxy. This seems to be especially common at various companies. A HTTP proxy
|
||||
may require its own user and password to allow the client to get through to
|
||||
@@ -253,6 +405,8 @@ Date: Jan 19, 2011
|
||||
If you use any one these user+password options but leave out the password
|
||||
part, curl will prompt for the password interactively.
|
||||
|
||||
6.4 Hiding credentials
|
||||
|
||||
Do note that when a program is run, its parameters might be possible to see
|
||||
when listing the running processes of the system. Thus, other users may be
|
||||
able to watch your passwords if you pass them as plain command line
|
||||
@@ -262,7 +416,9 @@ Date: Jan 19, 2011
|
||||
many web sites will not use this concept when they provide logins etc. See
|
||||
the Web Login chapter further below for more details on that.
|
||||
|
||||
7. Referer
|
||||
7. More HTTP Headers
|
||||
|
||||
7.1 Referer
|
||||
|
||||
A HTTP request may include a 'referer' field (yes it is misspelled), which
|
||||
can be used to tell from which URL the client got to this particular
|
||||
@@ -276,7 +432,7 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --referer http://www.example.come http://www.example.com
|
||||
|
||||
8. User Agent
|
||||
7.2 User Agent
|
||||
|
||||
Very similar to the referer field, all HTTP requests may set the User-Agent
|
||||
field. It names what user agent (client) that is being used. Many
|
||||
@@ -298,7 +454,9 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" [URL]
|
||||
|
||||
9. Redirects
|
||||
8. Redirects
|
||||
|
||||
8.1 Location header
|
||||
|
||||
When a resource is requested from a server, the reply from the server may
|
||||
include a hint about where the browser should go next to find this page, or a
|
||||
@@ -318,7 +476,16 @@ Date: Jan 19, 2011
|
||||
only use POST in the first request, and then revert to GET in the following
|
||||
operations.
|
||||
|
||||
10. Cookies
|
||||
8.2 Other redirects
|
||||
|
||||
Browser typically support at least two other ways of redirects that curl
|
||||
doesn't: first the html may contain a meta refresh tag that asks the browser
|
||||
to load a specific URL after a set number of seconds, or it may use
|
||||
javascript to do it.
|
||||
|
||||
9. Cookies
|
||||
|
||||
9.1 Cookie Basics
|
||||
|
||||
The way the web browsers do "client side state control" is by using
|
||||
cookies. Cookies are just names with associated contents. The cookies are
|
||||
@@ -335,6 +502,8 @@ Date: Jan 19, 2011
|
||||
must be able to record and send back cookies the way the web application
|
||||
expects them. The same way browsers deal with them.
|
||||
|
||||
9.2 Cookie options
|
||||
|
||||
The simplest way to send a few cookies to the server when getting a page with
|
||||
curl is to add them on the command line like:
|
||||
|
||||
@@ -366,16 +535,18 @@ Date: Jan 19, 2011
|
||||
curl --cookie nada --location http://www.example.com
|
||||
|
||||
Curl has the ability to read and write cookie files that use the same file
|
||||
format that Netscape and Mozilla do. It is a convenient way to share cookies
|
||||
between browsers and automatic scripts. The --cookie (-b) switch
|
||||
automatically detects if a given file is such a cookie file and parses it,
|
||||
and by using the --cookie-jar (-c) option you'll make curl write a new cookie
|
||||
file at the end of an operation:
|
||||
format that Netscape and Mozilla once used. It is a convenient way to share
|
||||
cookies between scripts or invokes. The --cookie (-b) switch automatically
|
||||
detects if a given file is such a cookie file and parses it, and by using the
|
||||
--cookie-jar (-c) option you'll make curl write a new cookie file at the end
|
||||
of an operation:
|
||||
|
||||
curl --cookie cookies.txt --cookie-jar newcookies.txt \
|
||||
http://www.example.com
|
||||
|
||||
11. HTTPS
|
||||
10. HTTPS
|
||||
|
||||
10.1 HTTPS is HTTP secure
|
||||
|
||||
There are a few ways to do secure HTTP transfers. The by far most common
|
||||
protocol for doing this is what is generally known as HTTPS, HTTP over
|
||||
@@ -391,7 +562,7 @@ Date: Jan 19, 2011
|
||||
|
||||
curl https://secure.example.com
|
||||
|
||||
11.1 Certificates
|
||||
10.2 Certificates
|
||||
|
||||
In the HTTPS world, you use certificates to validate that you are the one
|
||||
you claim to be, as an addition to normal passwords. Curl supports client-
|
||||
@@ -413,7 +584,9 @@ Date: Jan 19, 2011
|
||||
|
||||
http://curl.haxx.se/docs/sslcerts.html
|
||||
|
||||
12. Custom Request Elements
|
||||
11. Custom Request Elements
|
||||
|
||||
11.1 Modify method and headers
|
||||
|
||||
Doing fancy stuff, you may need to add or change elements of a single curl
|
||||
request.
|
||||
@@ -434,7 +607,26 @@ Date: Jan 19, 2011
|
||||
|
||||
curl --header "Destination: http://nowhere" http://example.com
|
||||
|
||||
13. Web Login
|
||||
11.2 More on changed methods
|
||||
|
||||
It should be noted that curl selects which methods to use on its own
|
||||
depending on what action to ask for. -d will do POST, -I will do HEAD and so
|
||||
on. If you use the --request / -X option you can change the method keyword
|
||||
curl selects, but you will not modify curl's behavior. This means that if you
|
||||
for example use -d "data" to do a POST, you can modify the method to a
|
||||
PROPFIND with -X and curl will still think it sends a POST. You can change
|
||||
the normal GET to a POST method by simply adding -X POST in a command line
|
||||
like:
|
||||
|
||||
curl -X POST http://example.org/
|
||||
|
||||
... but curl will still think and act as if it sent a GET so it won't send any
|
||||
request body etc.
|
||||
|
||||
|
||||
12. Web Login
|
||||
|
||||
12.1 Some login tricks
|
||||
|
||||
While not strictly just HTTP related, it still cause a lot of people problems
|
||||
so here's the executive run-down of how the vast majority of all login forms
|
||||
@@ -463,7 +655,9 @@ Date: Jan 19, 2011
|
||||
to do a proper login POST. Remember that the contents need to be URL encoded
|
||||
when sent in a normal POST.
|
||||
|
||||
14. Debug
|
||||
13. Debug
|
||||
|
||||
13.1 Some debug tricks
|
||||
|
||||
Many times when you run curl on a site, you'll notice that the site doesn't
|
||||
seem to respond the same way to your curl requests as it does to your
|
||||
@@ -473,35 +667,40 @@ Date: Jan 19, 2011
|
||||
browser's requests:
|
||||
|
||||
* Use the --trace-ascii option to store fully detailed logs of the requests
|
||||
for easier analyzing and better understanding
|
||||
for easier analyzing and better understanding
|
||||
|
||||
* Make sure you check for and use cookies when needed (both reading with
|
||||
--cookie and writing with --cookie-jar)
|
||||
--cookie and writing with --cookie-jar)
|
||||
|
||||
* Set user-agent to one like a recent popular browser does
|
||||
|
||||
* Set referer like it is set by the browser
|
||||
|
||||
* If you use POST, make sure you send all the fields and in the same order as
|
||||
the browser does it. (See chapter 4.5 above)
|
||||
the browser does it.
|
||||
|
||||
A very good helper to make sure you do this right, is the LiveHTTPHeader tool
|
||||
that lets you view all headers you send and receive with Mozilla/Firefox
|
||||
(even when using HTTPS).
|
||||
(even when using HTTPS). Chrome features similar functionality out of the box
|
||||
among the developer's tools.
|
||||
|
||||
A more raw approach is to capture the HTTP traffic on the network with tools
|
||||
such as ethereal or tcpdump and check what headers that were sent and
|
||||
received by the browser. (HTTPS makes this technique inefficient.)
|
||||
|
||||
15. References
|
||||
14. References
|
||||
|
||||
14.1 Standards
|
||||
|
||||
RFC 2616 is a must to read if you want in-depth understanding of the HTTP
|
||||
protocol.
|
||||
protocol
|
||||
|
||||
RFC 3986 explains the URL syntax.
|
||||
RFC 3986 explains the URL syntax
|
||||
|
||||
RFC 2109 defines how cookies are supposed to work.
|
||||
RFC 1867 defines the HTTP post upload format
|
||||
|
||||
RFC 1867 defines the HTTP post upload format.
|
||||
RFC 6525 defines how HTTP cookies work
|
||||
|
||||
14.2 Sites
|
||||
|
||||
http://curl.haxx.se is the home of the cURL project
|
||||
|
||||
10
docs/curl.1
10
docs/curl.1
@@ -287,11 +287,11 @@ data pieces specified will be merged together with a separating
|
||||
chunk that looks like \&'name=daniel&skill=lousy'.
|
||||
|
||||
If you start the data with the letter @, the rest should be a file name to
|
||||
read the data from, or - if you want curl to read the data from stdin. The
|
||||
contents of the file must already be URL-encoded. Multiple files can also be
|
||||
specified. Posting data from a file named 'foobar' would thus be done with
|
||||
\fI--data\fP @foobar. When --data is told to read from a file like that,
|
||||
carriage returns and newlines will be stripped out.
|
||||
read the data from, or - if you want curl to read the data from
|
||||
stdin. Multiple files can also be specified. Posting data from a file
|
||||
named 'foobar' would thus be done with \fI--data\fP @foobar. When --data is
|
||||
told to read from a file like that, carriage returns and newlines will be
|
||||
stripped out.
|
||||
.IP "-D, --dump-header <file>"
|
||||
Write the protocol headers to the specified file.
|
||||
|
||||
|
||||
@@ -4,8 +4,12 @@ check_PROGRAMS = 10-at-a-time anyauthput cookie_interface debug fileupload \
|
||||
https multi-app multi-debugcallback multi-double multi-post multi-single \
|
||||
persistant post-callback postit2 sepheaders simple simplepost simplessl \
|
||||
sendrecv httpcustomheader certinfo chkspeed ftpgetinfo ftp-wildcard \
|
||||
smtp-multi simplesmtp smtp-tls rtsp externalsocket resolve \
|
||||
progressfunc pop3s pop3slist imap url2file sftpget ftpsget postinmemory
|
||||
smtp-mail smtp-multi smtp-ssl smtp-tls smtp-vrfy smtp-expn rtsp \
|
||||
externalsocket resolve progressfunc pop3-retr pop3-list pop3-uidl pop3-dele \
|
||||
pop3-top pop3-stat pop3-noop pop3-ssl pop3-tls pop3-multi imap-list \
|
||||
imap-fetch imap-store imap-append imap-examine imap-search imap-create \
|
||||
imap-delete imap-copy imap-noop imap-ssl imap-tls imap-multi url2file \
|
||||
sftpget ftpsget postinmemory
|
||||
|
||||
# These examples require external dependencies that may not be commonly
|
||||
# available on POSIX systems, so don't bother attempting to compile them here.
|
||||
|
||||
115
docs/examples/imap-append.c
Normal file
115
docs/examples/imap-append.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to send mail using libcurl's IMAP
|
||||
* capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
|
||||
static const char *payload_text[] = {
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n",
|
||||
"To: " TO "\r\n",
|
||||
"From: " FROM "(Example User)\r\n",
|
||||
"Cc: " CC "(Another example User)\r\n",
|
||||
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
|
||||
"Subject: IMAP example message\r\n",
|
||||
"\r\n", /* empty line to divide headers from body, see RFC5322 */
|
||||
"The body of the message starts here.\r\n",
|
||||
"\r\n",
|
||||
"It could be a lot of lines, could be MIME encoded, whatever.\r\n",
|
||||
"Check RFC5322.\r\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct upload_status {
|
||||
int lines_read;
|
||||
};
|
||||
|
||||
static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
struct upload_status *upload_ctx = (struct upload_status *)userp;
|
||||
const char *data;
|
||||
|
||||
if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = payload_text[upload_ctx->lines_read];
|
||||
|
||||
if(data) {
|
||||
size_t len = strlen(data);
|
||||
memcpy(ptr, data, len);
|
||||
upload_ctx->lines_read++;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
struct upload_status upload_ctx;
|
||||
|
||||
upload_ctx.lines_read = 0;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will create a new message 100. Note that you should perform an
|
||||
* EXAMINE command to obtain the UID of the next message to create and a
|
||||
* SELECT to ensure you are creating the message in the OUTBOX. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/100");
|
||||
|
||||
/* In this case, we're using a callback function to specify the data. You
|
||||
* could just use the CURLOPT_READDATA option to specify a FILE pointer to
|
||||
* read from. */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* Perform the append */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
65
docs/examples/imap-copy.c
Normal file
65
docs/examples/imap-copy.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to copy a mail from one mailbox folder
|
||||
* to another using libcurl's IMAP capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is source mailbox folder to select */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX");
|
||||
|
||||
/* Set the COPY command specifing the message ID and destination folder */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "COPY 1 FOLDER");
|
||||
|
||||
/* Note that to perform a move operation you will need to perform the copy,
|
||||
* then mark the original mail as Deleted and EXPUNGE or CLOSE. Please see
|
||||
* imap-store.c for more information on deleting messages. */
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
61
docs/examples/imap-create.c
Normal file
61
docs/examples/imap-create.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to create a new mailbox folder using
|
||||
* libcurl's IMAP capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
||||
/* Set the CREATE command specifing the new folder name */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "CREATE FOLDER");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
61
docs/examples/imap-delete.c
Normal file
61
docs/examples/imap-delete.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to delete an existing mailbox folder
|
||||
* using libcurl's IMAP capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
||||
/* Set the DELETE command specifing the existing folder */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE FOLDER");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
61
docs/examples/imap-examine.c
Normal file
61
docs/examples/imap-examine.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to obtain information about a mailbox
|
||||
* folder using libcurl's IMAP capabilities via the EXAMINE command.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
||||
/* Set the EXAMINE command specifing the mailbox folder */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "EXAMINE OUTBOX");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -22,6 +22,12 @@
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to fetch mail using libcurl's IMAP
|
||||
* capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
@@ -30,15 +36,23 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will fetch the mailbox named "foobar" */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/foobar");
|
||||
/* This will fetch message 1 from the user's inbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
|
||||
|
||||
/* Perform the fetch */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
60
docs/examples/imap-list.c
Normal file
60
docs/examples/imap-list.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to list the folders within an IMAP
|
||||
* mailbox.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will list the folders within the user's mailbox. If you want to
|
||||
* list the folders within a specific folder, for example the inbox, then
|
||||
* specify the folder as a path in the URL such as /INBOX */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
||||
/* Perform the list */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
145
docs/examples/imap-multi.c
Normal file
145
docs/examples/imap-multi.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to fetch mail using libcurl's IMAP
|
||||
* capabilities. It builds on the imap-fetch.c example to demonstrate how to
|
||||
* use libcurl's multi interface.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
static struct timeval tvnow(void)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
/* time() returns the value of time in seconds since the epoch */
|
||||
now.tv_sec = (long)time(NULL);
|
||||
now.tv_usec = 0;
|
||||
|
||||
return now;
|
||||
}
|
||||
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec - older.tv_sec) * 1000 +
|
||||
(newer.tv_usec - older.tv_usec) / 1000;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLM *mcurl;
|
||||
int still_running = 1;
|
||||
struct timeval mp_start;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
return 1;
|
||||
|
||||
mcurl = curl_multi_init();
|
||||
if(!mcurl)
|
||||
return 2;
|
||||
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will fetch message 1 from the user's inbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
|
||||
|
||||
/* Tell the multi stack about our easy handle */
|
||||
curl_multi_add_handle(mcurl, curl);
|
||||
|
||||
/* Record the start time which we can use later */
|
||||
mp_start = tvnow();
|
||||
|
||||
/* We start some action by calling perform right away */
|
||||
curl_multi_perform(mcurl, &still_running);
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd = -1;
|
||||
int rc;
|
||||
|
||||
long curl_timeo = -1;
|
||||
|
||||
/* Initialise the file descriptors */
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* Set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
curl_multi_timeout(mcurl, &curl_timeo);
|
||||
if(curl_timeo >= 0) {
|
||||
timeout.tv_sec = curl_timeo / 1000;
|
||||
if(timeout.tv_sec > 1)
|
||||
timeout.tv_sec = 1;
|
||||
else
|
||||
timeout.tv_usec = (curl_timeo % 1000) * 1000;
|
||||
}
|
||||
|
||||
/* Get file descriptors from the transfers */
|
||||
curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls. On success, the value of maxfd is guaranteed to be
|
||||
greater or equal than -1. We call select(maxfd + 1, ...), specially in
|
||||
case of (maxfd == -1), we call select(0, ...), which is basically equal
|
||||
to sleep. */
|
||||
rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
if(tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
fprintf(stderr,
|
||||
"ABORTING: Since it seems that we would have run forever.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(rc) {
|
||||
case -1: /* select error */
|
||||
break;
|
||||
case 0: /* timeout */
|
||||
default: /* action */
|
||||
curl_multi_perform(mcurl, &still_running);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Always cleanup */
|
||||
curl_multi_remove_handle(mcurl, curl);
|
||||
curl_multi_cleanup(mcurl);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
61
docs/examples/imap-noop.c
Normal file
61
docs/examples/imap-noop.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to perform a noop using libcurl's IMAP
|
||||
* capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
||||
/* Set the NOOP command */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "NOOP");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
65
docs/examples/imap-search.c
Normal file
65
docs/examples/imap-search.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to search for new messages using
|
||||
* libcurl's IMAP capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is mailbox folder to select */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX");
|
||||
|
||||
/* Set the SEARCH command specifing what we want to search for. Note that
|
||||
* this can contain a message sequence set and a number of search criteria
|
||||
* keywords including flags such as ANSWERED, DELETED, DRAFT, FLAGGED, NEW,
|
||||
* RECENT and SEEN. For more information about the search criteria please
|
||||
* see RFC-3501 section 6.4.4. */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "SEARCH NEW");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -22,52 +22,64 @@
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to fetch mail using libcurl's IMAP
|
||||
* capabilities. It builds on the imap-fetch.c example adding transport
|
||||
* security to protect the authentication details from being snooped.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will list every message of the given mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3s://user@pop.example.com/");
|
||||
/* This will fetch message 1 from the user's inbox. Note the use of
|
||||
* imaps:// rather than imap:// to request a SSL based connection. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imaps://imap.example.com/INBOX/;UID=1");
|
||||
|
||||
#ifdef SKIP_PEER_VERIFICATION
|
||||
/*
|
||||
* If you want to connect to a site who isn't using a certificate that is
|
||||
/* If you want to connect to a site who isn't using a certificate that is
|
||||
* signed by one of the certs in the CA bundle you have, you can skip the
|
||||
* verification of the server's certificate. This makes the connection
|
||||
* A LOT LESS SECURE.
|
||||
*
|
||||
* If you have a CA cert for the server stored someplace else than in the
|
||||
* default bundle, then the CURLOPT_CAPATH option might come handy for
|
||||
* you.
|
||||
*/
|
||||
* you. */
|
||||
#ifdef SKIP_PEER_VERIFICATION
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
|
||||
#ifdef SKIP_HOSTNAME_VERFICATION
|
||||
/*
|
||||
* If the site you're connecting to uses a different host name that what
|
||||
/* If the site you're connecting to uses a different host name that what
|
||||
* they have mentioned in their server certificate's commonName (or
|
||||
* subjectAltName) fields, libcurl will refuse to connect. You can skip
|
||||
* this check, but this will make the connection less secure.
|
||||
*/
|
||||
* this check, but this will make the connection less secure. */
|
||||
#ifdef SKIP_HOSTNAME_VERFICATION
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
#endif
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
/* Since the traffic will be encrypted, it is very useful to turn on debug
|
||||
* information within libcurl to see what is happening during the
|
||||
* transfer */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* Perform the fetch */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* always cleanup */
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
76
docs/examples/imap-store.c
Normal file
76
docs/examples/imap-store.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to modify an existing mail using
|
||||
* libcurl's IMAP capabilities with the STORE command.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is the mailbox folder to select */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX");
|
||||
|
||||
/* Set the STORE command with the Deleted flag for message 1. Note that
|
||||
* you can use the STORE command to set other flags such as Seen, Answered,
|
||||
* Flagged, Draft and Recent. */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "STORE 1 +Flags \\Deleted");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
else {
|
||||
/* Set the EXPUNGE command, although you can use the CLOSE command if you
|
||||
* don't want to know the result of the STORE */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "EXPUNGE");
|
||||
|
||||
/* Perform the second custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
}
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
84
docs/examples/imap-tls.c
Normal file
84
docs/examples/imap-tls.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to fetch mail using libcurl's IMAP
|
||||
* capabilities. It builds on the imap-fetch.c example adding transport
|
||||
* security to protect the authentication details from being snooped.
|
||||
*
|
||||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will fetch message 1 from the user's inbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
|
||||
|
||||
/* In this example, we'll start with a plain text connection, and upgrade
|
||||
* to Transport Layer Security (TLS) using the STARTTLS command. Be careful
|
||||
* of using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer
|
||||
* will continue anyway - see the security discussion in the libcurl
|
||||
* tutorial for more details. */
|
||||
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
|
||||
|
||||
/* If your server doesn't have a valid certificate, then you can disable
|
||||
* part of the Transport Layer Security protection by setting the
|
||||
* CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false).
|
||||
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
* That is, in general, a bad idea. It is still better than sending your
|
||||
* authentication details in plain text though.
|
||||
* Instead, you should get the issuer certificate (or the host certificate
|
||||
* if the certificate is self-signed) and add it to the set of certificates
|
||||
* that are known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See
|
||||
* docs/SSLCERTS for more information. */
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
|
||||
|
||||
/* Since the traffic will be encrypted, it is very useful to turn on debug
|
||||
* information within libcurl to see what is happening during the
|
||||
* transfer */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* Perform the fetch */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
64
docs/examples/pop3-dele.c
Normal file
64
docs/examples/pop3-dele.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to delete an existing mail using
|
||||
* libcurl's POP3 capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.26.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* You can specify the message either in the URL or DELE command */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
|
||||
|
||||
/* Set the DELE command */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELE");
|
||||
|
||||
/* Do not perform a transfer as DELE returns no data */
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
58
docs/examples/pop3-list.c
Normal file
58
docs/examples/pop3-list.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example using libcurl's POP3 capabilities to list the
|
||||
* contents of a mailbox.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will list every message of the given mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com");
|
||||
|
||||
/* Perform the list */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
145
docs/examples/pop3-multi.c
Normal file
145
docs/examples/pop3-multi.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to retrieve mail using libcurl's POP3
|
||||
* capabilities. It builds on the pop3-retr.c example to demonstrate how to use
|
||||
* libcurl's multi interface.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
static struct timeval tvnow(void)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
/* time() returns the value of time in seconds since the epoch */
|
||||
now.tv_sec = (long)time(NULL);
|
||||
now.tv_usec = 0;
|
||||
|
||||
return now;
|
||||
}
|
||||
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec - older.tv_sec) * 1000 +
|
||||
(newer.tv_usec - older.tv_usec) / 1000;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLM *mcurl;
|
||||
int still_running = 1;
|
||||
struct timeval mp_start;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
return 1;
|
||||
|
||||
mcurl = curl_multi_init();
|
||||
if(!mcurl)
|
||||
return 2;
|
||||
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will retreive message 1 from the user's mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
|
||||
|
||||
/* Tell the multi stack about our easy handle */
|
||||
curl_multi_add_handle(mcurl, curl);
|
||||
|
||||
/* Record the start time which we can use later */
|
||||
mp_start = tvnow();
|
||||
|
||||
/* We start some action by calling perform right away */
|
||||
curl_multi_perform(mcurl, &still_running);
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd = -1;
|
||||
int rc;
|
||||
|
||||
long curl_timeo = -1;
|
||||
|
||||
/* Initialise the file descriptors */
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* Set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
curl_multi_timeout(mcurl, &curl_timeo);
|
||||
if(curl_timeo >= 0) {
|
||||
timeout.tv_sec = curl_timeo / 1000;
|
||||
if(timeout.tv_sec > 1)
|
||||
timeout.tv_sec = 1;
|
||||
else
|
||||
timeout.tv_usec = (curl_timeo % 1000) * 1000;
|
||||
}
|
||||
|
||||
/* Get file descriptors from the transfers */
|
||||
curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls. On success, the value of maxfd is guaranteed to be
|
||||
greater or equal than -1. We call select(maxfd + 1, ...), specially in
|
||||
case of (maxfd == -1), we call select(0, ...), which is basically equal
|
||||
to sleep. */
|
||||
rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
if(tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
fprintf(stderr,
|
||||
"ABORTING: Since it seems that we would have run forever.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(rc) {
|
||||
case -1: /* select error */
|
||||
break;
|
||||
case 0: /* timeout */
|
||||
default: /* action */
|
||||
curl_multi_perform(mcurl, &still_running);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Always cleanup */
|
||||
curl_multi_remove_handle(mcurl, curl);
|
||||
curl_multi_cleanup(mcurl);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
docs/examples/pop3-noop.c
Normal file
64
docs/examples/pop3-noop.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to perform a noop using libcurl's POP3
|
||||
* capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.26.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com");
|
||||
|
||||
/* Set the NOOP command */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "NOOP");
|
||||
|
||||
/* Do not perform a transfer as NOOP returns no data */
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
58
docs/examples/pop3-retr.c
Normal file
58
docs/examples/pop3-retr.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to retrieve mail using libcurl's POP3
|
||||
* capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will retreive message 1 from the user's mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
|
||||
|
||||
/* Perform the retr */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -22,52 +22,64 @@
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to retrieve mail using libcurl's POP3
|
||||
* capabilities. It builds on the pop3-retr.c example adding transport
|
||||
* security to protect the authentication details from being snooped.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will only fetch the message with ID "1" of the given mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3s://user@pop.example.com/1");
|
||||
/* This will retreive message 1 from the user's mailbox. Note the use of
|
||||
* pop3s:// rather than pop3:// to request a SSL based connection. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3s://pop.example.com/1");
|
||||
|
||||
#ifdef SKIP_PEER_VERIFICATION
|
||||
/*
|
||||
* If you want to connect to a site who isn't using a certificate that is
|
||||
/* If you want to connect to a site who isn't using a certificate that is
|
||||
* signed by one of the certs in the CA bundle you have, you can skip the
|
||||
* verification of the server's certificate. This makes the connection
|
||||
* A LOT LESS SECURE.
|
||||
*
|
||||
* If you have a CA cert for the server stored someplace else than in the
|
||||
* default bundle, then the CURLOPT_CAPATH option might come handy for
|
||||
* you.
|
||||
*/
|
||||
* you. */
|
||||
#ifdef SKIP_PEER_VERIFICATION
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
|
||||
#ifdef SKIP_HOSTNAME_VERFICATION
|
||||
/*
|
||||
* If the site you're connecting to uses a different host name that what
|
||||
/* If the site you're connecting to uses a different host name that what
|
||||
* they have mentioned in their server certificate's commonName (or
|
||||
* subjectAltName) fields, libcurl will refuse to connect. You can skip
|
||||
* this check, but this will make the connection less secure.
|
||||
*/
|
||||
* this check, but this will make the connection less secure. */
|
||||
#ifdef SKIP_HOSTNAME_VERFICATION
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
#endif
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
/* Since the traffic will be encrypted, it is very useful to turn on debug
|
||||
* information within libcurl to see what is happening during the
|
||||
* transfer */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* Perform the retr */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* always cleanup */
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
64
docs/examples/pop3-stat.c
Normal file
64
docs/examples/pop3-stat.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to obtain message statistics using
|
||||
* libcurl's POP3 capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.26.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com");
|
||||
|
||||
/* Set the STAT command */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "STAT");
|
||||
|
||||
/* Do not perform a transfer as the data is in the response */
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
84
docs/examples/pop3-tls.c
Normal file
84
docs/examples/pop3-tls.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to retrieve mail using libcurl's POP3
|
||||
* capabilities. It builds on the pop3-retr.c example adding transport
|
||||
* security to protect the authentication details from being snooped.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will retreive message 1 from the user's mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
|
||||
|
||||
/* In this example, we'll start with a plain text connection, and upgrade
|
||||
* to Transport Layer Security (TLS) using the STLS command. Be careful of
|
||||
* using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer
|
||||
* will continue anyway - see the security discussion in the libcurl
|
||||
* tutorial for more details. */
|
||||
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
|
||||
|
||||
/* If your server doesn't have a valid certificate, then you can disable
|
||||
* part of the Transport Layer Security protection by setting the
|
||||
* CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false).
|
||||
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
* That is, in general, a bad idea. It is still better than sending your
|
||||
* authentication details in plain text though.
|
||||
* Instead, you should get the issuer certificate (or the host certificate
|
||||
* if the certificate is self-signed) and add it to the set of certificates
|
||||
* that are known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See
|
||||
* docs/SSLCERTS for more information. */
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
|
||||
|
||||
/* Since the traffic will be encrypted, it is very useful to turn on debug
|
||||
* information within libcurl to see what is happening during the
|
||||
* transfer */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* Perform the retr */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
61
docs/examples/pop3-top.c
Normal file
61
docs/examples/pop3-top.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to retrieve only the headers of a mail
|
||||
* using libcurl's POP3 capabilities.
|
||||
*
|
||||
* Note that this example requires libcurl 7.26.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com");
|
||||
|
||||
/* Set the TOP command for message 1 to only include the headers */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "TOP 1 0");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
61
docs/examples/pop3-uidl.c
Normal file
61
docs/examples/pop3-uidl.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example using libcurl's POP3 capabilities to list the
|
||||
* contents of a mailbox by unique ID.
|
||||
*
|
||||
* Note that this example requires libcurl 7.26.0 or above.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com");
|
||||
|
||||
/* Set the UIDL command */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "UIDL");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
struct curl_slist *recipients = NULL;
|
||||
|
||||
/* value for envelope reverse-path */
|
||||
static const char *from = "<bradh@example.com>";
|
||||
|
||||
/* this becomes the envelope forward-path */
|
||||
static const char *to = "<bradh@example.net>";
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* this is the URL for your mailserver - you can also use an smtps:// URL
|
||||
* here */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.net.");
|
||||
|
||||
/* Note that this option isn't strictly required, omitting it will result in
|
||||
* libcurl will sent the MAIL FROM command with no sender data. All
|
||||
* autoresponses should have an empty reverse-path, and should be directed
|
||||
* to the address in the reverse-path which triggered them. Otherwise, they
|
||||
* could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, from);
|
||||
|
||||
/* Note that the CURLOPT_MAIL_RCPT takes a list, not a char array. */
|
||||
recipients = curl_slist_append(recipients, to);
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
/* You provide the payload (headers and the body of the message) as the
|
||||
* "data" element. There are two choices, either:
|
||||
* - provide a callback function and specify the function name using the
|
||||
* CURLOPT_READFUNCTION option; or
|
||||
* - just provide a FILE pointer that can be used to read the data from.
|
||||
* The easiest case is just to read from standard input, (which is available
|
||||
* as a FILE pointer) as shown here.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, stdin);
|
||||
|
||||
/* send the message (including headers) */
|
||||
res = curl_easy_perform(curl);
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* free the list of recipients */
|
||||
curl_slist_free_all(recipients);
|
||||
|
||||
/* curl won't send the QUIT command until you call cleanup, so you should be
|
||||
* able to re-use this connection for additional messages (setting
|
||||
* CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling
|
||||
* curl_easy_perform() again. It may not be a good idea to keep the
|
||||
* connection open for a very long time though (more than a few minutes may
|
||||
* result in the server timing out the connection), and you do want to clean
|
||||
* up in the end.
|
||||
*/
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
73
docs/examples/smtp-expn.c
Normal file
73
docs/examples/smtp-expn.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to expand an email mailing list.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* 1) This example requires libcurl 7.34.0 or above.
|
||||
* 2) Not all email servers support this command.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
struct curl_slist *recipients = NULL;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* This is the URL for your mailserver */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
|
||||
|
||||
/* Note that the CURLOPT_MAIL_RCPT takes a list, not a char array */
|
||||
recipients = curl_slist_append(recipients, "Friends");
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
/* Set the EXPN command */
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "EXPN");
|
||||
|
||||
/* Perform the custom request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Free the list of recipients */
|
||||
curl_slist_free_all(recipients);
|
||||
|
||||
/* Curl won't send the QUIT command until you call cleanup, so you should
|
||||
* be able to re-use this connection for additional requests. It may not be
|
||||
* a good idea to keep the connection open for a very long time though
|
||||
* (more than a few minutes may result in the server timing out the
|
||||
* connection) and you do want to clean up in the end.
|
||||
*/
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
137
docs/examples/smtp-mail.c
Normal file
137
docs/examples/smtp-mail.c
Normal file
@@ -0,0 +1,137 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to send mail using libcurl's SMTP
|
||||
* capabilities. For an exmaple of using the multi interface please see
|
||||
* smtp-multi.c.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
|
||||
static const char *payload_text[] = {
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n",
|
||||
"To: " TO "\r\n",
|
||||
"From: " FROM "(Example User)\r\n",
|
||||
"Cc: " CC "(Another example User)\r\n",
|
||||
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
|
||||
"Subject: SMTP example message\r\n",
|
||||
"\r\n", /* empty line to divide headers from body, see RFC5322 */
|
||||
"The body of the message starts here.\r\n",
|
||||
"\r\n",
|
||||
"It could be a lot of lines, could be MIME encoded, whatever.\r\n",
|
||||
"Check RFC5322.\r\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct upload_status {
|
||||
int lines_read;
|
||||
};
|
||||
|
||||
static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
struct upload_status *upload_ctx = (struct upload_status *)userp;
|
||||
const char *data;
|
||||
|
||||
if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = payload_text[upload_ctx->lines_read];
|
||||
|
||||
if(data) {
|
||||
size_t len = strlen(data);
|
||||
memcpy(ptr, data, len);
|
||||
upload_ctx->lines_read++;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx;
|
||||
|
||||
upload_ctx.lines_read = 0;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* This is the URL for your mailserver */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
|
||||
|
||||
/* Note that this option isn't strictly required, omitting it will result in
|
||||
* libcurl sending the MAIL FROM command with empty sender data. All
|
||||
* autoresponses should have an empty reverse-path, and should be directed
|
||||
* to the address in the reverse-path which triggered them. Otherwise, they
|
||||
* could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
|
||||
|
||||
/* Add two recipients, in this particular case they correspond to the
|
||||
* To: and Cc: addressees in the header, but they could be any kind of
|
||||
* recipient. */
|
||||
recipients = curl_slist_append(recipients, TO);
|
||||
recipients = curl_slist_append(recipients, CC);
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
/* We're using a callback function to specify the payload (the headers and
|
||||
* body of the message). You could just use the CURLOPT_READDATA option to
|
||||
* specify a FILE pointer to read from. */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* Send the message */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Free the list of recipients */
|
||||
curl_slist_free_all(recipients);
|
||||
|
||||
/* curl won't send the QUIT command until you call cleanup, so you should be
|
||||
* able to re-use this connection for additional messages (setting
|
||||
* CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling
|
||||
* curl_easy_perform() again. It may not be a good idea to keep the
|
||||
* connection open for a very long time though (more than a few minutes may
|
||||
* result in the server timing out the connection), and you do want to clean
|
||||
* up in the end.
|
||||
*/
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -19,139 +19,151 @@
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* This is an example application source code sending SMTP mail using the
|
||||
* multi interface.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* This is the list of basic details you need to tweak to get things right.
|
||||
/* This is an example showing how to send mail using libcurl's SMTP
|
||||
* capabilities. It builds on the smtp-mail.c example to demonstrate how to use
|
||||
* libcurl's multi interface.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
#define USERNAME "user@example.com"
|
||||
#define PASSWORD "123qwerty"
|
||||
#define SMTPSERVER "smtp.example.com"
|
||||
#define SMTPPORT ":587" /* it is a colon+port string, but you can set it
|
||||
to "" to use the default port */
|
||||
#define RECIPIENT "<recipient@example.com>"
|
||||
#define MAILFROM "<realuser@example.com>"
|
||||
|
||||
#define FROM "<sender@example.com>"
|
||||
#define TO "<recipient@example.com>"
|
||||
#define CC "<info@example.com>"
|
||||
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
/* Note that you should include the actual meta data headers here as well if
|
||||
you want the mail to have a Subject, another From:, show a To: or whatever
|
||||
you think your mail should feature! */
|
||||
static const char *text[]={
|
||||
"one\n",
|
||||
"two\n",
|
||||
"three\n",
|
||||
" Hello, this is CURL email SMTP\n",
|
||||
static const char *payload_text[] = {
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n",
|
||||
"To: " TO "\r\n",
|
||||
"From: " FROM "(Example User)\r\n",
|
||||
"Cc: " CC "(Another example User)\r\n",
|
||||
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
|
||||
"Subject: SMTP multi example message\r\n",
|
||||
"\r\n", /* empty line to divide headers from body, see RFC5322 */
|
||||
"The body of the message starts here.\r\n",
|
||||
"\r\n",
|
||||
"It could be a lot of lines, could be MIME encoded, whatever.\r\n",
|
||||
"Check RFC5322.\r\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct WriteThis {
|
||||
int counter;
|
||||
struct upload_status {
|
||||
int lines_read;
|
||||
};
|
||||
|
||||
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
struct WriteThis *pooh = (struct WriteThis *)userp;
|
||||
struct upload_status *upload_ctx = (struct upload_status *)userp;
|
||||
const char *data;
|
||||
|
||||
if(size*nmemb < 1)
|
||||
if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = text[pooh->counter];
|
||||
data = payload_text[upload_ctx->lines_read];
|
||||
|
||||
if(data) {
|
||||
size_t len = strlen(data);
|
||||
memcpy(ptr, data, len);
|
||||
pooh->counter++; /* advance pointer */
|
||||
upload_ctx->lines_read++;
|
||||
|
||||
return len;
|
||||
}
|
||||
return 0; /* no more data left to deliver */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct timeval tvnow(void)
|
||||
{
|
||||
/*
|
||||
** time() returns the value of time in seconds since the Epoch.
|
||||
*/
|
||||
struct timeval now;
|
||||
|
||||
/* time() returns the value of time in seconds since the epoch */
|
||||
now.tv_sec = (long)time(NULL);
|
||||
now.tv_usec = 0;
|
||||
|
||||
return now;
|
||||
}
|
||||
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec-older.tv_sec)*1000+
|
||||
(newer.tv_usec-older.tv_usec)/1000;
|
||||
return (newer.tv_sec - older.tv_sec) * 1000 +
|
||||
(newer.tv_usec - older.tv_usec) / 1000;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLM *mcurl;
|
||||
int still_running = 1;
|
||||
struct timeval mp_start;
|
||||
struct WriteThis pooh;
|
||||
struct curl_slist* rcpt_list = NULL;
|
||||
CURL *curl;
|
||||
CURLM *mcurl;
|
||||
int still_running = 1;
|
||||
struct timeval mp_start;
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx;
|
||||
|
||||
pooh.counter = 0;
|
||||
upload_ctx.lines_read = 0;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
return 1;
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
return 1;
|
||||
|
||||
mcurl = curl_multi_init();
|
||||
if(!mcurl)
|
||||
return 2;
|
||||
mcurl = curl_multi_init();
|
||||
if(!mcurl)
|
||||
return 2;
|
||||
|
||||
rcpt_list = curl_slist_append(rcpt_list, RECIPIENT);
|
||||
/* more addresses can be added here
|
||||
rcpt_list = curl_slist_append(rcpt_list, "<others@example.com>");
|
||||
/* This is the URL for your mailserver */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
|
||||
|
||||
/* Note that this option isn't strictly required, omitting it will result in
|
||||
* libcurl sending the MAIL FROM command with empty sender data. All
|
||||
* autoresponses should have an empty reverse-path, and should be directed
|
||||
* to the address in the reverse-path which triggered them. Otherwise, they
|
||||
* could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://" SMTPSERVER SMTPPORT);
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, USERNAME);
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, PASSWORD);
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, MAILFROM);
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
|
||||
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &pooh);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_SSLVERSION, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE, 0L);
|
||||
curl_multi_add_handle(mcurl, curl);
|
||||
/* Add two recipients, in this particular case they correspond to the
|
||||
* To: and Cc: addressees in the header, but they could be any kind of
|
||||
* recipient. */
|
||||
recipients = curl_slist_append(recipients, TO);
|
||||
recipients = curl_slist_append(recipients, CC);
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
mp_start = tvnow();
|
||||
/* We're using a callback function to specify the payload (the headers and
|
||||
* body of the message). You could just use the CURLOPT_READDATA option to
|
||||
* specify a FILE pointer to read from. */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* we start some action by calling perform right away */
|
||||
/* Tell the multi stack about our easy handle */
|
||||
curl_multi_add_handle(mcurl, curl);
|
||||
|
||||
/* Record the start time which we can use later */
|
||||
mp_start = tvnow();
|
||||
|
||||
/* We start some action by calling perform right away */
|
||||
curl_multi_perform(mcurl, &still_running);
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
int rc; /* select() return code */
|
||||
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd = -1;
|
||||
int rc;
|
||||
|
||||
long curl_timeo = -1;
|
||||
|
||||
/* Initialise the file descriptors */
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
/* Set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
@@ -164,7 +176,7 @@ int main(void)
|
||||
timeout.tv_usec = (curl_timeo % 1000) * 1000;
|
||||
}
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
/* Get file descriptors from the transfers */
|
||||
curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
@@ -172,32 +184,32 @@ int main(void)
|
||||
greater or equal than -1. We call select(maxfd + 1, ...), specially in
|
||||
case of (maxfd == -1), we call select(0, ...), which is basically equal
|
||||
to sleep. */
|
||||
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
if (tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
fprintf(stderr, "ABORTING TEST, since it seems "
|
||||
"that it would have run forever.\n");
|
||||
if(tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
fprintf(stderr,
|
||||
"ABORTING: Since it seems that we would have run forever.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
case -1: /* select error */
|
||||
break;
|
||||
case 0: /* timeout */
|
||||
default: /* action */
|
||||
case 0: /* timeout */
|
||||
default: /* action */
|
||||
curl_multi_perform(mcurl, &still_running);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
curl_slist_free_all(rcpt_list);
|
||||
/* Free the list of recipients */
|
||||
curl_slist_free_all(recipients);
|
||||
|
||||
/* Always cleanup */
|
||||
curl_multi_remove_handle(mcurl, curl);
|
||||
curl_multi_cleanup(mcurl);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
161
docs/examples/smtp-ssl.c
Normal file
161
docs/examples/smtp-ssl.c
Normal file
@@ -0,0 +1,161 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to send mail using libcurl's SMTP
|
||||
* capabilities. It builds on the smtp-mail.c example to add authentication
|
||||
* and, more importantly, transport security to protect the authentication
|
||||
* details from being snooped.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
|
||||
static const char *payload_text[] = {
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n",
|
||||
"To: " TO "\r\n",
|
||||
"From: " FROM "(Example User)\r\n",
|
||||
"Cc: " CC "(Another example User)\r\n",
|
||||
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
|
||||
"Subject: SMTP SSL example message\r\n",
|
||||
"\r\n", /* empty line to divide headers from body, see RFC5322 */
|
||||
"The body of the message starts here.\r\n",
|
||||
"\r\n",
|
||||
"It could be a lot of lines, could be MIME encoded, whatever.\r\n",
|
||||
"Check RFC5322.\r\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct upload_status {
|
||||
int lines_read;
|
||||
};
|
||||
|
||||
static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
struct upload_status *upload_ctx = (struct upload_status *)userp;
|
||||
const char *data;
|
||||
|
||||
if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = payload_text[upload_ctx->lines_read];
|
||||
|
||||
if(data) {
|
||||
size_t len = strlen(data);
|
||||
memcpy(ptr, data, len);
|
||||
upload_ctx->lines_read++;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx;
|
||||
|
||||
upload_ctx.lines_read = 0;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is the URL for your mailserver. Note the use of smtps:// rather
|
||||
* than smtp:// to request a SSL based connection. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtps://mainserver.example.net");
|
||||
|
||||
/* If you want to connect to a site who isn't using a certificate that is
|
||||
* signed by one of the certs in the CA bundle you have, you can skip the
|
||||
* verification of the server's certificate. This makes the connection
|
||||
* A LOT LESS SECURE.
|
||||
*
|
||||
* If you have a CA cert for the server stored someplace else than in the
|
||||
* default bundle, then the CURLOPT_CAPATH option might come handy for
|
||||
* you. */
|
||||
#ifdef SKIP_PEER_VERIFICATION
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
|
||||
/* If the site you're connecting to uses a different host name that what
|
||||
* they have mentioned in their server certificate's commonName (or
|
||||
* subjectAltName) fields, libcurl will refuse to connect. You can skip
|
||||
* this check, but this will make the connection less secure. */
|
||||
#ifdef SKIP_HOSTNAME_VERFICATION
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
#endif
|
||||
|
||||
/* Note that this option isn't strictly required, omitting it will result in
|
||||
* libcurl sending the MAIL FROM command with empty sender data. All
|
||||
* autoresponses should have an empty reverse-path, and should be directed
|
||||
* to the address in the reverse-path which triggered them. Otherwise, they
|
||||
* could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
|
||||
|
||||
/* Add two recipients, in this particular case they correspond to the
|
||||
* To: and Cc: addressees in the header, but they could be any kind of
|
||||
* recipient. */
|
||||
recipients = curl_slist_append(recipients, TO);
|
||||
recipients = curl_slist_append(recipients, CC);
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
/* We're using a callback function to specify the payload (the headers and
|
||||
* body of the message). You could just use the CURLOPT_READDATA option to
|
||||
* specify a FILE pointer to read from. */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* Since the traffic will be encrypted, it is very useful to turn on debug
|
||||
* information within libcurl to see what is happening during the
|
||||
* transfer */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* Send the message */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Free the list of recipients */
|
||||
curl_slist_free_all(recipients);
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -24,26 +24,29 @@
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to send mail using libcurl's SMTP
|
||||
* capabilities. It builds on the simplesmtp.c example, adding some
|
||||
* authentication and transport security.
|
||||
* capabilities. It builds on the smtp-mail.c example to add authentication
|
||||
* and, more importantly, transport security to protect the authentication
|
||||
* details from being snooped.
|
||||
*
|
||||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
|
||||
static const char *payload_text[]={
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\n",
|
||||
"To: " TO "\n",
|
||||
"From: " FROM "(Example User)\n",
|
||||
"Cc: " CC "(Another example User)\n",
|
||||
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\n",
|
||||
"Subject: SMTP TLS example message\n",
|
||||
"\n", /* empty line to divide headers from body, see RFC5322 */
|
||||
"The body of the message starts here.\n",
|
||||
"\n",
|
||||
"It could be a lot of lines, could be MIME encoded, whatever.\n",
|
||||
"Check RFC5322.\n",
|
||||
static const char *payload_text[] = {
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n",
|
||||
"To: " TO "\r\n",
|
||||
"From: " FROM "(Example User)\r\n",
|
||||
"Cc: " CC "(Another example User)\r\n",
|
||||
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
|
||||
"Subject: SMTP TLS example message\r\n",
|
||||
"\r\n", /* empty line to divide headers from body, see RFC5322 */
|
||||
"The body of the message starts here.\r\n",
|
||||
"\r\n",
|
||||
"It could be a lot of lines, could be MIME encoded, whatever.\r\n",
|
||||
"Check RFC5322.\r\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -56,33 +59,38 @@ static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
struct upload_status *upload_ctx = (struct upload_status *)userp;
|
||||
const char *data;
|
||||
|
||||
if ((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
|
||||
if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = payload_text[upload_ctx->lines_read];
|
||||
|
||||
if (data) {
|
||||
if(data) {
|
||||
size_t len = strlen(data);
|
||||
memcpy(ptr, data, len);
|
||||
upload_ctx->lines_read ++;
|
||||
upload_ctx->lines_read++;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
CURLcode res = CURLE_OK;
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx;
|
||||
|
||||
upload_ctx.lines_read = 0;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is the URL for your mailserver. Note the use of port 587 here,
|
||||
* instead of the normal SMTP port (25). Port 587 is commonly used for
|
||||
* secure mail submission (see RFC4403), but you should use whatever
|
||||
@@ -106,18 +114,17 @@ int main(void)
|
||||
* Instead, you should get the issuer certificate (or the host certificate
|
||||
* if the certificate is self-signed) and add it to the set of certificates
|
||||
* that are known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See
|
||||
* docs/SSLCERTS for more information.
|
||||
*/
|
||||
* docs/SSLCERTS for more information. */
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
|
||||
|
||||
/* A common reason for requiring transport security is to protect
|
||||
* authentication details (user names and passwords) from being "snooped"
|
||||
* on the network. Here is how the user name and password are provided: */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user@example.net");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "P@ssw0rd");
|
||||
|
||||
/* value for envelope reverse-path */
|
||||
/* Note that this option isn't strictly required, omitting it will result in
|
||||
* libcurl sending the MAIL FROM command with empty sender data. All
|
||||
* autoresponses should have an empty reverse-path, and should be directed
|
||||
* to the address in the reverse-path which triggered them. Otherwise, they
|
||||
* could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
|
||||
|
||||
/* Add two recipients, in this particular case they correspond to the
|
||||
* To: and Cc: addressees in the header, but they could be any kind of
|
||||
* recipient. */
|
||||
@@ -125,28 +132,32 @@ int main(void)
|
||||
recipients = curl_slist_append(recipients, CC);
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
/* In this case, we're using a callback function to specify the data. You
|
||||
* could just use the CURLOPT_READDATA option to specify a FILE pointer to
|
||||
* read from.
|
||||
*/
|
||||
/* We're using a callback function to specify the payload (the headers and
|
||||
* body of the message). You could just use the CURLOPT_READDATA option to
|
||||
* specify a FILE pointer to read from. */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* Since the traffic will be encrypted, it is very useful to turn on debug
|
||||
* information within libcurl to see what is happening during the transfer.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* send the message (including headers) */
|
||||
/* Send the message */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* free the list of recipients and clean up */
|
||||
/* Free the list of recipients */
|
||||
curl_slist_free_all(recipients);
|
||||
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
73
docs/examples/smtp-vrfy.c
Normal file
73
docs/examples/smtp-vrfy.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to verify an email address from an
|
||||
* SMTP server.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* 1) This example requires libcurl 7.34.0 or above.
|
||||
* 2) Not all email servers support this command and even if your email server
|
||||
* does support it, it may respond with a 252 response code even though the
|
||||
* address doesn't exist.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
struct curl_slist *recipients = NULL;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* This is the URL for your mailserver */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
|
||||
|
||||
/* Note that the CURLOPT_MAIL_RCPT takes a list, not a char array */
|
||||
recipients = curl_slist_append(recipients, "<recipient@example.com>");
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
/* Perform the VRFY */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* Free the list of recipients */
|
||||
curl_slist_free_all(recipients);
|
||||
|
||||
/* Curl won't send the QUIT command until you call cleanup, so you should
|
||||
* be able to re-use this connection for additional requests. It may not be
|
||||
* a good idea to keep the connection open for a very long time though
|
||||
* (more than a few minutes may result in the server timing out the
|
||||
* connection) and you do want to clean up in the end.
|
||||
*/
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -31,8 +31,8 @@ curl_easy_pause - pause and unpause a connection
|
||||
Using this function, you can explicitly mark a running connection to get
|
||||
paused, and you can unpause a connection that was previously paused.
|
||||
|
||||
A connection can be paused by using this function or by letting the read
|
||||
or the write callbacks return the proper magic return code
|
||||
A connection can be paused by using this function or by letting the read or
|
||||
the write callbacks return the proper magic return code
|
||||
(\fICURL_READFUNC_PAUSE\fP and \fICURL_WRITEFUNC_PAUSE\fP). A write callback
|
||||
that returns pause signals to the library that it couldn't take care of any
|
||||
data at all, and that data will then be delivered again to the callback when
|
||||
@@ -68,6 +68,10 @@ Convenience define that unpauses both directions
|
||||
CURLE_OK (zero) means that the option was set properly, and a non-zero return
|
||||
code means something wrong occurred after the new state was set. See the
|
||||
\fIlibcurl-errors(3)\fP man page for the full list with descriptions.
|
||||
.SH LIMITATIONS
|
||||
The pausing of transfers does not work with protocols that work without
|
||||
network connectivity, like FILE://. Trying to pause such a transfer, in any
|
||||
direction, will cause problems in the worst case or an error in the best case.
|
||||
.SH AVAILABILITY
|
||||
This function was added in libcurl 7.18.0. Before this version, there was no
|
||||
explicit support for pausing transfers.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
@@ -1150,7 +1150,7 @@ connections or \fICURLOPT_LOGIN_OPTIONS\fP to control IMAP, POP3 and SMTP
|
||||
options.
|
||||
|
||||
The user and password strings are not URL decoded, so there's no way to send
|
||||
in a user name containing a colon using this option. Use \fCURLOPT_USERNAME\fP
|
||||
in a user name containing a colon using this option. Use \fICURLOPT_USERNAME\fP
|
||||
for that, or include it in the URL.
|
||||
.IP CURLOPT_PROXYUSERPWD
|
||||
Pass a char * as parameter, which should be [user name]:[password] to use for
|
||||
@@ -1184,7 +1184,7 @@ At present only IMAP, POP3 and SMTP support login options. For more
|
||||
information about the login options please see RFC2384, RFC5092 and IETF draft
|
||||
draft-earhart-url-smtp-00.txt
|
||||
|
||||
\CURLOPT_LOGIN_OPTIONS\fP can be used to set protocol specific login options,
|
||||
\fBCURLOPT_LOGIN_OPTIONS\fP can be used to set protocol specific login options,
|
||||
such as the preferred authentication mechanism via "AUTH=NTLM" or "AUTH=*",
|
||||
and should be used in conjunction with the \fICURLOPT_USERNAME\fP option.
|
||||
.IP CURLOPT_PROXYUSERNAME
|
||||
@@ -1306,8 +1306,7 @@ authentication methods it supports and then pick the best one you allow it to
|
||||
use. For some methods, this will induce an extra network round-trip. Set the
|
||||
actual name and password with the \fICURLOPT_PROXYUSERPWD\fP option. The
|
||||
bitmask can be constructed by or'ing together the bits listed above for the
|
||||
\fICURLOPT_HTTPAUTH\fP option. As of this writing, only Basic, Digest and NTLM
|
||||
work. (Added in 7.10.7)
|
||||
\fICURLOPT_HTTPAUTH\fP option. \fICURLOPT_PROXYAUTH\fP was added in 7.10.7
|
||||
.IP CURLOPT_SASL_IR
|
||||
Pass a long. If the value is 1, curl will send the initial response to the
|
||||
server in the first authentication packet in order to reduce the number of
|
||||
@@ -1317,10 +1316,10 @@ mechanisms and to the IMAP, POP3 and SMTP protocols. (Added in 7.31.0)
|
||||
Note: Whilst IMAP supports this option there is no need to explicitly set it,
|
||||
as libcurl can determine the feature itself when the server supports the
|
||||
SASL-IR CAPABILITY.
|
||||
.IP CURLOPT_BEARER
|
||||
Pass a char * as parameter, which should point to the zero terminated OAUTH
|
||||
2.0 Bearer Access Token for use with IMAP. POP3 and SMTP servers that support
|
||||
the OAUTH 2.0 Authorization Framework. (Added in 7.33.0)
|
||||
.IP CURLOPT_XOAUTH2_BEARER
|
||||
Pass a char * as parameter, which should point to the zero terminated OAuth
|
||||
2.0 Bearer Access Token for use with IMAP, POP3 and SMTP servers that support
|
||||
the OAuth 2.0 Authorization Framework. (Added in 7.33.0)
|
||||
|
||||
Note: The user name used to generate the Bearer Token should be supplied via
|
||||
the \fICURLOPT_USERNAME\fP option.
|
||||
@@ -2134,6 +2133,8 @@ as a long. See also \fICURLOPT_INFILESIZE_LARGE\fP.
|
||||
For uploading using SCP, this option or \fICURLOPT_INFILESIZE_LARGE\fP is
|
||||
mandatory.
|
||||
|
||||
To "unset" this value again, set it to -1.
|
||||
|
||||
When sending emails using SMTP, this command can be used to specify the
|
||||
optional SIZE parameter for the MAIL FROM command. (Added in 7.23.0)
|
||||
|
||||
@@ -2146,6 +2147,11 @@ as a curl_off_t. (Added in 7.11.0)
|
||||
|
||||
For uploading using SCP, this option or \fICURLOPT_INFILESIZE\fP is mandatory.
|
||||
|
||||
To "unset" this value again, set it to -1.
|
||||
|
||||
When sending emails using SMTP, this command can be used to specify the
|
||||
optional SIZE parameter for the MAIL FROM command. (Added in 7.23.0)
|
||||
|
||||
This option does not limit how much data libcurl will actually send, as that
|
||||
is controlled entirely by what the read callback returns.
|
||||
.IP CURLOPT_UPLOAD
|
||||
@@ -2229,12 +2235,18 @@ it too slow and abort.
|
||||
Pass a curl_off_t as parameter. If an upload exceeds this speed (counted in
|
||||
bytes per second) on cumulative average during the transfer, the transfer will
|
||||
pause to keep the average rate less than or equal to the parameter value.
|
||||
Defaults to unlimited speed. (Added in 7.15.5)
|
||||
Defaults to unlimited speed.
|
||||
|
||||
This option doesn't affect transfer speeds done with FILE:// URLs. (Added in
|
||||
7.15.5)
|
||||
.IP CURLOPT_MAX_RECV_SPEED_LARGE
|
||||
Pass a curl_off_t as parameter. If a download exceeds this speed (counted in
|
||||
bytes per second) on cumulative average during the transfer, the transfer will
|
||||
pause to keep the average rate less than or equal to the parameter
|
||||
value. Defaults to unlimited speed. (Added in 7.15.5)
|
||||
value. Defaults to unlimited speed.
|
||||
|
||||
This option doesn't affect transfer speeds done with FILE:// URLs. (Added in
|
||||
7.15.5)
|
||||
.IP CURLOPT_MAXCONNECTS
|
||||
Pass a long. The set number will be the persistent connection cache size. The
|
||||
set amount will be the maximum amount of simultaneously open connections that
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
@@ -21,22 +21,17 @@
|
||||
.\" **************************************************************************
|
||||
.TH curl_getdate 3 "12 Aug 2005" "libcurl 7.0" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_getdate - Convert a date string to number of seconds since January 1,
|
||||
1970
|
||||
curl_getdate - Convert a date string to number of seconds
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
.sp
|
||||
.BI "time_t curl_getdate(char *" datestring ", time_t *"now " );"
|
||||
.ad
|
||||
.SH DESCRIPTION
|
||||
This function returns the number of seconds since January 1st 1970 in the UTC
|
||||
time zone, for the date and time that the \fIdatestring\fP parameter
|
||||
specifies. The \fInow\fP parameter is not used, pass a NULL there.
|
||||
|
||||
\fBNOTE:\fP This function was rewritten for the 7.12.2 release and this
|
||||
documentation covers the functionality of the new one. The new one is not
|
||||
feature-complete with the old one, but most of the formats supported by the
|
||||
new one was supported by the old too.
|
||||
\fIcurl_getdate(3)\fP returns the number of seconds since the Epoch, January
|
||||
1st 1970 00:00:00 in the UTC time zone, for the date and time that the
|
||||
\fIdatestring\fP parameter specifies. The \fInow\fP parameter is not used,
|
||||
pass a NULL there.
|
||||
.SH PARSING DATES AND TIMES
|
||||
A "date" is a string containing several items separated by whitespace. The
|
||||
order of the items is immaterial. A date string may contain many flavors of
|
||||
@@ -108,10 +103,3 @@ number).
|
||||
Having a 64 bit time_t is not a guarantee that dates beyond 03:14:07 UTC,
|
||||
January 19, 2038 will work fine. On systems with a 64 bit time_t but with a
|
||||
crippled mktime(), \fIcurl_getdate\fP will return -1 in this case.
|
||||
.SH REWRITE
|
||||
The former version of this function was built with yacc and was not only very
|
||||
large, it was also never quite understood and it wasn't possible to build with
|
||||
non-GNU tools since only GNU Bison could make it thread-safe!
|
||||
|
||||
The rewrite was done for 7.12.2. The new one is much smaller and uses simpler
|
||||
code.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 2008 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" * Copyright (C) 2008 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
@@ -20,7 +20,7 @@
|
||||
.\" *
|
||||
.\" **************************************************************************
|
||||
.\"
|
||||
.TH mk-ca-bundle 1 "5 Jan 2013" "version 1.17" "mk-ca-bundle manual"
|
||||
.TH mk-ca-bundle 1 "5 Jan 2013" "version 1.20" "mk-ca-bundle manual"
|
||||
.SH NAME
|
||||
mk-ca-bundle \- convert mozilla's certdata.txt to PEM format
|
||||
.SH SYNOPSIS
|
||||
@@ -42,6 +42,10 @@ curl, wget and more.
|
||||
The following options are supported:
|
||||
.IP -b
|
||||
backup an existing version of \fIoutputfilename\fP
|
||||
.IP -d [name]
|
||||
specify which Mozilla tree to pull certdata.txt from (or a custom URL). Valid
|
||||
names are: aurora, beta, central, mozilla, nss, release (default). They are
|
||||
shortcuts for which source tree to get the cert data from.
|
||||
.IP -f
|
||||
force rebuild even if certdata.txt is current (Added in version 1.17)
|
||||
.IP -i
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -26,17 +26,17 @@
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2013 Daniel Stenberg, <daniel@haxx.se>."
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2014 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.34.0-DEV"
|
||||
#define LIBCURL_VERSION "7.34.1-DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 34
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
#define LIBCURL_VERSION_PATCH 1
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||
@@ -53,7 +53,7 @@
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x072200
|
||||
#define LIBCURL_VERSION_NUM 0x072201
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
|
||||
@@ -60,20 +60,15 @@ CFLAGS += @CURL_CFLAG_EXTRAS@
|
||||
# $(top_builddir)/ares is for in-tree c-ares's generated ares_build.h file
|
||||
# $(top_srcdir)/ares is for in-tree c-ares's external include files
|
||||
|
||||
if USE_EMBEDDED_ARES
|
||||
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(top_srcdir)/lib \
|
||||
-I$(top_builddir)/ares \
|
||||
-I$(top_srcdir)/ares
|
||||
else
|
||||
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(top_srcdir)/lib
|
||||
|
||||
if USE_EMBEDDED_ARES
|
||||
AM_CPPFLAGS += -I$(top_builddir)/ares \
|
||||
-I$(top_srcdir)/ares
|
||||
endif
|
||||
|
||||
# Prevent LIBS from being used for all link targets
|
||||
|
||||
104
lib/Makefile.inc
104
lib/Makefile.inc
@@ -1,49 +1,65 @@
|
||||
# ./lib/Makefile.inc
|
||||
# Using the backslash as line continuation character might be problematic
|
||||
# with some make flavours, as Watcom's wmake showed us already. If we
|
||||
# ever want to change this in a portable manner then we should consider
|
||||
# this idea (posted to the libcurl list by Adam Kellas):
|
||||
# CSRC1 = file1.c file2.c file3.c
|
||||
# CSRC2 = file4.c file5.c file6.c
|
||||
# CSOURCES = $(CSRC1) $(CSRC2)
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
VSOURCES=vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c vtls/qssl.c \
|
||||
vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c vtls/cyassl.c \
|
||||
vtls/curl_schannel.c vtls/curl_darwinssl.c vtls/gskit.c
|
||||
VHEADERS= vtls/qssl.h vtls/openssl.h vtls/vtls.h vtls/gtls.h \
|
||||
vtls/nssg.h vtls/polarssl.h vtls/polarssl_threadlock.h vtls/axtls.h \
|
||||
vtls/cyassl.h vtls/curl_schannel.h vtls/curl_darwinssl.h vtls/gskit.h
|
||||
|
||||
CSOURCES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
|
||||
cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c \
|
||||
ldap.c ssluse.c version.c getenv.c escape.c mprintf.c telnet.c \
|
||||
netrc.c getinfo.c transfer.c strequal.c easy.c security.c \
|
||||
curl_fnmatch.c fileinfo.c ftplistparser.c wildcard.c krb5.c \
|
||||
memdebug.c http_chunks.c strtok.c connect.c llist.c hash.c multi.c \
|
||||
content_encoding.c share.c http_digest.c md4.c md5.c \
|
||||
http_negotiate.c inet_pton.c strtoofft.c strerror.c amigaos.c \
|
||||
hostasyn.c hostip4.c hostip6.c hostsyn.c inet_ntop.c parsedate.c \
|
||||
select.c gtls.c sslgen.c tftp.c splay.c strdup.c socks.c ssh.c nss.c \
|
||||
qssl.c rawstr.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \
|
||||
ldap.c version.c getenv.c escape.c mprintf.c telnet.c netrc.c \
|
||||
getinfo.c transfer.c strequal.c easy.c security.c curl_fnmatch.c \
|
||||
fileinfo.c ftplistparser.c wildcard.c krb5.c memdebug.c http_chunks.c \
|
||||
strtok.c connect.c llist.c hash.c multi.c content_encoding.c share.c \
|
||||
http_digest.c md4.c md5.c http_negotiate.c inet_pton.c strtoofft.c \
|
||||
strerror.c amigaos.c hostasyn.c hostip4.c hostip6.c hostsyn.c \
|
||||
inet_ntop.c parsedate.c select.c tftp.c splay.c strdup.c socks.c \
|
||||
ssh.c rawstr.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \
|
||||
curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \
|
||||
pingpong.c rtsp.c curl_threads.c warnless.c hmac.c polarssl.c \
|
||||
polarssl_threadlock.c curl_rtmp.c openldap.c curl_gethostname.c \
|
||||
gopher.c axtls.c idn_win32.c http_negotiate_sspi.c cyassl.c \
|
||||
http_proxy.c non-ascii.c asyn-ares.c asyn-thread.c curl_gssapi.c \
|
||||
curl_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_ntlm_msgs.c \
|
||||
curl_sasl.c curl_schannel.c curl_multibyte.c curl_darwinssl.c \
|
||||
hostcheck.c bundles.c conncache.c pipeline.c dotdot.c x509asn1.c \
|
||||
gskit.c http2.c
|
||||
pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \
|
||||
openldap.c curl_gethostname.c gopher.c idn_win32.c \
|
||||
http_negotiate_sspi.c http_proxy.c non-ascii.c asyn-ares.c \
|
||||
asyn-thread.c curl_gssapi.c curl_ntlm.c curl_ntlm_wb.c \
|
||||
curl_ntlm_core.c curl_ntlm_msgs.c curl_sasl.c curl_multibyte.c \
|
||||
hostcheck.c bundles.c conncache.c pipeline.c dotdot.c x509asn1.c \
|
||||
http2.c $(VSOURCES)
|
||||
|
||||
HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \
|
||||
progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h \
|
||||
if2ip.h speedcheck.h urldata.h curl_ldap.h ssluse.h escape.h telnet.h \
|
||||
getinfo.h strequal.h curl_sec.h memdebug.h http_chunks.h \
|
||||
curl_fnmatch.h wildcard.h fileinfo.h ftplistparser.h strtok.h \
|
||||
connect.h llist.h hash.h content_encoding.h share.h curl_md4.h \
|
||||
curl_md5.h http_digest.h http_negotiate.h inet_pton.h amigaos.h \
|
||||
strtoofft.h strerror.h inet_ntop.h curlx.h curl_memory.h curl_setup.h \
|
||||
transfer.h select.h easyif.h multiif.h parsedate.h sslgen.h gtls.h \
|
||||
tftp.h sockaddr.h splay.h strdup.h socks.h ssh.h nssg.h curl_base64.h \
|
||||
rawstr.h curl_addrinfo.h curl_sspi.h slist.h nonblock.h \
|
||||
curl_memrchr.h imap.h pop3.h smtp.h pingpong.h rtsp.h curl_threads.h \
|
||||
warnless.h curl_hmac.h polarssl.h polarssl_threadlock.h curl_rtmp.h \
|
||||
curl_gethostname.h gopher.h axtls.h cyassl.h http_proxy.h non-ascii.h \
|
||||
asyn.h curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \
|
||||
curl_ntlm_msgs.h curl_sasl.h curl_schannel.h curl_multibyte.h \
|
||||
curl_darwinssl.h hostcheck.h bundles.h conncache.h curl_setup_once.h \
|
||||
multihandle.h setup-vms.h pipeline.h dotdot.h x509asn1.h gskit.h \
|
||||
http2.h sigpipe.h
|
||||
HHEADERS = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
|
||||
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
|
||||
speedcheck.h urldata.h curl_ldap.h escape.h telnet.h getinfo.h \
|
||||
strequal.h curl_sec.h memdebug.h http_chunks.h curl_fnmatch.h \
|
||||
wildcard.h fileinfo.h ftplistparser.h strtok.h connect.h llist.h \
|
||||
hash.h content_encoding.h share.h curl_md4.h curl_md5.h http_digest.h \
|
||||
http_negotiate.h inet_pton.h amigaos.h strtoofft.h strerror.h \
|
||||
inet_ntop.h curlx.h curl_memory.h curl_setup.h transfer.h select.h \
|
||||
easyif.h multiif.h parsedate.h tftp.h sockaddr.h splay.h strdup.h \
|
||||
socks.h ssh.h curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h \
|
||||
slist.h nonblock.h curl_memrchr.h imap.h pop3.h smtp.h pingpong.h \
|
||||
rtsp.h curl_threads.h warnless.h curl_hmac.h curl_rtmp.h \
|
||||
curl_gethostname.h gopher.h http_proxy.h non-ascii.h asyn.h \
|
||||
curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \
|
||||
curl_ntlm_msgs.h curl_sasl.h curl_multibyte.h hostcheck.h bundles.h \
|
||||
conncache.h curl_setup_once.h multihandle.h setup-vms.h pipeline.h \
|
||||
dotdot.h x509asn1.h http2.h sigpipe.h $(VHEADERS)
|
||||
|
||||
@@ -315,10 +315,12 @@ endif
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include Makefile.inc
|
||||
|
||||
OBJS := $(patsubst %.c,$(OBJDIR)/%.o,$(strip $(CSOURCES))) $(OBJDIR)/nwos.o
|
||||
OBJS := $(patsubst %.c,$(OBJDIR)/%.o,$(strip $(notdir $(CSOURCES)))) $(OBJDIR)/nwos.o
|
||||
|
||||
OBJL = $(OBJS) $(OBJDIR)/nwlib.o $(LDLIBS)
|
||||
|
||||
vpath %.c . vtls
|
||||
|
||||
all: lib nlm
|
||||
|
||||
nlm: prebuild $(TARGET).nlm
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1999 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
# Copyright (C) 1999 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
@@ -165,6 +165,18 @@ CC = $(CCNODBG) $(RTLIB) $(CFLAGSSSL) $(CFLAGSLIB)
|
||||
CFGSET = TRUE
|
||||
!ENDIF
|
||||
|
||||
######################
|
||||
# release-winssl
|
||||
|
||||
!IF "$(CFG)" == "release-winssl"
|
||||
TARGET = $(LIBCURL_STA_LIB_REL)
|
||||
DIROBJ = $(CFG)
|
||||
LFLAGSZLIB = "/LIBPATH:$(ZLIB_PATH)"
|
||||
LNK = $(LNKLIB) /out:$(DIROBJ)\$(TARGET)
|
||||
CC = $(CCNODBG) $(RTLIB) $(CFLAGSWINSSL) $(CFLAGSLIB)
|
||||
CFGSET = TRUE
|
||||
!ENDIF
|
||||
|
||||
######################
|
||||
# release-zlib
|
||||
|
||||
@@ -601,8 +613,8 @@ X_OBJS= \
|
||||
$(DIROBJ)\speedcheck.obj \
|
||||
$(DIROBJ)\splay.obj \
|
||||
$(DIROBJ)\ssh.obj \
|
||||
$(DIROBJ)\sslgen.obj \
|
||||
$(DIROBJ)\ssluse.obj \
|
||||
$(DIROBJ)\vtls.obj \
|
||||
$(DIROBJ)\openssl.obj \
|
||||
$(DIROBJ)\strdup.obj \
|
||||
$(DIROBJ)\strequal.obj \
|
||||
$(DIROBJ)\strerror.obj \
|
||||
@@ -641,6 +653,9 @@ $(DIROBJ):
|
||||
{.\}.c{$(DIROBJ)\}.obj:
|
||||
$(CC) $(CFLAGS) /Fo"$@" $<
|
||||
|
||||
{.\vtls\}.c{$(DIROBJ)\}.obj:
|
||||
$(CC) $(CFLAGS) /Fo"$@" $<
|
||||
|
||||
debug-dll\libcurl.res \
|
||||
debug-dll-ssl-dll\libcurl.res \
|
||||
debug-dll-zlib-dll\libcurl.res \
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -209,7 +209,7 @@ int init_thread_sync_data(struct thread_sync_data * tsd,
|
||||
memset(tsd, 0, sizeof(*tsd));
|
||||
|
||||
tsd->port = port;
|
||||
#ifdef CURLRES_IPV6
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
DEBUGASSERT(hints);
|
||||
tsd->hints = *hints;
|
||||
#else
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2012, Linus Nielsen Feltzing, <linus@haxx.se>
|
||||
* Copyright (C) 2012 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2012 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -166,10 +166,13 @@ void Curl_conncache_remove_conn(struct conncache *connc,
|
||||
if(bundle->num_connections == 0) {
|
||||
conncache_remove_bundle(connc, bundle);
|
||||
}
|
||||
connc->num_connections--;
|
||||
|
||||
DEBUGF(infof(conn->data, "The cache now contains %d members\n",
|
||||
connc->num_connections));
|
||||
if(connc) {
|
||||
connc->num_connections--;
|
||||
|
||||
DEBUGF(infof(conn->data, "The cache now contains %d members\n",
|
||||
connc->num_connections));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -71,7 +71,7 @@
|
||||
#include "sockaddr.h" /* required for Curl_sockaddr_storage */
|
||||
#include "inet_ntop.h"
|
||||
#include "inet_pton.h"
|
||||
#include "sslgen.h" /* for Curl_ssl_check_cxn() */
|
||||
#include "vtls/vtls.h" /* for Curl_ssl_check_cxn() */
|
||||
#include "progress.h"
|
||||
#include "warnless.h"
|
||||
#include "conncache.h"
|
||||
@@ -556,7 +556,11 @@ static CURLcode trynextip(struct connectdata *conn,
|
||||
else {
|
||||
/* happy eyeballs - try the other protocol family */
|
||||
int firstfamily = conn->tempaddr[0]->ai_family;
|
||||
#ifdef ENABLE_IPV6
|
||||
family = (firstfamily == AF_INET) ? AF_INET6 : AF_INET;
|
||||
#else
|
||||
family = firstfamily;
|
||||
#endif
|
||||
ai = conn->tempaddr[0]->ai_next;
|
||||
}
|
||||
|
||||
@@ -653,6 +657,10 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
|
||||
struct Curl_sockaddr_storage ssloc;
|
||||
struct SessionHandle *data = conn->data;
|
||||
|
||||
if(conn->socktype == SOCK_DGRAM)
|
||||
/* there's no connection! */
|
||||
return;
|
||||
|
||||
if(!conn->bits.reuse) {
|
||||
|
||||
len = sizeof(struct Curl_sockaddr_storage);
|
||||
@@ -908,19 +916,40 @@ void Curl_sndbufset(curl_socket_t sockfd)
|
||||
int val = CURL_MAX_WRITE_SIZE + 32;
|
||||
int curval = 0;
|
||||
int curlen = sizeof(curval);
|
||||
DWORD majorVersion = 6;
|
||||
|
||||
OSVERSIONINFO osver;
|
||||
static int detectOsState = DETECT_OS_NONE;
|
||||
|
||||
if(detectOsState == DETECT_OS_NONE) {
|
||||
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
|
||||
(_WIN32_WINNT < _WIN32_WINNT_WIN2K)
|
||||
OSVERSIONINFO osver;
|
||||
|
||||
memset(&osver, 0, sizeof(osver));
|
||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
||||
|
||||
detectOsState = DETECT_OS_PREVISTA;
|
||||
if(GetVersionEx(&osver)) {
|
||||
if(osver.dwMajorVersion >= 6)
|
||||
if(osver.dwMajorVersion >= majorVersion)
|
||||
detectOsState = DETECT_OS_VISTA_OR_LATER;
|
||||
}
|
||||
#else
|
||||
ULONGLONG majorVersionMask;
|
||||
OSVERSIONINFOEX osver;
|
||||
|
||||
memset(&osver, 0, sizeof(osver));
|
||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
||||
osver.dwMajorVersion = majorVersion;
|
||||
majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION,
|
||||
VER_GREATER_EQUAL);
|
||||
|
||||
if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask))
|
||||
detectOsState = DETECT_OS_VISTA_OR_LATER;
|
||||
else
|
||||
detectOsState = DETECT_OS_PREVISTA;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(detectOsState == DETECT_OS_VISTA_OR_LATER)
|
||||
return;
|
||||
|
||||
@@ -932,7 +961,6 @@ void Curl_sndbufset(curl_socket_t sockfd)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* singleipconnect()
|
||||
*
|
||||
@@ -1081,7 +1109,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
||||
{
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct timeval before = Curl_tvnow();
|
||||
CURLcode res;
|
||||
CURLcode res = CURLE_COULDNT_CONNECT;
|
||||
|
||||
long timeout_ms = Curl_timeleft(data, &before, TRUE);
|
||||
|
||||
@@ -1096,20 +1124,19 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
||||
conn->tempaddr[1] = NULL;
|
||||
conn->tempsock[0] = CURL_SOCKET_BAD;
|
||||
conn->tempsock[1] = CURL_SOCKET_BAD;
|
||||
Curl_expire(conn->data,
|
||||
HAPPY_EYEBALLS_TIMEOUT + (MULTI_TIMEOUT_INACCURACY/1000));
|
||||
Curl_expire(conn->data, HAPPY_EYEBALLS_TIMEOUT);
|
||||
|
||||
/* Max time for the next connection attempt */
|
||||
conn->timeoutms_per_addr =
|
||||
conn->tempaddr[0]->ai_next == NULL ? timeout_ms : timeout_ms / 2;
|
||||
|
||||
/* start connecting to first IP */
|
||||
res = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0]));
|
||||
while(res != CURLE_OK &&
|
||||
conn->tempaddr[0] &&
|
||||
conn->tempaddr[0]->ai_next &&
|
||||
conn->tempsock[0] == CURL_SOCKET_BAD)
|
||||
res = trynextip(conn, FIRSTSOCKET, 0);
|
||||
while(conn->tempaddr[0]) {
|
||||
res = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0]));
|
||||
if(res == CURLE_OK)
|
||||
break;
|
||||
conn->tempaddr[0] = conn->tempaddr[0]->ai_next;
|
||||
}
|
||||
|
||||
if(conn->tempsock[0] == CURL_SOCKET_BAD)
|
||||
return res;
|
||||
|
||||
44
lib/cookie.c
44
lib/cookie.c
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -489,9 +489,6 @@ Curl_cookie_add(struct SessionHandle *data,
|
||||
badcookie = TRUE;
|
||||
break;
|
||||
}
|
||||
co->expires =
|
||||
strtol((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0],NULL,10)
|
||||
+ (long)now;
|
||||
}
|
||||
else if(Curl_raw_equal("expires", name)) {
|
||||
strstore(&co->expirestr, whatptr);
|
||||
@@ -499,17 +496,6 @@ Curl_cookie_add(struct SessionHandle *data,
|
||||
badcookie = TRUE;
|
||||
break;
|
||||
}
|
||||
/* Note that if the date couldn't get parsed for whatever reason,
|
||||
the cookie will be treated as a session cookie */
|
||||
co->expires = curl_getdate(what, &now);
|
||||
|
||||
/* Session cookies have expires set to 0 so if we get that back
|
||||
from the date parser let's add a second to make it a
|
||||
non-session cookie */
|
||||
if(co->expires == 0)
|
||||
co->expires = 1;
|
||||
else if(co->expires < 0)
|
||||
co->expires = 0;
|
||||
}
|
||||
else if(!co->name) {
|
||||
co->name = strdup(name);
|
||||
@@ -544,6 +530,30 @@ Curl_cookie_add(struct SessionHandle *data,
|
||||
semiptr=strchr(ptr, '\0');
|
||||
} while(semiptr);
|
||||
|
||||
if(co->maxage) {
|
||||
co->expires =
|
||||
curlx_strtoofft((*co->maxage=='\"')?
|
||||
&co->maxage[1]:&co->maxage[0], NULL, 10);
|
||||
if(CURL_OFF_T_MAX - now < co->expires)
|
||||
/* avoid overflow */
|
||||
co->expires = CURL_OFF_T_MAX;
|
||||
else
|
||||
co->expires += now;
|
||||
}
|
||||
else if(co->expirestr) {
|
||||
/* Note that if the date couldn't get parsed for whatever reason,
|
||||
the cookie will be treated as a session cookie */
|
||||
co->expires = curl_getdate(co->expirestr, NULL);
|
||||
|
||||
/* Session cookies have expires set to 0 so if we get that back
|
||||
from the date parser let's add a second to make it a
|
||||
non-session cookie */
|
||||
if(co->expires == 0)
|
||||
co->expires = 1;
|
||||
else if(co->expires < 0)
|
||||
co->expires = 0;
|
||||
}
|
||||
|
||||
if(!badcookie && !co->domain) {
|
||||
if(domain) {
|
||||
/* no domain was given in the header line, set the default */
|
||||
@@ -815,7 +825,7 @@ Curl_cookie_add(struct SessionHandle *data,
|
||||
if(c->running)
|
||||
/* Only show this when NOT reading the cookies from a file */
|
||||
infof(data, "%s cookie %s=\"%s\" for domain %s, path %s, "
|
||||
"expire %" FORMAT_OFF_T "\n",
|
||||
"expire %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
replace_old?"Replaced":"Added", co->name, co->value,
|
||||
co->domain, co->path, co->expires);
|
||||
|
||||
@@ -1172,7 +1182,7 @@ static char *get_netscape_format(const struct Cookie *co)
|
||||
"%s\t" /* tailmatch */
|
||||
"%s\t" /* path */
|
||||
"%s\t" /* secure */
|
||||
"%" FORMAT_OFF_T "\t" /* expires */
|
||||
"%" CURL_FORMAT_CURL_OFF_T "\t" /* expires */
|
||||
"%s\t" /* name */
|
||||
"%s", /* value */
|
||||
co->httponly?"#HttpOnly_":"",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <curl/mprintf.h>
|
||||
|
||||
#if defined(USE_NSS)
|
||||
#include "nssg.h"
|
||||
#include "vtls/nssg.h"
|
||||
#elif defined(USE_WINDOWS_SSPI)
|
||||
#include "curl_sspi.h"
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
# include "curl_sspi.h"
|
||||
#endif
|
||||
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
|
||||
#define BUILDING_CURL_NTLM_MSGS_C
|
||||
#include "curl_ntlm_msgs.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2012 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2012 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include "curl_base64.h"
|
||||
#include "curl_md5.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "curl_hmac.h"
|
||||
#include "curl_ntlm_msgs.h"
|
||||
#include "curl_sasl.h"
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "curl_memory.h"
|
||||
|
||||
#ifdef USE_NSS
|
||||
#include "nssg.h" /* for Curl_nss_force_init() */
|
||||
#include "vtls/nssg.h" /* for Curl_nss_force_init() */
|
||||
#endif
|
||||
|
||||
#define _MPRINTF_REPLACE /* use our functions only */
|
||||
|
||||
@@ -139,29 +139,6 @@
|
||||
Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set up internal curl_off_t formatting string directives for
|
||||
* exclusive use with libcurl's internal *printf functions.
|
||||
*/
|
||||
|
||||
#ifdef FORMAT_OFF_T
|
||||
# error "FORMAT_OFF_T shall not be defined before this point!"
|
||||
Error Compilation_aborted_FORMAT_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef FORMAT_OFF_TU
|
||||
# error "FORMAT_OFF_TU shall not be defined before this point!"
|
||||
Error Compilation_aborted_FORMAT_OFF_TU_already_defined
|
||||
#endif
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
|
||||
# define FORMAT_OFF_T "lld"
|
||||
# define FORMAT_OFF_TU "llu"
|
||||
#else
|
||||
# define FORMAT_OFF_T "ld"
|
||||
# define FORMAT_OFF_TU "lu"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Disable other protocols when http is the only one desired.
|
||||
*/
|
||||
|
||||
@@ -68,25 +68,52 @@ PSecurityFunctionTable s_pSecFn = NULL;
|
||||
*/
|
||||
CURLcode Curl_sspi_global_init(void)
|
||||
{
|
||||
OSVERSIONINFO osver;
|
||||
bool securityDll = FALSE;
|
||||
INITSECURITYINTERFACE_FN pInitSecurityInterface;
|
||||
|
||||
/* If security interface is not yet initialized try to do this */
|
||||
if(!s_hSecDll) {
|
||||
|
||||
/* Find out Windows version */
|
||||
memset(&osver, 0, sizeof(osver));
|
||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
||||
if(!GetVersionEx(&osver))
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
/* Security Service Provider Interface (SSPI) functions are located in
|
||||
* security.dll on WinNT 4.0 and in secur32.dll on Win9x. Win2K and XP
|
||||
* have both these DLLs (security.dll forwards calls to secur32.dll) */
|
||||
DWORD majorVersion = 4;
|
||||
DWORD platformId = VER_PLATFORM_WIN32_NT;
|
||||
|
||||
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
|
||||
(_WIN32_WINNT < _WIN32_WINNT_WIN2K)
|
||||
OSVERSIONINFO osver;
|
||||
|
||||
memset(&osver, 0, sizeof(osver));
|
||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
||||
|
||||
/* Find out Windows version */
|
||||
if(!GetVersionEx(&osver))
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
/* Verify the major version number == 4 and platform id == WIN_NT */
|
||||
if(osver.dwMajorVersion == majorVersion &&
|
||||
osver.dwPlatformId == platformId)
|
||||
securityDll = TRUE;
|
||||
#else
|
||||
ULONGLONG majorVersionMask;
|
||||
ULONGLONG platformIdMask;
|
||||
OSVERSIONINFOEX osver;
|
||||
|
||||
memset(&osver, 0, sizeof(osver));
|
||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
||||
osver.dwMajorVersion = majorVersion;
|
||||
osver.dwPlatformId = platformId;
|
||||
majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
|
||||
platformIdMask = VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL);
|
||||
|
||||
/* Verify the major version number == 4 and platform id == WIN_NT */
|
||||
if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask) &&
|
||||
VerifyVersionInfo(&osver, VER_PLATFORMID, platformIdMask))
|
||||
securityDll = TRUE;
|
||||
#endif
|
||||
|
||||
/* Load SSPI dll into the address space of the calling process */
|
||||
if(osver.dwPlatformId == VER_PLATFORM_WIN32_NT
|
||||
&& osver.dwMajorVersion == 4)
|
||||
if(securityDll)
|
||||
s_hSecDll = LoadLibrary(TEXT("security.dll"));
|
||||
else
|
||||
s_hSecDll = LoadLibrary(TEXT("secur32.dll"));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -63,32 +63,38 @@ static void *curl_thread_create_thunk(void *arg)
|
||||
|
||||
curl_thread_t Curl_thread_create(unsigned int (*func) (void*), void *arg)
|
||||
{
|
||||
curl_thread_t t;
|
||||
curl_thread_t t = malloc(sizeof(pthread_t));
|
||||
struct curl_actual_call *ac = malloc(sizeof(struct curl_actual_call));
|
||||
if(!ac)
|
||||
return curl_thread_t_null;
|
||||
if(!(ac && t))
|
||||
goto err;
|
||||
|
||||
ac->func = func;
|
||||
ac->arg = arg;
|
||||
|
||||
if(pthread_create(&t, NULL, curl_thread_create_thunk, ac) != 0) {
|
||||
free(ac);
|
||||
return curl_thread_t_null;
|
||||
}
|
||||
if(pthread_create(t, NULL, curl_thread_create_thunk, ac) != 0)
|
||||
goto err;
|
||||
|
||||
return t;
|
||||
|
||||
err:
|
||||
Curl_safefree(t);
|
||||
Curl_safefree(ac);
|
||||
return curl_thread_t_null;
|
||||
}
|
||||
|
||||
void Curl_thread_destroy(curl_thread_t hnd)
|
||||
{
|
||||
if(hnd != curl_thread_t_null)
|
||||
pthread_detach(hnd);
|
||||
if(hnd != curl_thread_t_null) {
|
||||
pthread_detach(*hnd);
|
||||
free(hnd);
|
||||
}
|
||||
}
|
||||
|
||||
int Curl_thread_join(curl_thread_t *hnd)
|
||||
{
|
||||
int ret = (pthread_join(*hnd, NULL) == 0);
|
||||
int ret = (pthread_join(**hnd, NULL) == 0);
|
||||
|
||||
free(*hnd);
|
||||
*hnd = curl_thread_t_null;
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#if defined(USE_THREADS_POSIX)
|
||||
# define CURL_STDCALL
|
||||
# define curl_mutex_t pthread_mutex_t
|
||||
# define curl_thread_t pthread_t
|
||||
# define curl_thread_t_null (pthread_t)0
|
||||
# define curl_thread_t pthread_t *
|
||||
# define curl_thread_t_null (pthread_t *)0
|
||||
# define Curl_mutex_init(m) pthread_mutex_init(m, NULL)
|
||||
# define Curl_mutex_acquire(m) pthread_mutex_lock(m)
|
||||
# define Curl_mutex_release(m) pthread_mutex_unlock(m)
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "urldata.h"
|
||||
#include <curl/curl.h>
|
||||
#include "transfer.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "url.h"
|
||||
#include "getinfo.h"
|
||||
#include "hostip.h"
|
||||
|
||||
15
lib/file.c
15
lib/file.c
@@ -152,14 +152,14 @@ static CURLcode file_range(struct connectdata *conn)
|
||||
if((-1 == to) && (from>=0)) {
|
||||
/* X - */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(data, "RANGE %" FORMAT_OFF_T " to end of file\n",
|
||||
DEBUGF(infof(data, "RANGE %" CURL_FORMAT_CURL_OFF_T " to end of file\n",
|
||||
from));
|
||||
}
|
||||
else if(from < 0) {
|
||||
/* -Y */
|
||||
data->req.maxdownload = -from;
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(data, "RANGE the last %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(data, "RANGE the last %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
-from));
|
||||
}
|
||||
else {
|
||||
@@ -167,12 +167,13 @@ static CURLcode file_range(struct connectdata *conn)
|
||||
totalsize = to-from;
|
||||
data->req.maxdownload = totalsize+1; /* include last byte */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(data, "RANGE from %" FORMAT_OFF_T
|
||||
" getting %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(data, "RANGE from %" CURL_FORMAT_CURL_OFF_T
|
||||
" getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, data->req.maxdownload));
|
||||
}
|
||||
DEBUGF(infof(data, "range-download from %" FORMAT_OFF_T
|
||||
" to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(data, "range-download from %" CURL_FORMAT_CURL_OFF_T
|
||||
" to %" CURL_FORMAT_CURL_OFF_T ", totally %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, to, data->req.maxdownload));
|
||||
}
|
||||
else
|
||||
@@ -465,7 +466,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||
if(data->set.opt_no_body && data->set.include_header && fstated) {
|
||||
CURLcode result;
|
||||
snprintf(buf, sizeof(data->state.buffer),
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n", expected_size);
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
|
||||
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "urldata.h" /* for struct SessionHandle */
|
||||
#include "formdata.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "strequal.h"
|
||||
#include "curl_memory.h"
|
||||
#include "sendf.h"
|
||||
|
||||
51
lib/ftp.c
51
lib/ftp.c
@@ -62,7 +62,7 @@
|
||||
#include "curl_sec.h"
|
||||
#include "strtoofft.h"
|
||||
#include "strequal.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "connect.h"
|
||||
#include "strerror.h"
|
||||
#include "inet_ntop.h"
|
||||
@@ -2263,8 +2263,8 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
|
||||
if(data->state.resume_from< 0) {
|
||||
/* We're supposed to download the last abs(from) bytes */
|
||||
if(filesize < -data->state.resume_from) {
|
||||
failf(data, "Offset (%" FORMAT_OFF_T
|
||||
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
|
||||
") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
@@ -2275,8 +2275,8 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
|
||||
}
|
||||
else {
|
||||
if(filesize < data->state.resume_from) {
|
||||
failf(data, "Offset (%" FORMAT_OFF_T
|
||||
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
|
||||
") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
@@ -2298,13 +2298,13 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
|
||||
}
|
||||
|
||||
/* Set resume file transfer offset */
|
||||
infof(data, "Instructs server to resume from offset %" FORMAT_OFF_T
|
||||
"\n", data->state.resume_from);
|
||||
infof(data, "Instructs server to resume from offset %"
|
||||
CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
|
||||
|
||||
PPSENDF(&ftpc->pp, "REST %" FORMAT_OFF_T, data->state.resume_from);
|
||||
PPSENDF(&ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T,
|
||||
data->state.resume_from);
|
||||
|
||||
state(conn, FTP_RETR_REST);
|
||||
|
||||
}
|
||||
else {
|
||||
/* no resume */
|
||||
@@ -2331,7 +2331,7 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
|
||||
#ifdef CURL_FTP_HTTPSTYLE_HEAD
|
||||
if(-1 != filesize) {
|
||||
snprintf(buf, sizeof(data->state.buffer),
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n", filesize);
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", filesize);
|
||||
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
|
||||
if(result)
|
||||
return result;
|
||||
@@ -2508,10 +2508,12 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
|
||||
else if((instate != FTP_LIST) && (data->set.prefer_ascii))
|
||||
size = -1; /* kludge for servers that understate ASCII mode file size */
|
||||
|
||||
infof(data, "Maxdownload = %" FORMAT_OFF_T "\n", data->req.maxdownload);
|
||||
infof(data, "Maxdownload = %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
data->req.maxdownload);
|
||||
|
||||
if(instate != FTP_LIST)
|
||||
infof(data, "Getting file with size: %" FORMAT_OFF_T "\n", size);
|
||||
infof(data, "Getting file with size: %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
size);
|
||||
|
||||
/* FTP download: */
|
||||
conn->proto.ftpc.state_saved = instate;
|
||||
@@ -3367,8 +3369,8 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
|
||||
(data->set.infilesize != *ftp->bytecountp) &&
|
||||
!data->set.crlf &&
|
||||
(ftp->transfer == FTPTRANSFER_BODY)) {
|
||||
failf(data, "Uploaded unaligned file size (%" FORMAT_OFF_T
|
||||
" out of %" FORMAT_OFF_T " bytes)",
|
||||
failf(data, "Uploaded unaligned file size (%" CURL_FORMAT_CURL_OFF_T
|
||||
" out of %" CURL_FORMAT_CURL_OFF_T " bytes)",
|
||||
*ftp->bytecountp, data->set.infilesize);
|
||||
result = CURLE_PARTIAL_FILE;
|
||||
}
|
||||
@@ -3385,8 +3387,8 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
|
||||
*ftp->bytecountp) &&
|
||||
#endif /* CURL_DO_LINEEND_CONV */
|
||||
(data->req.maxdownload != *ftp->bytecountp)) {
|
||||
failf(data, "Received only partial file: %" FORMAT_OFF_T " bytes",
|
||||
*ftp->bytecountp);
|
||||
failf(data, "Received only partial file: %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes", *ftp->bytecountp);
|
||||
result = CURLE_PARTIAL_FILE;
|
||||
}
|
||||
else if(!ftpc->dont_check &&
|
||||
@@ -3551,26 +3553,27 @@ static CURLcode ftp_range(struct connectdata *conn)
|
||||
if((-1 == to) && (from>=0)) {
|
||||
/* X - */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(conn->data, "FTP RANGE %" FORMAT_OFF_T " to end of file\n",
|
||||
from));
|
||||
DEBUGF(infof(conn->data, "FTP RANGE %" CURL_FORMAT_CURL_OFF_T
|
||||
" to end of file\n", from));
|
||||
}
|
||||
else if(from < 0) {
|
||||
/* -Y */
|
||||
data->req.maxdownload = -from;
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(conn->data, "FTP RANGE the last %" FORMAT_OFF_T " bytes\n",
|
||||
-from));
|
||||
DEBUGF(infof(conn->data, "FTP RANGE the last %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes\n", -from));
|
||||
}
|
||||
else {
|
||||
/* X-Y */
|
||||
data->req.maxdownload = (to-from)+1; /* include last byte */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(conn->data, "FTP RANGE from %" FORMAT_OFF_T
|
||||
" getting %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(conn->data, "FTP RANGE from %" CURL_FORMAT_CURL_OFF_T
|
||||
" getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, data->req.maxdownload));
|
||||
}
|
||||
DEBUGF(infof(conn->data, "range-download from %" FORMAT_OFF_T
|
||||
" to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(conn->data, "range-download from %" CURL_FORMAT_CURL_OFF_T
|
||||
" to %" CURL_FORMAT_CURL_OFF_T ", totally %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, to, data->req.maxdownload));
|
||||
ftpc->dont_check = TRUE; /* dont check for successful transfer */
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -449,9 +449,12 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
|
||||
finfo->b_data[parser->item_length - 1] = 0;
|
||||
if(strncmp("total ", finfo->b_data, 6) == 0) {
|
||||
char *endptr = finfo->b_data+6;
|
||||
/* here we can deal with directory size */
|
||||
/* here we can deal with directory size, pass the leading white
|
||||
spaces and then the digits */
|
||||
while(ISSPACE(*endptr))
|
||||
endptr++;
|
||||
while(ISDIGIT(*endptr))
|
||||
endptr++;
|
||||
if(*endptr != 0) {
|
||||
PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
|
||||
return bufflen;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "getinfo.h"
|
||||
|
||||
#include "curl_memory.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "connect.h" /* Curl_getconnectinfo() */
|
||||
#include "progress.h"
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ hostcache_timestamp_remove(void *datap, void *hc)
|
||||
(struct hostcache_prune_data *) datap;
|
||||
struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc;
|
||||
|
||||
return (data->now - c->timestamp >= data->cache_timeout);
|
||||
return !c->inuse && (data->now - c->timestamp >= data->cache_timeout);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
61
lib/http.c
61
lib/http.c
@@ -54,7 +54,7 @@
|
||||
#include "curl_base64.h"
|
||||
#include "cookie.h"
|
||||
#include "strequal.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "http_digest.h"
|
||||
#include "curl_ntlm.h"
|
||||
#include "curl_ntlm_wb.h"
|
||||
@@ -414,8 +414,9 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
|
||||
/* this is already marked to get closed */
|
||||
return CURLE_OK;
|
||||
|
||||
infof(data, "NTLM send, close instead of sending %" FORMAT_OFF_T
|
||||
" bytes\n", (curl_off_t)(expectsend - bytessent));
|
||||
infof(data, "NTLM send, close instead of sending %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
(curl_off_t)(expectsend - bytessent));
|
||||
}
|
||||
|
||||
/* This is not NTLM or many bytes left to send: close
|
||||
@@ -2018,9 +2019,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
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, "Could only read %" FORMAT_OFF_T
|
||||
" bytes from the input",
|
||||
passed);
|
||||
failf(data, "Could only read %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes from the input", passed);
|
||||
return CURLE_READ_ERROR;
|
||||
}
|
||||
} while(passed < data->state.resume_from);
|
||||
@@ -2065,8 +2065,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
remote part so we tell the server (and act accordingly) that we
|
||||
upload the whole file (again) */
|
||||
conn->allocptr.rangeline =
|
||||
aprintf("Content-Range: bytes 0-%" FORMAT_OFF_T
|
||||
"/%" FORMAT_OFF_T "\r\n",
|
||||
aprintf("Content-Range: bytes 0-%" CURL_FORMAT_CURL_OFF_T
|
||||
"/%" CURL_FORMAT_CURL_OFF_T "\r\n",
|
||||
data->set.infilesize - 1, data->set.infilesize);
|
||||
|
||||
}
|
||||
@@ -2075,8 +2075,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
curl_off_t total_expected_size=
|
||||
data->state.resume_from + data->set.infilesize;
|
||||
conn->allocptr.rangeline =
|
||||
aprintf("Content-Range: bytes %s%" FORMAT_OFF_T
|
||||
"/%" FORMAT_OFF_T "\r\n",
|
||||
aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T
|
||||
"/%" CURL_FORMAT_CURL_OFF_T "\r\n",
|
||||
data->state.range, total_expected_size-1,
|
||||
total_expected_size);
|
||||
}
|
||||
@@ -2084,7 +2084,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
/* Range was selected and then we just pass the incoming range and
|
||||
append total size */
|
||||
conn->allocptr.rangeline =
|
||||
aprintf("Content-Range: bytes %s/%" FORMAT_OFF_T "\r\n",
|
||||
aprintf("Content-Range: bytes %s/%" CURL_FORMAT_CURL_OFF_T "\r\n",
|
||||
data->state.range, data->set.infilesize);
|
||||
}
|
||||
if(!conn->allocptr.rangeline)
|
||||
@@ -2294,8 +2294,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
!Curl_checkheaders(data, "Content-Length:")) {
|
||||
/* only add Content-Length if not uploading chunked */
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n",
|
||||
http->postsize);
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
|
||||
"\r\n", http->postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
@@ -2366,8 +2366,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
!Curl_checkheaders(data, "Content-Length:")) {
|
||||
/* only add Content-Length if not uploading chunked */
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n",
|
||||
postsize );
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
|
||||
"\r\n", postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
@@ -2408,20 +2408,19 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
data->set.postfieldsize:
|
||||
(data->set.postfields? (curl_off_t)strlen(data->set.postfields):-1);
|
||||
}
|
||||
if(!data->req.upload_chunky) {
|
||||
/* We only set Content-Length and allow a custom Content-Length if
|
||||
we don't upload data chunked, as RFC2616 forbids us to set both
|
||||
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
|
||||
|
||||
if(conn->bits.authneg || !Curl_checkheaders(data, "Content-Length:")) {
|
||||
/* we allow replacing this header if not during auth negotiation,
|
||||
although it isn't very wise to actually set your own */
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T"\r\n",
|
||||
postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
/* We only set Content-Length and allow a custom Content-Length if
|
||||
we don't upload data chunked, as RFC2616 forbids us to set both
|
||||
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
|
||||
if((postsize != -1) && !data->req.upload_chunky &&
|
||||
!Curl_checkheaders(data, "Content-Length:")) {
|
||||
/* we allow replacing this header if not during auth negotiation,
|
||||
although it isn't very wise to actually set your own */
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
|
||||
"\r\n", postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(!Curl_checkheaders(data, "Content-Type:")) {
|
||||
@@ -2582,8 +2581,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
if(http->writebytecount >= postsize) {
|
||||
/* already sent the entire request body, mark the "upload" as
|
||||
complete */
|
||||
infof(data, "upload completely sent off: %" FORMAT_OFF_T " out of "
|
||||
"%" FORMAT_OFF_T " bytes\n",
|
||||
infof(data, "upload completely sent off: %" CURL_FORMAT_CURL_OFF_T
|
||||
" out of %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
http->writebytecount, postsize);
|
||||
data->req.upload_done = TRUE;
|
||||
data->req.keepon &= ~KEEP_SEND; /* we're done writing */
|
||||
@@ -3233,7 +3232,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
|
||||
happens for example when older Apache servers send large
|
||||
files */
|
||||
conn->bits.close = TRUE;
|
||||
infof(data, "Negative content-length: %" FORMAT_OFF_T
|
||||
infof(data, "Negative content-length: %" CURL_FORMAT_CURL_OFF_T
|
||||
", closing after transfer\n", contentlength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "http.h"
|
||||
#include "curl_memory.h"
|
||||
#include "non-ascii.h" /* for Curl_convert_to_network prototype */
|
||||
#include "strtoofft.h"
|
||||
#include "warnless.h"
|
||||
|
||||
#define _MPRINTF_REPLACE /* use our functions only */
|
||||
#include <curl/mprintf.h>
|
||||
@@ -87,8 +89,8 @@ static bool Curl_isxdigit(char digit)
|
||||
void Curl_httpchunk_init(struct connectdata *conn)
|
||||
{
|
||||
struct Curl_chunker *chunk = &conn->chunk;
|
||||
chunk->hexindex=0; /* start at 0 */
|
||||
chunk->dataleft=0; /* no data left yet! */
|
||||
chunk->hexindex=0; /* start at 0 */
|
||||
chunk->dataleft=0; /* no data left yet! */
|
||||
chunk->state = CHUNK_HEX; /* we get hex first! */
|
||||
}
|
||||
|
||||
@@ -113,7 +115,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
struct Curl_chunker *ch = &conn->chunk;
|
||||
struct SingleRequest *k = &data->req;
|
||||
size_t piece;
|
||||
size_t length = (size_t)datalen;
|
||||
curl_off_t length = (curl_off_t)datalen;
|
||||
size_t *wrote = (size_t *)wrotep;
|
||||
|
||||
*wrote = 0; /* nothing's written yet */
|
||||
@@ -141,11 +143,12 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(0 == ch->hexindex) {
|
||||
char *endptr;
|
||||
if(0 == ch->hexindex)
|
||||
/* This is illegal data, we received junk where we expected
|
||||
a hexadecimal digit. */
|
||||
return CHUNKE_ILLEGAL_HEX;
|
||||
}
|
||||
|
||||
/* length and datap are unmodified */
|
||||
ch->hexbuffer[ch->hexindex]=0;
|
||||
|
||||
@@ -155,50 +158,38 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
if(result) {
|
||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||
/* Treat it as a bad hex character */
|
||||
return(CHUNKE_ILLEGAL_HEX);
|
||||
return CHUNKE_ILLEGAL_HEX ;
|
||||
}
|
||||
|
||||
ch->datasize=strtoul(ch->hexbuffer, NULL, 16);
|
||||
ch->state = CHUNK_POSTHEX;
|
||||
ch->datasize=curlx_strtoofft(ch->hexbuffer, &endptr, 16);
|
||||
if(errno == ERANGE)
|
||||
/* over or underflow is an error */
|
||||
return CHUNKE_ILLEGAL_HEX;
|
||||
ch->state = CHUNK_LF; /* now wait for the CRLF */
|
||||
}
|
||||
break;
|
||||
|
||||
case CHUNK_POSTHEX:
|
||||
/* In this state, we're waiting for CRLF to arrive. We support
|
||||
this to allow so called chunk-extensions to show up here
|
||||
before the CRLF comes. */
|
||||
if(*datap == 0x0d)
|
||||
ch->state = CHUNK_CR;
|
||||
length--;
|
||||
datap++;
|
||||
break;
|
||||
|
||||
case CHUNK_CR:
|
||||
/* waiting for the LF */
|
||||
case CHUNK_LF:
|
||||
/* waiting for the LF after a chunk size */
|
||||
if(*datap == 0x0a) {
|
||||
/* we're now expecting data to come, unless size was zero! */
|
||||
if(0 == ch->datasize) {
|
||||
ch->state = CHUNK_TRAILER; /* now check for trailers */
|
||||
conn->trlPos=0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
ch->state = CHUNK_DATA;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* previously we got a fake CR, go back to CR waiting! */
|
||||
ch->state = CHUNK_CR;
|
||||
|
||||
datap++;
|
||||
length--;
|
||||
break;
|
||||
|
||||
case CHUNK_DATA:
|
||||
/* we get pure and fine data
|
||||
|
||||
We expect another 'datasize' of data. We have 'length' right now,
|
||||
it can be more or less than 'datasize'. Get the smallest piece.
|
||||
/* We expect 'datasize' of data. We have 'length' right now, it can be
|
||||
more or less than 'datasize'. Get the smallest piece.
|
||||
*/
|
||||
piece = (ch->datasize >= length)?length:ch->datasize;
|
||||
piece = curlx_sotouz((ch->datasize >= length)?length:ch->datasize);
|
||||
|
||||
/* Write the data portion available */
|
||||
#ifdef HAVE_LIBZ
|
||||
@@ -251,37 +242,22 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
|
||||
if(0 == ch->datasize)
|
||||
/* end of data this round, we now expect a trailing CRLF */
|
||||
ch->state = CHUNK_POSTCR;
|
||||
break;
|
||||
|
||||
case CHUNK_POSTCR:
|
||||
if(*datap == 0x0d) {
|
||||
ch->state = CHUNK_POSTLF;
|
||||
datap++;
|
||||
length--;
|
||||
}
|
||||
else
|
||||
return CHUNKE_BAD_CHUNK;
|
||||
|
||||
break;
|
||||
|
||||
case CHUNK_POSTLF:
|
||||
if(*datap == 0x0a) {
|
||||
/*
|
||||
* The last one before we go back to hex state and start all
|
||||
* over.
|
||||
*/
|
||||
Curl_httpchunk_init(conn);
|
||||
datap++;
|
||||
length--;
|
||||
/* The last one before we go back to hex state and start all over. */
|
||||
Curl_httpchunk_init(conn); /* sets state back to CHUNK_HEX */
|
||||
}
|
||||
else
|
||||
else if(*datap != 0x0d)
|
||||
return CHUNKE_BAD_CHUNK;
|
||||
|
||||
datap++;
|
||||
length--;
|
||||
break;
|
||||
|
||||
case CHUNK_TRAILER:
|
||||
if(*datap == 0x0d) {
|
||||
if((*datap == 0x0d) || (*datap == 0x0a)) {
|
||||
/* this is the end of a trailer, but if the trailer was zero bytes
|
||||
there was no trailer and we move on */
|
||||
|
||||
@@ -307,6 +283,9 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
}
|
||||
conn->trlPos=0;
|
||||
ch->state = CHUNK_TRAILER_CR;
|
||||
if(*datap == 0x0a)
|
||||
/* already on the LF */
|
||||
break;
|
||||
}
|
||||
else {
|
||||
/* no trailer, we're on the final CRLF pair */
|
||||
@@ -352,27 +331,18 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
case CHUNK_TRAILER_POSTCR:
|
||||
/* We enter this state when a CR should arrive so we expect to
|
||||
have to first pass a CR before we wait for LF */
|
||||
if(*datap != 0x0d) {
|
||||
if((*datap != 0x0d) && (*datap != 0x0a)) {
|
||||
/* not a CR then it must be another header in the trailer */
|
||||
ch->state = CHUNK_TRAILER;
|
||||
break;
|
||||
}
|
||||
datap++;
|
||||
length--;
|
||||
/* now wait for the final LF */
|
||||
ch->state = CHUNK_STOP;
|
||||
break;
|
||||
|
||||
case CHUNK_STOPCR:
|
||||
/* Read the final CRLF that ends all chunk bodies */
|
||||
|
||||
if(*datap == 0x0d) {
|
||||
ch->state = CHUNK_STOP;
|
||||
/* skip if CR */
|
||||
datap++;
|
||||
length--;
|
||||
}
|
||||
else
|
||||
return CHUNKE_BAD_CHUNK;
|
||||
/* now wait for the final LF */
|
||||
ch->state = CHUNK_STOP;
|
||||
break;
|
||||
|
||||
case CHUNK_STOP:
|
||||
@@ -381,15 +351,12 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
|
||||
/* Record the length of any data left in the end of the buffer
|
||||
even if there's no more chunks to read */
|
||||
ch->dataleft = curlx_sotouz(length);
|
||||
|
||||
ch->dataleft = length;
|
||||
return CHUNKE_STOP; /* return stop */
|
||||
}
|
||||
else
|
||||
return CHUNKE_BAD_CHUNK;
|
||||
|
||||
default:
|
||||
return CHUNKE_STATE_ERROR;
|
||||
}
|
||||
}
|
||||
return CHUNKE_OK;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -29,40 +29,25 @@
|
||||
#define MAXNUM_SIZE 16
|
||||
|
||||
typedef enum {
|
||||
CHUNK_FIRST, /* never use */
|
||||
|
||||
/* In this we await and buffer all hexadecimal digits until we get one
|
||||
that isn't a hexadecimal digit. When done, we go POSTHEX */
|
||||
/* await and buffer all hexadecimal digits until we get one that isn't a
|
||||
hexadecimal digit. When done, we go CHUNK_LF */
|
||||
CHUNK_HEX,
|
||||
|
||||
/* We have received the hexadecimal digit and we eat all characters until
|
||||
we get a CRLF pair. When we see a CR we go to the CR state. */
|
||||
CHUNK_POSTHEX,
|
||||
|
||||
/* A single CR has been found and we should get a LF right away in this
|
||||
state or we go back to POSTHEX. When LF is received, we go to DATA.
|
||||
If the size given was zero, we set state to STOP and return. */
|
||||
CHUNK_CR,
|
||||
/* wait for LF, ignore all else */
|
||||
CHUNK_LF,
|
||||
|
||||
/* We eat the amount of data specified. When done, we move on to the
|
||||
POST_CR state. */
|
||||
CHUNK_DATA,
|
||||
|
||||
/* POSTCR should get a CR and nothing else, then move to POSTLF */
|
||||
CHUNK_POSTCR,
|
||||
|
||||
/* POSTLF should get a LF and nothing else, then move back to HEX as the
|
||||
CRLF combination marks the end of a chunk */
|
||||
/* POSTLF should get a CR and then a LF and nothing else, then move back to
|
||||
HEX as the CRLF combination marks the end of a chunk. A missing CR is no
|
||||
big deal. */
|
||||
CHUNK_POSTLF,
|
||||
|
||||
/* Each Chunk body should end with a CRLF. Read a CR and nothing else,
|
||||
then move to CHUNK_STOP */
|
||||
CHUNK_STOPCR,
|
||||
|
||||
/* This is mainly used to really mark that we're out of the game.
|
||||
NOTE: that there's a 'dataleft' field in the struct that will tell how
|
||||
many bytes that were not passed to the client in the end of the last
|
||||
buffer! */
|
||||
/* Used to mark that we're out of the game. NOTE: that there's a 'dataleft'
|
||||
field in the struct that will tell how many bytes that were not passed to
|
||||
the client in the end of the last buffer! */
|
||||
CHUNK_STOP,
|
||||
|
||||
/* At this point optional trailer headers can be found, unless the next line
|
||||
@@ -77,10 +62,7 @@ typedef enum {
|
||||
signalled If this is an empty trailer CHUNKE_STOP will be signalled.
|
||||
Otherwise the trailer will be broadcasted via Curl_client_write() and the
|
||||
next state will be CHUNK_TRAILER */
|
||||
CHUNK_TRAILER_POSTCR,
|
||||
|
||||
CHUNK_LAST /* never use */
|
||||
|
||||
CHUNK_TRAILER_POSTCR
|
||||
} ChunkyState;
|
||||
|
||||
typedef enum {
|
||||
@@ -100,7 +82,7 @@ struct Curl_chunker {
|
||||
char hexbuffer[ MAXNUM_SIZE + 1];
|
||||
int hexindex;
|
||||
ChunkyState state;
|
||||
size_t datasize;
|
||||
curl_off_t datasize;
|
||||
size_t dataleft; /* untouched data amount at the end of the last buffer */
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "http_digest.h"
|
||||
#include "strtok.h"
|
||||
#include "curl_memory.h"
|
||||
#include "sslgen.h" /* for Curl_rand() */
|
||||
#include "vtls/vtls.h" /* for Curl_rand() */
|
||||
#include "non-ascii.h" /* included for Curl_convert_... prototypes */
|
||||
#include "warnless.h"
|
||||
|
||||
|
||||
@@ -380,9 +380,9 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
keepon = 2;
|
||||
|
||||
if(cl) {
|
||||
|
||||
infof(data, "Ignore %" FORMAT_OFF_T
|
||||
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes of response-body\n", cl);
|
||||
|
||||
/* remove the remaining chunk of what we already
|
||||
read */
|
||||
cl -= (gotbytes - i);
|
||||
|
||||
350
lib/imap.c
350
lib/imap.c
@@ -71,7 +71,7 @@
|
||||
|
||||
#include "strtoofft.h"
|
||||
#include "strequal.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "connect.h"
|
||||
#include "strerror.h"
|
||||
#include "select.h"
|
||||
@@ -105,6 +105,10 @@ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...);
|
||||
static CURLcode imap_parse_url_options(struct connectdata *conn);
|
||||
static CURLcode imap_parse_url_path(struct connectdata *conn);
|
||||
static CURLcode imap_parse_custom_request(struct connectdata *conn);
|
||||
static CURLcode imap_calc_sasl_details(struct connectdata *conn,
|
||||
const char **mech,
|
||||
char **initresp, size_t *len,
|
||||
imapstate *state1, imapstate *state2);
|
||||
|
||||
/*
|
||||
* IMAP protocol handler.
|
||||
@@ -559,16 +563,45 @@ static CURLcode imap_perform_login(struct connectdata *conn)
|
||||
*
|
||||
* imap_perform_authenticate()
|
||||
*
|
||||
* Sends an AUTHENTICATE command allowing the client to login with the
|
||||
* appropriate SASL authentication mechanism.
|
||||
*
|
||||
* Additionally, the function will perform fallback to the LOGIN command
|
||||
* should a common mechanism not be available between the client and server.
|
||||
* Sends an AUTHENTICATE command allowing the client to login with the given
|
||||
* SASL authentication mechanism.
|
||||
*/
|
||||
static CURLcode imap_perform_authenticate(struct connectdata *conn)
|
||||
static CURLcode imap_perform_authenticate(struct connectdata *conn,
|
||||
const char *mech,
|
||||
const char *initresp,
|
||||
imapstate state1, imapstate state2)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
if(initresp) {
|
||||
/* Send the AUTHENTICATE command with the initial response */
|
||||
result = imap_sendf(conn, "AUTHENTICATE %s %s", mech, initresp);
|
||||
|
||||
if(!result)
|
||||
state(conn, state2);
|
||||
}
|
||||
else {
|
||||
/* Send the AUTHENTICATE command */
|
||||
result = imap_sendf(conn, "AUTHENTICATE %s", mech);
|
||||
|
||||
if(!result)
|
||||
state(conn, state1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* imap_perform_authentication()
|
||||
*
|
||||
* Initiates the authentication sequence, with the appropriate SASL
|
||||
* authentication mechanism, falling back to clear text should a common
|
||||
* mechanism not be available between the client and server.
|
||||
*/
|
||||
static CURLcode imap_perform_authentication(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
const char *mech = NULL;
|
||||
char *initresp = NULL;
|
||||
@@ -584,89 +617,14 @@ static CURLcode imap_perform_authenticate(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Calculate the supported authentication mechanism, by decreasing order of
|
||||
security, as well as the initial response where appropriate */
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
if((imapc->authmechs & SASL_MECH_DIGEST_MD5) &&
|
||||
(imapc->prefmech & SASL_MECH_DIGEST_MD5)) {
|
||||
mech = SASL_MECH_STRING_DIGEST_MD5;
|
||||
state1 = IMAP_AUTHENTICATE_DIGESTMD5;
|
||||
imapc->authused = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if((imapc->authmechs & SASL_MECH_CRAM_MD5) &&
|
||||
(imapc->prefmech & SASL_MECH_CRAM_MD5)) {
|
||||
mech = SASL_MECH_STRING_CRAM_MD5;
|
||||
state1 = IMAP_AUTHENTICATE_CRAMMD5;
|
||||
imapc->authused = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_NTLM
|
||||
if((imapc->authmechs & SASL_MECH_NTLM) &&
|
||||
(imapc->prefmech & SASL_MECH_NTLM)) {
|
||||
mech = SASL_MECH_STRING_NTLM;
|
||||
state1 = IMAP_AUTHENTICATE_NTLM;
|
||||
state2 = IMAP_AUTHENTICATE_NTLM_TYPE2MSG;
|
||||
imapc->authused = SASL_MECH_NTLM;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
|
||||
&conn->ntlm,
|
||||
&initresp, &len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(((imapc->authmechs & SASL_MECH_XOAUTH2) &&
|
||||
(imapc->prefmech & SASL_MECH_XOAUTH2) &&
|
||||
(imapc->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) {
|
||||
mech = SASL_MECH_STRING_XOAUTH2;
|
||||
state1 = IMAP_AUTHENTICATE_XOAUTH2;
|
||||
state2 = IMAP_AUTHENTICATE_FINAL;
|
||||
imapc->authused = SASL_MECH_XOAUTH2;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_xoauth2_message(conn->data, conn->user,
|
||||
conn->xoauth2_bearer,
|
||||
&initresp, &len);
|
||||
}
|
||||
else if((imapc->authmechs & SASL_MECH_LOGIN) &&
|
||||
(imapc->prefmech & SASL_MECH_LOGIN)) {
|
||||
mech = SASL_MECH_STRING_LOGIN;
|
||||
state1 = IMAP_AUTHENTICATE_LOGIN;
|
||||
state2 = IMAP_AUTHENTICATE_LOGIN_PASSWD;
|
||||
imapc->authused = SASL_MECH_LOGIN;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_login_message(conn->data, conn->user,
|
||||
&initresp, &len);
|
||||
}
|
||||
else if((imapc->authmechs & SASL_MECH_PLAIN) &&
|
||||
(imapc->prefmech & SASL_MECH_PLAIN)) {
|
||||
mech = SASL_MECH_STRING_PLAIN;
|
||||
state1 = IMAP_AUTHENTICATE_PLAIN;
|
||||
state2 = IMAP_AUTHENTICATE_FINAL;
|
||||
imapc->authused = SASL_MECH_PLAIN;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_plain_message(conn->data, conn->user,
|
||||
conn->passwd, &initresp, &len);
|
||||
}
|
||||
/* Calculate the SASL login details */
|
||||
result = imap_calc_sasl_details(conn, &mech, &initresp, &len, &state1,
|
||||
&state2);
|
||||
|
||||
if(!result) {
|
||||
if(mech && (imapc->preftype & IMAP_TYPE_SASL)) {
|
||||
/* Perform SASL based authentication */
|
||||
if(initresp) {
|
||||
result = imap_sendf(conn, "AUTHENTICATE %s %s", mech, initresp);
|
||||
|
||||
if(!result)
|
||||
state(conn, state2);
|
||||
}
|
||||
else {
|
||||
result = imap_sendf(conn, "AUTHENTICATE %s", mech);
|
||||
|
||||
if(!result)
|
||||
state(conn, state1);
|
||||
}
|
||||
result = imap_perform_authenticate(conn, mech, initresp, state1, state2);
|
||||
|
||||
Curl_safefree(initresp);
|
||||
}
|
||||
@@ -817,7 +775,7 @@ static CURLcode imap_perform_append(struct connectdata *conn)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* Send the APPEND command */
|
||||
result = imap_sendf(conn, "APPEND %s (\\Seen) {%" FORMAT_OFF_T "}",
|
||||
result = imap_sendf(conn, "APPEND %s (\\Seen) {%" CURL_FORMAT_CURL_OFF_T "}",
|
||||
mailbox, conn->data->set.infilesize);
|
||||
|
||||
Curl_safefree(mailbox);
|
||||
@@ -949,17 +907,17 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
|
||||
result = imap_perform_starttls(conn);
|
||||
else if(data->set.use_ssl == CURLUSESSL_TRY)
|
||||
/* Fallback and carry on with authentication */
|
||||
result = imap_perform_authenticate(conn);
|
||||
result = imap_perform_authentication(conn);
|
||||
else {
|
||||
failf(data, "STARTTLS not supported.");
|
||||
result = CURLE_USE_SSL_FAILED;
|
||||
}
|
||||
}
|
||||
else
|
||||
result = imap_perform_authenticate(conn);
|
||||
result = imap_perform_authentication(conn);
|
||||
}
|
||||
else
|
||||
result = imap_perform_login(conn);
|
||||
result = imap_perform_authentication(conn);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -980,7 +938,7 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn,
|
||||
result = CURLE_USE_SSL_FAILED;
|
||||
}
|
||||
else
|
||||
result = imap_perform_authenticate(conn);
|
||||
result = imap_perform_authentication(conn);
|
||||
}
|
||||
else
|
||||
result = imap_perform_upgrade_tls(conn);
|
||||
@@ -1349,14 +1307,45 @@ static CURLcode imap_state_auth_cancel_resp(struct connectdata *conn,
|
||||
int imapcode,
|
||||
imapstate instate)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
const char *mech = NULL;
|
||||
char *initresp = NULL;
|
||||
size_t len = 0;
|
||||
imapstate state1 = IMAP_STOP;
|
||||
imapstate state2 = IMAP_STOP;
|
||||
|
||||
(void)imapcode;
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
failf(data, "Authentication cancelled");
|
||||
/* Remove the offending mechanism from the supported list */
|
||||
imapc->authmechs ^= imapc->authused;
|
||||
|
||||
return CURLE_LOGIN_DENIED;
|
||||
/* Calculate alternative SASL login details */
|
||||
result = imap_calc_sasl_details(conn, &mech, &initresp, &len, &state1,
|
||||
&state2);
|
||||
|
||||
if(!result) {
|
||||
/* Do we have any mechanisms left or can we fallback to clear text? */
|
||||
if(mech) {
|
||||
/* Retry SASL based authentication */
|
||||
result = imap_perform_authenticate(conn, mech, initresp, state1, state2);
|
||||
|
||||
Curl_safefree(initresp);
|
||||
}
|
||||
else if((!imapc->login_disabled) &&
|
||||
(imapc->preftype & IMAP_TYPE_CLEARTEXT))
|
||||
/* Perform clear text authentication */
|
||||
result = imap_perform_login(conn);
|
||||
else {
|
||||
failf(data, "Authentication cancelled");
|
||||
|
||||
result = CURLE_LOGIN_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* For final responses in the AUTHENTICATE sequence */
|
||||
@@ -1505,7 +1494,8 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
|
||||
}
|
||||
|
||||
if(parsed) {
|
||||
infof(data, "Found %" FORMAT_OFF_TU " bytes to download\n", size);
|
||||
infof(data, "Found %" CURL_FORMAT_CURL_OFF_TU " bytes to download\n",
|
||||
size);
|
||||
Curl_pgrsSetDownloadSize(data, size);
|
||||
|
||||
if(pp->cache) {
|
||||
@@ -1524,7 +1514,8 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
|
||||
|
||||
data->req.bytecount += chunk;
|
||||
|
||||
infof(data, "Written %" FORMAT_OFF_TU " bytes, %" FORMAT_OFF_TU
|
||||
infof(data, "Written %" CURL_FORMAT_CURL_OFF_TU
|
||||
" bytes, %" CURL_FORMAT_CURL_OFF_TU
|
||||
" bytes are left for transfer\n", (curl_off_t)chunk,
|
||||
size - chunk);
|
||||
|
||||
@@ -2323,52 +2314,64 @@ static CURLcode imap_parse_url_options(struct connectdata *conn)
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
const char *options = conn->options;
|
||||
const char *ptr = options;
|
||||
bool reset = TRUE;
|
||||
|
||||
if(options) {
|
||||
while(ptr && *ptr) {
|
||||
const char *key = ptr;
|
||||
|
||||
while(*ptr && *ptr != '=')
|
||||
ptr++;
|
||||
|
||||
if(strnequal(key, "AUTH", 4)) {
|
||||
const char *value = ptr + 1;
|
||||
size_t len = 0;
|
||||
const char *value = ++ptr;
|
||||
|
||||
if(strequal(value, "*")) {
|
||||
imapc->preftype = IMAP_TYPE_ANY;
|
||||
imapc->prefmech = SASL_AUTH_ANY;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_LOGIN)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech = SASL_MECH_LOGIN;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_PLAIN)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech = SASL_MECH_PLAIN;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_CRAM_MD5)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_DIGEST_MD5)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_GSSAPI)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech = SASL_MECH_GSSAPI;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_NTLM)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech = SASL_MECH_NTLM;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_XOAUTH2)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech = SASL_MECH_XOAUTH2;
|
||||
}
|
||||
else {
|
||||
if(reset) {
|
||||
reset = FALSE;
|
||||
imapc->preftype = IMAP_TYPE_NONE;
|
||||
imapc->prefmech = SASL_AUTH_NONE;
|
||||
}
|
||||
|
||||
while(*ptr && *ptr != ';') {
|
||||
ptr++;
|
||||
len++;
|
||||
}
|
||||
|
||||
if(strnequal(value, "*", len)) {
|
||||
imapc->preftype = IMAP_TYPE_ANY;
|
||||
imapc->prefmech = SASL_AUTH_ANY;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech |= SASL_MECH_LOGIN;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech |= SASL_MECH_PLAIN;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech |= SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech |= SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech |= SASL_MECH_GSSAPI;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech |= SASL_MECH_NTLM;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) {
|
||||
imapc->preftype = IMAP_TYPE_SASL;
|
||||
imapc->prefmech |= SASL_MECH_XOAUTH2;
|
||||
}
|
||||
|
||||
if(*ptr == ';')
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
result = CURLE_URL_MALFORMAT;
|
||||
@@ -2524,4 +2527,89 @@ static CURLcode imap_parse_custom_request(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* imap_calc_sasl_details()
|
||||
*
|
||||
* Calculate the required login details for SASL authentication.
|
||||
*/
|
||||
static CURLcode imap_calc_sasl_details(struct connectdata *conn,
|
||||
const char **mech,
|
||||
char **initresp, size_t *len,
|
||||
imapstate *state1, imapstate *state2)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
|
||||
/* Calculate the supported authentication mechanism, by decreasing order of
|
||||
security, as well as the initial response where appropriate */
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
if((imapc->authmechs & SASL_MECH_DIGEST_MD5) &&
|
||||
(imapc->prefmech & SASL_MECH_DIGEST_MD5)) {
|
||||
*mech = SASL_MECH_STRING_DIGEST_MD5;
|
||||
*state1 = IMAP_AUTHENTICATE_DIGESTMD5;
|
||||
imapc->authused = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if((imapc->authmechs & SASL_MECH_CRAM_MD5) &&
|
||||
(imapc->prefmech & SASL_MECH_CRAM_MD5)) {
|
||||
*mech = SASL_MECH_STRING_CRAM_MD5;
|
||||
*state1 = IMAP_AUTHENTICATE_CRAMMD5;
|
||||
imapc->authused = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_NTLM
|
||||
if((imapc->authmechs & SASL_MECH_NTLM) &&
|
||||
(imapc->prefmech & SASL_MECH_NTLM)) {
|
||||
*mech = SASL_MECH_STRING_NTLM;
|
||||
*state1 = IMAP_AUTHENTICATE_NTLM;
|
||||
*state2 = IMAP_AUTHENTICATE_NTLM_TYPE2MSG;
|
||||
imapc->authused = SASL_MECH_NTLM;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
|
||||
&conn->ntlm,
|
||||
initresp, len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(((imapc->authmechs & SASL_MECH_XOAUTH2) &&
|
||||
(imapc->prefmech & SASL_MECH_XOAUTH2) &&
|
||||
(imapc->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) {
|
||||
*mech = SASL_MECH_STRING_XOAUTH2;
|
||||
*state1 = IMAP_AUTHENTICATE_XOAUTH2;
|
||||
*state2 = IMAP_AUTHENTICATE_FINAL;
|
||||
imapc->authused = SASL_MECH_XOAUTH2;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_xoauth2_message(data, conn->user,
|
||||
conn->xoauth2_bearer,
|
||||
initresp, len);
|
||||
}
|
||||
else if((imapc->authmechs & SASL_MECH_LOGIN) &&
|
||||
(imapc->prefmech & SASL_MECH_LOGIN)) {
|
||||
*mech = SASL_MECH_STRING_LOGIN;
|
||||
*state1 = IMAP_AUTHENTICATE_LOGIN;
|
||||
*state2 = IMAP_AUTHENTICATE_LOGIN_PASSWD;
|
||||
imapc->authused = SASL_MECH_LOGIN;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_login_message(data, conn->user, initresp, len);
|
||||
}
|
||||
else if((imapc->authmechs & SASL_MECH_PLAIN) &&
|
||||
(imapc->prefmech & SASL_MECH_PLAIN)) {
|
||||
*mech = SASL_MECH_STRING_PLAIN;
|
||||
*state1 = IMAP_AUTHENTICATE_PLAIN;
|
||||
*state2 = IMAP_AUTHENTICATE_FINAL;
|
||||
imapc->authused = SASL_MECH_PLAIN;
|
||||
|
||||
if(imapc->ir_supported || data->set.sasl_ir)
|
||||
result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd,
|
||||
initresp, len);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* CURL_DISABLE_IMAP */
|
||||
|
||||
@@ -314,7 +314,7 @@ void curl_dofree(void *ptr, int line, const char *source)
|
||||
{
|
||||
struct memdebug *mem;
|
||||
|
||||
assert(ptr != NULL);
|
||||
if(ptr) {
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
@@ -322,17 +322,18 @@ void curl_dofree(void *ptr, int line, const char *source)
|
||||
/* 1684: conversion from pointer to same-sized integral type */
|
||||
#endif
|
||||
|
||||
mem = (void *)((char *)ptr - offsetof(struct memdebug, mem));
|
||||
mem = (void *)((char *)ptr - offsetof(struct memdebug, mem));
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/* destroy */
|
||||
mt_free_fill(mem->mem, mem->size);
|
||||
/* destroy */
|
||||
mt_free_fill(mem->mem, mem->size);
|
||||
|
||||
/* free for real */
|
||||
(Curl_cfree)(mem);
|
||||
/* free for real */
|
||||
(Curl_cfree)(mem);
|
||||
}
|
||||
|
||||
if(source)
|
||||
curl_memlog("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# * | (__| |_| | _ <| |___
|
||||
# * \___|\___/|_| \_\_____|
|
||||
# *
|
||||
# * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
# * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
# *
|
||||
# * This software is licensed as described in the file COPYING, which
|
||||
# * you should have received as part of this distribution. The terms
|
||||
@@ -34,19 +34,43 @@ use Getopt::Std;
|
||||
use MIME::Base64;
|
||||
use LWP::UserAgent;
|
||||
use strict;
|
||||
use vars qw($opt_b $opt_f $opt_h $opt_i $opt_l $opt_n $opt_q $opt_t $opt_u $opt_v $opt_w);
|
||||
use vars qw($opt_b $opt_d $opt_f $opt_h $opt_i $opt_l $opt_n $opt_q $opt_t $opt_u $opt_v $opt_w);
|
||||
|
||||
my %urls = (
|
||||
'nss' =>
|
||||
'http://mxr.mozilla.org/nss/source/lib/ckfw/builtins/certdata.txt?raw=1',
|
||||
'central' =>
|
||||
'http://mxr.mozilla.org/mozilla-central/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1',
|
||||
'aurora' =>
|
||||
'http://mxr.mozilla.org/mozilla-aurora/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1',
|
||||
'beta' =>
|
||||
'http://mxr.mozilla.org/mozilla-beta/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1',
|
||||
'release' =>
|
||||
'http://mxr.mozilla.org/mozilla-release/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1',
|
||||
'mozilla' =>
|
||||
'http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1'
|
||||
);
|
||||
|
||||
$opt_d = 'release';
|
||||
|
||||
my $url = 'http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1';
|
||||
# If the OpenSSL commandline is not in search path you can configure it here!
|
||||
my $openssl = 'openssl';
|
||||
|
||||
my $version = '1.19';
|
||||
my $version = '1.20';
|
||||
|
||||
$opt_w = 76; # default base64 encoded lines length
|
||||
|
||||
$0 =~ s@.*(/|\\)@@;
|
||||
$Getopt::Std::STANDARD_HELP_VERSION = 1;
|
||||
getopts('bfhilnqtuvw:');
|
||||
getopts('bd:fhilnqtuvw:');
|
||||
|
||||
if(!defined($opt_d)) {
|
||||
# to make plain "-d" use not cause warnings, and actually still work
|
||||
$opt_d = 'release';
|
||||
}
|
||||
|
||||
# Use predefined URL or else custom URL specified on command line.
|
||||
my $url = ( defined( $urls{$opt_d} ) ) ? $urls{$opt_d} : $opt_d;
|
||||
|
||||
if ($opt_i) {
|
||||
print ("=" x 78 . "\n");
|
||||
@@ -60,9 +84,29 @@ if ($opt_i) {
|
||||
print ("=" x 78 . "\n");
|
||||
}
|
||||
|
||||
sub WARNING_MESSAGE() {
|
||||
if ( $opt_d =~ m/^risk$/i ) { # Long Form Warning and Exit
|
||||
print "Warning: Use of this script may pose some risk:\n";
|
||||
print "\n";
|
||||
print " 1) Using http is subject to man in the middle attack of certdata content\n";
|
||||
print " 2) Default to 'release', but more recent updates may be found in other trees\n";
|
||||
print " 3) certdata.txt file format may change, lag time to update this script\n";
|
||||
print " 4) Generally unwise to blindly trust CAs without manual review & verification\n";
|
||||
print " 5) Mozilla apps use additional security checks aren't represented in certdata\n";
|
||||
print " 6) Use of this script will make a security engineer grind his teeth and\n";
|
||||
print " swear at you. ;)\n";
|
||||
exit;
|
||||
} else { # Short Form Warning
|
||||
print "Warning: Use of this script may pose some risk, -d risk for more details.\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub HELP_MESSAGE() {
|
||||
print "Usage:\t${0} [-b] [-f] [-i] [-l] [-n] [-q] [-t] [-u] [-v] [-w<l>] [<outputfile>]\n";
|
||||
print "Usage:\t${0} [-b] [-d<certdata>] [-f] [-i] [-l] [-n] [-q] [-t] [-u] [-v] [-w<l>] [<outputfile>]\n";
|
||||
print "\t-b\tbackup an existing version of ca-bundle.crt\n";
|
||||
print "\t-d\tspecify Mozilla tree to pull certdata.txt or custom URL\n";
|
||||
print "\t\t Valid names are:\n";
|
||||
print "\t\t ", join( ", ", map { ( $_ =~ m/$opt_d/ ) ? "$_ (default)" : "$_" } sort keys %urls ), "\n";
|
||||
print "\t-f\tforce rebuild even if certdata.txt is current\n";
|
||||
print "\t-i\tprint version info about used modules\n";
|
||||
print "\t-l\tprint license info about certdata.txt\n";
|
||||
@@ -79,6 +123,7 @@ sub VERSION_MESSAGE() {
|
||||
print "${0} version ${version} running Perl ${]} on ${^O}\n";
|
||||
}
|
||||
|
||||
WARNING_MESSAGE() unless ($opt_q || $url =~ m/^(ht|f)tps:/i );
|
||||
HELP_MESSAGE() if ($opt_h);
|
||||
|
||||
my $crt = $ARGV[0] || 'ca-bundle.crt';
|
||||
|
||||
@@ -72,6 +72,19 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Non-ANSI integer extensions
|
||||
*/
|
||||
|
||||
#if (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)) || \
|
||||
(defined(__WATCOMC__) && defined(__386__)) || \
|
||||
(defined(__POCC__) && defined(_MSC_VER)) || \
|
||||
(defined(_WIN32_WCE)) || \
|
||||
(defined(__MINGW32__)) || \
|
||||
(defined(_MSC_VER) && (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64))
|
||||
# define MP_HAVE_INT_EXTENSIONS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Max integer data types that mprintf.c is capable
|
||||
*/
|
||||
@@ -189,17 +202,27 @@ static long dprintf_DollarString(char *input, char **end)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dprintf_IsQualifierNoDollar(char c)
|
||||
static bool dprintf_IsQualifierNoDollar(const char *fmt)
|
||||
{
|
||||
switch (c) {
|
||||
#if defined(MP_HAVE_INT_EXTENSIONS)
|
||||
if(!strncmp(fmt, "I32", 3) || !strncmp(fmt, "I64", 3)) {
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(*fmt) {
|
||||
case '-': case '+': case ' ': case '#': case '.':
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case 'h': case 'l': case 'L': case 'z': case 'q':
|
||||
case '*': case 'O':
|
||||
return 1; /* true */
|
||||
#if defined(MP_HAVE_INT_EXTENSIONS)
|
||||
case 'I':
|
||||
#endif
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return 0; /* false */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,8 +278,20 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
||||
|
||||
/* Handle the flags */
|
||||
|
||||
while(dprintf_IsQualifierNoDollar(*fmt)) {
|
||||
switch (*fmt++) {
|
||||
while(dprintf_IsQualifierNoDollar(fmt)) {
|
||||
#if defined(MP_HAVE_INT_EXTENSIONS)
|
||||
if(!strncmp(fmt, "I32", 3)) {
|
||||
flags |= FLAGS_LONG;
|
||||
fmt += 3;
|
||||
}
|
||||
else if(!strncmp(fmt, "I64", 3)) {
|
||||
flags |= FLAGS_LONGLONG;
|
||||
fmt += 3;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
switch(*fmt++) {
|
||||
case ' ':
|
||||
flags |= FLAGS_SPACE;
|
||||
break;
|
||||
@@ -296,6 +331,15 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
||||
case 'h':
|
||||
flags |= FLAGS_SHORT;
|
||||
break;
|
||||
#if defined(MP_HAVE_INT_EXTENSIONS)
|
||||
case 'I':
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
|
||||
flags |= FLAGS_LONGLONG;
|
||||
#else
|
||||
flags |= FLAGS_LONG;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
case 'l':
|
||||
if(flags & FLAGS_LONG)
|
||||
flags |= FLAGS_LONGLONG;
|
||||
|
||||
80
lib/multi.c
80
lib/multi.c
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -329,6 +329,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
|
||||
multi->conn_cache = NULL;
|
||||
Curl_close(multi->closure_handle);
|
||||
multi->closure_handle = NULL;
|
||||
Curl_llist_destroy(multi->msglist, NULL);
|
||||
|
||||
free(multi);
|
||||
return NULL;
|
||||
@@ -985,10 +986,19 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||
Curl_tvdiff(now, data->progress.t_startsingle));
|
||||
else {
|
||||
k = &data->req;
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
|
||||
Curl_tvdiff(now, data->progress.t_startsingle), k->bytecount,
|
||||
k->size);
|
||||
if(k->size != -1) {
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
CURL_FORMAT_CURL_OFF_T " out of %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes received",
|
||||
Curl_tvdiff(k->now, data->progress.t_startsingle),
|
||||
k->bytecount, k->size);
|
||||
}
|
||||
else {
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes received",
|
||||
Curl_tvdiff(now, data->progress.t_startsingle),
|
||||
k->bytecount);
|
||||
}
|
||||
}
|
||||
|
||||
/* Force the connection closed because the server could continue to
|
||||
@@ -1381,7 +1391,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||
Curl_move_handle_from_send_to_recv_pipe(data, data->easy_conn);
|
||||
/* Check if we can move pending requests to send pipe */
|
||||
Curl_multi_process_pending_handles(multi);
|
||||
multistate(data, CURLM_STATE_WAITPERFORM);
|
||||
|
||||
/* Only perform the transfer if there's a good socket to work with.
|
||||
Having both BAD is a signal to skip immediately to DONE */
|
||||
if((data->easy_conn->sockfd != CURL_SOCKET_BAD) ||
|
||||
(data->easy_conn->writesockfd != CURL_SOCKET_BAD))
|
||||
multistate(data, CURLM_STATE_WAITPERFORM);
|
||||
else
|
||||
multistate(data, CURLM_STATE_DONE);
|
||||
result = CURLM_CALL_MULTI_PERFORM;
|
||||
break;
|
||||
|
||||
@@ -1577,13 +1594,20 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||
result = CURLM_CALL_MULTI_PERFORM;
|
||||
|
||||
if(data->easy_conn) {
|
||||
CURLcode res;
|
||||
|
||||
/* Remove ourselves from the receive pipeline, if we are there. */
|
||||
Curl_removeHandleFromPipeline(data, data->easy_conn->recv_pipe);
|
||||
/* Check if we can move pending requests to send pipe */
|
||||
Curl_multi_process_pending_handles(multi);
|
||||
|
||||
/* post-transfer command */
|
||||
data->result = Curl_done(&data->easy_conn, CURLE_OK, FALSE);
|
||||
res = Curl_done(&data->easy_conn, CURLE_OK, FALSE);
|
||||
|
||||
/* allow a previously set error code take precedence */
|
||||
if(!data->result)
|
||||
data->result = res;
|
||||
|
||||
/*
|
||||
* If there are other handles on the pipeline, Curl_done won't set
|
||||
* easy_conn to NULL. In such a case, curl_multi_remove_handle() can
|
||||
@@ -1672,6 +1696,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||
else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) {
|
||||
/* aborted due to progress callback return code must close the
|
||||
connection */
|
||||
data->result = CURLE_ABORTED_BY_CALLBACK;
|
||||
data->easy_conn->bits.close = TRUE;
|
||||
|
||||
/* if not yet in DONE state, go there, otherwise COMPLETED */
|
||||
@@ -2146,10 +2171,12 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
|
||||
|
||||
/* walk through each easy handle and do the socket state change magic
|
||||
and callbacks */
|
||||
data=multi->easyp;
|
||||
while(data) {
|
||||
singlesocket(multi, data);
|
||||
data = data->next;
|
||||
if(result != CURLM_BAD_HANDLE) {
|
||||
data=multi->easyp;
|
||||
while(data) {
|
||||
singlesocket(multi, data);
|
||||
data = data->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* or should we fall-through and do the timer-based stuff? */
|
||||
@@ -2213,31 +2240,16 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
|
||||
|
||||
data = NULL; /* set data to NULL again to avoid calling
|
||||
multi_runsingle() in case there's no need to */
|
||||
now = Curl_tvnow(); /* get a newer time since the multi_runsingle() loop
|
||||
may have taken some time */
|
||||
}
|
||||
}
|
||||
|
||||
/* Compensate for bad precision timers that might've triggered too early.
|
||||
|
||||
This precaution was added in commit 2c72732ebf3da5e as a result of bad
|
||||
resolution in the windows function use(d).
|
||||
|
||||
The problematic case here is when using the multi_socket API and libcurl
|
||||
has told the application about a timeout, and that timeout is what fires
|
||||
off a bit early. As we don't have any IDs associated with the timeout we
|
||||
can't tell which timeout that fired off but we only have the times to use
|
||||
to check what to do. If it fires off too early, we don't run the correct
|
||||
actions and we don't tell the application again about the same timeout as
|
||||
was already first in the queue...
|
||||
|
||||
Originally we made the timeouts run 40 milliseconds early on all systems,
|
||||
but now we have an #ifdef setup to provide a decent precaution inaccuracy
|
||||
margin.
|
||||
*/
|
||||
|
||||
now.tv_usec += MULTI_TIMEOUT_INACCURACY;
|
||||
if(now.tv_usec >= 1000000) {
|
||||
now.tv_sec++;
|
||||
now.tv_usec -= 1000000;
|
||||
else {
|
||||
/* Asked to run due to time-out. Clear the 'lastcall' variable to force
|
||||
update_timer() to trigger a callback to the app again even if the same
|
||||
timeout is still the one to run after this call. That handles the case
|
||||
when the application asks libcurl to run the timeout prematurely. */
|
||||
memset(&multi->timer_lastcall, 0, sizeof(multi->timer_lastcall));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -22,16 +22,6 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* See multi_socket() for the explanation of this constant. Counted in number
|
||||
of microseconds. */
|
||||
#ifdef WIN32
|
||||
#define MULTI_TIMEOUT_INACCURACY 40000
|
||||
#else
|
||||
#define MULTI_TIMEOUT_INACCURACY 3000
|
||||
#endif
|
||||
|
||||
#define MULTI_TIMEOUT_INACCURACY_MS (MULTI_TIMEOUT_INACCURACY / 1000)
|
||||
|
||||
/*
|
||||
* Prototypes for library-wide functions provided by multi.c
|
||||
*/
|
||||
|
||||
29
lib/netrc.c
29
lib/netrc.c
@@ -62,8 +62,6 @@ int Curl_parsenetrc(const char *host,
|
||||
FILE *file;
|
||||
int retcode=1;
|
||||
int specific_login = (**loginp != 0);
|
||||
char *home = NULL;
|
||||
bool home_alloc = FALSE;
|
||||
bool netrc_alloc = FALSE;
|
||||
enum host_lookup_state state=NOTHING;
|
||||
|
||||
@@ -74,7 +72,8 @@ int Curl_parsenetrc(const char *host,
|
||||
#define NETRC DOT_CHAR "netrc"
|
||||
|
||||
if(!netrcfile) {
|
||||
home = curl_getenv("HOME"); /* portable environment reader */
|
||||
bool home_alloc = FALSE;
|
||||
char *home = curl_getenv("HOME"); /* portable environment reader */
|
||||
if(home) {
|
||||
home_alloc = TRUE;
|
||||
#if defined(HAVE_GETPWUID) && defined(HAVE_GETEUID)
|
||||
@@ -92,15 +91,17 @@ int Curl_parsenetrc(const char *host,
|
||||
return -1;
|
||||
|
||||
netrcfile = curl_maprintf("%s%s%s", home, DIR_CHAR, NETRC);
|
||||
if(home_alloc)
|
||||
Curl_safefree(home);
|
||||
if(!netrcfile) {
|
||||
if(home_alloc)
|
||||
free(home);
|
||||
return -1;
|
||||
}
|
||||
netrc_alloc = TRUE;
|
||||
}
|
||||
|
||||
file = fopen(netrcfile, "r");
|
||||
if(netrc_alloc)
|
||||
Curl_safefree(netrcfile);
|
||||
if(file) {
|
||||
char *tok;
|
||||
char *tok_buf;
|
||||
@@ -146,8 +147,10 @@ int Curl_parsenetrc(const char *host,
|
||||
else {
|
||||
free(*loginp);
|
||||
*loginp = strdup(tok);
|
||||
if(!*loginp)
|
||||
return -1; /* allocation failed */
|
||||
if(!*loginp) {
|
||||
retcode = -1; /* allocation failed */
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
state_login=0;
|
||||
}
|
||||
@@ -155,8 +158,10 @@ int Curl_parsenetrc(const char *host,
|
||||
if(state_our_login || !specific_login) {
|
||||
free(*passwordp);
|
||||
*passwordp = strdup(tok);
|
||||
if(!*passwordp)
|
||||
return -1; /* allocation failed */
|
||||
if(!*passwordp) {
|
||||
retcode = -1; /* allocation failed */
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
state_password=0;
|
||||
}
|
||||
@@ -176,13 +181,9 @@ int Curl_parsenetrc(const char *host,
|
||||
} /* while(tok) */
|
||||
} /* while fgets() */
|
||||
|
||||
out:
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
if(home_alloc)
|
||||
free(home);
|
||||
if(netrc_alloc)
|
||||
free(netrcfile);
|
||||
|
||||
return retcode;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org>
|
||||
* Copyright (C) 2010, 2013, Howard Chu, <hyc@openldap.org>
|
||||
* Copyright (C) 2011 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "urldata.h"
|
||||
#include <curl/curl.h>
|
||||
#include "sendf.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "transfer.h"
|
||||
#include "curl_ldap.h"
|
||||
#include "curl_memory.h"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "pingpong.h"
|
||||
#include "multiif.h"
|
||||
#include "non-ascii.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
|
||||
#define _MPRINTF_REPLACE /* use our functions only */
|
||||
#include <curl/mprintf.h>
|
||||
@@ -376,11 +376,9 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
|
||||
if(pp->endofresp(conn, pp->linestart_resp, perline, code)) {
|
||||
/* This is the end of the last line, copy the last line to the
|
||||
start of the buffer and zero terminate, for old times sake */
|
||||
char *meow;
|
||||
int n;
|
||||
for(meow=pp->linestart_resp, n=0; meow<ptr; meow++, n++)
|
||||
buf[n] = *meow;
|
||||
*meow=0; /* zero terminate */
|
||||
size_t n = ptr - pp->linestart_resp;
|
||||
memmove(buf, pp->linestart_resp, n);
|
||||
buf[n]=0; /* zero terminate */
|
||||
keepon=FALSE;
|
||||
pp->linestart_resp = ptr+1; /* advance pointer */
|
||||
i++; /* skip this before getting out */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2013, Linus Nielsen Feltzing, <linus@haxx.se>
|
||||
* Copyright (C) 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2013-2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -85,8 +85,8 @@ bool Curl_pipeline_penalized(struct SessionHandle *data,
|
||||
(curl_off_t)conn->chunk.datasize > chunk_penalty_size)
|
||||
penalized = TRUE;
|
||||
|
||||
infof(data, "Conn: %ld (%p) Receive pipe weight: (%" FORMAT_OFF_T
|
||||
"/%zu), penalized: %s\n",
|
||||
infof(data, "Conn: %ld (%p) Receive pipe weight: (%"
|
||||
CURL_FORMAT_CURL_OFF_T "/%zu), penalized: %s\n",
|
||||
conn->connection_id, (void *)conn, recv_size,
|
||||
conn->chunk.datasize, penalized?"TRUE":"FALSE");
|
||||
return penalized;
|
||||
@@ -103,22 +103,17 @@ CURLcode Curl_add_handle_to_pipeline(struct SessionHandle *handle,
|
||||
|
||||
pipeline = conn->send_pipe;
|
||||
|
||||
infof(conn->data, "Adding handle: conn: %p\n", (void *)conn);
|
||||
infof(conn->data, "Adding handle: send: %d\n", conn->send_pipe->size);
|
||||
infof(conn->data, "Adding handle: recv: %d\n", conn->recv_pipe->size);
|
||||
rc = Curl_addHandleToPipeline(handle, pipeline);
|
||||
|
||||
if(pipeline == conn->send_pipe && sendhead != conn->send_pipe->head) {
|
||||
/* this is a new one as head, expire it */
|
||||
conn->writechannel_inuse = FALSE; /* not in use yet */
|
||||
#ifdef DEBUGBUILD
|
||||
infof(conn->data, "%p is at send pipe head!\n",
|
||||
(void *)conn->send_pipe->head->ptr);
|
||||
#endif
|
||||
Curl_expire(conn->send_pipe->head->ptr, 1);
|
||||
}
|
||||
|
||||
#if 0 /* enable for pipeline debugging */
|
||||
print_pipeline(conn);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -309,7 +304,7 @@ CURLMcode Curl_pipeline_set_server_blacklist(char **servers,
|
||||
return CURLM_OK;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
void print_pipeline(struct connectdata *conn)
|
||||
{
|
||||
struct curl_llist_element *curr;
|
||||
@@ -331,3 +326,5 @@ void print_pipeline(struct connectdata *conn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2013, Linus Nielsen Feltzing, <linus@haxx.se>
|
||||
* Copyright (C) 2013 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -41,6 +41,4 @@ bool Curl_pipeline_server_blacklisted(struct SessionHandle *handle,
|
||||
CURLMcode Curl_pipeline_set_server_blacklist(char **servers,
|
||||
struct curl_llist **list_ptr);
|
||||
|
||||
void print_pipeline(struct connectdata *conn);
|
||||
|
||||
#endif /* HEADER_CURL_PIPELINE_H */
|
||||
|
||||
605
lib/pop3.c
605
lib/pop3.c
@@ -73,7 +73,7 @@
|
||||
|
||||
#include "strtoofft.h"
|
||||
#include "strequal.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "connect.h"
|
||||
#include "strerror.h"
|
||||
#include "select.h"
|
||||
@@ -106,6 +106,10 @@ static CURLcode pop3_setup_connection(struct connectdata *conn);
|
||||
static CURLcode pop3_parse_url_options(struct connectdata *conn);
|
||||
static CURLcode pop3_parse_url_path(struct connectdata *conn);
|
||||
static CURLcode pop3_parse_custom_request(struct connectdata *conn);
|
||||
static CURLcode pop3_calc_sasl_details(struct connectdata *conn,
|
||||
const char **mech,
|
||||
char **initresp, size_t *len,
|
||||
pop3state *state1, pop3state *state2);
|
||||
|
||||
/*
|
||||
* POP3 protocol handler.
|
||||
@@ -232,8 +236,6 @@ static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len,
|
||||
int *resp)
|
||||
{
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
size_t wordlen;
|
||||
size_t i;
|
||||
|
||||
/* Do we have an error response? */
|
||||
if(len >= 4 && !memcmp("-ERR", line, 4)) {
|
||||
@@ -242,101 +244,15 @@ static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Are we processing servergreet responses? */
|
||||
if(pop3c->state == POP3_SERVERGREET) {
|
||||
/* Look for the APOP timestamp */
|
||||
if(len >= 3 && line[len - 3] == '>') {
|
||||
for(i = 0; i < len - 3; ++i) {
|
||||
if(line[i] == '<') {
|
||||
/* Calculate the length of the timestamp */
|
||||
size_t timestamplen = len - 2 - i;
|
||||
|
||||
/* Allocate some memory for the timestamp */
|
||||
pop3c->apoptimestamp = (char *)calloc(1, timestamplen + 1);
|
||||
|
||||
if(!pop3c->apoptimestamp)
|
||||
break;
|
||||
|
||||
/* Copy the timestamp */
|
||||
memcpy(pop3c->apoptimestamp, line + i, timestamplen);
|
||||
pop3c->apoptimestamp[timestamplen] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Are we processing CAPA command responses? */
|
||||
else if(pop3c->state == POP3_CAPA) {
|
||||
if(pop3c->state == POP3_CAPA) {
|
||||
/* Do we have the terminating line? */
|
||||
if(len >= 1 && !memcmp(line, ".", 1)) {
|
||||
if(len >= 1 && !memcmp(line, ".", 1))
|
||||
*resp = '+';
|
||||
else
|
||||
*resp = '*';
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Does the server support the STLS capability? */
|
||||
if(len >= 4 && !memcmp(line, "STLS", 4))
|
||||
pop3c->tls_supported = TRUE;
|
||||
|
||||
/* Does the server support clear text authentication? */
|
||||
else if(len >= 4 && !memcmp(line, "USER", 4))
|
||||
pop3c->authtypes |= POP3_TYPE_CLEARTEXT;
|
||||
|
||||
/* Does the server support APOP authentication? */
|
||||
else if(len >= 4 && !memcmp(line, "APOP", 4))
|
||||
pop3c->authtypes |= POP3_TYPE_APOP;
|
||||
|
||||
/* Does the server support SASL based authentication? */
|
||||
else if(len >= 5 && !memcmp(line, "SASL ", 5)) {
|
||||
pop3c->authtypes |= POP3_TYPE_SASL;
|
||||
|
||||
/* Advance past the SASL keyword */
|
||||
line += 5;
|
||||
len -= 5;
|
||||
|
||||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
while(len &&
|
||||
(*line == ' ' || *line == '\t' ||
|
||||
*line == '\r' || *line == '\n')) {
|
||||
|
||||
line++;
|
||||
len--;
|
||||
}
|
||||
|
||||
if(!len)
|
||||
break;
|
||||
|
||||
/* Extract the word */
|
||||
for(wordlen = 0; wordlen < len && line[wordlen] != ' ' &&
|
||||
line[wordlen] != '\t' && line[wordlen] != '\r' &&
|
||||
line[wordlen] != '\n';)
|
||||
wordlen++;
|
||||
|
||||
/* Test the word for a matching authentication mechanism */
|
||||
if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_LOGIN))
|
||||
pop3c->authmechs |= SASL_MECH_LOGIN;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_PLAIN))
|
||||
pop3c->authmechs |= SASL_MECH_PLAIN;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_CRAM_MD5))
|
||||
pop3c->authmechs |= SASL_MECH_CRAM_MD5;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_DIGEST_MD5))
|
||||
pop3c->authmechs |= SASL_MECH_DIGEST_MD5;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_GSSAPI))
|
||||
pop3c->authmechs |= SASL_MECH_GSSAPI;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_EXTERNAL))
|
||||
pop3c->authmechs |= SASL_MECH_EXTERNAL;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_NTLM))
|
||||
pop3c->authmechs |= SASL_MECH_NTLM;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_XOAUTH2))
|
||||
pop3c->authmechs |= SASL_MECH_XOAUTH2;
|
||||
|
||||
line += wordlen;
|
||||
len -= wordlen;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Do we have a command or continuation response? */
|
||||
@@ -574,18 +490,48 @@ static CURLcode pop3_perform_apop(struct connectdata *conn)
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* pop3_perform_authenticate()
|
||||
* pop3_perform_auth()
|
||||
*
|
||||
* Sends an AUTH command allowing the client to login with the appropriate
|
||||
* SASL authentication mechanism.
|
||||
*
|
||||
* Additionally, the function will perform fallback to APOP and USER commands
|
||||
* should a common mechanism not be available between the client and server.
|
||||
* Sends an AUTH command allowing the client to login with the given SASL
|
||||
* authentication mechanism.
|
||||
*/
|
||||
static CURLcode pop3_perform_authenticate(struct connectdata *conn)
|
||||
static CURLcode pop3_perform_auth(struct connectdata *conn,
|
||||
const char *mech,
|
||||
const char *initresp, size_t len,
|
||||
pop3state state1, pop3state state2)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
|
||||
if(initresp && 8 + strlen(mech) + len <= 255) { /* AUTH <mech> ...<crlf> */
|
||||
/* Send the AUTH command with the initial response */
|
||||
result = Curl_pp_sendf(&pop3c->pp, "AUTH %s %s", mech, initresp);
|
||||
|
||||
if(!result)
|
||||
state(conn, state2);
|
||||
}
|
||||
else {
|
||||
/* Send the AUTH command */
|
||||
result = Curl_pp_sendf(&pop3c->pp, "AUTH %s", mech);
|
||||
|
||||
if(!result)
|
||||
state(conn, state1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* pop3_perform_authentication()
|
||||
*
|
||||
* Initiates the authentication sequence, with the appropriate SASL
|
||||
* authentication mechanism, falling back to APOP and clear text should a
|
||||
* common mechanism not be available between the client and server.
|
||||
*/
|
||||
static CURLcode pop3_perform_authentication(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *mech = NULL;
|
||||
char *initresp = NULL;
|
||||
@@ -601,93 +547,15 @@ static CURLcode pop3_perform_authenticate(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Calculate the supported authentication mechanism, by decreasing order of
|
||||
security, as well as the initial response where appropriate */
|
||||
if(pop3c->authtypes & POP3_TYPE_SASL) {
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
if((pop3c->authmechs & SASL_MECH_DIGEST_MD5) &&
|
||||
(pop3c->prefmech & SASL_MECH_DIGEST_MD5)) {
|
||||
mech = SASL_MECH_STRING_DIGEST_MD5;
|
||||
state1 = POP3_AUTH_DIGESTMD5;
|
||||
pop3c->authused = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if((pop3c->authmechs & SASL_MECH_CRAM_MD5) &&
|
||||
(pop3c->prefmech & SASL_MECH_CRAM_MD5)) {
|
||||
mech = SASL_MECH_STRING_CRAM_MD5;
|
||||
state1 = POP3_AUTH_CRAMMD5;
|
||||
pop3c->authused = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_NTLM
|
||||
if((pop3c->authmechs & SASL_MECH_NTLM) &&
|
||||
(pop3c->prefmech & SASL_MECH_NTLM)) {
|
||||
mech = SASL_MECH_STRING_NTLM;
|
||||
state1 = POP3_AUTH_NTLM;
|
||||
state2 = POP3_AUTH_NTLM_TYPE2MSG;
|
||||
pop3c->authused = SASL_MECH_NTLM;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
|
||||
&conn->ntlm,
|
||||
&initresp, &len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(((pop3c->authmechs & SASL_MECH_XOAUTH2) &&
|
||||
(pop3c->prefmech & SASL_MECH_XOAUTH2) &&
|
||||
(pop3c->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) {
|
||||
mech = SASL_MECH_STRING_XOAUTH2;
|
||||
state1 = POP3_AUTH_XOAUTH2;
|
||||
state2 = POP3_AUTH_FINAL;
|
||||
pop3c->authused = SASL_MECH_XOAUTH2;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_xoauth2_message(conn->data, conn->user,
|
||||
conn->xoauth2_bearer,
|
||||
&initresp, &len);
|
||||
}
|
||||
else if((pop3c->authmechs & SASL_MECH_LOGIN) &&
|
||||
(pop3c->prefmech & SASL_MECH_LOGIN)) {
|
||||
mech = SASL_MECH_STRING_LOGIN;
|
||||
state1 = POP3_AUTH_LOGIN;
|
||||
state2 = POP3_AUTH_LOGIN_PASSWD;
|
||||
pop3c->authused = SASL_MECH_LOGIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_login_message(conn->data, conn->user,
|
||||
&initresp, &len);
|
||||
}
|
||||
else if((pop3c->authmechs & SASL_MECH_PLAIN) &&
|
||||
(pop3c->prefmech & SASL_MECH_PLAIN)) {
|
||||
mech = SASL_MECH_STRING_PLAIN;
|
||||
state1 = POP3_AUTH_PLAIN;
|
||||
state2 = POP3_AUTH_FINAL;
|
||||
pop3c->authused = SASL_MECH_PLAIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_plain_message(conn->data, conn->user,
|
||||
conn->passwd, &initresp,
|
||||
&len);
|
||||
}
|
||||
}
|
||||
/* Calculate the SASL login details */
|
||||
if(pop3c->authtypes & POP3_TYPE_SASL)
|
||||
result = pop3_calc_sasl_details(conn, &mech, &initresp, &len, &state1,
|
||||
&state2);
|
||||
|
||||
if(!result) {
|
||||
if(mech && (pop3c->preftype & POP3_TYPE_SASL)) {
|
||||
/* Perform SASL based authentication */
|
||||
if(initresp &&
|
||||
8 + strlen(mech) + len <= 255) { /* AUTH <mech> ...<crlf> */
|
||||
result = Curl_pp_sendf(&pop3c->pp, "AUTH %s %s", mech, initresp);
|
||||
|
||||
if(!result)
|
||||
state(conn, state2);
|
||||
}
|
||||
else {
|
||||
result = Curl_pp_sendf(&pop3c->pp, "AUTH %s", mech);
|
||||
|
||||
if(!result)
|
||||
state(conn, state1);
|
||||
}
|
||||
result = pop3_perform_auth(conn, mech, initresp, len, state1, state2);
|
||||
|
||||
Curl_safefree(initresp);
|
||||
}
|
||||
@@ -777,6 +645,10 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t i;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
@@ -784,8 +656,36 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
|
||||
failf(data, "Got unexpected pop3-server response");
|
||||
result = CURLE_FTP_WEIRD_SERVER_REPLY;
|
||||
}
|
||||
else
|
||||
else {
|
||||
/* Does the server support APOP authentication? */
|
||||
if(len >= 4 && line[len - 2] == '>') {
|
||||
/* Look for the APOP timestamp */
|
||||
for(i = 3; i < len - 2; ++i) {
|
||||
if(line[i] == '<') {
|
||||
/* Calculate the length of the timestamp */
|
||||
size_t timestamplen = len - 1 - i;
|
||||
if(!timestamplen)
|
||||
break;
|
||||
|
||||
/* Allocate some memory for the timestamp */
|
||||
pop3c->apoptimestamp = (char *)calloc(1, timestamplen + 1);
|
||||
|
||||
if(!pop3c->apoptimestamp)
|
||||
break;
|
||||
|
||||
/* Copy the timestamp */
|
||||
memcpy(pop3c->apoptimestamp, line + i, timestamplen);
|
||||
pop3c->apoptimestamp[timestamplen] = '\0';
|
||||
|
||||
/* Store the APOP capability */
|
||||
pop3c->authtypes |= POP3_TYPE_APOP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = pop3_perform_capa(conn);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -797,26 +697,95 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code,
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t wordlen;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
if(pop3code != '+')
|
||||
result = pop3_perform_user(conn);
|
||||
else if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
|
||||
/* We don't have a SSL/TLS connection yet, but SSL is requested */
|
||||
if(pop3c->tls_supported)
|
||||
/* Switch to TLS connection now */
|
||||
result = pop3_perform_starttls(conn);
|
||||
else if(data->set.use_ssl == CURLUSESSL_TRY)
|
||||
/* Fallback and carry on with authentication */
|
||||
result = pop3_perform_authenticate(conn);
|
||||
else {
|
||||
failf(data, "STLS not supported.");
|
||||
result = CURLE_USE_SSL_FAILED;
|
||||
/* Do we have a untagged response? */
|
||||
if(pop3code == '*') {
|
||||
/* Does the server support the STLS capability? */
|
||||
if(len >= 4 && !memcmp(line, "STLS", 4))
|
||||
pop3c->tls_supported = TRUE;
|
||||
|
||||
/* Does the server support clear text authentication? */
|
||||
else if(len >= 4 && !memcmp(line, "USER", 4))
|
||||
pop3c->authtypes |= POP3_TYPE_CLEARTEXT;
|
||||
|
||||
/* Does the server support SASL based authentication? */
|
||||
else if(len >= 5 && !memcmp(line, "SASL ", 5)) {
|
||||
pop3c->authtypes |= POP3_TYPE_SASL;
|
||||
|
||||
/* Advance past the SASL keyword */
|
||||
line += 5;
|
||||
len -= 5;
|
||||
|
||||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
while(len &&
|
||||
(*line == ' ' || *line == '\t' ||
|
||||
*line == '\r' || *line == '\n')) {
|
||||
|
||||
line++;
|
||||
len--;
|
||||
}
|
||||
|
||||
if(!len)
|
||||
break;
|
||||
|
||||
/* Extract the word */
|
||||
for(wordlen = 0; wordlen < len && line[wordlen] != ' ' &&
|
||||
line[wordlen] != '\t' && line[wordlen] != '\r' &&
|
||||
line[wordlen] != '\n';)
|
||||
wordlen++;
|
||||
|
||||
/* Test the word for a matching authentication mechanism */
|
||||
if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_LOGIN))
|
||||
pop3c->authmechs |= SASL_MECH_LOGIN;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_PLAIN))
|
||||
pop3c->authmechs |= SASL_MECH_PLAIN;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_CRAM_MD5))
|
||||
pop3c->authmechs |= SASL_MECH_CRAM_MD5;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_DIGEST_MD5))
|
||||
pop3c->authmechs |= SASL_MECH_DIGEST_MD5;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_GSSAPI))
|
||||
pop3c->authmechs |= SASL_MECH_GSSAPI;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_EXTERNAL))
|
||||
pop3c->authmechs |= SASL_MECH_EXTERNAL;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_NTLM))
|
||||
pop3c->authmechs |= SASL_MECH_NTLM;
|
||||
else if(sasl_mech_equal(line, wordlen, SASL_MECH_STRING_XOAUTH2))
|
||||
pop3c->authmechs |= SASL_MECH_XOAUTH2;
|
||||
|
||||
line += wordlen;
|
||||
len -= wordlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
result = pop3_perform_authenticate(conn);
|
||||
else if(pop3code == '+') {
|
||||
if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
|
||||
/* We don't have a SSL/TLS connection yet, but SSL is requested */
|
||||
if(pop3c->tls_supported)
|
||||
/* Switch to TLS connection now */
|
||||
result = pop3_perform_starttls(conn);
|
||||
else if(data->set.use_ssl == CURLUSESSL_TRY)
|
||||
/* Fallback and carry on with authentication */
|
||||
result = pop3_perform_authentication(conn);
|
||||
else {
|
||||
failf(data, "STLS not supported.");
|
||||
result = CURLE_USE_SSL_FAILED;
|
||||
}
|
||||
}
|
||||
else
|
||||
result = pop3_perform_authentication(conn);
|
||||
}
|
||||
else {
|
||||
/* Clear text is supported when CAPA isn't recognised */
|
||||
pop3c->authtypes |= POP3_TYPE_CLEARTEXT;
|
||||
|
||||
result = pop3_perform_authentication(conn);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -837,7 +806,7 @@ static CURLcode pop3_state_starttls_resp(struct connectdata *conn,
|
||||
result = CURLE_USE_SSL_FAILED;
|
||||
}
|
||||
else
|
||||
result = pop3_perform_authenticate(conn);
|
||||
result = pop3_perform_authentication(conn);
|
||||
}
|
||||
else
|
||||
result = pop3_perform_upgrade_tls(conn);
|
||||
@@ -1205,14 +1174,52 @@ static CURLcode pop3_state_auth_cancel_resp(struct connectdata *conn,
|
||||
int pop3code,
|
||||
pop3state instate)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *mech = NULL;
|
||||
char *initresp = NULL;
|
||||
size_t len = 0;
|
||||
pop3state state1 = POP3_STOP;
|
||||
pop3state state2 = POP3_STOP;
|
||||
|
||||
(void)pop3code;
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
failf(data, "Authentication cancelled");
|
||||
/* Remove the offending mechanism from the supported list */
|
||||
pop3c->authmechs ^= pop3c->authused;
|
||||
|
||||
return CURLE_LOGIN_DENIED;
|
||||
/* Calculate alternative SASL login details */
|
||||
result = pop3_calc_sasl_details(conn, &mech, &initresp, &len, &state1,
|
||||
&state2);
|
||||
|
||||
if(!result) {
|
||||
/* Do we have any mechanisms left or can we fallback to another
|
||||
authentication type? */
|
||||
if(mech) {
|
||||
/* Retry SASL based authentication */
|
||||
result = pop3_perform_auth(conn, mech, initresp, len, state1, state2);
|
||||
|
||||
Curl_safefree(initresp);
|
||||
}
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
else if((pop3c->authtypes & POP3_TYPE_APOP) &&
|
||||
(pop3c->preftype & POP3_TYPE_APOP))
|
||||
/* Perform APOP authentication */
|
||||
result = pop3_perform_apop(conn);
|
||||
#endif
|
||||
else if((pop3c->authtypes & POP3_TYPE_CLEARTEXT) &&
|
||||
(pop3c->preftype & POP3_TYPE_CLEARTEXT))
|
||||
/* Perform clear text authentication */
|
||||
result = pop3_perform_user(conn);
|
||||
else {
|
||||
failf(data, "Authentication cancelled");
|
||||
|
||||
result = CURLE_LOGIN_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* For final responses in the AUTH sequence */
|
||||
@@ -1375,12 +1382,15 @@ static CURLcode pop3_statemach_act(struct connectdata *conn)
|
||||
if(pp->sendleft)
|
||||
return Curl_pp_flushsend(pp);
|
||||
|
||||
/* Read the response from the server */
|
||||
result = Curl_pp_readresp(sock, pp, &pop3code, &nread);
|
||||
if(result)
|
||||
return result;
|
||||
do {
|
||||
/* Read the response from the server */
|
||||
result = Curl_pp_readresp(sock, pp, &pop3code, &nread);
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
if(!pop3code)
|
||||
break;
|
||||
|
||||
if(pop3code) {
|
||||
/* We have now received a full POP3 server response */
|
||||
switch(pop3c->state) {
|
||||
case POP3_SERVERGREET:
|
||||
@@ -1470,7 +1480,7 @@ static CURLcode pop3_statemach_act(struct connectdata *conn)
|
||||
state(conn, POP3_STOP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while(!result && pop3c->state != POP3_STOP && Curl_pp_moredata(pp));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1824,56 +1834,68 @@ static CURLcode pop3_parse_url_options(struct connectdata *conn)
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *options = conn->options;
|
||||
const char *ptr = options;
|
||||
bool reset = TRUE;
|
||||
|
||||
if(options) {
|
||||
while(ptr && *ptr) {
|
||||
const char *key = ptr;
|
||||
|
||||
while(*ptr && *ptr != '=')
|
||||
ptr++;
|
||||
|
||||
if(strnequal(key, "AUTH", 4)) {
|
||||
const char *value = ptr + 1;
|
||||
size_t len = 0;
|
||||
const char *value = ++ptr;
|
||||
|
||||
if(strequal(value, "*")) {
|
||||
pop3c->preftype = POP3_TYPE_ANY;
|
||||
pop3c->prefmech = SASL_AUTH_ANY;
|
||||
}
|
||||
else if(strequal(value, "+APOP")) {
|
||||
pop3c->preftype = POP3_TYPE_APOP;
|
||||
pop3c->prefmech = SASL_AUTH_NONE;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_LOGIN)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech = SASL_MECH_LOGIN;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_PLAIN)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech = SASL_MECH_PLAIN;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_CRAM_MD5)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_DIGEST_MD5)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_GSSAPI)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech = SASL_MECH_GSSAPI;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_NTLM)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech = SASL_MECH_NTLM;
|
||||
}
|
||||
else if(strequal(value, SASL_MECH_STRING_XOAUTH2)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech = SASL_MECH_XOAUTH2;
|
||||
}
|
||||
else {
|
||||
if(reset) {
|
||||
reset = FALSE;
|
||||
pop3c->preftype = POP3_TYPE_NONE;
|
||||
pop3c->prefmech = SASL_AUTH_NONE;
|
||||
}
|
||||
|
||||
while(*ptr && *ptr != ';') {
|
||||
ptr++;
|
||||
len++;
|
||||
}
|
||||
|
||||
if(strnequal(value, "*", len)) {
|
||||
pop3c->preftype = POP3_TYPE_ANY;
|
||||
pop3c->prefmech = SASL_AUTH_ANY;
|
||||
}
|
||||
else if(strnequal(value, "+APOP", len)) {
|
||||
pop3c->preftype = POP3_TYPE_APOP;
|
||||
pop3c->prefmech = SASL_AUTH_NONE;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech |= SASL_MECH_LOGIN;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech |= SASL_MECH_PLAIN;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech |= SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech |= SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech |= SASL_MECH_GSSAPI;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech |= SASL_MECH_NTLM;
|
||||
}
|
||||
else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) {
|
||||
pop3c->preftype = POP3_TYPE_SASL;
|
||||
pop3c->prefmech |= SASL_MECH_XOAUTH2;
|
||||
}
|
||||
|
||||
if(*ptr == ';')
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
result = CURLE_URL_MALFORMAT;
|
||||
@@ -1919,6 +1941,91 @@ static CURLcode pop3_parse_custom_request(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* pop3_calc_sasl_details()
|
||||
*
|
||||
* Calculate the required login details for SASL authentication.
|
||||
*/
|
||||
static CURLcode pop3_calc_sasl_details(struct connectdata *conn,
|
||||
const char **mech,
|
||||
char **initresp, size_t *len,
|
||||
pop3state *state1, pop3state *state2)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
|
||||
/* Calculate the supported authentication mechanism, by decreasing order of
|
||||
security, as well as the initial response where appropriate */
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
if((pop3c->authmechs & SASL_MECH_DIGEST_MD5) &&
|
||||
(pop3c->prefmech & SASL_MECH_DIGEST_MD5)) {
|
||||
*mech = SASL_MECH_STRING_DIGEST_MD5;
|
||||
*state1 = POP3_AUTH_DIGESTMD5;
|
||||
pop3c->authused = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if((pop3c->authmechs & SASL_MECH_CRAM_MD5) &&
|
||||
(pop3c->prefmech & SASL_MECH_CRAM_MD5)) {
|
||||
*mech = SASL_MECH_STRING_CRAM_MD5;
|
||||
*state1 = POP3_AUTH_CRAMMD5;
|
||||
pop3c->authused = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_NTLM
|
||||
if((pop3c->authmechs & SASL_MECH_NTLM) &&
|
||||
(pop3c->prefmech & SASL_MECH_NTLM)) {
|
||||
*mech = SASL_MECH_STRING_NTLM;
|
||||
*state1 = POP3_AUTH_NTLM;
|
||||
*state2 = POP3_AUTH_NTLM_TYPE2MSG;
|
||||
pop3c->authused = SASL_MECH_NTLM;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
|
||||
&conn->ntlm,
|
||||
initresp, len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(((pop3c->authmechs & SASL_MECH_XOAUTH2) &&
|
||||
(pop3c->prefmech & SASL_MECH_XOAUTH2) &&
|
||||
(pop3c->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) {
|
||||
*mech = SASL_MECH_STRING_XOAUTH2;
|
||||
*state1 = POP3_AUTH_XOAUTH2;
|
||||
*state2 = POP3_AUTH_FINAL;
|
||||
pop3c->authused = SASL_MECH_XOAUTH2;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_xoauth2_message(data, conn->user,
|
||||
conn->xoauth2_bearer,
|
||||
initresp, len);
|
||||
}
|
||||
else if((pop3c->authmechs & SASL_MECH_LOGIN) &&
|
||||
(pop3c->prefmech & SASL_MECH_LOGIN)) {
|
||||
*mech = SASL_MECH_STRING_LOGIN;
|
||||
*state1 = POP3_AUTH_LOGIN;
|
||||
*state2 = POP3_AUTH_LOGIN_PASSWD;
|
||||
pop3c->authused = SASL_MECH_LOGIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_login_message(data, conn->user, initresp, len);
|
||||
}
|
||||
else if((pop3c->authmechs & SASL_MECH_PLAIN) &&
|
||||
(pop3c->prefmech & SASL_MECH_PLAIN)) {
|
||||
*mech = SASL_MECH_STRING_PLAIN;
|
||||
*state1 = POP3_AUTH_PLAIN;
|
||||
*state2 = POP3_AUTH_FINAL;
|
||||
pop3c->authused = SASL_MECH_PLAIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd,
|
||||
initresp, len);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Curl_pop3_write()
|
||||
|
||||
@@ -42,8 +42,8 @@ static void time2str(char *r, curl_off_t seconds)
|
||||
if(h <= CURL_OFF_T_C(99)) {
|
||||
m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
|
||||
s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
|
||||
snprintf(r, 9, "%2" FORMAT_OFF_T ":%02" FORMAT_OFF_T ":%02" FORMAT_OFF_T,
|
||||
h, m, s);
|
||||
snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
|
||||
":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
|
||||
}
|
||||
else {
|
||||
/* this equals to more than 99 hours, switch to a more suitable output
|
||||
@@ -51,9 +51,10 @@ static void time2str(char *r, curl_off_t seconds)
|
||||
d = seconds / CURL_OFF_T_C(86400);
|
||||
h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600);
|
||||
if(d <= CURL_OFF_T_C(999))
|
||||
snprintf(r, 9, "%3" FORMAT_OFF_T "d %02" FORMAT_OFF_T "h", d, h);
|
||||
snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
|
||||
"d %02" CURL_FORMAT_CURL_OFF_T "h", d, h);
|
||||
else
|
||||
snprintf(r, 9, "%7" FORMAT_OFF_T "d", d);
|
||||
snprintf(r, 9, "%7" CURL_FORMAT_CURL_OFF_T "d", d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,40 +70,40 @@ static char *max5data(curl_off_t bytes, char *max5)
|
||||
#define ONE_PETABYTE (CURL_OFF_T_C(1024) * ONE_TERABYTE)
|
||||
|
||||
if(bytes < CURL_OFF_T_C(100000))
|
||||
snprintf(max5, 6, "%5" FORMAT_OFF_T, bytes);
|
||||
snprintf(max5, 6, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_KILOBYTE)
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "k", bytes/ONE_KILOBYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "k", bytes/ONE_KILOBYTE);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(100) * ONE_MEGABYTE)
|
||||
/* 'XX.XM' is good as long as we're less than 100 megs */
|
||||
snprintf(max5, 6, "%2" FORMAT_OFF_T ".%0" FORMAT_OFF_T "M",
|
||||
bytes/ONE_MEGABYTE,
|
||||
snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
|
||||
CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE,
|
||||
(bytes%ONE_MEGABYTE) / (ONE_MEGABYTE/CURL_OFF_T_C(10)) );
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_MEGABYTE)
|
||||
/* 'XXXXM' is good until we're at 10000MB or above */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(100) * ONE_GIGABYTE)
|
||||
/* 10000 MB - 100 GB, we show it as XX.XG */
|
||||
snprintf(max5, 6, "%2" FORMAT_OFF_T ".%0" FORMAT_OFF_T "G",
|
||||
bytes/ONE_GIGABYTE,
|
||||
snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
|
||||
CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE,
|
||||
(bytes%ONE_GIGABYTE) / (ONE_GIGABYTE/CURL_OFF_T_C(10)) );
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_GIGABYTE)
|
||||
/* up to 10000GB, display without decimal: XXXXG */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "G", bytes/ONE_GIGABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_TERABYTE)
|
||||
/* up to 10000TB, display without decimal: XXXXT */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "T", bytes/ONE_TERABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "T", bytes/ONE_TERABYTE);
|
||||
|
||||
else
|
||||
/* up to 10000PB, display without decimal: XXXXP */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "P", bytes/ONE_PETABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "P", bytes/ONE_PETABYTE);
|
||||
|
||||
/* 16384 petabytes (16 exabytes) is the maximum a 64 bit unsigned number
|
||||
can hold, but our data type is signed so 8192PB will be the maximum. */
|
||||
@@ -110,7 +111,7 @@ static char *max5data(curl_off_t bytes, char *max5)
|
||||
#else
|
||||
|
||||
else
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -392,8 +393,8 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
if(!(data->progress.flags & PGRS_HEADERS_OUT)) {
|
||||
if(data->state.resume_from) {
|
||||
fprintf(data->set.err,
|
||||
"** Resuming transfer from byte position %" FORMAT_OFF_T "\n",
|
||||
data->state.resume_from);
|
||||
"** Resuming transfer from byte position %"
|
||||
CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
|
||||
}
|
||||
fprintf(data->set.err,
|
||||
" %% Total %% Received %% Xferd Average Speed "
|
||||
@@ -457,9 +458,9 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
|
||||
fprintf(data->set.err,
|
||||
"\r"
|
||||
"%3" FORMAT_OFF_T " %s "
|
||||
"%3" FORMAT_OFF_T " %s "
|
||||
"%3" FORMAT_OFF_T " %s %s %s %s %s %s %s",
|
||||
"%3" CURL_FORMAT_CURL_OFF_T " %s "
|
||||
"%3" CURL_FORMAT_CURL_OFF_T " %s "
|
||||
"%3" CURL_FORMAT_CURL_OFF_T " %s %s %s %s %s %s %s",
|
||||
total_percen, /* 3 letters */ /* total % */
|
||||
max5data(total_expected_transfer, max5[2]), /* total size */
|
||||
dlpercen, /* 3 letters */ /* rcvd % */
|
||||
|
||||
@@ -509,7 +509,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
|
||||
* actually set a custom Content-Length in the headers */
|
||||
if(!Curl_checkheaders(data, "Content-Length:")) {
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T"\r\n",
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
|
||||
(data->set.upload ? putsize : postsize));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
18
lib/sendf.c
18
lib/sendf.c
@@ -27,7 +27,7 @@
|
||||
#include "urldata.h"
|
||||
#include "sendf.h"
|
||||
#include "connect.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "ssh.h"
|
||||
#include "multiif.h"
|
||||
#include "non-ascii.h"
|
||||
@@ -444,10 +444,18 @@ CURLcode Curl_client_write(struct connectdata *conn,
|
||||
wrote = len;
|
||||
}
|
||||
|
||||
if(CURL_WRITEFUNC_PAUSE == wrote)
|
||||
return pausewrite(data, type, ptr, len);
|
||||
|
||||
if(wrote != len) {
|
||||
if(CURL_WRITEFUNC_PAUSE == wrote) {
|
||||
if(conn->handler->flags & PROTOPT_NONETWORK) {
|
||||
/* Protocols that work without network cannot be paused. This is
|
||||
actually only FILE:// just now, and it can't pause since the
|
||||
transfer isn't done using the "normal" procedure. */
|
||||
failf(data, "Write callback asked for PAUSE when not supported!");
|
||||
return CURLE_WRITE_ERROR;
|
||||
}
|
||||
else
|
||||
return pausewrite(data, type, ptr, len);
|
||||
}
|
||||
else if(wrote != len) {
|
||||
failf(data, "Failed writing body (%zu != %zu)", wrote, len);
|
||||
return CURLE_WRITE_ERROR;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <curl/curl.h>
|
||||
#include "urldata.h"
|
||||
#include "share.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "curl_memory.h"
|
||||
|
||||
/* The last #include file should be: */
|
||||
|
||||
306
lib/smtp.c
306
lib/smtp.c
@@ -72,7 +72,7 @@
|
||||
|
||||
#include "strtoofft.h"
|
||||
#include "strequal.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "connect.h"
|
||||
#include "strerror.h"
|
||||
#include "select.h"
|
||||
@@ -105,6 +105,10 @@ static CURLcode smtp_setup_connection(struct connectdata *conn);
|
||||
static CURLcode smtp_parse_url_options(struct connectdata *conn);
|
||||
static CURLcode smtp_parse_url_path(struct connectdata *conn);
|
||||
static CURLcode smtp_parse_custom_request(struct connectdata *conn);
|
||||
static CURLcode smtp_calc_sasl_details(struct connectdata *conn,
|
||||
const char **mech,
|
||||
char **initresp, size_t *len,
|
||||
smtpstate *state1, smtpstate *state2);
|
||||
|
||||
/*
|
||||
* SMTP protocol handler.
|
||||
@@ -430,16 +434,47 @@ static CURLcode smtp_perform_upgrade_tls(struct connectdata *conn)
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* smtp_perform_authenticate()
|
||||
* smtp_perform_auth()
|
||||
*
|
||||
* Sends an AUTH command allowing the client to login with the appropriate
|
||||
* SASL authentication mechanism.
|
||||
* Sends an AUTH command allowing the client to login with the given SASL
|
||||
* authentication mechanism.
|
||||
*/
|
||||
static CURLcode smtp_perform_authenticate(struct connectdata *conn)
|
||||
static CURLcode smtp_perform_auth(struct connectdata *conn,
|
||||
const char *mech,
|
||||
const char *initresp, size_t len,
|
||||
smtpstate state1, smtpstate state2)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
|
||||
if(initresp && 8 + strlen(mech) + len <= 512) { /* AUTH <mech> ...<crlf> */
|
||||
/* Send the AUTH command with the initial response */
|
||||
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp);
|
||||
|
||||
if(!result)
|
||||
state(conn, state2);
|
||||
}
|
||||
else {
|
||||
/* Send the AUTH command */
|
||||
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s", mech);
|
||||
|
||||
if(!result)
|
||||
state(conn, state1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* smtp_perform_authentication()
|
||||
*
|
||||
* Initiates the authentication sequence, with the appropriate SASL
|
||||
* authentication mechanism.
|
||||
*/
|
||||
static CURLcode smtp_perform_authentication(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
const char *mech = NULL;
|
||||
char *initresp = NULL;
|
||||
size_t len = 0;
|
||||
@@ -454,90 +489,14 @@ static CURLcode smtp_perform_authenticate(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Calculate the supported authentication mechanism, by decreasing order of
|
||||
security, as well as the initial response where appropriate */
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
if((smtpc->authmechs & SASL_MECH_DIGEST_MD5) &&
|
||||
(smtpc->prefmech & SASL_MECH_DIGEST_MD5)) {
|
||||
mech = SASL_MECH_STRING_DIGEST_MD5;
|
||||
state1 = SMTP_AUTH_DIGESTMD5;
|
||||
smtpc->authused = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if((smtpc->authmechs & SASL_MECH_CRAM_MD5) &&
|
||||
(smtpc->prefmech & SASL_MECH_CRAM_MD5)) {
|
||||
mech = SASL_MECH_STRING_CRAM_MD5;
|
||||
state1 = SMTP_AUTH_CRAMMD5;
|
||||
smtpc->authused = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_NTLM
|
||||
if((smtpc->authmechs & SASL_MECH_NTLM) &&
|
||||
(smtpc->prefmech & SASL_MECH_NTLM)) {
|
||||
mech = SASL_MECH_STRING_NTLM;
|
||||
state1 = SMTP_AUTH_NTLM;
|
||||
state2 = SMTP_AUTH_NTLM_TYPE2MSG;
|
||||
smtpc->authused = SASL_MECH_NTLM;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
|
||||
&conn->ntlm,
|
||||
&initresp, &len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(((smtpc->authmechs & SASL_MECH_XOAUTH2) &&
|
||||
(smtpc->prefmech & SASL_MECH_XOAUTH2) &&
|
||||
(smtpc->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) {
|
||||
mech = SASL_MECH_STRING_XOAUTH2;
|
||||
state1 = SMTP_AUTH_XOAUTH2;
|
||||
state2 = SMTP_AUTH_FINAL;
|
||||
smtpc->authused = SASL_MECH_XOAUTH2;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_xoauth2_message(conn->data, conn->user,
|
||||
conn->xoauth2_bearer,
|
||||
&initresp, &len);
|
||||
}
|
||||
else if((smtpc->authmechs & SASL_MECH_LOGIN) &&
|
||||
(smtpc->prefmech & SASL_MECH_LOGIN)) {
|
||||
mech = SASL_MECH_STRING_LOGIN;
|
||||
state1 = SMTP_AUTH_LOGIN;
|
||||
state2 = SMTP_AUTH_LOGIN_PASSWD;
|
||||
smtpc->authused = SASL_MECH_LOGIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_login_message(conn->data, conn->user,
|
||||
&initresp, &len);
|
||||
}
|
||||
else if((smtpc->authmechs & SASL_MECH_PLAIN) &&
|
||||
(smtpc->prefmech & SASL_MECH_PLAIN)) {
|
||||
mech = SASL_MECH_STRING_PLAIN;
|
||||
state1 = SMTP_AUTH_PLAIN;
|
||||
state2 = SMTP_AUTH_FINAL;
|
||||
smtpc->authused = SASL_MECH_PLAIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_plain_message(conn->data, conn->user,
|
||||
conn->passwd, &initresp, &len);
|
||||
}
|
||||
/* Calculate the SASL login details */
|
||||
result = smtp_calc_sasl_details(conn, &mech, &initresp, &len, &state1,
|
||||
&state2);
|
||||
|
||||
if(!result) {
|
||||
if(mech) {
|
||||
/* Perform SASL based authentication */
|
||||
if(initresp &&
|
||||
8 + strlen(mech) + len <= 512) { /* AUTH <mech> ...<crlf> */
|
||||
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp);
|
||||
|
||||
if(!result)
|
||||
state(conn, state2);
|
||||
}
|
||||
else {
|
||||
result = Curl_pp_sendf(&smtpc->pp, "AUTH %s", mech);
|
||||
|
||||
if(!result)
|
||||
state(conn, state1);
|
||||
}
|
||||
result = smtp_perform_auth(conn, mech, initresp, len, state1, state2);
|
||||
|
||||
Curl_safefree(initresp);
|
||||
}
|
||||
@@ -623,7 +582,7 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
|
||||
|
||||
/* Calculate the optional SIZE parameter */
|
||||
if(conn->proto.smtpc.size_supported && conn->data->set.infilesize > 0) {
|
||||
size = aprintf("%" FORMAT_OFF_T, data->set.infilesize);
|
||||
size = aprintf("%" CURL_FORMAT_CURL_OFF_T, data->set.infilesize);
|
||||
|
||||
if(!size) {
|
||||
Curl_safefree(from);
|
||||
@@ -738,7 +697,7 @@ static CURLcode smtp_state_starttls_resp(struct connectdata *conn,
|
||||
result = CURLE_USE_SSL_FAILED;
|
||||
}
|
||||
else
|
||||
result = smtp_perform_authenticate(conn);
|
||||
result = smtp_perform_authentication(conn);
|
||||
}
|
||||
else
|
||||
result = smtp_perform_upgrade_tls(conn);
|
||||
@@ -835,14 +794,14 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
|
||||
result = smtp_perform_starttls(conn);
|
||||
else if(data->set.use_ssl == CURLUSESSL_TRY)
|
||||
/* Fallback and carry on with authentication */
|
||||
result = smtp_perform_authenticate(conn);
|
||||
result = smtp_perform_authentication(conn);
|
||||
else {
|
||||
failf(data, "STARTTLS not supported.");
|
||||
result = CURLE_USE_SSL_FAILED;
|
||||
}
|
||||
}
|
||||
else
|
||||
result = smtp_perform_authenticate(conn);
|
||||
result = smtp_perform_authentication(conn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1230,14 +1189,41 @@ static CURLcode smtp_state_auth_cancel_resp(struct connectdata *conn,
|
||||
int smtpcode,
|
||||
smtpstate instate)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
const char *mech = NULL;
|
||||
char *initresp = NULL;
|
||||
size_t len = 0;
|
||||
smtpstate state1 = SMTP_STOP;
|
||||
smtpstate state2 = SMTP_STOP;
|
||||
|
||||
(void)smtpcode;
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
failf(data, "Authentication cancelled");
|
||||
/* Remove the offending mechanism from the supported list */
|
||||
smtpc->authmechs ^= smtpc->authused;
|
||||
|
||||
return CURLE_LOGIN_DENIED;
|
||||
/* Calculate alternative SASL login details */
|
||||
result = smtp_calc_sasl_details(conn, &mech, &initresp, &len, &state1,
|
||||
&state2);
|
||||
|
||||
if(!result) {
|
||||
/* Do we have any mechanisms left? */
|
||||
if(mech) {
|
||||
/* Retry SASL based authentication */
|
||||
result = smtp_perform_auth(conn, mech, initresp, len, state1, state2);
|
||||
|
||||
Curl_safefree(initresp);
|
||||
}
|
||||
else {
|
||||
failf(data, "Authentication cancelled");
|
||||
|
||||
result = CURLE_LOGIN_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* For final responses in the AUTH sequence */
|
||||
@@ -1941,34 +1927,47 @@ static CURLcode smtp_parse_url_options(struct connectdata *conn)
|
||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
const char *options = conn->options;
|
||||
const char *ptr = options;
|
||||
bool reset = TRUE;
|
||||
|
||||
if(options) {
|
||||
while(ptr && *ptr) {
|
||||
const char *key = ptr;
|
||||
|
||||
while(*ptr && *ptr != '=')
|
||||
ptr++;
|
||||
|
||||
if(strnequal(key, "AUTH", 4)) {
|
||||
const char *value = ptr + 1;
|
||||
size_t len = 0;
|
||||
const char *value = ++ptr;
|
||||
|
||||
if(strequal(value, "*"))
|
||||
smtpc->prefmech = SASL_AUTH_ANY;
|
||||
else if(strequal(value, SASL_MECH_STRING_LOGIN))
|
||||
smtpc->prefmech = SASL_MECH_LOGIN;
|
||||
else if(strequal(value, SASL_MECH_STRING_PLAIN))
|
||||
smtpc->prefmech = SASL_MECH_PLAIN;
|
||||
else if(strequal(value, SASL_MECH_STRING_CRAM_MD5))
|
||||
smtpc->prefmech = SASL_MECH_CRAM_MD5;
|
||||
else if(strequal(value, SASL_MECH_STRING_DIGEST_MD5))
|
||||
smtpc->prefmech = SASL_MECH_DIGEST_MD5;
|
||||
else if(strequal(value, SASL_MECH_STRING_GSSAPI))
|
||||
smtpc->prefmech = SASL_MECH_GSSAPI;
|
||||
else if(strequal(value, SASL_MECH_STRING_NTLM))
|
||||
smtpc->prefmech = SASL_MECH_NTLM;
|
||||
else if(strequal(value, SASL_MECH_STRING_XOAUTH2))
|
||||
smtpc->prefmech = SASL_MECH_XOAUTH2;
|
||||
else
|
||||
if(reset) {
|
||||
reset = FALSE;
|
||||
smtpc->prefmech = SASL_AUTH_NONE;
|
||||
}
|
||||
|
||||
while(*ptr && *ptr != ';') {
|
||||
ptr++;
|
||||
len++;
|
||||
}
|
||||
|
||||
if(strnequal(value, "*", len))
|
||||
smtpc->prefmech = SASL_AUTH_ANY;
|
||||
else if(strnequal(value, SASL_MECH_STRING_LOGIN, len))
|
||||
smtpc->prefmech |= SASL_MECH_LOGIN;
|
||||
else if(strnequal(value, SASL_MECH_STRING_PLAIN, len))
|
||||
smtpc->prefmech |= SASL_MECH_PLAIN;
|
||||
else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len))
|
||||
smtpc->prefmech |= SASL_MECH_CRAM_MD5;
|
||||
else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len))
|
||||
smtpc->prefmech |= SASL_MECH_DIGEST_MD5;
|
||||
else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len))
|
||||
smtpc->prefmech |= SASL_MECH_GSSAPI;
|
||||
else if(strnequal(value, SASL_MECH_STRING_NTLM, len))
|
||||
smtpc->prefmech |= SASL_MECH_NTLM;
|
||||
else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len))
|
||||
smtpc->prefmech |= SASL_MECH_XOAUTH2;
|
||||
|
||||
if(*ptr == ';')
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
result = CURLE_URL_MALFORMAT;
|
||||
@@ -2023,6 +2022,91 @@ static CURLcode smtp_parse_custom_request(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* smtp_calc_sasl_details()
|
||||
*
|
||||
* Calculate the required login details for SASL authentication.
|
||||
*/
|
||||
static CURLcode smtp_calc_sasl_details(struct connectdata *conn,
|
||||
const char **mech,
|
||||
char **initresp, size_t *len,
|
||||
smtpstate *state1, smtpstate *state2)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
|
||||
/* Calculate the supported authentication mechanism, by decreasing order of
|
||||
security, as well as the initial response where appropriate */
|
||||
#ifndef CURL_DISABLE_CRYPTO_AUTH
|
||||
if((smtpc->authmechs & SASL_MECH_DIGEST_MD5) &&
|
||||
(smtpc->prefmech & SASL_MECH_DIGEST_MD5)) {
|
||||
*mech = SASL_MECH_STRING_DIGEST_MD5;
|
||||
*state1 = SMTP_AUTH_DIGESTMD5;
|
||||
smtpc->authused = SASL_MECH_DIGEST_MD5;
|
||||
}
|
||||
else if((smtpc->authmechs & SASL_MECH_CRAM_MD5) &&
|
||||
(smtpc->prefmech & SASL_MECH_CRAM_MD5)) {
|
||||
*mech = SASL_MECH_STRING_CRAM_MD5;
|
||||
*state1 = SMTP_AUTH_CRAMMD5;
|
||||
smtpc->authused = SASL_MECH_CRAM_MD5;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_NTLM
|
||||
if((smtpc->authmechs & SASL_MECH_NTLM) &&
|
||||
(smtpc->prefmech & SASL_MECH_NTLM)) {
|
||||
*mech = SASL_MECH_STRING_NTLM;
|
||||
*state1 = SMTP_AUTH_NTLM;
|
||||
*state2 = SMTP_AUTH_NTLM_TYPE2MSG;
|
||||
smtpc->authused = SASL_MECH_NTLM;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd,
|
||||
&conn->ntlm,
|
||||
initresp, len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(((smtpc->authmechs & SASL_MECH_XOAUTH2) &&
|
||||
(smtpc->prefmech & SASL_MECH_XOAUTH2) &&
|
||||
(smtpc->prefmech != SASL_AUTH_ANY)) || conn->xoauth2_bearer) {
|
||||
*mech = SASL_MECH_STRING_XOAUTH2;
|
||||
*state1 = SMTP_AUTH_XOAUTH2;
|
||||
*state2 = SMTP_AUTH_FINAL;
|
||||
smtpc->authused = SASL_MECH_XOAUTH2;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_xoauth2_message(data, conn->user,
|
||||
conn->xoauth2_bearer,
|
||||
initresp, len);
|
||||
}
|
||||
else if((smtpc->authmechs & SASL_MECH_LOGIN) &&
|
||||
(smtpc->prefmech & SASL_MECH_LOGIN)) {
|
||||
*mech = SASL_MECH_STRING_LOGIN;
|
||||
*state1 = SMTP_AUTH_LOGIN;
|
||||
*state2 = SMTP_AUTH_LOGIN_PASSWD;
|
||||
smtpc->authused = SASL_MECH_LOGIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_login_message(data, conn->user, initresp, len);
|
||||
}
|
||||
else if((smtpc->authmechs & SASL_MECH_PLAIN) &&
|
||||
(smtpc->prefmech & SASL_MECH_PLAIN)) {
|
||||
*mech = SASL_MECH_STRING_PLAIN;
|
||||
*state1 = SMTP_AUTH_PLAIN;
|
||||
*state2 = SMTP_AUTH_FINAL;
|
||||
smtpc->authused = SASL_MECH_PLAIN;
|
||||
|
||||
if(data->set.sasl_ir)
|
||||
result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd,
|
||||
initresp, len);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
|
||||
{
|
||||
/* When sending a SMTP payload we must detect CRLF. sequences making sure
|
||||
|
||||
30
lib/ssh.c
30
lib/ssh.c
@@ -73,7 +73,7 @@
|
||||
#include "getinfo.h"
|
||||
|
||||
#include "strequal.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "connect.h"
|
||||
#include "strerror.h"
|
||||
#include "inet_ntop.h"
|
||||
@@ -1568,9 +1568,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
if(data->set.upload)
|
||||
state(conn, SSH_SFTP_UPLOAD_INIT);
|
||||
else {
|
||||
if(data->set.opt_no_body)
|
||||
state(conn, SSH_STOP);
|
||||
else if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
|
||||
if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
|
||||
state(conn, SSH_SFTP_READDIR_INIT);
|
||||
else
|
||||
state(conn, SSH_SFTP_DOWNLOAD_INIT);
|
||||
@@ -1602,7 +1600,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
else {
|
||||
curl_off_t size = attrs.filesize;
|
||||
if(size < 0) {
|
||||
failf(data, "Bad file size (%" FORMAT_OFF_T ")", size);
|
||||
failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
data->state.resume_from = attrs.filesize;
|
||||
@@ -1808,6 +1806,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
break;
|
||||
|
||||
case SSH_SFTP_READDIR_INIT:
|
||||
Curl_pgrsSetDownloadSize(data, -1);
|
||||
if(data->set.opt_no_body)
|
||||
state(conn, SSH_STOP);
|
||||
|
||||
/*
|
||||
* This is a directory that we are trying to get, so produce a directory
|
||||
* listing
|
||||
@@ -2065,12 +2067,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
*/
|
||||
data->req.size = -1;
|
||||
data->req.maxdownload = -1;
|
||||
Curl_pgrsSetDownloadSize(data, -1);
|
||||
}
|
||||
else {
|
||||
curl_off_t size = attrs.filesize;
|
||||
|
||||
if(size < 0) {
|
||||
failf(data, "Bad file size (%" FORMAT_OFF_T ")", size);
|
||||
failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
if(conn->data->state.use_range) {
|
||||
@@ -2092,8 +2095,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
}
|
||||
if(from >= size) {
|
||||
failf(data, "Offset (%"
|
||||
FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
from, attrs.filesize);
|
||||
CURL_FORMAT_CURL_OFF_T ") was beyond file size (%"
|
||||
CURL_FORMAT_CURL_OFF_T ")", from, attrs.filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
if(from > to) {
|
||||
@@ -2117,7 +2120,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
/* We're supposed to download the last abs(from) bytes */
|
||||
if((curl_off_t)attrs.filesize < -data->state.resume_from) {
|
||||
failf(data, "Offset (%"
|
||||
FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
CURL_FORMAT_CURL_OFF_T ") was beyond file size (%"
|
||||
CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, attrs.filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
@@ -2126,8 +2130,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
}
|
||||
else {
|
||||
if((curl_off_t)attrs.filesize < data->state.resume_from) {
|
||||
failf(data, "Offset (%" FORMAT_OFF_T
|
||||
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
|
||||
") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, attrs.filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
@@ -2141,6 +2145,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
SFTP_SEEK(sshc->sftp_handle, data->state.resume_from);
|
||||
}
|
||||
}
|
||||
|
||||
if(data->set.opt_no_body)
|
||||
state(conn, SSH_SFTP_CLOSE);
|
||||
|
||||
/* Setup the actual download */
|
||||
if(data->req.size == 0) {
|
||||
/* no data to transfer */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -499,7 +499,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
||||
|
||||
/* add tsize option */
|
||||
if(data->set.upload && (data->set.infilesize != -1))
|
||||
snprintf( buf, sizeof(buf), "%" FORMAT_OFF_T, data->set.infilesize );
|
||||
snprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T,
|
||||
data->set.infilesize);
|
||||
else
|
||||
strcpy(buf, "0"); /* the destination is large enough */
|
||||
|
||||
@@ -1040,7 +1041,8 @@ static CURLcode tftp_done(struct connectdata *conn, CURLcode status,
|
||||
return CURLE_ABORTED_BY_CALLBACK;
|
||||
|
||||
/* If we have encountered an error */
|
||||
code = tftp_translate_code(state->error);
|
||||
if(state)
|
||||
code = tftp_translate_code(state->error);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -70,7 +70,7 @@
|
||||
#include "http.h"
|
||||
#include "url.h"
|
||||
#include "getinfo.h"
|
||||
#include "sslgen.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "http_digest.h"
|
||||
#include "curl_ntlm.h"
|
||||
#include "http_negotiate.h"
|
||||
@@ -128,14 +128,24 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
|
||||
return CURLE_ABORTED_BY_CALLBACK;
|
||||
}
|
||||
else if(nread == CURL_READFUNC_PAUSE) {
|
||||
struct SingleRequest *k = &data->req;
|
||||
/* CURL_READFUNC_PAUSE pauses read callbacks that feed socket writes */
|
||||
k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */
|
||||
if(data->req.upload_chunky) {
|
||||
/* Back out the preallocation done above */
|
||||
data->req.upload_fromhere -= (8 + 2);
|
||||
|
||||
if(conn->handler->flags & PROTOPT_NONETWORK) {
|
||||
/* protocols that work without network cannot be paused. This is
|
||||
actually only FILE:// just now, and it can't pause since the transfer
|
||||
isn't done using the "normal" procedure. */
|
||||
failf(data, "Read callback asked for PAUSE when not supported!");
|
||||
return CURLE_READ_ERROR;
|
||||
}
|
||||
else {
|
||||
struct SingleRequest *k = &data->req;
|
||||
/* CURL_READFUNC_PAUSE pauses read callbacks that feed socket writes */
|
||||
k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */
|
||||
if(data->req.upload_chunky) {
|
||||
/* Back out the preallocation done above */
|
||||
data->req.upload_fromhere -= (8 + 2);
|
||||
}
|
||||
*nreadp = 0;
|
||||
}
|
||||
*nreadp = 0;
|
||||
return CURLE_OK; /* nothing was read */
|
||||
}
|
||||
else if((size_t)nread > buffersize) {
|
||||
@@ -636,9 +646,9 @@ static CURLcode readwrite_data(struct SessionHandle *data,
|
||||
always will fit in a size_t */
|
||||
infof(data,
|
||||
"Rewinding stream by : %zu"
|
||||
" bytes on url %s (size = %" FORMAT_OFF_T
|
||||
", maxdownload = %" FORMAT_OFF_T
|
||||
", bytecount = %" FORMAT_OFF_T ", nread = %zd)\n",
|
||||
" bytes on url %s (size = %" CURL_FORMAT_CURL_OFF_T
|
||||
", maxdownload = %" CURL_FORMAT_CURL_OFF_T
|
||||
", bytecount = %" CURL_FORMAT_CURL_OFF_T ", nread = %zd)\n",
|
||||
excess, data->state.path,
|
||||
k->size, k->maxdownload, k->bytecount, nread);
|
||||
read_rewind(conn, excess);
|
||||
@@ -647,9 +657,9 @@ static CURLcode readwrite_data(struct SessionHandle *data,
|
||||
infof(data,
|
||||
"Excess found in a non pipelined read:"
|
||||
" excess = %zu"
|
||||
", size = %" FORMAT_OFF_T
|
||||
", maxdownload = %" FORMAT_OFF_T
|
||||
", bytecount = %" FORMAT_OFF_T "\n",
|
||||
", size = %" CURL_FORMAT_CURL_OFF_T
|
||||
", maxdownload = %" CURL_FORMAT_CURL_OFF_T
|
||||
", bytecount = %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
excess, k->size, k->maxdownload, k->bytecount);
|
||||
}
|
||||
}
|
||||
@@ -1085,13 +1095,14 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
if(0 > Curl_timeleft(data, &k->now, FALSE)) {
|
||||
if(k->size != -1) {
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
|
||||
CURL_FORMAT_CURL_OFF_T " out of %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes received",
|
||||
Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount,
|
||||
k->size);
|
||||
}
|
||||
else {
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
FORMAT_OFF_T " bytes received",
|
||||
CURL_FORMAT_CURL_OFF_T " bytes received",
|
||||
Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount);
|
||||
}
|
||||
return CURLE_OPERATION_TIMEDOUT;
|
||||
@@ -1113,7 +1124,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
(k->bytecount != (k->size + data->state.crlf_conversions)) &&
|
||||
#endif /* CURL_DO_LINEEND_CONV */
|
||||
!data->req.newurl) {
|
||||
failf(data, "transfer closed with %" FORMAT_OFF_T
|
||||
failf(data, "transfer closed with %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes remaining to read",
|
||||
k->size - k->bytecount);
|
||||
return CURLE_PARTIAL_FILE;
|
||||
@@ -1309,11 +1320,10 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
|
||||
Curl_pgrsStartNow(data);
|
||||
|
||||
if(data->set.timeout)
|
||||
Curl_expire(data, data->set.timeout + MULTI_TIMEOUT_INACCURACY_MS);
|
||||
Curl_expire(data, data->set.timeout);
|
||||
|
||||
if(data->set.connecttimeout)
|
||||
Curl_expire(data, data->set.connecttimeout +
|
||||
MULTI_TIMEOUT_INACCURACY_MS);
|
||||
Curl_expire(data, data->set.connecttimeout);
|
||||
|
||||
/* In case the handle is re-used and an authentication method was picked
|
||||
in the session we need to make sure we only use the one(s) we now
|
||||
@@ -1959,8 +1969,7 @@ Curl_setup_transfer(
|
||||
|
||||
/* Set a timeout for the multi interface. Add the inaccuracy margin so
|
||||
that we don't fire slightly too early and get denied to run. */
|
||||
Curl_expire(data, CURL_TIMEOUT_EXPECT_100 +
|
||||
MULTI_TIMEOUT_INACCURACY / 1000);
|
||||
Curl_expire(data, CURL_TIMEOUT_EXPECT_100);
|
||||
}
|
||||
else {
|
||||
if(data->state.expect100header)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user