Compare commits

..

No commits in common. "main" and "curl-7_47_1" have entirely different histories.

299 changed files with 2080 additions and 3585 deletions

View File

@ -1,9 +0,0 @@
### I did this
### I expected the following
### curl/libcurl version
[curl -V output perhaps?]
### operating system

View File

@ -8,7 +8,7 @@ Join the community
2. Subscribe to the suitable [mailing lists](https://curl.haxx.se/mail/) 2. Subscribe to the suitable [mailing lists](https://curl.haxx.se/mail/)
Read [CONTRIBUTE](../docs/CONTRIBUTE) Read [docs/CONTRIBUTE](docs/CONTRIBUTE)
--------------------------------------- ---------------------------------------
Send your suggestions using one of these methods: Send your suggestions using one of these methods:
@ -16,8 +16,10 @@ Send your suggestions using one of these methods:
1. in a mail to the mailing list 1. in a mail to the mailing list
2. as a [pull request](https://github.com/curl/curl/pulls) 2. as a pull request on github
3. as an issue on github
3. as an [issue](https://github.com/curl/curl/issues)
/ The cURL team! / The cURL team!

View File

@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___ # | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____| # \___|\___/|_| \_\_____|
# #
# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. # Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
# #
# This software is licensed as described in the file COPYING, which # This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms # you should have received as part of this distribution. The terms
@ -92,45 +92,37 @@ VC14_SRCTMPL = projects/Windows/VC14/src/curl.tmpl
VC14_SRCVCXPROJ = projects/Windows/VC14/src/curl.vcxproj.dist VC14_SRCVCXPROJ = projects/Windows/VC14/src/curl.vcxproj.dist
VC14_SRCVCXPROJ_DEPS = $(VC14_SRCTMPL) Makefile.am src/Makefile.inc VC14_SRCVCXPROJ_DEPS = $(VC14_SRCTMPL) Makefile.am src/Makefile.inc
VC_DIST = projects/README \ VC_DIST = projects/README \
projects/build-openssl.bat \ projects/build-openssl.bat \
projects/build-wolfssl.bat \ projects/build-wolfssl.bat \
projects/checksrc.bat \ projects/checksrc.bat \
projects/Windows/VC6/curl-all.dsw \ projects/Windows/VC6/curl-all.dsw \
projects/Windows/VC6/lib/libcurl.dsw \ projects/Windows/VC6/lib/libcurl.dsw \
projects/Windows/VC6/src/curl.dsw \ projects/Windows/VC6/src/curl.dsw \
projects/Windows/VC7/curl-all.sln \ projects/Windows/VC7/curl-all.sln \
projects/Windows/VC7/lib/libcurl.sln \ projects/Windows/VC7/lib/libcurl.sln \
projects/Windows/VC7/src/curl.sln \ projects/Windows/VC7/src/curl.sln \
projects/Windows/VC7.1/curl-all.sln \ projects/Windows/VC7.1/curl-all.sln \
projects/Windows/VC7.1/lib/libcurl.sln \ projects/Windows/VC7.1/lib/libcurl.sln \
projects/Windows/VC7.1/src/curl.sln \ projects/Windows/VC7.1/src/curl.sln \
projects/Windows/VC8/curl-all.sln \ projects/Windows/VC8/curl-all.sln \
projects/Windows/VC8/lib/libcurl.sln \ projects/Windows/VC8/lib/libcurl.sln \
projects/Windows/VC8/src/curl.sln \ projects/Windows/VC8/src/curl.sln \
projects/Windows/VC9/curl-all.sln \ projects/Windows/VC9/curl-all.sln \
projects/Windows/VC9/lib/libcurl.sln \ projects/Windows/VC9/lib/libcurl.sln \
projects/Windows/VC9/src/curl.sln \ projects/Windows/VC9/src/curl.sln \
projects/Windows/VC10/curl-all.sln \ projects/Windows/VC10/curl-all.sln \
projects/Windows/VC10/lib/libcurl.sln \ projects/Windows/VC10/lib/libcurl.sln \
projects/Windows/VC10/lib/libcurl.vcxproj.filters \ projects/Windows/VC10/src/curl.sln \
projects/Windows/VC10/src/curl.sln \ projects/Windows/VC11/curl-all.sln \
projects/Windows/VC10/src/curl.vcxproj.filters \ projects/Windows/VC11/lib/libcurl.sln \
projects/Windows/VC11/curl-all.sln \ projects/Windows/VC11/src/curl.sln \
projects/Windows/VC11/lib/libcurl.sln \ projects/Windows/VC12/curl-all.sln \
projects/Windows/VC11/lib/libcurl.vcxproj.filters \ projects/Windows/VC12/lib/libcurl.sln \
projects/Windows/VC11/src/curl.sln \ projects/Windows/VC12/src/curl.sln \
projects/Windows/VC11/src/curl.vcxproj.filters \ projects/Windows/VC14/curl-all.sln \
projects/Windows/VC12/curl-all.sln \ projects/Windows/VC14/lib/libcurl.sln \
projects/Windows/VC12/lib/libcurl.sln \ projects/Windows/VC14/src/curl.sln
projects/Windows/VC12/lib/libcurl.vcxproj.filters \
projects/Windows/VC12/src/curl.sln \
projects/Windows/VC12/src/curl.vcxproj.filters \
projects/Windows/VC14/curl-all.sln \
projects/Windows/VC14/lib/libcurl.sln \
projects/Windows/VC14/lib/libcurl.vcxproj.filters \
projects/Windows/VC14/src/curl.sln \
projects/Windows/VC14/src/curl.vcxproj.filters
WINBUILD_DIST = winbuild/BUILD.WINDOWS.txt winbuild/gen_resp_file.bat \ WINBUILD_DIST = winbuild/BUILD.WINDOWS.txt winbuild/gen_resp_file.bat \
winbuild/MakefileBuild.vc winbuild/Makefile.vc \ winbuild/MakefileBuild.vc winbuild/Makefile.vc \
@ -138,8 +130,7 @@ WINBUILD_DIST = winbuild/BUILD.WINDOWS.txt winbuild/gen_resp_file.bat \
EXTRA_DIST = CHANGES COPYING maketgz Makefile.dist curl-config.in \ EXTRA_DIST = CHANGES COPYING maketgz Makefile.dist curl-config.in \
RELEASE-NOTES buildconf libcurl.pc.in MacOSX-Framework scripts/zsh.pl \ RELEASE-NOTES buildconf libcurl.pc.in MacOSX-Framework scripts/zsh.pl \
$(CMAKE_DIST) $(VC_DIST) $(WINBUILD_DIST) lib/libcurl.vers.in \ $(CMAKE_DIST) $(VC_DIST) $(WINBUILD_DIST) lib/libcurl.vers.in
buildconf.bat
CLEANFILES = $(VC6_LIBDSP) $(VC6_SRCDSP) $(VC7_LIBVCPROJ) $(VC7_SRCVCPROJ) \ CLEANFILES = $(VC6_LIBDSP) $(VC6_SRCDSP) $(VC7_LIBVCPROJ) $(VC7_SRCVCPROJ) \
$(VC71_LIBVCPROJ) $(VC71_SRCVCPROJ) $(VC8_LIBVCPROJ) $(VC8_SRCVCPROJ) \ $(VC71_LIBVCPROJ) $(VC71_SRCVCPROJ) $(VC8_LIBVCPROJ) $(VC8_SRCVCPROJ) \

View File

@ -1,45 +0,0 @@
Curl is a command line tool for transferring data specified with URL
syntax. Find out how to use curl by reading [the curl.1 man
page](https://curl.haxx.se/docs/manpage.html) or [the MANUAL
document](https://curl.haxx.se/docs/manual.html). Find out how to install Curl
by reading [the INSTALL document](https://curl.haxx.se/docs/install.html).
libcurl is the library curl is using to do its job. It is readily available to
be used by your software. Read [the libcurl.3 man
page](https://curl.haxx.se/libcurl/c/libcurl.html) to learn how!
You find answers to the most frequent questions we get in [the FAQ
document](https://curl.haxx.se/docs/faq.html).
Study [the COPYING file](https://curl.haxx.se/docs/copyright.html) for
distribution terms and similar. If you distribute curl binaries or other
binaries that involve libcurl, you might enjoy [the LICENSE-MIXING
document](https://curl.haxx.se/legal/licmix.html).
## CONTACT
If you have problems, questions, ideas or suggestions, please contact us by
posting to a suitable [mailing list](https://curl.haxx.se/mail/).
All contributors to the project are listed in [the THANKS
document](https://curl.haxx.se/docs/thanks.html).
## WEB SITE
Visit the [curl web site](https://curl.haxx.se/) for the latest news and
downloads.
## GIT
To download the very latest source off the GIT server do this:
git clone https://github.com/curl/curl.git
(you'll get a directory named curl created, filled with the source code)
## NOTICE
Curl contains pieces of source code that is Copyright (c) 1998, 1999 Kungliga
Tekniska Högskolan. This notice is included here to comply with the
distribution terms.

View File

@ -1,95 +1,26 @@
Curl and libcurl 7.48.0 Curl and libcurl 7.47.1
Public curl releases: 153 Public curl releases: 152
Command line options: 179 Command line options: 179
curl_easy_setopt() options: 221 curl_easy_setopt() options: 221
Public functions in libcurl: 61 Public functions in libcurl: 61
Contributors: 1364 Contributors: 1346
This release includes the following changes:
o configure: --with-ca-fallback: use built-in TLS CA fallback [2]
o TFTP: add --tftp-no-options to expose CURLOPT_TFTP_NO_OPTIONS [22]
o getinfo: CURLINFO_TLS_SSL_PTR supersedes CURLINFO_TLS_SESSION [25]
o added CODE_STYLE.md [47]
This release includes the following bugfixes: This release includes the following bugfixes:
o Proxy-Connection: stop sending this header by default [1] o getredirect.c: fix variable name
o os400: sync ILE/RPG definitions with latest public header files o tool_doswin: silence unused function warning [1]
o cookies: allow spaces in cookie names, cut of trailing spaces [3] o cmake: fixed when OpenSSL enabled on Windows and schannel detected [2]
o tool_urlglob: Allow reserved dos device names (Windows) [4] o curl.1: Explain remote-name behavior if file already exists
o openssl: remove most BoringSSL #ifdefs [5] o tool_operate: Don't sanitize --output path (Windows) [3]
o tool_doswin: Support for literal path prefix \\?\ o URLs: change all http:// URLs to https:// in documentation & comments
o mbedtls: fix ALPN usage segfault [6] o sasl_sspi: Fix memory leak in domain populate [4]
o mbedtls: fix memory leak when destroying SSL connection data [7] o COPYING: clarify that Daniel is not the sole author
o nss: do not count enabled cipher-suites o examples/htmltitle: Use _stricmp on Windows [5]
o examples/cookie_interface.c: add cleanup call o examples/asiohiper: Avoid function name collision on Windows [6]
o examples: adhere to curl code style o idn_win32: Better error checking [7]
o curlx_tvdiff: handle 32bit time_t overflows [8] o openssl: Fix signed/unsigned mismatch warning in X509V3_ext [8]
o dist: ship buildconf.bat too o curl save files: check for backslashes on cygwin [9]
o curl.1: --disable-{eprt,epsv} are ignored for IPv6 hosts [9]
o generate.bat: Fix comment bug by removing old comments [10]
o test1604: Add to Makefile.inc so it gets run
o gtls: fix for builds lacking encrypted key file support [11]
o SCP: use libssh2_scp_recv2 to support > 2GB files on windows [12]
o CURLOPT_CONNECTTIMEOUT_MS.3: Fix example to use milliseconds option [13]
o cookie: do not refuse cookies to localhost [14]
o openssl: avoid direct PKEY access with OpenSSL 1.1.0 [15]
o http: Don't break the header into chunks if HTTP/2 [16]
o http2: don't decompress gzip decoding automatically [17]
o curlx.c: i2s_ASN1_IA5STRING() clashes with an openssl function
o curl.1: add a missing dash
o curl.1: HTTP headers for --cookie must be Set-Cookie style [18]
o CURLOPT_COOKIEFILE.3: HTTP headers must be Set-Cookie style [18]
o curl_sasl: Fix memory leak in digest parser [19]
o src/Makefile.m32: add CURL_{LD,C}FLAGS_EXTRAS support [20]
o CURLOPT_DEBUGFUNCTION.3: Fix example
o runtests: Fixed usage of %PWD on MinGW64 [21]
o tests/sshserver.pl: use RSA instead of DSA for host auth [23]
o multi_remove_handle: keep the timeout list until after disconnect [24]
o Curl_read: check for activated HTTP/1 pipelining, not only requested
o configure: warn on invalid ca bundle or path [26]
o file: try reading from files with no size [27]
o getinfo: Add support for mbedTLS TLS session info
o formpost: fix memory leaks in AddFormData error branches [28]
o makefile.m32: allow to pass .dll/.exe-specific LDFLAGS [29]
o url: if Curl_done is premature then pipeline not in use [30]
o cookie: remove redundant check [31]
o cookie: Don't expire session cookies in remove_expired [32]
o makefile.m32: fix to allow -ssh2-winssl combination [33]
o checksrc.bat: Fixed cannot find perl if installed but not in path
o build-openssl.bat: Fixed cannot find perl if installed but not in path
o mbedtls: fix user-specified SSL protocol version
o makefile.m32: add missing libs for static -winssl-ssh2 builds [34]
o test46: change cookie expiry date [35]
o pipeline: Sanity check pipeline pointer before accessing it [36]
o openssl: use the correct OpenSSL/BoringSSL/LibreSSL in messages
o ftp_done: clear tunnel_state when secondary socket closes [37]
o opt-docs: fix heading macros [38]
o imap/pop3/smtp: Fixed connections upgraded with TLS are not reused [39]
o curl_multi_wait: never return -1 in 'numfds' [40]
o url.c: fix clang warning: no newline at end of file
o krb5: improved type handling to avoid clang compiler warnings
o cookies: first n/v pair in Set-Cookie: is the cookie, then parameters [41]
o multi: avoid blocking during CURLM_STATE_WAITPROXYCONNECT [42]
o multi hash: ensure modulo performed on curl_socket_t [43]
o curl: glob_range: no need to check unsigned variable for negative
o easy: add check to malloc() when running event-based
o CURLOPT_SSLENGINE.3: Only for OpenSSL built with engine support [44]
o version: thread safety
o openssl: verbose: show matching SAN pattern
o openssl: adapt to OpenSSL 1.1.0 API breakage in ERR_remove_thread_state()
o formdata.c: Fixed compilation warning
o configure: use cpp -P when needed [45]
o imap.c: Fixed compilation warning with /Wall enabled
o config-w32.h: Fixed compilation warning when /Wall enabled
o ftp/imap/pop3/smtp: Fixed compilation warning when /Wall enabled
o build: Added missing Visual Studio filter files for VC10 onwards
o easy: Remove poll failure check in easy_transfer
o mbedtls: fix compiler warning
o build-wolfssl: Update VS properties for wolfSSL v3.9.0
o Fixed various compilation warnings when verbose strings disabled
This release includes the following known bugs: This release includes the following known bugs:
@ -98,62 +29,20 @@ This release includes the following known bugs:
This release would not have looked like this without help, code, reports and This release would not have looked like this without help, code, reports and
advice from friends like these: advice from friends like these:
Anders Bakken, Brad Fitzpatrick, Clint Clayton, Dan Fandrich, Bernard Spil, Dan Fandrich, Daniel Stenberg, Gisle Vanem, Michael Kaufmann,
Daniel Stenberg, David Benjamin, David Byron, Emil Lerner, Eric S. Raymond, Octavio Schroeder, Ray Satiro, Sergei Nikulov, Viktor Szakáts,
Gisle Vanem, Jaime Fullaondo, Jeffrey Walton, Jesse Tan, Justin Ehlert, (9 contributors)
Kamil Dudka, Kazuho Oku, Ludwig Nussel, Maksim Kuzevanov, Michael König,
Oliver Graute, Patrick Monnerat, Rafael Antonio, Ray Satiro, Seth Mos,
Shine Fan, Steve Holme, Tatsuhiro Tsujikawa, Timotej Lazar, Tim Rühsen,
Viktor Szakáts,
(30 contributors)
Thanks! (and sorry if I forgot to mention someone) Thanks! (and sorry if I forgot to mention someone)
References to bug reports and discussions on issues: References to bug reports and discussions on issues:
[1] = https://curl.haxx.se/bug/?i=633 [1] = https://github.com/curl/curl/pull/616
[2] = https://curl.haxx.se/bug/?i=569 [2] = https://curl.haxx.se/bug/?i=617
[3] = https://curl.haxx.se/bug/?i=639 [3] = https://curl.haxx.se/bug/?i=624
[4] = https://github.com/curl/curl/commit/4520534#commitcomment-15954863 [4] = https://github.com/curl/curl/issues/635
[5] = https://curl.haxx.se/bug/?i=640 [5] = https://curl.haxx.se/mail/lib-2016-02/0017.html
[6] = https://curl.haxx.se/bug/?i=642 [6] = https://curl.haxx.se/mail/lib-2016-02/0016.html
[7] = https://curl.haxx.se/bug/?i=626 [7] = https://github.com/curl/curl/pull/637
[8] = https://curl.haxx.se/bug/?i=646 [8] = https://github.com/curl/curl/commit/dd1b44c#commitcomment-15913896
[9] = https://bugzilla.redhat.com/1305970 [9] = https://curl.haxx.se/docs/adv_20160127B.html
[10] = https://curl.haxx.se/bug/?i=649
[11] = https://curl.haxx.se/bug/?i=651
[12] = https://curl.haxx.se/bug/?i=451
[13] = https://curl.haxx.se/bug/?i=653
[14] = https://curl.haxx.se/bug/?i=658
[15] = https://curl.haxx.se/bug/?i=650
[16] = https://curl.haxx.se/bug/?i=659
[17] = https://curl.haxx.se/bug/?i=661
[18] = https://curl.haxx.se/bug/?i=666
[19] = https://curl.haxx.se/bug/?i=667
[20] = https://curl.haxx.se/bug/?i=670
[21] = https://curl.haxx.se/bug/?i=672
[22] = https://curl.haxx.se/bug/?i=481
[23] = https://curl.haxx.se/bug/?i=676
[24] = https://curl.haxx.se/mail/lib-2016-02/0097.html
[25] = https://curl.haxx.se/libcurl/c/CURLINFO_TLS_SSL_PTR.html
[26] = https://curl.haxx.se/bug/?i=404
[27] = https://curl.haxx.se/bug/?i=681
[28] = https://curl.haxx.se/bug/?i=688
[29] = https://curl.haxx.se/bug/?i=689
[30] = https://curl.haxx.se/bug/?i=690
[31] = https://curl.haxx.se/bug/?i=695
[32] = https://curl.haxx.se/bug/?i=697
[33] = https://curl.haxx.se/bug/?i=692
[34] = https://curl.haxx.se/bug/?i=693
[35] = https://curl.haxx.se/bug/?i=697
[36] = https://curl.haxx.se/bug/?i=704
[37] = https://curl.haxx.se/bug/?i=701
[38] = https://curl.haxx.se/bug/?i=705
[39] = https://curl.haxx.se/bug/?i=422
[40] = https://curl.haxx.se/bug/?i=707
[41] = https://curl.haxx.se/bug/?i=709
[42] = https://curl.haxx.se/bug/?i=703
[43] = https://curl.haxx.se/bug/?i=712
[44] = https://curl.haxx.se/mail/lib-2016-03/0150.html
[45] = https://curl.haxx.se/bug/?i=719
[47] = https://curl.haxx.se/dev/code-style.html

View File

@ -20,6 +20,7 @@
# #
#*************************************************************************** #***************************************************************************
dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT]) dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Use the C preprocessor to find out if the given object-style symbol dnl Use the C preprocessor to find out if the given object-style symbol
@ -30,10 +31,6 @@ dnl result in a set of double-quoted strings the returned expansion will
dnl actually be a single double-quoted string concatenating all them. dnl actually be a single double-quoted string concatenating all them.
AC_DEFUN([CURL_CHECK_DEF], [ AC_DEFUN([CURL_CHECK_DEF], [
AC_REQUIRE([CURL_CPP_P])dnl
OLDCPPFLAGS=$CPPFLAGS
# CPPPFLAGS comes from CURL_CPP_P
CPPFLAGS="$CPPPFLAGS"
AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
if test -z "$SED"; then if test -z "$SED"; then
@ -70,7 +67,6 @@ CURL_DEF_TOKEN $1
fi fi
AS_VAR_POPDEF([ac_Def])dnl AS_VAR_POPDEF([ac_Def])dnl
AS_VAR_POPDEF([ac_HaveDef])dnl AS_VAR_POPDEF([ac_HaveDef])dnl
CPPFLAGS=$OLDCPPFLAGS
]) ])
@ -2574,8 +2570,7 @@ AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
AC_MSG_CHECKING([default CA cert bundle/path]) AC_MSG_CHECKING([default CA cert bundle/path])
AC_ARG_WITH(ca-bundle, AC_ARG_WITH(ca-bundle,
AC_HELP_STRING([--with-ca-bundle=FILE], AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
[Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]), AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
[ [
want_ca="$withval" want_ca="$withval"
@ -2585,11 +2580,7 @@ AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
], ],
[ want_ca="unset" ]) [ want_ca="unset" ])
AC_ARG_WITH(ca-path, AC_ARG_WITH(ca-path,
AC_HELP_STRING([--with-ca-path=DIRECTORY], AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
[Path to a directory containing CA certificates stored individually, with \
their filenames in a hash format. This option can be used with OpenSSL, \
GnuTLS and PolarSSL backends. Refer to OpenSSL c_rehash for details. \
(example: /etc/certificates)])
AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]), AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
[ [
want_capath="$withval" want_capath="$withval"
@ -2599,10 +2590,6 @@ AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
], ],
[ want_capath="unset"]) [ want_capath="unset"])
ca_warning=" (warning: certs not found)"
capath_warning=" (warning: certs not found)"
check_capath=""
if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \ if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
"x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
dnl both given dnl both given
@ -2651,7 +2638,12 @@ AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
fi fi
if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \ if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
"x$OPENSSL_ENABLED" = "x1"; then "x$OPENSSL_ENABLED" = "x1"; then
check_capath="/etc/ssl/certs/" for a in /etc/ssl/certs/; do
if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then
capath="$a"
break
fi
done
fi fi
else else
dnl no option given and cross-compiling dnl no option given and cross-compiling
@ -2659,30 +2651,6 @@ AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
fi fi
fi fi
if test "x$ca" = "xno" || test -f "$ca"; then
ca_warning=""
fi
if test "x$capath" != "xno"; then
check_capath="$capath"
fi
if test ! -z "$check_capath"; then
for a in "$check_capath"; do
if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then
if test "x$capath" = "xno"; then
capath="$a"
fi
capath_warning=""
break
fi
done
fi
if test "x$capath" = "xno"; then
capath_warning=""
fi
if test "x$ca" != "xno"; then if test "x$ca" != "xno"; then
CURL_CA_BUNDLE='"'$ca'"' CURL_CA_BUNDLE='"'$ca'"'
AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle]) AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
@ -2697,24 +2665,6 @@ AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
if test "x$ca" = "xno" && test "x$capath" = "xno"; then if test "x$ca" = "xno" && test "x$capath" = "xno"; then
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
fi fi
AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
AC_ARG_WITH(ca-fallback,
AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
[
if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
fi
],
[ with_ca_fallback="no"])
AC_MSG_RESULT([$with_ca_fallback])
if test "x$with_ca_fallback" = "xyes"; then
if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
fi
AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
fi
]) ])
@ -3151,48 +3101,3 @@ use vars qw(
1; 1;
_EOF _EOF
]) ])
dnl CURL_CPP_P
dnl
dnl Check if $cpp -P should be used for extract define values due to gcc 5
dnl splitting up strings and defines between line outputs. gcc by default
dnl (without -P) will show TEST EINVAL TEST as
dnl
dnl # 13 "conftest.c"
dnl TEST
dnl # 13 "conftest.c" 3 4
dnl 22
dnl # 13 "conftest.c"
dnl TEST
AC_DEFUN([CURL_CPP_P], [
AC_MSG_CHECKING([if cpp -P is needed])
AC_EGREP_CPP([TEST.*TEST], [
#include <errno.h>
TEST EINVAL TEST
], [cpp=no], [cpp=yes])
AC_MSG_RESULT([$cpp])
dnl we need cpp -P so check if it works then
if test "x$cpp" = "xyes"; then
AC_MSG_CHECKING([if cpp -P works])
OLDCPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -P"
AC_EGREP_CPP([TEST.*TEST], [
#include <errno.h>
TEST EINVAL TEST
], [cpp_p=yes], [cpp_p=no])
AC_MSG_RESULT([$cpp_p])
if test "x$cpp_p" = "xno"; then
AC_MSG_WARN([failed to figure out cpp -P alternative])
# without -P
CPPPFLAGS=$OLDCPPFLAGS
else
# with -P
CPPPFLAGS=$CPPFLAGS
fi
dnl restore CPPFLAGS
CPPFLAGS=$OLDCPPFLAGS
fi
])

View File

