summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-06-15 07:54:27 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-06-15 07:54:27 +0000
commit2b16df81fe835d441e4dde275c3894a1fcdc66d3 (patch)
treebdb08f1704c2911d2def83af23c353d916877444
parentf98b33efcd99185c4a81eda7eb90098b490bac79 (diff)
MirLua: AddEvent support string as blob
git-svn-id: http://svn.miranda-ng.org/main/trunk@16974 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/MirLua/src/m_database.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp
index a4ac7f1de6..588e27af82 100644
--- a/plugins/MirLua/src/m_database.cpp
+++ b/plugins/MirLua/src/m_database.cpp
@@ -254,8 +254,10 @@ void MakeDbEvent(lua_State *L, DBEVENTINFO &dbei)
lua_pop(L, 1);
lua_getfield(L, -1, "Blob");
- if (lua_istable(L, -1))
+
+ switch (lua_type(L, -1))
{
+ case LUA_TTABLE:
dbei.cbBlob = lua_rawlen(L, 4);
dbei.pBlob = (BYTE*)mir_calloc(dbei.cbBlob);
for (DWORD i = 0; i < dbei.cbBlob; i++)
@@ -264,6 +266,14 @@ void MakeDbEvent(lua_State *L, DBEVENTINFO &dbei)
dbei.pBlob[i] = lua_tointeger(L, -1);
lua_pop(L, 1);
}
+ break;
+ case LUA_TSTRING:
+ size_t nLen;
+ const char *str = lua_tolstring(L, -1, &nLen);
+ dbei.cbBlob = nLen;
+ dbei.pBlob = (BYTE*)mir_alloc(nLen);
+ memcpy(dbei.pBlob, str, nLen);
+ break;
}
lua_pop(L, 1);
}
@@ -272,7 +282,7 @@ static int db_AddEvent(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, 1);
- DBEVENTINFO dbei;
+ DBEVENTINFO dbei = {};
MakeDbEvent(L, dbei);
MEVENT hDbEvent = db_event_add(hContact, &dbei);