Annotation of mqtt/src/pubmqtt.c, revision 1.1.2.2
1.1.2.1 misho 1: #include "global.h"
2:
3:
1.1.2.2 ! misho 4: /*
! 5: * mqtt_db_log() Log database connection message
! 6: *
! 7: * @fmt = format string
! 8: * @... = argument list
! 9: * return: none
! 10: */
! 11: static void
! 12: mqtt_rtlm_log(const char *fmt, ...)
! 13: {
! 14: va_list lst;
! 15:
! 16: va_start(lst, fmt);
! 17: vsyslog(LOG_ERR, fmt, lst);
! 18: va_end(lst);
! 19: }
! 20: #define MQTT_DB_LOG(_sql) (assert((_sql)), mqtt_rtlm_log("Error:: SQL #%d - %s", \
! 21: sqlite3_errcode((_sql)), sqlite3_errmsg((_sql))))
! 22:
! 23:
! 24: /*
! 25: * mqtt_rtlm_open() Open database connection
! 26: *
! 27: * @csCfgName = config filename
! 28: * return: NULL error or SQL handle
! 29: */
! 30: sqlite3 *
! 31: mqtt_rtlm_open(sl_config *cfg)
! 32: {
! 33: sqlite3 *sql = NULL;
! 34: const char *str = NULL;
! 35:
! 36: if (!cfg)
! 37: return NULL;
! 38:
! 39: str = (const char*) cfg_GetAttribute(cfg, CFG("mqtt_pub"), CFG("name"));
! 40: if (!str) {
! 41: mqtt_rtlm_log("Error:: Unknown database name ...\n");
! 42: return NULL;
! 43: }
! 44:
! 45: if (sqlite3_open_v2(str, &sql, SQLITE_OPEN_READWRITE, NULL)) {
! 46: MQTT_DB_LOG(sql);
! 47: sqlite3_close(sql);
! 48: return NULL;
! 49: }
! 50:
! 51: return sql;
! 52: }
! 53:
! 54: /*
! 55: * mqtt_rtlm_close() Close database connection
! 56: *
! 57: * @sql = SQL handle
! 58: * return: none
! 59: */
! 60: void
! 61: mqtt_rtlm_close(sqlite3 *sql)
! 62: {
! 63: sqlite3_close(sql);
! 64: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>