From 06bea8ae54dd3cd714b231b3d8a8deef77136613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Thu, 10 Jun 2021 13:01:01 +0800 Subject: The client now takes an "on success" callback argument --- client.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index 0dad4c9..8813db9 100644 --- a/client.c +++ b/client.c @@ -37,23 +37,23 @@ bool icclient_init(const char *url, const char *certificate) if (append) strcat(server_url, "/"); } + icclient_catalog_init(); return (bool)curl; #endif } -void icclient_results(const char *prod_group, icclient_handler handler, struct icclient_catalog **catalogptr) +extern size_t icclient_catalog_results(void *, size_t, size_t, void *); + +void icclient_results(const char *prod_group, + void (*callback)(struct icclient_catalog *), struct icclient_catalog **catalog, icclient_handler handler) { char nonspaced[strlen(prod_group) + 1]; strcpy(nonspaced, prod_group); char *space = NULL; while ((space = strchr(nonspaced, ' '))) *space = '-'; - request(handler, (void *)catalogptr, 0, "%s", nonspaced); -} - -void icclient_allproducts(icclient_handler handler, struct icclient_catalog **catalogptr) -{ - request(handler, (void *)catalogptr, 0, "%s", "All-Products"); + request(handler ? handler : icclient_catalog_results, (void *)catalog, 0, "%s", nonspaced); + callback(*catalog); } void icclient_flypage(const char *sku, icclient_handler handler, struct icclient_product **productptr) -- cgit v1.2.3