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: end:
61: call.CloseLOG(logg);
62: call.ClosePUB(pub);
63: call.CloseACC(acc);
64: mqttUnloadRTLM(2);
65: mqttUnloadRTLM(1);
66: mqttUnloadRTLM(0);
67: UnloadConfig(&cfg);
68: return 0;
69: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>