diff --git a/include/gargoyle/sleuth.h b/include/gargoyle/sleuth.h index 2de4c7e..684637e 100644 --- a/include/gargoyle/sleuth.h +++ b/include/gargoyle/sleuth.h @@ -13,7 +13,8 @@ struct gargoyle_opt { }; #define GARGOYLE_MK_OPT(brand) brand, (sizeof(brand) - 1) -#define GARGOYLE_EZ_OPT(brand, val) brand, (sizeof(brand) - 1), 0[brand], &val, sizeof(val) +#define GARGOYLE_EZ_OPT(brand, val) GARGOYLE_MK_OPT(brand), 0[brand], &val, sizeof(val) +#define GARGOYLE_CS_OPT(brand, val) GARGOYLE_MK_OPT(brand), 0[brand], &val[0], sizeof(val) struct gargoyle_opt *gargoyle_find_brand(uint16_t optc, struct gargoyle_opt *optv, const char *brand); struct gargoyle_opt *gargoyle_find_emblem(uint16_t optc, struct gargoyle_opt *optv, const char emblem); diff --git a/include/gargoyle/twine.h b/include/gargoyle/twine.h index 30757d8..4d997c0 100644 --- a/include/gargoyle/twine.h +++ b/include/gargoyle/twine.h @@ -8,5 +8,6 @@ static const uint8_t GARGOYLE_CMP_SYMBL = 1 << 1; static const uint8_t GARGOYLE_CMP_FLXBL = GARGOYLE_CMP_ICASE | GARGOYLE_CMP_SYMBL; uint8_t gargoyle_cmp(const char *s1, const char *s2, uint16_t len, uint8_t flags); +char *gargoyle_cpy(char *dst, const char *src, uint16_t len); #endif diff --git a/src/scribe.c b/src/scribe.c index 0def6cb..cb96972 100644 --- a/src/scribe.c +++ b/src/scribe.c @@ -29,6 +29,10 @@ uint8_t gargoyle_from_rope(struct gargoyle_opt *opt, const char *brand) { if(*end) { return GARGOYLE_ERR_INVALID_DBLE; } + } else if(opt->type & GARGOYLE_TYPE_ROPE) { + char *val = opt->val; + char *end = gargoyle_cpy(val, brand, opt->val_sz - 1); + *end = '\0'; } return 0; diff --git a/src/twine.c b/src/twine.c index 456c3be..6791fc6 100644 --- a/src/twine.c +++ b/src/twine.c @@ -22,3 +22,18 @@ uint8_t gargoyle_cmp(const char *s1, const char *s2, uint16_t len, uint8_t flags return 1; } + +char *gargoyle_cpy(char *dst, const char *src, uint16_t len) { + uint16_t idx = 1; + + for(; len; dst += 1, len -= 1, idx += 1) { + if(*src) { + *dst = *src; + src += 1; + } else { + *dst = '\0'; + } + } + + return dst; +}