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

#include <stdbool.h>
#include "icclient/member.h"
#include "request.h"

inline void login(size_t (*handler)(void *contents, size_t size
			, size_t nmemb, void *userdata), struct icclient_user *user
		, const char *username, const char *password, const char *verify
		, const char *click, const char *successpage, const char *nextpage
		, const char *failpage)
{
	struct curl_httppost *post, *last = NULL;
	curl_formadd(&post, &last
			, CURLFORM_COPYNAME, "mv_username"
			, CURLFORM_PTRCONTENTS, username
			, CURLFORM_END);
	curl_formadd(&post, &last
			, CURLFORM_COPYNAME, "mv_password"
			, CURLFORM_PTRCONTENTS, password
			, CURLFORM_END);
	if (verify)
		curl_formadd(&post, &last
				, CURLFORM_COPYNAME, "mv_verify"
				, CURLFORM_PTRCONTENTS, verify
				, CURLFORM_END);
	curl_formadd(&post, &last
			, CURLFORM_COPYNAME, "mv_click"
			, CURLFORM_PTRCONTENTS, click
			, CURLFORM_END);
	if (successpage)
		curl_formadd(&post, &last
				, CURLFORM_COPYNAME, "mv_successpage"
				, CURLFORM_PTRCONTENTS, successpage
				, CURLFORM_END);
	if (nextpage)
		curl_formadd(&post, &last
				, CURLFORM_COPYNAME, "mv_nextpage"
				, CURLFORM_PTRCONTENTS, nextpage
				, CURLFORM_END);
	if (failpage)
		curl_formadd(&post, &last
				, CURLFORM_COPYNAME, "mv_failpage"
				, CURLFORM_PTRCONTENTS, failpage
				, CURLFORM_END);
	last = NULL;
	request(handler, user, post, "%s", "process");
	curl_formfree(post);
	post = NULL;
}

#endif // ICCLIENT_LOGIN_H