curl/docs/examples
Viktor Szakats a3585c9576
Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3)
`Makefile.mk` supported MS-DOS and Amiga, but `./configure` also
supported them in a better tested and more flexible way.

This patch also adds CMake support for MS-DOS/DJGPP and Amiga OS 3.

`Makefile.mk` was not maintained. Delete it in favour of first-tier
build methods.

Also include some non-MS-DOS/AmigaOS-specific tidy-up, see details at
the end of this message.

Details:

- fix/silence all MS-DOS/DJGPP build warnings and issues.
- add MS-DOS support to cmake.
  - default to `ENABLE_THREADED_RESOLVER=OFF` for MS-DOS.
  - add support for `WATT_ROOT`.
  - use static libcurl with MS-DOS.
  - fixup default CMake suffixes/prefixes for DJGPP.
  - disable hidden symbols for MS-DOS. Not supported on MS-DOS.
  - opt-in MS-DOS into `USE_UNIX_SOCKETS`.
- improve MS-DOS support in autotools.
  - default to `--disable-threaded-resolver` for MS-DOS.
- make sure to use `close_s()` (from Watt-32) with autotools and cmake.
  `Makefile.mk` used it before this patch.
- GHA: add DJGPP cmake (~30s) and autotools (~60s) build jobs.
  Also build tests and examples with cmake.
- improve AmigaOS support in autotools:
  - configure: detect `CloseSocket()` when it's a macro.
  - configure: fix `IoctlSocket` detection on AmigaOS.
  - curl-amissl.m4: pass AmiSSL libs to tests/servers.
- add AmigaOS3 support to cmake:
  - cmake: fix `HAVE_IOCTLSOCKET_CAMEL` and
    `HAVE_IOCTLSOCKET_CAMEL_FIONBIO` detections.
  - set necessary system libs.
  - add AmiSSL support.
  - inet_ntop, inet_pton: fix using it for AmigaOS. cmake detects them,
    and they did not compile with AmigaOS.
  - cmake: better sync `gethostname` detection with autotools.
    Fixes detection for AmigaOS, where `gethostname` is a macro.
  - cmake: fix `sys/utime.h` detection on AmigaOS.
  - cmake: force-disable `getaddrinfo` for AmigaOS.
  - cmake: tweak threading and static/shared default for AmigaOS.
  - cmake: rely on manual variable `AMIGA` to enable the platform.
- GHA: add AmigaOS cmake and autotools (~45s) jobs.
  Also build tests and examples with cmake.
- INSTALL: update MS-DOS and AmigaOS build instructions.
- amigaos: fix `-Wpointer-sign` and
  `zero or negative size array '_args'` in `Printf()`.
- amigaos: fix `-Wpointer-sign`
- amigaos: fix `-Wredundant-decls` `errno` and `h_errno`.
- amigaos: brute-force silence `lseek()` size warnings.
- amigaos: server/resolve: silence `-Wdiscarded-qualifiers`.
- amigaos: server/resolve: fix `-Wpointer-sign`.
- amigaos: fix `CURL_SA_FAMILY_T` type.
- nonblock: prefer `HAVE_IOCTLSOCKET_CAMEL_FIONBIO` for AmigaOS.
  `ioctl` is also detected, but fails when used. Make the above override
  it for a successful build.
  Authored-by: Darren Banfi
  Fixes #15537
  Closes #15603
- tftpd: prefer `HAVE_IOCTLSOCKET_CAMEL_FIONBIO` for AmigaOS.
- tftpd: tidy-up conditional code.
- curl: set stack size to 16384 for AmigaOS3/4
  Overriding the default 4096.
  Suggested-by: Darren Banfi
  Ref: https://github.com/curl/curl/pull/15543#issuecomment-2498783123
  Ref: https://wiki.amigaos.net/wiki/Controlling_Application_Stack
- functypes.h: fix `SEND_QUAL_ARG2` for AmigaOS.
- tftp: add missing cast in sendto() call for AmigaOS.
- getinfo: fix warning with AmigaOS.
- tool_operate: silence warning with AmigaOS
- amigaos: fix building libtests due to missing `RLIMIT_NOFILE`.
- curl_gethostname: silence warning for AmigaOS.
- ftp: silence `-Wtype-limits` for AmigaOS.
- libtest: fix timeval initialization for AmigaOS.
- examples: fix `timeval` initialization for AmigaOS.
- examples: silence warning for AmigaOS.
- configure: fix IPv6 detection for cross-builds.
- netrc: fix to build with AmigaOS cleanly.
- buildinfo: detect and add `DOS` tag for MS-DOS builds.
- buildinfo: add `AMIGA` to buildinfo.txt in auttools.
- build: move `USE_WATT32` macro definition to cmake/configure.

Non-MS-DOS/AmigeOS-specific tidy-ups:

- configure: sync `sa_family_t` detection with cmake.
- configure: sync `ADDRESS_FAMILY` detection signals with cmake.
- doh: use `CURL_SA_FAMILY_T`.
- lib: drop mingw-specific `CURL_SA_FAMILY_T` workaround.
- cmake: extend instead of override check-specific
  configurations/requirements.
  This allows to honor global requirements added earlier.
  Necessary for AmigaOS for example.
- cmake: omit warning on disabled IPv6 for MS-DOS and AmigaOS.
  No IPv6 support on these platforms. Also sync with autotools.
