--- mqtt/src/dl.c 2011/11/23 08:50:03 1.1.2.4 +++ mqtt/src/dl.c 2012/01/27 15:05:38 1.2 @@ -4,7 +4,9 @@ static void *acc_rtlm, *pub_rtlm, *log_rtlm; +struct tagCallbacks call; + /* * mqttLog() Log message to syslog * @@ -53,7 +55,7 @@ mqttLoadRTLM(sl_config *cfg, int modtype) rtlm = dlopen(str, RTLD_LAZY); if (!rtlm) { - mqttLog("Error:: RTL module not found %s\n", dlerror()); + mqttLog("Error:: RTL module %s not found %s\n", str, dlerror()); return NULL; } @@ -73,18 +75,42 @@ mqttLoadRTLM(sl_config *cfg, int modtype) switch (modtype) { case 0: acc_rtlm = rtlm; - mqttOpenACC = mqttOpenRTLM; - mqttCloseACC = mqttCloseRTLM; + call.OpenACC = mqttOpenRTLM; + call.CloseACC = mqttCloseRTLM; + call.LoginACC = dlsym(rtlm, "mqtt_rtlm_login"); + if (!call.LoginACC) { + mqttLog("Error:: incorrect module ...\n"); + dlclose(rtlm); + return NULL; + } break; case 1: pub_rtlm = rtlm; - mqttOpenPUB = mqttOpenRTLM; - mqttClosePUB = mqttCloseRTLM; + call.OpenPUB = mqttOpenRTLM; + call.ClosePUB = mqttCloseRTLM; + call.InitSessPUB = dlsym(rtlm, "mqtt_rtlm_init_session"); + call.FiniSessPUB = dlsym(rtlm, "mqtt_rtlm_fini_session"); + call.ChkSessPUB = dlsym(rtlm, "mqtt_rtlm_chk_session"); + call.WritePUB = dlsym(rtlm, "mqtt_rtlm_write_topic"); + call.ReadPUB = dlsym(rtlm, "mqtt_rtlm_read_topic"); + call.DeletePUB = dlsym(rtlm, "mqtt_rtlm_delete_topic"); + if (!call.InitSessPUB || !call.FiniSessPUB || !call.ChkSessPUB || + !call.WritePUB || !call.ReadPUB || !call.DeletePUB) { + mqttLog("Error:: incorrect module ...\n"); + dlclose(rtlm); + return NULL; + } break; default: log_rtlm = rtlm; - mqttOpenLOG = mqttOpenRTLM; - mqttCloseLOG = mqttCloseRTLM; + call.OpenLOG = mqttOpenRTLM; + call.CloseLOG = mqttCloseRTLM; + call.LOG = dlsym(rtlm, "mqtt_rtlm_logger"); + if (!call.LOG) { + mqttLog("Error:: incorrect module ...\n"); + dlclose(rtlm); + return NULL; + } break; }