lm_message_node.c
changeset 66 a40beb82130c
parent 54 6bef2082e5f9
--- a/lm_message_node.c	Sat Mar 05 18:04:48 2016 +0200
+++ b/lm_message_node.c	Wed Mar 16 01:53:56 2016 +0200
@@ -1,5 +1,5 @@
 
-/* Copyright 2009 Myhailo Danylenko
+/* Copyright 2009-2016 Myhailo Danylenko
 
 This file is part of lua-lm.
 
@@ -229,6 +229,23 @@
 	return 1;
 }
 
+/// message_node:attributes
+/// Returns a table with message node attributes.
+/// R: table
+int attributes_lm_node (lua_State *L)
+{
+	lua_newtable (L);
+#ifdef HAVE_LM_MESSAGE_NODE_ATTRIBUTE
+	LmMessageNode          *node = luaL_checkLmMessageNode (L, 1);
+	LmMessageNodeAttribute *attribute;
+	for (attribute = node -> attributes; attribute; attribute = attribute -> next) {
+		lua_pushstring (L, attribute -> value);
+		lua_setfield (L, -2, attribute -> name);
+	}
+#endif
+	return 1;
+}
+
 /// message_node:xml
 /// Returns node representation in xml.
 /// R: string