From 7270c84fe616357da17baca20437ef1113bb87eb 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: Tue, 16 May 2023 15:13:17 +0800 Subject: Replace struct body with const char *[][2] --- ord.c | 62 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'ord.c') diff --git a/ord.c b/ord.c index 4964931..c9b8f22 100644 --- a/ord.c +++ b/ord.c @@ -17,12 +17,13 @@ void interchange_ord_order(const char *sku, const char *item, } while ((qty /= 10)); char *qty_str = malloc(length + 1); sprintf(qty_str, "%d", quantity); - request(parser, NULL, &(struct body){ 4, { - { "mv_action", "refresh" }, - { "mv_sku", sku }, - { "mv_order_item", item }, - { "mv_order_quantity", qty_str } - }}, "%s", "ord/basket"); + request(parser, NULL, (const char *[][2]){ + "mv_action", "refresh", + "mv_sku", sku, + "mv_order_item", item, + "mv_order_quantity", qty_str, + NULL + }, "%s", "ord/basket"); } void interchange_ord_update(const char *name, const unsigned int quantity, @@ -36,35 +37,38 @@ void interchange_ord_update(const char *name, const unsigned int quantity, } while ((qty /= 10)); char *qty_str = malloc(length + 1); sprintf(qty_str, "%d", quantity); - request(parser, NULL, &(struct body){ 4 + (nextpage ? 1 : 0), { - { "mv_quantity_update", "1" }, - { "mv_doit", "refresh" }, - { name, qty_str }, - { "mv_orderpage", orderpage ? orderpage : "ord/basket" }, - { "mv_nextpage", nextpage } - }}, "%s", "process"); + request(parser, NULL, (const char *[][2]){ + "mv_quantity_update", "1", + "mv_doit", "refresh", + name, qty_str, + "mv_orderpage", orderpage ? orderpage : "ord/basket", + "mv_nextpage", nextpage, + NULL + }, "%s", "process"); } void interchange_ord_checkout(const char *order_profile, struct interchange_member member, void (*handler)(interchange_response *)) { - request(handler, NULL, &(struct body){ 14, { - { "mv_todo", "submit" }, - { "mv_action", "refresh" }, - { "mv_order_profile", order_profile }, - { "fname", member.fname }, - { "lname", member.lname }, - { "address1", member.address1 }, - { "address2", member.address2 }, - { "city", member.city }, - { "state", member.state }, - { "zip", member.zip }, - { "email", member.email }, - { "phone_day", member.phone_day }, - { "mv_same_billing", member.preferences.mv_same_billing? "1" : "0" }, - { "email_copy", member.preferences.email_copy? "1" : "0" } - }}, "%s", "ord/checkout"); + request(handler, NULL, (const char *[][2]){ + "mv_todo", "submit", + "mv_action", "refresh", + "mv_order_profile", order_profile, + "fname", member.fname, + "lname", member.lname, + "address1", member.address1, + "address2", member.address2, + "city", member.city, + "state", member.state, + "zip", member.zip, + "email", member.email, + "phone_day", member.phone_day, + "mv_same_billing", + member.preferences.mv_same_billing ? "1" : "0", + "email_copy", member.preferences.email_copy? "1" : "0", + NULL + }, "%s", "ord/checkout"); } void interchange_ord_free_order(struct interchange_ord_order *order) -- cgit v1.2.3