examples: tidy-up headers and includes

To have a more similar layout across examples.

Closes #19580
This commit is contained in:
Viktor Szakats
2025-11-17 23:48:39 +01:00
parent 0a2618b265
commit 3c7cf8eac3
96 changed files with 116 additions and 121 deletions

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
#if !defined(_WIN32) && !defined(MSDOS) && !defined(__AMIGA__)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -30,9 +30,11 @@
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <curl/curl.h>
#include <stdio.h>
#include <curl/curl.h>
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic ignored "-Woverlength-strings"
#endif

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -20,25 +20,27 @@
*
* SPDX-License-Identifier: curl
*
* To compile:
* gcc crawler.c $(pkg-config --cflags --libs libxml-2.0 libcurl)
*
*/
***************************************************************************/
/* <DESC>
* Web crawler based on curl and libxml2 to stress-test curl with
* hundreds of concurrent connections to various servers.
* </DESC>
*/
/*
* To compile:
* gcc crawler.c $(pkg-config --cflags --libs libxml-2.0 libcurl)
*/
#include <libxml/HTMLparser.h>
#include <libxml/xpath.h>
#include <libxml/uri.h>
#include <curl/curl.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <signal.h>
#include <curl/curl.h>
/* Parameters */
static int max_con = 200;
static int max_total = 20000;

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
struct data {

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -62,18 +62,20 @@ callback.
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <sys/poll.h>
#include <curl/curl.h>
#include <ev.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <curl/curl.h>
#define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */

View File

@@ -37,6 +37,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <curl/curl.h>
#ifdef _WIN32

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include <stdio.h>
#include <curl/curl.h>
/* <DESC>
* Delete a single file from an FTP server.
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
static size_t write_cb(void *buffer, size_t size, size_t nmemb, void *stream)
{

View File

@@ -27,6 +27,7 @@
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
static const char data[]=

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,7 +26,6 @@
* chunk of memory instead of storing it in a file.
* </DESC>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -55,14 +55,15 @@
callback.
*/
#include <glib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <curl/curl.h>
#define MSG_OUT g_print /* Change to "g_error" to write to stderr */

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
static size_t write_cb(char *data, size_t n, size_t l, void *userp)

View File

@@ -58,21 +58,22 @@ This is purely a demo app, all retrieved data is simply discarded by the write
callback.
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <sys/poll.h>
#include <curl/curl.h>
#include <event2/event.h>
#include <event2/event_struct.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/cdefs.h>
#define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */

View File

@@ -28,10 +28,11 @@
/*
* LibTidy => https://www.html-tidy.org/
*/
#include <stdio.h>
#include <tidy/tidy.h>
#include <tidy/tidybuffio.h>
#include <curl/curl.h>
/* curl write callback, to fill tidy's input buffer... */

View File

@@ -36,7 +36,9 @@
#include <string.h>
#include <stdlib.h>
#include <string>
#include <curl/curl.h>
#include <libxml/HTMLparser.h>
//

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -36,7 +36,6 @@
#include <string.h>
#include <errno.h>
/* curl stuff */
#include <curl/curl.h>
#ifndef CURLPIPE_MULTIPLEX

View File

@@ -29,7 +29,6 @@
#include <stdlib.h>
#include <string.h>
/* curl stuff */
#include <curl/curl.h>
struct Memory {

View File

@@ -35,7 +35,6 @@
#include <stdlib.h>
#include <string.h>
/* curl stuff */
#include <curl/curl.h>
#ifndef CURLPIPE_MULTIPLEX

View File

@@ -45,7 +45,6 @@
#include <unistd.h>
#endif
/* curl stuff */
#include <curl/curl.h>
#ifndef CURLPIPE_MULTIPLEX

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -27,6 +27,7 @@
*/
#include <stdio.h>
#include <fcntl.h>
#include <curl/curl.h>
static const char olivertwist[]=

View File

@@ -34,6 +34,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <curl/curl.h>
#ifdef _WIN32

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Send email with IMAP
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to send mail using libcurl's IMAP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Retrieve emails from a shared IMAP mailbox
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to fetch mail using libcurl's IMAP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Copy an email from one IMAP folder to another
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to copy a mail from one mailbox folder

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Create a new IMAP folder
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to create a new mailbox folder using

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Delete an IMAP folder
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to delete an existing mailbox folder

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Obtain information about an IMAP folder
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to obtain information about a mailbox

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Retrieve IMAP emails
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to fetch mail using libcurl's IMAP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* List the folders within an IMAP mailbox
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to list the folders within an IMAP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* List the subscribed IMAP folders
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to list the subscribed folders within

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Get IMAP email with the multi interface
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to fetch mail using libcurl's IMAP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Perform an IMAP noop
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to perform a noop using libcurl's IMAP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Search for new IMAP emails
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to search for new messages using

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* IMAP with implicit SSL
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to fetch mail using libcurl's IMAP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Modify the properties of an email over IMAP
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to modify an existing mail using

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* IMAP using TLS
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to fetch mail using libcurl's IMAP

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,11 +26,9 @@
* transfers in parallel.
* </DESC>
*/
#include <stdio.h>
#include <string.h>
/* curl stuff */
#include <curl/curl.h>
/*

View File

@@ -25,11 +25,9 @@
* multi interface and debug callback
* </DESC>
*/
#include <stdio.h>
#include <string.h>
/* curl stuff */
#include <curl/curl.h>
#define TRUE 1

View File

@@ -28,7 +28,6 @@
#include <stdio.h>
#include <string.h>
/* curl stuff */
#include <curl/curl.h>
/*

View File

@@ -21,15 +21,15 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* multi_socket API using libevent
* </DESC>
*/
#include <stdio.h>
#include <stdlib.h>
#include <event2/event.h>
#include <curl/curl.h>
static struct event_base *base;

View File

@@ -25,12 +25,10 @@
* using the multi interface to do a multipart formpost without blocking
* </DESC>
*/
/*
* Warning: this example uses the deprecated form api. See "multi-post.c"
* for a similar example using the mime api.
* Warning: this example uses the deprecated form API. See "multi-post.c"
* for a similar example using the mime API.
*/
#include <stdio.h>
#include <string.h>

View File

@@ -26,7 +26,6 @@
* transfers in parallel without curl_multi_wait/poll.
* </DESC>
*/
#include <stdio.h>
#include <string.h>
@@ -36,7 +35,6 @@
#include <unistd.h>
#endif
/* curl stuff */
#include <curl/curl.h>
/*

View File

@@ -25,7 +25,6 @@
* using the multi interface to do a multipart formpost without blocking
* </DESC>
*/
#include <stdio.h>
#include <string.h>

View File

@@ -29,7 +29,6 @@
#include <stdio.h>
#include <string.h>
/* curl stuff */
#include <curl/curl.h>
/*

View File

@@ -25,7 +25,6 @@
* multi_socket API using libuv
* </DESC>
*/
/* Use the socket_action interface to download multiple files in parallel,
powered by libuv.
@@ -38,7 +37,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
#include <curl/curl.h>
/* object to pass to the callbacks */

View File

@@ -29,7 +29,9 @@
/* Requires: HAVE_PTHREAD_H */
#include <stdio.h>
#include <pthread.h>
#include <curl/curl.h>
#define NUMT 4

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
#if !CURL_AT_LEAST_VERSION(7, 62, 0)

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Retrieve emails from a shared POP3 mailbox
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to retrieve mail using libcurl's POP3

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Delete POP3 emails
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to delete an existing mail using

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* List the contents of a POP3 mailbox
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example using libcurl's POP3 capabilities to list the

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Get POP3 email using the multi interface
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to retrieve mail using libcurl's POP3

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Perform a POP3 noop
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to perform a noop using libcurl's POP3

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Retrieve POP3 email
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to retrieve mail using libcurl's POP3

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Get POP3 email using implicit SSL
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to retrieve mail using libcurl's POP3

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Obtain POP3 message statistics
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to obtain message statistics using

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* POP3 using TLS
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to retrieve mail using libcurl's POP3

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* POP3 example showing how to retrieve only the headers of an email
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example showing how to retrieve only the headers of a mail

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* List the contents of a POP3 mailbox by unique ID
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
/* This is a simple example using libcurl's POP3 capabilities to list the

View File

@@ -27,6 +27,7 @@
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* silly test data to POST */

View File

@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
struct MemoryStruct {

View File

@@ -25,7 +25,6 @@
* HTTP Multipart formpost with file upload and two additional parts.
* </DESC>
*/
/*
* Example code that uploads a filename 'foo' to a remote script that accepts
* "HTML form based" (as described in RFC 1738) uploads using HTTP POST.
@@ -41,7 +40,6 @@
* <input type="submit" value="send" name="submit">
* </form>
*/
#include <stdio.h>
#include <string.h>

View File

@@ -37,7 +37,6 @@
* </form>
*
*/
#include <stdio.h>
#include <string.h>

View File

@@ -27,6 +27,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
#if !CURL_AT_LEAST_VERSION(7,87,0)

View File

@@ -27,6 +27,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -25,9 +25,9 @@
* Demonstrate curl_easy_send() and curl_easy_recv() usage.
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* Avoid warning in FD_SET() with pre-2020 Cygwin/MSYS releases:

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
static void my_lock(CURL *curl, curl_lock_data data,

View File

@@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)

View File

@@ -27,6 +27,7 @@
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
int main(void)

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Send email on behalf of another user with SMTP
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/*

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Expand an SMTP email mailing list
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to expand an email mailing list.

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Send email with SMTP
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/*

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Send SMTP mime emails
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to send mime mail using libcurl's SMTP

View File

@@ -21,13 +21,12 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Send SMTP email with the multi interface
* </DESC>
*/
#include <string.h>
#include <curl/curl.h>
/* This is an example showing how to send mail using libcurl's SMTP

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Send SMTP email using implicit SSL
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to send mail using libcurl's SMTP

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Send SMTP email using implicit TLS
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to send mail using libcurl's SMTP

View File

@@ -21,14 +21,13 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* <DESC>
* Verify an SMTP email address
* </DESC>
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
/* This is a simple example showing how to verify an email address from an

View File

@@ -32,12 +32,12 @@
* gcc -Wall -I/usr/local/include xmlstream.c -lcurl -lexpat -o xmlstream
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <expat.h>
#include <curl/curl.h>
struct MemoryStruct {