dynbuf.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef HEADER_CURL_DYNBUF_H
  2. #define HEADER_CURL_DYNBUF_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2020, 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.haxx.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. ***************************************************************************/
  24. struct dynbuf {
  25. char *bufr; /* point to a zero terminated allocated buffer */
  26. size_t leng; /* number of bytes *EXCLUDING* the zero terminator */
  27. size_t allc; /* size of the current allocation */
  28. size_t toobig; /* size limit for the buffer */
  29. #ifdef DEBUGBUILD
  30. int init; /* detect API usage mistakes */
  31. #endif
  32. };
  33. void Curl_dyn_init(struct dynbuf *s, size_t toobig);
  34. void Curl_dyn_free(struct dynbuf *s);
  35. CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len)
  36. WARN_UNUSED_RESULT;
  37. CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
  38. WARN_UNUSED_RESULT;
  39. CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
  40. WARN_UNUSED_RESULT;
  41. void Curl_dyn_reset(struct dynbuf *s);
  42. CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail);
  43. char *Curl_dyn_ptr(const struct dynbuf *s);
  44. unsigned char *Curl_dyn_uptr(const struct dynbuf *s);
  45. size_t Curl_dyn_len(const struct dynbuf *s);
  46. /* Dynamic buffer max sizes */
  47. #define DYN_DOH_RESPONSE 3000
  48. #define DYN_DOH_CNAME 256
  49. #define DYN_PAUSE_BUFFER (64 * 1024 * 1024)
  50. #define DYN_HAXPROXY 2048
  51. #define DYN_HTTP_REQUEST (128*1024)
  52. #define DYN_H2_HEADERS (128*1024)
  53. #define DYN_H2_TRAILER 4096
  54. #define DYN_APRINTF 8000000
  55. #define DYN_RTSP_REQ_HEADER (64*1024)
  56. #define DYN_TRAILERS (64*1024)
  57. #define DYN_PROXY_CONNECT_HEADERS 16384
  58. #define DYN_QLOG_NAME 1024
  59. #endif