From ac40a2ae4e9ca7a386caba1505b454a15c3dce7a 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, 17 Jun 2021 18:48:45 +0800 Subject: Swapped handler and callback parameter positions --- client.c | 2 +- icclient.h | 14 +++++++++----- main.c | 11 ++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client.c b/client.c index 2badec5..5c6e31a 100644 --- a/client.c +++ b/client.c @@ -19,7 +19,7 @@ void icclient_init(const char *url, const char *dir, const char *certificate) init(certificate); } -void icclient_results(const char *prod_group, void (*callback)(struct icclient_catalog *), void (*handler)(icclient_fetch_t *)) +void icclient_results(const char *prod_group, void (*handler)(icclient_fetch_t *), void (*callback)(struct icclient_catalog *)) { char nonspaced[strlen(prod_group) + 1]; strcpy(nonspaced, prod_group); diff --git a/icclient.h b/icclient.h index 38fdb6e..6a1c365 100644 --- a/icclient.h +++ b/icclient.h @@ -3,8 +3,6 @@ #include "icclient/typedefs.h" -#define icclient_allproducts(callback, handler) icclient_results("All-Products", callback, handler) - struct icclient_product { char *sku; char *description; @@ -27,6 +25,13 @@ struct icclient_catalog { struct icclient_product *products[]; }; +/*! + * \brief For fetching data about all of the products that are active. + * \param handler A pointer to the function when a custom handler is needed to arrange the data into the catalog. + * \param callback A pointer to the function that needs to be called after the catalog is ready. + */ +#define icclient_allproducts(handler, callback) icclient_results("All-Products", handler, callback) + #ifdef __cplusplus extern "C" { #endif @@ -36,17 +41,16 @@ extern "C" { * \param sampleurl The value of the SAMPLEURL setting in products/variable.txt. * \param image_dir The value of the IMAGE_DIR setting in products/variable.txt. * \param certificate Path to the CA certificate file. - * \return True if the initialisation works, false otherwise. */ void icclient_init(const char *sampleurl, const char *image_dir, const char *certificate); /*! * \brief For fetching data about products that belong a specific group. * \param prod_group The name of the product group. - * \param callback A pointer to the function that needs to be called after the catalog is ready. * \param handler A pointer to the function when a custom handler is needed to arrange the data into the catalog. + * \param callback A pointer to the function that needs to be called after the catalog is ready. */ -void icclient_results(const char *prod_group, void (*callback)(struct icclient_catalog *), void (*handler)(icclient_fetch_t *)); +void icclient_results(const char *prod_group, void (*handler)(icclient_fetch_t *), void (*callback)(struct icclient_catalog *)); /*! * \brief For fetching data about a specific product. diff --git a/main.c b/main.c index ef16563..113abe3 100644 --- a/main.c +++ b/main.c @@ -33,13 +33,10 @@ static void print(icclient_fetch_t *fetch) int main(int argc, char *argv[]) { icclient_init("https://demo.interchangecommerce.org/i/demo", "/demo/images", NULL); -/* - icclient_allproducts(print_catalog, NULL); - struct icclient_member *member = icclient_member_login("kirk@icdevgroup.net", "kirk", NULL, NULL, NULL, print); - icclient_member_logout(member); -*/ - struct icclient_admin *admin = icclient_admin_login("interch", "pass", NULL); - icclient_admin_new_admin("Hardware", "pass", "Hardware stuff", 0, ICCLIENT_ADMIN_GROUP_MERCH, NULL); + icclient_allproducts(NULL, print_catalog); + struct icclient_admin *admin = icclient_admin_login("demo", "demo", NULL); icclient_admin_logout(admin, NULL); + struct icclient_member *member = icclient_member_login("kirk@icdevgroup.net", "kirk", print); + icclient_member_logout(member); icclient_cleanup(); } -- cgit v1.2.3