File:  [ELWIX - Embedded LightWeight unIX -] / mqtt / src / utils.c
Revision 1.2.2.5: download - view: text, annotated - select for diffs - revision graph
Fri Jun 29 08:47:28 2012 UTC (12 years ago) by misho
Branches: mqtt1_1
change server to use new mqtt lib api calls

    1: #include "global.h"
    2: #include "mqttd.h"
    3: 
    4: 
    5: inline int
    6: srv_Socket(cfg_root_t * __restrict cfg)
    7: {
    8: 	int s = -1;
    9: 	ait_val_t v;
   10: 	u_short port;
   11: 	io_sockaddr_t sa = {{ 0 }};
   12: 
   13: 	ioTRACE(2);
   14: 
   15: 	assert(cfg);
   16: 
   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);
   21: 	if (!io_gethostbyname(AIT_GET_STR(&v), port, &sa)) {
   22: 		ioLIBERR(io);
   23: 		AIT_FREE_VAL(&v);
   24: 		return -1;
   25: 	} else
   26: 		AIT_FREE_VAL(&v);
   27: 
   28: 	s = mqtt_srv_Create(&sa.sa, sa.sa.sa_len);
   29: 	if (s == -1) {
   30: 		ioLIBERR(mqtt);
   31: 		return -1;
   32: 	}
   33: 
   34: 	return s;
   35: }
   36: 
   37: inline int
   38: srv_Close(int s)
   39: {
   40: 	ioTRACE(2);
   41: 
   42: 	return mqtt_srv_Destroy(s);
   43: }

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