- lib1960: use libcurl `inet_pton()` wrapper.
- cmake: detect LibreSSL (to match autotools).
- cmake: say the specific OpenSSL flavour detected.
- hostip: add missing `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` guard.
- lib: simplify classic mac feature guards.

Follow-up to a8861b6ccd #9764

Closes #15543
2024-12-16 23:20:55 +01:00
..
.checksrc checksrc: ban use of sscanf() 2024-12-13 09:43:05 +01:00
.gitignore examples: add missing binaries to .gitignore 2024-06-14 13:25:55 +02:00
10-at-a-time.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
adddocsref.pl copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01: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: use present tense in comments 2024-02-27 16:19:43 +01:00
anyauthput.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
cacertinmem.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
certinfo.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
chkspeed.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
CMakeLists.txt cmake: namespace functions and macros 2024-12-16 21:55:00 +01:00
connect-to.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
cookie_interface.c cmake: separate target for examples, optimize CI, fix fallouts 2024-09-20 23:53:33 +02:00
crawler.c example/crawler: make it use a few more options 2023-06-19 09:06:41 +02:00
debug.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
default-scheme.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
ephiperfifo.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
evhiperfifo.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
externalsocket.c examples: fix compiling with MSVC 2024-05-26 22:43:04 +02:00
fileupload.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
ftp-wildcard.c examples: fix/silence -Wsign-conversion 2024-05-11 11:11:32 +02:00
ftpget.c build: fix -Wconversion/-Wsign-conversion warnings 2023-12-20 15:38:45 +00:00
ftpgetinfo.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
ftpgetresp.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
ftpsget.c build: fix -Wconversion/-Wsign-conversion warnings 2023-12-20 15:38:45 +00:00
ftpupload.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
ftpuploadfrommem.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
ftpuploadresume.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
getinfo.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
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 lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
headerapi.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
hiperfifo.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
href_extractor.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
hsts-preload.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
htmltidy.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
htmltitle.cpp misc: fix spelling mistakes 2023-05-23 10:42:09 +02:00
http2-download.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
http2-pushinmemory.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
http2-serverpush.c cmake: separate target for examples, optimize CI, fix fallouts 2024-09-20 23:53:33 +02:00
http2-upload.c build: fix clang-cl builds, add CI job 2024-10-30 23:15:32 +01:00
http3-present.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
http3.c examples: use present tense in comments 2024-02-27 16:19:43 +01: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 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
httpput-postfields.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
httpput.c tidy-up: OS names 2024-08-04 19:17:45 +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 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
imap-delete.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
imap-examine.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
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 docs: remove use of the word 'very' 2023-09-07 22:52:07 +02:00
imap-multi.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-noop.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
imap-search.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
imap-ssl.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
imap-store.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
imap-tls.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
interface.c docs/examples/interface.c: show CURLOPT_INTERFACE use 2023-10-30 12:45:34 +01:00
ipv6.c examples/ipv6.c: new example showing IPv6-only internet transfer 2024-01-10 09:33:03 +01: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 Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) 2024-12-16 23:20:55 +01:00
Makefile.example tidy-up: adjust casing of project names 2024-07-12 13:56:16 +02:00
Makefile.inc examples/range.c: add 2024-01-10 09:33:08 +01:00
maxconnects.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
multi-app.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
multi-debugcallback.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
multi-double.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
multi-event.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
multi-formadd.c build: tidy up deprecation suppression, enable warnings for clang 2024-09-21 00:59:52 +02:00
multi-legacy.c Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) 2024-12-16 23:20:55 +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 example/multi-uv: remove the use of globals 2024-07-27 23:09:44 +02:00
multithread.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +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 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
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 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
pop3-retr.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
pop3-ssl.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
pop3-stat.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
pop3-tls.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
pop3-top.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
pop3-uidl.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
post-callback.c tidy-up: OS names 2024-08-04 19:17:45 +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 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
protofeats.c docs/examples/protofeats.c: Outputs all protocols and features 2023-04-18 08:10:27 +02:00
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 Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) 2024-12-16 23:20:55 +01:00
sepheaders.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
sessioninfo.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
sftpget.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
sftpuploadresume.c copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01: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 cmake: separate target for examples, optimize CI, fix fallouts 2024-09-20 23:53:33 +02:00
smooth-gtk-thread.c examples: use present tense in comments 2024-02-27 16:19:43 +01: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 examples: use present tense in comments 2024-02-27 16:19:43 +01:00
smtp-tls.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
smtp-vrfy.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
sslbackend.c docs: use CURLSSLBACKEND_NONE 2023-09-21 14:15:03 +02:00
synctime.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
threaded-ssl.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
unixsocket.c tidy-up: OS names 2024-08-04 19:17:45 +02:00
url2file.c examples: delete unused includes 2024-05-28 00:27:04 +02:00
urlapi.c examples: make use of CURLOPT_(REDIR_|)PROTOCOLS_STR 2023-06-18 11:09:13 +02:00
usercertinmem.c tidy-up: adjust casing of project names 2024-07-12 13:56:16 +02:00
version-check.pl copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
websocket-cb.c examples: use present tense in comments 2024-02-27 16:19:43 +01:00
websocket.c build: fix MSVC UWP builds 2024-11-28 14:24:03 +01:00
xmlstream.c examples: delete unused includes 2024-05-28 00:27:04 +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.