summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin.c8
-rw-r--r--client.c8
-rw-r--r--handler.c6
-rw-r--r--icclient.h6
-rw-r--r--icclient/admin.h8
-rw-r--r--icclient/member.h4
-rw-r--r--icclient/typedefs.h4
-rw-r--r--login.c2
-rw-r--r--login.h2
-rw-r--r--main.c4
-rw-r--r--member.c4
-rw-r--r--request.c12
-rw-r--r--request.h14
13 files changed, 41 insertions, 41 deletions
diff --git a/admin.c b/admin.c
index 57d88ff..1bda169 100644
--- a/admin.c
+++ b/admin.c
@@ -3,14 +3,14 @@
#include "login.h"
#include "icclient/admin.h"
-void icclient_admin_login(const char *username, const char *password, void (*handler)(icclient_fetch_t *),
+void icclient_admin_login(const char *username, const char *password, void (*handler)(icclient_response *),
void (*callback)(struct icclient_admin *))
{
login(username, password, NULL, "MMLogin", handler, (void (*)(void *))callback);
}
void icclient_admin_new_admin(const char *username, const char *password, const char *name, bool super,
- enum icclient_admin_group group, void (*handler)(icclient_fetch_t *))
+ enum icclient_admin_group group, void (*handler)(icclient_response *))
{
request(handler, NULL, &(struct body){ 13, {
{ "mv_todo", "set" },
@@ -31,7 +31,7 @@ void icclient_admin_new_admin(const char *username, const char *password, const
}
void icclient_admin_new_item(const char *description, const char *comment, const char *price, const char *image_path,
- void (*handler)(icclient_fetch_t *))
+ void (*handler)(icclient_response *))
{
request(handler, NULL, &(struct body){ 15, {
{ "mv_click", "process_filter" },
@@ -59,7 +59,7 @@ void icclient_admin_new_item(const char *description, const char *comment, const
}}, "%s", "admin/item_edit");
}
-void icclient_admin_logout(struct icclient_admin *admin, void (*handler)(icclient_fetch_t *))
+void icclient_admin_logout(struct icclient_admin *admin, void (*handler)(icclient_response *))
{
request(handler, NULL, NULL, "%s", "admin/login");
if (admin->name)
diff --git a/client.c b/client.c
index 5c6e31a..fd34d3b 100644
--- a/client.c
+++ b/client.c
@@ -4,7 +4,7 @@
char *sampleurl;
char *image_dir;
-extern void handle_results(icclient_fetch_t *fetch);
+extern void handle_results(icclient_response *);
void icclient_init(const char *url, const char *dir, const char *certificate)
{
@@ -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 (*handler)(icclient_fetch_t *), void (*callback)(struct icclient_catalog *))
+void icclient_results(const char *prod_group, void (*handler)(icclient_response *), void (*callback)(struct icclient_catalog *))
{
char nonspaced[strlen(prod_group) + 1];
strcpy(nonspaced, prod_group);
@@ -29,12 +29,12 @@ void icclient_results(const char *prod_group, void (*handler)(icclient_fetch_t *
request(handler ? handler : handle_results, (void *)callback, 0, "%s", nonspaced);
}
-void icclient_flypage(const char *sku, void (*handler)(icclient_fetch_t *), struct icclient_product **productptr)
+void icclient_flypage(const char *sku, void (*handler)(icclient_response *), struct icclient_product **productptr)
{
request(handler, (void *)productptr, 0, "%s", sku);
}
-void icclient_page(const char *path, void (*handler)(icclient_fetch_t *), void **dataptr)
+void icclient_page(const char *path, void (*handler)(icclient_response *), void **dataptr)
{
request(handler, (void *)dataptr, 0, "%s", path);
}
diff --git a/handler.c b/handler.c
index f3e8f70..382184e 100644
--- a/handler.c
+++ b/handler.c
@@ -118,11 +118,11 @@ static void dumpNode(TidyDoc doc, TidyNode tnod, struct icclient_catalog **catal
}
}
-void handle_results(icclient_fetch_t *fetch)
+void handle_results(icclient_response *response)
{
TidyDoc tdoc = tidyCreate();
tidyOptSetBool(tdoc, TidyXhtmlOut, yes);
- tidyParseString(tdoc, fetch->data);
+ tidyParseString(tdoc, response->data);
tidyCleanAndRepair(tdoc);
tidyOptSetBool(tdoc, TidyForceOutput, yes);
TidyBuffer output = {0};
@@ -135,5 +135,5 @@ void handle_results(icclient_fetch_t *fetch)
tidyRelease(tdoc);
if (loc)
freelocale(loc);
- ((void (*)(struct icclient_catalog *))fetch->userData)(catalog);
+ ((void (*)(struct icclient_catalog *))response->userData)(catalog);
}
diff --git a/icclient.h b/icclient.h
index 6a1c365..670e2df 100644
--- a/icclient.h
+++ b/icclient.h
@@ -50,7 +50,7 @@ void icclient_init(const char *sampleurl, const char *image_dir, const char *cer
* \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 (*handler)(icclient_fetch_t *), void (*callback)(struct icclient_catalog *));
+void icclient_results(const char *prod_group, void (*handler)(icclient_response *), void (*callback)(struct icclient_catalog *));
/*!
* \brief For fetching data about a specific product.
@@ -58,9 +58,9 @@ void icclient_results(const char *prod_group, void (*handler)(icclient_fetch_t *
* \param handler A pointer to a cURL write function callback.
* \param productptr A pointer to pointer to the product to store the data.
*/
-void icclient_flypage(const char *sku, void (*handler)(icclient_fetch_t *), struct icclient_product **productptr);
+void icclient_flypage(const char *sku, void (*handler)(icclient_response *), struct icclient_product **productptr);
-void icclient_page(const char *path, void (*handler)(icclient_fetch_t *), void **dataptr);
+void icclient_page(const char *path, void (*handler)(icclient_response *), void **dataptr);
void icclient_free_product(struct icclient_product *product);
diff --git a/icclient/admin.h b/icclient/admin.h
index e1acee9..8f3c070 100644
--- a/icclient/admin.h
+++ b/icclient/admin.h
@@ -19,13 +19,13 @@ struct icclient_admin {
extern "C" {
#endif
- void icclient_admin_login(const char *username, const char *password, void (*handler)(icclient_fetch_t *),
+ void icclient_admin_login(const char *username, const char *password, void (*handler)(icclient_response *),
void (*callback)(struct icclient_admin *));
void icclient_admin_new_admin(const char *username, const char *password, const char *name, bool super,
- enum icclient_admin_group group, void (*handler)(icclient_fetch_t *));
+ enum icclient_admin_group group, void (*handler)(icclient_response *));
void icclient_admin_new_item(const char *description, const char *comment, const char *price, const char *image_path,
- void (*handler)(icclient_fetch_t *));
- void icclient_admin_logout(struct icclient_admin *admin, void (*handler)(icclient_fetch_t *));
+ void (*handler)(icclient_response *));
+ void icclient_admin_logout(struct icclient_admin *admin, void (*handler)(icclient_response *));
#ifdef __cplusplus
}
diff --git a/icclient/member.h b/icclient/member.h
index a1943a0..4e86bb2 100644
--- a/icclient/member.h
+++ b/icclient/member.h
@@ -61,8 +61,8 @@ extern "C" {
#endif
void icclient_member_newaccount(const char *username, const char *password, const char *verify,
- void (*handler)(icclient_fetch_t *), void (*callback)(struct icclient_member *));
- void icclient_member_login(const char *username, const char *password, void (*handler)(icclient_fetch_t *),
+ void (*handler)(icclient_response *), void (*callback)(struct icclient_member *));
+ void icclient_member_login(const char *username, const char *password, void (*handler)(icclient_response *),
void (*callback)(struct icclient_member *));
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);
diff --git a/icclient/typedefs.h b/icclient/typedefs.h
index ff5caca..73d8adf 100644
--- a/icclient/typedefs.h
+++ b/icclient/typedefs.h
@@ -9,7 +9,7 @@
#include <emscripten/fetch.h>
-typedef emscripten_fetch_t icclient_fetch_t;
+typedef emscripten_fetch_t icclient_response;
typedef char icclient_post;
#else
@@ -20,7 +20,7 @@ typedef struct {
void *userData;
char *data;
size_t numBytes;
-} icclient_fetch_t;
+} icclient_response;
typedef struct curl_httppost icclient_post;
#endif
diff --git a/login.c b/login.c
index 588cb37..1099479 100644
--- a/login.c
+++ b/login.c
@@ -1,3 +1,3 @@
#include "login.h"
-extern inline void login(const char *, const char *, const char *, const char *, void (*)(icclient_fetch_t *), void (*)(void *));
+extern inline void login(const char *, const char *, const char *, const char *, void (*)(icclient_response *), void (*)(void *));
diff --git a/login.h b/login.h
index 57d3446..dc0bc63 100644
--- a/login.h
+++ b/login.h
@@ -4,7 +4,7 @@
#include "request.h"
static inline void login(const char *username, const char *password, const char *verify, const char *click,
- void (*handler)(icclient_fetch_t *), void (*callback)(void *))
+ void (*handler)(icclient_response *), void (*callback)(void *))
{
request(handler, callback, &(struct body){ 4, {
{ "mv_username", username },
diff --git a/main.c b/main.c
index 2fd9dfa..befa49a 100644
--- a/main.c
+++ b/main.c
@@ -25,9 +25,9 @@ static void print_catalog(struct icclient_catalog *catalog)
icclient_free_catalog(catalog);
}
-static void print(icclient_fetch_t *fetch)
+static void print(icclient_response *response)
{
- printf("%s\n", fetch->data);
+ printf("%s\n", response->data);
}
int main(int argc, char *argv[])
diff --git a/member.c b/member.c
index 9f53113..74f416c 100644
--- a/member.c
+++ b/member.c
@@ -4,12 +4,12 @@
#include "icclient/member.h"
void icclient_member_newaccount(const char *username, const char *password, const char *verify,
- void (*handler)(icclient_fetch_t *), void (*callback)(struct icclient_member *))
+ void (*handler)(icclient_response *), void (*callback)(struct icclient_member *))
{
login(username, password, verify, "NewAccount", handler, (void (*)(void *))callback);
}
-void icclient_member_login(const char *username, const char *password, void (*handler)(icclient_fetch_t *),
+void icclient_member_login(const char *username, const char *password, void (*handler)(icclient_response *),
void (*callback)(struct icclient_member *))
{
login(username, password, NULL, "Login", handler, (void (*)(void *))callback);
diff --git a/request.c b/request.c
index 0912fa8..7c92a51 100644
--- a/request.c
+++ b/request.c
@@ -4,17 +4,17 @@
emscripten_fetch_attr_t attr;
#else
CURL *curl;
-size_t append(char *data, size_t size, size_t nmemb, icclient_fetch_t *fetch)
+size_t append(char *data, size_t size, size_t nmemb, icclient_response *response)
{
size_t realsize = size * nmemb;
- fetch->data = realloc(fetch->data, fetch->numBytes + realsize + 1);
- memcpy(&(fetch->data[fetch->numBytes]), data, realsize);
- fetch->numBytes += realsize;
- fetch->data[fetch->numBytes] = '\0';
+ response->data = realloc(response->data, response->numBytes + realsize + 1);
+ memcpy(&(response->data[response->numBytes]), data, realsize);
+ response->numBytes += realsize;
+ response->data[response->numBytes] = '\0';
return realsize;
}
#endif
extern inline void init(const char *);
-extern inline void request(void (*)(icclient_fetch_t *), void (*)(void *), struct body *, char *, ...);
+extern inline void request(void (*)(icclient_response *), void (*)(void *), struct body *, char *, ...);
extern inline void cleanup();
diff --git a/request.h b/request.h
index 64d6974..ec6720a 100644
--- a/request.h
+++ b/request.h
@@ -23,7 +23,7 @@ extern emscripten_fetch_attr_t attr;
#else
extern CURL *curl;
extern char *sampleurl;
-size_t append(char *, size_t, size_t, icclient_fetch_t *);
+size_t append(char *, size_t, size_t, icclient_response *);
#endif
static inline void init(const char *certificate)
@@ -44,7 +44,7 @@ static inline void init(const char *certificate)
#endif
}
-static inline void request(void (*handler)(icclient_fetch_t *), void (*callback)(void *), struct body *body, char *fmt, ...)
+static inline void request(void (*handler)(icclient_response *), void (*callback)(void *), struct body *body, char *fmt, ...)
{
va_list ap;
char *p, *sval;
@@ -138,7 +138,7 @@ static inline void request(void (*handler)(icclient_fetch_t *), void (*callback)
#else
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, append);
- icclient_fetch_t fetch = { .numBytes = 0 };
+ icclient_response response = { .numBytes = 0 };
struct curl_httppost *post, *last = NULL;
if (body) {
for (size_t i = 0; i < body->num_pairs; i++) {
@@ -155,15 +155,15 @@ static inline void request(void (*handler)(icclient_fetch_t *), void (*callback)
struct icclient_post_callback *post_callback = malloc(sizeof(struct icclient_post_callback));
post_callback->post = post;
post_callback->callback = callback;
- fetch.userData = post_callback;
+ response.userData = post_callback;
} else {
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
- fetch.userData = callback;
+ response.userData = callback;
}
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &fetch);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
CURLcode res = curl_easy_perform(curl);
if (res == CURLE_OK && handler)
- handler(&fetch);
+ handler(&response);
#ifdef DEBUG
else {
const char *error = curl_easy_strerror(res);