curl-curl/docs/examples
Viktor Szakats 9678ff5b1b
build: avoid overriding system open and stat symbols
Replace them by `curlx_open()` and `curlx_stat()`.

To make it obvious in the source code what is being executed.

Also:
- tests/server: stop overriding `open()` for test servers.
  This is critical for the call made from the signal handler.
  For other calls, it's an option to use `curlx_open()`, but
  doesn't look important enough to do it, following the path
  taken with `fopen()`.

Follow-up to 10bac43b87 #18774
Follow-up to 20142f5d06 #18634
Follow-up to bf7375ecc5 #18503

Closes #18776
2025-09-30 16:30:09 +02:00
..
.checksrc build: avoid overriding system open and stat symbols 2025-09-30 16:30:09 +02:00
.gitignore websocket: support CURLOPT_READFUNCTION 2025-08-11 23:28:54 +02:00
10-at-a-time.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
adddocsref.pl scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
address-scope.c Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) 2024-12-16 23:20:55 +01:00
altsvc.c examples: drop long cast for CURLALTSVC_* 2025-08-01 18:54:27 +02:00
anyauthput.c build: avoid overriding system open and stat symbols 2025-09-30 16:30:09 +02:00
block_ip.c tidy-up: formatting 2025-08-23 01:12:27 +02:00
cacertinmem.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
certinfo.c
chkspeed.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
CMakeLists.txt cmake: clang detection tidy-ups 2025-09-21 15:26:49 +02:00
connect-to.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
cookie_interface.c tidy-up: prefer return over exit(), fix fallouts 2025-02-28 13:11:41 +01:00
crawler.c checksrc: reduce exceptions, apply again to curlx 2025-06-27 17:33:35 +02:00
debug.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
default-scheme.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
ephiperfifo.c tidy-up: whitespace 2025-09-15 15:00:11 +02:00
evhiperfifo.c tidy-up: whitespace 2025-09-15 15:00:11 +02:00
externalsocket.c lib/src/docs/test: improve curl_easy_setopt() calls 2025-04-23 23:44:55 +02:00
fileupload.c build: avoid overriding system open and stat symbols 2025-09-30 16:30:09 +02:00
ftp-delete.c docs/examples: add ftp-delete.c 2025-06-05 12:17:21 +02:00
ftp-wildcard.c lib/src/docs/test: improve curl_easy_setopt() calls 2025-04-23 23:44:55 +02:00
ftpget.c
ftpgetinfo.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
ftpgetresp.c clang-tidy: add to CI, add cmake support, fix fallouts 2024-12-27 13:42:32 +01:00
ftpsget.c
ftpupload.c build: avoid overriding system open and stat symbols 2025-09-30 16:30:09 +02:00
ftpuploadfrommem.c GHA/checksrc: expand spellcheck, fix issues found 2025-07-21 16:09:01 +02:00
ftpuploadresume.c examples: fix two issues found by CodeQL 2025-09-18 20:14:21 +02:00
getinfo.c
getinmemory.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
getredirect.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
getreferrer.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
ghiper.c CURLOPT: drop redundant long casts 2025-07-28 10:32:13 +02:00
headerapi.c tidy-up: assortment of small fixes 2025-09-21 16:50:14 +02:00
hiperfifo.c tidy-up: whitespace 2025-09-15 15:00:11 +02:00
hsts-preload.c CURLOPT: drop redundant long casts 2025-07-28 10:32:13 +02:00
htmltidy.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
htmltitle.cpp tidy-up: more whitespace/indent, comments 2025-07-25 11:47:51 +02:00
http2-download.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
http2-pushinmemory.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
http2-serverpush.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
http2-upload.c build: avoid overriding system open and stat symbols 2025-09-30 16:30:09 +02:00
http3-present.c
http3.c CURLOPT: drop redundant long casts 2025-07-28 10:32:13 +02:00
http-options.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
http-post.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
httpcustomheader.c
httpput-postfields.c GHA/checksrc: expand spellcheck, fix issues found 2025-07-21 16:09:01 +02:00
httpput.c build: avoid overriding system open and stat symbols 2025-09-30 16:30:09 +02:00
https.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-append.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-authzid.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-copy.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-create.c
imap-delete.c
imap-examine.c
imap-fetch.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-list.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-lsub.c
imap-multi.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-noop.c
imap-search.c
imap-ssl.c spelling: 'a' vs 'an' 2025-05-30 11:38:35 +02:00
imap-store.c
imap-tls.c CURLOPT: drop redundant long casts 2025-07-28 10:32:13 +02:00
interface.c
ipv6.c curl.h: make CURL_IPRESOLVE_* symbols defined as longs 2025-07-07 14:37:12 +02:00
keepalive.c tcpkeepalive: add CURLOPT_TCP_KEEPCNT and --keepalive-cnt 2024-06-12 09:31:17 +02:00
localport.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
Makefile.am build: avoid overriding system symbols for socket functions 2025-09-20 13:44:59 +02:00
Makefile.example Makefile.example: simplify and make it configurable 2025-09-16 11:25:55 +02:00
Makefile.inc examples: remove href_extractor.c 2025-08-12 14:02:43 +02:00
maxconnects.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
multi-app.c docs: use lowercase curl and libcurl 2025-01-02 17:15:54 +01:00
multi-debugcallback.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
multi-double.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
multi-event.c checksrc: reduce exceptions, apply again to curlx 2025-06-27 17:33:35 +02:00
multi-formadd.c build: tidy up deprecation suppression, enable warnings for clang 2024-09-21 00:59:52 +02:00
multi-legacy.c docs: use lowercase curl and libcurl 2025-01-02 17:15:54 +01:00
multi-post.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
multi-single.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
multi-uv.c checksrc: reduce exceptions, apply again to curlx 2025-06-27 17:33:35 +02:00
multithread.c tidy-up: move literal to the right side of comparisons 2025-07-27 22:35:17 +02:00
netrc.c examples/netrc.c: add 2024-01-10 09:33:06 +01:00
parseurl.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
persistent.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
pop3-authzid.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
pop3-dele.c
pop3-list.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
pop3-multi.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
pop3-noop.c
pop3-retr.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
pop3-ssl.c spelling: 'a' vs 'an' 2025-05-30 11:38:35 +02:00
pop3-stat.c
pop3-tls.c CURLOPT: drop redundant long casts 2025-07-28 10:32:13 +02:00
pop3-top.c
pop3-uidl.c
post-callback.c GHA/checksrc: expand spellcheck, fix issues found 2025-07-21 16:09:01 +02:00
postinmemory.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
postit2-formadd.c build: tidy up deprecation suppression, enable warnings for clang 2024-09-21 00:59:52 +02:00
postit2.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
progressfunc.c
protofeats.c
range.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
README.md GHA: silence proselint warnings and an error 2024-10-15 16:44:17 +02:00
resolve.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
rtsp-options.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
sendrecv.c build: fix compiling with GCC 4.x versions 2025-01-22 11:26:15 +01:00
sepheaders.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
sessioninfo.c tidy-up: more whitespace/indent, comments 2025-07-25 11:47:51 +02:00
sftpget.c CURLOPT: bump remaining macros to long 2025-08-01 18:49:23 +02:00
sftpuploadresume.c tidy-up: move literal to the right side of comparisons 2025-07-27 22:35:17 +02:00
shared-connection-cache.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
simple.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
simplepost.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
simplessl.c GHA/checksrc: expand spellcheck, fix issues found 2025-07-21 16:09:01 +02:00
smooth-gtk-thread.c tidy-up: move literal to the right side of comparisons 2025-07-27 22:35:17 +02:00
smtp-authzid.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
smtp-expn.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
smtp-mail.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
smtp-mime.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
smtp-multi.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
smtp-ssl.c spelling: 'a' vs 'an' 2025-05-30 11:38:35 +02:00
smtp-tls.c CURLOPT: drop redundant long casts 2025-07-28 10:32:13 +02:00
smtp-vrfy.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
sslbackend.c
synctime.c build: avoid overriding system symbols for socket functions 2025-09-20 13:44:59 +02:00
threaded-ssl.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
unixsocket.c spelling: file system 2025-08-22 15:53:41 +02:00
url2file.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
urlapi.c
usercertinmem.c tidy-up: drop stray "unused" comments 2025-09-03 16:31:16 +02:00
version-check.pl scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
websocket-cb.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
websocket-updown.c docs: fix typo (staring -> starting) 2025-09-02 10:11:51 +02:00
websocket.c websocket example: cast print values to unsigned int 2025-08-21 09:29:59 +02:00
xmlstream.c checksrc: reduce exceptions, apply again to curlx 2025-06-27 17:33:35 +02:00

libcurl examples

This directory is for libcurl programming examples. They are meant to show some simple steps on how you can build your own application to take full advantage of libcurl.

If you end up with other small but still useful example sources, please mail them for submission in future packages and on the website.

Building

The Makefile.example is an example Makefile that could be used to build these examples. Just edit the file according to your system and requirements first.

Most examples should build fine using a command line like this:

`curl-config --cc --cflags --libs` -o example-my example.c

Some compilers do not like having the arguments in this order but instead want you do reorganize them like:

`curl-config --cc` -o example-my example.c `curl-config --cflags --libs`

Please do not use the curl.se site as a test target for your libcurl applications/experiments. Even if some of the examples use that site as a URL at some places, it does not mean that the URLs work or that we expect you to actually torture our website with your tests. Thanks.

Examples

Each example source code file is designed to be and work stand-alone and rather self-explanatory. The examples may at times lack the level of error checks you need in a real world, but that is then only for the sake of readability: to make the code smaller and easier to follow.