]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
STRPARSE: amend with recently added functions
authorDaniel Stenberg <daniel@haxx.se>
Mon, 10 Mar 2025 08:54:37 +0000 (09:54 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 10 Mar 2025 11:18:48 +0000 (12:18 +0100)
Closes #16647

docs/internals/STRPARSE.md

index 82fae94bda2a353be2433b4962e61211b7d54a4a..b01a2e5f2c53eaddda39b6f890755146189606ff 100644 (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