Mercurial > octave-nkf
diff src/DLD-FUNCTIONS/urlwrite.cc @ 9885:dd3fc8ba4796
support libcurl < 7.19
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 29 Nov 2009 07:49:40 +0100 |
parents | 7f77e5081e83 |
children | 84a7c11ff928 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/urlwrite.cc Sat Nov 28 15:46:10 2009 -0500 +++ b/src/DLD-FUNCTIONS/urlwrite.cc Sun Nov 29 07:49:40 2009 +0100 @@ -51,6 +51,7 @@ #if defined (HAVE_CURL) #include <curl/curl.h> +#include <curl/curlver.h> #include <curl/types.h> #include <curl/easy.h> @@ -559,10 +560,23 @@ setopt (CURLOPT_NOBODY, 1); // Set the username and password +#if (LIBCURL_VERSION_NUM >= 0x071300) + // This is possible since cURL 7.19. if (user.length () != 0) setopt (CURLOPT_USERNAME, user.c_str()); if (passwd.length () != 0) setopt (CURLOPT_PASSWORD, passwd.c_str()); +#else + // Probably needs to be static to remain valid long enough. + static std::string userpwd; + if (user.length () != 0) + { + userpwd = user; + if (passwd.length () != 0) + userpwd += ':' + passwd; + setopt (CURLOPT_USERPWD, userpwd.c_str ()); + } +#endif // Define our callback to get called when there's data to be written. setopt (CURLOPT_WRITEFUNCTION, write_data);