summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin.c8
-rw-r--r--client.c18
-rw-r--r--icclient/admin.h5
-rw-r--r--icclient/client.h11
-rw-r--r--login.c4
-rw-r--r--login.h8
-rw-r--r--main.c2
7 files changed, 42 insertions, 14 deletions
diff --git a/admin.c b/admin.c
index 60bf583..6e40ddd 100644
--- a/admin.c
+++ b/admin.c
@@ -1,11 +1,15 @@
#include "login.h"
#include "icclient/admin.h"
-void icclient_admin_login(const char *username, const char *password
+void icclient_admin_login(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata)
+ , struct icclient_user *user
+ , const char *username, const char *password
, const char *successpage, const char *nextpage
, const char *failpage)
{
- login(username, password, NULL, "MMLogin", successpage, nextpage, failpage);
+ login(handler, user, username, password, NULL, "MMLogin", successpage
+ , nextpage, failpage);
}
void icclient_admin_logout()
diff --git a/client.c b/client.c
index d60c8e1..9a2aa09 100644
--- a/client.c
+++ b/client.c
@@ -5,6 +5,7 @@
#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;
@@ -115,19 +116,26 @@ void icclient_order(icclient_ord_order **orderptr, const char *sku
request(NULL, NULL, NULL, "%s%s", "order?mv_arg=", sku);
}
-void icclient_newaccount(const char *username, const char *password
+void icclient_newaccount(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata)
+ , struct icclient_user *user
+ , const char *username, const char *password
, const char *verify, const char *successpage, const char *nextpage
, const char *failpage)
{
- login(username, password, verify, "NewAccount", successpage, nextpage
- , failpage);
+ login(handler, user, username, password, verify, "NewAccount", successpage
+ , nextpage, failpage);
}
-void icclient_login(const char *username, const char *password
+void icclient_login(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata)
+ , struct icclient_user *user
+ , const char *username, const char *password
, const char *successpage, const char *nextpage
, const char *failpage)
{
- login(username, password, NULL, "Login", successpage, nextpage, failpage);
+ login(handler, user, username, password, NULL, "Login", successpage
+ , nextpage, failpage);
}
void icclient_logout()
diff --git a/icclient/admin.h b/icclient/admin.h
index e01fdc9..1b6bd68 100644
--- a/icclient/admin.h
+++ b/icclient/admin.h
@@ -5,7 +5,10 @@
extern "C" {
#endif
- void icclient_admin_login(const char *username, const char *password
+ void icclient_admin_login(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata)
+ , struct icclient_user *user
+ , const char *username, const char *password
, const char *successpage, const char *nextpage
, const char *failpage);
void icclient_admin_logout();
diff --git a/icclient/client.h b/icclient/client.h
index db38926..56db8fd 100644
--- a/icclient/client.h
+++ b/icclient/client.h
@@ -3,6 +3,7 @@
struct icclient_product;
struct icclient_catalog;
+struct icclient_user;
struct icclient_ord_order;
#ifdef __cplusplus
@@ -15,10 +16,16 @@ extern "C" {
, struct icclient_catalog **catalogptr);
void icclient_order(struct icclient_ord_order **orderptr, const char *sku
, struct icclient_catalog *catalog);
- void icclient_newaccount(const char *username, const char *password
+ void icclient_newaccount(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata)
+ , struct icclient_user *user
+ , const char *username, const char *password
, const char *verify, const char *successpage
, const char *nextpage, const char *failpage);
- void icclient_login(const char *username, const char *password
+ void icclient_login(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata)
+ , struct icclient_user *user
+ , const char *username, const char *password
, const char *successpage, const char *nextpage
, const char *failpage);
void icclient_logout();
diff --git a/login.c b/login.c
index 7455e6f..be32612 100644
--- a/login.c
+++ b/login.c
@@ -1,4 +1,6 @@
#include "login.h"
-extern inline void login(const char *, const char *, const char *, const char *
+extern inline void login(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata), struct icclient_user *user
+ , const char *, const char *, const char *, const char *
, const char *, const char *, const char *);
diff --git a/login.h b/login.h
index a9dbe43..6d02cde 100644
--- a/login.h
+++ b/login.h
@@ -1,9 +1,13 @@
#ifndef ICCLIENT_LOGIN_H
#define ICCLIENT_LOGIN_H
+#include <stdbool.h>
+#include "icclient/member.h"
#include "request.h"
-inline void login(const char *username, const char *password, const char *verify
+inline void login(size_t (*handler)(void *contents, size_t size
+ , size_t nmemb, void *userdata), struct icclient_user *user
+ , const char *username, const char *password, const char *verify
, const char *click, const char *successpage, const char *nextpage
, const char *failpage)
{
@@ -41,7 +45,7 @@ inline void login(const char *username, const char *password, const char *verify
, CURLFORM_PTRCONTENTS, failpage
, CURLFORM_END);
last = NULL;
- request(NULL, NULL, post, "%s", "process");
+ request(handler, user, post, "%s", "process");
curl_formfree(post);
post = NULL;
}
diff --git a/main.c b/main.c
index 2d72969..68f5867 100644
--- a/main.c
+++ b/main.c
@@ -26,7 +26,7 @@ int main(void)
icclient_init(url, NULL);
free(url);
- icclient_login(name, pass, NULL, NULL, NULL);
+ icclient_login(NULL, NULL, name, pass, NULL, NULL, NULL);
free(name);
free(pass);