# HG changeset patch # User Myhailo Danylenko # Date 1236466099 -7200 # Node ID a8c6460d612ba7463a246c54a6118588c41ed238 # Parent aed141accdd903a192727c799c9d2000aaab133a Naming scheme change to more ld-friendly diff -r aed141accdd9 -r a8c6460d612b README --- a/README Mon Feb 23 19:19:13 2009 +0200 +++ b/README Sun Mar 08 00:48:19 2009 +0200 @@ -1,21 +1,27 @@ This is a lua 5.1 interface for loudmouth jabber client library. -To install it, you need lua, glib and loudmouth headers and libraries, -cmake and perl (optional, for documentation). Then do +To install it, you need: +- lua +- liblua headers and library +- glib headers and library +- loudmouth headers and library +- cmake +- pkg-config +- perl (optional) + +Then do +$ mkdir build $ cd build $ cmake .. +$ cmake edit_cache $ make # make install Debian users can instead of make install do -$ make package +$ fakeroot make package # dpkg -i liblua5.1-*.deb -Also you can be interested in running -$ make edit_cache -before doing make to configure some project settings. - This code underlies terms of GNU GPL v2 or later. I will be happy to get feedback, patches, suggestions, etc. diff -r aed141accdd9 -r a8c6460d612b lm_connection.c --- a/lm_connection.c Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_connection.c Sun Mar 08 00:48:19 2009 +0200 @@ -18,7 +18,7 @@ /// connection state /// Stirng, representing current connection state. /// G: -const string2enum_t llm_connection_state[] = { +const string2enum_t state_lm_connection[] = { { "closed", LM_CONNECTION_STATE_CLOSED }, { "opening", LM_CONNECTION_STATE_OPENING }, { "open", LM_CONNECTION_STATE_OPEN }, @@ -31,7 +31,7 @@ /// String, according to which handler will be placed into one /// of three handler groups. /// G: -const string2enum_t llm_handler_priority[] = { +const string2enum_t priority_lm_handler[] = { { "last", LM_HANDLER_PRIORITY_LAST }, { "normal", LM_HANDLER_PRIORITY_NORMAL }, { "first", LM_HANDLER_PRIORITY_FIRST }, @@ -59,7 +59,7 @@ /// Creates a new connection (closed). /// A: string (server name), lightuserdata (C glib main context object, optional) /// R: lm connection object -static int llm_connection_new (lua_State *L) +static int new_lm_connection (lua_State *L) { const char *server = luaL_checkstring (L, 1); LmConnection *connection; @@ -69,7 +69,7 @@ luaL_argcheck (L, lua_islightuserdata (L, 2), 2, "glib main context lightuserdata expected"); connection = lm_connection_new_with_context (server, (GMainContext *) lua_touserdata (L, 2)); } - llm_connection_bless (L, connection); + bless_lm_connection (L, connection); lm_connection_unref (connection); D ("Connection %X created", (int) connection); return 1; @@ -80,10 +80,10 @@ /// Note: it adds a reference to connection. /// A: lightuserdata (C lm connection object) /// R: lm connection object -static int llm_connection_bless_lua (lua_State *L) +static int bless_lua_lm_connection (lua_State *L) { luaL_argcheck (L, lua_islightuserdata (L, 1), 1, "loudmouth connection lightuserdata expected"); - llm_connection_bless (L, (LmConnection *) lua_touserdata (L, 1)); + bless_lm_connection (L, (LmConnection *) lua_touserdata (L, 1)); return 1; } @@ -91,10 +91,10 @@ /// User function, that will be called on connection establishment operation end, /// eg. successful/unsuccessful opening or authentication. /// A: lm connection object, boolean (success) -static void llm_connection_callback (LmConnection *connection, int success, llm_callback_t *cb) +static void callback_lm_connection (LmConnection *connection, int success, llm_callback_t *cb) { lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); - llm_connection_bless (cb->L, connection); + bless_lm_connection (cb->L, connection); // XXX lm_connection_unref (connection); lua_pushboolean (cb->L, success); if (lua_pcall (cb->L, 2, 0, 0)) { @@ -107,7 +107,7 @@ /// Opens connection to the server and then calls callback function. /// A: connection callback function /// R: lm connection object or nil, string (error message) -static int llm_connection_open (lua_State *L) +static int open_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); llm_callback_t *cb; @@ -118,7 +118,7 @@ cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); cb->L = L; - if (lm_connection_open (object->connection, (LmResultFunction) llm_connection_callback, + if (lm_connection_open (object->connection, (LmResultFunction) callback_lm_connection, cb, (GDestroyNotify) llm_callback_destroy, &err)) return 1; else { @@ -133,7 +133,7 @@ /// Tries to authenticate against opened connection, then calls callback function. /// A: string (username), string (password), string (resource), connection callback function /// R: lm connection object or nil, string (error message) -static int llm_connection_authenticate (lua_State *L) +static int authenticate_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); const char *username = luaL_checkstring (L, 2); @@ -149,7 +149,7 @@ cb->L = L; if (lm_connection_authenticate (object->connection, username, password, resource, - (LmResultFunction) llm_connection_callback, cb, + (LmResultFunction) callback_lm_connection, cb, (GDestroyNotify) llm_callback_destroy, &err)) { lua_pop (L, 3); return 1; @@ -165,7 +165,7 @@ /// Gets or sets server port to connect. /// A: integer (optional) /// R: integer (when called with no args) or lm connection object -static int llm_connection_port (lua_State *L) +static int port_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set @@ -181,7 +181,7 @@ /// Gets or sets server to connect to. /// A: string (optional, server name) /// R: string (when called with no args) or lm connection object -static int llm_connection_server (lua_State *L) +static int server_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set @@ -197,7 +197,7 @@ /// Gets or sets jid for connection. /// A: string (optional) /// R: string (when called with no args) or lm connection object -static int llm_connection_jid (lua_State *L) +static int jid_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set @@ -215,7 +215,7 @@ /// loudmouth versions, that should have it according to documentation. /// integer (optional, seconds) /// integer (when called with no args) or lm connection object or nil, string (error message, when get function is not available in loudmouth) -static int llm_connection_keep_alive_rate (lua_State *L) +static int keep_alive_rate_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set @@ -239,7 +239,7 @@ /// Gets or sets proxy server for connection. /// A: lm proxy object (optional) /// R: lm proxy object or nil (when called with no args) or lm connection object -static int llm_connection_proxy (lua_State *L) +static int proxy_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set @@ -250,7 +250,7 @@ LmProxy *proxy = lm_connection_get_proxy (object->connection); lua_pop (L, 1); if (proxy) { - llm_proxy_bless (L, proxy); + bless_lm_proxy (L, proxy); // XXX lm_proxy_unref (proxy); } else lua_pushnil (L); @@ -262,7 +262,7 @@ /// Gets or sets ssl object for connection. /// A: lm ssl object (optional) /// R: lm ssl object or nil (when called with no args) or lm connection object -static int llm_connection_ssl (lua_State *L) +static int ssl_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); if (lua_gettop (L) > 1) { // Set @@ -273,7 +273,7 @@ LmSSL *ssl = lm_connection_get_ssl (object->connection); lua_pop (L, 1); if (ssl) { - llm_ssl_bless (L, ssl); + bless_lm_ssl (L, ssl); // XXX lm_ssl_unref (ssl); } else lua_pushnil (L); @@ -284,7 +284,7 @@ /// connection:close /// Close connection. /// R: lm connection object or nil, string (error message) -static int llm_connection_close (lua_State *L) +static int close_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); GError *err = NULL; @@ -301,10 +301,10 @@ /// connection:status /// Returns string, describing connection state. /// R: connection state -static int llm_connection_status (lua_State *L) +static int status_lm_connection (lua_State *L) { llm_connection_t *connection = luaL_checklm_connection (L, 1); - luaL_pushenum (L, lm_connection_get_state (connection->connection), llm_connection_state); + luaL_pushenum (L, lm_connection_get_state (connection->connection), state_lm_connection); return 1; } @@ -320,7 +320,7 @@ /// If connection is nil, errmsg contains error message. /// A: lm message object/string, message handler callback function/lm message handler object (optional) /// R: lm connection object or nil, string (error message) -static int llm_connection_send (lua_State *L) +static int send_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); int status; @@ -340,16 +340,16 @@ cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); cb->L = L; handler = lm_message_handler_new ( - (LmHandleMessageFunction)llm_message_handler_callback, + (LmHandleMessageFunction)callback_lm_handler, cb, (GDestroyNotify)llm_callback_destroy); status = lm_connection_send_with_reply (object->connection, message->message, handler, &err); lm_message_handler_unref (handler); } else { // Send w/reply, handler llm_message_t *message = luaL_checklm_message (L, 2); - llm_message_handler_t *handler = luaL_checklm_message_handler (L, 3); + llm_handler_t *handler = luaL_checklm_handler (L, 3); status = lm_connection_send_with_reply (object->connection, message->message, - handler->message_handler, &err); + handler->handler, &err); lua_pop (L, 1); }; lua_pop (L, 1); @@ -370,13 +370,13 @@ /// Though, you can unregister only a message handler object. /// A: message handler callback function or lm message handler object, message type, handler priority (optional) /// R: lm connection object -static int llm_connection_handler (lua_State *L) +static int handler_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); - int type = luaL_checkenum (L, 3, llm_message_type); + int type = luaL_checkenum (L, 3, type_lm_message); if (lua_gettop (L) > 3) { // Register - int priority = luaL_checkenum (L, 4, llm_handler_priority); + int priority = luaL_checkenum (L, 4, priority_lm_handler); if (lua_isfunction (L, 2)) { // Function LmMessageHandler *handler; @@ -386,22 +386,22 @@ cb->L = L; handler = lm_message_handler_new ( - (LmHandleMessageFunction)llm_message_handler_callback, + (LmHandleMessageFunction)callback_lm_handler, cb, (GDestroyNotify)llm_callback_destroy); lm_connection_register_message_handler (object->connection, handler, type, priority); lm_message_handler_unref (handler); } else { // Object - llm_message_handler_t *handler = luaL_checklm_message_handler (L, 2); + llm_handler_t *handler = luaL_checklm_handler (L, 2); lm_connection_register_message_handler (object->connection, - handler->message_handler, + handler->handler, type, priority); } lua_pop (L, 1); } else { // Unregister - llm_message_handler_t *handler = luaL_checklm_message_handler (L, 2); + llm_handler_t *handler = luaL_checklm_handler (L, 2); lm_connection_unregister_message_handler (object->connection, - handler->message_handler, + handler->handler, type); } lua_pop (L, 2); @@ -414,7 +414,7 @@ void llm_disconnect_callback (LmConnection *connection, LmDisconnectReason reason, llm_callback_t *cb) { lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); - llm_connection_bless (cb->L, connection); + bless_lm_connection (cb->L, connection); // XXX lm_connection_unref (connection); luaL_pushenum (cb->L, reason, llm_disconnect_reason); if (lua_pcall (cb->L, 2, 0, 0)) { @@ -427,7 +427,7 @@ /// Sets callback, that will be called on connection disconnect. /// A: disconnect callback function /// R: lm connection object -static int llm_connection_ondisconnect (lua_State *L) +static int ondisconnect_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); llm_callback_t *cb; @@ -446,7 +446,7 @@ /// connection:open_wait /// Synchronous open call, that will block until connection will be opened. /// R: lm connection object or nil, string (error message) -static int llm_connection_open_wait (lua_State *L) +static int open_wait_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); GError *err = NULL; @@ -464,7 +464,7 @@ /// Synchronous authentication call, that will wait until the end of authentication. /// A: string (username), string (password), string (resource) /// R: lm connection object or nil, string (error message) -static int llm_connection_authenticate_wait (lua_State *L) +static int authenticate_wait_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); const char *username = luaL_checkstring (L, 2); @@ -486,7 +486,7 @@ /// Synchronous call, that will send message and wait for reply to it. /// A: lm message object /// R: lm message object or nil, string (error message) -static int llm_connection_send_wait (lua_State *L) +static int send_wait_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); llm_message_t *message = luaL_checklm_message (L, 2); @@ -499,7 +499,7 @@ lua_pushstring (L, err->message); return 2; } else { - llm_message_bless (L, new); + bless_lm_message (L, new); lm_message_unref (new); // XXX return 1; } @@ -508,7 +508,7 @@ /// connection:pointer /// Returns pointer to underlying C loudmouth structure. /// R: lightuserdata -static int llm_connection_pointer (lua_State *L) +static int pointer_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); lua_pushlightuserdata (L, object->connection); @@ -516,7 +516,7 @@ return 1; } -static int llm_connection_gc (lua_State *L) +static int gc_lm_connection (lua_State *L) { llm_connection_t *object = luaL_checklm_connection (L, 1); D ("Connection %X gc called", (int) object); @@ -524,31 +524,31 @@ return 0; } -static const luaL_Reg llm_connection_reg_f[] = { - { "new", llm_connection_new }, - { "bless", llm_connection_bless_lua }, +static const luaL_Reg reg_f_lm_connection[] = { + { "new", new_lm_connection }, + { "bless", bless_lua_lm_connection }, { NULL, NULL }, }; -static const luaL_Reg llm_connection_reg_m[] = { - { "open", llm_connection_open }, - { "close", llm_connection_close }, - { "authenticate", llm_connection_authenticate }, - { "port", llm_connection_port }, - { "server", llm_connection_server }, - { "jid", llm_connection_jid }, - { "keep_alive_rate", llm_connection_keep_alive_rate }, - { "state", llm_connection_status }, - { "proxy", llm_connection_proxy }, - { "ssl", llm_connection_ssl }, - { "send", llm_connection_send }, - { "handler", llm_connection_handler }, - { "ondisconnect", llm_connection_ondisconnect }, - { "open_wait", llm_connection_open_wait }, - { "authenticate_wait", llm_connection_authenticate_wait }, - { "send_wait", llm_connection_send_wait }, - { "pointer", llm_connection_pointer }, - { "__gc", llm_connection_gc }, +static const luaL_Reg reg_m_lm_connection[] = { + { "open", open_lm_connection }, + { "close", close_lm_connection }, + { "authenticate", authenticate_lm_connection }, + { "port", port_lm_connection }, + { "server", server_lm_connection }, + { "jid", jid_lm_connection }, + { "keep_alive_rate", keep_alive_rate_lm_connection }, + { "state", status_lm_connection }, + { "proxy", proxy_lm_connection }, + { "ssl", ssl_lm_connection }, + { "send", send_lm_connection }, + { "handler", handler_lm_connection }, + { "ondisconnect", ondisconnect_lm_connection }, + { "open_wait", open_wait_lm_connection }, + { "authenticate_wait", authenticate_wait_lm_connection }, + { "send_wait", send_wait_lm_connection }, + { "pointer", pointer_lm_connection }, + { "__gc", gc_lm_connection }, { NULL, NULL }, }; @@ -558,9 +558,9 @@ lua_pushstring (L, "__index"); lua_pushvalue (L, -2); lua_settable (L, -3); - luaL_register (L, NULL, llm_connection_reg_m); + luaL_register (L, NULL, reg_m_lm_connection); lua_pop (L, 1); - luaL_register (L, "lm.connection", llm_connection_reg_f); + luaL_register (L, "lm.connection", reg_f_lm_connection); return 1; } diff -r aed141accdd9 -r a8c6460d612b lm_connection.h --- a/lm_connection.h Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_connection.h Sun Mar 08 00:48:19 2009 +0200 @@ -6,8 +6,8 @@ #include "util.h" -extern const string2enum_t llm_connection_state[]; -extern const string2enum_t llm_handler_priority[]; +extern const string2enum_t state_lm_connection[]; +extern const string2enum_t priority_lm_handler[]; int luaopen_lm_connection (lua_State *L); diff -r aed141accdd9 -r a8c6460d612b lm_message.c --- a/lm_message.c Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_message.c Sun Mar 08 00:48:19 2009 +0200 @@ -20,7 +20,7 @@ /// message type /// Message type (root tag type). /// G: -const string2enum_t llm_message_type[] = { +const string2enum_t type_lm_message[] = { { "message", LM_MESSAGE_TYPE_MESSAGE }, { "presence", LM_MESSAGE_TYPE_PRESENCE }, { "iq", LM_MESSAGE_TYPE_IQ }, @@ -46,7 +46,7 @@ /// message sub type /// Message subtype, not all combinations of type and subtype are possible. /// G: -const string2enum_t llm_message_sub_type[] = { +const string2enum_t sub_type_lm_message[] = { { "not set", LM_MESSAGE_SUB_TYPE_NOT_SET }, { "available", LM_MESSAGE_SUB_TYPE_AVAILABLE }, { "normal", LM_MESSAGE_SUB_TYPE_NORMAL }, @@ -71,17 +71,17 @@ /// Creates new message object. /// A: string (to), message type, message sub type (optional) /// R: lm message object -static int llm_message_new (lua_State *L) +static int new_lm_message (lua_State *L) { const char *to = luaL_checkstring (L, 1); - int type = luaL_checkenum (L, 2, llm_message_type); + int type = luaL_checkenum (L, 2, type_lm_message); LmMessage *message; if (lua_gettop (L) > 2) message = lm_message_new_with_sub_type (to, type, - luaL_checkenum (L, 3, llm_message_sub_type)); + luaL_checkenum (L, 3, sub_type_lm_message)); else message = lm_message_new (to, type); - llm_message_bless (L, message); + bless_lm_message (L, message); lm_message_unref (message); D ("Message %X created", (int) message); return 1; @@ -91,21 +91,21 @@ /// Blesses given pointer to lm message object. /// A: lightuserdata (C lm message object) /// R: lm message object -static int llm_message_bless_lua (lua_State *L) +static int bless_lua_lm_message (lua_State *L) { luaL_argcheck (L, lua_islightuserdata (L, 1), 1, "lm message lightuserdata expected"); - llm_message_bless (L, lua_touserdata (L, 1)); + bless_lm_message (L, lua_touserdata (L, 1)); return 1; } /// message:node /// Returns root node object of message. /// R: lm message node object -static int llm_message_node (lua_State *L) +static int node_lm_message (lua_State *L) { llm_message_t *object = luaL_checklm_message (L, 1); LmMessageNode *node = lm_message_get_node (object->message); - llm_message_node_bless (L, node); + bless_lm_node (L, node); // XXX lm_message_node_unref (node); return 1; } @@ -113,25 +113,25 @@ /// message:type /// Returns two strings: message type and message sub type. /// R: message type, message sub type -static int llm_message_kind (lua_State *L) +static int kind_lm_message (lua_State *L) { llm_message_t *object = luaL_checklm_message (L, 1); - luaL_pushenum (L, lm_message_get_type (object->message), llm_message_type); - luaL_pushenum (L, lm_message_get_sub_type (object->message), llm_message_sub_type); + luaL_pushenum (L, lm_message_get_type (object->message), type_lm_message); + luaL_pushenum (L, lm_message_get_sub_type (object->message), sub_type_lm_message); return 2; } /// message:pointer /// Returns pointer to underlying C loudmouth structure. /// R: lightuserdata -static int llm_message_pointer (lua_State *L) +static int pointer_lm_message (lua_State *L) { llm_message_t *object = luaL_checklm_message (L, 1); lua_pushlightuserdata (L, object->message); return 1; } -static int llm_message_gc (lua_State *L) +static int gc_lm_message (lua_State *L) { llm_message_t *message = luaL_checklm_message (L, 1); D ("Message %X gc called", (int) message); @@ -139,30 +139,30 @@ return 0; } -static const luaL_Reg llm_message_reg_f[] = { - { "new", llm_message_new }, - { "bless", llm_message_bless_lua }, +static const luaL_Reg reg_f_lm_message[] = { + { "new", new_lm_message }, + { "bless", bless_lua_lm_message }, { NULL, NULL }, }; -static const luaL_Reg llm_message_reg_m[] = { - { "node", llm_message_node }, - { "type", llm_message_kind }, +static const luaL_Reg reg_m_lm_message[] = { + { "node", node_lm_message }, + { "type", kind_lm_message }, // These methods are common for message and message node - { "next", llm_message_node_next }, - { "prev", llm_message_node_prev }, - { "children", llm_message_node_children }, - { "parent", llm_message_node_parent }, - { "value", llm_message_node_value }, - { "child", llm_message_node_child }, - { "find_child", llm_message_node_find_child }, - { "attribute", llm_message_node_attribute }, - { "raw", llm_message_node_raw }, - { "xml", llm_message_node_xml }, - { "path", llm_message_node_path }, + { "next", next_lm_node }, + { "prev", prev_lm_node }, + { "children", children_lm_node }, + { "parent", parent_lm_node }, + { "value", value_lm_node }, + { "child", child_lm_node }, + { "find_child", find_child_lm_node }, + { "attribute", attribute_lm_node }, + { "raw", raw_lm_node }, + { "xml", xml_lm_node }, + { "path", path_lm_node }, // End common methods - { "pointer", llm_message_pointer }, - { "__gc", llm_message_gc }, + { "pointer", pointer_lm_message }, + { "__gc", gc_lm_message }, { NULL, NULL }, }; @@ -172,9 +172,9 @@ lua_pushstring (L, "__index"); lua_pushvalue (L, -2); lua_settable (L, -3); - luaL_register (L, NULL, llm_message_reg_m); + luaL_register (L, NULL, reg_m_lm_message); lua_pop (L, 1); - luaL_register (L, "lm.message", llm_message_reg_f); + luaL_register (L, "lm.message", reg_f_lm_message); return 1; } diff -r aed141accdd9 -r a8c6460d612b lm_message.h --- a/lm_message.h Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_message.h Sun Mar 08 00:48:19 2009 +0200 @@ -6,8 +6,8 @@ #include "util.h" -extern const string2enum_t llm_message_type[]; -extern const string2enum_t llm_message_sub_type[]; +extern const string2enum_t type_lm_message[]; +extern const string2enum_t sub_type_lm_message[]; int luaopen_lm_message (lua_State *L); diff -r aed141accdd9 -r a8c6460d612b lm_message_handler.c --- a/lm_message_handler.c Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_message_handler.c Sun Mar 08 00:48:19 2009 +0200 @@ -17,13 +17,13 @@ /// handlers should be called. /// A: lm connection object, lm message object /// R: boolean -LmHandlerResult llm_message_handler_callback (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, llm_callback_t *cb) +LmHandlerResult callback_lm_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, llm_callback_t *cb) { int ret; lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); - llm_connection_bless (cb->L, connection); + bless_lm_connection (cb->L, connection); // XXX lm_connection_unref (connection); - llm_message_bless (cb->L, message); + bless_lm_message (cb->L, message); // XXX lm_message_unref (message); if (lua_pcall (cb->L, 2, 1, 0)) { W ("Message handler callback error: %s", lua_tostring (cb->L, -1)); @@ -42,7 +42,7 @@ /// Creates new message handler object. /// A: message handler callback function /// R: lm message handler object -static int llm_message_handler_new (lua_State *L) +static int new_lm_handler (lua_State *L) { llm_callback_t *cb; LmMessageHandler *handler; @@ -52,9 +52,9 @@ cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); cb->L = L; - handler = lm_message_handler_new ((LmHandleMessageFunction)llm_message_handler_callback, + handler = lm_message_handler_new ((LmHandleMessageFunction)callback_lm_handler, cb, (GDestroyNotify)llm_callback_destroy); - llm_message_handler_bless (L, handler); + bless_lm_handler (L, handler); lm_message_handler_unref (handler); // XXX D ("Message handler %X created", (int) handler); return 1; @@ -64,10 +64,10 @@ /// Blesses given pointer to lm message handler object. /// A: lightuserdata (C lm message handler object) /// R: lm message handler object -static int llm_message_handler_bless_lua (lua_State *L) +static int bless_lua_lm_handler (lua_State *L) { luaL_argcheck (L, lua_islightuserdata (L, 1), 1, "loudmouth message handler pointer expected"); - llm_message_handler_bless (L, lua_touserdata (L, 1)); + bless_lm_handler (L, lua_touserdata (L, 1)); return 1; } @@ -75,52 +75,52 @@ /// message_handler:invalidate /// Invalidates handler. /// R: lm message handler object -static int llm_message_handler_invalidate (lua_State *L) +static int invalidate_lm_handler (lua_State *L) { - llm_message_handler_t *object = luaL_checklm_message_handler (L, 1); - lm_message_handler_invalidate (object->message_handler); + llm_handler_t *object = luaL_checklm_handler (L, 1); + lm_message_handler_invalidate (object->handler); return 1; } /// message_handler:valid /// Returns true if message handler is still valid. /// R: boolean -static int llm_message_handler_valid (lua_State *L) +static int valid_lm_handler (lua_State *L) { - llm_message_handler_t *object = luaL_checklm_message_handler (L, 1); - lua_pushboolean (L, lm_message_handler_is_valid (object->message_handler)); + llm_handler_t *object = luaL_checklm_handler (L, 1); + lua_pushboolean (L, lm_message_handler_is_valid (object->handler)); return 1; } /// message_handler:pointer /// Returns pointer to underlying C loudmouth structure. /// R: lightuserdata -static int llm_message_handler_pointer (lua_State *L) +static int pointer_lm_handler (lua_State *L) { - llm_message_handler_t *object = luaL_checklm_message_handler (L, 1); - lua_pushlightuserdata (L, object->message_handler); + llm_handler_t *object = luaL_checklm_handler (L, 1); + lua_pushlightuserdata (L, object->handler); return 1; } -static int llm_message_handler_gc (lua_State *L) +static int gc_lm_handler (lua_State *L) { - llm_message_handler_t *object = luaL_checklm_message_handler (L, 1); + llm_handler_t *object = luaL_checklm_handler (L, 1); D ("Message handler %X gc called", (int) object); - lm_message_handler_unref (object->message_handler); + lm_message_handler_unref (object->handler); return 0; } -static const luaL_Reg llm_message_handler_reg_f[] = { - { "new", llm_message_handler_new }, - { "bless", llm_message_handler_bless_lua }, +static const luaL_Reg reg_f_lm_handler[] = { + { "new", new_lm_handler }, + { "bless", bless_lua_lm_handler }, { NULL, NULL }, }; -static const luaL_Reg llm_message_handler_reg_m[] = { - { "invalidate", llm_message_handler_invalidate }, - { "valid", llm_message_handler_valid }, - { "pointer", llm_message_handler_pointer }, - { "__gc", llm_message_handler_gc }, +static const luaL_Reg reg_m_lm_handler[] = { + { "invalidate", invalidate_lm_handler }, + { "valid", valid_lm_handler }, + { "pointer", pointer_lm_handler }, + { "__gc", gc_lm_handler }, { NULL, NULL }, }; @@ -130,9 +130,9 @@ lua_pushstring (L, "__index"); lua_pushvalue (L, -2); lua_settable (L, -3); - luaL_register (L, NULL, llm_message_handler_reg_m); + luaL_register (L, NULL, reg_m_lm_handler); lua_pop (L, 1); - luaL_register (L, "lm.message_handler", llm_message_handler_reg_f); + luaL_register (L, "lm.message_handler", reg_f_lm_handler); return 1; } diff -r aed141accdd9 -r a8c6460d612b lm_message_handler.h --- a/lm_message_handler.h Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_message_handler.h Sun Mar 08 00:48:19 2009 +0200 @@ -7,7 +7,7 @@ #include "lm_types.h" -LmHandlerResult llm_message_handler_callback (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, llm_callback_t *cb); +LmHandlerResult callback_lm_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, llm_callback_t *cb); int luaopen_lm_message_handler (lua_State *L); #endif diff -r aed141accdd9 -r a8c6460d612b lm_message_node.c --- a/lm_message_node.c Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_message_node.c Sun Mar 08 00:48:19 2009 +0200 @@ -14,17 +14,17 @@ /// Blesses given pointer to lm message node object. /// A: lightuserdata (C lm message node object) /// R: lm message node object -static int llm_message_node_bless_lua (lua_State *L) +static int bless_lua_lm_node (lua_State *L) { luaL_argcheck (L, lua_islightuserdata (L, 1), 1, "loudmouth message node lightuserdata expected"); - llm_message_node_bless (L, lua_touserdata (L, 1)); + bless_lm_node (L, lua_touserdata (L, 1)); return 1; } /// message_node:name /// Gets a name of message node. /// R: string -int llm_message_node_name (lua_State *L) +int name_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); lua_pushstring (L, node->name); @@ -34,12 +34,12 @@ /// message_node:next /// Gets next message node. /// R: lm message node object or nil -int llm_message_node_next (lua_State *L) +int next_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); LmMessageNode *next = node->next; if (next) - llm_message_node_bless (L, next); + bless_lm_node (L, next); else lua_pushnil (L); return 1; @@ -48,12 +48,12 @@ /// message_node:prev /// Gets previous message node. /// R: lm message node object or nil -int llm_message_node_prev (lua_State *L) +int prev_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); LmMessageNode *prev = node->prev; if (prev) - llm_message_node_bless (L, prev); + bless_lm_node (L, prev); else lua_pushnil (L); return 1; @@ -62,12 +62,12 @@ /// message_node:children /// Gets first child node (raw access used). /// R: lm message node object or nil -int llm_message_node_children (lua_State *L) +int children_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); LmMessageNode *child = node->children; if (child) - llm_message_node_bless (L, child); + bless_lm_node (L, child); else lua_pushnil (L); return 1; @@ -76,12 +76,12 @@ /// message_node:parent /// Gets parent message node. /// R: lm message node object or nil -int llm_message_node_parent (lua_State *L) +int parent_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); LmMessageNode *parent = node->parent; if (parent) - llm_message_node_bless (L, parent); + bless_lm_node (L, parent); else lua_pushnil (L); return 1; @@ -91,7 +91,7 @@ /// Gets or sets a value of message node. /// A: string (optional value) /// R: string (if called without arguments) or lm message node object -int llm_message_node_value (lua_State *L) +int value_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); if (lua_gettop (L) > 1) { // Set @@ -107,7 +107,7 @@ /// Gets or creates child node object with given name. /// A: string (name), string (optional value) /// R: lm message node object or nil -int llm_message_node_child (lua_State *L) +int child_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); const char *name = luaL_checkstring (L, 2); @@ -123,7 +123,7 @@ return 1; } } - llm_message_node_bless (L, child); + bless_lm_node (L, child); // XXX lm_message_node_unref (child); return 1; } @@ -132,7 +132,7 @@ /// Searches for node with a given name over all node subtree. /// A: string (name) /// R: lm message node object or nil -int llm_message_node_find_child (lua_State *L) +int find_child_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); const char *name = luaL_checkstring (L, 2); @@ -142,7 +142,7 @@ if (!child) lua_pushnil (L); else { - llm_message_node_bless (L, child); + bless_lm_node (L, child); // XXX lm_message_node_unref (child); } return 1; @@ -153,7 +153,7 @@ /// When set, value of node will not be escaped. /// A: boolean (optional) /// V: boolean (if called with no apguments) or lm message node object -int llm_message_node_raw (lua_State *L) +int raw_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); if (lua_gettop (L) > 1) { // Set @@ -169,7 +169,7 @@ /// Gets or sets value of node attribute with a given name. /// A: string (name), string (optional value) /// R: string (when called with one aprgument) or lm message node object -int llm_message_node_attribute (lua_State *L) +int attribute_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); const char *name = luaL_checkstring (L, 2); @@ -184,7 +184,7 @@ /// message_node:xml /// Returns node representation in xml. /// R: string -int llm_message_node_xml (lua_State *L) +int xml_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); lua_pushstring (L, lm_message_node_to_string (node)); @@ -196,7 +196,7 @@ /// If any element in a path cannot be found, it returns nil. /// A: string (node name), ... /// R: lm message node object or nil -int llm_message_node_path (lua_State *L) +int path_lm_node (lua_State *L) { LmMessageNode *node = luaL_checkLmMessageNode (L, 1); int i = 1; @@ -207,7 +207,7 @@ return 1; } } - llm_message_node_bless (L, node); + bless_lm_node (L, node); // XXX lm_message_node_unref (child); return 1; } @@ -215,41 +215,41 @@ /// message_node:pointer /// Returns pointer to underlying C structure. /// R: lightuserdata -static int llm_message_node_pointer (lua_State *L) +static int pointer_lm_node (lua_State *L) { - llm_message_node_t *object = luaL_checklm_message_node (L, 1); - lua_pushlightuserdata (L, object->message_node); + llm_node_t *object = luaL_checklm_node (L, 1); + lua_pushlightuserdata (L, object->node); return 1; } -static int llm_message_node_gc (lua_State *L) +static int gc_lm_node (lua_State *L) { - llm_message_node_t *object = luaL_checklm_message_node (L, 1); + llm_node_t *object = luaL_checklm_node (L, 1); D ("Message node %X gc called", (int) object); - lm_message_node_unref (object->message_node); + lm_message_node_unref (object->node); return 0; } -static const luaL_Reg llm_message_node_reg_f[] = { - { "bless", llm_message_node_bless_lua }, +static const luaL_Reg reg_f_lm_node[] = { + { "bless", bless_lua_lm_node }, { NULL, NULL }, }; -static const luaL_Reg llm_message_node_reg_m[] = { - { "name", llm_message_node_name }, - { "next", llm_message_node_next }, - { "prev", llm_message_node_prev }, - { "children", llm_message_node_children }, - { "parent", llm_message_node_parent }, - { "value", llm_message_node_value }, - { "child", llm_message_node_child }, - { "find_child", llm_message_node_find_child }, - { "attribute", llm_message_node_attribute }, - { "raw", llm_message_node_raw }, - { "xml", llm_message_node_xml }, - { "path", llm_message_node_path }, - { "pointer", llm_message_node_pointer }, - { "__gc", llm_message_node_gc }, +static const luaL_Reg reg_m_lm_node[] = { + { "name", name_lm_node }, + { "next", next_lm_node }, + { "prev", prev_lm_node }, + { "children", children_lm_node }, + { "parent", parent_lm_node }, + { "value", value_lm_node }, + { "child", child_lm_node }, + { "find_child", find_child_lm_node }, + { "attribute", attribute_lm_node }, + { "raw", raw_lm_node }, + { "xml", xml_lm_node }, + { "path", path_lm_node }, + { "pointer", pointer_lm_node }, + { "__gc", gc_lm_node }, { NULL, NULL }, }; @@ -259,9 +259,9 @@ lua_pushstring (L, "__index"); lua_pushvalue (L, -2); lua_settable (L, -3); - luaL_register (L, NULL, llm_message_node_reg_m); + luaL_register (L, NULL, reg_m_lm_node); lua_pop (L, 1); - luaL_register (L, "lm.message_node", llm_message_node_reg_f); + luaL_register (L, "lm.message_node", reg_f_lm_node); return 1; } diff -r aed141accdd9 -r a8c6460d612b lm_message_node.h --- a/lm_message_node.h Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_message_node.h Sun Mar 08 00:48:19 2009 +0200 @@ -4,18 +4,18 @@ #include -int llm_message_node_name (lua_State *L); -int llm_message_node_next (lua_State *L); -int llm_message_node_prev (lua_State *L); -int llm_message_node_children (lua_State *L); -int llm_message_node_parent (lua_State *L); -int llm_message_node_value (lua_State *L); -int llm_message_node_child (lua_State *L); -int llm_message_node_find_child (lua_State *L); -int llm_message_node_raw (lua_State *L); -int llm_message_node_attribute (lua_State *L); -int llm_message_node_xml (lua_State *L); -int llm_message_node_path (lua_State *L); +int name_lm_node (lua_State *L); +int next_lm_node (lua_State *L); +int prev_lm_node (lua_State *L); +int children_lm_node (lua_State *L); +int parent_lm_node (lua_State *L); +int value_lm_node (lua_State *L); +int child_lm_node (lua_State *L); +int find_child_lm_node (lua_State *L); +int raw_lm_node (lua_State *L); +int attribute_lm_node (lua_State *L); +int xml_lm_node (lua_State *L); +int path_lm_node (lua_State *L); int luaopen_lm_message_node (lua_State *L); diff -r aed141accdd9 -r a8c6460d612b lm_proxy.c --- a/lm_proxy.c Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_proxy.c Sun Mar 08 00:48:19 2009 +0200 @@ -16,7 +16,7 @@ /// proxy type /// Stirng, specifying proxy-server type. The only type supported for now is http. /// G: -const string2enum_t llm_proxy_type[] = { +const string2enum_t type_lm_proxy[] = { { "http", LM_PROXY_TYPE_HTTP }, { "none", LM_PROXY_TYPE_NONE }, { NULL, LM_PROXY_TYPE_HTTP }, @@ -27,15 +27,15 @@ /// Note, you should specify either none of args or both. /// A: proxy type, string (optional proxy server name), integer (optional server port) /// R: lm proxy object -static int llm_proxy_new (lua_State *L) +static int new_lm_proxy (lua_State *L) { - int type = luaL_checkenum (L, 1, llm_proxy_type); + int type = luaL_checkenum (L, 1, type_lm_proxy); LmProxy *proxy; if (lua_gettop (L) > 0) proxy = lm_proxy_new_with_server (type, luaL_checkstring (L, 2), luaL_checkint (L, 3)); else proxy = lm_proxy_new (type); - llm_proxy_bless (L, proxy); + bless_lm_proxy (L, proxy); lm_proxy_unref (proxy); // XXX D ("Proxy %X created", (int) proxy); return 1; @@ -45,10 +45,10 @@ /// Blesses given pointer to lm proxy object. /// A: lightuserdata (C lm proxy object) /// R: lm proxy object -static int llm_proxy_bless_lua (lua_State *L) +static int bless_lua_lm_proxy (lua_State *L) { luaL_argcheck (L, lua_islightuserdata (L, 1), 1, "lm proxy lightuserdata expected"); - llm_proxy_bless (L, lua_touserdata (L, 1)); + bless_lm_proxy (L, lua_touserdata (L, 1)); return 1; } @@ -56,14 +56,14 @@ /// Gets or sets proxy server type. /// A: proxy type (optional) /// R: proxy type (when called with no args) or lm proxy object -static int llm_proxy_kind (lua_State *L) +static int kind_lm_proxy (lua_State *L) { llm_proxy_t *proxy = luaL_checklm_proxy (L, 1); if (lua_gettop (L) > 1) { // Set - lm_proxy_set_type (proxy->proxy, luaL_checkenum (L, 2, llm_proxy_type)); + lm_proxy_set_type (proxy->proxy, luaL_checkenum (L, 2, type_lm_proxy)); lua_pop (L, 1); } else // Get - luaL_pushenum (L, lm_proxy_get_type (proxy->proxy), llm_proxy_type); + luaL_pushenum (L, lm_proxy_get_type (proxy->proxy), type_lm_proxy); return 1; } @@ -71,7 +71,7 @@ /// Gets or sets proxy server name. /// A: string (optional) /// R: string (when called with no args) or lm proxy object -static int llm_proxy_server (lua_State *L) +static int server_lm_proxy (lua_State *L) { llm_proxy_t *object = luaL_checklm_proxy (L, 1); if (lua_gettop (L) > 1) { // Set @@ -86,7 +86,7 @@ /// Gets or sets proxy server port. /// A: integer (optional) /// R: integer (when called with no args) or lm proxy object -static int llm_proxy_port (lua_State *L) +static int port_lm_proxy (lua_State *L) { llm_proxy_t *object = luaL_checklm_proxy (L, 1); if (lua_gettop (L) > 1) { // Set @@ -101,7 +101,7 @@ /// Gets or sets username to authenticate to proxy server with. /// A: string (optional) /// R: string (when called with no args) or lm proxy object -static int llm_proxy_username (lua_State *L) +static int username_lm_proxy (lua_State *L) { llm_proxy_t *object = luaL_checklm_proxy (L, 1); if (lua_gettop (L) > 1) { // Set @@ -116,7 +116,7 @@ /// Gets or sets password to authenticate to proxy server with. /// A: string (optional) /// R: string (when called with no args) or lm proxy object -static int llm_proxy_password (lua_State *L) +static int password_lm_proxy (lua_State *L) { llm_proxy_t *object = luaL_checklm_proxy (L, 1); if (lua_gettop (L) > 1) { // Set @@ -130,14 +130,14 @@ /// proxy:pointer /// Returns pointer to underlying C structure. /// R: lightuserdata -static int llm_proxy_pointer (lua_State *L) +static int pointer_lm_proxy (lua_State *L) { llm_proxy_t *object = luaL_checklm_proxy (L, 1); lua_pushlightuserdata (L, object->proxy); return 1; } -static int llm_proxy_gc (lua_State *L) +static int gc_lm_proxy (lua_State *L) { llm_proxy_t *object = luaL_checklm_proxy (L, 1); D ("Proxy %X gc called", (int) object); @@ -145,20 +145,20 @@ return 0; } -static const luaL_Reg llm_proxy_reg_f[] = { - { "new", llm_proxy_new }, - { "bless", llm_proxy_bless_lua }, +static const luaL_Reg reg_f_lm_proxy[] = { + { "new", new_lm_proxy }, + { "bless", bless_lua_lm_proxy }, { NULL, NULL }, }; -static const luaL_Reg llm_proxy_reg_m[] = { - { "port", llm_proxy_port }, - { "server", llm_proxy_server }, - { "type", llm_proxy_kind }, - { "username", llm_proxy_username }, - { "password", llm_proxy_password }, - { "pointer", llm_proxy_pointer }, - { "__gc", llm_proxy_gc }, +static const luaL_Reg reg_m_lm_proxy[] = { + { "port", port_lm_proxy }, + { "server", server_lm_proxy }, + { "type", kind_lm_proxy }, + { "username", username_lm_proxy }, + { "password", password_lm_proxy }, + { "pointer", pointer_lm_proxy }, + { "__gc", gc_lm_proxy }, { NULL, NULL }, }; @@ -168,9 +168,9 @@ lua_pushstring (L, "__index"); lua_pushvalue (L, -2); lua_settable (L, -3); - luaL_register (L, NULL, llm_proxy_reg_m); + luaL_register (L, NULL, reg_m_lm_proxy); lua_pop (L, 1); - luaL_register (L, "lm.proxy", llm_proxy_reg_f); + luaL_register (L, "lm.proxy", reg_f_lm_proxy); return 1; } diff -r aed141accdd9 -r a8c6460d612b lm_proxy.h --- a/lm_proxy.h Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_proxy.h Sun Mar 08 00:48:19 2009 +0200 @@ -6,7 +6,7 @@ #include "util.h" -string2enum_t *llm_proxy_type; +string2enum_t *type_lm_proxy; int luaopen_lm_proxy (lua_State *L); diff -r aed141accdd9 -r a8c6460d612b lm_ssl.c --- a/lm_ssl.c Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_ssl.c Sun Mar 08 00:48:19 2009 +0200 @@ -16,7 +16,7 @@ /// ssl status /// String, representing what problem have current ssl session. /// G: -const string2enum_t llm_ssl_status[] = { +const string2enum_t status_lm_ssl[] = { { "no cert found", LM_SSL_STATUS_NO_CERT_FOUND }, { "untrusted cert", LM_SSL_STATUS_UNTRUSTED_CERT }, { "cert expired", LM_SSL_STATUS_CERT_EXPIRED }, @@ -33,13 +33,13 @@ /// though, with upvalues it is not required. /// A: lm ssl object, ssl status /// R: boolean (false if connection process should be terminated) -LmSSLResponse llm_ssl_callback (LmSSL *ssl, LmSSLStatus status, llm_callback_t *cb) +LmSSLResponse callback_lm_ssl (LmSSL *ssl, LmSSLStatus status, llm_callback_t *cb) { int ret; lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); - llm_ssl_bless (cb->L, ssl); + bless_lm_ssl (cb->L, ssl); // XXX lm_ssl_unref (ssl); - luaL_pushenum (cb->L, status, llm_ssl_status); + luaL_pushenum (cb->L, status, status_lm_ssl); if (lua_pcall (cb->L, 2, 0, 0)) { W ("SSL callback error: %s", lua_tostring (cb->L, -1)); lua_pop (cb->L, 1); @@ -70,7 +70,7 @@ /// SSL fingerprint is a string like '01:23:45:67:89:AB:CD:EF:FE:DC:BA:98:76:54:32:10'. /// A: string (optional ssl fingerprint), ssl callback function (optional) /// R: lm ssl object -static int llm_ssl_new (lua_State *L) +static int new_lm_ssl (lua_State *L) { int args = lua_gettop (L); LmSSL *ssl; @@ -99,10 +99,10 @@ cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); cb->L = L; - ssl = lm_ssl_new ((args > 1) ? buffer : NULL, (LmSSLFunction)llm_ssl_callback, + ssl = lm_ssl_new ((args > 1) ? buffer : NULL, (LmSSLFunction)callback_lm_ssl, cb, (GDestroyNotify)llm_callback_destroy); } - llm_ssl_bless (L, ssl); + bless_lm_ssl (L, ssl); lm_ssl_unref (ssl); // XXX D ("SSL %X created", (int) ssl); return 1; @@ -112,17 +112,17 @@ /// Blesses given pointer to lm ssl object. /// A: lightuserdata (C lm ssl object) /// R: lm ssl object -static int llm_ssl_bless_lua (lua_State *L) +static int bless_lua_lm_ssl (lua_State *L) { luaL_argcheck (L, lua_islightuserdata (L, 1), 1, "lm ssl lightuserdata expected"); - llm_ssl_bless (L, lua_touserdata (L, 1)); + bless_lm_ssl (L, lua_touserdata (L, 1)); return 1; } /// lm.ssl.supported /// Indicates if SSL is supported by loudmouth library. /// R: boolean -static int llm_ssl_supported (lua_State *L) +static int supported_lm_ssl (lua_State *L) { lua_pushboolean (L, lm_ssl_is_supported ()); return 1; @@ -131,7 +131,7 @@ /// ssl:fingerprint /// Returns fingerprint of remote server. /// R: string or nil -static int llm_ssl_fingerprint (lua_State *L) +static int fingerprint_lm_ssl (lua_State *L) { char buffer[48]; llm_ssl_t *object = luaL_checklm_ssl (L, 1); @@ -154,14 +154,14 @@ /// ssl:pointer /// Returns pointer to underlying C structure. /// R: lightuserdata -static int llm_ssl_pointer (lua_State *L) +static int pointer_lm_ssl (lua_State *L) { llm_ssl_t *object = luaL_checklm_ssl (L, 1); lua_pushlightuserdata (L, object->ssl); return 1; } -static int llm_ssl_gc (lua_State *L) +static int gc_lm_ssl (lua_State *L) { llm_ssl_t *object = luaL_checklm_ssl (L, 1); D ("SSL %X gc called", (int) object); @@ -169,17 +169,17 @@ return 0; } -const static luaL_Reg llm_ssl_reg_f[] = { - { "new", llm_ssl_new }, - { "bless", llm_ssl_bless_lua }, - { "supported", llm_ssl_supported }, +const static luaL_Reg reg_f_lm_ssl[] = { + { "new", new_lm_ssl }, + { "bless", bless_lua_lm_ssl }, + { "supported", supported_lm_ssl }, { NULL, NULL }, }; -const static luaL_Reg llm_ssl_reg_m[] = { - { "fingerprint", llm_ssl_fingerprint }, - { "pointer", llm_ssl_pointer }, - { "__gc", llm_ssl_gc }, +const static luaL_Reg reg_m_lm_ssl[] = { + { "fingerprint", fingerprint_lm_ssl }, + { "pointer", pointer_lm_ssl }, + { "__gc", gc_lm_ssl }, { NULL, NULL }, }; @@ -189,9 +189,9 @@ lua_pushstring (L, "__index"); lua_pushvalue (L, -2); lua_settable (L, -3); - luaL_register (L, NULL, llm_ssl_reg_m); + luaL_register (L, NULL, reg_m_lm_ssl); lua_pop (L, 1); - luaL_register (L, "lm.ssl", llm_ssl_reg_f); + luaL_register (L, "lm.ssl", reg_f_lm_ssl); return 1; } diff -r aed141accdd9 -r a8c6460d612b lm_ssl.h --- a/lm_ssl.h Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_ssl.h Sun Mar 08 00:48:19 2009 +0200 @@ -6,7 +6,7 @@ #include "util.h" -string2enum_t *llm_ssl_status; +string2enum_t *status_lm_ssl; int luaopen_lm_ssl (lua_State *L); diff -r aed141accdd9 -r a8c6460d612b lm_types.c --- a/lm_types.c Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_types.c Sun Mar 08 00:48:19 2009 +0200 @@ -22,8 +22,8 @@ return object; \ } -#define LLM_BLESS(WHAT, TYPE) \ -llm_##WHAT##_t *llm_##WHAT##_bless (lua_State *L, TYPE *WHAT) \ +#define LLM_BLESS(WHAT, LWHAT, TYPE) \ +llm_##WHAT##_t *bless_lm_##WHAT (lua_State *L, TYPE *WHAT) \ { \ llm_##WHAT##_t *object; /* top of stack */ \ lua_pushstring (L, LLM_OBJREGISTRY); /* 1 registry table name */ \ @@ -33,34 +33,34 @@ if (!lua_isnil (L, -1)) { /* 2 object */ \ lua_remove (L, -2); /* 1 object */ \ object = lua_touserdata (L, -1); \ - D ("Existing " #WHAT " object %X requested", (int) object); \ + D ("Existing " #LWHAT " object %X requested", (int) object); \ return object; \ } \ /* 2 nil */ \ lua_remove (L, -1); /* 1 registry table */ \ object = lua_newuserdata (L, sizeof (llm_##WHAT##_t)); /* 2 userdata */ \ - luaL_getmetatable (L, "loudmouth." #WHAT); /* 3 metatable */ \ + luaL_getmetatable (L, "loudmouth." #LWHAT); /* 3 metatable */ \ lua_setmetatable (L, -2); /* 2 object */ \ lua_pushlightuserdata (L, WHAT); /* 3 light userdata */ \ lua_pushvalue (L, -2); /* 4 object */ \ lua_rawset (L, -4); /* 2 object */ \ lua_remove (L, -2); /* 1 object */ \ object->WHAT = WHAT; \ - lm_##WHAT##_ref (WHAT); \ - D ("New " #WHAT " object %X blessed", (int) object); \ + lm_##LWHAT##_ref (WHAT); \ + D ("New " #LWHAT " object %X blessed", (int) object); \ return object; \ } -#define LLM_DEFINE(WHAT, TYPE) \ +#define LLM_DEFINE(WHAT, LWHAT, TYPE) \ LLM_CHECK (WHAT, TYPE) \ -LLM_BLESS (WHAT, TYPE) +LLM_BLESS (WHAT, LWHAT, TYPE) -LLM_DEFINE (connection, LmConnection) -LLM_DEFINE (message, LmMessage) -LLM_DEFINE (message_handler, LmMessageHandler) -LLM_DEFINE (message_node, LmMessageNode) -LLM_DEFINE (proxy, LmProxy) -LLM_DEFINE (ssl, LmSSL) +LLM_DEFINE (connection, connection, LmConnection) +LLM_DEFINE (message, message, LmMessage) +LLM_DEFINE (handler, message_handler, LmMessageHandler) +LLM_DEFINE (node, message_node, LmMessageNode) +LLM_DEFINE (proxy, proxy, LmProxy) +LLM_DEFINE (ssl, ssl, LmSSL) LmMessageNode *luaL_checkLmMessageNode (lua_State *L, int index) { @@ -73,7 +73,7 @@ if (lua_rawequal (L, -2, -3)) // Message object = (void *) lm_message_get_node (((llm_message_t *) object)->message); else if (lua_rawequal (L, -1, -3)) // Node - object = (void *) (((llm_message_node_t *) object)->message_node); + object = (void *) (((llm_node_t *) object)->node); else luaL_argerror (L, index, "loudmouth message or message node expected"); lua_pop (L, 3); diff -r aed141accdd9 -r a8c6460d612b lm_types.h --- a/lm_types.h Mon Feb 23 19:19:13 2009 +0200 +++ b/lm_types.h Sun Mar 08 00:48:19 2009 +0200 @@ -26,8 +26,8 @@ LLM_DECLARE (connection, LmConnection) LLM_DECLARE (message, LmMessage) -LLM_DECLARE (message_handler, LmMessageHandler) -LLM_DECLARE (message_node, LmMessageNode) +LLM_DECLARE (handler, LmMessageHandler) +LLM_DECLARE (node, LmMessageNode) LLM_DECLARE (proxy, LmProxy) LLM_DECLARE (ssl, LmSSL)