diff options
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 34 |
1 files changed, 30 insertions, 4 deletions
@@ -1,8 +1,6 @@ #include <stdbool.h> #include <string.h> #include "request.h" -#include "icclient/product.h" -#include "icclient/catalog.h" #include "icclient/client.h" #ifdef __EMSCRIPTEN__ @@ -11,9 +9,9 @@ extern void icclient_catalog_results(emscripten_fetch_t *); extern size_t icclient_catalog_results(void *, size_t, size_t, void *); #endif -bool icclient_init(const char *url, const char *certificate) +void icclient_init(const char *url, const char *certificate) { - return icclient_request_init(url, certificate); + icclient_request_init(url, certificate); } void icclient_results(const char *prod_group, void (*callback)(struct icclient_catalog *), icclient_handler handler) @@ -36,6 +34,34 @@ void icclient_page(const char *path, icclient_handler handler, void **dataptr) request(handler, (void *)dataptr, 0, "%s", path); } +void icclient_free_product(struct icclient_product *product) +{ + if (product->crosssell) + for (size_t i = 0; i < product->crosssell->length; i++) + free(product->crosssell->skus[i]); + if (product->author) + free(product->author); + if (product->prod_group) + free(product->prod_group); + if (product->image) + free(product->image); + if (product->thumb) + free(product->thumb); + if (product->comment) + free(product->comment); + if (product->description) + free(product->description); + free(product->sku); + free(product); +} + +void icclient_free_catalog(struct icclient_catalog *catalog) +{ + for (size_t i = 0; i < catalog->length; i++) + icclient_free_product(catalog->products[i]); + free(catalog); +} + void icclient_cleanup() { icclient_request_cleanup(); |