summaryrefslogtreecommitdiff
path: root/src/config/headers.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-10-27 14:33:26 +0000
committerLaurent Bercot <ska@appnovation.com>2023-10-27 14:33:26 +0000
commitffd8df879dea5b306b1a1615c2eabe0d463a3a3b (patch)
tree278ef36a856c2ddc756a1474d69906be7dfbf316 /src/config/headers.c
parentd05b3963381a4cd0329bced938d79a23bb392658 (diff)
downloadtipidee-ffd8df879dea5b306b1a1615c2eabe0d463a3a3b.tar.xz
custom-headers revamp, can be removed now
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/config/headers.c')
-rw-r--r--src/config/headers.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/config/headers.c b/src/config/headers.c
index 829b898..9ea069f 100644
--- a/src/config/headers.c
+++ b/src/config/headers.c
@@ -68,16 +68,19 @@ node const *headers_search (char const *key)
void headers_addv (char const *key, uint8_t options, char const *s, size_t const *word, size_t n, size_t filepos, uint32_t line)
{
node node ;
- if (!n) return ;
+ char c = !s << 7 | (options & 1) ;
node_start(&headers_storage, &node, key, filepos, line) ;
- node_add(&headers_storage, &node, options & 1 ? "\1" : "", 1) ;
- node_add(&headers_storage, &node, s + word[0], strlen(s + word[0])) ;
- for (size_t i = 1 ; i < n ; i++)
+ node_add(&headers_storage, &node, &c, 1) ;
+ if (s)
{
- node_add(&headers_storage, &node, " ", 1) ;
- node_add(&headers_storage, &node, s + word[i], strlen(s + word[i])) ;
+ node_add(&headers_storage, &node, s + word[0], strlen(s + word[0])) ;
+ for (size_t i = 1 ; i < n ; i++)
+ {
+ node_add(&headers_storage, &node, " ", 1) ;
+ node_add(&headers_storage, &node, s + word[i], strlen(s + word[i])) ;
+ }
+ node_add(&headers_storage, &node, "", 1) ;
}
- node_add(&headers_storage, &node, "", 1) ;
repo_add(&headers, &node) ;
}
@@ -87,11 +90,11 @@ static inline void headers_defaults (void)
{
node node ;
struct builtinheaders_s const *p = builtinheaders + i ;
- if (!p->value) continue ;
+ char c = (!p->value << 7) | p->overridable ;
if (p->overridable && headers_search(p->key)) continue ;
node_start(&headers_storage, &node, p->key, 0, 0) ;
- node_add(&headers_storage, &node, p->overridable ? "\1" : "", 1) ;
- node_add(&headers_storage, &node, p->value, strlen(p->value) + 1) ;
+ node_add(&headers_storage, &node, &c, 1) ;
+ if (p->value) node_add(&headers_storage, &node, p->value, strlen(p->value) + 1) ;
repo_add(&headers, &node) ;
}
}