Remove [AP]F_* comment from netcslisten.
[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{
15 int i;
16 struct pollfd pfd;
17 int fd, done;
18 struct dc_response *resp;
19 struct dc_intresp *ires;
20
21 dc_init();
22 fd = dc_connect("localhost", -1);
23 done = 0;
24 while(!done)
25 {
26 pfd.fd = fd;
27 pfd.events = POLLIN;
28 if(dc_wantwrite())
29 pfd.events = POLLOUT;
30 if(poll(&pfd, 1, -1) < 0)
31 {
32 perror("poll");
33 exit(1);
34 }
35 if((pfd.revents & POLLIN) && dc_handleread())
36 done = 1;
37 if((pfd.revents & POLLOUT) && dc_handlewrite())
38 done = 1;
39 while((resp = dc_getresp()) != NULL)
40 {
41 if(resp->cmdname == NULL)
42 {
43 printf("Connected\n");
44 dc_loginasync(NULL, 0, NULL, authcallback, NULL);
45 }
46 dc_freeresp(resp);
47 }
48 }
49 dc_cleanup();
50 return(0);
51}