]> code.citadel.org Git - citadel.git/blob - libCxClient/src/testlib.c
Initial revision
[citadel.git] / libCxClient / src / testlib.c
1 /**
2  ** This is a test program for libCxClient.  It's not important.
3  **/
4 #include        <stdio.h>
5 #include        <stdlib.h>
6 #include        <string.h>
7 #include        "CxClient.h"
8
9 /**
10  ** 901 express message callback...
11  **/
12 void            chathook(const char *user, const char *msg) {
13         printf("Chat Message Handler\n");
14
15         printf("[[[[[[ %s ]]]]]]\n", user);
16         printf("%s\n", msg);
17 }
18
19 int             main(int argc, char *argv[]) {
20 CXLIST          fl = 0;
21 USERINFO        *user_info = 0;
22 ROOMINFO        *room_info = 0;
23 char            buf[255],*s = 0;
24
25         printf("libCxClient Test Program\n");
26         printf("Library Revision %0.2f\n\n", CxRevision());
27
28         if(argc<3) {
29                 printf("\nUsage:\n      %s system username password\n\n", argv[0]);
30                 exit(0);
31         }
32
33         CxClRegClient("test program");
34         printf("Registering callbacks\n");
35         CxMiExpHook(chathook);
36
37         // I suggest 'tesseract.citadel.org'
38         printf("Connecting to '%s'...\n",argv[1]);
39         if(!CxClConnect(argv[1])) {
40
41                 printf("Logging in\n");
42                 if(user_info = CxUsAuth(argv[2],argv[3])) {
43                         CxFree(user_info);
44                         user_info = 0;
45
46                         room_info = CxRmGoto("_BASEROOM_",0);
47                         CxFree(room_info);
48                         room_info = 0;
49
50                         fl = CxLlFlush(fl);
51                         fl = CxMsList();
52
53                         fl = CxLlFlush(fl);
54
55                         CxMiExpSend("detsaoT","Hello, World");
56                         CxMiExpSend("detsaoT","How are you?");
57                         CxMiExpSend("detsaoT","Blah blah blah.");
58
59
60                         CxClSend("ECHO Hello");
61                         CxClRecv(buf);
62
63                 }
64
65                 CxClCbShutdown();
66
67         } else {
68                 printf("Unable to connect to 'bbs.shadowcom.net'!\n");
69         }
70
71 }