Commit Graph

789 Commits

Author SHA1 Message Date
Daniel Stenberg
5d75bcd2ea
examples/range.c: add
Closes #12671
2024-01-10 09:33:08 +01:00
Daniel Stenberg
1404bcdeae
examples/netrc.c: add
Closes #12671
2024-01-10 09:33:06 +01:00
Daniel Stenberg
dd09f88f13
examples/ipv6.c: new example showing IPv6-only internet transfer
Closes #12671
2024-01-10 09:33:03 +01:00
Daniel Stenberg
ebbc6243d7
examples/address-scope.c: renamed from ipv6.c
It shows address scope use really

Closes #12671
2024-01-10 09:32:54 +01:00
Jay Satiro
82cbdd8396 examples/sendrecv: fix comment line length
Caught by checksrc.
2023-12-26 03:28:46 -05:00
Viktor Szakats
95a882d268
build: fix -Wconversion/-Wsign-conversion warnings
Fix remaining warnings in examples and tests which are not suppressed
by the pragma in `lib/curl_setup.h`.

Silence a toolchain issue causing warnings in `FD_SET()` calls with
older Cygwin/MSYS2 builds. Likely fixed on 2020-08-03 by:
https://cygwin.com/git/?p=newlib-cygwin.git;a=commitdiff;h=5717262b8ecfed0f7fab63e2c09c78991e36f9dd

Follow-up to 2dbe75bd7f #12492

Closes #12557
2023-12-20 15:38:45 +00:00
Viktor Szakats
03e7dff8ff
windows: delete redundant headers
`winsock2.h` pulls in `windows.h`. `ws2tcpip.h` pulls in `winsock2.h`.
`winsock2.h` and `ws2tcpip.h` are also pulled by `curl/curl.h`.

Keep only those headers that are not already included, or the code under
it uses something from that specific header.

Closes #12539
2023-12-18 14:56:57 +00:00
Viktor Szakats
c1bc090d65
windows: simplify detecting and using system headers
- autotools, cmake: assume that if we detect Windows, `windows.h`,
  `winsock2.h` and `ws2tcpip.h` do exist.
- lib: fix 3 outlier `#if` conditions to use `USE_WINSOCK` instead of
  looking for `winsock2.h`.
- autotools: merge 3 Windows check methods into one.
- move Watt-32 and lwIP socket support to `setup-win32.h` from
  `config-win32.h`. It opens up using these with all build tools. Also
  merge logic with Windows Sockets.
- fix to assume Windows sockets with the mingw32ce toolchain.
  Follow-up to: 2748c64d60
- cmake: delete unused variable `signature_call_conv` since
  eb33ccd533.
- autotools: simplify `CURL_CHECK_WIN32_LARGEFILE` detection.
- examples/externalsocket: fix header order.
- cmake/OtherTests.cmake: delete Windows-specific `_source_epilogue`
  that wasn't used anymore.
- cmake/OtherTests.cmake: set `WIN32_LEAN_AND_MEAN` for test
  `SIZEOF_STRUCT_SOCKADDR_STORAGE`.

After this patch curl universally uses `_WIN32` to guard
Windows-specific logic. It guards Windows Sockets-specific logic with
`USE_WINSOCK` (this might need further work).

Reviewed-by: Jay Satiro
Closes #12495
2023-12-16 13:13:44 +00:00
Viktor Szakats
3829759bd0
build: enable missing OpenSSF-recommended warnings, with fixes
https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
as of 2023-11-29 [1].

Enable new recommended warnings (except `-Wsign-conversion`):

- enable `-Wformat=2` for clang (in both cmake and autotools).
- add `CURL_PRINTF()` internal attribute and mark functions accepting
  printf arguments with it. This is a copy of existing
  `CURL_TEMP_PRINTF()` but using `__printf__` to make it compatible
  with redefinting the `printf` symbol:
  https://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_5.html#SEC94
- fix `CURL_PRINTF()` and existing `CURL_TEMP_PRINTF()` for
  mingw-w64 and enable it on this platform.
- enable `-Wimplicit-fallthrough`.
- enable `-Wtrampolines`.
- add `-Wsign-conversion` commented with a FIXME.
- cmake: enable `-pedantic-errors` the way we do it with autotools.
  Follow-up to d5c0351055 #2747
