summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-26 11:19:10 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-26 11:19:10 +0800
commit737bd34f39e9a3d14d170633e07c555d9e26d026 (patch)
treed67249324c3a1f7f3aab66d65af66abcc4cb22d3
parentb2073e82d797557321a803332204d96f21e2cb22 (diff)
Build product code again
-rw-r--r--Makefile.am2
-rw-r--r--icclient/product.h2
-rw-r--r--main.c9
-rw-r--r--product.c18
4 files changed, 20 insertions, 11 deletions
diff --git a/Makefile.am b/Makefile.am
index e603edd..f45c7d0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,10 +3,12 @@ libicclient_a_SOURCES = \
icclient/request.h \
icclient/login.h \
icclient/admin.h \
+ icclient/product.h \
icclient/client.h \
request.c \
login.c \
admin.c \
+ product.c \
client.c
bin_PROGRAMS = icclienttest
diff --git a/icclient/product.h b/icclient/product.h
index f912b17..2ea1f53 100644
--- a/icclient/product.h
+++ b/icclient/product.h
@@ -7,7 +7,7 @@ struct ic_product {
};
struct ic_catalog {
- unsigned int length;
+ size_t length;
struct ic_product *products[];
};
diff --git a/main.c b/main.c
index 2cad4f3..13df866 100644
--- a/main.c
+++ b/main.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
-#include <icclient/admin.h>
+#include <icclient/product.h>
#include <icclient/client.h>
int main(void)
@@ -27,10 +27,13 @@ int main(void)
icclient_init(url, NULL);
free(url);
- icclient_admin_login(name, pass, NULL, NULL, NULL);
+ icclient_login(name, pass, NULL, NULL, NULL);
free(name);
free(pass);
- icclient_admin_logout();
+ icclient_logout();
+
+ icclient_product_all(NULL, NULL);
+
icclient_cleanup();
}
diff --git a/product.c b/product.c
index d5d9bbe..bc7a7ea 100644
--- a/product.c
+++ b/product.c
@@ -1,21 +1,25 @@
#include <stdlib.h>
-#include "icclient/request.h"
+#include "request.h"
#include "icclient/product.h"
void icclient_product_all(struct ic_catalog **catalogptr
, size_t (*callback)(void *, size_t, size_t, void *))
{
- request("All-Products", callback, (void *)catalogptr, NULL);
+ request(NULL, NULL, NULL, "%s", "All-Products");
}
void rtclient_product_freecatalog(struct ic_catalog *catalog)
{
- for (unsigned short i = 0; i < catalog->length; i++) {
+ for (size_t i = 0; i < catalog->length; i++) {
struct ic_product *product = catalog->products[i];
- free(product->image);
- free(product->comment);
- free(product->description);
- free(product->sku);
+ if (product->image)
+ free(product->image);
+ if (product->comment)
+ free(product->comment);
+ if (product->description)
+ free(product->description);
+ if (product->sku)
+ free(product->sku);
free(product);
}
free(catalog);