Annotation of mqtt/src/mqtt.c, revision 1.1.1.1.2.11
1.1 misho 1: #include "global.h"
1.1.1.1.2.5 misho 2: #include "rtlm.h"
3:
4:
5: sl_config cfg;
1.1 misho 6:
7:
8: int
9: main(int argc, char **argv)
10: {
1.1.1.1.2.6 misho 11: sqlite3 *acc = NULL, *pub = NULL;
1.1.1.1.2.9 misho 12: FILE *logg = NULL;
1.1.1.1.2.11! misho 13: int ret = 0;
1.1.1.1.2.5 misho 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)) {
1.1.1.1.2.8 misho 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);
1.1.1.1.2.5 misho 28: return 2;
29: }
1.1.1.1.2.9 misho 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: }
1.1.1.1.2.5 misho 37:
1.1.1.1.2.10 misho 38: acc = call.OpenACC(&cfg);
1.1.1.1.2.5 misho 39: if (!acc)
40: goto end;
1.1.1.1.2.10 misho 41: pub = call.OpenPUB(&cfg);
1.1.1.1.2.6 misho 42: if (!pub)
43: goto end;
1.1.1.1.2.10 misho 44: logg = call.OpenLOG(&cfg);
1.1.1.1.2.9 misho 45: if (!logg)
46: goto end;
1.1.1.1.2.5 misho 47:
1.1.1.1.2.7 misho 48: if (mqttMkDir(&cfg)) {
49: printf("Error:: in statedir #%d - %s\n", errno, strerror(errno));
50: goto end;
51: }
52:
1.1.1.1.2.10 misho 53: call.LOG(logg, "success!\n");
1.1.1.1.2.11! misho 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");
1.1.1.1.2.5 misho 59:
60: end:
1.1.1.1.2.10 misho 61: call.CloseLOG(logg);
62: call.ClosePUB(pub);
63: call.CloseACC(acc);
1.1.1.1.2.9 misho 64: mqttUnloadRTLM(2);
1.1.1.1.2.8 misho 65: mqttUnloadRTLM(1);
1.1.1.1.2.5 misho 66: mqttUnloadRTLM(0);
67: UnloadConfig(&cfg);
1.1 misho 68: return 0;
69: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>