1 | #ifndef HEADER_CURL_DYNBUF_H |
2 | #define |
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 | |
27 | #include <curl/curl.h> |
28 | |
29 | #ifndef BUILDING_LIBCURL |
30 | /* this renames the functions so that the tool code can use the same code |
31 | without getting symbol collisions */ |
32 | #define Curl_dyn_init(a,b) curlx_dyn_init(a,b) |
33 | #define Curl_dyn_add(a,b) curlx_dyn_add(a,b) |
34 | #define Curl_dyn_addn(a,b,c) curlx_dyn_addn(a,b,c) |
35 | #define Curl_dyn_addf curlx_dyn_addf |
36 | #define Curl_dyn_vaddf curlx_dyn_vaddf |
37 | #define Curl_dyn_free(a) curlx_dyn_free(a) |
38 | #define Curl_dyn_ptr(a) curlx_dyn_ptr(a) |
39 | #define Curl_dyn_uptr(a) curlx_dyn_uptr(a) |
40 | #define Curl_dyn_len(a) curlx_dyn_len(a) |
41 | #define Curl_dyn_reset(a) curlx_dyn_reset(a) |
42 | #define Curl_dyn_tail(a,b) curlx_dyn_tail(a,b) |
43 | #define Curl_dyn_setlen(a,b) curlx_dyn_setlen(a,b) |
44 | #define curlx_dynbuf dynbuf /* for the struct name */ |
45 | #endif |
46 | |
47 | struct dynbuf { |
48 | char *bufr; /* point to a null-terminated allocated buffer */ |
49 | size_t leng; /* number of bytes *EXCLUDING* the null-terminator */ |
50 | size_t allc; /* size of the current allocation */ |
51 | size_t toobig; /* size limit for the buffer */ |
52 | #ifdef DEBUGBUILD |
53 | int init; /* detect API usage mistakes */ |
54 | #endif |
55 | }; |
56 | |
57 | void Curl_dyn_init(struct dynbuf *s, size_t toobig); |
58 | void Curl_dyn_free(struct dynbuf *s); |
59 | CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len) |
60 | WARN_UNUSED_RESULT; |
61 | CURLcode Curl_dyn_add(struct dynbuf *s, const char *str) |
62 | WARN_UNUSED_RESULT; |
63 | CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...) |
64 | WARN_UNUSED_RESULT; |
65 | CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap) |
66 | WARN_UNUSED_RESULT; |
67 | void Curl_dyn_reset(struct dynbuf *s); |
68 | CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail); |
69 | CURLcode Curl_dyn_setlen(struct dynbuf *s, size_t set); |
70 | char *Curl_dyn_ptr(const struct dynbuf *s); |
71 | unsigned char *Curl_dyn_uptr(const struct dynbuf *s); |
72 | size_t Curl_dyn_len(const struct dynbuf *s); |
73 | |
74 | /* returns 0 on success, -1 on error */ |
75 | /* The implementation of this function exists in mprintf.c */ |
76 | int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save); |
77 | |
78 | /* Dynamic buffer max sizes */ |
79 | #define DYN_DOH_RESPONSE 3000 |
80 | #define DYN_DOH_CNAME 256 |
81 | #define DYN_PAUSE_BUFFER (64 * 1024 * 1024) |
82 | #define DYN_HAXPROXY 2048 |
83 | #define DYN_HTTP_REQUEST (1024*1024) |
84 | #define DYN_APRINTF 8000000 |
85 | #define (64*1024) |
86 | #define DYN_TRAILERS (64*1024) |
87 | #define 16384 |
88 | #define DYN_QLOG_NAME 1024 |
89 | #define DYN_H1_TRAILER 4096 |
90 | #define DYN_PINGPPONG_CMD (64*1024) |
91 | #define DYN_IMAP_CMD (64*1024) |
92 | #define DYN_MQTT_RECV (64*1024) |
93 | #endif |
94 | |