Annotation of mqtt/example/rtlm.c, revision 1.1.2.1

1.1.2.1 ! misho       1: /*
        !             2:  * Test sequence for RTLM SQL modules
        !             3:  */
        !             4: #include <stdio.h>
        !             5: #include <stdlib.h>
        !             6: #include <string.h>
        !             7: #include <sys/types.h>
        !             8: #include <aitmqtt.h>
        !             9: 
        !            10: #if 0
        !            11:        int ret = 0;
        !            12:        mqtt_subscr_t *s, *p;
        !            13: 
        !            14:        if (LoadConfig("/etc/mqtt.conf", &cfg)) {
        !            15:                printf("Error:: Load config #%d - %s\n", cfg_GetErrno(), cfg_GetError());
        !            16:                return 1;
        !            17:        }
        !            18:        if (!mqttLoadRTLM(&cfg, 0)) {
        !            19:                printf("Error:: Can't load RTL ACC module\n");
        !            20:                UnloadConfig(&cfg);
        !            21:                return 2;
        !            22:        }
        !            23:        if (!mqttLoadRTLM(&cfg, 1)) {
        !            24:                printf("Error:: Can't load RTL PUB module\n");
        !            25:                mqttUnloadRTLM(0);
        !            26:                UnloadConfig(&cfg);
        !            27:                return 2;
        !            28:        }
        !            29:        if (!mqttLoadRTLM(&cfg, 2)) {
        !            30:                printf("Error:: Can't load RTL LOG module\n");
        !            31:                mqttUnloadRTLM(1);
        !            32:                mqttUnloadRTLM(0);
        !            33:                UnloadConfig(&cfg);
        !            34:                return 2;
        !            35:        }
        !            36: 
        !            37:        acc = call.OpenACC(&cfg);
        !            38:        if (!acc)
        !            39:                goto end;
        !            40:        pub = call.OpenPUB(&cfg);
        !            41:        if (!pub)
        !            42:                goto end;
        !            43:        logg = call.OpenLOG(&cfg);
        !            44:        if (!logg)
        !            45:                goto end;
        !            46: 
        !            47:        if (mqttMkDir(&cfg)) {
        !            48:                printf("Error:: in statedir #%d - %s\n", errno, strerror(errno));
        !            49:                goto end;
        !            50:        }
        !            51: 
        !            52:        call.LOG(logg, "success!\n");
        !            53:        if ((ret = call.LoginACC(&cfg, acc, "misho", "test123")) == -1) {
        !            54:                printf("Error:: Authentication problem\n");
        !            55:                goto end;
        !            56:        } else
        !            57:                call.LOG(logg, "Login: %s\n", ret ? "ALLOW" : "DENIED");
        !            58: 
        !            59:        if ((ret = call.InitSessPUB(&cfg, pub, "misho", "doophenschmerz", "127.0.0.1", 12345, 1, 
        !            60:                                        "Topic43", "mmm", 2, 0)) == -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", "doophenschmerz", "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.DeletePUB(&cfg, pub, 10, "%", "%", "%", -1)) == -1) {
        !            73:                printf("Error:: Clear problem\n");
        !            74:                goto end;
        !            75:        } else
        !            76:                call.LOG(logg, "Clear: %d\n", ret);
        !            77: 
        !            78:        if ((ret = call.WritePUB(&cfg, pub, 10, "oho/boho", "MRYN    \n tryn brymbryn", "misho", "1.1.1.1", 1)) == -1) {
        !            79:                printf("Error:: Publish problem\n");
        !            80:                goto end;
        !            81:        } else
        !            82:                call.LOG(logg, "Publish: %d\n", ret);
        !            83:        if ((ret = call.WritePUB(&cfg, pub, 11, "boh", "testing", "misho", "1.1.1.2", 0)) == -1) {
        !            84:                printf("Error:: Publish problem\n");
        !            85:                goto end;
        !            86:        } else
        !            87:                call.LOG(logg, "Publish: %d\n", ret);
        !            88:        if (!(s = call.ReadPUB(&cfg, pub, 10, "%", -1))) {
        !            89:                printf("Error:: Subscribe problem\n");
        !            90:                goto end;
        !            91:        } else {
        !            92:                call.LOG(logg, "Subscribe: %p\n", s);
        !            93:                for (p = s; p->sub_topic._base; p++) {
        !            94:                        printf("Retain=%d Topic(%d)=%s Value(%d)=%s\n", p->sub_ret, 
        !            95:                                        p->sub_topic._size, p->sub_topic._base, 
        !            96:                                        p->sub_value._size, p->sub_value._base);
        !            97:                }
        !            98:                mqtt_subFree(&s);
        !            99:        }
        !           100:        if ((ret = call.DeletePUB(&cfg, pub, 11, "boh", "misho", "1.1.1._", 0)) == -1) {
        !           101:                printf("Error:: Delete problem\n");
        !           102:                goto end;
        !           103:        } else
        !           104:                call.LOG(logg, "Delete: %d\n", ret);
        !           105: 
        !           106:        if ((ret = call.FiniSessPUB(&cfg, pub, "misho", "doophenschmerz", "127.0._.1%")) == -1) {
        !           107:                printf("Error:: Session fini problem\n");
        !           108:                goto end;
        !           109:        } else
        !           110:                call.LOG(logg, "FiniSess: %d\n", ret);
        !           111: 
        !           112: end:
        !           113:        call.CloseLOG(logg);
        !           114:        call.ClosePUB(pub);
        !           115:        call.CloseACC(acc);
        !           116:        mqttUnloadRTLM(2);
        !           117:        mqttUnloadRTLM(1);
        !           118:        mqttUnloadRTLM(0);
        !           119:        UnloadConfig(&cfg);
        !           120: #endif

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