summaryrefslogtreecommitdiff
path: root/main.c
blob: b3e4f4feadb0eefe37799e7bf4e341be5494f7d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "icclient.h"
#include "icclient/member.h"

static void print_catalog(struct icclient_catalog *catalog)
{
	for (size_t i = 0; i < catalog->length; i++) {
		struct icclient_product *product = catalog->products[i];
		printf("sku: %s | "
				"desc: %s | "
				"img: %s | "
				"prc: %f | "
				"cat: %s\n",
				product->sku,
				product->description,
				product->image,
				product->price,
				product->category
		      );
	}
	icclient_free_catalog(catalog);
}
/*
static void print_user(icclient_fetch_t *fetch)
{
	printf("%s\n", fetch->data);
}
*/
int main(int argc, char *argv[])
{
	icclient_init("https://demo.interchangecommerce.org/i/demo", "/demo/images", NULL);
	icclient_allproducts(print_catalog, NULL);
/*
	char *name_line = NULL;
	printf("\nName: ");
	ssize_t name_nread = getline(&name_line, &(size_t){0}, stdin);
	char *name = malloc(--name_nread + 1);
	strncpy(name, name_line, name_nread);
	free(name_line);

	char *pass_line = NULL;
	printf("Pass: ");
	ssize_t pass_nread = getline(&pass_line, &(size_t){0}, stdin);
	char *pass = malloc(--pass_nread + 1);
	strncpy(pass, pass_line, pass_nread);
	free(pass_line);
	pass[pass_nread] = '\0';

	struct icclient_member *member = icclient_member_login(name, pass, NULL, NULL, NULL, print_user);
	free(name);
	free(pass);
	icclient_member_logout(member);
*/
	icclient_cleanup();
}