Annotation of mqtt/src/utils.c, revision 1.2.2.5

1.2       misho       1: #include "global.h"
1.2.2.5 ! misho       2: #include "mqttd.h"
1.2       misho       3: 
                      4: 
1.2.2.5 ! misho       5: inline int
1.2.2.1   misho       6: srv_Socket(cfg_root_t * __restrict cfg)
1.2       misho       7: {
1.2.2.5 ! misho       8:        int s = -1;
1.2.2.1   misho       9:        ait_val_t v;
1.2       misho      10:        u_short port;
1.2.2.4   misho      11:        io_sockaddr_t sa = {{ 0 }};
1.2       misho      12: 
                     13:        ioTRACE(2);
                     14: 
1.2.2.4   misho      15:        assert(cfg);
                     16: 
1.2.2.1   misho      17:        cfg_loadAttribute(cfg, "mqttd", "port", &v, MQTT_PORT);
                     18:        port = strtol(AIT_GET_STR(&v), NULL, 0);
                     19:        AIT_FREE_VAL(&v);
                     20:        cfg_loadAttribute(cfg, "mqttd", "listen", &v, MQTT_HOST);
1.2.2.3   misho      21:        if (!io_gethostbyname(AIT_GET_STR(&v), port, &sa)) {
                     22:                ioLIBERR(io);
                     23:                AIT_FREE_VAL(&v);
1.2       misho      24:                return -1;
1.2.2.3   misho      25:        } else
                     26:                AIT_FREE_VAL(&v);
1.2       misho      27: 
1.2.2.5 ! misho      28:        s = mqtt_srv_Create(&sa.sa, sa.sa.sa_len);
1.2       misho      29:        if (s == -1) {
1.2.2.5 ! misho      30:                ioLIBERR(mqtt);
1.2       misho      31:                return -1;
                     32:        }
                     33: 
                     34:        return s;
                     35: }
                     36: 
1.2.2.5 ! misho      37: inline int
1.2       misho      38: srv_Close(int s)
                     39: {
                     40:        ioTRACE(2);
                     41: 
1.2.2.5 ! misho      42:        return mqtt_srv_Destroy(s);
1.2       misho      43: }

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