2022-06-27 23:25:31 +00:00
|
|
|
#include <ctype.h>
|
2022-06-19 16:04:51 +00:00
|
|
|
#include <gargoyle/codex.h>
|
2022-06-19 05:13:49 +00:00
|
|
|
#include <gargoyle/sleuth.h>
|
|
|
|
#include <gargoyle/twine.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2022-06-29 01:24:07 +00:00
|
|
|
struct gargoyle_opt *gargoyle_find_brand(uint16_t optc, struct gargoyle_opt *optv, const char *brand, const char *neg, uint16_t neg_sz, gargoyle_flag_type flags) {
|
2022-06-29 21:06:49 +00:00
|
|
|
if(!neg) {
|
|
|
|
neg = "no-";
|
|
|
|
neg_sz = 3;
|
|
|
|
}
|
|
|
|
|
2022-06-19 05:13:49 +00:00
|
|
|
for(; optc; optc -= 1, optv += 1) {
|
2022-06-19 07:55:16 +00:00
|
|
|
const char *idx = brand;
|
2022-06-19 06:38:20 +00:00
|
|
|
|
2022-06-29 01:24:07 +00:00
|
|
|
if(optv->type & GARGOYLE_TYPE_BOOL && gargoyle_cmp(idx, neg, neg_sz, flags)) {
|
2022-06-29 21:06:49 +00:00
|
|
|
idx += neg_sz;
|
2022-06-19 07:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t end = !*(idx + optv->brand_sz);
|
|
|
|
uint8_t eql = *(idx + optv->brand_sz) == '=';
|
|
|
|
|
2022-06-27 23:25:31 +00:00
|
|
|
if(gargoyle_cmp(idx, optv->brand, optv->brand_sz, flags) && (end || eql)) {
|
2022-06-19 05:13:49 +00:00
|
|
|
return optv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-06-19 05:56:39 +00:00
|
|
|
|
2022-06-27 23:25:31 +00:00
|
|
|
struct gargoyle_opt *gargoyle_find_emblem(uint16_t optc, struct gargoyle_opt *optv, const char emblem, gargoyle_flag_type flags) {
|
2022-06-19 05:56:39 +00:00
|
|
|
for(; optc; optc -= 1, optv += 1) {
|
|
|
|
if(emblem == optv->emblem) {
|
|
|
|
return optv;
|
2022-06-29 07:12:58 +00:00
|
|
|
} else if(flags & GARGOYLE_FLG_ECASE && gargoyle_is_eql(emblem, optv->emblem)) {
|
2022-06-27 23:25:31 +00:00
|
|
|
return optv;
|
2022-06-19 05:56:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|