@ -6,7 +6,7 @@ rem * / __| | | | |_) | |
rem * | (__| |_| | _ <| |___ rem * | (__| |_| | _ <| |___
rem * \___|\___/|_| \_\_____| rem * \___|\___/|_| \_\_____|
rem * rem *
rem * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. rem * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
rem * rem *
rem * This software is licensed as described in the file COPYING, which rem * This software is licensed as described in the file COPYING, which
rem * you should have received as part of this distribution. The terms rem * you should have received as part of this distribution. The terms
@ -26,6 +26,8 @@ rem
rem This batch file must be used to set up a git tree to build on systems where rem This batch file must be used to set up a git tree to build on systems where
rem there is no autotools support (i.e. DOS and Windows). rem there is no autotools support (i.e. DOS and Windows).
rem rem
rem This file is not included or required for curl's release archives or daily
rem snapshot archives.
:begin :begin
rem Set our variables rem Set our variables

View File

@ -1631,6 +1631,8 @@ if test "$curl_ssl_msg" = "$init_ssl_msg" && test X"$OPT_SSL" != Xno; then
dnl Older versions of Cyassl (some time before 2.9.4) don't have dnl Older versions of Cyassl (some time before 2.9.4) don't have
dnl SSL_get_shutdown (but this check won't actually detect it there dnl SSL_get_shutdown (but this check won't actually detect it there
dnl as it's a macro that needs the header files be included) dnl as it's a macro that needs the header files be included)
dnl BoringSSL didn't have DES_set_odd_parity for a while but now it is
dnl back again.
AC_CHECK_FUNCS( RAND_status \ AC_CHECK_FUNCS( RAND_status \
RAND_screen \ RAND_screen \
@ -1638,7 +1640,8 @@ if test "$curl_ssl_msg" = "$init_ssl_msg" && test X"$OPT_SSL" != Xno; then
ENGINE_cleanup \ ENGINE_cleanup \
CRYPTO_cleanup_all_ex_data \ CRYPTO_cleanup_all_ex_data \
SSL_get_shutdown \ SSL_get_shutdown \
SSLv2_client_method ) SSLv2_client_method \
DES_set_odd_parity )
AC_MSG_CHECKING([for BoringSSL]) AC_MSG_CHECKING([for BoringSSL])
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
@ -1653,7 +1656,6 @@ if test "$curl_ssl_msg" = "$init_ssl_msg" && test X"$OPT_SSL" != Xno; then
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_BORINGSSL, 1, AC_DEFINE_UNQUOTED(HAVE_BORINGSSL, 1,
[Define to 1 if using BoringSSL.]) [Define to 1 if using BoringSSL.])
curl_ssl_msg="enabled (BoringSSL)"
],[ ],[
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
]) ])
@ -3891,9 +3893,8 @@ AC_MSG_NOTICE([Configured to build curl/libcurl:
--libcurl option: ${curl_libcurl_msg} --libcurl option: ${curl_libcurl_msg}
Verbose errors: ${curl_verbose_msg} Verbose errors: ${curl_verbose_msg}
SSPI support: ${curl_sspi_msg} SSPI support: ${curl_sspi_msg}
ca cert bundle: ${ca}${ca_warning} ca cert bundle: ${ca}
ca cert path: ${capath}${capath_warning} ca cert path: ${capath}
ca fallback: ${with_ca_fallback}
LDAP support: ${curl_ldap_msg} LDAP support: ${curl_ldap_msg}
LDAPS support: ${curl_ldaps_msg} LDAPS support: ${curl_ldaps_msg}
RTSP support: ${curl_rtsp_msg} RTSP support: ${curl_rtsp_msg}

View File

@ -1,185 +0,0 @@
# cURL C code style
Source code that has a common style is easier to read than code that uses
different styles in different places. It helps making the code feel like one
single code base. Easy-to-read is a very important property of code and helps
making it easier to review when new things are added and it helps debugging
code when developers are trying to figure out why things go wrong. A unified
style is more important than individual contributors having their own personal
tastes satisfied.
Our C code has a few style rules. Most of them are verified and upheld by the
lib/checksrc.pl script. Invoked with `make checksrc` or even by default by the
build system when built after `./configure --enable-debug` has been used.
It is normally not a problem for anyone to follow the guidelines, as you just
need to copy the style already used in the source code and there are no
particularly unusual rules in our set of rules.
We also work hard on writing code that are warning-free on all the major
platforms and in general on as many platforms as possible. Code that obviously
will cause warnings will not be accepted as-is.
## Naming
Try using a non-confusing naming scheme for your new functions and variable
names. It doesn't necessarily have to mean that you should use the same as in
other places of the code, just that the names should be logical,
understandable and be named according to what they're used for. File-local
functions should be made static. We like lower case names.
See the INTERNALS document on how we name non-exported library-global symbols.
## Indenting
We use only spaces for indentation, never TABs. We use two spaces for each new
open brace.
if(something_is_true) {
while(second_statement == fine) {
moo();
}
}
## Comments
Since we write C89 code, `//` comments are not allowed. They weren't
introduced in the C standard until C99. We use only `/*` and `*/` comments:
/* this is a comment */
## Long lines
Source code in curl may never be wider than 80 columns and there are two
reasons for maintaining this even in the modern era of very large and high
resolution screens:
1. Narrower columns are easier to read than very wide ones. There's a reason
newspapers have used columns for decades or centuries.
2. Narrower columns allow developers to easier show multiple pieces of code
next to each other in different windows. I often have two or three source
code windows next to each other on the same screen - as well as multiple
terminal and debugging windows.
## Braces
In if/while/do/for expressions, we write the open brace on the same line as
the keyword and we then set the closing brace on the same indentation level as
the initial keyword. Like this:
if(age < 40) {
/* clearly a youngster */
}
When we write functions however, the opening brace should be in the first
column of the first line:
int main(int argc, char **argv)
{
return 1;
}
## 'else' on the following line
When adding an `else` clause to a conditional expression using braces, we add
it on a new line after the closing brace. Like this:
if(age < 40) {
/* clearly a youngster */
}
else {
/* probably grumpy */
}
## No space before parentheses
When writing expressions using if/while/do/for, there shall be no space
between the keyword and the open parenthesis. Like this:
while(1) {
/* loop forever */
}
## Use boolean conditions
Rather than test a conditional value such as a bool against TRUE or FALSE, a
pointer against NULL or != NULL and an int against zero or not zero in
if/while conditions we prefer:
result = do_something();
if(!result) {
/* something went wrong */
return result;
}
## No assignments in conditions
To increase readability and reduce complexity of conditionals, we avoid
assigning variables within if/while conditions. We frown upon this style:
if((ptr = malloc(100)) == NULL)
return NULL;
and instead we encourage the above version to be spelled out more clearly:
ptr = malloc(100);
if(!ptr)
return NULL;
## New block on a new line
We never write multiple statements on the same source line, even for very
short if() conditions.
if(a)
return TRUE;
else if(b)
return FALSE;
and NEVER:
if(a) return TRUE;
else if(b) return FALSE;
## Space around operators
Please use spaces on both sides of operators in C expressions. Postfix `(),
[], ->, ., ++, --` and Unary `+, - !, ~, &` operators excluded they should
have no space.
Examples:
bla = func();
who = name[0];
age += 1;
true = !false;
size += -2 + 3 * (a + b);
ptr->member = a++;
struct.field = b--;
ptr = &address;
contents = *pointer;
complement = ~bits;
## Platform dependent code
Use `#ifdef HAVE_FEATURE` to do conditional code. We avoid checking for
particular operating systems or hardware in the #ifdef lines. The HAVE_FEATURE
shall be generated by the configure script for unix-like systems and they are
hard-coded in the config-[system].h files for the others.
We also encourage use of macros/functions that possibly are empty or defined
to constants when libcurl is built without that feature, to make the code
seamless. Like this style where the `magic()` function works differently
depending on a build-time conditional:
#ifdef HAVE_MAGIC
void magic(int a)
{
return a + 2;
}
#else
#define magic(x) 1
#endif
int content = magic(3);

View File

@ -15,13 +15,18 @@
1.2 License 1.2 License
1.3 What To Read 1.3 What To Read
2. Write a good patch 2. cURL Coding Standards
2.1 Follow code style 2.1 Naming
2.2 Non-clobbering All Over 2.2 Indenting
2.3 Write Separate Patches 2.3 Commenting
2.4 Patch Against Recent Sources 2.4 Line Lengths
2.5 Document 2.5 General Style
2.6 Test Cases 2.6 Non-clobbering All Over
2.7 Platform Dependent Code
2.8 Write Separate Patches
2.9 Patch Against Recent Sources
2.10 Document
2.11 Test Cases
3. Pushing Out Your Changes 3. Pushing Out Your Changes
3.1 Write Access to git Repository 3.1 Write Access to git Repository
@ -82,15 +87,48 @@
list is gonna give you a lot of insights on what's going on right now. Asking list is gonna give you a lot of insights on what's going on right now. Asking
there is a good idea too. there is a good idea too.
2. Write a good patch 2. cURL Coding Standards
2.1 Follow code style 2.1 Naming
When writing C code, follow the CODE_STYLE already established in the Try using a non-confusing naming scheme for your new functions and variable
project. Consistent style makes code easier to read and mistakes less likely names. It doesn't necessarily have to mean that you should use the same as in
to happen. other places of the code, just that the names should be logical,
understandable and be named according to what they're used for. File-local
functions should be made static. We like lower case names.
2.2 Non-clobbering All Over See the INTERNALS document on how we name non-exported library-global
symbols.
2.2 Indenting
Use the same indenting levels and bracing method as all the other code
already does. It makes the source code easier to follow if all of it is
written using the same style. We don't ask you to like it, we just ask you to
follow the tradition! ;-) This mainly means: 2-level indents, 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
use C++ comments (// this style). Commented code is quality code and enables
future modifications much more. Uncommented code risk having to be completely
replaced when someone wants to extend things, since other persons' source
code can get quite hard to read.
2.4 Line Lengths
We write source lines shorter than 80 columns.
2.5 General Style
Keep your functions small. If they're small you avoid a lot of mistakes and
you don't accidentally mix up variables etc.
2.6 Non-clobbering All Over
When you write new functionality or fix bugs, it is important that you don't When you write new functionality or fix bugs, it is important that you don't
fiddle all over the source files and functions. Remember that it is likely fiddle all over the source files and functions. Remember that it is likely
@ -99,7 +137,14 @@
functionality, try writing it in a new source file. If you fix bugs, try to functionality, try writing it in a new source file. If you fix bugs, try to
fix one bug at a time and send them as separate patches. fix one bug at a time and send them as separate patches.
2.3 Write Separate Patches 2.7 Platform Dependent Code
Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
particular operating systems or hardware in the #ifdef lines. The
HAVE_FEATURE shall be generated by the configure script for unix-like systems
and they are hard-coded in the config-[system].h files for the others.
2.8 Write Separate Patches
It is annoying when you get a huge patch from someone that is said to fix 511 It is annoying when you get a huge patch from someone that is said to fix 511
odd problems, but discussions and opinions don't agree with 510 of them - or odd problems, but discussions and opinions don't agree with 510 of them - or
@ -113,14 +158,14 @@
Also, separate patches enable bisecting much better when we track problems in Also, separate patches enable bisecting much better when we track problems in
the future. the future.
2.4 Patch Against Recent Sources 2.9 Patch Against Recent Sources
Please try to get the latest available sources to make your patches Please try to get the latest available sources to make your patches
against. It makes the life of the developers so much easier. The very best is against. It makes the life of the developers so much easier. The very best is
if you get the most up-to-date sources from the git repository, but the if you get the most up-to-date sources from the git repository, but the
latest release archive is quite OK as well! latest release archive is quite OK as well!
2.5 Document 2.10 Document
Writing docs is dead boring and one of the big problems with many open source Writing docs is dead boring and one of the big problems with many open source
projects. Someone's gotta do it. It makes it a lot easier if you submit a projects. Someone's gotta do it. It makes it a lot easier if you submit a
@ -131,7 +176,7 @@
ASCII files. All HTML files on the web site and in the release archives are ASCII files. All HTML files on the web site and in the release archives are
generated from the nroff/ASCII versions. generated from the nroff/ASCII versions.
2.6 Test Cases 2.11 Test Cases
Since the introduction of the test suite, we can quickly verify that the main Since the introduction of the test suite, we can quickly verify that the main
features are working as they're supposed to. To maintain this situation and features are working as they're supposed to. To maintain this situation and

View File

@ -30,7 +30,6 @@ FAQ
2.2 Does curl work/build with other SSL libraries? 2.2 Does curl work/build with other SSL libraries?
2.3 Where can I find a copy of LIBEAY32.DLL? 2.3 Where can I find a copy of LIBEAY32.DLL?
2.4 Does curl support SOCKS (RFC 1928) ? 2.4 Does curl support SOCKS (RFC 1928) ?
2.5 Install libcurl for both 32bit and 64bit?
3. Usage Problems 3. Usage Problems
3.1 curl: (1) SSL is disabled, https: not supported 3.1 curl: (1) SSL is disabled, https: not supported
@ -465,32 +464,6 @@ FAQ
Yes, SOCKS 4 and 5 are supported. Yes, SOCKS 4 and 5 are supported.
2.5 Install libcurl for both 32bit and 64bit?
In curl's configure procedure one of the regular include files get created
with platform specific information. The file 'curl/curlbuild.h' in the
installed libcurl file tree is therefore somewhat tied to that particular
platform.
To allow applications to get built for either 32bit or 64bit you need to
install libcurl headers for both setups and unfortunately curl doesn't do
this automatically.
A commonly used procedure is this:
$ ./configure [32bit platform]
$ mv curl/curlbuild.h curl/curlbuild-32bit.h
$ ./configure [64bit platform]
$ mv curl/curlbuild.h curl/curlbuild-64bit.h
Then you make a toplevel curl/curlbuild.h replacement that only does this:
#ifdef IS_32BIT
#include "curlbuild-32bit.h"
else
#include "curlbuild-64bit.h"
#endif
3. Usage problems 3. Usage problems

View File

@ -36,17 +36,12 @@ Over an https:// URL
If `CURLOPT_HTTP_VERSION` is set to `CURL_HTTP_VERSION_2_0`, libcurl will use If `CURLOPT_HTTP_VERSION` is set to `CURL_HTTP_VERSION_2_0`, libcurl will use
ALPN (or NPN) to negotiate which protocol to continue with. Possibly introduce ALPN (or NPN) to negotiate which protocol to continue with. Possibly introduce
an option that will cause libcurl to fail if not possible to use HTTP/2. an option that will cause libcurl to fail if not possible to use HTTP/2.
Consider options to explicitly disable ALPN and/or NPN.
`CURL_HTTP_VERSION_2TLS` was added in 7.47.0 as a way to ask libcurl to prefer
HTTP/2 for HTTPS but stick to 1.1 by default for plain old HTTP connections.
ALPN is the TLS extension that HTTP/2 is expected to use. The NPN extension is ALPN is the TLS extension that HTTP/2 is expected to use. The NPN extension is
for a similar purpose, was made prior to ALPN and is used for SPDY so early for a similar purpose, was made prior to ALPN and is used for SPDY so early
HTTP/2 servers are implemented using NPN before ALPN support is widespread. HTTP/2 servers are implemented using NPN before ALPN support is widespread.
`CURLOPT_SSL_ENABLE_ALPN` and `CURLOPT_SSL_ENABLE_NPN` are offered to allow
applications to explicitly disable ALPN or NPN.
SSL libs SSL libs
-------- --------
@ -89,9 +84,7 @@ in HTTP 1.1 style. This allows applications to work unmodified.
curl tool curl tool
--------- ---------
curl offers the `--http2` command line option to enable use of HTTP/2. curl offers the `--http2` command line option to enable use of HTTP/2
Since 7.47.0, the curl tool enables HTTP/2 by default for HTTPS connections.
HTTP Alternative Services HTTP Alternative Services
------------------------- -------------------------
@ -102,7 +95,7 @@ same origin server that you get the response from. A browser or long-living
client can use that hint to create a new connection asynchronously. For client can use that hint to create a new connection asynchronously. For
libcurl, we may introduce a way to bring such clues to the applicaton and/or libcurl, we may introduce a way to bring such clues to the applicaton and/or
let a subsequent request use the alternate route let a subsequent request use the alternate route
automatically. [Spec](https://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-14) automatically. [Spec](https://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-05)
TODO TODO
---- ----

View File

@ -3,24 +3,6 @@ join in and help us correct one or more of these! Also be sure to check the
changelog of the current development status, as one or more of these problems changelog of the current development status, as one or more of these problems
may have been fixed since this was written! may have been fixed since this was written!
93. It is not possible to pass a 64-bit value using CURLFORM_CONTENTLEN with
CURLFORM_ARRAY, when compiled on 32-bit platforms that support 64-bit
integers. This is because the underlying structure 'curl_forms' uses a dual
purpose char* for storing these values in via casting. For more information
see the now closed related issue:
https://github.com/curl/curl/issues/608
92. curl tool 7.47.1 in Windows will not --output to literal paths \\?\ or to
reserved dos device names unless the device prefix \\.\ is used. To send
output to a device that has a reserved dos device name you can use the
Windows device prefix (eg: --output \\.\NUL). You can also use the
redirection operator to send output to a literal path or a reserved device
name (eg: > NUL).
The next release of curl will support --output in Windows to literal paths
and to reserved device names without the device prefix.
https://github.com/curl/curl/commit/c3aac48
https://github.com/curl/curl/commit/4fc80f3
91. "curl_easy_perform hangs with imap and PolarSSL" 91. "curl_easy_perform hangs with imap and PolarSSL"
https://github.com/curl/curl/issues/334 https://github.com/curl/curl/issues/334

View File

@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___ # | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____| # \___|\___/|_| \_\_____|
# #
# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. # Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
# #
# This software is licensed as described in the file COPYING, which # This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms # you should have received as part of this distribution. The terms
@ -38,7 +38,7 @@ EXTRA_DIST = MANUAL BUGS CONTRIBUTE FAQ FEATURES INTERNALS SSLCERTS \
KNOWN_BUGS BINDINGS $(man_MANS) $(HTMLPAGES) HISTORY INSTALL \ KNOWN_BUGS BINDINGS $(man_MANS) $(HTMLPAGES) HISTORY INSTALL \
$(PDFPAGES) LICENSE-MIXING README.netware INSTALL.devcpp \ $(PDFPAGES) LICENSE-MIXING README.netware INSTALL.devcpp \
MAIL-ETIQUETTE HTTP-COOKIES SECURITY RELEASE-PROCEDURE SSL-PROBLEMS \ MAIL-ETIQUETTE HTTP-COOKIES SECURITY RELEASE-PROCEDURE SSL-PROBLEMS \
HTTP2.md ROADMAP.md CODE_OF_CONDUCT.md CODE_STYLE.md HTTP2.md ROADMAP.md CODE_OF_CONDUCT.md
MAN2HTML= roffit < $< >$@ MAN2HTML= roffit < $< >$@

View File

@ -11,8 +11,8 @@ in the source code repo
- make sure all relevant changes are committed on the master branch - make sure all relevant changes are committed on the master branch
- tag the git repo in this style: `git tag -a curl-7_34_0`. -a annotates the - tag the git repo in this style: `git tag -a curl-7_34_0`. -a annotates the
tag and we use underscores instead of dots in the version number. tag and we use underscores instead of dots in the version number.
- run "./maketgz 7.34.0" to build the release tarballs. It is important that - run "./maketgz 7.34.0" to build the release tarballs. It is important that
you run this on a machine with the correct set of autotools etc installed you run this on a machine with the correct set of autotools etc installed
as this is what then will be shipped and used by most users on *nix like as this is what then will be shipped and used by most users on *nix like
@ -24,6 +24,8 @@ in the source code repo
- upload the 8 resulting files to the primary download directory - upload the 8 resulting files to the primary download directory
- upload the 4 tarballs to github for the HTTPS download
in the curl-www repo in the curl-www repo
-------------------- --------------------

View File

@ -23,19 +23,6 @@ HTTP/2
As it would avoid the roundtrip-heavy Upgrade: procedures when you _know_ As it would avoid the roundtrip-heavy Upgrade: procedures when you _know_
it speaks HTTP/2. it speaks HTTP/2.
HTTP cookies
------------
Two cookie drafts have been adopted by the httpwg in IETF and we should
support them as the popular browsers will as well:
[Deprecate modification of 'secure' cookies from non-secure
origins](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone-00)
[Cookie Prefixes](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-prefixes-00)
[Firefox bug report about secure cookies](https://bugzilla.mozilla.org/show_bug.cgi?id=976073)
SRV records SRV records
----------- -----------
@ -44,9 +31,7 @@ How to find services for specific domains/hosts.
HTTPS to proxy HTTPS to proxy
-------------- --------------
To avoid network traffic to/from the proxy getting snooped on. There's a git To avoid network traffic to/from the proxy getting snooped on.
branch in the public git repository for this that we need to make sure works
for all TLS backends and then merge!
curl_formadd() curl_formadd()
-------------- --------------

View File

@ -20,8 +20,8 @@ support.
It is about trust It is about trust
----------------- -----------------
This system is about trust. In your local CA certificate store you have certs This system is about trust. In your local CA cert bundle you have certs from
from *trusted* Certificate Authorities that you then can use to verify that the *trusted* Certificate Authorities that you then can use to verify that the
server certificates you see are valid. They're signed by one of the CAs you server certificates you see are valid. They're signed by one of the CAs you
trust. trust.
@ -35,16 +35,16 @@ Certificate Verification
------------------------ ------------------------
libcurl performs peer SSL certificate verification by default. This is done libcurl performs peer SSL certificate verification by default. This is done
by using a CA certificate store that the SSL library can use to make sure the by using CA cert bundle that the SSL library can use to make sure the peer's
peer's server certificate is valid. server certificate is valid.
If you communicate with HTTPS, FTPS or other TLS-using servers using If you communicate with HTTPS, FTPS or other TLS-using servers using
certificates that are signed by CAs present in the store, you can be sure certificates that are signed by CAs present in the bundle, you can be sure
that the remote server really is the one it claims to be. that the remote server really is the one it claims to be.
If the remote server uses a self-signed certificate, if you don't install a CA If the remote server uses a self-signed certificate, if you don't install a CA
cert store, if the server uses a certificate signed by a CA that isn't cert bundle, if the server uses a certificate signed by a CA that isn't
included in the store you use or if the remote host is an impostor included in the bundle you use or if the remote host is an impostor
impersonating your favorite site, and you want to transfer files from this impersonating your favorite site, and you want to transfer files from this
server, do one of the following: server, do one of the following:
@ -59,22 +59,12 @@ server, do one of the following:
With the curl command line tool: --cacert [file] With the curl command line tool: --cacert [file]
3. Add the CA cert for your server to the existing default CA certificate 3. Add the CA cert for your server to the existing default CA cert bundle.
store. The default CA certificate store can changed at compile time with the The default path of the CA bundle used can be changed by running configure
following configure options: with the --with-ca-bundle option pointing out the path of your choice.
--with-ca-bundle=FILE: use the specified file as CA certificate store. CA To do this, you need to get the CA cert for your server in PEM format and
certificates need to be concatenated in PEM format into this file. then append that to your CA cert bundle.
--with-ca-path=PATH: use the specified path as CA certificate store. CA
certificates need to be stored as individual PEM files in this directory.
You may need to run c_rehash after adding files there.
If neither of the two options is specified, configure will try to auto-detect
a setting. It's also possible to explicitly not hardcode any default store
but rely on the built in default the crypto library may provide instead.
You can achieve that by passing both --without-ca-bundle and
--without-ca-path to the configure script.
If you use Internet Explorer, this is one way to get extract the CA cert If you use Internet Explorer, this is one way to get extract the CA cert
for a particular server: for a particular server:
@ -86,7 +76,7 @@ server, do one of the following:
- Convert it from crt to PEM using the openssl tool: - Convert it from crt to PEM using the openssl tool:
openssl x509 -inform DES -in yourdownloaded.crt \ openssl x509 -inform DES -in yourdownloaded.crt \
-out outcert.pem -text -out outcert.pem -text
- Add the 'outcert.pem' to the CA certificate store or use it stand-alone - Append the 'outcert.pem' to the CA cert bundle or use it stand-alone
as described below. as described below.
If you use the 'openssl' tool, this is one way to get extract the CA cert If you use the 'openssl' tool, this is one way to get extract the CA cert
@ -99,9 +89,9 @@ server, do one of the following:
- If you want to see the data in the certificate, you can do: "openssl - If you want to see the data in the certificate, you can do: "openssl
x509 -inform PEM -in certfile -text -out certdata" where certfile is x509 -inform PEM -in certfile -text -out certdata" where certfile is
the cert you extracted from logfile. Look in certdata. the cert you extracted from logfile. Look in certdata.
- If you want to trust the certificate, you can add it to your CA - If you want to trust the certificate, you can append it to your
certificate store or use it stand-alone as described. Just remember that cert bundle or use it stand-alone as described. Just remember that the
the security is no better than the way you obtained the certificate. security is no better than the way you obtained the certificate.
4. If you're using the curl command line tool, you can specify your own CA 4. If you're using the curl command line tool, you can specify your own CA
cert path by setting the environment variable `CURL_CA_BUNDLE` to the path cert path by setting the environment variable `CURL_CA_BUNDLE` to the path
@ -123,9 +113,9 @@ server, do one of the following:
Neglecting to use one of the above methods when dealing with a server using a Neglecting to use one of the above methods when dealing with a server using a
certificate that isn't signed by one of the certificates in the installed CA certificate that isn't signed by one of the certificates in the installed CA
certificate store, will cause SSL to report an error ("certificate verify cert bundle, will cause SSL to report an error ("certificate verify failed")
failed") during the handshake and SSL will then refuse further communication during the handshake and SSL will then refuse further communication with that
with that server. server.
Certificate Verification with NSS Certificate Verification with NSS
--------------------------------- ---------------------------------
@ -133,8 +123,8 @@ Certificate Verification with NSS
If libcurl was built with NSS support, then depending on the OS distribution, If libcurl was built with NSS support, then depending on the OS distribution,
it is probably required to take some additional steps to use the system-wide it is probably required to take some additional steps to use the system-wide
CA cert db. RedHat ships with an additional module, libnsspem.so, which CA cert db. RedHat ships with an additional module, libnsspem.so, which
enables NSS to read the OpenSSL PEM CA bundle. On openSUSE you can install enables NSS to read the OpenSSL PEM CA bundle. This library is missing in
p11-kit-nss-trust which makes NSS use the system wide CA certificate store. NSS OpenSuSE, and without it, NSS can only work with its own internal formats. NSS
also has a new [database format](https://wiki.mozilla.org/NSS_Shared_DB). also has a new [database format](https://wiki.mozilla.org/NSS_Shared_DB).
Starting with version 7.19.7, libcurl automatically adds the 'sql:' prefix to Starting with version 7.19.7, libcurl automatically adds the 'sql:' prefix to

View File

@ -135,7 +135,6 @@ Benjamin Kircher
Benoit Neil Benoit Neil
Benoit Sigoure Benoit Sigoure
Bernard Leak Bernard Leak
Bernard Spil
Bernhard Reutner-Fischer Bernhard Reutner-Fischer
Bert Huijben Bert Huijben
Bertrand Demiddelaer Bertrand Demiddelaer
@ -155,7 +154,6 @@ Bob Richmond
Bob Schader Bob Schader
Bogdan Nicula Bogdan Nicula
Brad Burdick Brad Burdick
Brad Fitzpatrick
Brad Harder Brad Harder
Brad Hards Brad Hards
Brad King Brad King
@ -223,7 +221,6 @@ Claes Jakobsson
Clarence Gardner Clarence Gardner
Clemens Gruber Clemens Gruber
Clifford Wolf Clifford Wolf
Clint Clayton
Cody Jones Cody Jones
Cody Mack Cody Mack
Colby Ranger Colby Ranger
@ -283,7 +280,6 @@ Dave Thompson
Dave Vasilevsky Dave Vasilevsky
Davey Shafik Davey Shafik
David Bau David Bau
David Benjamin
David Binderman David Binderman
David Blaikie David Blaikie
David Byron David Byron
@ -460,7 +456,6 @@ Glen A Johnson Jr.
Glen Nakamura Glen Nakamura
Glen Scott Glen Scott
Glenn Sheridan Glenn Sheridan
Google Inc.
Gordon Marler Gordon Marler
Gorilla Maguila Gorilla Maguila
Grant Erickson Grant Erickson
@ -535,7 +530,6 @@ Jacob Meuser
Jacob Moshenko Jacob Moshenko
Jactry Zeng Jactry Zeng
Jad Chamcham Jad Chamcham
Jaime Fullaondo
Jakub Zakrzewski Jakub Zakrzewski
James Bursa James Bursa
James Cheng James Cheng
@ -583,7 +577,6 @@ Jeff Lawson
Jeff Phillips Jeff Phillips
Jeff Pohlmeyer Jeff Pohlmeyer
Jeff Weber Jeff Weber
Jeffrey Walton
Jens Rantil Jens Rantil
Jeremy Friesner Jeremy Friesner
Jeremy Huddleston Jeremy Huddleston
@ -598,7 +591,6 @@ Jerry Wu
Jes Badwal Jes Badwal
Jesper Jensen Jesper Jensen
Jesse Noller Jesse Noller
Jesse Tan
Jie He Jie He
Jim Drash Jim Drash
Jim Freeman Jim Freeman
@ -700,7 +692,6 @@ Karl Moerder
Karol Pietrzak Karol Pietrzak
Kaspar Brand Kaspar Brand
Katie Wang Katie Wang
Kazuho Oku
Kees Cook Kees Cook
Keith MacDonald Keith MacDonald
Keith McGuigan Keith McGuigan
@ -773,7 +764,6 @@ Lucas Adamski
Lucas Pardue Lucas Pardue
Ludek Finstrle Ludek Finstrle
Ludovico Cavedon Ludovico Cavedon
Ludwig Nussel
Lukas Ruzicka Lukas Ruzicka
Lukasz Czekierda Lukasz Czekierda
Luke Amery Luke Amery
@ -785,7 +775,6 @@ Maciej Karpiuk
Maciej Puzio Maciej Puzio
Maciej W. Rozycki Maciej W. Rozycki
Maks Naumov Maks Naumov
Maksim Kuzevanov
Maksim Stsepanenka Maksim Stsepanenka
Mamoru Tasaka Mamoru Tasaka
Mandy Wu Mandy Wu
@ -872,7 +861,6 @@ Michael Jahn
Michael Jerris Michael Jerris
Michael Kalinin Michael Kalinin
Michael Kaufmann Michael Kaufmann
Michael König
Michael Mealling Michael Mealling
Michael Mueller Michael Mueller
Michael Osipov Michael Osipov
@ -946,13 +934,11 @@ Nodak Sodak
Norbert Frese Norbert Frese
Norbert Kett Norbert Kett
Norbert Novotny Norbert Novotny
Octavio Schroeder
Ofer Ofer
Ola Mork Ola Mork
Olaf Flebbe Olaf Flebbe
Olaf Stüben Olaf Stüben
Oliver Gondža Oliver Gondža
Oliver Graute
Oliver Kuckertz Oliver Kuckertz
Oliver Schindler Oliver Schindler
Olivier Berger Olivier Berger
@ -1045,7 +1031,6 @@ Quanah Gibson-Mount
Quinn Slack Quinn Slack
Radu Simionescu Radu Simionescu
Rafa Muyo Rafa Muyo
Rafael Antonio
Rafael Sagula Rafael Sagula
Rafayel Mkrtchyan Rafayel Mkrtchyan
Rafaël Carré Rafaël Carré
@ -1165,14 +1150,12 @@ Sergei Nikulov
Sergey Tatarincev Sergey Tatarincev
Sergio Ballestrero Sergio Ballestrero
Seshubabu Pasam Seshubabu Pasam
Seth Mos
Sh Diao Sh Diao
Shao Shuchao Shao Shuchao
Sharad Gupta Sharad Gupta
Shard Shard
Shawn Landden Shawn Landden
Shawn Poulson Shawn Poulson
Shine Fan
Shmulik Regev Shmulik Regev
Siddhartha Prakash Jain Siddhartha Prakash Jain
Sidney San Martin Sidney San Martin
@ -1258,7 +1241,6 @@ Tim Sneddon
Tim Stack Tim Stack
Tim Starling Tim Starling
Timo Sirainen Timo Sirainen
Timotej Lazar
Tinus van den Berg Tinus van den Berg
Tobias Markus Tobias Markus
Tobias Rundström Tobias Rundström

View File

@ -52,4 +52,3 @@ s/Jonathan Cardoso/Jonathan Cardoso Machado/
s/Linus Nielsen/Linus Nielsen Feltzing/ s/Linus Nielsen/Linus Nielsen Feltzing/
s/Todd Ouska$/Todd A Ouska/ s/Todd Ouska$/Todd A Ouska/
s/Tim Ruehsen/Tim Rühsen/ s/Tim Ruehsen/Tim Rühsen/
s/Michael Koenig/Michael König/

View File

@ -69,23 +69,23 @@
7. SMTP 7. SMTP
7.1 Pipelining 7.1 Pipelining
7.2 Enhanced capability support 7.2 Enhanced capability support
8. POP3 8. POP3
8.1 Pipelining 8.1 Pipelining
8.2 Enhanced capability support 8.2 Enhanced capability support
9. IMAP 9. IMAP
9.1 Enhanced capability support 9.1 Enhanced capability support
10. LDAP 10. LDAP
10.1 SASL based authentication mechanisms 10.1 SASL based authentication mechanisms
11. SMB 11. SMB
11.1 File listing support 11.1 File listing support
11.2 Honor file timestamps 11.2 Honor file timestamps
11.3 Use NTLMv2 11.3 Use NTLMv2
11.4 Create remote directories 11.4 Create remote directories
12. New protocols 12. New protocols
12.1 RSYNC 12.1 RSYNC
@ -111,8 +111,8 @@
16. SASL 16. SASL
16.1 Other authentication mechanisms 16.1 Other authentication mechanisms
16.2 Add QOP support to GSSAPI authentication 16.2 Add QOP support to GSSAPI authentication
17. Command line tool 17. Client
17.1 sync 17.1 sync
17.2 glob posts 17.2 glob posts
17.3 prevent file overwriting 17.3 prevent file overwriting
@ -124,7 +124,6 @@
17.9 Choose the name of file in braces for complex URLs 17.9 Choose the name of file in braces for complex URLs
17.10 improve how curl works in a windows console window 17.10 improve how curl works in a windows console window
17.11 -w output to stderr 17.11 -w output to stderr
17.12 keep running, read instructions from pipe/socket
18. Build 18. Build
18.1 roffit 18.1 roffit
@ -135,7 +134,6 @@
19.3 more protocols supported 19.3 more protocols supported
19.4 more platforms supported 19.4 more platforms supported
19.5 Add support for concurrent connections 19.5 Add support for concurrent connections
19.6 Use the RFC6265 test suite
20. Next SONAME bump 20. Next SONAME bump
20.1 http-style HEAD output for FTP 20.1 http-style HEAD output for FTP
@ -431,7 +429,7 @@ This is not detailed in any FTP specification.
For example: For example:
http://test:pass;auth=NTLM@example.com would be equivalent to specifying --user http://test:pass;auth=NTLM@example.com would be equivalent to specifying --user
test:pass;auth=NTLM or --user test:pass --ntlm from the command line. test:pass;auth=NTLM or --user test:pass --ntlm from the command line.
Additionally this should be implemented for proxy base URLs as well. Additionally this should be implemented for proxy base URLs as well.
@ -652,7 +650,7 @@ that doesn't exist on the server, just like --ftp-create-dirs.
Add support for other authentication mechanisms such as OLP, Add support for other authentication mechanisms such as OLP,
GSS-SPNEGO and others. GSS-SPNEGO and others.
16.2 Add QOP support to GSSAPI authentication 16.2 Add QOP support to GSSAPI authentication
Currently the GSSAPI authentication only supports the default QOP of auth Currently the GSSAPI authentication only supports the default QOP of auth
@ -660,7 +658,7 @@ that doesn't exist on the server, just like --ftp-create-dirs.
with integrity protection) and auth-conf (Authentication with integrity and with integrity protection) and auth-conf (Authentication with integrity and
privacy protection). privacy protection).
17. Command line tool 17. Client
17.1 sync 17.1 sync
@ -748,13 +746,6 @@ that doesn't exist on the server, just like --ftp-create-dirs.
instead. Proposed name: --write-stderr. See instead. Proposed name: --write-stderr. See
https://github.com/curl/curl/issues/613 https://github.com/curl/curl/issues/613
17.12 keep running, read instructions from pipe/socket
Provide an option that makes curl not exit after the last URL (or even work
without a given URL), and then make it read instructions passed on a pipe or
over a socket to make further instructions so that a second subsequent curl
invoke can talk to the still running instance and ask for transfers to get
done, and thus maintain its connection pool, DNS cache and more.
18. Build 18. Build
@ -800,16 +791,6 @@ that doesn't exist on the server, just like --ftp-create-dirs.
and thus the wait for connections loop is never entered to receive the second and thus the wait for connections loop is never entered to receive the second
connection. connection.
19.6 Use the RFC6265 test suite
A test suite made for HTTP cookies (RFC 6265) by Adam Barth is available at
https://github.com/abarth/http-state/tree/master/tests
It'd be really awesome if someone would write a script/setup that would run
curl with that test suite and detect deviances. Ideally, that would even be
incorporated into our regular test suite.
20. Next SONAME bump 20. Next SONAME bump
20.1 http-style HEAD output for FTP 20.1 http-style HEAD output for FTP

View File

@ -216,8 +216,8 @@ read previously stored cookie lines from, which should be used in this session
if they match. Using this method also activates the cookie engine which will if they match. Using this method also activates the cookie engine which will
make curl record incoming cookies too, which may be handy if you're using this make curl record incoming cookies too, which may be handy if you're using this
in combination with the \fI-L, --location\fP option. The file format of the in combination with the \fI-L, --location\fP option. The file format of the
file to read cookies from should be plain HTTP headers (Set-Cookie style) or file to read cookies from should be plain HTTP headers or the Netscape/Mozilla
the Netscape/Mozilla cookie file format. cookie file format.
The file specified with \fI-b, --cookie\fP is only used as input. No cookies The file specified with \fI-b, --cookie\fP is only used as input. No cookies
will be written to the file. To store cookies, use the \fI-c, --cookie-jar\fP will be written to the file. To store cookies, use the \fI-c, --cookie-jar\fP
@ -430,9 +430,6 @@ the traditional PORT command.
\fB--eprt\fP can be used to explicitly enable EPRT again and \fB--no-eprt\fP \fB--eprt\fP can be used to explicitly enable EPRT again and \fB--no-eprt\fP
is an alias for \fB--disable-eprt\fP. is an alias for \fB--disable-eprt\fP.
If the server is an IPv6 host, this option will have no effect as EPRT is
necessary then.
Disabling EPRT only changes the active behavior. If you want to switch to Disabling EPRT only changes the active behavior. If you want to switch to
passive mode you need to not use \fI-P, --ftp-port\fP or force it with passive mode you need to not use \fI-P, --ftp-port\fP or force it with
\fI--ftp-pasv\fP. \fI--ftp-pasv\fP.
@ -444,9 +441,6 @@ but with this option, it will not try using EPSV.
\fB--epsv\fP can be used to explicitly enable EPSV again and \fB--no-epsv\fP \fB--epsv\fP can be used to explicitly enable EPSV again and \fB--no-epsv\fP
is an alias for \fB--disable-epsv\fP. is an alias for \fB--disable-epsv\fP.
If the server is an IPv6 host, this option will have no effect as EPSV is
necessary then.
Disabling EPSV only changes the passive behavior. If you want to switch to Disabling EPSV only changes the passive behavior. If you want to switch to
active mode you need to use \fI-P, --ftp-port\fP. active mode you need to use \fI-P, --ftp-port\fP.
.IP "--dns-interface <interface>" .IP "--dns-interface <interface>"
@ -977,7 +971,7 @@ re-send the following request using the same unmodified method.
You can tell curl to not change the non-GET request method to GET after a 30x You can tell curl to not change the non-GET request method to GET after a 30x
response by using the dedicated options for that: \fI--post301\fP, response by using the dedicated options for that: \fI--post301\fP,
\fI--post302\fP and \fI--post303\fP. \fI--post302\fP and \fI-post303\fP.
.IP "--libcurl <file>" .IP "--libcurl <file>"
Append this option to any ordinary curl command line, and you will get a Append this option to any ordinary curl command line, and you will get a
libcurl-using C source code written to the file that does the equivalent libcurl-using C source code written to the file that does the equivalent
@ -1730,14 +1724,6 @@ default 512 bytes will be used.
If this option is used several times, the last one will be used. If this option is used several times, the last one will be used.
(Added in 7.20.0) (Added in 7.20.0)
.IP "--tftp-no-options"
(TFTP) Tells curl not to send TFTP options requests.
This option improves interop with some legacy servers that do not acknowledge
or properly implement TFTP options. When this option is used
\fI--tftp-blksize\fP is ignored.
(Added in 7.48.0)
.IP "--tlsauthtype <authtype>" .IP "--tlsauthtype <authtype>"
Set TLS authentication type. Currently, the only supported option is "SRP", Set TLS authentication type. Currently, the only supported option is "SRP",
for TLS-SRP (RFC 5054). If \fI--tlsuser\fP and \fI--tlspassword\fP are for TLS-SRP (RFC 5054). If \fI--tlsuser\fP and \fI--tlspassword\fP are

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -127,42 +127,41 @@ int main(void)
uses */ uses */
curl_multi_setopt(cm, CURLMOPT_MAXCONNECTS, (long)MAX); curl_multi_setopt(cm, CURLMOPT_MAXCONNECTS, (long)MAX);
for(C = 0; C < MAX; ++C) { for (C = 0; C < MAX; ++C) {
init(cm, C); init(cm, C);
} }
while(U) { while (U) {
curl_multi_perform(cm, &U); curl_multi_perform(cm, &U);
if(U) { if (U) {
FD_ZERO(&R); FD_ZERO(&R);
FD_ZERO(&W); FD_ZERO(&W);
FD_ZERO(&E); FD_ZERO(&E);
if(curl_multi_fdset(cm, &R, &W, &E, &M)) { if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
fprintf(stderr, "E: curl_multi_fdset\n"); fprintf(stderr, "E: curl_multi_fdset\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(curl_multi_timeout(cm, &L)) { if (curl_multi_timeout(cm, &L)) {
fprintf(stderr, "E: curl_multi_timeout\n"); fprintf(stderr, "E: curl_multi_timeout\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(L == -1) if (L == -1)
L = 100; L = 100;
if(M == -1) { if (M == -1) {
#ifdef WIN32 #ifdef WIN32
Sleep(L); Sleep(L);
#else #else
sleep((unsigned int)L / 1000); sleep(L / 1000);
#endif #endif
} } else {
else {
T.tv_sec = L/1000; T.tv_sec = L/1000;
T.tv_usec = (L%1000)*1000; T.tv_usec = (L%1000)*1000;
if(0 > select(M+1, &R, &W, &E, &T)) { if (0 > select(M+1, &R, &W, &E, &T)) {
fprintf(stderr, "E: select(%i,,,,%li): %i: %s\n", fprintf(stderr, "E: select(%i,,,,%li): %i: %s\n",
M+1, L, errno, strerror(errno)); M+1, L, errno, strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
@ -170,8 +169,8 @@ int main(void)
} }
} }
while((msg = curl_multi_info_read(cm, &Q))) { while ((msg = curl_multi_info_read(cm, &Q))) {
if(msg->msg == CURLMSG_DONE) { if (msg->msg == CURLMSG_DONE) {
char *url; char *url;
CURL *e = msg->easy_handle; CURL *e = msg->easy_handle;
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url); curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url);
@ -183,7 +182,7 @@ int main(void)
else { else {
fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg); fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg);
} }
if(C < CNT) { if (C < CNT) {
init(cm, C++); init(cm, C++);
U++; /* just to prevent it from remaining at 0 if there are more U++; /* just to prevent it from remaining at 0 if there are more
URLs to get */ URLs to get */

View File

@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___ # | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____| # \___|\___/|_| \_\_____|
# #
# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. # Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
# #
# This software is licensed as described in the file COPYING, which # This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms # you should have received as part of this distribution. The terms
@ -61,6 +61,3 @@ endif
include Makefile.inc include Makefile.inc
all: $(check_PROGRAMS) all: $(check_PROGRAMS)
checksrc:
@@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/docs/examples *.c

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -78,8 +78,7 @@
/* ioctl callback function */ /* ioctl callback function */
static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp) static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
{ {
int *fdp = (int *)userp; intptr_t fd = (intptr_t)userp;
int fd = *fdp;
(void)handle; /* not used in here */ (void)handle; /* not used in here */
@ -101,11 +100,10 @@ static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
/* read callback function, fread() look alike */ /* read callback function, fread() look alike */
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
ssize_t retcode; size_t retcode;
curl_off_t nread; curl_off_t nread;
int *fdp = (int *)stream; intptr_t fd = (intptr_t)stream;
int fd = *fdp;
retcode = read(fd, ptr, size * nmemb); retcode = read(fd, ptr, size * nmemb);
@ -121,7 +119,7 @@ int main(int argc, char **argv)
{ {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
int hd; intptr_t hd ;
struct stat file_info; struct stat file_info;
char *file; char *file;
@ -134,7 +132,7 @@ int main(int argc, char **argv)
url = argv[2]; url = argv[2];
/* get the file size of the local file */ /* get the file size of the local file */
hd = open(file, O_RDONLY); hd = open(file, O_RDONLY) ;
fstat(hd, &file_info); fstat(hd, &file_info);
/* In windows, this will init the winsock stuff */ /* In windows, this will init the winsock stuff */
@ -147,20 +145,20 @@ int main(int argc, char **argv)
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* which file to upload */ /* which file to upload */
curl_easy_setopt(curl, CURLOPT_READDATA, (void*)&hd); curl_easy_setopt(curl, CURLOPT_READDATA, (void*)hd);
/* set the ioctl function */ /* set the ioctl function */
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, my_ioctl); curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, my_ioctl);
/* pass the file descriptor to the ioctl callback as well */ /* pass the file descriptor to the ioctl callback as well */
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, (void*)&hd); curl_easy_setopt(curl, CURLOPT_IOCTLDATA, (void*)hd);
/* enable "uploading" (which means PUT when doing HTTP) */ /* enable "uploading" (which means PUT when doing HTTP) */
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L) ;
/* specify target URL, and note that this URL should also include a file /* specify target URL, and note that this URL should also include a file
name, not only a directory (as you can do with GTP uploads) */ name, not only a directory (as you can do with GTP uploads) */
curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl,CURLOPT_URL, url);
/* and give the size of the upload, this supports large file sizes /* and give the size of the upload, this supports large file sizes
on systems that have general support for it */ on systems that have general support for it */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -30,8 +30,8 @@
size_t writefunction( void *ptr, size_t size, size_t nmemb, void *stream) size_t writefunction( void *ptr, size_t size, size_t nmemb, void *stream)
{ {
fwrite(ptr, size, nmemb, stream); fwrite(ptr,size,nmemb,stream);
return (nmemb*size); return(nmemb*size);
} }
static CURLcode sslctx_function(CURL * curl, void * sslctx, void * parm) static CURLcode sslctx_function(CURL * curl, void * sslctx, void * parm)
@ -87,14 +87,14 @@ static CURLcode sslctx_function(CURL * curl, void * sslctx, void * parm)
* structure that SSL can use * structure that SSL can use
*/ */
PEM_read_bio_X509(bio, &cert, 0, NULL); PEM_read_bio_X509(bio, &cert, 0, NULL);
if(cert == NULL) if (cert == NULL)
printf("PEM_read_bio_X509 failed...\n"); printf("PEM_read_bio_X509 failed...\n");
/* get a pointer to the X509 certificate store (which may be empty!) */ /* get a pointer to the X509 certificate store (which may be empty!) */
store=SSL_CTX_get_cert_store((SSL_CTX *)sslctx); store=SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
/* add our certificate to this store */ /* add our certificate to this store */
if(X509_STORE_add_cert(store, cert)==0) if (X509_STORE_add_cert(store, cert)==0)
printf("error adding certificate\n"); printf("error adding certificate\n");
/* decrease reference counts */ /* decrease reference counts */
@ -102,7 +102,7 @@ static CURLcode sslctx_function(CURL * curl, void * sslctx, void * parm)
BIO_free(bio); BIO_free(bio);
/* all set to go */ /* all set to go */
return CURLE_OK; return CURLE_OK ;
} }
int main(void) int main(void)
@ -112,22 +112,22 @@ int main(void)
rv=curl_global_init(CURL_GLOBAL_ALL); rv=curl_global_init(CURL_GLOBAL_ALL);
ch=curl_easy_init(); ch=curl_easy_init();
rv=curl_easy_setopt(ch, CURLOPT_VERBOSE, 0L); rv=curl_easy_setopt(ch,CURLOPT_VERBOSE, 0L);
rv=curl_easy_setopt(ch, CURLOPT_HEADER, 0L); rv=curl_easy_setopt(ch,CURLOPT_HEADER, 0L);
rv=curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 1L); rv=curl_easy_setopt(ch,CURLOPT_NOPROGRESS, 1L);
rv=curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L); rv=curl_easy_setopt(ch,CURLOPT_NOSIGNAL, 1L);
rv=curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, *writefunction); rv=curl_easy_setopt(ch,CURLOPT_WRITEFUNCTION, *writefunction);
rv=curl_easy_setopt(ch, CURLOPT_WRITEDATA, stdout); rv=curl_easy_setopt(ch,CURLOPT_WRITEDATA, stdout);
rv=curl_easy_setopt(ch, CURLOPT_HEADERFUNCTION, *writefunction); rv=curl_easy_setopt(ch,CURLOPT_HEADERFUNCTION, *writefunction);
rv=curl_easy_setopt(ch, CURLOPT_HEADERDATA, stderr); rv=curl_easy_setopt(ch,CURLOPT_HEADERDATA, stderr);
rv=curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); rv=curl_easy_setopt(ch,CURLOPT_SSLCERTTYPE,"PEM");
rv=curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L); rv=curl_easy_setopt(ch,CURLOPT_SSL_VERIFYPEER,1L);
rv=curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); rv=curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
/* first try: retrieve page without cacerts' certificate -> will fail /* first try: retrieve page without cacerts' certificate -> will fail
*/ */
rv=curl_easy_perform(ch); rv=curl_easy_perform(ch);
if(rv==CURLE_OK) if (rv==CURLE_OK)
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
else else
printf("*** transfer failed ***\n"); printf("*** transfer failed ***\n");
@ -136,9 +136,9 @@ int main(void)
* load the certificate by installing a function doing the nescessary * load the certificate by installing a function doing the nescessary
* "modifications" to the SSL CONTEXT just before link init * "modifications" to the SSL CONTEXT just before link init
*/ */
rv=curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); rv=curl_easy_setopt(ch,CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
rv=curl_easy_perform(ch); rv=curl_easy_perform(ch);
if(rv==CURLE_OK) if (rv==CURLE_OK)
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
else else
printf("*** transfer failed ***\n"); printf("*** transfer failed ***\n");

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -68,78 +68,63 @@ int main(int argc, char *argv[])
const char *url = URL_1M; const char *url = URL_1M;
char *appname = argv[0]; char *appname = argv[0];
if(argc > 1) { if (argc > 1) {
/* parse input parameters */ /* parse input parameters */
for(argc--, argv++; *argv; argc--, argv++) { for (argc--, argv++; *argv; argc--, argv++) {
if(strncasecmp(*argv, "-", 1) == 0) { if (strncasecmp(*argv, "-", 1) == 0) {
if(strncasecmp(*argv, "-H", 2) == 0) { if (strncasecmp(*argv, "-H", 2) == 0) {
fprintf(stderr, fprintf(stderr,
"\rUsage: %s [-m=1|2|5|10|20|50|100] [-t] [-x] [url]\n", "\rUsage: %s [-m=1|2|5|10|20|50|100] [-t] [-x] [url]\n",
appname); appname);
exit(1); exit(1);
} } else if (strncasecmp(*argv, "-V", 2) == 0) {
else if(strncasecmp(*argv, "-V", 2) == 0) {
fprintf(stderr, "\r%s %s - %s\n", fprintf(stderr, "\r%s %s - %s\n",
appname, CHKSPEED_VERSION, curl_version()); appname, CHKSPEED_VERSION, curl_version());
exit(1); exit(1);
} } else if (strncasecmp(*argv, "-A", 2) == 0) {
else if(strncasecmp(*argv, "-A", 2) == 0) {
prtall = 1; prtall = 1;
} } else if (strncasecmp(*argv, "-X", 2) == 0) {
else if(strncasecmp(*argv, "-X", 2) == 0) {
prtsep = 1; prtsep = 1;
} } else if (strncasecmp(*argv, "-T", 2) == 0) {
else if(strncasecmp(*argv, "-T", 2) == 0) {
prttime = 1; prttime = 1;
} } else if (strncasecmp(*argv, "-M=", 3) == 0) {
else if(strncasecmp(*argv, "-M=", 3) == 0) {
long m = strtol((*argv)+3, NULL, 10); long m = strtol((*argv)+3, NULL, 10);
switch(m) { switch(m) {
case 1: case 1: url = URL_1M;
url = URL_1M; break;
break; case 2: url = URL_2M;
case 2: break;
url = URL_2M; case 5: url = URL_5M;
break; break;
case 5: case 10: url = URL_10M;
url = URL_5M; break;
break; case 20: url = URL_20M;
case 10: break;
url = URL_10M; case 50: url = URL_50M;
break; break;
case 20: case 100: url = URL_100M;
url = URL_20M; break;
break; default: fprintf(stderr, "\r%s: invalid parameter %s\n",
case 50: appname, *argv + 3);
url = URL_50M; exit(1);
break;
case 100:
url = URL_100M;
break;
default:
fprintf(stderr, "\r%s: invalid parameter %s\n",
appname, *argv + 3);
exit(1);
} }
} } else {
else {
fprintf(stderr, "\r%s: invalid or unknown option %s\n", fprintf(stderr, "\r%s: invalid or unknown option %s\n",
appname, *argv); appname, *argv);
exit(1); exit(1);
} }
} } else {
else {
url = *argv; url = *argv;
} }
} }
} }
/* print separator line */ /* print separator line */
if(prtsep) { if (prtsep) {
printf("-------------------------------------------------\n"); printf("-------------------------------------------------\n");
} }
/* print localtime */ /* print localtime */
if(prttime) { if (prttime) {
time_t t = time(NULL); time_t t = time(NULL);
printf("Localtime: %s", ctime(&t)); printf("Localtime: %s", ctime(&t));
} }
@ -182,7 +167,7 @@ int main(int argc, char *argv[])
if((CURLE_OK == res) && (val>0)) if((CURLE_OK == res) && (val>0))
printf("Average download speed: %0.3f kbyte/sec.\n", val / 1024); printf("Average download speed: %0.3f kbyte/sec.\n", val / 1024);
if(prtall) { if (prtall) {
/* check for name resolution time */ /* check for name resolution time */
res = curl_easy_getinfo(curl_handle, CURLINFO_NAMELOOKUP_TIME, &val); res = curl_easy_getinfo(curl_handle, CURLINFO_NAMELOOKUP_TIME, &val);
if((CURLE_OK == res) && (val>0)) if((CURLE_OK == res) && (val>0))
@ -193,8 +178,8 @@ int main(int argc, char *argv[])
if((CURLE_OK == res) && (val>0)) if((CURLE_OK == res) && (val>0))
printf("Connect time: %0.3f sec.\n", val); printf("Connect time: %0.3f sec.\n", val);
} }
}
else { } else {
fprintf(stderr, "Error while fetching '%s' : %s\n", fprintf(stderr, "Error while fetching '%s' : %s\n",
url, curl_easy_strerror(res)); url, curl_easy_strerror(res));
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -42,18 +42,17 @@ print_cookies(CURL *curl)
printf("Cookies, curl knows:\n"); printf("Cookies, curl knows:\n");
res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies); res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if(res != CURLE_OK) { if (res != CURLE_OK) {
fprintf(stderr, "Curl curl_easy_getinfo failed: %s\n", fprintf(stderr, "Curl curl_easy_getinfo failed: %s\n", curl_easy_strerror(res));
curl_easy_strerror(res));
exit(1); exit(1);
} }
nc = cookies, i = 1; nc = cookies, i = 1;
while(nc) { while (nc) {
printf("[%d]: %s\n", i, nc->data); printf("[%d]: %s\n", i, nc->data);
nc = nc->next; nc = nc->next;
i++; i++;
} }
if(i == 1) { if (i == 1) {
printf("(none)\n"); printf("(none)\n");
} }
curl_slist_free_all(cookies); curl_slist_free_all(cookies);
@ -67,14 +66,14 @@ main(void)
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if (curl) {
char nline[256]; char nline[256];
curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/"); curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* start cookie engine */ curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* just to start the cookie engine */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res != CURLE_OK) { if (res != CURLE_OK) {
fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res)); fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res));
return 1; return 1;
} }
@ -93,13 +92,10 @@ main(void)
#endif #endif
/* Netscape format cookie */ /* Netscape format cookie */
snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%lu\t%s\t%s", snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%lu\t%s\t%s",
".google.com", "TRUE", "/", "FALSE", ".google.com", "TRUE", "/", "FALSE", (unsigned long)time(NULL) + 31337UL, "PREF", "hello google, i like you very much!");
(unsigned long)time(NULL) + 31337UL,
"PREF", "hello google, i like you very much!");
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline); res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
if(res != CURLE_OK) { if (res != CURLE_OK) {
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n", fprintf(stderr, "Curl curl_easy_setopt failed: %s\n", curl_easy_strerror(res));
curl_easy_strerror(res));
return 1; return 1;
} }
@ -113,21 +109,18 @@ main(void)
"Set-Cookie: OLD_PREF=3d141414bf4209321; " "Set-Cookie: OLD_PREF=3d141414bf4209321; "
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com"); "expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com");
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline); res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
if(res != CURLE_OK) { if (res != CURLE_OK) {
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n", fprintf(stderr, "Curl curl_easy_setopt failed: %s\n", curl_easy_strerror(res));
curl_easy_strerror(res));
return 1; return 1;
} }
print_cookies(curl); print_cookies(curl);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res != CURLE_OK) { if (res != CURLE_OK) {
fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res)); fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res));
return 1; return 1;
} }
curl_easy_cleanup(curl);
} }
else { else {
fprintf(stderr, "Curl init failed!\n"); fprintf(stderr, "Curl init failed!\n");

View File

@ -50,9 +50,9 @@ void *my_thread(void *ptr)
gchar *url = ptr; gchar *url = ptr;
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if(curl)
const char *filename = "test.curl"; {
outfile = fopen(filename, "wb"); outfile = fopen("test.curl", "w");
curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
@ -97,7 +97,7 @@ int main(int argc, char **argv)
gtk_container_add(GTK_CONTAINER(Frame2), Bar); gtk_container_add(GTK_CONTAINER(Frame2), Bar);
gtk_widget_show_all(Window); gtk_widget_show_all(Window);
if(!g_thread_create(&my_thread, argv[1], FALSE, NULL) != 0) if (!g_thread_create(&my_thread, argv[1], FALSE, NULL) != 0)
g_warning("can't create the thread"); g_warning("can't create the thread");

View File

@ -101,18 +101,13 @@
static const char *curlx_usage[]={ static const char *curlx_usage[]={
"usage: curlx args\n", "usage: curlx args\n",
" -p12 arg - tia file ", " -p12 arg - tia file ",
" -envpass arg - environement variable which content the tia private" " -envpass arg - environement variable which content the tia private key password",
" key password",
" -out arg - output file (response)- default stdout", " -out arg - output file (response)- default stdout",
" -in arg - input file (request)- default stdin", " -in arg - input file (request)- default stdin",
" -connect arg - URL of the server for the connection ex:" " -connect arg - URL of the server for the connection ex: www.openevidence.org",
" www.openevidence.org", " -mimetype arg - MIME type for data in ex : application/timestamp-query or application/dvcs -default application/timestamp-query",
" -mimetype arg - MIME type for data in ex : application/timestamp-query" " -acceptmime arg - MIME type acceptable for the response ex : application/timestamp-response or application/dvcs -default none",
" or application/dvcs -default application/timestamp-query", " -accesstype arg - an Object identifier in an AIA/SIA method, e.g. AD_DVCS or ad_timestamping",
" -acceptmime arg - MIME type acceptable for the response ex : "
"application/timestamp-response or application/dvcs -default none",
" -accesstype arg - an Object identifier in an AIA/SIA method, e.g."
" AD_DVCS or ad_timestamping",
NULL NULL
}; };
@ -133,22 +128,22 @@ static const char *curlx_usage[]={
/* This is a context that we pass to all callbacks */ /* This is a context that we pass to all callbacks */
typedef struct sslctxparm_st { typedef struct sslctxparm_st {
unsigned char * p12file; unsigned char * p12file ;
const char * pst; const char * pst ;
PKCS12 * p12; PKCS12 * p12 ;
EVP_PKEY * pkey; EVP_PKEY * pkey ;
X509 * usercert; X509 * usercert ;
STACK_OF(X509) * ca; STACK_OF(X509) * ca ;
CURL * curl; CURL * curl;
BIO * errorbio; BIO * errorbio;
int accesstype; int accesstype ;
int verbose; int verbose;
} sslctxparm; } sslctxparm;
/* some helper function. */ /* some helper function. */
static char *ia5string(ASN1_IA5STRING *ia5) static char *i2s_ASN1_IA5STRING( ASN1_IA5STRING *ia5)
{ {
char *tmp; char *tmp;
if(!ia5 || !ia5->length) if(!ia5 || !ia5->length)
@ -160,20 +155,20 @@ static char *ia5string(ASN1_IA5STRING *ia5)
} }
/* A conveniance routine to get an access URI. */ /* A conveniance routine to get an access URI. */
static unsigned char *my_get_ext(X509 *cert, const int type,
int extensiontype)
{
int i;
STACK_OF(ACCESS_DESCRIPTION) * accessinfo;
accessinfo = X509_get_ext_d2i(cert, extensiontype, NULL, NULL);
if(!sk_ACCESS_DESCRIPTION_num(accessinfo)) static unsigned char *my_get_ext(X509 * cert, const int type, int extensiontype) {
int i;
STACK_OF(ACCESS_DESCRIPTION) * accessinfo ;
accessinfo = X509_get_ext_d2i(cert, extensiontype, NULL, NULL) ;
if (!sk_ACCESS_DESCRIPTION_num(accessinfo))
return NULL; return NULL;
for(i = 0; i < sk_ACCESS_DESCRIPTION_num(accessinfo); i++) { for (i = 0; i < sk_ACCESS_DESCRIPTION_num(accessinfo); i++) {
ACCESS_DESCRIPTION * ad = sk_ACCESS_DESCRIPTION_value(accessinfo, i); ACCESS_DESCRIPTION * ad = sk_ACCESS_DESCRIPTION_value(accessinfo, i);
if(OBJ_obj2nid(ad->method) == type) { if (OBJ_obj2nid(ad->method) == type) {
if(ad->location->type == GEN_URI) { if (ad->location->type == GEN_URI) {
return ia5string(ad->location->d.ia5); return i2s_ASN1_IA5STRING(ad->location->d.ia5);
} }
return NULL; return NULL;
} }
@ -192,86 +187,84 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg)
sslctxparm * p = (sslctxparm *) arg; sslctxparm * p = (sslctxparm *) arg;
int ok; int ok;
if(p->verbose > 2) if (p->verbose > 2)
BIO_printf(p->errorbio, "entering ssl_app_verify_callback\n"); BIO_printf(p->errorbio,"entering ssl_app_verify_callback\n");
if((ok= X509_verify_cert(ctx)) && ctx->cert) { if ((ok= X509_verify_cert(ctx)) && ctx->cert) {
unsigned char * accessinfo; unsigned char * accessinfo ;
if(p->verbose > 1) if (p->verbose > 1)
X509_print_ex(p->errorbio, ctx->cert, 0, 0); X509_print_ex(p->errorbio,ctx->cert,0,0);
if(accessinfo = my_get_ext(ctx->cert, p->accesstype, NID_sinfo_access)) { if (accessinfo = my_get_ext(ctx->cert,p->accesstype ,NID_sinfo_access)) {
if(p->verbose) if (p->verbose)
BIO_printf(p->errorbio, "Setting URL from SIA to: %s\n", accessinfo); BIO_printf(p->errorbio,"Setting URL from SIA to: %s\n", accessinfo);
curl_easy_setopt(p->curl, CURLOPT_URL, accessinfo); curl_easy_setopt(p->curl, CURLOPT_URL,accessinfo);
} }
else if(accessinfo = my_get_ext(ctx->cert, p->accesstype, else if (accessinfo = my_get_ext(ctx->cert,p->accesstype,
NID_info_access)) { NID_info_access)) {
if(p->verbose) if (p->verbose)
BIO_printf(p->errorbio, "Setting URL from AIA to: %s\n", accessinfo); BIO_printf(p->errorbio,"Setting URL from AIA to: %s\n", accessinfo);
curl_easy_setopt(p->curl, CURLOPT_URL, accessinfo); curl_easy_setopt(p->curl, CURLOPT_URL,accessinfo);
} }
} }
if(p->verbose > 2) if (p->verbose > 2)
BIO_printf(p->errorbio, "leaving ssl_app_verify_callback with %d\n", ok); BIO_printf(p->errorbio,"leaving ssl_app_verify_callback with %d\n", ok);
return(ok);
return ok;
} }
/* The SSL initialisation callback. The callback sets: /* This is an example of an curl SSL initialisation call back. The callback sets:
- a private key and certificate - a private key and certificate
- a trusted ca certificate - a trusted ca certificate
- a preferred cipherlist - a preferred cipherlist
- an application verification callback (the function above) - an application verification callback (the function above)
*/ */
static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) {
{
sslctxparm * p = (sslctxparm *) parm; sslctxparm * p = (sslctxparm *) parm;
SSL_CTX * ctx = (SSL_CTX *) sslctx; SSL_CTX * ctx = (SSL_CTX *) sslctx ;
if(!SSL_CTX_use_certificate(ctx, p->usercert)) { if (!SSL_CTX_use_certificate(ctx,p->usercert)) {
BIO_printf(p->errorbio, "SSL_CTX_use_certificate problem\n"); BIO_printf(p->errorbio, "SSL_CTX_use_certificate problem\n"); goto err;
goto err;
} }
if(!SSL_CTX_use_PrivateKey(ctx, p->pkey)) { if (!SSL_CTX_use_PrivateKey(ctx,p->pkey)) {
BIO_printf(p->errorbio, "SSL_CTX_use_PrivateKey\n"); BIO_printf(p->errorbio, "SSL_CTX_use_PrivateKey\n"); goto err;
goto err;
} }
if(!SSL_CTX_check_private_key(ctx)) { if (!SSL_CTX_check_private_key(ctx)) {
BIO_printf(p->errorbio, "SSL_CTX_check_private_key\n"); BIO_printf(p->errorbio, "SSL_CTX_check_private_key\n"); goto err;
goto err;
} }
SSL_CTX_set_quiet_shutdown(ctx, 1); SSL_CTX_set_quiet_shutdown(ctx,1);
SSL_CTX_set_cipher_list(ctx, "RC4-MD5"); SSL_CTX_set_cipher_list(ctx,"RC4-MD5");
SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), sk_X509_value(p->ca, sk_X509_num(p->ca)-1));
sk_X509_value(p->ca, sk_X509_num(p->ca)-1));
SSL_CTX_set_verify_depth(ctx,2);
SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER,ZERO_NULL);
SSL_CTX_set_verify_depth(ctx, 2);
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, ZERO_NULL);
SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm); SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm);
return CURLE_OK;
return CURLE_OK ;
err: err:
ERR_print_errors(p->errorbio); ERR_print_errors(p->errorbio);
return CURLE_SSL_CERTPROBLEM; return CURLE_SSL_CERTPROBLEM;
} }
int main(int argc, char **argv) int main(int argc, char **argv) {
{
BIO* in=NULL; BIO* in=NULL;
BIO* out=NULL; BIO* out=NULL;
char * outfile = NULL; char * outfile = NULL;
char * infile = NULL; char * infile = NULL ;
int tabLength=100; int tabLength=100;
char *binaryptr; char *binaryptr;
@ -280,7 +273,7 @@ int main(int argc, char **argv)
char* contenttype; char* contenttype;
const char** pp; const char** pp;
unsigned char* hostporturl = NULL; unsigned char* hostporturl = NULL;
BIO * p12bio; BIO * p12bio ;
char **args = argv + 1; char **args = argv + 1;
unsigned char * serverurl; unsigned char * serverurl;
sslctxparm p; sslctxparm p;
@ -303,91 +296,66 @@ int main(int argc, char **argv)
OpenSSL_add_all_digests(); OpenSSL_add_all_digests();
ERR_load_crypto_strings(); ERR_load_crypto_strings();
while(*args && *args[0] == '-') {
if(!strcmp (*args, "-in")) {
if(args[1]) { while (*args && *args[0] == '-') {
if (!strcmp (*args, "-in")) {
if (args[1]) {
infile=*(++args); infile=*(++args);
} } else badarg=1;
else } else if (!strcmp (*args, "-out")) {
badarg=1; if (args[1]) {
}
else if(!strcmp (*args, "-out")) {
if(args[1]) {
outfile=*(++args); outfile=*(++args);
} } else badarg=1;
else } else if (!strcmp (*args, "-p12")) {
badarg=1; if (args[1]) {
}
else if(!strcmp (*args, "-p12")) {
if(args[1]) {
p.p12file = *(++args); p.p12file = *(++args);
} } else badarg=1;
else } else if (strcmp(*args,"-envpass") == 0) {
badarg=1; if (args[1]) {
}
else if(strcmp(*args, "-envpass") == 0) {
if(args[1]) {
p.pst = getenv(*(++args)); p.pst = getenv(*(++args));
} } else badarg=1;
else } else if (strcmp(*args,"-connect") == 0) {
badarg=1; if (args[1]) {
}
else if(strcmp(*args, "-connect") == 0) {
if(args[1]) {
hostporturl = *(++args); hostporturl = *(++args);
} } else badarg=1;
else } else if (strcmp(*args,"-mimetype") == 0) {
badarg=1; if (args[1]) {
}
else if(strcmp(*args, "-mimetype") == 0) {
if(args[1]) {
mimetype = *(++args); mimetype = *(++args);
} } else badarg=1;
else } else if (strcmp(*args,"-acceptmime") == 0) {
badarg=1; if (args[1]) {
}
else if(strcmp(*args, "-acceptmime") == 0) {
if(args[1]) {
mimetypeaccept = *(++args); mimetypeaccept = *(++args);
} } else badarg=1;
else } else if (strcmp(*args,"-accesstype") == 0) {
badarg=1; if (args[1]) {
} if ((p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args,0))) == 0) badarg=1;
else if(strcmp(*args, "-accesstype") == 0) { } else badarg=1;
if(args[1]) { } else if (strcmp(*args,"-verbose") == 0) {
if((p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args, 0))) == 0)
badarg=1;
}
else
badarg=1;
}
else if(strcmp(*args, "-verbose") == 0) {
p.verbose++; p.verbose++;
} } else badarg=1;
else
badarg=1;
args++; args++;
} }
if(mimetype==NULL || mimetypeaccept == NULL) if (mimetype==NULL || mimetypeaccept == NULL) badarg = 1;
badarg = 1;
if(badarg) { if (badarg) {
for(pp=curlx_usage; (*pp != NULL); pp++) for (pp=curlx_usage; (*pp != NULL); pp++)
BIO_printf(p.errorbio, "%s\n", *pp); BIO_printf(p.errorbio,"%s\n",*pp);
BIO_printf(p.errorbio, "\n"); BIO_printf(p.errorbio,"\n");
goto err; goto err;
} }
/* set input */ /* set input */
if((in=BIO_new(BIO_s_file())) == NULL) { if ((in=BIO_new(BIO_s_file())) == NULL) {
BIO_printf(p.errorbio, "Error setting input bio\n"); BIO_printf(p.errorbio, "Error setting input bio\n");
goto err; goto err;
} } else if (infile == NULL)
else if(infile == NULL) BIO_set_fp(in,stdin,BIO_NOCLOSE|BIO_FP_TEXT);
BIO_set_fp(in, stdin, BIO_NOCLOSE|BIO_FP_TEXT); else if (BIO_read_filename(in,infile) <= 0) {
else if(BIO_read_filename(in, infile) <= 0) {
BIO_printf(p.errorbio, "Error opening input file %s\n", infile); BIO_printf(p.errorbio, "Error opening input file %s\n", infile);
BIO_free(in); BIO_free(in);
goto err; goto err;
@ -395,13 +363,12 @@ int main(int argc, char **argv)
/* set output */ /* set output */
if((out=BIO_new(BIO_s_file())) == NULL) { if ((out=BIO_new(BIO_s_file())) == NULL) {
BIO_printf(p.errorbio, "Error setting output bio.\n"); BIO_printf(p.errorbio, "Error setting output bio.\n");
goto err; goto err;
} } else if (outfile == NULL)
else if(outfile == NULL) BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
BIO_set_fp(out, stdout, BIO_NOCLOSE|BIO_FP_TEXT); else if (BIO_write_filename(out,outfile) <= 0) {
else if(BIO_write_filename(out, outfile) <= 0) {
BIO_printf(p.errorbio, "Error opening output file %s\n", outfile); BIO_printf(p.errorbio, "Error opening output file %s\n", outfile);
BIO_free(out); BIO_free(out);
goto err; goto err;
@ -410,66 +377,62 @@ int main(int argc, char **argv)
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE); p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
if(!(p.curl = curl_easy_init())) { if (!(p.curl = curl_easy_init())) {
BIO_printf(p.errorbio, "Cannot init curl lib\n"); BIO_printf(p.errorbio, "Cannot init curl lib\n");
goto err; goto err;
} }
if(!(p12bio = BIO_new_file(p.p12file , "rb"))) {
BIO_printf(p.errorbio, "Error opening P12 file %s\n", p.p12file);
goto err; if (!(p12bio = BIO_new_file(p.p12file , "rb"))) {
BIO_printf(p.errorbio, "Error opening P12 file %s\n", p.p12file); goto err;
} }
if(!(p.p12 = d2i_PKCS12_bio (p12bio, NULL))) { if (!(p.p12 = d2i_PKCS12_bio (p12bio, NULL))) {
BIO_printf(p.errorbio, "Cannot decode P12 structure %s\n", p.p12file); BIO_printf(p.errorbio, "Cannot decode P12 structure %s\n", p.p12file); goto err;
goto err;
} }
p.ca= NULL; p.ca= NULL;
if(!(PKCS12_parse (p.p12, p.pst, &(p.pkey), &(p.usercert), &(p.ca) ) )) { if (!(PKCS12_parse (p.p12, p.pst, &(p.pkey), &(p.usercert), &(p.ca) ) )) {
BIO_printf(p.errorbio, "Invalid P12 structure in %s\n", p.p12file); BIO_printf(p.errorbio,"Invalid P12 structure in %s\n", p.p12file); goto err;
goto err;
} }
if(sk_X509_num(p.ca) <= 0) { if (sk_X509_num(p.ca) <= 0) {
BIO_printf(p.errorbio, "No trustworthy CA given.%s\n", p.p12file); BIO_printf(p.errorbio,"No trustworthy CA given.%s\n", p.p12file); goto err;
goto err;
} }
if(p.verbose > 1) if (p.verbose > 1)
X509_print_ex(p.errorbio, p.usercert, 0, 0); X509_print_ex(p.errorbio,p.usercert,0,0);
/* determine URL to go */ /* determine URL to go */
if(hostporturl) { if (hostporturl) {
size_t len = strlen(hostporturl) + 9; serverurl = malloc(9+strlen(hostporturl));
serverurl = malloc(len); sprintf(serverurl,"https://%s",hostporturl);
snprintf(serverurl, len, "https://%s", hostporturl);
} }
else if(p.accesstype != 0) { /* see whether we can find an AIA or SIA for a else if (p.accesstype != 0) { /* see whether we can find an AIA or SIA for a given access type */
given access type */ if (!(serverurl = my_get_ext(p.usercert,p.accesstype,NID_info_access))) {
if(!(serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access))) {
int j=0; int j=0;
BIO_printf(p.errorbio, "no service URL in user cert " BIO_printf(p.errorbio,"no service URL in user cert "
"cherching in others certificats\n"); "cherching in others certificats\n");
for(j=0; j<sk_X509_num(p.ca); j++) { for (j=0;j<sk_X509_num(p.ca);j++) {
if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype, if ((serverurl = my_get_ext(sk_X509_value(p.ca,j),p.accesstype,
NID_info_access))) NID_info_access)))
break; break;
if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype, if ((serverurl = my_get_ext(sk_X509_value(p.ca,j),p.accesstype,
NID_sinfo_access))) NID_sinfo_access)))
break; break;
} }
} }
} }
if(!serverurl) { if (!serverurl) {
BIO_printf(p.errorbio, "no service URL in certificats," BIO_printf(p.errorbio, "no service URL in certificats,"
" check '-accesstype (AD_DVCS | ad_timestamping)'" " check '-accesstype (AD_DVCS | ad_timestamping)'"
" or use '-connect'\n"); " or use '-connect'\n");
goto err; goto err;
} }
if(p.verbose) if (p.verbose)
BIO_printf(p.errorbio, "Service URL: <%s>\n", serverurl); BIO_printf(p.errorbio, "Service URL: <%s>\n", serverurl);
curl_easy_setopt(p.curl, CURLOPT_URL, serverurl); curl_easy_setopt(p.curl, CURLOPT_URL, serverurl);
@ -477,39 +440,38 @@ int main(int argc, char **argv)
/* Now specify the POST binary data */ /* Now specify the POST binary data */
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDS, binaryptr); curl_easy_setopt(p.curl, CURLOPT_POSTFIELDS, binaryptr);
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDSIZE, (long)tabLength); curl_easy_setopt(p.curl, CURLOPT_POSTFIELDSIZE,(long)tabLength);
/* pass our list of custom made headers */ /* pass our list of custom made headers */
contenttype = malloc(15+strlen(mimetype)); contenttype = malloc(15+strlen(mimetype));
snprintf(contenttype, 15+strlen(mimetype), "Content-type: %s", mimetype); sprintf(contenttype,"Content-type: %s",mimetype);
headers = curl_slist_append(headers, contenttype); headers = curl_slist_append(headers,contenttype);
curl_easy_setopt(p.curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(p.curl, CURLOPT_HTTPHEADER, headers);
if(p.verbose) if (p.verbose)
BIO_printf(p.errorbio, "Service URL: <%s>\n", serverurl); BIO_printf(p.errorbio, "Service URL: <%s>\n", serverurl);
{ {
FILE *outfp; FILE *outfp;
BIO_get_fp(out, &outfp); BIO_get_fp(out,&outfp);
curl_easy_setopt(p.curl, CURLOPT_WRITEDATA, outfp); curl_easy_setopt(p.curl, CURLOPT_WRITEDATA, outfp);
} }
res = curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun); res = curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun) ;
if(res != CURLE_OK) if (res != CURLE_OK)
BIO_printf(p.errorbio, "%d %s=%d %d\n", __LINE__, BIO_printf(p.errorbio,"%d %s=%d %d\n", __LINE__, "CURLOPT_SSL_CTX_FUNCTION",CURLOPT_SSL_CTX_FUNCTION,res);
"CURLOPT_SSL_CTX_FUNCTION", CURLOPT_SSL_CTX_FUNCTION, res);
curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p); curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p);
{ {
int lu; int i=0; int lu; int i=0;
while((lu = BIO_read (in, &binaryptr[i], tabLength-i)) >0 ) { while ((lu = BIO_read (in,&binaryptr[i],tabLength-i)) >0 ) {
i+=lu; i+=lu;
if(i== tabLength) { if (i== tabLength) {
tabLength+=100; tabLength+=100;
binaryptr=realloc(binaryptr, tabLength); /* should be more careful */ binaryptr=realloc(binaryptr,tabLength); /* should be more careful */
} }
} }
tabLength = i; tabLength = i;
@ -517,23 +479,23 @@ int main(int argc, char **argv)
/* Now specify the POST binary data */ /* Now specify the POST binary data */
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDS, binaryptr); curl_easy_setopt(p.curl, CURLOPT_POSTFIELDS, binaryptr);
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDSIZE, (long)tabLength); curl_easy_setopt(p.curl, CURLOPT_POSTFIELDSIZE,(long)tabLength);
/* Perform the request, res will get the return code */ /* Perform the request, res will get the return code */
BIO_printf(p.errorbio, "%d %s %d\n", __LINE__, "curl_easy_perform", BIO_printf(p.errorbio,"%d %s %d\n", __LINE__, "curl_easy_perform",
res = curl_easy_perform(p.curl)); res = curl_easy_perform(p.curl));
{ {
int result =curl_easy_getinfo(p.curl, CURLINFO_CONTENT_TYPE, &response); int result =curl_easy_getinfo(p.curl,CURLINFO_CONTENT_TYPE,&response);
if(mimetypeaccept && p.verbose) if( mimetypeaccept && p.verbose)
if(!strcmp(mimetypeaccept, response)) if(!strcmp(mimetypeaccept,response))
BIO_printf(p.errorbio, "the response has a correct mimetype : %s\n", BIO_printf(p.errorbio,"the response has a correct mimetype : %s\n",
response); response);
else else
BIO_printf(p.errorbio, "the response doesn\'t have an acceptable " BIO_printf(p.errorbio,"the response doesn\'t have an acceptable "
"mime type, it is %s instead of %s\n", "mime type, it is %s instead of %s\n",
response, mimetypeaccept); response,mimetypeaccept);
} }
/*** code d'erreur si accept mime ***, egalement code return HTTP != 200 ***/ /*** code d'erreur si accept mime ***, egalement code return HTTP != 200 ***/
@ -549,6 +511,6 @@ int main(int argc, char **argv)
BIO_free(out); BIO_free(out);
return (EXIT_SUCCESS); return (EXIT_SUCCESS);
err: BIO_printf(p.errorbio, "error"); err: BIO_printf(p.errorbio,"error");
exit(1); exit(1);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -62,14 +62,14 @@ void dump(const char *text,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stream, "%c", fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -119,12 +119,12 @@ static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{ {
DPRINT("%s %li\n", __PRETTY_FUNCTION__, timeout_ms); DPRINT("%s %li\n", __PRETTY_FUNCTION__, timeout_ms);
ev_timer_stop(g->loop, &g->timer_event); ev_timer_stop(g->loop, &g->timer_event);
if(timeout_ms > 0) { if (timeout_ms > 0)
{
double t = timeout_ms / 1000; double t = timeout_ms / 1000;
ev_timer_init(&g->timer_event, timer_cb, t, 0.); ev_timer_init(&g->timer_event, timer_cb, t, 0.);
ev_timer_start(g->loop, &g->timer_event); ev_timer_start(g->loop, &g->timer_event);
} }else
else
timer_cb(g->loop, &g->timer_event, 0); timer_cb(g->loop, &g->timer_event, 0);
return 0; return 0;
} }
@ -132,32 +132,20 @@ static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
/* Die if we get a bad CURLMcode somewhere */ /* Die if we get a bad CURLMcode somewhere */
static void mcode_or_die(const char *where, CURLMcode code) static void mcode_or_die(const char *where, CURLMcode code)
{ {
if(CURLM_OK != code) { if ( CURLM_OK != code )
{
const char *s; const char *s;
switch (code) { switch ( code )
case CURLM_BAD_HANDLE: {
s="CURLM_BAD_HANDLE"; case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break;
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break;
case CURLM_LAST: s="CURLM_LAST"; break;
default: s="CURLM_unknown";
break; break;
case CURLM_BAD_EASY_HANDLE: case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET";
s="CURLM_BAD_EASY_HANDLE";
break;
case CURLM_OUT_OF_MEMORY:
s="CURLM_OUT_OF_MEMORY";
break;
case CURLM_INTERNAL_ERROR:
s="CURLM_INTERNAL_ERROR";
break;
case CURLM_UNKNOWN_OPTION:
s="CURLM_UNKNOWN_OPTION";
break;
case CURLM_LAST:
s="CURLM_LAST";
break;
default:
s="CURLM_unknown";
break;
case CURLM_BAD_SOCKET:
s="CURLM_BAD_SOCKET";
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s); fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
/* ignore this error */ /* ignore this error */
return; return;
@ -180,8 +168,8 @@ static void check_multi_info(GlobalInfo *g)
CURLcode res; CURLcode res;
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running); fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
while((msg = curl_multi_info_read(g->multi, &msgs_left))) { while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
if(msg->msg == CURLMSG_DONE) { if (msg->msg == CURLMSG_DONE) {
easy = msg->easy_handle; easy = msg->easy_handle;
res = msg->data.result; res = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn); curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
@ -209,7 +197,8 @@ static void event_cb(EV_P_ struct ev_io *w, int revents)
rc = curl_multi_socket_action(g->multi, w->fd, action, &g->still_running); rc = curl_multi_socket_action(g->multi, w->fd, action, &g->still_running);
mcode_or_die("event_cb: curl_multi_socket_action", rc); mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_multi_info(g); check_multi_info(g);
if(g->still_running <= 0) { if ( g->still_running <= 0 )
{
fprintf(MSG_OUT, "last transfer done, kill timeout\n"); fprintf(MSG_OUT, "last transfer done, kill timeout\n");
ev_timer_stop(g->loop, &g->timer_event); ev_timer_stop(g->loop, &g->timer_event);
} }
@ -223,8 +212,7 @@ static void timer_cb(EV_P_ struct ev_timer *w, int revents)
GlobalInfo *g = (GlobalInfo *)w->data; GlobalInfo *g = (GlobalInfo *)w->data;
CURLMcode rc; CURLMcode rc;
rc = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0, rc = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0, &g->still_running);
&g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", rc); mcode_or_die("timer_cb: curl_multi_socket_action", rc);
check_multi_info(g); check_multi_info(g);
} }
@ -233,8 +221,9 @@ static void timer_cb(EV_P_ struct ev_timer *w, int revents)
static void remsock(SockInfo *f, GlobalInfo *g) static void remsock(SockInfo *f, GlobalInfo *g)
{ {
printf("%s \n", __PRETTY_FUNCTION__); printf("%s \n", __PRETTY_FUNCTION__);
if(f) { if ( f )
if(f->evset) {
if ( f->evset )
ev_io_stop(g->loop, &f->ev); ev_io_stop(g->loop, &f->ev);
free(f); free(f);
} }
@ -252,7 +241,7 @@ static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
f->sockfd = s; f->sockfd = s;
f->action = act; f->action = act;
f->easy = e; f->easy = e;
if(f->evset) if ( f->evset )
ev_io_stop(g->loop, &f->ev); ev_io_stop(g->loop, &f->ev);
ev_io_init(&f->ev, event_cb, f->sockfd, kind); ev_io_init(&f->ev, event_cb, f->sockfd, kind);
f->ev.data = g; f->ev.data = g;
@ -284,16 +273,18 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
fprintf(MSG_OUT, fprintf(MSG_OUT,
"socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
if(what == CURL_POLL_REMOVE) { if ( what == CURL_POLL_REMOVE )
{
fprintf(MSG_OUT, "\n"); fprintf(MSG_OUT, "\n");
remsock(fdp, g); remsock(fdp, g);
} } else
else { {
if(!fdp) { if ( !fdp )
{
fprintf(MSG_OUT, "Adding data: %s\n", whatstr[what]); fprintf(MSG_OUT, "Adding data: %s\n", whatstr[what]);
addsock(s, e, what, g); addsock(s, e, what, g);
} } else
else { {
fprintf(MSG_OUT, fprintf(MSG_OUT,
"Changing action from %s to %s\n", "Changing action from %s to %s\n",
whatstr[fdp->action], whatstr[what]); whatstr[fdp->action], whatstr[what]);
@ -339,7 +330,8 @@ static void new_conn(char *url, GlobalInfo *g )
conn->error[0]='\0'; conn->error[0]='\0';
conn->easy = curl_easy_init(); conn->easy = curl_easy_init();
if(!conn->easy) { if ( !conn->easy )
{
fprintf(MSG_OUT, "curl_easy_init() failed, exiting!\n"); fprintf(MSG_OUT, "curl_easy_init() failed, exiting!\n");
exit(2); exit(2);
} }
@ -374,16 +366,16 @@ static void fifo_cb(EV_P_ struct ev_io *w, int revents)
int n=0; int n=0;
GlobalInfo *g = (GlobalInfo *)w->data; GlobalInfo *g = (GlobalInfo *)w->data;
do { do
{
s[0]='\0'; s[0]='\0';
rv=fscanf(g->input, "%1023s%n", s, &n); rv=fscanf(g->input, "%1023s%n", s, &n);
s[n]='\0'; s[n]='\0';
if(n && s[0]) { if ( n && s[0] )
new_conn(s, g); /* if we read a URL, go get it! */ {
} new_conn(s,g); /* if we read a URL, go get it! */
else } else break;
break; } while ( rv != EOF );
} while(rv != EOF);
} }
/* Create a named pipe and tell libevent to monitor it */ /* Create a named pipe and tell libevent to monitor it */
@ -394,20 +386,24 @@ static int init_fifo (GlobalInfo *g)
curl_socket_t sockfd; curl_socket_t sockfd;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo); fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
if(lstat (fifo, &st) == 0) { if ( lstat (fifo, &st) == 0 )
if((st.st_mode & S_IFMT) == S_IFREG) { {
if ( (st.st_mode & S_IFMT) == S_IFREG )
{
errno = EEXIST; errno = EEXIST;
perror("lstat"); perror("lstat");
exit (1); exit (1);
} }
} }
unlink(fifo); unlink(fifo);
if(mkfifo (fifo, 0600) == -1) { if ( mkfifo (fifo, 0600) == -1 )
{
perror("mkfifo"); perror("mkfifo");
exit (1); exit (1);
} }
sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0); sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0);
if(sockfd == -1) { if ( sockfd == -1 )
{
perror("open"); perror("open");
exit (1); exit (1);
} }
@ -416,7 +412,7 @@ static int init_fifo (GlobalInfo *g)
fprintf(MSG_OUT, "Now, pipe some URL's into > %s\n", fifo); fprintf(MSG_OUT, "Now, pipe some URL's into > %s\n", fifo);
ev_io_init(&g->fifo_event, fifo_cb, sockfd, EV_READ); ev_io_init(&g->fifo_event, fifo_cb, sockfd, EV_READ);
ev_io_start(g->loop, &g->fifo_event); ev_io_start(g->loop, &g->fifo_event);
return (0); return(0);
} }
int main(int argc, char **argv) int main(int argc, char **argv)

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -54,7 +54,7 @@
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream); int written = fwrite(ptr, size, nmemb, (FILE *)stream);
return written; return written;
} }
@ -92,7 +92,7 @@ int main(void)
WSADATA wsaData; WSADATA wsaData;
int initwsa; int initwsa;
if((initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0) { if((initwsa = WSAStartup(MAKEWORD(2,0), &wsaData)) != 0) {
printf("WSAStartup failed: %d\n", initwsa); printf("WSAStartup failed: %d\n", initwsa);
return 1; return 1;
} }
@ -107,7 +107,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
/* Create the socket "manually" */ /* Create the socket "manually" */
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD ) { if( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD ) {
printf("Error creating listening socket.\n"); printf("Error creating listening socket.\n");
return 3; return 3;
} }
@ -116,10 +116,10 @@ int main(void)
servaddr.sin_family = AF_INET; servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(PORTNUM); servaddr.sin_port = htons(PORTNUM);
if(INADDR_NONE == (servaddr.sin_addr.s_addr = inet_addr(IPADDR))) if (INADDR_NONE == (servaddr.sin_addr.s_addr = inet_addr(IPADDR)))
return 2; return 2;
if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) == if(connect(sockfd,(struct sockaddr *) &servaddr, sizeof(servaddr)) ==
-1) { -1) {
close(sockfd); close(sockfd);
printf("client error: connect: %s\n", strerror(errno)); printf("client error: connect: %s\n", strerror(errno));

View File

@ -80,7 +80,7 @@ struct fcurl_data
typedef struct fcurl_data URL_FILE; typedef struct fcurl_data URL_FILE;
/* exported functions */ /* exported functions */
URL_FILE *url_fopen(const char *url, const char *operation); URL_FILE *url_fopen(const char *url,const char *operation);
int url_fclose(URL_FILE *file); int url_fclose(URL_FILE *file);
int url_feof(URL_FILE *file); int url_feof(URL_FILE *file);
size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file); size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file);
@ -106,9 +106,9 @@ static size_t write_callback(char *buffer,
if(size > rembuff) { if(size > rembuff) {
/* not enough space in buffer */ /* not enough space in buffer */
newbuff=realloc(url->buffer, url->buffer_len + (size - rembuff)); newbuff=realloc(url->buffer,url->buffer_len + (size - rembuff));
if(newbuff==NULL) { if(newbuff==NULL) {
fprintf(stderr, "callback buffer grow failed\n"); fprintf(stderr,"callback buffer grow failed\n");
size=rembuff; size=rembuff;
} }
else { else {
@ -165,7 +165,8 @@ static int fill_buffer(URL_FILE *file, size_t want)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }
@ -229,7 +230,7 @@ static int use_buffer(URL_FILE *file, size_t want)
return 0; return 0;
} }
URL_FILE *url_fopen(const char *url, const char *operation) URL_FILE *url_fopen(const char *url,const char *operation)
{ {
/* this code could check for URLs or types in the 'url' and /* this code could check for URLs or types in the 'url' and
basically use the real fopen() for standard files */ basically use the real fopen() for standard files */
@ -243,7 +244,7 @@ URL_FILE *url_fopen(const char *url, const char *operation)
memset(file, 0, sizeof(URL_FILE)); memset(file, 0, sizeof(URL_FILE));
if((file->handle.file=fopen(url, operation))) if((file->handle.file=fopen(url,operation)))
file->type = CFTYPE_FILE; /* marked as URL */ file->type = CFTYPE_FILE; /* marked as URL */
else { else {
@ -337,13 +338,13 @@ size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file)
switch(file->type) { switch(file->type) {
case CFTYPE_FILE: case CFTYPE_FILE:
want=fread(ptr, size, nmemb, file->handle.file); want=fread(ptr,size,nmemb,file->handle.file);
break; break;
case CFTYPE_CURL: case CFTYPE_CURL:
want = nmemb * size; want = nmemb * size;
fill_buffer(file, want); fill_buffer(file,want);
/* check if theres data in the buffer - if not fill_buffer() /* check if theres data in the buffer - if not fill_buffer()
* either errored or EOF */ * either errored or EOF */
@ -357,7 +358,7 @@ size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file)
/* xfer data to caller */ /* xfer data to caller */
memcpy(ptr, file->buffer, want); memcpy(ptr, file->buffer, want);
use_buffer(file, want); use_buffer(file,want);
want = want / size; /* number of items */ want = want / size; /* number of items */
break; break;
@ -382,7 +383,7 @@ char *url_fgets(char *ptr, size_t size, URL_FILE *file)
break; break;
case CFTYPE_CURL: case CFTYPE_CURL:
fill_buffer(file, want); fill_buffer(file,want);
/* check if theres data in the buffer - if not fill either errored or /* check if theres data in the buffer - if not fill either errored or
* EOF */ * EOF */
@ -406,7 +407,7 @@ char *url_fgets(char *ptr, size_t size, URL_FILE *file)
memcpy(ptr, file->buffer, want); memcpy(ptr, file->buffer, want);
ptr[want]=0;/* allways null terminate */ ptr[want]=0;/* allways null terminate */
use_buffer(file, want); use_buffer(file,want);
break; break;
@ -446,10 +447,6 @@ void url_rewind(URL_FILE *file)
} }
} }
#define FGETSFILE "fgets.test"
#define FREADFILE "fread.test"
#define REWINDFILE "rewind.test"
/* Small main program to retrive from a url using fgets and fread saving the /* Small main program to retrive from a url using fgets and fread saving the
* output to two test files (note the fgets method will corrupt binary files if * output to two test files (note the fgets method will corrupt binary files if
* they contain 0 chars */ * they contain 0 chars */
@ -468,7 +465,7 @@ int main(int argc, char *argv[])
url=argv[1];/* use passed url */ url=argv[1];/* use passed url */
/* copy from url line by line with fgets */ /* copy from url line by line with fgets */
outf=fopen(FGETSFILE, "wb+"); outf=fopen("fgets.test","w+");
if(!outf) { if(!outf) {
perror("couldn't open fgets output file\n"); perror("couldn't open fgets output file\n");
return 1; return 1;
@ -482,8 +479,8 @@ int main(int argc, char *argv[])
} }
while(!url_feof(handle)) { while(!url_feof(handle)) {
url_fgets(buffer, sizeof(buffer), handle); url_fgets(buffer,sizeof(buffer),handle);
fwrite(buffer, 1, strlen(buffer), outf); fwrite(buffer,1,strlen(buffer),outf);
} }
url_fclose(handle); url_fclose(handle);
@ -492,7 +489,7 @@ int main(int argc, char *argv[])
/* Copy from url with fread */ /* Copy from url with fread */
outf=fopen(FREADFILE, "wb+"); outf=fopen("fread.test","w+");
if(!outf) { if(!outf) {
perror("couldn't open fread output file\n"); perror("couldn't open fread output file\n");
return 1; return 1;
@ -507,7 +504,7 @@ int main(int argc, char *argv[])
do { do {
nread = url_fread(buffer, 1, sizeof(buffer), handle); nread = url_fread(buffer, 1, sizeof(buffer), handle);
fwrite(buffer, 1, nread, outf); fwrite(buffer,1,nread,outf);
} while(nread); } while(nread);
url_fclose(handle); url_fclose(handle);
@ -516,7 +513,7 @@ int main(int argc, char *argv[])
/* Test rewind */ /* Test rewind */
outf=fopen(REWINDFILE, "wb+"); outf=fopen("rewind.test","w+");
if(!outf) { if(!outf) {
perror("couldn't open fread output file\n"); perror("couldn't open fread output file\n");
return 1; return 1;
@ -529,19 +526,21 @@ int main(int argc, char *argv[])
return 2; return 2;
} }
nread = url_fread(buffer, 1, sizeof(buffer), handle); nread = url_fread(buffer, 1,sizeof(buffer), handle);
fwrite(buffer, 1, nread, outf); fwrite(buffer,1,nread,outf);
url_rewind(handle); url_rewind(handle);
buffer[0]='\n'; buffer[0]='\n';
fwrite(buffer, 1, 1, outf); fwrite(buffer,1,1,outf);
nread = url_fread(buffer, 1,sizeof(buffer), handle);
fwrite(buffer,1,nread,outf);
nread = url_fread(buffer, 1, sizeof(buffer), handle);
fwrite(buffer, 1, nread, outf);
url_fclose(handle); url_fclose(handle);
fclose(outf); fclose(outf);
return 0;/* all done */ return 0;/* all done */
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -119,7 +119,7 @@ static long file_is_coming(struct curl_fileinfo *finfo,
return CURL_CHUNK_BGN_FUNC_SKIP; return CURL_CHUNK_BGN_FUNC_SKIP;
} }
data->output = fopen(finfo->filename, "wb"); data->output = fopen(finfo->filename, "w");
if(!data->output) { if(!data->output) {
return CURL_CHUNK_BGN_FUNC_FAIL; return CURL_CHUNK_BGN_FUNC_FAIL;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -63,7 +63,7 @@ int main(void)
* You better replace the URL with one that works! * You better replace the URL with one that works!
*/ */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL,
"ftp://ftp.example.com/curl/curl-7.9.2.tar.gz"); "ftp://ftp.example.com/pub/www/utilities/curl/curl-7.9.2.tar.gz");
/* Define our callback to get called when there's data to be written */ /* Define our callback to get called when there's data to be written */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
/* Set a pointer to our struct to pass to the callback */ /* Set a pointer to our struct to pass to the callback */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -71,12 +71,10 @@ int main(void)
time_t file_time = (time_t)filetime; time_t file_time = (time_t)filetime;
printf("filetime %s: %s", filename, ctime(&file_time)); printf("filetime %s: %s", filename, ctime(&file_time));
} }
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize);
&filesize);
if((CURLE_OK == res) && (filesize>0.0)) if((CURLE_OK == res) && (filesize>0.0))
printf("filesize %s: %0.0f bytes\n", filename, filesize); printf("filesize %s: %0.0f bytes\n", filename, filesize);
} } else {
else {
/* we failed */ /* we failed */
fprintf(stderr, "curl told us %d\n", res); fprintf(stderr, "curl told us %d\n", res);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -35,9 +35,6 @@ write_response(void *ptr, size_t size, size_t nmemb, void *data)
return fwrite(ptr, size, nmemb, writehere); return fwrite(ptr, size, nmemb, writehere);
} }
#define FTPBODY "ftp-list"
#define FTPHEADERS "ftp-responses"
int main(void) int main(void)
{ {
CURL *curl; CURL *curl;
@ -46,10 +43,10 @@ int main(void)
FILE *respfile; FILE *respfile;
/* local file name to store the file as */ /* local file name to store the file as */
ftpfile = fopen(FTPBODY, "wb"); /* b is binary, needed on win32 */ ftpfile = fopen("ftp-list", "wb"); /* b is binary, needed on win32 */
/* local file name to store the FTP server's response lines in */ /* local file name to store the FTP server's response lines in */
respfile = fopen(FTPHEADERS, "wb"); /* b is binary, needed on win32 */ respfile = fopen("ftp-responses", "wb"); /* b is binary, needed on win32 */
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if(curl) {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -104,7 +104,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */ /* specify target */
curl_easy_setopt(curl, CURLOPT_URL, REMOTE_URL); curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
/* pass in that last of FTP commands to run after the transfer */ /* pass in that last of FTP commands to run after the transfer */
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist); curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -36,8 +36,7 @@
/* The MinGW headers are missing a few Win32 function definitions, /* The MinGW headers are missing a few Win32 function definitions,
you shouldn't need this if you use VC++ */ you shouldn't need this if you use VC++ */
#if defined(__MINGW32__) && !defined(__MINGW64__) #if defined(__MINGW32__) && !defined(__MINGW64__)
int __cdecl _snscanf(const char * input, size_t length, int __cdecl _snscanf(const char * input, size_t length, const char * format, ...);
const char * format, ...);
#endif #endif
@ -50,7 +49,7 @@ size_t getcontentlengthfunc(void *ptr, size_t size, size_t nmemb, void *stream)
/* _snscanf() is Win32 specific */ /* _snscanf() is Win32 specific */
r = _snscanf(ptr, size * nmemb, "Content-Length: %ld\n", &len); r = _snscanf(ptr, size * nmemb, "Content-Length: %ld\n", &len);
if(r) /* Microsoft: we don't read the specs */ if (r) /* Microsoft: we don't read the specs */
*((long *) stream) = len; *((long *) stream) = len;
return size * nmemb; return size * nmemb;
@ -68,7 +67,7 @@ size_t readfunc(void *ptr, size_t size, size_t nmemb, void *stream)
FILE *f = stream; FILE *f = stream;
size_t n; size_t n;
if(ferror(f)) if (ferror(f))
return CURL_READFUNC_ABORT; return CURL_READFUNC_ABORT;
n = fread(ptr, size, nmemb, f) * size; n = fread(ptr, size, nmemb, f) * size;
@ -86,7 +85,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
int c; int c;
f = fopen(localpath, "rb"); f = fopen(localpath, "rb");
if(!f) { if (f == NULL) {
perror(NULL); perror(NULL);
return 0; return 0;
} }
@ -95,7 +94,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath); curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath);
if(timeout) if (timeout)
curl_easy_setopt(curlhandle, CURLOPT_FTP_RESPONSE_TIMEOUT, timeout); curl_easy_setopt(curlhandle, CURLOPT_FTP_RESPONSE_TIMEOUT, timeout);
curl_easy_setopt(curlhandle, CURLOPT_HEADERFUNCTION, getcontentlengthfunc); curl_easy_setopt(curlhandle, CURLOPT_HEADERFUNCTION, getcontentlengthfunc);
@ -106,15 +105,14 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc); curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc);
curl_easy_setopt(curlhandle, CURLOPT_READDATA, f); curl_easy_setopt(curlhandle, CURLOPT_READDATA, f);
/* disable passive mode */ curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); /* disable passive mode */
curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-");
curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1L);
for(c = 0; (r != CURLE_OK) && (c < tries); c++) { for (c = 0; (r != CURLE_OK) && (c < tries); c++) {
/* are we resuming? */ /* are we resuming? */
if(c) { /* yes */ if (c) { /* yes */
/* determine the length of the file already written */ /* determine the length of the file already written */
/* /*
@ -129,7 +127,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L); curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L);
r = curl_easy_perform(curlhandle); r = curl_easy_perform(curlhandle);
if(r != CURLE_OK) if (r != CURLE_OK)
continue; continue;
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 0L); curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 0L);
@ -148,7 +146,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
fclose(f); fclose(f);
if(r == CURLE_OK) if (r == CURLE_OK)
return 1; return 1;
else { else {
fprintf(stderr, "%s\n", curl_easy_strerror(r)); fprintf(stderr, "%s\n", curl_easy_strerror(r));
@ -163,8 +161,7 @@ int main(int c, char **argv)
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
curlhandle = curl_easy_init(); curlhandle = curl_easy_init();
upload(curlhandle, "ftp://user:pass@example.com/path/file", "C:\\file", upload(curlhandle, "ftp://user:pass@example.com/path/file", "C:\\file", 0, 3);
0, 3);
curl_easy_cleanup(curlhandle); curl_easy_cleanup(curlhandle);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,32 +28,33 @@
* *
* Written by Jeff Pohlmeyer * Written by Jeff Pohlmeyer
Requires glib-2.x and a (POSIX?) system that has mkfifo(). Requires glib-2.x and a (POSIX?) system that has mkfifo().
This is an adaptation of libcurl's "hipev.c" and libevent's "event-test.c" This is an adaptation of libcurl's "hipev.c" and libevent's "event-test.c"
sample programs, adapted to use glib's g_io_channel in place of libevent. sample programs, adapted to use glib's g_io_channel in place of libevent.
When running, the program creates the named pipe "hiper.fifo" When running, the program creates the named pipe "hiper.fifo"
Whenever there is input into the fifo, the program reads the input as a list Whenever there is input into the fifo, the program reads the input as a list
of URL's and creates some new easy handles to fetch each URL via the of URL's and creates some new easy handles to fetch each URL via the
curl_multi "hiper" API. curl_multi "hiper" API.
Thus, you can try a single URL: Thus, you can try a single URL:
% echo http://www.yahoo.com > hiper.fifo % echo http://www.yahoo.com > hiper.fifo
Or a whole bunch of them: Or a whole bunch of them:
% cat my-url-list > hiper.fifo % cat my-url-list > hiper.fifo
The fifo buffer is handled almost instantly, so you can even add more URL's The fifo buffer is handled almost instantly, so you can even add more URL's
while the previous requests are still being downloaded. while the previous requests are still being downloaded.
This is purely a demo app, all retrieved data is simply discarded by the write This is purely a demo app, all retrieved data is simply discarded by the write
callback. callback.
*/ */
#include <glib.h> #include <glib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@ -63,10 +64,13 @@
#include <errno.h> #include <errno.h>
#include <curl/curl.h> #include <curl/curl.h>
#define MSG_OUT g_print /* Change to "g_error" to write to stderr */ #define MSG_OUT g_print /* Change to "g_error" to write to stderr */
#define SHOW_VERBOSE 0 /* Set to non-zero for libcurl messages */ #define SHOW_VERBOSE 0 /* Set to non-zero for libcurl messages */
#define SHOW_PROGRESS 0 /* Set to non-zero to enable progress callback */ #define SHOW_PROGRESS 0 /* Set to non-zero to enable progress callback */
/* Global information, common to all connections */ /* Global information, common to all connections */
typedef struct _GlobalInfo { typedef struct _GlobalInfo {
CURLM *multi; CURLM *multi;
@ -74,6 +78,8 @@ typedef struct _GlobalInfo {
int still_running; int still_running;
} GlobalInfo; } GlobalInfo;
/* Information associated with a specific easy handle */ /* Information associated with a specific easy handle */
typedef struct _ConnInfo { typedef struct _ConnInfo {
CURL *easy; CURL *easy;
@ -82,6 +88,7 @@ typedef struct _ConnInfo {
char error[CURL_ERROR_SIZE]; char error[CURL_ERROR_SIZE];
} ConnInfo; } ConnInfo;
/* Information associated with a specific socket */ /* Information associated with a specific socket */
typedef struct _SockInfo { typedef struct _SockInfo {
curl_socket_t sockfd; curl_socket_t sockfd;
@ -93,25 +100,30 @@ typedef struct _SockInfo {
GlobalInfo *global; GlobalInfo *global;
} SockInfo; } SockInfo;
/* Die if we get a bad CURLMcode somewhere */ /* Die if we get a bad CURLMcode somewhere */
static void mcode_or_die(const char *where, CURLMcode code) { static void mcode_or_die(const char *where, CURLMcode code) {
if(CURLM_OK != code) { if ( CURLM_OK != code ) {
const char *s; const char *s;
switch (code) { switch (code) {
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break; case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break; case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break; case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break; case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break;
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET"; break; case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET"; break;
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break; case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break;
case CURLM_LAST: s="CURLM_LAST"; break; case CURLM_LAST: s="CURLM_LAST"; break;
default: s="CURLM_unknown"; default: s="CURLM_unknown";
} }
MSG_OUT("ERROR: %s returns %s\n", where, s); MSG_OUT("ERROR: %s returns %s\n", where, s);
exit(code); exit(code);
} }
} }
/* Check for completed transfers, and remove their easy handles */ /* Check for completed transfers, and remove their easy handles */
static void check_multi_info(GlobalInfo *g) static void check_multi_info(GlobalInfo *g)
{ {
@ -123,8 +135,8 @@ static void check_multi_info(GlobalInfo *g)
CURLcode res; CURLcode res;
MSG_OUT("REMAINING: %d\n", g->still_running); MSG_OUT("REMAINING: %d\n", g->still_running);
while((msg = curl_multi_info_read(g->multi, &msgs_left))) { while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
if(msg->msg == CURLMSG_DONE) { if (msg->msg == CURLMSG_DONE) {
easy = msg->easy_handle; easy = msg->easy_handle;
res = msg->data.result; res = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn); curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
@ -138,6 +150,8 @@ static void check_multi_info(GlobalInfo *g)
} }
} }
/* Called by glib when our timeout expires */ /* Called by glib when our timeout expires */
static gboolean timer_cb(gpointer data) static gboolean timer_cb(gpointer data)
{ {
@ -145,12 +159,14 @@ static gboolean timer_cb(gpointer data)
CURLMcode rc; CURLMcode rc;
rc = curl_multi_socket_action(g->multi, rc = curl_multi_socket_action(g->multi,
CURL_SOCKET_TIMEOUT, 0, &g->still_running); CURL_SOCKET_TIMEOUT, 0, &g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", rc); mcode_or_die("timer_cb: curl_multi_socket_action", rc);
check_multi_info(g); check_multi_info(g);
return FALSE; return FALSE;
} }
/* Update the event timer after curl_multi library calls */ /* Update the event timer after curl_multi library calls */
static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp) static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp)
{ {
@ -160,12 +176,15 @@ static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp)
timeout.tv_usec = (timeout_ms%1000)*1000; timeout.tv_usec = (timeout_ms%1000)*1000;
MSG_OUT("*** update_timeout_cb %ld => %ld:%ld ***\n", MSG_OUT("*** update_timeout_cb %ld => %ld:%ld ***\n",
timeout_ms, timeout.tv_sec, timeout.tv_usec); timeout_ms, timeout.tv_sec, timeout.tv_usec);
g->timer_event = g_timeout_add(timeout_ms, timer_cb, g); g->timer_event = g_timeout_add(timeout_ms, timer_cb, g);
return 0; return 0;
} }
/* Called by glib when we get action on a multi socket */ /* Called by glib when we get action on a multi socket */
static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data) static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
{ {
@ -183,43 +202,41 @@ static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
check_multi_info(g); check_multi_info(g);
if(g->still_running) { if(g->still_running) {
return TRUE; return TRUE;
} } else {
else {
MSG_OUT("last transfer done, kill timeout\n"); MSG_OUT("last transfer done, kill timeout\n");
if(g->timer_event) { if (g->timer_event) { g_source_remove(g->timer_event); }
g_source_remove(g->timer_event);
}
return FALSE; return FALSE;
} }
} }
/* Clean up the SockInfo structure */ /* Clean up the SockInfo structure */
static void remsock(SockInfo *f) static void remsock(SockInfo *f)
{ {
if(!f) { if (!f) { return; }
return; if (f->ev) { g_source_remove(f->ev); }
}
if(f->ev) {
g_source_remove(f->ev);
}
g_free(f); g_free(f);
} }
/* Assign information to a SockInfo structure */ /* Assign information to a SockInfo structure */
static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g) static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
{ {
GIOCondition kind = GIOCondition kind =
(act&CURL_POLL_IN?G_IO_IN:0)|(act&CURL_POLL_OUT?G_IO_OUT:0); (act&CURL_POLL_IN?G_IO_IN:0)|(act&CURL_POLL_OUT?G_IO_OUT:0);
f->sockfd = s; f->sockfd = s;
f->action = act; f->action = act;
f->easy = e; f->easy = e;
if(f->ev) { if (f->ev) { g_source_remove(f->ev); }
g_source_remove(f->ev); f->ev=g_io_add_watch(f->ch, kind, event_cb,g);
}
f->ev=g_io_add_watch(f->ch, kind, event_cb, g);
} }
/* Initialize a new SockInfo structure */ /* Initialize a new SockInfo structure */
static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g) static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g)
{ {
@ -231,6 +248,8 @@ static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g)
curl_multi_assign(g->multi, s, fdp); curl_multi_assign(g->multi, s, fdp);
} }
/* CURLMOPT_SOCKETFUNCTION */ /* CURLMOPT_SOCKETFUNCTION */
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{ {
@ -239,15 +258,14 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
static const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" }; static const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };
MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
if(what == CURL_POLL_REMOVE) { if (what == CURL_POLL_REMOVE) {
MSG_OUT("\n"); MSG_OUT("\n");
remsock(fdp); remsock(fdp);
} } else {
else { if (!fdp) {
if(!fdp) {
MSG_OUT("Adding data: %s%s\n", MSG_OUT("Adding data: %s%s\n",
what&CURL_POLL_IN?"READ":"", what&CURL_POLL_IN?"READ":"",
what&CURL_POLL_OUT?"WRITE":"" ); what&CURL_POLL_OUT?"WRITE":"" );
addsock(s, e, what, g); addsock(s, e, what, g);
} }
else { else {
@ -259,6 +277,8 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
return 0; return 0;
} }
/* CURLOPT_WRITEFUNCTION */ /* CURLOPT_WRITEFUNCTION */
static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data) static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
{ {
@ -269,15 +289,18 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
return realsize; return realsize;
} }
/* CURLOPT_PROGRESSFUNCTION */ /* CURLOPT_PROGRESSFUNCTION */
static int prog_cb (void *p, double dltotal, double dlnow, double ult, static int prog_cb (void *p, double dltotal, double dlnow, double ult, double uln)
double uln)
{ {
ConnInfo *conn = (ConnInfo *)p; ConnInfo *conn = (ConnInfo *)p;
MSG_OUT("Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal); MSG_OUT("Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
return 0; return 0;
} }
/* Create a new easy handle, and add it to the global curl_multi */ /* Create a new easy handle, and add it to the global curl_multi */
static void new_conn(char *url, GlobalInfo *g ) static void new_conn(char *url, GlobalInfo *g )
{ {
@ -285,9 +308,11 @@ static void new_conn(char *url, GlobalInfo *g )
CURLMcode rc; CURLMcode rc;
conn = g_malloc0(sizeof(ConnInfo)); conn = g_malloc0(sizeof(ConnInfo));
conn->error[0]='\0'; conn->error[0]='\0';
conn->easy = curl_easy_init(); conn->easy = curl_easy_init();
if(!conn->easy) { if (!conn->easy) {
MSG_OUT("curl_easy_init() failed, exiting!\n"); MSG_OUT("curl_easy_init() failed, exiting!\n");
exit(2); exit(2);
} }
@ -315,90 +340,93 @@ static void new_conn(char *url, GlobalInfo *g )
that the necessary socket_action() call will be called by this app */ that the necessary socket_action() call will be called by this app */
} }
/* This gets called by glib whenever data is received from the fifo */ /* This gets called by glib whenever data is received from the fifo */
static gboolean fifo_cb (GIOChannel *ch, GIOCondition condition, gpointer data) static gboolean fifo_cb (GIOChannel *ch, GIOCondition condition, gpointer data)
{ {
#define BUF_SIZE 1024 #define BUF_SIZE 1024
gsize len, tp; gsize len, tp;
gchar *buf, *tmp, *all=NULL; gchar *buf, *tmp, *all=NULL;
GIOStatus rv; GIOStatus rv;
do { do {
GError *err=NULL; GError *err=NULL;
rv = g_io_channel_read_line(ch, &buf, &len, &tp, &err); rv = g_io_channel_read_line (ch,&buf,&len,&tp,&err);
if(buf) { if ( buf ) {
if(tp) { if (tp) { buf[tp]='\0'; }
buf[tp]='\0'; new_conn(buf,(GlobalInfo*)data);
}
new_conn(buf, (GlobalInfo*)data);
g_free(buf); g_free(buf);
} } else {
else {
buf = g_malloc(BUF_SIZE+1); buf = g_malloc(BUF_SIZE+1);
while(TRUE) { while (TRUE) {
buf[BUF_SIZE]='\0'; buf[BUF_SIZE]='\0';
g_io_channel_read_chars(ch, buf, BUF_SIZE, &len, &err); g_io_channel_read_chars(ch,buf,BUF_SIZE,&len,&err);
if(len) { if (len) {
buf[len]='\0'; buf[len]='\0';
if(all) { if (all) {
tmp=all; tmp=all;
all=g_strdup_printf("%s%s", tmp, buf); all=g_strdup_printf("%s%s", tmp, buf);
g_free(tmp); g_free(tmp);
} } else {
else {
all = g_strdup(buf); all = g_strdup(buf);
} }
} } else {
else { break;
break;
} }
} }
if(all) { if (all) {
new_conn(all, (GlobalInfo*)data); new_conn(all,(GlobalInfo*)data);
g_free(all); g_free(all);
} }
g_free(buf); g_free(buf);
} }
if(err) { if ( err ) {
g_error("fifo_cb: %s", err->message); g_error("fifo_cb: %s", err->message);
g_free(err); g_free(err);
break; break;
} }
} while((len) && (rv == G_IO_STATUS_NORMAL)); } while ( (len) && (rv == G_IO_STATUS_NORMAL) );
return TRUE; return TRUE;
} }
int init_fifo(void) int init_fifo(void)
{ {
struct stat st; struct stat st;
const char *fifo = "hiper.fifo"; const char *fifo = "hiper.fifo";
int socket; int socket;
if(lstat (fifo, &st) == 0) { if (lstat (fifo, &st) == 0) {
if((st.st_mode & S_IFMT) == S_IFREG) { if ((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST; errno = EEXIST;
perror("lstat"); perror("lstat");
exit (1); exit (1);
}
} }
}
unlink (fifo); unlink (fifo);
if(mkfifo (fifo, 0600) == -1) { if (mkfifo (fifo, 0600) == -1) {
perror("mkfifo"); perror("mkfifo");
exit (1); exit (1);
} }
socket = open (fifo, O_RDWR | O_NONBLOCK, 0); socket = open (fifo, O_RDWR | O_NONBLOCK, 0);
if(socket == -1) { if (socket == -1) {
perror("open"); perror("open");
exit (1); exit (1);
} }
MSG_OUT("Now, pipe some URL's into > %s\n", fifo); MSG_OUT("Now, pipe some URL's into > %s\n", fifo);
return socket;
return socket;
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
GlobalInfo *g; GlobalInfo *g;
@ -410,8 +438,8 @@ int main(int argc, char **argv)
fd=init_fifo(); fd=init_fifo();
ch=g_io_channel_unix_new(fd); ch=g_io_channel_unix_new(fd);
g_io_add_watch(ch, G_IO_IN, fifo_cb, g); g_io_add_watch(ch,G_IO_IN,fifo_cb,g);
gmain=g_main_loop_new(NULL, FALSE); gmain=g_main_loop_new(NULL,FALSE);
g->multi = curl_multi_init(); g->multi = curl_multi_init();
curl_multi_setopt(g->multi, CURLMOPT_SOCKETFUNCTION, sock_cb); curl_multi_setopt(g->multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g); curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -126,7 +126,7 @@ static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
/* Die if we get a bad CURLMcode somewhere */ /* Die if we get a bad CURLMcode somewhere */
static void mcode_or_die(const char *where, CURLMcode code) static void mcode_or_die(const char *where, CURLMcode code)
{ {
if(CURLM_OK != code) { if ( CURLM_OK != code ) {
const char *s; const char *s;
switch (code) { switch (code) {
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break; case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
@ -160,8 +160,8 @@ static void check_multi_info(GlobalInfo *g)
CURLcode res; CURLcode res;
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running); fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
while((msg = curl_multi_info_read(g->multi, &msgs_left))) { while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
if(msg->msg == CURLMSG_DONE) { if (msg->msg == CURLMSG_DONE) {
easy = msg->easy_handle; easy = msg->easy_handle;
res = msg->data.result; res = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn); curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
@ -191,9 +191,9 @@ static void event_cb(int fd, short kind, void *userp)
mcode_or_die("event_cb: curl_multi_socket_action", rc); mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_multi_info(g); check_multi_info(g);
if(g->still_running <= 0 ) { if ( g->still_running <= 0 ) {
fprintf(MSG_OUT, "last transfer done, kill timeout\n"); fprintf(MSG_OUT, "last transfer done, kill timeout\n");
if(evtimer_pending(g->timer_event, NULL)) { if (evtimer_pending(g->timer_event, NULL)) {
evtimer_del(g->timer_event); evtimer_del(g->timer_event);
} }
} }
@ -220,8 +220,8 @@ static void timer_cb(int fd, short kind, void *userp)
/* Clean up the SockInfo structure */ /* Clean up the SockInfo structure */
static void remsock(SockInfo *f) static void remsock(SockInfo *f)
{ {
if(f) { if (f) {
if(f->evset) if (f->evset)
event_free(f->ev); event_free(f->ev);
free(f); free(f);
} }
@ -238,7 +238,7 @@ static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
f->sockfd = s; f->sockfd = s;
f->action = act; f->action = act;
f->easy = e; f->easy = e;
if(f->evset) if (f->evset)
event_free(f->ev); event_free(f->ev);
f->ev = event_new(g->evbase, f->sockfd, kind, event_cb, g); f->ev = event_new(g->evbase, f->sockfd, kind, event_cb, g);
f->evset = 1; f->evset = 1;
@ -266,12 +266,12 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
fprintf(MSG_OUT, fprintf(MSG_OUT,
"socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
if(what == CURL_POLL_REMOVE) { if (what == CURL_POLL_REMOVE) {
fprintf(MSG_OUT, "\n"); fprintf(MSG_OUT, "\n");
remsock(fdp); remsock(fdp);
} }
else { else {
if(!fdp) { if (!fdp) {
fprintf(MSG_OUT, "Adding data: %s\n", whatstr[what]); fprintf(MSG_OUT, "Adding data: %s\n", whatstr[what]);
addsock(s, e, what, g); addsock(s, e, what, g);
} }
@ -322,7 +322,7 @@ static void new_conn(char *url, GlobalInfo *g )
conn->error[0]='\0'; conn->error[0]='\0';
conn->easy = curl_easy_init(); conn->easy = curl_easy_init();
if(!conn->easy) { if (!conn->easy) {
fprintf(MSG_OUT, "curl_easy_init() failed, exiting!\n"); fprintf(MSG_OUT, "curl_easy_init() failed, exiting!\n");
exit(2); exit(2);
} }
@ -360,12 +360,10 @@ static void fifo_cb(int fd, short event, void *arg)
s[0]='\0'; s[0]='\0';
rv=fscanf(g->input, "%1023s%n", s, &n); rv=fscanf(g->input, "%1023s%n", s, &n);
s[n]='\0'; s[n]='\0';
if(n && s[0] ) { if ( n && s[0] ) {
new_conn(s, arg); /* if we read a URL, go get it! */ new_conn(s,arg); /* if we read a URL, go get it! */
} } else break;
else } while ( rv != EOF);
break;
} while(rv != EOF);
} }
/* Create a named pipe and tell libevent to monitor it */ /* Create a named pipe and tell libevent to monitor it */
@ -376,20 +374,20 @@ static int init_fifo (GlobalInfo *g)
curl_socket_t sockfd; curl_socket_t sockfd;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo); fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
if(lstat (fifo, &st) == 0) { if (lstat (fifo, &st) == 0) {
if((st.st_mode & S_IFMT) == S_IFREG) { if ((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST; errno = EEXIST;
perror("lstat"); perror("lstat");
exit (1); exit (1);
} }
} }
unlink(fifo); unlink(fifo);
if(mkfifo (fifo, 0600) == -1) { if (mkfifo (fifo, 0600) == -1) {
perror("mkfifo"); perror("mkfifo");
exit (1); exit (1);
} }
sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0); sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0);
if(sockfd == -1) { if (sockfd == -1) {
perror("open"); perror("open");
exit (1); exit (1);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -38,11 +38,11 @@ static size_t write_callback(void *buffer, size_t size, size_t nmemb,
void *hsp) void *hsp)
{ {
size_t realsize = size * nmemb, p; size_t realsize = size * nmemb, p;
for(p = 0; p < realsize; p++) { for (p = 0; p < realsize; p++) {
html_parser_char_parse(hsp, ((char *)buffer)[p]); html_parser_char_parse(hsp, ((char *)buffer)[p]);
if(html_parser_cmp_tag(hsp, "a", 1)) if (html_parser_cmp_tag(hsp, "a", 1))
if(html_parser_cmp_attr(hsp, "href", 4)) if (html_parser_cmp_attr(hsp, "href", 4))
if(html_parser_is_in(hsp, HTML_VALUE_ENDED)) { if (html_parser_is_in(hsp, HTML_VALUE_ENDED)) {
html_parser_val(hsp)[html_parser_val_length(hsp)] = '\0'; html_parser_val(hsp)[html_parser_val_length(hsp)] = '\0';
printf("%s\n", html_parser_val(hsp)); printf("%s\n", html_parser_val(hsp));
} }
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
CURL *curl; CURL *curl;
HTMLSTREAMPARSER *hsp; HTMLSTREAMPARSER *hsp;
if(argc != 2) { if (argc != 2) {
printf("Usage: %s URL\n", argv[0]); printf("Usage: %s URL\n", argv[0]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -38,21 +38,23 @@ uint write_cb(char *in, uint size, uint nmemb, TidyBuffer *out)
uint r; uint r;
r = size * nmemb; r = size * nmemb;
tidyBufAppend( out, in, r ); tidyBufAppend( out, in, r );
return r; return(r);
} }
/* Traverse the document tree */ /* Traverse the document tree */
void dumpNode(TidyDoc doc, TidyNode tnod, int indent ) void dumpNode(TidyDoc doc, TidyNode tnod, int indent )
{ {
TidyNode child; TidyNode child;
for(child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) { for ( child = tidyGetChild(tnod); child; child = tidyGetNext(child) )
{
ctmbstr name = tidyNodeGetName( child ); ctmbstr name = tidyNodeGetName( child );
if(name) { if ( name )
{
/* if it has a name, then it's an HTML tag ... */ /* if it has a name, then it's an HTML tag ... */
TidyAttr attr; TidyAttr attr;
printf( "%*.*s%s ", indent, indent, "<", name); printf( "%*.*s%s ", indent, indent, "<", name);
/* walk the attribute list */ /* walk the attribute list */
for(attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) { for ( attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) {
printf(tidyAttrName(attr)); printf(tidyAttrName(attr));
tidyAttrValue(attr)?printf("=\"%s\" ", tidyAttrValue(attr)?printf("=\"%s\" ",
tidyAttrValue(attr)):printf(" "); tidyAttrValue(attr)):printf(" ");
@ -80,7 +82,7 @@ int main(int argc, char **argv )
TidyBuffer docbuf = {0}; TidyBuffer docbuf = {0};
TidyBuffer tidy_errbuf = {0}; TidyBuffer tidy_errbuf = {0};
int err; int err;
if(argc == 2) { if ( argc == 2) {
curl = curl_easy_init(); curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, argv[1]); curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errbuf); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errbuf);
@ -96,13 +98,13 @@ int main(int argc, char **argv )
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf);
err=curl_easy_perform(curl); err=curl_easy_perform(curl);
if(!err) { if ( !err ) {
err = tidyParseBuffer(tdoc, &docbuf); /* parse the input */ err = tidyParseBuffer(tdoc, &docbuf); /* parse the input */
if(err >= 0) { if ( err >= 0 ) {
err = tidyCleanAndRepair(tdoc); /* fix any problems */ err = tidyCleanAndRepair(tdoc); /* fix any problems */
if(err >= 0) { if ( err >= 0 ) {
err = tidyRunDiagnostics(tdoc); /* load tidy error buffer */ err = tidyRunDiagnostics(tdoc); /* load tidy error buffer */
if(err >= 0) { if ( err >= 0 ) {
dumpNode( tdoc, tidyGetRoot(tdoc), 0 ); /* walk the tree */ dumpNode( tdoc, tidyGetRoot(tdoc), 0 ); /* walk the tree */
fprintf(stderr, "%s\n", tidy_errbuf.bp); /* show errors */ fprintf(stderr, "%s\n", tidy_errbuf.bp); /* show errors */
} }
@ -117,11 +119,11 @@ int main(int argc, char **argv )
tidyBufFree(&docbuf); tidyBufFree(&docbuf);
tidyBufFree(&tidy_errbuf); tidyBufFree(&tidy_errbuf);
tidyRelease(tdoc); tidyRelease(tdoc);
return err; return(err);
} }
else else
printf( "usage: %s <url>\n", argv[0] ); printf( "usage: %s <url>\n", argv[0] );
return 0; return(0);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -89,14 +89,14 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stderr, "%c", fprintf(stderr, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -149,7 +149,7 @@ static void setup(CURL *hnd, int num)
FILE *out; FILE *out;
char filename[128]; char filename[128];
snprintf(filename, 128, "dl-%d", num); sprintf(filename, "dl-%d", num);
out = fopen(filename, "wb"); out = fopen(filename, "wb");
@ -244,7 +244,8 @@ int main(int argc, char **argv)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -69,14 +69,14 @@ void dump(const char *text, unsigned char *ptr, size_t size,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stderr, "%c", fprintf(stderr, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -123,11 +123,9 @@ int my_trace(CURL *handle, curl_infotype type,
return 0; return 0;
} }
#define OUTPUTFILE "dl"
static void setup(CURL *hnd) static void setup(CURL *hnd)
{ {
FILE *out = fopen(OUTPUTFILE, "wb"); FILE *out = fopen("dl", "wb");
/* write to this file */ /* write to this file */
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, out); curl_easy_setopt(hnd, CURLOPT_WRITEDATA, out);
@ -169,7 +167,7 @@ static int server_push_callback(CURL *parent,
(void)parent; /* we have no use for this */ (void)parent; /* we have no use for this */
snprintf(filename, 128, "push%u", count++); sprintf(filename, "push%u", count++);
/* here's a new stream, save it in a new file for each new push */ /* here's a new stream, save it in a new file for each new push */
out = fopen(filename, "wb"); out = fopen(filename, "wb");

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -90,14 +90,14 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stderr, "%c", fprintf(stderr, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -187,10 +187,10 @@ static void setup(CURL *hnd, int num, const char *upload)
struct stat file_info; struct stat file_info;
curl_off_t uploadsize; curl_off_t uploadsize;
snprintf(filename, 128, "dl-%d", num); sprintf(filename, "dl-%d", num);
out = fopen(filename, "wb"); out = fopen(filename, "wb");
snprintf(url, 256, "https://localhost:8443/upload-%d", num); sprintf(url, "https://localhost:8443/upload-%d", num);
/* get the file size of the local file */ /* get the file size of the local file */
stat(upload, &file_info); stat(upload, &file_info);
@ -308,7 +308,8 @@ int main(int argc, char **argv)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -60,7 +60,7 @@ int main(int argc, char **argv)
{ {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
FILE * hd_src; FILE * hd_src ;
struct stat file_info; struct stat file_info;
char *file; char *file;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -44,8 +44,7 @@ static const char *payload_text[] = {
"To: " TO "\r\n", "To: " TO "\r\n",
"From: " FROM "(Example User)\r\n", "From: " FROM "(Example User)\r\n",
"Cc: " CC "(Another example User)\r\n", "Cc: " CC "(Another example User)\r\n",
"Message-ID: " "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
"<dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
"Subject: IMAP example message\r\n", "Subject: IMAP example message\r\n",
"\r\n", /* empty line to divide headers from body, see RFC5322 */ "\r\n", /* empty line to divide headers from body, see RFC5322 */
"The body of the message starts here.\r\n", "The body of the message starts here.\r\n",

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -46,8 +46,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will fetch message 1 from the user's inbox */ /* This will fetch message 1 from the user's inbox */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
"imap://imap.example.com/INBOX/;UID=1");
/* Perform the fetch */ /* Perform the fetch */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -120,7 +120,8 @@ int main(void)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -48,8 +48,7 @@ int main(void)
/* This will fetch message 1 from the user's inbox. Note the use of /* This will fetch message 1 from the user's inbox. Note the use of
* imaps:// rather than imap:// to request a SSL based connection. */ * imaps:// rather than imap:// to request a SSL based connection. */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL, "imaps://imap.example.com/INBOX/;UID=1");
"imaps://imap.example.com/INBOX/;UID=1");
/* If you want to connect to a site who isn't using a certificate that is /* If you want to connect to a site who isn't using a certificate that is
* signed by one of the certs in the CA bundle you have, you can skip the * signed by one of the certs in the CA bundle you have, you can skip the

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -47,8 +47,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will fetch message 1 from the user's inbox */ /* This will fetch message 1 from the user's inbox */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
"imap://imap.example.com/INBOX/;UID=1");
/* In this example, we'll start with a plain text connection, and upgrade /* In this example, we'll start with a plain text connection, and upgrade
* to Transport Layer Security (TLS) using the STARTTLS command. Be careful * to Transport Layer Security (TLS) using the STARTTLS command. Be careful
@ -62,13 +61,12 @@ int main(void)
* CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false). * CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false).
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
*
* That is, in general, a bad idea. It is still better than sending your * That is, in general, a bad idea. It is still better than sending your
* authentication details in plain text though. Instead, you should get * authentication details in plain text though.
* the issuer certificate (or the host certificate if the certificate is * Instead, you should get the issuer certificate (or the host certificate
* self-signed) and add it to the set of certificates that are known to * if the certificate is self-signed) and add it to the set of certificates
* libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See docs/SSLCERTS * that are known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See
* for more information. */ * docs/SSLCERTS for more information. */
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
/* Since the traffic will be encrypted, it is very useful to turn on debug /* Since the traffic will be encrypted, it is very useful to turn on debug

View File

@ -55,8 +55,8 @@ int main(void)
int msgs_left; /* how many messages are left */ int msgs_left; /* how many messages are left */
/* Allocate one CURL handle per transfer */ /* Allocate one CURL handle per transfer */
for(i=0; i<HANDLECOUNT; i++) for (i=0; i<HANDLECOUNT; i++)
handles[i] = curl_easy_init(); handles[i] = curl_easy_init();
/* set the options (I left out a few, you'll get the point anyway) */ /* set the options (I left out a few, you'll get the point anyway) */
curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "http://example.com"); curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "http://example.com");
@ -68,8 +68,8 @@ int main(void)
multi_handle = curl_multi_init(); multi_handle = curl_multi_init();
/* add the individual transfers */ /* add the individual transfers */
for(i=0; i<HANDLECOUNT; i++) for (i=0; i<HANDLECOUNT; i++)
curl_multi_add_handle(multi_handle, handles[i]); curl_multi_add_handle(multi_handle, handles[i]);
/* we start some action by calling perform right away */ /* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running); curl_multi_perform(multi_handle, &still_running);
@ -106,7 +106,8 @@ int main(void)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }
@ -145,12 +146,12 @@ int main(void)
} while(still_running); } while(still_running);
/* See how the transfers went */ /* See how the transfers went */
while((msg = curl_multi_info_read(multi_handle, &msgs_left))) { while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
if(msg->msg == CURLMSG_DONE) { if (msg->msg == CURLMSG_DONE) {
int idx, found = 0; int idx, found = 0;
/* Find out which handle this message is about */ /* Find out which handle this message is about */
for(idx=0; idx<HANDLECOUNT; idx++) { for (idx=0; idx<HANDLECOUNT; idx++) {
found = (msg->easy_handle == handles[idx]); found = (msg->easy_handle == handles[idx]);
if(found) if(found)
break; break;
@ -170,8 +171,8 @@ int main(void)
curl_multi_cleanup(multi_handle); curl_multi_cleanup(multi_handle);
/* Free the CURL handles */ /* Free the CURL handles */
for(i=0; i<HANDLECOUNT; i++) for (i=0; i<HANDLECOUNT; i++)
curl_easy_cleanup(handles[i]); curl_easy_cleanup(handles[i]);
return 0; return 0;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -69,14 +69,14 @@ void dump(const char *text,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stream, "%c", fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -179,7 +179,8 @@ int main(void)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -95,7 +95,8 @@ int main(void)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -115,7 +115,8 @@ int main(void)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -77,7 +77,8 @@ int main(void)
/* wait for activity, timeout or "nothing" */ /* wait for activity, timeout or "nothing" */
mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds); mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_wait() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_wait() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -84,9 +84,9 @@ void add_download(const char *url, int num)
FILE *file; FILE *file;
CURL *handle; CURL *handle;
snprintf(filename, 50, "%d.download", num); sprintf(filename, "%d.download", num);
file = fopen(filename, "wb"); file = fopen(filename, "w");
if(!file) { if(!file) {
fprintf(stderr, "Error opening %s\n", filename); fprintf(stderr, "Error opening %s\n", filename);
return; return;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -42,19 +42,19 @@
#define THREAD_ID pthread_self( ) #define THREAD_ID pthread_self( )
void handle_error(const char *file, int lineno, const char *msg) void handle_error(const char *file, int lineno, const char *msg){
{ fprintf(stderr, "** %s:%d %s\n", file, lineno, msg);
fprintf(stderr, "** %s:%d %s\n", file, lineno, msg); ERR_print_errors_fp(stderr);
ERR_print_errors_fp(stderr); /* exit(-1); */
/* exit(-1); */ }
}
/* This array will store all of the mutexes available to OpenSSL. */ /* This array will store all of the mutexes available to OpenSSL. */
static MUTEX_TYPE *mutex_buf= NULL; static MUTEX_TYPE *mutex_buf= NULL;
static void locking_function(int mode, int n, const char * file, int line) static void locking_function(int mode, int n, const char * file, int line)
{ {
if(mode & CRYPTO_LOCK) if (mode & CRYPTO_LOCK)
MUTEX_LOCK(mutex_buf[n]); MUTEX_LOCK(mutex_buf[n]);
else else
MUTEX_UNLOCK(mutex_buf[n]); MUTEX_UNLOCK(mutex_buf[n]);
@ -70,9 +70,9 @@ int thread_setup(void)
int i; int i;
mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(MUTEX_TYPE)); mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(MUTEX_TYPE));
if(!mutex_buf) if (!mutex_buf)
return 0; return 0;
for(i = 0; i < CRYPTO_num_locks( ); i++) for (i = 0; i < CRYPTO_num_locks( ); i++)
MUTEX_SETUP(mutex_buf[i]); MUTEX_SETUP(mutex_buf[i]);
CRYPTO_set_id_callback(id_function); CRYPTO_set_id_callback(id_function);
CRYPTO_set_locking_callback(locking_function); CRYPTO_set_locking_callback(locking_function);
@ -83,11 +83,11 @@ int thread_cleanup(void)
{ {
int i; int i;
if(!mutex_buf) if (!mutex_buf)
return 0; return 0;
CRYPTO_set_id_callback(NULL); CRYPTO_set_id_callback(NULL);
CRYPTO_set_locking_callback(NULL); CRYPTO_set_locking_callback(NULL);
for(i = 0; i < CRYPTO_num_locks( ); i++) for (i = 0; i < CRYPTO_num_locks( ); i++)
MUTEX_CLEANUP(mutex_buf[i]); MUTEX_CLEANUP(mutex_buf[i]);
free(mutex_buf); free(mutex_buf);
mutex_buf = NULL; mutex_buf = NULL;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -120,7 +120,8 @@ int main(void)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -61,13 +61,12 @@ int main(void)
* CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false). * CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false).
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
*
* That is, in general, a bad idea. It is still better than sending your * That is, in general, a bad idea. It is still better than sending your
* authentication details in plain text though. Instead, you should get * authentication details in plain text though.
* the issuer certificate (or the host certificate if the certificate is * Instead, you should get the issuer certificate (or the host certificate
* self-signed) and add it to the set of certificates that are known to * if the certificate is self-signed) and add it to the set of certificates
* libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See docs/SSLCERTS * that are known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See
* for more information. */ * docs/SSLCERTS for more information. */
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
/* Since the traffic will be encrypted, it is very useful to turn on debug /* Since the traffic will be encrypted, it is very useful to turn on debug

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
if(curl) { if(curl) {
/* what URL that receives this POST */ /* what URL that receives this POST */
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/examplepost.cgi"); curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/examplepost.cgi");
if((argc == 2) && (!strcmp(argv[1], "noexpectheader"))) if ( (argc == 2) && (!strcmp(argv[1], "noexpectheader")) )
/* only disable 100-continue header if explicitly requested */ /* only disable 100-continue header if explicitly requested */
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);

View File

@ -62,12 +62,12 @@ static int _getch(void)
/* error handling macros */ /* error handling macros */
#define my_curl_easy_setopt(A, B, C) \ #define my_curl_easy_setopt(A, B, C) \
if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \ if ((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \
fprintf(stderr, "curl_easy_setopt(%s, %s, %s) failed: %d\n", \ fprintf(stderr, "curl_easy_setopt(%s, %s, %s) failed: %d\n", \
#A, #B, #C, res); #A, #B, #C, res);
#define my_curl_easy_perform(A) \ #define my_curl_easy_perform(A) \
if((res = curl_easy_perform((A))) != CURLE_OK) \ if ((res = curl_easy_perform((A))) != CURLE_OK) \
fprintf(stderr, "curl_easy_perform(%s) failed: %d\n", #A, res); fprintf(stderr, "curl_easy_perform(%s) failed: %d\n", #A, res);
@ -87,9 +87,9 @@ static void rtsp_describe(CURL *curl, const char *uri,
const char *sdp_filename) const char *sdp_filename)
{ {
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
FILE *sdp_fp = fopen(sdp_filename, "wb"); FILE *sdp_fp = fopen(sdp_filename, "wt");
printf("\nRTSP: DESCRIBE %s\n", uri); printf("\nRTSP: DESCRIBE %s\n", uri);
if(sdp_fp == NULL) { if (sdp_fp == NULL) {
fprintf(stderr, "Could not open '%s' for writing\n", sdp_filename); fprintf(stderr, "Could not open '%s' for writing\n", sdp_filename);
sdp_fp = stdout; sdp_fp = stdout;
} }
@ -100,7 +100,7 @@ static void rtsp_describe(CURL *curl, const char *uri,
my_curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_DESCRIBE); my_curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_DESCRIBE);
my_curl_easy_perform(curl); my_curl_easy_perform(curl);
my_curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); my_curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
if(sdp_fp != stdout) { if (sdp_fp != stdout) {
fclose(sdp_fp); fclose(sdp_fp);
} }
} }
@ -141,15 +141,14 @@ static void rtsp_teardown(CURL *curl, const char *uri)
/* convert url into an sdp filename */ /* convert url into an sdp filename */
static void get_sdp_filename(const char *url, char *sdp_filename, static void get_sdp_filename(const char *url, char *sdp_filename)
size_t namelen)
{ {
const char *s = strrchr(url, '/'); const char *s = strrchr(url, '/');
strcpy(sdp_filename, "video.sdp"); strcpy(sdp_filename, "video.sdp");
if(s != NULL) { if (s != NULL) {
s++; s++;
if(s[0] != '\0') { if (s[0] != '\0') {
snprintf(sdp_filename, namelen, "%s.sdp", s); sprintf(sdp_filename, "%s.sdp", s);
} }
} }
} }
@ -161,10 +160,10 @@ static void get_media_control_attribute(const char *sdp_filename,
{ {
int max_len = 256; int max_len = 256;
char *s = malloc(max_len); char *s = malloc(max_len);
FILE *sdp_fp = fopen(sdp_filename, "rb"); FILE *sdp_fp = fopen(sdp_filename, "rt");
control[0] = '\0'; control[0] = '\0';
if(sdp_fp != NULL) { if (sdp_fp != NULL) {
while(fgets(s, max_len - 2, sdp_fp) != NULL) { while (fgets(s, max_len - 2, sdp_fp) != NULL) {
sscanf(s, " a = control: %s", control); sscanf(s, " a = control: %s", control);
} }
fclose(sdp_fp); fclose(sdp_fp);
@ -179,8 +178,7 @@ int main(int argc, char * const argv[])
#if 1 #if 1
const char *transport = "RTP/AVP;unicast;client_port=1234-1235"; /* UDP */ const char *transport = "RTP/AVP;unicast;client_port=1234-1235"; /* UDP */
#else #else
/* TCP */ const char *transport = "RTP/AVP/TCP;unicast;client_port=1234-1235"; /* TCP */
const char *transport = "RTP/AVP/TCP;unicast;client_port=1234-1235";
#endif #endif
const char *range = "0.000-"; const char *range = "0.000-";
int rc = EXIT_SUCCESS; int rc = EXIT_SUCCESS;
@ -191,53 +189,50 @@ int main(int argc, char * const argv[])
printf(" Requires cURL V7.20 or greater\n\n"); printf(" Requires cURL V7.20 or greater\n\n");
/* check command line */ /* check command line */
if((argc != 2) && (argc != 3)) { if ((argc != 2) && (argc != 3)) {
base_name = strrchr(argv[0], '/'); base_name = strrchr(argv[0], '/');
if(base_name == NULL) { if (base_name == NULL) {
base_name = strrchr(argv[0], '\\'); base_name = strrchr(argv[0], '\\');
} }
if(base_name == NULL) { if (base_name == NULL) {
base_name = argv[0]; base_name = argv[0];
} } else {
else {
base_name++; base_name++;
} }
printf("Usage: %s url [transport]\n", base_name); printf("Usage: %s url [transport]\n", base_name);
printf(" url of video server\n"); printf(" url of video server\n");
printf(" transport (optional) specifier for media stream" printf(" transport (optional) specifier for media stream protocol\n");
" protocol\n");
printf(" default transport: %s\n", transport); printf(" default transport: %s\n", transport);
printf("Example: %s rtsp://192.168.0.2/media/video1\n\n", base_name); printf("Example: %s rtsp://192.168.0.2/media/video1\n\n", base_name);
rc = EXIT_FAILURE; rc = EXIT_FAILURE;
} } else {
else {
const char *url = argv[1]; const char *url = argv[1];
char *uri = malloc(strlen(url) + 32); char *uri = malloc(strlen(url) + 32);
char *sdp_filename = malloc(strlen(url) + 32); char *sdp_filename = malloc(strlen(url) + 32);
char *control = malloc(strlen(url) + 32); char *control = malloc(strlen(url) + 32);
CURLcode res; CURLcode res;
get_sdp_filename(url, sdp_filename, strlen(url) + 32); get_sdp_filename(url, sdp_filename);
if(argc == 3) { if (argc == 3) {
transport = argv[2]; transport = argv[2];
} }
/* initialize curl */ /* initialize curl */
res = curl_global_init(CURL_GLOBAL_ALL); res = curl_global_init(CURL_GLOBAL_ALL);
if(res == CURLE_OK) { if (res == CURLE_OK) {
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
CURL *curl; CURL *curl;
fprintf(stderr, " cURL V%s loaded\n", data->version); fprintf(stderr, " cURL V%s loaded\n", data->version);
/* initialize this curl session */ /* initialize this curl session */
curl = curl_easy_init(); curl = curl_easy_init();
if(curl != NULL) { if (curl != NULL) {
my_curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); my_curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
my_curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); my_curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
my_curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); my_curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);
my_curl_easy_setopt(curl, CURLOPT_URL, url); my_curl_easy_setopt(curl, CURLOPT_URL, url);
/* request server options */ /* request server options */
snprintf(uri, strlen(url) + 32, "%s", url); sprintf(uri, "%s", url);
rtsp_options(curl, uri); rtsp_options(curl, uri);
/* request session description and write response to sdp file */ /* request session description and write response to sdp file */
@ -247,11 +242,11 @@ int main(int argc, char * const argv[])
get_media_control_attribute(sdp_filename, control); get_media_control_attribute(sdp_filename, control);
/* setup media stream */ /* setup media stream */
snprintf(uri, strlen(url) + 32, "%s/%s", url, control); sprintf(uri, "%s/%s", url, control);
rtsp_setup(curl, uri, transport); rtsp_setup(curl, uri, transport);
/* start playing media stream */ /* start playing media stream */
snprintf(uri, strlen(url) + 32, "%s/", url); sprintf(uri, "%s/", url);
rtsp_play(curl, uri, range); rtsp_play(curl, uri, range);
printf("Playing video, press any key to stop ..."); printf("Playing video, press any key to stop ...");
_getch(); _getch();
@ -263,13 +258,11 @@ int main(int argc, char * const argv[])
/* cleanup */ /* cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl = NULL; curl = NULL;
} } else {
else {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
} }
curl_global_cleanup(); curl_global_cleanup();
} } else {
else {
fprintf(stderr, "curl_global_init(%s) failed: %d\n", fprintf(stderr, "curl_global_init(%s) failed: %d\n",
"CURL_GLOBAL_ALL", res); "CURL_GLOBAL_ALL", res);
} }

View File

@ -49,11 +49,10 @@ CURLcode my_conv_from_ascii_to_ebcdic(char *buffer, size_t length)
int rc; int rc;
tempptrin = tempptrout = buffer; tempptrin = tempptrout = buffer;
rc = platform_a2e(&tempptrin, &bytes, &tempptrout, &bytes); rc = platform_a2e(&tempptrin, &bytes, &tempptrout, &bytes);
if(rc == PLATFORM_CONV_OK) { if (rc == PLATFORM_CONV_OK) {
return CURLE_OK; return(CURLE_OK);
} } else {
else { return(CURLE_CONV_FAILED);
return CURLE_CONV_FAILED;
} }
} }
@ -64,11 +63,10 @@ CURLcode my_conv_from_ebcdic_to_ascii(char *buffer, size_t length)
int rc; int rc;
tempptrin = tempptrout = buffer; tempptrin = tempptrout = buffer;
rc = platform_e2a(&tempptrin, &bytes, &tempptrout, &bytes); rc = platform_e2a(&tempptrin, &bytes, &tempptrout, &bytes);
if(rc == PLATFORM_CONV_OK) { if (rc == PLATFORM_CONV_OK) {
return CURLE_OK; return(CURLE_OK);
} } else {
else { return(CURLE_CONV_FAILED);
return CURLE_CONV_FAILED;
} }
} }
@ -79,11 +77,10 @@ CURLcode my_conv_from_utf8_to_ebcdic(char *buffer, size_t length)
int rc; int rc;
tempptrin = tempptrout = buffer; tempptrin = tempptrout = buffer;
rc = platform_u2e(&tempptrin, &bytes, &tempptrout, &bytes); rc = platform_u2e(&tempptrin, &bytes, &tempptrout, &bytes);
if(rc == PLATFORM_CONV_OK) { if (rc == PLATFORM_CONV_OK) {
return CURLE_OK; return(CURLE_OK);
} } else {
else { return(CURLE_CONV_FAILED);
return CURLE_CONV_FAILED;
} }
} }

View File

@ -44,10 +44,12 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
FD_SET(sockfd, &errfd); /* always check for error */ FD_SET(sockfd, &errfd); /* always check for error */
if(for_recv) { if(for_recv)
{
FD_SET(sockfd, &infd); FD_SET(sockfd, &infd);
} }
else { else
{
FD_SET(sockfd, &outfd); FD_SET(sockfd, &outfd);
} }
@ -82,7 +84,8 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(CURLE_OK != res) { if(CURLE_OK != res)
{
printf("Error: %s\n", strerror(res)); printf("Error: %s\n", strerror(res));
return 1; return 1;
} }
@ -93,15 +96,17 @@ int main(void)
*/ */
res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockextr); res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockextr);
if(CURLE_OK != res) { if(CURLE_OK != res)
{
printf("Error: %s\n", curl_easy_strerror(res)); printf("Error: %s\n", curl_easy_strerror(res));
return 1; return 1;
} }
sockfd = (curl_socket_t)sockextr; sockfd = sockextr;
/* wait for the socket to become ready for sending */ /* wait for the socket to become ready for sending */
if(!wait_on_socket(sockfd, 0, 60000L)) { if(!wait_on_socket(sockfd, 0, 60000L))
{
printf("Error: timeout.\n"); printf("Error: timeout.\n");
return 1; return 1;
} }
@ -111,14 +116,16 @@ int main(void)
* to see if all the request has been sent */ * to see if all the request has been sent */
res = curl_easy_send(curl, request, strlen(request), &iolen); res = curl_easy_send(curl, request, strlen(request), &iolen);
if(CURLE_OK != res) { if(CURLE_OK != res)
{
printf("Error: %s\n", curl_easy_strerror(res)); printf("Error: %s\n", curl_easy_strerror(res));
return 1; return 1;
} }
puts("Reading response."); puts("Reading response.");
/* read the response */ /* read the response */
for(;;) { for(;;)
{
char buf[1024]; char buf[1024];
wait_on_socket(sockfd, 1, 60000L); wait_on_socket(sockfd, 1, 60000L);

View File

@ -31,7 +31,7 @@
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream); int written = fwrite(ptr, size, nmemb, (FILE *)stream);
return written; return written;
} }

View File

@ -47,6 +47,7 @@
int main(void) int main(void)
{ {
int i;
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
FILE *headerfile; FILE *headerfile;
@ -54,7 +55,6 @@ int main(void)
static const char *pCertFile = "testcert.pem"; static const char *pCertFile = "testcert.pem";
static const char *pCACertFile="cacert.pem"; static const char *pCACertFile="cacert.pem";
static const char *pHeaderFile = "dumpit";
const char *pKeyName; const char *pKeyName;
const char *pKeyType; const char *pKeyType;
@ -71,7 +71,7 @@ int main(void)
pEngine = NULL; pEngine = NULL;
#endif #endif
headerfile = fopen(pHeaderFile, "wb"); headerfile = fopen("dumpit", "w");
curl_global_init(CURL_GLOBAL_DEFAULT); curl_global_init(CURL_GLOBAL_DEFAULT);
@ -81,46 +81,47 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://your.favourite.ssl.site"); curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://your.favourite.ssl.site");
curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile); curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile);
do { /* dummy loop, just to break out from */ for(i = 0; i < 1; i++) /* single-iteration loop, just to break out from */
if(pEngine) { {
/* use crypto engine */ if (pEngine) /* use crypto engine */
if(curl_easy_setopt(curl, CURLOPT_SSLENGINE, pEngine) != CURLE_OK) { {
/* load the crypto engine */ if (curl_easy_setopt(curl, CURLOPT_SSLENGINE,pEngine) != CURLE_OK)
fprintf(stderr, "can't set crypto engine\n"); { /* load the crypto engine */
fprintf(stderr,"can't set crypto engine\n");
break; break;
} }
if(curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1L) != CURLE_OK) { if (curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT,1L) != CURLE_OK)
/* set the crypto engine as default */ { /* set the crypto engine as default */
/* only needed for the first time you load /* only needed for the first time you load
a engine in a curl object... */ a engine in a curl object... */
fprintf(stderr, "can't set crypto engine as default\n"); fprintf(stderr,"can't set crypto engine as default\n");
break; break;
} }
} }
/* cert is stored PEM coded in file... */ /* cert is stored PEM coded in file... */
/* since PEM is default, we needn't set it for PEM */ /* since PEM is default, we needn't set it for PEM */
curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
/* set the cert for client authentication */ /* set the cert for client authentication */
curl_easy_setopt(curl, CURLOPT_SSLCERT, pCertFile); curl_easy_setopt(curl,CURLOPT_SSLCERT,pCertFile);
/* sorry, for engine we must set the passphrase /* sorry, for engine we must set the passphrase
(if the key has one...) */ (if the key has one...) */
if(pPassphrase) if (pPassphrase)
curl_easy_setopt(curl, CURLOPT_KEYPASSWD, pPassphrase); curl_easy_setopt(curl,CURLOPT_KEYPASSWD,pPassphrase);
/* if we use a key stored in a crypto engine, /* if we use a key stored in a crypto engine,
we must set the key type to "ENG" */ we must set the key type to "ENG" */
curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, pKeyType); curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,pKeyType);
/* set the private key (file or ID in engine) */ /* set the private key (file or ID in engine) */
curl_easy_setopt(curl, CURLOPT_SSLKEY, pKeyName); curl_easy_setopt(curl,CURLOPT_SSLKEY,pKeyName);
/* set the file with the certs vaildating the server */ /* set the file with the certs vaildating the server */
curl_easy_setopt(curl, CURLOPT_CAINFO, pCACertFile); curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile);
/* disconnect if we can't validate server's cert */ /* disconnect if we can't validate server's cert */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L);
/* Perform the request, res will get the return code */ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
@ -130,7 +131,7 @@ int main(void)
curl_easy_strerror(res)); curl_easy_strerror(res));
/* we are done... */ /* we are done... */
} while(0); }
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }

View File

@ -74,7 +74,8 @@ void *pull_one_url(void *NaN)
/* Stop threads from entering unless j is incremented */ /* Stop threads from entering unless j is incremented */
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
while(j < num_urls) { while ( j < num_urls )
{
printf("j = %d\n", j); printf("j = %d\n", j);
http = http =
@ -84,9 +85,11 @@ void *pull_one_url(void *NaN)
printf( "http %s", http ); printf( "http %s", http );
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if(curl)
{
outfile = fopen(urls[j], "wb"); outfile = fopen(urls[j], "w");
/* printf("fopen\n"); */
/* Set the URL and transfer type */ /* Set the URL and transfer type */
curl_easy_setopt(curl, CURLOPT_URL, http); curl_easy_setopt(curl, CURLOPT_URL, http);
@ -216,7 +219,7 @@ int main(int argc, char **argv)
g_signal_connect(G_OBJECT (top_window), "delete-event", g_signal_connect(G_OBJECT (top_window), "delete-event",
G_CALLBACK(cb_delete), NULL); G_CALLBACK(cb_delete), NULL);
if(!g_thread_create(&create_thread, progress_bar, FALSE, NULL) != 0) if (!g_thread_create(&create_thread, progress_bar, FALSE, NULL) != 0)
g_warning("can't create the thread"); g_warning("can't create the thread");
gtk_main(); gtk_main();
@ -225,3 +228,4 @@ int main(int argc, char **argv)
return 0; return 0;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -45,8 +45,7 @@ static const char *payload_text[] = {
"To: " TO "\r\n", "To: " TO "\r\n",
"From: " FROM "(Example User)\r\n", "From: " FROM "(Example User)\r\n",
"Cc: " CC "(Another example User)\r\n", "Cc: " CC "(Another example User)\r\n",
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
"rfcpedant.example.org>\r\n",
"Subject: SMTP example message\r\n", "Subject: SMTP example message\r\n",
"\r\n", /* empty line to divide headers from body, see RFC5322 */ "\r\n", /* empty line to divide headers from body, see RFC5322 */
"The body of the message starts here.\r\n", "The body of the message starts here.\r\n",
@ -96,12 +95,11 @@ int main(void)
/* This is the URL for your mailserver */ /* This is the URL for your mailserver */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
/* Note that this option isn't strictly required, omitting it will result /* Note that this option isn't strictly required, omitting it will result in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise, they
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
* details.
*/ */
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM); curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
@ -130,13 +128,13 @@ int main(void)
/* Free the list of recipients */ /* Free the list of recipients */
curl_slist_free_all(recipients); curl_slist_free_all(recipients);
/* curl won't send the QUIT command until you call cleanup, so you should /* curl won't send the QUIT command until you call cleanup, so you should be
* be able to re-use this connection for additional messages (setting * able to re-use this connection for additional messages (setting
* CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling * CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling
* curl_easy_perform() again. It may not be a good idea to keep the * curl_easy_perform() again. It may not be a good idea to keep the
* connection open for a very long time though (more than a few minutes * connection open for a very long time though (more than a few minutes may
* may result in the server timing out the connection), and you do want to * result in the server timing out the connection), and you do want to clean
* clean up in the end. * up in the end.
*/ */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -46,8 +46,7 @@ static const char *payload_text[] = {
"To: " TO "\r\n", "To: " TO "\r\n",
"From: " FROM "(Example User)\r\n", "From: " FROM "(Example User)\r\n",
"Cc: " CC "(Another example User)\r\n", "Cc: " CC "(Another example User)\r\n",
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
"rfcpedant.example.org>\r\n",
"Subject: SMTP multi example message\r\n", "Subject: SMTP multi example message\r\n",
"\r\n", /* empty line to divide headers from body, see RFC5322 */ "\r\n", /* empty line to divide headers from body, see RFC5322 */
"The body of the message starts here.\r\n", "The body of the message starts here.\r\n",
@ -187,7 +186,8 @@ int main(void)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) { if(mc != CURLM_OK)
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -46,8 +46,7 @@ static const char *payload_text[] = {
"To: " TO "\r\n", "To: " TO "\r\n",
"From: " FROM "(Example User)\r\n", "From: " FROM "(Example User)\r\n",
"Cc: " CC "(Another example User)\r\n", "Cc: " CC "(Another example User)\r\n",
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
"rfcpedant.example.org>\r\n",
"Subject: SMTP SSL example message\r\n", "Subject: SMTP SSL example message\r\n",
"\r\n", /* empty line to divide headers from body, see RFC5322 */ "\r\n", /* empty line to divide headers from body, see RFC5322 */
"The body of the message starts here.\r\n", "The body of the message starts here.\r\n",
@ -122,12 +121,11 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif #endif
/* Note that this option isn't strictly required, omitting it will result /* Note that this option isn't strictly required, omitting it will result in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise, they
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
* details.
*/ */
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM); curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -46,8 +46,7 @@ static const char *payload_text[] = {
"To: " TO "\r\n", "To: " TO "\r\n",
"From: " FROM "(Example User)\r\n", "From: " FROM "(Example User)\r\n",
"Cc: " CC "(Another example User)\r\n", "Cc: " CC "(Another example User)\r\n",
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n",
"rfcpedant.example.org>\r\n",
"Subject: SMTP TLS example message\r\n", "Subject: SMTP TLS example message\r\n",
"\r\n", /* empty line to divide headers from body, see RFC5322 */ "\r\n", /* empty line to divide headers from body, see RFC5322 */
"The body of the message starts here.\r\n", "The body of the message starts here.\r\n",
@ -117,19 +116,18 @@ int main(void)
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
* curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); * curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
* That is, in general, a bad idea. It is still better than sending your * That is, in general, a bad idea. It is still better than sending your
* authentication details in plain text though. Instead, you should get * authentication details in plain text though.
* the issuer certificate (or the host certificate if the certificate is * Instead, you should get the issuer certificate (or the host certificate
* self-signed) and add it to the set of certificates that are known to * if the certificate is self-signed) and add it to the set of certificates
* libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See docs/SSLCERTS * that are known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See
* for more information. */ * docs/SSLCERTS for more information. */
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
/* Note that this option isn't strictly required, omitting it will result /* Note that this option isn't strictly required, omitting it will result in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise, they
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
* details.
*/ */
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM); curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);

View File

@ -129,7 +129,7 @@ size_t SyncTime_CURL_WriteOutput(void *ptr, size_t size, size_t nmemb,
void *stream) void *stream)
{ {
fwrite(ptr, size, nmemb, stream); fwrite(ptr, size, nmemb, stream);
return (nmemb*size); return(nmemb*size);
} }
size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb, size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
@ -138,17 +138,17 @@ size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
int i, RetVal; int i, RetVal;
char TmpStr1[26], TmpStr2[26]; char TmpStr1[26], TmpStr2[26];
if(ShowAllHeader == 1) if (ShowAllHeader == 1)
fprintf(stderr, "%s", (char *)(ptr)); fprintf(stderr, "%s", (char *)(ptr));
if(strncmp((char *)(ptr), "Date:", 5) == 0) { if (strncmp((char *)(ptr), "Date:", 5) == 0) {
if(ShowAllHeader == 0) if (ShowAllHeader == 0)
fprintf(stderr, "HTTP Server. %s", (char *)(ptr)); fprintf(stderr, "HTTP Server. %s", (char *)(ptr));
if(AutoSyncTime == 1) { if (AutoSyncTime == 1) {
*TmpStr1 = 0; *TmpStr1 = 0;
*TmpStr2 = 0; *TmpStr2 = 0;
if(strlen((char *)(ptr)) > 50) /* Can prevent buffer overflow to if (strlen((char *)(ptr)) > 50) /* Can prevent buffer overflow to
TmpStr1 & 2? */ TmpStr1 & 2? */
AutoSyncTime = 0; AutoSyncTime = 0;
else { else {
@ -156,10 +156,11 @@ size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
TmpStr1, &SYSTime.wDay, TmpStr2, &SYSTime.wYear, TmpStr1, &SYSTime.wDay, TmpStr2, &SYSTime.wYear,
&SYSTime.wHour, &SYSTime.wMinute, &SYSTime.wSecond); &SYSTime.wHour, &SYSTime.wMinute, &SYSTime.wSecond);
if(RetVal == 7) { if (RetVal == 7) {
SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */ SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */
for(i=0; i<12; i++) { for (i=0; i<12; i++) {
if(strcmp(MthStr[i], TmpStr2) == 0) { if (strcmp(MthStr[i], TmpStr2) == 0) {
SYSTime.wMonth = i+1; SYSTime.wMonth = i+1;
break; break;
} }
@ -173,21 +174,21 @@ size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
} }
} }
if(strncmp((char *)(ptr), "X-Cache: HIT", 12) == 0) { if (strncmp((char *)(ptr), "X-Cache: HIT", 12) == 0) {
fprintf(stderr, "ERROR: HTTP Server data is cached." fprintf(stderr, "ERROR: HTTP Server data is cached."
" Server Date is no longer valid.\n"); " Server Date is no longer valid.\n");
AutoSyncTime = 0; AutoSyncTime = 0;
} }
return (nmemb*size); return(nmemb*size);
} }
void SyncTime_CURL_Init(CURL *curl, char *proxy_port, void SyncTime_CURL_Init(CURL *curl, char *proxy_port,
char *proxy_user_password) char *proxy_user_password)
{ {
if(strlen(proxy_port) > 0) if (strlen(proxy_port) > 0)
curl_easy_setopt(curl, CURLOPT_PROXY, proxy_port); curl_easy_setopt(curl, CURLOPT_PROXY, proxy_port);
if(strlen(proxy_user_password) > 0) if (strlen(proxy_user_password) > 0)
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, proxy_user_password); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, proxy_user_password);
#ifdef SYNCTIME_UA #ifdef SYNCTIME_UA
@ -204,7 +205,7 @@ int SyncTime_CURL_Fetch(CURL *curl, char *URL_Str, char *OutFileName,
CURLcode res; CURLcode res;
outfile = NULL; outfile = NULL;
if(HttpGetBody == HTTP_COMMAND_HEAD) if (HttpGetBody == HTTP_COMMAND_HEAD)
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
else { else {
outfile = fopen(OutFileName, "wb"); outfile = fopen(OutFileName, "wb");
@ -213,7 +214,7 @@ int SyncTime_CURL_Fetch(CURL *curl, char *URL_Str, char *OutFileName,
curl_easy_setopt(curl, CURLOPT_URL, URL_Str); curl_easy_setopt(curl, CURLOPT_URL, URL_Str);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(outfile != NULL) if (outfile != NULL)
fclose(outfile); fclose(outfile);
return res; /* (CURLE_OK) */ return res; /* (CURLE_OK) */
} }
@ -243,7 +244,7 @@ int conf_init(conf_t *conf)
int i; int i;
*conf->http_proxy = 0; *conf->http_proxy = 0;
for(i=0; i<MAX_STRING1; i++) for (i=0; i<MAX_STRING1; i++)
conf->proxy_user[i] = 0; /* Clean up password from memory */ conf->proxy_user[i] = 0; /* Clean up password from memory */
*conf->timeserver = 0; *conf->timeserver = 0;
return 1; return 1;
@ -271,24 +272,24 @@ int main(int argc, char *argv[])
RetValue = 0; /* Successful Exit */ RetValue = 0; /* Successful Exit */
conf_init(conf); conf_init(conf);
if(argc > 1) { if (argc > 1) {
while(OptionIndex < argc) { while (OptionIndex < argc) {
if(strncmp(argv[OptionIndex], "--server=", 9) == 0) if (strncmp(argv[OptionIndex], "--server=", 9) == 0)
snprintf(conf->timeserver, MAX_STRING, "%s", &argv[OptionIndex][9]); snprintf(conf->timeserver, MAX_STRING, "%s", &argv[OptionIndex][9]);
if(strcmp(argv[OptionIndex], "--showall") == 0) if (strcmp(argv[OptionIndex], "--showall") == 0)
ShowAllHeader = 1; ShowAllHeader = 1;
if(strcmp(argv[OptionIndex], "--synctime") == 0) if (strcmp(argv[OptionIndex], "--synctime") == 0)
AutoSyncTime = 1; AutoSyncTime = 1;
if(strncmp(argv[OptionIndex], "--proxy-user=", 13) == 0) if (strncmp(argv[OptionIndex], "--proxy-user=", 13) == 0)
snprintf(conf->proxy_user, MAX_STRING, "%s", &argv[OptionIndex][13]); snprintf(conf->proxy_user, MAX_STRING, "%s", &argv[OptionIndex][13]);
if(strncmp(argv[OptionIndex], "--proxy=", 8) == 0) if (strncmp(argv[OptionIndex], "--proxy=", 8) == 0)
snprintf(conf->http_proxy, MAX_STRING, "%s", &argv[OptionIndex][8]); snprintf(conf->http_proxy, MAX_STRING, "%s", &argv[OptionIndex][8]);
if((strcmp(argv[OptionIndex], "--help") == 0) || if ((strcmp(argv[OptionIndex], "--help") == 0) ||
(strcmp(argv[OptionIndex], "/?") == 0)) { (strcmp(argv[OptionIndex], "/?") == 0)) {
showUsage(); showUsage();
return 0; return 0;
@ -297,13 +298,13 @@ int main(int argc, char *argv[])
} }
} }
if(*conf->timeserver == 0) /* Use default server for time information */ if (*conf->timeserver == 0) /* Use default server for time information */
snprintf(conf->timeserver, MAX_STRING, "%s", DefaultTimeServer[0]); snprintf(conf->timeserver, MAX_STRING, "%s", DefaultTimeServer[0]);
/* Init CURL before usage */ /* Init CURL before usage */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if (curl) {
SyncTime_CURL_Init(curl, conf->http_proxy, conf->proxy_user); SyncTime_CURL_Init(curl, conf->http_proxy, conf->proxy_user);
/* Calculating time diff between GMT and localtime */ /* Calculating time diff between GMT and localtime */
@ -315,7 +316,7 @@ int main(int argc, char *argv[])
tzonediffFloat = difftime(tt_local, tt_gmt); tzonediffFloat = difftime(tt_local, tt_gmt);
tzonediffWord = (int)(tzonediffFloat/3600.0); tzonediffWord = (int)(tzonediffFloat/3600.0);
if((double)(tzonediffWord * 3600) == tzonediffFloat) if ((double)(tzonediffWord * 3600) == tzonediffFloat)
snprintf(tzoneBuf, 15, "%+03d'00'", tzonediffWord); snprintf(tzoneBuf, 15, "%+03d'00'", tzonediffWord);
else else
snprintf(tzoneBuf, 15, "%+03d'30'", tzonediffWord); snprintf(tzoneBuf, 15, "%+03d'30'", tzonediffWord);
@ -344,9 +345,9 @@ int main(int argc, char *argv[])
LOCALTime.wMilliseconds); LOCALTime.wMilliseconds);
fprintf(stderr, "\nAfter HTTP. Date: %s%s\n", timeBuf, tzoneBuf); fprintf(stderr, "\nAfter HTTP. Date: %s%s\n", timeBuf, tzoneBuf);
if(AutoSyncTime == 3) { if (AutoSyncTime == 3) {
/* Synchronising computer clock */ /* Synchronising computer clock */
if(!SetSystemTime(&SYSTime)) { /* Set system time */ if (!SetSystemTime(&SYSTime)) { /* Set system time */
fprintf(stderr, "ERROR: Unable to set system time.\n"); fprintf(stderr, "ERROR: Unable to set system time.\n");
RetValue = 1; RetValue = 1;
} }

View File

@ -51,7 +51,7 @@ static void lock_callback(int mode, int type, char *file, int line)
{ {
(void)file; (void)file;
(void)line; (void)line;
if(mode & CRYPTO_LOCK) { if (mode & CRYPTO_LOCK) {
pthread_mutex_lock(&(lockarray[type])); pthread_mutex_lock(&(lockarray[type]));
} }
else { else {
@ -64,7 +64,7 @@ static unsigned long thread_id(void)
unsigned long ret; unsigned long ret;
ret=(unsigned long)pthread_self(); ret=(unsigned long)pthread_self();
return ret; return(ret);
} }
static void init_locks(void) static void init_locks(void)
@ -73,8 +73,8 @@ static void init_locks(void)
lockarray=(pthread_mutex_t *)OPENSSL_malloc(CRYPTO_num_locks() * lockarray=(pthread_mutex_t *)OPENSSL_malloc(CRYPTO_num_locks() *
sizeof(pthread_mutex_t)); sizeof(pthread_mutex_t));
for(i=0; i<CRYPTO_num_locks(); i++) { for (i=0; i<CRYPTO_num_locks(); i++) {
pthread_mutex_init(&(lockarray[i]), NULL); pthread_mutex_init(&(lockarray[i]),NULL);
} }
CRYPTO_set_id_callback((unsigned long (*)())thread_id); CRYPTO_set_id_callback((unsigned long (*)())thread_id);
@ -86,7 +86,7 @@ static void kill_locks(void)
int i; int i;
CRYPTO_set_locking_callback(NULL); CRYPTO_set_locking_callback(NULL);
for(i=0; i<CRYPTO_num_locks(); i++) for (i=0; i<CRYPTO_num_locks(); i++)
pthread_mutex_destroy(&(lockarray[i])); pthread_mutex_destroy(&(lockarray[i]));
OPENSSL_free(lockarray); OPENSSL_free(lockarray);

View File

@ -65,7 +65,7 @@ int main(int argc, char *argv[])
/* open the file */ /* open the file */
pagefile = fopen(pagefilename, "wb"); pagefile = fopen(pagefilename, "wb");
if(pagefile) { if (pagefile) {
/* write the page body to this file handle */ /* write the page body to this file handle */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile);

View File

@ -38,8 +38,8 @@
static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream) static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
fwrite(ptr, size, nmemb, stream); fwrite(ptr,size,nmemb,stream);
return (nmemb*size); return(nmemb*size);
} }
static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
@ -120,7 +120,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
/* get a BIO */ /* get a BIO */
bio = BIO_new_mem_buf((char *)mypem, -1); bio = BIO_new_mem_buf((char *)mypem, -1);
if(bio == NULL) { if (bio == NULL) {
printf("BIO_new_mem_buf failed\n"); printf("BIO_new_mem_buf failed\n");
} }
@ -128,49 +128,49 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
* structure that SSL can use * structure that SSL can use
*/ */
cert = PEM_read_bio_X509(bio, NULL, 0, NULL); cert = PEM_read_bio_X509(bio, NULL, 0, NULL);
if(cert == NULL) { if (cert == NULL) {
printf("PEM_read_bio_X509 failed...\n"); printf("PEM_read_bio_X509 failed...\n");
} }
/*tell SSL to use the X509 certificate*/ /*tell SSL to use the X509 certificate*/
ret = SSL_CTX_use_certificate((SSL_CTX*)sslctx, cert); ret = SSL_CTX_use_certificate((SSL_CTX*)sslctx, cert);
if(ret != 1) { if (ret != 1) {
printf("Use certificate failed\n"); printf("Use certificate failed\n");
} }
/*create a bio for the RSA key*/ /*create a bio for the RSA key*/
kbio = BIO_new_mem_buf((char *)mykey, -1); kbio = BIO_new_mem_buf((char *)mykey, -1);
if(kbio == NULL) { if (kbio == NULL) {
printf("BIO_new_mem_buf failed\n"); printf("BIO_new_mem_buf failed\n");
} }
/*read the key bio into an RSA object*/ /*read the key bio into an RSA object*/
rsa = PEM_read_bio_RSAPrivateKey(kbio, NULL, 0, NULL); rsa = PEM_read_bio_RSAPrivateKey(kbio, NULL, 0, NULL);
if(rsa == NULL) { if (rsa == NULL) {
printf("Failed to create key bio\n"); printf("Failed to create key bio\n");
} }
/*tell SSL to use the RSA key from memory*/ /*tell SSL to use the RSA key from memory*/
ret = SSL_CTX_use_RSAPrivateKey((SSL_CTX*)sslctx, rsa); ret = SSL_CTX_use_RSAPrivateKey((SSL_CTX*)sslctx, rsa);
if(ret != 1) { if (ret != 1) {
printf("Use Key failed\n"); printf("Use Key failed\n");
} }
/* free resources that have been allocated by openssl functions */ /* free resources that have been allocated by openssl functions */
if(bio) if (bio)
BIO_free(bio); BIO_free(bio);
if(kbio) if (kbio)
BIO_free(kbio); BIO_free(kbio);
if(rsa) if (rsa)
RSA_free(rsa); RSA_free(rsa);
if(cert) if (cert)
X509_free(cert); X509_free(cert);
/* all set to go */ /* all set to go */
return CURLE_OK; return CURLE_OK ;
} }
int main(void) int main(void)
@ -180,28 +180,28 @@ int main(void)
rv = curl_global_init(CURL_GLOBAL_ALL); rv = curl_global_init(CURL_GLOBAL_ALL);
ch = curl_easy_init(); ch = curl_easy_init();
rv = curl_easy_setopt(ch, CURLOPT_VERBOSE, 0L); rv = curl_easy_setopt(ch,CURLOPT_VERBOSE, 0L);
rv = curl_easy_setopt(ch, CURLOPT_HEADER, 0L); rv = curl_easy_setopt(ch,CURLOPT_HEADER, 0L);
rv = curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 1L); rv = curl_easy_setopt(ch,CURLOPT_NOPROGRESS, 1L);
rv = curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L); rv = curl_easy_setopt(ch,CURLOPT_NOSIGNAL, 1L);
rv = curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, writefunction); rv = curl_easy_setopt(ch,CURLOPT_WRITEFUNCTION, *writefunction);
rv = curl_easy_setopt(ch, CURLOPT_WRITEDATA, stdout); rv = curl_easy_setopt(ch,CURLOPT_WRITEDATA, stdout);
rv = curl_easy_setopt(ch, CURLOPT_HEADERFUNCTION, writefunction); rv = curl_easy_setopt(ch,CURLOPT_HEADERFUNCTION, *writefunction);
rv = curl_easy_setopt(ch, CURLOPT_HEADERDATA, stderr); rv = curl_easy_setopt(ch,CURLOPT_HEADERDATA, stderr);
rv = curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); rv = curl_easy_setopt(ch,CURLOPT_SSLCERTTYPE,"PEM");
/* both VERIFYPEER and VERIFYHOST are set to 0 in this case because there is /* both VERIFYPEER and VERIFYHOST are set to 0 in this case because there is
no CA certificate*/ no CA certificate*/
rv = curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 0L); rv = curl_easy_setopt(ch,CURLOPT_SSL_VERIFYPEER, 0L);
rv = curl_easy_setopt(ch, CURLOPT_SSL_VERIFYHOST, 0L); rv = curl_easy_setopt(ch,CURLOPT_SSL_VERIFYHOST, 0L);
rv = curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); rv = curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
rv = curl_easy_setopt(ch, CURLOPT_SSLKEYTYPE, "PEM"); rv = curl_easy_setopt(ch, CURLOPT_SSLKEYTYPE, "PEM");
/* first try: retrieve page without user certificate and key -> will fail /* first try: retrieve page without user certificate and key -> will fail
*/ */
rv = curl_easy_perform(ch); rv = curl_easy_perform(ch);
if(rv==CURLE_OK) { if (rv==CURLE_OK) {
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
} }
else { else {
@ -212,9 +212,9 @@ int main(void)
* load the certificate and key by installing a function doing the necessary * load the certificate and key by installing a function doing the necessary
* "modifications" to the SSL CONTEXT just before link init * "modifications" to the SSL CONTEXT just before link init
*/ */
rv = curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); rv = curl_easy_setopt(ch,CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
rv = curl_easy_perform(ch); rv = curl_easy_perform(ch);
if(rv==CURLE_OK) { if (rv==CURLE_OK) {
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
} }
else { else {

View File

@ -51,8 +51,7 @@ struct ParserStruct {
struct MemoryStruct characters; struct MemoryStruct characters;
}; };
static void startElement(void *userData, const XML_Char *name, static void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
const XML_Char **atts)
{ {
struct ParserStruct *state = (struct ParserStruct *) userData; struct ParserStruct *state = (struct ParserStruct *) userData;
state->tags++; state->tags++;
@ -90,18 +89,16 @@ static void endElement(void *userData, const XML_Char *name)
printf("%5lu %10lu %s\n", state->depth, state->characters.size, name); printf("%5lu %10lu %s\n", state->depth, state->characters.size, name);
} }
static size_t parseStreamCallback(void *contents, size_t length, size_t nmemb, static size_t parseStreamCallback(void *contents, size_t length, size_t nmemb, void *userp)
void *userp)
{ {
XML_Parser parser = (XML_Parser) userp; XML_Parser parser = (XML_Parser) userp;
size_t real_size = length * nmemb; size_t real_size = length * nmemb;
struct ParserStruct *state = (struct ParserStruct *) XML_GetUserData(parser); struct ParserStruct *state = (struct ParserStruct *) XML_GetUserData(parser);
/* Only parse if we're not already in a failure state. */ /* Only parse if we're not already in a failure state. */
if(state->ok && XML_Parse(parser, contents, real_size, 0) == 0) { if (state->ok && XML_Parse(parser, contents, real_size, 0) == 0) {
int error_code = XML_GetErrorCode(parser); int error_code = XML_GetErrorCode(parser);
fprintf(stderr, "Parsing response buffer of length %lu failed" fprintf(stderr, "Parsing response buffer of length %lu failed with error code %d (%s).\n",
" with error code %d (%s).\n",
real_size, error_code, XML_ErrorString(error_code)); real_size, error_code, XML_ErrorString(error_code));
state->ok = 0; state->ok = 0;
} }
@ -129,8 +126,7 @@ int main(void)
/* Initialize a libcurl handle. */ /* Initialize a libcurl handle. */
curl_global_init(CURL_GLOBAL_ALL ^ CURL_GLOBAL_SSL); curl_global_init(CURL_GLOBAL_ALL ^ CURL_GLOBAL_SSL);
curl_handle = curl_easy_init(); curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, curl_easy_setopt(curl_handle, CURLOPT_URL, "http://www.w3schools.com/xml/simple.xml");
"http://www.w3schools.com/xml/simple.xml");
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, parseStreamCallback); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, parseStreamCallback);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)parser); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)parser);
@ -142,9 +138,9 @@ int main(void)
fprintf(stderr, "curl_easy_perform() failed: %s\n", fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res)); curl_easy_strerror(res));
} }
else if(state.ok) { else if (state.ok) {
/* Expat requires one final call to finalize parsing. */ /* Expat requires one final call to finalize parsing. */
if(XML_Parse(parser, NULL, 0, 1) == 0) { if (XML_Parse(parser, NULL, 0, 1) == 0) {
int error_code = XML_GetErrorCode(parser); int error_code = XML_GetErrorCode(parser);
fprintf(stderr, "Finalizing parsing failed with error code %d (%s).\n", fprintf(stderr, "Finalizing parsing failed with error code %d (%s).\n",
error_code, XML_ErrorString(error_code)); error_code, XML_ErrorString(error_code));

View File

@ -194,9 +194,9 @@ See \fICURLINFO_FTP_ENTRY_PATH(3)\fP
Certificate chain. Certificate chain.
See \fICURLINFO_CERTINFO(3)\fP See \fICURLINFO_CERTINFO(3)\fP
.IP CURLINFO_TLS_SSL_PTR .IP CURLINFO_TLS_SESSION
TLS session info that can be used for further processing. TLS session info that can be used for further processing.
See \fICURLINFO_TLS_SSL_PTR(3)\fP See \fICURLINFO_TLS_SESSION(3)\fP
.IP CURLINFO_CONDITION_UNMET .IP CURLINFO_CONDITION_UNMET
Whether or not a time conditional was met. Whether or not a time conditional was met.

View File

@ -314,8 +314,6 @@ Authentication address. See \fICURLOPT_MAIL_AUTH(3)\fP
.SH TFTP OPTIONS .SH TFTP OPTIONS
.IP CURLOPT_TFTP_BLKSIZE .IP CURLOPT_TFTP_BLKSIZE
TFTP block size. See \fICURLOPT_TFTP_BLKSIZE(3)\fP TFTP block size. See \fICURLOPT_TFTP_BLKSIZE(3)\fP
.IP CURLOPT_TFTP_NO_OPTIONS
Do not send TFTP options requests. See \fICURLOPT_TFTP_NO_OPTIONS(3)\fP
.SH FTP OPTIONS .SH FTP OPTIONS
.IP CURLOPT_FTPPORT .IP CURLOPT_FTPPORT
Use active FTP. See \fICURLOPT_FTPPORT(3)\fP Use active FTP. See \fICURLOPT_FTPPORT(3)\fP

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -71,48 +71,6 @@ priority read events such as out of band data.
.IP CURL_WAIT_POLLOUT .IP CURL_WAIT_POLLOUT
Bit flag to curl_waitfd.events indicating the socket should poll on write Bit flag to curl_waitfd.events indicating the socket should poll on write
events such as the socket being clear to write without blocking. events such as the socket being clear to write without blocking.
.SH EXAMPLE
.nf
CURL *easy_handle;
CURLM *multi_handle;
/* add the individual easy handle */
curl_multi_add_handle(multi_handle, easy_handle);
do {
CURLMcode mc;
int numfds;
mc = curl_multi_perform(multi_handle, &still_running);
if(mc == CURLM_OK ) {
/* wait for activity, timeout or "nothing" */
mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds);
}
if(mc != CURLM_OK) {
fprintf(stderr, "curl_multi failed, code %d.\n", mc);
break;
}
/* 'numfds' being zero means either a timeout or no file descriptors to
wait for. Try timeout on first occurrence, then assume no file
descriptors and no file descriptors to wait for means wait for 100
milliseconds. */
if(!numfds) {
repeats++; /* count number of repeated zero numfds */
if(repeats > 1) {
WAITMS(100); /* sleep 100 milliseconds */
}
}
else
repeats = 0;
} while(still_running);
curl_multi_remove_handle(multi_handle, easy_handle);
.fi
.SH RETURN VALUE .SH RETURN VALUE
CURLMcode type, general libcurl multi interface error code. See CURLMcode type, general libcurl multi interface error code. See
\fIlibcurl-errors(3)\fP \fIlibcurl-errors(3)\fP

View File

@ -91,5 +91,5 @@ fail-safe initialization that takes place the first time
These functions, provided either by your operating system or your own These functions, provided either by your operating system or your own
replacements, must be thread safe. You can use \fIcurl_global_init_mem(3)\fP replacements, must be thread safe. You can use \fIcurl_global_init_mem(3)\fP
to set your own replacement memory functions. to set your own replacement memory functions.
.IP "Non-safe functions" .IP Non-safe functions
\fICURLOPT_DNS_USE_GLOBAL_CACHE(3)\fP is not thread-safe. \fICURLOPT_DNS_USE_GLOBAL_CACHE(3)\fP is not thread-safe.

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -47,4 +47,3 @@ Added in 7.14.1
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR curl_easy_getinfo "(3), " curl_easy_setopt "(3), " .BR curl_easy_getinfo "(3), " curl_easy_setopt "(3), "
.BR CURLOPT_COOKIELIST "(3), "

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -30,22 +30,44 @@ CURLINFO_TLS_SESSION \- get TLS session info
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION, CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION,
struct curl_tlssessioninfo **session); struct curl_tlssessioninfo **session);
.SH DESCRIPTION .SH DESCRIPTION
\fBThis option has been superseded\fP by \fICURLINFO_TLS_SSL_PTR(3)\fP which Pass a pointer to a 'struct curl_tlssessioninfo *'. The pointer will be
was added in 7.48.0. The only reason you would use this option instead is if initialized to refer to a 'struct curl_tlssessioninfo *' that will contain an
you could be using a version of libcurl earlier than 7.48.0. enum indicating the SSL library used for the handshake and the respective
internal TLS session structure of this underlying SSL library.
This option is exactly the same as \fICURLINFO_TLS_SSL_PTR(3)\fP except in the This may then be used to extract certificate information in a format
case of OpenSSL. If the session \fIbackend\fP is CURLSSLBACKEND_OPENSSL the convenient for further processing, such as manual validation. NOTE: this
session \fIinternals\fP pointer varies depending on the option: option may not be available for all SSL backends; unsupported SSL backends
will always return NULL in the \fIinternals\fP pointer to indicate that they
are not supported.
CURLINFO_TLS_SESSION OpenSSL session \fIinternals\fP is SSL_CTX *. .nf
struct curl_tlssessioninfo {
curl_sslbackend backend;
void *internals;
};
.fi
CURLINFO_TLS_SSL_PTR OpenSSL session \fIinternals\fP is SSL *. The \fIbackend\fP struct member is one of the defines in the CURLSSLBACKEND_*
series: CURLSSLBACKEND_NONE (when built without TLS support),
CURLSSLBACKEND_OPENSSL, CURLSSLBACKEND_GNUTLS, CURLSSLBACKEND_NSS,
CURLSSLBACKEND_GSKIT, CURLSSLBACKEND_POLARSSL, CURLSSLBACKEND_CYASSL,
CURLSSLBACKEND_SCHANNEL, CURLSSLBACKEND_DARWINSSL or
CURLSSLBACKEND_AXTLS. (Note that the OpenSSL forks are all reported as just
OpenSSL here.)
You can obtain an SSL_CTX pointer from an SSL pointer using OpenSSL function The \fIinternals\fP struct member will point to a TLS library specific pointer
SSL_get_SSL_CTX. Therefore unless you need compatibility with older versions of with the following underlying types:
libcurl use \fICURLINFO_TLS_SSL_PTR(3)\fP. Refer to that document for more .RS
information. .IP OpenSSL
SSL_CTX *
.IP GnuTLS
gnutls_session_t
.IP NSS
PRFileDesc *
.IP gskit
gsk_handle
.RE
.SH PROTOCOLS .SH PROTOCOLS
All TLS-based All TLS-based
.SH EXAMPLE .SH EXAMPLE
@ -56,4 +78,3 @@ Added in 7.34.0
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR curl_easy_getinfo "(3), " curl_easy_setopt "(3), " .BR curl_easy_getinfo "(3), " curl_easy_setopt "(3), "
.BR CURLINFO_TLS_SSL_PTR "(3), "

View File

@ -1,140 +0,0 @@
.\" **************************************************************************
.\" * _ _ ____ _
.\" * Project ___| | | | _ \| |
.\" * / __| | | | |_) | |
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2016, 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 https://curl.haxx.se/docs/copyright.html.
.\" *
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
.\" * copies of the Software, and permit persons to whom the Software is
.\" * furnished to do so, under the terms of the COPYING file.
.\" *
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
.\" * KIND, either express or implied.
.\" *
.\" **************************************************************************
.\"
.TH CURLINFO_TLS_SSL_PTR 3 "23 Feb 2016" "libcurl 7.48.0" "curl_easy_getinfo options"
.SH NAME
CURLINFO_TLS_SESSION, CURLINFO_TLS_SSL_PTR \- get TLS session info
.SH SYNOPSIS
.nf
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SSL_PTR,
struct curl_tlssessioninfo **session);
/* if you need compatibility with libcurl < 7.48.0 use
CURLINFO_TLS_SESSION instead: */
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION,
struct curl_tlssessioninfo **session);
.SH DESCRIPTION
Pass a pointer to a 'struct curl_tlssessioninfo *'. The pointer will be
initialized to refer to a 'struct curl_tlssessioninfo *' that will contain an
enum indicating the SSL library used for the handshake and a pointer to the
respective internal TLS session structure of this underlying SSL library.
This option may be useful for example to extract certificate information in a
format convenient for further processing, such as manual validation. Refer to
the \fBLIMITATIONS\fP section.
.nf
struct curl_tlssessioninfo {
curl_sslbackend backend;
void *internals;
};
.fi
The \fIbackend\fP struct member is one of the defines in the CURLSSLBACKEND_*
series: CURLSSLBACKEND_NONE (when built without TLS support),
CURLSSLBACKEND_AXTLS, CURLSSLBACKEND_CYASSL, CURLSSLBACKEND_DARWINSSL,
CURLSSLBACKEND_GNUTLS, CURLSSLBACKEND_GSKIT, CURLSSLBACKEND_MBEDTLS,
CURLSSLBACKEND_NSS, CURLSSLBACKEND_OPENSSL, CURLSSLBACKEND_POLARSSL or
CURLSSLBACKEND_SCHANNEL. (Note that the OpenSSL forks are all reported as just
OpenSSL here.)
The \fIinternals\fP struct member will point to a TLS library specific pointer
for the active ("in use") SSL connection, with the following underlying types:
.RS
.IP GnuTLS
gnutls_session_t
.IP gskit
gsk_handle
.IP NSS
PRFileDesc *
.IP OpenSSL
CURLINFO_TLS_SESSION: SSL_CTX *
CURLINFO_TLS_SSL_PTR: SSL *
.RE
Since 7.48.0 the \fIinternals\fP member can point to these other SSL backends
as well:
.RS
.IP axTLS
SSL *
.IP mbedTLS
mbedtls_ssl_session *
.IP PolarSSL
ssl_session *
.IP "Secure Channel (WinSSL)"
CtxtHandle *
.IP "Secure Transport (DarwinSSL)"
SSLContext *
.IP "WolfSSL (formerly CyaSSL)"
SSL *
.RE
If the \fIinternals\fP pointer is NULL then either the SSL backend is not
supported or an SSL session has not yet been established.
.SH LIMITATIONS
\fBThis option has some limitations that could make it unsafe when it comes to
the manual verification of certificates.\fP
This option only retrieves the first in-use SSL session pointer for your easy
handle, however your easy handle may have more than one in-use SSL session if
using FTP over SSL. That is because the FTP protocol has a control channel and
a data channel and one or both may be over SSL. \fBCurrently there is no way to
retrieve a second in-use SSL session associated with an easy handle.\fP
This option has not been thoroughly tested with plaintext protocols that can be
upgraded/downgraded to/from SSL: FTP, SMTP, POP3, IMAP when used with
\fICURLOPT_USE_SSL(3)\fP. Though you will be able to retrieve the SSL pointer,
it's possible that before you can do that \fBdata (including auth) may have
already been sent over a connection after it was upgraded.\fP
Renegotiation. If unsafe renegotiation or renegotiation in a way that the
certificate is allowed to change is allowed by your SSL library this may occur
and the certificate may change, and \fBdata may continue to be sent or received
after renegotiation but before you are able to get the (possibly) changed SSL
pointer,\fP with the (possibly) changed certificate information.
If you are using OpenSSL or wolfSSL then \fICURLOPT_SSL_CTX_FUNCTION(3)\fP can
be used to set a certificate verification callback in the CTX. That is safer
than using this option to poll for certificate changes and doesn't suffer from
any of the problems above. There is currently no way in libcurl to set a
verification callback for the other SSL backends.
How are you using this option? Are you affected by any of these limitations?
Please let us know by making a comment at
https://github.com/curl/curl/issues/685
.SH PROTOCOLS
All TLS-based
.SH EXAMPLE
TODO
.SH AVAILABILITY
Added in 7.48.0.
This option supersedes \fICURLINFO_TLS_SESSION(3)\fP which was added in 7.34.0.
This option is exactly the same as that option except in the case of OpenSSL.
.SH RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO"
.BR curl_easy_getinfo "(3), " curl_easy_setopt "(3), "
.BR CURLINFO_TLS_SESSION "(3), "

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -31,21 +31,11 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ACCEPTTIMEOUT_MS, long ms);
Pass a long telling libcurl the maximum number of milliseconds to wait for a Pass a long telling libcurl the maximum number of milliseconds to wait for a
server to connect back to libcurl when an active FTP connection is used. server to connect back to libcurl when an active FTP connection is used.
.SH DEFAULT .SH DEFAULT
60000 milliseconds If no timeout is set, the internal default of 60000 (one minute) will be used.
.SH PROTOCOLS .SH PROTOCOLS
FTP FTP
.SH EXAMPLE .SH EXAMPLE
.nf TODO
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/path/file");
/* wait no more than 5 seconds for FTP server responses */
curl_easy_setopt(curl, CURLOPT_ACCEPTTIMEOUT_MS, 5000L);
curl_easy_perform(curl);
}
.fi
.SH AVAILABILITY .SH AVAILABILITY
Added in 7.24.0 Added in 7.24.0
.SH RETURN VALUE .SH RETURN VALUE

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -52,18 +52,7 @@ NULL
.SH PROTOCOLS .SH PROTOCOLS
HTTP HTTP
.SH EXAMPLE .SH EXAMPLE
.nf TODO
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* enable all supported built-in compressions */
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
/* Perform the request */
curl_easy_perform(curl);
}
.fi
.SH AVAILABILITY .SH AVAILABILITY
This option was called CURLOPT_ENCODING before 7.21.6 This option was called CURLOPT_ENCODING before 7.21.6
.SH RETURN VALUE .SH RETURN VALUE

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -28,28 +28,17 @@ CURLOPT_APPEND \- enable appending to the remote file
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_APPEND, long append); CURLcode curl_easy_setopt(CURL *handle, CURLOPT_APPEND, long append);
.SH DESCRIPTION .SH DESCRIPTION
A long parameter set to 1 tells the library to append to the remote file A parameter set to 1 tells the library to append to the remote file instead of
instead of overwrite it. This is only useful when uploading to an FTP site. overwrite it. This is only useful when uploading to an FTP site.
.SH DEFAULT .SH DEFAULT
0 (disabled) 0
.SH PROTOCOLS .SH PROTOCOLS
FTP FTP
.SH EXAMPLE .SH EXAMPLE
.nf TODO
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_APPEND, 1L);
curl_easy_perform(curl);
}
.fi
.SH AVAILABILITY .SH AVAILABILITY
This option was known as CURLOPT_FTPAPPEND up to 7.16.4 This option was known as CURLOPT_FTPAPPEND up to 7.16.4
.SH RETURN VALUE .SH RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_DIRLISTONLY "(3), " CURLOPT_RESUME_FROM "(3), " .BR CURLOPT_DIRLISTONLY "(3), " CURLOPT_RESUME_FROM "(3), "
.BR CURLOPT_UPLOAD "(3), "

View File

@ -47,7 +47,7 @@ if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* complete connection within 10000 milliseconds */ /* complete connection within 10000 milliseconds */
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10000L);
curl_easy_perform(curl); curl_easy_perform(curl);
} }

View File

@ -30,8 +30,8 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIEFILE, char *filename);
.SH DESCRIPTION .SH DESCRIPTION
Pass a pointer to a zero terminated string as parameter. It should point to Pass a pointer to a zero terminated string as parameter. It should point to
the file name of your file holding cookie data to read. The cookie data can be the file name of your file holding cookie data to read. The cookie data can be
in either the old Netscape / Mozilla cookie data format or just regular HTTP in either the old Netscape / Mozilla cookie data format or just regular
headers (Set-Cookie style) dumped to a file. HTTP-style headers dumped to a file.
It also enables the cookie engine, making libcurl parse and send cookies on It also enables the cookie engine, making libcurl parse and send cookies on
subsequent requests with this handle. subsequent requests with this handle.

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -117,4 +117,3 @@ Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
CURLE_OUT_OF_MEMORY if there was insufficient heap space. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_COOKIEFILE "(3), " CURLOPT_COOKIEJAR "(3), " CURLOPT_COOKIE "(3), " .BR CURLOPT_COOKIEFILE "(3), " CURLOPT_COOKIEJAR "(3), " CURLOPT_COOKIE "(3), "
.BR CURLINFO_COOKIELIST "(3), "

View File

@ -103,10 +103,8 @@ void dump(const char *text,
} }
/* show data on the right */ /* show data on the right */
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++)
char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x80) ? ptr[i+c] : '.'; fputc(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.', stream);
fputc(x, stream);
}
fputc('\\n', stream); /* newline */ fputc('\\n', stream); /* newline */
} }

View File

@ -59,4 +59,4 @@ Added in 7.15.1
.SH RETURN VALUE .SH RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_DIRLISTONLY "(3), " CURLOPT_FTP_SKIP_PASV_IP "(3), " .BR CURLOPT_FTPLISTONLY "(3), " CURLOPT_FTP_SKIP_PASV_IP "(3), "

View File

@ -45,4 +45,4 @@ This option was known as CURLOPT_KRB4LEVEL up to 7.16.3
Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
CURLE_OUT_OF_MEMORY if there was insufficient heap space. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_KRBLEVEL "(3), " CURLOPT_USE_SSL "(3), " .BR CURLOPT_KRBLEVEL "(3), " CURLOPT_FTP_SSL "(3), "

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -36,23 +36,6 @@ Future versions of libcurl are likely to not have any built-in progress meter
at all. at all.
.SH DEFAULT .SH DEFAULT
1, meaning it normally runs without a progress meter. 1, meaning it normally runs without a progress meter.
.SH PROTOCOLS
All
.SH EXAMPLE
.nf
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* enable progress meter */
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
/* Perform the request */
curl_easy_perform(curl);
}
.fi
.SH AVAILABILITY
Always
.SH RETURN VALUE .SH RETURN VALUE
Returns CURLE_OK. Returns CURLE_OK.
.SH "SEE ALSO" .SH "SEE ALSO"

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ CURLOPT_PATH_AS_IS \- do not handle dot dot sequences
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PATH_AS_IS, long leaveit); CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PATH_AS_IS, long leaveit);
.SH DESCRIPTION .SH DESCRIPTION
Set the long \fIleaveit\fP to 1, to explicitly tell libcurl to not alter the By setting the long \fIleaveit\fP to 1, to explicitly tell libcurl to not alter
given path before passing it on to the server. the given path before passing it on to the server.
This instructs libcurl to NOT squash sequences of "/../" or "/./" that may This tells libcurl to NOT squash sequences of "/../" or "/./" that may exist
exist in the URL's path part and that is supposed to be removed according to in the URL's path part and that is supposed to be removed according to RFC
RFC 3986 section 5.2.4. 3986 section 5.2.4.
Some server implementations are known to (erroneously) require the dot dot Some server implementations are known to (erroneously) require the dot dot
sequences to remain in the path and some clients want to pass these on in sequences to remain in the path and some clients want to pass these on in
@ -61,5 +61,3 @@ Aded in 7.42.0
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_STDERR "(3), " CURLOPT_DEBUGFUNCTION "(3), " .BR CURLOPT_STDERR "(3), " CURLOPT_DEBUGFUNCTION "(3), "
.BR CURLOPT_URL "(3), "

View File

@ -30,7 +30,7 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SERVICE_NAME, char *name);
.SH DESCRIPTION .SH DESCRIPTION
Pass a char * as parameter to a string holding the \fIname\fP of the Pass a char * as parameter to a string holding the \fIname\fP of the
service. The default service name is "HTTP". This option allows you to change it. service. The default service name is "HTTP". This option allows you to change it.
.SH DEFAULT ..SH DEFAULT
See above See above
.SH PROTOCOLS .SH PROTOCOLS
Most Most

View File

@ -31,7 +31,7 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SERVICE_NAME, char *name);
Pass a char * as parameter to a string holding the \fIname\fP of the Pass a char * as parameter to a string holding the \fIname\fP of the
service. The default service name is "HTTP". This option allows you to service. The default service name is "HTTP". This option allows you to
change it. change it.
.SH DEFAULT ..SH DEFAULT
See above See above
.SH PROTOCOLS .SH PROTOCOLS
Most Most

View File

@ -30,6 +30,9 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLENGINE, char *id);
.SH DESCRIPTION .SH DESCRIPTION
Pass a pointer to a zero terminated string as parameter. It will be used as Pass a pointer to a zero terminated string as parameter. It will be used as
the identifier for the crypto engine you want to use for your private key. the identifier for the crypto engine you want to use for your private key.
If the crypto device cannot be loaded, \fICURLE_SSL_ENGINE_NOTFOUND\fP is
returned.
.SH DEFAULT .SH DEFAULT
NULL NULL
.SH PROTOCOLS .SH PROTOCOLS
@ -37,19 +40,9 @@ All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
.SH EXAMPLE .SH EXAMPLE
TODO TODO
.SH AVAILABILITY .SH AVAILABILITY
Only if the SSL backend is OpenSSL built with engine support. If built TLS enabled.
.SH RETURN VALUE .SH RETURN VALUE
CURLE_OK - Engine found. Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or
CURLE_OUT_OF_MEMORY if there was insufficient heap space.
CURLE_SSL_ENGINE_NOTFOUND - Engine not found, or OpenSSL was not built with
engine support.
CURLE_SSL_ENGINE_INITFAILED - Engine found but initialization failed.
CURLE_NOT_BUILT_IN - Option not built in, OpenSSL is not the SSL backend.
CURLE_UNKNOWN_OPTION - Option not recognized.
CURLE_OUT_OF_MEMORY - Insufficient heap space.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_SSLENGINE_DEFAULT "(3), " CURLOPT_SSLKEY "(3), " .BR CURLOPT_SSLENGINE_DEFAULT "(3), " CURLOPT_SSLKEY "(3), "

View File

@ -28,10 +28,11 @@ CURLOPT_SSLENGINE_DEFAULT \- make SSL engine default
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLENGINE_DEFAULT, long val); CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLENGINE_DEFAULT, long val);
.SH DESCRIPTION .SH DESCRIPTION
Pass a long set to 1 to make the already specified crypto engine the default Pass a long set to 1 as parameter. Sets the actual crypto engine as the
for (asymmetric) crypto operations. default for (asymmetric) crypto operations.
This option has no effect unless set after \fICURLOPT_SSLENGINE\fP. If the crypto device cannot be set, \fICURLE_SSL_ENGINE_SETFAILED\fP is
returned.
.SH DEFAULT .SH DEFAULT
None None
.SH PROTOCOLS .SH PROTOCOLS
@ -39,16 +40,9 @@ All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
.SH EXAMPLE .SH EXAMPLE
TODO TODO
.SH AVAILABILITY .SH AVAILABILITY
Only if the SSL backend is OpenSSL built with engine support. If built TLS enabled.
.SH RETURN VALUE .SH RETURN VALUE
CURLE_OK - Engine set as default. Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or
CURLE_OUT_OF_MEMORY if there was insufficient heap space.
CURLE_SSL_ENGINE_SETFAILED - Engine could not be set as default.
CURLE_NOT_BUILT_IN - Option not built in, OpenSSL is not the SSL backend.
CURLE_UNKNOWN_OPTION - Option not recognized.
CURLE_OUT_OF_MEMORY - Insufficient heap space.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_SSLENGINE "(3), " CURLOPT_SSLCERT "(3), " .BR CURLOPT_SSLENGINE "(3), " CURLOPT_SSLCERT "(3), "

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -50,88 +50,18 @@ callback's error code. Set the \fIuserptr\fP argument with the
This function will get called on all new connections made to a server, during This function will get called on all new connections made to a server, during
the SSL negotiation. The SSL_CTX pointer will be a new one every time. the SSL negotiation. The SSL_CTX pointer will be a new one every time.
To use this properly, a non-trivial amount of knowledge of your SSL library is To use this properly, a non-trivial amount of knowledge of your SSL library
necessary. For example, you can use this function to call library-specific is necessary. For example, you can use this function to call library-specific
callbacks to add additional validation code for certificates, and even to callbacks to add additional validation code for certificates, and even to
change the actual URI of a HTTPS request. change the actual URI of a HTTPS request (example used in the lib509 test
case). See also the example section for a replacement of the key, certificate
and trust file settings.
.SH DEFAULT .SH DEFAULT
NULL NULL
.SH PROTOCOLS .SH PROTOCOLS
All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
.SH EXAMPLE .SH EXAMPLE
.nf TODO
/* OpenSSL specific */
#include <openssl/ssl.h>
#include <curl/curl.h>
#include <stdio.h>
static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
{
X509_STORE *store;
X509 *cert=NULL;
BIO *bio;
char *mypem = /* example CA cert PEM - shortened */
"-----BEGIN CERTIFICATE-----\n"
"MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290\n"
"IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB\n"
"IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA\n"
"Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO\n"
"GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk\n"
"zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW\n"
"omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\n"\
"-----END CERTIFICATE-----\n";
/* get a BIO */
bio=BIO_new_mem_buf(mypem, -1);
/* use it to read the PEM formatted certificate from memory into an X509
* structure that SSL can use
*/
PEM_read_bio_X509(bio, &cert, 0, NULL);
if(cert == NULL)
printf("PEM_read_bio_X509 failed...\n");
/* get a pointer to the X509 certificate store (which may be empty!) */
store=SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
/* add our certificate to this store */
if(X509_STORE_add_cert(store, cert)==0)
printf("error adding certificate\n");
/* decrease reference counts */
X509_free(cert);
BIO_free(bio);
/* all set to go */
return CURLE_OK;
}
int main(void)
{
CURL * ch;
CURLcode rv;
rv=curl_global_init(CURL_GLOBAL_ALL);
ch=curl_easy_init();
rv=curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM");
rv=curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L);
rv=curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
/* Retrieve page using cacerts' certificate -> will succeed
* load the certificate by installing a function doing the nescessary
* "modifications" to the SSL CONTEXT just before link init
*/
rv=curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
rv=curl_easy_perform(ch);
if(rv==CURLE_OK)
printf("*** transfer succeeded ***\n");
else
printf("*** transfer failed ***\n");
curl_easy_cleanup(ch);
curl_global_cleanup();
return rv;
}
.fi
.SH AVAILABILITY .SH AVAILABILITY
Added in 7.11.0 for OpenSSL. Added in 7.42.0 for wolfSSL/CyaSSL. Other SSL Added in 7.11.0 for OpenSSL. Added in 7.42.0 for wolfSSL/CyaSSL. Other SSL
backends not supported. backends not supported.

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