curl-curl/docs/examples
Viktor Szakats ce6c441cf2
build: drop redundant HAVE_PTHREAD_H guard
Prior to this patch code used either `HAVE_PTHREAD_H`, or
`HAVE_THREADS_POSIX`, or both, to decide if POSIX Threads support is
present. In effect requiring both to be defined for a consistent build.

Drop detecting and guarding for `pthread.h`, and assume it present when
`HAVE_THREADS_POSIX` is set.

OS/400 had `HAVE_PTHREAD_H` set, but not `HAVE_THREADS_POSIX`, which
possibly left threading disabled in most sources.

Ref: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/pthread.h.html
Ref: 930f2e8227 #21144

Closes #21158
2026-03-30 18:57:07 +02:00
..
.checksrc build: tidy up curl-specific fstat calls and stat struct type 2026-02-02 18:57:13 +01:00
.gitignore examples/threaded-ssl: delete in favor of examples/threaded 2025-12-17 00:32:20 +01:00
10-at-a-time.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
adddocsref.pl perl: harden external command invocations 2026-03-26 14:20:07 +01:00
address-scope.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
altsvc.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
anyauthput.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
block_ip.c badwords: rework exceptions, fix many of them 2026-03-12 01:01:16 +01:00
cacertinmem.c examples: drop warning silencers no longer hit 2026-03-12 01:01:16 +01:00
certinfo.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
chkspeed.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
CMakeLists.txt cmake: drop support for CMake 3.17 and older 2026-03-21 13:24:47 +01:00
connect-to.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
cookie_interface.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
crawler.c tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
debug.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
default-scheme.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ephiperfifo.c badwords: avoid 'simply' 2026-03-10 19:34:06 +01:00
evhiperfifo.c badwords: avoid 'simply' 2026-03-10 19:34:06 +01:00
externalsocket.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
fileupload.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ftp-delete.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ftp-wildcard.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ftpget.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ftpgetinfo.c clang-tidy: drop redundant casts 2026-02-19 15:27:17 +01:00
ftpgetresp.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ftpsget.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ftpupload.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
ftpuploadfrommem.c docs: rename CURLcode variables to 'result' 2025-12-17 08:55:12 +01:00
ftpuploadresume.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
getinfo.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
getinmemory.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
getredirect.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
getreferrer.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ghiper.c badwords: avoid 'simply' 2026-03-10 19:34:06 +01:00
headerapi.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
hiperfifo.c badwords: avoid 'simply' 2026-03-10 19:34:06 +01:00
hsts-preload.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
htmltidy.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
htmltitle.cpp docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
http2-download.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
http2-pushinmemory.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
http2-serverpush.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
http2-upload.c badwords: rework exceptions, fix many of them 2026-03-12 01:01:16 +01:00
http3-present.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
http3.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
http-options.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
http-post.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
httpcustomheader.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
httpput-postfields.c badwords: rework exceptions, fix many of them 2026-03-12 01:01:16 +01:00
httpput.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
https.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-append.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
imap-authzid.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-copy.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-create.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
imap-delete.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
imap-examine.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
imap-fetch.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-list.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-lsub.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
imap-multi.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-noop.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
imap-search.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
imap-ssl.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-store.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
imap-tls.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
interface.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
ipv6.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
keepalive.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
localport.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
log_failed_transfers.c badwords: prefer 'null-terminated' 2026-03-18 11:40:13 +01:00
Makefile.am cmake: support building some complicated examples, build them in CI 2025-10-07 19:09:02 +02:00
Makefile.example Makefile.example: make default options more likely to work 2025-10-20 13:52:58 +02:00
Makefile.inc examples/threaded-ssl: delete in favor of examples/threaded 2025-12-17 00:32:20 +01:00
maxconnects.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
multi-app.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
multi-debugcallback.c badwords: avoid 'simply' 2026-03-10 19:34:06 +01:00
multi-double.c badwords: avoid 'simply' 2026-03-10 19:34:06 +01:00
multi-event.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
multi-formadd.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
multi-legacy.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
multi-post.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
multi-single.c badwords: avoid 'simply' 2026-03-10 19:34:06 +01:00
multi-uv.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
netrc.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
parseurl.c examples: tidy-up headers and includes 2025-11-18 02:05:07 +01:00
persistent.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-authzid.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-dele.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-list.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-multi.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-noop.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
pop3-retr.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-ssl.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-stat.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
pop3-tls.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
pop3-top.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
pop3-uidl.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
post-callback.c docs: rename CURLcode variables to 'result' 2025-12-17 08:55:12 +01:00
postinmemory.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
postit2-formadd.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
postit2.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
progressfunc.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
protofeats.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
range.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
README.md stop using the word 'just' 2026-03-03 15:30:22 +01:00
resolve.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
rtsp-options.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
sendrecv.c gcc: guard #pragma diagnostic in core code for <4.6, disable picky warnings 2026-03-18 11:33:37 +01:00
sepheaders.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
sessioninfo.c tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
sftpget.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
sftpuploadresume.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
shared-connection-cache.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
simple.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
simplepost.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
simplessl.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
smooth-gtk-thread.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
smtp-authzid.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
smtp-expn.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
smtp-mail.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
smtp-mime.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
smtp-multi.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
smtp-ssl.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
smtp-tls.c stop using the word 'just' 2026-03-03 15:30:22 +01:00
smtp-vrfy.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
sslbackend.c build: use more const 2026-02-02 12:32:49 +01:00
synctime.c synctime: fix off-by-one read and write to a read-only buffer (Windows) 2026-03-19 11:17:17 +01:00
threaded.c build: drop redundant HAVE_PTHREAD_H guard 2026-03-30 18:57:07 +02:00
unixsocket.c tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
url2file.c tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
urlapi.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
usercertinmem.c examples: drop warning silencers no longer hit 2026-03-12 01:01:16 +01:00
version-check.pl tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
websocket-cb.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01:00
websocket-updown.c tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
websocket.c examples/websocket: fix to sleep more on Windows 2026-03-18 11:37:15 +01:00
xmlstream.c docs: compare result against literal CURLE_OK (where missing) 2026-02-07 19:40:45 +01: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. 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.