Annotation of mqtt/src/mqtt.c, revision 1.1.1.1.2.14

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: 
1.1.1.1.2.12  misho      60:        if ((ret = call.InitSessPUB(&cfg, pub, "misho", "127.0.0.1", 12345)) == -1) {
1.1.1.1.2.13  misho      61:                printf("Error:: Session init problem\n");
1.1.1.1.2.12  misho      62:                goto end;
                     63:        } else
                     64:                call.LOG(logg, "InitSess: %d\n", ret);
                     65: 
1.1.1.1.2.14! misho      66:        if ((ret = call.ChkSessPUB(&cfg, pub, "misho", "127.0._.1%")) == -1) {
        !            67:                printf("Error:: Session check problem\n");
        !            68:                goto end;
        !            69:        } else
        !            70:                call.LOG(logg, "ChkSess: %d\n", ret);
        !            71: 
1.1.1.1.2.13  misho      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: 
1.1.1.1.2.5  misho      78: end:
1.1.1.1.2.10  misho      79:        call.CloseLOG(logg);
                     80:        call.ClosePUB(pub);
                     81:        call.CloseACC(acc);
1.1.1.1.2.9  misho      82:        mqttUnloadRTLM(2);
1.1.1.1.2.8  misho      83:        mqttUnloadRTLM(1);
1.1.1.1.2.5  misho      84:        mqttUnloadRTLM(0);
                     85:        UnloadConfig(&cfg);
1.1       misho      86:        return 0;
                     87: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>