mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 17:41:41 +01:00
Common: adds more gcc constrants
This commit is contained in:
+10
-7
@@ -29,14 +29,16 @@ typedef struct FFNetworkingState {
|
||||
bool tfo; // if true, TCP Fast Open will be attempted first, and fallback to traditional connection if it fails
|
||||
} FFNetworkingState;
|
||||
|
||||
const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, uint16_t port, const char* path, const char* headers);
|
||||
const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer);
|
||||
// `headers` is optional and may be null; the other pointer arguments are dereferenced unconditionally.
|
||||
// Both functions report failure through their return value, which must be checked.
|
||||
[[gnu::nonnull(1, 2, 4), nodiscard]] const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, uint16_t port, const char* path, const char* headers);
|
||||
[[gnu::nonnull(1, 2), nodiscard]] const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer);
|
||||
|
||||
// Case-insensitive header lookup restricted to the header block [0, headerEnd).
|
||||
// Restricting the range matters because the body may already share the same buffer.
|
||||
// Returns a pointer to the first character of the value; `valueLen` receives its
|
||||
// length excluding the terminating CRLF. Returns nullptr when the header is absent.
|
||||
const char* ffNetworkingFindHeader(const char* headers, uint32_t headerEnd, const char* name, uint32_t* valueLen);
|
||||
[[gnu::nonnull(1, 3, 4), gnu::pure, nodiscard]] const char* ffNetworkingFindHeader(const char* headers, uint32_t headerEnd, const char* name, uint32_t* valueLen);
|
||||
|
||||
// Checks whether a `Transfer-Encoding: chunked` body has been received in full, so that
|
||||
// framing does not have to rely on the server closing the connection.
|
||||
@@ -44,11 +46,12 @@ const char* ffNetworkingFindHeader(const char* headers, uint32_t headerEnd, cons
|
||||
// 0 when more data is needed, and -1 when the body is malformed.
|
||||
// The caller must not wait for a fixed amount of data (e.g. `MSG_WAITALL`) while the
|
||||
// response length is still unknown, otherwise this check never gets to run.
|
||||
int ffNetworkingChunkedComplete(const char* body, uint32_t bodyLen, uint32_t* consumed);
|
||||
// Not `pure`: the `strtoul` it calls writes `errno`.
|
||||
[[gnu::nonnull(1, 3), nodiscard]] int ffNetworkingChunkedComplete(const char* body, uint32_t bodyLen, uint32_t* consumed);
|
||||
|
||||
// Decodes a `Transfer-Encoding: chunked` body in place and rewrites the response with a
|
||||
// `Content-Length` header in place of `Transfer-Encoding`.
|
||||
bool ffNetworkingDecodeChunked(FFstrbuf* buffer, uint32_t headerEnd);
|
||||
[[gnu::nonnull(1), nodiscard]] bool ffNetworkingDecodeChunked(FFstrbuf* buffer, uint32_t headerEnd);
|
||||
|
||||
// Result of parsing a `Transfer-Encoding` header value
|
||||
typedef enum FFNetworkingTransferEncoding {
|
||||
@@ -62,9 +65,9 @@ typedef enum FFNetworkingTransferEncoding {
|
||||
// and any other coding (e.g. `gzip, chunked`) leaves the payload encoded, which this
|
||||
// client cannot decode. Only a lone `chunked` is accepted; everything else is reported
|
||||
// as unsupported so that the caller fails the response instead of returning garbage.
|
||||
FFNetworkingTransferEncoding ffNetworkingParseTransferEncoding(const char* value, uint32_t valueLen);
|
||||
[[gnu::nonnull(1), gnu::pure, nodiscard]] FFNetworkingTransferEncoding ffNetworkingParseTransferEncoding(const char* value, uint32_t valueLen);
|
||||
|
||||
#ifdef FF_HAVE_ZLIB
|
||||
const char* ffNetworkingLoadZlibLibrary(void);
|
||||
bool ffNetworkingDecompressGzip(FFstrbuf* buffer, char* headerEnd);
|
||||
[[gnu::nonnull(1, 2), nodiscard]] bool ffNetworkingDecompressGzip(FFstrbuf* buffer, char* headerEnd);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user