- lib/curl_trc.h: use `CURL_FORMAT()`, this also fixes it to enable format
  checks. Previously it was always disabled due to the internal `printf`
  macro.

Fix them:

- fix bug where an `set_ipv6_v6only()` call was missed in builds with
  `--disable-verbose` / `CURL_DISABLE_VERBOSE_STRINGS=ON`.
- add internal `FALLTHROUGH()` macro.
- replace obsolete fall-through comments with `FALLTHROUGH()`.
- fix fallthrough markups: Delete redundant ones (showing up as
  warnings in most cases). Add missing ones. Fix indentation.
- silence `-Wformat-nonliteral` warnings with llvm/clang.
- fix one `-Wformat-nonliteral` warning.
- fix new `-Wformat` and `-Wformat-security` warnings.
- fix `CURL_FORMAT_SOCKET_T` value for mingw-w64. Also move its
  definition to `lib/curl_setup.h` allowing use in `tests/server`.
- lib: fix two wrongly passed string arguments in log outputs.
  Co-authored-by: Jay Satiro
- fix new `-Wformat` warnings on mingw-w64.

[1] 56c0fde389/docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C%2B%2B.md

Closes #12489
2023-12-16 13:12:37 +00:00
Viktor Szakats
ba8752e556
Makefile.mk: drop Windows support
And DLL-support with it. This leaves `Makefile.mk` for MS-DOS and Amiga.

We recommend CMake instead. With unity mode it's much faster, and about
the same without.

Ref: https://github.com/curl/curl/pull/12221#issuecomment-1783761806
Reviewed-by: Daniel Stenberg
Closes #12224
2023-12-16 13:12:22 +00:00
Daniel Stenberg
79147a76cd
examples/rtsp-options.c: add
Just a bare bones RTSP example using CURLOPT_RTSP_SESSION_ID and
CURLOPT_RTSP_REQUEST set to CURL_RTSPREQ_OPTIONS.

Closes #12452
2023-12-04 22:35:38 +01:00
Viktor Szakats
e9a7d4a1c8
windows: use built-in _WIN32 macro to detect Windows
Windows compilers define `_WIN32` automatically. Windows SDK headers
or build env defines `WIN32`, or we have to take care of it. The
agreement seems to be that `_WIN32` is the preferred practice here.
Make the source code rely on that to detect we're building for Windows.

Public `curl.h` was using `WIN32`, `__WIN32__` and `CURL_WIN32` for
Windows detection, next to the official `_WIN32`. After this patch it
only uses `_WIN32` for this. Also, make it stop defining `CURL_WIN32`.

There is a slight chance these break compatibility with Windows
compilers that fail to define `_WIN32`. I'm not aware of any obsolete
or modern compiler affected, but in case there is one, one possible
solution is to define this macro manually.

grepping for `WIN32` remains useful to discover Windows-specific code.

Also:

- extend `checksrc` to ensure we're not using `WIN32` anymore.

- apply minor formatting here and there.

- delete unnecessary checks for `!MSDOS` when `_WIN32` is present.

Co-authored-by: Jay Satiro
Reviewed-by: Daniel Stenberg

Closes #12376
2023-11-22 15:42:25 +00:00
Daniel Stenberg
41b9fd5384
docs/example/keepalive.c: show TCP keep-alive options
Closes #12242
2023-11-01 10:57:15 +01:00
Daniel Stenberg
92a315b1a9
docs/example/localport.c: show off CURLOPT_LOCALPORT
Closes #12230
2023-10-30 12:49:00 +01:00
Daniel Stenberg
22130826b7
docs/examples/interface.c: show CURLOPT_INTERFACE use
Although super simple.

Closes #12229
2023-10-30 12:45:34 +01:00
Viktor Szakats
3b6d18bbf6
spelling: fix codespell 2.2.6 typos
Closes #12019
2023-10-03 21:37:56 +00:00
Ted Lyngmo
c1ab33ed79
docs: use CURLSSLBACKEND_NONE
[ssl] use CURLSSLBACKEND_NONE instead of (curl_sslbackend)-1 in
documentation and examples.

