1: #include "global.h"
2: #include "rtlm.h"
3:
4:
5: sl_config cfg;
6:
7:
8: int
9: main(int argc, char **argv)
10: {
11: sqlite3 *acc = NULL, *pub = NULL;
12: FILE *logg = NULL;
13: int ret = 0;
14:
15: if (LoadConfig("/etc/mqtt.conf", &cfg)) {
16: printf("Error:: Load config #%d - %s\n", cfg_GetErrno(), cfg_GetError());
17: return 1;
18: }
19: if (!mqttLoadRTLM(&cfg, 0)) {
20: printf("Error:: Can't load RTL ACC module\n");
21: UnloadConfig(&cfg);
22: return 2;
23: }
24: if (!mqttLoadRTLM(&cfg, 1)) {
25: printf("Error:: Can't load RTL PUB module\n");
26: mqttUnloadRTLM(0);
27: UnloadConfig(&cfg);
28: return 2;
29: }
30: if (!mqttLoadRTLM(&cfg, 2)) {
31: printf("Error:: Can't load RTL LOG module\n");
32: mqttUnloadRTLM(1);
33: mqttUnloadRTLM(0);
34: UnloadConfig(&cfg);
35: return 2;
36: }
37:
38: acc = call.OpenACC(&cfg);
39: if (!acc)
40: goto end;
41: pub = call.OpenPUB(&cfg);
42: if (!pub)
43: goto end;
44: logg = call.OpenLOG(&cfg);
45: if (!logg)
46: goto end;
47:
48: if (mqttMkDir(&cfg)) {
49: printf("Error:: in statedir #%d - %s\n", errno, strerror(errno));
50: goto end;
51: }
52:
53: call.LOG(logg, "success!\n");
54: if ((ret = call.LoginACC(&cfg, acc, "misho", "test123")) == -1) {
55: printf("Error:: Authentication problem\n");
56: goto end;
57: } else
58: call.LOG(logg, "Login: %s\n", ret ? "ALLOW" : "DENIED");
59:
60: if ((ret = call.InitSessPUB(&cfg, pub, "misho", "127.0.0.1", 12345)) == -1) {
61: printf("Error:: Session init problem\n");
62: goto end;
63: } else
64: call.LOG(logg, "InitSess: %d\n", ret);
65:
66: if ((ret = call.ChkSessPUB(&cfg, pub, "misho", "127.0._.%")) == -1) {
67: printf("Error:: Session check problem\n");
68: goto end;
69: } else
70: call.LOG(logg, "ChkSess: %d\n", ret);
71:
72: if ((ret = call.FiniSessPUB(&cfg, pub, "misho", "127.0._.1%")) == -1) {
73: printf("Error:: Session fini problem\n");
74: goto end;
75: } else
76: call.LOG(logg, "FiniSess: %d\n", ret);
77:
78: end:
79: call.CloseLOG(logg);
80: call.ClosePUB(pub);
81: call.CloseACC(acc);
82: mqttUnloadRTLM(2);
83: mqttUnloadRTLM(1);
84: mqttUnloadRTLM(0);
85: UnloadConfig(&cfg);
86: return 0;
87: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>