wip
parent
5b612127b2
commit
4a0df8db6b
|
@ -86,4 +86,17 @@ uint64_t lnm_atoi(const char *s, size_t len);
|
||||||
*/
|
*/
|
||||||
uint64_t lnm_digits(uint64_t num);
|
uint64_t lnm_digits(uint64_t num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the first case-insensitive occurence of s2 in s1.
|
||||||
|
*
|
||||||
|
* @param out pointer to store start of match in
|
||||||
|
* @param s1 pointer to string to look in
|
||||||
|
* @param s1_len length of s1
|
||||||
|
* @param s2 string to search for in s1
|
||||||
|
* @param s2_len length of s2
|
||||||
|
* @return true if found, false otherwise
|
||||||
|
*/
|
||||||
|
bool lnm_stristr(const char **out, const char *s1, size_t s1_len,
|
||||||
|
const char *s2, size_t s2_len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -113,3 +113,15 @@ lnm_err lnm_http_req_header_get_s(lnm_http_req_hdr *out, lnm_http_req *req,
|
||||||
|
|
||||||
return lnm_err_not_found;
|
return lnm_err_not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lnm_err lnm_http_req_header_param(lnm_http_req_hdr_param *param,
|
||||||
|
const lnm_http_req_hdr *header,
|
||||||
|
const char *key) {
|
||||||
|
size_t key_len = strlen(key);
|
||||||
|
|
||||||
|
const char *s;
|
||||||
|
if (lnm_stristr(&s, header->name.s, header->name.len - 1, key, key_len) && (header->name.s[key_len] == '=')) {
|
||||||
|
// Value runs till end of header or next semi-colon
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -55,3 +55,19 @@ uint64_t lnm_digits(uint64_t num) {
|
||||||
|
|
||||||
return digits;
|
return digits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lnm_stristr(const char **out, const char *s1, size_t s1_len,
|
||||||
|
const char *s2, size_t s2_len) {
|
||||||
|
while (s1_len >= s2_len) {
|
||||||
|
if (lnm_strnieq(s1, s1_len, s2, s2_len)) {
|
||||||
|
*out = s1;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
s1_len--;
|
||||||
|
s1++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue