From: Daniel Stenberg Date: Mon, 10 Mar 2025 08:54:37 +0000 (+0100) Subject: STRPARSE: amend with recently added functions X-Git-Tag: curl-8_13_0~195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06ae0eceb97627fcced7b0f366114bebe898461b;p=thirdparty%2Fcurl.git STRPARSE: amend with recently added functions Closes #16647 --- diff --git a/docs/internals/STRPARSE.md b/docs/internals/STRPARSE.md index 82fae94bda..b01a2e5f2c 100644 --- a/docs/internals/STRPARSE.md +++ b/docs/internals/STRPARSE.md @@ -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