Lines Matching refs:dynhds
91 void Curl_dynhds_init(struct dynhds *dynhds, size_t max_entries, in Curl_dynhds_init() argument
94 DEBUGASSERT(dynhds); in Curl_dynhds_init()
96 dynhds->hds = NULL; in Curl_dynhds_init()
97 dynhds->hds_len = dynhds->hds_allc = dynhds->strs_len = 0; in Curl_dynhds_init()
98 dynhds->max_entries = max_entries; in Curl_dynhds_init()
99 dynhds->max_strs_size = max_strs_size; in Curl_dynhds_init()
100 dynhds->opts = 0; in Curl_dynhds_init()
103 void Curl_dynhds_free(struct dynhds *dynhds) in Curl_dynhds_free() argument
105 DEBUGASSERT(dynhds); in Curl_dynhds_free()
106 if(dynhds->hds && dynhds->hds_len) { in Curl_dynhds_free()
108 DEBUGASSERT(dynhds->hds); in Curl_dynhds_free()
109 for(i = 0; i < dynhds->hds_len; ++i) { in Curl_dynhds_free()
110 entry_free(dynhds->hds[i]); in Curl_dynhds_free()
113 Curl_safefree(dynhds->hds); in Curl_dynhds_free()
114 dynhds->hds_len = dynhds->hds_allc = dynhds->strs_len = 0; in Curl_dynhds_free()
117 void Curl_dynhds_reset(struct dynhds *dynhds) in Curl_dynhds_reset() argument
119 DEBUGASSERT(dynhds); in Curl_dynhds_reset()
120 if(dynhds->hds_len) { in Curl_dynhds_reset()
122 DEBUGASSERT(dynhds->hds); in Curl_dynhds_reset()
123 for(i = 0; i < dynhds->hds_len; ++i) { in Curl_dynhds_reset()
124 entry_free(dynhds->hds[i]); in Curl_dynhds_reset()
125 dynhds->hds[i] = NULL; in Curl_dynhds_reset()
128 dynhds->hds_len = dynhds->strs_len = 0; in Curl_dynhds_reset()
131 size_t Curl_dynhds_count(struct dynhds *dynhds) in Curl_dynhds_count() argument
133 return dynhds->hds_len; in Curl_dynhds_count()
136 void Curl_dynhds_set_opts(struct dynhds *dynhds, int opts) in Curl_dynhds_set_opts() argument
138 dynhds->opts = opts; in Curl_dynhds_set_opts()
141 struct dynhds_entry *Curl_dynhds_getn(struct dynhds *dynhds, size_t n) in Curl_dynhds_getn() argument
143 DEBUGASSERT(dynhds); in Curl_dynhds_getn()
144 return (n < dynhds->hds_len) ? dynhds->hds[n] : NULL; in Curl_dynhds_getn()
147 struct dynhds_entry *Curl_dynhds_get(struct dynhds *dynhds, const char *name, in Curl_dynhds_get() argument
151 for(i = 0; i < dynhds->hds_len; ++i) { in Curl_dynhds_get()
152 if(dynhds->hds[i]->namelen == namelen && in Curl_dynhds_get()
153 strncasecompare(dynhds->hds[i]->name, name, namelen)) { in Curl_dynhds_get()
154 return dynhds->hds[i]; in Curl_dynhds_get()
160 struct dynhds_entry *Curl_dynhds_cget(struct dynhds *dynhds, const char *name) in Curl_dynhds_cget() argument
162 return Curl_dynhds_get(dynhds, name, strlen(name)); in Curl_dynhds_cget()
165 CURLcode Curl_dynhds_add(struct dynhds *dynhds, in Curl_dynhds_add() argument
172 DEBUGASSERT(dynhds); in Curl_dynhds_add()
173 if(dynhds->max_entries && dynhds->hds_len >= dynhds->max_entries) in Curl_dynhds_add()
175 if(dynhds->strs_len + namelen + valuelen > dynhds->max_strs_size) in Curl_dynhds_add()
178 entry = entry_new(name, namelen, value, valuelen, dynhds->opts); in Curl_dynhds_add()
182 if(dynhds->hds_len + 1 >= dynhds->hds_allc) { in Curl_dynhds_add()
183 size_t nallc = dynhds->hds_len + 16; in Curl_dynhds_add()
186 if(dynhds->max_entries && nallc > dynhds->max_entries) in Curl_dynhds_add()
187 nallc = dynhds->max_entries; in Curl_dynhds_add()
192 if(dynhds->hds) { in Curl_dynhds_add()
193 memcpy(nhds, dynhds->hds, in Curl_dynhds_add()
194 dynhds->hds_len * sizeof(struct dynhds_entry *)); in Curl_dynhds_add()
195 Curl_safefree(dynhds->hds); in Curl_dynhds_add()
197 dynhds->hds = nhds; in Curl_dynhds_add()
198 dynhds->hds_allc = nallc; in Curl_dynhds_add()
200 dynhds->hds[dynhds->hds_len++] = entry; in Curl_dynhds_add()
202 dynhds->strs_len += namelen + valuelen; in Curl_dynhds_add()
211 CURLcode Curl_dynhds_cadd(struct dynhds *dynhds, in Curl_dynhds_cadd() argument
214 return Curl_dynhds_add(dynhds, name, strlen(name), value, strlen(value)); in Curl_dynhds_cadd()
217 CURLcode Curl_dynhds_h1_add_line(struct dynhds *dynhds, in Curl_dynhds_h1_add_line() argument
232 if(!dynhds->hds_len) in Curl_dynhds_h1_add_line()
241 e = dynhds->hds[dynhds->hds_len-1]; in Curl_dynhds_h1_add_line()
245 dynhds->hds[dynhds->hds_len-1] = e2; in Curl_dynhds_h1_add_line()
269 return Curl_dynhds_add(dynhds, name, namelen, value, valuelen); in Curl_dynhds_h1_add_line()
273 CURLcode Curl_dynhds_h1_cadd_line(struct dynhds *dynhds, const char *line) in Curl_dynhds_h1_cadd_line() argument
275 return Curl_dynhds_h1_add_line(dynhds, line, line ? strlen(line) : 0); in Curl_dynhds_h1_cadd_line()
281 bool Curl_dynhds_contains(struct dynhds *dynhds, in Curl_dynhds_contains() argument
284 return !!Curl_dynhds_get(dynhds, name, namelen); in Curl_dynhds_contains()
287 bool Curl_dynhds_ccontains(struct dynhds *dynhds, const char *name) in Curl_dynhds_ccontains() argument
289 return Curl_dynhds_contains(dynhds, name, strlen(name)); in Curl_dynhds_ccontains()
292 size_t Curl_dynhds_count_name(struct dynhds *dynhds, in Curl_dynhds_count_name() argument
296 if(dynhds->hds_len) { in Curl_dynhds_count_name()
298 for(i = 0; i < dynhds->hds_len; ++i) { in Curl_dynhds_count_name()
299 if((namelen == dynhds->hds[i]->namelen) && in Curl_dynhds_count_name()
300 strncasecompare(name, dynhds->hds[i]->name, namelen)) in Curl_dynhds_count_name()
307 size_t Curl_dynhds_ccount_name(struct dynhds *dynhds, const char *name) in Curl_dynhds_ccount_name() argument
309 return Curl_dynhds_count_name(dynhds, name, strlen(name)); in Curl_dynhds_ccount_name()
312 CURLcode Curl_dynhds_set(struct dynhds *dynhds, in Curl_dynhds_set() argument
316 Curl_dynhds_remove(dynhds, name, namelen); in Curl_dynhds_set()
317 return Curl_dynhds_add(dynhds, name, namelen, value, valuelen); in Curl_dynhds_set()
320 size_t Curl_dynhds_remove(struct dynhds *dynhds, in Curl_dynhds_remove() argument
324 if(dynhds->hds_len) { in Curl_dynhds_remove()
326 for(i = 0; i < dynhds->hds_len; ++i) { in Curl_dynhds_remove()
327 if((namelen == dynhds->hds[i]->namelen) && in Curl_dynhds_remove()
328 strncasecompare(name, dynhds->hds[i]->name, namelen)) { in Curl_dynhds_remove()
330 --dynhds->hds_len; in Curl_dynhds_remove()
331 dynhds->strs_len -= (dynhds->hds[i]->namelen + in Curl_dynhds_remove()
332 dynhds->hds[i]->valuelen); in Curl_dynhds_remove()
333 entry_free(dynhds->hds[i]); in Curl_dynhds_remove()
334 len = dynhds->hds_len - i; /* remaining entries */ in Curl_dynhds_remove()
336 memmove(&dynhds->hds[i], &dynhds->hds[i + 1], in Curl_dynhds_remove()
337 len * sizeof(dynhds->hds[i])); in Curl_dynhds_remove()
346 size_t Curl_dynhds_cremove(struct dynhds *dynhds, const char *name) in Curl_dynhds_cremove() argument
348 return Curl_dynhds_remove(dynhds, name, strlen(name)); in Curl_dynhds_cremove()
353 CURLcode Curl_dynhds_h1_dprint(struct dynhds *dynhds, struct dynbuf *dbuf) in Curl_dynhds_h1_dprint() argument
358 if(!dynhds->hds_len) in Curl_dynhds_h1_dprint()
361 for(i = 0; i < dynhds->hds_len; ++i) { in Curl_dynhds_h1_dprint()
363 (int)dynhds->hds[i]->namelen, dynhds->hds[i]->name, in Curl_dynhds_h1_dprint()
364 (int)dynhds->hds[i]->valuelen, dynhds->hds[i]->value); in Curl_dynhds_h1_dprint()
374 nghttp2_nv *Curl_dynhds_to_nva(struct dynhds *dynhds, size_t *pcount) in Curl_dynhds_to_nva() argument
376 nghttp2_nv *nva = calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len); in Curl_dynhds_to_nva()
383 for(i = 0; i < dynhds->hds_len; ++i) { in Curl_dynhds_to_nva()
384 struct dynhds_entry *e = dynhds->hds[i]; in Curl_dynhds_to_nva()
392 *pcount = dynhds->hds_len; in Curl_dynhds_to_nva()