diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-17 18:48:45 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-17 18:48:45 +0800 |
commit | ac40a2ae4e9ca7a386caba1505b454a15c3dce7a (patch) | |
tree | 484031cba8cc4f2932851d2c9cb8817be64e9dfc | |
parent | a9667989e8bb66035585320c402b589328c14f23 (diff) |
Swapped handler and callback parameter positions
-rw-r--r-- | client.c | 2 | ||||
-rw-r--r-- | icclient.h | 14 | ||||
-rw-r--r-- | main.c | 11 |
3 files changed, 14 insertions, 13 deletions
@@ -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); @@ -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. @@ -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(); } |