diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-01-11 01:22:31 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-01-11 01:22:31 (GMT) |
commit | aeb08658107e925476f97668233fb6ae85063099 (patch) | |
tree | 409bba18e30c03c3b56d5453287c53e5a728e1f3 /Source/CTest/Curl/Testing | |
parent | 3587c439a813638b6077dae3c6d5f70324d77f25 (diff) | |
download | CMake-aeb08658107e925476f97668233fb6ae85063099.zip CMake-aeb08658107e925476f97668233fb6ae85063099.tar.gz CMake-aeb08658107e925476f97668233fb6ae85063099.tar.bz2 |
Add curl testing
Diffstat (limited to 'Source/CTest/Curl/Testing')
-rw-r--r-- | Source/CTest/Curl/Testing/curltest.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Source/CTest/Curl/Testing/curltest.c b/Source/CTest/Curl/Testing/curltest.c new file mode 100644 index 0000000..106483d --- /dev/null +++ b/Source/CTest/Curl/Testing/curltest.c @@ -0,0 +1,85 @@ +#include "curl/curl.h" + +int GetFtpFile(void) +{ + int retVal = 0; + CURL *curl; + CURLcode res; + curl = curl_easy_init(); + if(curl) + { + /* Get curl 7.9.2 from sunet.se's FTP site: */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://public.kitware.com/pub/cmake/cygwin/setup.hint"); + res = curl_easy_perform(curl); + if ( res != 0 ) + { + printf("Error fetching: http://www.cmake.org/\n"); + retVal = 1; + } + + /* always cleanup */ + curl_easy_cleanup(curl); + } + else + { + printf("Cannot create curl object\n"); + retVal = 1; + } + return retVal; +} + +int GetWebFile(void) +{ + int retVal = 0; + CURL *curl; + CURLcode res; + curl = curl_easy_init(); + if(curl) + { + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + + /* get the first document */ + curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/"); + res = curl_easy_perform(curl); + if ( res != 0 ) + { + printf("Error fetching: http://www.cmake.org/\n"); + retVal = 1; + } + + + /* get another document from the same server using the same + connection */ + curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/HTML/Index.html"); + res = curl_easy_perform(curl); + if ( res != 0 ) + { + printf("Error fetching: http://www.cmake.org/HTML/Index.html\n"); + retVal = 1; + } + + /* always cleanup */ + curl_easy_cleanup(curl); + } + else + { + printf("Cannot create curl object\n"); + retVal = 1; + } + + return retVal; +} + +int main(int argc, char **argv) +{ + int retVal = 0; + curl_global_init(CURL_GLOBAL_DEFAULT); + retVal += GetWebFile(); + retVal += GetFtpFile(); + curl_global_cleanup(); + return retVal; +} |