lib544.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "test.h"
00023 
00024 #include "memdebug.h"
00025 
00026 static char teststring[] =
00027 #ifdef CURL_DOES_CONVERSIONS
00028   /* ASCII representation with escape sequences for non-ASCII platforms */
00029   "\x54\x68\x69\x73\x00\x20\x69\x73\x20\x74\x65\x73\x74\x20\x62\x69\x6e\x61"
00030   "\x72\x79\x20\x64\x61\x74\x61\x20\x77\x69\x74\x68\x20\x61\x6e\x20\x65\x6d"
00031   "\x62\x65\x64\x64\x65\x64\x20\x4e\x55\x4c\x20\x62\x79\x74\x65\x0a";
00032 #else
00033 {   'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ',
00034     'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ',
00035     'w', 'i', 't', 'h', ' ', 'a', 'n', ' ',
00036     'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'};
00037 #endif
00038 
00039 
00040 int test(char *URL)
00041 {
00042   CURL *curl;
00043   CURLcode res=CURLE_OK;
00044 
00045   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00046     fprintf(stderr, "curl_global_init() failed\n");
00047     return TEST_ERR_MAJOR_BAD;
00048   }
00049 
00050   curl = curl_easy_init();
00051   if(!curl) {
00052     fprintf(stderr, "curl_easy_init() failed\n");
00053     curl_global_cleanup();
00054     return TEST_ERR_MAJOR_BAD;
00055   }
00056 
00057   /* First set the URL that is about to receive our POST. */
00058   test_setopt(curl, CURLOPT_URL, URL);
00059 
00060 #ifdef LIB545
00061   test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring);
00062 #endif
00063 
00064   test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
00065 
00066   test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
00067   test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
00068 
00069   /* Update the original data to detect non-copy. */
00070   strcpy(teststring, "FAIL");
00071 
00072 #ifdef LIB545
00073   {
00074     CURL *handle2;
00075     handle2 = curl_easy_duphandle(curl);
00076     curl_easy_cleanup(curl);
00077 
00078     curl = handle2;
00079   }
00080 #endif
00081 
00082   /* Now, this is a POST request with binary 0 embedded in POST data. */
00083   res = curl_easy_perform(curl);
00084 
00085 test_cleanup:
00086 
00087   /* always cleanup */
00088   curl_easy_cleanup(curl);
00089   curl_global_cleanup();
00090 
00091   return (int)res;
00092 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05