Compare commits

...

90 Commits

Author SHA1 Message Date
Daniel Stenberg
d994a873a4 this is what 1.5.0 is 2007-11-21 09:24:03 +00:00
Daniel Stenberg
b6575ce0b0 While inspecting the Negotiate code, I noticed how the proxy auth was using
the same state struct as the host auth, so both could never be used at the
same time! I fixed it (without being able to check) to use two separate
structs to allow authentication using Negotiate on host and proxy
simultanouesly.
2007-11-20 23:17:08 +00:00
Daniel Stenberg
e2b2a84497 clarify somewhat what happens to some data when a share is set to be used 2007-11-20 23:16:19 +00:00
Daniel Stenberg
86956c2261 white space changes only to clean up indent and source width 2007-11-20 23:02:58 +00:00
Daniel Stenberg
ef6dfdc7fd remove the unconditional enabling of cookies if you set a share to use! 2007-11-20 22:59:10 +00:00
Daniel Stenberg
f3b85ef79d a bunch of new comments 2007-11-20 22:57:24 +00:00
Daniel Stenberg
1d7e42ee9f rephrased 2007-11-20 22:01:05 +00:00
Yang Tse
6dfb5b4e1f Don't gather additional debug info unless sshd actually fails 2007-11-20 16:47:56 +00:00
Patrick Monnerat
930085751c ILE RPG binding: OS/400 specific and contained in source distribution 2007-11-20 14:23:13 +00:00
Yang Tse
258c4686b2 Improve detection of sshd un/supported options.
Gather additional debug info when the test suite ssh server fails to start.
2007-11-20 14:10:09 +00:00
Daniel Stenberg
600d0b1303 Introuced --data-urlencode to the curl tool for easier url encoding of the
data sent in a post.
2007-11-20 10:08:42 +00:00
Daniel Stenberg
2f928797cf fix the treatment of the parameter-based precision, as in "%.*s%s" as
previously the second %s would wrongly get the numerical argument that is used
for the variable precision for the first %s...
2007-11-20 10:03:33 +00:00
Daniel Stenberg
f3f06e823c 107 - resolve the type= thing for FTP URLs over HTTP proxies 2007-11-20 09:44:37 +00:00
Daniel Stenberg
58292f49c5 106 - Share interface force-enable the cookie parser 2007-11-19 23:20:15 +00:00
Yang Tse
5376d1047c This is a temporary change to test if OpenSSH 3.6 and SunSSH 1.1
are good/compatible enough to run the test suite ssh server and
socks tests
2007-11-19 17:20:32 +00:00
Daniel Stenberg
1746b57161 fill in missing copyrights 2007-11-19 15:47:01 +00:00
Daniel Stenberg
0561bffab3 I think this is the right fix for other non-OpenSSL libs, based on the NSS fix
from the other day. It is time to setup the internal SSL libs and treat them
with a "handler" struct similar to how we deal with the protocols these days...
2007-11-19 09:24:24 +00:00
Yang Tse
968e943eac Temporary change to help debugging string(s) returned by sshd -V
when sshd is not being identified as an OpenSSH daemon
2007-11-19 01:49:28 +00:00
Gunter Knauf
5be00c95a7 removed now obsolete defines;
updated external library versions to latest.
2007-11-18 22:48:39 +00:00
Daniel Stenberg
c80b9c3778 Rob Crittenden fixed SSL connections with NSS done with the multi-interface 2007-11-18 09:45:05 +00:00
Yang Tse
536f98a766 Add /opt/ssh/sbin and /opt/ssh/libexec to the sshd locations search list.
Improve wording of a couple of debug messages.
2007-11-18 01:16:44 +00:00
Yang Tse
c4e5613a7d When unable to start test suite sshserver, log if OpenSSH has not been
found or the OpenSSH version found
2007-11-17 17:43:33 +00:00
Daniel Stenberg
bff962398d Andres Garcia made the examples build fine on Windows (mingw + msys) when
the lib was built staticly.
2007-11-17 10:22:44 +00:00
Yang Tse
2b15823dab Add /usr/local/sbin and /usr/freeware/bin to the sshd locations search list 2007-11-17 02:28:54 +00:00
Daniel Stenberg
59dcc7e191 Michal Marek made the test suite remember what test servers that fail to
start so that subsequent tries are simply skipped.
2007-11-16 23:06:53 +00:00
Steinar H. Gunderson
ea3fe98867 Fix a double free. 2007-11-16 09:36:00 +00:00
Yang Tse
4f05613fbb Fix unsigned integral math check in add_buffer_send() 2007-11-16 01:19:46 +00:00
Daniel Stenberg
22e52ddd6e Ates Goral identified a problem in http.c:add_buffer_send() when a debug
callback was used, as it could wrongly pass on a bad size for the outgoing
HTTP header. The bad size would be a very large value as it was a wrapped
size_t content. This happened when the whole HTTP request failed to get sent
in one single send.  http://curl.haxx.se/mail/lib-2007-11/0165.html
2007-11-15 23:42:21 +00:00
Daniel Stenberg
1125d45397 removed unnecessary check from add_buffer_send() that only was made within
#ifdef CURL_DOES_CONVERSIONS anyway! I turned it into a DEBUGASSERT() instead.
2007-11-15 23:30:59 +00:00
Daniel Stenberg
44d408204a Michal Marek fixed the test suite to better deal with the case when the HTTP
ipv6 server can't run.
2007-11-15 22:41:31 +00:00
Daniel Stenberg
50feea3eef Rearranged code and changed Curl_readwrite_init() and Curl_pre_readwrite() into
do_init() and do_complete() which now are called first and last in the DO
function. It simplified the flow in multi.c and the functions got more
sensible names!
2007-11-15 21:45:45 +00:00
Yang Tse
ca95f58ac0 Needed now that in6_addr is referenced in ares.h 2007-11-15 19:44:01 +00:00
Yang Tse
ed636cbe44 Replace isupper with our uppercase macro version 2007-11-15 13:20:18 +00:00
Yang Tse
738e4f410c Replace isgraph with our uppercase macro version 2007-11-15 13:12:35 +00:00
Daniel Stenberg
4e731a0189 Make the Transfer() function return earlier without doing any initializations
for the cases where there's nothing to do in here, like for SFTP directory
listings that already is complete when this function gets called. The init
stuff clears byte counters which isn't really desired.
2007-11-15 11:03:02 +00:00
Steinar H. Gunderson
5cf6a539fe When looking up in DNS and then in the hosts file, return the error code from DNS if both fail, instead of returning the error code from the hosts file, as today. Patch from the Google tree. 2007-11-15 09:16:48 +00:00
Steinar H. Gunderson
17fde12fb8 Return TTL data from ares_parse_{a,aaaa}_reply, if the user is so inclined. Patch from the Google tree. 2007-11-15 08:36:25 +00:00
Daniel Stenberg
5c8b973d4f use the existing variable instead 2007-11-14 22:44:30 +00:00
Daniel Stenberg
b22e03b2b2 Fix how TFTP connections are treated when re-used, if the SessionHandle has
been used for other protocols in between. I found this when test 2004 started
to fail for me!
2007-11-14 22:41:42 +00:00
Yang Tse
a2926ebe7c Fix a variable potential wrapping in add_buffer() when using absolutely
huge send buffer sizes
2007-11-14 00:48:11 +00:00
Daniel Stenberg
c508d70258 Fixed a remaining problem with doing SFTP directory listings on a re-used
persistent connection. Mentioned by Immanuel Gregoire on the mailing list.
2007-11-12 23:04:44 +00:00
Daniel Stenberg
f5971f54ff comment language 2007-11-12 21:42:20 +00:00
Daniel Stenberg
c5b16d4468 Bug report #1830637 (http://curl.haxx.se/bug/view.cgi?id=1830637), which was
forwarded from the Gentoo bug tracker by Daniel Black and was originally
submitted by Robin Johnson, pointed out that libcurl would do bad memory
references when it failed and bailed out before the handler thing was
setup. My fix is not done like the provided patch does it, but instead I
make sure that there's never any chance for a NULL pointer in that struct
member.
2007-11-12 21:38:43 +00:00
Daniel Stenberg
3c71a1bab7 oops, fixed build when CURL_LIBSSH2_DEBUG is defined 2007-11-12 09:24:05 +00:00
Daniel Stenberg
3ec322685b new ruby binding, curl-multi version 0.1 2007-11-11 14:20:15 +00:00
Yang Tse
9a39839a43 Some versions of winsock2.h have pollfd struct and constants 2007-11-10 04:23:15 +00:00
Yang Tse
e87c996fe0 Fix compiler warning: integral size mismatch in argument 2007-11-08 19:28:25 +00:00
Yang Tse
32195c673d Define WIN32 when build target is Win32 API.
This also defines it for WinCE even though it is a subset of WIN32.
2007-11-08 18:13:54 +00:00
Yang Tse
b99a61c5b0 Fix compiler warning: may be used uninitialized 2007-11-08 16:43:01 +00:00
Yang Tse
c960cd41e8 Fix comment 2007-11-08 16:32:31 +00:00
Daniel Stenberg
a29471d0f7 spell! 2007-11-08 10:25:23 +00:00
Daniel Stenberg
ba6f20a244 Bug report #1823487 (http://curl.haxx.se/bug/view.cgi?id=1823487) pointed
out that SFTP requests didn't use persistent connections. Neither did SCP
ones.  I gave the SSH code a good beating and now both SCP and SFTP should
use persistent connections fine. I also did a bunch for indent changes as
well as a bug fix for the "keyboard interactive" auth.
2007-11-08 10:22:49 +00:00
Yang Tse
61572a1f97 The only libraries actually needed for sample programs adig and
ahost are ws2_32.lib and advapi32.lib
2007-11-08 01:33:28 +00:00
Yang Tse
dee3844f13 MSVC versions prior to VS2005 do not complain about portable C functions 2007-11-07 18:18:42 +00:00
Daniel Stenberg
cbd1a77ec2 if () => if()
while () => while()
and some other minor re-indentings
2007-11-07 09:21:35 +00:00
Dan Fandrich
33f7ac06c3 Improved telnet support by drastically reducing the number of write
callbacks needed to pass a buffer to the user.  Instead one per byte it
is now as little as one per segment.
2007-11-07 05:52:03 +00:00
Dan Fandrich
70f10f1ac9 Add a call to curl_global_cleanup to show how to do a proper shutdown. 2007-11-07 04:53:37 +00:00
Yang Tse
775b60fa09 Bug report #1824894 (http://curl.haxx.se/bug/view.cgi?id=1824894) pointed
out a problem in curl.h when building C++ apps with MSVC. To fix it, the
inclusion of header files in curl.h is moved outside of the C++ extern "C"
linkage block.
2007-11-06 17:18:27 +00:00
Gisle Vanem
66e4d391d3 Added prototype for _strtoi64(). 2007-11-06 16:20:54 +00:00
Gisle Vanem
caf880be18 Constified from arguments. 2007-11-06 16:20:04 +00:00
Dan Fandrich
c8355c27e9 Sort the directory listing because the server doesn't always do it. 2007-11-05 20:54:35 +00:00
Dan Fandrich
c2d7e2ae17 Added some keywords 2007-11-05 20:53:15 +00:00
Daniel Stenberg
98ecad0da6 tclcurl and a mirror recount when bad ones have been cut out 2007-11-05 15:43:41 +00:00
Daniel Stenberg
bbc4e05434 Andres Garcia made it build and run on windows 2007-11-05 10:07:34 +00:00
Daniel Stenberg
ad6e28073c removed space after if and while before the parenthesis for better source code
consistency
2007-11-05 09:45:09 +00:00
Daniel Stenberg
af29dcbafb I check the code right now and while() and if() are in majority over while ()
and if () so the rule is from now on => no space before the parenthesis.
2007-11-05 09:31:30 +00:00
Daniel Stenberg
b9a7f4e502 Move connection-oriented variables from the SessionHandle struct to the
connectdata struct. This will in theory enable us to do persistent connections
with SCP+SFTP, but currently the state machine always (and wrongly) cleanup
everything in the 'done' action instead of in 'disconnect'. Also did a bunch
of indent fixes, if () => if() and a few other source cleanups like added
comments etc.
2007-11-05 09:30:45 +00:00
Daniel Stenberg
51009a40b4 make sure the code deals with failures on the DO_MORE state properly 2007-11-03 14:44:38 +00:00
Daniel Stenberg
2ec8f77f21 avoid setting up a transfer when the state machine failed previously 2007-11-02 23:34:00 +00:00
Daniel Stenberg
7f62028d66 Toby Peterson patched a memory problem in the command line tool that
happened when a user had a home dir as an empty string. curl would then do
free() on a wrong area.
2007-11-01 21:49:59 +00:00
Daniel Stenberg
d34fe06fb0 minor re-indent 2007-11-01 21:43:56 +00:00
Dan Fandrich
2f3d520571 Ignore more features that curl-config is not expected to know about 2007-11-01 21:20:24 +00:00
Dan Fandrich
48dd0c5673 Fixed curl-config --features to not display libz when it wasn't used
due to a missing header file.
2007-11-01 18:55:00 +00:00
Dan Fandrich
8be493296d Make postcheck failure message more like the others 2007-11-01 17:42:39 +00:00
Dan Fandrich
6f33531861 Added test case 1014 to compare curl-config --features with curl --version 2007-11-01 03:09:27 +00:00
Dan Fandrich
16897354bc Added test case 1013 to check that curl-config --protocols matches the
protocols listed in curl --version
2007-11-01 00:36:55 +00:00
Dan Fandrich
823a0454a6 Fixed the output of curl-config --protocols which showed SCP and SFTP
always, except when --without-libssh2 was given
2007-10-31 23:33:58 +00:00
Dan Fandrich
6790c559af Detect curl source when valgrind provides an absolute source file name 2007-10-31 18:32:06 +00:00
Gisle Vanem
c56c4a0a47 Add support for LDAP urls. Allthough the OpenWatcom
headers <winlap.h> and <winber.h> defines wrong calling convention.
2007-10-31 10:58:51 +00:00
Gisle Vanem
45064c5778 Added optional use of zlib (USE_ZLIB=1).
Use a response-file for the C-compiler.
2007-10-31 10:20:48 +00:00
Daniel Stenberg
7aba59f577 contributor re-count (we'll break the 600 limit very very soon now) and I made
all the numericals at the top phrased "shorter" and I cut out the "number of
releases since the very beginning" since that's just the number curl releases
+ 26 and not a very interesting number anyway.
2007-10-31 09:21:31 +00:00
Dan Fandrich
59b05ac383 Fixed an OOM problem with file: URLs
Moved Curl_file_connect into the protocol handler struct.
2007-10-30 23:00:40 +00:00
Daniel Stenberg
9b15f1be26 added new people from the 7.17.1 announcement 2007-10-30 22:48:08 +00:00
Dan Fandrich
38cd2d781f Added test case 546 to check that subsequent FTP transfers work after a
failed one using the multi interface
2007-10-29 22:57:31 +00:00
Daniel Stenberg
2f285b3f16 curl-config --features and --protocols show the correct output when built
with NSS
2007-10-29 22:13:09 +00:00
Daniel Stenberg
57d2fb41d0 Based on one of those bug reports that are intercepted by a distro's bug
tracker (https://bugzilla.redhat.com/show_bug.cgi?id=316191), I now made
curl-config --features and --protocols show the correct output when built
with NSS.
2007-10-29 22:13:00 +00:00
Dan Fandrich
0f77fe55b6 Reverted the const change--what was I thinking? 2007-10-29 20:57:03 +00:00
Dan Fandrich
68ee002ad0 Made some pointers const 2007-10-29 18:32:20 +00:00
Daniel Stenberg
1fc3b18592 7.17.2 2007-10-29 15:06:04 +00:00
Daniel Stenberg
5a5287ef2a start working on 7.17.2 2007-10-29 15:05:47 +00:00
120 changed files with 4444 additions and 3536 deletions

111
CHANGES
View File

@@ -6,6 +6,117 @@
Changelog
Daniel S (21 Nov 2007)
- While inspecting the Negotiate code, I noticed how the proxy auth was using
the same state struct as the host auth, so both could never be used at the
same time! I fixed it (without being able to check) to use two separate
structs to allow authentication using Negotiate on host and proxy
simultanouesly.
Daniel S (20 Nov 2007)
- Emil Romanus pointed out a bug that made an easy handle get the cookie
engine activated when set to use a share (even if the share doesn't share
cookies). I fixed it.
- Fixed a very long-lasting mprintf() bug that occured when we did "%.*s%s",
since the second %s would then wrongly used the numerical precision argument
instead and crash.
- Introuced --data-urlencode to the curl tool for easier url encoding of the
data sent in a post.
Daniel S (18 Nov 2007)
- Rob Crittenden fixed SSL connections with NSS done with the multi-interface
Daniel S (17 Nov 2007)
- Michal Marek made the test suite remember what test servers that fail to
start so that subsequent tries are simply skipped.
- Andres Garcia made the examples build fine on Windows (mingw + msys) when
the lib was built staticly.
Daniel S (16 Nov 2007)
- Ates Goral identified a problem in http.c:add_buffer_send() when a debug
callback was used, as it could wrongly pass on a bad size for the outgoing
HTTP header. The bad size would be a very large value as it was a wrapped
size_t content. This happened when the whole HTTP request failed to get sent
in one single send. http://curl.haxx.se/mail/lib-2007-11/0165.html
Daniel S (15 Nov 2007)
- Fixed yet another remaining problem with doing SFTP directory listings on a
re-used persistent connection. Mentioned by Immanuel Gregoire on the mailing
list.
- Michal Marek fixed the test suite to better deal with the case when the HTTP
ipv6 server can't run.
Yang Tse (14 Nov 2007)
- Fix a variable potential wrapping in add_buffer() when using absolutely
huge send buffer sizes.
Daniel S (13 Nov 2007)
- Fixed a remaining problem with doing SFTP directory listings on a re-used
persistent connection. Mentioned by Immanuel Gregoire on the mailing list.
Daniel S (12 Nov 2007)
- Bug report #1830637 (http://curl.haxx.se/bug/view.cgi?id=1830637), which was
forwarded from the Gentoo bug tracker by Daniel Black and was originally
submitted by Robin Johnson, pointed out that libcurl would do bad memory
references when it failed and bailed out before the handler thing was
setup. My fix is not done like the provided patch does it, but instead I
make sure that there's never any chance for a NULL pointer in that struct
member.
Daniel S (8 Nov 2007)
- Bug report #1823487 (http://curl.haxx.se/bug/view.cgi?id=1823487) pointed
out that SFTP requests didn't use persistent connections. Neither did SCP
ones. I gave the SSH code a good beating and now both SCP and SFTP should
use persistent connections fine. I also did a bunch of indent changes as
well as a bug fix for the "keyboard interactive" auth.
Dan F (6 Nov 2007)
- Improved telnet support by drastically reducing the number of write
callbacks needed to pass a buffer to the user. Instead one per byte it
is now as little as one per segment.
Yang Tse (6 Nov 2007)
- Bug report #1824894 (http://curl.haxx.se/bug/view.cgi?id=1824894) pointed
out a problem in curl.h when building C++ apps with MSVC. To fix it, the
inclusion of header files in curl.h is moved outside of the C++ extern "C"
linkage block.
Daniel S (1 Nov 2007)
- Toby Peterson patched a memory problem in the command line tool that
happened when a user had a home dir as an empty string. curl would then do
free() on a wrong area.
Dan F (1 Nov 2007)
- Fixed curl-config --features to not display libz when it wasn't used
due to a missing header file.
Dan F (31 October 2007)
- Fixed the output of curl-config --protocols which showed SCP and SFTP
always, except when --without-libssh2 was given
- Added test cases 1013 and 1014 to check that curl-config --protocols and
curl-config --features matches the output of curl --version
Dan F (30 October 2007)
- Fixed an OOM problem with file: URLs
- Moved Curl_file_connect into the protocol handler struct
Dan F (29 October 2007)
- Added test case 546 to check that subsequent FTP transfers work after a
failed one using the multi interface
Daniel S (29 October 2007)
- Based on one of those bug reports that are intercepted by a distro's bug
tracker (https://bugzilla.redhat.com/show_bug.cgi?id=316191), I now made
curl-config --features and --protocols show the correct output when built
with NSS.
Version 7.17.1 (29 October 2007)
Dan F (25 October 2007)

View File

@@ -1,53 +1,31 @@
Curl and libcurl 7.17.1
Curl and libcurl 7.17.2
Public curl release number: 102
Releases counted from the very beginning: 128
Available command line options: 121
Available curl_easy_setopt() options: 147
Number of public functions in libcurl: 55
Amount of public web site mirrors: 43
Number of known libcurl bindings: 36
Number of contributors: 588
Public curl releases: 103
Command line options: 122
curl_easy_setopt() options: 147
Public functions in libcurl: 55
Public web site mirrors: 42
Known libcurl bindings: 36
Contributors: 597
This release includes the following changes:
o automatically append ";type=<a|i>" when using HTTP proxies for FTP urls
o improved NSS support
o added --proxy-negotiate
o added --post301 and CURLOPT_POST301
o builds with c-ares 1.5.0
o added CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 and --hostpubmd5
o renamed CURLE_SSL_PEER_CERTIFICATE to CURLE_PEER_FAILED_VERIFICATION
o added CURLOPT_OPENSOCKETFUNCTION and CURLOPT_OPENSOCKETDATA
o CULROPT_COOKIELIST supports "FLUSH"
o added CURLOPT_COPYPOSTFIELDS
o added --static-libs to curl-config
o --data-urlencode was added
This release includes the following bugfixes:
o curl-config --protocols now properly reports LDAPS, SCP and SFTP
o ldapv3 support on Windows
o ldap builds with the MSVC makefiles
o no HOME and no key given caused SSH auth failure
o Negotiate authentication over proxy
o --ftp-method nocwd on directory listings
o FTP, CURLOPT_NOBODY enabled and CURLOPT_HEADER disabled now does TYPE
before SIZE
o re-used handle transfers with SFTP
o curl_easy_escape() problem with byte values >= 128
o handles chunked-encoded CONNECT responses
o misuse of ares_timeout() result
o --local-port on TFTP transfers
o CURLOPT_POSTFIELDS could fail to send binary data
o specifying a proxy with a trailing slash didn't work (unless it also
contained a port number)
o redirect from HTTP to FTP or TFTP memory problems and leaks
o re-used connections a bit too much when using non-SSL protocols tunneled
over a HTTP proxy
o embed the manifest in VC8 builds
o use valgrind in the tests even when the lib is built shared with libtool
o libcurl built with NSS can now ignore the peer verification even when the
ca cert bundle is absent
o curl-config --features and --protocols show the correct output when built
with NSS, and also when SCP, SFTP and libz are not available
o free problem in the curl tool for users with empty home dir
o curl.h version 7.17.1 problem when building C++ apps with MSVC
o SFTP and SCP use persistent connections
o segfault on bad URL
o variable wrapping when using absolutely huge send buffer sizes
o variable wrapping when using debug callback and the HTTP request wasn't sent
in one go
o SSL connections with NSS done with the multi-interface
o setting a share no longer activates cookies
o Negotiate now works on auth and proxy simultanouesly
This release includes the following known bugs:
@@ -55,18 +33,18 @@ This release includes the following known bugs:
Other curl-related news:
o
o TclCurl 7.17.1 => http://personal1.iddeo.es/andresgarci/tclcurl/english/
o Ruby Curl::Multi 0.1 => http://curl-multi.rubyforge.org/
New curl mirrors:
o http://curl.wetzlmayr.at/ is a new web mirror in Nuremberg, Germany
o http://curl.gominet.net/ is new web mirror in Vizcaya, Portugal
This release would not have looked like this without help, code, reports and
advice from friends like these:
Dan Fandrich, Michal Marek, G<>nter Knauf, Rob Crittenden, Immanuel Gregoire,
Mark Davies, Max Katsev, Philip Langdale, Alex Fishman, Johnny Luong,
Alexey Pesternikov, Yang Tse, Kim Rinnewitz, Michael Wallner,
Patrick Monnerat, Vladimir Lazarenko
Dan Fandrich, Gisle Vanem, Toby Peterson, Yang Tse, Daniel Black,
Robin Johnson, Michal Marek, Ates Goral, Andres Garcia, Rob Crittenden,
Emil Romanus
Thanks! (and sorry if I forgot to mention someone)

View File

@@ -1,4 +1,6 @@
To be addressed before 7.17.1 (planned release: late October 2007)
To be addressed before 7.17.2 (planned release: December 2007)
=============================
106 -
107 - resolve the type= thing for FTP URLs over HTTP proxies
108 -

View File

@@ -300,7 +300,6 @@ ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define DL_LDAP_FILE "ldapsdk.nlm"$(DL) >> $@
@echo $(DL)#define socklen_t int$(DL) >> $@
@echo $(DL)#define strncasecmp strnicmp$(DL) >> $@
@echo $(DL)#define strcasecmp stricmp$(DL) >> $@
@@ -338,7 +337,6 @@ else
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
@echo $(DL)#define DL_LDAP_FILE "lldapsdk.nlm"$(DL) >> $@
endif
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ARPA_NAMESER_H 1$(DL) >> $@

View File

@@ -1,9 +1,26 @@
This is what's new and changed in the c-ares 1.4.1 release:
This is what's new and changed in the c-ares 1.5.0 release:
o
o SONAME bump to a few API and ABI breaking changes:
- ares_host_callback()
- ares_nameinfo_callback()
- ares_parse_a_reply()
- ares_parse_aaaa_reply()
o two valgrind reports were silenced
o ares_save_options() fix
o do DNS retries even on TCP connections
o correctly clear sockets from the fd_set in several functions
o always wait on TCP events to detect connect closures
o new socket options: ARES_OPT_SOCK_SNDBUF and ARES_OPT_SOCK_RCVBUF
o made the query callbacks receive the number of timeouts that happened during
the execution of a query
o don't skip a server if it's the only one
o segfault when generating a DNS "Transaction ID" under low memory conditions
o ares_strerror() segfault fix
o added copyright texts to a few places that were missing them
Thanks go to these friendly people for their efforts and contributions:
Vlad Dinulescu, Brad House, Steinar H. Gunderson, Yang Tse
Have fun!

View File

@@ -40,13 +40,6 @@
#include "inet_net_pton.h"
#include "ares_getopt.h"
#ifndef HAVE_STRUCT_IN6_ADDR
struct in6_addr
{
unsigned char s6_addr[16];
};
#endif
static void callback(void *arg, int status, int timeouts, struct hostent *host);
static void usage(void);

View File

@@ -18,6 +18,14 @@
#ifndef ARES__H
#define ARES__H
/*
* Define WIN32 when build target is Win32 API
*/
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
#define WIN32
#endif
#include <sys/types.h>
#if defined(_AIX) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
@@ -35,8 +43,12 @@
#include <sys/socket.h>
#include <tcp.h>
#elif defined(WIN32)
#include <winsock2.h>
#include <windows.h>
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <winsock2.h>
# include <ws2tcpip.h>
#else
#include <netinet/in.h>
#include <sys/socket.h>
@@ -232,10 +244,38 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
int alen, char **s, long *enclen);
int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf,
int alen, unsigned char **s, long *enclen);
#ifndef s6_addr
struct in6_addr {
union {
unsigned char _S6_u8[16];
} _S6_un;
};
#define s6_addr _S6_un._S6_u8
#endif
struct addrttl {
struct in_addr ipaddr;
int ttl;
};
struct addr6ttl {
struct in6_addr ip6addr;
int ttl;
};
/*
** Parse the buffer, starting at *abuf and of length alen bytes, previously
** obtained from an ares_search call. Put the results in *host, if nonnull.
** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
** their TTLs in that array, and set *naddrttls to the number of addresses
** so written.
*/
int ares_parse_a_reply(const unsigned char *abuf, int alen,
struct hostent **host);
struct hostent **host,
struct addrttl *addrttls, int *naddrttls);
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
struct hostent **host);
struct hostent **host,
struct addr6ttl *addrttls, int *naddrttls);
int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
int addrlen, int family, struct hostent **host);
int ares_parse_ns_reply(const unsigned char *abuf, int alen,

View File

@@ -57,7 +57,7 @@ struct host_query {
int timeouts;
};
static void next_lookup(struct host_query *hquery, int status);
static void next_lookup(struct host_query *hquery, int status_code);
static void host_callback(void *arg, int status, int timeouts,
unsigned char *abuf, int alen);
static void end_hquery(struct host_query *hquery, int status,
@@ -111,13 +111,14 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family,
hquery->timeouts = 0;
/* Start performing lookups according to channel->lookups. */
next_lookup(hquery, ARES_SUCCESS);
next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */);
}
static void next_lookup(struct host_query *hquery, int status)
static void next_lookup(struct host_query *hquery, int status_code)
{
const char *p;
struct hostent *host;
int status = status_code;
for (p = hquery->remaining_lookups; *p; p++)
{
@@ -142,6 +143,7 @@ static void next_lookup(struct host_query *hquery, int status)
end_hquery(hquery, status, host);
return;
}
status = status_code; /* Use original status code */
break;
}
}
@@ -160,13 +162,13 @@ static void host_callback(void *arg, int status, int timeouts,
{
if (hquery->family == AF_INET)
{
status = ares_parse_a_reply(abuf, alen, &host);
status = ares_parse_a_reply(abuf, alen, &host, NULL, NULL);
if (host && channel->nsort)
sort_addresses(host, channel->sortlist, channel->nsort);
}
else if (hquery->family == AF_INET6)
{
status = ares_parse_aaaa_reply(abuf, alen, &host);
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
if (host && channel->nsort)
sort6_addresses(host, channel->sortlist, channel->nsort);
}

View File

@@ -1,6 +1,7 @@
/* $Id$ */
/*
/* Copyright (C) 2005 by Dominick Meglio
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
@@ -21,11 +22,13 @@
#define PF_INET6 AF_INET6
#endif
#ifndef HAVE_STRUCT_IN6_ADDR
struct in6_addr
{
unsigned char s6_addr[16];
#ifndef s6_addr
struct in6_addr {
union {
unsigned char _S6_u8[16];
} _S6_un;
};
#define s6_addr _S6_un._S6_u8
#endif
#ifndef HAVE_STRUCT_SOCKADDR_IN6

View File

@@ -22,24 +22,39 @@ ares_parse_a_reply \- Parse a reply to a DNS query of type A into a hostent
.B #include <ares.h>
.PP
.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
.B struct hostent **\fIhost\fP);
.B struct hostent **\fIhost\fP,
.B struct addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
.fi
.SH DESCRIPTION
The
.B ares_parse_a_reply
function parses the response to a query of type A into a
.BR "struct hostent" .
.BR "struct hostent"
and/or an array of
.BR "struct addrttls" .
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR host .
.IR host ,
if host is nonnull.
It is the caller's responsibility to free the resulting host structure
using
.BR ares_free_hostent (3)
when it is no longer needed.
.PP
If
.IR addrttls
and
.IR naddrttls
are both nonnull,
then up to *naddrttls
.BR "struct addrttl"
records are stored in the array pointed to by addrttls,
and then *naddrttls is set to the number of records so stored.
Note that the memory for these records is supplied by the caller.
.SH RETURN VALUES
.B ares_parse_a_reply
can return any of the following values:

View File

@@ -32,24 +32,32 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
int ares_parse_a_reply(const unsigned char *abuf, int alen,
struct hostent **host)
struct hostent **host,
struct addrttl *addrttls, int *naddrttls)
{
unsigned int qdcount, ancount;
int status, i, rr_type, rr_class, rr_len, naddrs;
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
int naliases;
long len;
const unsigned char *aptr;
char *hostname, *rr_name, *rr_data, **aliases;
struct in_addr *addrs;
struct hostent *hostent;
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
/* Set *host to NULL for all failure cases. */
*host = NULL;
if (host)
*host = NULL;
/* Same with *naddrttls. */
if (naddrttls)
*naddrttls = 0;
/* Give up if abuf doesn't have room for a header. */
if (alen < HFIXEDSZ)
@@ -73,20 +81,29 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
}
aptr += len + QFIXEDSZ;
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
addrs = malloc(ancount * sizeof(struct in_addr));
if (!addrs)
if (host)
{
free(hostname);
return ARES_ENOMEM;
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
addrs = malloc(ancount * sizeof(struct in_addr));
if (!addrs)
{
free(hostname);
return ARES_ENOMEM;
}
aliases = malloc((ancount + 1) * sizeof(char *));
if (!aliases)
{
free(hostname);
free(addrs);
return ARES_ENOMEM;
}
}
aliases = malloc((ancount + 1) * sizeof(char *));
if (!aliases)
else
{
free(hostname);
free(addrs);
return ARES_ENOMEM;
addrs = NULL;
aliases = NULL;
}
naddrs = 0;
naliases = 0;
@@ -106,13 +123,33 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
rr_type = DNS_RR_TYPE(aptr);
rr_class = DNS_RR_CLASS(aptr);
rr_len = DNS_RR_LEN(aptr);
rr_ttl = DNS_RR_TTL(aptr);
aptr += RRFIXEDSZ;
if (rr_class == C_IN && rr_type == T_A
&& rr_len == sizeof(struct in_addr)
&& strcasecmp(rr_name, hostname) == 0)
{
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
if (addrs)
{
if (aptr + sizeof(struct in_addr) > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
}
if (naddrs < max_addr_ttls)
{
struct addrttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct in_addr) > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
memcpy(&at->ipaddr, aptr, sizeof(struct in_addr));
at->ttl = rr_ttl;
}
naddrs++;
status = ARES_SUCCESS;
}
@@ -120,7 +157,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (rr_class == C_IN && rr_type == T_CNAME)
{
/* Record the RR name as an alias. */
aliases[naliases] = rr_name;
if (aliases)
aliases[naliases] = rr_name;
else
free(rr_name);
naliases++;
/* Decode the RR data and replace the hostname with it. */
@@ -129,6 +169,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
break;
free(hostname);
hostname = rr_data;
/* Take the min of the TTLs we see in the CNAME chain. */
if (cname_ttl > rr_ttl)
cname_ttl = rr_ttl;
}
else
free(rr_name);
@@ -145,32 +189,51 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
status = ARES_ENODATA;
if (status == ARES_SUCCESS)
{
/* We got our answer. Allocate memory to build the host entry. */
aliases[naliases] = NULL;
hostent = malloc(sizeof(struct hostent));
if (hostent)
/* We got our answer. */
if (naddrttls)
{
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
if (hostent->h_addr_list)
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
for (i = 0; i < n; i++)
{
/* Fill in the hostent and return successfully. */
hostent->h_name = hostname;
hostent->h_aliases = aliases;
hostent->h_addrtype = AF_INET;
hostent->h_length = sizeof(struct in_addr);
for (i = 0; i < naddrs; i++)
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
*host = hostent;
return ARES_SUCCESS;
/* Ensure that each A TTL is no larger than the CNAME TTL. */
if (addrttls[i].ttl > cname_ttl)
addrttls[i].ttl = cname_ttl;
}
free(hostent);
*naddrttls = n;
}
status = ARES_ENOMEM;
if (aliases)
aliases[naliases] = NULL;
if (host)
{
/* Allocate memory to build the host entry. */
hostent = malloc(sizeof(struct hostent));
if (hostent)
{
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
if (hostent->h_addr_list)
{
/* Fill in the hostent and return successfully. */
hostent->h_name = hostname;
hostent->h_aliases = aliases;
hostent->h_addrtype = AF_INET;
hostent->h_length = sizeof(struct in_addr);
for (i = 0; i < naddrs; i++)
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
*host = hostent;
return ARES_SUCCESS;
}
free(hostent);
}
status = ARES_ENOMEM;
}
}
if (aliases)
{
for (i = 0; i < naliases; i++)
free(aliases[i]);
free(aliases);
}
for (i = 0; i < naliases; i++)
free(aliases[i]);
free(aliases);
free(addrs);
free(hostname);
return status;

View File

@@ -22,24 +22,39 @@ ares_parse_aaaa_reply \- Parse a reply to a DNS query of type AAAA into a hosten
.B #include <ares.h>
.PP
.B int ares_parse_aaaa_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
.B struct hostent **\fIhost\fP);
.B struct hostent **\fIhost\fP,
.B struct addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
.fi
.SH DESCRIPTION
The
.B ares_parse_aaaa_reply
function parses the response to a query of type AAAA into a
.BR "struct hostent" .
.BR "struct hostent"
and/or an array of
.BR "struct addrttls" .
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR host .
.IR host ,
if host is nonnull.
It is the caller's responsibility to free the resulting host structure
using
.BR ares_free_hostent (3)
when it is no longer needed.
.PP
If
.IR addrttls
and
.IR naddrttls
are both nonnull,
then up to *naddrttls
.BR "struct addr6ttl"
records are stored in the array pointed to by addrttls,
and then *naddrttls is set to the number of records so stored.
Note that the memory for these records is supplied by the caller.
.SH RETURN VALUES
.B ares_parse_aaaa_reply
can return any of the following values:

View File

@@ -34,25 +34,33 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "ares.h"
#include "ares_dns.h"
#include "inet_net_pton.h"
#include "ares_private.h"
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
struct hostent **host)
struct hostent **host, struct addr6ttl *addrttls,
int *naddrttls)
{
unsigned int qdcount, ancount;
int status, i, rr_type, rr_class, rr_len, naddrs;
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
int naliases;
long len;
const unsigned char *aptr;
char *hostname, *rr_name, *rr_data, **aliases;
struct in6_addr *addrs;
struct hostent *hostent;
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
/* Set *host to NULL for all failure cases. */
*host = NULL;
if (host)
*host = NULL;
/* Same with *naddrttls. */
if (naddrttls)
*naddrttls = 0;
/* Give up if abuf doesn't have room for a header. */
if (alen < HFIXEDSZ)
@@ -77,18 +85,26 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
aptr += len + QFIXEDSZ;
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
addrs = malloc(ancount * sizeof(struct in6_addr));
if (!addrs)
if (host)
{
free(hostname);
return ARES_ENOMEM;
addrs = malloc(ancount * sizeof(struct in6_addr));
if (!addrs)
{
free(hostname);
return ARES_ENOMEM;
}
aliases = malloc((ancount + 1) * sizeof(char *));
if (!aliases)
{
free(hostname);
free(addrs);
return ARES_ENOMEM;
}
}
aliases = malloc((ancount + 1) * sizeof(char *));
if (!aliases)
else
{
free(hostname);
free(addrs);
return ARES_ENOMEM;
addrs = NULL;
aliases = NULL;
}
naddrs = 0;
naliases = 0;
@@ -109,13 +125,33 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
rr_type = DNS_RR_TYPE(aptr);
rr_class = DNS_RR_CLASS(aptr);
rr_len = DNS_RR_LEN(aptr);
rr_ttl = DNS_RR_TTL(aptr);
aptr += RRFIXEDSZ;
if (rr_class == C_IN && rr_type == T_AAAA
&& rr_len == sizeof(struct in6_addr)
&& strcasecmp(rr_name, hostname) == 0)
{
memcpy(&addrs[naddrs], aptr, sizeof(struct in6_addr));
if (addrs)
{
if (aptr + sizeof(struct in6_addr) > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
memcpy(&addrs[naddrs], aptr, sizeof(struct in6_addr));
}
if (naddrs < max_addr_ttls)
{
struct addr6ttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct in6_addr) > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
memcpy(&at->ip6addr, aptr, sizeof(struct in6_addr));
at->ttl = rr_ttl;
}
naddrs++;
status = ARES_SUCCESS;
}
@@ -123,7 +159,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
if (rr_class == C_IN && rr_type == T_CNAME)
{
/* Record the RR name as an alias. */
aliases[naliases] = rr_name;
if (aliases)
aliases[naliases] = rr_name;
else
free(rr_name);
naliases++;
/* Decode the RR data and replace the hostname with it. */
@@ -132,6 +171,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
break;
free(hostname);
hostname = rr_data;
/* Take the min of the TTLs we see in the CNAME chain. */
if (cname_ttl > rr_ttl)
cname_ttl = rr_ttl;
}
else
free(rr_name);
@@ -148,32 +191,51 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
status = ARES_ENODATA;
if (status == ARES_SUCCESS)
{
/* We got our answer. Allocate memory to build the host entry. */
aliases[naliases] = NULL;
hostent = malloc(sizeof(struct hostent));
if (hostent)
/* We got our answer. */
if (naddrttls)
{
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
if (hostent->h_addr_list)
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
for (i = 0; i < n; i++)
{
/* Fill in the hostent and return successfully. */
hostent->h_name = hostname;
hostent->h_aliases = aliases;
hostent->h_addrtype = AF_INET6;
hostent->h_length = sizeof(struct in6_addr);
for (i = 0; i < naddrs; i++)
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
*host = hostent;
return ARES_SUCCESS;
/* Ensure that each A TTL is no larger than the CNAME TTL. */
if (addrttls[i].ttl > cname_ttl)
addrttls[i].ttl = cname_ttl;
}
free(hostent);
*naddrttls = n;
}
if (aliases)
aliases[naliases] = NULL;
if (host)
{
/* Allocate memory to build the host entry. */
hostent = malloc(sizeof(struct hostent));
if (hostent)
{
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
if (hostent->h_addr_list)
{
/* Fill in the hostent and return successfully. */
hostent->h_name = hostname;
hostent->h_aliases = aliases;
hostent->h_addrtype = AF_INET6;
hostent->h_length = sizeof(struct in6_addr);
for (i = 0; i < naddrs; i++)
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
*host = hostent;
return ARES_SUCCESS;
}
free(hostent);
}
status = ARES_ENOMEM;
}
status = ARES_ENOMEM;
}
for (i = 0; i < naliases; i++)
free(aliases[i]);
free(aliases);
if (aliases)
{
for (i = 0; i < naliases; i++)
free(aliases[i]);
free(aliases);
}
free(addrs);
free(hostname);
return status;

View File

@@ -18,6 +18,14 @@
* without express or implied warranty.
*/
/*
* Define WIN32 when build target is Win32 API
*/
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
#define WIN32
#endif
#include <stdio.h>
#include <sys/types.h>

View File

@@ -3,7 +3,8 @@
/* $Id$ */
/*
/* Copyright (C) 2005 by Dominick Meglio
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright

View File

@@ -159,24 +159,44 @@
/* Define this if you have struct timeval */
#define HAVE_STRUCT_TIMEVAL 1
/* ---------------------------------------------------------------- */
/* COMPILER SPECIFIC */
/* ---------------------------------------------------------------- */
/* Define to avoid VS2005 complaining about portable C functions */
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
/* ---------------------------------------------------------------- */
/* IPV6 COMPATIBILITY */
/* ---------------------------------------------------------------- */
/* Define this if you have address family AF_INET6 */
#ifdef HAVE_WINSOCK2_H
#define HAVE_AF_INET6 1
#endif
/* Define this if you have protocol family PF_INET6 */
#ifdef HAVE_WINSOCK2_H
#define HAVE_PF_INET6 1
#endif
/* Define this if you have struct in6_addr */
#ifdef HAVE_WS2TCPIP_H
#define HAVE_STRUCT_IN6_ADDR 1
#endif
/* Define this if you have struct sockaddr_in6 */
#ifdef HAVE_WS2TCPIP_H
#define HAVE_STRUCT_SOCKADDR_IN6 1
#endif
/* Define this if you have sockaddr_in6 with scopeid */
#ifdef HAVE_WS2TCPIP_H
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
#endif
#endif /* __ARES_CONFIG_WIN32_H */

View File

@@ -3,7 +3,8 @@
/* $Id$ */
/*
/* Copyright (C) 2005 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright

View File

@@ -3,7 +3,8 @@
/* $Id$ */
/*
/* Copyright (C) 2005 by Dominick Meglio
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright

View File

@@ -7,9 +7,6 @@
port build */
#ifndef NETWARE
#ifndef __CYGWIN__
#include <windows.h>
#endif
#include <process.h> /* for the _getpid() proto */
#endif /* !NETWARE */
#include <sys/types.h>

View File

@@ -16,13 +16,11 @@
* without express or implied warranty.
*/
#if !defined(WIN32) && defined(__WIN32__)
/* Borland fix */
#define WIN32
#endif
/*
* Define WIN32 when build target is Win32 API
*/
#if !defined(WIN32) && defined(_WIN32)
/* VS2005 on x64 fix */
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
#define WIN32
#endif

View File

@@ -49,8 +49,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
!ELSEIF "$(CFG)" == "adig - Win32 Debug"
@@ -73,8 +73,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
!ENDIF

View File

@@ -39,6 +39,7 @@ RSC=rc.exe
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
@@ -48,8 +49,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
!ELSEIF "$(CFG)" == "ahost - Win32 Debug"
@@ -62,6 +63,7 @@ LINK32=link.exe
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
@@ -71,8 +73,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
!ENDIF

View File

@@ -174,6 +174,7 @@ case $host in
esac
AC_MSG_RESULT($mimpure)
AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
AM_CONDITIONAL(STATICLIB, false)
AC_MSG_CHECKING([if we need BUILDING_LIBCURL])
case $host in
@@ -185,6 +186,7 @@ case $host in
then
AC_DEFINE(CURL_STATICLIB, 1, [when not building a shared library])
AC_MSG_RESULT(yes)
AM_CONDITIONAL(STATICLIB, true)
else
AC_MSG_RESULT(no)
fi
@@ -1292,6 +1294,7 @@ else
if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
then
AC_MSG_WARN([configure found only the libz lib, not the header file!])
HAVE_LIBZ=""
elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
then
AC_MSG_WARN([configure found only the libz header file, not the lib!])
@@ -1356,8 +1359,9 @@ if test X"$OPT_LIBSSH2" != Xno; then
AC_CHECK_HEADERS(libssh2.h,
curl_ssh_msg="enabled (libSSH2)"
LIBSSH2_ENABLED=1
AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use]))
AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
AC_SUBST(USE_LIBSSH2, [1])
)
if test X"$OPT_LIBSSH2" != Xoff &&
test "$LIBSSH2_ENABLED" != "1"; then
@@ -1566,13 +1570,17 @@ fi dnl OPENSSL != 1 -a GNUTLS_ENABLED != 1
if test "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED" = "x"; then
AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
AC_MSG_WARN([Use --with-ssl, --with-gnutls or --with-nss to address this.])
else
# SSL is enabled, genericly
AC_SUBST(SSL_ENABLED)
SSL_ENABLED="1"
fi
dnl **********************************************************************
dnl Check for the CA bundle
dnl **********************************************************************
if test X"$USE_NSS$USE_GNUTLS$OPENSSL_ENABLED" != "X"; then
if test X"$SSL_ENABLED" != "X"; then
AC_MSG_CHECKING([CA cert bundle install path])

View File

@@ -83,7 +83,7 @@ while test $# -gt 0; do
if test "@USE_SSLEAY@" = "1"; then
echo "SSL"
NTLM=1 # OpenSSL implies NTLM
elif test -n "@USE_GNUTLS@"; then
elif test -n "@SSL_ENABLED@"; then
echo "SSL"
fi
if test "@KRB4_ENABLED@" = "1"; then
@@ -113,13 +113,13 @@ while test $# -gt 0; do
--protocols)
if test "@CURL_DISABLE_HTTP@" != "1"; then
echo "HTTP"
if test "@USE_SSLEAY@" = "1"; then
if test "@SSL_ENABLED@" = "1"; then
echo "HTTPS"
fi
fi
if test "@CURL_DISABLE_FTP@" != "1"; then
echo "FTP"
if test "@USE_SSLEAY@" = "1"; then
if test "@SSL_ENABLED@" = "1"; then
echo "FTPS"
fi
fi

View File

@@ -143,11 +143,20 @@ Rexx
Written Mark Hessling
http://rexxcurl.sourceforge.net/
RPG
Support for ILE/RPG on OS/400 is included in source distribution
http://curl.haxx.se/libcurl/
See packages/OS400/README.OS400 and packages/OS400/curl.inc.in
Ruby
Written by Ross Bamford
curb - written by Ross Bamford
http://curb.rubyforge.org/
ruby-curl-multi - written by Kristjan Petursson and Keith Rarick
http://curl-multi.rubyforge.org/
Scheme
Bigloo binding by Kirill Lisovsky

View File

@@ -102,6 +102,8 @@
using spaces only (no tabs) and having the opening brace ({) on the same line
as the if() or while().
Also note that we use if() and while() with no space before the parenthesis.
2.3 Commenting
Comment your source code extensively using C comments (/* comment */), DO NOT

View File

@@ -12,6 +12,7 @@ Albert Chin-A-Young
Albert Choy
Ale Vesely
Aleksandar Milivojevic
Alex Fishman
Alex Neblett
Alex Suykov
Alex aka WindEagle
@@ -19,6 +20,7 @@ Alexander Kourakos
Alexander Krasnostavsky
Alexander Lazic
Alexander Zhuravlev
Alexey Pesternikov
Alexey Simak
Alexis Carvalho
Allen Pulsifer
@@ -229,6 +231,7 @@ Ignacio Vazquez-Abrams
Igor Polyakov
Ilguiz Latypov
Ilja van Sprundel
Immanuel Gregoire
Ingmar Runge
Ingo Ralf Blum
Ingo Wilken
@@ -274,6 +277,7 @@ John Janssen
John Kelly
John Lask
John McGowan
Johnny Luong
Jon Grubbs
Jon Travis
Jon Turner
@@ -308,6 +312,7 @@ Kent Boortz
Kevin Fisk
Kevin Lussier
Kevin Roth
Kim Rinnewitz
Kimmo Kinnunen
Kjell Ericson
Kjetil Jacobsen
@@ -348,6 +353,7 @@ Marco G. Salvagno
Marcus Webster
Mario Schroeder
Mark Butler
Mark Davies
Mark Eichin
Mark Lentczner
Markus Koetter
@@ -368,6 +374,7 @@ Matt Witherspoon
Matthew Blain
Matthew Clarke
Maurice Barnum
Max Katsev
Mekonikum
Mettgut Jamalla
Michael Benedict
@@ -440,6 +447,7 @@ Peter Wullinger
Peteris Krumins
Phil Karn
Philip Gladstone
Philip Langdale
Philippe Hameau
Philippe Raoult
Philippe Vaucher
@@ -575,6 +583,7 @@ Vilmos Nebehaj
Vincent Bronner
Vincent Penquerc'h
Vincent Sanders
Vladimir Lazarenko
Vojtech Janota
Vojtech Minarik
Walter J. Mack

View File

@@ -21,7 +21,7 @@
.\" * $Id$
.\" **************************************************************************
.\"
.TH curl 1 "21 Sep 2007" "Curl 7.17.1" "Curl Manual"
.TH curl 1 "20 Nov 2007" "Curl 7.17.2" "Curl Manual"
.SH NAME
curl \- transfer a URL
.SH SYNOPSIS
@@ -261,6 +261,20 @@ the \fI--data-ascii\fP option, this is for you.
If this option is used several times, the ones following the first will
append data.
.IP "--data-urlencode <data>"
(HTTP) This posts data, similar to the other --data options with the exception
that this will do partial URL encoding. (Added in 7.17.2)
The <data> part should be using one of the two following syntaxes:
.RS
.IP "name=content"
This will make curl URL encode the content part and pass that on. Note that
the name part is expected to be URL encoded already.
.IP "name@filename"
This will make curl load data from the given file, URL encode that data and
pass it on in the POST like \fIname=urlencoded-data\fP. Note that the name
is expected to be URL encoded already.
.RE
.IP "--digest"
(HTTP) Enables HTTP Digest authentication. This is a authentication that
prevents the password from being sent over the wire in clear text. Use this in

View File

@@ -18,6 +18,9 @@
#include <string.h>
#include <unistd.h>
#include <curl/multi.h>
#ifdef WIN32
#include <windows.h>
#endif
static const char *urls[] = {
"http://www.microsoft.com",
@@ -138,7 +141,11 @@ int main(void)
L = 100;
if (M == -1) {
#ifdef WIN32
Sleep(L);
#else
sleep(L / 1000);
#endif
} else {
T.tv_sec = L/1000;
T.tv_usec = (L%1000)*1000;

View File

@@ -9,7 +9,13 @@ EXTRA_DIST = README Makefile.example makefile.dj $(COMPLICATED_EXAMPLES)
INCLUDES = -I$(top_srcdir)/include
LIBDIR = $(top_builddir)/lib
CPPFLAGS = -DCURL_NO_OLDIES
if STATICLIB
# we need this define when building with a static lib on Windows
STATICCPPFLAGS = -DCURL_STATICLIB
endif
CPPFLAGS = -DCURL_NO_OLDIES $(STATICCPPFLAGS)
# Dependencies
LDADD = $(LIBDIR)/libcurl.la

View File

@@ -98,5 +98,8 @@ int main(int argc, char **argv)
if(chunk.memory)
free(chunk.memory);
/* we're done with libcurl, so clean it up */
curl_global_cleanup();
return 0;
}

View File

@@ -1491,6 +1491,14 @@ this curl handle use the data from the shared handle instead of keeping the
data to itself. This enables several curl handles to share data. If the curl
handles are used simultaneously, you \fBMUST\fP use the locking methods in the
share handle. See \fIcurl_share_setopt(3)\fP for details.
If you add a share that is set to share cookies, your easy handle will use
that cookie cache and get the cookie engine enabled. If you unshare an object
that were using cookies (or change to another object that doesn't share
cookies), the easy handle will get its cookie engine disabled.
Data that the share object is not set to share will be dealt with the usual
way, as if no share was used.
.IP CURLOPT_NEW_FILE_PERMS
Pass a long as a parameter, containing the value of the permissions that will
be assigned to newly created files on the remote server. The default value is

View File

@@ -29,6 +29,14 @@
#include "curlver.h" /* the libcurl version defines */
/*
* Define WIN32 when build target is Win32 API
*/
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
#define WIN32
#endif
#include <stdio.h>
#include <limits.h>
@@ -41,12 +49,42 @@
# include <time.h>
#endif /* defined (vms) */
typedef void CURL;
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
!defined(__CYGWIN__) || defined(__MINGW32__)
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
/* The check above prevents the winsock2 inclusion if winsock.h already was
included, since they can't co-exist without problems */
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#else
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
libc5-based Linux systems. Only include it on system that are known to
require it! */
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || defined(__minix)
#include <sys/select.h>
#endif
#ifndef _WIN32_WCE
#include <sys/socket.h>
#endif
#ifndef __WATCOMC__
#include <sys/time.h>
#endif
#include <sys/types.h>
#endif
#ifdef __BEOS__
#include <support/SupportDefs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef void CURL;
/*
* Decorate exportable functions for Win32 DLL linking.
* This avoids using a .def file for building libcurl.dll.
@@ -139,38 +177,6 @@ extern "C" {
#undef FILESIZEBITS
#endif
#if defined(_WIN32) && !defined(WIN32)
/* Chris Lewis mentioned that he doesn't get WIN32 defined, only _WIN32 so we
make this adjustment to catch this. */
#define WIN32 1
#endif
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
!defined(__CYGWIN__) || defined(__MINGW32__)
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
/* The check above prevents the winsock2 inclusion if winsock.h already was
included, since they can't co-exist without problems */
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#else
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
libc5-based Linux systems. Only include it on system that are known to
require it! */
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || defined(__minix)
#include <sys/select.h>
#endif
#ifndef _WIN32_WCE
#include <sys/socket.h>
#endif
#ifndef __WATCOMC__
#include <sys/time.h>
#endif
#include <sys/types.h>
#endif
#ifndef curl_socket_typedef
/* socket typedef */
#ifdef WIN32
@@ -1241,10 +1247,6 @@ typedef enum {
CURL_TIMECOND_LAST
} curl_TimeCond;
#ifdef __BEOS__
#include <support/SupportDefs.h>
#endif
/* curl_strequal() and curl_strnequal() are subject for removal in a future
libcurl, see lib/README.curlx for details */

View File

@@ -28,13 +28,13 @@
/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.17.1-CVS"
#define LIBCURL_VERSION "7.17.2-CVS"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 17
#define LIBCURL_VERSION_PATCH 1
#define LIBCURL_VERSION_PATCH 2
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
@@ -51,7 +51,7 @@
and it is always a greater number in a more recent release. It makes
comparisons with greater than and less than work.
*/
#define LIBCURL_VERSION_NUM 0x071101
#define LIBCURL_VERSION_NUM 0x071102
/*
* This is the date and time when the full source package was created. The

View File

@@ -12,9 +12,20 @@ CFLAGS = -3r -mf -d3 -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm -bt=
-d+ -dWIN32 -dCURL_CA_BUNDLE=getenv("CURL_CA_BUNDLE") &
-dBUILDING_LIBCURL -dWITHOUT_MM_LIB -dHAVE_SPNEGO=1 -dENABLE_IPV6 &
-dDEBUG_THREADING_GETADDRINFO -dDEBUG=1 -dCURLDEBUG -d_WIN32_WINNT=0x0501 &
-I. -I..\include -dCURL_DISABLE_LDAP
-I. -I..\include -dWINBERAPI=__declspec(cdecl) -dWINLDAPAPI=__declspec(cdecl)
#
# Change to suite.
#
ZLIB_ROOT = ..\..\..\zlib-1.2.3
USE_ZLIB = 0
!ifeq USE_ZLIB 1
CFLAGS += -dHAVE_ZLIB_H -dHAVE_LIBZ -I$(ZLIB_ROOT)
!endif
OBJ_DIR = Watcom_obj
C_ARG = $(OBJ_DIR)\wcc386.arg
LIB_ARG = $(OBJ_DIR)\wlib.arg
LINK_ARG = $(OBJ_DIR)\wlink.arg
@@ -50,7 +61,7 @@ OBJS = $(OBJ_DIR)\base64.obj $(OBJ_DIR)\connect.obj &
RESOURCE = $(OBJ_DIR)\libcurl.res
all: $(OBJ_DIR) $(TARGETS) .SYMBOLIC
all: $(OBJ_DIR) $(C_ARG) $(TARGETS) .SYMBOLIC
@echo Welcome to libcurl
$(OBJ_DIR):
@@ -69,7 +80,7 @@ clean: .SYMBOLIC
- rm -f $(OBJS) $(RESOURCE)
vclean realclean: clean .SYMBOLIC
- rm -f $(TARGETS) $(LIB_ARG) $(LINK_ARG) libcurl_wc.map
- rm -f $(TARGETS) $(C_ARG) $(LIB_ARG) $(LINK_ARG) libcurl_wc.map
- rmdir $(OBJ_DIR)
.ERASE
@@ -78,8 +89,11 @@ $(RESOURCE): libcurl.rc
.ERASE
.c{$(OBJ_DIR)}.obj:
$(CC) $[@ $(CFLAGS) -fo=$@
@echo .
$(CC) $[@ @$(C_ARG) -fo=$@
$(C_ARG): $(__MAKEFILES__)
%create $^@
%append $^@ $(CFLAGS)
$(LIB_ARG): $(__MAKEFILES__)
%create $^@
@@ -91,7 +105,10 @@ $(LINK_ARG): $(__MAKEFILES__)
@%append $^@ file { $(OBJS) }
@%append $^@ option quiet, map, caseexact, eliminate, implib=libcurl_wc_imp.lib,
@%append $^@ res=$(RESOURCE) libpath $(%watcom)\lib386;$(%watcom)\lib386\nt
@%append $^@ library clib3r.lib, ws2_32.lib
@%append $^@ library clib3r.lib, wldap32.lib, ws2_32.lib
!ifeq USE_ZLIB 1
@%append $^@ library $(ZLIB_ROOT)\zlib.lib
!endif
#
# Dependencies based on "gcc -MM .."

View File

@@ -20,12 +20,12 @@ endif
# Edit the path below to point to the base of your OpenSSL package.
ifndef OPENSSL_PATH
OPENSSL_PATH = ../../openssl-0.9.8e
OPENSSL_PATH = ../../openssl-0.9.8g
endif
# Edit the path below to point to the base of your LibSSH2 package.
ifndef LIBSSH2_PATH
LIBSSH2_PATH = ../../libssh2-0.16
LIBSSH2_PATH = ../../libssh2-0.18
endif
ifndef INSTDIR
@@ -372,7 +372,6 @@ ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define socklen_t int$(DL) >> $@
@echo $(DL)#define DL_LDAP_FILE "ldapsdk.nlm"$(DL) >> $@
else
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
@@ -405,7 +404,6 @@ else
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
@echo $(DL)#define DL_LDAP_FILE "lldapsdk.nlm"$(DL) >> $@
ifdef ENABLE_IPV6
@echo $(DL)#define ENABLE_IPV6 1$(DL) >> $@
endif

View File

@@ -101,7 +101,7 @@ size_t Curl_base64_decode(const char *src, unsigned char **outptr)
numQuantums = (length + equalsTerm) / 4;
/* Don't allocate a buffer if the decoded length is 0 */
if (numQuantums <= 0)
if(numQuantums <= 0)
return 0;
rawlen = (numQuantums * 3) - equalsTerm;

View File

@@ -347,6 +347,12 @@
#define HAVE_LONGLONG 1
#endif
/* Define to avoid VS2005 complaining about portable C functions */
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
/* ---------------------------------------------------------------- */
/* LDAP SUPPORT */
/* ---------------------------------------------------------------- */
@@ -370,10 +376,6 @@
/* ADDITIONAL DEFINITIONS */
/* ---------------------------------------------------------------- */
/* Defines set for VS2005 to _not_ deprecate a few functions we use. */
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
/* Define cpu-machine-OS */
#undef OS
#if defined(_M_IX86) || defined(__i386__) /* x86 (MSVC or gcc) */

View File

@@ -308,6 +308,12 @@
/* Undef keyword 'const' if it does not work. */
/* #undef const */
/* Define to avoid VS2005 complaining about portable C functions */
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
/* ---------------------------------------------------------------- */
/* LDAP SUPPORT */
/* ---------------------------------------------------------------- */
@@ -320,10 +326,6 @@
/* ADDITIONAL DEFINITIONS */
/* ---------------------------------------------------------------- */
/* Defines set for VS2005 to _not_ deprecate a few functions we use. */
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
/* Define cpu-machine-OS */
#undef OS
#define OS "i386-pc-win32ce"

View File

@@ -116,7 +116,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
int flags;
flags = fcntl(sockfd, F_GETFL, 0);
if (FALSE != nonblock)
if(FALSE != nonblock)
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
else
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
@@ -165,7 +165,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
#define SETBLOCK 6
#endif
#if (SETBLOCK == 0)
#if(SETBLOCK == 0)
#error "no non-blocking method was found/used/set"
#endif
}
@@ -233,7 +233,7 @@ static CURLcode bindlocal(struct connectdata *conn,
/*************************************************************
* Select device to bind socket to
*************************************************************/
if (dev && (strlen(dev)<255) ) {
if(dev && (strlen(dev)<255) ) {
struct Curl_dns_entry *h=NULL;
char myhost[256] = "";
in_addr_t in;
@@ -303,11 +303,11 @@ static CURLcode bindlocal(struct connectdata *conn,
* interfaces to go out the external interface.
*
*/
if (was_iface) {
if(was_iface) {
/* Only bind to the interface when specified as interface, not just as a
* hostname or ip address.
*/
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
dev, strlen(dev)+1) != 0) {
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
sockfd, dev, Curl_strerror(SOCKERRNO)); */
@@ -323,12 +323,12 @@ static CURLcode bindlocal(struct connectdata *conn,
#ifdef ENABLE_IPV6
in6 = Curl_inet_pton (AF_INET6, myhost, (void *)&ipv6_addr);
#endif
if (CURL_INADDR_NONE == in && -1 == in6) {
if(CURL_INADDR_NONE == in && -1 == in6) {
failf(data,"couldn't find my own IP address (%s)", myhost);
return CURLE_INTERFACE_FAILED;
} /* end of inet_addr */
if ( h ) {
if( h ) {
Curl_addrinfo *addr = h->addr;
sock = addr->ai_addr;
socksize = addr->ai_addrlen;
@@ -433,33 +433,33 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
#endif
if (0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize))
if(0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize))
err = SOCKERRNO;
#ifdef _WIN32_WCE
/* Old WinCE versions don't support SO_ERROR */
if (WSAENOPROTOOPT == err) {
if(WSAENOPROTOOPT == err) {
SET_SOCKERRNO(0);
err = 0;
}
#endif
#ifdef __minix
/* Minix 3.1.x doesn't support getsockopt on UDP sockets */
if (EBADIOCTL == err) {
if(EBADIOCTL == err) {
SET_SOCKERRNO(0);
err = 0;
}
#endif
if ((0 == err) || (EISCONN == err))
if((0 == err) || (EISCONN == err))
/* we are connected, awesome! */
rc = TRUE;
else
/* This wasn't a successful connect */
rc = FALSE;
if (error)
if(error)
*error = err;
#else
(void)sockfd;
if (error)
if(error)
*error = SOCKERRNO;
#endif
return rc;
@@ -504,7 +504,7 @@ static bool trynextip(struct connectdata *conn,
/* try the next address */
ai = conn->ip_addr->ai_next;
while (ai) {
while(ai) {
sockfd = singleipconnect(conn, ai, 0L, connected);
if(sockfd != CURL_SOCKET_BAD) {
/* store the new socket descriptor */
@@ -545,7 +545,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
/* subtract the most strict timeout of the ones */
if(data->set.timeout && data->set.connecttimeout) {
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
allow_total = allow = data->set.timeout;
else
allow = data->set.connecttimeout;
@@ -576,7 +576,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
if(WAITCONN_CONNECTED == rc) {
int error;
if (verifyconnect(sockfd, &error)) {
if(verifyconnect(sockfd, &error)) {
/* we are connected, awesome! */
*connected = TRUE;
return CURLE_OK;
@@ -594,7 +594,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
int error = 0;
/* nope, not connected */
if (WAITCONN_FDSET_ERROR == rc) {
if(WAITCONN_FDSET_ERROR == rc) {
(void)verifyconnect(sockfd, &error);
data->state.os_errno = error;
infof(data, "%s\n",Curl_strerror(conn,error));
@@ -628,7 +628,7 @@ static void tcpnodelay(struct connectdata *conn,
#ifdef HAVE_GETPROTOBYNAME
struct protoent *pe = getprotobyname("tcp");
if (pe)
if(pe)
proto = pe->p_proto;
#endif
@@ -703,7 +703,7 @@ singleipconnect(struct connectdata *conn,
CURLSOCKTYPE_IPCXN, addr);
else
sockfd = socket(addr->family, addr->socktype, addr->protocol);
if (sockfd == CURL_SOCKET_BAD)
if(sockfd == CURL_SOCKET_BAD)
return CURL_SOCKET_BAD;
*connected = FALSE; /* default is not connected */
@@ -728,7 +728,7 @@ singleipconnect(struct connectdata *conn,
error = data->set.fsockopt(data->set.sockopt_client,
sockfd,
CURLSOCKTYPE_IPCXN);
if (error) {
if(error) {
sclose(sockfd); /* close the socket and bail out */
return CURL_SOCKET_BAD;
}
@@ -836,9 +836,9 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
/* if a timeout is set, use the most restrictive one */
if (data->set.timeout > 0)
if(data->set.timeout > 0)
timeout_set += 1;
if (data->set.connecttimeout > 0)
if(data->set.connecttimeout > 0)
timeout_set += 2;
switch (timeout_set) {
@@ -849,7 +849,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
timeout_ms = data->set.connecttimeout;
break;
case 3:
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout_ms = data->set.timeout;
else
timeout_ms = data->set.connecttimeout;
@@ -859,7 +859,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
break;
}
if (timeout_set > 0) {
if(timeout_set > 0) {
/* if a timeout was already set, substract elapsed time */
timeout_ms -= Curl_tvdiff(before, data->progress.t_startsingle);
if(timeout_ms < 0) {
@@ -906,7 +906,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
before = after;
} /* end of connect-to-each-address loop */
if (sockfd == CURL_SOCKET_BAD) {
if(sockfd == CURL_SOCKET_BAD) {
/* no good connect was made */
*sockconn = CURL_SOCKET_BAD;
failf(data, "couldn't connect to host");

View File

@@ -57,7 +57,7 @@ static CURLcode
process_zlib_error(struct connectdata *conn, z_stream *z)
{
struct SessionHandle *data = conn->data;
if (z->msg)
if(z->msg)
failf (data, "Error while processing content unencoding: %s",
z->msg);
else
@@ -90,7 +90,7 @@ inflate_stream(struct connectdata *conn,
/* Dynamically allocate a buffer for decompression because it's uncommonly
large to hold on the stack */
decomp = (char*)malloc(DSIZ);
if (decomp == NULL) {
if(decomp == NULL) {
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
}
@@ -102,39 +102,39 @@ inflate_stream(struct connectdata *conn,
z->avail_out = DSIZ;
status = inflate(z, Z_SYNC_FLUSH);
if (status == Z_OK || status == Z_STREAM_END) {
if(status == Z_OK || status == Z_STREAM_END) {
allow_restart = 0;
if(DSIZ - z->avail_out) {
result = Curl_client_write(conn, CLIENTWRITE_BODY, decomp,
DSIZ - z->avail_out);
/* if !CURLE_OK, clean up, return */
if (result) {
if(result) {
free(decomp);
return exit_zlib(z, &k->zlib_init, result);
}
}
/* Done? clean up, return */
if (status == Z_STREAM_END) {
if(status == Z_STREAM_END) {
free(decomp);
if (inflateEnd(z) == Z_OK)
if(inflateEnd(z) == Z_OK)
return exit_zlib(z, &k->zlib_init, result);
else
return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
}
/* Done with these bytes, exit */
if (status == Z_OK && z->avail_in == 0) {
if(status == Z_OK && z->avail_in == 0) {
free(decomp);
return result;
}
}
else if (allow_restart && status == Z_DATA_ERROR) {
else if(allow_restart && status == Z_DATA_ERROR) {
/* some servers seem to not generate zlib headers, so this is an attempt
to fix and continue anyway */
(void) inflateEnd(z); /* don't care about the return code */
if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
return process_zlib_error(conn, z);
}
z->next_in = orig_in;
@@ -158,13 +158,13 @@ Curl_unencode_deflate_write(struct connectdata *conn,
z_stream *z = &k->z; /* zlib state structure */
/* Initialize zlib? */
if (k->zlib_init == ZLIB_UNINIT) {
if(k->zlib_init == ZLIB_UNINIT) {
z->zalloc = (alloc_func)Z_NULL;
z->zfree = (free_func)Z_NULL;
z->opaque = 0;
z->next_in = NULL;
z->avail_in = 0;
if (inflateInit(z) != Z_OK)
if(inflateInit(z) != Z_OK)
return process_zlib_error(conn, z);
k->zlib_init = ZLIB_INIT;
}
@@ -189,16 +189,16 @@ static enum {
const ssize_t totallen = len;
/* The shortest header is 10 bytes */
if (len < 10)
if(len < 10)
return GZIP_UNDERFLOW;
if ((data[0] != GZIP_MAGIC_0) || (data[1] != GZIP_MAGIC_1))
if((data[0] != GZIP_MAGIC_0) || (data[1] != GZIP_MAGIC_1))
return GZIP_BAD;
method = data[2];
flags = data[3];
if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
if(method != Z_DEFLATED || (flags & RESERVED) != 0) {
/* Can't handle this compression method or unknown flag */
return GZIP_BAD;
}
@@ -207,28 +207,28 @@ static enum {
len -= 10;
data += 10;
if (flags & EXTRA_FIELD) {
if(flags & EXTRA_FIELD) {
ssize_t extra_len;
if (len < 2)
if(len < 2)
return GZIP_UNDERFLOW;
extra_len = (data[1] << 8) | data[0];
if (len < (extra_len+2))
if(len < (extra_len+2))
return GZIP_UNDERFLOW;
len -= (extra_len + 2);
data += (extra_len + 2);
}
if (flags & ORIG_NAME) {
if(flags & ORIG_NAME) {
/* Skip over NUL-terminated file name */
while (len && *data) {
while(len && *data) {
--len;
++data;
}
if (!len || *data)
if(!len || *data)
return GZIP_UNDERFLOW;
/* Skip over the NUL */
@@ -236,13 +236,13 @@ static enum {
++data;
}
if (flags & COMMENT) {
if(flags & COMMENT) {
/* Skip over NUL-terminated comment */
while (len && *data) {
while(len && *data) {
--len;
++data;
}
if (!len || *data)
if(!len || *data)
return GZIP_UNDERFLOW;
/* Skip over the NUL */
@@ -250,8 +250,8 @@ static enum {
++data;
}
if (flags & HEAD_CRC) {
if (len < 2)
if(flags & HEAD_CRC) {
if(len < 2)
return GZIP_UNDERFLOW;
len -= 2;
@@ -271,30 +271,30 @@ Curl_unencode_gzip_write(struct connectdata *conn,
z_stream *z = &k->z; /* zlib state structure */
/* Initialize zlib? */
if (k->zlib_init == ZLIB_UNINIT) {
if(k->zlib_init == ZLIB_UNINIT) {
z->zalloc = (alloc_func)Z_NULL;
z->zfree = (free_func)Z_NULL;
z->opaque = 0;
z->next_in = NULL;
z->avail_in = 0;
if (strcmp(zlibVersion(), "1.2.0.4") >= 0) {
if(strcmp(zlibVersion(), "1.2.0.4") >= 0) {
/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
if (inflateInit2(z, MAX_WBITS+32) != Z_OK) {
if(inflateInit2(z, MAX_WBITS+32) != Z_OK) {
return process_zlib_error(conn, z);
}
k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
} else {
/* we must parse the gzip header ourselves */
if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
return process_zlib_error(conn, z);
}
k->zlib_init = ZLIB_INIT; /* Initial call state */
}
}
if (k->zlib_init == ZLIB_INIT_GZIP) {
if(k->zlib_init == ZLIB_INIT_GZIP) {
/* Let zlib handle the gzip decompression entirely */
z->next_in = (Bytef *)k->str;
z->avail_in = (uInt)nread;
@@ -342,7 +342,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
*/
z->avail_in = (uInt)nread;
z->next_in = malloc(z->avail_in);
if (z->next_in == NULL) {
if(z->next_in == NULL) {
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
}
memcpy(z->next_in, k->str, z->avail_in);
@@ -366,7 +366,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
z->avail_in += nread;
z->next_in = realloc(z->next_in, z->avail_in);
if (z->next_in == NULL) {
if(z->next_in == NULL) {
free(oldblock);
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
}
@@ -404,7 +404,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
break;
}
if (z->avail_in == 0) {
if(z->avail_in == 0) {
/* We don't have any data to inflate; wait until next time */
return CURLE_OK;
}

View File

@@ -483,7 +483,7 @@ Curl_cookie_add(struct SessionHandle *data,
/* It turns out, that sometimes the file format allows the path
field to remain not filled in, we try to detect this and work
around it! Andr<64>s Garc<72>a made us aware of this... */
if (strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
if(strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
/* only if the path doesn't look like a boolean option! */
co->path = strdup(ptr);
if(!co->path)
@@ -972,7 +972,7 @@ int Curl_cookie_output(struct CookieInfo *c, const char *dumphere)
while(co) {
format_ptr = get_netscape_format(co);
if (format_ptr == NULL) {
if(format_ptr == NULL) {
fprintf(out, "#\n# Fatal libcurl error\n");
fclose(out);
return 1;
@@ -996,27 +996,27 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
struct Cookie *c;
char *line;
if ((data->cookies == NULL) ||
if((data->cookies == NULL) ||
(data->cookies->numcookies == 0))
return NULL;
c = data->cookies->cookies;
beg = list;
while (c) {
while(c) {
/* fill the list with _all_ the cookies we know */
line = get_netscape_format(c);
if (line == NULL) {
if(line == NULL) {
curl_slist_free_all(beg);
return NULL;
}
list = curl_slist_append(list, line);
free(line);
if (list == NULL) {
if(list == NULL) {
curl_slist_free_all(beg);
return NULL;
}
else if (beg == NULL) {
else if(beg == NULL) {
beg = list;
}
c = c->next;

View File

@@ -129,7 +129,7 @@ static char *unescape_word(struct SessionHandle *data, const char *inp)
for(ptr = newp;
(byte = *ptr) != 0;
ptr++) {
if ((byte <= 32) || (byte == 127) ||
if((byte <= 32) || (byte == 127) ||
(byte == '\'') || (byte == '\"') || (byte == '\\')) {
dictp[olen++] = '\\';
}
@@ -164,35 +164,35 @@ static CURLcode Curl_dict(struct connectdata *conn, bool *done)
/* AUTH is missing */
}
if (strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
if(strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
word = strchr(path, ':');
if (word) {
if(word) {
word++;
database = strchr(word, ':');
if (database) {
if(database) {
*database++ = (char)0;
strategy = strchr(database, ':');
if (strategy) {
if(strategy) {
*strategy++ = (char)0;
nthdef = strchr(strategy, ':');
if (nthdef) {
if(nthdef) {
*nthdef++ = (char)0;
}
}
}
}
if ((word == NULL) || (*word == (char)0)) {
if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing");
word=(char *)"default";
}
if ((database == NULL) || (*database == (char)0)) {
if((database == NULL) || (*database == (char)0)) {
database = (char *)"!";
}
if ((strategy == NULL) || (*strategy == (char)0)) {
if((strategy == NULL) || (*strategy == (char)0)) {
strategy = (char *)".";
}
@@ -223,28 +223,28 @@ static CURLcode Curl_dict(struct connectdata *conn, bool *done)
if(result)
return result;
}
else if (strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
else if(strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
word = strchr(path, ':');
if (word) {
if(word) {
word++;
database = strchr(word, ':');
if (database) {
if(database) {
*database++ = (char)0;
nthdef = strchr(database, ':');
if (nthdef) {
if(nthdef) {
*nthdef++ = (char)0;
}
}
}
if ((word == NULL) || (*word == (char)0)) {
if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing");
word=(char *)"default";
}
if ((database == NULL) || (*database == (char)0)) {
if((database == NULL) || (*database == (char)0)) {
database = (char *)"!";
}
@@ -276,12 +276,12 @@ static CURLcode Curl_dict(struct connectdata *conn, bool *done)
else {
ppath = strchr(path, '/');
if (ppath) {
if(ppath) {
int i;
ppath++;
for (i = 0; ppath[i]; i++) {
if (ppath[i] == ':')
if(ppath[i] == ':')
ppath[i] = ' ';
}
result = Curl_sendf(sockfd, conn,

View File

@@ -127,7 +127,7 @@ static CURLcode win32_init(void)
err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0)
if(err != 0)
/* Tell the user that we couldn't find a useable */
/* winsock.dll. */
return CURLE_FAILED_INIT;
@@ -138,7 +138,7 @@ static CURLcode win32_init(void)
/* wVersionRequested in wVersion. wHighVersion contains the */
/* highest supported version. */
if ( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
if( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
HIBYTE( wsaData.wVersion ) != HIBYTE(wVersionRequested) ) {
/* Tell the user that we couldn't find a useable */
@@ -168,7 +168,7 @@ static void idna_init (void)
char buf[60];
UINT cp = GetACP();
if (!getenv("CHARSET") && cp > 0) {
if(!getenv("CHARSET") && cp > 0) {
snprintf(buf, sizeof(buf), "CHARSET=cp%u", cp);
putenv(buf);
}
@@ -212,7 +212,7 @@ curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc;
*/
CURLcode curl_global_init(long flags)
{
if (initialized++)
if(initialized++)
return CURLE_OK;
/* Setup the default memory functions here (again) */
@@ -222,14 +222,14 @@ CURLcode curl_global_init(long flags)
Curl_cstrdup = (curl_strdup_callback)system_strdup;
Curl_ccalloc = (curl_calloc_callback)calloc;
if (flags & CURL_GLOBAL_SSL)
if (!Curl_ssl_init()) {
if(flags & CURL_GLOBAL_SSL)
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
return CURLE_FAILED_INIT;
}
if (flags & CURL_GLOBAL_WIN32)
if (win32_init() != CURLE_OK) {
if(flags & CURL_GLOBAL_WIN32)
if(win32_init() != CURLE_OK) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
return CURLE_FAILED_INIT;
}
@@ -267,16 +267,16 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
CURLcode code = CURLE_OK;
/* Invalid input, return immediately */
if (!m || !f || !r || !s || !c)
if(!m || !f || !r || !s || !c)
return CURLE_FAILED_INIT;
/* Already initialized, don't do it again */
if ( initialized )
if( initialized )
return CURLE_OK;
/* Call the actual init function first */
code = curl_global_init(flags);
if (code == CURLE_OK) {
if(code == CURLE_OK) {
Curl_cmalloc = m;
Curl_cfree = f;
Curl_cstrdup = s;
@@ -293,18 +293,18 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
*/
void curl_global_cleanup(void)
{
if (!initialized)
if(!initialized)
return;
if (--initialized)
if(--initialized)
return;
Curl_global_host_cache_dtor();
if (init_flags & CURL_GLOBAL_SSL)
if(init_flags & CURL_GLOBAL_SSL)
Curl_ssl_cleanup();
if (init_flags & CURL_GLOBAL_WIN32)
if(init_flags & CURL_GLOBAL_WIN32)
win32_cleanup();
#ifdef __AMIGA__
@@ -324,7 +324,7 @@ CURL *curl_easy_init(void)
struct SessionHandle *data;
/* Make sure we inited the global SSL stuff */
if (!initialized) {
if(!initialized) {
res = curl_global_init(CURL_GLOBAL_DEFAULT);
if(res) {
/* something in the global init failed, return nothing */
@@ -465,17 +465,17 @@ CURLcode curl_easy_perform(CURL *curl)
if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT;
if ( ! (data->share && data->share->hostcache) ) {
if( ! (data->share && data->share->hostcache) ) {
if (Curl_global_host_cache_use(data) &&
if(Curl_global_host_cache_use(data) &&
(data->dns.hostcachetype != HCACHE_GLOBAL)) {
if (data->dns.hostcachetype == HCACHE_PRIVATE)
if(data->dns.hostcachetype == HCACHE_PRIVATE)
Curl_hash_destroy(data->dns.hostcache);
data->dns.hostcache = Curl_global_host_cache_get();
data->dns.hostcachetype = HCACHE_GLOBAL;
}
if (!data->dns.hostcache) {
if(!data->dns.hostcache) {
data->dns.hostcachetype = HCACHE_PRIVATE;
data->dns.hostcache = Curl_mk_dnscache();
@@ -520,7 +520,7 @@ void Curl_easy_addmulti(struct SessionHandle *data,
void *multi)
{
data->multi = multi;
if (multi == NULL)
if(multi == NULL)
/* the association is cleared, mark the easy handle as not used by an
interface */
data->state.used_interface = Curl_if_none;
@@ -579,7 +579,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
outcurl->state.headersize=HEADERSIZE;
/* copy all userdefined values */
if (Curl_dupset(outcurl, data) != CURLE_OK)
if(Curl_dupset(outcurl, data) != CURLE_OK)
break;
if(data->state.used_interface == Curl_if_multi)
@@ -600,9 +600,9 @@ CURL *curl_easy_duphandle(CURL *incurl)
/* If cookies are enabled in the parent handle, we enable them
in the clone as well! */
outcurl->cookies = Curl_cookie_init(data,
data->cookies->filename,
outcurl->cookies,
data->set.cookiesession);
data->cookies->filename,
outcurl->cookies,
data->set.cookiesession);
if(!outcurl->cookies) {
break;
}
@@ -789,7 +789,7 @@ CURLcode Curl_convert_to_network(struct SessionHandle *data,
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)) {
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
error = ERRNO;
failf(data,
"The Curl_convert_to_network iconv call failed with errno %i: %s",
@@ -849,7 +849,7 @@ CURLcode Curl_convert_from_network(struct SessionHandle *data,
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)) {
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
error = ERRNO;
failf(data,
"The Curl_convert_from_network iconv call failed with errno %i: %s",
@@ -910,14 +910,14 @@ CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
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)) {
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) {
if(output_ptr < input_ptr) {
/* null terminate the now shorter output string */
*output_ptr = 0x00;
}

View File

@@ -112,7 +112,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
#ifdef CURL_DOES_CONVERSIONS
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
if (!handle ||
if(!handle ||
(Curl_convert_to_network(handle, &in, 1) != CURLE_OK)) {
/* Curl_convert_to_network calls failf if unsuccessful */
free(ns);
@@ -163,7 +163,7 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length,
#ifdef CURL_DOES_CONVERSIONS
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
if (!handle ||
if(!handle ||
(Curl_convert_from_network(handle, &in, 1) != CURLE_OK)) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(ns);

View File

@@ -97,6 +97,7 @@
static CURLcode Curl_file(struct connectdata *, bool *done);
static CURLcode Curl_file_done(struct connectdata *conn,
CURLcode status, bool premature);
static CURLcode Curl_file_connect(struct connectdata *conn, bool *done);
/*
* FILE scheme handler.
@@ -108,7 +109,7 @@ const struct Curl_handler Curl_handler_file = {
Curl_file, /* do_it */
Curl_file_done, /* done */
ZERO_NULL, /* do_more */
ZERO_NULL, /* connect_it */
Curl_file_connect, /* connect_it */
ZERO_NULL, /* connecting */
ZERO_NULL, /* doing */
ZERO_NULL, /* proto_getsock */
@@ -123,7 +124,7 @@ const struct Curl_handler Curl_handler_file = {
* do protocol-specific actions at connect-time. We emulate a
* connect-then-transfer protocol and "connect" to the file here
*/
CURLcode Curl_file_connect(struct connectdata *conn)
static CURLcode Curl_file_connect(struct connectdata *conn, bool *done)
{
struct SessionHandle *data = conn->data;
char *real_path = curl_easy_unescape(data, data->reqdata.path, 0, NULL);
@@ -141,7 +142,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
sessionhandle, deal with it */
Curl_reset_reqproto(conn);
if (!data->reqdata.proto.file) {
if(!data->reqdata.proto.file) {
file = (struct FILEPROTO *)calloc(sizeof(struct FILEPROTO), 1);
if(!file) {
free(real_path);
@@ -176,7 +177,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
with a drive letter.
*/
actual_path = real_path;
if ((actual_path[0] == '/') &&
if((actual_path[0] == '/') &&
actual_path[1] &&
(actual_path[2] == ':' || actual_path[2] == '|'))
{
@@ -186,7 +187,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
/* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
for (i=0; actual_path[i] != '\0'; ++i)
if (actual_path[i] == '/')
if(actual_path[i] == '/')
actual_path[i] = '\\';
fd = open(actual_path, O_RDONLY | O_BINARY); /* no CR/LF translation! */
@@ -203,6 +204,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
Curl_file_done(conn, CURLE_FILE_COULDNT_READ_FILE, FALSE);
return CURLE_FILE_COULDNT_READ_FILE;
}
*done = TRUE;
return CURLE_OK;
}
@@ -218,9 +220,6 @@ static CURLcode Curl_file_done(struct connectdata *conn,
if(file->fd != -1)
close(file->fd);
free(file);
conn->data->reqdata.proto.file= NULL; /* clear it! */
return CURLE_OK;
}
@@ -271,7 +270,7 @@ static CURLcode file_upload(struct connectdata *conn)
fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC,
conn->data->set.new_file_perms);
#endif /* !(WIN32 || MSDOS || __EMX__) */
if (fd < 0) {
if(fd < 0) {
failf(data, "Can't open %s for writing", file->path);
return CURLE_WRITE_ERROR;
}
@@ -298,13 +297,13 @@ static CURLcode file_upload(struct connectdata *conn)
data->reqdata.resume_from = (curl_off_t)file_stat.st_size;
}
while (res == CURLE_OK) {
while(res == CURLE_OK) {
int readcount;
res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
if(res)
break;
if (readcount <= 0) /* fix questionable compare error. curlvms */
if(readcount <= 0) /* fix questionable compare error. curlvms */
break;
nread = (size_t)readcount;
@@ -379,7 +378,6 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done)
*done = TRUE; /* unconditionally */
Curl_readwrite_init(conn);
Curl_initinfo(data);
Curl_pgrsStartNow(data);
@@ -436,14 +434,14 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done)
return result;
}
if (data->reqdata.resume_from <= expected_size)
if(data->reqdata.resume_from <= expected_size)
expected_size -= data->reqdata.resume_from;
else {
failf(data, "failed to resume file:// transfer");
return CURLE_BAD_DOWNLOAD_RESUME;
}
if (fstated && (expected_size == 0))
if(fstated && (expected_size == 0))
return CURLE_OK;
/* The following is a shortcut implementation of file reading
@@ -461,13 +459,13 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done)
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
while (res == CURLE_OK) {
while(res == CURLE_OK) {
nread = read(fd, buf, BUFSIZE-1);
if ( nread > 0)
if( nread > 0)
buf[nread] = 0;
if (nread <= 0)
if(nread <= 0)
break;
bytecount += nread;

View File

@@ -25,7 +25,5 @@
***************************************************************************/
#ifndef CURL_DISABLE_FILE
extern const struct Curl_handler Curl_handler_file;
CURLcode Curl_file_connect(struct connectdata *);
#endif
#endif

View File

@@ -187,7 +187,7 @@ AddHttpPost(char * name, size_t namelength,
else
return NULL;
if (parent_post) {
if(parent_post) {
/* now, point our 'more' to the original 'more' */
post->more = parent_post->more;
@@ -224,16 +224,16 @@ static FormInfo * AddFormInfo(char *value,
form_info = (FormInfo *)malloc(sizeof(FormInfo));
if(form_info) {
memset(form_info, 0, sizeof(FormInfo));
if (value)
if(value)
form_info->value = value;
if (contenttype)
if(contenttype)
form_info->contenttype = contenttype;
form_info->flags = HTTPPOST_FILENAME;
}
else
return NULL;
if (parent_form_info) {
if(parent_form_info) {
/* now, point our 'more' to the original 'more' */
form_info->more = parent_form_info->more;
@@ -316,7 +316,7 @@ static char *memdup(const char *src, size_t buffer_length)
bool add = FALSE;
char *buffer;
if (buffer_length)
if(buffer_length)
length = buffer_length;
else if(src) {
length = strlen(src);
@@ -327,13 +327,13 @@ static char *memdup(const char *src, size_t buffer_length)
return strdup((char *)"");
buffer = (char*)malloc(length+add);
if (!buffer)
if(!buffer)
return NULL; /* fail */
memcpy(buffer, src, length);
/* if length unknown do null termination */
if (add)
if(add)
buffer[length] = '\0';
return buffer;
@@ -418,16 +418,16 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/*
* Loop through all the options set. Break if we have an error to report.
*/
while (return_value == CURL_FORMADD_OK) {
while(return_value == CURL_FORMADD_OK) {
/* first see if we have more parts of the array param */
if ( array_state ) {
if( array_state ) {
/* get the upcoming option from the given array */
option = forms->option;
array_value = (char *)forms->value;
forms++; /* advance this to next entry */
if (CURLFORM_END == option) {
if(CURLFORM_END == option) {
/* end of array state */
array_state = FALSE;
continue;
@@ -436,7 +436,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
else {
/* This is not array-state, get next option */
option = va_arg(params, CURLformoption);
if (CURLFORM_END == option)
if(CURLFORM_END == option)
break;
}
@@ -447,7 +447,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_ILLEGAL_ARRAY;
else {
forms = va_arg(params, struct curl_forms *);
if (forms)
if(forms)
array_state = TRUE;
else
return_value = CURL_FORMADD_NULL;
@@ -465,19 +465,19 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
current_form->flags |= HTTPPOST_PTRNAME; /* fall through */
#endif
case CURLFORM_COPYNAME:
if (current_form->name)
if(current_form->name)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
char *name = array_state?
array_value:va_arg(params, char *);
if (name)
if(name)
current_form->name = name; /* store for the moment */
else
return_value = CURL_FORMADD_NULL;
}
break;
case CURLFORM_NAMELENGTH:
if (current_form->namelength)
if(current_form->namelength)
return_value = CURL_FORMADD_OPTION_TWICE;
else
current_form->namelength =
@@ -490,19 +490,19 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
case CURLFORM_PTRCONTENTS:
current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */
case CURLFORM_COPYCONTENTS:
if (current_form->value)
if(current_form->value)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
char *value =
array_state?array_value:va_arg(params, char *);
if (value)
if(value)
current_form->value = value; /* store for the moment */
else
return_value = CURL_FORMADD_NULL;
}
break;
case CURLFORM_CONTENTSLENGTH:
if (current_form->contentslength)
if(current_form->contentslength)
return_value = CURL_FORMADD_OPTION_TWICE;
else
current_form->contentslength =
@@ -511,12 +511,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* Get contents from a given file name */
case CURLFORM_FILECONTENT:
if (current_form->flags != 0)
if(current_form->flags != 0)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
const char *filename = array_state?
array_value:va_arg(params, char *);
if (filename) {
if(filename) {
current_form->value = strdup(filename);
if(!current_form->value)
return_value = CURL_FORMADD_MEMORY;
@@ -536,10 +536,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
const char *filename = array_state?array_value:
va_arg(params, char *);
if (current_form->value) {
if (current_form->flags & HTTPPOST_FILENAME) {
if (filename) {
if ((current_form = AddFormInfo(strdup(filename),
if(current_form->value) {
if(current_form->flags & HTTPPOST_FILENAME) {
if(filename) {
if((current_form = AddFormInfo(strdup(filename),
NULL, current_form)) == NULL)
return_value = CURL_FORMADD_MEMORY;
}
@@ -550,7 +550,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_OPTION_TWICE;
}
else {
if (filename) {
if(filename) {
current_form->value = strdup(filename);
if(!current_form->value)
return_value = CURL_FORMADD_MEMORY;
@@ -570,10 +570,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
const char *filename = array_state?array_value:
va_arg(params, char *);
if (current_form->value) {
if (current_form->flags & HTTPPOST_BUFFER) {
if (filename) {
if ((current_form = AddFormInfo(strdup(filename),
if(current_form->value) {
if(current_form->flags & HTTPPOST_BUFFER) {
if(filename) {
if((current_form = AddFormInfo(strdup(filename),
NULL, current_form)) == NULL)
return_value = CURL_FORMADD_MEMORY;
}
@@ -584,7 +584,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_OPTION_TWICE;
}
else {
if (filename) {
if(filename) {
current_form->value = strdup(filename);
if(!current_form->value)
return_value = CURL_FORMADD_MEMORY;
@@ -598,12 +598,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
case CURLFORM_BUFFERPTR:
current_form->flags |= HTTPPOST_PTRBUFFER;
if (current_form->buffer)
if(current_form->buffer)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
char *buffer =
array_state?array_value:va_arg(params, char *);
if (buffer)
if(buffer)
current_form->buffer = buffer; /* store for the moment */
else
return_value = CURL_FORMADD_NULL;
@@ -611,7 +611,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
break;
case CURLFORM_BUFFERLENGTH:
if (current_form->bufferlength)
if(current_form->bufferlength)
return_value = CURL_FORMADD_OPTION_TWICE;
else
current_form->bufferlength =
@@ -622,10 +622,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
{
const char *contenttype =
array_state?array_value:va_arg(params, char *);
if (current_form->contenttype) {
if (current_form->flags & HTTPPOST_FILENAME) {
if (contenttype) {
if ((current_form = AddFormInfo(NULL,
if(current_form->contenttype) {
if(current_form->flags & HTTPPOST_FILENAME) {
if(contenttype) {
if((current_form = AddFormInfo(NULL,
strdup(contenttype),
current_form)) == NULL)
return_value = CURL_FORMADD_MEMORY;
@@ -637,7 +637,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_OPTION_TWICE;
}
else {
if (contenttype) {
if(contenttype) {
current_form->contenttype = strdup(contenttype);
if(!current_form->contenttype)
return_value = CURL_FORMADD_MEMORY;
@@ -692,7 +692,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
for(form = first_form;
form != NULL;
form = form->more) {
if ( ((!form->name || !form->value) && !post) ||
if( ((!form->name || !form->value) && !post) ||
( (form->contentslength) &&
(form->flags & HTTPPOST_FILENAME) ) ||
( (form->flags & HTTPPOST_FILENAME) &&
@@ -709,7 +709,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
break;
}
else {
if ( ((form->flags & HTTPPOST_FILENAME) ||
if( ((form->flags & HTTPPOST_FILENAME) ||
(form->flags & HTTPPOST_BUFFER)) &&
!form->contenttype ) {
/* our contenttype is missing */
@@ -721,23 +721,23 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
}
form->contenttype_alloc = TRUE;
}
if ( !(form->flags & HTTPPOST_PTRNAME) &&
if( !(form->flags & HTTPPOST_PTRNAME) &&
(form == first_form) ) {
/* copy name (without strdup; possibly contains null characters) */
form->name = memdup(form->name, form->namelength);
if (!form->name) {
if(!form->name) {
return_value = CURL_FORMADD_MEMORY;
break;
}
form->name_alloc = TRUE;
}
if ( !(form->flags & HTTPPOST_FILENAME) &&
if( !(form->flags & HTTPPOST_FILENAME) &&
!(form->flags & HTTPPOST_READFILE) &&
!(form->flags & HTTPPOST_PTRCONTENTS) &&
!(form->flags & HTTPPOST_PTRBUFFER) ) {
/* copy value (without strdup; possibly contains null characters) */
form->value = memdup(form->value, form->contentslength);
if (!form->value) {
if(!form->value) {
return_value = CURL_FORMADD_MEMORY;
break;
}
@@ -756,7 +756,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
break;
}
if (form->contenttype)
if(form->contenttype)
prevtype = form->contenttype;
}
}
@@ -780,7 +780,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* always delete the allocated memory before returning */
form = first_form;
while (form != NULL) {
while(form != NULL) {
FormInfo *delete_form;
delete_form = form;
@@ -820,7 +820,7 @@ static CURLcode AddFormData(struct FormData **formp,
{
struct FormData *newform = (struct FormData *)
malloc(sizeof(struct FormData));
if (!newform)
if(!newform)
return CURLE_OUT_OF_MEMORY;
newform->next = NULL;
@@ -829,7 +829,7 @@ static CURLcode AddFormData(struct FormData **formp,
length = strlen((char *)line);
newform->line = (char *)malloc(length+1);
if (!newform->line) {
if(!newform->line) {
free(newform);
return CURLE_OUT_OF_MEMORY;
}
@@ -845,7 +845,7 @@ static CURLcode AddFormData(struct FormData **formp,
else
*formp = newform;
if (size) {
if(size) {
if((type == FORM_DATA) || (type == FORM_CONTENT))
*size += length;
else {
@@ -896,7 +896,7 @@ void Curl_formclean(struct FormData **form_ptr)
free(form->line); /* free the line */
free(form); /* free the struct */
} while ((form = next) != NULL); /* continue */
} while((form = next) != NULL); /* continue */
*form_ptr = NULL;
}
@@ -920,13 +920,13 @@ CURLcode Curl_formconvert(struct SessionHandle *data, struct FormData *form)
do {
next=form->next; /* the following form line */
if (form->type == FORM_DATA) {
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)
if(rc != CURLE_OK)
return rc;
}
} while ((form = next) != NULL); /* continue */
} while((form = next) != NULL); /* continue */
return CURLE_OK;
}
#endif /* CURL_DOES_CONVERSIONS */
@@ -944,11 +944,11 @@ int curl_formget(struct curl_httppost *form, void *arg,
struct FormData *data, *ptr;
rc = Curl_getFormData(&data, form, NULL, &size);
if (rc != CURLE_OK)
if(rc != CURLE_OK)
return (int)rc;
for (ptr = data; ptr; ptr = ptr->next) {
if (ptr->type == FORM_FILE) {
if(ptr->type == FORM_FILE) {
char buffer[8192];
size_t nread;
struct Form temp;
@@ -957,16 +957,16 @@ int curl_formget(struct curl_httppost *form, void *arg,
do {
nread = readfromfile(&temp, buffer, sizeof(buffer));
if ((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
if (temp.fp) {
if((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
if(temp.fp) {
fclose(temp.fp);
}
Curl_formclean(&data);
return -1;
}
} while (nread == sizeof(buffer));
} while(nread == sizeof(buffer));
} else {
if (ptr->length != append(arg, ptr->line, ptr->length)) {
if(ptr->length != append(arg, ptr->line, ptr->length)) {
Curl_formclean(&data);
return -1;
}
@@ -1005,7 +1005,7 @@ void curl_formfree(struct curl_httppost *form)
free(form->showfilename); /* free the faked file name */
free(form); /* free the struct */
} while ((form = next) != NULL); /* continue */
} while((form = next) != NULL); /* continue */
}
#ifndef HAVE_BASENAME
@@ -1110,7 +1110,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"Content-Type: multipart/form-data",
boundary);
if (result) {
if(result) {
free(boundary);
return result;
}
@@ -1123,13 +1123,13 @@ CURLcode Curl_getFormData(struct FormData **finalform,
if(size) {
result = AddFormDataf(&form, &size, "\r\n");
if (result)
if(result)
break;
}
/* boundary */
result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
if (result)
if(result)
break;
/* Maybe later this should be disabled when a custom_content_type is
@@ -1138,16 +1138,16 @@ CURLcode Curl_getFormData(struct FormData **finalform,
*/
result = AddFormDataf(&form, &size,
"Content-Disposition: form-data; name=\"");
if (result)
if(result)
break;
result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
&size);
if (result)
if(result)
break;
result = AddFormDataf(&form, &size, "\"");
if (result)
if(result)
break;
if(post->more) {
@@ -1160,7 +1160,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"\r\nContent-Type: multipart/mixed,"
" boundary=%s\r\n",
fileboundary);
if (result)
if(result)
break;
}
@@ -1183,9 +1183,9 @@ CURLcode Curl_getFormData(struct FormData **finalform,
fileboundary,
(file->showfilename?file->showfilename:
filebasename));
if (filebasename)
if(filebasename)
free(filebasename);
if (result)
if(result)
break;
}
else if((post->flags & HTTPPOST_FILENAME) ||
@@ -1198,10 +1198,10 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"; filename=\"%s\"",
(post->showfilename?post->showfilename:
filebasename));
if (filebasename)
if(filebasename)
free(filebasename);
if (result)
if(result)
break;
}
@@ -1210,7 +1210,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
result = AddFormDataf(&form, &size,
"\r\nContent-Type: %s",
file->contenttype);
if (result)
if(result)
break;
}
@@ -1218,11 +1218,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
while( curList ) {
/* Process the additional headers specified for this form */
result = AddFormDataf( &form, &size, "\r\n%s", curList->data );
if (result)
if(result)
break;
curList = curList->next;
}
if (result) {
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@@ -1240,13 +1240,13 @@ CURLcode Curl_getFormData(struct FormData **finalform,
/* this is not a text content, mention our binary encoding */
result = AddFormDataf(&form, &size,
"\r\nContent-Transfer-Encoding: binary");
if (result)
if(result)
break;
}
#endif
result = AddFormDataf(&form, &size, "\r\n\r\n");
if (result)
if(result)
break;
if((post->flags & HTTPPOST_FILENAME) ||
@@ -1278,14 +1278,14 @@ CURLcode Curl_getFormData(struct FormData **finalform,
*/
size_t nread;
char buffer[512];
while ((nread = fread(buffer, 1, sizeof(buffer), fileread)) != 0) {
while((nread = fread(buffer, 1, sizeof(buffer), fileread)) != 0) {
result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
if (result)
if(result)
break;
}
}
if (result) {
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@@ -1305,11 +1305,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
}
}
else if (post->flags & HTTPPOST_BUFFER) {
else if(post->flags & HTTPPOST_BUFFER) {
/* include contents of buffer */
result = AddFormData(&form, FORM_CONTENT, post->buffer,
post->bufferlength, &size);
if (result)
if(result)
break;
}
@@ -1317,11 +1317,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
/* include the contents we got */
result = AddFormData(&form, FORM_CONTENT, post->contents,
post->contentslength, &size);
if (result)
if(result)
break;
}
} while ((file = file->more) != NULL); /* for each specified file for this field */
if (result) {
} while((file = file->more) != NULL); /* for each specified file for this field */
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@@ -1334,12 +1334,12 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"\r\n--%s--",
fileboundary);
free(fileboundary);
if (result)
if(result)
break;
}
} while ((post = post->next) != NULL); /* for each field */
if (result) {
} while((post = post->next) != NULL); /* for each field */
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@@ -1349,7 +1349,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
result = AddFormDataf(&form, &size,
"\r\n--%s--\r\n",
boundary);
if (result) {
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@@ -1488,7 +1488,7 @@ int FormAddTest(const char * errormsg,
int result;
va_list arg;
va_start(arg, last_post);
if ((result = FormAdd(httppost, last_post, arg)))
if((result = FormAdd(httppost, last_post, arg)))
fprintf (stderr, "ERROR doing FormAdd ret: %d action: %s\n", result,
errormsg);
va_end(arg);
@@ -1539,11 +1539,11 @@ int main(int argc, argv_item_t argv[])
(void) argc;
(void) argv;
if (FormAddTest("simple COPYCONTENTS test", &httppost, &last_post,
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,
if(FormAddTest("COPYCONTENTS + CONTENTTYPE test", &httppost, &last_post,
CURLFORM_COPYNAME, name2, CURLFORM_COPYCONTENTS, value2,
CURLFORM_CONTENTTYPE, type2, CURLFORM_END))
++errors;
@@ -1551,41 +1551,41 @@ int main(int argc, argv_item_t argv[])
correctly */
name3[1] = '\0';
value3[1] = '\0';
if (FormAddTest("PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH test",
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,
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,
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",
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,
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,
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,
if(FormAddTest("FILE1 + FILE2 + FILE3 test", &httppost, &last_post,
CURLFORM_COPYNAME, name9, CURLFORM_FILE, value7,
CURLFORM_FILE, value8, CURLFORM_FILE, value7, CURLFORM_END))
++errors;
@@ -1596,11 +1596,11 @@ int main(int argc, argv_item_t argv[])
forms[2].option = CURLFORM_FILE;
forms[2].value = value7;
forms[3].option = CURLFORM_END;
if (FormAddTest("FILE1 + FILE2 + FILE3 ARRAY test", &httppost, &last_post,
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,
if(FormAddTest("FILECONTENT test", &httppost, &last_post,
CURLFORM_COPYNAME, name11, CURLFORM_FILECONTENT, value7,
CURLFORM_END))
++errors;
@@ -1628,7 +1628,7 @@ int main(int argc, argv_item_t argv[])
fprintf(stdout, "size: ");
fprintf(stdout, CURL_FORMAT_OFF_T, size);
fprintf(stdout, "\n");
if (errors)
if(errors)
fprintf(stdout, "\n==> %d Test(s) failed!\n", errors);
else
fprintf(stdout, "\nAll Tests seem to have worked (please check output)\n");

128
lib/ftp.c
View File

@@ -111,7 +111,7 @@
#endif
#ifdef CURL_DISABLE_VERBOSE_STRINGS
#define ftp_pasv_verbose(a,b,c,d) do { } while (0)
#define ftp_pasv_verbose(a,b,c,d) do { } while(0)
#endif
/* Local API functions */
@@ -152,9 +152,9 @@ static CURLcode Curl_ftps_setup_connection(struct connectdata * conn);
#endif
/* easy-to-use macro: */
#define FTPSENDF(x,y,z) if ((result = Curl_ftpsendf(x,y,z)) != CURLE_OK) \
#define FTPSENDF(x,y,z) if((result = Curl_ftpsendf(x,y,z)) != CURLE_OK) \
return result
#define NBFTPSENDF(x,y,z) if ((result = Curl_nbftpsendf(x,y,z)) != CURLE_OK) \
#define NBFTPSENDF(x,y,z) if((result = Curl_nbftpsendf(x,y,z)) != CURLE_OK) \
return result
@@ -307,9 +307,9 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
/* if a timeout is set, use the most restrictive one */
if (data->set.timeout > 0)
if(data->set.timeout > 0)
timeout_set += 1;
if (data->set.connecttimeout > 0)
if(data->set.connecttimeout > 0)
timeout_set += 2;
switch (timeout_set) {
@@ -320,7 +320,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
timeout_ms = data->set.connecttimeout;
break;
case 3:
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout_ms = data->set.timeout;
else
timeout_ms = data->set.connecttimeout;
@@ -330,7 +330,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
break;
}
if (timeout_set > 0) {
if(timeout_set > 0) {
/* if a timeout was already set, substract elapsed time */
timeout_ms -= Curl_tvdiff(Curl_tvnow(), conn->now);
if(timeout_ms < 0) {
@@ -366,7 +366,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
}
sclose(sock); /* close the first socket */
if (CURL_SOCKET_BAD == s) {
if(CURL_SOCKET_BAD == s) {
/* DIE! */
failf(data, "Error accept()ing server connect");
return CURLE_FTP_PORT_FAILED;
@@ -643,7 +643,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
size_t nread;
int cache_skip=0;
if (ftpcode)
if(ftpcode)
*ftpcode = 0; /* 0 for errors */
*nreadp=0;
@@ -846,7 +846,7 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
result = ftp_state_post_cwd(conn);
else {
ftpc->count2 = 0;
if (conn->bits.reuse && ftpc->entrypath) {
if(conn->bits.reuse && ftpc->entrypath) {
/* This is a re-used connection. Since we change directory to where the
transfer is taking place, we must first get back to the original dir
where we ended up after login: */
@@ -922,13 +922,13 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
the IP from the control connection */
sslen = sizeof(ss);
if (getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) {
if(getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) {
failf(data, "getsockname() failed: %s",
Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED;
}
if (sslen > (socklen_t)sizeof(ss))
if(sslen > (socklen_t)sizeof(ss))
sslen = sizeof(ss);
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL,
0, NIFLAGS);
@@ -960,11 +960,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/*
* Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype):
*/
if (ai->ai_socktype == 0)
if(ai->ai_socktype == 0)
ai->ai_socktype = conn->socktype;
portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (portsock == CURL_SOCKET_BAD) {
if(portsock == CURL_SOCKET_BAD) {
error = SOCKERRNO;
continue;
}
@@ -978,11 +978,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* step 3, bind to a suitable local address */
/* Try binding the given address. */
if (bind(portsock, ai->ai_addr, ai->ai_addrlen)) {
if(bind(portsock, ai->ai_addr, ai->ai_addrlen)) {
/* It failed. Bind the address used for the control connection instead */
sslen = sizeof(ss);
if (getsockname(conn->sock[FIRSTSOCKET],
if(getsockname(conn->sock[FIRSTSOCKET],
(struct sockaddr *)sa, &sslen)) {
failf(data, "getsockname() failed: %s",
Curl_strerror(conn, SOCKERRNO) );
@@ -996,7 +996,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
else
((struct sockaddr_in6 *)sa)->sin6_port =0;
if (sslen > (socklen_t)sizeof(ss))
if(sslen > (socklen_t)sizeof(ss))
sslen = sizeof(ss);
if(bind(portsock, (struct sockaddr *)sa, sslen)) {
@@ -1018,7 +1018,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* step 4, listen on the socket */
if (listen(portsock, 1)) {
if(listen(portsock, 1)) {
failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO));
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
@@ -1054,7 +1054,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
break;
}
if (EPRT == fcmd) {
if(EPRT == fcmd) {
/*
* Two fine examples from RFC2428;
*
@@ -1070,11 +1070,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
return result;
break;
}
else if (PORT == fcmd) {
else if(PORT == fcmd) {
char *source = myhost;
char *dest = tmp;
if ((PORT == fcmd) && ai->ai_family != AF_INET)
if((PORT == fcmd) && ai->ai_family != AF_INET)
continue;
/* translate x.x.x.x to x,x,x,x */
@@ -1161,19 +1161,19 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(!addr) {
/* pick a suitable default here */
if (getsockname(conn->sock[FIRSTSOCKET],
if(getsockname(conn->sock[FIRSTSOCKET],
(struct sockaddr *)&sa, &sslen)) {
failf(data, "getsockname() failed: %s",
Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED;
}
if (sslen > (socklen_t)sizeof(sa))
if(sslen > (socklen_t)sizeof(sa))
sslen = sizeof(sa);
sa_filled_in = TRUE; /* the sa struct is filled in */
}
if (addr || sa_filled_in) {
if(addr || sa_filled_in) {
portsock = socket(AF_INET, SOCK_STREAM, 0);
if(CURL_SOCKET_BAD != portsock) {
@@ -1205,7 +1205,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
}
porttouse = ntohs(add.sin_port);
if ( listen(portsock, 1) < 0 ) {
if( listen(portsock, 1) < 0 ) {
failf(data, "listen(2) failed on socket");
return CURLE_FTP_PORT_FAILED;
}
@@ -1484,7 +1484,7 @@ static CURLcode ftp_state_post_mdtm(struct connectdata *conn)
/* Some servers return different sizes for different modes, and thus we
must set the proper type before we check the size */
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_TYPE);
if (result)
if(result)
return result;
}
else
@@ -1659,7 +1659,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
result = ftp_state_cwd(conn);
break;
case FTP_RETR_PREQUOTE:
if (ftp->transfer != FTPTRANSFER_BODY)
if(ftp->transfer != FTPTRANSFER_BODY)
state(conn, FTP_STOP);
else {
NBFTPSENDF(conn, "SIZE %s", ftpc->file);
@@ -1724,7 +1724,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
if(ptr) {
newport = (unsigned short)(num & 0xffff);
if (conn->bits.tunnel_proxy ||
if(conn->bits.tunnel_proxy ||
data->set.proxytype == CURLPROXY_SOCKS5 ||
data->set.proxytype == CURLPROXY_SOCKS4)
/* proxy tunnel -> use other host info because ip_addr_str is the
@@ -1759,7 +1759,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
* "227 Entering passive mode. 127,0,0,1,4,51"
*/
while(*str) {
if (6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
if(6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
&ip[0], &ip[1], &ip[2], &ip[3],
&port[0], &port[1]))
break;
@@ -1778,7 +1778,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n",
ip[0], ip[1], ip[2], ip[3],
conn->ip_addr_str);
if (conn->bits.tunnel_proxy ||
if(conn->bits.tunnel_proxy ||
data->set.proxytype == CURLPROXY_SOCKS5 ||
data->set.proxytype == CURLPROXY_SOCKS4)
/* proxy tunnel -> use other host info because ip_addr_str is the
@@ -1848,7 +1848,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
Curl_resolv_unlock(data, addr); /* we're done using this address */
if (result && ftpc->count1 == 0 && ftpcode == 229) {
if(result && ftpc->count1 == 0 && ftpcode == 229) {
infof(data, "got positive EPSV response, but can't connect. "
"Disabling EPSV\n");
/* disable it for next transfer */
@@ -1936,7 +1936,7 @@ static CURLcode ftp_state_port_resp(struct connectdata *conn,
if(ftpcode != 200) {
/* the command failed */
if (EPRT == fcmd) {
if(EPRT == fcmd) {
infof(data, "disabling EPRT usage\n");
conn->bits.ftp_use_eprt = FALSE;
}
@@ -2098,7 +2098,7 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn,
struct FTP *ftp = data->reqdata.proto.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if (data->set.max_filesize && (filesize > data->set.max_filesize)) {
if(data->set.max_filesize && (filesize > data->set.max_filesize)) {
failf(data, "Maximum file size exceeded");
return CURLE_FILESIZE_EXCEEDED;
}
@@ -2220,7 +2220,7 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
case FTP_REST:
default:
#ifdef CURL_FTP_HTTPSTYLE_HEAD
if (ftpcode == 350) {
if(ftpcode == 350) {
char buffer[24]= { "Accept-ranges: bytes\r\n" };
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buffer, 0);
if(result)
@@ -2231,7 +2231,7 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
break;
case FTP_RETR_REST:
if (ftpcode != 350) {
if(ftpcode != 350) {
failf(conn->data, "Couldn't use REST");
result = CURLE_FTP_COULDNT_USE_REST;
}
@@ -2497,7 +2497,7 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
530 User ... access denied
(the server denies to log the specified user) */
if (conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
if(conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
!conn->data->state.ftp_trying_alternative) {
/* Ok, USER failed. Let's try the supplied command. */
NBFTPSENDF(conn, "%s",
@@ -2721,7 +2721,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
break;
case FTP_CCC:
if (ftpcode < 500) {
if(ftpcode < 500) {
/* First shut down the SSL layer (note: this call will block) */
result = Curl_ssl_shutdown(conn, FIRSTSOCKET);
@@ -2947,8 +2947,8 @@ static CURLcode Curl_ftp_multi_statemach(struct connectdata *conn,
}
rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
0);
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
0);
if(rc == -1) {
failf(data, "select/poll error");
@@ -2980,8 +2980,8 @@ static CURLcode ftp_easy_statemach(struct connectdata *conn)
}
rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
(int)timeout_ms);
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
(int)timeout_ms);
if(rc == -1) {
failf(data, "select/poll error");
@@ -3024,7 +3024,7 @@ static CURLcode ftp_init(struct connectdata *conn)
/* no need to duplicate them, this connectdata struct won't change */
ftp->user = conn->user;
ftp->passwd = conn->passwd;
if (isBadFtpString(ftp->user) || isBadFtpString(ftp->passwd))
if(isBadFtpString(ftp->user) || isBadFtpString(ftp->passwd))
return CURLE_URL_MALFORMAT;
return CURLE_OK;
@@ -3066,7 +3066,7 @@ static CURLcode Curl_ftp_connect(struct connectdata *conn,
ftpc->response_time = 3600000; /* set default response time-out */
#ifndef CURL_DISABLE_HTTP
if (conn->bits.tunnel_proxy && conn->bits.httpproxy) {
if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
/* BLOCKING */
/* We want "seamless" FTP operations through HTTP proxy tunnel */
@@ -3159,7 +3159,7 @@ static CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status,
/* the connection stays alive fine even though this happened */
/* fall-through */
case CURLE_OK: /* doesn't affect the control connection's status */
if (!premature) {
if(!premature) {
ftpc->ctl_valid = was_ctl_valid;
break;
}
@@ -3330,15 +3330,15 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
CURLcode result;
item = quote;
while (item) {
if (item->data) {
while(item) {
if(item->data) {
FTPSENDF(conn, "%s", item->data);
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if (result)
if(result)
return result;
if (ftpcode >= 400) {
if(ftpcode >= 400) {
failf(conn->data, "QUOT string not accepted: %s", item->data);
return CURLE_QUOTE_ERROR;
}
@@ -3377,7 +3377,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
CURLcode result;
char want = (char)(ascii?'A':'I');
if (ftpc->transfertype == want) {
if(ftpc->transfertype == want) {
state(conn, newstate);
return ftp_state_type_resp(conn, 200, newstate);
}
@@ -3493,7 +3493,7 @@ static CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
if(data->set.upload) {
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_STOR_TYPE);
if (result)
if(result)
return result;
}
else {
@@ -3511,24 +3511,24 @@ static CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
/* But only if a body transfer was requested. */
if(ftp->transfer == FTPTRANSFER_BODY) {
result = ftp_nb_type(conn, 1, FTP_LIST_TYPE);
if (result)
if(result)
return result;
}
/* otherwise just fall through */
}
else {
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_RETR_TYPE);
if (result)
if(result)
return result;
}
}
result = ftp_easy_statemach(conn);
}
if(ftp->transfer != FTPTRANSFER_BODY)
if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY))
/* no data to transfer. FIX: it feels like a kludge to have this here
too! */
result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
/* end of transfer */
DEBUGF(infof(data, "DO-MORE phase ends with %d\n", result));
@@ -3612,7 +3612,7 @@ static CURLcode Curl_ftp(struct connectdata *conn, bool *done)
return retcode;
retcode = ftp_parse_url_path(conn);
if (retcode)
if(retcode)
return retcode;
retcode = ftp_regular_transfer(conn, done);
@@ -3809,7 +3809,7 @@ static CURLcode Curl_ftp_disconnect(struct connectdata *conn)
if(ftpc->entrypath) {
struct SessionHandle *data = conn->data;
if (data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
data->state.most_recent_ftp_entrypath = NULL;
}
free(ftpc->entrypath);
@@ -3922,25 +3922,25 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
}
else {
/* parse the URL path into separate path components */
while ((slash_pos = strchr(cur_pos, '/')) != NULL) {
while((slash_pos = strchr(cur_pos, '/')) != NULL) {
/* 1 or 0 to indicate absolute directory */
bool absolute_dir = (bool)((cur_pos - data->reqdata.path > 0) &&
(ftpc->dirdepth == 0));
/* 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
CWD requires a parameter and a non-existant parameter a) doesn't
work on many servers and b) has no effect on the others. */
int len = (int)(slash_pos - cur_pos + absolute_dir);
ftpc->dirs[ftpc->dirdepth] =
curl_easy_unescape(conn->data, cur_pos - absolute_dir, len, NULL);
if (!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
if(!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
failf(data, "no memory");
freedirs(ftpc);
return CURLE_OUT_OF_MEMORY;
}
if (isBadFtpString(ftpc->dirs[ftpc->dirdepth])) {
if(isBadFtpString(ftpc->dirs[ftpc->dirdepth])) {
free(ftpc->dirs[ftpc->dirdepth]);
freedirs(ftpc);
return CURLE_URL_MALFORMAT;
@@ -3975,7 +3975,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
failf(data, "no memory");
return CURLE_OUT_OF_MEMORY;
}
if (isBadFtpString(ftpc->file)) {
if(isBadFtpString(ftpc->file)) {
freedirs(ftpc);
return CURLE_URL_MALFORMAT;
}
@@ -4117,7 +4117,7 @@ static CURLcode Curl_ftp_setup_connection(struct connectdata * conn)
/* Unless we have asked to tunnel ftp operations through the proxy, we
switch and use HTTP operations only */
#ifndef CURL_DISABLE_HTTP
if (conn->handler == &Curl_handler_ftp)
if(conn->handler == &Curl_handler_ftp)
conn->handler = &Curl_handler_ftp_proxy;
else {
#ifdef USE_SSL
@@ -4140,10 +4140,10 @@ static CURLcode Curl_ftp_setup_connection(struct connectdata * conn)
* we'll try to get now! */
type = strstr(data->reqdata.path, ";type=");
if (!type)
if(!type)
type = strstr(conn->host.rawalloc, ";type=");
if (type) {
if(type) {
*type = 0; /* it was in the middle of the hostname */
command = (char) toupper((int) type[6]);

View File

@@ -46,13 +46,13 @@ char *GetEnv(const char *variable)
char env[MAX_PATH]; /* MAX_PATH is from windef.h */
char *temp = getenv(variable);
env[0] = '\0';
if (temp != NULL)
if(temp != NULL)
ExpandEnvironmentStrings(temp, env, sizeof(env));
return (env[0] != '\0')?strdup(env):NULL;
#else
char *env = getenv(variable);
#ifdef VMS
if (env && strcmp("HOME",variable) == 0)
if(env && strcmp("HOME",variable) == 0)
env = decc$translate_vms(env);
#endif
return (env && env[0])?strdup(env):NULL;

View File

@@ -58,7 +58,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
info->httpversion=0;
info->filetime=-1; /* -1 is an illegal time and thus means unknown */
if (info->contenttype)
if(info->contenttype)
free(info->contenttype);
info->contenttype = NULL;
@@ -214,7 +214,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
/* determine if ssl */
if(c->ssl[FIRSTSOCKET].use) {
/* use the SSL context */
if (!Curl_ssl_check_cxn(c))
if(!Curl_ssl_check_cxn(c))
*param_longp = -1; /* FIN received */
}
/* Minix 3.1 doesn't support any flags on recv; just assume socket is OK */

View File

@@ -97,7 +97,7 @@ int Curl_gtls_init(void)
static int _Curl_gtls_init(void)
{
int ret = 1;
if (!gtls_inited) {
if(!gtls_inited) {
ret = gnutls_global_init()?0:1;
#ifdef GTLSDEBUG
gnutls_global_set_log_function(tls_log_func);
@@ -110,7 +110,7 @@ static int _Curl_gtls_init(void)
int Curl_gtls_cleanup(void)
{
if (gtls_inited)
if(gtls_inited)
gnutls_global_deinit();
return 1;
}
@@ -148,7 +148,7 @@ static CURLcode handshake(struct connectdata *conn,
{
struct SessionHandle *data = conn->data;
int rc;
if (!gtls_inited)
if(!gtls_inited)
_Curl_gtls_init();
do {
rc = gnutls_handshake(session);
@@ -198,7 +198,7 @@ static CURLcode handshake(struct connectdata *conn,
break;
} while(1);
if (rc < 0) {
if(rc < 0) {
failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
}
@@ -244,7 +244,7 @@ Curl_gtls_connect(struct connectdata *conn,
void *ssl_sessionid;
size_t ssl_idsize;
if (!gtls_inited) _Curl_gtls_init();
if(!gtls_inited) _Curl_gtls_init();
/* GnuTLS only supports TLSv1 (and SSLv3?) */
if(data->set.ssl.version == CURL_SSLVERSION_SSLv2) {
failf(data, "GnuTLS does not support SSLv2");
@@ -269,7 +269,7 @@ Curl_gtls_connect(struct connectdata *conn,
if(rc < 0) {
infof(data, "error reading ca cert file %s (%s)\n",
data->set.ssl.CAfile, gnutls_strerror(rc));
if (data->set.ssl.verifypeer)
if(data->set.ssl.verifypeer)
return CURLE_SSL_CACERT_BADFILE;
}
else
@@ -365,14 +365,14 @@ Curl_gtls_connect(struct connectdata *conn,
gnutls_certificate_set_verify_limits(). */
rc = gnutls_certificate_verify_peers2(session, &verify_status);
if (rc < 0) {
if(rc < 0) {
failf(data, "server cert verify failed: %d", rc);
return CURLE_SSL_CONNECT_ERROR;
}
/* verify_status is a bitmask of gnutls_certificate_status bits */
if(verify_status & GNUTLS_CERT_INVALID) {
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
failf(data, "server certificate verification failed. CAfile: %s",
data->set.ssl.CAfile?data->set.ssl.CAfile:"none");
return CURLE_SSL_CACERT;
@@ -409,7 +409,7 @@ Curl_gtls_connect(struct connectdata *conn,
rc = gnutls_x509_crt_check_hostname(x509_cert, conn->host.name);
if(!rc) {
if (data->set.ssl.verifyhost > 1) {
if(data->set.ssl.verifyhost > 1) {
failf(data, "SSL: certificate subject name (%s) does not match "
"target host name '%s'", certbuf, conn->host.dispname);
gnutls_x509_crt_deinit(x509_cert);
@@ -431,7 +431,7 @@ Curl_gtls_connect(struct connectdata *conn,
}
if(clock < time(NULL)) {
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
failf(data, "server certificate expiration date has passed.");
return CURLE_PEER_FAILED_VERIFICATION;
}
@@ -449,7 +449,7 @@ Curl_gtls_connect(struct connectdata *conn,
}
if(clock > time(NULL)) {
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
failf(data, "server certificate not activated yet.");
return CURLE_PEER_FAILED_VERIFICATION;
}
@@ -670,12 +670,12 @@ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */
}
*wouldblock = FALSE;
if (!ret) {
if(!ret) {
failf(conn->data, "Peer closed the TLS connection");
return -1;
}
if (ret < 0) {
if(ret < 0) {
failf(conn->data, "GnuTLS recv error (%d): %s",
(int)ret, gnutls_strerror(ret));
return -1;

View File

@@ -39,7 +39,7 @@ hash_element_dtor(void *user, void *element)
struct curl_hash *h = (struct curl_hash *) user;
struct curl_hash_element *e = (struct curl_hash_element *) element;
if (e->key)
if(e->key)
free(e->key);
h->dtor(e->ptr);
@@ -57,7 +57,7 @@ Curl_hash_init(struct curl_hash *h,
{
int i;
if (!slots || !hfunc || !comparator ||!dtor) {
if(!slots || !hfunc || !comparator ||!dtor) {
return 1; /* failure */
}
@@ -92,12 +92,12 @@ Curl_hash_alloc(int slots,
{
struct curl_hash *h;
if (!slots || !hfunc || !comparator ||!dtor) {
if(!slots || !hfunc || !comparator ||!dtor) {
return NULL; /* failure */
}
h = (struct curl_hash *) malloc(sizeof(struct curl_hash));
if (h) {
if(h) {
if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) {
/* failure */
free(h);
@@ -148,14 +148,14 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
for (le = l->head; le; le = le->next) {
he = (struct curl_hash_element *) le->ptr;
if (h->comp_func(he->key, he->key_len, key, key_len)) {
if(h->comp_func(he->key, he->key_len, key, key_len)) {
h->dtor(p); /* remove the NEW entry */
return he->ptr; /* return the EXISTING entry */
}
}
he = mk_hash_element(key, key_len, p);
if (he) {
if(he) {
if(Curl_llist_insert_next(l, l->tail, he)) {
++h->size;
return p; /* return the new entry */
@@ -182,7 +182,7 @@ int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
for (le = l->head; le; le = le->next) {
he = le->ptr;
if (h->comp_func(he->key, he->key_len, key, key_len)) {
if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *) h);
return 0;
}
@@ -199,7 +199,7 @@ Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
for (le = l->head; le; le = le->next) {
he = le->ptr;
if (h->comp_func(he->key, he->key_len, key, key_len)) {
if(h->comp_func(he->key, he->key_len, key, key_len)) {
return he->ptr;
}
}
@@ -254,7 +254,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
struct curl_hash_element *he = le->ptr;
lnext = le->next;
/* ask the callback function if we shall remove this entry or not */
if (comp(user, he->ptr)) {
if(comp(user, he->ptr)) {
Curl_llist_remove(list, le, (void *) h);
--h->size; /* one less entry in the hash now */
}
@@ -266,7 +266,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
void
Curl_hash_destroy(struct curl_hash *h)
{
if (!h)
if(!h)
return;
Curl_hash_clean(h);
@@ -279,7 +279,7 @@ size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num)
const char *end = key_str + key_length;
unsigned long h = 5381;
while (key_str < end) {
while(key_str < end) {
h += h << 5;
h ^= (unsigned long) *key_str++;
}
@@ -292,7 +292,7 @@ size_t Curl_str_key_compare(void*k1, size_t key1_len, void*k2, size_t key2_len)
char *key1 = (char *)k1;
char *key2 = (char *)k2;
if (key1_len == key2_len &&
if(key1_len == key2_len &&
*key1 == *key2 &&
memcmp(key1, key2, key1_len) == 0) {
return 1;
@@ -309,7 +309,7 @@ void Curl_hash_print(struct curl_hash *h,
struct curl_llist_element *le;
struct curl_llist *list;
struct curl_hash_element *he;
if (!h)
if(!h)
return;
fprintf(stderr, "=Hash dump=\n");

View File

@@ -244,7 +244,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
timeout = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve timeout */
/* Wait for the name resolve query to complete. */
while (1) {
while(1) {
struct timeval *tvp, tv, store;
struct timeval now = Curl_tvnow();
long timediff;
@@ -262,7 +262,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
timediff = Curl_tvdiff(Curl_tvnow(), now); /* spent time */
timeout -= timediff?timediff:1; /* always deduct at least 1 */
if (timeout < 0) {
if(timeout < 0) {
/* our timeout, so we cancel the ares operation */
ares_cancel(data->state.areschannel);
break;
@@ -316,7 +316,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
*waitp = FALSE;
if (in != CURL_INADDR_NONE) {
if(in != CURL_INADDR_NONE) {
/* This is a dotted IP address 123.123.123.123-style */
return Curl_ip2addr(in, hostname, port);
}

View File

@@ -130,7 +130,7 @@ static void freednsentry(void *freethis);
*/
void Curl_global_host_cache_init(void)
{
if (!host_cache_initialized) {
if(!host_cache_initialized) {
Curl_hash_init(&hostname_cache, 7, Curl_hash_str, Curl_str_key_compare,
freednsentry);
host_cache_initialized = 1;
@@ -150,7 +150,7 @@ struct curl_hash *Curl_global_host_cache_get(void)
*/
void Curl_global_host_cache_dtor(void)
{
if (host_cache_initialized) {
if(host_cache_initialized) {
Curl_hash_clean(&hostname_cache);
host_cache_initialized = 0;
}
@@ -218,7 +218,7 @@ hostcache_timestamp_remove(void *datap, void *hc)
(struct hostcache_prune_data *) datap;
struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc;
if ((data->now - c->timestamp < data->cache_timeout) ||
if((data->now - c->timestamp < data->cache_timeout) ||
c->inuse) {
/* please don't remove */
return 0;
@@ -284,7 +284,7 @@ remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns)
time(&user.now);
user.cache_timeout = data->set.dns_cache_timeout;
if ( !hostcache_timestamp_remove(&user,dns) )
if( !hostcache_timestamp_remove(&user,dns) )
return 0;
/* ok, we do need to clear the cache. although we need to remove just a
@@ -336,13 +336,13 @@ Curl_cache_addr(struct SessionHandle *data,
/* Create an entry id, based upon the hostname and port */
entry_id = create_hostcache_id(hostname, port);
/* If we can't create the entry id, fail */
if (!entry_id)
if(!entry_id)
return NULL;
entry_len = strlen(entry_id);
/* Create a new cache entry */
dns = (struct Curl_dns_entry *) calloc(sizeof(struct Curl_dns_entry), 1);
if (!dns) {
if(!dns) {
free(entry_id);
return NULL;
}
@@ -407,7 +407,7 @@ int Curl_resolv(struct connectdata *conn,
/* this allows us to time-out from the name resolver, as the timeout
will generate a signal and we will siglongjmp() from that here */
if(!data->set.no_signal) {
if (sigsetjmp(curl_jmpenv, 1)) {
if(sigsetjmp(curl_jmpenv, 1)) {
/* this is coming from a siglongjmp() */
failf(data, "name lookup timed out");
return CURLRESOLV_ERROR;
@@ -418,7 +418,7 @@ int Curl_resolv(struct connectdata *conn,
/* Create an entry id, based upon the hostname and port */
entry_id = create_hostcache_id(hostname, port);
/* If we can't create the entry id, fail */
if (!entry_id)
if(!entry_id)
return CURLRESOLV_ERROR;
entry_len = strlen(entry_id);
@@ -437,12 +437,12 @@ int Curl_resolv(struct connectdata *conn,
/* See whether the returned entry is stale. Deliberately done after the
locked block */
if ( remove_entry_if_stale(data,dns) )
if( remove_entry_if_stale(data,dns) )
dns = NULL; /* the memory deallocation is being handled by the hash */
rc = CURLRESOLV_ERROR; /* default to failure */
if (!dns) {
if(!dns) {
/* The entry was not in the cache. Resolve it to IP address */
Curl_addrinfo *addr;
@@ -458,7 +458,7 @@ int Curl_resolv(struct connectdata *conn,
resolve call */
addr = Curl_getaddrinfo(conn, hostname, port, &respwait);
if (!addr) {
if(!addr) {
if(respwait) {
/* the response to our resolve call will come asynchronously at
a later time, good or bad */

View File

@@ -289,7 +289,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
#else
h = gethostbyname(hostname);
#endif
if (!h)
if(!h)
infof(conn->data, "gethostbyname(2) failed for %s\n", hostname);
#endif /*HAVE_GETHOSTBYNAME_R */
}
@@ -297,7 +297,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
if(h) {
ai = Curl_he2ai(h, port);
if (buf) /* used a *_r() function */
if(buf) /* used a *_r() function */
free(buf);
}

View File

@@ -185,7 +185,7 @@ bool Curl_ipvalid(struct SessionHandle *data)
if(data->set.ip_version == CURL_IPRESOLVE_V6) {
/* see if we have an IPv6 stack */
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
if (s == CURL_SOCKET_BAD)
if(s == CURL_SOCKET_BAD)
/* an ipv6 address was requested and we can't get/use one */
return FALSE;
sclose(s);
@@ -204,7 +204,7 @@ static void dump_addrinfo(struct connectdata *conn, const struct addrinfo *ai)
printf(" fam %2d, CNAME %s, ",
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
if (Curl_printable_address(ai, buf, sizeof(buf)))
if(Curl_printable_address(ai, buf, sizeof(buf)))
printf("%s\n", buf);
else
printf("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
@@ -241,7 +241,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
/* see if we have an IPv6 stack */
s = socket(PF_INET6, SOCK_DGRAM, 0);
if (s == CURL_SOCKET_BAD) {
if(s == CURL_SOCKET_BAD) {
/* Some non-IPv6 stacks have been found to make very slow name resolves
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
* the stack seems to be a non-ipv6 one. */
@@ -290,7 +290,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
sbufptr=sbuf;
}
error = getaddrinfo(hostname, sbufptr, &hints, &res);
if (error) {
if(error) {
infof(data, "getaddrinfo(3) failed for %s:%d\n", hostname, port);
return NULL;
}

View File

@@ -110,18 +110,18 @@ static bool init_resolve_thread(struct connectdata *conn,
defined(DEBUG_THREADING_GETADDRINFO)
/* If this is defined, provide tracing */
#define TRACE(args) \
do { trace_it("%u: ", __LINE__); trace_it args; } while (0)
do { trace_it("%u: ", __LINE__); trace_it args; } while(0)
static void trace_it (const char *fmt, ...)
{
static int do_trace = -1;
va_list args;
if (do_trace == -1) {
if(do_trace == -1) {
const char *env = getenv("CURL_TRACE");
do_trace = (env && atoi(env) > 0);
}
if (!do_trace)
if(!do_trace)
return;
va_start (args, fmt);
vfprintf (stderr, fmt, args);
@@ -141,7 +141,7 @@ static void dump_addrinfo (struct connectdata *conn, const struct addrinfo *ai)
trace_it(" fam %2d, CNAME %s, ",
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
if (Curl_printable_address(ai, buf, sizeof(buf)))
if(Curl_printable_address(ai, buf, sizeof(buf)))
trace_it("%s\n", buf);
else
trace_it("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
@@ -179,13 +179,13 @@ struct thread_sync_data {
static
void destroy_thread_sync_data(struct thread_sync_data * tsd)
{
if (tsd->hostname)
if(tsd->hostname)
free(tsd->hostname);
if (tsd->event_terminate)
if(tsd->event_terminate)
CloseHandle(tsd->event_terminate);
if (tsd->mutex_terminate)
if(tsd->mutex_terminate)
CloseHandle(tsd->mutex_terminate);
if (tsd->mutex_waiting)
if(tsd->mutex_waiting)
CloseHandle(tsd->mutex_waiting);
memset(tsd,0,sizeof(*tsd));
}
@@ -199,21 +199,21 @@ BOOL init_thread_sync_data(struct thread_data * td,
HANDLE curr_proc = GetCurrentProcess();
memset(tsd, 0, sizeof(*tsd));
if (!DuplicateHandle(curr_proc, td->mutex_waiting,
if(!DuplicateHandle(curr_proc, td->mutex_waiting,
curr_proc, &tsd->mutex_waiting, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
/* failed to duplicate the mutex, no point in continuing */
destroy_thread_sync_data(tsd);
return FALSE;
}
if (!DuplicateHandle(curr_proc, td->mutex_terminate,
if(!DuplicateHandle(curr_proc, td->mutex_terminate,
curr_proc, &tsd->mutex_terminate, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
/* failed to duplicate the mutex, no point in continuing */
destroy_thread_sync_data(tsd);
return FALSE;
}
if (!DuplicateHandle(curr_proc, td->event_terminate,
if(!DuplicateHandle(curr_proc, td->event_terminate,
curr_proc, &tsd->event_terminate, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
/* failed to duplicate the event, no point in continuing */
@@ -224,7 +224,7 @@ BOOL init_thread_sync_data(struct thread_data * td,
* thread during gethostbyname execution.
*/
tsd->hostname = strdup(hostname);
if (!tsd->hostname) {
if(!tsd->hostname) {
/* Memory allocation failed */
destroy_thread_sync_data(tsd);
return FALSE;
@@ -237,15 +237,15 @@ static
BOOL acquire_thread_sync(struct thread_sync_data * tsd)
{
/* is the thread initiator still waiting for us ? */
if (WaitForSingleObject(tsd->mutex_waiting, 0) == WAIT_TIMEOUT) {
if(WaitForSingleObject(tsd->mutex_waiting, 0) == WAIT_TIMEOUT) {
/* yes, it is */
/* Waiting access to event_terminate */
if (WaitForSingleObject(tsd->mutex_terminate, INFINITE) != WAIT_OBJECT_0) {
if(WaitForSingleObject(tsd->mutex_terminate, INFINITE) != WAIT_OBJECT_0) {
/* Something went wrong - now just ignoring */
}
else {
if (WaitForSingleObject(tsd->event_terminate, 0) != WAIT_TIMEOUT) {
if(WaitForSingleObject(tsd->event_terminate, 0) != WAIT_TIMEOUT) {
/* Parent thread signaled us to terminate.
* This means that all data in conn->async is now destroyed
* and we cannot use it.
@@ -287,7 +287,7 @@ static unsigned __stdcall gethostbyname_thread (void *arg)
*/
struct thread_sync_data tsd = { 0,0,0,NULL };
if (!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
if(!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
/* thread synchronization data initialization failed */
return (unsigned)-1;
}
@@ -302,11 +302,11 @@ static unsigned __stdcall gethostbyname_thread (void *arg)
he = gethostbyname (tsd.hostname);
/* is parent thread waiting for us and are we able to access conn members? */
if (acquire_thread_sync(&tsd)) {
if(acquire_thread_sync(&tsd)) {
/* Mark that we have obtained the information, and that we are calling
* back with it. */
SetEvent(td->event_resolved);
if (he) {
if(he) {
rc = Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he);
}
else {
@@ -348,7 +348,7 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
*/
struct thread_sync_data tsd = { 0,0,0,NULL };
if (!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
if(!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
/* thread synchronization data initialization failed */
return -1;
}
@@ -365,12 +365,12 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
rc = getaddrinfo(tsd.hostname, service, &hints, &res);
/* is parent thread waiting for us and are we able to access conn members? */
if (acquire_thread_sync(&tsd)) {
if(acquire_thread_sync(&tsd)) {
/* Mark that we have obtained the information, and that we are calling
back with it. */
SetEvent(td->event_resolved);
if (rc == 0) {
if(rc == 0) {
#ifdef DEBUG_THREADING_GETADDRINFO
dump_addrinfo (conn, res);
#endif
@@ -397,16 +397,16 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
*/
void Curl_destroy_thread_data (struct Curl_async *async)
{
if (async->hostname)
if(async->hostname)
free(async->hostname);
if (async->os_specific) {
if(async->os_specific) {
struct thread_data *td = (struct thread_data*) async->os_specific;
curl_socket_t sock = td->dummy_sock;
if (td->mutex_terminate && td->event_terminate) {
if(td->mutex_terminate && td->event_terminate) {
/* Signaling resolver thread to terminate */
if (WaitForSingleObject(td->mutex_terminate, INFINITE) == WAIT_OBJECT_0) {
if(WaitForSingleObject(td->mutex_terminate, INFINITE) == WAIT_OBJECT_0) {
SetEvent(td->event_terminate);
ReleaseMutex(td->mutex_terminate);
}
@@ -415,24 +415,24 @@ void Curl_destroy_thread_data (struct Curl_async *async)
}
}
if (td->mutex_terminate)
if(td->mutex_terminate)
CloseHandle(td->mutex_terminate);
if (td->event_terminate)
if(td->event_terminate)
CloseHandle(td->event_terminate);
if (td->event_thread_started)
if(td->event_thread_started)
CloseHandle(td->event_thread_started);
if (sock != CURL_SOCKET_BAD)
if(sock != CURL_SOCKET_BAD)
sclose(sock);
/* destroy the synchronization objects */
if (td->mutex_waiting)
if(td->mutex_waiting)
CloseHandle(td->mutex_waiting);
td->mutex_waiting = NULL;
if (td->event_resolved)
if(td->event_resolved)
CloseHandle(td->event_resolved);
if (td->thread_hnd)
if(td->thread_hnd)
CloseHandle(td->thread_hnd);
free(async->os_specific);
@@ -454,14 +454,14 @@ static bool init_resolve_thread (struct connectdata *conn,
struct thread_data *td = calloc(sizeof(*td), 1);
HANDLE thread_and_event[2] = {0};
if (!td) {
if(!td) {
SET_ERRNO(ENOMEM);
return FALSE;
}
Curl_safefree(conn->async.hostname);
conn->async.hostname = strdup(hostname);
if (!conn->async.hostname) {
if(!conn->async.hostname) {
free(td);
SET_ERRNO(ENOMEM);
return FALSE;
@@ -478,7 +478,7 @@ static bool init_resolve_thread (struct connectdata *conn,
* still waiting, and take initial ownership.
*/
td->mutex_waiting = CreateMutex(NULL, TRUE, NULL);
if (td->mutex_waiting == NULL) {
if(td->mutex_waiting == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@@ -488,7 +488,7 @@ static bool init_resolve_thread (struct connectdata *conn,
* done resolving. Do not signal it.
*/
td->event_resolved = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_resolved == NULL) {
if(td->event_resolved == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@@ -497,7 +497,7 @@ static bool init_resolve_thread (struct connectdata *conn,
* between us and resolver thread.
*/
td->mutex_terminate = CreateMutex(NULL, FALSE, NULL);
if (td->mutex_terminate == NULL) {
if(td->mutex_terminate == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@@ -505,7 +505,7 @@ static bool init_resolve_thread (struct connectdata *conn,
/* Create the event used to signal thread that it should terminate.
*/
td->event_terminate = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_terminate == NULL) {
if(td->event_terminate == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@@ -513,7 +513,7 @@ static bool init_resolve_thread (struct connectdata *conn,
/* Create the event used by thread to inform it has initialized its own data.
*/
td->event_thread_started = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_thread_started == NULL) {
if(td->event_thread_started == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@@ -535,7 +535,7 @@ static bool init_resolve_thread (struct connectdata *conn,
(void) hints;
#endif
if (!td->thread_hnd) {
if(!td->thread_hnd) {
#ifdef _WIN32_WCE
TRACE(("CreateThread() failed; %s\n", Curl_strerror(conn, ERRNO)));
#else
@@ -549,7 +549,7 @@ static bool init_resolve_thread (struct connectdata *conn,
*/
thread_and_event[0] = td->thread_hnd;
thread_and_event[1] = td->event_thread_started;
if (WaitForMultipleObjects(sizeof(thread_and_event) /
if(WaitForMultipleObjects(sizeof(thread_and_event) /
sizeof(thread_and_event[0]),
(const HANDLE*)thread_and_event, FALSE,
INFINITE) == WAIT_FAILED) {
@@ -608,9 +608,9 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
td->event_resolved = NULL;
/* has the resolver thread succeeded in resolving our query ? */
if (status == WAIT_OBJECT_0) {
if(status == WAIT_OBJECT_0) {
/* wait for the thread to exit, it's in the callback sequence */
if (WaitForSingleObject(td->thread_hnd, 5000) == WAIT_TIMEOUT) {
if(WaitForSingleObject(td->thread_hnd, 5000) == WAIT_TIMEOUT) {
TerminateThread(td->thread_hnd, 0);
conn->async.done = TRUE;
td->thread_status = (DWORD)-1;
@@ -640,9 +640,9 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
rc = CURLE_OK;
if (!conn->async.dns) {
if(!conn->async.dns) {
/* a name was not resolved */
if (td->thread_status == CURLE_OUT_OF_MEMORY) {
if(td->thread_status == CURLE_OUT_OF_MEMORY) {
rc = CURLE_OUT_OF_MEMORY;
failf(data, "Could not resolve host: %s", curl_easy_strerror(rc));
}
@@ -658,7 +658,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
rc = CURLE_COULDNT_RESOLVE_HOST;
}
}
else if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) {
else if(td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) {
failf(data, "Resolving host timed out: %s", conn->host.name);
rc = CURLE_OPERATION_TIMEDOUT;
}
@@ -684,10 +684,10 @@ CURLcode Curl_is_resolved(struct connectdata *conn,
{
*entry = NULL;
if (conn->async.done) {
if(conn->async.done) {
/* we're done */
Curl_destroy_thread_data(&conn->async);
if (!conn->async.dns) {
if(!conn->async.dns) {
TRACE(("Curl_is_resolved(): CURLE_COULDNT_RESOLVE_HOST\n"));
return CURLE_COULDNT_RESOLVE_HOST;
}
@@ -704,7 +704,7 @@ int Curl_resolv_getsock(struct connectdata *conn,
const struct thread_data *td =
(const struct thread_data *) conn->async.os_specific;
if (td && td->dummy_sock != CURL_SOCKET_BAD) {
if(td && td->dummy_sock != CURL_SOCKET_BAD) {
if(numsocks) {
/* return one socket waiting for writable, even though this is just
a dummy */
@@ -731,12 +731,12 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
*waitp = 0; /* don't wait, we act synchronously */
in = inet_addr(hostname);
if (in != CURL_INADDR_NONE)
if(in != CURL_INADDR_NONE)
/* This is a dotted IP address 123.123.123.123-style */
return Curl_ip2addr(in, hostname, port);
/* fire up a new resolver thread! */
if (init_resolve_thread(conn, hostname, port, NULL)) {
if(init_resolve_thread(conn, hostname, port, NULL)) {
*waitp = TRUE; /* please wait for the response */
return NULL;
}
@@ -746,7 +746,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
hostname, Curl_strerror(conn, ERRNO));
h = gethostbyname(hostname);
if (!h) {
if(!h) {
infof(data, "gethostbyname(2) failed for %s:%d; %s\n",
hostname, port, Curl_strerror(conn, SOCKERRNO));
return NULL;
@@ -775,7 +775,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
/* see if we have an IPv6 stack */
s = socket(PF_INET6, SOCK_DGRAM, 0);
if (s == CURL_SOCKET_BAD) {
if(s == CURL_SOCKET_BAD) {
/* Some non-IPv6 stacks have been found to make very slow name resolves
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
* the stack seems to be a non-ipv6 one. */
@@ -813,7 +813,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
itoa(port, sbuf, 10);
/* fire up a new resolver thread! */
if (init_resolve_thread(conn, hostname, port, &hints)) {
if(init_resolve_thread(conn, hostname, port, &hints)) {
*waitp = TRUE; /* please wait for the response */
return NULL;
}
@@ -823,7 +823,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
hostname, Curl_strerror(conn, ERRNO));
error = getaddrinfo(hostname, sbuf, &hints, &res);
if (error) {
if(error) {
infof(data, "getaddrinfo() failed for %s:%d; %s\n",
hostname, port, Curl_strerror(conn, SOCKERRNO));
return NULL;

View File

@@ -385,7 +385,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if(pickhost || pickproxy) {
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
if (!data->reqdata.newurl)
if(!data->reqdata.newurl)
return CURLE_OUT_OF_MEMORY;
if((data->set.httpreq != HTTPREQ_GET) &&
@@ -407,12 +407,12 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if((data->set.httpreq != HTTPREQ_GET) &&
(data->set.httpreq != HTTPREQ_HEAD)) {
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
if (!data->reqdata.newurl)
if(!data->reqdata.newurl)
return CURLE_OUT_OF_MEMORY;
data->state.authhost.done = TRUE;
}
}
if (Curl_http_should_fail(conn)) {
if(Curl_http_should_fail(conn)) {
failf (data, "The requested URL returned error: %d",
data->reqdata.keep.httpcode);
code = CURLE_HTTP_RETURNED_ERROR;
@@ -475,7 +475,7 @@ Curl_http_output_auth(struct connectdata *conn,
authproxy->picked = authproxy->want;
/* Send proxy authentication header if needed */
if (conn->bits.httpproxy &&
if(conn->bits.httpproxy &&
(conn->bits.tunnel_proxy == proxytunnel)) {
#ifdef HAVE_GSSAPI
if((authproxy->picked == CURLAUTH_GSSNEGOTIATE) &&
@@ -483,7 +483,7 @@ Curl_http_output_auth(struct connectdata *conn,
!GSS_ERROR(data->state.negotiate.status)) {
auth="GSS-Negotiate";
result = Curl_output_negotiate(conn, TRUE);
if (result)
if(result)
return result;
authproxy->done = TRUE;
}
@@ -552,7 +552,7 @@ Curl_http_output_auth(struct connectdata *conn,
!GSS_ERROR(data->state.negotiate.status)) {
auth="GSS-Negotiate";
result = Curl_output_negotiate(conn, FALSE);
if (result)
if(result)
return result;
authhost->done = TRUE;
}
@@ -627,7 +627,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
const char *start;
struct auth *authp;
if (httpcode == 407) {
if(httpcode == 407) {
start = header+strlen("Proxy-authenticate:");
availp = &data->info.proxyauthavail;
authp = &data->state.authproxy;
@@ -652,14 +652,14 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
*/
#ifdef HAVE_GSSAPI
if (checkprefix("GSS-Negotiate", start) ||
if(checkprefix("GSS-Negotiate", start) ||
checkprefix("Negotiate", start)) {
*availp |= CURLAUTH_GSSNEGOTIATE;
authp->avail |= CURLAUTH_GSSNEGOTIATE;
if(authp->picked == CURLAUTH_GSSNEGOTIATE) {
/* if exactly this is wanted, go */
int neg = Curl_input_negotiate(conn, (bool)(httpcode == 407), start);
if (neg == 0) {
if(neg == 0) {
data->reqdata.newurl = strdup(data->change.url);
data->state.authproblem = (data->reqdata.newurl == NULL);
}
@@ -758,16 +758,16 @@ int Curl_http_should_fail(struct connectdata *conn)
** If we haven't been asked to fail on error,
** don't fail.
*/
if (!data->set.http_fail_on_error)
if(!data->set.http_fail_on_error)
return 0;
/*
** Any code < 400 is never terminal.
*/
if (k->httpcode < 400)
if(k->httpcode < 400)
return 0;
if (data->reqdata.resume_from &&
if(data->reqdata.resume_from &&
(data->set.httpreq==HTTPREQ_GET) &&
(k->httpcode == 416)) {
/* "Requested Range Not Satisfiable", just proceed and
@@ -779,7 +779,7 @@ int Curl_http_should_fail(struct connectdata *conn)
** Any code >= 400 that's not 401 or 407 is always
** a terminal error
*/
if ((k->httpcode != 401) &&
if((k->httpcode != 401) &&
(k->httpcode != 407))
return 1;
@@ -932,6 +932,7 @@ CURLcode add_buffer_send(send_buffer *in,
struct HTTP *http = conn->data->reqdata.proto.http;
size_t sendsize;
curl_socket_t sockfd;
size_t headersize;
DEBUGASSERT(socketindex <= SECONDARYSOCKET);
@@ -943,17 +944,20 @@ CURLcode add_buffer_send(send_buffer *in,
ptr = in->buffer;
size = in->size_used;
headersize = size - included_body_bytes; /* the initial part that isn't body
is header */
DEBUGASSERT(size > included_body_bytes);
#ifdef CURL_DOES_CONVERSIONS
if(size - included_body_bytes > 0) {
res = Curl_convert_to_network(conn->data, ptr, size - included_body_bytes);
/* Curl_convert_to_network calls failf if unsuccessful */
if(res != CURLE_OK) {
/* conversion failed, free memory and return to the caller */
if(in->buffer)
free(in->buffer);
free(in);
return res;
}
res = Curl_convert_to_network(conn->data, ptr, headersize);
/* Curl_convert_to_network calls failf if unsuccessful */
if(res != CURLE_OK) {
/* conversion failed, free memory and return to the caller */
if(in->buffer)
free(in->buffer);
free(in);
return res;
}
#endif /* CURL_DOES_CONVERSIONS */
@@ -981,20 +985,29 @@ CURLcode add_buffer_send(send_buffer *in,
res = Curl_write(conn, sockfd, ptr, sendsize, &amount);
if(CURLE_OK == res) {
/*
* Note that we may not send the entire chunk at once, and we have a set
* number of data bytes at the end of the big buffer (out of which we may
* only send away a part).
*/
/* how much of the header that was sent */
size_t headlen = (size_t)amount>headersize?headersize:(size_t)amount;
size_t bodylen = amount - headlen;
if(conn->data->set.verbose) {
/* this data _may_ contain binary stuff */
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr,
(size_t)(amount-included_body_bytes), conn);
if (included_body_bytes)
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, headlen, conn);
if((size_t)amount > headlen) {
/* there was body data sent beyond the initial header part, pass that
on to the debug callback too */
Curl_debug(conn->data, CURLINFO_DATA_OUT,
ptr+amount-included_body_bytes,
(size_t)included_body_bytes, conn);
ptr+headlen, bodylen, conn);
}
}
if (included_body_bytes)
if(bodylen)
/* since we sent a piece of the body here, up the byte counter for it
accordingly */
http->writebytecount = included_body_bytes;
http->writebytecount += bodylen;
*bytes_written += amount;
@@ -1083,9 +1096,28 @@ CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
char *new_rb;
size_t new_size;
if(~size < in->size_used) {
/* If resulting used size of send buffer would wrap size_t, cleanup
the whole buffer and return error. Otherwise the required buffer
size will fit into a single allocatable memory chunk */
Curl_safefree(in->buffer);
free(in);
return CURLE_OUT_OF_MEMORY;
}
if(!in->buffer ||
((in->size_used + size) > (in->size_max - 1))) {
new_size = (in->size_used+size)*2;
/* If current buffer size isn't enough to hold the result, use a
buffer size that doubles the required size. If this new size
would wrap size_t, then just use the largest possible one */
if((size > (size_t)-1/2) || (in->size_used > (size_t)-1/2) ||
(~(size*2) < (in->size_used*2)))
new_size = (size_t)-1;
else
new_size = (in->size_used+size)*2;
if(in->buffer)
/* we have a buffer, enlarge the existing one */
new_rb = (char *)realloc(in->buffer, new_size);
@@ -1207,7 +1239,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
conn->bits.proxy_connect_closed = FALSE;
do {
if (!conn->bits.tunnel_connecting) { /* BEGIN CONNECT PHASE */
if(!conn->bits.tunnel_connecting) { /* BEGIN CONNECT PHASE */
char *host_port;
send_buffer *req_buffer;
@@ -1314,8 +1346,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
}
/* if we're in multi-mode and we would block, return instead for a retry */
if (Curl_if_multi == data->state.used_interface) {
if (0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
if(Curl_if_multi == data->state.used_interface) {
if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
/* return so we'll be called again polling-style */
return CURLE_OK;
else {
@@ -1571,7 +1603,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
headers. 'newurl' is set to a new URL if we must loop. */
Curl_http_auth_act(conn);
if (closeConnection && data->reqdata.newurl) {
if(closeConnection && data->reqdata.newurl) {
/* Connection closed by server. Don't use it anymore */
sclose(conn->sock[sockindex]);
conn->sock[sockindex] = CURL_SOCKET_BAD;
@@ -1584,7 +1616,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
failf(data, "Received HTTP code %d from proxy after CONNECT",
k->httpcode);
if (closeConnection && data->reqdata.newurl)
if(closeConnection && data->reqdata.newurl)
conn->bits.proxy_connect_closed = TRUE;
return CURLE_RECV_ERROR;
@@ -1634,14 +1666,14 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
return result;
}
if (conn->bits.tunnel_connecting) {
if(conn->bits.tunnel_connecting) {
/* nothing else to do except wait right now - we're not done here. */
return CURLE_OK;
}
if(!data->state.this_is_a_follow) {
/* this is not a followed location, get the original host name */
if (data->state.first_host)
if(data->state.first_host)
/* Free to avoid leaking memory on multiple requests*/
free(data->state.first_host);
@@ -1692,18 +1724,18 @@ static int Curl_https_getsock(struct connectdata *conn,
curl_socket_t *socks,
int numsocks)
{
if (conn->protocol & PROT_HTTPS) {
if(conn->protocol & PROT_HTTPS) {
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
if(!numsocks)
return GETSOCK_BLANK;
if (connssl->connecting_state == ssl_connect_2_writing) {
if(connssl->connecting_state == ssl_connect_2_writing) {
/* write mode */
socks[0] = conn->sock[FIRSTSOCKET];
return GETSOCK_WRITESOCK(0);
}
else if (connssl->connecting_state == ssl_connect_2_reading) {
else if(connssl->connecting_state == ssl_connect_2_reading) {
/* read mode */
socks[0] = conn->sock[FIRSTSOCKET];
return GETSOCK_READSOCK(0);
@@ -1766,7 +1798,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
conn->fread_func = data->set.fread_func; /* restore */
conn->fread_in = data->set.in; /* restore */
if (http == NULL)
if(http == NULL)
return CURLE_OK;
if(http->send_buffer) {
@@ -1790,7 +1822,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
else if(HTTPREQ_PUT == data->set.httpreq)
k->bytecount = http->readbytecount + http->writebytecount;
if (status != CURLE_OK)
if(status != CURLE_OK)
return (status);
if(!conn->bits.retry &&
@@ -1909,7 +1941,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
else
http = data->reqdata.proto.http;
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
if( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
data->set.upload) {
httpreq = HTTPREQ_PUT;
}
@@ -1990,7 +2022,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
}
else {
if (httpreq == HTTPREQ_GET)
if(httpreq == HTTPREQ_GET)
conn->bits.upload_chunky = FALSE;
if(conn->bits.upload_chunky)
te = "Transfer-Encoding: chunked\r\n";
@@ -2035,7 +2067,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) ||
(!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) )
/* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
/* if(HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
the port number in the host string */
conn->allocptr.host = aprintf("Host: %s%s%s\r\n",
conn->bits.ipv6_ip?"[":"",
@@ -2053,7 +2085,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
return CURLE_OUT_OF_MEMORY;
}
if (conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
/* Using a proxy but does not tunnel through it */
/* The path sent to the proxy is in fact the entire URL. But if the remote
@@ -2095,9 +2127,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
ppath = data->change.url;
/* when doing ftp, append ;type=<a|i> if not present */
if (checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
if(checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
char *p = strstr(ppath, ";type=");
if (p && p[6] && p[7] == 0) {
if(p && p[6] && p[7] == 0) {
switch (toupper((int)((unsigned char)p[6]))) {
case 'A':
case 'D':
@@ -2107,7 +2139,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
p = NULL;
}
}
if (!p)
if(!p)
snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c",
data->set.prefer_ascii ? 'a' : 'i');
}
@@ -2307,7 +2339,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
co = Curl_cookie_getlist(data->cookies,
conn->allocptr.cookiehost?
conn->allocptr.cookiehost:host, data->reqdata.path,
conn->allocptr.cookiehost:host,
data->reqdata.path,
(bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE));
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}

View File

@@ -118,7 +118,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
/* the original data is written to the client, but we go on with the
chunk read process, to properly calculate the content length*/
if (data->set.http_te_skip && !k->ignorebody)
if(data->set.http_te_skip && !k->ignorebody)
Curl_client_write(conn, CLIENTWRITE_BODY, datap,datalen);
while(length) {
@@ -178,7 +178,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
if(*datap == 0x0a) {
/* we're now expecting data to come, unless size was zero! */
if(0 == ch->datasize) {
if (conn->bits.trailerHdrPresent!=TRUE) {
if(conn->bits.trailerhdrpresent!=TRUE) {
/* No Trailer: header found - revert to original Curl processing */
ch->state = CHUNK_STOPCR;
@@ -221,7 +221,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
case IDENTITY:
#endif
if(!k->ignorebody) {
if ( !data->set.http_te_skip )
if( !data->set.http_te_skip )
result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
piece);
else
@@ -298,7 +298,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
case CHUNK_TRAILER:
/* conn->trailer is assumed to be freed in url.c on a
connection basis */
if (conn->trlPos >= conn->trlMax) {
if(conn->trlPos >= conn->trlMax) {
char *ptr;
if(conn->trlMax) {
conn->trlMax *= 2;
@@ -333,10 +333,10 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
break;
case CHUNK_TRAILER_POSTCR:
if (*datap == 0x0a) {
if(*datap == 0x0a) {
conn->trailer[conn->trlPos++]=0x0a;
conn->trailer[conn->trlPos]=0;
if (conn->trlPos==2) {
if(conn->trlPos==2) {
ch->state = CHUNK_STOP;
datap++;
length--;
@@ -362,7 +362,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
return(CHUNKE_BAD_CHUNK);
}
#endif /* CURL_DOES_CONVERSIONS */
if ( !data->set.http_te_skip )
if( !data->set.http_te_skip )
Curl_client_write(conn, CLIENTWRITE_HEADER,
conn->trailer, conn->trlPos);
}
@@ -389,7 +389,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
break;
case CHUNK_STOP:
if (*datap == 0x0a) {
if(*datap == 0x0a) {
datap++;
length--;

View File

@@ -133,23 +133,23 @@ CURLdigest Curl_input_digest(struct connectdata *conn,
if(!tmp)
return CURLDIGEST_NOMEM;
token = strtok_r(tmp, ",", &tok_buf);
while (token != NULL) {
if (strequal(token, "auth")) {
while(token != NULL) {
if(strequal(token, "auth")) {
foundAuth = TRUE;
}
else if (strequal(token, "auth-int")) {
else if(strequal(token, "auth-int")) {
foundAuthInt = TRUE;
}
token = strtok_r(NULL, ",", &tok_buf);
}
free(tmp);
/*select only auth o auth-int. Otherwise, ignore*/
if (foundAuth) {
if(foundAuth) {
d->qop = strdup("auth");
if(!d->qop)
return CURLDIGEST_NOMEM;
}
else if (foundAuthInt) {
else if(foundAuthInt) {
d->qop = strdup("auth-int");
if(!d->qop)
return CURLDIGEST_NOMEM;
@@ -243,7 +243,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
*/
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
if (rc != CURLE_OK) { \
if(rc != CURLE_OK) { \
free(b); \
return rc; \
}
@@ -266,7 +266,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
authp = &data->state.authhost;
}
if (*allocuserpwd) {
if(*allocuserpwd) {
Curl_safefree(*allocuserpwd);
*allocuserpwd = NULL;
}
@@ -353,7 +353,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
return CURLE_OUT_OF_MEMORY;
}
if (d->qop && strequal(d->qop, "auth-int")) {
if(d->qop && strequal(d->qop, "auth-int")) {
/* We don't support auth-int at the moment. I can't see a easy way to get
entity-body here */
/* TODO: Append H(entity-body)*/
@@ -363,7 +363,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
free(md5this); /* free this again */
md5_to_ascii(md5buf, ha2);
if (d->qop) {
if(d->qop) {
md5this = (unsigned char *)aprintf("%s:%s:%08x:%s:%s:%s",
ha1,
d->nonce,
@@ -393,7 +393,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca"
*/
if (d->qop) {
if(d->qop) {
*allocuserpwd =
aprintf( "%sAuthorization: Digest "
"username=\"%s\", "

View File

@@ -51,7 +51,8 @@
static int
get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
{
struct negotiatedata *neg_ctx = &conn->data->state.negotiate;
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
&conn->data->state.negotiate;
OM_uint32 major_status, minor_status;
gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
char name[2048];
@@ -64,16 +65,18 @@ get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
/* IIS uses the <service>@<fqdn> form but uses 'http' as the service name */
if (neg_ctx->gss)
if(neg_ctx->gss)
service = "KHTTP";
else
service = "HTTP";
token.length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name : conn->host.name) + 1;
if (token.length + 1 > sizeof(name))
token.length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name :
conn->host.name) + 1;
if(token.length + 1 > sizeof(name))
return EMSGSIZE;
snprintf(name, sizeof(name), "%s@%s", service, proxy ? conn->proxy.name : conn->host.name);
snprintf(name, sizeof(name), "%s@%s", service, proxy ? conn->proxy.name :
conn->host.name);
token.value = (void *) name;
major_status = gss_import_name(&minor_status,
@@ -96,26 +99,28 @@ log_gss_error(struct connectdata *conn, OM_uint32 error_status, char *prefix)
snprintf(buf, sizeof(buf), "%s", prefix);
len = strlen(buf);
do {
maj_stat = gss_display_status (&min_stat,
error_status,
GSS_C_MECH_CODE,
GSS_C_NO_OID,
&msg_ctx,
&status_string);
if (sizeof(buf) > len + status_string.length + 1) {
maj_stat = gss_display_status(&min_stat,
error_status,
GSS_C_MECH_CODE,
GSS_C_NO_OID,
&msg_ctx,
&status_string);
if(sizeof(buf) > len + status_string.length + 1) {
snprintf(buf + len, sizeof(buf) - len,
": %s", (char*) status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
} while (!GSS_ERROR(maj_stat) && msg_ctx != 0);
} while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
infof(conn->data, "%s", buf);
}
int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *header)
int Curl_input_negotiate(struct connectdata *conn, bool proxy,
const char *header)
{
struct negotiatedata *neg_ctx = &conn->data->state.negotiate;
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
&conn->data->state.negotiate;
OM_uint32 major_status, minor_status, minor_status2;
gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
@@ -130,15 +135,15 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
protocol = "GSS-Negotiate";
gss = TRUE;
}
else if (checkprefix("Negotiate", header)) {
else if(checkprefix("Negotiate", header)) {
protocol = "Negotiate";
gss = FALSE;
}
else
return -1;
if (neg_ctx->context) {
if (neg_ctx->gss != gss) {
if(neg_ctx->context) {
if(neg_ctx->gss != gss) {
return -1;
}
}
@@ -147,7 +152,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
neg_ctx->gss = gss;
}
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
* rejected it (since we're again here). Exit with an error since we
* can't invent anything better */
@@ -155,7 +160,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
return -1;
}
if (neg_ctx->server_name == NULL &&
if(neg_ctx->server_name == NULL &&
(ret = get_gss_name(conn, proxy, &neg_ctx->server_name)))
return ret;
@@ -164,14 +169,15 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
header++;
len = strlen(header);
if (len > 0) {
int rawlen = Curl_base64_decode(header, (unsigned char **)&input_token.value);
if (rawlen < 0)
if(len > 0) {
int rawlen = Curl_base64_decode(header,
(unsigned char **)&input_token.value);
if(rawlen < 0)
return -1;
input_token.length = rawlen;
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if (checkprefix("Negotiate", header)) {
if(checkprefix("Negotiate", header)) {
ASN1_OBJECT * object = NULL;
int rc = 1;
unsigned char * spnegoToken = NULL;
@@ -180,12 +186,12 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
size_t mechTokenLength = 0;
spnegoToken = malloc(input_token.length);
if (input_token.value == NULL)
if(input_token.value == NULL)
return ENOMEM;
spnegoTokenLength = input_token.length;
object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
if (!parseSpnegoTargetToken(spnegoToken,
if(!parseSpnegoTargetToken(spnegoToken,
spnegoTokenLength,
NULL,
NULL,
@@ -224,17 +230,17 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
&output_token,
NULL,
NULL);
if (input_token.length > 0)
if(input_token.length > 0)
gss_release_buffer(&minor_status2, &input_token);
neg_ctx->status = major_status;
if (GSS_ERROR(major_status)) {
if(GSS_ERROR(major_status)) {
/* Curl_cleanup_negotiate(conn->data) ??? */
log_gss_error(conn, minor_status,
(char *)"gss_init_sec_context() failed: ");
return -1;
}
if (output_token.length == 0) {
if(output_token.length == 0) {
return -1;
}
@@ -247,13 +253,14 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
{
struct negotiatedata *neg_ctx = &conn->data->state.negotiate;
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
&conn->data->state.negotiate;
OM_uint32 minor_status;
char *encoded = NULL;
int len;
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if (checkprefix("Negotiate",neg_ctx->protocol)) {
if(checkprefix("Negotiate", neg_ctx->protocol)) {
ASN1_OBJECT * object = NULL;
int rc = 1;
unsigned char * spnegoToken = NULL;
@@ -262,14 +269,14 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
size_t responseTokenLength = 0;
responseToken = malloc(neg_ctx->output_token.length);
if ( responseToken == NULL)
if( responseToken == NULL)
return CURLE_OUT_OF_MEMORY;
memcpy(responseToken, neg_ctx->output_token.value,
neg_ctx->output_token.length);
responseTokenLength = neg_ctx->output_token.length;
object=OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
if (!makeSpnegoInitialToken (object,
if(!makeSpnegoInitialToken (object,
responseToken,
responseTokenLength,
&spnegoToken,
@@ -295,33 +302,38 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
neg_ctx->output_token.length,
&encoded);
if (len == 0)
if(len == 0)
return CURLE_OUT_OF_MEMORY;
conn->allocptr.userpwd =
aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "", neg_ctx->protocol, encoded);
aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "",
neg_ctx->protocol, encoded);
free(encoded);
gss_release_buffer(&minor_status, &neg_ctx->output_token);
return (conn->allocptr.userpwd == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
}
void Curl_cleanup_negotiate(struct SessionHandle *data)
static void cleanup(struct negotiatedata *neg_ctx)
{
OM_uint32 minor_status;
struct negotiatedata *neg_ctx = &data->state.negotiate;
if (neg_ctx->context != GSS_C_NO_CONTEXT)
if(neg_ctx->context != GSS_C_NO_CONTEXT)
gss_delete_sec_context(&minor_status, &neg_ctx->context, GSS_C_NO_BUFFER);
if (neg_ctx->output_token.length != 0)
if(neg_ctx->output_token.length != 0)
gss_release_buffer(&minor_status, &neg_ctx->output_token);
if (neg_ctx->server_name != GSS_C_NO_NAME)
if(neg_ctx->server_name != GSS_C_NO_NAME)
gss_release_name(&minor_status, &neg_ctx->server_name);
memset(neg_ctx, 0, sizeof(*neg_ctx));
}
void Curl_cleanup_negotiate(struct SessionHandle *data)
{
cleanup(&data->state.negotiate);
cleanup(&data->state.proxyneg);
}
#endif
#endif

View File

@@ -198,7 +198,7 @@ static void print_hex(FILE *handle, const char *buf, size_t len)
{
const char *p = buf;
fprintf(stderr, "0x");
while (len-- > 0)
while(len-- > 0)
fprintf(stderr, "%02.2x", (unsigned int)*p++);
}
#else
@@ -263,7 +263,7 @@ CURLntlm Curl_input_ntlm(struct connectdata *conn,
#ifdef USE_WINDOWS_SSPI
ntlm->type_2 = malloc(size+1);
if (ntlm->type_2 == NULL) {
if(ntlm->type_2 == NULL) {
free(buffer);
return CURLE_OUT_OF_MEMORY;
}
@@ -368,7 +368,7 @@ static void mk_lm_hash(struct SessionHandle *data,
unsigned int i;
size_t len = strlen(password);
if (len > 14)
if(len > 14)
len = 14;
for (i=0; i<len; i++)
@@ -425,7 +425,7 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
{
size_t len = strlen(password);
unsigned char *pw = malloc(len*2);
if (!pw)
if(!pw)
return CURLE_OUT_OF_MEMORY;
utf8_to_unicode_le(pw, password, len);
@@ -465,19 +465,19 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
static void
ntlm_sspi_cleanup(struct ntlmdata *ntlm)
{
if (ntlm->type_2) {
if(ntlm->type_2) {
free(ntlm->type_2);
ntlm->type_2 = NULL;
}
if (ntlm->has_handles) {
if(ntlm->has_handles) {
s_pSecFn->DeleteSecurityContext(&ntlm->c_handle);
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
ntlm->has_handles = 0;
}
if (ntlm->p_identity) {
if (ntlm->identity.User) free(ntlm->identity.User);
if (ntlm->identity.Password) free(ntlm->identity.Password);
if (ntlm->identity.Domain) free(ntlm->identity.Domain);
if(ntlm->p_identity) {
if(ntlm->identity.User) free(ntlm->identity.User);
if(ntlm->identity.Password) free(ntlm->identity.Password);
if(ntlm->identity.Domain) free(ntlm->identity.Domain);
ntlm->p_identity = NULL;
}
}
@@ -546,7 +546,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
#ifdef USE_WINDOWS_SSPI
/* If security interface is not yet initialized try to do this */
if (s_hSecDll == NULL) {
if(s_hSecDll == NULL) {
/* Determine Windows version. Security functions are located in
* security.dll on WinNT 4.0 and in secur32.dll on Win9x. Win2K and XP
* contain both these DLLs (security.dll just forwards calls to
@@ -555,21 +555,21 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
OSVERSIONINFO osver;
osver.dwOSVersionInfoSize = sizeof(osver);
GetVersionEx(&osver);
if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT
if(osver.dwPlatformId == VER_PLATFORM_WIN32_NT
&& osver.dwMajorVersion == 4)
s_hSecDll = LoadLibrary("security.dll");
else
s_hSecDll = LoadLibrary("secur32.dll");
if (s_hSecDll != NULL) {
if(s_hSecDll != NULL) {
INIT_SECURITY_INTERFACE pInitSecurityInterface;
pInitSecurityInterface =
(INIT_SECURITY_INTERFACE)GetProcAddress(s_hSecDll,
"InitSecurityInterfaceA");
if (pInitSecurityInterface != NULL)
if(pInitSecurityInterface != NULL)
s_pSecFn = pInitSecurityInterface();
}
}
if (s_pSecFn == NULL)
if(s_pSecFn == NULL)
return CURLE_RECV_ERROR;
#endif
@@ -589,10 +589,10 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
ntlm_sspi_cleanup(ntlm);
user = strchr(userp, '\\');
if (!user)
if(!user)
user = strchr(userp, '/');
if (user) {
if(user) {
domain = userp;
domlen = user - userp;
user++;
@@ -603,19 +603,19 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
domlen = 0;
}
if (user && *user) {
if(user && *user) {
/* note: initialize all of this before doing the mallocs so that
* it can be cleaned up later without leaking memory.
*/
ntlm->p_identity = &ntlm->identity;
memset(ntlm->p_identity, 0, sizeof(*ntlm->p_identity));
if ((ntlm->identity.User = (unsigned char *)strdup(user)) == NULL)
if((ntlm->identity.User = (unsigned char *)strdup(user)) == NULL)
return CURLE_OUT_OF_MEMORY;
ntlm->identity.UserLength = strlen(user);
if ((ntlm->identity.Password = (unsigned char *)strdup(passwdp)) == NULL)
if((ntlm->identity.Password = (unsigned char *)strdup(passwdp)) == NULL)
return CURLE_OUT_OF_MEMORY;
ntlm->identity.PasswordLength = strlen(passwdp);
if ((ntlm->identity.Domain = malloc(domlen+1)) == NULL)
if((ntlm->identity.Domain = malloc(domlen+1)) == NULL)
return CURLE_OUT_OF_MEMORY;
strncpy((char *)ntlm->identity.Domain, domain, domlen);
ntlm->identity.Domain[domlen] = '\0';
@@ -626,7 +626,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
ntlm->p_identity = NULL;
}
if (s_pSecFn->AcquireCredentialsHandle(
if(s_pSecFn->AcquireCredentialsHandle(
NULL, (char *)"NTLM", SECPKG_CRED_OUTBOUND, NULL, ntlm->p_identity,
NULL, NULL, &ntlm->handle, &tsDummy
) != SEC_E_OK) {
@@ -650,11 +650,11 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
&ntlm->c_handle, &desc,
&attrs, &tsDummy);
if (status == SEC_I_COMPLETE_AND_CONTINUE ||
if(status == SEC_I_COMPLETE_AND_CONTINUE ||
status == SEC_I_CONTINUE_NEEDED) {
s_pSecFn->CompleteAuthToken(&ntlm->c_handle, &desc);
}
else if (status != SEC_E_OK) {
else if(status != SEC_E_OK) {
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
return CURLE_RECV_ERROR;
}
@@ -805,7 +805,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
0, &ntlm->c_handle, &type_3_desc,
&attrs, &tsDummy);
if (status != SEC_E_OK)
if(status != SEC_E_OK)
return CURLE_RECV_ERROR;
size = type_3.cbBuffer;
@@ -827,7 +827,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
if(!user)
user = strchr(userp, '/');
if (user) {
if(user) {
domain = userp;
domlen = (user - domain);
user++;
@@ -836,7 +836,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
user = userp;
userlen = strlen(user);
if (gethostname(host, HOSTNAME_MAX)) {
if(gethostname(host, HOSTNAME_MAX)) {
infof(conn->data, "gethostname() failed, continuing without!");
hostlen = 0;
}
@@ -846,14 +846,14 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
* name, which NTLM doesn't like.
*/
char *dot = strchr(host, '.');
if (dot)
if(dot)
*dot = '\0';
hostlen = strlen(host);
}
#if USE_NTLM2SESSION
/* 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) {
unsigned char ntbuffer[0x18];
unsigned char tmp[0x18];
unsigned char md5sum[MD5_DIGEST_LENGTH];
@@ -878,7 +878,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
MD5_Final(md5sum, &MD5pw);
/* We shall only use the first 8 bytes of md5sum,
but the des code in lm_resp only encrypt the first 8 bytes */
if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
if(mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
return CURLE_OUT_OF_MEMORY;
lm_resp(ntbuffer, md5sum, ntresp);
@@ -893,7 +893,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
unsigned char lmbuffer[0x18];
#if USE_NTRESPONSES
if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
if(mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
return CURLE_OUT_OF_MEMORY;
lm_resp(ntbuffer, &ntlm->nonce[0], ntresp);
#endif
@@ -1113,7 +1113,7 @@ Curl_ntlm_cleanup(struct connectdata *conn)
#ifdef USE_WINDOWS_SSPI
ntlm_sspi_cleanup(&conn->ntlm);
ntlm_sspi_cleanup(&conn->proxyntlm);
if (s_hSecDll != NULL) {
if(s_hSecDll != NULL) {
FreeLibrary(s_hSecDll);
s_hSecDll = NULL;
s_pSecFn = NULL;

View File

@@ -91,7 +91,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size)
return NULL;
dummy = socket(AF_INET, SOCK_STREAM, 0);
if (SYS_ERROR == dummy) {
if(SYS_ERROR == dummy) {
return NULL;
}
else {
@@ -105,9 +105,9 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size)
memcpy(req.ifr_name, interface, len+1);
req.ifr_addr.sa_family = AF_INET;
#ifdef IOCTL_3_ARGS
if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
#else
if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
#endif
sclose(dummy);
return NULL;

View File

@@ -79,7 +79,7 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
#else
const char *addr = inet_ntoa(*(struct in_addr*)src);
if (strlen(addr) >= size)
if(strlen(addr) >= size)
{
SET_ERRNO(ENOSPC);
return (NULL);
@@ -125,23 +125,23 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
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;
else
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;
cur.base = -1;
}
}
if ((cur.base != -1) && (best.base == -1 || cur.len > best.len))
if((cur.base != -1) && (best.base == -1 || cur.len > best.len))
best = cur;
if (best.base != -1 && best.len < 2)
if(best.base != -1 && best.len < 2)
best.base = -1;
/* Format the result.
@@ -151,24 +151,24 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
{
/* 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++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex?
*/
if (i != 0)
if(i != 0)
*tp++ = ':';
/* 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)))
{
if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
{
SET_ERRNO(ENOSPC);
return (NULL);
@@ -181,13 +181,13 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
/* Was it a trailing run of 0x00's?
*/
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
if(best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size)
if((size_t)(tp - tmp) > size)
{
SET_ERRNO(ENOSPC);
return (NULL);

View File

@@ -108,29 +108,31 @@ inet_pton4(const char *src, unsigned char *dst)
octets = 0;
tp = tmp;
*tp = 0;
while ((ch = *src++) != '\0') {
while((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr(digits, ch)) != NULL) {
if((pch = strchr(digits, ch)) != NULL) {
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
if (val > 255)
if(val > 255)
return (0);
*tp = (unsigned char)val;
if (! saw_digit) {
if (++octets > 4)
if(! saw_digit) {
if(++octets > 4)
return (0);
saw_digit = 1;
}
} else if (ch == '.' && saw_digit) {
if (octets == 4)
}
else if(ch == '.' && saw_digit) {
if(octets == 4)
return (0);
*++tp = 0;
saw_digit = 0;
} else
}
else
return (0);
}
if (octets < 4)
if(octets < 4)
return (0);
/* bcopy(tmp, dst, INADDRSZ); */
memcpy(dst, tmp, INADDRSZ);
@@ -165,34 +167,34 @@ inet_pton6(const char *src, unsigned char *dst)
endp = tp + IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
if(*src == ':')
if(*++src != ':')
return (0);
curtok = src;
saw_xdigit = 0;
val = 0;
while ((ch = *src++) != '\0') {
while((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
if((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
if(pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
if(val > 0xffff)
return (0);
saw_xdigit = 1;
continue;
}
if (ch == ':') {
if(ch == ':') {
curtok = src;
if (!saw_xdigit) {
if (colonp)
if(!saw_xdigit) {
if(colonp)
return (0);
colonp = tp;
continue;
}
if (tp + INT16SZ > endp)
if(tp + INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
@@ -200,7 +202,7 @@ inet_pton6(const char *src, unsigned char *dst)
val = 0;
continue;
}
if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
if(ch == '.' && ((tp + INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += INADDRSZ;
saw_xdigit = 0;
@@ -208,13 +210,13 @@ inet_pton6(const char *src, unsigned char *dst)
}
return (0);
}
if (saw_xdigit) {
if (tp + INT16SZ > endp)
if(saw_xdigit) {
if(tp + INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
}
if (colonp != NULL) {
if(colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
@@ -228,7 +230,7 @@ inet_pton6(const char *src, unsigned char *dst)
}
tp = endp;
}
if (tp != endp)
if(tp != endp)
return (0);
/* bcopy(tmp, dst, IN6ADDRSZ); */
memcpy(dst, tmp, IN6ADDRSZ);

View File

@@ -97,7 +97,7 @@ strlcpy (char *dst, const char *src, size_t dst_sz)
++p, ++src, ++n)
*p = *src;
*p = '\0';
if (*src == '\0')
if(*src == '\0')
return n;
else
return n + strlen (src);
@@ -228,17 +228,17 @@ krb4_auth(void *app_data, struct connectdata *conn)
}
#ifdef HAVE_KRB_GET_OUR_IP_FOR_REALM
if (krb_get_config_bool("nat_in_use")) {
if(krb_get_config_bool("nat_in_use")) {
struct sockaddr_in *localaddr = (struct sockaddr_in *)LOCAL_ADDR;
struct in_addr natAddr;
if (krb_get_our_ip_for_realm(krb_realmofhost(host),
if(krb_get_our_ip_for_realm(krb_realmofhost(host),
&natAddr) != KSUCCESS
&& krb_get_our_ip_for_realm(NULL, &natAddr) != KSUCCESS)
infof(data, "Can't get address for realm %s\n",
krb_realmofhost(host));
else {
if (natAddr.s_addr != localaddr->sin_addr.s_addr) {
if(natAddr.s_addr != localaddr->sin_addr.s_addr) {
#ifdef HAVE_INET_NTOA_R
char ntoa_buf[64];
char *ip = (char *)inet_ntoa_r(natAddr, ntoa_buf, sizeof(ntoa_buf));
@@ -387,7 +387,7 @@ CURLcode Curl_krb_kauth(struct connectdata *conn)
des_pcbc_encrypt((void *)tkt.dat, (void *)tktcopy.dat,
tkt.length,
schedule, &key, DES_DECRYPT);
if (strcmp ((char*)tktcopy.dat + 8,
if(strcmp ((char*)tktcopy.dat + 8,
KRB_TICKET_GRANTING_TICKET) != 0) {
afs_string_to_key(passwd,
krb_realmofhost(conn->host.name),

View File

@@ -110,7 +110,7 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp);
#define LDAP_TRACE(x) do { \
_ldap_trace ("%u: ", __LINE__); \
_ldap_trace x; \
} while (0)
} while(0)
static void _ldap_trace (const char *fmt, ...);
#else
@@ -191,14 +191,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#else
rc = _ldap_url_parse(conn, &ludp);
#endif
if (rc != 0) {
if(rc != 0) {
failf(data, "LDAP local: %s", ldap_err2string(rc));
status = CURLE_LDAP_INVALID_URL;
goto quit;
}
/* Get the URL scheme ( either ldap or ldaps ) */
if (strequal(conn->protostr, "LDAPS"))
if(strequal(conn->protostr, "LDAPS"))
ldap_ssl = 1;
infof(data, "LDAP local: trying to establish %s connection\n",
ldap_ssl ? "encrypted" : "cleartext");
@@ -208,7 +208,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#endif
ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
if (ldap_ssl) {
if(ldap_ssl) {
#ifdef HAVE_LDAP_SSL
#ifdef CURL_LDAP_WIN
/* Win32 LDAP SDK doesnt support insecure mode without CA! */
@@ -219,18 +219,18 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
char* ldap_ca = data->set.str[STRING_SSL_CAFILE];
#if defined(CURL_HAS_NOVELL_LDAPSDK)
rc = ldapssl_client_init(NULL, NULL);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
/* Novell SDK supports DER or BASE64 files. */
int cert_type = LDAPSSL_CERT_FILETYPE_B64;
if ((data->set.str[STRING_CERT_TYPE]) &&
if((data->set.str[STRING_CERT_TYPE]) &&
(strequal(data->set.str[STRING_CERT_TYPE], "DER")))
cert_type = LDAPSSL_CERT_FILETYPE_DER;
if (!ldap_ca) {
if(!ldap_ca) {
failf(data, "LDAP local: ERROR %s CA cert not set!",
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"));
status = CURLE_SSL_CERTPROBLEM;
@@ -240,7 +240,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
ldap_ca);
rc = ldapssl_add_trusted_cert(ldap_ca, cert_type);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting %s CA cert: %s",
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
ldap_err2string(rc));
@@ -252,36 +252,36 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
ldap_option = LDAPSSL_VERIFY_NONE;
}
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",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
server = ldapssl_init(conn->host.name, (int)conn->port, 1);
if (server == NULL) {
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%d",
conn->host.name, conn->port);
status = CURLE_COULDNT_CONNECT;
goto quit;
}
#elif defined(LDAP_OPT_X_TLS)
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
/* OpenLDAP SDK supports BASE64 files. */
if ((data->set.str[STRING_CERT_TYPE]) &&
if((data->set.str[STRING_CERT_TYPE]) &&
(!strequal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
failf(data, "LDAP local: ERROR OpenLDAP does only support PEM cert-type!");
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
if (!ldap_ca) {
if(!ldap_ca) {
failf(data, "LDAP local: ERROR PEM CA cert not set!");
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca);
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
@@ -292,14 +292,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
ldap_option = LDAP_OPT_X_TLS_NEVER;
}
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",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
server = ldap_init(conn->host.name, (int)conn->port);
if (server == NULL) {
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%d",
conn->host.name, conn->port);
status = CURLE_COULDNT_CONNECT;
@@ -307,7 +307,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
}
ldap_option = LDAP_OPT_X_TLS_HARD;
rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
@@ -315,7 +315,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
}
/*
rc = ldap_start_tls_s(server, NULL, NULL);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
@@ -334,7 +334,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#endif /* CURL_LDAP_USE_SSL */
} else {
server = ldap_init(conn->host.name, (int)conn->port);
if (server == NULL) {
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%d",
conn->host.name, conn->port);
status = CURLE_COULDNT_CONNECT;
@@ -348,14 +348,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
rc = ldap_simple_bind_s(server,
conn->bits.user_passwd ? conn->user : NULL,
conn->bits.user_passwd ? conn->passwd : NULL);
if (!ldap_ssl && rc != 0) {
if(!ldap_ssl && rc != 0) {
ldap_proto = LDAP_VERSION2;
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
rc = ldap_simple_bind_s(server,
conn->bits.user_passwd ? conn->user : NULL,
conn->bits.user_passwd ? conn->passwd : NULL);
}
if (rc != 0) {
if(rc != 0) {
failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
status = CURLE_LDAP_CANNOT_BIND;
goto quit;
@@ -364,7 +364,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
ludp->lud_filter, ludp->lud_attrs, 0, &result);
if (rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
failf(data, "LDAP remote: %s", ldap_err2string(rc));
status = CURLE_LDAP_SEARCH_FAILED;
goto quit;
@@ -389,14 +389,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
{
BerValue **vals = ldap_get_values_len(server, entryIterator, attribute);
if (vals != NULL)
if(vals != NULL)
{
for (i = 0; (vals[i] != NULL); i++)
{
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 *)": ", 2);
if ((strlen(attribute) > 7) &&
if((strlen(attribute) > 7) &&
(strcmp(";binary",
(char *)attribute +
(strlen((char *)attribute) - 7)) == 0)) {
@@ -405,7 +405,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
vals[i]->bv_val,
vals[i]->bv_len,
&val_b64);
if (val_b64_sz > 0) {
if(val_b64_sz > 0) {
Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
free(val_b64);
}
@@ -423,23 +423,23 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
ldap_memfree(attribute);
}
ldap_memfree(dn);
if (ber)
if(ber)
ber_free(ber, 0);
}
quit:
if (result) {
if(result) {
ldap_msgfree(result);
LDAP_TRACE (("Received %d entries\n", num));
}
if (rc == LDAP_SIZELIMIT_EXCEEDED)
if(rc == LDAP_SIZELIMIT_EXCEEDED)
infof(data, "There are more than %d entries\n", num);
if (ludp)
if(ludp)
ldap_free_urldesc(ludp);
if (server)
if(server)
ldap_unbind_s(server);
#if defined(HAVE_LDAP_SSL) && defined(CURL_HAS_NOVELL_LDAPSDK)
if (ldap_ssl)
if(ldap_ssl)
ldapssl_client_deinit();
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
@@ -456,11 +456,11 @@ static void _ldap_trace (const char *fmt, ...)
static int do_trace = -1;
va_list args;
if (do_trace == -1) {
if(do_trace == -1) {
const char *env = getenv("CURL_TRACE");
do_trace = (env && atoi(env) > 0);
}
if (!do_trace)
if(!do_trace)
return;
va_start (args, fmt);
@@ -476,15 +476,15 @@ static void _ldap_trace (const char *fmt, ...)
*/
static int str2scope (const char *p)
{
if (!stricmp(p, "one"))
if(!stricmp(p, "one"))
return LDAP_SCOPE_ONELEVEL;
if (!stricmp(p, "onetree"))
if(!stricmp(p, "onetree"))
return LDAP_SCOPE_ONELEVEL;
if (!stricmp(p, "base"))
if(!stricmp(p, "base"))
return LDAP_SCOPE_BASE;
if (!stricmp(p, "sub"))
if(!stricmp(p, "sub"))
return LDAP_SCOPE_SUBTREE;
if (!stricmp( p, "subtree"))
if(!stricmp( p, "subtree"))
return LDAP_SCOPE_SUBTREE;
return (-1);
}
@@ -502,7 +502,7 @@ static char **split_str (char *str)
s = strchr(++s,',');
res = calloc(i, sizeof(char*));
if (!res)
if(!res)
return NULL;
for (i = 0, s = strtok_r(str, ",", &lasts); s;
@@ -518,31 +518,31 @@ static bool unescape_elements (void *data, LDAPURLDesc *ludp)
{
int i;
if (ludp->lud_filter) {
if(ludp->lud_filter) {
ludp->lud_filter = curl_easy_unescape(data, ludp->lud_filter, 0, NULL);
if (!ludp->lud_filter)
if(!ludp->lud_filter)
return (FALSE);
}
for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) {
ludp->lud_attrs[i] = curl_easy_unescape(data, ludp->lud_attrs[i], 0, NULL);
if (!ludp->lud_attrs[i])
if(!ludp->lud_attrs[i])
return (FALSE);
}
for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) {
ludp->lud_exts[i] = curl_easy_unescape(data, ludp->lud_exts[i], 0, NULL);
if (!ludp->lud_exts[i])
if(!ludp->lud_exts[i])
return (FALSE);
}
if (ludp->lud_dn) {
if(ludp->lud_dn) {
char *dn = ludp->lud_dn;
char *new_dn = curl_easy_unescape(data, dn, 0, NULL);
free(dn);
ludp->lud_dn = new_dn;
if (!new_dn)
if(!new_dn)
return (FALSE);
}
return (TRUE);
@@ -567,7 +567,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
char *p, *q;
int i;
if (!conn->data ||
if(!conn->data ||
!conn->data->reqdata.path ||
conn->data->reqdata.path[0] != '/' ||
!checkprefix(conn->protostr, conn->data->change.url))
@@ -580,14 +580,14 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
/* parse DN (Distinguished Name).
*/
ludp->lud_dn = strdup(conn->data->reqdata.path+1);
if (!ludp->lud_dn)
if(!ludp->lud_dn)
return LDAP_NO_MEMORY;
p = strchr(ludp->lud_dn, '?');
LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) :
strlen(ludp->lud_dn), ludp->lud_dn));
if (!p)
if(!p)
goto success;
*p++ = '\0';
@@ -595,12 +595,12 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
/* parse attributes. skip "??".
*/
q = strchr(p, '?');
if (q)
if(q)
*q++ = '\0';
if (*p && *p != '?') {
if(*p && *p != '?') {
ludp->lud_attrs = split_str(p);
if (!ludp->lud_attrs)
if(!ludp->lud_attrs)
return LDAP_NO_MEMORY;
for (i = 0; ludp->lud_attrs[i]; i++)
@@ -608,52 +608,52 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
}
p = q;
if (!p)
if(!p)
goto success;
/* parse scope. skip "??"
*/
q = strchr(p, '?');
if (q)
if(q)
*q++ = '\0';
if (*p && *p != '?') {
if(*p && *p != '?') {
ludp->lud_scope = str2scope(p);
if (ludp->lud_scope == -1)
if(ludp->lud_scope == -1)
return LDAP_INVALID_SYNTAX;
LDAP_TRACE (("scope %d\n", ludp->lud_scope));
}
p = q;
if (!p)
if(!p)
goto success;
/* parse filter
*/
q = strchr(p, '?');
if (q)
if(q)
*q++ = '\0';
if (!*p)
if(!*p)
return LDAP_INVALID_SYNTAX;
ludp->lud_filter = p;
LDAP_TRACE (("filter '%s'\n", ludp->lud_filter));
p = q;
if (!p)
if(!p)
goto success;
/* parse extensions
*/
ludp->lud_exts = split_str(p);
if (!ludp->lud_exts)
if(!ludp->lud_exts)
return LDAP_NO_MEMORY;
for (i = 0; ludp->lud_exts[i]; i++)
LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i]));
success:
if (!unescape_elements(conn->data, ludp))
if(!unescape_elements(conn->data, ludp))
return LDAP_NO_MEMORY;
return LDAP_SUCCESS;
}
@@ -665,11 +665,11 @@ static int _ldap_url_parse (const struct connectdata *conn,
int rc;
*ludpp = NULL;
if (!ludp)
if(!ludp)
return LDAP_NO_MEMORY;
rc = _ldap_url_parse2 (conn, ludp);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
_ldap_free_urldesc(ludp);
ludp = NULL;
}
@@ -681,22 +681,22 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp)
{
int i;
if (!ludp)
if(!ludp)
return;
if (ludp->lud_dn)
if(ludp->lud_dn)
free(ludp->lud_dn);
if (ludp->lud_filter)
if(ludp->lud_filter)
free(ludp->lud_filter);
if (ludp->lud_attrs) {
if(ludp->lud_attrs) {
for (i = 0; ludp->lud_attrs[i]; i++)
free(ludp->lud_attrs[i]);
free(ludp->lud_attrs);
}
if (ludp->lud_exts) {
if(ludp->lud_exts) {
for (i = 0; ludp->lud_exts[i]; i++)
free(ludp->lud_exts[i]);
free(ludp->lud_exts);

View File

@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2007, 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
@@ -68,7 +68,7 @@ Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e,
return 0;
ne->ptr = (void *) p;
if (list->size == 0) {
if(list->size == 0) {
list->head = ne;
list->head->prev = NULL;
list->head->next = NULL;
@@ -77,7 +77,7 @@ Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e,
else {
ne->next = e->next;
ne->prev = e;
if (e->next) {
if(e->next) {
e->next->prev = ne;
}
else {
@@ -95,19 +95,19 @@ int
Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e,
void *user)
{
if (e == NULL || list->size == 0)
if(e == NULL || list->size == 0)
return 1;
if (e == list->head) {
if(e == list->head) {
list->head = e->next;
if (list->head == NULL)
if(list->head == NULL)
list->tail = NULL;
else
e->next->prev = NULL;
} else {
e->prev->next = e->next;
if (!e->next)
if(!e->next)
list->tail = e->prev;
else
e->next->prev = e->prev;
@@ -124,7 +124,7 @@ void
Curl_llist_destroy(struct curl_llist *list, void *user)
{
if(list) {
while (list->size > 0)
while(list->size > 0)
Curl_llist_remove(list, list->tail, user);
free(list);

View File

@@ -1,16 +1,16 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2007, 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.
@@ -161,21 +161,21 @@ static void MD5_Update (struct md5_ctx *context, /* context */
bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
if((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - bufindex;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
if(inputLen >= partLen) {
memcpy((void *)&context->buffer[bufindex], (void *)input, partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform(context->state, &input[i]);
bufindex = 0;
}
else

View File

@@ -71,7 +71,7 @@ static long memsize = 0; /* set number of mallocs allowed */
/* this sets the log file name */
void curl_memdebug(const char *logname)
{
if (!logfile) {
if(!logfile) {
if(logname)
logfile = fopen(logname, "w");
else
@@ -87,7 +87,7 @@ void curl_memdebug(const char *logname)
successfully! */
void curl_memlimit(long limit)
{
if (!memlimit) {
if(!memlimit) {
memlimit = TRUE;
memsize = limit;
}
@@ -185,8 +185,8 @@ char *curl_dostrdup(const char *str, int line, const char *source)
len=strlen(str)+1;
mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */
if (mem)
memcpy(mem, str, len);
if(mem)
memcpy(mem, str, len);
if(logfile)
fprintf(logfile, "MEM %s:%d strdup(%p) (%zd) = %p\n",

View File

@@ -308,9 +308,9 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
long max_param=0;
long i;
while (*fmt) {
if (*fmt++ == '%') {
if (*fmt == '%') {
while(*fmt) {
if(*fmt++ == '%') {
if(*fmt == '%') {
fmt++;
continue; /* while */
}
@@ -322,11 +322,11 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
param_num++;
this_param = dprintf_DollarString(fmt, &fmt);
if (0 == this_param)
if(0 == this_param)
/* we got no positional, get the next counter */
this_param = param_num;
if (this_param > max_param)
if(this_param > max_param)
max_param = this_param;
/*
@@ -340,7 +340,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
/* Handle the flags */
while (dprintf_IsQualifierNoDollar(*fmt)) {
while(dprintf_IsQualifierNoDollar(*fmt)) {
switch (*fmt++) {
case ' ':
flags |= FLAGS_SPACE;
@@ -357,7 +357,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
break;
case '.':
flags |= FLAGS_PREC;
if ('*' == *fmt) {
if('*' == *fmt) {
/* The precision is picked from a specified parameter */
flags |= FLAGS_PRECPARAM;
@@ -365,12 +365,12 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
param_num++;
i = dprintf_DollarString(fmt, &fmt);
if (i)
if(i)
precision = i;
else
precision = param_num;
if (precision > max_param)
if(precision > max_param)
max_param = precision;
}
else {
@@ -382,7 +382,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
flags |= FLAGS_SHORT;
break;
case 'l':
if (flags & FLAGS_LONG)
if(flags & FLAGS_LONG)
flags |= FLAGS_LONGLONG;
else
flags |= FLAGS_LONG;
@@ -410,7 +410,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
#endif
break;
case '0':
if (!(flags & FLAGS_LEFT))
if(!(flags & FLAGS_LEFT))
flags |= FLAGS_PAD_NIL;
/* FALLTHROUGH */
case '1': case '2': case '3': case '4':
@@ -503,7 +503,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
vto[i].width = width;
vto[i].precision = precision;
if (flags & FLAGS_WIDTHPARAM) {
if(flags & FLAGS_WIDTHPARAM) {
/* we have the width specified from a parameter, so we make that
parameter's info setup properly */
vto[i].width = width - 1;
@@ -513,7 +513,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
vto[i].precision = vto[i].width = 0; /* can't use width or precision
of width! */
}
if (flags & FLAGS_PRECPARAM) {
if(flags & FLAGS_PRECPARAM) {
/* we have the precision specified from a parameter, so we make that
parameter's info setup properly */
vto[i].precision = precision - 1;
@@ -533,7 +533,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
/* Read the arg list parameters into our data list */
for (i=0; i<max_param; i++) {
if ((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
if((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
{
/* Width/precision arguments must be read before the main argument
* they are attached to
@@ -620,7 +620,7 @@ static int dprintf_formatf(
created for us */
f = (char *)format;
while (*f != '\0') {
while(*f != '\0') {
/* Format spec modifiers. */
char alt;
@@ -644,7 +644,7 @@ static int dprintf_formatf(
#endif
long signed_num;
if (*f != '%') {
if(*f != '%') {
/* This isn't a format spec, so write everything out until the next one
OR end of string is reached. */
do {
@@ -659,7 +659,7 @@ static int dprintf_formatf(
'%' as a conversion specifier, it says "The complete format
specification shall be `%%'," so we can avoid all the width
and precision processing. */
if (*f == '%') {
if(*f == '%') {
++f;
OUTCHAR('%');
continue;
@@ -686,8 +686,11 @@ static int dprintf_formatf(
width = p->width;
/* pick up the specified precision */
if(p->flags & FLAGS_PRECPARAM)
if(p->flags & FLAGS_PRECPARAM) {
prec = vto[p->precision].data.num;
param_num++; /* since the precision is extraced from a parameter, we
must skip that to get to the next one properly */
}
else if(p->flags & FLAGS_PREC)
prec = p->precision;
else
@@ -700,12 +703,12 @@ static int dprintf_formatf(
num = p->data.num;
if(p->flags & FLAGS_CHAR) {
/* Character. */
if (!(p->flags & FLAGS_LEFT))
while (--width > 0)
if(!(p->flags & FLAGS_LEFT))
while(--width > 0)
OUTCHAR(' ');
OUTCHAR((char) num);
if (p->flags & FLAGS_LEFT)
while (--width > 0)
if(p->flags & FLAGS_LEFT)
while(--width > 0)
OUTCHAR(' ');
break;
}
@@ -756,47 +759,47 @@ static int dprintf_formatf(
char *w;
/* Supply a default precision if none was given. */
if (prec == -1)
if(prec == -1)
prec = 1;
/* Put the number in WORK. */
w = workend;
while (num > 0) {
while(num > 0) {
*w-- = digits[num % base];
num /= base;
}
width -= (long)(workend - w);
prec -= (long)(workend - w);
if (alt && base == 8 && prec <= 0) {
if(alt && base == 8 && prec <= 0) {
*w-- = '0';
--width;
}
if (prec > 0) {
if(prec > 0) {
width -= prec;
while (prec-- > 0)
while(prec-- > 0)
*w-- = '0';
}
if (alt && base == 16)
if(alt && base == 16)
width -= 2;
if (is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
if(is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
--width;
if (!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
while (width-- > 0)
if(!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
while(width-- > 0)
OUTCHAR(' ');
if (is_neg)
if(is_neg)
OUTCHAR('-');
else if (p->flags & FLAGS_SHOWSIGN)
else if(p->flags & FLAGS_SHOWSIGN)
OUTCHAR('+');
else if (p->flags & FLAGS_SPACE)
else if(p->flags & FLAGS_SPACE)
OUTCHAR(' ');
if (alt && base == 16) {
if(alt && base == 16) {
OUTCHAR('0');
if(p->flags & FLAGS_UPPER)
OUTCHAR('X');
@@ -804,17 +807,17 @@ static int dprintf_formatf(
OUTCHAR('x');
}
if (!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
while (width-- > 0)
if(!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
while(width-- > 0)
OUTCHAR('0');
/* Write the number. */
while (++w <= workend) {
while(++w <= workend) {
OUTCHAR(*w);
}
if (p->flags & FLAGS_LEFT)
while (width-- > 0)
if(p->flags & FLAGS_LEFT)
while(width-- > 0)
OUTCHAR(' ');
}
break;
@@ -827,9 +830,9 @@ static int dprintf_formatf(
size_t len;
str = (char *) p->data.str;
if ( str == NULL) {
if( str == NULL) {
/* Write null[] if there's space. */
if (prec == -1 || prec >= (long) sizeof(null) - 1) {
if(prec == -1 || prec >= (long) sizeof(null) - 1) {
str = null;
len = sizeof(null) - 1;
/* Disable quotes around (nil) */
@@ -843,24 +846,24 @@ static int dprintf_formatf(
else
len = strlen(str);
if (prec != -1 && (size_t) prec < len)
if(prec != -1 && (size_t) prec < len)
len = prec;
width -= (long)len;
if (p->flags & FLAGS_ALT)
if(p->flags & FLAGS_ALT)
OUTCHAR('"');
if (!(p->flags&FLAGS_LEFT))
while (width-- > 0)
if(!(p->flags&FLAGS_LEFT))
while(width-- > 0)
OUTCHAR(' ');
while (len-- > 0)
while(len-- > 0)
OUTCHAR(*str++);
if (p->flags&FLAGS_LEFT)
while (width-- > 0)
if(p->flags&FLAGS_LEFT)
while(width-- > 0)
OUTCHAR(' ');
if (p->flags & FLAGS_ALT)
if(p->flags & FLAGS_ALT)
OUTCHAR('"');
}
break;
@@ -870,7 +873,7 @@ static int dprintf_formatf(
{
void *ptr;
ptr = (void *) p->data.ptr;
if (ptr != NULL) {
if(ptr != NULL) {
/* If the pointer is not NULL, write it as a %#x spec. */
base = 16;
digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
@@ -885,13 +888,13 @@ static int dprintf_formatf(
const char *point;
width -= sizeof(strnil) - 1;
if (p->flags & FLAGS_LEFT)
while (width-- > 0)
if(p->flags & FLAGS_LEFT)
while(width-- > 0)
OUTCHAR(' ');
for (point = strnil; *point != '\0'; ++point)
OUTCHAR(*point);
if (! (p->flags & FLAGS_LEFT))
while (width-- > 0)
if(! (p->flags & FLAGS_LEFT))
while(width-- > 0)
OUTCHAR(' ');
}
}
@@ -905,24 +908,24 @@ static int dprintf_formatf(
int len;
width = -1;
if (p->flags & FLAGS_WIDTH)
if(p->flags & FLAGS_WIDTH)
width = p->width;
else if (p->flags & FLAGS_WIDTHPARAM)
else if(p->flags & FLAGS_WIDTHPARAM)
width = vto[p->width].data.num;
prec = -1;
if (p->flags & FLAGS_PREC)
if(p->flags & FLAGS_PREC)
prec = p->precision;
else if (p->flags & FLAGS_PRECPARAM)
else if(p->flags & FLAGS_PRECPARAM)
prec = vto[p->precision].data.num;
if (p->flags & FLAGS_LEFT)
if(p->flags & FLAGS_LEFT)
strcat(formatbuf, "-");
if (p->flags & FLAGS_SHOWSIGN)
if(p->flags & FLAGS_SHOWSIGN)
strcat(formatbuf, "+");
if (p->flags & FLAGS_SPACE)
if(p->flags & FLAGS_SPACE)
strcat(formatbuf, " ");
if (p->flags & FLAGS_ALT)
if(p->flags & FLAGS_ALT)
strcat(formatbuf, "#");
fptr=&formatbuf[strlen(formatbuf)];
@@ -939,12 +942,12 @@ static int dprintf_formatf(
fptr += len;
left -= len;
}
if (p->flags & FLAGS_LONG)
if(p->flags & FLAGS_LONG)
*fptr++ = 'l';
if (p->flags & FLAGS_FLOATE)
if(p->flags & FLAGS_FLOATE)
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
else if (p->flags & FLAGS_FLOATG)
else if(p->flags & FLAGS_FLOATG)
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
else
*fptr++ = 'f';
@@ -963,13 +966,13 @@ static int dprintf_formatf(
case FORMAT_INTPTR:
/* Answer the count of characters written. */
#ifdef ENABLE_64BIT
if (p->flags & FLAGS_LONGLONG)
if(p->flags & FLAGS_LONGLONG)
*(LONG_LONG *) p->data.ptr = (LONG_LONG)done;
else
#endif
if (p->flags & FLAGS_LONG)
if(p->flags & FLAGS_LONG)
*(long *) p->data.ptr = (long)done;
else if (!(p->flags & FLAGS_SHORT))
else if(!(p->flags & FLAGS_SHORT))
*(int *) p->data.ptr = (int)done;
else
*(short *) p->data.ptr = (short)done;

View File

@@ -446,14 +446,14 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
/* for multi interface connections, we share DNS cache automatically if the
easy handle's one is currently private. */
if (easy->easy_handle->dns.hostcache &&
if(easy->easy_handle->dns.hostcache &&
(easy->easy_handle->dns.hostcachetype == HCACHE_PRIVATE)) {
Curl_hash_destroy(easy->easy_handle->dns.hostcache);
easy->easy_handle->dns.hostcache = NULL;
easy->easy_handle->dns.hostcachetype = HCACHE_NONE;
}
if (!easy->easy_handle->dns.hostcache ||
if(!easy->easy_handle->dns.hostcache ||
(easy->easy_handle->dns.hostcachetype == HCACHE_NONE)) {
easy->easy_handle->dns.hostcache = multi->hostcache;
easy->easy_handle->dns.hostcachetype = HCACHE_MULTI;
@@ -578,7 +578,7 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
alive connections when this is removed */
multi->num_alive--;
if (easy->easy_handle->state.is_in_pipeline &&
if(easy->easy_handle->state.is_in_pipeline &&
easy->state > CURLM_STATE_DO &&
easy->state < CURLM_STATE_COMPLETED) {
/* If the handle is in a pipeline and has finished sending off its
@@ -679,7 +679,7 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
/* NOTE NOTE NOTE
We do not touch the easy handle here! */
if (easy->msg)
if(easy->msg)
free(easy->msg);
free(easy);
@@ -701,7 +701,7 @@ void Curl_multi_handlePipeBreak(struct SessionHandle *data)
{
struct Curl_one_easy *one_easy = data->set.one_easy;
if (one_easy)
if(one_easy)
one_easy->easy_conn = NULL;
}
@@ -745,12 +745,12 @@ static int multi_getsock(struct Curl_one_easy *easy,
singlesocket() => multi_getsock().
*/
if (easy->easy_handle->state.pipe_broke ||
if(easy->easy_handle->state.pipe_broke ||
!easy->easy_conn) {
return 0;
}
if (easy->state > CURLM_STATE_CONNECT &&
if(easy->state > CURLM_STATE_CONNECT &&
easy->state < CURLM_STATE_COMPLETED) {
/* Set up ownership correctly */
easy->easy_conn->data = easy->easy_handle;
@@ -855,7 +855,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* Handle the case when the pipe breaks, i.e., the connection
we're using gets cleaned up and we're left with nothing. */
if (easy->easy_handle->state.pipe_broke) {
if(easy->easy_handle->state.pipe_broke) {
infof(easy->easy_handle, "Pipe broke: handle 0x%x, url = %s\n",
easy, easy->easy_handle->reqdata.path);
@@ -875,13 +875,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
}
if (easy->state > CURLM_STATE_CONNECT &&
if(easy->state > CURLM_STATE_CONNECT &&
easy->state < CURLM_STATE_COMPLETED) {
/* Make sure we set the connection's current owner */
easy->easy_conn->data = easy->easy_handle;
}
if (CURLM_STATE_WAITCONNECT <= easy->state &&
if(CURLM_STATE_WAITCONNECT <= easy->state &&
easy->state <= CURLM_STATE_DO &&
easy->easy_handle->change.url_changed) {
char *gotourl;
@@ -935,28 +935,28 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* Add this handle to the send pipeline */
easy->result = Curl_addHandleToPipeline(easy->easy_handle,
easy->easy_conn->send_pipe);
if(CURLE_OK == easy->result) {
if(async)
/* We're now waiting for an asynchronous name lookup */
multistate(easy, CURLM_STATE_WAITRESOLVE);
else {
/* after the connect has been sent off, go WAITCONNECT unless the
protocol connect is already done and we can go directly to
WAITDO! */
result = CURLM_CALL_MULTI_PERFORM;
if(CURLE_OK == easy->result) {
if(async)
/* We're now waiting for an asynchronous name lookup */
multistate(easy, CURLM_STATE_WAITRESOLVE);
else {
/* after the connect has been sent off, go WAITCONNECT unless the
protocol connect is already done and we can go directly to
WAITDO! */
result = CURLM_CALL_MULTI_PERFORM;
if(protocol_connect)
multistate(easy, CURLM_STATE_WAITDO);
else {
if(protocol_connect)
multistate(easy, CURLM_STATE_WAITDO);
else {
#ifndef CURL_DISABLE_HTTP
if (easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else
if(easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else
#endif
multistate(easy, CURLM_STATE_WAITCONNECT);
}
}
}
multistate(easy, CURLM_STATE_WAITCONNECT);
}
}
}
}
break;
@@ -985,7 +985,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multistate(easy, CURLM_STATE_WAITDO);
else {
#ifndef CURL_DISABLE_HTTP
if (easy->easy_conn->bits.tunnel_connecting)
if(easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else
#endif
@@ -1008,7 +1008,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->result = Curl_http_connect(easy->easy_conn, &protocol_connect);
if(CURLE_OK == easy->result) {
if (!easy->easy_conn->bits.tunnel_connecting)
if(!easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITCONNECT);
}
break;
@@ -1038,7 +1038,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
BUT if we are using a proxy we must change to WAITPROXYCONNECT
*/
#ifndef CURL_DISABLE_HTTP
if (easy->easy_conn->bits.tunnel_connecting)
if(easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else
#endif
@@ -1057,7 +1057,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* protocol-specific connect phase */
easy->result = Curl_protocol_connecting(easy->easy_conn,
&protocol_connect);
if(protocol_connect) {
if((easy->result == CURLE_OK) && protocol_connect) {
/* after the connect has completed, go WAITDO */
multistate(easy, CURLM_STATE_WAITDO);
result = CURLM_CALL_MULTI_PERFORM;
@@ -1080,7 +1080,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
Curl_isHandleAtHead(easy->easy_handle,
easy->easy_conn->send_pipe));
#endif
if (!easy->easy_conn->writechannel_inuse &&
if(!easy->easy_conn->writechannel_inuse &&
Curl_isHandleAtHead(easy->easy_handle,
easy->easy_conn->send_pipe)) {
/* Grab the channel */
@@ -1121,11 +1121,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
else {
/* we're done with the DO, now DO_DONE */
easy->result = Curl_readwrite_init(easy->easy_conn);
if(CURLE_OK == easy->result) {
multistate(easy, CURLM_STATE_DO_DONE);
result = CURLM_CALL_MULTI_PERFORM;
}
multistate(easy, CURLM_STATE_DO_DONE);
result = CURLM_CALL_MULTI_PERFORM;
}
}
else {
@@ -1152,11 +1149,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
else {
/* we're done with the DO, now DO_DONE */
easy->result = Curl_readwrite_init(easy->easy_conn);
if(CURLE_OK == easy->result) {
multistate(easy, CURLM_STATE_DO_DONE);
result = CURLM_CALL_MULTI_PERFORM;
}
multistate(easy, CURLM_STATE_DO_DONE);
result = CURLM_CALL_MULTI_PERFORM;
}
} /* dophase_done */
}
@@ -1179,17 +1173,19 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
*/
easy->result = Curl_do_more(easy->easy_conn);
if(CURLE_OK == easy->result)
easy->result = Curl_readwrite_init(easy->easy_conn);
else
/* Remove ourselves from the send pipeline */
Curl_removeHandleFromPipeline(easy->easy_handle,
easy->easy_conn->send_pipe);
/* No need to remove ourselves from the send pipeline here since that
is done for us in Curl_done() */
if(CURLE_OK == easy->result) {
multistate(easy, CURLM_STATE_DO_DONE);
result = CURLM_CALL_MULTI_PERFORM;
}
else {
/* failure detected */
Curl_posttransfer(easy->easy_handle);
Curl_done(&easy->easy_conn, easy->result, FALSE);
disconnect_conn = TRUE;
}
}
break;
@@ -1202,9 +1198,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe);
multistate(easy, CURLM_STATE_WAITPERFORM);
result = CURLM_CALL_MULTI_PERFORM;
Curl_pre_readwrite(easy->easy_conn);
break;
case CURLM_STATE_WAITPERFORM:
@@ -1217,7 +1210,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe));
#endif
/* Wait for our turn to PERFORM */
if (!easy->easy_conn->readchannel_inuse &&
if(!easy->easy_conn->readchannel_inuse &&
Curl_isHandleAtHead(easy->easy_handle,
easy->easy_conn->recv_pipe)) {
/* Grab the channel */
@@ -1230,7 +1223,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
/* if both rates are within spec, resume transfer */
Curl_pgrsUpdate(easy->easy_conn);
if ( ( ( easy->easy_handle->set.max_send_speed == 0 ) ||
if( ( ( easy->easy_handle->set.max_send_speed == 0 ) ||
( easy->easy_handle->progress.ulspeed <
easy->easy_handle->set.max_send_speed ) ) &&
( ( easy->easy_handle->set.max_recv_speed == 0 ) ||
@@ -1242,7 +1235,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_PERFORM:
/* check if over speed */
if ( ( ( easy->easy_handle->set.max_send_speed > 0 ) &&
if( ( ( easy->easy_handle->set.max_send_speed > 0 ) &&
( easy->easy_handle->progress.ulspeed >
easy->easy_handle->set.max_send_speed ) ) ||
( ( easy->easy_handle->set.max_recv_speed > 0 ) &&
@@ -1261,12 +1254,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
k = &easy->easy_handle->reqdata.keep;
if (!(k->keepon & KEEP_READ)) {
if(!(k->keepon & KEEP_READ)) {
/* We're done reading */
easy->easy_conn->readchannel_inuse = FALSE;
}
if (!(k->keepon & KEEP_WRITE)) {
if(!(k->keepon & KEEP_WRITE)) {
/* We're done writing */
easy->easy_conn->writechannel_inuse = FALSE;
}
@@ -1332,14 +1325,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe);
easy->easy_handle->state.is_in_pipeline = FALSE;
if (easy->easy_conn->bits.stream_was_rewound) {
if(easy->easy_conn->bits.stream_was_rewound) {
/* This request read past its response boundary so we quickly
let the other requests consume those bytes since there is no
guarantee that the socket will become active again */
result = CURLM_CALL_MULTI_PERFORM;
}
if (!easy->easy_handle->state.cancelled) {
if(!easy->easy_handle->state.cancelled) {
/* post-transfer command */
easy->result = Curl_done(&easy->easy_conn, CURLE_OK, FALSE);
@@ -1351,7 +1344,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
case CURLM_STATE_COMPLETED:
if (easy->easy_handle->state.cancelled)
if(easy->easy_handle->state.cancelled)
/* Go into the CANCELLED state if we were cancelled */
multistate(easy, CURLM_STATE_CANCELLED);
@@ -1399,7 +1392,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe);
}
if (disconnect_conn) {
if(disconnect_conn) {
Curl_disconnect(easy->easy_conn); /* disconnect properly */
/* This is where we make sure that the easy_conn pointer is reset.
@@ -1412,9 +1405,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
}
} while (easy->easy_handle->change.url_changed);
} while(easy->easy_handle->change.url_changed);
if ((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) {
if((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) {
if(easy->easy_handle->dns.hostcachetype == HCACHE_MULTI) {
/* clear out the usage of the shared DNS cache */
easy->easy_handle->dns.hostcache = NULL;
@@ -1467,7 +1460,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
while(easy != &multi->easy) {
CURLMcode result;
if (easy->easy_handle->state.cancelled &&
if(easy->easy_handle->state.cancelled &&
easy->state == CURLM_STATE_CANCELLED) {
/* Remove cancelled handles once it's safe to do so */
Curl_multi_rmeasy(multi_handle, easy->easy_handle);
@@ -1493,7 +1486,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
int key = now.tv_sec; /* drop the usec part */
multi->timetree = Curl_splaygetbest(key, multi->timetree, &t);
if (t) {
if(t) {
struct SessionHandle *d = t->payload;
struct timeval* tv = &d->state.expiretime;
@@ -1507,7 +1500,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
*running_handles = multi->num_alive;
if ( CURLM_OK >= returncode )
if( CURLM_OK >= returncode )
update_timer(multi);
return returncode;
}
@@ -1573,7 +1566,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle)
Curl_easy_addmulti(easy->easy_handle, NULL); /* clear the association */
if (easy->msg)
if(easy->msg)
free(easy->msg);
free(easy);
easy = nexteasy;
@@ -1748,7 +1741,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
/* or should we fall-through and do the timer-based stuff? */
return result;
}
else if (s != CURL_SOCKET_TIMEOUT) {
else if(s != CURL_SOCKET_TIMEOUT) {
struct Curl_sh_entry *entry =
Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s));
@@ -1763,12 +1756,12 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
/* bad bad bad bad bad bad bad */
return CURLM_INTERNAL_ERROR;
if (data->set.one_easy->easy_conn) /* set socket event bitmask */
if(data->set.one_easy->easy_conn) /* set socket event bitmask */
data->set.one_easy->easy_conn->cselect_bits = ev_bitmask;
result = multi_runsingle(multi, data->set.one_easy);
if (data->set.one_easy->easy_conn)
if(data->set.one_easy->easy_conn)
data->set.one_easy->easy_conn->cselect_bits = 0;
if(CURLM_OK >= result)
@@ -1873,7 +1866,7 @@ CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
{
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
0, running_handles);
if (CURLM_OK >= result)
if(CURLM_OK >= result)
update_timer((struct Curl_multi *)multi_handle);
return result;
}
@@ -1883,7 +1876,7 @@ CURLMcode curl_multi_socket_action(CURLM *multi_handle, curl_socket_t s,
{
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
ev_bitmask, running_handles);
if (CURLM_OK >= result)
if(CURLM_OK >= result)
update_timer((struct Curl_multi *)multi_handle);
return result;
}
@@ -1893,7 +1886,7 @@ CURLMcode curl_multi_socket_all(CURLM *multi_handle, int *running_handles)
{
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle,
TRUE, CURL_SOCKET_BAD, 0, running_handles);
if (CURLM_OK >= result)
if(CURLM_OK >= result)
update_timer((struct Curl_multi *)multi_handle);
return result;
}
@@ -1940,11 +1933,11 @@ CURLMcode curl_multi_timeout(CURLM *multi_handle,
static int update_timer(struct Curl_multi *multi)
{
long timeout_ms;
if (!multi->timer_cb)
if(!multi->timer_cb)
return 0;
if ( multi_timeout(multi, &timeout_ms) != CURLM_OK )
if( multi_timeout(multi, &timeout_ms) != CURLM_OK )
return -1;
if ( timeout_ms < 0 )
if( timeout_ms < 0 )
return 0;
/* When multi_timeout() is done, multi->timetree points to the node with the

View File

@@ -99,7 +99,7 @@ int Curl_parsenetrc(char *host,
char *override = curl_getenv("CURL_DEBUG_NETRC");
if (override) {
if(override) {
fprintf(stderr, "NETRC: overridden " NETRC " file: %s\n", override);
netrcfile = override;
netrc_alloc = TRUE;
@@ -115,7 +115,7 @@ int Curl_parsenetrc(char *host,
else {
struct passwd *pw;
pw= getpwuid(geteuid());
if (pw) {
if(pw) {
#ifdef VMS
home = decc$translate_vms(pw->pw_dir);
#else
@@ -148,7 +148,7 @@ int Curl_parsenetrc(char *host,
tok=strtok_r(netrcbuffer, " \t\n", &tok_buf);
while(!done && tok) {
if (login[0] && password[0]) {
if(login[0] && password[0]) {
done=TRUE;
break;
}
@@ -179,7 +179,7 @@ int Curl_parsenetrc(char *host,
case HOSTVALID:
/* we are now parsing sub-keywords concerning "our" host */
if(state_login) {
if (specific_login) {
if(specific_login) {
state_our_login = strequal(login, tok);
}
else {
@@ -191,7 +191,7 @@ int Curl_parsenetrc(char *host,
state_login=0;
}
else if(state_password) {
if (state_our_login || !specific_login) {
if(state_our_login || !specific_login) {
strncpy(password, tok, PASSWORDSIZE-1);
#ifdef _NETRC_DEBUG
fprintf(stderr, "PASSWORD: %s\n", password);
@@ -212,7 +212,7 @@ int Curl_parsenetrc(char *host,
} /* switch (state) */
tok = strtok_r(NULL, " \t\n", &tok_buf);
} /* while (tok) */
} /* while(tok) */
} /* while fgets() */
fclose(file);

View File

@@ -283,7 +283,7 @@ nss_load_cert(const char *filename, PRBool cacert)
}
else {
/* A nickname from the NSS internal database */
if (cacert)
if(cacert)
return 0; /* You can't specify an NSS CA nickname this way */
nickname = strdup(filename);
goto done;
@@ -296,7 +296,7 @@ nss_load_cert(const char *filename, PRBool cacert)
* for storing certificates. With each new user certificate we increment
* the slot count. We only support 1 user certificate right now.
*/
if (cacert)
if(cacert)
slotID = 0;
else
slotID = 1;
@@ -308,7 +308,7 @@ nss_load_cert(const char *filename, PRBool cacert)
slot = PK11_FindSlotByName(slotname);
if (!slot) {
if(!slot) {
free(slotname);
free(nickname);
return 0;
@@ -318,7 +318,7 @@ nss_load_cert(const char *filename, PRBool cacert)
PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++;
PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)filename,
strlen(filename)+1); attrs++;
if (cacert) {
if(cacert) {
PK11_SETATTRS(attrs, CKA_TRUST, &cktrue, sizeof(CK_BBOOL) ); attrs++;
}
else {
@@ -348,11 +348,11 @@ done:
/* Double-check that the certificate or nickname requested exists in
* either the token or the NSS certificate database.
*/
if (!cacert) {
if(!cacert) {
cert = PK11_FindCertFromNickname((char *)nickname, NULL);
/* An invalid nickname was passed in */
if (cert == NULL) {
if(cert == NULL) {
free(nickname);
PR_SetError(SEC_ERROR_UNKNOWN_CERT, 0);
return 0;
@@ -533,7 +533,7 @@ static SECStatus nss_Init_Tokens(struct connectdata * conn)
ret = PK11_Authenticate(slot, PR_TRUE, parg);
if(SECSuccess != ret) {
if (PR_GetError() == SEC_ERROR_BAD_PASSWORD)
if(PR_GetError() == SEC_ERROR_BAD_PASSWORD)
infof(conn->data, "The password for token '%s' is incorrect\n",
PK11_GetTokenName(slot));
status = SECFailure;
@@ -556,7 +556,7 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
CERTCertificate *cert = NULL;
char *subject, *issuer;
if (conn->data->set.ssl.certverifyresult!=0)
if(conn->data->set.ssl.certverifyresult!=0)
return success;
conn->data->set.ssl.certverifyresult=err;
@@ -568,34 +568,34 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
switch(err) {
case SEC_ERROR_CA_CERT_INVALID:
infof(conn->data, "Issuer certificate is invalid: '%s'\n", issuer);
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
break;
case SEC_ERROR_UNTRUSTED_ISSUER:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "Certificate is signed by an untrusted issuer: '%s'\n",
issuer);
break;
case SSL_ERROR_BAD_CERT_DOMAIN:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "common name: %s (does not match '%s')\n",
subject, conn->host.dispname);
break;
case SEC_ERROR_EXPIRED_CERTIFICATE:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "Remote Certificate has expired.\n");
break;
default:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "Bad certificate received. Subject = '%s', "
"Issuer = '%s'\n", subject, issuer);
break;
}
if (success == SECSuccess)
if(success == SECSuccess)
infof(conn->data, "SSL certificate verify ok.\n");
PR_Free(subject);
PR_Free(issuer);
@@ -623,10 +623,10 @@ static void display_conn_info(struct connectdata *conn, PRFileDesc *sock)
char timeString[256];
PRTime notBefore, notAfter;
if (SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
SECSuccess && channel.length == sizeof channel &&
channel.cipherSuite) {
if (SSL_GetCipherSuiteInfo(channel.cipherSuite,
if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
&suite, sizeof suite) == SECSuccess) {
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
}
@@ -678,7 +678,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
proto_win = SSL_RevealPinArg(sock);
if (!nickname)
if(!nickname)
return secStatus;
cert = PK11_FindCertFromNickname(nickname, proto_win);
@@ -708,7 +708,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
*pRetKey = privKey;
}
else {
if (cert)
if(cert)
CERT_DestroyCertificate(cert);
}
@@ -814,11 +814,11 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
certDir = getenv("SSL_DIR"); /* Look in $SSL_DIR */
if (!certDir) {
if(!certDir) {
struct stat st;
if (stat(SSL_DIR, &st) == 0)
if (S_ISDIR(st.st_mode)) {
if(stat(SSL_DIR, &st) == 0)
if(S_ISDIR(st.st_mode)) {
certDir = (char *)SSL_DIR;
}
}
@@ -845,8 +845,8 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
mod = SECMOD_LoadUserModule(configstring, NULL, PR_FALSE);
free(configstring);
if (!mod || !mod->loaded) {
if (mod) {
if(!mod || !mod->loaded) {
if(mod) {
SECMOD_DestroyModule(mod);
mod = NULL;
}
@@ -912,31 +912,31 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
if(!data->set.ssl.verifypeer)
/* skip the verifying of the peer */
;
else if (data->set.ssl.CAfile) {
else if(data->set.ssl.CAfile) {
int rc = nss_load_cert(data->set.ssl.CAfile, PR_TRUE);
if (!rc) {
if(!rc) {
curlerr = CURLE_SSL_CACERT_BADFILE;
goto error;
}
}
else if (data->set.ssl.CApath) {
else if(data->set.ssl.CApath) {
struct stat st;
PRDir *dir;
PRDirEntry *entry;
if (stat(data->set.ssl.CApath, &st) == -1) {
if(stat(data->set.ssl.CApath, &st) == -1) {
curlerr = CURLE_SSL_CACERT_BADFILE;
goto error;
}
if (S_ISDIR(st.st_mode)) {
if(S_ISDIR(st.st_mode)) {
int rc;
dir = PR_OpenDir(data->set.ssl.CApath);
do {
entry = PR_ReadDir(dir, PR_SKIP_BOTH | PR_SKIP_HIDDEN);
if (entry) {
if(entry) {
char fullpath[PATH_MAX];
snprintf(fullpath, sizeof(fullpath), "%s/%s", data->set.ssl.CApath,
@@ -946,7 +946,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
}
/* This is purposefully tolerant of errors so non-PEM files
* can be in the same directory */
} while (entry != NULL);
} while(entry != NULL);
PR_CloseDir(dir);
}
}
@@ -963,7 +963,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
nickname = (char *)malloc(PATH_MAX);
if(is_file(data->set.str[STRING_CERT])) {
n = strrchr(data->set.str[STRING_CERT], '/');
if (n) {
if(n) {
n++; /* skip last slash */
snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", 1, n);
}
@@ -975,7 +975,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
free(nickname);
goto error;
}
if (!cert_stuff(conn, data->set.str[STRING_CERT],
if(!cert_stuff(conn, data->set.str[STRING_CERT],
data->set.str[STRING_KEY])) {
/* failf() is already done in cert_stuff() */
free(nickname);
@@ -1011,10 +1011,10 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
SSL_SetURL(connssl->handle, conn->host.name);
/* Force the handshake now */
if (SSL_ForceHandshakeWithTimeout(connssl->handle,
if(SSL_ForceHandshakeWithTimeout(connssl->handle,
PR_SecondsToInterval(HANDSHAKE_TIMEOUT))
!= SECSuccess) {
if (conn->data->set.ssl.certverifyresult!=0)
if(conn->data->set.ssl.certverifyresult!=0)
curlerr = CURLE_SSL_CACERT;
goto error;
}

View File

@@ -82,7 +82,7 @@ int _NonAppStart( void *NLMHandle,
const char **messages )
{
NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
#ifndef __GNUC__
#pragma unused(cmdLine)
#pragma unused(loadDirPath)
@@ -105,7 +105,7 @@ int _NonAppStart( void *NLMHandle,
"<library-name> memory allocations",
AllocSignature);
if (!gAllocTag) {
if(!gAllocTag) {
OutputToScreen(errorScreen, "Unable to allocate resource tag for "
"library memory allocations.\n");
return -1;
@@ -113,7 +113,7 @@ int _NonAppStart( void *NLMHandle,
gLibId = register_library(DisposeLibraryData);
if (gLibId < -1) {
if(gLibId < -1) {
OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
return -1;
}
@@ -121,8 +121,8 @@ int _NonAppStart( void *NLMHandle,
gLibHandle = NLMHandle;
gLibLock = NXMutexAlloc(0, 0, &liblock);
if (!gLibLock) {
if(!gLibLock) {
OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
return -1;
}
@@ -175,7 +175,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
*/
app_data = (libdata_t *) get_app_data(id);
if (!app_data) {
if(!app_data) {
/*
** This application hasn't called us before; set up application AND per-thread
** data. Of course, just in case a thread from this same application is calling
@@ -186,25 +186,25 @@ int GetOrSetUpData(int id, libdata_t **appData,
*/
NXLock(gLibLock);
if (!(app_data = (libdata_t *) get_app_data(id))) {
if(!(app_data = (libdata_t *) get_app_data(id))) {
app_data = (libdata_t *) malloc(sizeof(libdata_t));
if (app_data) {
if(app_data) {
memset(app_data, 0, sizeof(libdata_t));
app_data->tenbytes = malloc(10);
app_data->lock = NXMutexAlloc(0, 0, &liblock);
if (!app_data->tenbytes || !app_data->lock) {
if (app_data->lock)
if(!app_data->tenbytes || !app_data->lock) {
if(app_data->lock)
NXMutexFree(app_data->lock);
free(app_data);
app_data = (libdata_t *) NULL;
err = ENOMEM;
}
if (app_data) {
if(app_data) {
/*
** Here we burn in the application data that we were trying to get by calling
** get_app_data(). Next time we call the first function, we'll get this data
@@ -213,8 +213,8 @@ int GetOrSetUpData(int id, libdata_t **appData,
** thread the first time it calls us.
*/
err = set_app_data(gLibId, app_data);
if (err) {
if(err) {
free(app_data);
app_data = (libdata_t *) NULL;
err = ENOMEM;
@@ -222,23 +222,23 @@ int GetOrSetUpData(int id, libdata_t **appData,
else {
/* create key for thread-specific data... */
err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
if (err) /* (no more keys left?) */
if(err) /* (no more keys left?) */
key = -1;
app_data->perthreadkey = key;
}
}
}
}
NXUnlock(gLibLock);
}
if (app_data) {
if(app_data) {
key = app_data->perthreadkey;
if (key != -1 /* couldn't create a key? no thread data */
if(key != -1 /* couldn't create a key? no thread data */
&& !(err = NXKeyGetValue(key, (void **) &thread_data))
&& !thread_data) {
/*
@@ -249,18 +249,18 @@ int GetOrSetUpData(int id, libdata_t **appData,
** complex per-thread data.
*/
thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
if (thread_data) {
if(thread_data) {
thread_data->_errno = 0;
thread_data->twentybytes = malloc(20);
if (!thread_data->twentybytes) {
if(!thread_data->twentybytes) {
free(thread_data);
thread_data = (libthreaddata_t *) NULL;
err = ENOMEM;
}
if ((err = NXKeySetValue(key, thread_data))) {
if((err = NXKeySetValue(key, thread_data))) {
free(thread_data->twentybytes);
free(thread_data);
thread_data = (libthreaddata_t *) NULL;
@@ -269,10 +269,10 @@ int GetOrSetUpData(int id, libdata_t **appData,
}
}
if (appData)
if(appData)
*appData = app_data;
if (threadData)
if(threadData)
*threadData = thread_data;
return err;
@@ -280,12 +280,12 @@ int GetOrSetUpData(int id, libdata_t **appData,
int DisposeLibraryData( void *data )
{
if (data) {
if(data) {
void *tenbytes = ((libdata_t *) data)->tenbytes;
if (tenbytes)
if(tenbytes)
free(tenbytes);
free(data);
}
@@ -294,12 +294,12 @@ int DisposeLibraryData( void *data )
void DisposeThreadData( void *data )
{
if (data) {
if(data) {
void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
if (twentybytes)
if(twentybytes)
free(twentybytes);
free(data);
}
}
@@ -312,7 +312,7 @@ int main ( void )
{
/* initialize any globals here... */
/* do this if any global initializing was done
/* do this if any global initializing was done
SynchronizeStart();
*/
ExitThread (TSR_THREAD, 0);

View File

@@ -57,17 +57,17 @@ int netware_init ( void )
/* import UseAccurateCaseForPaths dynamically for NW3.x compatibility */
void (*pUseAccurateCaseForPaths)(int) = (void(*)(int))
ImportSymbol(myHandle, "UseAccurateCaseForPaths");
if (pUnAugmentAsterisk)
if(pUnAugmentAsterisk)
pUnAugmentAsterisk(1);
if (pUseAccurateCaseForPaths)
if(pUseAccurateCaseForPaths)
pUseAccurateCaseForPaths(1);
UnimportSymbol(myHandle, "UnAugmentAsterisk");
UnimportSymbol(myHandle, "UseAccurateCaseForPaths");
/* set long name space */
if ((SetCurrentNameSpace(4) == 255)) {
if((SetCurrentNameSpace(4) == 255)) {
rc = 1;
}
if ((SetTargetNameSpace(4) == 255)) {
if((SetTargetNameSpace(4) == 255)) {
rc = rc + 2;
}
return rc;

View File

@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2007, 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
@@ -154,7 +154,7 @@ static const struct tzinfo tz[]= {
0 monday - 6 sunday
*/
static int checkday(char *check, size_t len)
static int checkday(const char *check, size_t len)
{
int i;
const char * const *what;
@@ -173,7 +173,7 @@ static int checkday(char *check, size_t len)
return found?i:-1;
}
static int checkmonth(char *check)
static int checkmonth(const char *check)
{
int i;
const char * const *what;
@@ -193,7 +193,7 @@ static int checkmonth(char *check)
/* return the time zone offset between GMT and the input one, in number
of seconds or -1 if the timezone wasn't found/legal */
static int checktz(char *check)
static int checktz(const char *check)
{
unsigned int i;
const struct tzinfo *what;
@@ -325,7 +325,7 @@ static time_t Curl_parsedate(const char *date)
yearnum = val;
found = TRUE;
if(yearnum < 1900) {
if (yearnum > 70)
if(yearnum > 70)
yearnum += 1900;
else
yearnum += 2000;

View File

@@ -80,10 +80,10 @@ static CURLcode Curl_qsossl_init_session(struct SessionHandle * data)
certname = data->set.str[STRING_CERT];
if (!certname) {
if(!certname) {
certname = data->set.str[STRING_SSL_CAFILE];
if (!certname)
if(!certname)
return CURLE_OK; /* Use previous setup. */
}
@@ -94,7 +94,7 @@ static CURLcode Curl_qsossl_init_session(struct SessionHandle * data)
initappstr.sessionType = SSL_REGISTERED_AS_CLIENT;
rc = SSL_Init_Application(&initappstr);
if (rc == SSL_ERROR_NOT_REGISTERED) {
if(rc == SSL_ERROR_NOT_REGISTERED) {
initstr.keyringFileName = certname;
initstr.keyringPassword = data->set.str[STRING_KEY];
initstr.cipherSuiteList = NULL; /* Use default. */
@@ -141,7 +141,7 @@ static CURLcode Curl_qsossl_create(struct connectdata * conn, int sockindex)
h = SSL_Create(conn->sock[sockindex], SSL_ENCRYPT);
if (!h) {
if(!h) {
failf(conn->data, "SSL_Create() I/O error: %s\n", strerror(errno));
return CURLE_SSL_CONNECT_ERROR;
}
@@ -169,17 +169,17 @@ static CURLcode Curl_qsossl_handshake(struct connectdata * conn, int sockindex)
h->exitPgm = NULL;
if (!data->set.ssl.verifyhost)
if(!data->set.ssl.verifyhost)
h->exitPgm = Curl_qsossl_trap_cert;
if (data->set.connecttimeout) {
if(data->set.connecttimeout) {
timeout_ms = data->set.connecttimeout;
if (data->set.timeout)
if (timeout_ms > data->set.timeout)
if(data->set.timeout)
if(timeout_ms > data->set.timeout)
timeout_ms = data->set.timeout;
}
else if (data->set.timeout)
else if(data->set.timeout)
timeout_ms = data->set.timeout;
else
timeout_ms = DEFAULT_CONNECT_TIMEOUT;
@@ -253,10 +253,10 @@ CURLcode Curl_qsossl_connect(struct connectdata * conn, int sockindex)
rc = Curl_qsossl_init_session(data);
if (rc == CURLE_OK) {
if(rc == CURLE_OK) {
rc = Curl_qsossl_create(conn, sockindex);
if (rc == CURLE_OK)
if(rc == CURLE_OK)
rc = Curl_qsossl_handshake(conn, sockindex);
else {
SSL_Destroy(connssl->handle);
@@ -281,7 +281,7 @@ static int Curl_qsossl_close_one(struct ssl_connect_data * conn,
rc = SSL_Destroy(conn->handle);
if(rc) {
if (rc == SSL_ERROR_IO) {
if(rc == SSL_ERROR_IO) {
failf(data, "SSL_Destroy() I/O error: %s\n", strerror(errno));
return -1;
}
@@ -326,13 +326,13 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
int rc;
char buf[120];
if (!connssl->handle)
if(!connssl->handle)
return 0;
if (data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
if(data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
return 0;
if (Curl_qsossl_close_one(connssl, data))
if(Curl_qsossl_close_one(connssl, data))
return -1;
rc = 0;
@@ -341,14 +341,14 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
for (;;) {
if (what < 0) {
if(what < 0) {
/* anything that gets here is fatally bad */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
rc = -1;
break;
}
if (!what) { /* timeout */
if(!what) { /* timeout */
failf(data, "SSL shutdown timeout");
break;
}
@@ -358,12 +358,12 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
nread = read(conn->sock[sockindex], buf, sizeof(buf));
if (nread < 0) {
if(nread < 0) {
failf(data, "read: %s\n", strerror(errno));
rc = -1;
}
if (nread <= 0)
if(nread <= 0)
break;
what = Curl_socket_ready(conn->sock[sockindex], CURL_SOCKET_BAD, 0);
@@ -470,13 +470,13 @@ int Curl_qsossl_check_cxn(struct connectdata * cxn)
/* The only thing that can be tested here is at the socket level. */
if (!cxn->ssl[FIRSTSOCKET].handle)
if(!cxn->ssl[FIRSTSOCKET].handle)
return 0; /* connection has been closed */
err = 0;
errlen = sizeof err;
if (getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
(unsigned char *) &err, &errlen) ||
errlen != sizeof err || err)
return 0; /* connection has been closed */

View File

@@ -9,6 +9,9 @@
*
* Copyright (c) 1998, 1999 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
*
* Copyright (C) 2001 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,13 +70,13 @@
#define min(a, b) ((a) < (b) ? (a) : (b))
static const struct {
enum protection_level level;
const char *name;
enum protection_level level;
const char *name;
} level_names[] = {
{ prot_clear, "clear" },
{ prot_safe, "safe" },
{ prot_confidential, "confidential" },
{ prot_private, "private" }
{ prot_clear, "clear" },
{ prot_safe, "safe" },
{ prot_confidential, "confidential" },
{ prot_private, "private" }
};
static enum protection_level
@@ -88,12 +91,12 @@ name_to_level(const char *name)
static const struct Curl_sec_client_mech * const mechs[] = {
#ifdef HAVE_GSSAPI
&Curl_krb5_client_mech,
&Curl_krb5_client_mech,
#endif
#ifdef HAVE_KRB4
&Curl_krb4_client_mech,
&Curl_krb4_client_mech,
#endif
NULL
NULL
};
int
@@ -116,11 +119,11 @@ block_read(int fd, void *buf, size_t len)
int b;
while(len) {
b = read(fd, p, len);
if (b == 0)
if(b == 0)
return 0;
else if (b < 0 && (errno == EINTR || errno == EAGAIN))
else if(b < 0 && (errno == EINTR || errno == EAGAIN))
continue;
else if (b < 0)
else if(b < 0)
return -1;
len -= b;
p += b;
@@ -135,7 +138,7 @@ block_write(int fd, const void *buf, size_t len)
int b;
while(len) {
b = write(fd, p, len);
if (b < 0 && (errno == EINTR || errno == EAGAIN))
if(b < 0 && (errno == EINTR || errno == EAGAIN))
continue;
else if(b < 0)
return -1;
@@ -153,16 +156,16 @@ sec_get_data(struct connectdata *conn,
int b;
b = block_read(fd, &len, sizeof(len));
if (b == 0)
if(b == 0)
return 0;
else if (b < 0)
else if(b < 0)
return -1;
len = ntohl(len);
buf->data = realloc(buf->data, len);
b = buf->data ? block_read(fd, buf->data, len) : -1;
if (b == 0)
if(b == 0)
return 0;
else if (b < 0)
else if(b < 0)
return -1;
buf->size = (conn->mech->decode)(conn->app_data, buf->data, len,
conn->data_prot, conn);
@@ -173,64 +176,64 @@ sec_get_data(struct connectdata *conn,
static size_t
buffer_read(struct krb4buffer *buf, void *data, size_t len)
{
len = min(len, buf->size - buf->index);
memcpy(data, (char*)buf->data + buf->index, len);
buf->index += len;
return len;
len = min(len, buf->size - buf->index);
memcpy(data, (char*)buf->data + buf->index, len);
buf->index += len;
return len;
}
static size_t
buffer_write(struct krb4buffer *buf, void *data, size_t len)
{
if(buf->index + len > buf->size) {
void *tmp;
if(buf->data == NULL)
tmp = malloc(1024);
else
tmp = realloc(buf->data, buf->index + len);
if(tmp == NULL)
return -1;
buf->data = tmp;
buf->size = buf->index + len;
}
memcpy((char*)buf->data + buf->index, data, len);
buf->index += len;
return len;
if(buf->index + len > buf->size) {
void *tmp;
if(buf->data == NULL)
tmp = malloc(1024);
else
tmp = realloc(buf->data, buf->index + len);
if(tmp == NULL)
return -1;
buf->data = tmp;
buf->size = buf->index + len;
}
memcpy((char*)buf->data + buf->index, data, len);
buf->index += len;
return len;
}
int
Curl_sec_read(struct connectdata *conn, int fd, void *buffer, int length)
{
size_t len;
int rx = 0;
size_t len;
int rx = 0;
if(conn->sec_complete == 0 || conn->data_prot == 0)
return read(fd, buffer, length);
if(conn->sec_complete == 0 || conn->data_prot == 0)
return read(fd, buffer, length);
if(conn->in_buffer.eof_flag){
conn->in_buffer.eof_flag = 0;
return 0;
if(conn->in_buffer.eof_flag){
conn->in_buffer.eof_flag = 0;
return 0;
}
len = buffer_read(&conn->in_buffer, buffer, length);
length -= len;
rx += len;
buffer = (char*)buffer + len;
while(length) {
if(sec_get_data(conn, fd, &conn->in_buffer) < 0)
return -1;
if(conn->in_buffer.size == 0) {
if(rx)
conn->in_buffer.eof_flag = 1;
return rx;
}
len = buffer_read(&conn->in_buffer, buffer, length);
length -= len;
rx += len;
buffer = (char*)buffer + len;
while(length) {
if(sec_get_data(conn, fd, &conn->in_buffer) < 0)
return -1;
if(conn->in_buffer.size == 0) {
if(rx)
conn->in_buffer.eof_flag = 1;
return rx;
}
len = buffer_read(&conn->in_buffer, buffer, length);
length -= len;
rx += len;
buffer = (char*)buffer + len;
}
return rx;
}
return rx;
}
static int
@@ -255,15 +258,17 @@ sec_send(struct connectdata *conn, int fd, char *from, int length)
bytes = Curl_base64_encode(conn->data, (char *)buf, bytes, &cmdbuf);
if(bytes > 0) {
if(protlevel == prot_private)
block_write(fd, "ENC ", 4);
block_write(fd, "ENC ", 4);
else
block_write(fd, "MIC ", 4);
block_write(fd, "MIC ", 4);
block_write(fd, cmdbuf, bytes);
block_write(fd, "\r\n", 2);
Curl_infof(conn->data, "%s %s\n", protlevel == prot_private ? "ENC" : "MIC", cmdbuf);
Curl_infof(conn->data, "%s %s\n",
protlevel == prot_private ? "ENC" : "MIC", cmdbuf);
free(cmdbuf);
}
} else {
}
else {
bytes = htonl(bytes);
block_write(fd, &bytes, sizeof(bytes));
block_write(fd, buf, ntohl(bytes));
@@ -278,7 +283,7 @@ Curl_sec_fflush_fd(struct connectdata *conn, int fd)
if(conn->data_prot != prot_clear) {
if(conn->out_buffer.index > 0){
Curl_sec_write(conn, fd,
conn->out_buffer.data, conn->out_buffer.index);
conn->out_buffer.data, conn->out_buffer.index);
conn->out_buffer.index = 0;
}
sec_send(conn, fd, NULL, 0);
@@ -457,7 +462,7 @@ Curl_sec_login(struct connectdata *conn)
void *tmp;
tmp = realloc(conn->app_data, (*m)->size);
if (tmp == NULL) {
if(tmp == NULL) {
failf (data, "realloc %u failed", (*m)->size);
return -1;
}
@@ -518,7 +523,7 @@ Curl_sec_login(struct connectdata *conn)
void
Curl_sec_end(struct connectdata *conn)
{
if (conn->mech != NULL) {
if(conn->mech != NULL) {
if(conn->mech->end)
(conn->mech->end)(conn->app_data);
memset(conn->app_data, 0, conn->mech->size);

View File

@@ -52,7 +52,7 @@
/* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1] */
#if defined(USE_WINSOCK) || defined(TPF)
#define VERIFY_SOCK(x) do { } while (0)
#define VERIFY_SOCK(x) do { } while(0)
#else
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
#define VERIFY_SOCK(x) do { \
@@ -105,9 +105,9 @@ static int wait_ms(int timeout_ms)
#endif
int r = 0;
if (!timeout_ms)
if(!timeout_ms)
return 0;
if (timeout_ms < 0) {
if(timeout_ms < 0) {
SET_SOCKERRNO(EINVAL);
return -1;
}
@@ -126,17 +126,17 @@ static int wait_ms(int timeout_ms)
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
r = select(0, NULL, NULL, NULL, &pending_tv);
#endif /* HAVE_POLL_FINE */
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || error_is_EINTR)
if((error == EINVAL) || error_is_EINTR)
break;
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
} while (r == -1);
} while(r == -1);
#endif /* USE_WINSOCK */
if (r)
if(r)
r = -1;
return r;
}
@@ -189,7 +189,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
when function is called with a zero timeout or a negative timeout
value indicating a blocking call should be performed. */
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms;
initial_tv = curlx_tvnow();
}
@@ -197,13 +197,13 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
#ifdef HAVE_POLL_FINE
num = 0;
if (readfd != CURL_SOCKET_BAD) {
if(readfd != CURL_SOCKET_BAD) {
pfd[num].fd = readfd;
pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
pfd[num].revents = 0;
num++;
}
if (writefd != CURL_SOCKET_BAD) {
if(writefd != CURL_SOCKET_BAD) {
pfd[num].fd = writefd;
pfd[num].events = POLLWRNORM|POLLOUT;
pfd[num].revents = 0;
@@ -211,41 +211,41 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
}
do {
if (timeout_ms < 0)
if(timeout_ms < 0)
pending_ms = -1;
else if (!timeout_ms)
else if(!timeout_ms)
pending_ms = 0;
r = poll(pfd, num, pending_ms);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || error_is_EINTR)
if((error == EINVAL) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
if (r < 0)
if(r < 0)
return -1;
if (r == 0)
if(r == 0)
return 0;
ret = 0;
num = 0;
if (readfd != CURL_SOCKET_BAD) {
if (pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
if(readfd != CURL_SOCKET_BAD) {
if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
ret |= CURL_CSELECT_IN;
if (pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
ret |= CURL_CSELECT_ERR;
num++;
}
if (writefd != CURL_SOCKET_BAD) {
if (pfd[num].revents & (POLLWRNORM|POLLOUT))
if(writefd != CURL_SOCKET_BAD) {
if(pfd[num].revents & (POLLWRNORM|POLLOUT))
ret |= CURL_CSELECT_OUT;
if (pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL))
if(pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL))
ret |= CURL_CSELECT_ERR;
}
@@ -257,7 +257,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
maxfd = (curl_socket_t)-1;
FD_ZERO(&fds_read);
if (readfd != CURL_SOCKET_BAD) {
if(readfd != CURL_SOCKET_BAD) {
VERIFY_SOCK(readfd);
FD_SET(readfd, &fds_read);
FD_SET(readfd, &fds_err);
@@ -265,54 +265,54 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
}
FD_ZERO(&fds_write);
if (writefd != CURL_SOCKET_BAD) {
if(writefd != CURL_SOCKET_BAD) {
VERIFY_SOCK(writefd);
FD_SET(writefd, &fds_write);
FD_SET(writefd, &fds_err);
if (writefd > maxfd)
if(writefd > maxfd)
maxfd = writefd;
}
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
}
else if (!timeout_ms) {
else if(!timeout_ms) {
pending_tv.tv_sec = 0;
pending_tv.tv_usec = 0;
}
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || (error == EBADF) || error_is_EINTR)
if((error == EINVAL) || (error == EBADF) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
if (r < 0)
if(r < 0)
return -1;
if (r == 0)
if(r == 0)
return 0;
ret = 0;
if (readfd != CURL_SOCKET_BAD) {
if (FD_ISSET(readfd, &fds_read))
if(readfd != CURL_SOCKET_BAD) {
if(FD_ISSET(readfd, &fds_read))
ret |= CURL_CSELECT_IN;
if (FD_ISSET(readfd, &fds_err))
if(FD_ISSET(readfd, &fds_err))
ret |= CURL_CSELECT_ERR;
}
if (writefd != CURL_SOCKET_BAD) {
if (FD_ISSET(writefd, &fds_write))
if(writefd != CURL_SOCKET_BAD) {
if(FD_ISSET(writefd, &fds_write))
ret |= CURL_CSELECT_OUT;
if (FD_ISSET(writefd, &fds_err))
if(FD_ISSET(writefd, &fds_err))
ret |= CURL_CSELECT_ERR;
}
@@ -355,15 +355,15 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
int error;
int r;
if (ufds) {
if(ufds) {
for (i = 0; i < nfds; i++) {
if (ufds[i].fd != CURL_SOCKET_BAD) {
if(ufds[i].fd != CURL_SOCKET_BAD) {
fds_none = FALSE;
break;
}
}
}
if (fds_none) {
if(fds_none) {
r = wait_ms(timeout_ms);
return r;
}
@@ -373,7 +373,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
when function is called with a zero timeout or a negative timeout
value indicating a blocking call should be performed. */
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms;
initial_tv = curlx_tvnow();
}
@@ -381,22 +381,22 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
#ifdef HAVE_POLL_FINE
do {
if (timeout_ms < 0)
if(timeout_ms < 0)
pending_ms = -1;
else if (!timeout_ms)
else if(!timeout_ms)
pending_ms = 0;
r = poll(ufds, nfds, pending_ms);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || error_is_EINTR)
if((error == EINVAL) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
#else /* HAVE_POLL_FINE */
@@ -407,18 +407,18 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
for (i = 0; i < nfds; i++) {
ufds[i].revents = 0;
if (ufds[i].fd == CURL_SOCKET_BAD)
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
VERIFY_SOCK(ufds[i].fd);
if (ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
if (ufds[i].fd > maxfd)
if(ufds[i].fd > maxfd)
maxfd = ufds[i].fd;
if (ufds[i].events & (POLLRDNORM|POLLIN))
if(ufds[i].events & (POLLRDNORM|POLLIN))
FD_SET(ufds[i].fd, &fds_read);
if (ufds[i].events & (POLLWRNORM|POLLOUT))
if(ufds[i].events & (POLLWRNORM|POLLOUT))
FD_SET(ufds[i].fd, &fds_write);
if (ufds[i].events & (POLLRDBAND|POLLPRI))
if(ufds[i].events & (POLLRDBAND|POLLPRI))
FD_SET(ufds[i].fd, &fds_err);
}
}
@@ -426,44 +426,44 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
}
else if (!timeout_ms) {
else if(!timeout_ms) {
pending_tv.tv_sec = 0;
pending_tv.tv_usec = 0;
}
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || (error == EBADF) || error_is_EINTR)
if((error == EINVAL) || (error == EBADF) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
if (r < 0)
if(r < 0)
return -1;
if (r == 0)
if(r == 0)
return 0;
r = 0;
for (i = 0; i < nfds; i++) {
ufds[i].revents = 0;
if (ufds[i].fd == CURL_SOCKET_BAD)
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
if (FD_ISSET(ufds[i].fd, &fds_read))
if(FD_ISSET(ufds[i].fd, &fds_read))
ufds[i].revents |= POLLIN;
if (FD_ISSET(ufds[i].fd, &fds_write))
if(FD_ISSET(ufds[i].fd, &fds_write))
ufds[i].revents |= POLLOUT;
if (FD_ISSET(ufds[i].fd, &fds_err))
if(FD_ISSET(ufds[i].fd, &fds_err))
ufds[i].revents |= POLLPRI;
if (ufds[i].revents != 0)
if(ufds[i].revents != 0)
r++;
}

View File

@@ -40,13 +40,16 @@
#undef HAVE_POLL_FINE
#define HAVE_POLL_FINE 1
#define poll(x,y,z) WSAPoll((x),(y),(z))
#if defined(_MSC_VER) && defined(POLLRDNORM)
#define HAVE_STRUCT_POLLFD 1
#endif
#endif
/*
* Definition of pollfd struct and constants for platforms lacking them.
*/
#ifndef HAVE_SYS_POLL_H
#if !defined(HAVE_STRUCT_POLLFD) && !defined(HAVE_SYS_POLL_H)
#define POLLIN 0x01
#define POLLPRI 0x02

View File

@@ -67,12 +67,12 @@ static struct curl_slist *slist_get_last(struct curl_slist *list)
struct curl_slist *item;
/* if caller passed us a NULL, return now */
if (!list)
if(!list)
return NULL;
/* loop through to find the last item */
item = list;
while (item->next) {
while(item->next) {
item = item->next;
}
return item;
@@ -92,7 +92,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
struct curl_slist *new_item;
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
if (new_item) {
if(new_item) {
char *dupdata = strdup(data);
if(dupdata) {
new_item->next = NULL;
@@ -106,7 +106,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
else
return NULL;
if (list) {
if(list) {
last = slist_get_last(list);
last->next = new_item;
return list;
@@ -122,19 +122,19 @@ void curl_slist_free_all(struct curl_slist *list)
struct curl_slist *next;
struct curl_slist *item;
if (!list)
if(!list)
return;
item = list;
do {
next = item->next;
if (item->data) {
if(item->data) {
free(item->data);
}
free(item);
item = next;
} while (next);
} while(next);
}
#ifdef CURL_DO_LINEEND_CONV
@@ -150,14 +150,14 @@ static size_t convert_lineends(struct SessionHandle *data,
char *inPtr, *outPtr;
/* sanity check */
if ((startPtr == NULL) || (size < 1)) {
if((startPtr == NULL) || (size < 1)) {
return(size);
}
if (data->state.prev_block_had_trailing_cr == TRUE) {
if(data->state.prev_block_had_trailing_cr == TRUE) {
/* The previous block of incoming data
had a trailing CR, which was turned into a LF. */
if (*startPtr == '\n') {
if(*startPtr == '\n') {
/* This block of incoming data starts with the
previous block's LF so get rid of it */
memcpy(startPtr, startPtr+1, size-1);
@@ -170,11 +170,11 @@ static size_t convert_lineends(struct SessionHandle *data,
/* find 1st CR, if any */
inPtr = outPtr = memchr(startPtr, '\r', size);
if (inPtr) {
if(inPtr) {
/* at least one CR, now look for CRLF */
while (inPtr < (startPtr+size-1)) {
while(inPtr < (startPtr+size-1)) {
/* note that it's size-1, so we'll never look past the last byte */
if (memcmp(inPtr, "\r\n", 2) == 0) {
if(memcmp(inPtr, "\r\n", 2) == 0) {
/* CRLF found, bump past the CR and copy the NL */
inPtr++;
*outPtr = *inPtr;
@@ -182,7 +182,7 @@ static size_t convert_lineends(struct SessionHandle *data,
data->state.crlf_conversions++;
}
else {
if (*inPtr == '\r') {
if(*inPtr == '\r') {
/* lone CR, move LF instead */
*outPtr = '\n';
}
@@ -195,9 +195,9 @@ static size_t convert_lineends(struct SessionHandle *data,
inPtr++;
} /* end of while loop */
if (inPtr < startPtr+size) {
if(inPtr < startPtr+size) {
/* handle last byte */
if (*inPtr == '\r') {
if(*inPtr == '\r') {
/* deal with a CR at the end of the buffer */
*outPtr = '\n'; /* copy a NL instead */
/* note that a CRLF might be split across two blocks */
@@ -210,7 +210,7 @@ static size_t convert_lineends(struct SessionHandle *data,
outPtr++;
inPtr++;
}
if (outPtr < startPtr+size) {
if(outPtr < startPtr+size) {
/* tidy up by null terminating the now shorter data */
*outPtr = '\0';
}
@@ -285,7 +285,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
write_len = strlen(s);
sptr = s;
while (1) {
while(1) {
/* Write the buffer to the socket */
res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
@@ -355,13 +355,13 @@ CURLcode Curl_write(struct connectdata *conn,
CURLcode retcode;
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
if (conn->ssl[num].use)
if(conn->ssl[num].use)
/* only TRUE if SSL enabled */
bytes_written = Curl_ssl_send(conn, num, mem, len);
#ifdef USE_LIBSSH2
else if (conn->protocol & PROT_SCP)
else if(conn->protocol & PROT_SCP)
bytes_written = Curl_scp_send(conn, num, mem, len);
else if (conn->protocol & PROT_SFTP)
else if(conn->protocol & PROT_SFTP)
bytes_written = Curl_sftp_send(conn, num, mem, len);
#endif /* !USE_LIBSSH2 */
else if(conn->sec_complete)
@@ -389,7 +389,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
struct SessionHandle *data = conn->data;
size_t wrote;
if (data->state.cancelled) {
if(data->state.cancelled) {
/* We just suck everything into a black hole */
return CURLE_OK;
}
@@ -415,7 +415,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
}
/* If the previous block of data ended with CR and this block of data is
just a NL, then the length might be zero */
if (len) {
if(len) {
wrote = data->set.fwrite_func(ptr, 1, len, data->set.out);
}
else {
@@ -485,7 +485,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
size_t bytestocopy = MIN(conn->buf_len - conn->read_pos, sizerequested);
/* Copy from our master buffer first if we have some unread data there*/
if (bytestocopy > 0) {
if(bytestocopy > 0) {
memcpy(buf, conn->master_buffer + conn->read_pos, bytestocopy);
conn->read_pos += bytestocopy;
conn->bits.stream_was_rewound = FALSE;
@@ -512,10 +512,10 @@ int Curl_read(struct connectdata *conn, /* connection data */
}
}
#ifdef USE_LIBSSH2
else if (conn->protocol & (PROT_SCP|PROT_SFTP)) {
else if(conn->protocol & (PROT_SCP|PROT_SFTP)) {
if(conn->protocol & PROT_SCP)
nread = Curl_scp_recv(conn, num, buffertofill, bytesfromsocket);
else if (conn->protocol & PROT_SFTP)
else if(conn->protocol & PROT_SFTP)
nread = Curl_sftp_recv(conn, num, buffertofill, bytesfromsocket);
#ifdef LIBSSH2CHANNEL_EAGAIN
if((nread == LIBSSH2CHANNEL_EAGAIN) || (nread == 0))
@@ -545,7 +545,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
}
}
if (nread >= 0) {
if(nread >= 0) {
if(pipelining) {
memcpy(buf, conn->master_buffer, nread);
conn->buf_len = nread;
@@ -573,7 +573,7 @@ static int showit(struct SessionHandle *data, curl_infotype type,
case CURLINFO_HEADER_OUT:
/* assume output headers are ASCII */
/* copy the data into my buffer so the original is unchanged */
if (size > BUFSIZE) {
if(size > BUFSIZE) {
size = BUFSIZE; /* truncate if necessary */
buf[BUFSIZE] = '\0';
}

View File

@@ -32,13 +32,11 @@
#define CURL_DISABLE_FILE
#endif /* HTTP_ONLY */
#if !defined(WIN32) && defined(__WIN32__)
/* Borland fix */
#define WIN32
#endif
/*
* Define WIN32 when build target is Win32 API
*/
#if !defined(WIN32) && defined(_WIN32)
/* VS2005 on x64 fix */
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
#define WIN32
#endif

View File

@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2007, 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
@@ -38,7 +38,7 @@ curl_share_init(void)
{
struct Curl_share *share =
(struct Curl_share *)malloc(sizeof(struct Curl_share));
if (share) {
if(share) {
memset (share, 0, sizeof(struct Curl_share));
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
}
@@ -56,7 +56,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
curl_unlock_function unlockfunc;
void *ptr;
if (share->dirty)
if(share->dirty)
/* don't allow setting options while one or more handles are already
using this share */
return CURLSHE_IN_USE;
@@ -70,7 +70,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
share->specifier |= (1<<type);
switch( type ) {
case CURL_LOCK_DATA_DNS:
if (!share->hostcache) {
if(!share->hostcache) {
share->hostcache = Curl_mk_dnscache();
if(!share->hostcache)
return CURLSHE_NOMEM;
@@ -79,7 +79,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
case CURL_LOCK_DATA_COOKIE:
if (!share->cookies) {
if(!share->cookies) {
share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE );
if(!share->cookies)
return CURLSHE_NOMEM;
@@ -102,7 +102,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
switch( type )
{
case CURL_LOCK_DATA_DNS:
if (share->hostcache) {
if(share->hostcache) {
Curl_hash_destroy(share->hostcache);
share->hostcache = NULL;
}
@@ -110,7 +110,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
case CURL_LOCK_DATA_COOKIE:
if (share->cookies) {
if(share->cookies) {
Curl_cookie_cleanup(share->cookies);
share->cookies = NULL;
}
@@ -155,14 +155,14 @@ curl_share_cleanup(CURLSH *sh)
{
struct Curl_share *share = (struct Curl_share *)sh;
if (share == NULL)
if(share == NULL)
return CURLSHE_INVALID;
if(share->lockfunc)
share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE,
share->clientdata);
if (share->dirty) {
if(share->dirty) {
if(share->unlockfunc)
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
return CURLSHE_IN_USE;
@@ -190,7 +190,7 @@ Curl_share_lock(struct SessionHandle *data, curl_lock_data type,
{
struct Curl_share *share = data->share;
if (share == NULL)
if(share == NULL)
return CURLSHE_INVALID;
if(share->specifier & (1<<type)) {
@@ -207,7 +207,7 @@ Curl_share_unlock(struct SessionHandle *data, curl_lock_data type)
{
struct Curl_share *share = data->share;
if (share == NULL)
if(share == NULL)
return CURLSHE_INVALID;
if(share->specifier & (1<<type)) {

View File

@@ -136,7 +136,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* get timeout */
if(data->set.timeout && data->set.connecttimeout) {
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout = data->set.timeout;
else
timeout = data->set.connecttimeout;
@@ -186,7 +186,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
*/
if(dns)
hp=dns->addr;
if (hp) {
if(hp) {
char buf[64];
unsigned short ip[4];
Curl_printable_address(hp, buf, sizeof(buf));
@@ -216,7 +216,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
* This is currently not supporting "Identification Protocol (RFC1413)".
*/
socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
if (proxy_name)
if(proxy_name)
strlcat((char*)socksreq + 8, proxy_name, sizeof(socksreq) - 8);
/*
@@ -230,7 +230,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* Send request */
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
if ((code != CURLE_OK) || (written != packetsize)) {
if((code != CURLE_OK) || (written != packetsize)) {
failf(data, "Failed to send SOCKS4 connect request.");
return CURLE_COULDNT_CONNECT;
}
@@ -240,7 +240,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* Receive response */
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
&actualread, timeout);
if ((result != CURLE_OK) || (actualread != packetsize)) {
if((result != CURLE_OK) || (actualread != packetsize)) {
failf(data, "Failed to receive SOCKS4 connect request ack.");
return CURLE_COULDNT_CONNECT;
}
@@ -265,7 +265,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
*/
/* wrong version ? */
if (socksreq[0] != 0) {
if(socksreq[0] != 0) {
failf(data,
"SOCKS4 reply has wrong version, version should be 4.");
return CURLE_COULDNT_CONNECT;
@@ -362,7 +362,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
/* get timeout */
if(data->set.timeout && data->set.connecttimeout) {
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout = data->set.timeout;
else
timeout = data->set.connecttimeout;
@@ -402,7 +402,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
code = Curl_write(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
&written);
if ((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
if((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
failf(data, "Unable to send initial SOCKS5 request.");
return CURLE_COULDNT_CONNECT;
}
@@ -428,20 +428,20 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
Curl_nonblock(sock, FALSE);
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread, timeout);
if ((result != CURLE_OK) || (actualread != 2)) {
if((result != CURLE_OK) || (actualread != 2)) {
failf(data, "Unable to receive initial SOCKS5 response.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[0] != 5) {
if(socksreq[0] != 5) {
failf(data, "Received invalid version in initial SOCKS5 response.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[1] == 0) {
if(socksreq[1] == 0) {
/* Nothing to do, no authentication needed */
;
}
else if (socksreq[1] == 2) {
else if(socksreq[1] == 2) {
/* Needs user name and password */
size_t userlen, pwlen;
int len;
@@ -471,20 +471,20 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
len += pwlen;
code = Curl_write(conn, sock, (char *)socksreq, len, &written);
if ((code != CURLE_OK) || (len != written)) {
if((code != CURLE_OK) || (len != written)) {
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
return CURLE_COULDNT_CONNECT;
}
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread,
timeout);
if ((result != CURLE_OK) || (actualread != 2)) {
if((result != CURLE_OK) || (actualread != 2)) {
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
return CURLE_COULDNT_CONNECT;
}
/* ignore the first (VER) byte */
if (socksreq[1] != 0) { /* status */
if(socksreq[1] != 0) { /* status */
failf(data, "User was rejected by the SOCKS5 server (%d %d).",
socksreq[0], socksreq[1]);
return CURLE_COULDNT_CONNECT;
@@ -494,13 +494,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
}
else {
/* error */
if (socksreq[1] == 1) {
if(socksreq[1] == 1) {
failf(data,
"SOCKS5 GSSAPI per-message authentication is not supported.");
return CURLE_COULDNT_CONNECT;
}
else if (socksreq[1] == 255) {
if (!proxy_name || !*proxy_name) {
else if(socksreq[1] == 255) {
if(!proxy_name || !*proxy_name) {
failf(data,
"No authentication method was acceptable. (It is quite likely"
" that the SOCKS5 server wanted a username/password, since none"
@@ -542,7 +542,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
*/
if(dns)
hp=dns->addr;
if (hp) {
if(hp) {
char buf[64];
unsigned short ip[4];
Curl_printable_address(hp, buf, sizeof(buf));
@@ -572,24 +572,24 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
const int packetsize = 10;
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
if ((code != CURLE_OK) || (written != packetsize)) {
if((code != CURLE_OK) || (written != packetsize)) {
failf(data, "Failed to send SOCKS5 connect request.");
return CURLE_COULDNT_CONNECT;
}
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
&actualread, timeout);
if ((result != CURLE_OK) || (actualread != packetsize)) {
if((result != CURLE_OK) || (actualread != packetsize)) {
failf(data, "Failed to receive SOCKS5 connect request ack.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[0] != 5) { /* version */
if(socksreq[0] != 5) { /* version */
failf(data,
"SOCKS5 reply has wrong version, version should be 5.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[1] != 0) { /* Anything besides 0 is an error */
if(socksreq[1] != 0) { /* Anything besides 0 is an error */
failf(data,
"Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)",
(unsigned char)socksreq[4], (unsigned char)socksreq[5],

View File

@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1997 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1997 - 2007, 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
@@ -42,37 +42,37 @@ struct Curl_tree *Curl_splay(int i, struct Curl_tree *t)
struct Curl_tree N, *l, *r, *y;
int comp;
if (t == NULL)
if(t == NULL)
return t;
N.smaller = N.larger = NULL;
l = r = &N;
for (;;) {
comp = compare(i, t->key);
if (comp < 0) {
if (t->smaller == NULL)
if(comp < 0) {
if(t->smaller == NULL)
break;
if (compare(i, t->smaller->key) < 0) {
if(compare(i, t->smaller->key) < 0) {
y = t->smaller; /* rotate smaller */
t->smaller = y->larger;
y->larger = t;
t = y;
if (t->smaller == NULL)
if(t->smaller == NULL)
break;
}
r->smaller = t; /* link smaller */
r = t;
t = t->smaller;
}
else if (comp > 0) {
if (t->larger == NULL)
else if(comp > 0) {
if(t->larger == NULL)
break;
if (compare(i, t->larger->key) > 0) {
if(compare(i, t->larger->key) > 0) {
y = t->larger; /* rotate larger */
t->larger = y->smaller;
y->smaller = t;
t = y;
if (t->larger == NULL)
if(t->larger == NULL)
break;
}
l->larger = t; /* link larger */
@@ -97,12 +97,12 @@ struct Curl_tree *Curl_splayinsert(int i,
struct Curl_tree *t,
struct Curl_tree *node)
{
if (node == NULL)
if(node == NULL)
return t;
if (t != NULL) {
if(t != NULL) {
t = Curl_splay(i,t);
if (compare(i, t->key)==0) {
if(compare(i, t->key)==0) {
/* There already exists a node in the tree with the very same key. Build
a linked list of nodes. We make the new 'node' struct the new master
node and make the previous node the first one in the 'same' list. */
@@ -123,10 +123,10 @@ struct Curl_tree *Curl_splayinsert(int i,
}
}
if (t == NULL) {
if(t == NULL) {
node->smaller = node->larger = NULL;
}
else if (compare(i, t->key) < 0) {
else if(compare(i, t->key) < 0) {
node->smaller = t->smaller;
node->larger = t;
t->smaller = NULL;
@@ -156,11 +156,11 @@ struct Curl_tree *Curl_splayremove(int i, struct Curl_tree *t,
*removed = NULL; /* default to no removed */
if (t==NULL)
if(t==NULL)
return NULL;
t = Curl_splay(i,t);
if (compare(i, t->key) == 0) { /* found it */
if(compare(i, t->key) == 0) { /* found it */
/* FIRST! Check if there is a list with identical sizes */
if((x = t->same)) {
@@ -176,7 +176,7 @@ struct Curl_tree *Curl_splayremove(int i, struct Curl_tree *t,
return x; /* new root */
}
if (t->smaller == NULL) {
if(t->smaller == NULL) {
x = t->larger;
}
else {
@@ -199,7 +199,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
{
struct Curl_tree *x;
if (!t) {
if(!t) {
*removed = NULL; /* none removed since there was no root */
return NULL;
}
@@ -216,7 +216,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
}
}
if (compare(i, t->key) >= 0) { /* found it */
if(compare(i, t->key) >= 0) { /* found it */
/* FIRST! Check if there is a list with identical sizes */
x = t->same;
if(x) {
@@ -232,7 +232,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
return x; /* new root */
}
if (t->smaller == NULL) {
if(t->smaller == NULL) {
x = t->larger;
}
else {
@@ -265,14 +265,14 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
{
struct Curl_tree *x;
if (!t || !removenode)
if(!t || !removenode)
return 1;
if(KEY_NOTUSED == removenode->key) {
/* Key set to NOTUSED means it is a subnode within a 'same' linked list
and thus we can unlink it easily. The 'smaller' link of a subnode
links to the parent node. */
if (removenode->smaller == NULL)
if(removenode->smaller == NULL)
return 3;
removenode->smaller->same = removenode->same;
@@ -312,7 +312,7 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
}
else {
/* Remove the root node */
if (t->smaller == NULL)
if(t->smaller == NULL)
x = t->larger;
else {
x = Curl_splay(removenode->key, t->smaller);
@@ -332,7 +332,7 @@ void Curl_splayprint(struct Curl_tree * t, int d, char output)
struct Curl_tree *node;
int i;
int count;
if (t == NULL)
if(t == NULL)
return;
Curl_splayprint(t->larger, d+1, output);

2931
lib/ssh.c

File diff suppressed because it is too large Load Diff

View File

@@ -243,15 +243,18 @@ Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
#else
#ifdef USE_NSS
*done = TRUE; /* fallback to BLOCKING */
conn->ssl[sockindex].use = TRUE;
return Curl_nss_connect(conn, sockindex);
#else
#ifdef USE_QSOSSL
*done = TRUE; /* fallback to BLOCKING */
conn->ssl[sockindex].use = TRUE;
return Curl_qsossl_connect(conn, sockindex);
#else
/* not implemented!
fallback to BLOCKING call. */
*done = TRUE;
conn->ssl[sockindex].use = TRUE;
return Curl_ssl_connect(conn, sockindex);
#endif /* USE_QSOSSL */
#endif /* USE_NSS */
@@ -383,7 +386,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
store->name = clone_host; /* clone host name */
store->remote_port = conn->remote_port; /* port number */
if (!Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config))
if(!Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config))
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;

View File

@@ -238,7 +238,7 @@ static int ossl_seed(struct SessionHandle *data)
RAND_add(area, len, (len >> 1));
free(area); /* now remove the random junk */
} while (!RAND_status());
} while(!RAND_status());
}
#endif
@@ -366,7 +366,7 @@ int cert_stuff(struct connectdata *conn,
EVP_PKEY *pri;
f = fopen(cert_file,"rb");
if (!f) {
if(!f) {
failf(data, "could not open PKCS12 file '%s'", cert_file);
return 0;
}
@@ -375,7 +375,7 @@ int cert_stuff(struct connectdata *conn,
PKCS12_PBE_add();
if (!PKCS12_parse(p12, data->set.str[STRING_KEY_PASSWD], &pri, &x509,
if(!PKCS12_parse(p12, data->set.str[STRING_KEY_PASSWD], &pri, &x509,
NULL)) {
failf(data,
"could not parse PKCS12 file, check password, OpenSSL error %s",
@@ -483,7 +483,7 @@ int cert_stuff(struct connectdata *conn,
}
ssl=SSL_new(ctx);
if (NULL == ssl) {
if(NULL == ssl) {
failf(data,"unable to create an SSL structure\n");
return 0;
}
@@ -564,7 +564,7 @@ int Curl_ossl_init(void)
SSL_load_error_strings();
/* Setup all the global SSL stuff */
if (!SSLeay_add_ssl_algorithms())
if(!SSLeay_add_ssl_algorithms())
return 0;
return 1;
@@ -609,10 +609,10 @@ int Curl_ossl_check_cxn(struct connectdata *conn)
char buf;
rc = SSL_peek(conn->ssl[FIRSTSOCKET].handle, (void*)&buf, 1);
if (rc > 0)
if(rc > 0)
return 1; /* connection still in place */
if (rc == 0)
if(rc == 0)
return 0; /* connection has been closed */
return -1; /* connection status unknown */
@@ -625,17 +625,17 @@ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine)
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
ENGINE *e = ENGINE_by_id(engine);
if (!e) {
if(!e) {
failf(data, "SSL Engine '%s' not found", engine);
return (CURLE_SSL_ENGINE_NOTFOUND);
}
if (data->state.engine) {
if(data->state.engine) {
ENGINE_finish(data->state.engine);
ENGINE_free(data->state.engine);
data->state.engine = NULL;
}
if (!ENGINE_init(e)) {
if(!ENGINE_init(e)) {
char buf[256];
ENGINE_free(e);
@@ -657,8 +657,8 @@ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine)
CURLcode Curl_ossl_set_engine_default(struct SessionHandle *data)
{
#ifdef HAVE_OPENSSL_ENGINE_H
if (data->state.engine) {
if (ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
if(data->state.engine) {
if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
infof(data,"set default crypto engine '%s'\n", ENGINE_get_id(data->state.engine));
}
else {
@@ -683,11 +683,11 @@ struct curl_slist *Curl_ossl_engines_list(struct SessionHandle *data)
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) {
list = curl_slist_append(list, ENGINE_get_id(e));
if (list == NULL) {
if(list == NULL) {
curl_slist_free_all(beg);
return NULL;
}
else if (beg == NULL) {
else if(beg == NULL) {
beg = list;
}
}
@@ -919,26 +919,26 @@ static int Curl_ASN1_UTCTIME_output(struct connectdata *conn,
static int hostmatch(const char *hostname, const char *pattern)
{
while (1) {
while(1) {
char c = *pattern++;
if (c == '\0')
if(c == '\0')
return (*hostname ? HOST_NOMATCH : HOST_MATCH);
if (c == '*') {
if(c == '*') {
c = *pattern;
if (c == '\0') /* "*\0" matches anything remaining */
if(c == '\0') /* "*\0" matches anything remaining */
return HOST_MATCH;
while (*hostname) {
while(*hostname) {
/* The only recursive function in libcurl! */
if (hostmatch(hostname++,pattern) == HOST_MATCH)
if(hostmatch(hostname++,pattern) == HOST_MATCH)
return HOST_MATCH;
}
break;
}
if (toupper(c) != toupper(*hostname++))
if(toupper(c) != toupper(*hostname++))
break;
}
return HOST_NOMATCH;
@@ -947,14 +947,14 @@ static int hostmatch(const char *hostname, const char *pattern)
static int
cert_hostcheck(const char *match_pattern, const char *hostname)
{
if (!match_pattern || !*match_pattern ||
if(!match_pattern || !*match_pattern ||
!hostname || !*hostname) /* sanity check */
return 0;
if(curl_strequal(hostname,match_pattern)) /* trivial case */
return 1;
if (hostmatch(hostname,match_pattern) == HOST_MATCH)
if(hostmatch(hostname,match_pattern) == HOST_MATCH)
return 1;
return 0;
}
@@ -1042,7 +1042,7 @@ static CURLcode verifyhost(struct connectdata *conn,
"I checked the 0.9.6 and 0.9.8 sources before my patch and
it always 0-terminates an IA5String."
*/
if (cert_hostcheck(altptr, conn->host.name))
if(cert_hostcheck(altptr, conn->host.name))
matched = TRUE;
break;
@@ -1073,15 +1073,15 @@ static CURLcode verifyhost(struct connectdata *conn,
unsigned char *peer_CN = nulstr;
X509_NAME *name = X509_get_subject_name(server_cert) ;
if (name)
while ((j=X509_NAME_get_index_by_NID(name,NID_commonName,i))>=0)
if(name)
while((j=X509_NAME_get_index_by_NID(name,NID_commonName,i))>=0)
i=j;
/* we have the name entry and we will now convert this to a string
that we can use for comparison. Doing this we support BMPstring,
UTF8 etc. */
if (i>=0) {
if(i>=0) {
ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i));
/* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input
@@ -1089,11 +1089,11 @@ static CURLcode verifyhost(struct connectdata *conn,
string manually to avoid the problem. This code can be made
conditional in the future when OpenSSL has been fixed. Work-around
brought by Alexis S. L. Carvalho. */
if (tmp && ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
if(tmp && ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
j = ASN1_STRING_length(tmp);
if (j >= 0) {
if(j >= 0) {
peer_CN = OPENSSL_malloc(j+1);
if (peer_CN) {
if(peer_CN) {
memcpy(peer_CN, ASN1_STRING_data(tmp), j);
peer_CN[j] = '\0';
}
@@ -1103,7 +1103,7 @@ static CURLcode verifyhost(struct connectdata *conn,
j = ASN1_STRING_to_UTF8(&peer_CN, tmp);
}
if (peer_CN == nulstr)
if(peer_CN == nulstr)
peer_CN = NULL;
#ifdef CURL_DOES_CONVERSIONS
else {
@@ -1111,14 +1111,14 @@ static CURLcode verifyhost(struct connectdata *conn,
size_t rc;
rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
/* Curl_convert_from_utf8 calls failf if unsuccessful */
if (rc != CURLE_OK) {
if(rc != CURLE_OK) {
OPENSSL_free(peer_CN);
return rc;
}
}
#endif /* CURL_DOES_CONVERSIONS */
if (!peer_CN) {
if(!peer_CN) {
failf(data,
"SSL: unable to obtain common name from peer certificate");
return CURLE_PEER_FAILED_VERIFICATION;
@@ -1149,7 +1149,7 @@ static CURLcode verifyhost(struct connectdata *conn,
static const char *ssl_msg_type(int ssl_ver, int msg)
{
if (ssl_ver == SSL2_VERSION_MAJOR) {
if(ssl_ver == SSL2_VERSION_MAJOR) {
switch (msg) {
case SSL2_MT_ERROR:
return "Error";
@@ -1171,7 +1171,7 @@ static const char *ssl_msg_type(int ssl_ver, int msg)
return "Client CERT";
}
}
else if (ssl_ver == SSL3_VERSION_MAJOR) {
else if(ssl_ver == SSL3_VERSION_MAJOR) {
switch (msg) {
case SSL3_MT_HELLO_REQUEST:
return "Hello request";
@@ -1221,7 +1221,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
char ssl_buf[1024];
int ver, msg_type, txt_len;
if (!conn || !conn->data || !conn->data->set.fdebug ||
if(!conn || !conn->data || !conn->data->set.fdebug ||
(direction != 0 && direction != 1))
return;
@@ -1234,7 +1234,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
* always pass-up content-type as 0. But the interesting message-type
* is at 'buf[0]'.
*/
if (ssl_ver == SSL3_VERSION_MAJOR && content_type != 0)
if(ssl_ver == SSL3_VERSION_MAJOR && content_type != 0)
tls_rt_name = tls_rt_type(content_type);
else
tls_rt_name = "";
@@ -1290,7 +1290,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
break;
}
if (connssl->ctx)
if(connssl->ctx)
SSL_CTX_free(connssl->ctx);
connssl->ctx = SSL_CTX_new(req_method);
@@ -1300,14 +1300,14 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
#ifdef SSL_CTRL_SET_MSG_CALLBACK
if (data->set.fdebug && data->set.verbose) {
if(data->set.fdebug && data->set.verbose) {
/* the SSL trace callback is only used for verbose logging so we only
inform about failures of setting it */
if (!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK,
if(!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK,
(void (*)(void))ssl_tls_trace)) {
infof(data, "SSL: couldn't set callback!\n");
}
else if (!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0,
else if(!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0,
conn)) {
infof(data, "SSL: couldn't set callback argument!\n");
}
@@ -1330,7 +1330,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
* non-blocking. It doesn't seem to care, but just return with
* SSL_ERROR_WANT_x.
*/
if (data->state.used_interface == Curl_if_multi)
if(data->state.used_interface == Curl_if_multi)
SSL_CTX_ctrl(connssl->ctx, BIO_C_SET_NBIO, 1, NULL);
#endif
@@ -1354,13 +1354,13 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
}
if (data->set.str[STRING_SSL_CAFILE] || data->set.str[STRING_SSL_CAPATH]) {
if(data->set.str[STRING_SSL_CAFILE] || data->set.str[STRING_SSL_CAPATH]) {
/* tell SSL where to find CA certificates that are used to verify
the servers certificate. */
if (!SSL_CTX_load_verify_locations(connssl->ctx,
if(!SSL_CTX_load_verify_locations(connssl->ctx,
data->set.str[STRING_SSL_CAFILE],
data->set.str[STRING_SSL_CAPATH])) {
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
/* Fail if we insist on successfully verifying the server. */
failf(data,"error setting certificate verify locations:\n"
" CAfile: %s\n CApath: %s\n",
@@ -1408,10 +1408,10 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
/* Lets make an SSL structure */
if (connssl->handle)
if(connssl->handle)
SSL_free(connssl->handle);
connssl->handle = SSL_new(connssl->ctx);
if (!connssl->handle) {
if(!connssl->handle) {
failf(data, "SSL: couldn't create a context (handle)!");
return CURLE_OUT_OF_MEMORY;
}
@@ -1422,7 +1422,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
/* Check if there's a cached ID we can/should use here! */
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL)) {
/* we got a session id, use it! */
if (!SSL_set_session(connssl->handle, ssl_sessionid)) {
if(!SSL_set_session(connssl->handle, ssl_sessionid)) {
failf(data, "SSL: SSL_set_session failed: %s",
ERR_error_string(ERR_get_error(),NULL));
return CURLE_SSL_CONNECT_ERROR;
@@ -1432,7 +1432,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
/* pass the raw socket into the SSL layers */
if (!SSL_set_fd(connssl->handle, sockfd)) {
if(!SSL_set_fd(connssl->handle, sockfd)) {
failf(data, "SSL: SSL_set_fd failed: %s",
ERR_error_string(ERR_get_error(),NULL));
return CURLE_SSL_CONNECT_ERROR;
@@ -1545,7 +1545,7 @@ Curl_ossl_connect_step2(struct connectdata *conn,
* (RST connection etc.), OpenSSL gives no explanation whatsoever and
* the SO_ERROR is also lost.
*/
if (CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) {
if(CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) {
failf(data, "Unknown SSL protocol error in connection to %s:%d ",
conn->host.name, conn->port);
return rc;
@@ -1704,19 +1704,19 @@ Curl_ossl_connect_common(struct connectdata *conn,
curl_socket_t sockfd = conn->sock[sockindex];
long timeout_ms;
if (ssl_connect_1==connssl->connecting_state) {
if(ssl_connect_1==connssl->connecting_state) {
retcode = Curl_ossl_connect_step1(conn, sockindex);
if (retcode)
if(retcode)
return retcode;
}
timeout_ms = 0;
while (ssl_connect_2 == connssl->connecting_state ||
ssl_connect_2_reading == connssl->connecting_state ||
ssl_connect_2_writing == connssl->connecting_state) {
while(ssl_connect_2 == connssl->connecting_state ||
ssl_connect_2_reading == connssl->connecting_state ||
ssl_connect_2_writing == connssl->connecting_state) {
/* if ssl is expecting something, check if it's available. */
if (connssl->connecting_state == ssl_connect_2_reading
if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) {
int writefd = ssl_connect_2_writing==
@@ -1730,7 +1730,7 @@ Curl_ossl_connect_common(struct connectdata *conn,
/* readable or writable, go loop in the outer loop */
break;
else if(0 == what) {
if (nonblocking) {
if(nonblocking) {
*done = FALSE;
return CURLE_OK;
}
@@ -1750,19 +1750,19 @@ Curl_ossl_connect_common(struct connectdata *conn,
/* get the timeout from step2 to avoid computing it twice. */
retcode = Curl_ossl_connect_step2(conn, sockindex, &timeout_ms);
if (retcode)
if(retcode)
return retcode;
} /* repeat step2 until all transactions are done. */
if (ssl_connect_3==connssl->connecting_state) {
if(ssl_connect_3==connssl->connecting_state) {
retcode = Curl_ossl_connect_step3(conn, sockindex);
if (retcode)
if(retcode)
return retcode;
}
if (ssl_connect_done==connssl->connecting_state) {
if(ssl_connect_done==connssl->connecting_state) {
*done = TRUE;
}
else {
@@ -1791,7 +1791,7 @@ Curl_ossl_connect(struct connectdata *conn,
bool done = FALSE;
retcode = Curl_ossl_connect_common(conn, sockindex, FALSE, &done);
if (retcode)
if(retcode)
return retcode;
DEBUGASSERT(done);
@@ -1892,7 +1892,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
return snprintf(buffer, size, "yassl/%s", YASSL_VERSION);
#else /* YASSL_VERSION */
#if (SSLEAY_VERSION_NUMBER >= 0x905000)
#if(SSLEAY_VERSION_NUMBER >= 0x905000)
{
char sub[2];
unsigned long ssleay_value;
@@ -1919,7 +1919,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
#else /* SSLEAY_VERSION_NUMBER is less than 0.9.5 */
#if (SSLEAY_VERSION_NUMBER >= 0x900000)
#if(SSLEAY_VERSION_NUMBER >= 0x900000)
return snprintf(buffer, size, "OpenSSL/%lx.%lx.%lx",
(SSLEAY_VERSION_NUMBER>>28)&0xff,
(SSLEAY_VERSION_NUMBER>>20)&0xff,

View File

@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2007, 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
@@ -30,12 +30,12 @@ char *curlx_strdup(const char *str)
int len;
char *newstr;
if (!str)
if(!str)
return (char *)NULL;
len = strlen(str);
newstr = (char *) malloc((len+1)*sizeof(char));
if (!newstr)
if(!newstr)
return (char *)NULL;
memcpy(newstr,str,(len+1)*sizeof(char));

View File

@@ -52,8 +52,8 @@ int curl_strequal(const char *first, const char *second)
#elif defined(HAVE_STRICMP)
return !(stricmp)(first, second);
#else
while (*first && *second) {
if (toupper(*first) != toupper(*second)) {
while(*first && *second) {
if(toupper(*first) != toupper(*second)) {
break;
}
first++;
@@ -72,8 +72,8 @@ int curl_strnequal(const char *first, const char *second, size_t max)
#elif defined(HAVE_STRICMP)
return !strnicmp(first, second, max);
#else
while (*first && *second && max) {
if (toupper(*first) != toupper(*second)) {
while(*first && *second && max) {
if(toupper(*first) != toupper(*second)) {
break;
}
max--;
@@ -132,15 +132,15 @@ size_t Curl_strlcat(char *dst, const char *src, size_t siz)
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
while(n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;
if (n == 0)
if(n == 0)
return(dlen + strlen(s));
while (*s != '\0') {
if (n != 1) {
while(*s != '\0') {
if(n != 1) {
*d++ = *s;
n--;
}

View File

@@ -294,7 +294,7 @@ curl_easy_strerror(CURLcode error)
*/
return "Unknown error";
#else
if (error == CURLE_OK)
if(error == CURLE_OK)
return "No error";
else
return "Error";
@@ -336,7 +336,7 @@ curl_multi_strerror(CURLMcode error)
return "Unknown error";
#else
if (error == CURLM_OK)
if(error == CURLM_OK)
return "No error";
else
return "Error";
@@ -369,7 +369,7 @@ curl_share_strerror(CURLSHcode error)
return "CURLSHcode unknown";
#else
if (error == CURLSHE_OK)
if(error == CURLSHE_OK)
return "No error";
else
return "Error";
@@ -555,7 +555,7 @@ get_winsock_error (int err, char *buf, size_t len)
return NULL;
}
#else
if (err == CURLE_OK)
if(err == CURLE_OK)
return NULL;
else
p = "error";
@@ -604,10 +604,10 @@ const char *Curl_strerror(struct connectdata *conn, int err)
#else
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
if (err >= 0 && err < sys_nerr)
if(err >= 0 && err < sys_nerr)
strncpy(buf, strerror(err), max);
else {
if (!get_winsock_error(err, buf, max) &&
if(!get_winsock_error(err, buf, max) &&
!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
LANG_NEUTRAL, buf, (DWORD)max, NULL))
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
@@ -646,9 +646,9 @@ const char *Curl_strerror(struct connectdata *conn, int err)
buf[max] = '\0'; /* make sure the string is zero terminated */
/* strip trailing '\r\n' or '\n'. */
if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
*p = '\0';
if ((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
*p = '\0';
return buf;
}
@@ -716,12 +716,12 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err)
break;
}
#else
if ((Idna_rc)err == IDNA_SUCCESS)
if((Idna_rc)err == IDNA_SUCCESS)
str = "No error";
else
str = "Error";
#endif
if (str)
if(str)
strncpy(buf, str, max);
buf[max] = '\0';
return (buf);

View File

@@ -1,16 +1,16 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2007, 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.
@@ -32,15 +32,15 @@
char *
Curl_strtok_r(char *ptr, const char *sep, char **end)
{
if (!ptr)
if(!ptr)
/* we got NULL input so then we get our last position instead */
ptr = *end;
/* pass all letters that are including in the separator string */
while (*ptr && strchr(sep, *ptr))
while(*ptr && strchr(sep, *ptr))
++ptr;
if (*ptr) {
if(*ptr) {
/* so this is where the next piece of string starts */
char *start = ptr;
@@ -49,10 +49,10 @@ Curl_strtok_r(char *ptr, const char *sep, char **end)
/* scan through the string to find where it ends, it ends on a
null byte or a character that exists in the separator string */
while (**end && !strchr(sep, **end))
while(**end && !strchr(sep, **end))
++*end;
if (**end) {
if(**end) {
/* the end is not a null byte */
**end = '\0'; /* zero terminate it! */
++*end; /* advance the last pointer to beyond the null byte */

View File

@@ -40,7 +40,7 @@
/* Range tests can be used for alphanum decoding if characters are consecutive,
like in ASCII. Else an array is scanned. Determine this condition now. */
#if ('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25
#if('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25
#include <string.h>
#define NO_RANGE_TEST
@@ -67,35 +67,35 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
/* Skip leading whitespace. */
end = (char *)nptr;
while (ISSPACE(end[0])) {
while(ISSPACE(end[0])) {
end++;
}
/* Handle the sign, if any. */
if (end[0] == '-') {
if(end[0] == '-') {
is_negative = 1;
end++;
}
else if (end[0] == '+') {
else if(end[0] == '+') {
end++;
}
else if (end[0] == '\0') {
else if(end[0] == '\0') {
/* We had nothing but perhaps some whitespace -- there was no number. */
if (endptr) {
if(endptr) {
*endptr = end;
}
return 0;
}
/* Handle special beginnings, if present and allowed. */
if (end[0] == '0' && end[1] == 'x') {
if (base == 16 || base == 0) {
if(end[0] == '0' && end[1] == 'x') {
if(base == 16 || base == 0) {
end += 2;
base = 16;
}
}
else if (end[0] == '0') {
if (base == 8 || base == 0) {
else if(end[0] == '0') {
if(base == 8 || base == 0) {
end++;
base = 8;
}
@@ -104,7 +104,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
/* Matching strtol, if the base is 0 and it doesn't look like
* the number is octal or hex, we assume it's base 10.
*/
if (base == 0) {
if(base == 0) {
base = 10;
}
@@ -115,7 +115,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
i != -1;
end++, i = get_char(end[0], base)) {
newval = base * value + i;
if (newval < value) {
if(newval < value) {
/* We've overflowed. */
overflow = 1;
break;
@@ -124,14 +124,14 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
value = newval;
}
if (!overflow) {
if (is_negative) {
if(!overflow) {
if(is_negative) {
/* Fix the sign. */
value *= -1;
}
}
else {
if (is_negative)
if(is_negative)
value = CURL_LLONG_MIN;
else
value = CURL_LLONG_MAX;
@@ -139,7 +139,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
SET_ERRNO(ERANGE);
}
if (endptr)
if(endptr)
*endptr = end;
return value;
@@ -159,13 +159,13 @@ static int get_char(char c, int base)
{
#ifndef NO_RANGE_TEST
int value = -1;
if (c <= '9' && c >= '0') {
if(c <= '9' && c >= '0') {
value = c - '0';
}
else if (c <= 'Z' && c >= 'A') {
else if(c <= 'Z' && c >= 'A') {
value = c - 'A' + 10;
}
else if (c <= 'z' && c >= 'a') {
else if(c <= 'z' && c >= 'a') {
value = c - 'a' + 10;
}
#else
@@ -174,16 +174,16 @@ static int get_char(char c, int base)
cp = memchr(valchars, c, 10 + 26 + 26);
if (!cp)
if(!cp)
return -1;
value = cp - valchars;
if (value >= 10 + 26)
if(value >= 10 + 26)
value -= 26; /* Lowercase. */
#endif
if (value >= base) {
if(value >= base) {
value = -1;
}

View File

@@ -45,6 +45,7 @@
/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
_CRTIMP __int64 __cdecl _strtoi64(const char *, char **, int); /* in <crt/stdlib.h> */
#define curlx_strtoofft _strtoi64
#else /* MSVC7 or later */
curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);

View File

@@ -86,7 +86,7 @@
#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer;
#define CURL_SB_TERM(x) { x->subend = x->subpointer; CURL_SB_CLEAR(x); }
#define CURL_SB_ACCUM(x,c) \
if (x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
if(x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
*x->subpointer++ = (c); \
}
@@ -96,7 +96,7 @@
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
#ifdef CURL_DISABLE_VERBOSE_STRINGS
#define printoption(a,b,c,d) do { } while (0)
#define printoption(a,b,c,d) do { } while(0)
#endif
#ifdef USE_WINSOCK
@@ -106,7 +106,7 @@ static CURLcode check_wsock2 ( struct SessionHandle *data );
static
void telrcv(struct connectdata *,
unsigned char *inbuf, /* Data received from socket */
const unsigned char *inbuf, /* Data received from socket */
ssize_t count); /* Number of bytes received */
#ifndef CURL_DISABLE_VERBOSE_STRINGS
@@ -213,7 +213,7 @@ check_wsock2 ( struct SessionHandle *data )
/* We must've called this once already, so this call */
/* should always succeed. But, just in case... */
if (err != 0) {
if(err != 0) {
failf(data,"WSAStartup failed (%d)",err);
return CURLE_FAILED_INIT;
}
@@ -223,7 +223,7 @@ check_wsock2 ( struct SessionHandle *data )
WSACleanup();
/* Check that our version is supported */
if (LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
/* Our version isn't supported */
failf(data,"insufficient winsock version to support "
@@ -283,11 +283,11 @@ static void printoption(struct SessionHandle *data,
const char *fmt;
const char *opt;
if (data->set.verbose)
if(data->set.verbose)
{
if (cmd == CURL_IAC)
if(cmd == CURL_IAC)
{
if (CURL_TELCMD_OK(option))
if(CURL_TELCMD_OK(option))
infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option));
else
infof(data, "%s IAC %d\n", direction, option);
@@ -296,11 +296,11 @@ static void printoption(struct SessionHandle *data,
{
fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
(cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
if (fmt)
if(fmt)
{
if (CURL_TELOPT_OK(option))
if(CURL_TELOPT_OK(option))
opt = CURL_TELOPT(option);
else if (option == CURL_TELOPT_EXOPL)
else if(option == CURL_TELOPT_EXOPL)
opt = "EXOPL";
else
opt = NULL;
@@ -705,30 +705,30 @@ static void printsub(struct SessionHandle *data,
{
unsigned int i = 0;
if (data->set.verbose)
if(data->set.verbose)
{
if (direction)
if(direction)
{
infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
if (length >= 3)
if(length >= 3)
{
int j;
i = pointer[length-2];
j = pointer[length-1];
if (i != CURL_IAC || j != CURL_SE)
if(i != CURL_IAC || j != CURL_SE)
{
infof(data, "(terminated by ");
if (CURL_TELOPT_OK(i))
if(CURL_TELOPT_OK(i))
infof(data, "%s ", CURL_TELOPT(i));
else if (CURL_TELCMD_OK(i))
else if(CURL_TELCMD_OK(i))
infof(data, "%s ", CURL_TELCMD(i));
else
infof(data, "%d ", i);
if (CURL_TELOPT_OK(j))
if(CURL_TELOPT_OK(j))
infof(data, "%s", CURL_TELOPT(j));
else if (CURL_TELCMD_OK(j))
else if(CURL_TELCMD_OK(j))
infof(data, "%s", CURL_TELCMD(j));
else
infof(data, "%d", j);
@@ -737,13 +737,13 @@ static void printsub(struct SessionHandle *data,
}
length -= 2;
}
if (length < 1)
if(length < 1)
{
infof(data, "(Empty suboption?)");
return;
}
if (CURL_TELOPT_OK(pointer[0])) {
if(CURL_TELOPT_OK(pointer[0])) {
switch(pointer[0]) {
case CURL_TELOPT_TTYPE:
case CURL_TELOPT_XDISPLOC:
@@ -803,7 +803,7 @@ static void printsub(struct SessionHandle *data,
break;
}
if (direction)
if(direction)
{
infof(data, "\n");
}
@@ -949,107 +949,122 @@ static void suboption(struct connectdata *conn)
static
void telrcv(struct connectdata *conn,
unsigned char *inbuf, /* Data received from socket */
const unsigned char *inbuf, /* Data received from socket */
ssize_t count) /* Number of bytes received */
{
unsigned char c;
int in = 0;
int startwrite=-1;
struct SessionHandle *data = conn->data;
struct TELNET *tn = (struct TELNET *)data->reqdata.proto.telnet;
#define startskipping() \
if(startwrite >= 0) \
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&inbuf[startwrite], in-startwrite); \
startwrite = -1
#define writebyte() \
if(startwrite < 0) \
startwrite = in
#define bufferflush() startskipping()
while(count--)
{
c = inbuf[in++];
c = inbuf[in];
/*infof(data,"In rcv state %d char %d\n", tn->telrcv_state, c);*/
switch (tn->telrcv_state)
{
case CURL_TS_CR:
tn->telrcv_state = CURL_TS_DATA;
if (c == '\0')
if(c == '\0')
{
startskipping();
break; /* Ignore \0 after CR */
}
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);
continue;
writebyte();
break;
case CURL_TS_DATA:
if (c == CURL_IAC)
if(c == CURL_IAC)
{
tn->telrcv_state = CURL_TS_IAC;
startskipping();
break;
}
else if(c == '\r')
{
tn->telrcv_state = CURL_TS_CR;
}
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);
continue;
writebyte();
break;
case CURL_TS_IAC:
process_iac:
DEBUGASSERT(startwrite < 0);
switch (c)
{
case CURL_WILL:
tn->telrcv_state = CURL_TS_WILL;
continue;
break;
case CURL_WONT:
tn->telrcv_state = CURL_TS_WONT;
continue;
break;
case CURL_DO:
tn->telrcv_state = CURL_TS_DO;
continue;
break;
case CURL_DONT:
tn->telrcv_state = CURL_TS_DONT;
continue;
break;
case CURL_SB:
CURL_SB_CLEAR(tn);
tn->telrcv_state = CURL_TS_SB;
continue;
break;
case CURL_IAC:
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);
tn->telrcv_state = CURL_TS_DATA;
writebyte();
break;
case CURL_DM:
case CURL_NOP:
case CURL_GA:
default:
tn->telrcv_state = CURL_TS_DATA;
printoption(data, "RCVD", CURL_IAC, c);
break;
}
tn->telrcv_state = CURL_TS_DATA;
continue;
break;
case CURL_TS_WILL:
printoption(data, "RCVD", CURL_WILL, c);
tn->please_negotiate = 1;
rec_will(conn, c);
tn->telrcv_state = CURL_TS_DATA;
continue;
break;
case CURL_TS_WONT:
printoption(data, "RCVD", CURL_WONT, c);
tn->please_negotiate = 1;
rec_wont(conn, c);
tn->telrcv_state = CURL_TS_DATA;
continue;
break;
case CURL_TS_DO:
printoption(data, "RCVD", CURL_DO, c);
tn->please_negotiate = 1;
rec_do(conn, c);
tn->telrcv_state = CURL_TS_DATA;
continue;
break;
case CURL_TS_DONT:
printoption(data, "RCVD", CURL_DONT, c);
tn->please_negotiate = 1;
rec_dont(conn, c);
tn->telrcv_state = CURL_TS_DATA;
continue;
break;
case CURL_TS_SB:
if (c == CURL_IAC)
if(c == CURL_IAC)
{
tn->telrcv_state = CURL_TS_SE;
}
@@ -1057,12 +1072,12 @@ void telrcv(struct connectdata *conn,
{
CURL_SB_ACCUM(tn,c);
}
continue;
break;
case CURL_TS_SE:
if (c != CURL_SE)
if(c != CURL_SE)
{
if (c != CURL_IAC)
if(c != CURL_IAC)
{
/*
* This is an error. We only expect to get "IAC IAC" or "IAC SE".
@@ -1097,7 +1112,9 @@ void telrcv(struct connectdata *conn,
}
break;
}
++in;
}
bufferflush();
}
static CURLcode Curl_telnet_done(struct connectdata *conn,
@@ -1143,7 +1160,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
char *buf = data->state.buffer;
struct TELNET *tn;
*done = TRUE; /* uncontionally */
*done = TRUE; /* unconditionally */
code = init_telnet(conn);
if(code)
@@ -1161,20 +1178,20 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
** make sure have it.
*/
code = check_wsock2(data);
if (code)
if(code)
return code;
/* OK, so we have WinSock 2.0. We need to dynamically */
/* load ws2_32.dll and get the function pointers we need. */
wsock2 = LoadLibrary("WS2_32.DLL");
if (wsock2 == NULL) {
if(wsock2 == NULL) {
failf(data,"failed to load WS2_32.DLL (%d)", ERRNO);
return CURLE_FAILED_INIT;
}
/* Grab a pointer to WSACreateEvent */
create_event_func = GetProcAddress(wsock2,"WSACreateEvent");
if (create_event_func == NULL) {
if(create_event_func == NULL) {
failf(data,"failed to find WSACreateEvent function (%d)",
ERRNO);
FreeLibrary(wsock2);
@@ -1183,7 +1200,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* And WSACloseEvent */
close_event_func = GetProcAddress(wsock2,"WSACloseEvent");
if (close_event_func == NULL) {
if(close_event_func == NULL) {
failf(data,"failed to find WSACloseEvent function (%d)",
ERRNO);
FreeLibrary(wsock2);
@@ -1192,7 +1209,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* And WSAEventSelect */
event_select_func = GetProcAddress(wsock2,"WSAEventSelect");
if (event_select_func == NULL) {
if(event_select_func == NULL) {
failf(data,"failed to find WSAEventSelect function (%d)",
ERRNO);
FreeLibrary(wsock2);
@@ -1201,7 +1218,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* And WSAEnumNetworkEvents */
enum_netevents_func = GetProcAddress(wsock2,"WSAEnumNetworkEvents");
if (enum_netevents_func == NULL) {
if(enum_netevents_func == NULL) {
failf(data,"failed to find WSAEnumNetworkEvents function (%d)",
ERRNO);
FreeLibrary(wsock2);
@@ -1215,7 +1232,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* First, create a sockets event object */
event_handle = (WSAEVENT)create_event_func();
if (event_handle == WSA_INVALID_EVENT) {
if(event_handle == WSA_INVALID_EVENT) {
failf(data,"WSACreateEvent failed (%d)", SOCKERRNO);
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
@@ -1343,7 +1360,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
}
/* We called WSACreateEvent, so call WSACloseEvent */
if (close_event_func(event_handle) == FALSE) {
if(close_event_func(event_handle) == FALSE) {
infof(data,"WSACloseEvent failed (%d)", SOCKERRNO);
}
@@ -1354,7 +1371,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
enum_netevents_func = NULL;
/* We called LoadLibrary, so call FreeLibrary */
if (!FreeLibrary(wsock2))
if(!FreeLibrary(wsock2))
infof(data,"FreeLibrary(wsock2) failed (%d)", ERRNO);
#else
pfd[0].fd = sockfd;
@@ -1363,7 +1380,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
pfd[1].events = POLLIN;
interval_ms = 1 * 1000;
while (keepon) {
while(keepon) {
switch (Curl_poll(pfd, 2, interval_ms)) {
case -1: /* error, stop reading */
keepon = FALSE;
@@ -1396,7 +1413,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* if we receive 0 or less here, the server closed the connection and
we bail out from this! */
if (nread <= 0) {
if(nread <= 0) {
keepon = FALSE;
break;
}

View File

@@ -306,7 +306,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
if(data->set.upload) {
/* If we are uploading, send an WRQ */
setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
state->conn->data->reqdata.upload_fromhere = (char *)&state->spacket.data[4];
state->conn->data->reqdata.upload_fromhere =
(char *)&state->spacket.data[4];
if(data->set.infilesize != -1)
Curl_pgrsSetUploadSize(data, data->set.infilesize);
}
@@ -318,7 +319,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
file name so we skip the always-present first letter of the path string. */
filename = curl_easy_unescape(data, &state->conn->data->reqdata.path[1], 0,
NULL);
if (!filename)
if(!filename)
return CURLE_OUT_OF_MEMORY;
snprintf((char *)&state->spacket.data[2],
@@ -377,12 +378,12 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
/* Is this the block we expect? */
rblock = getrpacketblock(&state->rpacket);
if ((state->block+1) != rblock) {
if((state->block+1) != rblock) {
/* No, log it, up the retry count and fail if over the limit */
infof(data,
"Received unexpected DATA packet block %d\n", rblock);
state->retries++;
if (state->retries>state->retry_max) {
if(state->retries>state->retry_max) {
failf(data, "tftp_rx: giving up waiting for block %d\n",
state->block+1);
return CURLE_TFTP_ILLEGAL;
@@ -403,7 +404,7 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
}
/* Check if completed (That is, a less than full packet is received) */
if (state->rbytes < (int)sizeof(state->spacket)){
if(state->rbytes < (int)sizeof(state->spacket)){
state->state = TFTP_STATE_FIN;
}
else {
@@ -698,8 +699,7 @@ static CURLcode Curl_tftp_done(struct connectdata *conn, CURLcode status,
static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
{
struct SessionHandle *data = conn->data;
tftp_state_data_t *state =
(tftp_state_data_t *) conn->data->reqdata.proto.tftp;
tftp_state_data_t *state;
tftp_event_t event;
CURLcode code;
int rc;
@@ -716,16 +716,14 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
make sure we have a good 'struct TFTP' to play with. For new connections,
the struct TFTP is allocated and setup in the Curl_tftp_connect() function.
*/
if(!state) {
Curl_reset_reqproto(conn);
if(!data->reqdata.proto.tftp) {
code = Curl_tftp_connect(conn, done);
if(code)
return code;
state = (tftp_state_data_t *)conn->data->reqdata.proto.tftp;
}
code = Curl_readwrite_init(conn);
if(code)
return code;
state = (tftp_state_data_t *)data->reqdata.proto.tftp;
/* Run the TFTP State Machine */
for(code=tftp_state_machine(state, TFTP_EVENT_INIT);
@@ -742,7 +740,7 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
failf(data, "%s\n", Curl_strerror(conn, error));
event = TFTP_EVENT_ERROR;
}
else if (rc==0) {
else if(rc==0) {
/* A timeout occured */
event = TFTP_EVENT_TIMEOUT;
@@ -763,8 +761,8 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
}
/* Sanity check packet length */
if (state->rbytes < 4) {
failf(conn->data, "Received too short packet\n");
if(state->rbytes < 4) {
failf(data, "Received too short packet\n");
/* Not a timeout, but how best to handle it? */
event = TFTP_EVENT_TIMEOUT;
}
@@ -776,7 +774,7 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
switch(event) {
case TFTP_EVENT_DATA:
/* Don't pass to the client empty or retransmitted packets */
if (state->rbytes > 4 &&
if(state->rbytes > 4 &&
((state->block+1) == getrpacketblock(&state->rpacket))) {
code = Curl_client_write(conn, CLIENTWRITE_BODY,
(char *)&state->rpacket.data[4],
@@ -789,14 +787,14 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
break;
case TFTP_EVENT_ERROR:
state->error = (tftp_error_t)getrpacketblock(&state->rpacket);
infof(conn->data, "%s\n", (char *)&state->rpacket.data[4]);
infof(data, "%s\n", (char *)&state->rpacket.data[4]);
break;
case TFTP_EVENT_ACK:
break;
case TFTP_EVENT_RRQ:
case TFTP_EVENT_WRQ:
default:
failf(conn->data, "%s\n", "Internal error: Unexpected packet");
failf(data, "%s\n", "Internal error: Unexpected packet");
break;
}
@@ -882,10 +880,10 @@ static CURLcode Curl_tftp_setup_connection(struct connectdata * conn)
* we'll try to get now! */
type = strstr(data->reqdata.path, ";mode=");
if (!type)
if(!type)
type = strstr(conn->host.rawalloc, ";mode=");
if (type) {
if(type) {
*type = 0; /* it was in the middle of the hostname */
command = (char) toupper((int) type[6]);

View File

@@ -128,7 +128,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
/* this function returns a size_t, so we typecast to int to prevent warnings
with picky compilers */
nread = (int)conn->fread_func(data->reqdata.upload_fromhere, 1,
buffersize, conn->fread_in);
buffersize, conn->fread_in);
if(nread == CURL_READFUNC_ABORT) {
failf(data, "operation aborted by callback\n");
@@ -188,12 +188,12 @@ checkhttpprefix(struct SessionHandle *data,
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding using a scratch area */
char *scratch = calloc(1, strlen(s)+1);
if (NULL == scratch) {
if(NULL == scratch) {
failf (data, "Failed to calloc memory for conversion!");
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
}
strcpy(scratch, s);
if (CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(scratch);
return FALSE; /* can't return CURLE_foobar so return FALSE */
@@ -201,15 +201,15 @@ checkhttpprefix(struct SessionHandle *data,
s = scratch;
#endif /* CURL_DOES_CONVERSIONS */
while (head) {
if (checkprefix(head->data, s)) {
while(head) {
if(checkprefix(head->data, s)) {
rc = TRUE;
break;
}
head = head->next;
}
if ((rc != TRUE) && (checkprefix("HTTP/", s))) {
if((rc != TRUE) && (checkprefix("HTTP/", s))) {
rc = TRUE;
}
@@ -292,7 +292,7 @@ static void read_rewind(struct connectdata *conn,
size_t show;
show = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
if (conn->master_buffer) {
if(conn->master_buffer) {
memcpy(buf, conn->master_buffer + conn->read_pos, show);
buf[show] = '\0';
}
@@ -333,7 +333,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if((k->keepon & (KEEP_READ|KEEP_READ_HOLD)) == KEEP_READ) {
fd_read = conn->sockfd;
#if defined(USE_LIBSSH2)
if (conn->protocol & (PROT_SCP|PROT_SFTP))
if(conn->protocol & (PROT_SCP|PROT_SFTP))
select_res |= CURL_CSELECT_IN;
#endif /* USE_LIBSSH2 */
} else
@@ -344,7 +344,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
else
fd_write = CURL_SOCKET_BAD;
if (!select_res) { /* Call for select()/poll() only, if read/write/error
if(!select_res) { /* Call for select()/poll() only, if read/write/error
status is not known. */
select_res = Curl_socket_ready(fd_read, fd_write, 0);
}
@@ -371,7 +371,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
size_t bytestoread = buffersize;
int readrc;
if (k->size != -1 && !k->header) {
if(k->size != -1 && !k->header) {
/* make sure we don't read "too much" if we can help it since we
might be pipelining and then someone else might want to read what
follows! */
@@ -393,7 +393,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(result>0)
return result;
if ((k->bytecount == 0) && (k->writebytecount == 0)) {
if((k->bytecount == 0) && (k->writebytecount == 0)) {
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
if(k->wait100_after_headers)
/* set time stamp to compare with when waiting for the 100 */
@@ -405,10 +405,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0));
/* NULL terminate, allowing string ops to be used */
if (0 < nread || is_empty_data) {
if(0 < nread || is_empty_data) {
k->buf[nread] = 0;
}
else if (0 >= nread) {
else if(0 >= nread) {
/* if we receive 0 or less here, the server closed the connection
and we bail out from this! */
DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n"));
@@ -422,7 +422,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* Since this is a two-state thing, we check if we are parsing
headers at the moment or not. */
if (k->header) {
if(k->header) {
/* we are in parse-the-header-mode */
bool stop_reading = FALSE;
@@ -439,11 +439,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* data is in network encoding so use 0x0a instead of '\n' */
k->end_ptr = memchr(k->str_start, 0x0a, nread);
if (!k->end_ptr) {
if(!k->end_ptr) {
/* Not a complete header line within buffer, append the data to
the end of the headerbuff. */
if (k->hbuflen + nread >= data->state.headersize) {
if(k->hbuflen + nread >= data->state.headersize) {
/* We enlarge the header buffer as it is too small */
char *newbuff;
size_t newsize=CURLMAX((k->hbuflen+nread)*3/2,
@@ -461,7 +461,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
memcpy(k->hbufp, k->str, nread);
k->hbufp += nread;
k->hbuflen += nread;
if (!k->headerline && (k->hbuflen>5)) {
if(!k->headerline && (k->hbuflen>5)) {
/* make a first check that this looks like a HTTP header */
if(!checkhttpprefix(data, data->state.headerbuff)) {
/* this is not the beginning of a HTTP first header line */
@@ -488,7 +488,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* fit in the allocated header buffer, or else we enlarge
* it.
*/
if (k->hbuflen + full_length >=
if(k->hbuflen + full_length >=
data->state.headersize) {
char *newbuff;
size_t newsize=CURLMAX((k->hbuflen+full_length)*3/2,
@@ -537,23 +537,23 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* headers are in network encoding so
use 0x0a and 0x0d instead of '\n' and '\r' */
if ((0x0a == *k->p) || (0x0d == *k->p)) {
if((0x0a == *k->p) || (0x0d == *k->p)) {
size_t headerlen;
/* Zero-length header line means end of headers! */
#ifdef CURL_DOES_CONVERSIONS
if (0x0d == *k->p) {
if(0x0d == *k->p) {
*k->p = '\r'; /* replace with CR in host encoding */
k->p++; /* pass the CR byte */
}
if (0x0a == *k->p) {
if(0x0a == *k->p) {
*k->p = '\n'; /* replace with LF in host encoding */
k->p++; /* pass the LF byte */
}
#else
if ('\r' == *k->p)
if('\r' == *k->p)
k->p++; /* pass the \r byte */
if ('\n' == *k->p)
if('\n' == *k->p)
k->p++; /* pass the \n byte */
#endif /* CURL_DOES_CONVERSIONS */
@@ -568,7 +568,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->header = TRUE;
k->headerline = 0; /* restart the header line counter */
/* if we did wait for this do enable write now! */
if (k->write_after_100_header) {
if(k->write_after_100_header) {
k->write_after_100_header = FALSE;
k->keepon |= KEEP_WRITE;
@@ -590,7 +590,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
}
if (417 == k->httpcode) {
if(417 == k->httpcode) {
/*
* we got: "417 Expectation Failed" this means:
* we have made a HTTP call and our Expect Header
@@ -606,7 +606,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* When all the headers have been parsed, see if we should give
* up and return an error.
*/
if (Curl_http_should_fail(conn)) {
if(Curl_http_should_fail(conn)) {
failf (data, "The requested URL returned error: %d",
k->httpcode);
return CURLE_HTTP_RETURNED_ERROR;
@@ -616,7 +616,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* now, only output this if the header AND body are requested:
*/
writetype = CLIENTWRITE_HEADER;
if (data->set.include_header)
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
headerlen = k->p - data->state.headerbuff;
@@ -633,7 +633,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
data->reqdata.keep.deductheadercount =
(100 == k->httpcode)?data->reqdata.keep.headerbytecount:0;
if (data->reqdata.resume_from &&
if(data->reqdata.resume_from &&
(data->set.httpreq==HTTPREQ_GET) &&
(k->httpcode == 416)) {
/* "Requested Range Not Satisfiable" */
@@ -721,7 +721,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* Checks for special headers coming up.
*/
if (!k->headerline++) {
if(!k->headerline++) {
/* This is the first header, it MUST be the error code line
or else we consider this to be the body right away! */
int httpversion_major;
@@ -741,7 +741,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
res = Curl_convert_from_network(data,
&scratch[0],
SCRATCHSIZE);
if (CURLE_OK != res) {
if(CURLE_OK != res) {
/* Curl_convert_from_network calls failf if unsuccessful */
return res;
}
@@ -754,7 +754,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
&httpversion_major,
&k->httpversion,
&k->httpcode);
if (nc==3) {
if(nc==3) {
k->httpversion += 10 * httpversion_major;
}
else {
@@ -767,8 +767,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* If user has set option HTTP200ALIASES,
compare header line against list of aliases
*/
if (!nc) {
if (checkhttpprefix(data, k->p)) {
if(!nc) {
if(checkhttpprefix(data, k->p)) {
nc = 1;
k->httpcode = 200;
k->httpversion = 10;
@@ -776,7 +776,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
}
if (nc) {
if(nc) {
data->info.httpcode = k->httpcode;
data->info.httpversion = k->httpversion;
@@ -788,11 +788,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* depending on how authentication is working. Other codes
* are definitely errors, so give up here.
*/
if (data->set.http_fail_on_error && (k->httpcode >= 400) &&
if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
((k->httpcode != 401) || !conn->bits.user_passwd) &&
((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) {
if (data->reqdata.resume_from &&
if(data->reqdata.resume_from &&
(data->set.httpreq==HTTPREQ_GET) &&
(k->httpcode == 416)) {
/* "Requested Range Not Satisfiable", just proceed and
@@ -848,7 +848,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding */
result = Curl_convert_from_network(data, k->p, strlen(k->p));
if (CURLE_OK != result) {
if(CURLE_OK != result) {
return(result);
}
/* Curl_convert_from_network calls failf if unsuccessful */
@@ -858,10 +858,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
the header completely if we get a 416 response as then we're
resuming a document that we don't get, and this header contains
info about the true size of the document we didn't get now. */
if (!k->ignorecl && !data->set.ignorecl &&
if(!k->ignorecl && !data->set.ignorecl &&
checkprefix("Content-Length:", k->p)) {
contentlength = curlx_strtoofft(k->p+15, NULL, 10);
if (data->set.max_filesize &&
if(data->set.max_filesize &&
contentlength > data->set.max_filesize) {
failf(data, "Maximum file size exceeded");
return CURLE_FILESIZE_EXCEEDED;
@@ -884,7 +884,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
}
/* 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 *start;
char *end;
size_t len;
@@ -913,7 +913,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
Curl_safefree(data->info.contenttype);
data->info.contenttype = malloc(len + 1);
if (NULL == data->info.contenttype)
if(NULL == data->info.contenttype)
return CURLE_OUT_OF_MEMORY;
/* copy the content-type string */
@@ -957,7 +957,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
conn->bits.close = FALSE; /* don't close when done */
infof(data, "HTTP/1.0 connection set to keep alive!\n");
}
else if (Curl_compareheader(k->p, "Connection:", "close")) {
else if(Curl_compareheader(k->p, "Connection:", "close")) {
/*
* [RFC 2616, section 8.1.2.1]
* "Connection: close" is HTTP/1.1 language and means that
@@ -966,7 +966,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*/
conn->bits.close = TRUE; /* close when done */
}
else if (Curl_compareheader(k->p,
else if(Curl_compareheader(k->p,
"Transfer-Encoding:", "chunked")) {
/*
* [RFC 2616, section 3.6.1] A 'chunked' transfer encoding
@@ -982,7 +982,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
Curl_httpchunk_init(conn);
}
else if (checkprefix("Trailer:", k->p) ||
else if(checkprefix("Trailer:", k->p) ||
checkprefix("Trailers:", k->p)) {
/*
* This test helps Curl_httpchunk_read() to determine to look
@@ -992,10 +992,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*
* It seems both Trailer: and Trailers: occur in the wild.
*/
conn->bits.trailerHdrPresent = TRUE;
conn->bits.trailerhdrpresent = TRUE;
}
else if (checkprefix("Content-Encoding:", k->p) &&
else if(checkprefix("Content-Encoding:", k->p) &&
data->set.str[STRING_ENCODING]) {
/*
* Process Content-Encoding. Look for the values: identity,
@@ -1013,18 +1013,18 @@ CURLcode Curl_readwrite(struct connectdata *conn,
; /* empty loop */
/* Record the content-encoding for later use */
if (checkprefix("identity", start))
if(checkprefix("identity", start))
k->content_encoding = IDENTITY;
else if (checkprefix("deflate", start))
else if(checkprefix("deflate", start))
k->content_encoding = DEFLATE;
else if (checkprefix("gzip", start)
else if(checkprefix("gzip", start)
|| checkprefix("x-gzip", start))
k->content_encoding = GZIP;
else if (checkprefix("compress", start)
else if(checkprefix("compress", start)
|| checkprefix("x-compress", start))
k->content_encoding = COMPRESS;
}
else if (checkprefix("Content-Range:", k->p)) {
else if(checkprefix("Content-Range:", k->p)) {
/* Content-Range: bytes [num]-
Content-Range: bytes: [num]-
Content-Range: [num]-
@@ -1042,7 +1042,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->offset = curlx_strtoofft(ptr, NULL, 10);
if (data->reqdata.resume_from == k->offset)
if(data->reqdata.resume_from == k->offset)
/* we asked for a resume and we got it */
k->content_range = TRUE;
}
@@ -1077,7 +1077,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(result)
return result;
}
else if ((k->httpcode >= 300 && k->httpcode < 400) &&
else if((k->httpcode >= 300 && k->httpcode < 400) &&
checkprefix("Location:", k->p)) {
if(data->set.http_follow_location) {
/* this is the URL that the server advices us to get instead */
@@ -1119,7 +1119,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*/
writetype = CLIENTWRITE_HEADER;
if (data->set.include_header)
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
if(data->set.verbose)
@@ -1137,7 +1137,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->hbufp = data->state.headerbuff;
k->hbuflen = 0;
}
while (!stop_reading && *k->str); /* header line within buffer */
while(!stop_reading && *k->str); /* header line within buffer */
if(stop_reading)
/* We've stopped dealing with input, get out of the do-while loop */
@@ -1152,7 +1152,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* This is not an 'else if' since it may be a rest from the header
parsing, where the beginning of the buffer is headers and the end
is non-headers. */
if (k->str && !k->header && (nread > 0 || is_empty_data)) {
if(k->str && !k->header && (nread > 0 || is_empty_data)) {
if(0 == k->bodywrites && !is_empty_data) {
/* These checks are only made the first time we are about to
@@ -1160,7 +1160,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(conn->protocol&PROT_HTTP) {
/* HTTP-only checks */
if (data->reqdata.newurl) {
if(data->reqdata.newurl) {
if(conn->bits.close) {
/* Abort after the headers if "follow Location" is set
and we're set to close anyway. */
@@ -1174,7 +1174,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->ignorebody = TRUE;
infof(data, "Ignoring the response-body\n");
}
if (data->reqdata.resume_from && !k->content_range &&
if(data->reqdata.resume_from && !k->content_range &&
(data->set.httpreq==HTTPREQ_GET) &&
!k->ignorebody) {
/* we wanted to resume a download, although the server doesn't
@@ -1263,7 +1263,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
Push it back to be read on the next pass. */
dataleft = conn->chunk.dataleft;
if (dataleft != 0) {
if(dataleft != 0) {
infof(conn->data, "Leftovers after chunking. "
" Rewinding %d bytes\n",dataleft);
read_rewind(conn, dataleft);
@@ -1278,7 +1278,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* The 'excess' amount below can't be more than BUFSIZE which
always will fit in a size_t */
size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
if (excess > 0 && !k->ignorebody) {
if(excess > 0 && !k->ignorebody) {
infof(data,
"Rewinding stream by : %d"
" bytes on url %s (size = %" FORMAT_OFF_T
@@ -1360,9 +1360,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
return result;
}
} /* if (! header and data to read ) */
} /* if(! header and data to read ) */
if (is_empty_data) {
if(is_empty_data) {
/* if we received nothing, the server closed the connection and we
are done */
k->keepon &= ~KEEP_READ;
@@ -1381,7 +1381,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
ssize_t bytes_written;
bool writedone=TRUE;
if ((k->bytecount == 0) && (k->writebytecount == 0))
if((k->bytecount == 0) && (k->writebytecount == 0))
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
didwhat |= KEEP_WRITE;
@@ -1427,7 +1427,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* the signed int typecase of nread of for systems that has
unsigned size_t */
if (nread<=0) {
if(nread<=0) {
/* done */
k->keepon &= ~KEEP_WRITE; /* we're done writing */
writedone = TRUE;
@@ -1446,9 +1446,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* convert LF to CRLF if so asked */
#ifdef CURL_DO_LINEEND_CONV
/* always convert if we're FTPing in ASCII mode */
if ((data->set.crlf) || (data->set.prefer_ascii)) {
if((data->set.crlf) || (data->set.prefer_ascii)) {
#else
if (data->set.crlf) {
if(data->set.crlf) {
#endif /* CURL_DO_LINEEND_CONV */
if(data->state.scratch == NULL)
data->state.scratch = malloc(2*BUFSIZE);
@@ -1463,10 +1463,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* must be used instead of the escape sequences \r & \n.
*/
for(i = 0, si = 0; i < nread; i++, si++) {
if (data->reqdata.upload_fromhere[i] == 0x0a) {
if(data->reqdata.upload_fromhere[i] == 0x0a) {
data->state.scratch[si++] = 0x0d;
data->state.scratch[si] = 0x0a;
if (!data->set.crlf) {
if(!data->set.crlf) {
/* we're here only because FTP is in ASCII mode...
bump infilesize for the LF we just added */
data->set.infilesize++;
@@ -1550,7 +1550,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
else {
/* no read no write, this is a timeout? */
if (k->write_after_100_header) {
if(k->write_after_100_header) {
/* This should allow some time for the header to arrive, but only a
very short time as otherwise it'll be too much wasted times too
often. */
@@ -1577,12 +1577,12 @@ CURLcode Curl_readwrite(struct connectdata *conn,
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, k->now);
if (result)
if(result)
return result;
if (data->set.timeout &&
if(data->set.timeout &&
(Curl_tvdiff(k->now, k->start) >= data->set.timeout)) {
if (k->size != -1) {
if(k->size != -1) {
failf(data, "Operation timed out after %ld milliseconds with %"
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
data->set.timeout, k->bytecount, k->size);
@@ -1640,102 +1640,6 @@ CURLcode Curl_readwrite(struct connectdata *conn,
return CURLE_OK;
}
/*
* Curl_readwrite_init() inits the readwrite session. This is inited each time
* for a transfer, sometimes multiple times on the same SessionHandle
*/
CURLcode Curl_readwrite_init(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
struct Curl_transfer_keeper *k = &data->reqdata.keep;
/* NB: the content encoding software depends on this initialization of
Curl_transfer_keeper.*/
memset(k, 0, sizeof(struct Curl_transfer_keeper));
k->start = Curl_tvnow(); /* start time */
k->now = k->start; /* current time is now */
k->header = TRUE; /* assume header */
k->httpversion = -1; /* unknown at this point */
k->size = data->reqdata.size;
k->maxdownload = data->reqdata.maxdownload;
k->bytecountp = data->reqdata.bytecountp;
k->writebytecountp = data->reqdata.writebytecountp;
k->bytecount = 0;
k->buf = data->state.buffer;
k->uploadbuf = data->state.uploadbuffer;
k->maxfd = (conn->sockfd>conn->writesockfd?
conn->sockfd:conn->writesockfd)+1;
k->hbufp = data->state.headerbuff;
k->ignorebody=FALSE;
Curl_pgrsTime(data, TIMER_PRETRANSFER);
Curl_speedinit(data);
Curl_pgrsSetUploadCounter(data, 0);
Curl_pgrsSetDownloadCounter(data, 0);
if (!conn->bits.getheader) {
k->header = FALSE;
if(k->size > 0)
Curl_pgrsSetDownloadSize(data, k->size);
}
/* we want header and/or body, if neither then don't do this! */
if(conn->bits.getheader || !conn->bits.no_body) {
if(conn->sockfd != CURL_SOCKET_BAD) {
k->keepon |= KEEP_READ;
}
if(conn->writesockfd != CURL_SOCKET_BAD) {
/* HTTP 1.1 magic:
Even if we require a 100-return code before uploading data, we might
need to write data before that since the REQUEST may not have been
finished sent off just yet.
Thus, we must check if the request has been sent before we set the
state info where we wait for the 100-return code
*/
if (data->state.expect100header &&
(data->reqdata.proto.http->sending == HTTPSEND_BODY)) {
/* wait with write until we either got 100-continue or a timeout */
k->write_after_100_header = TRUE;
k->start100 = k->start;
}
else {
if(data->state.expect100header)
/* when we've sent off the rest of the headers, we must await a
100-continue */
k->wait100_after_headers = TRUE;
k->keepon |= KEEP_WRITE;
}
}
}
return CURLE_OK;
}
/*
* Curl_readwrite may get called multiple times. This function is called
* immediately before the first Curl_readwrite. Note that this can't be moved
* to Curl_readwrite_init since that function can get called while another
* pipeline request is in the middle of receiving data.
*
* We init chunking and trailer bits to their default values here immediately
* before receiving any header data for the current request in the pipeline.
*/
void Curl_pre_readwrite(struct connectdata *conn)
{
conn->bits.chunk=FALSE;
conn->bits.trailerHdrPresent=FALSE;
}
/*
* Curl_single_getsock() gets called by the multi interface code when the app
* has requested to get the sockets for the current connection. This function
@@ -1757,6 +1661,9 @@ int Curl_single_getsock(const struct connectdata *conn,
return GETSOCK_BLANK;
if(data->reqdata.keep.keepon & KEEP_READ) {
DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD);
bitmap |= GETSOCK_READSOCK(sockindex);
sock[sockindex] = conn->sockfd;
}
@@ -1769,6 +1676,9 @@ int Curl_single_getsock(const struct connectdata *conn,
one, we increase index */
if(data->reqdata.keep.keepon & KEEP_READ)
sockindex++; /* increase index if we need two entries */
DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD);
sock[sockindex] = conn->writesockfd;
}
@@ -1801,15 +1711,6 @@ Transfer(struct connectdata *conn)
struct Curl_transfer_keeper *k = &data->reqdata.keep;
bool done=FALSE;
if(!(conn->protocol & (PROT_FILE|PROT_TFTP))) {
/* Only do this if we are not transferring FILE or TFTP, since those
transfers are treated differently. They do their entire transfers in
the DO function and just returns from this. That is ugly indeed.
*/
Curl_readwrite_init(conn);
Curl_pre_readwrite(conn);
}
if((conn->sockfd == CURL_SOCKET_BAD) &&
(conn->writesockfd == CURL_SOCKET_BAD))
/* nothing to read, nothing to write, we're already OK! */
@@ -1819,14 +1720,14 @@ Transfer(struct connectdata *conn)
if(!conn->bits.getheader && conn->bits.no_body)
return CURLE_OK;
while (!done) {
while(!done) {
curl_socket_t fd_read;
curl_socket_t fd_write;
/* limit-rate logic: if speed exceeds threshold, then do not include fd in
select set. The current speed is recalculated in each Curl_readwrite()
call */
if ((k->keepon & KEEP_WRITE) &&
if((k->keepon & KEEP_WRITE) &&
(!data->set.max_send_speed ||
(data->progress.ulspeed < data->set.max_send_speed) )) {
fd_write = conn->writesockfd;
@@ -1838,7 +1739,7 @@ Transfer(struct connectdata *conn)
k->keepon |= KEEP_WRITE_HOLD; /* hold it */
}
if ((k->keepon & KEEP_READ) &&
if((k->keepon & KEEP_READ) &&
(!data->set.max_recv_speed ||
(data->progress.dlspeed < data->set.max_recv_speed)) ) {
fd_read = conn->sockfd;
@@ -2034,7 +1935,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
char *newest;
if(!retry) {
if ((data->set.maxredirs != -1) &&
if((data->set.maxredirs != -1) &&
(data->set.followlocation >= data->set.maxredirs)) {
failf(data,"Maximum (%d) redirects followed", data->set.maxredirs);
return CURLE_TOO_MANY_REDIRECTS;
@@ -2350,7 +2251,7 @@ Curl_connect_host(struct SessionHandle *data,
the Curl_connect(), we detect it here and act as if we are redirected
to the new URL */
urlchanged = data->change.url_changed;
if ((CURLE_OK == res) && urlchanged) {
if((CURLE_OK == res) && urlchanged) {
res = Curl_done(conn, res, FALSE);
if(CURLE_OK == res) {
char *gotourl = strdup(data->change.url);
@@ -2359,7 +2260,7 @@ Curl_connect_host(struct SessionHandle *data,
free(gotourl);
}
}
} while (urlchanged && res == CURLE_OK);
} while(urlchanged && res == CURLE_OK);
return res;
}
@@ -2523,25 +2424,23 @@ CURLcode Curl_perform(struct SessionHandle *data)
*/
CURLcode
Curl_setup_transfer(
struct connectdata *c_conn, /* connection data */
int sockindex, /* socket index to read from or -1 */
curl_off_t size, /* -1 if unknown at this point */
bool getheader, /* TRUE if header parsing is wanted */
curl_off_t *bytecountp, /* return number of bytes read or NULL */
int writesockindex, /* socket index to write to, it may very
well be the same we read from. -1
disables */
curl_off_t *writecountp /* return number of bytes written or
NULL */
)
struct connectdata *conn, /* connection data */
int sockindex, /* socket index to read from or -1 */
curl_off_t size, /* -1 if unknown at this point */
bool getheader, /* TRUE if header parsing is wanted */
curl_off_t *bytecountp, /* return number of bytes read or NULL */
int writesockindex, /* socket index to write to, it may very well be
the same we read from. -1 disables */
curl_off_t *writecountp /* return number of bytes written or NULL */
)
{
struct connectdata *conn = (struct connectdata *)c_conn;
struct SessionHandle *data;
struct Curl_transfer_keeper *k;
if(!conn)
return CURLE_BAD_FUNCTION_ARGUMENT;
DEBUGASSERT(conn != NULL);
data = conn->data;
k = &data->reqdata.keep;
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
@@ -2556,5 +2455,47 @@ Curl_setup_transfer(
data->reqdata.bytecountp = bytecountp;
data->reqdata.writebytecountp = writecountp;
/* The code sequence below is placed in this function just because all
necessary input is not always known in do_complete() as this function may
be called after that */
if(!conn->bits.getheader) {
k->header = FALSE;
if(k->size > 0)
Curl_pgrsSetDownloadSize(data, k->size);
}
/* we want header and/or body, if neither then don't do this! */
if(conn->bits.getheader || !conn->bits.no_body) {
if(conn->sockfd != CURL_SOCKET_BAD) {
k->keepon |= KEEP_READ;
}
if(conn->writesockfd != CURL_SOCKET_BAD) {
/* HTTP 1.1 magic:
Even if we require a 100-return code before uploading data, we might
need to write data before that since the REQUEST may not have been
finished sent off just yet.
Thus, we must check if the request has been sent before we set the
state info where we wait for the 100-return code
*/
if(data->state.expect100header &&
(data->reqdata.proto.http->sending == HTTPSEND_BODY)) {
/* wait with write until we either got 100-continue or a timeout */
k->write_after_100_header = TRUE;
k->start100 = k->start;
}
else {
if(data->state.expect100header)
/* when we've sent off the rest of the headers, we must await a
100-continue */
k->wait100_after_headers = TRUE;
k->keepon |= KEEP_WRITE;
}
}
}
return CURLE_OK;
}

View File

@@ -31,8 +31,6 @@ CURLcode Curl_readwrite(struct connectdata *conn, bool *done);
int Curl_single_getsock(const struct connectdata *conn,
curl_socket_t *socks,
int numsocks);
CURLcode Curl_readwrite_init(struct connectdata *conn);
void Curl_pre_readwrite(struct connectdata *conn);
CURLcode Curl_readrewind(struct connectdata *conn);
CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp);
bool Curl_retry_request(struct connectdata *conn, char **url);

Some files were not shown because too many files have changed in this diff Show More