diff --git a/include/cryb/cpe.h b/include/cryb/cpe.h index 9d1fc24..681720b 100644 --- a/include/cryb/cpe.h +++ b/include/cryb/cpe.h @@ -65,18 +65,25 @@ enum cpe23_attributes { cpe23_nattr }; -struct cpe_name { +typedef struct cpe_name { int ver; int nattr; wchar_t *attr[]; -}; +} cpe_name; -struct cpe_name *cpe_upgrade(const struct cpe_name *); -struct cpe_name *cpe_from_string(const wchar_t *); -wchar_t *cpe_to_string(const struct cpe_name *); -struct cpe_name *cpe_from_string(const wchar_t *); -wchar_t *cpe_to_string(const struct cpe_name *); -struct cpe_name *cpe_from_string(const wchar_t *); -wchar_t *cpe_to_string(const struct cpe_name *); +cpe_name *cpe_new(void); +void cpe_destroy(cpe_name *); +cpe_name *cpe_clone(const cpe_name *); + +cpe_name *cpe_upgrade(const cpe_name *); + +cpe_name *cpe_unbind_fs(const wstring *); +wstring *cpe_bind_to_fs(const cpe_name *); + +cpe_name *cpe_unbind_uri(const wstring *); +wstring *cpe_bind_to_uri(const cpe_name *); + +cpe_name *cpe_from_wfn(const wchar_t *); +wchar_t *cpe_to_wfn(const cpe_name *); #endif diff --git a/lib/cpe/cpe.c b/lib/cpe/cpe.c index 85196a1..64f30b5 100644 --- a/lib/cpe/cpe.c +++ b/lib/cpe/cpe.c @@ -30,15 +30,17 @@ #include "cryb/impl.h" #include +#include #include +#include #include /* * Free all memory allocated to a cpe structure. */ void -cpe_destroy(struct cpe_name *cpe) +cpe_destroy(cpe_name *cpe) { if (cpe == NULL) @@ -54,7 +56,7 @@ cpe_destroy(struct cpe_name *cpe) * corresponding attribute in the destination will be an empty string. */ static int -cpe_copy_attr(struct cpe_name *dst, const struct cpe_name *src, int base, int nattr) +cpe_copy_attr(cpe_name *dst, const cpe_name *src, int base, int nattr) { if (base < 0 || nattr < 0 || base + nattr > src->nattr || @@ -77,10 +79,10 @@ cpe_copy_attr(struct cpe_name *dst, const struct cpe_name *src, int base, int na * Duplicate a cpe structure. Any attributes that are NULL in the source * will be empty strings in the destination. */ -struct cpe_name * -cpe_clone(const struct cpe_name *cpe) +cpe_name * +cpe_clone(const cpe_name *cpe) { - struct cpe_name *ncpe; + cpe_name *ncpe; ncpe = calloc(1, sizeof *ncpe + cpe->nattr * sizeof *ncpe->attr); @@ -96,10 +98,10 @@ cpe_clone(const struct cpe_name *cpe) /* * Allocate a new cpe structure. */ -struct cpe_name * +cpe_name * cpe_new(void) { - struct cpe_name *ncpe; + cpe_name *ncpe; if ((ncpe = calloc(1, sizeof *ncpe)) == NULL) return (NULL); @@ -111,10 +113,10 @@ cpe_new(void) /* * Upgrade a cpe 2.2 structure to the latest supported version. */ -struct cpe_name * -cpe_upgrade22(const struct cpe_name *cpe) +cpe_name * +cpe_upgrade22(const cpe_name *cpe) { - struct cpe_name *ncpe; + cpe_name *ncpe; if ((ncpe = cpe_new()) == NULL) return (NULL); @@ -140,15 +142,15 @@ cpe_upgrade22(const struct cpe_name *cpe) /* * Upgrade a cpe structure to the latest supported version. */ -struct cpe_name * -cpe_upgrade(const struct cpe_name *cpe) +cpe_name * +cpe_upgrade(const cpe_name *cpe) { switch (cpe->ver) { - case cpe22_ver: + case cpe23_ver: /* already latest */ return (cpe_clone(cpe)); - case cpe23_ver: + case cpe22_ver: return (cpe_upgrade22(cpe)); default: return (NULL); diff --git a/lib/cpe/cpe_string.c b/lib/cpe/cpe_string.c index 5876ba2..2028a85 100644 --- a/lib/cpe/cpe_string.c +++ b/lib/cpe/cpe_string.c @@ -29,20 +29,22 @@ #include "cryb/impl.h" +#include #include +#include #include -struct cpe * -cpe_unbind_fs(const wchar_t *str) +cpe_name * +cpe_unbind_fs(const wstring *str) { (void)str; return (NULL); } -wchar_t * -cpe_bind_to_fs(const struct cpe *cpe) +wstring * +cpe_bind_to_fs(const cpe_name *cpe) { (void)cpe; diff --git a/lib/cpe/cpe_uri.c b/lib/cpe/cpe_uri.c index d543cd8..4fb2fe8 100644 --- a/lib/cpe/cpe_uri.c +++ b/lib/cpe/cpe_uri.c @@ -29,20 +29,22 @@ #include "cryb/impl.h" +#include #include +#include #include -struct cpe * -cpe_unbind_uri(const wchar_t *str) +cpe_name * +cpe_unbind_uri(const wstring *str) { (void)str; return (NULL); } -wchar_t * -cpe_bind_to_uri(const struct cpe *cpe) +wstring * +cpe_bind_to_uri(const cpe_name *cpe) { (void)cpe; diff --git a/lib/cpe/cpe_wfn.c b/lib/cpe/cpe_wfn.c index 835f0f8..2a74e87 100644 --- a/lib/cpe/cpe_wfn.c +++ b/lib/cpe/cpe_wfn.c @@ -29,11 +29,13 @@ #include "cryb/impl.h" +#include #include +#include #include -struct cpe * +cpe_name * cpe_from_wfn(const wchar_t *str) { @@ -42,7 +44,7 @@ cpe_from_wfn(const wchar_t *str) } wchar_t * -cpe_to_wfn(const struct cpe *cpe) +cpe_to_wfn(const cpe_name *cpe) { (void)cpe;