Use ${_sysconfdir} instead of PLD's ${_appconfdir}.
[doldaconnect.git] / clients / test.c
CommitLineData
d3372da9 1#include <stdio.h>
2#include <stdlib.h>
3#include <sys/poll.h>
4
5#include <doldaconnect/uilib.h>
6#include <doldaconnect/uimisc.h>
7
8void authcallback(int err, wchar_t *reason, void *data)
9{
10 printf("Logged in: %i\n", err);
11}
12
13int main(int argc, char **argv)
14{
d3372da9 15 struct pollfd pfd;
16 int fd, done;
17 struct dc_response *resp;
d3372da9 18
19 dc_init();
65bf229b 20 fd = dc_connect(NULL);
d3372da9 21 done = 0;
22 while(!done)
23 {
24 pfd.fd = fd;
25 pfd.events = POLLIN;
26 if(dc_wantwrite())
27 pfd.events = POLLOUT;
28 if(poll(&pfd, 1, -1) < 0)
29 {
30 perror("poll");
31 exit(1);
32 }
33 if((pfd.revents & POLLIN) && dc_handleread())
34 done = 1;
35 if((pfd.revents & POLLOUT) && dc_handlewrite())
36 done = 1;
37 while((resp = dc_getresp()) != NULL)
38 {
bf46d8f1 39 if(!wcscmp(resp->cmdname, L".connect"))
d3372da9 40 {
1157d12b 41 printf("Connected: %i\n", resp->code);
e5c8b0ca 42 if(resp->code == 201)
1157d12b 43 dc_loginasync(NULL, 1, NULL, authcallback, NULL);
d3372da9 44 }
45 dc_freeresp(resp);
46 }
47 }
48 dc_cleanup();
49 return(0);
50}