STRPARSE: amend with recently added functions

Closes #16647
This commit is contained in:
Daniel Stenberg 2025-03-10 09:54:37 +01:00
parent 09a5b2f2de
commit 06ae0eceb9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -18,6 +18,9 @@ if(Curl_str_word(&line, &word1, MAX) ||
fprintf(stderr, "ERROR\n");
~~~
The input pointer **must** point to a null terminated buffer area or these
functions risk continuing "off the edge".
## Strings
The functions that return string information does so by populating a
@ -43,6 +46,14 @@ This initiates a string struct. The parser functions that store info in
strings always init the string themselves, so this stand-alone use is often
not necessary.
## `Curl_str_assign`
~~~c
void Curl_str_assign(struct Curl_str *out, const char *str, size_t len)
~~~
Set a pointer and associated length in the string struct.
## `Curl_str_word`
~~~c
@ -74,6 +85,29 @@ custom delimiter non-zero byte `delim`.
The parsed word must be at least one byte, otherwise it is considered an
error.
## `Curl_str_untilnl`
~~~c
int Curl_str_untilnl(char **linep, struct Curl_str *out, const size_t max);
~~~
Like `Curl_str_untilnl` but instead parses until it finds a "newline byte".
That means either a CR (ASCII 13) or an LF (ASCII 10) octet.
`max` is the longest accepted word, or it returns error.
The parsed word must be at least one byte, otherwise it is considered an
error.
## `Curl_str_cspn`
~~~c
int Curl_str_cspn(const char **linep, struct Curl_str *out, const char *cspn);
~~~
Get a sequence of characters until one of the bytes in the `cspn` string
matches. Similar to the `strcspn` function.
## `Curl_str_quotedword`
~~~c
@ -104,6 +138,23 @@ int Curl_str_singlespace(char **linep);
Advance over a single ASCII space. Return non-zero on error.
## `Curl_str_passblanks`
~~~c
void Curl_str_passblanks(char **linep);
~~~
Advance over all spaces and tabs.
## `Curl_str_trimblanks`
~~~c
void Curl_str_trimblanks(struct Curl_str *out);
~~~
Trim off blanks (spaces and tabs) from the start and the end of the given
string.
## `Curl_str_number`
~~~c
@ -114,6 +165,15 @@ Get an unsigned decimal number not larger than `max`. Leading zeroes are just
swallowed. Return non-zero on error. Returns error if there was not a single
digit.
## `Curl_str_numblanks`
~~~c
int Curl_str_numblanks(char **linep, curl_size_t *nump);
~~~
Get an unsigned 63-bit decimal number. Leading blanks and zeroes are skipped.
Returns non-zero on error. Returns error if there was not a single digit.
## `Curl_str_hex`
~~~c