Compare commits
	
		
			214 Commits
		
	
	
		
			curl-7_21_
			...
			curl-7_21_
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 8da5da9b65 | ||
|   | 42c6b7577f | ||
|   | e5010ec3ff | ||
|   | 5c314c6bb4 | ||
|   | 9016958aa8 | ||
|   | 1614dc0745 | ||
|   | af6dcc92d5 | ||
|   | 57064e4a0d | ||
|   | d9e71809cb | ||
|   | a7cc54a5a8 | ||
|   | c9a82f39e2 | ||
|   | e4bca6a01c | ||
|   | 56e5302b53 | ||
|   | 4cbc6fc6ab | ||
|   | c9f16e67ef | ||
|   | f851f76857 | ||
|   | 0126b4a959 | ||
|   | 49a8fe5142 | ||
|   | 8fc4be9e7b | ||
|   | 70eee054f2 | ||
|   | 0aedccc18a | ||
|   | 85881f9f35 | ||
|   | 84e13f2e07 | ||
|   | 832e827518 | ||
|   | a6fa7fc38e | ||
|   | b122f8be61 | ||
|   | 950fb3efcc | ||
|   | ee015947d4 | ||
|   | a2a2863306 | ||
|   | b688f2c260 | ||
|   | c4dd8df081 | ||
|   | 0f7bea7c3a | ||
|   | d5cc77b744 | ||
|   | 36a22f9074 | ||
|   | 6e0dd48f97 | ||
|   | cb2f300364 | ||
|   | 7530a28878 | ||
|   | e8d73c9c2d | ||
|   | 8a3c0fe56c | ||
|   | f551aa5c16 | ||
|   | 377f88364e | ||
|   | c0b9dd27b5 | ||
|   | 6aff805942 | ||
|   | b772f3a321 | ||
|   | 7559b77727 | ||
|   | 4f170ee8f9 | ||
|   | fba00c9f7b | ||
|   | 10a7d05be3 | ||
|   | 9776f3445d | ||
|   | adeac15d8e | ||
|   | 5d4e5593d5 | ||
|   | c2eb8c932d | ||
|   | a6f14e17b7 | ||
|   | b3740f0e09 | ||
|   | 2a31dde76c | ||
|   | bf749bb2c5 | ||
|   | 65a9fa59dc | ||
|   | 9eea43dce2 | ||
|   | 910d7953aa | ||
|   | 970117ef2d | ||
|   | aa76dec33a | ||
|   | d6bb8dcc23 | ||
|   | 685359d4c3 | ||
|   | a689072f33 | ||
|   | 3d64ed25df | ||
|   | ecfe0b5b18 | ||
|   | 9460896cbe | ||
|   | a87102c792 | ||
|   | 2e7a2027f1 | ||
|   | ae677edf90 | ||
|   | f5d78919af | ||
|   | f3d77f772d | ||
|   | 7dd449d843 | ||
|   | f461c6e61d | ||
|   | 3c9ff41a1f | ||
|   | c8c8816a97 | ||
|   | 5d39dea3b3 | ||
|   | 9f390a356e | ||
|   | 017ee34bba | ||
|   | 340228cc81 | ||
|   | edf282c096 | ||
|   | a947a9ac62 | ||
|   | 9b5343054a | ||
|   | b735717606 | ||
|   | ec33742d1b | ||
|   | 2ea31b0e6f | ||
|   | de70ddb749 | ||
|   | a41c7f9736 | ||
|   | 512b2f7740 | ||
|   | 8bdc48eddb | ||
|   | 328600e02b | ||
|   | e2747ebbc0 | ||
|   | 41ebda02b2 | ||
|   | 30c9799f72 | ||
|   | bed6b89a2f | ||
|   | 3e70c28ce5 | ||
|   | 79cc6c244a | ||
|   | d30ddd9977 | ||
|   | 8b849265d8 | ||
|   | fce7276f54 | ||
|   | 004d84fcc1 | ||
|   | 02f3ff3b0a | ||
|   | 3f6ffcd26d | ||
|   | 3912e7bde3 | ||
|   | 488521427f | ||
|   | e83816bfcf | ||
|   | b578534508 | ||
|   | 5db30a1d8c | ||
|   | 664ff30650 | ||
|   | 873d70a6d8 | ||
|   | 6dfa16c3c4 | ||
|   | 60f0ebbdc9 | ||
|   | b5d170b551 | ||
|   | d4e000906a | ||
|   | bb7ff942d3 | ||
|   | 48a40f0402 | ||
|   | 0c8e6f598a | ||
|   | 2ef7a28a71 | ||
|   | 2a02c07a15 | ||
|   | 212d8c8f65 | ||
|   | b996b202c4 | ||
|   | 32001ac414 | ||
|   | 9c629e5348 | ||
|   | f0612f166a | ||
|   | e34131db78 | ||
|   | 335dfa793c | ||
|   | 574aecee20 | ||
|   | 51075a6777 | ||
|   | 4508ea103f | ||
|   | 558f997e99 | ||
|   | fda0985bfd | ||
|   | 93ec4555ff | ||
|   | 61877b569f | ||
|   | dc15a88076 | ||
|   | adae5926dd | ||
|   | ade337d79e | ||
|   | 365db94e0a | ||
|   | d4ebf3c6b0 | ||
|   | f78fa6a57d | ||
|   | 038a631274 | ||
|   | 7d94af497d | ||
|   | a490961b10 | ||
|   | 821301de15 | ||
|   | 3440f4d374 | ||
|   | f83c36934f | ||
|   | c4bc1d473f | ||
|   | 5b7e1f9efe | ||
|   | c33aee1667 | ||
|   | 3b1b26578f | ||
|   | 2cbe885c1a | ||
|   | 4a42e5cdaa | ||
|   | 53ef3493bf | ||
|   | cbd98b2c28 | ||
|   | 4685db9462 | ||
|   | 45de057920 | ||
|   | aa87f0ab15 | ||
|   | 6a6981503e | ||
|   | 889d1e973f | ||
|   | 1b758b01c1 | ||
|   | 7ddcc8fea4 | ||
|   | 068d656c6d | ||
|   | 92f722017c | ||
|   | 9869668884 | ||
|   | b903186fa0 | ||
|   | 592eda8e3f | ||
|   | 6d013b0aab | ||
|   | bcc29cda8e | ||
|   | 4235457129 | ||
|   | e9542ccab6 | ||
|   | 7de2f9271c | ||
|   | 24d84da073 | ||
|   | ca015f1a45 | ||
|   | 722f286f80 | ||
|   | f20b4606de | ||
|   | c985a8df51 | ||
|   | a0fad3017e | ||
|   | 2a05025510 | ||
|   | d8373cb992 | ||
|   | 17df5d8caa | ||
|   | 210278d9a1 | ||
|   | 5942362847 | ||
|   | 7d86e467fa | ||
|   | 7609b32e7c | ||
|   | 1702a2c08d | ||
|   | 9230be0797 | ||
|   | 7872c8d5a2 | ||
|   | 37b9fe104a | ||
|   | 3242abd87a | ||
|   | 1b6df743f6 | ||
|   | c2c8948190 | ||
|   | c6a0abdd97 | ||
|   | 9039d19f01 | ||
|   | c828646f60 | ||
|   | eb65a49bef | ||
|   | b2140a09f8 | ||
|   | 519bec7c91 | ||
|   | 24e5a40156 | ||
|   | 2d1b6242f2 | ||
|   | a5db4a46ac | ||
|   | 65aadf2118 | ||
|   | 24667466f0 | ||
|   | 5aae3c13e2 | ||
|   | 8e4fb01e64 | ||
|   | ebb37eac8b | ||
|   | 9d191a6a40 | ||
|   | be973b6f91 | ||
|   | 2db6f7e703 | ||
|   | 0790b27910 | ||
|   | e80b957789 | ||
|   | 213939c8ba | ||
|   | 82ecc85d9e | ||
|   | 84f809e7a8 | ||
|   | cae351e9f5 | ||
|   | 909acfbbba | 
| @@ -62,8 +62,7 @@ CURL_HEADERS := \ | |||||||
| 	mprintf.h \ | 	mprintf.h \ | ||||||
| 	multi.h \ | 	multi.h \ | ||||||
| 	stdcheaders.h \ | 	stdcheaders.h \ | ||||||
| 	typecheck-gcc.h \ | 	typecheck-gcc.h | ||||||
| 	types.h |  | ||||||
|  |  | ||||||
| LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES)) | LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES)) | ||||||
| LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ | ||||||
| @@ -73,6 +72,7 @@ LOCAL_COPY_HEADERS_TO := libcurl/curl | |||||||
| LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS)) | LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS)) | ||||||
|  |  | ||||||
| LOCAL_MODULE:= libcurl | LOCAL_MODULE:= libcurl | ||||||
|  | LOCAL_MODULE_TAGS := optional | ||||||
|  |  | ||||||
| # Copy the licence to a place where Android will find it. | # Copy the licence to a place where Android will find it. | ||||||
| # Actually, this doesn't quite work because the build system searches | # Actually, this doesn't quite work because the build system searches | ||||||
| @@ -93,6 +93,7 @@ include $(LOCAL_PATH)/src/Makefile.inc | |||||||
| LOCAL_SRC_FILES := $(addprefix src/,$(CURL_CFILES)) | LOCAL_SRC_FILES := $(addprefix src/,$(CURL_CFILES)) | ||||||
|  |  | ||||||
| LOCAL_MODULE := curl | LOCAL_MODULE := curl | ||||||
|  | LOCAL_MODULE_TAGS := optional | ||||||
| LOCAL_STATIC_LIBRARIES := libcurl | LOCAL_STATIC_LIBRARIES := libcurl | ||||||
| LOCAL_SYSTEM_SHARED_LIBRARIES := libc | LOCAL_SYSTEM_SHARED_LIBRARIES := libc | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ include(Utilities) | |||||||
|  |  | ||||||
| project( CURL C ) | project( CURL C ) | ||||||
|  |  | ||||||
|  |  | ||||||
| file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) | file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) | ||||||
| string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)" | string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)" | ||||||
|   LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS}) |   LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS}) | ||||||
| @@ -191,12 +190,12 @@ if(WIN32) | |||||||
| endif(WIN32) | endif(WIN32) | ||||||
|  |  | ||||||
| # This macro checks if the symbol exists in the library and if it | # This macro checks if the symbol exists in the library and if it | ||||||
| # does, it appends library to the list. | # does, it prepends library to the list. | ||||||
| macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) | macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) | ||||||
|   check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "" |   check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}" | ||||||
|     ${VARIABLE}) |     ${VARIABLE}) | ||||||
|   if(${VARIABLE}) |   if(${VARIABLE}) | ||||||
|     set(CURL_LIBS ${CURL_LIBS} ${LIBRARY}) |     set(CURL_LIBS ${LIBRARY} ${CURL_LIBS}) | ||||||
|   endif(${VARIABLE}) |   endif(${VARIABLE}) | ||||||
| endmacro(CHECK_LIBRARY_EXISTS_CONCAT) | endmacro(CHECK_LIBRARY_EXISTS_CONCAT) | ||||||
|  |  | ||||||
| @@ -224,25 +223,6 @@ check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32) | |||||||
| #  CHECK_LIBRARY_EXISTS_CONCAT("z"      inflateEnd   HAVE_LIBZ) | #  CHECK_LIBRARY_EXISTS_CONCAT("z"      inflateEnd   HAVE_LIBZ) | ||||||
| # ENDIF(NOT CURL_SPECIAL_LIBZ) | # ENDIF(NOT CURL_SPECIAL_LIBZ) | ||||||
|  |  | ||||||
| option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) |  | ||||||
| mark_as_advanced(CMAKE_USE_OPENSSL) |  | ||||||
| if(CMAKE_USE_OPENSSL) |  | ||||||
|   if(WIN32) |  | ||||||
|     find_package(OpenSSL) |  | ||||||
|     if(OPENSSL_FOUND) |  | ||||||
|       set(USE_SSLEAY TRUE) |  | ||||||
|       set(USE_OPENSSL TRUE) |  | ||||||
|       list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} ) |  | ||||||
|     else() |  | ||||||
|       set(CMAKE_USE_OPENSSL FALSE) |  | ||||||
|       message(STATUS "OpenSSL NOT Found, disabling CMAKE_USE_OPENSSL") |  | ||||||
|     endif() |  | ||||||
|   else(WIN32) |  | ||||||
|     check_library_exists_concat("crypto" CRYPTO_lock  HAVE_LIBCRYPTO) |  | ||||||
|     check_library_exists_concat("ssl"    SSL_connect  HAVE_LIBSSL) |  | ||||||
|   endif(WIN32) |  | ||||||
| endif(CMAKE_USE_OPENSSL) |  | ||||||
|  |  | ||||||
| # Check for idn | # Check for idn | ||||||
| check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN) | check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN) | ||||||
|  |  | ||||||
| @@ -271,6 +251,25 @@ if(CURL_ZLIB)  # AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE | |||||||
|   endif() |   endif() | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
|  | option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) | ||||||
|  | mark_as_advanced(CMAKE_USE_OPENSSL) | ||||||
|  | if(CMAKE_USE_OPENSSL) | ||||||
|  |   if(WIN32) | ||||||
|  |     find_package(OpenSSL) | ||||||
|  |     if(OPENSSL_FOUND) | ||||||
|  |       set(USE_SSLEAY TRUE) | ||||||
|  |       set(USE_OPENSSL TRUE) | ||||||
|  |       list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} ) | ||||||
|  |     else() | ||||||
|  |       set(CMAKE_USE_OPENSSL FALSE) | ||||||
|  |       message(STATUS "OpenSSL NOT Found, disabling CMAKE_USE_OPENSSL") | ||||||
|  |     endif() | ||||||
|  |   else(WIN32) | ||||||
|  |     check_library_exists_concat("crypto" CRYPTO_lock  HAVE_LIBCRYPTO) | ||||||
|  |     check_library_exists_concat("ssl"    SSL_connect  HAVE_LIBSSL) | ||||||
|  |   endif(WIN32) | ||||||
|  | endif(CMAKE_USE_OPENSSL) | ||||||
|  |  | ||||||
| # If we have features.h, then do the _BSD_SOURCE magic | # If we have features.h, then do the _BSD_SOURCE magic | ||||||
| check_include_file("features.h"       HAVE_FEATURES_H) | check_include_file("features.h"       HAVE_FEATURES_H) | ||||||
|  |  | ||||||
| @@ -852,3 +851,14 @@ endif() | |||||||
| if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE) | if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE) | ||||||
|   set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") |   set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
|  | # Installation. | ||||||
|  | # First, install generated curlbuild.h | ||||||
|  | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/curl/curlbuild.h" | ||||||
|  |     DESTINATION include/curl ) | ||||||
|  | # Next, install other headers excluding curlbuild.h | ||||||
|  | install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl" | ||||||
|  |     DESTINATION include | ||||||
|  |     FILES_MATCHING PATTERN "*.h" | ||||||
|  |     PATTERN "curlbuild.h" EXCLUDE) | ||||||
|  |   | ||||||
| @@ -40,8 +40,8 @@ EXTRA_DIST = CHANGES COPYING maketgz Makefile.dist curl-config.in	\ | |||||||
|  |  | ||||||
| bin_SCRIPTS = curl-config | bin_SCRIPTS = curl-config | ||||||
|  |  | ||||||
| SUBDIRS = lib src | SUBDIRS = lib src include | ||||||
| DIST_SUBDIRS = $(SUBDIRS) tests include packages docs | DIST_SUBDIRS = $(SUBDIRS) tests packages docs | ||||||
|  |  | ||||||
| pkgconfigdir = $(libdir)/pkgconfig | pkgconfigdir = $(libdir)/pkgconfig | ||||||
| pkgconfig_DATA = libcurl.pc | pkgconfig_DATA = libcurl.pc | ||||||
| @@ -155,3 +155,7 @@ ca-bundle: lib/mk-ca-bundle.pl | |||||||
| ca-firefox: lib/firefox-db2pem.sh | ca-firefox: lib/firefox-db2pem.sh | ||||||
| 	@echo "generate a fresh ca-bundle.crt" | 	@echo "generate a fresh ca-bundle.crt" | ||||||
| 	./lib/firefox-db2pem.sh lib/ca-bundle.crt | 	./lib/firefox-db2pem.sh lib/ca-bundle.crt | ||||||
|  |  | ||||||
|  | checksrc: | ||||||
|  | 	cd lib && $(MAKE) checksrc | ||||||
|  | 	cd src && $(MAKE) checksrc | ||||||
|   | |||||||
| @@ -70,30 +70,18 @@ mingw32: | |||||||
| 	$(MAKE) -C lib -f Makefile.m32 | 	$(MAKE) -C lib -f Makefile.m32 | ||||||
| 	$(MAKE) -C src -f Makefile.m32 | 	$(MAKE) -C src -f Makefile.m32 | ||||||
|  |  | ||||||
| mingw32-zlib: |  | ||||||
| 	$(MAKE) -C lib -f Makefile.m32 ZLIB=1 |  | ||||||
| 	$(MAKE) -C src -f Makefile.m32 ZLIB=1 |  | ||||||
|  |  | ||||||
| mingw32-ssl-zlib: |  | ||||||
| 	$(MAKE) -C lib -f Makefile.m32 SSL=1 ZLIB=1 |  | ||||||
| 	$(MAKE) -C src -f Makefile.m32 SSL=1 ZLIB=1 |  | ||||||
|  |  | ||||||
| mingw32-ssh2-ssl-zlib: |  | ||||||
| 	$(MAKE) -C lib -f Makefile.m32 SSH2=1 SSL=1 ZLIB=1 |  | ||||||
| 	$(MAKE) -C src -f Makefile.m32 SSH2=1 SSL=1 ZLIB=1 |  | ||||||
|  |  | ||||||
| mingw32-ssh2-ssl-sspi-zlib: |  | ||||||
| 	$(MAKE) -C lib -f Makefile.m32 SSH2=1 SSL=1 SSPI=1 ZLIB=1 |  | ||||||
| 	$(MAKE) -C src -f Makefile.m32 SSH2=1 SSL=1 SSPI=1 ZLIB=1 |  | ||||||
|  |  | ||||||
| mingw32-rtmp-ssh2-ssl-sspi-zlib: |  | ||||||
| 	$(MAKE) -C lib -f Makefile.m32 RTMP=1 SSH2=1 SSL=1 SSPI=1 ZLIB=1 |  | ||||||
| 	$(MAKE) -C src -f Makefile.m32 RTMP=1 SSH2=1 SSL=1 SSPI=1 ZLIB=1 |  | ||||||
|  |  | ||||||
| mingw32-clean: | mingw32-clean: | ||||||
| 	$(MAKE) -C lib -f Makefile.m32 clean | 	$(MAKE) -C lib -f Makefile.m32 clean | ||||||
| 	$(MAKE) -C src -f Makefile.m32 clean | 	$(MAKE) -C src -f Makefile.m32 clean | ||||||
|  |  | ||||||
|  | mingw32-vclean mingw32-distclean: | ||||||
|  | 	$(MAKE) -C lib -f Makefile.m32 vclean | ||||||
|  | 	$(MAKE) -C src -f Makefile.m32 vclean | ||||||
|  |  | ||||||
|  | mingw32%: | ||||||
|  | 	$(MAKE) -C lib -f Makefile.m32 CFG=$@ | ||||||
|  | 	$(MAKE) -C src -f Makefile.m32 CFG=$@ | ||||||
|  |  | ||||||
| vc-clean: $(VC) | vc-clean: $(VC) | ||||||
| 	cd lib | 	cd lib | ||||||
| 	nmake -f Makefile.$(VC) clean | 	nmake -f Makefile.$(VC) clean | ||||||
|   | |||||||
| @@ -1,69 +1,38 @@ | |||||||
| Curl and libcurl 7.21.5 | Curl and libcurl 7.21.7 | ||||||
|  |  | ||||||
|  Public curl releases:         121 |  Public curl releases:         123 | ||||||
|  Command line options:         143 |  Command line options:         144 | ||||||
|  curl_easy_setopt() options:   185 |  curl_easy_setopt() options:   186 | ||||||
|  Public functions in libcurl:  58 |  Public functions in libcurl:  58 | ||||||
|  Known libcurl bindings:       39 |  Known libcurl bindings:       39 | ||||||
|  Contributors:                 854 |  Contributors:                 868 | ||||||
|  |  | ||||||
| This release includes the following changes: | This release includes the following changes: | ||||||
|  |  | ||||||
|  o SOCKOPTFUNCTION: callback can say already-connected |  o recognize the [protocol]:// prefix in proxy hosts where the protocol is one | ||||||
|  o Added --netrc-file |    of socks4, socks4a, socks5 or socks5h. | ||||||
|  o Added (new) support for cyassl |  o Added CURLOPT_CLOSESOCKETFUNCTION and CURLOPT_CLOSESOCKETDATA | ||||||
|  o TSL-SRP: enabled with OpenSSL |  | ||||||
|  o Added CURLE_NOT_BUILT_IN and CURLE_UNKNOWN_OPTION |  | ||||||
|  |  | ||||||
| This release includes the following bugfixes: | This release includes the following bugfixes: | ||||||
|  |  | ||||||
|  o nss: avoid memory leak on SSL connection failure |  o SECURITY ADVISORY: inappropriate GSSAPI delegation. Full details at | ||||||
|  o nss: do not ignore failure of SSL handshake |    http://curl.haxx.se/docs/adv_20110623.html | ||||||
|  o multi: better failed connect handling when using FTP, SMTP, POP3 and IMAP |  o NTLM: work with unicode | ||||||
|  o runtests.pl: fix pid number concatenation that prevented it from killing |  o fix connect with SOCKS proxy when using the multi interface | ||||||
|    the correct process at times |  o anyauthput.c: stdint.h must not be included unconditionally | ||||||
|  o PolarSSL: Return 0 on receiving TLS CLOSE_NOTIFY alert |  o CMake: improved build | ||||||
|  o curl_easy_setopt.3: Removed wrong reference to CURLOPT_USERPASSWORD |  o SCP/SFTP enable non-blocking earlier | ||||||
|  o multi: close connection on timeout |  o GnuTLS handshake: fix timeout | ||||||
|  o IMAP in multi mode does SSL connections non-blocking |  o cyassl: build without filesystem | ||||||
|  o honours the --disable-ldaps configure option |  o HTTPS over HTTP proxy using the multi interface | ||||||
|  o Force setopt constants written by --libcurl to be long |  o speedcheck: invalid timeout event on a reused handle | ||||||
|  o ssh_connect: treat libssh2 return code better |  o Force connection close for HTTP 200 OK when time condition matched | ||||||
|  o SFTP upload could stall the state machine when the multi_socket API was |  o curl_formget: fix FILE * leak | ||||||
|    used |  o configure: improved OpenSSL detection | ||||||
|  o SFTP and SCP could leak memory when used with the multi interface and  |  o Android build: support gingerbread | ||||||
|    the connection was closed |  o CURLFORM_STREAM: acknowledge CURLFORM_FILENAME | ||||||
|  o Added missing file to repair the MSVC makefiles |  o windows build: use correct MS CRT | ||||||
|  o Fixed detection of recvfrom arguments on Android/bionic |  o pop3: remove extra space in LIST command | ||||||
|  o GSS: handle reuse fix |  | ||||||
|  o transfer: avoid insane conversion of time_t |  | ||||||
|  o nss: do not ignore value of CURLOPT_SSL_VERIFYPEER in certain cases |  | ||||||
|  o SMTP-multi: non-blocking connect |  | ||||||
|  o SFTP-multi: set cselect for sftp and scp to fix "stall" risk |  | ||||||
|  o configure: removed wrongly claimed default paths |  | ||||||
|  o pop3: fixed torture tests to succeed |  | ||||||
|  o symbols-in-versions: many corrections |  | ||||||
|  o if a HTTP request gets retried because the connection was dead, rewind if |  | ||||||
|    any data was sent as part of it |  | ||||||
|  o only probe for working ipv6 once and then re-use that info for further |  | ||||||
|    requests |  | ||||||
|  o requests that are asked to bound to a local interface/port will no longer |  | ||||||
|    wrongly re-use connections that aren't |  | ||||||
|  o libcurl.m4: Add missing quotes in AC_LINK_IFELSE |  | ||||||
|  o progress output: don't print the last update on a separate line |  | ||||||
|  o POP3: the command to send is STLS, not STARTTLS |  | ||||||
|  o POP3: PASS command was not sent after upgrade to TLS |  | ||||||
|  o configure: fix libtool warning |  | ||||||
|  o nss: allow to use multiple client certificates for a single host |  | ||||||
|  o HTTP pipelining: Fix handling of zero-length responses |  | ||||||
|  o Don't list NTLM in curl-config when HTTP is disabled |  | ||||||
|  o curl_easy_setopt.3: CURLOPT_RESOLVE typo version |  | ||||||
|  o OpenSSL: build fine with no-sslv2 versions |  | ||||||
|  o checkconnection: don't call with NULL pointer with RTSP and multi interface |  | ||||||
|  o Borland makefile updates |  | ||||||
|  o configure: libssh2 link fix without pkg-config |  | ||||||
|  o certinfo crash |  | ||||||
|  o CCC crash |  | ||||||
|  |  | ||||||
| This release includes the following known bugs: | This release includes the following known bugs: | ||||||
|  |  | ||||||
| @@ -72,10 +41,9 @@ This release includes the following known bugs: | |||||||
| This release would not have looked like this without help, code, reports and | This release would not have looked like this without help, code, reports and | ||||||
| advice from friends like these: | advice from friends like these: | ||||||
|  |  | ||||||
|  Mike Crowe, Kamil Dudka, Julien Chaffraix, Hoi-Ho Chan, Ben Noordhuis, |  Dan Fandrich, Guenter Knauf, Vsevolod Novikov, Zmey Petroff, | ||||||
|  Dan Fandrich, Henry Ludemann, Karl M, Manuel Massing, Marcus Sundberg, |  Dagobert Michelsen, Jeff Pohlmeyer, Dmitri Shubin, Matteo Rocco, | ||||||
|  Stefan Krause, Todd A Ouska, Saqib Ali, Andre Guibert de Bruet, |  Aaron Orenstein, Yang Tse, Kamil Dudka, Amr Shahin, Josue Andrade Gomes, | ||||||
|  Tor Arntsen, Vincent Torri, Dave Reisner, Chris Smowton, Tinus van den Berg, |  Ori Avtalion, Richard Silverman, Julien Chaffraix | ||||||
|  Hongli Lai, Gisle Vanem, Andrei Benea, Mehmet Bozkurt |  | ||||||
|  |  | ||||||
|         Thanks! (and sorry if I forgot to mention someone) |         Thanks! (and sorry if I forgot to mention someone) | ||||||
|   | |||||||
							
								
								
									
										23
									
								
								acinclude.m4
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								acinclude.m4
									
									
									
									
									
								
							| @@ -1663,7 +1663,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [ | |||||||
|           for recvfrom_arg2 in 'char *' 'void *'; do |           for recvfrom_arg2 in 'char *' 'void *'; do | ||||||
|             for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do |             for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do | ||||||
|               for recvfrom_arg4 in 'int' 'unsigned int'; do |               for recvfrom_arg4 in 'int' 'unsigned int'; do | ||||||
|                 for recvfrom_arg5 in 'const struct sockaddr *' 'struct sockaddr *' 'void *'; do |                 for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do | ||||||
|                   for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do |                   for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do | ||||||
|                     if test "$curl_cv_func_recvfrom_args" = "unknown"; then |                     if test "$curl_cv_func_recvfrom_args" = "unknown"; then | ||||||
|                       AC_COMPILE_IFELSE([ |                       AC_COMPILE_IFELSE([ | ||||||
| @@ -1731,7 +1731,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [ | |||||||
|       shift |       shift | ||||||
|       # |       # | ||||||
|       recvfrom_ptrt_arg2=$[2] |       recvfrom_ptrt_arg2=$[2] | ||||||
|       recvfrom_ptrt_arg5=$[5] |       recvfrom_qual_ptrt_arg5=$[5] | ||||||
|       recvfrom_ptrt_arg6=$[6] |       recvfrom_ptrt_arg6=$[6] | ||||||
|       # |       # | ||||||
|       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1], |       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1], | ||||||
| @@ -1753,12 +1753,25 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [ | |||||||
|           ;; |           ;; | ||||||
|       esac |       esac | ||||||
|       # |       # | ||||||
|  |       case "$recvfrom_qual_ptrt_arg5" in | ||||||
|  |         const*) | ||||||
|  |           recvfrom_qual_arg5=const | ||||||
|  |           recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'` | ||||||
|  |         ;; | ||||||
|  |         *) | ||||||
|  |           recvfrom_qual_arg5= | ||||||
|  |           recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5 | ||||||
|  |         ;; | ||||||
|  |       esac | ||||||
|  |       # | ||||||
|       recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'` |       recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'` | ||||||
|       recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'` |       recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'` | ||||||
|       recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'` |       recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'` | ||||||
|       # |       # | ||||||
|       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2, |       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2, | ||||||
|         [Define to the type pointed by arg 2 for recvfrom.]) |         [Define to the type pointed by arg 2 for recvfrom.]) | ||||||
|  |       AC_DEFINE_UNQUOTED(RECVFROM_QUAL_ARG5, $recvfrom_qual_arg5, | ||||||
|  |         [Define to the type qualifier pointed by arg 5 for recvfrom.]) | ||||||
|       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5, |       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5, | ||||||
|         [Define to the type pointed by arg 5 for recvfrom.]) |         [Define to the type pointed by arg 5 for recvfrom.]) | ||||||
|       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6, |       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6, | ||||||
| @@ -2843,7 +2856,7 @@ AC_DEFUN([DO_CURL_OFF_T_CHECK], [ | |||||||
|     tmp_includes="" |     tmp_includes="" | ||||||
|     tmp_source="" |     tmp_source="" | ||||||
|     tmp_fmt="" |     tmp_fmt="" | ||||||
|     case AS_TR_SH([$1]) in |     case XC_SH_TR_SH([$1]) in | ||||||
|       int64_t) |       int64_t) | ||||||
|         tmp_includes="$curl_includes_inttypes" |         tmp_includes="$curl_includes_inttypes" | ||||||
|         tmp_source="char f@<:@@:>@ = PRId64;" |         tmp_source="char f@<:@@:>@ = PRId64;" | ||||||
| @@ -2901,7 +2914,7 @@ AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [ | |||||||
|   curl_suffix_curl_off_t="unknown" |   curl_suffix_curl_off_t="unknown" | ||||||
|   curl_suffix_curl_off_tu="unknown" |   curl_suffix_curl_off_tu="unknown" | ||||||
|   # |   # | ||||||
|   case AS_TR_SH([$1]) in |   case XC_SH_TR_SH([$1]) in | ||||||
|     long_long | __longlong | __longlong_t) |     long_long | __longlong | __longlong_t) | ||||||
|       tst_suffixes="LL::" |       tst_suffixes="LL::" | ||||||
|       ;; |       ;; | ||||||
| @@ -3073,7 +3086,7 @@ AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [ | |||||||
|     curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'` |     curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'` | ||||||
|   else |   else | ||||||
|     x_pull_headers="no" |     x_pull_headers="no" | ||||||
|     case AS_TR_SH([$curl_typeof_curl_off_t]) in |     case XC_SH_TR_SH([$curl_typeof_curl_off_t]) in | ||||||
|       long_long | __longlong | __longlong_t) |       long_long | __longlong | __longlong_t) | ||||||
|         curl_format_curl_off_t="lld" |         curl_format_curl_off_t="lld" | ||||||
|         curl_format_curl_off_tu="llu" |         curl_format_curl_off_tu="llu" | ||||||
|   | |||||||
| @@ -411,7 +411,7 @@ else | |||||||
| fi | fi | ||||||
|  |  | ||||||
| #-------------------------------------------------------------------------- | #-------------------------------------------------------------------------- | ||||||
| # Finished succesfully. | # Finished successfully. | ||||||
| # | # | ||||||
|  |  | ||||||
| echo "buildconf: OK" | echo "buildconf: OK" | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								configure.ac
									
									
									
									
									
								
							| @@ -305,6 +305,24 @@ AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes) | |||||||
| CURL_CHECK_CURLDEBUG | CURL_CHECK_CURLDEBUG | ||||||
| AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes) | AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes) | ||||||
|  |  | ||||||
|  | supports_unittests=yes | ||||||
|  | # cross-compilation of unit tests static library/programs fails when | ||||||
|  | # libcurl shared library is built. This might be due to a libtool or | ||||||
|  | # automake issue. In this case we disable unit tests. | ||||||
|  | if test "x$cross_compiling" != "xno" && | ||||||
|  |    test "x$enable_shared" != "xno"; then | ||||||
|  |   supports_unittests=no | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | dnl Build unit tests when option --enable-debug is given. | ||||||
|  | if test "x$want_debug" = "xyes" && | ||||||
|  |    test "x$supports_unittests" = "xyes"; then | ||||||
|  |   want_unittests=yes | ||||||
|  | else | ||||||
|  |   want_unittests=no | ||||||
|  | fi | ||||||
|  | AM_CONDITIONAL(BUILD_UNITTESTS, test x$want_unittests = xyes) | ||||||
|  |  | ||||||
| dnl ********************************************************************** | dnl ********************************************************************** | ||||||
| dnl Compilation based checks should not be done before this point. | dnl Compilation based checks should not be done before this point. | ||||||
| dnl ********************************************************************** | dnl ********************************************************************** | ||||||
| @@ -1513,6 +1531,7 @@ if test X"$OPT_SSL" != Xno; then | |||||||
|        export LD_LIBRARY_PATH |        export LD_LIBRARY_PATH | ||||||
|        AC_MSG_NOTICE([Added $LIB_OPENSSL to LD_LIBRARY_PATH]) |        AC_MSG_NOTICE([Added $LIB_OPENSSL to LD_LIBRARY_PATH]) | ||||||
|     fi |     fi | ||||||
|  |     CURL_CHECK_OPENSSL_API | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
| fi | fi | ||||||
| @@ -1624,8 +1643,12 @@ if test X"$OPENSSL_ENABLED" = X"1"; then | |||||||
|                  [read randomness from FILE (default=/dev/urandom)]), |                  [read randomness from FILE (default=/dev/urandom)]), | ||||||
|       [ RANDOM_FILE="$withval" ], |       [ RANDOM_FILE="$withval" ], | ||||||
|       [ |       [ | ||||||
|  |           if test x$cross_compiling != xyes; then | ||||||
|             dnl Check for random device |             dnl Check for random device | ||||||
|             AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] ) |             AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] ) | ||||||
|  |           else | ||||||
|  |             AC_MSG_WARN([skipped the /dev/urandom detection when cross-compiling]) | ||||||
|  |           fi | ||||||
|       ] |       ] | ||||||
|   ) |   ) | ||||||
|   if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then |   if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then | ||||||
| @@ -2517,6 +2540,7 @@ CURL_CHECK_FUNC_FREEIFADDRS | |||||||
| CURL_CHECK_FUNC_FSETXATTR | CURL_CHECK_FUNC_FSETXATTR | ||||||
| CURL_CHECK_FUNC_FTRUNCATE | CURL_CHECK_FUNC_FTRUNCATE | ||||||
| CURL_CHECK_FUNC_GETADDRINFO | CURL_CHECK_FUNC_GETADDRINFO | ||||||
|  | CURL_CHECK_FUNC_GAI_STRERROR | ||||||
| CURL_CHECK_FUNC_GETHOSTBYADDR | CURL_CHECK_FUNC_GETHOSTBYADDR | ||||||
| CURL_CHECK_FUNC_GETHOSTBYADDR_R | CURL_CHECK_FUNC_GETHOSTBYADDR_R | ||||||
| CURL_CHECK_FUNC_GETHOSTBYNAME | CURL_CHECK_FUNC_GETHOSTBYNAME | ||||||
| @@ -2593,7 +2617,7 @@ AC_CHECK_FUNCS([fork \ | |||||||
|     ],[ |     ],[ | ||||||
|       AC_MSG_RESULT([yes]) |       AC_MSG_RESULT([yes]) | ||||||
|       eval "ac_cv_func_$func=yes" |       eval "ac_cv_func_$func=yes" | ||||||
|       AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$func]), [1], |       AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1], | ||||||
|         [Define to 1 if you have the $func function.]) |         [Define to 1 if you have the $func function.]) | ||||||
|     ],[ |     ],[ | ||||||
|       AC_MSG_RESULT([but still no]) |       AC_MSG_RESULT([but still no]) | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| #                            | (__| |_| |  _ <| |___ | #                            | (__| |_| |  _ <| |___ | ||||||
| #                             \___|\___/|_| \_\_____| | #                             \___|\___/|_| \_\_____| | ||||||
| # | # | ||||||
| # Copyright (C) 2001 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. | # Copyright (C) 2001 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
| # | # | ||||||
| # This software is licensed as described in the file COPYING, which | # This software is licensed as described in the file COPYING, which | ||||||
| # you should have received as part of this distribution. The terms | # you should have received as part of this distribution. The terms | ||||||
| @@ -94,7 +94,7 @@ while test $# -gt 0; do | |||||||
| 	;; | 	;; | ||||||
|  |  | ||||||
|     --version) |     --version) | ||||||
| 	echo libcurl @VERSION@ | 	echo libcurl @CURLVERSION@ | ||||||
| 	exit 0 | 	exit 0 | ||||||
| 	;; | 	;; | ||||||
|  |  | ||||||
| @@ -113,7 +113,7 @@ while test $# -gt 0; do | |||||||
| 	  # silent success | 	  # silent success | ||||||
| 	  exit 0 | 	  exit 0 | ||||||
| 	else | 	else | ||||||
| 	  echo "requested version $checkfor is newer than existing @VERSION@" | 	  echo "requested version $checkfor is newer than existing @CURLVERSION@" | ||||||
| 	  exit 1 | 	  exit 1 | ||||||
| 	fi | 	fi | ||||||
| 	;; | 	;; | ||||||
|   | |||||||
							
								
								
									
										29
									
								
								docs/FAQ
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								docs/FAQ
									
									
									
									
									
								
							| @@ -36,7 +36,7 @@ FAQ | |||||||
|   3.2 How do I tell curl to resume a transfer? |   3.2 How do I tell curl to resume a transfer? | ||||||
|   3.3 Why doesn't my posting using -F work? |   3.3 Why doesn't my posting using -F work? | ||||||
|   3.4 How do I tell curl to run custom FTP commands? |   3.4 How do I tell curl to run custom FTP commands? | ||||||
|   3.5 How can I disable the Pragma: nocache header? |   3.5 How can I disable the Accept: */* header? | ||||||
|   3.6 Does curl support ASP, XML, XHTML or HTML version Y? |   3.6 Does curl support ASP, XML, XHTML or HTML version Y? | ||||||
|   3.7 Can I use curl to delete/rename a file through FTP? |   3.7 Can I use curl to delete/rename a file through FTP? | ||||||
|   3.8 How do I tell curl to follow HTTP redirects? |   3.8 How do I tell curl to follow HTTP redirects? | ||||||
| @@ -491,7 +491,6 @@ FAQ | |||||||
|   3.2 How do I tell curl to resume a transfer? |   3.2 How do I tell curl to resume a transfer? | ||||||
|  |  | ||||||
|   Curl supports resumed transfers both ways on both FTP and HTTP. |   Curl supports resumed transfers both ways on both FTP and HTTP. | ||||||
|  |  | ||||||
|   Try the -C option. |   Try the -C option. | ||||||
|  |  | ||||||
|   3.3 Why doesn't my posting using -F work? |   3.3 Why doesn't my posting using -F work? | ||||||
| @@ -517,11 +516,11 @@ FAQ | |||||||
|   FTP commands without transferring anything. Therefore you must always specify |   FTP commands without transferring anything. Therefore you must always specify | ||||||
|   a URL to transfer to/from even when doing custom FTP commands. |   a URL to transfer to/from even when doing custom FTP commands. | ||||||
|  |  | ||||||
|   3.5 How can I disable the Pragma: nocache header? |   3.5 How can I disable the Accept: */* header? | ||||||
|  |  | ||||||
|   You can change all internally generated headers by adding a replacement with |   You can change all internally generated headers by adding a replacement with | ||||||
|   the -H/--header option. By adding a header with empty contents you safely |   the -H/--header option. By adding a header with empty contents you safely | ||||||
|   disable that one. Use -H "Pragma:" to disable that specific header. |   disable that one. Use -H "Accept:" to disable that specific header. | ||||||
|  |  | ||||||
|   3.6 Does curl support ASP, XML, XHTML or HTML version Y? |   3.6 Does curl support ASP, XML, XHTML or HTML version Y? | ||||||
|  |  | ||||||
| @@ -565,6 +564,12 @@ FAQ | |||||||
|   install and use them, in the libcurl section of the curl web site: |   install and use them, in the libcurl section of the curl web site: | ||||||
|   http://curl.haxx.se/libcurl/ |   http://curl.haxx.se/libcurl/ | ||||||
|  |  | ||||||
|  |   All the various bindings to libcurl are made by other projects and people, | ||||||
|  |   outside of the cURL project. The cURL project itself only produces libcurl | ||||||
|  |   with its plain C API. If you don't find anywhere else to ask you can ask | ||||||
|  |   about bindings on the curl-library list too, but be prepared that people on | ||||||
|  |   that list may not know anything about bindings. | ||||||
|  |  | ||||||
|   In October 2009, there were interfaces available for the following |   In October 2009, there were interfaces available for the following | ||||||
|   languages: Ada95, Basic, C, C++, Ch, Cocoa, D, Dylan, Eiffel, Euphoria, |   languages: Ada95, Basic, C, C++, Ch, Cocoa, D, Dylan, Eiffel, Euphoria, | ||||||
|   Ferite, Gambas, glib/GTK+, Haskell, ILE/RPG, Java, Lisp, Lua, Mono, .NET, |   Ferite, Gambas, glib/GTK+, Haskell, ILE/RPG, Java, Lisp, Lua, Mono, .NET, | ||||||
| @@ -1152,6 +1157,11 @@ FAQ | |||||||
|   libcurl will reuse connections for all transfers that are made using the |   libcurl will reuse connections for all transfers that are made using the | ||||||
|   same libcurl handle. |   same libcurl handle. | ||||||
|  |  | ||||||
|  |   When you use the easy interface, the connection cache is kept within the | ||||||
|  |   easy handle. If you instead use the multi interface, the connection cache | ||||||
|  |   will be kept within the multi handle and will be shared among all the easy | ||||||
|  |   handles that are used within the same multi handle. | ||||||
|  |  | ||||||
|   5.7 Link errors when building libcurl on Windows! |   5.7 Link errors when building libcurl on Windows! | ||||||
|  |  | ||||||
|   You need to make sure that your project, and all the libraries (both static |   You need to make sure that your project, and all the libraries (both static | ||||||
| @@ -1260,14 +1270,13 @@ FAQ | |||||||
|   With the easy interface you make sure to return the correct error code from |   With the easy interface you make sure to return the correct error code from | ||||||
|   one of the callbacks, but none of them are instant. There is no function you |   one of the callbacks, but none of them are instant. There is no function you | ||||||
|   can call from another thread or similar that will stop it immediately. |   can call from another thread or similar that will stop it immediately. | ||||||
|   Instead you need to make sure that one of the callbacks you use return an |   Instead, you need to make sure that one of the callbacks you use returns an | ||||||
|   appropriate value that will stop the transfer. |   appropriate value that will stop the transfer.  Suitable callbacks that you | ||||||
|  |   can do this with include the progress callback, the read callback and the | ||||||
|   Suitable callbacks that you can do this with include the progress callback, |   write callback. | ||||||
|   the read callback and the write callback. |  | ||||||
|  |  | ||||||
|   If you're using the multi interface, you can also stop a transfer by |   If you're using the multi interface, you can also stop a transfer by | ||||||
|   removing the particular easy handle from the multi stack. At any moment you |   removing the particular easy handle from the multi stack at any moment you | ||||||
|   think the transfer is done. |   think the transfer is done. | ||||||
|  |  | ||||||
|   5.14 Using C++ non-static functions for callbacks? |   5.14 Using C++ non-static functions for callbacks? | ||||||
|   | |||||||
| @@ -14,6 +14,12 @@ Installing Binary Packages | |||||||
|    binary package. This document describes how to compile, build and install |    binary package. This document describes how to compile, build and install | ||||||
|    curl and libcurl from source code. |    curl and libcurl from source code. | ||||||
|  |  | ||||||
|  | Building from git | ||||||
|  | ================= | ||||||
|  |  | ||||||
|  |    If you get your code off a git repository, see the GIT-INFO file in the | ||||||
|  |    root directory for specific instructions on how to proceed. | ||||||
|  |  | ||||||
| UNIX | UNIX | ||||||
| ==== | ==== | ||||||
|    A normal unix installation is made in three or four steps (after you've |    A normal unix installation is made in three or four steps (after you've | ||||||
| @@ -213,7 +219,7 @@ Win32 | |||||||
|  |  | ||||||
|      set ZLIB_PATH=c:\zlib-1.2.5 |      set ZLIB_PATH=c:\zlib-1.2.5 | ||||||
|      set OPENSSL_PATH=c:\openssl-0.9.8r |      set OPENSSL_PATH=c:\openssl-0.9.8r | ||||||
|      set LIBSSH2_PATH=c:\libssh2-1.2.7 |      set LIBSSH2_PATH=c:\libssh2-1.2.8 | ||||||
|  |  | ||||||
|    ATTENTION: if you want to build with libssh2 support you have to use latest |    ATTENTION: if you want to build with libssh2 support you have to use latest | ||||||
|    version 0.17 - previous versions will NOT work with 7.17.0 and later! |    version 0.17 - previous versions will NOT work with 7.17.0 and later! | ||||||
|   | |||||||
| @@ -18,6 +18,17 @@ Building with CMake | |||||||
|    CMake builds can be configured either from the command line, or from one |    CMake builds can be configured either from the command line, or from one | ||||||
|    of CMake's GUI's. |    of CMake's GUI's. | ||||||
|  |  | ||||||
|  | Important notice | ||||||
|  | ================== | ||||||
|  |    If you got your curl sources from a distribution tarball, make sure to | ||||||
|  |    delete the generic 'include/curl/curlbuild.h' file that comes with it: | ||||||
|  |        rm -f curl/include/curl/curlbuild.h | ||||||
|  |  | ||||||
|  |    The purpose of this file is to provide reasonable definitions for systems | ||||||
|  |    where autoconfiguration is not available. CMake will create its own | ||||||
|  |    version of this file in its build directory. If the "generic" version | ||||||
|  |    is not deleted, weird build errors may occur on some systems. | ||||||
|  |  | ||||||
| Command Line CMake | Command Line CMake | ||||||
| ================== | ================== | ||||||
|    A command line build of Curl is similar to the autotools build of Curl. It |    A command line build of Curl is similar to the autotools build of Curl. It | ||||||
| @@ -32,9 +43,10 @@ Command Line CMake | |||||||
|        # variable prior to running CMake. |        # variable prior to running CMake. | ||||||
|        cmake ../curl |        cmake ../curl | ||||||
|        make |        make | ||||||
|        # currently make test and make install are not implemented |        # currently make test is not implemented | ||||||
|        #make test |        #make test | ||||||
|        #make install |        # Install to default location: | ||||||
|  |        make install | ||||||
|  |  | ||||||
| ccmake | ccmake | ||||||
| ========= | ========= | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								docs/THANKS
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								docs/THANKS
									
									
									
									
									
								
							| @@ -78,6 +78,7 @@ Bas Mevissen | |||||||
| Ben Darnell | Ben Darnell | ||||||
| Ben Greear | Ben Greear | ||||||
| Ben Madsen | Ben Madsen | ||||||
|  | Ben Noordhuis | ||||||
| Ben Van Hof | Ben Van Hof | ||||||
| Benbuck Nason | Benbuck Nason | ||||||
| Benjamin Gerard | Benjamin Gerard | ||||||
| @@ -123,6 +124,7 @@ Chris Flerackers | |||||||
| Chris Gaukroger | Chris Gaukroger | ||||||
| Chris Maltby | Chris Maltby | ||||||
| Chris Mumford | Chris Mumford | ||||||
|  | Chris Smowton | ||||||
| Christian Krause | Christian Krause | ||||||
| Christian Kurz | Christian Kurz | ||||||
| Christian Robottom Reis | Christian Robottom Reis | ||||||
| @@ -320,6 +322,7 @@ Heikki Korpela | |||||||
| Heinrich Ko | Heinrich Ko | ||||||
| Hendrik Visage | Hendrik Visage | ||||||
| Henrik Storner | Henrik Storner | ||||||
|  | Henry Ludemann | ||||||
| Hidemoto Nakada | Hidemoto Nakada | ||||||
| Hoi-Ho Chan | Hoi-Ho Chan | ||||||
| Hongli Lai | Hongli Lai | ||||||
| @@ -421,6 +424,7 @@ Jose Kahan | |||||||
| Josef Wolf | Josef Wolf | ||||||
| Josh Kapell | Josh Kapell | ||||||
| Joshua Kwan | Joshua Kwan | ||||||
|  | Josue Andrade Gomes | ||||||
| Juan F. Codagnone | Juan F. Codagnone | ||||||
| Juan Ignacio Herv<72>s | Juan Ignacio Herv<72>s | ||||||
| Judson Bishop | Judson Bishop | ||||||
| @@ -438,6 +442,7 @@ Kai-Uwe Rommel | |||||||
| Kalle Vahlman | Kalle Vahlman | ||||||
| Kamil Dudka | Kamil Dudka | ||||||
| Kang-Jin Lee | Kang-Jin Lee | ||||||
|  | Karl M | ||||||
| Karl Moerder | Karl Moerder | ||||||
| Karol Pietrzak | Karol Pietrzak | ||||||
| Kaspar Brand | Kaspar Brand | ||||||
| @@ -499,6 +504,7 @@ Luong Dinh Dung | |||||||
| Maciej Karpiuk | Maciej Karpiuk | ||||||
| Maciej W. Rozycki | Maciej W. Rozycki | ||||||
| Manfred Schwarb | Manfred Schwarb | ||||||
|  | Manuel Massing | ||||||
| Marc Boucher | Marc Boucher | ||||||
| Marc Kleine-Budde | Marc Kleine-Budde | ||||||
| Marcel Roelofs | Marcel Roelofs | ||||||
| @@ -506,6 +512,7 @@ Marcelo Juchem | |||||||
| Marcin Konicki | Marcin Konicki | ||||||
| Marco G. Salvagno | Marco G. Salvagno | ||||||
| Marco Maggi | Marco Maggi | ||||||
|  | Marcus Sundberg | ||||||
| Marcus Webster | Marcus Webster | ||||||
| Mario Schroeder | Mario Schroeder | ||||||
| Mark Butler | Mark Butler | ||||||
| @@ -545,6 +552,7 @@ Mauro Iorio | |||||||
| Max Katsev | Max Katsev | ||||||
| Maxim Ivanov | Maxim Ivanov | ||||||
| Maxim Perenesenko | Maxim Perenesenko | ||||||
|  | Mehmet Bozkurt | ||||||
| Mekonikum | Mekonikum | ||||||
| Mettgut Jamalla | Mettgut Jamalla | ||||||
| Michael Benedict | Michael Benedict | ||||||
| @@ -666,6 +674,7 @@ Rafa Muyo | |||||||
| Rafael Sagula | Rafael Sagula | ||||||
| Rainer Canavan | Rainer Canavan | ||||||
| Rainer Koenig | Rainer Koenig | ||||||
|  | Rajesh Naganathan | ||||||
| Ralf S. Engelschall | Ralf S. Engelschall | ||||||
| Ralph Beckmann | Ralph Beckmann | ||||||
| Ralph Mitchell | Ralph Mitchell | ||||||
| @@ -720,6 +729,7 @@ Ruslan Gazizov | |||||||
| Rutger Hofman | Rutger Hofman | ||||||
| Ryan Chan | Ryan Chan | ||||||
| Ryan Nelson | Ryan Nelson | ||||||
|  | Ryan Schmidt | ||||||
| S. Moonesamy | S. Moonesamy | ||||||
| Salvador D<>vila | Salvador D<>vila | ||||||
| Salvatore Sorrentino | Salvatore Sorrentino | ||||||
| @@ -730,6 +740,7 @@ Samuel Listopad | |||||||
| Samuel Thibault | Samuel Thibault | ||||||
| Sander Gates | Sander Gates | ||||||
| Sandor Feldi | Sandor Feldi | ||||||
|  | Saqib Ali | ||||||
| Saul good | Saul good | ||||||
| Scott Barrett | Scott Barrett | ||||||
| Scott Cantor | Scott Cantor | ||||||
| @@ -796,8 +807,10 @@ Tim Chen | |||||||
| Tim Costello | Tim Costello | ||||||
| Tim Newsome | Tim Newsome | ||||||
| Tim Sneddon | Tim Sneddon | ||||||
|  | Tinus van den Berg | ||||||
| Tobias Rundstr<74>m | Tobias Rundstr<74>m | ||||||
| Toby Peterson | Toby Peterson | ||||||
|  | Todd A Ouska | ||||||
| Todd Kulesza | Todd Kulesza | ||||||
| Todd Vierling | Todd Vierling | ||||||
| Tom Benoist | Tom Benoist | ||||||
| @@ -833,6 +846,7 @@ Vincent Bronner | |||||||
| Vincent Le Normand | Vincent Le Normand | ||||||
| Vincent Penquerc'h | Vincent Penquerc'h | ||||||
| Vincent Sanders | Vincent Sanders | ||||||
|  | Vincent Torri | ||||||
| Vlad Grachov | Vlad Grachov | ||||||
| Vlad Ureche | Vlad Ureche | ||||||
| Vladimir Lazarenko | Vladimir Lazarenko | ||||||
|   | |||||||
							
								
								
									
										920
									
								
								docs/curl.1
									
									
									
									
									
								
							
							
						
						
									
										920
									
								
								docs/curl.1
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -26,8 +26,6 @@ | |||||||
| #else | #else | ||||||
| #  ifdef __VMS | #  ifdef __VMS | ||||||
|      typedef int intptr_t; |      typedef int intptr_t; | ||||||
| #  else |  | ||||||
| #    include <stdint.h> |  | ||||||
| #  endif | #  endif | ||||||
| #  include <unistd.h> | #  include <unistd.h> | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| .\" *                            | (__| |_| |  _ <| |___ | .\" *                            | (__| |_| |  _ <| |___ | ||||||
| .\" *                             \___|\___/|_| \_\_____| | .\" *                             \___|\___/|_| \_\_____| | ||||||
| .\" * | .\" * | ||||||
| .\" * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. | .\" * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
| .\" * | .\" * | ||||||
| .\" * This software is licensed as described in the file COPYING, which | .\" * This software is licensed as described in the file COPYING, which | ||||||
| .\" * you should have received as part of this distribution. The terms | .\" * you should have received as part of this distribution. The terms | ||||||
| @@ -31,8 +31,8 @@ curl_easy_escape - URL encodes the given string | |||||||
| .SH DESCRIPTION | .SH DESCRIPTION | ||||||
| This function converts the given input string to an URL encoded string and | This function converts the given input string to an URL encoded string and | ||||||
| returns that as a new allocated string. All input characters that are not a-z, | returns that as a new allocated string. All input characters that are not a-z, | ||||||
| A-Z or 0-9 are converted to their "URL escaped" version (%NN where NN is a | A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" version | ||||||
| two-digit hexadecimal number). | (%NN where NN is a two-digit hexadecimal number). | ||||||
|  |  | ||||||
| If the \fBlength\fP argument is set to 0 (zero), \fIcurl_easy_escape(3)\fP | If the \fBlength\fP argument is set to 0 (zero), \fIcurl_easy_escape(3)\fP | ||||||
| uses strlen() on the input \fBurl\fP to find out the size. | uses strlen() on the input \fBurl\fP to find out the size. | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| .\" *                            | (__| |_| |  _ <| |___ | .\" *                            | (__| |_| |  _ <| |___ | ||||||
| .\" *                             \___|\___/|_| \_\_____| | .\" *                             \___|\___/|_| \_\_____| | ||||||
| .\" * | .\" * | ||||||
| .\" * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. | .\" * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
| .\" * | .\" * | ||||||
| .\" * This software is licensed as described in the file COPYING, which | .\" * This software is licensed as described in the file COPYING, which | ||||||
| .\" * you should have received as part of this distribution. The terms | .\" * you should have received as part of this distribution. The terms | ||||||
| @@ -80,12 +80,13 @@ waits in line for the pipeline and more. (Added in 7.19.0) | |||||||
| Pass a pointer to a double to receive the time, in seconds, it took from the | Pass a pointer to a double to receive the time, in seconds, it took from the | ||||||
| start until the file transfer is just about to begin. This includes all | start until the file transfer is just about to begin. This includes all | ||||||
| pre-transfer commands and negotiations that are specific to the particular | pre-transfer commands and negotiations that are specific to the particular | ||||||
| protocol(s) involved. | protocol(s) involved. It does \fInot\fP involve the sending of the protocol- | ||||||
|  | specific request that triggers a transfer. | ||||||
| .IP CURLINFO_STARTTRANSFER_TIME | .IP CURLINFO_STARTTRANSFER_TIME | ||||||
| Pass a pointer to a double to receive the time, in seconds, it took from the | Pass a pointer to a double to receive the time, in seconds, it took from the | ||||||
| start until the first byte is just about to be transferred. This includes | start until the first byte is received by libcurl. This includes | ||||||
| CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate | CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate the | ||||||
| the result. | result. | ||||||
| .IP CURLINFO_REDIRECT_TIME | .IP CURLINFO_REDIRECT_TIME | ||||||
| Pass a pointer to a double to receive the total time, in seconds, it took for | Pass a pointer to a double to receive the total time, in seconds, it took for | ||||||
| all redirection steps include name lookup, connect, pretransfer and transfer | all redirection steps include name lookup, connect, pretransfer and transfer | ||||||
| @@ -275,7 +276,7 @@ file transfer is just about to begin. This includes all pre-transfer commands | |||||||
| and negotiations that are specific to the particular protocol(s) involved. | and negotiations that are specific to the particular protocol(s) involved. | ||||||
| .IP STARTTRANSFER | .IP STARTTRANSFER | ||||||
| \fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the | \fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the | ||||||
| first byte is just about to be transferred. | first byte is received by libcurl. | ||||||
| .IP TOTAL | .IP TOTAL | ||||||
| \fICURLINFO_TOTAL_TIME\fP. Total time of the previous request. | \fICURLINFO_TOTAL_TIME\fP. Total time of the previous request. | ||||||
| .IP REDIRECT | .IP REDIRECT | ||||||
|   | |||||||
| @@ -68,8 +68,9 @@ A parameter set to 1 tells the library to include the header in the body | |||||||
| output. This is only relevant for protocols that actually have headers | output. This is only relevant for protocols that actually have headers | ||||||
| preceding the data (like HTTP). | preceding the data (like HTTP). | ||||||
| .IP CURLOPT_NOPROGRESS | .IP CURLOPT_NOPROGRESS | ||||||
| A parameter set to 1 tells the library to shut off the built-in progress meter | Pass a long. If set to 1, it tells the library to shut off the progress meter | ||||||
| completely. | completely. It will also present the \fICURLOPT_PROGRESSFUNCTION\fP from | ||||||
|  | getting called. | ||||||
|  |  | ||||||
| Future versions of libcurl are likely to not have any built-in progress meter | Future versions of libcurl are likely to not have any built-in progress meter | ||||||
| at all. | at all. | ||||||
| @@ -105,18 +106,18 @@ This feature is only supported by the FTP download for now. | |||||||
|  |  | ||||||
| A brief introduction of its syntax follows: | A brief introduction of its syntax follows: | ||||||
| .RS | .RS | ||||||
| .IP "\fB*\fP - ASTERISK" | .IP "* - ASTERISK" | ||||||
| \&ftp://example.com/some/path/\fB*.txt\fP (for all txt's from the root | \&ftp://example.com/some/path/\fB*.txt\fP (for all txt's from the root | ||||||
| directory) | directory) | ||||||
| .RE | .RE | ||||||
| .RS | .RS | ||||||
| .IP "\fB?\fP - QUESTION MARK" | .IP "? - QUESTION MARK" | ||||||
| Question mark matches any (exactly one) character. | Question mark matches any (exactly one) character. | ||||||
|  |  | ||||||
| \&ftp://example.com/some/path/\fBphoto?.jpeg\fP | \&ftp://example.com/some/path/\fBphoto?.jpeg\fP | ||||||
| .RE | .RE | ||||||
| .RS | .RS | ||||||
| .IP "\fB[\fP - BRACKET EXPRESSION" | .IP "[ - BRACKET EXPRESSION" | ||||||
| The left bracket opens a bracket expression. The question mark and asterisk have | The left bracket opens a bracket expression. The question mark and asterisk have | ||||||
| no special meaning in a bracket expression. Each bracket expression ends by the | no special meaning in a bracket expression. Each bracket expression ends by the | ||||||
| right bracket and matches exactly one character. Some examples follow: | right bracket and matches exactly one character. Some examples follow: | ||||||
| @@ -145,7 +146,7 @@ Using the rules above, a file name pattern can be constructed: | |||||||
| .SH CALLBACK OPTIONS | .SH CALLBACK OPTIONS | ||||||
| .IP CURLOPT_WRITEFUNCTION | .IP CURLOPT_WRITEFUNCTION | ||||||
| Function pointer that should match the following prototype: \fBsize_t | Function pointer that should match the following prototype: \fBsize_t | ||||||
| function( void *ptr, size_t size, size_t nmemb, void *userdata);\fP This | function( char *ptr, size_t size, size_t nmemb, void *userdata);\fP This | ||||||
| function gets called by libcurl as soon as there is data received that needs | function gets called by libcurl as soon as there is data received that needs | ||||||
| to be saved. The size of the data pointed to by \fIptr\fP is \fIsize\fP | to be saved. The size of the data pointed to by \fIptr\fP is \fIsize\fP | ||||||
| multiplied with \fInmemb\fP, it will not be zero terminated. Return the number | multiplied with \fInmemb\fP, it will not be zero terminated. Return the number | ||||||
| @@ -307,6 +308,17 @@ address blacklisting.  The default behavior is: | |||||||
| Pass a pointer that will be untouched by libcurl and passed as the first | Pass a pointer that will be untouched by libcurl and passed as the first | ||||||
| argument in the opensocket callback set with \fICURLOPT_OPENSOCKETFUNCTION\fP. | argument in the opensocket callback set with \fICURLOPT_OPENSOCKETFUNCTION\fP. | ||||||
| (Option added in 7.17.1.) | (Option added in 7.17.1.) | ||||||
|  | .IP CURLOPT_CLOSESOCKETFUNCTION | ||||||
|  | Function pointer that should match the \fIcurl_closesocket_callback\fP | ||||||
|  | prototype found in \fI<curl/curl.h>\fP. This function gets called by libcurl | ||||||
|  | instead of the \fIclose(3)\fP or \fIclosesocket(3)\fP call when sockets are | ||||||
|  | closed (not for any other file descriptors). This is pretty much the reverse | ||||||
|  | to the \fICURLOPT_OPENSOCKETFUNCTION\fP option. Return 0 to signal success and | ||||||
|  | 1 if there was an error.  (Option added in 7.21.7) | ||||||
|  | .IP CURLOPT_CLOSESOCKETDATA | ||||||
|  | Pass a pointer that will be untouched by libcurl and passed as the first | ||||||
|  | argument in the opensocket callback set with | ||||||
|  | \fICURLOPT_CLOSESOCKETFUNCTION\fP.  (Option added in 7.21.7) | ||||||
| .IP CURLOPT_PROGRESSFUNCTION | .IP CURLOPT_PROGRESSFUNCTION | ||||||
| Function pointer that should match the \fIcurl_progress_callback\fP prototype | Function pointer that should match the \fIcurl_progress_callback\fP prototype | ||||||
| found in \fI<curl/curl.h>\fP. This function gets called by libcurl instead of | found in \fI<curl/curl.h>\fP. This function gets called by libcurl instead of | ||||||
| @@ -331,10 +343,10 @@ Function pointer that should match the following prototype: \fIsize_t | |||||||
| function( void *ptr, size_t size, size_t nmemb, void *userdata);\fP. This | function( void *ptr, size_t size, size_t nmemb, void *userdata);\fP. This | ||||||
| function gets called by libcurl as soon as it has received header data. The | function gets called by libcurl as soon as it has received header data. The | ||||||
| header callback will be called once for each header and only complete header | header callback will be called once for each header and only complete header | ||||||
| lines are passed on to the callback. Parsing headers should be easy enough | lines are passed on to the callback. Parsing headers is very easy using | ||||||
| using this. The size of the data pointed to by \fIptr\fP is \fIsize\fP | this. The size of the data pointed to by \fIptr\fP is \fIsize\fP multiplied | ||||||
| multiplied with \fInmemb\fP. Do not assume that the header line is zero | with \fInmemb\fP. Do not assume that the header line is zero terminated! The | ||||||
| terminated! The pointer named \fIuserdata\fP is the one you set with the | pointer named \fIuserdata\fP is the one you set with the | ||||||
| \fICURLOPT_WRITEHEADER\fP option. The callback function must return the number | \fICURLOPT_WRITEHEADER\fP option. The callback function must return the number | ||||||
| of bytes actually taken care of. If that amount differs from the amount passed | of bytes actually taken care of. If that amount differs from the amount passed | ||||||
| to your function, it'll signal an error to the library. This will abort the | to your function, it'll signal an error to the library. This will abort the | ||||||
| @@ -353,19 +365,20 @@ negotiation. If you need to operate on only the headers from the final | |||||||
| response, you will need to collect headers in the callback yourself and use | response, you will need to collect headers in the callback yourself and use | ||||||
| HTTP status lines, for example, to delimit response boundaries. | HTTP status lines, for example, to delimit response boundaries. | ||||||
|  |  | ||||||
| Since 7.14.1: When a server sends a chunked encoded transfer, it may contain a | When a server sends a chunked encoded transfer, it may contain a trailer. That | ||||||
| trailer. That trailer is identical to a HTTP header and if such a trailer is | trailer is identical to a HTTP header and if such a trailer is received it is | ||||||
| received it is passed to the application using this callback as well. There | passed to the application using this callback as well. There are several ways | ||||||
| are several ways to detect it being a trailer and not an ordinary header: 1) | to detect it being a trailer and not an ordinary header: 1) it comes after the | ||||||
| it comes after the response-body. 2) it comes after the final header line (CR | response-body. 2) it comes after the final header line (CR LF) 3) a Trailer: | ||||||
| LF) 3) a Trailer: header among the response-headers mention what header to | header among the regular response-headers mention what header(s) to expect in | ||||||
| expect in the trailer. | the trailer. | ||||||
| .IP CURLOPT_WRITEHEADER | .IP CURLOPT_WRITEHEADER | ||||||
| (This option is also known as \fBCURLOPT_HEADERDATA\fP) Pass a pointer to be | (This option is also known as \fBCURLOPT_HEADERDATA\fP) Pass a pointer to be | ||||||
| used to write the header part of the received data to. If you don't use your | used to write the header part of the received data to. If you don't use | ||||||
| own callback to take care of the writing, this must be a valid FILE *. See | \fICURLOPT_WRITEFUNCTION\fP or \fICURLOPT_HEADERFUNCTION\fP to take care of | ||||||
| also the \fICURLOPT_HEADERFUNCTION\fP option above on how to set a custom | the writing, this must be a valid FILE * as the internal default will then be | ||||||
| get-all-headers callback. | a plain fwrite(). See also the \fICURLOPT_HEADERFUNCTION\fP option above on | ||||||
|  | how to set a custom get-all-headers callback. | ||||||
| .IP CURLOPT_DEBUGFUNCTION | .IP CURLOPT_DEBUGFUNCTION | ||||||
| Function pointer that should match the following prototype: \fIint | Function pointer that should match the following prototype: \fIint | ||||||
| curl_debug_callback (CURL *, curl_infotype, char *, size_t, void *);\fP | curl_debug_callback (CURL *, curl_infotype, char *, size_t, void *);\fP | ||||||
| @@ -632,6 +645,13 @@ use of a proxy, even if there is an environment variable set for it. | |||||||
| Since 7.14.1, the proxy host string given in environment variables can be | Since 7.14.1, the proxy host string given in environment variables can be | ||||||
| specified the exact same way as the proxy can be set with \fICURLOPT_PROXY\fP, | specified the exact same way as the proxy can be set with \fICURLOPT_PROXY\fP, | ||||||
| include protocol prefix (http://) and embedded user + password. | include protocol prefix (http://) and embedded user + password. | ||||||
|  |  | ||||||
|  | Since 7.21.7, the proxy string may be specified with a protocol:// prefix to | ||||||
|  | specify alternative proxy protocols. Use socks4://, socks4a://, socks5:// or | ||||||
|  | socks5h:// (the last one to enable socks5 and asking the proxy to do the | ||||||
|  | resolving, also known as CURLPROXY_SOCKS5_HOSTNAME type) to request the | ||||||
|  | specific SOCKS version to be used. No protocol specified, http:// and all | ||||||
|  | others will be treated as HTTP proxies. | ||||||
| .IP CURLOPT_PROXYPORT | .IP CURLOPT_PROXYPORT | ||||||
| Pass a long with this option to set the proxy port to connect to unless it is | Pass a long with this option to set the proxy port to connect to unless it is | ||||||
| specified in the proxy string \fICURLOPT_PROXY\fP. | specified in the proxy string \fICURLOPT_PROXY\fP. | ||||||
| @@ -641,6 +661,11 @@ this are \fICURLPROXY_HTTP\fP, \fICURLPROXY_HTTP_1_0\fP (added in 7.19.4), | |||||||
| \fICURLPROXY_SOCKS4\fP (added in 7.15.2), \fICURLPROXY_SOCKS5\fP, | \fICURLPROXY_SOCKS4\fP (added in 7.15.2), \fICURLPROXY_SOCKS5\fP, | ||||||
| \fICURLPROXY_SOCKS4A\fP (added in 7.18.0) and \fICURLPROXY_SOCKS5_HOSTNAME\fP | \fICURLPROXY_SOCKS4A\fP (added in 7.18.0) and \fICURLPROXY_SOCKS5_HOSTNAME\fP | ||||||
| (added in 7.18.0). The HTTP type is default. (Added in 7.10) | (added in 7.18.0). The HTTP type is default. (Added in 7.10) | ||||||
|  |  | ||||||
|  | If you set \fBCURLOPT_PROXYTYPE\fP to \fICURLPROXY_HTTP_1_0\fP, it will only | ||||||
|  | affect how libcurl speaks to a proxy when CONNECT is used. The HTTP version | ||||||
|  | used for "regular" HTTP requests is instead controled with | ||||||
|  | \fICURLOPT_HTTP_VERSION\fP. | ||||||
| .IP CURLOPT_NOPROXY | .IP CURLOPT_NOPROXY | ||||||
| Pass a pointer to a zero terminated string. The should be a comma- separated | Pass a pointer to a zero terminated string. The should be a comma- separated | ||||||
| list of hosts which do not use a proxy, if one is specified.  The only | list of hosts which do not use a proxy, if one is specified.  The only | ||||||
| @@ -916,7 +941,7 @@ work. (Added in 7.10.7) | |||||||
| Pass a parameter set to 1 to enable this. When enabled, libcurl will | Pass a parameter set to 1 to enable this. When enabled, libcurl will | ||||||
| automatically set the Referer: field in requests where it follows a Location: | automatically set the Referer: field in requests where it follows a Location: | ||||||
| redirect. | redirect. | ||||||
| .IP CURLOPT_ENCODING | .IP CURLOPT_ACCEPT_ENCODING | ||||||
| Sets the contents of the Accept-Encoding: header sent in an HTTP request, and | Sets the contents of the Accept-Encoding: header sent in an HTTP request, and | ||||||
| enables decoding of a response when a Content-Encoding: header is received. | enables decoding of a response when a Content-Encoding: header is received. | ||||||
| Three encodings are supported: \fIidentity\fP, which does nothing, | Three encodings are supported: \fIidentity\fP, which does nothing, | ||||||
| @@ -928,6 +953,21 @@ supported encodings is sent. | |||||||
| This is a request, not an order; the server may or may not do it.  This option | This is a request, not an order; the server may or may not do it.  This option | ||||||
| must be set (to any non-NULL value) or else any unsolicited encoding done by | must be set (to any non-NULL value) or else any unsolicited encoding done by | ||||||
| the server is ignored. See the special file lib/README.encoding for details. | the server is ignored. See the special file lib/README.encoding for details. | ||||||
|  |  | ||||||
|  | (This option was called CURLOPT_ENCODING before 7.21.6) | ||||||
|  | .IP CURLOPT_TRANSFER_ENCODING | ||||||
|  | Adds a request for compressed Transfer Encoding in the outgoing HTTP | ||||||
|  | request. If the server supports this and so desires, it can respond with the | ||||||
|  | HTTP resonse sent using a compressed Transfer-Encoding that will be | ||||||
|  | automatically uncompressed by libcurl on receival. | ||||||
|  |  | ||||||
|  | Transfer-Encoding differs slightly from the Content-Encoding you ask for with | ||||||
|  | \fBCURLOPT_ACCEPT_ENCODING\fP in that a Transfer-Encoding is strictly meant to | ||||||
|  | be for the transfer and thus MUST be decoded before the data arrives in the | ||||||
|  | client. Traditionally, Transfer-Encoding has been much less used and supported | ||||||
|  | by both HTTP clients and HTTP servers. | ||||||
|  |  | ||||||
|  | (Added in 7.21.6) | ||||||
| .IP CURLOPT_FOLLOWLOCATION | .IP CURLOPT_FOLLOWLOCATION | ||||||
| A parameter set to 1 tells the library to follow any Location: header that the | A parameter set to 1 tells the library to follow any Location: header that the | ||||||
| server sends as part of an HTTP header. | server sends as part of an HTTP header. | ||||||
| @@ -2078,13 +2118,15 @@ libcurl will reject the connection to the host unless the md5sums match. This | |||||||
| option is only for SCP and SFTP transfers. (Added in 7.17.1) | option is only for SCP and SFTP transfers. (Added in 7.17.1) | ||||||
| .IP CURLOPT_SSH_PUBLIC_KEYFILE | .IP CURLOPT_SSH_PUBLIC_KEYFILE | ||||||
| Pass a char * pointing to a file name for your public key. If not used, | Pass a char * pointing to a file name for your public key. If not used, | ||||||
| libcurl defaults to using \fB~/.ssh/id_dsa.pub\fP. | libcurl defaults to \fB$HOME/.ssh/id_dsa.pub\fP if the HOME environment | ||||||
| (Added in 7.16.1) | variable is set, and just "id_dsa.pub" in the current directory if HOME is not | ||||||
|  | set.  (Added in 7.16.1) | ||||||
| .IP CURLOPT_SSH_PRIVATE_KEYFILE | .IP CURLOPT_SSH_PRIVATE_KEYFILE | ||||||
| Pass a char * pointing to a file name for your private key. If not used, | Pass a char * pointing to a file name for your private key. If not used, | ||||||
| libcurl defaults to using \fB~/.ssh/id_dsa\fP.  If the file is | libcurl defaults to \fB$HOME/.ssh/id_dsa\fP if the HOME environment variable | ||||||
| password-protected, set the password with \fICURLOPT_KEYPASSWD\fP. (Added in | is set, and just "id_dsa" in the current directory if HOME is not set.  If the | ||||||
| 7.16.1) | file is password-protected, set the password with | ||||||
|  | \fICURLOPT_KEYPASSWD\fP. (Added in 7.16.1) | ||||||
| .IP CURLOPT_SSH_KNOWNHOSTS | .IP CURLOPT_SSH_KNOWNHOSTS | ||||||
| Pass a pointer to a zero terminated string holding the file name of the | Pass a pointer to a zero terminated string holding the file name of the | ||||||
| known_host file to use.  The known_hosts file should use the OpenSSH file | known_host file to use.  The known_hosts file should use the OpenSSH file | ||||||
|   | |||||||
| @@ -30,18 +30,19 @@ curl_formadd - add a section to a multipart/formdata HTTP POST | |||||||
| .ad | .ad | ||||||
| .SH DESCRIPTION | .SH DESCRIPTION | ||||||
| curl_formadd() is used to append sections when building a multipart/formdata | curl_formadd() is used to append sections when building a multipart/formdata | ||||||
| HTTP POST (sometimes referred to as RFC2388-style posts). Append one section at | HTTP POST (sometimes referred to as RFC2388-style posts). Append one section | ||||||
| a time until you've added all the sections you want included and then you pass | at a time until you've added all the sections you want included and then you | ||||||
| the \fIfirstitem\fP pointer as parameter to \fBCURLOPT_HTTPPOST\fP. | pass the \fIfirstitem\fP pointer as parameter to \fBCURLOPT_HTTPPOST\fP. | ||||||
| \fIlastitem\fP is set after each call and on repeated invokes it should be | \fIlastitem\fP is set after each \fIcurl_formadd(3)\fP call and on repeated | ||||||
| left as set to allow repeated invokes to find the end of the list faster. | invokes it should be left as set to allow repeated invokes to find the end of | ||||||
|  | the list faster. | ||||||
|  |  | ||||||
| After the \fIlastitem\fP pointer follow the real arguments. | After the \fIlastitem\fP pointer follow the real arguments. | ||||||
|  |  | ||||||
| The pointers \fI*firstitem\fP and \fI*lastitem\fP should both be pointing to | The pointers \fIfirstitem\fP and \fIlastitem\fP should both be pointing to | ||||||
| NULL in the first call to this function. All list-data will be allocated by | NULL in the first call to this function. All list-data will be allocated by | ||||||
| the function itself. You must call \fIcurl_formfree(3)\fP after the form post | the function itself. You must call \fIcurl_formfree(3)\fP on the | ||||||
| has been done to free the resources. | \fIfirstitem\P after the form post has been done to free the resources. | ||||||
|  |  | ||||||
| Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. | Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. | ||||||
| You can disable this header with \fICURLOPT_HTTPHEADER\fP as usual. | You can disable this header with \fICURLOPT_HTTPHEADER\fP as usual. | ||||||
|   | |||||||
| @@ -31,6 +31,13 @@ curl_formfree - free a previously build multipart/formdata HTTP POST chain | |||||||
| curl_formfree() is used to clean up data previously built/appended with | curl_formfree() is used to clean up data previously built/appended with | ||||||
| \fIcurl_formadd(3)\fP. This must be called when the data has been used, which | \fIcurl_formadd(3)\fP. This must be called when the data has been used, which | ||||||
| typically means after \fIcurl_easy_perform(3)\fP has been called. | typically means after \fIcurl_easy_perform(3)\fP has been called. | ||||||
|  |  | ||||||
|  | The pointer to free is the same pointer you passed to the | ||||||
|  | \fBCURLOPT_HTTPPOST\fP option, which is the \fIfirstitem\fP pointer from the | ||||||
|  | \fIcurl_formadd(3)\fP invoke(s). | ||||||
|  |  | ||||||
|  | \fBform\fP is the pointer as returned from a previous call to | ||||||
|  | \fIcurl_formadd(3)\fP and may be NULL. | ||||||
| .SH RETURN VALUE | .SH RETURN VALUE | ||||||
| None | None | ||||||
| .SH "SEE ALSO" | .SH "SEE ALSO" | ||||||
|   | |||||||
| @@ -23,24 +23,27 @@ | |||||||
| .SH NAME | .SH NAME | ||||||
| curl_formget - serialize a previously built multipart/formdata HTTP POST chain | curl_formget - serialize a previously built multipart/formdata HTTP POST chain | ||||||
| .SH SYNOPSIS | .SH SYNOPSIS | ||||||
|  | .nf | ||||||
| .B #include <curl/curl.h> | .B #include <curl/curl.h> | ||||||
| .sp |  | ||||||
| .BI "void curl_formget(struct curl_httppost *" form, " void *" arg, | void curl_formget(struct curl_httppost * form, void *userp, | ||||||
| .BI " curl_formget_callback " append ");" |                   curl_formget_callback append ); | ||||||
| .ad |  | ||||||
| .SH DESCRIPTION | .SH DESCRIPTION | ||||||
| curl_formget() is used to serialize data previously built/appended with | curl_formget() is used to serialize data previously built/appended with | ||||||
| \fIcurl_formadd(3)\fP. Accepts a void pointer as second argument which will be | \fIcurl_formadd(3)\fP. Accepts a void pointer as second argument named | ||||||
| passed to the curl_formget_callback function. | \fIuserp\fP which will be passed as the first argument to the | ||||||
|  | curl_formget_callback function. | ||||||
|  |  | ||||||
| .BI "typedef size_t (*curl_formget_callback)(void *" arg, " const char *" buf, | .BI "typedef size_t (*curl_formget_callback)(void *" userp, " const char *" buf, | ||||||
| .BI " size_t " len ");" | .BI " size_t " len ");" | ||||||
| .nf |  | ||||||
|  |  | ||||||
| The curl_formget_callback will be executed for each part of the HTTP POST | The curl_formget_callback will be executed for each part of the HTTP POST | ||||||
| chain. The void *arg pointer will be the one passed as second argument to | chain. The character buffer passed to the callback must not be freed. The | ||||||
| curl_formget(). The character buffer passed to it must not be freed. The |  | ||||||
| callback should return the buffer length passed to it on success. | callback should return the buffer length passed to it on success. | ||||||
|  |  | ||||||
|  | If the \fBCURLFORM_STREAM\fP option is used in the formpost, it will prevent | ||||||
|  | \fIcurl_formget(3)\fP from working until you've performed the actual HTTP | ||||||
|  | request as only then will libcurl get the actual read callback to use! | ||||||
| .SH RETURN VALUE | .SH RETURN VALUE | ||||||
| 0 means everything was ok, non-zero means an error occurred | 0 means everything was ok, non-zero means an error occurred | ||||||
| .SH EXAMPLE | .SH EXAMPLE | ||||||
| @@ -52,6 +55,7 @@ callback should return the buffer length passed to it on success. | |||||||
|    (*(size_t *) arg) += len; |    (*(size_t *) arg) += len; | ||||||
|    return len; |    return len; | ||||||
|  } |  } | ||||||
|  |  | ||||||
|  size_t print_httppost(struct curl_httppost *post) |  size_t print_httppost(struct curl_httppost *post) | ||||||
|  { |  { | ||||||
|    size_t total_size = 0; |    size_t total_size = 0; | ||||||
|   | |||||||
| @@ -282,6 +282,7 @@ CURLOPTTYPE_FUNCTIONPOINT       7.1 | |||||||
| CURLOPTTYPE_LONG                7.1 | CURLOPTTYPE_LONG                7.1 | ||||||
| CURLOPTTYPE_OBJECTPOINT         7.1 | CURLOPTTYPE_OBJECTPOINT         7.1 | ||||||
| CURLOPTTYPE_OFF_T               7.11.0 | CURLOPTTYPE_OFF_T               7.11.0 | ||||||
|  | CURLOPT_ACCEPT_ENCODING         7.21.6 | ||||||
| CURLOPT_ADDRESS_SCOPE           7.19.0 | CURLOPT_ADDRESS_SCOPE           7.19.0 | ||||||
| CURLOPT_APPEND                  7.17.0 | CURLOPT_APPEND                  7.17.0 | ||||||
| CURLOPT_AUTOREFERER             7.1 | CURLOPT_AUTOREFERER             7.1 | ||||||
| @@ -294,6 +295,8 @@ CURLOPT_CHUNK_DATA              7.21.0 | |||||||
| CURLOPT_CHUNK_END_FUNCTION      7.21.0 | CURLOPT_CHUNK_END_FUNCTION      7.21.0 | ||||||
| CURLOPT_CLOSEFUNCTION           7.7           7.11.1      7.15.5 | CURLOPT_CLOSEFUNCTION           7.7           7.11.1      7.15.5 | ||||||
| CURLOPT_CLOSEPOLICY             7.7           7.16.1 | CURLOPT_CLOSEPOLICY             7.7           7.16.1 | ||||||
|  | CURLOPT_CLOSESOCKETDATA         7.21.7 | ||||||
|  | CURLOPT_CLOSESOCKETFUNCTION     7.21.7 | ||||||
| CURLOPT_CONNECTTIMEOUT          7.7 | CURLOPT_CONNECTTIMEOUT          7.7 | ||||||
| CURLOPT_CONNECTTIMEOUT_MS       7.16.2 | CURLOPT_CONNECTTIMEOUT_MS       7.16.2 | ||||||
| CURLOPT_CONNECT_ONLY            7.15.2 | CURLOPT_CONNECT_ONLY            7.15.2 | ||||||
| @@ -485,6 +488,7 @@ CURLOPT_TLSAUTH_PASSWORD        7.21.4 | |||||||
| CURLOPT_TLSAUTH_TYPE            7.21.4 | CURLOPT_TLSAUTH_TYPE            7.21.4 | ||||||
| CURLOPT_TLSAUTH_USERNAME        7.21.4 | CURLOPT_TLSAUTH_USERNAME        7.21.4 | ||||||
| CURLOPT_TRANSFERTEXT            7.1.1 | CURLOPT_TRANSFERTEXT            7.1.1 | ||||||
|  | CURLOPT_TRANSFER_ENCODING       7.21.6 | ||||||
| CURLOPT_UNRESTRICTED_AUTH       7.10.4 | CURLOPT_UNRESTRICTED_AUTH       7.10.4 | ||||||
| CURLOPT_UPLOAD                  7.1 | CURLOPT_UPLOAD                  7.1 | ||||||
| CURLOPT_URL                     7.1 | CURLOPT_URL                     7.1 | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ The following notes apply to libcurl version 7.19.0 and later. | |||||||
| * If you intend to distribute an already compiled libcurl library you _MUST_ | * If you intend to distribute an already compiled libcurl library you _MUST_ | ||||||
|   also distribute along with it the generated curl/curlbuild.h which has been |   also distribute along with it the generated curl/curlbuild.h which has been | ||||||
|   used to compile it. Otherwise the library will be of no use for the users of |   used to compile it. Otherwise the library will be of no use for the users of | ||||||
|   the library that you have built. It is _your_ responsability to provide this |   the library that you have built. It is _your_ responsibility to provide this | ||||||
|   file. No one at the cURL project can know how you have built the library. |   file. No one at the cURL project can know how you have built the library. | ||||||
|  |  | ||||||
| * File curl/curlbuild.h includes platform and configuration dependent info, | * File curl/curlbuild.h includes platform and configuration dependent info, | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ | |||||||
| # | # | ||||||
| ########################################################################### | ########################################################################### | ||||||
| pkginclude_HEADERS = \ | pkginclude_HEADERS = \ | ||||||
| 	curl.h curlver.h easy.h mprintf.h stdcheaders.h types.h multi.h \ | 	curl.h curlver.h easy.h mprintf.h stdcheaders.h multi.h \ | ||||||
| 	typecheck-gcc.h curlbuild.h curlrules.h | 	typecheck-gcc.h curlbuild.h curlrules.h | ||||||
|  |  | ||||||
| pkgincludedir= $(includedir)/curl | pkgincludedir= $(includedir)/curl | ||||||
| @@ -44,3 +44,10 @@ EXTRA_DIST = curlbuild.h.in | |||||||
|  |  | ||||||
| DISTCLEANFILES = curlbuild.h | DISTCLEANFILES = curlbuild.h | ||||||
|  |  | ||||||
|  | checksrc: | ||||||
|  | 	@@PERL@ $(top_srcdir)/lib/checksrc.pl -Wcurlbuild.h -D$(top_srcdir)/include/curl $(pkginclude_HEADERS) $(EXTRA_DIST) | ||||||
|  |  | ||||||
|  | if CURLDEBUG | ||||||
|  | # for debug builds, we scan the sources on all regular make invokes | ||||||
|  | all-local: checksrc | ||||||
|  | endif | ||||||
|   | |||||||
| @@ -341,6 +341,9 @@ typedef curl_socket_t | |||||||
|                             curlsocktype purpose, |                             curlsocktype purpose, | ||||||
|                             struct curl_sockaddr *address); |                             struct curl_sockaddr *address); | ||||||
|  |  | ||||||
|  | typedef int | ||||||
|  | (*curl_closesocket_callback)(void *clientp, curl_socket_t item); | ||||||
|  |  | ||||||
| typedef enum { | typedef enum { | ||||||
|   CURLIOE_OK,            /* I/O operation successful */ |   CURLIOE_OK,            /* I/O operation successful */ | ||||||
|   CURLIOE_UNKNOWNCMD,    /* command was unknown to callback */ |   CURLIOE_UNKNOWNCMD,    /* command was unknown to callback */ | ||||||
| @@ -467,7 +470,7 @@ typedef enum { | |||||||
|   CURLE_SSL_CERTPROBLEM,         /* 58 - problem with the local certificate */ |   CURLE_SSL_CERTPROBLEM,         /* 58 - problem with the local certificate */ | ||||||
|   CURLE_SSL_CIPHER,              /* 59 - couldn't use specified cipher */ |   CURLE_SSL_CIPHER,              /* 59 - couldn't use specified cipher */ | ||||||
|   CURLE_SSL_CACERT,              /* 60 - problem with the CA cert (path?) */ |   CURLE_SSL_CACERT,              /* 60 - problem with the CA cert (path?) */ | ||||||
|   CURLE_BAD_CONTENT_ENCODING,    /* 61 - Unrecognized transfer encoding */ |   CURLE_BAD_CONTENT_ENCODING,    /* 61 - Unrecognized/bad encoding */ | ||||||
|   CURLE_LDAP_INVALID_URL,        /* 62 - Invalid LDAP URL */ |   CURLE_LDAP_INVALID_URL,        /* 62 - Invalid LDAP URL */ | ||||||
|   CURLE_FILESIZE_EXCEEDED,       /* 63 - Maximum file size exceeded */ |   CURLE_FILESIZE_EXCEEDED,       /* 63 - Maximum file size exceeded */ | ||||||
|   CURLE_USE_SSL_FAILED,          /* 64 - Requested FTP SSL level failed */ |   CURLE_USE_SSL_FAILED,          /* 64 - Requested FTP SSL level failed */ | ||||||
| @@ -507,7 +510,7 @@ typedef enum { | |||||||
|                                     7.19.0) */ |                                     7.19.0) */ | ||||||
|   CURLE_FTP_PRET_FAILED,         /* 84 - a PRET command failed */ |   CURLE_FTP_PRET_FAILED,         /* 84 - a PRET command failed */ | ||||||
|   CURLE_RTSP_CSEQ_ERROR,         /* 85 - mismatch of RTSP CSeq numbers */ |   CURLE_RTSP_CSEQ_ERROR,         /* 85 - mismatch of RTSP CSeq numbers */ | ||||||
|   CURLE_RTSP_SESSION_ERROR,      /* 86 - mismatch of RTSP Session Identifiers */ |   CURLE_RTSP_SESSION_ERROR,      /* 86 - mismatch of RTSP Session Ids */ | ||||||
|   CURLE_FTP_BAD_FILE_LIST,       /* 87 - unable to parse FTP file list */ |   CURLE_FTP_BAD_FILE_LIST,       /* 87 - unable to parse FTP file list */ | ||||||
|   CURLE_CHUNK_FAILED,            /* 88 - chunk callback reported error */ |   CURLE_CHUNK_FAILED,            /* 88 - chunk callback reported error */ | ||||||
|  |  | ||||||
| @@ -517,7 +520,8 @@ typedef enum { | |||||||
| #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all | #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all | ||||||
|                           the obsolete stuff removed! */ |                           the obsolete stuff removed! */ | ||||||
|  |  | ||||||
| /* Backwards compatibility with older names */ | /*  compatibility with older names */ | ||||||
|  | #define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING | ||||||
|  |  | ||||||
| /* The following were added in 7.21.5, April 2011 */ | /* The following were added in 7.21.5, April 2011 */ | ||||||
| #define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION | #define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION | ||||||
| @@ -754,7 +758,7 @@ typedef enum { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef CURL_ISOCPP | #ifdef CURL_ISOCPP | ||||||
| #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number | #define CINIT(na,t,nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu | ||||||
| #else | #else | ||||||
| /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ | /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ | ||||||
| #define LONG          CURLOPTTYPE_LONG | #define LONG          CURLOPTTYPE_LONG | ||||||
| @@ -923,7 +927,7 @@ typedef enum { | |||||||
|   CINIT(FAILONERROR, LONG, 45),  /* no output on http error codes >= 300 */ |   CINIT(FAILONERROR, LONG, 45),  /* no output on http error codes >= 300 */ | ||||||
|   CINIT(UPLOAD, LONG, 46),       /* this is an upload */ |   CINIT(UPLOAD, LONG, 46),       /* this is an upload */ | ||||||
|   CINIT(POST, LONG, 47),         /* HTTP POST method */ |   CINIT(POST, LONG, 47),         /* HTTP POST method */ | ||||||
|   CINIT(DIRLISTONLY, LONG, 48),  /* return bare names when listing directories */ |   CINIT(DIRLISTONLY, LONG, 48),  /* bare names when listing directories */ | ||||||
|  |  | ||||||
|   CINIT(APPEND, LONG, 50),       /* Append instead of overwrite on upload! */ |   CINIT(APPEND, LONG, 50),       /* Append instead of overwrite on upload! */ | ||||||
|  |  | ||||||
| @@ -990,8 +994,7 @@ typedef enum { | |||||||
|   /* Max amount of cached alive connections */ |   /* Max amount of cached alive connections */ | ||||||
|   CINIT(MAXCONNECTS, LONG, 71), |   CINIT(MAXCONNECTS, LONG, 71), | ||||||
|  |  | ||||||
|   /* What policy to use when closing connections when the cache is filled |   /* 72 - DEPRECATED */ | ||||||
|      up */ |  | ||||||
|   CINIT(CLOSEPOLICY, LONG, 72), |   CINIT(CLOSEPOLICY, LONG, 72), | ||||||
|  |  | ||||||
|   /* 73 = OBSOLETE */ |   /* 73 = OBSOLETE */ | ||||||
| @@ -1103,8 +1106,9 @@ typedef enum { | |||||||
|   CINIT(PROXYTYPE, LONG, 101), |   CINIT(PROXYTYPE, LONG, 101), | ||||||
|  |  | ||||||
|   /* Set the Accept-Encoding string. Use this to tell a server you would like |   /* Set the Accept-Encoding string. Use this to tell a server you would like | ||||||
|      the response to be compressed. */ |      the response to be compressed. Before 7.21.6, this was known as | ||||||
|   CINIT(ENCODING, OBJECTPOINT, 102), |      CURLOPT_ENCODING */ | ||||||
|  |   CINIT(ACCEPT_ENCODING, OBJECTPOINT, 102), | ||||||
|  |  | ||||||
|   /* Set pointer to private data */ |   /* Set pointer to private data */ | ||||||
|   CINIT(PRIVATE, OBJECTPOINT, 103), |   CINIT(PRIVATE, OBJECTPOINT, 103), | ||||||
| @@ -1117,8 +1121,8 @@ typedef enum { | |||||||
|      and password to whatever host the server decides. */ |      and password to whatever host the server decides. */ | ||||||
|   CINIT(UNRESTRICTED_AUTH, LONG, 105), |   CINIT(UNRESTRICTED_AUTH, LONG, 105), | ||||||
|  |  | ||||||
|   /* Specifically switch on or off the FTP engine's use of the EPRT command ( it |   /* Specifically switch on or off the FTP engine's use of the EPRT command ( | ||||||
|      also disables the LPRT attempt). By default, those ones will always be |      it also disables the LPRT attempt). By default, those ones will always be | ||||||
|      attempted before the good old traditional PORT command. */ |      attempted before the good old traditional PORT command. */ | ||||||
|   CINIT(FTP_USE_EPRT, LONG, 106), |   CINIT(FTP_USE_EPRT, LONG, 106), | ||||||
|  |  | ||||||
| @@ -1462,6 +1466,23 @@ typedef enum { | |||||||
|   /* Set authentication type for authenticated TLS */ |   /* Set authentication type for authenticated TLS */ | ||||||
|   CINIT(TLSAUTH_TYPE, OBJECTPOINT, 206), |   CINIT(TLSAUTH_TYPE, OBJECTPOINT, 206), | ||||||
|  |  | ||||||
|  |   /* Set to 1 to enable the "TE:" header in HTTP requests to ask for | ||||||
|  |      compressed transfer-encoded responses. Set to 0 to disable the use of TE: | ||||||
|  |      in outgoing requests. The current default is 0, but it might change in a | ||||||
|  |      future libcurl release. | ||||||
|  |  | ||||||
|  |      libcurl will ask for the compressed methods it knows of, and if that | ||||||
|  |      isn't any, it will not ask for transfer-encoding at all even if this | ||||||
|  |      option is set to 1. | ||||||
|  |  | ||||||
|  |   */ | ||||||
|  |   CINIT(TRANSFER_ENCODING, LONG, 207), | ||||||
|  |  | ||||||
|  |   /* Callback function for closing socket (instead of close(2)). The callback | ||||||
|  |      should have type curl_closesocket_callback */ | ||||||
|  |   CINIT(CLOSESOCKETFUNCTION, FUNCTIONPOINT, 208), | ||||||
|  |   CINIT(CLOSESOCKETDATA, OBJECTPOINT, 209), | ||||||
|  |  | ||||||
|   CURLOPT_LASTENTRY /* the last unused */ |   CURLOPT_LASTENTRY /* the last unused */ | ||||||
| } CURLoption; | } CURLoption; | ||||||
|  |  | ||||||
| @@ -1690,7 +1711,8 @@ CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost, | |||||||
|  * Should return the buffer length passed to it as the argument "len" on |  * Should return the buffer length passed to it as the argument "len" on | ||||||
|  *   success. |  *   success. | ||||||
|  */ |  */ | ||||||
| typedef size_t (*curl_formget_callback)(void *arg, const char *buf, size_t len); | typedef size_t (*curl_formget_callback)(void *arg, const char *buf, | ||||||
|  |                                         size_t len); | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * NAME curl_formget() |  * NAME curl_formget() | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
|   | |||||||
| @@ -30,13 +30,13 @@ | |||||||
|  |  | ||||||
| /* This is the version number of the libcurl package from which this header | /* This is the version number of the libcurl package from which this header | ||||||
|    file origins: */ |    file origins: */ | ||||||
| #define LIBCURL_VERSION "7.21.5-DEV" | #define LIBCURL_VERSION "7.21.7-DEV" | ||||||
|  |  | ||||||
| /* The numeric version number is also available "in parts" by using these | /* The numeric version number is also available "in parts" by using these | ||||||
|    defines: */ |    defines: */ | ||||||
| #define LIBCURL_VERSION_MAJOR 7 | #define LIBCURL_VERSION_MAJOR 7 | ||||||
| #define LIBCURL_VERSION_MINOR 21 | #define LIBCURL_VERSION_MINOR 21 | ||||||
| #define LIBCURL_VERSION_PATCH 5 | #define LIBCURL_VERSION_PATCH 7 | ||||||
|  |  | ||||||
| /* This is the numeric version of the libcurl version number, meant for easier | /* This is the numeric version of the libcurl version number, meant for easier | ||||||
|    parsing and comparions by programs. The LIBCURL_VERSION_NUM define will |    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 |    and it is always a greater number in a more recent release. It makes | ||||||
|    comparisons with greater than and less than work. |    comparisons with greater than and less than work. | ||||||
| */ | */ | ||||||
| #define LIBCURL_VERSION_NUM 0x071505 | #define LIBCURL_VERSION_NUM 0x071507 | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * This is the date and time when the full source package was created. The |  * This is the date and time when the full source package was created. The | ||||||
|   | |||||||
| @@ -53,8 +53,8 @@ CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); | |||||||
|  * |  * | ||||||
|  * Creates a new curl session handle with the same options set for the handle |  * Creates a new curl session handle with the same options set for the handle | ||||||
|  * passed in. Duplicating a handle could only be a matter of cloning data and |  * passed in. Duplicating a handle could only be a matter of cloning data and | ||||||
|  * options, internal state info and things like persistant connections cannot |  * options, internal state info and things like persistent connections cannot | ||||||
|  * be transfered. It is useful in multithreaded applications when you can run |  * be transferred. It is useful in multithreaded applications when you can run | ||||||
|  * curl_easy_duphandle() for each new thread to avoid a series of identical |  * curl_easy_duphandle() for each new thread to avoid a series of identical | ||||||
|  * curl_easy_setopt() invokes in every thread. |  * curl_easy_setopt() invokes in every thread. | ||||||
|  */ |  */ | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -149,7 +149,8 @@ _CURL_WARNING(_curl_easy_setopt_err_long, | |||||||
| _CURL_WARNING(_curl_easy_setopt_err_curl_off_t, | _CURL_WARNING(_curl_easy_setopt_err_curl_off_t, | ||||||
|   "curl_easy_setopt expects a curl_off_t argument for this option") |   "curl_easy_setopt expects a curl_off_t argument for this option") | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_string, | _CURL_WARNING(_curl_easy_setopt_err_string, | ||||||
|   "curl_easy_setopt expects a string (char* or char[]) argument for this option" |               "curl_easy_setopt expects a " | ||||||
|  |               "string (char* or char[]) argument for this option" | ||||||
|   ) |   ) | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_write_callback, | _CURL_WARNING(_curl_easy_setopt_err_write_callback, | ||||||
|   "curl_easy_setopt expects a curl_write_callback argument for this option") |   "curl_easy_setopt expects a curl_write_callback argument for this option") | ||||||
| @@ -160,7 +161,8 @@ _CURL_WARNING(_curl_easy_setopt_err_ioctl_cb, | |||||||
| _CURL_WARNING(_curl_easy_setopt_err_sockopt_cb, | _CURL_WARNING(_curl_easy_setopt_err_sockopt_cb, | ||||||
|   "curl_easy_setopt expects a curl_sockopt_callback argument for this option") |   "curl_easy_setopt expects a curl_sockopt_callback argument for this option") | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_opensocket_cb, | _CURL_WARNING(_curl_easy_setopt_err_opensocket_cb, | ||||||
|   "curl_easy_setopt expects a curl_opensocket_callback argument for this option" |               "curl_easy_setopt expects a " | ||||||
|  |               "curl_opensocket_callback argument for this option" | ||||||
|   ) |   ) | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_progress_cb, | _CURL_WARNING(_curl_easy_setopt_err_progress_cb, | ||||||
|   "curl_easy_setopt expects a curl_progress_callback argument for this option") |   "curl_easy_setopt expects a curl_progress_callback argument for this option") | ||||||
| @@ -173,9 +175,11 @@ _CURL_WARNING(_curl_easy_setopt_err_conv_cb, | |||||||
| _CURL_WARNING(_curl_easy_setopt_err_seek_cb, | _CURL_WARNING(_curl_easy_setopt_err_seek_cb, | ||||||
|   "curl_easy_setopt expects a curl_seek_callback argument for this option") |   "curl_easy_setopt expects a curl_seek_callback argument for this option") | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_cb_data, | _CURL_WARNING(_curl_easy_setopt_err_cb_data, | ||||||
|   "curl_easy_setopt expects a private data pointer as argument for this option") |               "curl_easy_setopt expects a " | ||||||
|  |               "private data pointer as argument for this option") | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_error_buffer, | _CURL_WARNING(_curl_easy_setopt_err_error_buffer, | ||||||
|   "curl_easy_setopt expects a char buffer of CURL_ERROR_SIZE as argument for this option") |               "curl_easy_setopt expects a " | ||||||
|  |               "char buffer of CURL_ERROR_SIZE as argument for this option") | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_FILE, | _CURL_WARNING(_curl_easy_setopt_err_FILE, | ||||||
|   "curl_easy_setopt expects a FILE* argument for this option") |   "curl_easy_setopt expects a FILE* argument for this option") | ||||||
| _CURL_WARNING(_curl_easy_setopt_err_postfields, | _CURL_WARNING(_curl_easy_setopt_err_postfields, | ||||||
| @@ -224,7 +228,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist, | |||||||
|    (option) == CURLOPT_PROXYUSERNAME ||                                       \ |    (option) == CURLOPT_PROXYUSERNAME ||                                       \ | ||||||
|    (option) == CURLOPT_PROXYPASSWORD ||                                       \ |    (option) == CURLOPT_PROXYPASSWORD ||                                       \ | ||||||
|    (option) == CURLOPT_NOPROXY ||                                             \ |    (option) == CURLOPT_NOPROXY ||                                             \ | ||||||
|    (option) == CURLOPT_ENCODING ||                                            \ |    (option) == CURLOPT_ACCEPT_ENCODING ||                                     \ | ||||||
|    (option) == CURLOPT_REFERER ||                                             \ |    (option) == CURLOPT_REFERER ||                                             \ | ||||||
|    (option) == CURLOPT_USERAGENT ||                                           \ |    (option) == CURLOPT_USERAGENT ||                                           \ | ||||||
|    (option) == CURLOPT_COOKIE ||                                              \ |    (option) == CURLOPT_COOKIE ||                                              \ | ||||||
| @@ -481,7 +485,8 @@ typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); | |||||||
| typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t, | typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t, | ||||||
|                                       curlsocktype); |                                       curlsocktype); | ||||||
|  |  | ||||||
| /* evaluates to true if expr is of type curl_opensocket_callback or "similar" */ | /* evaluates to true if expr is of type curl_opensocket_callback or | ||||||
|  |    "similar" */ | ||||||
| #define _curl_is_opensocket_cb(expr)                                    \ | #define _curl_is_opensocket_cb(expr)                                    \ | ||||||
|   (_curl_is_NULL(expr) ||                                                     \ |   (_curl_is_NULL(expr) ||                                                     \ | ||||||
|    __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\ |    __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\ | ||||||
| @@ -550,7 +555,8 @@ typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *); | |||||||
| typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *); | typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *); | ||||||
| typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *); | typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *); | ||||||
| typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *); | typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *); | ||||||
| typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, const void *); | typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, | ||||||
|  |                                            const void *); | ||||||
| #else | #else | ||||||
| typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; | ||||||
| typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; | ||||||
|   | |||||||
| @@ -1 +0,0 @@ | |||||||
| /* not used */ |  | ||||||
| @@ -122,3 +122,5 @@ if(WIN32) | |||||||
|     set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib") |     set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib") | ||||||
|   endif() |   endif() | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
|  | install(TARGETS ${LIB_NAME} DESTINATION lib) | ||||||
|   | |||||||
| @@ -70,6 +70,13 @@ CFLAGS += -d_WIN32_WINNT=0x0501 -dENABLE_IPV6 | |||||||
| CFLAGS += -dUSE_WINDOWS_SSPI | CFLAGS += -dUSE_WINDOWS_SSPI | ||||||
| !endif | !endif | ||||||
|  |  | ||||||
|  | !ifdef %use_winidn | ||||||
|  | CFLAGS += -dWINVER=0x0600 -dUSE_WIN32_IDN | ||||||
|  | !  if $(__VERSION__) <= 1290 | ||||||
|  | CFLAGS += -dWANT_IDN_PROTOTYPES | ||||||
|  | !  endif | ||||||
|  | !endif | ||||||
|  |  | ||||||
| # | # | ||||||
| # Change to suite. | # Change to suite. | ||||||
| # | # | ||||||
| @@ -82,7 +89,7 @@ ZLIB_ROOT = ..$(DS)..$(DS)zlib-1.2.5 | |||||||
| !ifdef %libssh2_root | !ifdef %libssh2_root | ||||||
| LIBSSH2_ROOT = $(%libssh2_root) | LIBSSH2_ROOT = $(%libssh2_root) | ||||||
| !else | !else | ||||||
| LIBSSH2_ROOT = ..$(DS)..$(DS)libssh2-1.2.7 | LIBSSH2_ROOT = ..$(DS)..$(DS)libssh2-1.2.8 | ||||||
| !endif | !endif | ||||||
|  |  | ||||||
| !ifdef %librtmp_root | !ifdef %librtmp_root | ||||||
| @@ -229,6 +236,14 @@ $(LINK_ARG): $(__MAKEFILES__) | |||||||
| !ifdef %use_ares | !ifdef %use_ares | ||||||
| 	@%append $^@ library $(ARES_ROOT)$(DS)cares.lib | 	@%append $^@ library $(ARES_ROOT)$(DS)cares.lib | ||||||
| !endif | !endif | ||||||
|  | !ifdef %use_winidn | ||||||
|  | !  if $(__VERSION__) > 1290 | ||||||
|  | 	@%append $^@ library normaliz.lib | ||||||
|  | !  else | ||||||
|  | 	@%append $^@ import '_IdnToAscii@20' 'NORMALIZ.DLL'.'IdnToAscii' | ||||||
|  | 	@%append $^@ import '_IdnToUnicode@20' 'NORMALIZ.DLL'.'IdnToUnicode' | ||||||
|  | !  endif | ||||||
|  | !endif | ||||||
|  |  | ||||||
| $(LIB_ARG): $(__MAKEFILES__) | $(LIB_ARG): $(__MAKEFILES__) | ||||||
| 	%create $^@ | 	%create $^@ | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ EXTRA_DIST = Makefile.b32 Makefile.m32 Makefile.vc6 $(DSP)                 \ | |||||||
|  config-win32ce.h config-os400.h setup-os400.h config-symbian.h		   \ |  config-win32ce.h config-os400.h setup-os400.h config-symbian.h		   \ | ||||||
|  Makefile.Watcom config-tpf.h $(DOCS) $(VCPROJ) mk-ca-bundle.pl		   \ |  Makefile.Watcom config-tpf.h $(DOCS) $(VCPROJ) mk-ca-bundle.pl		   \ | ||||||
|  mk-ca-bundle.vbs firefox-db2pem.sh $(CMAKE_DIST) config-vxworks.h	   \ |  mk-ca-bundle.vbs firefox-db2pem.sh $(CMAKE_DIST) config-vxworks.h	   \ | ||||||
|  Makefile.vxworks config-vms.h |  Makefile.vxworks config-vms.h checksrc.pl | ||||||
|  |  | ||||||
| CLEANFILES = $(DSP) $(VCPROJ) | CLEANFILES = $(DSP) $(VCPROJ) | ||||||
|  |  | ||||||
| @@ -46,7 +46,7 @@ lib_LTLIBRARIES = libcurl.la | |||||||
| LIBCURL_LIBS = @LIBCURL_LIBS@ | LIBCURL_LIBS = @LIBCURL_LIBS@ | ||||||
|  |  | ||||||
| # This might hold -Werror | # This might hold -Werror | ||||||
| libcurl_la_CFLAGS = $(CFLAGS) @CURL_CFLAG_EXTRAS@ | CFLAGS += @CURL_CFLAG_EXTRAS@ | ||||||
|  |  | ||||||
| # Specify our include paths here, and do it relative to $(top_srcdir) and | # Specify our include paths here, and do it relative to $(top_srcdir) and | ||||||
| # $(top_builddir), to ensure that these paths which belong to the library | # $(top_builddir), to ensure that these paths which belong to the library | ||||||
| @@ -106,7 +106,7 @@ endif | |||||||
| # For the full guide on libcurl ABI rules, see docs/libcurl/ABI | # For the full guide on libcurl ABI rules, see docs/libcurl/ABI | ||||||
|  |  | ||||||
| if NO_UNDEFINED | if NO_UNDEFINED | ||||||
| # The -no-undefined flag is CRUCIAL for this to build fine on Cygwin. | # The -no-undefined flag is crucial to build fine on some platforms | ||||||
| UNDEF = -no-undefined | UNDEF = -no-undefined | ||||||
| endif | endif | ||||||
|  |  | ||||||
| @@ -116,18 +116,18 @@ if MIMPURE | |||||||
| MIMPURE = -mimpure-text | MIMPURE = -mimpure-text | ||||||
| endif | endif | ||||||
|  |  | ||||||
| LINKFLAGS=$(UNDEF) $(MIMPURE) $(LIBCURL_LIBS) | libcurl_la_LDFLAGS = $(UNDEF) $(VERSIONINFO) $(MIMPURE) $(LIBCURL_LIBS) | ||||||
|  |  | ||||||
| libcurl_la_LDFLAGS = $(LINKFLAGS) $(VERSIONINFO) | # unit testing static library built only along with unit tests | ||||||
|  | if BUILD_UNITTESTS | ||||||
| # as unit testing will compile and link everything an extra time, we only |  | ||||||
| # do it if debug is enabled |  | ||||||
| if CURLDEBUG |  | ||||||
| noinst_LTLIBRARIES = libcurlu.la | noinst_LTLIBRARIES = libcurlu.la | ||||||
| libcurlu_la_CFLAGS = -DUNITTESTS | else | ||||||
| libcurlu_la_LDFLAGS = -static $(LINKFLAGS) | noinst_LTLIBRARIES = | ||||||
| endif | endif | ||||||
|  |  | ||||||
|  | libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DUNITTESTS | ||||||
|  | libcurlu_la_LDFLAGS = -static $(LIBCURL_LIBS) | ||||||
|  |  | ||||||
| # Makefile.inc provides the CSOURCES and HHEADERS defines | # Makefile.inc provides the CSOURCES and HHEADERS defines | ||||||
| include Makefile.inc | include Makefile.inc | ||||||
|  |  | ||||||
| @@ -184,3 +184,12 @@ $(VCPROJ): vc8proj.head vc8proj.foot Makefile.am | |||||||
| 	echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \ | 	echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \ | ||||||
| 	done; \ | 	done; \ | ||||||
| 	cat $(srcdir)/vc8proj.foot $(VCPROJOUT) ) | 	cat $(srcdir)/vc8proj.foot $(VCPROJOUT) ) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | checksrc: | ||||||
|  | 	@@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/lib $(CSOURCES) $(HHEADERS) | ||||||
|  |  | ||||||
|  | if CURLDEBUG | ||||||
|  | # for debug builds, we scan the sources on all regular make invokes | ||||||
|  | all-local: checksrc | ||||||
|  | endif | ||||||
|   | |||||||
| @@ -15,13 +15,14 @@ CSOURCES = file.c timeval.c base64.c hostip.c progress.c formdata.c	\ | |||||||
|   memdebug.c http_chunks.c strtok.c connect.c llist.c hash.c multi.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 curl_rand.c	\ |   content_encoding.c share.c http_digest.c md4.c md5.c curl_rand.c	\ | ||||||
|   http_negotiate.c http_ntlm.c inet_pton.c strtoofft.c strerror.c	\ |   http_negotiate.c http_ntlm.c inet_pton.c strtoofft.c strerror.c	\ | ||||||
|   hostares.c hostasyn.c hostip4.c hostip6.c hostsyn.c hostthre.c	\ |   hostasyn.c hostip4.c hostip6.c hostsyn.c inet_ntop.c parsedate.c	\ | ||||||
|   inet_ntop.c parsedate.c select.c gtls.c sslgen.c tftp.c splay.c	\ |   select.c gtls.c sslgen.c tftp.c splay.c strdup.c socks.c ssh.c nss.c	\ | ||||||
|   strdup.c socks.c ssh.c nss.c qssl.c rawstr.c curl_addrinfo.c		\ |   qssl.c rawstr.c curl_addrinfo.c socks_gssapi.c socks_sspi.c		\ | ||||||
|   socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c		\ |   curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c	\ | ||||||
|   curl_memrchr.c imap.c pop3.c smtp.c pingpong.c rtsp.c curl_threads.c	\ |   pingpong.c rtsp.c curl_threads.c warnless.c hmac.c polarssl.c		\ | ||||||
|   warnless.c hmac.c polarssl.c curl_rtmp.c openldap.c curl_gethostname.c\ |   curl_rtmp.c openldap.c curl_gethostname.c gopher.c axtls.c		\ | ||||||
|   gopher.c axtls.c idn_win32.c http_negotiate_sspi.c cyassl.c http_proxy.c |   idn_win32.c http_negotiate_sspi.c cyassl.c http_proxy.c non-ascii.c	\ | ||||||
|  |   asyn-ares.c asyn-thread.c | ||||||
|  |  | ||||||
| HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h	\ | 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	\ |   progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h	\ | ||||||
| @@ -36,5 +37,4 @@ HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h	\ | |||||||
|   curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h nonblock.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	\ |   curl_memrchr.h imap.h pop3.h smtp.h pingpong.h rtsp.h curl_threads.h	\ | ||||||
|   warnless.h curl_hmac.h polarssl.h curl_rtmp.h curl_gethostname.h	\ |   warnless.h curl_hmac.h polarssl.h curl_rtmp.h curl_gethostname.h	\ | ||||||
|   gopher.h axtls.h cyassl.h http_proxy.h |   gopher.h axtls.h cyassl.h http_proxy.h non-ascii.h asyn.h | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| ######################################################################### | ######################################################################### | ||||||
| # | # | ||||||
| ## Makefile for building libcurl.a with MingW32 (GCC-3.2 or later) | ## Makefile for building libcurl.a with MingW32 (GCC-3.2 or later) | ||||||
| ## and optionally OpenSSL (0.9.8), libssh2 (1.2), zlib (1.2.5) | ## and optionally OpenSSL (0.9.8), libssh2 (1.2), zlib (1.2.5), librtmp (2.3) | ||||||
| ## | ## | ||||||
| ## Usage: | ## Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...] | ||||||
| ## mingw32-make -f Makefile.m32 [SSL=1] [SSH2=1] [ZLIB=1] [IDN=1] [SSPI=1] [IPV6=1] [LDAPS=1] [RTMP=1] [DYN=1] | ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn | ||||||
| ## | ## | ||||||
| ## Hint: you can also set environment vars to control the build, f.e.: | ## Hint: you can also set environment vars to control the build, f.e.: | ||||||
| ## set ZLIB_PATH=c:/zlib-1.2.5 | ## set ZLIB_PATH=c:/zlib-1.2.5 | ||||||
| @@ -24,15 +24,21 @@ OPENSSL_PATH = ../../openssl-0.9.8r | |||||||
| endif | endif | ||||||
| # Edit the path below to point to the base of your LibSSH2 package. | # Edit the path below to point to the base of your LibSSH2 package. | ||||||
| ifndef LIBSSH2_PATH | ifndef LIBSSH2_PATH | ||||||
| LIBSSH2_PATH = ../../libssh2-1.2.7 | LIBSSH2_PATH = ../../libssh2-1.2.8 | ||||||
|  | endif | ||||||
|  | # Edit the path below to point to the base of your librtmp package. | ||||||
|  | ifndef LIBRTMP_PATH | ||||||
|  | LIBRTMP_PATH = ../../librtmp-2.3 | ||||||
| endif | endif | ||||||
| # Edit the path below to point to the base of your libidn package. | # Edit the path below to point to the base of your libidn package. | ||||||
| ifndef LIBIDN_PATH | ifndef LIBIDN_PATH | ||||||
| LIBIDN_PATH = ../../libidn-1.18 | LIBIDN_PATH = ../../libidn-1.18 | ||||||
| endif | endif | ||||||
| # Edit the path below to point to the base of your librtmp package. | # Edit the path below to point to the base of your MS idndlpackage.  | ||||||
| ifndef LIBRTMP_PATH | # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1 | ||||||
| LIBRTMP_PATH = ../../librtmp-2.3 | # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815 | ||||||
|  | ifndef WINIDN_PATH | ||||||
|  | WINIDN_PATH = ../../Microsoft IDN Mitigation APIs | ||||||
| endif | endif | ||||||
| # Edit the path below to point to the base of your Novell LDAP NDK. | # Edit the path below to point to the base of your Novell LDAP NDK. | ||||||
| ifndef LDAP_SDK | ifndef LDAP_SDK | ||||||
| @@ -45,9 +51,10 @@ LIBCARES_PATH = ../ares | |||||||
| endif | endif | ||||||
|  |  | ||||||
| CC = gcc | CC = gcc | ||||||
| AR = ar | CFLAGS = -g -O2 -Wall | ||||||
| # comment LDFLAGS below to keep debug info | # comment LDFLAGS below to keep debug info | ||||||
| LDFLAGS = -s | LDFLAGS = -s | ||||||
|  | AR = ar | ||||||
| RANLIB = ranlib | RANLIB = ranlib | ||||||
| RC = windres | RC = windres | ||||||
| RCFLAGS = --include-dir=../include -DDEBUGBUILD=0 -O COFF -i | RCFLAGS = --include-dir=../include -DDEBUGBUILD=0 -O COFF -i | ||||||
| @@ -57,8 +64,46 @@ STRIP = strip -g | |||||||
| ######################################################## | ######################################################## | ||||||
| ## Nothing more to do below this line! | ## Nothing more to do below this line! | ||||||
|  |  | ||||||
|  | ifeq ($(findstring -dyn,$(CFG)),-dyn) | ||||||
|  | DYN = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -ares,$(CFG)),-ares) | ||||||
|  | ARES = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -rtmp,$(CFG)),-rtmp) | ||||||
|  | RTMP = 1 | ||||||
|  | SSL = 1 | ||||||
|  | ZLIB = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -ssh2,$(CFG)),-ssh2) | ||||||
|  | SSH2 = 1 | ||||||
|  | SSL = 1 | ||||||
|  | ZLIB = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -ssl,$(CFG)),-ssl) | ||||||
|  | SSL = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -zlib,$(CFG)),-zlib) | ||||||
|  | ZLIB = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -idn,$(CFG)),-idn) | ||||||
|  | IDN = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -winidn,$(CFG)),-winidn) | ||||||
|  | WINIDN = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -sspi,$(CFG)),-sspi) | ||||||
|  | SSPI = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -ldaps,$(CFG)),-ldaps) | ||||||
|  | LDAPS = 1 | ||||||
|  | endif | ||||||
|  | ifeq ($(findstring -ipv6,$(CFG)),-ipv6) | ||||||
|  | IPV6 = 1 | ||||||
|  | endif | ||||||
|  |  | ||||||
| INCLUDES = -I. -I../include | INCLUDES = -I. -I../include | ||||||
| CFLAGS = -g -O2 -DBUILDING_LIBCURL | CFLAGS += -DBUILDING_LIBCURL | ||||||
| ifdef ARES | ifdef ARES | ||||||
|   INCLUDES += -I$(LIBCARES_PATH) |   INCLUDES += -I$(LIBCARES_PATH) | ||||||
|   CFLAGS += -DUSE_ARES |   CFLAGS += -DUSE_ARES | ||||||
| @@ -91,6 +136,13 @@ ifdef IDN | |||||||
|   INCLUDES += -I"$(LIBIDN_PATH)/include" |   INCLUDES += -I"$(LIBIDN_PATH)/include" | ||||||
|   CFLAGS += -DUSE_LIBIDN |   CFLAGS += -DUSE_LIBIDN | ||||||
|   DLL_LIBS += -L$(LIBIDN_PATH)/lib -lidn |   DLL_LIBS += -L$(LIBIDN_PATH)/lib -lidn | ||||||
|  | else | ||||||
|  | ifdef WINIDN | ||||||
|  |   INCLUDES += -I"$(WINIDN_PATH)/include" | ||||||
|  |   CFLAGS += -DHAVE_NORMALIZATION_H | ||||||
|  |   CFLAGS += -DUSE_WIN32_IDN | ||||||
|  |   DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz | ||||||
|  | endif | ||||||
| endif | endif | ||||||
| ifdef SSPI | ifdef SSPI | ||||||
|   CFLAGS += -DUSE_WINDOWS_SSPI |   CFLAGS += -DUSE_WINDOWS_SSPI | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ endif | |||||||
|  |  | ||||||
| # Edit the path below to point to the base of your LibSSH2 package. | # Edit the path below to point to the base of your LibSSH2 package. | ||||||
| ifndef LIBSSH2_PATH | ifndef LIBSSH2_PATH | ||||||
| LIBSSH2_PATH = ../../libssh2-1.2.7 | LIBSSH2_PATH = ../../libssh2-1.2.8 | ||||||
| endif | endif | ||||||
|  |  | ||||||
| # Edit the path below to point to the base of your axTLS package. | # Edit the path below to point to the base of your axTLS package. | ||||||
|   | |||||||
| @@ -101,7 +101,7 @@ CCNODBG    = cl.exe /O2 /DNDEBUG | |||||||
| CCDEBUG    = cl.exe /Od /Gm /Zi /D_DEBUG /GZ | CCDEBUG    = cl.exe /Od /Gm /Zi /D_DEBUG /GZ | ||||||
| CFLAGSSSL  = /DUSE_SSLEAY /I "$(OPENSSL_PATH)/inc32" /I "$(OPENSSL_PATH)/inc32/openssl" | CFLAGSSSL  = /DUSE_SSLEAY /I "$(OPENSSL_PATH)/inc32" /I "$(OPENSSL_PATH)/inc32/openssl" | ||||||
| CFLAGSZLIB = /DHAVE_ZLIB_H /DHAVE_ZLIB /DHAVE_LIBZ /I "$(ZLIB_PATH)" | CFLAGSZLIB = /DHAVE_ZLIB_H /DHAVE_ZLIB /DHAVE_LIBZ /I "$(ZLIB_PATH)" | ||||||
| CFLAGS     = /I. /I../include /nologo /W3 /GX /DWIN32 /YX /FD /c /DBUILDING_LIBCURL | CFLAGS     = /I. /I../include /nologo /W3 /GX /DWIN32 /YX /FD /c /DBUILDING_LIBCURL /D_BIND_TO_CURRENT_VCLIBS_VERSION=1 | ||||||
| CFLAGSLIB  = /DCURL_STATICLIB | CFLAGSLIB  = /DCURL_STATICLIB | ||||||
| LNKDLL     = link.exe /DLL | LNKDLL     = link.exe /DLL | ||||||
| LNKLIB     = link.exe /lib | LNKLIB     = link.exe /lib | ||||||
| @@ -457,6 +457,8 @@ clean: | |||||||
| # A config was provided, so the library can be built. | # A config was provided, so the library can be built. | ||||||
| # | # | ||||||
| X_OBJS= \ | X_OBJS= \ | ||||||
|  | 	$(DIROBJ)\asyn-ares.obj \ | ||||||
|  | 	$(DIROBJ)\asyn-thread.obj \ | ||||||
| 	$(DIROBJ)\base64.obj \ | 	$(DIROBJ)\base64.obj \ | ||||||
| 	$(DIROBJ)\connect.obj \ | 	$(DIROBJ)\connect.obj \ | ||||||
| 	$(DIROBJ)\content_encoding.obj \ | 	$(DIROBJ)\content_encoding.obj \ | ||||||
| @@ -479,17 +481,15 @@ X_OBJS= \ | |||||||
| 	$(DIROBJ)\ftp.obj \ | 	$(DIROBJ)\ftp.obj \ | ||||||
| 	$(DIROBJ)\getenv.obj \ | 	$(DIROBJ)\getenv.obj \ | ||||||
| 	$(DIROBJ)\getinfo.obj \ | 	$(DIROBJ)\getinfo.obj \ | ||||||
| 	$(DIROBJ)\gtls.obj \ |  | ||||||
| 	$(DIROBJ)\gopher.obj \ | 	$(DIROBJ)\gopher.obj \ | ||||||
|  | 	$(DIROBJ)\gtls.obj \ | ||||||
| 	$(DIROBJ)\hash.obj \ | 	$(DIROBJ)\hash.obj \ | ||||||
| 	$(DIROBJ)\hmac.obj \ | 	$(DIROBJ)\hmac.obj \ | ||||||
| 	$(DIROBJ)\hostares.obj \ |  | ||||||
| 	$(DIROBJ)\hostasyn.obj \ | 	$(DIROBJ)\hostasyn.obj \ | ||||||
| 	$(DIROBJ)\hostip4.obj \ | 	$(DIROBJ)\hostip4.obj \ | ||||||
| 	$(DIROBJ)\hostip6.obj \ | 	$(DIROBJ)\hostip6.obj \ | ||||||
| 	$(DIROBJ)\hostip.obj \ | 	$(DIROBJ)\hostip.obj \ | ||||||
| 	$(DIROBJ)\hostsyn.obj \ | 	$(DIROBJ)\hostsyn.obj \ | ||||||
| 	$(DIROBJ)\hostthre.obj \ |  | ||||||
| 	$(DIROBJ)\http_chunks.obj \ | 	$(DIROBJ)\http_chunks.obj \ | ||||||
| 	$(DIROBJ)\http_digest.obj \ | 	$(DIROBJ)\http_digest.obj \ | ||||||
| 	$(DIROBJ)\http_negotiate.obj \ | 	$(DIROBJ)\http_negotiate.obj \ | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #Description: makefile to be used in order to compile libcurl for VxWoorks 6.3. | #Description: makefile to be used in order to compile libcurl for VxWoorks 6.3. | ||||||
| # | # | ||||||
| #How to use: | #How to use: | ||||||
| #             1. Adjust environment variables at the file begining | #             1. Adjust environment variables at the file beginning | ||||||
| #             2. Open the Command Prompt window and change directory ('cd') | #             2. Open the Command Prompt window and change directory ('cd') | ||||||
| #                into the 'lib' folder | #                into the 'lib' folder | ||||||
| #             3. Add <CYGWIN>/bin folder to the PATH environment variable | #             3. Add <CYGWIN>/bin folder to the PATH environment variable | ||||||
|   | |||||||
| @@ -33,21 +33,21 @@ Gallagher, and support for the 'gzip' encoding was added by Dan Fandrich. | |||||||
|  |  | ||||||
| To cause libcurl to request a content encoding use: | To cause libcurl to request a content encoding use: | ||||||
|  |  | ||||||
|     curl_easy_setopt(curl, CURLOPT_ENCODING, <string>) |     curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, <string>) | ||||||
|  |  | ||||||
| where <string> is the intended value of the Accept-Encoding header. | where <string> is the intended value of the Accept-Encoding header. | ||||||
|  |  | ||||||
| Currently, libcurl only understands how to process responses that use the | Currently, libcurl only understands how to process responses that use the | ||||||
| "deflate" or "gzip" Content-Encoding, so the only values for CURLOPT_ENCODING | "deflate" or "gzip" Content-Encoding, so the only values for | ||||||
| that will work (besides "identity," which does nothing) are "deflate" and | CURLOPT_ACCEPT_ENCODING that will work (besides "identity," which does | ||||||
| "gzip" If a response is encoded using the "compress" or methods, libcurl will | nothing) are "deflate" and "gzip" If a response is encoded using the | ||||||
| return an error indicating that the response could not be decoded.  If | "compress" or methods, libcurl will return an error indicating that the | ||||||
| <string> is NULL no Accept-Encoding header is generated.  If <string> is a | response could not be decoded.  If <string> is NULL no Accept-Encoding header | ||||||
| zero-length string, then an Accept-Encoding header containing all supported | is generated.  If <string> is a zero-length string, then an Accept-Encoding | ||||||
| encodings will be generated. | header containing all supported encodings will be generated. | ||||||
|  |  | ||||||
| The CURLOPT_ENCODING must be set to any non-NULL value for content to be | The CURLOPT_ACCEPT_ENCODING must be set to any non-NULL value for content to | ||||||
| automatically decoded.  If it is not set and the server still sends encoded | be automatically decoded.  If it is not set and the server still sends encoded | ||||||
| content (despite not having been asked), the data is returned in its raw form | content (despite not having been asked), the data is returned in its raw form | ||||||
| and the Content-Encoding type is not checked. | and the Content-Encoding type is not checked. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ | |||||||
|  * Telnet option defines. Add more here if in need. |  * Telnet option defines. Add more here if in need. | ||||||
|  */ |  */ | ||||||
| #define CURL_TELOPT_BINARY   0  /* binary 8bit data */ | #define CURL_TELOPT_BINARY   0  /* binary 8bit data */ | ||||||
| #define CURL_TELOPT_SGA      3  /* Supress Go Ahead */ | #define CURL_TELOPT_SGA      3  /* Suppress Go Ahead */ | ||||||
| #define CURL_TELOPT_EXOPL  255  /* EXtended OPtions List */ | #define CURL_TELOPT_EXOPL  255  /* EXtended OPtions List */ | ||||||
| #define CURL_TELOPT_TTYPE   24  /* Terminal TYPE */ | #define CURL_TELOPT_TTYPE   24  /* Terminal TYPE */ | ||||||
| #define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */ | #define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */ | ||||||
|   | |||||||
| @@ -60,6 +60,14 @@ | |||||||
| #define in_addr_t unsigned long | #define in_addr_t unsigned long | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | /***********************************************************************
 | ||||||
|  |  * Only for ares-enabled builds | ||||||
|  |  * And only for functions that fulfill the asynch resolver backend API | ||||||
|  |  * as defined in asyn.h, nothing else belongs in this file! | ||||||
|  |  **********************************************************************/ | ||||||
|  | 
 | ||||||
|  | #ifdef CURLRES_ARES | ||||||
|  | 
 | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| #include "sendf.h" | #include "sendf.h" | ||||||
| #include "hostip.h" | #include "hostip.h" | ||||||
| @@ -76,18 +84,140 @@ | |||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| 
 | 
 | ||||||
|  | #  if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \ | ||||||
|  |      (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) | ||||||
|  | #    define CARES_STATICLIB | ||||||
|  | #  endif | ||||||
|  | #  include <ares.h> | ||||||
|  | 
 | ||||||
|  | #if ARES_VERSION >= 0x010500 | ||||||
|  | /* c-ares 1.5.0 or later, the callback proto is modified */ | ||||||
|  | #define HAVE_CARES_CALLBACK_TIMEOUTS 1 | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #include "curl_memory.h" | #include "curl_memory.h" | ||||||
| /* The last #include file should be: */ | /* The last #include file should be: */ | ||||||
| #include "memdebug.h" | #include "memdebug.h" | ||||||
| 
 | 
 | ||||||
| /***********************************************************************
 | struct ResolverResults { | ||||||
|  * Only for ares-enabled builds |   int num_pending; /* number of ares_gethostbyname() requests */ | ||||||
|  **********************************************************************/ |   Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares parts */ | ||||||
| 
 |   int last_status; | ||||||
| #ifdef CURLRES_ARES | }; | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_resolv_fdset() is called when someone from the outside world (using |  * Curl_resolver_global_init() - the generic low-level asynchronous name | ||||||
|  |  * resolve API.  Called from curl_global_init() to initialize global resolver | ||||||
|  |  * environment.  Initializes ares library. | ||||||
|  |  */ | ||||||
|  | int Curl_resolver_global_init(void) | ||||||
|  | { | ||||||
|  | #ifdef CARES_HAVE_ARES_LIBRARY_INIT | ||||||
|  |   if(ares_library_init(ARES_LIB_INIT_ALL)) { | ||||||
|  |     return CURLE_FAILED_INIT; | ||||||
|  |   } | ||||||
|  | #endif | ||||||
|  |   return CURLE_OK; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_global_cleanup() | ||||||
|  |  * | ||||||
|  |  * Called from curl_global_cleanup() to destroy global resolver environment. | ||||||
|  |  * Deinitializes ares library. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_global_cleanup(void) | ||||||
|  | { | ||||||
|  | #ifdef CARES_HAVE_ARES_LIBRARY_CLEANUP | ||||||
|  |   ares_library_cleanup(); | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_init() | ||||||
|  |  * | ||||||
|  |  * Called from curl_easy_init() -> Curl_open() to initialize resolver | ||||||
|  |  * URL-state specific environment ('resolver' member of the UrlState | ||||||
|  |  * structure).  Fills the passed pointer by the initialized ares_channel. | ||||||
|  |  */ | ||||||
|  | CURLcode Curl_resolver_init(void **resolver) | ||||||
|  | { | ||||||
|  |   int status = ares_init((ares_channel*)resolver); | ||||||
|  |   if(status != ARES_SUCCESS) { | ||||||
|  |     if(status == ARES_ENOMEM) | ||||||
|  |       return CURLE_OUT_OF_MEMORY; | ||||||
|  |     else | ||||||
|  |       return CURLE_FAILED_INIT; | ||||||
|  |   } | ||||||
|  |   return CURLE_OK; | ||||||
|  |   /* make sure that all other returns from this function should destroy the
 | ||||||
|  |      ares channel before returning error! */ | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_cleanup() | ||||||
|  |  * | ||||||
|  |  * Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver | ||||||
|  |  * URL-state specific environment ('resolver' member of the UrlState | ||||||
|  |  * structure).  Destroys the ares channel. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_cleanup(void *resolver) | ||||||
|  | { | ||||||
|  |   ares_destroy((ares_channel)resolver); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_duphandle() | ||||||
|  |  * | ||||||
|  |  * Called from curl_easy_duphandle() to duplicate resolver URL-state specific | ||||||
|  |  * environment ('resolver' member of the UrlState structure).  Duplicates the | ||||||
|  |  * 'from' ares channel and passes the resulting channel to the 'to' pointer. | ||||||
|  |  */ | ||||||
|  | int Curl_resolver_duphandle(void **to, void *from) | ||||||
|  | { | ||||||
|  |   /* Clone the ares channel for the new handle */ | ||||||
|  |   if(ARES_SUCCESS != ares_dup((ares_channel*)to,(ares_channel)from)) | ||||||
|  |     return CURLE_FAILED_INIT; | ||||||
|  |   return CURLE_OK; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void destroy_async_data (struct Curl_async *async); | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Cancel all possibly still on-going resolves for this connection. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_cancel(struct connectdata *conn) | ||||||
|  | { | ||||||
|  |   if(conn && conn->data && conn->data->state.resolver) | ||||||
|  |     ares_cancel((ares_channel)conn->data->state.resolver); | ||||||
|  |   destroy_async_data(&conn->async); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * destroy_async_data() cleans up async resolver data. | ||||||
|  |  */ | ||||||
|  | static void destroy_async_data (struct Curl_async *async) | ||||||
|  | { | ||||||
|  |   if(async->hostname) | ||||||
|  |     free(async->hostname); | ||||||
|  | 
 | ||||||
|  |   if(async->os_specific) { | ||||||
|  |     struct ResolverResults *res = (struct ResolverResults *)async->os_specific; | ||||||
|  |     if(res) { | ||||||
|  |       if(res->temp_ai) { | ||||||
|  |         Curl_freeaddrinfo(res->temp_ai); | ||||||
|  |         res->temp_ai = NULL; | ||||||
|  |       } | ||||||
|  |       free(res); | ||||||
|  |     } | ||||||
|  |     async->os_specific = NULL; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   async->hostname = NULL; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_fdset() is called when someone from the outside world (using | ||||||
|  * curl_multi_fdset()) wants to get our fd_set setup and we're talking with |  * curl_multi_fdset()) wants to get our fd_set setup and we're talking with | ||||||
|  * ares. The caller must make sure that this function is only called when we |  * ares. The caller must make sure that this function is only called when we | ||||||
|  * have a working ares channel. |  * have a working ares channel. | ||||||
| @@ -95,7 +225,7 @@ | |||||||
|  * Returns: CURLE_OK always! |  * Returns: CURLE_OK always! | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| int Curl_resolv_getsock(struct connectdata *conn, | int Curl_resolver_getsock(struct connectdata *conn, | ||||||
|                           curl_socket_t *socks, |                           curl_socket_t *socks, | ||||||
|                           int numsocks) |                           int numsocks) | ||||||
| 
 | 
 | ||||||
| @@ -103,14 +233,15 @@ int Curl_resolv_getsock(struct connectdata *conn, | |||||||
|   struct timeval maxtime; |   struct timeval maxtime; | ||||||
|   struct timeval timebuf; |   struct timeval timebuf; | ||||||
|   struct timeval *timeout; |   struct timeval *timeout; | ||||||
|   int max = ares_getsock(conn->data->state.areschannel, |   int max = ares_getsock((ares_channel)conn->data->state.resolver, | ||||||
|                          (ares_socket_t *)socks, numsocks); |                          (ares_socket_t *)socks, numsocks); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|   maxtime.tv_sec = CURL_TIMEOUT_RESOLVE; |   maxtime.tv_sec = CURL_TIMEOUT_RESOLVE; | ||||||
|   maxtime.tv_usec = 0; |   maxtime.tv_usec = 0; | ||||||
| 
 | 
 | ||||||
|   timeout = ares_timeout(conn->data->state.areschannel, &maxtime, &timebuf); |   timeout = ares_timeout((ares_channel)conn->data->state.resolver, &maxtime, | ||||||
|  |                          &timebuf); | ||||||
| 
 | 
 | ||||||
|   Curl_expire(conn->data, |   Curl_expire(conn->data, | ||||||
|               (timeout->tv_sec * 1000) + (timeout->tv_usec/1000)); |               (timeout->tv_sec * 1000) + (timeout->tv_usec/1000)); | ||||||
| @@ -138,7 +269,8 @@ static int waitperform(struct connectdata *conn, int timeout_ms) | |||||||
|   int i; |   int i; | ||||||
|   int num = 0; |   int num = 0; | ||||||
| 
 | 
 | ||||||
|   bitmask = ares_getsock(data->state.areschannel, socks, ARES_GETSOCK_MAXNUM); |   bitmask = ares_getsock((ares_channel)data->state.resolver, socks, | ||||||
|  |                          ARES_GETSOCK_MAXNUM); | ||||||
| 
 | 
 | ||||||
|   for(i=0; i < ARES_GETSOCK_MAXNUM; i++) { |   for(i=0; i < ARES_GETSOCK_MAXNUM; i++) { | ||||||
|     pfd[i].events = 0; |     pfd[i].events = 0; | ||||||
| @@ -165,11 +297,12 @@ static int waitperform(struct connectdata *conn, int timeout_ms) | |||||||
|   if(!nfds) |   if(!nfds) | ||||||
|     /* Call ares_process() unconditonally here, even if we simply timed out
 |     /* Call ares_process() unconditonally here, even if we simply timed out
 | ||||||
|        above, as otherwise the ares name resolve won't timeout! */ |        above, as otherwise the ares name resolve won't timeout! */ | ||||||
|     ares_process_fd(data->state.areschannel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); |     ares_process_fd((ares_channel)data->state.resolver, ARES_SOCKET_BAD, | ||||||
|  |                     ARES_SOCKET_BAD); | ||||||
|   else { |   else { | ||||||
|     /* move through the descriptors and ask for processing on them */ |     /* move through the descriptors and ask for processing on them */ | ||||||
|     for(i=0; i < num; i++) |     for(i=0; i < num; i++) | ||||||
|       ares_process_fd(data->state.areschannel, |       ares_process_fd((ares_channel)data->state.resolver, | ||||||
|                       pfd[i].revents & (POLLRDNORM|POLLIN)? |                       pfd[i].revents & (POLLRDNORM|POLLIN)? | ||||||
|                       pfd[i].fd:ARES_SOCKET_BAD, |                       pfd[i].fd:ARES_SOCKET_BAD, | ||||||
|                       pfd[i].revents & (POLLWRNORM|POLLOUT)? |                       pfd[i].revents & (POLLWRNORM|POLLOUT)? | ||||||
| @@ -179,23 +312,29 @@ static int waitperform(struct connectdata *conn, int timeout_ms) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_is_resolved() is called repeatedly to check if a previous name resolve |  * Curl_resolver_is_resolved() is called repeatedly to check if a previous | ||||||
|  * request has completed. It should also make sure to time-out if the |  * name resolve request has completed. It should also make sure to time-out if | ||||||
|  * operation seems to take too long. |  * the operation seems to take too long. | ||||||
|  * |  * | ||||||
|  * Returns normal CURLcode errors. |  * Returns normal CURLcode errors. | ||||||
|  */ |  */ | ||||||
| CURLcode Curl_is_resolved(struct connectdata *conn, | CURLcode Curl_resolver_is_resolved(struct connectdata *conn, | ||||||
|                                    struct Curl_dns_entry **dns) |                                    struct Curl_dns_entry **dns) | ||||||
| { | { | ||||||
|   struct SessionHandle *data = conn->data; |   struct SessionHandle *data = conn->data; | ||||||
|  |   struct ResolverResults *res = (struct ResolverResults *) | ||||||
|  |     conn->async.os_specific; | ||||||
| 
 | 
 | ||||||
|   *dns = NULL; |   *dns = NULL; | ||||||
| 
 | 
 | ||||||
|   waitperform(conn, 0); |   waitperform(conn, 0); | ||||||
| 
 | 
 | ||||||
|   if(conn->async.done) { |   if(res && !res->num_pending) { | ||||||
|     /* we're done, kill the ares handle */ |     (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai); | ||||||
|  |     /* temp_ai ownership is moved to the connection, so we need not free-up
 | ||||||
|  |        them */ | ||||||
|  |     res->temp_ai = NULL; | ||||||
|  |     destroy_async_data(&conn->async); | ||||||
|     if(!conn->async.dns) { |     if(!conn->async.dns) { | ||||||
|       failf(data, "Could not resolve host: %s (%s)", conn->host.dispname, |       failf(data, "Could not resolve host: %s (%s)", conn->host.dispname, | ||||||
|             ares_strerror(conn->async.status)); |             ares_strerror(conn->async.status)); | ||||||
| @@ -208,21 +347,24 @@ CURLcode Curl_is_resolved(struct connectdata *conn, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_wait_for_resolv() waits for a resolve to finish. This function should |  * Curl_resolver_wait_resolv() | ||||||
|  * be avoided since using this risk getting the multi interface to "hang". |  * | ||||||
|  |  * waits for a resolve to finish. This function should be avoided since using | ||||||
|  |  * this risk getting the multi interface to "hang". | ||||||
|  * |  * | ||||||
|  * If 'entry' is non-NULL, make it point to the resolved dns entry |  * If 'entry' is non-NULL, make it point to the resolved dns entry | ||||||
|  * |  * | ||||||
|  * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved, and |  * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved, and | ||||||
|  * CURLE_OPERATION_TIMEDOUT if a time-out occurred. |  * CURLE_OPERATION_TIMEDOUT if a time-out occurred. | ||||||
|  */ |  */ | ||||||
| CURLcode Curl_wait_for_resolv(struct connectdata *conn, | CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, | ||||||
|                                    struct Curl_dns_entry **entry) |                                    struct Curl_dns_entry **entry) | ||||||
| { | { | ||||||
|   CURLcode rc=CURLE_OK; |   CURLcode rc=CURLE_OK; | ||||||
|   struct SessionHandle *data = conn->data; |   struct SessionHandle *data = conn->data; | ||||||
|   long timeout; |   long timeout; | ||||||
|   struct timeval now = Curl_tvnow(); |   struct timeval now = Curl_tvnow(); | ||||||
|  |   struct Curl_dns_entry *temp_entry; | ||||||
| 
 | 
 | ||||||
|   timeout = Curl_timeleft(data, &now, TRUE); |   timeout = Curl_timeleft(data, &now, TRUE); | ||||||
|   if(!timeout) |   if(!timeout) | ||||||
| @@ -240,7 +382,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, | |||||||
|     store.tv_sec = itimeout/1000; |     store.tv_sec = itimeout/1000; | ||||||
|     store.tv_usec = (itimeout%1000)*1000; |     store.tv_usec = (itimeout%1000)*1000; | ||||||
| 
 | 
 | ||||||
|     tvp = ares_timeout(data->state.areschannel, &store, &tv); |     tvp = ares_timeout((ares_channel)data->state.resolver, &store, &tv); | ||||||
| 
 | 
 | ||||||
|     /* use the timeout period ares returned to us above if less than one
 |     /* use the timeout period ares returned to us above if less than one
 | ||||||
|        second is left, otherwise just use 1000ms to make sure the progress |        second is left, otherwise just use 1000ms to make sure the progress | ||||||
| @@ -251,6 +393,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, | |||||||
|       timeout_ms = 1000; |       timeout_ms = 1000; | ||||||
| 
 | 
 | ||||||
|     waitperform(conn, timeout_ms); |     waitperform(conn, timeout_ms); | ||||||
|  |     Curl_resolver_is_resolved(conn,&temp_entry); | ||||||
| 
 | 
 | ||||||
|     if(conn->async.done) |     if(conn->async.done) | ||||||
|       break; |       break; | ||||||
| @@ -267,7 +410,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, | |||||||
|     } |     } | ||||||
|     if(timeout < 0) { |     if(timeout < 0) { | ||||||
|       /* our timeout, so we cancel the ares operation */ |       /* our timeout, so we cancel the ares operation */ | ||||||
|       ares_cancel(data->state.areschannel); |       ares_cancel((ares_channel)data->state.resolver); | ||||||
|       break; |       break; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @@ -313,12 +456,29 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, | |||||||
|   return rc; |   return rc; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /* Connects results to the list */ | ||||||
|  | static void compound_results(struct ResolverResults *res, | ||||||
|  |                              Curl_addrinfo *ai) | ||||||
|  | { | ||||||
|  |   Curl_addrinfo *ai_tail; | ||||||
|  |   if(!ai) | ||||||
|  |     return; | ||||||
|  |   ai_tail = ai; | ||||||
|  | 
 | ||||||
|  |   while(ai_tail->ai_next) | ||||||
|  |     ai_tail = ai_tail->ai_next; | ||||||
|  | 
 | ||||||
|  |   /* Add the new results to the list of old results. */ | ||||||
|  |   ai_tail->ai_next = res->temp_ai; | ||||||
|  |   res->temp_ai = ai; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /*
 | /*
 | ||||||
|  * ares_query_completed_cb() is the callback that ares will call when |  * ares_query_completed_cb() is the callback that ares will call when | ||||||
|  * the host query initiated by ares_gethostbyname() from Curl_getaddrinfo(), |  * the host query initiated by ares_gethostbyname() from Curl_getaddrinfo(), | ||||||
|  * when using ares, is completed either successfully or with failure. |  * when using ares, is completed either successfully or with failure. | ||||||
|  */ |  */ | ||||||
| static void ares_query_completed_cb(void *arg,  /* (struct connectdata *) */ | static void query_completed_cb(void *arg,  /* (struct connectdata *) */ | ||||||
|                                int status, |                                int status, | ||||||
| #ifdef HAVE_CARES_CALLBACK_TIMEOUTS | #ifdef HAVE_CARES_CALLBACK_TIMEOUTS | ||||||
|                                int timeouts, |                                int timeouts, | ||||||
| @@ -326,37 +486,40 @@ static void ares_query_completed_cb(void *arg,  /* (struct connectdata *) */ | |||||||
|                                struct hostent *hostent) |                                struct hostent *hostent) | ||||||
| { | { | ||||||
|   struct connectdata *conn = (struct connectdata *)arg; |   struct connectdata *conn = (struct connectdata *)arg; | ||||||
|   struct Curl_addrinfo * ai = NULL; |   struct ResolverResults *res; | ||||||
| 
 | 
 | ||||||
| #ifdef HAVE_CARES_CALLBACK_TIMEOUTS | #ifdef HAVE_CARES_CALLBACK_TIMEOUTS | ||||||
|   (void)timeouts; /* ignored */ |   (void)timeouts; /* ignored */ | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|   switch(status) { |   if(ARES_EDESTRUCTION == status) | ||||||
|   case CURL_ASYNC_SUCCESS: |     /* when this ares handle is getting destroyed, the 'arg' pointer may not
 | ||||||
|     ai = Curl_he2ai(hostent, conn->async.port); |        be valid so only defer it when we know the 'status' says its fine! */ | ||||||
|     break; |  | ||||||
|   case ARES_EDESTRUCTION: |  | ||||||
|     /* this ares handle is getting destroyed, the 'arg' pointer may not be
 |  | ||||||
|        valid! */ |  | ||||||
|     return; |     return; | ||||||
|   default: |  | ||||||
|     /* do nothing */ |  | ||||||
|     break; |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|   (void)Curl_addrinfo_callback(arg, status, ai); |   res = (struct ResolverResults *)conn->async.os_specific; | ||||||
|  |   res->num_pending--; | ||||||
|  | 
 | ||||||
|  |   if(CURL_ASYNC_SUCCESS == status) { | ||||||
|  |     Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port); | ||||||
|  |     if(ai) { | ||||||
|  |       compound_results(res, ai); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   /* A successful result overwrites any previous error */ | ||||||
|  |   if(res->last_status != ARES_SUCCESS) | ||||||
|  |     res->last_status = status; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_getaddrinfo() - when using ares |  * Curl_resolver_getaddrinfo() - when using ares | ||||||
|  * |  * | ||||||
|  * Returns name information about the given hostname and port number. If |  * Returns name information about the given hostname and port number. If | ||||||
|  * successful, the 'hostent' is returned and the forth argument will point to |  * successful, the 'hostent' is returned and the forth argument will point to | ||||||
|  * memory we need to free after use. That memory *MUST* be freed with |  * memory we need to free after use. That memory *MUST* be freed with | ||||||
|  * Curl_freeaddrinfo(), nothing else. |  * Curl_freeaddrinfo(), nothing else. | ||||||
|  */ |  */ | ||||||
| Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, | ||||||
|                                          const char *hostname, |                                          const char *hostname, | ||||||
|                                          int port, |                                          int port, | ||||||
|                                          int *waitp) |                                          int *waitp) | ||||||
| @@ -379,10 +542,9 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | |||||||
| 
 | 
 | ||||||
| #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ | #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ | ||||||
|   /* Otherwise, check if this is an IPv6 address string */ |   /* Otherwise, check if this is an IPv6 address string */ | ||||||
|   if (Curl_inet_pton (AF_INET6, hostname, &in6) > 0) { |   if(Curl_inet_pton (AF_INET6, hostname, &in6) > 0) | ||||||
|     /* This must be an IPv6 address literal.  */ |     /* This must be an IPv6 address literal.  */ | ||||||
|     return Curl_ip2addr(AF_INET6, &in6, hostname, port); |     return Curl_ip2addr(AF_INET6, &in6, hostname, port); | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|   switch(conn->ip_version) { |   switch(conn->ip_version) { | ||||||
|   default: |   default: | ||||||
| @@ -402,34 +564,42 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | |||||||
| #endif /* CURLRES_IPV6 */ | #endif /* CURLRES_IPV6 */ | ||||||
| 
 | 
 | ||||||
|   bufp = strdup(hostname); |   bufp = strdup(hostname); | ||||||
| 
 |  | ||||||
|   if(bufp) { |   if(bufp) { | ||||||
|  |     struct ResolverResults *res = NULL; | ||||||
|     Curl_safefree(conn->async.hostname); |     Curl_safefree(conn->async.hostname); | ||||||
|     conn->async.hostname = bufp; |     conn->async.hostname = bufp; | ||||||
|     conn->async.port = port; |     conn->async.port = port; | ||||||
|     conn->async.done = FALSE;   /* not done */ |     conn->async.done = FALSE;   /* not done */ | ||||||
|     conn->async.status = 0;     /* clear */ |     conn->async.status = 0;     /* clear */ | ||||||
|     conn->async.dns = NULL;     /* clear */ |     conn->async.dns = NULL;     /* clear */ | ||||||
|     conn->async.temp_ai = NULL; /* clear */ |     res = calloc(sizeof(struct ResolverResults),1); | ||||||
|  |     if(!res) { | ||||||
|  |       Curl_safefree(conn->async.hostname); | ||||||
|  |       conn->async.hostname = NULL; | ||||||
|  |       return NULL; | ||||||
|  |     } | ||||||
|  |     conn->async.os_specific = res; | ||||||
| 
 | 
 | ||||||
|  |     /* initial status - failed */ | ||||||
|  |     res->last_status = ARES_ENOTFOUND; | ||||||
| #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ | #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ | ||||||
|     if(family == PF_UNSPEC) { |     if(family == PF_UNSPEC) { | ||||||
|       conn->async.num_pending = 2; |       res->num_pending = 2; | ||||||
| 
 | 
 | ||||||
|       /* areschannel is already setup in the Curl_open() function */ |       /* areschannel is already setup in the Curl_open() function */ | ||||||
|       ares_gethostbyname(data->state.areschannel, hostname, PF_INET, |       ares_gethostbyname((ares_channel)data->state.resolver, hostname, | ||||||
|                          ares_query_completed_cb, conn); |                          PF_INET, query_completed_cb, conn); | ||||||
|       ares_gethostbyname(data->state.areschannel, hostname, PF_INET6, |       ares_gethostbyname((ares_channel)data->state.resolver, hostname, | ||||||
|                          ares_query_completed_cb, conn); |                          PF_INET6, query_completed_cb, conn); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
| #endif /* CURLRES_IPV6 */ | #endif /* CURLRES_IPV6 */ | ||||||
|     { |     { | ||||||
|       conn->async.num_pending = 1; |       res->num_pending = 1; | ||||||
| 
 | 
 | ||||||
|       /* areschannel is already setup in the Curl_open() function */ |       /* areschannel is already setup in the Curl_open() function */ | ||||||
|       ares_gethostbyname(data->state.areschannel, hostname, family, |       ares_gethostbyname((ares_channel)data->state.resolver, hostname, family, | ||||||
|                          ares_query_completed_cb, conn); |                          query_completed_cb, conn); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     *waitp = 1; /* expect asynchronous response */ |     *waitp = 1; /* expect asynchronous response */ | ||||||
| @@ -64,6 +64,12 @@ | |||||||
| #define in_addr_t unsigned long | #define in_addr_t unsigned long | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #ifdef HAVE_GETADDRINFO | ||||||
|  | #  define RESOLVER_ENOMEM  EAI_MEMORY | ||||||
|  | #else | ||||||
|  | #  define RESOLVER_ENOMEM  ENOMEM | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| #include "sendf.h" | #include "sendf.h" | ||||||
| #include "hostip.h" | #include "hostip.h" | ||||||
| @@ -88,6 +94,71 @@ | |||||||
|  **********************************************************************/ |  **********************************************************************/ | ||||||
| #ifdef CURLRES_THREADED | #ifdef CURLRES_THREADED | ||||||
| 
 | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_global_init() | ||||||
|  |  * Called from curl_global_init() to initialize global resolver environment. | ||||||
|  |  * Does nothing here. | ||||||
|  |  */ | ||||||
|  | int Curl_resolver_global_init(void) | ||||||
|  | { | ||||||
|  |   return CURLE_OK; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_global_cleanup() | ||||||
|  |  * Called from curl_global_cleanup() to destroy global resolver environment. | ||||||
|  |  * Does nothing here. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_global_cleanup(void) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_init() | ||||||
|  |  * Called from curl_easy_init() -> Curl_open() to initialize resolver | ||||||
|  |  * URL-state specific environment ('resolver' member of the UrlState | ||||||
|  |  * structure).  Does nothing here. | ||||||
|  |  */ | ||||||
|  | CURLcode Curl_resolver_init(void **resolver) | ||||||
|  | { | ||||||
|  |   (void)resolver; | ||||||
|  |   return CURLE_OK; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_cleanup() | ||||||
|  |  * Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver | ||||||
|  |  * URL-state specific environment ('resolver' member of the UrlState | ||||||
|  |  * structure).  Does nothing here. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_cleanup(void *resolver) | ||||||
|  | { | ||||||
|  |   (void)resolver; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_duphandle() | ||||||
|  |  * Called from curl_easy_duphandle() to duplicate resolver URL state-specific | ||||||
|  |  * environment ('resolver' member of the UrlState structure).  Does nothing | ||||||
|  |  * here. | ||||||
|  |  */ | ||||||
|  | int Curl_resolver_duphandle(void **to, void *from) | ||||||
|  | { | ||||||
|  |   (void)to; | ||||||
|  |   (void)from; | ||||||
|  |   return CURLE_OK; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void destroy_async_data(struct Curl_async *); | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Cancel all possibly still on-going resolves for this connection. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_cancel(struct connectdata *conn) | ||||||
|  | { | ||||||
|  |   destroy_async_data(&conn->async); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* This function is used to init a threaded resolve */ | /* This function is used to init a threaded resolve */ | ||||||
| static bool init_resolve_thread(struct connectdata *conn, | static bool init_resolve_thread(struct connectdata *conn, | ||||||
|                                 const char *hostname, int port, |                                 const char *hostname, int port, | ||||||
| @@ -160,7 +231,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd, | |||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|   tsd->mtx = malloc(sizeof(curl_mutex_t)); |   tsd->mtx = malloc(sizeof(curl_mutex_t)); | ||||||
|   if (tsd->mtx == NULL) goto err_exit; |   if(tsd->mtx == NULL) | ||||||
|  |     goto err_exit; | ||||||
| 
 | 
 | ||||||
|   Curl_mutex_init(tsd->mtx); |   Curl_mutex_init(tsd->mtx); | ||||||
| 
 | 
 | ||||||
| @@ -170,7 +242,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd, | |||||||
|    * thread during gethostbyname execution. |    * thread during gethostbyname execution. | ||||||
|    */ |    */ | ||||||
|   tsd->hostname = strdup(hostname); |   tsd->hostname = strdup(hostname); | ||||||
|   if (!tsd->hostname) goto err_exit; |   if(!tsd->hostname) | ||||||
|  |     goto err_exit; | ||||||
| 
 | 
 | ||||||
|   return 1; |   return 1; | ||||||
| 
 | 
 | ||||||
| @@ -186,8 +259,8 @@ static int getaddrinfo_complete(struct connectdata *conn) | |||||||
|   int rc; |   int rc; | ||||||
| 
 | 
 | ||||||
|   rc = Curl_addrinfo_callback(conn, tsd->sock_error, tsd->res); |   rc = Curl_addrinfo_callback(conn, tsd->sock_error, tsd->res); | ||||||
|   /* The tsd->res structure has been copied to async.dns and perhaps the DNS cache.
 |   /* The tsd->res structure has been copied to async.dns and perhaps the DNS
 | ||||||
|      Set our copy to NULL so destroy_thread_sync_data doesn't free it. |      cache.  Set our copy to NULL so destroy_thread_sync_data doesn't free it. | ||||||
|   */ |   */ | ||||||
|   tsd->res = NULL; |   tsd->res = NULL; | ||||||
| 
 | 
 | ||||||
| @@ -214,9 +287,9 @@ static unsigned int CURL_STDCALL getaddrinfo_thread (void *arg) | |||||||
|   rc = Curl_getaddrinfo_ex(tsd->hostname, service, &tsd->hints, &tsd->res); |   rc = Curl_getaddrinfo_ex(tsd->hostname, service, &tsd->hints, &tsd->res); | ||||||
| 
 | 
 | ||||||
|   if(rc != 0) { |   if(rc != 0) { | ||||||
|     tsd->sock_error = SOCKERRNO; |     tsd->sock_error = SOCKERRNO?SOCKERRNO:rc; | ||||||
|     if(tsd->sock_error == 0) |     if(tsd->sock_error == 0) | ||||||
|       tsd->sock_error = ENOMEM; |       tsd->sock_error = RESOLVER_ENOMEM; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Curl_mutex_acquire(tsd->mtx); |   Curl_mutex_acquire(tsd->mtx); | ||||||
| @@ -240,7 +313,7 @@ static unsigned int CURL_STDCALL gethostbyname_thread (void *arg) | |||||||
|   if(!tsd->res) { |   if(!tsd->res) { | ||||||
|     tsd->sock_error = SOCKERRNO; |     tsd->sock_error = SOCKERRNO; | ||||||
|     if(tsd->sock_error == 0) |     if(tsd->sock_error == 0) | ||||||
|       tsd->sock_error = ENOMEM; |       tsd->sock_error = RESOLVER_ENOMEM; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Curl_mutex_acquire(tsd->mtx); |   Curl_mutex_acquire(tsd->mtx); | ||||||
| @@ -253,10 +326,9 @@ static unsigned int CURL_STDCALL gethostbyname_thread (void *arg) | |||||||
| #endif /* HAVE_GETADDRINFO */ | #endif /* HAVE_GETADDRINFO */ | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_destroy_thread_data() cleans up async resolver data and thread handle. |  * destroy_async_data() cleans up async resolver data and thread handle. | ||||||
|  * Complementary of ares_destroy. |  | ||||||
|  */ |  */ | ||||||
| void Curl_destroy_thread_data (struct Curl_async *async) | static void destroy_async_data (struct Curl_async *async) | ||||||
| { | { | ||||||
|   if(async->hostname) |   if(async->hostname) | ||||||
|     free(async->hostname); |     free(async->hostname); | ||||||
| @@ -289,7 +361,7 @@ static bool init_resolve_thread (struct connectdata *conn, | |||||||
|                                  const struct addrinfo *hints) |                                  const struct addrinfo *hints) | ||||||
| { | { | ||||||
|   struct thread_data *td = calloc(1, sizeof(struct thread_data)); |   struct thread_data *td = calloc(1, sizeof(struct thread_data)); | ||||||
|   int err = ENOMEM; |   int err = RESOLVER_ENOMEM; | ||||||
| 
 | 
 | ||||||
|   conn->async.os_specific = (void*) td; |   conn->async.os_specific = (void*) td; | ||||||
|   if(!td) |   if(!td) | ||||||
| @@ -311,7 +383,7 @@ static bool init_resolve_thread (struct connectdata *conn, | |||||||
|     goto err_exit; |     goto err_exit; | ||||||
| 
 | 
 | ||||||
| #ifdef WIN32 | #ifdef WIN32 | ||||||
|   /* This socket is only to keep Curl_resolv_fdset() and select() happy;
 |   /* This socket is only to keep Curl_resolver_fdset() and select() happy;
 | ||||||
|    * should never become signalled for read since it's unbound but |    * should never become signalled for read since it's unbound but | ||||||
|    * Windows needs at least 1 socket in select(). |    * Windows needs at least 1 socket in select(). | ||||||
|    */ |    */ | ||||||
| @@ -336,37 +408,93 @@ static bool init_resolve_thread (struct connectdata *conn, | |||||||
|   return TRUE; |   return TRUE; | ||||||
| 
 | 
 | ||||||
|  err_exit: |  err_exit: | ||||||
|   Curl_destroy_thread_data(&conn->async); |   destroy_async_data(&conn->async); | ||||||
| 
 | 
 | ||||||
|   SET_ERRNO(err); |   SET_ERRNO(err); | ||||||
| 
 | 
 | ||||||
|   return FALSE; |   return FALSE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #if defined(HAVE_GETADDRINFO) && !defined(HAVE_GAI_STRERROR) && !defined(WIN32) | ||||||
|  | /* NetWare has getaddrinfo but lacks gai_strerror.
 | ||||||
|  |    Windows has a gai_strerror but it is bad (not thread-safe) and the generic | ||||||
|  |    socket error string function can be used for this pupose. */ | ||||||
|  | static const char *gai_strerror(int ecode) | ||||||
|  | { | ||||||
|  |   switch (ecode){ | ||||||
|  |   case EAI_AGAIN: | ||||||
|  |     return "The name could not be resolved at this time"; | ||||||
|  |   case EAI_BADFLAGS: | ||||||
|  |     return "The flags parameter had an invalid value"; | ||||||
|  |   case EAI_FAIL: | ||||||
|  |     return "A non-recoverable error occurred when attempting to " | ||||||
|  |       "resolve the name"; | ||||||
|  |   case EAI_FAMILY: | ||||||
|  |     return "The address family was not recognized"; | ||||||
|  |   case EAI_MEMORY: | ||||||
|  |     return "Out of memory"; | ||||||
|  |   case EAI_NONAME: | ||||||
|  |     return "The name does not resolve for the supplied parameters"; | ||||||
|  |   case EAI_SERVICE: | ||||||
|  |     return "The service passed was not recognized for the " | ||||||
|  |       "specified socket type" | ||||||
|  |   case EAI_SOCKTYPE: | ||||||
|  |     return "The intended socket type was not recognized" | ||||||
|  |   case EAI_SYSTEM: | ||||||
|  |     return "A system error occurred"; | ||||||
|  |   case EAI_OVERFLOW: | ||||||
|  |     return "An argument buffer overflowed"; | ||||||
|  |   default: | ||||||
|  |     return "Unknown error"; | ||||||
|  | 
 | ||||||
|  | /* define this now as this is a private implementation of said function */ | ||||||
|  | #define HAVE_GAI_STRERROR | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_wait_for_resolv() waits for a resolve to finish. This function should |  * resolver_error() calls failf() with the appropriate message after a resolve | ||||||
|  * be avoided since using this risk getting the multi interface to "hang". |  * error | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | static void resolver_error(struct connectdata *conn, const char *host_or_proxy) | ||||||
|  | { | ||||||
|  |   failf(conn->data, "Could not resolve %s: %s; %s", host_or_proxy, | ||||||
|  |         conn->async.hostname, | ||||||
|  | #ifdef HAVE_GAI_STRERROR | ||||||
|  |         /* NetWare doesn't have gai_strerror and on Windows it isn't deemed
 | ||||||
|  |            thread-safe */ | ||||||
|  |         gai_strerror(conn->async.status) | ||||||
|  | #else | ||||||
|  |         Curl_strerror(conn, conn->async.status) | ||||||
|  | #endif | ||||||
|  |     ); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /*
 | ||||||
|  |  * Curl_resolver_wait_resolv() | ||||||
|  |  * | ||||||
|  |  * waits for a resolve to finish. This function should be avoided since using | ||||||
|  |  * this risk getting the multi interface to "hang". | ||||||
|  * |  * | ||||||
|  * If 'entry' is non-NULL, make it point to the resolved dns entry |  * If 'entry' is non-NULL, make it point to the resolved dns entry | ||||||
|  * |  * | ||||||
|  * This is the version for resolves-in-a-thread. |  * This is the version for resolves-in-a-thread. | ||||||
|  */ |  */ | ||||||
| CURLcode Curl_wait_for_resolv(struct connectdata *conn, | CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, | ||||||
|                                    struct Curl_dns_entry **entry) |                                    struct Curl_dns_entry **entry) | ||||||
| { | { | ||||||
|   struct thread_data   *td = (struct thread_data*) conn->async.os_specific; |   struct thread_data   *td = (struct thread_data*) conn->async.os_specific; | ||||||
|   struct SessionHandle *data = conn->data; |  | ||||||
|   CURLcode rc = CURLE_OK; |   CURLcode rc = CURLE_OK; | ||||||
| 
 | 
 | ||||||
|   DEBUGASSERT(conn && td); |   DEBUGASSERT(conn && td); | ||||||
| 
 | 
 | ||||||
|   /* wait for the thread to resolve the name */ |   /* wait for the thread to resolve the name */ | ||||||
|   if (Curl_thread_join(&td->thread_hnd)) { |   if(Curl_thread_join(&td->thread_hnd)) | ||||||
|     rc = getaddrinfo_complete(conn); |     rc = getaddrinfo_complete(conn); | ||||||
|   } else { |   else | ||||||
|     DEBUGASSERT(0); |     DEBUGASSERT(0); | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|   conn->async.done = TRUE; |   conn->async.done = TRUE; | ||||||
| 
 | 
 | ||||||
| @@ -376,17 +504,16 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, | |||||||
|   if(!conn->async.dns) { |   if(!conn->async.dns) { | ||||||
|     /* a name was not resolved */ |     /* a name was not resolved */ | ||||||
|     if(conn->bits.httpproxy) { |     if(conn->bits.httpproxy) { | ||||||
|       failf(data, "Could not resolve proxy: %s; %s", |       resolver_error(conn, "proxy"); | ||||||
|             conn->async.hostname, Curl_strerror(conn, conn->async.status)); |  | ||||||
|       rc = CURLE_COULDNT_RESOLVE_PROXY; |       rc = CURLE_COULDNT_RESOLVE_PROXY; | ||||||
|     } else { |     } | ||||||
|       failf(data, "Could not resolve host: %s; %s", |     else { | ||||||
|             conn->async.hostname, Curl_strerror(conn, conn->async.status)); |       resolver_error(conn, "host"); | ||||||
|       rc = CURLE_COULDNT_RESOLVE_HOST; |       rc = CURLE_COULDNT_RESOLVE_HOST; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Curl_destroy_thread_data(&conn->async); |   destroy_async_data(&conn->async); | ||||||
| 
 | 
 | ||||||
|   if(!conn->async.dns) |   if(!conn->async.dns) | ||||||
|     conn->bits.close = TRUE; |     conn->bits.close = TRUE; | ||||||
| @@ -395,11 +522,11 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_is_resolved() is called repeatedly to check if a previous name resolve |  * Curl_resolver_is_resolved() is called repeatedly to check if a previous | ||||||
|  * request has completed. It should also make sure to time-out if the |  * name resolve request has completed. It should also make sure to time-out if | ||||||
|  * operation seems to take too long. |  * the operation seems to take too long. | ||||||
|  */ |  */ | ||||||
| CURLcode Curl_is_resolved(struct connectdata *conn, | CURLcode Curl_resolver_is_resolved(struct connectdata *conn, | ||||||
|                                    struct Curl_dns_entry **entry) |                                    struct Curl_dns_entry **entry) | ||||||
| { | { | ||||||
|   struct SessionHandle *data = conn->data; |   struct SessionHandle *data = conn->data; | ||||||
| @@ -419,15 +546,15 @@ CURLcode Curl_is_resolved(struct connectdata *conn, | |||||||
| 
 | 
 | ||||||
|   if(done) { |   if(done) { | ||||||
|     getaddrinfo_complete(conn); |     getaddrinfo_complete(conn); | ||||||
|     Curl_destroy_thread_data(&conn->async); |     destroy_async_data(&conn->async); | ||||||
| 
 | 
 | ||||||
|     if(!conn->async.dns) { |     if(!conn->async.dns) { | ||||||
|       failf(data, "Could not resolve host: %s; %s", |       resolver_error(conn, "host"); | ||||||
|             conn->host.name, Curl_strerror(conn, conn->async.status)); |  | ||||||
|       return CURLE_COULDNT_RESOLVE_HOST; |       return CURLE_COULDNT_RESOLVE_HOST; | ||||||
|     } |     } | ||||||
|     *entry = conn->async.dns; |     *entry = conn->async.dns; | ||||||
|   } else { |   } | ||||||
|  |   else { | ||||||
|     /* poll for name lookup done with exponential backoff up to 250ms */ |     /* poll for name lookup done with exponential backoff up to 250ms */ | ||||||
|     int elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle); |     int elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle); | ||||||
|     if(elapsed < 0) |     if(elapsed < 0) | ||||||
| @@ -450,7 +577,7 @@ CURLcode Curl_is_resolved(struct connectdata *conn, | |||||||
|   return CURLE_OK; |   return CURLE_OK; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int Curl_resolv_getsock(struct connectdata *conn, | int Curl_resolver_getsock(struct connectdata *conn, | ||||||
|                           curl_socket_t *socks, |                           curl_socket_t *socks, | ||||||
|                           int numsocks) |                           int numsocks) | ||||||
| { | { | ||||||
| @@ -472,7 +599,7 @@ int Curl_resolv_getsock(struct connectdata *conn, | |||||||
| /*
 | /*
 | ||||||
|  * Curl_getaddrinfo() - for platforms without getaddrinfo |  * Curl_getaddrinfo() - for platforms without getaddrinfo | ||||||
|  */ |  */ | ||||||
| Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, | ||||||
|                                          const char *hostname, |                                          const char *hostname, | ||||||
|                                          int port, |                                          int port, | ||||||
|                                          int *waitp) |                                          int *waitp) | ||||||
| @@ -498,9 +625,9 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | |||||||
| #else /* !HAVE_GETADDRINFO */ | #else /* !HAVE_GETADDRINFO */ | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Curl_getaddrinfo() - for getaddrinfo |  * Curl_resolver_getaddrinfo() - for getaddrinfo | ||||||
|  */ |  */ | ||||||
| Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, | ||||||
|                                          const char *hostname, |                                          const char *hostname, | ||||||
|                                          int port, |                                          int port, | ||||||
|                                          int *waitp) |                                          int *waitp) | ||||||
| @@ -510,7 +637,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | |||||||
|   int error; |   int error; | ||||||
|   char sbuf[NI_MAXSERV]; |   char sbuf[NI_MAXSERV]; | ||||||
|   int pf = PF_INET; |   int pf = PF_INET; | ||||||
|   struct SessionHandle *data = conn->data; |  | ||||||
| 
 | 
 | ||||||
|   *waitp = 0; /* default to synchronous response */ |   *waitp = 0; /* default to synchronous response */ | ||||||
| 
 | 
 | ||||||
| @@ -549,12 +675,12 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /* fall-back to blocking version */ |   /* fall-back to blocking version */ | ||||||
|   infof(data, "init_resolve_thread() failed for %s; %s\n", |   infof(conn->data, "init_resolve_thread() failed for %s; %s\n", | ||||||
|         hostname, Curl_strerror(conn, ERRNO)); |         hostname, Curl_strerror(conn, ERRNO)); | ||||||
| 
 | 
 | ||||||
|   error = Curl_getaddrinfo_ex(hostname, sbuf, &hints, &res); |   error = Curl_getaddrinfo_ex(hostname, sbuf, &hints, &res); | ||||||
|   if(error) { |   if(error) { | ||||||
|     infof(data, "getaddrinfo() failed for %s:%d; %s\n", |     infof(conn->data, "getaddrinfo() failed for %s:%d; %s\n", | ||||||
|           hostname, port, Curl_strerror(conn, SOCKERRNO)); |           hostname, port, Curl_strerror(conn, SOCKERRNO)); | ||||||
|     return NULL; |     return NULL; | ||||||
|   } |   } | ||||||
							
								
								
									
										168
									
								
								lib/asyn.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										168
									
								
								lib/asyn.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,168 @@ | |||||||
|  | #ifndef HEADER_CURL_ASYN_H | ||||||
|  | #define HEADER_CURL_ASYN_H | ||||||
|  | /*************************************************************************** | ||||||
|  |  *                                  _   _ ____  _ | ||||||
|  |  *  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 "setup.h" | ||||||
|  | #include "curl_addrinfo.h" | ||||||
|  |  | ||||||
|  | struct addrinfo; | ||||||
|  | struct hostent; | ||||||
|  | struct SessionHandle; | ||||||
|  | struct connectdata; | ||||||
|  | struct Curl_dns_entry; | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * This header defines all functions in the internal asynch resolver interface. | ||||||
|  |  * All asynch resolvers need to provide these functions. | ||||||
|  |  * asyn-ares.c and asyn-thread.c are the current implementations of asynch | ||||||
|  |  * resolver backends. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_global_init() | ||||||
|  |  * | ||||||
|  |  * Called from curl_global_init() to initialize global resolver environment. | ||||||
|  |  * Returning anything else than CURLE_OK fails curl_global_init(). | ||||||
|  |  */ | ||||||
|  | int Curl_resolver_global_init(void); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_global_cleanup() | ||||||
|  |  * Called from curl_global_cleanup() to destroy global resolver environment. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_global_cleanup(void); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_init() | ||||||
|  |  * Called from curl_easy_init() -> Curl_open() to initialize resolver | ||||||
|  |  * URL-state specific environment ('resolver' member of the UrlState | ||||||
|  |  * structure).  Should fill the passed pointer by the initialized handler. | ||||||
|  |  * Returning anything else than CURLE_OK fails curl_easy_init() with the | ||||||
|  |  * correspondent code. | ||||||
|  |  */ | ||||||
|  | CURLcode Curl_resolver_init(void **resolver); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_cleanup() | ||||||
|  |  * Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver | ||||||
|  |  * URL-state specific environment ('resolver' member of the UrlState | ||||||
|  |  * structure).  Should destroy the handler and free all resources connected to | ||||||
|  |  * it. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_cleanup(void *resolver); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_duphandle() | ||||||
|  |  * Called from curl_easy_duphandle() to duplicate resolver URL-state specific | ||||||
|  |  * environment ('resolver' member of the UrlState structure).  Should | ||||||
|  |  * duplicate the 'from' handle and pass the resulting handle to the 'to' | ||||||
|  |  * pointer.  Returning anything else than CURLE_OK causes failed | ||||||
|  |  * curl_easy_duphandle() call. | ||||||
|  |  */ | ||||||
|  | int Curl_resolver_duphandle(void **to, void *from); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_cancel(). | ||||||
|  |  * | ||||||
|  |  * It is called from inside other functions to cancel currently performing | ||||||
|  |  * resolver request. Should also free any temporary resources allocated to | ||||||
|  |  * perform a request. | ||||||
|  |  */ | ||||||
|  | void Curl_resolver_cancel(struct connectdata *conn); | ||||||
|  |  | ||||||
|  | /* Curl_resolver_getsock() | ||||||
|  |  * | ||||||
|  |  * This function is called from the multi_getsock() function.  'sock' is a | ||||||
|  |  * pointer to an array to hold the file descriptors, with 'numsock' being the | ||||||
|  |  * size of that array (in number of entries). This function is supposed to | ||||||
|  |  * return bitmask indicating what file descriptors (referring to array indexes | ||||||
|  |  * in the 'sock' array) to wait for, read/write. | ||||||
|  |  */ | ||||||
|  | int Curl_resolver_getsock(struct connectdata *conn, curl_socket_t *sock, | ||||||
|  |                           int numsocks); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_is_resolved() | ||||||
|  |  * | ||||||
|  |  * Called repeatedly to check if a previous name resolve request has | ||||||
|  |  * completed. It should also make sure to time-out if the operation seems to | ||||||
|  |  * take too long. | ||||||
|  |  * | ||||||
|  |  * Returns normal CURLcode errors. | ||||||
|  |  */ | ||||||
|  | CURLcode Curl_resolver_is_resolved(struct connectdata *conn, | ||||||
|  |                                    struct Curl_dns_entry **dns); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_wait_resolv() | ||||||
|  |  * | ||||||
|  |  * waits for a resolve to finish. This function should be avoided since using | ||||||
|  |  * this risk getting the multi interface to "hang". | ||||||
|  |  * | ||||||
|  |  * If 'entry' is non-NULL, make it point to the resolved dns entry | ||||||
|  |  * | ||||||
|  |  * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved, and | ||||||
|  |  * CURLE_OPERATION_TIMEDOUT if a time-out occurred. | ||||||
|  |  | ||||||
|  |  */ | ||||||
|  | CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, | ||||||
|  |                                    struct Curl_dns_entry **dnsentry); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_resolver_getaddrinfo() - when using this resolver | ||||||
|  |  * | ||||||
|  |  * Returns name information about the given hostname and port number. If | ||||||
|  |  * successful, the 'hostent' is returned and the forth argument will point to | ||||||
|  |  * memory we need to free after use. That memory *MUST* be freed with | ||||||
|  |  * Curl_freeaddrinfo(), nothing else. | ||||||
|  |  * | ||||||
|  |  * Each resolver backend must of course make sure to return data in the | ||||||
|  |  * correct format to comply with this. | ||||||
|  |  */ | ||||||
|  | Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, | ||||||
|  |                                          const char *hostname, | ||||||
|  |                                          int port, | ||||||
|  |                                          int *waitp); | ||||||
|  |  | ||||||
|  | #ifndef CURLRES_ASYNCH | ||||||
|  | /* convert these functions if an asynch resolver isn't used */ | ||||||
|  | #define Curl_resolver_cancel(x) | ||||||
|  | #define Curl_resolver_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST | ||||||
|  | #define Curl_resolver_wait_resolv(x,y) CURLE_COULDNT_RESOLVE_HOST | ||||||
|  | #define Curl_resolver_getsock(x,y,z) 0 | ||||||
|  | #define Curl_resolver_duphandle(x,y) CURLE_OK | ||||||
|  | #define Curl_resolver_init(x) CURLE_OK | ||||||
|  | #define Curl_resolver_global_init() CURLE_OK | ||||||
|  | #define Curl_resolver_global_cleanup() | ||||||
|  | #define Curl_resolver_cleanup(x) | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifdef CURLRES_ASYNCH | ||||||
|  | #define Curl_resolver_asynch() 1 | ||||||
|  | #else | ||||||
|  | #define Curl_resolver_asynch() 0 | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /********** end of generic resolver interface functions *****************/ | ||||||
|  | #endif /* HEADER_CURL_ASYN_H */ | ||||||
| @@ -82,8 +82,7 @@ int Curl_axtls_cleanup(void) | |||||||
|  |  | ||||||
| static CURLcode map_error_to_curl(int axtls_err) | static CURLcode map_error_to_curl(int axtls_err) | ||||||
| { | { | ||||||
|   switch (axtls_err) |   switch (axtls_err) { | ||||||
|   { |  | ||||||
|   case SSL_ERROR_NOT_SUPPORTED: |   case SSL_ERROR_NOT_SUPPORTED: | ||||||
|   case SSL_ERROR_INVALID_VERSION: |   case SSL_ERROR_INVALID_VERSION: | ||||||
|   case -70:                       /* protocol version alert from server */ |   case -70:                       /* protocol version alert from server */ | ||||||
| @@ -296,7 +295,7 @@ Curl_axtls_connect(struct connectdata *conn, | |||||||
|   else |   else | ||||||
|     infof(data, "\t server certificate verification SKIPPED\n"); |     infof(data, "\t server certificate verification SKIPPED\n"); | ||||||
|  |  | ||||||
|   /* Here, gtls.c does issuer verfication. axTLS has no straightforward |   /* Here, gtls.c does issuer verification. axTLS has no straightforward | ||||||
|    * equivalent, so omitting for now.*/ |    * equivalent, so omitting for now.*/ | ||||||
|  |  | ||||||
|   /* See if common name was set in server certificate */ |   /* See if common name was set in server certificate */ | ||||||
|   | |||||||
							
								
								
									
										33
									
								
								lib/base64.c
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								lib/base64.c
									
									
									
									
									
								
							| @@ -31,10 +31,10 @@ | |||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
|  |  | ||||||
| #include "urldata.h" /* for the SessionHandle definition */ | #include "urldata.h" /* for the SessionHandle definition */ | ||||||
| #include "easyif.h"  /* for Curl_convert_... prototypes */ |  | ||||||
| #include "warnless.h" | #include "warnless.h" | ||||||
| #include "curl_base64.h" | #include "curl_base64.h" | ||||||
| #include "curl_memory.h" | #include "curl_memory.h" | ||||||
|  | #include "non-ascii.h" | ||||||
|  |  | ||||||
| /* include memdebug.h last */ | /* include memdebug.h last */ | ||||||
| #include "memdebug.h" | #include "memdebug.h" | ||||||
| @@ -73,6 +73,8 @@ static void decodeQuantum(unsigned char *dest, const char *src) | |||||||
|  * |  * | ||||||
|  * Given a base64 string at src, decode it and return an allocated memory in |  * Given a base64 string at src, decode it and return an allocated memory in | ||||||
|  * the *outptr. Returns the length of the decoded data. |  * the *outptr. Returns the length of the decoded data. | ||||||
|  |  * | ||||||
|  |  * @unittest: 1302 | ||||||
|  */ |  */ | ||||||
| size_t Curl_base64_decode(const char *src, unsigned char **outptr) | size_t Curl_base64_decode(const char *src, unsigned char **outptr) | ||||||
| { | { | ||||||
| @@ -135,20 +137,20 @@ size_t Curl_base64_decode(const char *src, unsigned char **outptr) | |||||||
|  * is a pointer to an allocated area holding the base64 data. If something |  * is a pointer to an allocated area holding the base64 data. If something | ||||||
|  * went wrong, 0 is returned. |  * went wrong, 0 is returned. | ||||||
|  * |  * | ||||||
|  |  * @unittest: 1302 | ||||||
|  */ |  */ | ||||||
| size_t Curl_base64_encode(struct SessionHandle *data, | size_t Curl_base64_encode(struct SessionHandle *data, | ||||||
|                           const char *inputbuff, size_t insize, |                           const char *inputbuff, size_t insize, | ||||||
|                           char **outptr) |                           char **outptr) | ||||||
| { | { | ||||||
|  |   CURLcode res; | ||||||
|   unsigned char ibuf[3]; |   unsigned char ibuf[3]; | ||||||
|   unsigned char obuf[4]; |   unsigned char obuf[4]; | ||||||
|   int i; |   int i; | ||||||
|   int inputparts; |   int inputparts; | ||||||
|   char *output; |   char *output; | ||||||
|   char *base64data; |   char *base64data; | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|   char *convbuf = NULL; |   char *convbuf = NULL; | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   const char *indata = inputbuff; |   const char *indata = inputbuff; | ||||||
|  |  | ||||||
| @@ -161,29 +163,19 @@ size_t Curl_base64_encode(struct SessionHandle *data, | |||||||
|   if(NULL == output) |   if(NULL == output) | ||||||
|     return 0; |     return 0; | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|   /* |   /* | ||||||
|    * The base64 data needs to be created using the network encoding |    * The base64 data needs to be created using the network encoding | ||||||
|    * not the host encoding.  And we can't change the actual input |    * not the host encoding.  And we can't change the actual input | ||||||
|    * so we copy it to a buffer, translate it, and use that instead. |    * so we copy it to a buffer, translate it, and use that instead. | ||||||
|    */ |    */ | ||||||
|   if(data) { |   res = Curl_convert_clone(data, indata, insize, &convbuf); | ||||||
|     convbuf = malloc(insize); |   if(res) { | ||||||
|     if(!convbuf) { |  | ||||||
|     free(output); |     free(output); | ||||||
|     return 0; |     return 0; | ||||||
|   } |   } | ||||||
|     memcpy(convbuf, indata, insize); |  | ||||||
|     if(CURLE_OK != Curl_convert_to_network(data, convbuf, insize)) { |   if(convbuf) | ||||||
|       free(convbuf); |     indata = (char *)convbuf; | ||||||
|       free(output); |  | ||||||
|       return 0; |  | ||||||
|     } |  | ||||||
|     indata = convbuf; /* switch to the converted buffer */ |  | ||||||
|   } |  | ||||||
| #else |  | ||||||
|   (void)data; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   while(insize > 0) { |   while(insize > 0) { | ||||||
|     for(i = inputparts = 0; i < 3; i++) { |     for(i = inputparts = 0; i < 3; i++) { | ||||||
| @@ -229,10 +221,9 @@ size_t Curl_base64_encode(struct SessionHandle *data, | |||||||
|   *output=0; |   *output=0; | ||||||
|   *outptr = base64data; /* make it return the actual data memory */ |   *outptr = base64data; /* make it return the actual data memory */ | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |   if(convbuf) | ||||||
|   if(data) |  | ||||||
|     free(convbuf); |     free(convbuf); | ||||||
| #endif |  | ||||||
|   return strlen(base64data); /* return the length of the new data */ |   return strlen(base64data); /* return the length of the new data */ | ||||||
| } | } | ||||||
| /* ---- End of Base64 Encoding ---- */ | /* ---- End of Base64 Encoding ---- */ | ||||||
|   | |||||||
							
								
								
									
										193
									
								
								lib/checksrc.pl
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										193
									
								
								lib/checksrc.pl
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,193 @@ | |||||||
|  | #!/usr/bin/perl | ||||||
|  | #*************************************************************************** | ||||||
|  | #                                  _   _ ____  _ | ||||||
|  | #  Project                     ___| | | |  _ \| | | ||||||
|  | #                             / __| | | | |_) | | | ||||||
|  | #                            | (__| |_| |  _ <| |___ | ||||||
|  | #                             \___|\___/|_| \_\_____| | ||||||
|  | # | ||||||
|  | # Copyright (C) 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. | ||||||
|  | # | ||||||
|  | ########################################################################### | ||||||
|  |  | ||||||
|  | my $max_column = 79; | ||||||
|  | my $indent = 2; | ||||||
|  |  | ||||||
|  | my $warnings; | ||||||
|  | my $errors; | ||||||
|  | my $file; | ||||||
|  | my $dir="."; | ||||||
|  | my $wlist; | ||||||
|  |  | ||||||
|  | sub checkwarn { | ||||||
|  |     my ($num, $col, $file, $line, $msg, $error) = @_; | ||||||
|  |  | ||||||
|  |     my $w=$error?"error":"warning"; | ||||||
|  |  | ||||||
|  |     if($w) { | ||||||
|  |         $warnings++; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         $errors++; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     $col++; | ||||||
|  |     print "$file:$num:$col: $w: $msg\n"; | ||||||
|  |     print " $line\n"; | ||||||
|  |  | ||||||
|  |     if($col < 80) { | ||||||
|  |         my $pref = (' ' x $col); | ||||||
|  |         print "${pref}^\n"; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | $file = shift @ARGV; | ||||||
|  |  | ||||||
|  | while(1) { | ||||||
|  |  | ||||||
|  |     if($file =~ /-D(.*)/) { | ||||||
|  |         $dir = $1; | ||||||
|  |         $file = shift @ARGV; | ||||||
|  |         next; | ||||||
|  |     } | ||||||
|  |     elsif($file =~ /-W(.*)/) { | ||||||
|  |         $wlist = $1; | ||||||
|  |         $file = shift @ARGV; | ||||||
|  |         next; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     last; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | if(!$file) { | ||||||
|  |     print "checksrc.pl [option] <file1> [file2] ...\n"; | ||||||
|  |     print " Options:\n"; | ||||||
|  |     print "  -D[DIR]   Directory to prepend file names\n"; | ||||||
|  |     print "  -W[file]  Whitelist the given file - ignore all its flaws\n"; | ||||||
|  |     exit; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | do { | ||||||
|  |     if($file ne "$wlist") { | ||||||
|  |         my $fullname = $file; | ||||||
|  |         $fullname = "$dir/$file" if ($fullname !~ '^\.?\.?/'); | ||||||
|  |         scanfile($fullname); | ||||||
|  |     } | ||||||
|  |     $file = shift @ARGV; | ||||||
|  |  | ||||||
|  | } while($file); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | sub scanfile { | ||||||
|  |     my ($file) = @_; | ||||||
|  |  | ||||||
|  |     my $line = 1; | ||||||
|  |     my $prevl; | ||||||
|  |     my $l; | ||||||
|  |     open(R, "<$file") || die "failed to open $file"; | ||||||
|  |  | ||||||
|  |     my $copyright=0; | ||||||
|  |  | ||||||
|  |     while(<R>) { | ||||||
|  |         chomp; | ||||||
|  |         my $l = $_; | ||||||
|  |         my $column = 0; | ||||||
|  |  | ||||||
|  |         # check for a copyright statement | ||||||
|  |         if(!$copyright && ($l =~ /copyright .* \d\d\d\d/i)) { | ||||||
|  |             $copyright=1; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         # detect long lines | ||||||
|  |         if(length($l) > $max_column) { | ||||||
|  |             checkwarn($line, length($l), $file, $l, "Longer than $max_column columns"); | ||||||
|  |         } | ||||||
|  |         # detect TAB characters | ||||||
|  |         if($l =~ /^(.*)\t/) { | ||||||
|  |             checkwarn($line, length($1), $file, $l, "Contains TAB character", 1); | ||||||
|  |         } | ||||||
|  |         # detect trailing white space | ||||||
|  |         if($l =~ /^(.*)[ \t]+\z/) { | ||||||
|  |             checkwarn($line, length($1), $file, $l, "Trailing whitespace"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         # check spaces after for/if/while | ||||||
|  |         if($l =~ /^(.*)(for|if|while) \(/) { | ||||||
|  |             if($1 =~ / *\#/) { | ||||||
|  |                 # this is a #if, treat it differently | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 checkwarn($line, length($1)+length($2), $file, $l, | ||||||
|  |                           "$2 with space"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         # check spaces after open paren after for/if/while | ||||||
|  |         if($l =~ /^(.*)(for|if|while)\( /) { | ||||||
|  |             if($1 =~ / *\#/) { | ||||||
|  |                 # this is a #if, treat it differently | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 checkwarn($line, length($1)+length($2)+1, $file, $l, | ||||||
|  |                           "$2 with space first in condition"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         # check for "} else" | ||||||
|  |         if($l =~ /^(.*)\} else/) { | ||||||
|  |             checkwarn($line, length($1), $file, $l, "else after closing brace on same line"); | ||||||
|  |         } | ||||||
|  |         # check for open brace first on line but not first column | ||||||
|  |         # only alert if previous line ended with a close paren and wasn't a cpp | ||||||
|  |         # line | ||||||
|  |         if((($prevl =~ /\)\z/) && ($prevl !~ /^ *#/)) && ($l =~ /^( +)\{/)) { | ||||||
|  |             checkwarn($line, length($1), $file, $l, "badly placed open brace"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         # if the previous line starts with if/while/for AND ends with an open | ||||||
|  |         # brace, check that this line is indented $indent more steps, if not | ||||||
|  |         # a cpp line | ||||||
|  |         if($prevl =~ /^( *)(if|while|for)\(.*\{\z/) { | ||||||
|  |             my $first = length($1); | ||||||
|  |  | ||||||
|  |             # this line has some character besides spaces | ||||||
|  |             if(($l !~ /^ *#/) && ($l =~ /^( *)[^ ]/)) { | ||||||
|  |                 my $second = length($1); | ||||||
|  |                 my $expect = $first+$indent; | ||||||
|  |                 if($expect != $second) { | ||||||
|  |                     my $diff = $second - $first; | ||||||
|  |                     checkwarn($line, length($1), $file, $l, | ||||||
|  |                               "not indented $indent steps, uses $diff)"); | ||||||
|  |  | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         $line++; | ||||||
|  |         $prevl = $l; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if(!$copyright) { | ||||||
|  |         checkwarn(1, 0, $file, "", "Missing copyright statement", 1); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     close(R); | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if($errors || $warnings) { | ||||||
|  |     printf "checksrc: %d errors and %d warnings\n", $errors, $warnings; | ||||||
|  |     exit 5; # return failure | ||||||
|  | } | ||||||
| @@ -89,6 +89,7 @@ | |||||||
| #include "inet_pton.h" | #include "inet_pton.h" | ||||||
| #include "sslgen.h" /* for Curl_ssl_check_cxn() */ | #include "sslgen.h" /* for Curl_ssl_check_cxn() */ | ||||||
| #include "progress.h" | #include "progress.h" | ||||||
|  | #include "warnless.h" | ||||||
|  |  | ||||||
| /* The last #include file should be: */ | /* The last #include file should be: */ | ||||||
| #include "memdebug.h" | #include "memdebug.h" | ||||||
| @@ -130,6 +131,8 @@ singleipconnect(struct connectdata *conn, | |||||||
|  * If 'nowp' is non-NULL, it points to the current time. |  * If 'nowp' is non-NULL, it points to the current time. | ||||||
|  * 'duringconnect' is FALSE if not during a connect, as then of course the |  * 'duringconnect' is FALSE if not during a connect, as then of course the | ||||||
|  * connect timeout is not taken into account! |  * connect timeout is not taken into account! | ||||||
|  |  * | ||||||
|  |  * @unittest: 1303 | ||||||
|  */ |  */ | ||||||
| long Curl_timeleft(struct SessionHandle *data, | long Curl_timeleft(struct SessionHandle *data, | ||||||
|                    struct timeval *nowp, |                    struct timeval *nowp, | ||||||
| @@ -174,7 +177,7 @@ long Curl_timeleft(struct SessionHandle *data, | |||||||
|     nowp = &now; |     nowp = &now; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* substract elapsed time */ |   /* subtract elapsed time */ | ||||||
|   timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle); |   timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle); | ||||||
|   if(!timeout_ms) |   if(!timeout_ms) | ||||||
|     /* avoid returning 0 as that means no timeout! */ |     /* avoid returning 0 as that means no timeout! */ | ||||||
| @@ -210,8 +213,8 @@ int waitconnect(struct connectdata *conn, | |||||||
|   for(;;) { |   for(;;) { | ||||||
|  |  | ||||||
|     /* now select() until we get connect or timeout */ |     /* now select() until we get connect or timeout */ | ||||||
|     rc = Curl_socket_ready(CURL_SOCKET_BAD, sockfd, (int)(timeout_msec>1000? |     rc = Curl_socket_ready(CURL_SOCKET_BAD, sockfd, timeout_msec>1000? | ||||||
|                                                           1000:timeout_msec)); |                            1000:timeout_msec); | ||||||
|     if(Curl_pgrsUpdate(conn)) |     if(Curl_pgrsUpdate(conn)) | ||||||
|       return WAITCONN_ABORTED; |       return WAITCONN_ABORTED; | ||||||
|  |  | ||||||
| @@ -324,7 +327,7 @@ static CURLcode bindlocal(struct connectdata *conn, | |||||||
|  |  | ||||||
|       rc = Curl_resolv(conn, dev, 0, &h); |       rc = Curl_resolv(conn, dev, 0, &h); | ||||||
|       if(rc == CURLRESOLV_PENDING) |       if(rc == CURLRESOLV_PENDING) | ||||||
|         (void)Curl_wait_for_resolv(conn, &h); |         (void)Curl_resolver_wait_resolv(conn, &h); | ||||||
|       conn->ip_version = ipver; |       conn->ip_version = ipver; | ||||||
|  |  | ||||||
|       if(h) { |       if(h) { | ||||||
| @@ -510,7 +513,7 @@ static CURLcode trynextip(struct connectdata *conn, | |||||||
|   *connected = FALSE; |   *connected = FALSE; | ||||||
|  |  | ||||||
|   if(sockindex != FIRSTSOCKET) { |   if(sockindex != FIRSTSOCKET) { | ||||||
|     sclose(fd_to_close); |     Curl_closesocket(conn, fd_to_close); | ||||||
|     return CURLE_COULDNT_CONNECT; /* no next */ |     return CURLE_COULDNT_CONNECT; /* no next */ | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -525,12 +528,12 @@ static CURLcode trynextip(struct connectdata *conn, | |||||||
|       /* store the new socket descriptor */ |       /* store the new socket descriptor */ | ||||||
|       conn->sock[sockindex] = sockfd; |       conn->sock[sockindex] = sockfd; | ||||||
|       conn->ip_addr = ai; |       conn->ip_addr = ai; | ||||||
|       sclose(fd_to_close); |       Curl_closesocket(conn, fd_to_close); | ||||||
|       return CURLE_OK; |       return CURLE_OK; | ||||||
|     } |     } | ||||||
|     ai = ai->ai_next; |     ai = ai->ai_next; | ||||||
|   } |   } | ||||||
|   sclose(fd_to_close); |   Curl_closesocket(conn, fd_to_close); | ||||||
|   return CURLE_COULDNT_CONNECT; |   return CURLE_COULDNT_CONNECT; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -698,7 +701,13 @@ CURLcode Curl_is_connected(struct connectdata *conn, | |||||||
|  |  | ||||||
|   if(WAITCONN_CONNECTED == rc) { |   if(WAITCONN_CONNECTED == rc) { | ||||||
|     if(verifyconnect(sockfd, &error)) { |     if(verifyconnect(sockfd, &error)) { | ||||||
|       /* we are connected, awesome! */ |       /* we are connected with TCP, awesome! */ | ||||||
|  |  | ||||||
|  |       /* see if we need to do any proxy magic first once we connected */ | ||||||
|  |       code = Curl_connected_proxy(conn); | ||||||
|  |       if(code) | ||||||
|  |         return code; | ||||||
|  |  | ||||||
|       conn->bits.tcpconnect = TRUE; |       conn->bits.tcpconnect = TRUE; | ||||||
|       *connected = TRUE; |       *connected = TRUE; | ||||||
|       Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */ |       Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */ | ||||||
| @@ -899,7 +908,7 @@ singleipconnect(struct connectdata *conn, | |||||||
|     error = ERRNO; |     error = ERRNO; | ||||||
|     failf(data, "sa_addr inet_ntop() failed with errno %d: %s", |     failf(data, "sa_addr inet_ntop() failed with errno %d: %s", | ||||||
|           error, Curl_strerror(conn, error)); |           error, Curl_strerror(conn, error)); | ||||||
|     sclose(sockfd); |     Curl_closesocket(conn, sockfd); | ||||||
|     return CURLE_OK; |     return CURLE_OK; | ||||||
|   } |   } | ||||||
|   memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN); |   memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN); | ||||||
| @@ -928,7 +937,7 @@ singleipconnect(struct connectdata *conn, | |||||||
|     if(error == CURL_SOCKOPT_ALREADY_CONNECTED) |     if(error == CURL_SOCKOPT_ALREADY_CONNECTED) | ||||||
|       isconnected = TRUE; |       isconnected = TRUE; | ||||||
|     else if(error) { |     else if(error) { | ||||||
|       sclose(sockfd); /* close the socket and bail out */ |       Curl_closesocket(conn, sockfd); /* close the socket and bail out */ | ||||||
|       return CURLE_ABORTED_BY_CALLBACK; |       return CURLE_ABORTED_BY_CALLBACK; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @@ -936,7 +945,7 @@ singleipconnect(struct connectdata *conn, | |||||||
|   /* possibly bind the local end to an IP, interface or port */ |   /* possibly bind the local end to an IP, interface or port */ | ||||||
|   res = bindlocal(conn, sockfd, addr.family); |   res = bindlocal(conn, sockfd, addr.family); | ||||||
|   if(res) { |   if(res) { | ||||||
|     sclose(sockfd); /* close socket and bail out */ |     Curl_closesocket(conn, sockfd); /* close socket and bail out */ | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -970,7 +979,7 @@ singleipconnect(struct connectdata *conn, | |||||||
| #endif | #endif | ||||||
|       rc = waitconnect(conn, sockfd, timeout_ms); |       rc = waitconnect(conn, sockfd, timeout_ms); | ||||||
|       if(WAITCONN_ABORTED == rc) { |       if(WAITCONN_ABORTED == rc) { | ||||||
|         sclose(sockfd); |         Curl_closesocket(conn, sockfd); | ||||||
|         return CURLE_ABORTED_BY_CALLBACK; |         return CURLE_ABORTED_BY_CALLBACK; | ||||||
|       } |       } | ||||||
|       break; |       break; | ||||||
| @@ -1011,7 +1020,7 @@ singleipconnect(struct connectdata *conn, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* connect failed or timed out */ |   /* connect failed or timed out */ | ||||||
|   sclose(sockfd); |   Curl_closesocket(conn, sockfd); | ||||||
|  |  | ||||||
|   return CURLE_OK; |   return CURLE_OK; | ||||||
| } | } | ||||||
| @@ -1157,3 +1166,17 @@ curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, | |||||||
|  |  | ||||||
|   return sockfd; |   return sockfd; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Close a socket. | ||||||
|  |  * | ||||||
|  |  * 'conn' can be NULL, beware! | ||||||
|  |  */ | ||||||
|  | int Curl_closesocket(struct connectdata *conn, | ||||||
|  |                      curl_socket_t sock) | ||||||
|  | { | ||||||
|  |   if(conn && conn->fclosesocket) | ||||||
|  |     return conn->fclosesocket(conn->closesocket_client, sock); | ||||||
|  |   else | ||||||
|  |     return sclose(sock); | ||||||
|  | } | ||||||
|   | |||||||
| @@ -68,7 +68,6 @@ void Curl_sndbufset(curl_socket_t sockfd); | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); | void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd); | ||||||
|  |  | ||||||
| void Curl_persistconninfo(struct connectdata *conn); | void Curl_persistconninfo(struct connectdata *conn); | ||||||
|  | int Curl_closesocket(struct connectdata *conn, curl_socket_t sock); | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								lib/cookie.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								lib/cookie.c
									
									
									
									
									
								
							| @@ -84,7 +84,7 @@ Example set of cookies: | |||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* without this on windows OS we get undefined reference to snprintf */ | #define _MPRINTF_REPLACE | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
|  |  | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| @@ -101,7 +101,6 @@ Example set of cookies: | |||||||
| /* The last #include file should be: */ | /* The last #include file should be: */ | ||||||
| #include "memdebug.h" | #include "memdebug.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| static void freecookie(struct Cookie *co) | static void freecookie(struct Cookie *co) | ||||||
| { | { | ||||||
|   if(co->expirestr) |   if(co->expirestr) | ||||||
| @@ -266,7 +265,7 @@ Curl_cookie_add(struct SessionHandle *data, | |||||||
|             } |             } | ||||||
|           } |           } | ||||||
|           else if(Curl_raw_equal("domain", name)) { |           else if(Curl_raw_equal("domain", name)) { | ||||||
|             /* note that this name may or may not have a preceeding dot, but |             /* note that this name may or may not have a preceding dot, but | ||||||
|                we don't care about that, we treat the names the same anyway */ |                we don't care about that, we treat the names the same anyway */ | ||||||
|  |  | ||||||
|             const char *domptr=whatptr; |             const char *domptr=whatptr; | ||||||
| @@ -307,7 +306,7 @@ Curl_cookie_add(struct SessionHandle *data, | |||||||
|                  or the given domain is not valid and thus cannot be set. */ |                  or the given domain is not valid and thus cannot be set. */ | ||||||
|  |  | ||||||
|               if('.' == whatptr[0]) |               if('.' == whatptr[0]) | ||||||
|                 whatptr++; /* ignore preceeding dot */ |                 whatptr++; /* ignore preceding dot */ | ||||||
|  |  | ||||||
|               if(!domain || tailmatch(whatptr, domain)) { |               if(!domain || tailmatch(whatptr, domain)) { | ||||||
|                 const char *tailptr=whatptr; |                 const char *tailptr=whatptr; | ||||||
| @@ -479,7 +478,7 @@ Curl_cookie_add(struct SessionHandle *data, | |||||||
|        marked with httpOnly after the domain name are not accessible |        marked with httpOnly after the domain name are not accessible | ||||||
|        from javascripts, but since curl does not operate at javascript |        from javascripts, but since curl does not operate at javascript | ||||||
|        level, we include them anyway. In Firefox's cookie files, these |        level, we include them anyway. In Firefox's cookie files, these | ||||||
|        lines are preceeded with #HttpOnly_ and then everything is |        lines are preceded with #HttpOnly_ and then everything is | ||||||
|        as usual, so we skip 10 characters of the line.. |        as usual, so we skip 10 characters of the line.. | ||||||
|     */ |     */ | ||||||
|     if(strncmp(lineptr, "#HttpOnly_", 10) == 0) { |     if(strncmp(lineptr, "#HttpOnly_", 10) == 0) { | ||||||
| @@ -514,7 +513,7 @@ Curl_cookie_add(struct SessionHandle *data, | |||||||
|         ptr=strtok_r(NULL, "\t", &tok_buf), fields++) { |         ptr=strtok_r(NULL, "\t", &tok_buf), fields++) { | ||||||
|       switch(fields) { |       switch(fields) { | ||||||
|       case 0: |       case 0: | ||||||
|         if(ptr[0]=='.') /* skip preceeding dots */ |         if(ptr[0]=='.') /* skip preceding dots */ | ||||||
|           ptr++; |           ptr++; | ||||||
|         co->domain = strdup(ptr); |         co->domain = strdup(ptr); | ||||||
|         if(!co->domain) |         if(!co->domain) | ||||||
| @@ -531,7 +530,7 @@ Curl_cookie_add(struct SessionHandle *data, | |||||||
|            As far as I can see, it is set to true when the cookie says |            As far as I can see, it is set to true when the cookie says | ||||||
|            .domain.com and to false when the domain is complete www.domain.com |            .domain.com and to false when the domain is complete www.domain.com | ||||||
|         */ |         */ | ||||||
|         co->tailmatch=(bool)Curl_raw_equal(ptr, "TRUE"); /* store information */ |         co->tailmatch=(bool)Curl_raw_equal(ptr, "TRUE"); | ||||||
|         break; |         break; | ||||||
|       case 2: |       case 2: | ||||||
|         /* It turns out, that sometimes the file format allows the path |         /* It turns out, that sometimes the file format allows the path | ||||||
| @@ -877,7 +876,7 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c, | |||||||
|     size_t i; |     size_t i; | ||||||
|  |  | ||||||
|     /* alloc an array and store all cookie pointers */ |     /* alloc an array and store all cookie pointers */ | ||||||
|     array = (struct Cookie **)malloc(sizeof(struct Cookie *) * matches); |     array = malloc(sizeof(struct Cookie *) * matches); | ||||||
|     if(!array) |     if(!array) | ||||||
|       goto fail; |       goto fail; | ||||||
|  |  | ||||||
| @@ -1040,14 +1039,14 @@ static char *get_netscape_format(const struct Cookie *co) | |||||||
| } | } | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Curl_cookie_output() |  * cookie_output() | ||||||
|  * |  * | ||||||
|  * Writes all internally known cookies to the specified file. Specify |  * Writes all internally known cookies to the specified file. Specify | ||||||
|  * "-" as file name to write to stdout. |  * "-" as file name to write to stdout. | ||||||
|  * |  * | ||||||
|  * The function returns non-zero on write failure. |  * The function returns non-zero on write failure. | ||||||
|  */ |  */ | ||||||
| int Curl_cookie_output(struct CookieInfo *c, const char *dumphere) | static int cookie_output(struct CookieInfo *c, const char *dumphere) | ||||||
| { | { | ||||||
|   struct Cookie *co; |   struct Cookie *co; | ||||||
|   FILE *out; |   FILE *out; | ||||||
| @@ -1147,7 +1146,7 @@ void Curl_flush_cookies(struct SessionHandle *data, int cleanup) | |||||||
|     Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); |     Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); | ||||||
|  |  | ||||||
|     /* if we have a destination file for all the cookies to get dumped to */ |     /* if we have a destination file for all the cookies to get dumped to */ | ||||||
|     if(Curl_cookie_output(data->cookies, data->set.str[STRING_COOKIEJAR])) |     if(cookie_output(data->cookies, data->set.str[STRING_COOKIEJAR])) | ||||||
|       infof(data, "WARNING: failed to save cookies in %s\n", |       infof(data, "WARNING: failed to save cookies in %s\n", | ||||||
|             data->set.str[STRING_COOKIEJAR]); |             data->set.str[STRING_COOKIEJAR]); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| #ifndef __COOKIE_H | #ifndef HEADER_CURL_COOKIE_H | ||||||
| #define __COOKIE_H | #define HEADER_CURL_COOKIE_H | ||||||
| /*************************************************************************** | /*************************************************************************** | ||||||
|  *                                  _   _ ____  _ |  *                                  _   _ ____  _ | ||||||
|  *  Project                     ___| | | |  _ \| | |  *  Project                     ___| | | |  _ \| | | ||||||
| @@ -92,13 +92,12 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *, const char *, | |||||||
| void Curl_cookie_freelist(struct Cookie *cookies, bool cookiestoo); | void Curl_cookie_freelist(struct Cookie *cookies, bool cookiestoo); | ||||||
| void Curl_cookie_clearall(struct CookieInfo *cookies); | void Curl_cookie_clearall(struct CookieInfo *cookies); | ||||||
| void Curl_cookie_clearsess(struct CookieInfo *cookies); | void Curl_cookie_clearsess(struct CookieInfo *cookies); | ||||||
| int Curl_cookie_output(struct CookieInfo *, const char *); |  | ||||||
|  |  | ||||||
| #if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES) | #if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES) | ||||||
| #define Curl_cookie_list(x) NULL | #define Curl_cookie_list(x) NULL | ||||||
| #define Curl_cookie_loadfiles(x) do { } while (0) | #define Curl_cookie_loadfiles(x) do { } while (0) | ||||||
| #define Curl_cookie_init(x,y,z,w) NULL | #define Curl_cookie_init(x,y,z,w) NULL | ||||||
| #define Curl_cookie_cleanup(x) | #define Curl_cookie_cleanup(x) do { } while (0) | ||||||
| #define Curl_flush_cookies(x,y) | #define Curl_flush_cookies(x,y) | ||||||
| #else | #else | ||||||
| void Curl_flush_cookies(struct SessionHandle *data, int cleanup); | void Curl_flush_cookies(struct SessionHandle *data, int cleanup); | ||||||
| @@ -109,4 +108,4 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data); | |||||||
| void Curl_cookie_loadfiles(struct SessionHandle *data); | void Curl_cookie_loadfiles(struct SessionHandle *data); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #endif | #endif /* HEADER_CURL_COOKIE_H */ | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -50,6 +50,7 @@ | |||||||
|  |  | ||||||
| #include "curl_addrinfo.h" | #include "curl_addrinfo.h" | ||||||
| #include "inet_pton.h" | #include "inet_pton.h" | ||||||
|  | #include "warnless.h" | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| @@ -486,7 +487,7 @@ Curl_addrinfo *Curl_str2addr(char *address, int port) | |||||||
|  * |  * | ||||||
|  * This is strictly for memory tracing and are using the same style as the |  * This is strictly for memory tracing and are using the same style as the | ||||||
|  * family otherwise present in memdebug.c. I put these ones here since they |  * family otherwise present in memdebug.c. I put these ones here since they | ||||||
|  * require a bunch of structs I didn't wanna include in memdebug.c |  * require a bunch of structs I didn't want to include in memdebug.c | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -506,7 +507,7 @@ curl_dofreeaddrinfo(struct addrinfo *freethis, | |||||||
|  * |  * | ||||||
|  * This is strictly for memory tracing and are using the same style as the |  * This is strictly for memory tracing and are using the same style as the | ||||||
|  * family otherwise present in memdebug.c. I put these ones here since they |  * family otherwise present in memdebug.c. I put these ones here since they | ||||||
|  * require a bunch of structs I didn't wanna include in memdebug.c |  * require a bunch of structs I didn't want to include in memdebug.c | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| int | int | ||||||
|   | |||||||
| @@ -1,8 +1,5 @@ | |||||||
| /* lib/curl_config.h.in.  Generated from configure.ac by autoheader.  */ | /* lib/curl_config.h.in.  Generated from configure.ac by autoheader.  */ | ||||||
|  |  | ||||||
| /* Define to 1 if you have the $func function. */ |  | ||||||
| #cmakedefine AS_TR_CPP ${AS_TR_CPP} |  | ||||||
|  |  | ||||||
| /* when building libcurl itself */ | /* when building libcurl itself */ | ||||||
| #cmakedefine BUILDING_LIBCURL ${BUILDING_LIBCURL} | #cmakedefine BUILDING_LIBCURL ${BUILDING_LIBCURL} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -413,6 +413,9 @@ static int loop(const unsigned char *pattern, const unsigned char *string) | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * @unittest: 1307 | ||||||
|  |  */ | ||||||
| int Curl_fnmatch(void *ptr, const char *pattern, const char *string) | int Curl_fnmatch(void *ptr, const char *pattern, const char *string) | ||||||
| { | { | ||||||
|   (void)ptr; /* the argument is specified by the curl_fnmatch_callback |   (void)ptr; /* the argument is specified by the curl_fnmatch_callback | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
|   | |||||||
| @@ -51,7 +51,7 @@ static CURLcode rtmp_setup(struct connectdata *conn); | |||||||
| static CURLcode rtmp_do(struct connectdata *conn, bool *done); | static CURLcode rtmp_do(struct connectdata *conn, bool *done); | ||||||
| static CURLcode rtmp_done(struct connectdata *conn, CURLcode, bool premature); | static CURLcode rtmp_done(struct connectdata *conn, CURLcode, bool premature); | ||||||
| static CURLcode rtmp_connect(struct connectdata *conn, bool *done); | static CURLcode rtmp_connect(struct connectdata *conn, bool *done); | ||||||
| static CURLcode rtmp_disconnect(struct connectdata *conn, bool dead_connection); | static CURLcode rtmp_disconnect(struct connectdata *conn, bool dead); | ||||||
|  |  | ||||||
| static Curl_recv rtmp_recv; | static Curl_recv rtmp_recv; | ||||||
| static Curl_send rtmp_send; | static Curl_send rtmp_send; | ||||||
| @@ -73,6 +73,7 @@ const struct Curl_handler Curl_handler_rtmp = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   rtmp_disconnect,                      /* disconnect */ |   rtmp_disconnect,                      /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_RTMP,                            /* defport */ |   PORT_RTMP,                            /* defport */ | ||||||
|   CURLPROTO_RTMP,                       /* protocol */ |   CURLPROTO_RTMP,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags*/ |   PROTOPT_NONE                          /* flags*/ | ||||||
| @@ -91,6 +92,7 @@ const struct Curl_handler Curl_handler_rtmpt = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   rtmp_disconnect,                      /* disconnect */ |   rtmp_disconnect,                      /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_RTMPT,                           /* defport */ |   PORT_RTMPT,                           /* defport */ | ||||||
|   CURLPROTO_RTMPT,                      /* protocol */ |   CURLPROTO_RTMPT,                      /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags*/ |   PROTOPT_NONE                          /* flags*/ | ||||||
| @@ -109,6 +111,7 @@ const struct Curl_handler Curl_handler_rtmpe = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   rtmp_disconnect,                      /* disconnect */ |   rtmp_disconnect,                      /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_RTMP,                            /* defport */ |   PORT_RTMP,                            /* defport */ | ||||||
|   CURLPROTO_RTMPE,                      /* protocol */ |   CURLPROTO_RTMPE,                      /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags*/ |   PROTOPT_NONE                          /* flags*/ | ||||||
| @@ -127,6 +130,7 @@ const struct Curl_handler Curl_handler_rtmpte = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   rtmp_disconnect,                      /* disconnect */ |   rtmp_disconnect,                      /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_RTMPT,                           /* defport */ |   PORT_RTMPT,                           /* defport */ | ||||||
|   CURLPROTO_RTMPTE,                     /* protocol */ |   CURLPROTO_RTMPTE,                     /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags*/ |   PROTOPT_NONE                          /* flags*/ | ||||||
| @@ -145,10 +149,12 @@ const struct Curl_handler Curl_handler_rtmps = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   rtmp_disconnect,                      /* disconnect */ |   rtmp_disconnect,                      /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_RTMPS,                           /* defport */ |   PORT_RTMPS,                           /* defport */ | ||||||
|   CURLPROTO_RTMPS,                      /* protocol */ |   CURLPROTO_RTMPS,                      /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags*/ |   PROTOPT_NONE                          /* flags*/ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const struct Curl_handler Curl_handler_rtmpts = { | const struct Curl_handler Curl_handler_rtmpts = { | ||||||
|   "RTMPTS",                             /* scheme */ |   "RTMPTS",                             /* scheme */ | ||||||
|   rtmp_setup,                           /* setup_connection */ |   rtmp_setup,                           /* setup_connection */ | ||||||
| @@ -162,6 +168,7 @@ const struct Curl_handler Curl_handler_rtmpts = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   rtmp_disconnect,                      /* disconnect */ |   rtmp_disconnect,                      /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_RTMPS,                           /* defport */ |   PORT_RTMPS,                           /* defport */ | ||||||
|   CURLPROTO_RTMPTS,                     /* protocol */ |   CURLPROTO_RTMPTS,                     /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags*/ |   PROTOPT_NONE                          /* flags*/ | ||||||
| @@ -198,11 +205,13 @@ static CURLcode rtmp_connect(struct connectdata *conn, bool *done) | |||||||
|     r->Link.protocol |= RTMP_FEATURE_WRITE; |     r->Link.protocol |= RTMP_FEATURE_WRITE; | ||||||
|  |  | ||||||
|   /* For plain streams, use the buffer toggle trick to keep data flowing */ |   /* For plain streams, use the buffer toggle trick to keep data flowing */ | ||||||
|   if (!(r->Link.lFlags & RTMP_LF_LIVE) && !(r->Link.protocol & RTMP_FEATURE_HTTP)) |   if(!(r->Link.lFlags & RTMP_LF_LIVE) && | ||||||
|  |      !(r->Link.protocol & RTMP_FEATURE_HTTP)) | ||||||
|     r->Link.lFlags |= RTMP_LF_BUFX; |     r->Link.lFlags |= RTMP_LF_BUFX; | ||||||
|  |  | ||||||
|   curlx_nonblock(r->m_sb.sb_socket, FALSE); |   curlx_nonblock(r->m_sb.sb_socket, FALSE); | ||||||
|   setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); |   setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, | ||||||
|  |              (char *)&tv, sizeof(tv)); | ||||||
|  |  | ||||||
|   if(!RTMP_Connect1(r, NULL)) |   if(!RTMP_Connect1(r, NULL)) | ||||||
|     return CURLE_FAILED_INIT; |     return CURLE_FAILED_INIT; | ||||||
| @@ -226,7 +235,8 @@ static CURLcode rtmp_do(struct connectdata *conn, bool *done) | |||||||
|   if(conn->data->set.upload) { |   if(conn->data->set.upload) { | ||||||
|     Curl_pgrsSetUploadSize(conn->data, conn->data->set.infilesize); |     Curl_pgrsSetUploadSize(conn->data, conn->data->set.infilesize); | ||||||
|     Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL); |     Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL); | ||||||
|   } else |   } | ||||||
|  |   else | ||||||
|     Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL); |     Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL); | ||||||
|   *done = TRUE; |   *done = TRUE; | ||||||
|   return CURLE_OK; |   return CURLE_OK; | ||||||
| @@ -269,7 +279,8 @@ static ssize_t rtmp_recv(struct connectdata *conn, int sockindex, char *buf, | |||||||
|         r->m_read.status == RTMP_READ_EOF) { |         r->m_read.status == RTMP_READ_EOF) { | ||||||
|       conn->data->req.size = conn->data->req.bytecount; |       conn->data->req.size = conn->data->req.bytecount; | ||||||
|       nread = 0; |       nread = 0; | ||||||
|     } else |     } | ||||||
|  |     else | ||||||
|       *err = CURLE_RECV_ERROR; |       *err = CURLE_RECV_ERROR; | ||||||
|   } |   } | ||||||
|   return nread; |   return nread; | ||||||
| @@ -284,9 +295,9 @@ static ssize_t rtmp_send(struct connectdata *conn, int sockindex, | |||||||
|   (void)sockindex; /* unused */ |   (void)sockindex; /* unused */ | ||||||
|  |  | ||||||
|   num = RTMP_Write(r, (char *)buf, len); |   num = RTMP_Write(r, (char *)buf, len); | ||||||
|   if (num < 0) { |   if(num < 0) | ||||||
|     *err = CURLE_SEND_ERROR; |     *err = CURLE_SEND_ERROR; | ||||||
|   } |  | ||||||
|   return num; |   return num; | ||||||
| } | } | ||||||
| #endif  /* USE_LIBRTMP */ | #endif  /* USE_LIBRTMP */ | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ | |||||||
| #include <curl/curl.h> | #include <curl/curl.h> | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * When including the folowing three headers, it is mandatory to define either |  * When including the following three headers, it is mandatory to define either | ||||||
|  * SECURITY_WIN32 or SECURITY_KERNEL, indicating who is compiling the code. |  * SECURITY_WIN32 or SECURITY_KERNEL, indicating who is compiling the code. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -95,7 +95,8 @@ int Curl_thread_join(curl_thread_t *hnd) | |||||||
|  |  | ||||||
| #elif defined(USE_THREADS_WIN32) | #elif defined(USE_THREADS_WIN32) | ||||||
|  |  | ||||||
| curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void*), void *arg) | curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void*), | ||||||
|  |                                  void *arg) | ||||||
| { | { | ||||||
| #ifdef _WIN32_WCE | #ifdef _WIN32_WCE | ||||||
|   return CreateThread(NULL, 0, func, arg, 0, NULL); |   return CreateThread(NULL, 0, func, arg, 0, NULL); | ||||||
|   | |||||||
| @@ -122,6 +122,7 @@ cyassl_connect_step1(struct connectdata *conn, | |||||||
|     return CURLE_OUT_OF_MEMORY; |     return CURLE_OUT_OF_MEMORY; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | #ifndef NO_FILESYSTEM | ||||||
|   /* load trusted cacert */ |   /* load trusted cacert */ | ||||||
|   if(data->set.str[STRING_SSL_CAFILE]) { |   if(data->set.str[STRING_SSL_CAFILE]) { | ||||||
|     if(!SSL_CTX_load_verify_locations(conssl->ctx, |     if(!SSL_CTX_load_verify_locations(conssl->ctx, | ||||||
| @@ -175,6 +176,11 @@ cyassl_connect_step1(struct connectdata *conn, | |||||||
|       return CURLE_SSL_CONNECT_ERROR; |       return CURLE_SSL_CONNECT_ERROR; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | #else | ||||||
|  |   if(CyaSSL_no_filesystem_verify(conssl->ctx)!= SSL_SUCCESS) { | ||||||
|  |     return CURLE_SSL_CONNECT_ERROR; | ||||||
|  |   } | ||||||
|  | #endif /* NO_FILESYSTEM */ | ||||||
|  |  | ||||||
|   /* SSL always tries to verify the peer, this only says whether it should |   /* SSL always tries to verify the peer, this only says whether it should | ||||||
|    * fail to connect if the verification fails, or if it should continue |    * fail to connect if the verification fails, or if it should continue | ||||||
| @@ -484,8 +490,7 @@ cyassl_connect_common(struct connectdata *conn, | |||||||
|       curl_socket_t readfd = ssl_connect_2_reading== |       curl_socket_t readfd = ssl_connect_2_reading== | ||||||
|         connssl->connecting_state?sockfd:CURL_SOCKET_BAD; |         connssl->connecting_state?sockfd:CURL_SOCKET_BAD; | ||||||
|  |  | ||||||
|       what = Curl_socket_ready(readfd, writefd, |       what = Curl_socket_ready(readfd, writefd, nonblocking?0:timeout_ms); | ||||||
|                                nonblocking?0:(int)timeout_ms); |  | ||||||
|       if(what < 0) { |       if(what < 0) { | ||||||
|         /* fatal error */ |         /* fatal error */ | ||||||
|         failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO); |         failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO); | ||||||
|   | |||||||
| @@ -107,6 +107,7 @@ const struct Curl_handler Curl_handler_dict = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_DICT,                            /* defport */ |   PORT_DICT,                            /* defport */ | ||||||
|   CURLPROTO_DICT,                       /* protocol */ |   CURLPROTO_DICT,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
|   | |||||||
							
								
								
									
										235
									
								
								lib/easy.c
									
									
									
									
									
								
							
							
						
						
									
										235
									
								
								lib/easy.c
									
									
									
									
									
								
							| @@ -85,22 +85,12 @@ | |||||||
| #include "connect.h" /* for Curl_getconnectinfo */ | #include "connect.h" /* for Curl_getconnectinfo */ | ||||||
| #include "slist.h" | #include "slist.h" | ||||||
| #include "curl_rand.h" | #include "curl_rand.h" | ||||||
|  | #include "non-ascii.h" | ||||||
|  | #include "warnless.h" | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
|  |  | ||||||
| #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV) |  | ||||||
| #include <iconv.h> |  | ||||||
| /* set default codesets for iconv */ |  | ||||||
| #ifndef CURL_ICONV_CODESET_OF_NETWORK |  | ||||||
| #define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" |  | ||||||
| #endif |  | ||||||
| #ifndef CURL_ICONV_CODESET_FOR_UTF8 |  | ||||||
| #define CURL_ICONV_CODESET_FOR_UTF8   "UTF-8" |  | ||||||
| #endif |  | ||||||
| #define ICONV_ERROR  (size_t)-1 |  | ||||||
| #endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */ |  | ||||||
|  |  | ||||||
| /* The last #include file should be: */ | /* The last #include file should be: */ | ||||||
| #include "memdebug.h" | #include "memdebug.h" | ||||||
|  |  | ||||||
| @@ -280,12 +270,10 @@ CURLcode curl_global_init(long flags) | |||||||
|   idna_init(); |   idna_init(); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef CARES_HAVE_ARES_LIBRARY_INIT |   if(Curl_resolver_global_init() != CURLE_OK) { | ||||||
|   if(ares_library_init(ARES_LIB_INIT_ALL)) { |     DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n")); | ||||||
|     DEBUGF(fprintf(stderr, "Error: ares_library_init failed\n")); |  | ||||||
|     return CURLE_FAILED_INIT; |     return CURLE_FAILED_INIT; | ||||||
|   } |   } | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT) | #if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT) | ||||||
|   if(libssh2_init(0)) { |   if(libssh2_init(0)) { | ||||||
| @@ -351,9 +339,7 @@ void curl_global_cleanup(void) | |||||||
|   if(init_flags & CURL_GLOBAL_SSL) |   if(init_flags & CURL_GLOBAL_SSL) | ||||||
|     Curl_ssl_cleanup(); |     Curl_ssl_cleanup(); | ||||||
|  |  | ||||||
| #ifdef CARES_HAVE_ARES_LIBRARY_CLEANUP |   Curl_resolver_global_cleanup(); | ||||||
|   ares_library_cleanup(); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   if(init_flags & CURL_GLOBAL_WIN32) |   if(init_flags & CURL_GLOBAL_WIN32) | ||||||
|     win32_cleanup(); |     win32_cleanup(); | ||||||
| @@ -687,21 +673,12 @@ CURL *curl_easy_duphandle(CURL *incurl) | |||||||
|     outcurl->change.referer_alloc = TRUE; |     outcurl->change.referer_alloc = TRUE; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| #ifdef USE_ARES |   /* Clone the resolver handle, if present, for the new handle */ | ||||||
|   /* If we use ares, we clone the ares channel for the new handle */ |   if(Curl_resolver_duphandle(&outcurl->state.resolver, | ||||||
|   if(ARES_SUCCESS != ares_dup(&outcurl->state.areschannel, |                              data->state.resolver) != CURLE_OK) | ||||||
|                               data->state.areschannel)) |  | ||||||
|     goto fail; |     goto fail; | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV) |   Curl_convert_setup(outcurl); | ||||||
|   outcurl->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST, |  | ||||||
|                                    CURL_ICONV_CODESET_OF_NETWORK); |  | ||||||
|   outcurl->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK, |  | ||||||
|                                     CURL_ICONV_CODESET_OF_HOST); |  | ||||||
|   outcurl->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST, |  | ||||||
|                                 CURL_ICONV_CODESET_FOR_UTF8); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   Curl_easy_initHandleData(outcurl); |   Curl_easy_initHandleData(outcurl); | ||||||
|  |  | ||||||
| @@ -788,8 +765,8 @@ CURLcode curl_easy_pause(CURL *curl, int action) | |||||||
|   k->keepon = newstate; |   k->keepon = newstate; | ||||||
|  |  | ||||||
|   if(!(newstate & KEEP_RECV_PAUSE) && data->state.tempwrite) { |   if(!(newstate & KEEP_RECV_PAUSE) && data->state.tempwrite) { | ||||||
|     /* we have a buffer for sending that we now seem to be able to deliver since |     /* we have a buffer for sending that we now seem to be able to deliver | ||||||
|        the receive pausing is lifted! */ |        since the receive pausing is lifted! */ | ||||||
|  |  | ||||||
|     /* get the pointer, type and length in local copies since the function may |     /* get the pointer, type and length in local copies since the function may | ||||||
|        return PAUSE again and then we'll get a new copy allocted and stored in |        return PAUSE again and then we'll get a new copy allocted and stored in | ||||||
| @@ -863,196 +840,6 @@ CURLcode curl_easy_pause(CURL *curl, int action) | |||||||
|   return result; |   return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
| /* |  | ||||||
|  * Curl_convert_to_network() is an internal function |  | ||||||
|  * for performing ASCII conversions on non-ASCII platforms. |  | ||||||
|  */ |  | ||||||
| CURLcode Curl_convert_to_network(struct SessionHandle *data, |  | ||||||
|                                  char *buffer, size_t length) |  | ||||||
| { |  | ||||||
|   CURLcode rc; |  | ||||||
|  |  | ||||||
|   if(data->set.convtonetwork) { |  | ||||||
|     /* use translation callback */ |  | ||||||
|     rc = data->set.convtonetwork(buffer, length); |  | ||||||
|     if(rc != CURLE_OK) { |  | ||||||
|       failf(data, |  | ||||||
|             "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s", |  | ||||||
|             (int)rc, curl_easy_strerror(rc)); |  | ||||||
|     } |  | ||||||
|     return(rc); |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
| #ifdef HAVE_ICONV |  | ||||||
|     /* do the translation ourselves */ |  | ||||||
|     char *input_ptr, *output_ptr; |  | ||||||
|     size_t in_bytes, out_bytes, rc; |  | ||||||
|     int error; |  | ||||||
|  |  | ||||||
|     /* open an iconv conversion descriptor if necessary */ |  | ||||||
|     if(data->outbound_cd == (iconv_t)-1) { |  | ||||||
|       data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK, |  | ||||||
|                                      CURL_ICONV_CODESET_OF_HOST); |  | ||||||
|       if(data->outbound_cd == (iconv_t)-1) { |  | ||||||
|         error = ERRNO; |  | ||||||
|         failf(data, |  | ||||||
|               "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s", |  | ||||||
|                CURL_ICONV_CODESET_OF_NETWORK, |  | ||||||
|                CURL_ICONV_CODESET_OF_HOST, |  | ||||||
|                error, strerror(error)); |  | ||||||
|         return CURLE_CONV_FAILED; |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|     /* call iconv */ |  | ||||||
|     input_ptr = output_ptr = buffer; |  | ||||||
|     in_bytes = out_bytes = length; |  | ||||||
|     rc = iconv(data->outbound_cd, (const char**)&input_ptr, &in_bytes, |  | ||||||
|                &output_ptr, &out_bytes); |  | ||||||
|     if((rc == ICONV_ERROR) || (in_bytes != 0)) { |  | ||||||
|       error = ERRNO; |  | ||||||
|       failf(data, |  | ||||||
|         "The Curl_convert_to_network iconv call failed with errno %i: %s", |  | ||||||
|              error, strerror(error)); |  | ||||||
|       return CURLE_CONV_FAILED; |  | ||||||
|     } |  | ||||||
| #else |  | ||||||
|     failf(data, "CURLOPT_CONV_TO_NETWORK_FUNCTION callback required"); |  | ||||||
|     return CURLE_CONV_REQD; |  | ||||||
| #endif /* HAVE_ICONV */ |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   return CURLE_OK; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * Curl_convert_from_network() is an internal function |  | ||||||
|  * for performing ASCII conversions on non-ASCII platforms. |  | ||||||
|  */ |  | ||||||
| CURLcode Curl_convert_from_network(struct SessionHandle *data, |  | ||||||
|                                       char *buffer, size_t length) |  | ||||||
| { |  | ||||||
|   CURLcode rc; |  | ||||||
|  |  | ||||||
|   if(data->set.convfromnetwork) { |  | ||||||
|     /* use translation callback */ |  | ||||||
|     rc = data->set.convfromnetwork(buffer, length); |  | ||||||
|     if(rc != CURLE_OK) { |  | ||||||
|       failf(data, |  | ||||||
|             "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s", |  | ||||||
|             (int)rc, curl_easy_strerror(rc)); |  | ||||||
|     } |  | ||||||
|     return(rc); |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
| #ifdef HAVE_ICONV |  | ||||||
|     /* do the translation ourselves */ |  | ||||||
|     char *input_ptr, *output_ptr; |  | ||||||
|     size_t in_bytes, out_bytes, rc; |  | ||||||
|     int error; |  | ||||||
|  |  | ||||||
|     /* open an iconv conversion descriptor if necessary */ |  | ||||||
|     if(data->inbound_cd == (iconv_t)-1) { |  | ||||||
|       data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST, |  | ||||||
|                                     CURL_ICONV_CODESET_OF_NETWORK); |  | ||||||
|       if(data->inbound_cd == (iconv_t)-1) { |  | ||||||
|         error = ERRNO; |  | ||||||
|         failf(data, |  | ||||||
|               "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s", |  | ||||||
|               CURL_ICONV_CODESET_OF_HOST, |  | ||||||
|               CURL_ICONV_CODESET_OF_NETWORK, |  | ||||||
|               error, strerror(error)); |  | ||||||
|         return CURLE_CONV_FAILED; |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|     /* call iconv */ |  | ||||||
|     input_ptr = output_ptr = buffer; |  | ||||||
|     in_bytes = out_bytes = length; |  | ||||||
|     rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes, |  | ||||||
|                &output_ptr, &out_bytes); |  | ||||||
|     if((rc == ICONV_ERROR) || (in_bytes != 0)) { |  | ||||||
|       error = ERRNO; |  | ||||||
|       failf(data, |  | ||||||
|             "The Curl_convert_from_network iconv call failed with errno %i: %s", |  | ||||||
|             error, strerror(error)); |  | ||||||
|       return CURLE_CONV_FAILED; |  | ||||||
|     } |  | ||||||
| #else |  | ||||||
|     failf(data, "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback required"); |  | ||||||
|     return CURLE_CONV_REQD; |  | ||||||
| #endif /* HAVE_ICONV */ |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   return CURLE_OK; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * Curl_convert_from_utf8() is an internal function |  | ||||||
|  * for performing UTF-8 conversions on non-ASCII platforms. |  | ||||||
|  */ |  | ||||||
| CURLcode Curl_convert_from_utf8(struct SessionHandle *data, |  | ||||||
|                                      char *buffer, size_t length) |  | ||||||
| { |  | ||||||
|   CURLcode rc; |  | ||||||
|  |  | ||||||
|   if(data->set.convfromutf8) { |  | ||||||
|     /* use translation callback */ |  | ||||||
|     rc = data->set.convfromutf8(buffer, length); |  | ||||||
|     if(rc != CURLE_OK) { |  | ||||||
|       failf(data, |  | ||||||
|             "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s", |  | ||||||
|             (int)rc, curl_easy_strerror(rc)); |  | ||||||
|     } |  | ||||||
|     return(rc); |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
| #ifdef HAVE_ICONV |  | ||||||
|     /* do the translation ourselves */ |  | ||||||
|     const char *input_ptr; |  | ||||||
|     char *output_ptr; |  | ||||||
|     size_t in_bytes, out_bytes, rc; |  | ||||||
|     int error; |  | ||||||
|  |  | ||||||
|     /* open an iconv conversion descriptor if necessary */ |  | ||||||
|     if(data->utf8_cd == (iconv_t)-1) { |  | ||||||
|       data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST, |  | ||||||
|                                  CURL_ICONV_CODESET_FOR_UTF8); |  | ||||||
|       if(data->utf8_cd == (iconv_t)-1) { |  | ||||||
|         error = ERRNO; |  | ||||||
|         failf(data, |  | ||||||
|               "The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s", |  | ||||||
|               CURL_ICONV_CODESET_OF_HOST, |  | ||||||
|               CURL_ICONV_CODESET_FOR_UTF8, |  | ||||||
|               error, strerror(error)); |  | ||||||
|         return CURLE_CONV_FAILED; |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|     /* call iconv */ |  | ||||||
|     input_ptr = output_ptr = buffer; |  | ||||||
|     in_bytes = out_bytes = length; |  | ||||||
|     rc = iconv(data->utf8_cd, &input_ptr, &in_bytes, |  | ||||||
|                &output_ptr, &out_bytes); |  | ||||||
|     if((rc == ICONV_ERROR) || (in_bytes != 0)) { |  | ||||||
|       error = ERRNO; |  | ||||||
|       failf(data, |  | ||||||
|             "The Curl_convert_from_utf8 iconv call failed with errno %i: %s", |  | ||||||
|             error, strerror(error)); |  | ||||||
|       return CURLE_CONV_FAILED; |  | ||||||
|     } |  | ||||||
|     if(output_ptr < input_ptr) { |  | ||||||
|       /* null terminate the now shorter output string */ |  | ||||||
|       *output_ptr = 0x00; |  | ||||||
|     } |  | ||||||
| #else |  | ||||||
|     failf(data, "CURLOPT_CONV_FROM_UTF8_FUNCTION callback required"); |  | ||||||
|     return CURLE_CONV_REQD; |  | ||||||
| #endif /* HAVE_ICONV */ |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   return CURLE_OK; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
| static CURLcode easy_connection(struct SessionHandle *data, | static CURLcode easy_connection(struct SessionHandle *data, | ||||||
|                                 curl_socket_t *sfd, |                                 curl_socket_t *sfd, | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -29,11 +29,4 @@ void Curl_easy_addmulti(struct SessionHandle *data, void *multi); | |||||||
|  |  | ||||||
| void Curl_easy_initHandleData(struct SessionHandle *data); | void Curl_easy_initHandleData(struct SessionHandle *data); | ||||||
|  |  | ||||||
| CURLcode Curl_convert_to_network(struct SessionHandle *data, |  | ||||||
|                                  char *buffer, size_t length); |  | ||||||
| CURLcode Curl_convert_from_network(struct SessionHandle *data, |  | ||||||
|                                  char *buffer, size_t length); |  | ||||||
| CURLcode Curl_convert_from_utf8(struct SessionHandle *data, |  | ||||||
|                                  char *buffer, size_t length); |  | ||||||
|  |  | ||||||
| #endif /* __EASYIF_H */ | #endif /* __EASYIF_H */ | ||||||
|   | |||||||
							
								
								
									
										32
									
								
								lib/escape.c
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								lib/escape.c
									
									
									
									
									
								
							| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -31,10 +31,9 @@ | |||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include "curl_memory.h" | #include "curl_memory.h" | ||||||
| /* urldata.h and easyif.h are included for Curl_convert_... prototypes */ |  | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| #include "easyif.h" |  | ||||||
| #include "warnless.h" | #include "warnless.h" | ||||||
|  | #include "non-ascii.h" | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| @@ -90,11 +89,8 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) | |||||||
|   size_t newlen = alloc; |   size_t newlen = alloc; | ||||||
|   int strindex=0; |   int strindex=0; | ||||||
|   size_t length; |   size_t length; | ||||||
|  |   CURLcode res; | ||||||
|  |  | ||||||
| #ifndef CURL_DOES_CONVERSIONS |  | ||||||
|   /* avoid compiler warnings */ |  | ||||||
|   (void)handle; |  | ||||||
| #endif |  | ||||||
|   ns = malloc(alloc); |   ns = malloc(alloc); | ||||||
|   if(!ns) |   if(!ns) | ||||||
|     return NULL; |     return NULL; | ||||||
| @@ -103,10 +99,9 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) | |||||||
|   while(length--) { |   while(length--) { | ||||||
|     in = *string; |     in = *string; | ||||||
|  |  | ||||||
|     if (Curl_isunreserved(in)) { |     if(Curl_isunreserved(in)) | ||||||
|       /* just copy this */ |       /* just copy this */ | ||||||
|       ns[strindex++]=in; |       ns[strindex++]=in; | ||||||
|     } |  | ||||||
|     else { |     else { | ||||||
|       /* encode it */ |       /* encode it */ | ||||||
|       newlen += 2; /* the size grows with two, since this'll become a %XX */ |       newlen += 2; /* the size grows with two, since this'll become a %XX */ | ||||||
| @@ -122,15 +117,12 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |       res = Curl_convert_to_network(handle, &in, 1); | ||||||
| /* escape sequences are always in ASCII so convert them on non-ASCII hosts */ |       if(res) { | ||||||
|       if(!handle || |  | ||||||
|           (Curl_convert_to_network(handle, &in, 1) != CURLE_OK)) { |  | ||||||
|         /* Curl_convert_to_network calls failf if unsuccessful */ |         /* Curl_convert_to_network calls failf if unsuccessful */ | ||||||
|         free(ns); |         free(ns); | ||||||
|         return NULL; |         return NULL; | ||||||
|       } |       } | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
|       snprintf(&ns[strindex], 4, "%%%02X", in); |       snprintf(&ns[strindex], 4, "%%%02X", in); | ||||||
|  |  | ||||||
| @@ -156,11 +148,8 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length, | |||||||
|   unsigned char in; |   unsigned char in; | ||||||
|   int strindex=0; |   int strindex=0; | ||||||
|   unsigned long hex; |   unsigned long hex; | ||||||
|  |   CURLcode res; | ||||||
|  |  | ||||||
| #ifndef CURL_DOES_CONVERSIONS |  | ||||||
|   /* avoid compiler warnings */ |  | ||||||
|   (void)handle; |  | ||||||
| #endif |  | ||||||
|   if(!ns) |   if(!ns) | ||||||
|     return NULL; |     return NULL; | ||||||
|  |  | ||||||
| @@ -178,15 +167,12 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length, | |||||||
|  |  | ||||||
|       in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */ |       in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */ | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |       res = Curl_convert_from_network(handle, &in, 1); | ||||||
| /* escape sequences are always in ASCII so convert them on non-ASCII hosts */ |       if(res) { | ||||||
|       if(!handle || |  | ||||||
|           (Curl_convert_from_network(handle, &in, 1) != CURLE_OK)) { |  | ||||||
|         /* Curl_convert_from_network calls failf if unsuccessful */ |         /* Curl_convert_from_network calls failf if unsuccessful */ | ||||||
|         free(ns); |         free(ns); | ||||||
|         return NULL; |         return NULL; | ||||||
|       } |       } | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
|       string+=2; |       string+=2; | ||||||
|       alloc-=2; |       alloc-=2; | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								lib/file.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								lib/file.c
									
									
									
									
									
								
							| @@ -90,7 +90,8 @@ | |||||||
| /* The last #include file should be: */ | /* The last #include file should be: */ | ||||||
| #include "memdebug.h" | #include "memdebug.h" | ||||||
|  |  | ||||||
| #if defined(WIN32) || defined(MSDOS) || defined(__EMX__) || defined(__SYMBIAN32__) | #if defined(WIN32) || defined(MSDOS) || defined(__EMX__) || \ | ||||||
|  |   defined(__SYMBIAN32__) | ||||||
| #define DOS_FILESYSTEM 1 | #define DOS_FILESYSTEM 1 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -126,9 +127,10 @@ const struct Curl_handler Curl_handler_file = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   0,                                    /* defport */ |   0,                                    /* defport */ | ||||||
|   CURLPROTO_FILE,                       /* protocol */ |   CURLPROTO_FILE,                       /* protocol */ | ||||||
|   PROTOPT_BANPROXY                      /* flags */ |   PROTOPT_NONETWORK                     /* flags */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -245,8 +247,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done) | |||||||
|   actual_path = real_path; |   actual_path = real_path; | ||||||
|   if((actual_path[0] == '/') && |   if((actual_path[0] == '/') && | ||||||
|       actual_path[1] && |       actual_path[1] && | ||||||
|       (actual_path[2] == ':' || actual_path[2] == '|')) |      (actual_path[2] == ':' || actual_path[2] == '|')) { | ||||||
|   { |  | ||||||
|     actual_path[2] = ':'; |     actual_path[2] = ':'; | ||||||
|     actual_path++; |     actual_path++; | ||||||
|   } |   } | ||||||
| @@ -256,7 +257,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done) | |||||||
|     if(actual_path[i] == '/') |     if(actual_path[i] == '/') | ||||||
|       actual_path[i] = '\\'; |       actual_path[i] = '\\'; | ||||||
|  |  | ||||||
|   fd = open_readonly(actual_path, O_RDONLY|O_BINARY); /* no CR/LF translation */ |   fd = open_readonly(actual_path, O_RDONLY|O_BINARY); | ||||||
|   file->path = actual_path; |   file->path = actual_path; | ||||||
| #else | #else | ||||||
|   fd = open_readonly(real_path, O_RDONLY); |   fd = open_readonly(real_path, O_RDONLY); | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 2010-2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -55,21 +55,3 @@ void Curl_fileinfo_dtor(void *user, void *element) | |||||||
|  |  | ||||||
|   free(finfo); |   free(finfo); | ||||||
| } | } | ||||||
|  |  | ||||||
| struct curl_fileinfo *Curl_fileinfo_dup(const struct curl_fileinfo *src) |  | ||||||
| { |  | ||||||
|   struct curl_fileinfo *ptr = malloc(sizeof(struct curl_fileinfo)); |  | ||||||
|   if(!ptr) |  | ||||||
|     return NULL; |  | ||||||
|   *ptr = *src; |  | ||||||
|  |  | ||||||
|   ptr->b_data = malloc(src->b_size); |  | ||||||
|   if(!ptr->b_data) { |  | ||||||
|     free(ptr); |  | ||||||
|     return NULL; |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     memcpy(ptr->b_data, src->b_data, src->b_size); |  | ||||||
|     return ptr; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|   | |||||||
							
								
								
									
										309
									
								
								lib/formdata.c
									
									
									
									
									
								
							
							
						
						
									
										309
									
								
								lib/formdata.c
									
									
									
									
									
								
							| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -20,87 +20,6 @@ | |||||||
|  * |  * | ||||||
|  ***************************************************************************/ |  ***************************************************************************/ | ||||||
|  |  | ||||||
| /* |  | ||||||
|   Debug the form generator stand-alone by compiling this source file with: |  | ||||||
|  |  | ||||||
|   gcc -DHAVE_CONFIG_H -I../ -g -D_FORM_DEBUG -DCURLDEBUG -o formdata \ |  | ||||||
|     -I../include formdata.c strequal.c memdebug.c mprintf.c strerror.c |  | ||||||
|  |  | ||||||
|   (depending on circumstances you may need further externals added) |  | ||||||
|  |  | ||||||
|   run the 'formdata' executable the output should end with: |  | ||||||
|   All Tests seem to have worked ... |  | ||||||
|   and the following parts should be there: |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="simple_COPYCONTENTS" |  | ||||||
| value for simple COPYCONTENTS |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="COPYCONTENTS_+_CONTENTTYPE" |  | ||||||
| Content-Type: image/gif |  | ||||||
| value for COPYCONTENTS + CONTENTTYPE |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="PRNAME_+_NAMELENGTH_+_COPYNAME_+_CONTENTSLENGTH" |  | ||||||
| vlue for PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH |  | ||||||
| (or you might see P^@RNAME and v^@lue at the start) |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="simple_PTRCONTENTS" |  | ||||||
| value for simple PTRCONTENTS |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="PTRCONTENTS_+_CONTENTSLENGTH" |  | ||||||
| vlue for PTRCONTENTS + CONTENTSLENGTH |  | ||||||
| (or you might see v^@lue at the start) |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="PTRCONTENTS_+_CONTENTSLENGTH_+_CONTENTTYPE" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| vlue for PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE |  | ||||||
| (or you might see v^@lue at the start) |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="FILE1_+_CONTENTTYPE"; filename="formdata.h" |  | ||||||
| Content-Type: text/html |  | ||||||
| ... |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="FILE1_+_FILE2" |  | ||||||
| Content-Type: multipart/mixed, boundary=curlz1s0dkticx49MV1KGcYP5cvfSsz |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="formdata.h" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="Makefile.b32" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="FILE1_+_FILE2_+_FILE3" |  | ||||||
| Content-Type: multipart/mixed, boundary=curlirkYPmPwu6FrJ1vJ1u1BmtIufh1 |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="formdata.h" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="Makefile.b32" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="formdata.h" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
|  |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="ARRAY: FILE1_+_FILE2_+_FILE3" |  | ||||||
| Content-Type: multipart/mixed, boundary=curlirkYPmPwu6FrJ1vJ1u1BmtIufh1 |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="formdata.h" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="Makefile.b32" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
| Content-Disposition: attachment; filename="formdata.h" |  | ||||||
| Content-Type: application/octet-stream |  | ||||||
| ... |  | ||||||
|  |  | ||||||
| Content-Disposition: form-data; name="FILECONTENT" |  | ||||||
| ... |  | ||||||
|  |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "setup.h" | #include "setup.h" | ||||||
| #include <curl/curl.h> | #include <curl/curl.h> | ||||||
|  |  | ||||||
| @@ -118,7 +37,6 @@ Content-Disposition: form-data; name="FILECONTENT" | |||||||
| #include <libgen.h> | #include <libgen.h> | ||||||
| #endif | #endif | ||||||
| #include "urldata.h" /* for struct SessionHandle */ | #include "urldata.h" /* for struct SessionHandle */ | ||||||
| #include "easyif.h" /* for Curl_convert_... prototypes */ |  | ||||||
| #include "formdata.h" | #include "formdata.h" | ||||||
| #include "curl_rand.h" | #include "curl_rand.h" | ||||||
| #include "strequal.h" | #include "strequal.h" | ||||||
| @@ -383,7 +301,7 @@ static char *memdup(const char *src, size_t buffer_length) | |||||||
|  * CURL_FORMADD_NULL           if a null pointer was given for a char |  * CURL_FORMADD_NULL           if a null pointer was given for a char | ||||||
|  * CURL_FORMADD_MEMORY         if the allocation of a FormInfo struct failed |  * CURL_FORMADD_MEMORY         if the allocation of a FormInfo struct failed | ||||||
|  * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used |  * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used | ||||||
|  * CURL_FORMADD_INCOMPLETE     if the some FormInfo is not complete (or an error) |  * CURL_FORMADD_INCOMPLETE     if the some FormInfo is not complete (or error) | ||||||
|  * CURL_FORMADD_MEMORY         if a HttpPost struct cannot be allocated |  * CURL_FORMADD_MEMORY         if a HttpPost struct cannot be allocated | ||||||
|  * CURL_FORMADD_MEMORY         if some allocation for string copying failed. |  * CURL_FORMADD_MEMORY         if some allocation for string copying failed. | ||||||
|  * CURL_FORMADD_ILLEGAL_ARRAY  if an illegal option is used in an array |  * CURL_FORMADD_ILLEGAL_ARRAY  if an illegal option is used in an array | ||||||
| @@ -461,8 +379,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, | |||||||
|        */ |        */ | ||||||
|     case CURLFORM_PTRNAME: |     case CURLFORM_PTRNAME: | ||||||
| #ifdef CURL_DOES_CONVERSIONS | #ifdef CURL_DOES_CONVERSIONS | ||||||
|       /* treat CURLFORM_PTR like CURLFORM_COPYNAME so we'll |       /* Treat CURLFORM_PTR like CURLFORM_COPYNAME so that libcurl will copy | ||||||
|          have safe memory for the eventual conversion */ |        * the data in all cases so that we'll have safe memory for the eventual | ||||||
|  |        * conversion. | ||||||
|  |        */ | ||||||
| #else | #else | ||||||
|       current_form->flags |= HTTPPOST_PTRNAME; /* fall through */ |       current_form->flags |= HTTPPOST_PTRNAME; /* fall through */ | ||||||
| #endif | #endif | ||||||
| @@ -817,6 +737,8 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, | |||||||
|  |  | ||||||
| /* | /* | ||||||
|  * curl_formadd() is a public API to add a section to the multipart formpost. |  * curl_formadd() is a public API to add a section to the multipart formpost. | ||||||
|  |  * | ||||||
|  |  * @unittest: 1308 | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| CURLFORMcode curl_formadd(struct curl_httppost **httppost, | CURLFORMcode curl_formadd(struct curl_httppost **httppost, | ||||||
| @@ -934,40 +856,12 @@ void Curl_formclean(struct FormData **form_ptr) | |||||||
|   *form_ptr = NULL; |   *form_ptr = NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
| /* |  | ||||||
|  * Curl_formcovert() is used from http.c, this converts any |  | ||||||
|    form items that need to be sent in the network encoding. |  | ||||||
|    Returns CURLE_OK on success. |  | ||||||
|  */ |  | ||||||
| CURLcode Curl_formconvert(struct SessionHandle *data, struct FormData *form) |  | ||||||
| { |  | ||||||
|   struct FormData *next; |  | ||||||
|   CURLcode rc; |  | ||||||
|  |  | ||||||
|   if(!form) |  | ||||||
|     return CURLE_OK; |  | ||||||
|  |  | ||||||
|   if(!data) |  | ||||||
|     return CURLE_BAD_FUNCTION_ARGUMENT; |  | ||||||
|  |  | ||||||
|   do { |  | ||||||
|     next=form->next;  /* the following form line */ |  | ||||||
|     if(form->type == FORM_DATA) { |  | ||||||
|       rc = Curl_convert_to_network(data, form->line, form->length); |  | ||||||
|       /* Curl_convert_to_network calls failf if unsuccessful */ |  | ||||||
|       if(rc != CURLE_OK) |  | ||||||
|         return rc; |  | ||||||
|     } |  | ||||||
|   } while((form = next) != NULL); /* continue */ |  | ||||||
|   return CURLE_OK; |  | ||||||
| } |  | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * curl_formget() |  * curl_formget() | ||||||
|  * Serialize a curl_httppost struct. |  * Serialize a curl_httppost struct. | ||||||
|  * Returns 0 on success. |  * Returns 0 on success. | ||||||
|  |  * | ||||||
|  |  * @unittest: 1308 | ||||||
|  */ |  */ | ||||||
| int curl_formget(struct curl_httppost *form, void *arg, | int curl_formget(struct curl_httppost *form, void *arg, | ||||||
|                  curl_formget_callback append) |                  curl_formget_callback append) | ||||||
| @@ -981,7 +875,7 @@ int curl_formget(struct curl_httppost *form, void *arg, | |||||||
|     return (int)rc; |     return (int)rc; | ||||||
|  |  | ||||||
|   for(ptr = data; ptr; ptr = ptr->next) { |   for(ptr = data; ptr; ptr = ptr->next) { | ||||||
|     if(ptr->type == FORM_FILE) { |     if((ptr->type == FORM_FILE) || (ptr->type == FORM_CALLBACK)) { | ||||||
|       char buffer[8192]; |       char buffer[8192]; | ||||||
|       size_t nread; |       size_t nread; | ||||||
|       struct Form temp; |       struct Form temp; | ||||||
| @@ -997,7 +891,7 @@ int curl_formget(struct curl_httppost *form, void *arg, | |||||||
|           Curl_formclean(&data); |           Curl_formclean(&data); | ||||||
|           return -1; |           return -1; | ||||||
|         } |         } | ||||||
|       } while(nread == sizeof(buffer)); |       } while(nread); | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
|       if(ptr->length != append(arg, ptr->line, ptr->length)) { |       if(ptr->length != append(arg, ptr->line, ptr->length)) { | ||||||
| @@ -1240,6 +1134,7 @@ CURLcode Curl_getformdata(struct SessionHandle *data, | |||||||
|         /* it should be noted that for the HTTPPOST_FILENAME and |         /* it should be noted that for the HTTPPOST_FILENAME and | ||||||
|            HTTPPOST_CALLBACK cases the ->showfilename struct member is always |            HTTPPOST_CALLBACK cases the ->showfilename struct member is always | ||||||
|            assigned at this point */ |            assigned at this point */ | ||||||
|  |         if(post->showfilename || (post->flags & HTTPPOST_FILENAME)) { | ||||||
|           char *filebasename= |           char *filebasename= | ||||||
|             (!post->showfilename)?strippath(post->contents):NULL; |             (!post->showfilename)?strippath(post->contents):NULL; | ||||||
|  |  | ||||||
| @@ -1249,6 +1144,7 @@ CURLcode Curl_getformdata(struct SessionHandle *data, | |||||||
|                                  filebasename)); |                                  filebasename)); | ||||||
|           if(filebasename) |           if(filebasename) | ||||||
|             free(filebasename); |             free(filebasename); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if(result) |         if(result) | ||||||
|           break; |           break; | ||||||
| @@ -1407,8 +1303,17 @@ static size_t readfromfile(struct Form *form, char *buffer, | |||||||
|   size_t nread; |   size_t nread; | ||||||
|   bool callback = (bool)(form->data->type == FORM_CALLBACK); |   bool callback = (bool)(form->data->type == FORM_CALLBACK); | ||||||
|  |  | ||||||
|   if(callback) |   if(callback) { | ||||||
|  |     if(form->fread_func == ZERO_NULL) | ||||||
|  |       return 0; | ||||||
|  |     else | ||||||
|       nread = form->fread_func(buffer, 1, size, form->data->line); |       nread = form->fread_func(buffer, 1, size, form->data->line); | ||||||
|  |  | ||||||
|  |     if(nread > size) | ||||||
|  |       /* the read callback can return a value larger than the buffer but | ||||||
|  |          treat any such as no data in this case */ | ||||||
|  |       nread = 0; | ||||||
|  |   } | ||||||
|   else { |   else { | ||||||
|     if(!form->fp) { |     if(!form->fp) { | ||||||
|       /* this file hasn't yet been opened */ |       /* this file hasn't yet been opened */ | ||||||
| @@ -1418,9 +1323,9 @@ static size_t readfromfile(struct Form *form, char *buffer, | |||||||
|     } |     } | ||||||
|     nread = fread(buffer, 1, size, form->fp); |     nread = fread(buffer, 1, size, form->fp); | ||||||
|   } |   } | ||||||
|   if(!nread || nread > size) { |   if(!nread) { | ||||||
|     /* this is the last chunk from the file, move on */ |     /* this is the last chunk from the file, move on */ | ||||||
|     if(!callback) { |     if(form->fp) { | ||||||
|       fclose(form->fp); |       fclose(form->fp); | ||||||
|       form->fp = NULL; |       form->fp = NULL; | ||||||
|     } |     } | ||||||
| @@ -1507,168 +1412,6 @@ char *Curl_formpostheader(void *formp, size_t *len) | |||||||
|   return header; |   return header; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifdef _FORM_DEBUG |  | ||||||
| int FormAddTest(const char * errormsg, |  | ||||||
|                  struct curl_httppost **httppost, |  | ||||||
|                  struct curl_httppost **last_post, |  | ||||||
|                  ...) |  | ||||||
| { |  | ||||||
|   int result; |  | ||||||
|   va_list arg; |  | ||||||
|   va_start(arg, last_post); |  | ||||||
|   if((result = FormAdd(httppost, last_post, arg))) |  | ||||||
|     fprintf (stderr, "ERROR doing FormAdd ret: %d action: %s\n", result, |  | ||||||
|              errormsg); |  | ||||||
|   va_end(arg); |  | ||||||
|   return result; |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| int main(int argc, argv_item_t argv[]) |  | ||||||
| { |  | ||||||
|   char name1[] = "simple_COPYCONTENTS"; |  | ||||||
|   char name2[] = "COPYCONTENTS_+_CONTENTTYPE"; |  | ||||||
|   char name3[] = "PTRNAME_+_NAMELENGTH_+_COPYNAME_+_CONTENTSLENGTH"; |  | ||||||
|   char name4[] = "simple_PTRCONTENTS"; |  | ||||||
|   char name5[] = "PTRCONTENTS_+_CONTENTSLENGTH"; |  | ||||||
|   char name6[] = "PTRCONTENTS_+_CONTENTSLENGTH_+_CONTENTTYPE"; |  | ||||||
|   char name7[] = "FILE1_+_CONTENTTYPE"; |  | ||||||
|   char name8[] = "FILE1_+_FILE2"; |  | ||||||
|   char name9[] = "FILE1_+_FILE2_+_FILE3"; |  | ||||||
|   char name10[] = "ARRAY: FILE1_+_FILE2_+_FILE3"; |  | ||||||
|   char name11[] = "FILECONTENT"; |  | ||||||
|   char value1[] = "value for simple COPYCONTENTS"; |  | ||||||
|   char value2[] = "value for COPYCONTENTS + CONTENTTYPE"; |  | ||||||
|   char value3[] = "value for PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH"; |  | ||||||
|   char value4[] = "value for simple PTRCONTENTS"; |  | ||||||
|   char value5[] = "value for PTRCONTENTS + CONTENTSLENGTH"; |  | ||||||
|   char value6[] = "value for PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE"; |  | ||||||
|   char value7[] = "formdata.h"; |  | ||||||
|   char value8[] = "Makefile.b32"; |  | ||||||
|   char type2[] = "image/gif"; |  | ||||||
|   char type6[] = "text/plain"; |  | ||||||
|   char type7[] = "text/html"; |  | ||||||
|   int name3length = strlen(name3); |  | ||||||
|   int value3length = strlen(value3); |  | ||||||
|   int value5length = strlen(value5); |  | ||||||
|   int value6length = strlen(value6); |  | ||||||
|   int errors = 0; |  | ||||||
|   CURLcode rc; |  | ||||||
|   curl_off_t size; |  | ||||||
|   size_t nread; |  | ||||||
|   char buffer[4096]; |  | ||||||
|   struct curl_httppost *httppost=NULL; |  | ||||||
|   struct curl_httppost *last_post=NULL; |  | ||||||
|   struct curl_forms forms[4]; |  | ||||||
|  |  | ||||||
|   struct FormData *form; |  | ||||||
|   struct Form formread; |  | ||||||
|  |  | ||||||
|   (void) argc; |  | ||||||
|   (void) argv; |  | ||||||
|  |  | ||||||
|   Curl_srand();         /* Because we do not call curl_global_init() here. */ |  | ||||||
|  |  | ||||||
|   if(FormAddTest("simple COPYCONTENTS test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name1, CURLFORM_COPYCONTENTS, value1, |  | ||||||
|                   CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   if(FormAddTest("COPYCONTENTS  + CONTENTTYPE test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name2, CURLFORM_COPYCONTENTS, value2, |  | ||||||
|                   CURLFORM_CONTENTTYPE, type2, CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   /* make null character at start to check that contentslength works |  | ||||||
|      correctly */ |  | ||||||
|   name3[1] = '\0'; |  | ||||||
|   value3[1] = '\0'; |  | ||||||
|   if(FormAddTest("PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH test", |  | ||||||
|                   &httppost, &last_post, |  | ||||||
|                   CURLFORM_PTRNAME, name3, CURLFORM_COPYCONTENTS, value3, |  | ||||||
|                   CURLFORM_CONTENTSLENGTH, value3length, |  | ||||||
|                   CURLFORM_NAMELENGTH, name3length, CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   if(FormAddTest("simple PTRCONTENTS test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name4, CURLFORM_PTRCONTENTS, value4, |  | ||||||
|                   CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   /* make null character at start to check that contentslength works |  | ||||||
|      correctly */ |  | ||||||
|   value5[1] = '\0'; |  | ||||||
|   if(FormAddTest("PTRCONTENTS + CONTENTSLENGTH test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name5, CURLFORM_PTRCONTENTS, value5, |  | ||||||
|                   CURLFORM_CONTENTSLENGTH, value5length, CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   /* make null character at start to check that contentslength works |  | ||||||
|      correctly */ |  | ||||||
|   value6[1] = '\0'; |  | ||||||
|   if(FormAddTest("PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE test", |  | ||||||
|                   &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name6, CURLFORM_PTRCONTENTS, value6, |  | ||||||
|                   CURLFORM_CONTENTSLENGTH, value6length, |  | ||||||
|                   CURLFORM_CONTENTTYPE, type6, CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   if(FormAddTest("FILE + CONTENTTYPE test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name7, CURLFORM_FILE, value7, |  | ||||||
|                   CURLFORM_CONTENTTYPE, type7, CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   if(FormAddTest("FILE1 + FILE2 test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name8, CURLFORM_FILE, value7, |  | ||||||
|                   CURLFORM_FILE, value8, CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   if(FormAddTest("FILE1 + FILE2 + FILE3 test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name9, CURLFORM_FILE, value7, |  | ||||||
|                   CURLFORM_FILE, value8, CURLFORM_FILE, value7, CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   forms[0].option = CURLFORM_FILE; |  | ||||||
|   forms[0].value  = value7; |  | ||||||
|   forms[1].option = CURLFORM_FILE; |  | ||||||
|   forms[1].value  = value8; |  | ||||||
|   forms[2].option = CURLFORM_FILE; |  | ||||||
|   forms[2].value  = value7; |  | ||||||
|   forms[3].option  = CURLFORM_END; |  | ||||||
|   if(FormAddTest("FILE1 + FILE2 + FILE3 ARRAY test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name10, CURLFORM_ARRAY, forms, |  | ||||||
|                   CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|   if(FormAddTest("FILECONTENT test", &httppost, &last_post, |  | ||||||
|                   CURLFORM_COPYNAME, name11, CURLFORM_FILECONTENT, value7, |  | ||||||
|                   CURLFORM_END)) |  | ||||||
|     ++errors; |  | ||||||
|  |  | ||||||
|   rc = Curl_getformdata(NULL, &form, httppost, NULL, &size); |  | ||||||
|   if(rc != CURLE_OK) { |  | ||||||
|     if(rc != CURLE_READ_ERROR) { |  | ||||||
|       const char *errortext = curl_easy_strerror(rc); |  | ||||||
|       fprintf(stdout, "\n==> Curl_getformdata error: %s\n", errortext); |  | ||||||
|     } |  | ||||||
|     return 0; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   Curl_FormInit(&formread, form); |  | ||||||
|  |  | ||||||
|   for(;;) { |  | ||||||
|     nread = Curl_FormReader(buffer, 1, sizeof(buffer), |  | ||||||
|                             (FILE *)&formread); |  | ||||||
|  |  | ||||||
|     if(nread < 1) |  | ||||||
|       break; |  | ||||||
|     fwrite(buffer, nread, 1, stdout); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   fprintf(stdout, "size: "); |  | ||||||
|   fprintf(stdout, "%" FORMAT_OFF_T, size); |  | ||||||
|   fprintf(stdout, "\n"); |  | ||||||
|   if(errors) |  | ||||||
|     fprintf(stdout, "\n==> %d Test(s) failed!\n", errors); |  | ||||||
|   else |  | ||||||
|     fprintf(stdout, "\nAll Tests seem to have worked (please check output)\n"); |  | ||||||
|  |  | ||||||
|   return 0; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #endif  /* _FORM_DEBUG */ |  | ||||||
|  |  | ||||||
| #else  /* CURL_DISABLE_HTTP */ | #else  /* CURL_DISABLE_HTTP */ | ||||||
| CURLFORMcode curl_formadd(struct curl_httppost **httppost, | CURLFORMcode curl_formadd(struct curl_httppost **httppost, | ||||||
|                           struct curl_httppost **last_post, |                           struct curl_httppost **last_post, | ||||||
|   | |||||||
							
								
								
									
										95
									
								
								lib/ftp.c
									
									
									
									
									
								
							
							
						
						
									
										95
									
								
								lib/ftp.c
									
									
									
									
									
								
							| @@ -61,8 +61,6 @@ | |||||||
| #include <curl/curl.h> | #include <curl/curl.h> | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| #include "sendf.h" | #include "sendf.h" | ||||||
| #include "easyif.h" /* for Curl_convert_... prototypes */ |  | ||||||
|  |  | ||||||
| #include "if2ip.h" | #include "if2ip.h" | ||||||
| #include "hostip.h" | #include "hostip.h" | ||||||
| #include "progress.h" | #include "progress.h" | ||||||
| @@ -94,6 +92,7 @@ | |||||||
| #include "speedcheck.h" | #include "speedcheck.h" | ||||||
| #include "warnless.h" | #include "warnless.h" | ||||||
| #include "http_proxy.h" | #include "http_proxy.h" | ||||||
|  | #include "non-ascii.h" | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| @@ -179,9 +178,10 @@ const struct Curl_handler Curl_handler_ftp = { | |||||||
|   ftp_getsock,                     /* doing_getsock */ |   ftp_getsock,                     /* doing_getsock */ | ||||||
|   ZERO_NULL,                       /* perform_getsock */ |   ZERO_NULL,                       /* perform_getsock */ | ||||||
|   ftp_disconnect,                  /* disconnect */ |   ftp_disconnect,                  /* disconnect */ | ||||||
|  |   ZERO_NULL,                       /* readwrite */ | ||||||
|   PORT_FTP,                        /* defport */ |   PORT_FTP,                        /* defport */ | ||||||
|   CURLPROTO_FTP,                   /* protocol */ |   CURLPROTO_FTP,                   /* protocol */ | ||||||
|   PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */ |   PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD /* flags */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -203,9 +203,11 @@ const struct Curl_handler Curl_handler_ftps = { | |||||||
|   ftp_getsock,                     /* doing_getsock */ |   ftp_getsock,                     /* doing_getsock */ | ||||||
|   ZERO_NULL,                       /* perform_getsock */ |   ZERO_NULL,                       /* perform_getsock */ | ||||||
|   ftp_disconnect,                  /* disconnect */ |   ftp_disconnect,                  /* disconnect */ | ||||||
|  |   ZERO_NULL,                       /* readwrite */ | ||||||
|   PORT_FTPS,                       /* defport */ |   PORT_FTPS,                       /* defport */ | ||||||
|   CURLPROTO_FTP | CURLPROTO_FTPS,  /* protocol */ |   CURLPROTO_FTP | CURLPROTO_FTPS,  /* protocol */ | ||||||
|   PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */ |   PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION | | ||||||
|  |   PROTOPT_NEEDSPWD /* flags */ | ||||||
| }; | }; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -227,6 +229,7 @@ static const struct Curl_handler Curl_handler_ftp_proxy = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_FTP,                             /* defport */ |   PORT_FTP,                             /* defport */ | ||||||
|   CURLPROTO_HTTP,                       /* protocol */ |   CURLPROTO_HTTP,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
| @@ -251,6 +254,7 @@ static const struct Curl_handler Curl_handler_ftps_proxy = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_FTPS,                            /* defport */ |   PORT_FTPS,                            /* defport */ | ||||||
|   CURLPROTO_HTTP,                       /* protocol */ |   CURLPROTO_HTTP,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
| @@ -339,7 +343,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn) | |||||||
|     if(timeout_ms < interval_ms) |     if(timeout_ms < interval_ms) | ||||||
|       interval_ms = timeout_ms; |       interval_ms = timeout_ms; | ||||||
|  |  | ||||||
|     switch (Curl_socket_ready(sock, CURL_SOCKET_BAD, (int)interval_ms)) { |     switch (Curl_socket_ready(sock, CURL_SOCKET_BAD, interval_ms)) { | ||||||
|     case -1: /* error */ |     case -1: /* error */ | ||||||
|       /* let's die here */ |       /* let's die here */ | ||||||
|       failf(data, "Error while waiting for server connect"); |       failf(data, "Error while waiting for server connect"); | ||||||
| @@ -353,7 +357,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn) | |||||||
|  |  | ||||||
|         s=accept(sock, (struct sockaddr *) &add, &size); |         s=accept(sock, (struct sockaddr *) &add, &size); | ||||||
|       } |       } | ||||||
|       sclose(sock); /* close the first socket */ |       Curl_closesocket(conn, sock); /* close the first socket */ | ||||||
|  |  | ||||||
|       if(CURL_SOCKET_BAD == s) { |       if(CURL_SOCKET_BAD == s) { | ||||||
|         failf(data, "Error accept()ing server connect"); |         failf(data, "Error accept()ing server connect"); | ||||||
| @@ -513,7 +517,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */ | |||||||
|        */ |        */ | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
|       switch (Curl_socket_ready(sockfd, CURL_SOCKET_BAD, (int)interval_ms)) { |       switch (Curl_socket_ready(sockfd, CURL_SOCKET_BAD, interval_ms)) { | ||||||
|       case -1: /* select() error, stop reading */ |       case -1: /* select() error, stop reading */ | ||||||
|         failf(data, "FTP response aborted due to select/poll error: %d", |         failf(data, "FTP response aborted due to select/poll error: %d", | ||||||
|               SOCKERRNO); |               SOCKERRNO); | ||||||
| @@ -766,13 +770,12 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|         port_min = port_max = 0; |         port_min = port_max = 0; | ||||||
|         strcpy(addr, string_ftpport); |         strcpy(addr, string_ftpport); | ||||||
|         ip_end = NULL; /* this got no port ! */ |         ip_end = NULL; /* this got no port ! */ | ||||||
|       } else |       } | ||||||
|  |       else | ||||||
| #endif | #endif | ||||||
|       { |  | ||||||
|         /* (ipv4|domain|interface):port(-range) */ |         /* (ipv4|domain|interface):port(-range) */ | ||||||
|         strncpy(addr, string_ftpport, ip_end - ip_start ); |         strncpy(addr, string_ftpport, ip_end - ip_start ); | ||||||
|     } |     } | ||||||
|     } |  | ||||||
|     else |     else | ||||||
|       /* ipv4|interface */ |       /* ipv4|interface */ | ||||||
|       strcpy(addr, string_ftpport); |       strcpy(addr, string_ftpport); | ||||||
| @@ -824,8 +827,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|         free(addr); |         free(addr); | ||||||
|       return CURLE_FTP_PORT_FAILED; |       return CURLE_FTP_PORT_FAILED; | ||||||
|     } |     } | ||||||
|     switch(sa->sa_family) |     switch(sa->sa_family) { | ||||||
|     { |  | ||||||
| #ifdef ENABLE_IPV6 | #ifdef ENABLE_IPV6 | ||||||
|     case AF_INET6: |     case AF_INET6: | ||||||
|       Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf)); |       Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf)); | ||||||
| @@ -841,7 +843,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|   /* resolv ip/host to ip */ |   /* resolv ip/host to ip */ | ||||||
|   rc = Curl_resolv(conn, host, 0, &h); |   rc = Curl_resolv(conn, host, 0, &h); | ||||||
|   if(rc == CURLRESOLV_PENDING) |   if(rc == CURLRESOLV_PENDING) | ||||||
|     (void)Curl_wait_for_resolv(conn, &h); |     (void)Curl_resolver_wait_resolv(conn, &h); | ||||||
|   if(h) { |   if(h) { | ||||||
|     res = h->addr; |     res = h->addr; | ||||||
|     /* when we return from this function, we can forget about this entry |     /* when we return from this function, we can forget about this entry | ||||||
| @@ -910,7 +912,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|         if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { |         if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { | ||||||
|           failf(data, "getsockname() failed: %s", |           failf(data, "getsockname() failed: %s", | ||||||
|                 Curl_strerror(conn, SOCKERRNO) ); |                 Curl_strerror(conn, SOCKERRNO) ); | ||||||
|           sclose(portsock); |           Curl_closesocket(conn, portsock); | ||||||
|           return CURLE_FTP_PORT_FAILED; |           return CURLE_FTP_PORT_FAILED; | ||||||
|         } |         } | ||||||
|         port = port_min; |         port = port_min; | ||||||
| @@ -919,7 +921,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|       else if(error != EADDRINUSE && error != EACCES) { |       else if(error != EADDRINUSE && error != EACCES) { | ||||||
|         failf(data, "bind(port=%hu) failed: %s", port, |         failf(data, "bind(port=%hu) failed: %s", port, | ||||||
|               Curl_strerror(conn, error) ); |               Curl_strerror(conn, error) ); | ||||||
|         sclose(portsock); |         Curl_closesocket(conn, portsock); | ||||||
|         return CURLE_FTP_PORT_FAILED; |         return CURLE_FTP_PORT_FAILED; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| @@ -932,7 +934,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|   /* maybe all ports were in use already*/ |   /* maybe all ports were in use already*/ | ||||||
|   if(port > port_max) { |   if(port > port_max) { | ||||||
|     failf(data, "bind() failed, we ran out of ports!"); |     failf(data, "bind() failed, we ran out of ports!"); | ||||||
|     sclose(portsock); |     Curl_closesocket(conn, portsock); | ||||||
|     return CURLE_FTP_PORT_FAILED; |     return CURLE_FTP_PORT_FAILED; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -942,7 +944,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|   if(getsockname(portsock, (struct sockaddr *)sa, &sslen)) { |   if(getsockname(portsock, (struct sockaddr *)sa, &sslen)) { | ||||||
|     failf(data, "getsockname() failed: %s", |     failf(data, "getsockname() failed: %s", | ||||||
|           Curl_strerror(conn, SOCKERRNO) ); |           Curl_strerror(conn, SOCKERRNO) ); | ||||||
|     sclose(portsock); |     Curl_closesocket(conn, portsock); | ||||||
|     return CURLE_FTP_PORT_FAILED; |     return CURLE_FTP_PORT_FAILED; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -950,7 +952,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|  |  | ||||||
|   if(listen(portsock, 1)) { |   if(listen(portsock, 1)) { | ||||||
|     failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO)); |     failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO)); | ||||||
|     sclose(portsock); |     Curl_closesocket(conn, portsock); | ||||||
|     return CURLE_FTP_PORT_FAILED; |     return CURLE_FTP_PORT_FAILED; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -1036,7 +1038,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, | |||||||
|      the cleanup function will close it in case we fail before the true |      the cleanup function will close it in case we fail before the true | ||||||
|      secondary stuff is made */ |      secondary stuff is made */ | ||||||
|   if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) |   if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) | ||||||
|     sclose(conn->sock[SECONDARYSOCKET]); |     Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]); | ||||||
|   conn->sock[SECONDARYSOCKET] = portsock; |   conn->sock[SECONDARYSOCKET] = portsock; | ||||||
|  |  | ||||||
|   /* this tcpconnect assignment below is a hackish work-around to make the |   /* this tcpconnect assignment below is a hackish work-around to make the | ||||||
| @@ -1557,10 +1559,10 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, | |||||||
|           newport = (unsigned short)(num & 0xffff); |           newport = (unsigned short)(num & 0xffff); | ||||||
|  |  | ||||||
|           if(conn->bits.tunnel_proxy || |           if(conn->bits.tunnel_proxy || | ||||||
|              data->set.proxytype == CURLPROXY_SOCKS5 || |              conn->proxytype == CURLPROXY_SOCKS5 || | ||||||
|              data->set.proxytype == CURLPROXY_SOCKS5_HOSTNAME || |              conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || | ||||||
|              data->set.proxytype == CURLPROXY_SOCKS4 || |              conn->proxytype == CURLPROXY_SOCKS4 || | ||||||
|              data->set.proxytype == CURLPROXY_SOCKS4A) |              conn->proxytype == CURLPROXY_SOCKS4A) | ||||||
|             /* proxy tunnel -> use other host info because ip_addr_str is the |             /* proxy tunnel -> use other host info because ip_addr_str is the | ||||||
|                proxy address not the ftp host */ |                proxy address not the ftp host */ | ||||||
|             snprintf(newhost, sizeof(newhost), "%s", conn->host.name); |             snprintf(newhost, sizeof(newhost), "%s", conn->host.name); | ||||||
| @@ -1613,10 +1615,10 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, | |||||||
|             ip[0], ip[1], ip[2], ip[3], |             ip[0], ip[1], ip[2], ip[3], | ||||||
|             conn->ip_addr_str); |             conn->ip_addr_str); | ||||||
|       if(conn->bits.tunnel_proxy || |       if(conn->bits.tunnel_proxy || | ||||||
|           data->set.proxytype == CURLPROXY_SOCKS5 || |          conn->proxytype == CURLPROXY_SOCKS5 || | ||||||
|           data->set.proxytype == CURLPROXY_SOCKS5_HOSTNAME || |          conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME || | ||||||
|           data->set.proxytype == CURLPROXY_SOCKS4 || |          conn->proxytype == CURLPROXY_SOCKS4 || | ||||||
|           data->set.proxytype == CURLPROXY_SOCKS4A) |          conn->proxytype == CURLPROXY_SOCKS4A) | ||||||
|         /* proxy tunnel -> use other host info because ip_addr_str is the |         /* proxy tunnel -> use other host info because ip_addr_str is the | ||||||
|            proxy address not the ftp host */ |            proxy address not the ftp host */ | ||||||
|         snprintf(newhost, sizeof(newhost), "%s", conn->host.name); |         snprintf(newhost, sizeof(newhost), "%s", conn->host.name); | ||||||
| @@ -1657,7 +1659,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, | |||||||
|     if(rc == CURLRESOLV_PENDING) |     if(rc == CURLRESOLV_PENDING) | ||||||
|       /* BLOCKING, ignores the return code but 'addr' will be NULL in |       /* BLOCKING, ignores the return code but 'addr' will be NULL in | ||||||
|          case of failure */ |          case of failure */ | ||||||
|       (void)Curl_wait_for_resolv(conn, &addr); |       (void)Curl_resolver_wait_resolv(conn, &addr); | ||||||
|  |  | ||||||
|     connectport = |     connectport = | ||||||
|       (unsigned short)conn->port; /* we connect to the proxy's port */ |       (unsigned short)conn->port; /* we connect to the proxy's port */ | ||||||
| @@ -1673,7 +1675,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, | |||||||
|     rc = Curl_resolv(conn, newhost, newport, &addr); |     rc = Curl_resolv(conn, newhost, newport, &addr); | ||||||
|     if(rc == CURLRESOLV_PENDING) |     if(rc == CURLRESOLV_PENDING) | ||||||
|       /* BLOCKING */ |       /* BLOCKING */ | ||||||
|       (void)Curl_wait_for_resolv(conn, &addr); |       (void)Curl_resolver_wait_resolv(conn, &addr); | ||||||
|  |  | ||||||
|     connectport = newport; /* we connect to the remote port */ |     connectport = newport; /* we connect to the remote port */ | ||||||
|  |  | ||||||
| @@ -1718,7 +1720,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, | |||||||
|     /* this just dumps information about this second connection */ |     /* this just dumps information about this second connection */ | ||||||
|     ftp_pasv_verbose(conn, conninfo, newhost, connectport); |     ftp_pasv_verbose(conn, conninfo, newhost, connectport); | ||||||
|  |  | ||||||
|   switch(data->set.proxytype) { |   switch(conn->proxytype) { | ||||||
|     /* FIX: this MUST wait for a proper connect first if 'connected' is |     /* FIX: this MUST wait for a proper connect first if 'connected' is | ||||||
|      * FALSE */ |      * FALSE */ | ||||||
|   case CURLPROXY_SOCKS5: |   case CURLPROXY_SOCKS5: | ||||||
| @@ -2163,7 +2165,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn, | |||||||
|     /* |     /* | ||||||
|       A; |       A; | ||||||
|       150 Opening BINARY mode data connection for /etc/passwd (2241 |       150 Opening BINARY mode data connection for /etc/passwd (2241 | ||||||
|       bytes).  (ok, the file is being transfered) |       bytes).  (ok, the file is being transferred) | ||||||
|  |  | ||||||
|       B: |       B: | ||||||
|       150 Opening ASCII mode data connection for /bin/ls |       150 Opening ASCII mode data connection for /bin/ls | ||||||
| @@ -2172,7 +2174,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn, | |||||||
|       150 ASCII data connection for /bin/ls (137.167.104.91,37445) (0 bytes). |       150 ASCII data connection for /bin/ls (137.167.104.91,37445) (0 bytes). | ||||||
|  |  | ||||||
|       D: |       D: | ||||||
|       150 Opening ASCII mode data connection for /linux/fisk/kpanelrc (0.0.0.0,0) (545 bytes). |       150 Opening ASCII mode data connection for [file] (0.0.0.0,0) (545 bytes) | ||||||
|  |  | ||||||
|       E: |       E: | ||||||
|       125 Data connection already open; Transfer starting. */ |       125 Data connection already open; Transfer starting. */ | ||||||
| @@ -2195,7 +2197,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn, | |||||||
|       /* |       /* | ||||||
|        * It seems directory listings either don't show the size or very |        * It seems directory listings either don't show the size or very | ||||||
|        * often uses size 0 anyway. ASCII transfers may very well turn out |        * often uses size 0 anyway. ASCII transfers may very well turn out | ||||||
|        * that the transfered amount of data is not the same as this line |        * that the transferred amount of data is not the same as this line | ||||||
|        * tells, why using this number in those cases only confuses us. |        * tells, why using this number in those cases only confuses us. | ||||||
|        * |        * | ||||||
|        * Example D above makes this parsing a little tricky */ |        * Example D above makes this parsing a little tricky */ | ||||||
| @@ -2693,7 +2695,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) | |||||||
|     case FTP_RETR_PREQUOTE: |     case FTP_RETR_PREQUOTE: | ||||||
|     case FTP_STOR_PREQUOTE: |     case FTP_STOR_PREQUOTE: | ||||||
|       if((ftpcode >= 400) && !ftpc->count2) { |       if((ftpcode >= 400) && !ftpc->count2) { | ||||||
|         /* failure reponse code, and not allowed to fail */ |         /* failure response code, and not allowed to fail */ | ||||||
|         failf(conn->data, "QUOT command failed with %03d", ftpcode); |         failf(conn->data, "QUOT command failed with %03d", ftpcode); | ||||||
|         return CURLE_QUOTE_ERROR; |         return CURLE_QUOTE_ERROR; | ||||||
|       } |       } | ||||||
| @@ -2914,7 +2916,7 @@ static CURLcode ftp_connect(struct connectdata *conn, | |||||||
|   if(CURLE_OK != result) |   if(CURLE_OK != result) | ||||||
|     return result; |     return result; | ||||||
|  |  | ||||||
|   /* We always support persistant connections on ftp */ |   /* We always support persistent connections on ftp */ | ||||||
|   conn->bits.close = FALSE; |   conn->bits.close = FALSE; | ||||||
|  |  | ||||||
|   pp->response_time = RESP_TIMEOUT; /* set default response time-out */ |   pp->response_time = RESP_TIMEOUT; /* set default response time-out */ | ||||||
| @@ -2949,10 +2951,8 @@ static CURLcode ftp_connect(struct connectdata *conn, | |||||||
|       return result; |       return result; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if(conn->handler->protocol & CURLPROTO_FTPS) { |   if(conn->handler->flags & PROTOPT_SSL) { | ||||||
|     /* BLOCKING */ |     /* BLOCKING */ | ||||||
|     /* FTPS is simply ftp with SSL for the control channel */ |  | ||||||
|     /* now, perform the SSL initialization for this socket */ |  | ||||||
|     result = Curl_ssl_connect(conn, FIRSTSOCKET); |     result = Curl_ssl_connect(conn, FIRSTSOCKET); | ||||||
|     if(result) |     if(result) | ||||||
|       return result; |       return result; | ||||||
| @@ -3100,7 +3100,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, | |||||||
|          still requested to use SSL */ |          still requested to use SSL */ | ||||||
|     } |     } | ||||||
|     if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) { |     if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) { | ||||||
|       sclose(conn->sock[SECONDARYSOCKET]); |       Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]); | ||||||
|       conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; |       conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @@ -3110,7 +3110,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status, | |||||||
|     /* |     /* | ||||||
|      * Let's see what the server says about the transfer we just performed, |      * Let's see what the server says about the transfer we just performed, | ||||||
|      * but lower the timeout as sometimes this connection has died while the |      * but lower the timeout as sometimes this connection has died while the | ||||||
|      * data has been transfered. This happens when doing through NATs etc that |      * data has been transferred. This happens when doing through NATs etc that | ||||||
|      * abandon old silent connections. |      * abandon old silent connections. | ||||||
|      */ |      */ | ||||||
|     long old_time = pp->response_time; |     long old_time = pp->response_time; | ||||||
| @@ -3562,7 +3562,7 @@ static CURLcode init_wc_data(struct connectdata *conn) | |||||||
|  |  | ||||||
|   /* backup old write_function */ |   /* backup old write_function */ | ||||||
|   ftp_tmp->backup.write_function = conn->data->set.fwrite_func; |   ftp_tmp->backup.write_function = conn->data->set.fwrite_func; | ||||||
|   /* parsing write function (callback included directly from ftplistparser.c) */ |   /* parsing write function */ | ||||||
|   conn->data->set.fwrite_func = Curl_ftp_parselist; |   conn->data->set.fwrite_func = Curl_ftp_parselist; | ||||||
|   /* backup old file descriptor */ |   /* backup old file descriptor */ | ||||||
|   ftp_tmp->backup.file_descriptor = conn->data->set.out; |   ftp_tmp->backup.file_descriptor = conn->data->set.out; | ||||||
| @@ -3772,13 +3772,10 @@ CURLcode Curl_ftpsendf(struct connectdata *conn, | |||||||
|   bytes_written=0; |   bytes_written=0; | ||||||
|   write_len = strlen(s); |   write_len = strlen(s); | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|   res = Curl_convert_to_network(conn->data, s, write_len); |   res = Curl_convert_to_network(conn->data, s, write_len); | ||||||
|   /* Curl_convert_to_network calls failf if unsuccessful */ |   /* Curl_convert_to_network calls failf if unsuccessful */ | ||||||
|   if(res != CURLE_OK) { |   if(res) | ||||||
|     return(res); |     return(res); | ||||||
|   } |  | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
|   for(;;) { |   for(;;) { | ||||||
| #if defined(HAVE_KRB4) || defined(HAVE_GSSAPI) | #if defined(HAVE_KRB4) || defined(HAVE_GSSAPI) | ||||||
| @@ -3985,7 +3982,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) | |||||||
|         /* seek out the next path component */ |         /* seek out the next path component */ | ||||||
|         if(slash_pos-cur_pos) { |         if(slash_pos-cur_pos) { | ||||||
|           /* we skip empty path components, like "x//y" since the FTP command |           /* we skip empty path components, like "x//y" since the FTP command | ||||||
|              CWD requires a parameter and a non-existant parameter a) doesn't |              CWD requires a parameter and a non-existent parameter a) doesn't | ||||||
|              work on many servers and b) has no effect on the others. */ |              work on many servers and b) has no effect on the others. */ | ||||||
|           int len = (int)(slash_pos - cur_pos + absolute_dir); |           int len = (int)(slash_pos - cur_pos + absolute_dir); | ||||||
|           ftpc->dirs[ftpc->dirdepth] = |           ftpc->dirs[ftpc->dirdepth] = | ||||||
| @@ -4009,14 +4006,14 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) | |||||||
|         cur_pos = slash_pos + 1; /* jump to the rest of the string */ |         cur_pos = slash_pos + 1; /* jump to the rest of the string */ | ||||||
|         if(++ftpc->dirdepth >= ftpc->diralloc) { |         if(++ftpc->dirdepth >= ftpc->diralloc) { | ||||||
|           /* enlarge array */ |           /* enlarge array */ | ||||||
|           char *bigger; |           char **bigger; | ||||||
|           ftpc->diralloc *= 2; /* double the size each time */ |           ftpc->diralloc *= 2; /* double the size each time */ | ||||||
|           bigger = realloc(ftpc->dirs, ftpc->diralloc * sizeof(ftpc->dirs[0])); |           bigger = realloc(ftpc->dirs, ftpc->diralloc * sizeof(ftpc->dirs[0])); | ||||||
|           if(!bigger) { |           if(!bigger) { | ||||||
|             freedirs(ftpc); |             freedirs(ftpc); | ||||||
|             return CURLE_OUT_OF_MEMORY; |             return CURLE_OUT_OF_MEMORY; | ||||||
|           } |           } | ||||||
|           ftpc->dirs = (char **)bigger; |           ftpc->dirs = bigger; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| @@ -4083,7 +4080,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn, | |||||||
|  |  | ||||||
|   if(result && (conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD)) { |   if(result && (conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD)) { | ||||||
|     /* Failure detected, close the second socket if it was created already */ |     /* Failure detected, close the second socket if it was created already */ | ||||||
|     sclose(conn->sock[SECONDARYSOCKET]); |     Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]); | ||||||
|     conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; |     conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; | ||||||
|     return result; |     return result; | ||||||
|   } |   } | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								lib/ftp.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								lib/ftp.h
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -66,7 +66,7 @@ typedef enum { | |||||||
|   FTP_STOR_TYPE, /* set type when about to STOR a file */ |   FTP_STOR_TYPE, /* set type when about to STOR a file */ | ||||||
|   FTP_SIZE, /* get the remote file's size for head-like request */ |   FTP_SIZE, /* get the remote file's size for head-like request */ | ||||||
|   FTP_RETR_SIZE, /* get the remote file's size for RETR */ |   FTP_RETR_SIZE, /* get the remote file's size for RETR */ | ||||||
|   FTP_STOR_SIZE, /* get the size for (resumed) STOR */ |   FTP_STOR_SIZE, /* get the size for STOR */ | ||||||
|   FTP_REST, /* when used to check if the server supports it in head-like */ |   FTP_REST, /* when used to check if the server supports it in head-like */ | ||||||
|   FTP_RETR_REST, /* when asking for "resume" in for RETR */ |   FTP_RETR_REST, /* when asking for "resume" in for RETR */ | ||||||
|   FTP_PORT, /* generic state for PORT, LPRT and EPRT, check count1 */ |   FTP_PORT, /* generic state for PORT, LPRT and EPRT, check count1 */ | ||||||
| @@ -93,7 +93,8 @@ struct ftp_wc_tmpdata { | |||||||
| typedef enum { | typedef enum { | ||||||
|   FTPFILE_MULTICWD  = 1, /* as defined by RFC1738 */ |   FTPFILE_MULTICWD  = 1, /* as defined by RFC1738 */ | ||||||
|   FTPFILE_NOCWD     = 2, /* use SIZE / RETR / STOR on the full path */ |   FTPFILE_NOCWD     = 2, /* use SIZE / RETR / STOR on the full path */ | ||||||
|   FTPFILE_SINGLECWD = 3  /* make one CWD, then SIZE / RETR / STOR on the file */ |   FTPFILE_SINGLECWD = 3  /* make one CWD, then SIZE / RETR / STOR on the | ||||||
|  |                             file */ | ||||||
| } curl_ftpfile; | } curl_ftpfile; | ||||||
|  |  | ||||||
| typedef enum { | typedef enum { | ||||||
| @@ -147,7 +148,8 @@ struct ftp_conn { | |||||||
|   ftpstate state; /* always use ftp.c:state() to change state! */ |   ftpstate state; /* always use ftp.c:state() to change state! */ | ||||||
|   char * server_os;     /* The target server operating system. */ |   char * server_os;     /* The target server operating system. */ | ||||||
|   curl_off_t known_filesize; /* file size is different from -1, if wildcard |   curl_off_t known_filesize; /* file size is different from -1, if wildcard | ||||||
|                                 LIST parsing was done and wc_statemach set it */ |                                 LIST parsing was done and wc_statemach set | ||||||
|  |                                 it */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif /* HEADER_CURL_FTP_H */ | #endif /* HEADER_CURL_FTP_H */ | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -329,7 +329,8 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, | |||||||
|     compare = Curl_fnmatch; |     compare = Curl_fnmatch; | ||||||
|  |  | ||||||
|   /* filter pattern-corresponding filenames */ |   /* filter pattern-corresponding filenames */ | ||||||
|   if(compare(conn->data->set.fnmatch_data, wc->pattern, finfo->filename) == 0) { |   if(compare(conn->data->set.fnmatch_data, wc->pattern, | ||||||
|  |              finfo->filename) == 0) { | ||||||
|     /* discard symlink which is containing multiple " -> " */ |     /* discard symlink which is containing multiple " -> " */ | ||||||
|     if((finfo->filetype == CURLFILETYPE_SYMLINK) && finfo->strings.target && |     if((finfo->filetype == CURLFILETYPE_SYMLINK) && finfo->strings.target && | ||||||
|        (strstr(finfo->strings.target, " -> "))) { |        (strstr(finfo->strings.target, " -> "))) { | ||||||
| @@ -960,7 +961,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, | |||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|               char *endptr; |               char *endptr; | ||||||
|               finfo->size = curlx_strtoofft(finfo->b_data + parser->item_offset, |               finfo->size = curlx_strtoofft(finfo->b_data + | ||||||
|  |                                             parser->item_offset, | ||||||
|                                             &endptr, 10); |                                             &endptr, 10); | ||||||
|               if(!*endptr) { |               if(!*endptr) { | ||||||
|                 if(finfo->size == CURL_OFF_T_MAX || |                 if(finfo->size == CURL_OFF_T_MAX || | ||||||
|   | |||||||
| @@ -260,7 +260,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) | |||||||
|     *param_slistp = ptr.to_slist; |     *param_slistp = ptr.to_slist; | ||||||
|     break; |     break; | ||||||
|   case CURLINFO_CONDITION_UNMET: |   case CURLINFO_CONDITION_UNMET: | ||||||
|     /* return if the condition prevented the document to get transfered */ |     /* return if the condition prevented the document to get transferred */ | ||||||
|     *param_longp = data->info.timecond; |     *param_longp = data->info.timecond; | ||||||
|     break; |     break; | ||||||
|   case CURLINFO_RTSP_SESSION_ID: |   case CURLINFO_RTSP_SESSION_ID: | ||||||
|   | |||||||
| @@ -112,6 +112,7 @@ const struct Curl_handler Curl_handler_gopher = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_GOPHER,                          /* defport */ |   PORT_GOPHER,                          /* defport */ | ||||||
|   CURLPROTO_GOPHER,                     /* protocol */ |   CURLPROTO_GOPHER,                     /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								lib/gtls.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								lib/gtls.c
									
									
									
									
									
								
							| @@ -255,7 +255,8 @@ static CURLcode handshake(struct connectdata *conn, | |||||||
|         connssl->connecting_state?sockfd:CURL_SOCKET_BAD; |         connssl->connecting_state?sockfd:CURL_SOCKET_BAD; | ||||||
|  |  | ||||||
|       what = Curl_socket_ready(readfd, writefd, |       what = Curl_socket_ready(readfd, writefd, | ||||||
|                                nonblocking?0:(int)timeout_ms?1000:timeout_ms); |                                nonblocking?0: | ||||||
|  |                                timeout_ms?timeout_ms:1000); | ||||||
|       if(what < 0) { |       if(what < 0) { | ||||||
|         /* fatal error */ |         /* fatal error */ | ||||||
|         failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO); |         failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO); | ||||||
| @@ -357,7 +358,8 @@ gtls_connect_step1(struct connectdata *conn, | |||||||
|       return CURLE_OUT_OF_MEMORY; |       return CURLE_OUT_OF_MEMORY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     rc = gnutls_srp_set_client_credentials(conn->ssl[sockindex].srp_client_cred, |     rc = gnutls_srp_set_client_credentials(conn->ssl[sockindex]. | ||||||
|  |                                            srp_client_cred, | ||||||
|                                            data->set.ssl.username, |                                            data->set.ssl.username, | ||||||
|                                            data->set.ssl.password); |                                            data->set.ssl.password); | ||||||
|     if(rc != GNUTLS_E_SUCCESS) { |     if(rc != GNUTLS_E_SUCCESS) { | ||||||
| @@ -447,7 +449,8 @@ gtls_connect_step1(struct connectdata *conn, | |||||||
|          data->set.str[STRING_CERT], |          data->set.str[STRING_CERT], | ||||||
|          data->set.str[STRING_KEY] ? |          data->set.str[STRING_KEY] ? | ||||||
|          data->set.str[STRING_KEY] : data->set.str[STRING_CERT], |          data->set.str[STRING_KEY] : data->set.str[STRING_CERT], | ||||||
|           do_file_type(data->set.str[STRING_CERT_TYPE]) ) != GNUTLS_E_SUCCESS) { |          do_file_type(data->set.str[STRING_CERT_TYPE]) ) != | ||||||
|  |        GNUTLS_E_SUCCESS) { | ||||||
|       failf(data, "error reading X.509 key or certificate file"); |       failf(data, "error reading X.509 key or certificate file"); | ||||||
|       return CURLE_SSL_CONNECT_ERROR; |       return CURLE_SSL_CONNECT_ERROR; | ||||||
|     } |     } | ||||||
| @@ -458,10 +461,10 @@ gtls_connect_step1(struct connectdata *conn, | |||||||
|   if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) { |   if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) { | ||||||
|     rc = gnutls_credentials_set(session, GNUTLS_CRD_SRP, |     rc = gnutls_credentials_set(session, GNUTLS_CRD_SRP, | ||||||
|                                 conn->ssl[sockindex].srp_client_cred); |                                 conn->ssl[sockindex].srp_client_cred); | ||||||
|     if (rc != GNUTLS_E_SUCCESS) { |     if(rc != GNUTLS_E_SUCCESS) | ||||||
|       failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc)); |       failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc)); | ||||||
|   } |   } | ||||||
|   } else |   else | ||||||
| #endif | #endif | ||||||
|     rc = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, |     rc = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, | ||||||
|                                 conn->ssl[sockindex].cred); |                                 conn->ssl[sockindex].cred); | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -140,7 +140,10 @@ mk_hash_element(const void *key, size_t key_len, const void *p) | |||||||
| #define FETCH_LIST(x,y,z) x->table[x->hash_func(y, z, x->slots)] | #define FETCH_LIST(x,y,z) x->table[x->hash_func(y, z, x->slots)] | ||||||
|  |  | ||||||
| /* Insert the data in the hash. If there already was a match in the hash, | /* Insert the data in the hash. If there already was a match in the hash, | ||||||
|    that data is replaced. */ |  * that data is replaced. | ||||||
|  |  * | ||||||
|  |  * @unittest: 1305 | ||||||
|  |  */ | ||||||
| void * | void * | ||||||
| Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) | Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -59,7 +59,8 @@ Curl_HMAC_init(const HMAC_params * hashparams, | |||||||
|   unsigned char b; |   unsigned char b; | ||||||
|  |  | ||||||
|   /* Create HMAC context. */ |   /* Create HMAC context. */ | ||||||
|   i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize + hashparams->hmac_resultlen; |   i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize + | ||||||
|  |     hashparams->hmac_resultlen; | ||||||
|   ctxt = malloc(i); |   ctxt = malloc(i); | ||||||
|  |  | ||||||
|   if(!ctxt) |   if(!ctxt) | ||||||
| @@ -114,7 +115,8 @@ int Curl_HMAC_final(HMAC_context * ctxt, unsigned char * result) | |||||||
| { | { | ||||||
|   const HMAC_params * hashparams = ctxt->hmac_hash; |   const HMAC_params * hashparams = ctxt->hmac_hash; | ||||||
|  |  | ||||||
|   /* Do not get result if called with a null parameter: only release storage. */ |   /* Do not get result if called with a null parameter: only release | ||||||
|  |      storage. */ | ||||||
|  |  | ||||||
|   if(!result) |   if(!result) | ||||||
|     result = (unsigned char *) ctxt->hmac_hashctxt2 + |     result = (unsigned char *) ctxt->hmac_hashctxt2 + | ||||||
|   | |||||||
							
								
								
									
										114
									
								
								lib/hostasyn.c
									
									
									
									
									
								
							
							
						
						
									
										114
									
								
								lib/hostasyn.c
									
									
									
									
									
								
							| @@ -72,20 +72,6 @@ | |||||||
|  **********************************************************************/ |  **********************************************************************/ | ||||||
| #ifdef CURLRES_ASYNCH | #ifdef CURLRES_ASYNCH | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * Cancel all possibly still on-going resolves for this connection. |  | ||||||
|  */ |  | ||||||
| void Curl_async_cancel(struct connectdata *conn) |  | ||||||
| { |  | ||||||
|   /* If we have a "half" response already received, we first clear that off |  | ||||||
|      so that nothing is tempted to use it */ |  | ||||||
|   if(conn->async.temp_ai) { |  | ||||||
|     Curl_freeaddrinfo(conn->async.temp_ai); |  | ||||||
|     conn->async.temp_ai = NULL; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Curl_addrinfo_callback() gets called by ares, gethostbyname_thread() |  * Curl_addrinfo_callback() gets called by ares, gethostbyname_thread() | ||||||
|  * or getaddrinfo_thread() when we got the name resolved (or not!). |  * or getaddrinfo_thread() when we got the name resolved (or not!). | ||||||
| @@ -109,24 +95,6 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn, | |||||||
|     if(ai) { |     if(ai) { | ||||||
|       struct SessionHandle *data = conn->data; |       struct SessionHandle *data = conn->data; | ||||||
|  |  | ||||||
| #if defined(ENABLE_IPV6) && defined(CURLRES_ARES) /* CURLRES_IPV6 */ |  | ||||||
|       Curl_addrinfo *ai_tail = ai; |  | ||||||
|  |  | ||||||
|       while (ai_tail->ai_next) |  | ||||||
|         ai_tail = ai_tail->ai_next; |  | ||||||
|  |  | ||||||
|       /* Add the new results to the list of old results. */ |  | ||||||
|       ai_tail->ai_next = conn->async.temp_ai; |  | ||||||
|       conn->async.temp_ai = ai; |  | ||||||
|  |  | ||||||
|       if(--conn->async.num_pending > 0) |  | ||||||
|         /* We are not done yet. Just return. */ |  | ||||||
|         return CURLE_OK; |  | ||||||
|  |  | ||||||
|       /* make sure the temp pointer is cleared and isn't pointing to something |  | ||||||
|          we take care of below */ |  | ||||||
|       conn->async.temp_ai = NULL; |  | ||||||
| #endif |  | ||||||
|       if(data->share) |       if(data->share) | ||||||
|         Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); |         Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); | ||||||
|  |  | ||||||
| @@ -143,52 +111,9 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn, | |||||||
|         Curl_share_unlock(data, CURL_LOCK_DATA_DNS); |         Curl_share_unlock(data, CURL_LOCK_DATA_DNS); | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
| #if defined(ENABLE_IPV6) && defined(CURLRES_ARES) /* CURLRES_IPV6 */ |  | ||||||
|       if(--conn->async.num_pending > 0) { |  | ||||||
|         /* We are not done yet. Clean up and return. |  | ||||||
| 	   This function will be called again. */ |  | ||||||
|         if(conn->async.temp_ai) { |  | ||||||
|           Curl_freeaddrinfo(conn->async.temp_ai); |  | ||||||
|           conn->async.temp_ai = NULL; |  | ||||||
|         } |  | ||||||
|         return CURLE_OUT_OF_MEMORY; |  | ||||||
|       } |  | ||||||
| #endif |  | ||||||
|       rc = CURLE_OUT_OF_MEMORY; |       rc = CURLE_OUT_OF_MEMORY; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| #if defined(ENABLE_IPV6) && defined(CURLRES_ARES) /* CURLRES_IPV6 */ |  | ||||||
|   else |  | ||||||
|   { |  | ||||||
|       if(--conn->async.num_pending > 0) |  | ||||||
|         /* We are not done yet. Just return. */ |  | ||||||
|         return CURLE_OK; |  | ||||||
|  |  | ||||||
|       if(conn->async.temp_ai) { |  | ||||||
|         /* We are done, and while this latest request |  | ||||||
|            failed, some previous results exist. */ |  | ||||||
|         struct SessionHandle *data = conn->data; |  | ||||||
|  |  | ||||||
|         if(data->share) |  | ||||||
|           Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); |  | ||||||
|  |  | ||||||
|         dns = Curl_cache_addr(data, conn->async.temp_ai, |  | ||||||
|                               conn->async.hostname, |  | ||||||
|                               conn->async.port); |  | ||||||
|         if(!dns) { |  | ||||||
|           /* failed to store, cleanup and return error */ |  | ||||||
|           Curl_freeaddrinfo(conn->async.temp_ai); |  | ||||||
|           rc = CURLE_OUT_OF_MEMORY; |  | ||||||
|         } |  | ||||||
|         if(data->share) |  | ||||||
|           Curl_share_unlock(data, CURL_LOCK_DATA_DNS); |  | ||||||
|  |  | ||||||
|         /* make sure the temp pointer is cleared and isn't pointing to |  | ||||||
|            something we've taken care of already */ |  | ||||||
|         conn->async.temp_ai = NULL; |  | ||||||
|       } |  | ||||||
|   } |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   conn->async.dns = dns; |   conn->async.dns = dns; | ||||||
|  |  | ||||||
| @@ -202,4 +127,43 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn, | |||||||
|   return rc; |   return rc; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* Call this function after Curl_connect() has returned async=TRUE and | ||||||
|  |    then a successful name resolve has been received. | ||||||
|  |  | ||||||
|  |    Note: this function disconnects and frees the conn data in case of | ||||||
|  |    resolve failure */ | ||||||
|  | CURLcode Curl_async_resolved(struct connectdata *conn, | ||||||
|  |                              bool *protocol_done) | ||||||
|  | { | ||||||
|  |   CURLcode code; | ||||||
|  |  | ||||||
|  |   if(conn->async.dns) { | ||||||
|  |     conn->dns_entry = conn->async.dns; | ||||||
|  |     conn->async.dns = NULL; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   code = Curl_setup_conn(conn, protocol_done); | ||||||
|  |  | ||||||
|  |   if(code) | ||||||
|  |     /* We're not allowed to return failure with memory left allocated | ||||||
|  |        in the connectdata struct, free those here */ | ||||||
|  |     Curl_disconnect(conn, FALSE); /* close the connection */ | ||||||
|  |  | ||||||
|  |   return code; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Curl_getaddrinfo() is the generic low-level name resolve API within this | ||||||
|  |  * source file. There are several versions of this function - for different | ||||||
|  |  * name resolve layers (selected at build-time). They all take this same set | ||||||
|  |  * of arguments | ||||||
|  |  */ | ||||||
|  | Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | ||||||
|  |                                 const char *hostname, | ||||||
|  |                                 int port, | ||||||
|  |                                 int *waitp) | ||||||
|  | { | ||||||
|  |   return Curl_resolver_getaddrinfo(conn, hostname, port, waitp); | ||||||
|  | } | ||||||
|  |  | ||||||
| #endif /* CURLRES_ASYNCH */ | #endif /* CURLRES_ASYNCH */ | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								lib/hostip.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								lib/hostip.c
									
									
									
									
									
								
							| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -110,11 +110,13 @@ | |||||||
|  * hostip.c   - method-independent resolver functions and utility functions |  * hostip.c   - method-independent resolver functions and utility functions | ||||||
|  * hostasyn.c - functions for asynchronous name resolves |  * hostasyn.c - functions for asynchronous name resolves | ||||||
|  * hostsyn.c  - functions for synchronous name resolves |  * hostsyn.c  - functions for synchronous name resolves | ||||||
|  * hostares.c - functions for ares-using name resolves |  | ||||||
|  * hostthre.c - functions for threaded name resolves |  | ||||||
|  * hostip4.c  - ipv4-specific functions |  * hostip4.c  - ipv4-specific functions | ||||||
|  * hostip6.c  - ipv6-specific functions |  * hostip6.c  - ipv6-specific functions | ||||||
|  * |  * | ||||||
|  |  * The two asynchronous name resolver backends are implemented in: | ||||||
|  |  * asyn-ares.c   - functions for ares-using name resolves | ||||||
|  |  * asyn-thread.c - functions for threaded name resolves | ||||||
|  |  | ||||||
|  * The hostip.h is the united header file for all this. It defines the |  * The hostip.h is the united header file for all this. It defines the | ||||||
|  * CURLRES_* defines based on the config*.h and setup.h defines. |  * CURLRES_* defines based on the config*.h and setup.h defines. | ||||||
|  */ |  */ | ||||||
| @@ -464,7 +466,7 @@ int Curl_resolv(struct connectdata *conn, | |||||||
|         /* the response to our resolve call will come asynchronously at |         /* the response to our resolve call will come asynchronously at | ||||||
|            a later time, good or bad */ |            a later time, good or bad */ | ||||||
|         /* First, check that we haven't received the info by now */ |         /* First, check that we haven't received the info by now */ | ||||||
|         result = Curl_is_resolved(conn, &dns); |         result = Curl_resolver_is_resolved(conn, &dns); | ||||||
|         if(result) /* error detected */ |         if(result) /* error detected */ | ||||||
|           return CURLRESOLV_ERROR; |           return CURLRESOLV_ERROR; | ||||||
|         if(dns) |         if(dns) | ||||||
|   | |||||||
							
								
								
									
										56
									
								
								lib/hostip.h
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								lib/hostip.h
									
									
									
									
									
								
							| @@ -25,6 +25,7 @@ | |||||||
| #include "setup.h" | #include "setup.h" | ||||||
| #include "hash.h" | #include "hash.h" | ||||||
| #include "curl_addrinfo.h" | #include "curl_addrinfo.h" | ||||||
|  | #include "asyn.h" | ||||||
|  |  | ||||||
| #ifdef HAVE_SETJMP_H | #ifdef HAVE_SETJMP_H | ||||||
| #include <setjmp.h> | #include <setjmp.h> | ||||||
| @@ -35,14 +36,6 @@ | |||||||
| #define in_addr_t unsigned long | #define in_addr_t unsigned long | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * Comfortable CURLRES_* definitions are included from setup.h |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #ifdef USE_ARES |  | ||||||
| #include <ares_version.h> |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| /* Allocate enough memory to hold the full name information structs and | /* Allocate enough memory to hold the full name information structs and | ||||||
|  * everything. OSF1 is known to require at least 8872 bytes. The buffer |  * everything. OSF1 is known to require at least 8872 bytes. The buffer | ||||||
|  * required for storing all possible aliases and IP numbers is according to |  * required for storing all possible aliases and IP numbers is according to | ||||||
| @@ -53,29 +46,13 @@ | |||||||
| #define CURL_TIMEOUT_RESOLVE 300 /* when using asynch methods, we allow this | #define CURL_TIMEOUT_RESOLVE 300 /* when using asynch methods, we allow this | ||||||
|                                     many seconds for a name resolve */ |                                     many seconds for a name resolve */ | ||||||
|  |  | ||||||
| #ifdef CURLRES_ARES |  | ||||||
| #define CURL_ASYNC_SUCCESS ARES_SUCCESS |  | ||||||
| #if ARES_VERSION >= 0x010500 |  | ||||||
| /* c-ares 1.5.0 or later, the callback proto is modified */ |  | ||||||
| #define HAVE_CARES_CALLBACK_TIMEOUTS 1 |  | ||||||
| #endif |  | ||||||
| #else |  | ||||||
| #define CURL_ASYNC_SUCCESS CURLE_OK | #define CURL_ASYNC_SUCCESS CURLE_OK | ||||||
| #define ares_cancel(x) do {} while(0) |  | ||||||
| #define ares_destroy(x) do {} while(0) |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| struct addrinfo; | struct addrinfo; | ||||||
| struct hostent; | struct hostent; | ||||||
| struct SessionHandle; | struct SessionHandle; | ||||||
| struct connectdata; | struct connectdata; | ||||||
|  |  | ||||||
| #ifdef CURLRES_ASYNCH |  | ||||||
| void Curl_async_cancel(struct connectdata *conn); |  | ||||||
| #else |  | ||||||
| #define Curl_async_cancel(x) do {} while(0) |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Curl_global_host_cache_init() initializes and sets up a global DNS cache. |  * Curl_global_host_cache_init() initializes and sets up a global DNS cache. | ||||||
|  * Global DNS cache is general badness. Do not use. This will be removed in |  * Global DNS cache is general badness. Do not use. This will be removed in | ||||||
| @@ -128,6 +105,7 @@ bool Curl_ipv6works(void); | |||||||
|  */ |  */ | ||||||
| bool Curl_ipvalid(struct connectdata *conn); | bool Curl_ipvalid(struct connectdata *conn); | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Curl_getaddrinfo() is the generic low-level name resolve API within this |  * Curl_getaddrinfo() is the generic low-level name resolve API within this | ||||||
|  * source file. There are several versions of this function - for different |  * source file. There are several versions of this function - for different | ||||||
| @@ -139,20 +117,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, | |||||||
|                                 int port, |                                 int port, | ||||||
|                                 int *waitp); |                                 int *waitp); | ||||||
|  |  | ||||||
| CURLcode Curl_is_resolved(struct connectdata *conn, |  | ||||||
|                           struct Curl_dns_entry **dns); |  | ||||||
| CURLcode Curl_wait_for_resolv(struct connectdata *conn, |  | ||||||
|                               struct Curl_dns_entry **dnsentry); |  | ||||||
|  |  | ||||||
| /* Curl_resolv_getsock() is a generic function that exists in multiple |  | ||||||
|    versions depending on what name resolve technology we've built to use. The |  | ||||||
|    function is called from the multi_getsock() function.  'sock' is a pointer |  | ||||||
|    to an array to hold the file descriptors, with 'numsock' being the size of |  | ||||||
|    that array (in number of entries). This function is supposed to return |  | ||||||
|    bitmask indicating what file descriptors (referring to array indexes in the |  | ||||||
|    'sock' array) to wait for, read/write. */ |  | ||||||
| int Curl_resolv_getsock(struct connectdata *conn, curl_socket_t *sock, |  | ||||||
|                         int numsocks); |  | ||||||
|  |  | ||||||
| /* unlock a previously resolved dns entry */ | /* unlock a previously resolved dns entry */ | ||||||
| void Curl_resolv_unlock(struct SessionHandle *data, | void Curl_resolv_unlock(struct SessionHandle *data, | ||||||
| @@ -182,11 +146,18 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa, | |||||||
| /* IPv4 threadsafe resolve function used for synch and asynch builds */ | /* IPv4 threadsafe resolve function used for synch and asynch builds */ | ||||||
| Curl_addrinfo *Curl_ipv4_resolve_r(const char * hostname, int port); | Curl_addrinfo *Curl_ipv4_resolve_r(const char * hostname, int port); | ||||||
|  |  | ||||||
|  | CURLcode Curl_async_resolved(struct connectdata *conn, | ||||||
|  |                              bool *protocol_connect); | ||||||
|  |  | ||||||
|  | #ifndef CURLRES_ASYNCH | ||||||
|  | #define Curl_async_resolved(x,y) CURLE_OK | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Curl_addrinfo_callback() is used when we build with any asynch specialty. |  * Curl_addrinfo_callback() is used when we build with any asynch specialty. | ||||||
|  * Handles end of async request processing. Inserts ai into hostcache when |  * Handles end of async request processing. Inserts ai into hostcache when | ||||||
|  * status is CURL_ASYNC_SUCCESS. Twiddles fields in conn to indicate async |  * status is CURL_ASYNC_SUCCESS. Twiddles fields in conn to indicate async | ||||||
|  * request completed wether successfull or failed. |  * request completed whether successful or failed. | ||||||
|  */ |  */ | ||||||
| CURLcode Curl_addrinfo_callback(struct connectdata *conn, | CURLcode Curl_addrinfo_callback(struct connectdata *conn, | ||||||
|                                 int status, |                                 int status, | ||||||
| @@ -209,13 +180,6 @@ struct Curl_dns_entry * | |||||||
| Curl_cache_addr(struct SessionHandle *data, Curl_addrinfo *addr, | Curl_cache_addr(struct SessionHandle *data, Curl_addrinfo *addr, | ||||||
|                 const char *hostname, int port); |                 const char *hostname, int port); | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * Curl_destroy_thread_data() cleans up async resolver data. |  | ||||||
|  * Complementary of ares_destroy. |  | ||||||
|  */ |  | ||||||
| struct Curl_async; /* forward-declaration */ |  | ||||||
| void Curl_destroy_thread_data(struct Curl_async *async); |  | ||||||
|  |  | ||||||
| #ifndef INADDR_NONE | #ifndef INADDR_NONE | ||||||
| #define CURL_INADDR_NONE (in_addr_t) ~0 | #define CURL_INADDR_NONE (in_addr_t) ~0 | ||||||
| #else | #else | ||||||
|   | |||||||
| @@ -87,6 +87,7 @@ bool Curl_ipvalid(struct connectdata *conn) | |||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef CURLRES_SYNCH | #ifdef CURLRES_SYNCH | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Curl_getaddrinfo() - the ipv4 synchronous version. |  * Curl_getaddrinfo() - the ipv4 synchronous version. | ||||||
|  * |  * | ||||||
|   | |||||||
| @@ -78,7 +78,7 @@ | |||||||
| #if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) | #if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) | ||||||
| /* These are strictly for memory tracing and are using the same style as the | /* These are strictly for memory tracing and are using the same style as the | ||||||
|  * family otherwise present in memdebug.c. I put these ones here since they |  * family otherwise present in memdebug.c. I put these ones here since they | ||||||
|  * require a bunch of structs I didn't wanna include in memdebug.c |  * require a bunch of structs I didn't want to include in memdebug.c | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -125,7 +125,7 @@ bool Curl_ipv6works(void) | |||||||
|       ipv6_works = 0; |       ipv6_works = 0; | ||||||
|     else { |     else { | ||||||
|       ipv6_works = 1; |       ipv6_works = 1; | ||||||
|       sclose(s); |       Curl_closesocket(NULL, s); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   return (ipv6_works>0)?TRUE:FALSE; |   return (ipv6_works>0)?TRUE:FALSE; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -72,52 +72,5 @@ | |||||||
|  **********************************************************************/ |  **********************************************************************/ | ||||||
| #ifdef CURLRES_SYNCH | #ifdef CURLRES_SYNCH | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * Curl_wait_for_resolv() for synch-builds.  Curl_resolv() can never return |  | ||||||
|  * wait==TRUE, so this function will never be called. If it still gets called, |  | ||||||
|  * we return failure at once. |  | ||||||
|  * |  | ||||||
|  * We provide this function only to allow multi.c to remain unaware if we are |  | ||||||
|  * doing asynch resolves or not. |  | ||||||
|  */ |  | ||||||
| CURLcode Curl_wait_for_resolv(struct connectdata *conn, |  | ||||||
|                               struct Curl_dns_entry **entry) |  | ||||||
| { |  | ||||||
|   (void)conn; |  | ||||||
|   *entry=NULL; |  | ||||||
|   return CURLE_COULDNT_RESOLVE_HOST; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * This function will never be called when synch-built. If it still gets |  | ||||||
|  * called, we return failure at once. |  | ||||||
|  * |  | ||||||
|  * We provide this function only to allow multi.c to remain unaware if we are |  | ||||||
|  * doing asynch resolves or not. |  | ||||||
|  */ |  | ||||||
| CURLcode Curl_is_resolved(struct connectdata *conn, |  | ||||||
|                           struct Curl_dns_entry **dns) |  | ||||||
| { |  | ||||||
|   (void)conn; |  | ||||||
|   *dns = NULL; |  | ||||||
|  |  | ||||||
|   return CURLE_COULDNT_RESOLVE_HOST; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * We just return OK, this function is never actually used for synch builds. |  | ||||||
|  * It is present here to keep #ifdefs out from multi.c |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| int Curl_resolv_getsock(struct connectdata *conn, |  | ||||||
|                         curl_socket_t *sock, |  | ||||||
|                         int numsocks) |  | ||||||
| { |  | ||||||
|   (void)conn; |  | ||||||
|   (void)sock; |  | ||||||
|   (void)numsocks; |  | ||||||
|  |  | ||||||
|   return 0; /* no bits since we don't use any socks */ |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #endif /* truly sync */ | #endif /* truly sync */ | ||||||
|   | |||||||
							
								
								
									
										176
									
								
								lib/http.c
									
									
									
									
									
								
							
							
						
						
									
										176
									
								
								lib/http.c
									
									
									
									
									
								
							| @@ -76,7 +76,6 @@ | |||||||
| #include <curl/curl.h> | #include <curl/curl.h> | ||||||
| #include "transfer.h" | #include "transfer.h" | ||||||
| #include "sendf.h" | #include "sendf.h" | ||||||
| #include "easyif.h" /* for Curl_convert_... prototypes */ |  | ||||||
| #include "formdata.h" | #include "formdata.h" | ||||||
| #include "progress.h" | #include "progress.h" | ||||||
| #include "curl_base64.h" | #include "curl_base64.h" | ||||||
| @@ -97,9 +96,9 @@ | |||||||
| #include "multiif.h" | #include "multiif.h" | ||||||
| #include "rawstr.h" | #include "rawstr.h" | ||||||
| #include "content_encoding.h" | #include "content_encoding.h" | ||||||
| #include "rtsp.h" |  | ||||||
| #include "http_proxy.h" | #include "http_proxy.h" | ||||||
| #include "warnless.h" | #include "warnless.h" | ||||||
|  | #include "non-ascii.h" | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| @@ -114,6 +113,8 @@ | |||||||
| static int http_getsock_do(struct connectdata *conn, | static int http_getsock_do(struct connectdata *conn, | ||||||
|                            curl_socket_t *socks, |                            curl_socket_t *socks, | ||||||
|                            int numsocks); |                            int numsocks); | ||||||
|  | static int http_should_fail(struct connectdata *conn); | ||||||
|  |  | ||||||
| #ifdef USE_SSL | #ifdef USE_SSL | ||||||
| static CURLcode https_connecting(struct connectdata *conn, bool *done); | static CURLcode https_connecting(struct connectdata *conn, bool *done); | ||||||
| static int https_getsock(struct connectdata *conn, | static int https_getsock(struct connectdata *conn, | ||||||
| @@ -139,6 +140,7 @@ const struct Curl_handler Curl_handler_http = { | |||||||
|   http_getsock_do,                      /* doing_getsock */ |   http_getsock_do,                      /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_HTTP,                            /* defport */ |   PORT_HTTP,                            /* defport */ | ||||||
|   CURLPROTO_HTTP,                       /* protocol */ |   CURLPROTO_HTTP,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
| @@ -161,6 +163,7 @@ const struct Curl_handler Curl_handler_https = { | |||||||
|   http_getsock_do,                      /* doing_getsock */ |   http_getsock_do,                      /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_HTTPS,                           /* defport */ |   PORT_HTTPS,                           /* defport */ | ||||||
|   CURLPROTO_HTTP | CURLPROTO_HTTPS,     /* protocol */ |   CURLPROTO_HTTP | CURLPROTO_HTTPS,     /* protocol */ | ||||||
|   PROTOPT_SSL                           /* flags */ |   PROTOPT_SSL                           /* flags */ | ||||||
| @@ -192,7 +195,7 @@ char *Curl_checkheaders(struct SessionHandle *data, const char *thisheader) | |||||||
|  * case of allocation failure. Returns an empty string if the header value |  * case of allocation failure. Returns an empty string if the header value | ||||||
|  * consists entirely of whitespace. |  * consists entirely of whitespace. | ||||||
|  */ |  */ | ||||||
| char *Curl_copy_header_value(const char *h) | static char *copy_header_value(const char *h) | ||||||
| { | { | ||||||
|   const char *start; |   const char *start; | ||||||
|   const char *end; |   const char *end; | ||||||
| @@ -338,17 +341,16 @@ static bool pickoneauth(struct auth *pick) | |||||||
|  *   } |  *   } | ||||||
|  * } |  * } | ||||||
|  */ |  */ | ||||||
| CURLcode Curl_http_perhapsrewind(struct connectdata *conn) | static CURLcode http_perhapsrewind(struct connectdata *conn) | ||||||
| { | { | ||||||
|   struct SessionHandle *data = conn->data; |   struct SessionHandle *data = conn->data; | ||||||
|   struct HTTP *http = data->state.proto.http; |   struct HTTP *http = data->state.proto.http; | ||||||
|   curl_off_t bytessent; |   curl_off_t bytessent; | ||||||
|   curl_off_t expectsend = -1; /* default is unknown */ |   curl_off_t expectsend = -1; /* default is unknown */ | ||||||
|  |  | ||||||
|   if(!http || !(conn->handler->protocol & CURLPROTO_HTTP)) |   if(!http) | ||||||
|     /* If this is still NULL, we have not reach very far and we can |     /* If this is still NULL, we have not reach very far and we can safely | ||||||
|        safely skip this rewinding stuff, or this is attempted to get used |        skip this rewinding stuff */ | ||||||
|        when HTTP isn't activated */ |  | ||||||
|     return CURLE_OK; |     return CURLE_OK; | ||||||
|  |  | ||||||
|   switch(data->set.httpreq) { |   switch(data->set.httpreq) { | ||||||
| @@ -475,7 +477,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) | |||||||
|     if((data->set.httpreq != HTTPREQ_GET) && |     if((data->set.httpreq != HTTPREQ_GET) && | ||||||
|        (data->set.httpreq != HTTPREQ_HEAD) && |        (data->set.httpreq != HTTPREQ_HEAD) && | ||||||
|        !conn->bits.rewindaftersend) { |        !conn->bits.rewindaftersend) { | ||||||
|       code = Curl_http_perhapsrewind(conn); |       code = http_perhapsrewind(conn); | ||||||
|       if(code) |       if(code) | ||||||
|         return code; |         return code; | ||||||
|     } |     } | ||||||
| @@ -496,7 +498,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) | |||||||
|       data->state.authhost.done = TRUE; |       data->state.authhost.done = TRUE; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   if(Curl_http_should_fail(conn)) { |   if(http_should_fail(conn)) { | ||||||
|     failf (data, "The requested URL returned error: %d", |     failf (data, "The requested URL returned error: %d", | ||||||
|            data->req.httpcode); |            data->req.httpcode); | ||||||
|     code = CURLE_HTTP_RETURNED_ERROR; |     code = CURLE_HTTP_RETURNED_ERROR; | ||||||
| @@ -819,7 +821,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, | |||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Curl_http_should_fail() determines whether an HTTP response has gotten us |  * http_should_fail() determines whether an HTTP response has gotten us | ||||||
|  * into an error state or not. |  * into an error state or not. | ||||||
|  * |  * | ||||||
|  * @param conn all information about the current connection |  * @param conn all information about the current connection | ||||||
| @@ -828,7 +830,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, | |||||||
|  * |  * | ||||||
|  * @retval 1 communications should not continue |  * @retval 1 communications should not continue | ||||||
|  */ |  */ | ||||||
| int Curl_http_should_fail(struct connectdata *conn) | static int http_should_fail(struct connectdata *conn) | ||||||
| { | { | ||||||
|   struct SessionHandle *data; |   struct SessionHandle *data; | ||||||
|   int httpcode; |   int httpcode; | ||||||
| @@ -886,16 +888,6 @@ int Curl_http_should_fail(struct connectdata *conn) | |||||||
|   ** the client needs to reauthenticate.  Once that info is |   ** the client needs to reauthenticate.  Once that info is | ||||||
|   ** available, use it here. |   ** available, use it here. | ||||||
|   */ |   */ | ||||||
| #if 0 /* set to 1 when debugging this functionality */ |  | ||||||
|   infof(data,"%s: authstage = %d\n",__FUNCTION__,data->state.authstage); |  | ||||||
|   infof(data,"%s: authwant = 0x%08x\n",__FUNCTION__,data->state.authwant); |  | ||||||
|   infof(data,"%s: authavail = 0x%08x\n",__FUNCTION__,data->state.authavail); |  | ||||||
|   infof(data,"%s: httpcode = %d\n",__FUNCTION__,k->httpcode); |  | ||||||
|   infof(data,"%s: authdone = %d\n",__FUNCTION__,data->state.authdone); |  | ||||||
|   infof(data,"%s: newurl = %s\n",__FUNCTION__,data->req.newurl ? |  | ||||||
|         data->req.newurl : "(null)"); |  | ||||||
|   infof(data,"%s: authproblem = %d\n",__FUNCTION__,data->state.authproblem); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|   ** Either we're not authenticating, or we're supposed to |   ** Either we're not authenticating, or we're supposed to | ||||||
| @@ -1014,19 +1006,17 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, | |||||||
|  |  | ||||||
|   DEBUGASSERT(size > included_body_bytes); |   DEBUGASSERT(size > included_body_bytes); | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|   res = Curl_convert_to_network(conn->data, ptr, headersize); |   res = Curl_convert_to_network(conn->data, ptr, headersize); | ||||||
|   /* Curl_convert_to_network calls failf if unsuccessful */ |   /* Curl_convert_to_network calls failf if unsuccessful */ | ||||||
|   if(res != CURLE_OK) { |   if(res) { | ||||||
|     /* conversion failed, free memory and return to the caller */ |     /* conversion failed, free memory and return to the caller */ | ||||||
|     if(in->buffer) |     if(in->buffer) | ||||||
|       free(in->buffer); |       free(in->buffer); | ||||||
|     free(in); |     free(in); | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
|   if(conn->handler->protocol & CURLPROTO_HTTPS) { |   if(conn->handler->flags & PROTOPT_SSL) { | ||||||
|     /* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk |     /* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk | ||||||
|        when we speak HTTPS, as if only a fraction of it is sent now, this data |        when we speak HTTPS, as if only a fraction of it is sent now, this data | ||||||
|        needs to fit into the normal read-callback buffer later on and that |        needs to fit into the normal read-callback buffer later on and that | ||||||
| @@ -1305,7 +1295,7 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done) | |||||||
|   } |   } | ||||||
| #endif /* CURL_DISABLE_PROXY */ | #endif /* CURL_DISABLE_PROXY */ | ||||||
|  |  | ||||||
|   if(conn->handler->protocol & CURLPROTO_HTTPS) { |   if(conn->given->flags & PROTOPT_SSL) { | ||||||
|     /* perform SSL initialization */ |     /* perform SSL initialization */ | ||||||
|     if(data->state.used_interface == Curl_if_multi) { |     if(data->state.used_interface == Curl_if_multi) { | ||||||
|       result = https_connecting(conn, done); |       result = https_connecting(conn, done); | ||||||
| @@ -1344,7 +1334,7 @@ static int http_getsock_do(struct connectdata *conn, | |||||||
| static CURLcode https_connecting(struct connectdata *conn, bool *done) | static CURLcode https_connecting(struct connectdata *conn, bool *done) | ||||||
| { | { | ||||||
|   CURLcode result; |   CURLcode result; | ||||||
|   DEBUGASSERT((conn) && (conn->handler->protocol & CURLPROTO_HTTPS)); |   DEBUGASSERT((conn) && (conn->handler->flags & PROTOPT_SSL)); | ||||||
|  |  | ||||||
|   /* perform SSL initialization for this socket */ |   /* perform SSL initialization for this socket */ | ||||||
|   result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, done); |   result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, done); | ||||||
| @@ -1362,7 +1352,7 @@ static int https_getsock(struct connectdata *conn, | |||||||
|                          curl_socket_t *socks, |                          curl_socket_t *socks, | ||||||
|                          int numsocks) |                          int numsocks) | ||||||
| { | { | ||||||
|   if(conn->handler->protocol & CURLPROTO_HTTPS) { |   if(conn->handler->flags & PROTOPT_SSL) { | ||||||
|     struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET]; |     struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET]; | ||||||
|  |  | ||||||
|     if(!numsocks) |     if(!numsocks) | ||||||
| @@ -1533,6 +1523,11 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn, | |||||||
|                    we will force length zero then */ |                    we will force length zero then */ | ||||||
|                 checkprefix("Content-Length", headers->data)) |                 checkprefix("Content-Length", headers->data)) | ||||||
|           ; |           ; | ||||||
|  |         else if(conn->allocptr.te && | ||||||
|  |                 /* when asking for Transfer-Encoding, don't pass on a custom | ||||||
|  |                    Connection: */ | ||||||
|  |                 checkprefix("Connection", headers->data)) | ||||||
|  |           ; | ||||||
|         else { |         else { | ||||||
|           CURLcode result = Curl_add_bufferf(req_buffer, "%s\r\n", |           CURLcode result = Curl_add_bufferf(req_buffer, "%s\r\n", | ||||||
|                                              headers->data); |                                              headers->data); | ||||||
| @@ -1728,6 +1723,29 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) | |||||||
|       return CURLE_OUT_OF_MEMORY; |       return CURLE_OUT_OF_MEMORY; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | #ifdef HAVE_LIBZ | ||||||
|  |   /* we only consider transfer-encoding magic if libz support is built-in */ | ||||||
|  |  | ||||||
|  |   if(!Curl_checkheaders(data, "TE:") && data->set.http_transfer_encoding) { | ||||||
|  |     /* When we are to insert a TE: header in the request, we must also insert | ||||||
|  |        TE in a Connection: header, so we need to merge the custom provided | ||||||
|  |        Connection: header and prevent the original to get sent. Note that if | ||||||
|  |        the user has inserted his/hers own TE: header we don't do this magic | ||||||
|  |        but then assume that the user will handle it all! */ | ||||||
|  |     char *cptr = Curl_checkheaders(data, "Connection:"); | ||||||
|  | #define TE_HEADER "TE: gzip\r\n" | ||||||
|  |  | ||||||
|  |     Curl_safefree(conn->allocptr.te); | ||||||
|  |  | ||||||
|  |     /* Create the (updated) Connection: header */ | ||||||
|  |     conn->allocptr.te = cptr? aprintf("%s, TE\r\n" TE_HEADER, cptr): | ||||||
|  |       strdup("Connection: TE\r\n" TE_HEADER); | ||||||
|  |  | ||||||
|  |     if(!conn->allocptr.te) | ||||||
|  |       return CURLE_OUT_OF_MEMORY; | ||||||
|  |   } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|   ptr = Curl_checkheaders(data, "Transfer-Encoding:"); |   ptr = Curl_checkheaders(data, "Transfer-Encoding:"); | ||||||
|   if(ptr) { |   if(ptr) { | ||||||
|     /* Some kind of TE is requested, check if 'chunked' is chosen */ |     /* Some kind of TE is requested, check if 'chunked' is chosen */ | ||||||
| @@ -1770,7 +1788,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) | |||||||
|        custom Host: header if this is NOT a redirect, as setting Host: in the |        custom Host: header if this is NOT a redirect, as setting Host: in the | ||||||
|        redirected request is being out on thin ice. Except if the host name |        redirected request is being out on thin ice. Except if the host name | ||||||
|        is the same as the first one! */ |        is the same as the first one! */ | ||||||
|     char *cookiehost = Curl_copy_header_value(ptr); |     char *cookiehost = copy_header_value(ptr); | ||||||
|     if(!cookiehost) |     if(!cookiehost) | ||||||
|       return CURLE_OUT_OF_MEMORY; |       return CURLE_OUT_OF_MEMORY; | ||||||
|     if(!*cookiehost) |     if(!*cookiehost) | ||||||
| @@ -2058,6 +2076,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) | |||||||
|                 "%s" /* user agent */ |                 "%s" /* user agent */ | ||||||
|                 "%s" /* host */ |                 "%s" /* host */ | ||||||
|                 "%s" /* accept */ |                 "%s" /* accept */ | ||||||
|  |                 "%s" /* TE: */ | ||||||
|                 "%s" /* accept-encoding */ |                 "%s" /* accept-encoding */ | ||||||
|                 "%s" /* referer */ |                 "%s" /* referer */ | ||||||
|                 "%s" /* Proxy-Connection */ |                 "%s" /* Proxy-Connection */ | ||||||
| @@ -2075,6 +2094,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) | |||||||
|                 conn->allocptr.uagent:"", |                 conn->allocptr.uagent:"", | ||||||
|                 (conn->allocptr.host?conn->allocptr.host:""), /* Host: host */ |                 (conn->allocptr.host?conn->allocptr.host:""), /* Host: host */ | ||||||
|                 http->p_accept?http->p_accept:"", |                 http->p_accept?http->p_accept:"", | ||||||
|  |                 conn->allocptr.te?conn->allocptr.te:"", | ||||||
|                 (data->set.str[STRING_ENCODING] && |                 (data->set.str[STRING_ENCODING] && | ||||||
|                  *data->set.str[STRING_ENCODING] && |                  *data->set.str[STRING_ENCODING] && | ||||||
|                  conn->allocptr.accept_encoding)? |                  conn->allocptr.accept_encoding)? | ||||||
| @@ -2262,14 +2282,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) | |||||||
|       Curl_formclean(&http->sendit); /* free that whole lot */ |       Curl_formclean(&http->sendit); /* free that whole lot */ | ||||||
|       return result; |       return result; | ||||||
|     } |     } | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
| /* time to convert the form data... */ |     /* convert the form data */ | ||||||
|     result = Curl_formconvert(data, http->sendit); |     result = Curl_convert_form(data, http->sendit); | ||||||
|     if(result) { |     if(result) { | ||||||
|       Curl_formclean(&http->sendit); /* free that whole lot */ |       Curl_formclean(&http->sendit); /* free that whole lot */ | ||||||
|       return result; |       return result; | ||||||
|     } |     } | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|     break; |     break; | ||||||
|  |  | ||||||
|   case HTTPREQ_PUT: /* Let's PUT the data to the server! */ |   case HTTPREQ_PUT: /* Let's PUT the data to the server! */ | ||||||
| @@ -2527,9 +2547,8 @@ checkhttpprefix(struct SessionHandle *data, | |||||||
|     head = head->next; |     head = head->next; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if((rc != TRUE) && (checkprefix("HTTP/", s))) { |   if((rc != TRUE) && (checkprefix("HTTP/", s))) | ||||||
|     rc = TRUE; |     rc = TRUE; | ||||||
|   } |  | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS | #ifdef CURL_DOES_CONVERSIONS | ||||||
|   free(scratch); |   free(scratch); | ||||||
| @@ -2775,7 +2794,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|        * When all the headers have been parsed, see if we should give |        * When all the headers have been parsed, see if we should give | ||||||
|        * up and return an error. |        * up and return an error. | ||||||
|        */ |        */ | ||||||
|       if(Curl_http_should_fail(conn)) { |       if(http_should_fail(conn)) { | ||||||
|         failf (data, "The requested URL returned error: %d", |         failf (data, "The requested URL returned error: %d", | ||||||
|                k->httpcode); |                k->httpcode); | ||||||
|         return CURLE_HTTP_RETURNED_ERROR; |         return CURLE_HTTP_RETURNED_ERROR; | ||||||
| @@ -2901,10 +2920,9 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|       res = Curl_convert_from_network(data, |       res = Curl_convert_from_network(data, | ||||||
|                                       &scratch[0], |                                       &scratch[0], | ||||||
|                                       SCRATCHSIZE); |                                       SCRATCHSIZE); | ||||||
|       if(CURLE_OK != res) { |       if(res) | ||||||
|         /* Curl_convert_from_network calls failf if unsuccessful */ |         /* Curl_convert_from_network calls failf if unsuccessful */ | ||||||
|         return res; |         return res; | ||||||
|       } |  | ||||||
| #else | #else | ||||||
| #define HEADER1 k->p /* no conversion needed, just use k->p */ | #define HEADER1 k->p /* no conversion needed, just use k->p */ | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ | #endif /* CURL_DOES_CONVERSIONS */ | ||||||
| @@ -3035,14 +3053,10 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|     /* convert from the network encoding */ |  | ||||||
|     result = Curl_convert_from_network(data, k->p, strlen(k->p)); |     result = Curl_convert_from_network(data, k->p, strlen(k->p)); | ||||||
|     if(CURLE_OK != result) { |  | ||||||
|       return(result); |  | ||||||
|     } |  | ||||||
|     /* Curl_convert_from_network calls failf if unsuccessful */ |     /* Curl_convert_from_network calls failf if unsuccessful */ | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |     if(result) | ||||||
|  |       return result; | ||||||
|  |  | ||||||
|     /* Check for Content-Length: header lines to get size */ |     /* Check for Content-Length: header lines to get size */ | ||||||
|     if(!k->ignorecl && !data->set.ignorecl && |     if(!k->ignorecl && !data->set.ignorecl && | ||||||
| @@ -3072,7 +3086,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|     } |     } | ||||||
|     /* check for Content-Type: header lines to get the MIME-type */ |     /* check for Content-Type: header lines to get the MIME-type */ | ||||||
|     else if(checkprefix("Content-Type:", k->p)) { |     else if(checkprefix("Content-Type:", k->p)) { | ||||||
|       char *contenttype = Curl_copy_header_value(k->p); |       char *contenttype = copy_header_value(k->p); | ||||||
|       if(!contenttype) |       if(!contenttype) | ||||||
|         return CURLE_OUT_OF_MEMORY; |         return CURLE_OUT_OF_MEMORY; | ||||||
|       if(!*contenttype) |       if(!*contenttype) | ||||||
| @@ -3127,8 +3141,9 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|        */ |        */ | ||||||
|       conn->bits.close = TRUE; /* close when done */ |       conn->bits.close = TRUE; /* close when done */ | ||||||
|     } |     } | ||||||
|     else if(Curl_compareheader(k->p, "Transfer-Encoding:", "chunked") && |     else if(checkprefix("Transfer-Encoding:", k->p)) { | ||||||
|             !(conn->handler->protocol & CURLPROTO_RTSP)) { |       /* One or more encodings. We check for chunked and/or a compression | ||||||
|  |          algorithm. */ | ||||||
|       /* |       /* | ||||||
|        * [RFC 2616, section 3.6.1] A 'chunked' transfer encoding |        * [RFC 2616, section 3.6.1] A 'chunked' transfer encoding | ||||||
|        * means that the server will send a series of "chunks". Each |        * means that the server will send a series of "chunks". Each | ||||||
| @@ -3137,10 +3152,60 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|        * with the previously mentioned size. There can be any amount |        * with the previously mentioned size. There can be any amount | ||||||
|        * of chunks, and a chunk-data set to zero signals the |        * of chunks, and a chunk-data set to zero signals the | ||||||
|        * end-of-chunks. */ |        * end-of-chunks. */ | ||||||
|  |  | ||||||
|  |       char *start; | ||||||
|  |  | ||||||
|  |       /* Find the first non-space letter */ | ||||||
|  |       start = k->p + 18; | ||||||
|  |  | ||||||
|  |       for(;;) { | ||||||
|  |         /* skip whitespaces and commas */ | ||||||
|  |         while(*start && (ISSPACE(*start) || (*start == ','))) | ||||||
|  |           start++; | ||||||
|  |  | ||||||
|  |         if(checkprefix("chunked", start)) { | ||||||
|           k->chunk = TRUE; /* chunks coming our way */ |           k->chunk = TRUE; /* chunks coming our way */ | ||||||
|  |  | ||||||
|           /* init our chunky engine */ |           /* init our chunky engine */ | ||||||
|           Curl_httpchunk_init(conn); |           Curl_httpchunk_init(conn); | ||||||
|  |  | ||||||
|  |           start += 7; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if(k->auto_decoding) | ||||||
|  |           /* TODO: we only support the first mentioned compression for now */ | ||||||
|  |           break; | ||||||
|  |  | ||||||
|  |         if(checkprefix("identity", start)) { | ||||||
|  |           k->auto_decoding = IDENTITY; | ||||||
|  |           start += 8; | ||||||
|  |         } | ||||||
|  |         else if(checkprefix("deflate", start)) { | ||||||
|  |           k->auto_decoding = DEFLATE; | ||||||
|  |           start += 7; | ||||||
|  |         } | ||||||
|  |         else if(checkprefix("gzip", start)) { | ||||||
|  |           k->auto_decoding = GZIP; | ||||||
|  |           start += 4; | ||||||
|  |         } | ||||||
|  |         else if(checkprefix("x-gzip", start)) { | ||||||
|  |           k->auto_decoding = GZIP; | ||||||
|  |           start += 6; | ||||||
|  |         } | ||||||
|  |         else if(checkprefix("compress", start)) { | ||||||
|  |           k->auto_decoding = COMPRESS; | ||||||
|  |           start += 8; | ||||||
|  |         } | ||||||
|  |         else if(checkprefix("x-compress", start)) { | ||||||
|  |           k->auto_decoding = COMPRESS; | ||||||
|  |           start += 10; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |           /* unknown! */ | ||||||
|  |           break; | ||||||
|  |  | ||||||
|  |       } | ||||||
|  |  | ||||||
|     } |     } | ||||||
|     else if(checkprefix("Content-Encoding:", k->p) && |     else if(checkprefix("Content-Encoding:", k->p) && | ||||||
|             data->set.str[STRING_ENCODING]) { |             data->set.str[STRING_ENCODING]) { | ||||||
| @@ -3160,15 +3225,15 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|  |  | ||||||
|       /* Record the content-encoding for later use */ |       /* Record the content-encoding for later use */ | ||||||
|       if(checkprefix("identity", start)) |       if(checkprefix("identity", start)) | ||||||
|         k->content_encoding = IDENTITY; |         k->auto_decoding = IDENTITY; | ||||||
|       else if(checkprefix("deflate", start)) |       else if(checkprefix("deflate", start)) | ||||||
|         k->content_encoding = DEFLATE; |         k->auto_decoding = DEFLATE; | ||||||
|       else if(checkprefix("gzip", start) |       else if(checkprefix("gzip", start) | ||||||
|               || checkprefix("x-gzip", start)) |               || checkprefix("x-gzip", start)) | ||||||
|         k->content_encoding = GZIP; |         k->auto_decoding = GZIP; | ||||||
|       else if(checkprefix("compress", start) |       else if(checkprefix("compress", start) | ||||||
|               || checkprefix("x-compress", start)) |               || checkprefix("x-compress", start)) | ||||||
|         k->content_encoding = COMPRESS; |         k->auto_decoding = COMPRESS; | ||||||
|     } |     } | ||||||
|     else if(checkprefix("Content-Range:", k->p)) { |     else if(checkprefix("Content-Range:", k->p)) { | ||||||
|       /* Content-Range: bytes [num]- |       /* Content-Range: bytes [num]- | ||||||
| @@ -3227,7 +3292,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|             checkprefix("Location:", k->p) && |             checkprefix("Location:", k->p) && | ||||||
|             !data->req.location) { |             !data->req.location) { | ||||||
|       /* this is the URL that the server advises us to use instead */ |       /* this is the URL that the server advises us to use instead */ | ||||||
|       char *location = Curl_copy_header_value(k->p); |       char *location = copy_header_value(k->p); | ||||||
|       if(!location) |       if(!location) | ||||||
|         return CURLE_OUT_OF_MEMORY; |         return CURLE_OUT_OF_MEMORY; | ||||||
|       if(!*location) |       if(!*location) | ||||||
| @@ -3244,19 +3309,18 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, | |||||||
|  |  | ||||||
|           /* some cases of POST and PUT etc needs to rewind the data |           /* some cases of POST and PUT etc needs to rewind the data | ||||||
|              stream at this point */ |              stream at this point */ | ||||||
|           result = Curl_http_perhapsrewind(conn); |           result = http_perhapsrewind(conn); | ||||||
|           if(result) |           if(result) | ||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| #ifndef CURL_DISABLE_RTSP |  | ||||||
|     else if(conn->handler->protocol & CURLPROTO_RTSP) { |     else if(conn->handler->protocol & CURLPROTO_RTSP) { | ||||||
|       result = Curl_rtsp_parseheader(conn, k->p); |       result = Curl_rtsp_parseheader(conn, k->p); | ||||||
|       if(result) |       if(result) | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
| #endif |  | ||||||
|     /* |     /* | ||||||
|      * End of header-checks. Write them to the client. |      * End of header-checks. Write them to the client. | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -36,9 +36,6 @@ bool Curl_compareheader(const char *headerline,  /* line to check */ | |||||||
|  |  | ||||||
| char *Curl_checkheaders(struct SessionHandle *data, const char *thisheader); | char *Curl_checkheaders(struct SessionHandle *data, const char *thisheader); | ||||||
|  |  | ||||||
| char *Curl_copy_header_value(const char *h); |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||||
| /* | /* | ||||||
|  * The add_buffer series of functions are used to build one large memory chunk |  * The add_buffer series of functions are used to build one large memory chunk | ||||||
| @@ -83,8 +80,6 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, | |||||||
| CURLcode Curl_http_auth_act(struct connectdata *conn); | CURLcode Curl_http_auth_act(struct connectdata *conn); | ||||||
| CURLcode Curl_http_perhapsrewind(struct connectdata *conn); | CURLcode Curl_http_perhapsrewind(struct connectdata *conn); | ||||||
|  |  | ||||||
| int Curl_http_should_fail(struct connectdata *conn); |  | ||||||
|  |  | ||||||
| /* If only the PICKNONE bit is set, there has been a round-trip and we | /* If only the PICKNONE bit is set, there has been a round-trip and we | ||||||
|    selected to use no auth at all. Ie, we actively select no auth, as opposed |    selected to use no auth at all. Ie, we actively select no auth, as opposed | ||||||
|    to not having one selected. The other CURLAUTH_* defines are present in the |    to not having one selected. The other CURLAUTH_* defines are present in the | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -35,7 +35,7 @@ | |||||||
| #include "content_encoding.h" | #include "content_encoding.h" | ||||||
| #include "http.h" | #include "http.h" | ||||||
| #include "curl_memory.h" | #include "curl_memory.h" | ||||||
| #include "easyif.h" /* for Curl_convert_to_network prototype */ | #include "non-ascii.h" /* for Curl_convert_to_network prototype */ | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| @@ -153,17 +153,16 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, | |||||||
|         } |         } | ||||||
|         /* length and datap are unmodified */ |         /* length and datap are unmodified */ | ||||||
|         ch->hexbuffer[ch->hexindex]=0; |         ch->hexbuffer[ch->hexindex]=0; | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|         /* convert to host encoding before calling strtoul */ |         /* convert to host encoding before calling strtoul */ | ||||||
|         result = Curl_convert_from_network(conn->data, |         result = Curl_convert_from_network(conn->data, ch->hexbuffer, | ||||||
|                                            ch->hexbuffer, |  | ||||||
|                                            ch->hexindex); |                                            ch->hexindex); | ||||||
|         if(result != CURLE_OK) { |         if(result) { | ||||||
|           /* Curl_convert_from_network calls failf if unsuccessful */ |           /* Curl_convert_from_network calls failf if unsuccessful */ | ||||||
|           /* Treat it as a bad hex character */ |           /* Treat it as a bad hex character */ | ||||||
|           return(CHUNKE_ILLEGAL_HEX); |           return(CHUNKE_ILLEGAL_HEX); | ||||||
|         } |         } | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|         ch->datasize=strtoul(ch->hexbuffer, NULL, 16); |         ch->datasize=strtoul(ch->hexbuffer, NULL, 16); | ||||||
|         ch->state = CHUNK_POSTHEX; |         ch->state = CHUNK_POSTHEX; | ||||||
|       } |       } | ||||||
| @@ -209,7 +208,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, | |||||||
|       /* Write the data portion available */ |       /* Write the data portion available */ | ||||||
| #ifdef HAVE_LIBZ | #ifdef HAVE_LIBZ | ||||||
|       switch (conn->data->set.http_ce_skip? |       switch (conn->data->set.http_ce_skip? | ||||||
|               IDENTITY : data->req.content_encoding) { |               IDENTITY : data->req.auto_decoding) { | ||||||
|       case IDENTITY: |       case IDENTITY: | ||||||
| #endif | #endif | ||||||
|         if(!k->ignorebody) { |         if(!k->ignorebody) { | ||||||
| @@ -297,17 +296,14 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, | |||||||
|           conn->trailer[conn->trlPos++]=0x0a; |           conn->trailer[conn->trlPos++]=0x0a; | ||||||
|           conn->trailer[conn->trlPos]=0; |           conn->trailer[conn->trlPos]=0; | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|           /* Convert to host encoding before calling Curl_client_write */ |           /* Convert to host encoding before calling Curl_client_write */ | ||||||
|           result = Curl_convert_from_network(conn->data, |           result = Curl_convert_from_network(conn->data, conn->trailer, | ||||||
|                                              conn->trailer, |  | ||||||
|                                              conn->trlPos); |                                              conn->trlPos); | ||||||
|           if(result != CURLE_OK) |           if(result) | ||||||
|             /* Curl_convert_from_network calls failf if unsuccessful */ |             /* Curl_convert_from_network calls failf if unsuccessful */ | ||||||
|             /* Treat it as a bad chunk */ |             /* Treat it as a bad chunk */ | ||||||
|             return CHUNKE_BAD_CHUNK; |             return CHUNKE_BAD_CHUNK; | ||||||
|  |  | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|           if(!data->set.http_te_skip) { |           if(!data->set.http_te_skip) { | ||||||
|             result = Curl_client_write(conn, CLIENTWRITE_HEADER, |             result = Curl_client_write(conn, CLIENTWRITE_HEADER, | ||||||
|                                        conn->trailer, conn->trlPos); |                                        conn->trailer, conn->trlPos); | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -38,7 +38,7 @@ | |||||||
| #include "strtok.h" | #include "strtok.h" | ||||||
| #include "url.h" /* for Curl_safefree() */ | #include "url.h" /* for Curl_safefree() */ | ||||||
| #include "curl_memory.h" | #include "curl_memory.h" | ||||||
| #include "easyif.h" /* included for Curl_convert_... prototypes */ | #include "non-ascii.h" /* included for Curl_convert_... prototypes */ | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| @@ -49,6 +49,8 @@ | |||||||
| #define MAX_VALUE_LENGTH 256 | #define MAX_VALUE_LENGTH 256 | ||||||
| #define MAX_CONTENT_LENGTH 1024 | #define MAX_CONTENT_LENGTH 1024 | ||||||
|  |  | ||||||
|  | static void digest_cleanup_one(struct digestdata *dig); | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Return 0 on success and then the buffers are filled in fine. |  * Return 0 on success and then the buffers are filled in fine. | ||||||
|  * |  * | ||||||
| @@ -88,8 +90,8 @@ static int get_pair(const char *str, char *value, char *content, | |||||||
|       break; |       break; | ||||||
|     case ',': |     case ',': | ||||||
|       if(!starts_with_quote) { |       if(!starts_with_quote) { | ||||||
|         /* this signals the end of the content if we didn't get a starting quote |         /* this signals the end of the content if we didn't get a starting | ||||||
|            and then we do "sloppy" parsing */ |            quote and then we do "sloppy" parsing */ | ||||||
|         c=0; /* the end */ |         c=0; /* the end */ | ||||||
|         continue; |         continue; | ||||||
|       } |       } | ||||||
| @@ -156,7 +158,7 @@ CURLdigest Curl_input_digest(struct connectdata *conn, | |||||||
|       before = TRUE; |       before = TRUE; | ||||||
|  |  | ||||||
|     /* clear off any former leftovers and init to defaults */ |     /* clear off any former leftovers and init to defaults */ | ||||||
|     Curl_digest_cleanup_one(d); |     digest_cleanup_one(d); | ||||||
|  |  | ||||||
|     for(;;) { |     for(;;) { | ||||||
|       char value[MAX_VALUE_LENGTH]; |       char value[MAX_VALUE_LENGTH]; | ||||||
| @@ -294,7 +296,6 @@ CURLcode Curl_output_digest(struct connectdata *conn, | |||||||
|  |  | ||||||
|   struct SessionHandle *data = conn->data; |   struct SessionHandle *data = conn->data; | ||||||
|   struct digestdata *d; |   struct digestdata *d; | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|   CURLcode rc; |   CURLcode rc; | ||||||
| /* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines. | /* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines. | ||||||
|    It converts digest text to ASCII so the MD5 will be correct for |    It converts digest text to ASCII so the MD5 will be correct for | ||||||
| @@ -306,9 +307,6 @@ CURLcode Curl_output_digest(struct connectdata *conn, | |||||||
|     free(b); \ |     free(b); \ | ||||||
|     return rc; \ |     return rc; \ | ||||||
|   } |   } | ||||||
| #else |  | ||||||
| #define CURL_OUTPUT_DIGEST_CONV(a, b) |  | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
|   if(proxy) { |   if(proxy) { | ||||||
|     d = &data->state.proxydigest; |     d = &data->state.proxydigest; | ||||||
| @@ -543,7 +541,7 @@ CURLcode Curl_output_digest(struct connectdata *conn, | |||||||
|   return CURLE_OK; |   return CURLE_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| void Curl_digest_cleanup_one(struct digestdata *d) | static void digest_cleanup_one(struct digestdata *d) | ||||||
| { | { | ||||||
|   if(d->nonce) |   if(d->nonce) | ||||||
|     free(d->nonce); |     free(d->nonce); | ||||||
| @@ -577,8 +575,8 @@ void Curl_digest_cleanup_one(struct digestdata *d) | |||||||
|  |  | ||||||
| void Curl_digest_cleanup(struct SessionHandle *data) | void Curl_digest_cleanup(struct SessionHandle *data) | ||||||
| { | { | ||||||
|   Curl_digest_cleanup_one(&data->state.digest); |   digest_cleanup_one(&data->state.digest); | ||||||
|   Curl_digest_cleanup_one(&data->state.proxydigest); |   digest_cleanup_one(&data->state.proxydigest); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -46,7 +46,6 @@ CURLcode Curl_output_digest(struct connectdata *conn, | |||||||
|                             bool proxy, |                             bool proxy, | ||||||
|                             const unsigned char *request, |                             const unsigned char *request, | ||||||
|                             const unsigned char *uripath); |                             const unsigned char *uripath); | ||||||
| void Curl_digest_cleanup_one(struct digestdata *dig); |  | ||||||
|  |  | ||||||
| #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH) | #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH) | ||||||
| void Curl_digest_cleanup(struct SessionHandle *data); | void Curl_digest_cleanup(struct SessionHandle *data); | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -100,7 +100,8 @@ get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server) | |||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| log_gss_error(struct connectdata *conn, OM_uint32 error_status, const char *prefix) | log_gss_error(struct connectdata *conn, OM_uint32 error_status, | ||||||
|  |               const char *prefix) | ||||||
| { | { | ||||||
|   OM_uint32 maj_stat, min_stat; |   OM_uint32 maj_stat, min_stat; | ||||||
|   OM_uint32 msg_ctx = 0; |   OM_uint32 msg_ctx = 0; | ||||||
| @@ -167,7 +168,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   if(neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) { |   if(neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) { | ||||||
|     /* We finished succesfully our part of authentication, but server |     /* We finished successfully our part of authentication, but server | ||||||
|      * rejected it (since we're again here). Exit with an error since we |      * rejected it (since we're again here). Exit with an error since we | ||||||
|      * can't invent anything better */ |      * can't invent anything better */ | ||||||
|     Curl_cleanup_negotiate(conn->data); |     Curl_cleanup_negotiate(conn->data); | ||||||
| @@ -242,7 +243,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, | |||||||
|                                       &neg_ctx->context, |                                       &neg_ctx->context, | ||||||
|                                       neg_ctx->server_name, |                                       neg_ctx->server_name, | ||||||
|                                       GSS_C_NO_OID, |                                       GSS_C_NO_OID, | ||||||
|                                       GSS_C_DELEG_FLAG, |                                       0, | ||||||
|                                       0, |                                       0, | ||||||
|                                       GSS_C_NO_CHANNEL_BINDINGS, |                                       GSS_C_NO_CHANNEL_BINDINGS, | ||||||
|                                       &input_token, |                                       &input_token, | ||||||
|   | |||||||
| @@ -122,7 +122,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   if(neg_ctx->context && neg_ctx->status == SEC_E_OK) { |   if(neg_ctx->context && neg_ctx->status == SEC_E_OK) { | ||||||
|     /* We finished succesfully our part of authentication, but server |     /* We finished successfully our part of authentication, but server | ||||||
|      * rejected it (since we're again here). Exit with an error since we |      * rejected it (since we're again here). Exit with an error since we | ||||||
|      * can't invent anything better */ |      * can't invent anything better */ | ||||||
|     Curl_cleanup_negotiate(conn->data); |     Curl_cleanup_negotiate(conn->data); | ||||||
| @@ -133,7 +133,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, | |||||||
|      (ret = get_gss_name(conn, proxy, neg_ctx->server_name))) |      (ret = get_gss_name(conn, proxy, neg_ctx->server_name))) | ||||||
|     return ret; |     return ret; | ||||||
|  |  | ||||||
|   if (!neg_ctx->max_token_length) { |   if(!neg_ctx->output_token) { | ||||||
|     PSecPkgInfo SecurityPackage; |     PSecPkgInfo SecurityPackage; | ||||||
|     ret = s_pSecFn->QuerySecurityPackageInfo((SEC_CHAR *)"Negotiate", |     ret = s_pSecFn->QuerySecurityPackageInfo((SEC_CHAR *)"Negotiate", | ||||||
|                                              &SecurityPackage); |                                              &SecurityPackage); | ||||||
| @@ -143,7 +143,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, | |||||||
|     /* Allocate input and output buffers according to the max token size |     /* Allocate input and output buffers according to the max token size | ||||||
|        as indicated by the security package */ |        as indicated by the security package */ | ||||||
|     neg_ctx->max_token_length = SecurityPackage->cbMaxToken; |     neg_ctx->max_token_length = SecurityPackage->cbMaxToken; | ||||||
|     neg_ctx->output_token = (BYTE *)malloc(neg_ctx->max_token_length); |     neg_ctx->output_token = malloc(neg_ctx->max_token_length); | ||||||
|     s_pSecFn->FreeContextBuffer(SecurityPackage); |     s_pSecFn->FreeContextBuffer(SecurityPackage); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -153,23 +153,12 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, | |||||||
|     header++; |     header++; | ||||||
|  |  | ||||||
|   len = strlen(header); |   len = strlen(header); | ||||||
|   if(len > 0) { |   if(!len) { | ||||||
|     input_token = malloc(neg_ctx->max_token_length); |     /* first call in a new negotation, we have to acquire credentials, | ||||||
|     if(!input_token) |  | ||||||
|       return -1; |  | ||||||
|  |  | ||||||
|     input_token_len = Curl_base64_decode(header, |  | ||||||
|                                          (unsigned char **)&input_token); |  | ||||||
|     if(input_token_len == 0) |  | ||||||
|       return -1; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if ( !input_token ) { |  | ||||||
|     /* first call in a new negotation, we have to require credentials, |  | ||||||
|        and allocate memory for the context */ |        and allocate memory for the context */ | ||||||
|  |  | ||||||
|     neg_ctx->credentials = (CredHandle *)malloc(sizeof(CredHandle)); |     neg_ctx->credentials = malloc(sizeof(CredHandle)); | ||||||
|     neg_ctx->context = (CtxtHandle *)malloc(sizeof(CtxtHandle)); |     neg_ctx->context = malloc(sizeof(CtxtHandle)); | ||||||
|  |  | ||||||
|     if(!neg_ctx->credentials || !neg_ctx->context) |     if(!neg_ctx->credentials || !neg_ctx->context) | ||||||
|       return -1; |       return -1; | ||||||
| @@ -182,6 +171,16 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, | |||||||
|     if(neg_ctx->status != SEC_E_OK) |     if(neg_ctx->status != SEC_E_OK) | ||||||
|       return -1; |       return -1; | ||||||
|   } |   } | ||||||
|  |   else { | ||||||
|  |     input_token = malloc(neg_ctx->max_token_length); | ||||||
|  |     if(!input_token) | ||||||
|  |       return -1; | ||||||
|  |  | ||||||
|  |     input_token_len = Curl_base64_decode(header, | ||||||
|  |                                          (unsigned char **)&input_token); | ||||||
|  |     if(input_token_len == 0) | ||||||
|  |       return -1; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /* prepare the output buffers, and input buffers if present */ |   /* prepare the output buffers, and input buffers if present */ | ||||||
|   out_buff_desc.ulVersion = 0; |   out_buff_desc.ulVersion = 0; | ||||||
| @@ -280,6 +279,8 @@ static void cleanup(struct negotiatedata *neg_ctx) | |||||||
|     free(neg_ctx->output_token); |     free(neg_ctx->output_token); | ||||||
|     neg_ctx->output_token = 0; |     neg_ctx->output_token = 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   neg_ctx->max_token_length = 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void Curl_cleanup_negotiate(struct SessionHandle *data) | void Curl_cleanup_negotiate(struct SessionHandle *data) | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -25,10 +25,6 @@ | |||||||
|  |  | ||||||
|    http://davenport.sourceforge.net/ntlm.html |    http://davenport.sourceforge.net/ntlm.html | ||||||
|    http://www.innovation.ch/java/ntlm.html |    http://www.innovation.ch/java/ntlm.html | ||||||
|  |  | ||||||
|    Another implementation: |  | ||||||
|    http://lxr.mozilla.org/mozilla/source/security/manager/ssl/src/nsNTLMAuthModule.cpp |  | ||||||
|  |  | ||||||
| */ | */ | ||||||
|  |  | ||||||
| #ifndef CURL_DISABLE_HTTP | #ifndef CURL_DISABLE_HTTP | ||||||
| @@ -52,7 +48,7 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| #include "easyif.h"  /* for Curl_convert_... prototypes */ | #include "non-ascii.h"  /* for Curl_convert_... prototypes */ | ||||||
| #include "sendf.h" | #include "sendf.h" | ||||||
| #include "rawstr.h" | #include "rawstr.h" | ||||||
| #include "curl_base64.h" | #include "curl_base64.h" | ||||||
| @@ -87,6 +83,10 @@ | |||||||
| #      include <rand.h> | #      include <rand.h> | ||||||
| #    endif | #    endif | ||||||
|  |  | ||||||
|  | #ifndef OPENSSL_VERSION_NUMBER | ||||||
|  | #error "OPENSSL_VERSION_NUMBER not defined" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #if OPENSSL_VERSION_NUMBER < 0x00907001L | #if OPENSSL_VERSION_NUMBER < 0x00907001L | ||||||
| #define DES_key_schedule des_key_schedule | #define DES_key_schedule des_key_schedule | ||||||
| #define DES_cblock des_cblock | #define DES_cblock des_cblock | ||||||
| @@ -516,6 +516,7 @@ static void mk_lm_hash(struct SessionHandle *data, | |||||||
|                        const char *password, |                        const char *password, | ||||||
|                        unsigned char *lmbuffer /* 21 bytes */) |                        unsigned char *lmbuffer /* 21 bytes */) | ||||||
| { | { | ||||||
|  |   CURLcode res; | ||||||
|   unsigned char pw[14]; |   unsigned char pw[14]; | ||||||
|   static const unsigned char magic[] = { |   static const unsigned char magic[] = { | ||||||
|     0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 /* i.e. KGS!@#$% */ |     0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 /* i.e. KGS!@#$% */ | ||||||
| @@ -525,16 +526,13 @@ static void mk_lm_hash(struct SessionHandle *data, | |||||||
|   Curl_strntoupper((char *)pw, password, len); |   Curl_strntoupper((char *)pw, password, len); | ||||||
|   memset(&pw[len], 0, 14-len); |   memset(&pw[len], 0, 14-len); | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|   /* |   /* | ||||||
|    * The LanManager hashed password needs to be created using the |    * The LanManager hashed password needs to be created using the | ||||||
|    * password in the network encoding not the host encoding. |    * password in the network encoding not the host encoding. | ||||||
|    */ |    */ | ||||||
|   if(data) |   res = Curl_convert_to_network(data, (char *)pw, 14); | ||||||
|     Curl_convert_to_network(data, (char *)pw, 14); |   if(res) | ||||||
| #else |     return; | ||||||
|   (void)data; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   { |   { | ||||||
|     /* Create LanManager hashed password. */ |     /* Create LanManager hashed password. */ | ||||||
| @@ -590,21 +588,19 @@ static CURLcode mk_nt_hash(struct SessionHandle *data, | |||||||
| { | { | ||||||
|   size_t len = strlen(password); |   size_t len = strlen(password); | ||||||
|   unsigned char *pw = malloc(len*2); |   unsigned char *pw = malloc(len*2); | ||||||
|  |   CURLcode result; | ||||||
|   if(!pw) |   if(!pw) | ||||||
|     return CURLE_OUT_OF_MEMORY; |     return CURLE_OUT_OF_MEMORY; | ||||||
|  |  | ||||||
|   ascii_to_unicode_le(pw, password, len); |   ascii_to_unicode_le(pw, password, len); | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|   /* |   /* | ||||||
|    * The NT hashed password needs to be created using the |    * The NT hashed password needs to be created using the password in the | ||||||
|    * password in the network encoding not the host encoding. |    * network encoding not the host encoding. | ||||||
|    */ |    */ | ||||||
|   if(data) |   result = Curl_convert_to_network(data, (char *)pw, len*2); | ||||||
|     Curl_convert_to_network(data, (char *)pw, len*2); |   if(result) | ||||||
| #else |     return result; | ||||||
|   (void)data; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|   { |   { | ||||||
|     /* Create NT hashed password. */ |     /* Create NT hashed password. */ | ||||||
| @@ -664,6 +660,20 @@ ntlm_sspi_cleanup(struct ntlmdata *ntlm) | |||||||
|  |  | ||||||
| #define HOSTNAME_MAX 1024 | #define HOSTNAME_MAX 1024 | ||||||
|  |  | ||||||
|  | #ifndef USE_WINDOWS_SSPI | ||||||
|  | /* copy the source to the destination and fill in zeroes in every | ||||||
|  |    other destination byte! */ | ||||||
|  | static void unicodecpy(unsigned char *dest, | ||||||
|  |                        const char *src, size_t length) | ||||||
|  | { | ||||||
|  |   size_t i; | ||||||
|  |   for(i=0; i<length; i++) { | ||||||
|  |     dest[2*i] = (unsigned char)src[i]; | ||||||
|  |     dest[2*i+1] = '\0'; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* this is for creating ntlm header output */ | /* this is for creating ntlm header output */ | ||||||
| CURLcode Curl_output_ntlm(struct connectdata *conn, | CURLcode Curl_output_ntlm(struct connectdata *conn, | ||||||
|                           bool proxy) |                           bool proxy) | ||||||
| @@ -881,7 +891,8 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     DEBUG_OUT({ |     DEBUG_OUT({ | ||||||
|       fprintf(stderr, "**** TYPE1 header flags=0x%02.2x%02.2x%02.2x%02.2x 0x%08.8x ", |         fprintf(stderr, "* TYPE1 header flags=0x%02.2x%02.2x%02.2x%02.2x " | ||||||
|  |                 "0x%08.8x ", | ||||||
|                 LONGQUARTET(NTLMFLAG_NEGOTIATE_OEM| |                 LONGQUARTET(NTLMFLAG_NEGOTIATE_OEM| | ||||||
|                             NTLMFLAG_REQUEST_TARGET| |                             NTLMFLAG_REQUEST_TARGET| | ||||||
|                             NTLMFLAG_NEGOTIATE_NTLM_KEY| |                             NTLMFLAG_NEGOTIATE_NTLM_KEY| | ||||||
| @@ -955,13 +966,16 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, | |||||||
|     type_3.pvBuffer   = ntlmbuf; |     type_3.pvBuffer   = ntlmbuf; | ||||||
|     type_3.cbBuffer   = sizeof(ntlmbuf); |     type_3.cbBuffer   = sizeof(ntlmbuf); | ||||||
|  |  | ||||||
|     status = s_pSecFn->InitializeSecurityContextA(&ntlm->handle, &ntlm->c_handle, |     status = s_pSecFn->InitializeSecurityContextA(&ntlm->handle, | ||||||
|  |                                                   &ntlm->c_handle, | ||||||
|                                                   (char *) host, |                                                   (char *) host, | ||||||
|                                                   ISC_REQ_CONFIDENTIALITY | |                                                   ISC_REQ_CONFIDENTIALITY | | ||||||
|                                                   ISC_REQ_REPLAY_DETECT | |                                                   ISC_REQ_REPLAY_DETECT | | ||||||
|                                                   ISC_REQ_CONNECTION, |                                                   ISC_REQ_CONNECTION, | ||||||
|                                        0, SECURITY_NETWORK_DREP, &type_2_desc, |                                                   0, SECURITY_NETWORK_DREP, | ||||||
|                                        0, &ntlm->c_handle, &type_3_desc, |                                                   &type_2_desc, | ||||||
|  |                                                   0, &ntlm->c_handle, | ||||||
|  |                                                   &type_3_desc, | ||||||
|                                                   &attrs, &tsDummy); |                                                   &attrs, &tsDummy); | ||||||
|  |  | ||||||
|     if(status != SEC_E_OK) |     if(status != SEC_E_OK) | ||||||
| @@ -978,9 +992,11 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, | |||||||
|     int ntrespoff; |     int ntrespoff; | ||||||
|     unsigned char ntresp[24]; /* fixed-size */ |     unsigned char ntresp[24]; /* fixed-size */ | ||||||
| #endif | #endif | ||||||
|  |     bool unicode = (ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE)?TRUE:FALSE; | ||||||
|     size_t useroff; |     size_t useroff; | ||||||
|     const char *user; |     const char *user; | ||||||
|     size_t userlen; |     size_t userlen; | ||||||
|  |     CURLcode res; | ||||||
|  |  | ||||||
|     user = strchr(userp, '\\'); |     user = strchr(userp, '\\'); | ||||||
|     if(!user) |     if(!user) | ||||||
| @@ -1010,6 +1026,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, | |||||||
|       hostlen = strlen(host); |       hostlen = strlen(host); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if(unicode) { | ||||||
|  |       domlen = domlen * 2; | ||||||
|  |       userlen = userlen * 2; | ||||||
|  |       hostlen = hostlen * 2; | ||||||
|  |     } | ||||||
|  |  | ||||||
| #if USE_NTLM2SESSION | #if USE_NTLM2SESSION | ||||||
|     /* We don't support NTLM2 if we don't have USE_NTRESPONSES */ |     /* We don't support NTLM2 if we don't have USE_NTRESPONSES */ | ||||||
|     if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) { |     if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) { | ||||||
| @@ -1099,13 +1121,6 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, | |||||||
|     useroff = domoff + domlen; |     useroff = domoff + domlen; | ||||||
|     hostoff = useroff + userlen; |     hostoff = useroff + userlen; | ||||||
|  |  | ||||||
|     /* |  | ||||||
|      * In the case the server sets the flag NTLMFLAG_NEGOTIATE_UNICODE, we |  | ||||||
|      * need to filter it off because libcurl doesn't UNICODE encode the |  | ||||||
|      * strings it packs into the NTLM authenticate packet. |  | ||||||
|      */ |  | ||||||
|     ntlm->flags &= ~NTLMFLAG_NEGOTIATE_UNICODE; |  | ||||||
|  |  | ||||||
|     /* Create the big type-3 message binary blob */ |     /* Create the big type-3 message binary blob */ | ||||||
|     size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf), |     size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf), | ||||||
|                     NTLMSSP_SIGNATURE "%c" |                     NTLMSSP_SIGNATURE "%c" | ||||||
| @@ -1233,25 +1248,34 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     DEBUGASSERT(size == domoff); |     DEBUGASSERT(size == domoff); | ||||||
|  |     if(unicode) | ||||||
|  |       unicodecpy(&ntlmbuf[size], domain, domlen/2); | ||||||
|  |     else | ||||||
|       memcpy(&ntlmbuf[size], domain, domlen); |       memcpy(&ntlmbuf[size], domain, domlen); | ||||||
|  |  | ||||||
|     size += domlen; |     size += domlen; | ||||||
|  |  | ||||||
|     DEBUGASSERT(size == useroff); |     DEBUGASSERT(size == useroff); | ||||||
|  |     if(unicode) | ||||||
|  |       unicodecpy(&ntlmbuf[size], user, userlen/2); | ||||||
|  |     else | ||||||
|       memcpy(&ntlmbuf[size], user, userlen); |       memcpy(&ntlmbuf[size], user, userlen); | ||||||
|  |  | ||||||
|     size += userlen; |     size += userlen; | ||||||
|  |  | ||||||
|     DEBUGASSERT(size == hostoff); |     DEBUGASSERT(size == hostoff); | ||||||
|  |     if(unicode) | ||||||
|  |       unicodecpy(&ntlmbuf[size], host, hostlen/2); | ||||||
|  |     else | ||||||
|       memcpy(&ntlmbuf[size], host, hostlen); |       memcpy(&ntlmbuf[size], host, hostlen); | ||||||
|  |  | ||||||
|     size += hostlen; |     size += hostlen; | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|     /* convert domain, user, and host to ASCII but leave the rest as-is */ |     /* convert domain, user, and host to ASCII but leave the rest as-is */ | ||||||
|     if(CURLE_OK != Curl_convert_to_network(conn->data, |     res = Curl_convert_to_network(conn->data, (char *)&ntlmbuf[domoff], | ||||||
|                                            (char *)&ntlmbuf[domoff], |                                   size-domoff); | ||||||
|                                            size-domoff)) { |     if(res) | ||||||
|       return CURLE_CONV_FAILED; |       return CURLE_CONV_FAILED; | ||||||
|     } |  | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,6 +24,9 @@ | |||||||
|  |  | ||||||
| #if !defined(CURL_DISABLE_PROXY) && !defined(CURL_DISABLE_HTTP) | #if !defined(CURL_DISABLE_PROXY) && !defined(CURL_DISABLE_HTTP) | ||||||
|  |  | ||||||
|  | #ifdef HAVE_UNISTD_H | ||||||
|  | #include <unistd.h> | ||||||
|  | #endif | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| #include <curl/curl.h> | #include <curl/curl.h> | ||||||
| #include "http_proxy.h" | #include "http_proxy.h" | ||||||
| @@ -33,6 +36,8 @@ | |||||||
| #include "select.h" | #include "select.h" | ||||||
| #include "rawstr.h" | #include "rawstr.h" | ||||||
| #include "progress.h" | #include "progress.h" | ||||||
|  | #include "non-ascii.h" | ||||||
|  | #include "connect.h" | ||||||
|  |  | ||||||
| #define _MPRINTF_REPLACE /* use our functions only */ | #define _MPRINTF_REPLACE /* use our functions only */ | ||||||
| #include <curl/mprintf.h> | #include <curl/mprintf.h> | ||||||
| @@ -160,7 +165,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, | |||||||
|  |  | ||||||
|         if(CURLE_OK == result) { |         if(CURLE_OK == result) { | ||||||
|           /* Now send off the request */ |           /* Now send off the request */ | ||||||
|           result = Curl_add_buffer_send(req_buffer, conn, |           result = | ||||||
|  |             Curl_add_buffer_send(req_buffer, conn, | ||||||
|                                  &data->info.request_size, 0, sockindex); |                                  &data->info.request_size, 0, sockindex); | ||||||
|         } |         } | ||||||
|         req_buffer = NULL; |         req_buffer = NULL; | ||||||
| @@ -238,7 +244,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, | |||||||
|  |  | ||||||
|         /* loop every second at least, less if the timeout is near */ |         /* loop every second at least, less if the timeout is near */ | ||||||
|         switch (Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, |         switch (Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, | ||||||
|                             check<1000L?(int)check:1000)) { |                                   check<1000L?check:1000)) { | ||||||
|         case -1: /* select() error, stop reading */ |         case -1: /* select() error, stop reading */ | ||||||
|           error = SELECT_ERROR; |           error = SELECT_ERROR; | ||||||
|           failf(data, "Proxy CONNECT aborted due to select/poll error"); |           failf(data, "Proxy CONNECT aborted due to select/poll error"); | ||||||
| @@ -315,14 +321,12 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, | |||||||
|                   char letter; |                   char letter; | ||||||
|                   int writetype; |                   int writetype; | ||||||
|  |  | ||||||
| #ifdef CURL_DOES_CONVERSIONS |  | ||||||
|                   /* convert from the network encoding */ |                   /* convert from the network encoding */ | ||||||
|                   result = Curl_convert_from_network(data, line_start, |                   result = Curl_convert_from_network(data, line_start, | ||||||
|                                                      perline); |                                                      perline); | ||||||
|                   /* Curl_convert_from_network calls failf if unsuccessful */ |                   /* Curl_convert_from_network calls failf if unsuccessful */ | ||||||
|                   if(result) |                   if(result) | ||||||
|                     return result; |                     return result; | ||||||
| #endif /* CURL_DOES_CONVERSIONS */ |  | ||||||
|  |  | ||||||
|                   /* output debug if that is requested */ |                   /* output debug if that is requested */ | ||||||
|                   if(data->set.verbose) |                   if(data->set.verbose) | ||||||
| @@ -479,7 +483,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, | |||||||
|  |  | ||||||
|       if(closeConnection && data->req.newurl) { |       if(closeConnection && data->req.newurl) { | ||||||
|         /* Connection closed by server. Don't use it anymore */ |         /* Connection closed by server. Don't use it anymore */ | ||||||
|         sclose(conn->sock[sockindex]); |         Curl_closesocket(conn, conn->sock[sockindex]); | ||||||
|         conn->sock[sockindex] = CURL_SOCKET_BAD; |         conn->sock[sockindex] = CURL_SOCKET_BAD; | ||||||
|         break; |         break; | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -1,3 +1,5 @@ | |||||||
|  | #ifndef HEADER_CURL_HTTP_PROXY_H | ||||||
|  | #define HEADER_CURL_HTTP_PROXY_H | ||||||
| /*************************************************************************** | /*************************************************************************** | ||||||
|  *                                  _   _ ____  _ |  *                                  _   _ ____  _ | ||||||
|  *  Project                     ___| | | |  _ \| | |  *  Project                     ___| | | |  _ \| | | ||||||
| @@ -31,3 +33,5 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, | |||||||
| #else | #else | ||||||
| #define Curl_proxyCONNECT(x,y,z,w) CURLE_NOT_BUILT_IN | #define Curl_proxyCONNECT(x,y,z,w) CURLE_NOT_BUILT_IN | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif /* HEADER_CURL_HTTP_PROXY_H */ | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -24,9 +24,15 @@ | |||||||
|  * Pierre Joye <pierre@php.net> |  * Pierre Joye <pierre@php.net> | ||||||
|  ***************************************************************************/ |  ***************************************************************************/ | ||||||
| #if defined(WIN32) && defined(USE_WIN32_IDN) | #if defined(WIN32) && defined(USE_WIN32_IDN) | ||||||
| #include "windows.h" | #include <windows.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <tchar.h> | #include <tchar.h> | ||||||
|  |  | ||||||
|  | #ifdef WANT_IDN_PROTOTYPES | ||||||
|  | WINBASEAPI int WINAPI IdnToAscii(DWORD, LPCWSTR, int, LPWSTR, int); | ||||||
|  | WINBASEAPI int WINAPI IdnToUnicode(DWORD, LPCWSTR, int, LPWSTR, int); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #define IDN_MAX_LENGTH 255 | #define IDN_MAX_LENGTH 255 | ||||||
|  |  | ||||||
| static wchar_t *_curl_win32_UTF8_to_wchar(const char *str_utf8) | static wchar_t *_curl_win32_UTF8_to_wchar(const char *str_utf8) | ||||||
| @@ -37,7 +43,7 @@ static wchar_t *_curl_win32_UTF8_to_wchar(const char *str_utf8) | |||||||
|     int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, |     int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, | ||||||
|                                         str_utf8, -1, NULL, 0); |                                         str_utf8, -1, NULL, 0); | ||||||
|     if(str_w_len) { |     if(str_w_len) { | ||||||
|       str_w = (wchar_t *) malloc(str_w_len * sizeof(wchar_t)); |       str_w = malloc(str_w_len * sizeof(wchar_t)); | ||||||
|       if(str_w) { |       if(str_w) { | ||||||
|         if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, |         if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, | ||||||
|                                 str_w_len) == 0) { |                                 str_w_len) == 0) { | ||||||
| @@ -58,18 +64,20 @@ static const char *_curl_win32_wchar_to_UTF8(const wchar_t *str_w) | |||||||
|   if(str_w) { |   if(str_w) { | ||||||
|     size_t str_utf8_len = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL, |     size_t str_utf8_len = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL, | ||||||
|                                               0, NULL, NULL); |                                               0, NULL, NULL); | ||||||
|     DWORD err = GetLastError(); |  | ||||||
|     if(str_utf8_len) { |     if(str_utf8_len) { | ||||||
|       str_utf8 = (char *) malloc(str_utf8_len * sizeof(wchar_t)); |       str_utf8 = malloc(str_utf8_len * sizeof(wchar_t)); | ||||||
|       if (str_w) { |       if(str_utf8) { | ||||||
|         if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, str_utf8_len, |         if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, str_utf8_len, | ||||||
|                                 NULL, FALSE) == 0) { |                                 NULL, FALSE) == 0) { | ||||||
|           DWORD err = GetLastError(); |           (void) GetLastError(); | ||||||
|           free((void *)str_utf8); |           free((void *)str_utf8); | ||||||
|           str_utf8 = NULL; |           str_utf8 = NULL; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |     else { | ||||||
|  |       (void) GetLastError(); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   return str_utf8; |   return str_utf8; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								lib/imap.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								lib/imap.c
									
									
									
									
									
								
							| @@ -64,8 +64,6 @@ | |||||||
| #include <curl/curl.h> | #include <curl/curl.h> | ||||||
| #include "urldata.h" | #include "urldata.h" | ||||||
| #include "sendf.h" | #include "sendf.h" | ||||||
| #include "easyif.h" /* for Curl_convert_... prototypes */ |  | ||||||
|  |  | ||||||
| #include "if2ip.h" | #include "if2ip.h" | ||||||
| #include "hostip.h" | #include "hostip.h" | ||||||
| #include "progress.h" | #include "progress.h" | ||||||
| @@ -101,7 +99,7 @@ static CURLcode imap_do(struct connectdata *conn, bool *done); | |||||||
| static CURLcode imap_done(struct connectdata *conn, | static CURLcode imap_done(struct connectdata *conn, | ||||||
|                           CURLcode, bool premature); |                           CURLcode, bool premature); | ||||||
| static CURLcode imap_connect(struct connectdata *conn, bool *done); | static CURLcode imap_connect(struct connectdata *conn, bool *done); | ||||||
| static CURLcode imap_disconnect(struct connectdata *conn, bool dead_connection); | static CURLcode imap_disconnect(struct connectdata *conn, bool dead); | ||||||
| static CURLcode imap_multi_statemach(struct connectdata *conn, bool *done); | static CURLcode imap_multi_statemach(struct connectdata *conn, bool *done); | ||||||
| static int imap_getsock(struct connectdata *conn, | static int imap_getsock(struct connectdata *conn, | ||||||
|                         curl_socket_t *socks, |                         curl_socket_t *socks, | ||||||
| @@ -128,9 +126,10 @@ const struct Curl_handler Curl_handler_imap = { | |||||||
|   imap_getsock,                     /* doing_getsock */ |   imap_getsock,                     /* doing_getsock */ | ||||||
|   ZERO_NULL,                        /* perform_getsock */ |   ZERO_NULL,                        /* perform_getsock */ | ||||||
|   imap_disconnect,                  /* disconnect */ |   imap_disconnect,                  /* disconnect */ | ||||||
|  |   ZERO_NULL,                        /* readwrite */ | ||||||
|   PORT_IMAP,                        /* defport */ |   PORT_IMAP,                        /* defport */ | ||||||
|   CURLPROTO_IMAP,                   /* protocol */ |   CURLPROTO_IMAP,                   /* protocol */ | ||||||
|   PROTOPT_CLOSEACTION               /* flags */ |   PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD /* flags */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -152,9 +151,10 @@ const struct Curl_handler Curl_handler_imaps = { | |||||||
|   imap_getsock,                     /* doing_getsock */ |   imap_getsock,                     /* doing_getsock */ | ||||||
|   ZERO_NULL,                        /* perform_getsock */ |   ZERO_NULL,                        /* perform_getsock */ | ||||||
|   imap_disconnect,                  /* disconnect */ |   imap_disconnect,                  /* disconnect */ | ||||||
|  |   ZERO_NULL,                        /* readwrite */ | ||||||
|   PORT_IMAPS,                       /* defport */ |   PORT_IMAPS,                       /* defport */ | ||||||
|   CURLPROTO_IMAP | CURLPROTO_IMAPS, /* protocol */ |   CURLPROTO_IMAP | CURLPROTO_IMAPS, /* protocol */ | ||||||
|   PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */ |   PROTOPT_CLOSEACTION | PROTOPT_SSL | PROTOPT_NEEDSPWD /* flags */ | ||||||
| }; | }; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -176,6 +176,7 @@ static const struct Curl_handler Curl_handler_imap_proxy = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_IMAP,                            /* defport */ |   PORT_IMAP,                            /* defport */ | ||||||
|   CURLPROTO_HTTP,                       /* protocol */ |   CURLPROTO_HTTP,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
| @@ -200,6 +201,7 @@ static const struct Curl_handler Curl_handler_imaps_proxy = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_IMAPS,                           /* defport */ |   PORT_IMAPS,                           /* defport */ | ||||||
|   CURLPROTO_HTTP,                       /* protocol */ |   CURLPROTO_HTTP,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
| @@ -472,7 +474,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, | |||||||
|     infof(data, "Filesize left: %" FORMAT_OFF_T "\n", filesize); |     infof(data, "Filesize left: %" FORMAT_OFF_T "\n", filesize); | ||||||
|  |  | ||||||
|     if(!filesize) |     if(!filesize) | ||||||
|       /* the entire data is already transfered! */ |       /* the entire data is already transferred! */ | ||||||
|       Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); |       Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); | ||||||
|     else |     else | ||||||
|       /* IMAP download */ |       /* IMAP download */ | ||||||
| @@ -631,12 +633,10 @@ static CURLcode imap_multi_statemach(struct connectdata *conn, | |||||||
|   struct imap_conn *imapc = &conn->proto.imapc; |   struct imap_conn *imapc = &conn->proto.imapc; | ||||||
|   CURLcode result; |   CURLcode result; | ||||||
|  |  | ||||||
|   if((conn->handler->protocol & CURLPROTO_IMAPS) && !imapc->ssldone) { |   if((conn->handler->flags & PROTOPT_SSL) && !imapc->ssldone) | ||||||
|     result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone); |     result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone); | ||||||
|   } |   else | ||||||
|   else { |  | ||||||
|     result = Curl_pp_multi_statemach(&imapc->pp); |     result = Curl_pp_multi_statemach(&imapc->pp); | ||||||
|   } |  | ||||||
|  |  | ||||||
|   *done = (bool)(imapc->state == IMAP_STOP); |   *done = (bool)(imapc->state == IMAP_STOP); | ||||||
|  |  | ||||||
| @@ -711,7 +711,7 @@ static CURLcode imap_connect(struct connectdata *conn, | |||||||
|   if(CURLE_OK != result) |   if(CURLE_OK != result) | ||||||
|     return result; |     return result; | ||||||
|  |  | ||||||
|   /* We always support persistant connections on imap */ |   /* We always support persistent connections on imap */ | ||||||
|   conn->bits.close = FALSE; |   conn->bits.close = FALSE; | ||||||
|  |  | ||||||
|   pp->response_time = RESP_TIMEOUT; /* set default response time-out */ |   pp->response_time = RESP_TIMEOUT; /* set default response time-out */ | ||||||
| @@ -746,11 +746,9 @@ static CURLcode imap_connect(struct connectdata *conn, | |||||||
|       return result; |       return result; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if((conn->handler->protocol & CURLPROTO_IMAPS) && |   if((conn->handler->flags & PROTOPT_SSL) && | ||||||
|      data->state.used_interface != Curl_if_multi) { |      data->state.used_interface != Curl_if_multi) { | ||||||
|     /* BLOCKING */ |     /* BLOCKING */ | ||||||
|     /* IMAPS is simply imap with SSL for the control channel */ |  | ||||||
|     /* now, perform the SSL initialization for this socket */ |  | ||||||
|     result = Curl_ssl_connect(conn, FIRSTSOCKET); |     result = Curl_ssl_connect(conn, FIRSTSOCKET); | ||||||
|     if(result) |     if(result) | ||||||
|       return result; |       return result; | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 2009, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 2009 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -33,7 +33,8 @@ typedef enum { | |||||||
|                        a connect */ |                        a connect */ | ||||||
|   IMAP_LOGIN, |   IMAP_LOGIN, | ||||||
|   IMAP_STARTTLS, |   IMAP_STARTTLS, | ||||||
|   IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS (multi mode only) */ |   IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS | ||||||
|  |                       (multi mode only) */ | ||||||
|   IMAP_SELECT, |   IMAP_SELECT, | ||||||
|   IMAP_FETCH, |   IMAP_FETCH, | ||||||
|   IMAP_LOGOUT, |   IMAP_LOGOUT, | ||||||
| @@ -48,7 +49,7 @@ struct imap_conn { | |||||||
|   imapstate state; /* always use imap.c:state() to change state! */ |   imapstate state; /* always use imap.c:state() to change state! */ | ||||||
|   int cmdid;       /* id number/index */ |   int cmdid;       /* id number/index */ | ||||||
|   const char *idstr; /* pointer to a string for which to wait for as id */ |   const char *idstr; /* pointer to a string for which to wait for as id */ | ||||||
|   bool ssldone;      /* is connect() over SSL done? only relevant in multi mode */ |   bool ssldone;      /* connect() over SSL? only relevant in multi mode */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| extern const struct Curl_handler Curl_handler_imap; | extern const struct Curl_handler Curl_handler_imap; | ||||||
|   | |||||||
| @@ -69,8 +69,7 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size) | |||||||
|           ((int)((unsigned char)src[3])) & 0xff); |           ((int)((unsigned char)src[3])) & 0xff); | ||||||
|  |  | ||||||
|   len = strlen(tmp); |   len = strlen(tmp); | ||||||
|   if(len == 0 || len >= size) |   if(len == 0 || len >= size) { | ||||||
|   { |  | ||||||
|     SET_ERRNO(ENOSPC); |     SET_ERRNO(ENOSPC); | ||||||
|     return (NULL); |     return (NULL); | ||||||
|   } |   } | ||||||
| @@ -113,17 +112,14 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size) | |||||||
|   best.len = 0; |   best.len = 0; | ||||||
|   cur.len = 0; |   cur.len = 0; | ||||||
|  |  | ||||||
|   for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) |   for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { | ||||||
|   { |     if(words[i] == 0) { | ||||||
|     if(words[i] == 0) |  | ||||||
|     { |  | ||||||
|       if(cur.base == -1) |       if(cur.base == -1) | ||||||
|         cur.base = i, cur.len = 1; |         cur.base = i, cur.len = 1; | ||||||
|       else |       else | ||||||
|         cur.len++; |         cur.len++; | ||||||
|     } |     } | ||||||
|     else if(cur.base != -1) |     else if(cur.base != -1) { | ||||||
|     { |  | ||||||
|       if(best.base == -1 || cur.len > best.len) |       if(best.base == -1 || cur.len > best.len) | ||||||
|         best = cur; |         best = cur; | ||||||
|       cur.base = -1; |       cur.base = -1; | ||||||
| @@ -133,16 +129,11 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size) | |||||||
|     best = cur; |     best = cur; | ||||||
|   if(best.base != -1 && best.len < 2) |   if(best.base != -1 && best.len < 2) | ||||||
|     best.base = -1; |     best.base = -1; | ||||||
|  |   /* Format the result. */ | ||||||
|   /* Format the result. |  | ||||||
|    */ |  | ||||||
|   tp = tmp; |   tp = tmp; | ||||||
|   for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) |   for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { | ||||||
|   { |     /* Are we inside the best run of 0x00's? */ | ||||||
|     /* Are we inside the best run of 0x00's? |     if(best.base != -1 && i >= best.base && i < (best.base + best.len)) { | ||||||
|      */ |  | ||||||
|     if(best.base != -1 && i >= best.base && i < (best.base + best.len)) |  | ||||||
|     { |  | ||||||
|       if(i == best.base) |       if(i == best.base) | ||||||
|         *tp++ = ':'; |         *tp++ = ':'; | ||||||
|       continue; |       continue; | ||||||
| @@ -156,10 +147,8 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size) | |||||||
|     /* Is this address an encapsulated IPv4? |     /* Is this address an encapsulated IPv4? | ||||||
|      */ |      */ | ||||||
|     if(i == 6 && best.base == 0 && |     if(i == 6 && best.base == 0 && | ||||||
|         (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) |         (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { | ||||||
|     { |       if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) { | ||||||
|       if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) |  | ||||||
|       { |  | ||||||
|         SET_ERRNO(ENOSPC); |         SET_ERRNO(ENOSPC); | ||||||
|         return (NULL); |         return (NULL); | ||||||
|       } |       } | ||||||
| @@ -177,8 +166,7 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size) | |||||||
|  |  | ||||||
|   /* Check for overflow, copy, and we're done. |   /* Check for overflow, copy, and we're done. | ||||||
|    */ |    */ | ||||||
|   if((size_t)(tp - tmp) > size) |   if((size_t)(tp - tmp) > size) { | ||||||
|   { |  | ||||||
|     SET_ERRNO(ENOSPC); |     SET_ERRNO(ENOSPC); | ||||||
|     return (NULL); |     return (NULL); | ||||||
|   } |   } | ||||||
| @@ -195,9 +183,9 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size) | |||||||
|  * error, EAFNOSUPPORT or ENOSPC. |  * error, EAFNOSUPPORT or ENOSPC. | ||||||
|  * |  * | ||||||
|  * On Windows we store the error in the thread errno, not |  * On Windows we store the error in the thread errno, not | ||||||
|  * in the winsock error code. This is to avoid loosing the |  * in the winsock error code. This is to avoid losing the | ||||||
|  * actual last winsock error. So use macro ERRNO to fetch the |  * actual last winsock error. So use macro ERRNO to fetch the | ||||||
|  * errno this funtion sets when returning NULL, not SOCKERRNO. |  * errno this function sets when returning NULL, not SOCKERRNO. | ||||||
|  */ |  */ | ||||||
| char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size) | char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -61,9 +61,9 @@ static int      inet_pton6(const char *src, unsigned char *dst); | |||||||
|  *      -1 if some other error occurred (`dst' is untouched in this case, too) |  *      -1 if some other error occurred (`dst' is untouched in this case, too) | ||||||
|  * notice: |  * notice: | ||||||
|  *      On Windows we store the error in the thread errno, not |  *      On Windows we store the error in the thread errno, not | ||||||
|  *      in the winsock error code. This is to avoid loosing the |  *      in the winsock error code. This is to avoid losing the | ||||||
|  *      actual last winsock error. So use macro ERRNO to fetch the |  *      actual last winsock error. So use macro ERRNO to fetch the | ||||||
|  *      errno this funtion sets when returning (-1), not SOCKERRNO. |  *      errno this function sets when returning (-1), not SOCKERRNO. | ||||||
|  * author: |  * author: | ||||||
|  *      Paul Vixie, 1996. |  *      Paul Vixie, 1996. | ||||||
|  */ |  */ | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  * |  * | ||||||
|  * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska H<>gskolan |  * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska H<>gskolan | ||||||
|  * (Royal Institute of Technology, Stockholm, Sweden). |  * (Royal Institute of Technology, Stockholm, Sweden). | ||||||
|  * Copyright (c) 2004 - 2010 Daniel Stenberg |  * Copyright (c) 2004 - 2011 Daniel Stenberg | ||||||
|  * All rights reserved. |  * All rights reserved. | ||||||
|  * |  * | ||||||
|  * Redistribution and use in source and binary forms, with or without |  * Redistribution and use in source and binary forms, with or without | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  *                            | (__| |_| |  _ <| |___ |  *                            | (__| |_| |  _ <| |___ | ||||||
|  *                             \___|\___/|_| \_\_____| |  *                             \___|\___/|_| \_\_____| | ||||||
|  * |  * | ||||||
|  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. |  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. | ||||||
|  * |  * | ||||||
|  * This software is licensed as described in the file COPYING, which |  * This software is licensed as described in the file COPYING, which | ||||||
|  * you should have received as part of this distribution. The terms |  * you should have received as part of this distribution. The terms | ||||||
| @@ -47,7 +47,8 @@ extern struct Curl_sec_client_mech Curl_krb5_client_mech; | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| CURLcode Curl_krb_kauth(struct connectdata *conn); | CURLcode Curl_krb_kauth(struct connectdata *conn); | ||||||
| int Curl_sec_read_msg (struct connectdata *conn, char *, enum protection_level); | int Curl_sec_read_msg (struct connectdata *conn, char *, | ||||||
|  |                        enum protection_level); | ||||||
| void Curl_sec_end (struct connectdata *); | void Curl_sec_end (struct connectdata *); | ||||||
| CURLcode Curl_sec_login (struct connectdata *); | CURLcode Curl_sec_login (struct connectdata *); | ||||||
| int Curl_sec_request_prot (struct connectdata *conn, const char *level); | int Curl_sec_request_prot (struct connectdata *conn, const char *level); | ||||||
|   | |||||||
| @@ -157,7 +157,8 @@ krb5_encode(void *app_data, const void *from, int length, int level, void **to, | |||||||
|   if(maj != GSS_S_COMPLETE) |   if(maj != GSS_S_COMPLETE) | ||||||
|     return -1; |     return -1; | ||||||
|  |  | ||||||
|   /* malloc a new buffer, in case gss_release_buffer doesn't work as expected */ |   /* malloc a new buffer, in case gss_release_buffer doesn't work as | ||||||
|  |      expected */ | ||||||
|   *to = malloc(enc.length); |   *to = malloc(enc.length); | ||||||
|   if(!*to) |   if(!*to) | ||||||
|     return -1; |     return -1; | ||||||
| @@ -222,7 +223,8 @@ krb5_auth(void *app_data, struct connectdata *conn) | |||||||
|     if(maj != GSS_S_COMPLETE) { |     if(maj != GSS_S_COMPLETE) { | ||||||
|       gss_release_name(&min, &gssname); |       gss_release_name(&min, &gssname); | ||||||
|       if(service == srv_host) { |       if(service == srv_host) { | ||||||
|         Curl_failf(data, "Error importing service name %s", input_buffer.value); |         Curl_failf(data, "Error importing service name %s", | ||||||
|  |                    input_buffer.value); | ||||||
|         return AUTH_ERROR; |         return AUTH_ERROR; | ||||||
|       } |       } | ||||||
|       service = srv_host; |       service = srv_host; | ||||||
|   | |||||||
							
								
								
									
										35
									
								
								lib/ldap.c
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								lib/ldap.c
									
									
									
									
									
								
							| @@ -46,7 +46,8 @@ | |||||||
| #ifdef CURL_LDAP_WIN            /* Use Windows LDAP implementation. */ | #ifdef CURL_LDAP_WIN            /* Use Windows LDAP implementation. */ | ||||||
| # include <winldap.h> | # include <winldap.h> | ||||||
| # ifndef LDAP_VENDOR_NAME | # ifndef LDAP_VENDOR_NAME | ||||||
| #  error Your Platform SDK is NOT sufficient for LDAP support! Update your Platform SDK, or disable LDAP support! | #  error Your Platform SDK is NOT sufficient for LDAP support! \ | ||||||
|  |          Update your Platform SDK, or disable LDAP support! | ||||||
| # else | # else | ||||||
| #  include <winber.h> | #  include <winber.h> | ||||||
| # endif | # endif | ||||||
| @@ -139,6 +140,7 @@ const struct Curl_handler Curl_handler_ldap = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_LDAP,                            /* defport */ |   PORT_LDAP,                            /* defport */ | ||||||
|   CURLPROTO_LDAP,                       /* protocol */ |   CURLPROTO_LDAP,                       /* protocol */ | ||||||
|   PROTOPT_NONE                          /* flags */ |   PROTOPT_NONE                          /* flags */ | ||||||
| @@ -162,6 +164,7 @@ const struct Curl_handler Curl_handler_ldaps = { | |||||||
|   ZERO_NULL,                            /* doing_getsock */ |   ZERO_NULL,                            /* doing_getsock */ | ||||||
|   ZERO_NULL,                            /* perform_getsock */ |   ZERO_NULL,                            /* perform_getsock */ | ||||||
|   ZERO_NULL,                            /* disconnect */ |   ZERO_NULL,                            /* disconnect */ | ||||||
|  |   ZERO_NULL,                            /* readwrite */ | ||||||
|   PORT_LDAPS,                           /* defport */ |   PORT_LDAPS,                           /* defport */ | ||||||
|   CURLPROTO_LDAP | CURLPROTO_LDAPS,     /* protocol */ |   CURLPROTO_LDAP | CURLPROTO_LDAPS,     /* protocol */ | ||||||
|   PROTOPT_SSL                           /* flags */ |   PROTOPT_SSL                           /* flags */ | ||||||
| @@ -205,7 +208,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* Get the URL scheme ( either ldap or ldaps ) */ |   /* Get the URL scheme ( either ldap or ldaps ) */ | ||||||
|   if(conn->given->protocol & CURLPROTO_LDAPS) |   if(conn->given->flags & PROTOPT_SSL) | ||||||
|     ldap_ssl = 1; |     ldap_ssl = 1; | ||||||
|   infof(data, "LDAP local: trying to establish %s connection\n", |   infof(data, "LDAP local: trying to establish %s connection\n", | ||||||
|           ldap_ssl ? "encrypted" : "cleartext"); |           ldap_ssl ? "encrypted" : "cleartext"); | ||||||
| @@ -218,7 +221,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
|   if(ldap_ssl) { |   if(ldap_ssl) { | ||||||
| #ifdef HAVE_LDAP_SSL | #ifdef HAVE_LDAP_SSL | ||||||
| #ifdef CURL_LDAP_WIN | #ifdef CURL_LDAP_WIN | ||||||
|     /* Win32 LDAP SDK doesnt support insecure mode without CA! */ |     /* Win32 LDAP SDK doesn't support insecure mode without CA! */ | ||||||
|     server = ldap_sslinit(conn->host.name, (int)conn->port, 1); |     server = ldap_sslinit(conn->host.name, (int)conn->port, 1); | ||||||
|     ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON); |     ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON); | ||||||
| #else | #else | ||||||
| @@ -255,9 +258,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
|         goto quit; |         goto quit; | ||||||
|       } |       } | ||||||
|       ldap_option = LDAPSSL_VERIFY_SERVER; |       ldap_option = LDAPSSL_VERIFY_SERVER; | ||||||
|     } else { |  | ||||||
|       ldap_option = LDAPSSL_VERIFY_NONE; |  | ||||||
|     } |     } | ||||||
|  |     else | ||||||
|  |       ldap_option = LDAPSSL_VERIFY_NONE; | ||||||
|     rc = ldapssl_set_verify_mode(ldap_option); |     rc = ldapssl_set_verify_mode(ldap_option); | ||||||
|     if(rc != LDAP_SUCCESS) { |     if(rc != LDAP_SUCCESS) { | ||||||
|       failf(data, "LDAP local: ERROR setting cert verify mode: %s", |       failf(data, "LDAP local: ERROR setting cert verify mode: %s", | ||||||
| @@ -277,7 +280,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
|       /* OpenLDAP SDK supports BASE64 files. */ |       /* OpenLDAP SDK supports BASE64 files. */ | ||||||
|       if((data->set.str[STRING_CERT_TYPE]) && |       if((data->set.str[STRING_CERT_TYPE]) && | ||||||
|          (!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) { |          (!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) { | ||||||
|         failf(data, "LDAP local: ERROR OpenLDAP does only support PEM cert-type!"); |         failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type!"); | ||||||
|         status = CURLE_SSL_CERTPROBLEM; |         status = CURLE_SSL_CERTPROBLEM; | ||||||
|         goto quit; |         goto quit; | ||||||
|       } |       } | ||||||
| @@ -295,9 +298,10 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
|         goto quit; |         goto quit; | ||||||
|       } |       } | ||||||
|       ldap_option = LDAP_OPT_X_TLS_DEMAND; |       ldap_option = LDAP_OPT_X_TLS_DEMAND; | ||||||
|     } else { |  | ||||||
|       ldap_option = LDAP_OPT_X_TLS_NEVER; |  | ||||||
|     } |     } | ||||||
|  |     else | ||||||
|  |       ldap_option = LDAP_OPT_X_TLS_NEVER; | ||||||
|  |  | ||||||
|     rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option); |     rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option); | ||||||
|     if(rc != LDAP_SUCCESS) { |     if(rc != LDAP_SUCCESS) { | ||||||
|       failf(data, "LDAP local: ERROR setting cert verify mode: %s", |       failf(data, "LDAP local: ERROR setting cert verify mode: %s", | ||||||
| @@ -339,7 +343,8 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
| #endif | #endif | ||||||
| #endif | #endif | ||||||
| #endif /* CURL_LDAP_USE_SSL */ | #endif /* CURL_LDAP_USE_SSL */ | ||||||
|   } else { |   } | ||||||
|  |   else { | ||||||
|     server = ldap_init(conn->host.name, (int)conn->port); |     server = ldap_init(conn->host.name, (int)conn->port); | ||||||
|     if(server == NULL) { |     if(server == NULL) { | ||||||
|       failf(data, "LDAP local: Cannot connect to %s:%hu", |       failf(data, "LDAP local: Cannot connect to %s:%hu", | ||||||
| @@ -379,8 +384,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
|  |  | ||||||
|   for(num = 0, entryIterator = ldap_first_entry(server, result); |   for(num = 0, entryIterator = ldap_first_entry(server, result); | ||||||
|       entryIterator; |       entryIterator; | ||||||
|       entryIterator = ldap_next_entry(server, entryIterator), num++) |       entryIterator = ldap_next_entry(server, entryIterator), num++) { | ||||||
|   { |  | ||||||
|     BerElement *ber = NULL; |     BerElement *ber = NULL; | ||||||
|     char  *attribute;       /*! suspicious that this isn't 'const' */ |     char  *attribute;       /*! suspicious that this isn't 'const' */ | ||||||
|     char  *dn = ldap_get_dn(server, entryIterator); |     char  *dn = ldap_get_dn(server, entryIterator); | ||||||
| @@ -394,14 +398,11 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) | |||||||
|  |  | ||||||
|     for(attribute = ldap_first_attribute(server, entryIterator, &ber); |     for(attribute = ldap_first_attribute(server, entryIterator, &ber); | ||||||
|         attribute; |         attribute; | ||||||
|          attribute = ldap_next_attribute(server, entryIterator, ber)) |         attribute = ldap_next_attribute(server, entryIterator, ber)) { | ||||||
|     { |  | ||||||
|       BerValue **vals = ldap_get_values_len(server, entryIterator, attribute); |       BerValue **vals = ldap_get_values_len(server, entryIterator, attribute); | ||||||
|  |  | ||||||
|       if(vals != NULL) |       if(vals != NULL) { | ||||||
|       { |         for(i = 0; (vals[i] != NULL); i++) { | ||||||
|         for (i = 0; (vals[i] != NULL); i++) |  | ||||||
|         { |  | ||||||
|           Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); |           Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); | ||||||
|           Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0); |           Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0); | ||||||
|           Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); |           Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user