37 lines
1.0 KiB
C
37 lines
1.0 KiB
C
#include <ctype.h>
|
|
#include <gargoyle/codex.h>
|
|
#include <gargoyle/sleuth.h>
|
|
#include <gargoyle/twine.h>
|
|
#include <stddef.h>
|
|
|
|
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) {
|
|
for(; optc; optc -= 1, optv += 1) {
|
|
const char *idx = brand;
|
|
|
|
if(optv->type & GARGOYLE_TYPE_BOOL && gargoyle_cmp(idx, neg, neg_sz, flags)) {
|
|
idx += 3;
|
|
}
|
|
|
|
uint8_t end = !*(idx + optv->brand_sz);
|
|
uint8_t eql = *(idx + optv->brand_sz) == '=';
|
|
|
|
if(gargoyle_cmp(idx, optv->brand, optv->brand_sz, flags) && (end || eql)) {
|
|
return optv;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
struct gargoyle_opt *gargoyle_find_emblem(uint16_t optc, struct gargoyle_opt *optv, const char emblem, gargoyle_flag_type flags) {
|
|
for(; optc; optc -= 1, optv += 1) {
|
|
if(emblem == optv->emblem) {
|
|
return optv;
|
|
} else if(flags & GARGOYLE_FLG_ECASE && gargoyle_is_eql(emblem, optv->emblem)) {
|
|
return optv;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|