diff options
-rw-r--r-- | include/lexer.h | 1 | ||||
-rw-r--r-- | src/lexer.c | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/include/lexer.h b/include/lexer.h index f5ab375..ef99187 100644 --- a/include/lexer.h +++ b/include/lexer.h @@ -31,5 +31,6 @@ typedef struct { list_t *lex(char *buffer); directive_t *find_directive(char *content, key_match_t *match); key_match_t *find_next_key(char *buffer); +char *find_contentfor_value(list_t *content_headers, char *key); #endif diff --git a/src/lexer.c b/src/lexer.c index 9366be7..da01151 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -208,3 +208,16 @@ found_start: return directive; } + +char * +find_contentfor_value(list_t *content_headers, char *key) +{ + for (size_t i = 0; i < content_headers->size; i++) { + contentfor_operand_t *operand = list_get(content_headers, i); + + if (strcmp(key, operand->key) == 0) + return operand->content; + } + + return NULL; +} |