summaryrefslogtreecommitdiffstats
path: root/src/main.c
blob: 7288332752066817fd7c1b0a3132f0534266b72b (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <libwebsockets.h>
#include <assert.h>
#include <signal.h>
#include <lib.c>
#include <ui.c>
#include <api.c>
int dc_interrupted;
void dc_signal (int i) {
	dc_interrupted++;
	return;
}
int main (int argc, char * argv[]) {
	if (DC_JSON_PATHS_LENGTH != sizeof(dc_json_paths)/sizeof(dc_json_paths[0]) || DC_JSON_PATHS_LENGTH > 255) {
		fprintf(stderr, "json paths enum: %d, array: %d (255 is max, must be same)\n", DC_JSON_PATHS_LENGTH, sizeof(dc_json_paths)/sizeof(dc_json_paths[0]));
		return 1;
	}
	struct dc_program * p = dc_program_init();
	struct dc_client * client = dc_client_init();
	lws_set_log_level(0xFF /* all message types */, NULL /* not change output location - cerr */);
	client->email = strdup(getenv("DC_E"));
	client->password = strdup(getenv("DC_P"));
	struct dc_api_io i = {
		.program = p,
		.type = DC_API_LOGIN,
		.client = client
	};
	dc_api_i(i);
	signal(SIGINT, dc_signal);
	while (!dc_interrupted)
		i = dc_api_o(i);
	/* dc_ui(argc, argv); */
	dc_program_free(p, DC_UNSET);
	return 0;
}