From 1f24bef71ff1087fab2bffb156314213f42ac962 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: Wed, 22 Feb 2023 10:11:10 +0800 Subject: Add handler to setaccount, & simplify member data --- interchange/member.h | 14 ++++++++++---- member.c | 36 +++++++++++++++++------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/interchange/member.h b/interchange/member.h index 3b33e6b..0611861 100644 --- a/interchange/member.h +++ b/interchange/member.h @@ -78,10 +78,16 @@ void interchange_member_login(const char *username, const char *password, */ void interchange_member_account(void (*handler)(interchange_response *)); -void interchange_member_setaccount(const char *fname, const char *lname, - const char *address1, const char *address2, const char *city, - const char *state, const char *zip, const char *email, - const char *phone_day); +/*! + * \brief For setting member account information. + * \param member A pointer to a member instance whose members will be used in + * POST data. + * \param handler A pointer to the function when a custom handler is needed to + * arrange the data into the member instance. +*/ +void interchange_member_setaccount(const struct interchange_member *member, + void (*handler)(interchange_response *)); + void interchange_member_changepassword(const char *password_old, const char *password, const char *verify); void interchange_member_logout(struct interchange_member *member); diff --git a/member.c b/member.c index 8ac2618..b5e3227 100644 --- a/member.c +++ b/member.c @@ -24,26 +24,24 @@ void interchange_member_account(void (*handler)(interchange_response *)) request(handler, NULL, NULL, "%s", "member/account"); } -void interchange_member_setaccount(const char *fname, const char *lname, - const char *address1, const char *address2, const char *city, - const char *state, const char *zip, const char *email, - const char *phone_day) +void interchange_member_setaccount(const struct interchange_member *member, + void (*handler)(interchange_response *)) { - request(NULL, NULL, &(struct body){ 13, { - { "mv_form_profile", "account_change" }, - { "mv_todo", "return" }, - { "mv_nextpage", "member/account" }, - { "mv_check", "Save_database" }, - { "fname", fname }, - { "lname", lname }, - { "address1", address1 }, - { "address2", address2 }, - { "city", city }, - { "state", state }, - { "zip", zip }, - { "email", email }, - { "phone_day", phone_day } - }}, "%s", "process"); + request(handler, NULL, &(struct body){ 13, { + { "mv_form_profile", "account_change" }, + { "mv_todo", "return" }, + { "mv_nextpage", "member/account" }, + { "mv_check", "Save_database" }, + { "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 } + }}, "%s", "process"); } void interchange_member_changepassword(const char *password_old, const char *password, const char *verify) -- cgit v1.2.3