diff options
-rw-r--r-- | client.c | 26 | ||||
-rw-r--r-- | icclient/client.h | 12 | ||||
-rw-r--r-- | icclient/member.h | 9 | ||||
-rw-r--r-- | login.h | 60 | ||||
-rw-r--r-- | member.c | 25 |
5 files changed, 64 insertions, 68 deletions
@@ -1,11 +1,10 @@ #include <stdbool.h> #include <stdlib.h> #include <string.h> -#include "login.h" +#include "request.h" #include "icclient/product.h" #include "icclient/catalog.h" #include "icclient/ord.h" -#include "icclient/member.h" #include "icclient/client.h" typedef struct icclient_product icclient_product; @@ -130,29 +129,6 @@ void icclient_order(const char *sku, const icclient_catalog *catalog, request(NULL, NULL, NULL, "%s%s", "order?mv_arg=", sku); } -void icclient_newaccount(size_t (*handler)(void *, size_t, size_t, void *), - struct icclient_member *member, - const char *username, const char *password, const char *verify, - const char *successpage, const char *nextpage, const char *failpage) -{ - login(handler, member, username, password, verify, "NewAccount", successpage, - nextpage, failpage); -} - -void icclient_login(size_t (*handler)(void *, size_t, size_t, void *), - struct icclient_member *member, - const char *username, const char *password, - const char *successpage, const char *nextpage, const char *failpage) -{ - login(handler, member, username, password, NULL, "Login", successpage, nextpage, - failpage); -} - -void icclient_logout() -{ - request(NULL, NULL, NULL, "%s", "logout"); -} - void icclient_page(const char *path, size_t (*handler)(void *, size_t, size_t, void *), void **dataptr) diff --git a/icclient/client.h b/icclient/client.h index a58bce1..ee11a2a 100644 --- a/icclient/client.h +++ b/icclient/client.h @@ -3,7 +3,6 @@ struct icclient_product; struct icclient_catalog; -struct icclient_member; struct icclient_ord_order; #ifdef __cplusplus @@ -54,17 +53,6 @@ extern "C" { */ void icclient_order(const char *sku, const struct icclient_catalog *catalog, struct icclient_ord_order **orderptr); - void icclient_newaccount(size_t (*handler)(void *, size_t, size_t, void *), - struct icclient_member *member, - const char *username, const char *password, - const char *verify, const char *successpage, - const char *nextpage, const char *failpage); - void icclient_login(size_t (*handler)(void *, size_t, size_t, void *), - struct icclient_member *member, - const char *username, const char *password, - const char *successpage, const char *nextpage, - const char *failpage); - void icclient_logout(); void icclient_page(const char *path, size_t (*handler)(void *, size_t, size_t, void *), void **dataptr); diff --git a/icclient/member.h b/icclient/member.h index dd44e78..a91c5d6 100644 --- a/icclient/member.h +++ b/icclient/member.h @@ -55,12 +55,21 @@ struct icclient_member { extern "C" { #endif + void icclient_member_newaccount(size_t (*handler)(void *, size_t, size_t, void *), + struct icclient_member *member, const char *username, + const char *password, const char *verify, const char *successpage, + const char *nextpage, const char *failpage); + void icclient_member_login(size_t (*handler)(void *, size_t, size_t, void *), + struct icclient_member *member, const char *username, + const char *password, const char *successpage, + const char *nextpage, const char *failpage); void icclient_member_account(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 icclient_member_changepassword(const char *password_old, const char *password, const char *verify); + void icclient_member_logout(); #ifdef __cplusplus } @@ -1,48 +1,48 @@ #ifndef ICCLIENT_LOGIN_H #define ICCLIENT_LOGIN_H -#include <stdbool.h> -#include "icclient/member.h" #include "request.h" +struct icclient_member; + inline void login(size_t (*handler)(void *, size_t, size_t, void *), struct icclient_member *member, const char *username, const char *password, const char *verify, const char *click, const char *successpage, const char *nextpage, const char *failpage) { struct curl_httppost *post, *last = NULL; - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "mv_username" - , CURLFORM_PTRCONTENTS, username - , CURLFORM_END); - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "mv_password" - , CURLFORM_PTRCONTENTS, password - , CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "mv_username", + CURLFORM_PTRCONTENTS, username, + CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "mv_password", + CURLFORM_PTRCONTENTS, password, + CURLFORM_END); if (verify) - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "mv_verify" - , CURLFORM_PTRCONTENTS, verify - , CURLFORM_END); - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "mv_click" - , CURLFORM_PTRCONTENTS, click - , CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "mv_verify", + CURLFORM_PTRCONTENTS, verify, + CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "mv_click", + CURLFORM_PTRCONTENTS, click, + CURLFORM_END); if (successpage) - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "mv_successpage" - , CURLFORM_PTRCONTENTS, successpage - , CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "mv_successpage", + CURLFORM_PTRCONTENTS, successpage, + CURLFORM_END); if (nextpage) - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "mv_nextpage" - , CURLFORM_PTRCONTENTS, nextpage - , CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "mv_nextpage", + CURLFORM_PTRCONTENTS, nextpage, + CURLFORM_END); if (failpage) - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "mv_failpage" - , CURLFORM_PTRCONTENTS, failpage - , CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "mv_failpage", + CURLFORM_PTRCONTENTS, failpage, + CURLFORM_END); last = NULL; request(handler, member, post, "%s", "process"); curl_formfree(post); @@ -1,7 +1,25 @@ +#include <stddef.h> #include <stdbool.h> -#include "request.h" +#include "login.h" #include "icclient/member.h" +void icclient_member_newaccount(size_t (*handler)(void *, size_t, size_t, void *), + struct icclient_member *member, const char *username, const char *password, + const char *verify, const char *successpage, const char *nextpage, + const char *failpage) +{ + login(handler, member, username, password, verify, "NewAccount", successpage, + nextpage, failpage); +} + +void icclient_member_login(size_t (*handler)(void *, size_t, size_t, void *), + struct icclient_member *member, const char *username, const char *password, + const char *successpage, const char *nextpage, const char *failpage) +{ + login(handler, member, username, password, NULL, "Login", successpage, nextpage, + failpage); +} + void icclient_member_account(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) @@ -98,3 +116,8 @@ void icclient_member_changepassword(const char *password_old, const char *passwo curl_formfree(post); post = NULL; } + +void icclient_member_logout() +{ + request(NULL, NULL, NULL, "%s", "logout"); +} |