add_dependencies(curl-examples ${_target_name})
endif()
target_link_libraries(${_target_name} ${LIB_SELECTED} ${CURL_NETWORK_AND_TIME_LIBS} ${_more_libs})
- target_compile_definitions(${_target_name} PRIVATE "CURL_NO_OLDIES"
- "$<$<BOOL:${WIN32}>:WIN32_LEAN_AND_MEAN>" "$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>")
+ target_compile_definitions(${_target_name} PRIVATE "CURL_NO_OLDIES" "$<$<BOOL:${WIN32}>:WIN32_LEAN_AND_MEAN>")
set_target_properties(${_target_name} PROPERTIES OUTPUT_NAME "${_target}" PROJECT_LABEL "Example ${_target}" UNITY_BUILD OFF)
endforeach()
* one the server supports/wants.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
int main(void) { printf("Platform not supported.\n"); return 1; }
#else
-#ifdef _WIN32
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
+#ifdef _MSC_VER
#ifndef _CRT_NONSTDC_NO_DEPRECATE
-#define _CRT_NONSTDC_NO_DEPRECATE
+#define _CRT_NONSTDC_NO_DEPRECATE /* for strdup() */
+#endif
#endif
+
+#ifdef _WIN32
#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600 /* Requires Windows Vista */
* dd if=/dev/urandom of=file_1M.bin bs=1M count=1
*
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for ctime() */
+#endif
+#endif
#include <stdio.h>
#include <stdlib.h>
* Import and export cookies with COOKIELIST.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for _snprintf() */
+#endif
+#endif
#include <stdio.h>
#include <string.h>
* </DESC>
*/
#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for strerror() */
+#endif
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS /* for inet_addr() */
#endif
* Upload to a file:// URL
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
#include <stdio.h>
-#include <curl/curl.h>
-#include <sys/stat.h>
#include <fcntl.h>
+#include <sys/stat.h>
+
+#include <curl/curl.h>
#ifdef _WIN32
#undef stat
* FTP wildcard pattern matching
* </DESC>
*/
-#include <curl/curl.h>
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
#include <stdio.h>
+#include <curl/curl.h>
+
struct callback_data {
FILE *output;
};
* SPDX-License-Identifier: curl
*
***************************************************************************/
-#include <stdio.h>
-
-#include <curl/curl.h>
-
/* <DESC>
* Get a single file from an FTP server.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
+#include <stdio.h>
+
+#include <curl/curl.h>
struct FtpFile {
const char *filename;
* SPDX-License-Identifier: curl
*
***************************************************************************/
-#include <stdio.h>
-#include <string.h>
-
-#include <curl/curl.h>
-
/* <DESC>
* Checks a single file's size and mtime from an FTP server.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include <curl/curl.h>
static size_t throw_away(void *ptr, size_t size, size_t nmemb, void *data)
{
* SPDX-License-Identifier: curl
*
***************************************************************************/
-#include <stdio.h>
-
-#include <curl/curl.h>
-
/* <DESC>
* Similar to ftpget.c but also stores the received response-lines
* in a separate file using our own callback!
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
+#include <stdio.h>
+
+#include <curl/curl.h>
+
static size_t write_response(void *ptr, size_t size, size_t nmemb, void *data)
{
FILE *writehere = (FILE *)data;
* SPDX-License-Identifier: curl
*
***************************************************************************/
-
-#include <stdio.h>
-
-#include <curl/curl.h>
-
/* <DESC>
* Get a single file from an FTPS server.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
+#include <stdio.h>
+
+#include <curl/curl.h>
struct FtpFile {
const char *filename;
* SPDX-License-Identifier: curl
*
***************************************************************************/
+/* <DESC>
+ * Performs an FTP upload and renames the file just after a successful
+ * transfer.
+ * </DESC>
+ */
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen(), strerror() */
+#endif
+#endif
+
#include <stdio.h>
#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <curl/curl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
+
#ifdef _WIN32
#include <io.h>
#undef stat
#include <unistd.h>
#endif
-/* <DESC>
- * Performs an FTP upload and renames the file just after a successful
- * transfer.
- * </DESC>
- */
-
#define LOCAL_FILE "/tmp/uploadthis.txt"
#define UPLOAD_FILE_AS "while-uploading.txt"
#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS
* Upload to FTP, resuming failed transfers. Active mode.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen(), sscanf() */
+#endif
+#endif
#include <stdlib.h>
#include <stdio.h>
+
#include <curl/curl.h>
/* parse headers for Content-Length */
* Preload domains to HSTS
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for strcpy() */
+#endif
+#endif
+
#include <stdio.h>
#include <string.h>
+
#include <curl/curl.h>
struct entry {
* Multiplexed HTTP/2 downloads over a single connection
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen(), strerror() */
+#endif
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
-#define snprintf _snprintf
-#endif
-
/* curl stuff */
#include <curl/curl.h>
#define CURLPIPE_MULTIPLEX 0L
#endif
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#define snprintf _snprintf
+#endif
+
struct transfer {
FILE *out;
CURL *curl;
* HTTP/2 server push
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen() */
+#endif
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* curl stuff */
#include <curl/curl.h>
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
-#define snprintf _snprintf
-#endif
-
#ifndef CURLPIPE_MULTIPLEX
#error "too old libcurl, cannot do HTTP/2 server push!"
#endif
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#define snprintf _snprintf
+#endif
+
static FILE *out_download;
static void dump(const char *text, unsigned char *ptr, size_t size, char nohex)
* Multiplexed HTTP/2 uploads over a single connection
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for '_snprintf(), fopen(), localtime(),
+ strerror() */
+#endif
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#endif
+/* curl stuff */
+#include <curl/curl.h>
+
+#ifndef CURLPIPE_MULTIPLEX
+/* This little trick makes sure that we do not enable pipelining for libcurls
+ old enough to not have this symbol. It is _not_ defined to zero in a recent
+ libcurl header. */
+#define CURLPIPE_MULTIPLEX 0L
+#endif
+
#ifdef _WIN32
#undef stat
#define stat _stat
#define snprintf _snprintf
#endif
-/* curl stuff */
-#include <curl/curl.h>
-
-#ifndef CURLPIPE_MULTIPLEX
-/* This little trick makes sure that we do not enable pipelining for libcurls
- old enough to not have this symbol. It is _not_ defined to zero in a recent
- libcurl header. */
-#define CURLPIPE_MULTIPLEX 0L
-#endif
-
#ifdef _MSC_VER
#define gettimeofday(a, b) my_gettimeofday((a), (b))
static int my_gettimeofday(struct timeval *tp, void *tzp)
* HTTP PUT with easy interface and read callback
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
* The transfer's log is written to disk only if the transfer fails.
*
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen(), strerror(), vsnprintf() */
+#endif
+#endif
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
+
#include <curl/curl.h>
#ifdef _WIN32
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
#include <windows.h>
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
* Simple HTTP GET that stores the headers in a separate file
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
#include <stdio.h>
#include <stdlib.h>
* Gets a file using an SFTP URL.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
#include <stdio.h>
* Upload to SFTP, resuming a previously aborted transfer.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
#include <stdlib.h>
#include <stdio.h>
+
#include <curl/curl.h>
/* read data to upload */
* Shows HTTPS usage with client certs and optional ssl engine use.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
#include <stdio.h>
#include <curl/curl.h>
* This software synchronises your computer clock only when you issue
* it with --synctime. By default, it only display the webserver's clock.
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen(), gmtime(),
+ localtime(), sscanf() */
+#endif
+#endif
#include <stdio.h>
* Download a given URL into a local file named page.out.
* </DESC>
*/
+#ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
+#endif
+#endif
+
#include <stdio.h>
#include <stdlib.h>
/* Disable Visual Studio warnings: 4127 "conditional expression is constant" */
#pragma warning(disable:4127)
/* Avoid VS2005 and upper complaining about portable C functions. */
-#ifndef _CRT_NONSTDC_NO_DEPRECATE
-#define _CRT_NONSTDC_NO_DEPRECATE /* for strdup(), write(), etc. */
-#endif
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE /* for fopen(), getenv(), etc. */
+#ifndef _CRT_NONSTDC_NO_DEPRECATE /* mingw-w64 v2+. MS SDK ~10+/~VS2017+. */
+#define _CRT_NONSTDC_NO_DEPRECATE /* for close(), fileno(), strdup(),
+ unlink(), etc. */
+#endif
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS /* for __sys_errlist, __sys_nerr, _wfopen(),
+ _wopen(), freopen(), getenv(), gmtime(),
+ sprintf(), strcpy(), wcscpy(), wcsncpy()
+ in tests: localtime(), open(), sscanf() */
#endif
#endif /* _MSC_VER */