summaryrefslogtreecommitdiff
path: root/plugins/MirLua/Modules/m_variables/src/main.cpp
blob: 8eac60540790f5a75ce4a68729d3c37cbd37b321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "stdafx.h"

static int lua_Parse(lua_State *L)
{
	if (!ServiceExists(MS_VARS_FORMATSTRING))
	{
		lua_pushvalue(L, 1);
		return 1;
	}

	ptrT format(mir_utf8decodeT(luaL_checkstring(L, 1)));
	MCONTACT hContact = lua_tointeger(L, 2);

	TCHAR *res = variables_parse_ex(format, NULL, hContact, NULL, 0);
	lua_pushstring(L, T2Utf(res));

	return 1;
}

static luaL_Reg variablesApi[] =
{
	{ "Parse", lua_Parse },

	{ NULL, NULL }
};

extern "C" LUAMOD_API int luaopen_m_variables(lua_State *L)
{
	luaL_newlib(L, variablesApi);

	return 1;
}