Signed-off-by: Ted Lyngmo <ted@lyncon.se>

Closes #11909
2023-09-21 14:15:03 +02:00
Daniel Stenberg
945db0d958
docs: remove use of the word 'very'
It is mostly superfluous. proselint would complain.

Closes #11818
2023-09-07 22:52:07 +02:00
Dave Cottlehuber
a86fcb284f
ws: fix spelling mistakes in examples and tests
Closes #11784
2023-09-03 18:01:58 +02:00
Viktor Szakats
ce3dce9015
tidy-up: mostly whitespace nits
- delete completed TODO from `./CMakeLists.txt`.
- convert a C++ comment to C89 in `./CMake/CurlTests.c`.
- delete duplicate EOLs from EOF.
- add missing EOL at EOF.
- delete whitespace at EOL (except from expected test results).
- convert tabs to spaces.
- convert CRLF EOLs to LF in GHA yaml.
- text casing fixes in `./CMakeLists.txt`.
- fix a codespell typo in `packages/OS400/initscript.sh`.

Closes #11772
2023-08-31 23:02:10 +00:00
Daniel Stenberg
5b060a4108
docs: rewrite to present tense
... instead of using future tense.

+ numerous cleanups and improvements
+ stick to "reuse" not "re-use"
+ fewer contractions

Closes #11713
2023-08-23 23:26:10 +02:00
Alexander Jaeger
959e613e7c
misc: fix various typos
Closes #11561
2023-08-01 14:09:32 +02:00
James Fuller
97394caa20
example/maxconnects: set maxconnect example
Closes #11343
2023-07-11 20:13:25 +02:00
Daniel Stenberg
22c92a6d51
docs: use a space after RFC when spelling out RFC numbers
Closes #11382
2023-07-09 19:13:33 +02:00
Margu
9bf89bdc5b
imap-append.c: update to make it more likely to work
Fixes #10300
Closes #11397
2023-07-09 18:58:39 +02:00
Daniel Stenberg
67ebc0d5b0
example/connect-to: show CURLOPT_CONNECT_TO
Closes #11340
2023-06-20 09:13:54 +02:00
Daniel Stenberg
ff1e885632
example/opensslthreadlock: remove
This shows how to setup OpenSSL mutex callbacks, but this is not
necessary since OpenSSL 1.1.0 - meaning that no currently supported
OpenSSL version requires this anymore

Closes #11341
2023-06-20 09:06:23 +02:00
Daniel Stenberg
aef74ae416
example/crawler: make it use a few more options
For show, but reasonable
2023-06-19 09:06:41 +02:00
Daniel Stenberg
c6ec264d1f
example/default-scheme: set the default scheme for schemeless URLs
Closes #11338
2023-06-18 23:37:48 +02:00
Daniel Stenberg
e6ad624996
example/hsts-preload: show one way to HSTS preload
Closes #11337
2023-06-18 23:35:40 +02:00
Daniel Stenberg
4e6a07e177
examples/http-options: show how to send "OPTIONS *"
With CURLOPT_REQUEST_TARGET.

Also add use of CURLOPT_QUICK_EXIT to show.

Closes #11333
2023-06-18 11:10:23 +02:00
Daniel Stenberg
741b6853b9
examples: make use of CURLOPT_(REDIR_|)PROTOCOLS_STR
To show how to use them

Closes #11334
2023-06-18 11:09:13 +02:00
Daniel Stenberg
b39181cedc
examples/smtp-mime: use CURLOPT_MAIL_RCPT_ALLOWFAILS
For show

Closes #11335
2023-06-18 11:08:22 +02:00
Daniel Stenberg
b5351c71c1
examples/multi-debugcallback.c: avoid the bool typedef
Apparently this cannot be done in c23

Reported-by: Cristian Rodríguez
Fixes #11299
Closes #11319
2023-06-15 15:54:48 +02:00
Daniel Stenberg
fdfc2bb6be
examples/ipv6: disable on win32
I can't make if_nametoindex() work there

Follow-up to c23dc42f39

Closes #11305
2023-06-12 15:28:35 +02:00
Daniel Stenberg
555bacd6d5
examples/https.c: use CURLOPT_CA_CACHE_TIMEOUT
for demonstration purposes

