summaryrefslogtreecommitdiff
path: root/login.h
blob: c5ca150fc61983d8f402c99503702b178323c67c (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
#ifndef INTERCHANGE_LOGIN_H
#define INTERCHANGE_LOGIN_H

#include "request.h"

static inline void login(const char *username, const char *password,
		const char *verify, const char *click, const char *nextpage,
		const char *successpage, const char *failpage,
		void (*handler)(interchange_response *),
		void (*callback)(void *))
{
	const char *body[(verify ? 1 : 0) + (successpage ? 1: 0)
		+ (failpage ? 1 : 0) + 5][2];
	body[0][0] = "mv_username";
	body[0][1] = username;
	body[1][0] = "mv_password";
	body[1][1] = password;
	body[2][0] = "mv_click";
	body[2][1] = click;
	body[3][0] = "mv_nextpage";
	body[3][1] = nextpage;
	size_t i = 4;
	if (successpage) {
		body[i][0] = "mv_successpage";
		body[i++][1] = successpage;
	}
	if (failpage) {
		body[i][0] = "mv_failpage";
		body[i++][1] = failpage;
	}
	if (verify) {
		body[i][0] = "mv_verify";
		body[i++][1] = verify;
	}
	body[i][0] = NULL;
	request(handler, callback, body, "%s", "process");
}

#endif