2
0

strparse.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #define STRE_OK 0
  28. #define STRE_BIG 1
  29. #define STRE_SHORT 2
  30. #define STRE_BEGQUOTE 3
  31. #define STRE_ENDQUOTE 4
  32. #define STRE_BYTE 5
  33. #define STRE_NEWLINE 6
  34. #define STRE_OVERFLOW 7
  35. struct Curl_str {
  36. char *str;
  37. size_t len;
  38. };
  39. /* Get a word until the first space
  40. return non-zero on error */
  41. int Curl_str_word(char **linep, struct Curl_str *out, const size_t max);
  42. /* Get a word until the first DELIM or end of string
  43. return non-zero on error */
  44. int Curl_str_until(char **linep, struct Curl_str *out, const size_t max,
  45. char delim);
  46. /* Get a "quoted" word. No escaping possible.
  47. return non-zero on error */
  48. int Curl_str_quotedword(char **linep, struct Curl_str *out, const size_t max);
  49. /* Advance over a single character.
  50. return non-zero on error */
  51. int Curl_str_single(char **linep, char byte);
  52. /* Advance over a single space.
  53. return non-zero on error */
  54. int Curl_str_singlespace(char **linep);
  55. /* Get an unsigned number
  56. return non-zero on error */
  57. int Curl_str_number(char **linep, size_t *nump, size_t max);
  58. /* Check for CR or LF
  59. return non-zero on error */
  60. int Curl_str_newline(char **linep);
  61. #endif /* HEADER_CURL_STRPARSE_H */