1 #ifndef HEADER_CURL_STRPARSE_H 2 #define HEADER_CURL_STRPARSE_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 11 * 12 * This software is licensed as described in the file COPYING, which 13 * you should have received as part of this distribution. The terms 14 * are also available at https://curl.se/docs/copyright.html. 15 * 16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 * copies of the Software, and permit persons to whom the Software is 18 * furnished to do so, under the terms of the COPYING file. 19 * 20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 * KIND, either express or implied. 22 * 23 * SPDX-License-Identifier: curl 24 * 25 ***************************************************************************/ 26 #include "curl_setup.h" 27 28 #define STRE_OK 0 29 #define STRE_BIG 1 30 #define STRE_SHORT 2 31 #define STRE_BEGQUOTE 3 32 #define STRE_ENDQUOTE 4 33 #define STRE_BYTE 5 34 #define STRE_NEWLINE 6 35 #define STRE_OVERFLOW 7 36 37 struct Curl_str { 38 char *str; 39 size_t len; 40 }; 41 42 /* Get a word until the first space 43 return non-zero on error */ 44 int Curl_str_word(char **linep, struct Curl_str *out, const size_t max); 45 46 /* Get a word until the first DELIM or end of string 47 return non-zero on error */ 48 int Curl_str_until(char **linep, struct Curl_str *out, const size_t max, 49 char delim); 50 51 /* Get a "quoted" word. No escaping possible. 52 return non-zero on error */ 53 int Curl_str_quotedword(char **linep, struct Curl_str *out, const size_t max); 54 55 /* Advance over a single character. 56 return non-zero on error */ 57 int Curl_str_single(char **linep, char byte); 58 59 /* Advance over a single space. 60 return non-zero on error */ 61 int Curl_str_singlespace(char **linep); 62 63 /* Get an unsigned number 64 return non-zero on error */ 65 int Curl_str_number(char **linep, size_t *nump, size_t max); 66 67 /* Check for CR or LF 68 return non-zero on error */ 69 int Curl_str_newline(char **linep); 70 71 #endif /* HEADER_CURL_STRPARSE_H */ 72