Closes #11290
2023-06-11 00:17:41 +02:00
Daniel Stenberg
c23dc42f39
example/ipv6: feature CURLOPT_ADDRESS_SCOPE in use
Closes #11282
2023-06-11 00:17:03 +02:00
Daniel Stenberg
ad8a8e048e
example/http2-download: set CURLOPT_BUFFERSIZE
Primarily because no other example sets it, and remove the disabling of
the certificate check because we should not recommend that.

Closes #11284
2023-06-09 16:48:20 +02:00
Daniel Stenberg
578becba30
example/crawler: also set CURLOPT_AUTOREFERER
Could make sense, and it was not used in any example before.

Closes #11283
2023-06-09 16:47:20 +02:00
Daniel Stenberg
67e9e90f96
examples/ftpuploadresume.c: add use of CURLOPT_ACCEPTTIMEOUT_MS
For show

Closes #11277
2023-06-08 23:37:43 +02:00
Daniel Stenberg
4894ca6813
examples/unixsocket.c: example using CURLOPT_UNIX_SOCKET_PATH
and alternatively CURLOPT_ABSTRACT_UNIX_SOCKET

Closes #11276
2023-06-08 23:36:55 +02:00
Daniel Stenberg
78886afb50
ws: make the curl_ws_meta() return pointer a const
The returned info is read-only for the user.

Closes #11261
2023-06-07 23:37:21 +02:00
Daniel Stenberg
e812473d1e
examples/websocket.c: websocket example using CONNECT_ONLY
Closes #11262
2023-06-07 14:56:02 +02:00
Daniel Stenberg
0e339b9e72
websocket-cb: example doing WebSocket download using callback
Very basic

Closes #11260
2023-06-07 14:52:00 +02:00
Daniel Stenberg
127eb0d83a
misc: fix spelling mistakes
Reported-by: musvaage on github
Fixes #11171
Closes #11172
2023-05-23 10:42:09 +02:00
Jay Satiro
6f93d5f604
lib: fix conversion warnings with gcc on macOS 2023-05-21 14:02:31 +02:00
Emanuele Torre
f198d33e8d
checksrc: disallow spaces before labels
Out of 415 labels throughout the code base, 86 of those labels were
not at the start of the line. Which means labels always at the start of
the line is the favoured style overall with 329 instances.

Out of the 86 labels not at the start of the line:
* 75 were indented with the same indentation level of the following line
* 8 were indented with exactly one space
* 2 were indented with one fewer indentation level then the following
  line
* 1 was indented with the indentation level of the following line minus
  three space (probably unintentional)

Co-Authored-By: Viktor Szakats

Closes #11134
2023-05-18 20:45:04 +02:00
Stefan Eissing
acd82c8bfd
tests/http: more tests with specific clients
- Makefile support for building test specific clients in tests/http/clients
- auto-make of clients when invoking pytest
- added test_09_02 for server PUSH_PROMISEs using clients/h2-serverpush
- added test_02_21 for lib based downloads and pausing/unpausing transfers

curl url parser:
- added internal method `curl_url_set_authority()` for setting the
  authority part of a url (used for PUSH_PROMISE)

http2:
- made logging of PUSH_PROMISE handling nicer

Placing python test requirements in requirements.txt files
- separate files to base test suite and http tests since use
  and module lists differ
- using the files in the gh workflows

websocket test cases, fixes for we and bufq
- bufq: account for spare chunks in space calculation
- bufq: reset chunks that are skipped empty
- ws: correctly encode frames with 126 bytes payload
- ws: update frame meta information on first call of collect
  callback that fills user buffer
- test client ws-data: some test/reporting improvements

Closes #11006
2023-04-26 23:24:46 +02:00
Daniel Stenberg
c9cff9262f
docs/examples/protofeats.c: Outputs all protocols and features
Showing off one way to get to char pointer arrays of info returned by
curl_version_info()

Closes #10991
2023-04-18 08:10:27 +02:00
Daniel Stenberg
49a9f13c39
examples/http3.c: use CURL_HTTP_VERSION_3
and update the comment

Closes #10619
2023-02-27 15:11:13 +01:00