<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.2.3">
</HEAD>
<BODY>
I've added the new functions to the page.<BR>
<BR>
Thanks,<BR>
<BR>
Peter<BR>
<BR>
On Fri, 2012-03-02 at 11:48 +0100, Daniel-Constantin Mierla wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hello Peter,

please add also to the wiki page of Lua api any new function you 
exported to Lua:

   * <A HREF="http://www.kamailio.org/wiki/embeddedapi/devel/lua">http://www.kamailio.org/wiki/embeddedapi/devel/lua</A>

Thanks,
Daniel

On 3/1/12 7:00 PM, Peter Dunkley wrote:
&gt; Module: sip-router
&gt; Branch: master
&gt; Commit: 681c06103eff1b03d2b2648d64f302cfc4587490
&gt; URL:    <A HREF="http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=681c06103eff1b03d2b2648d64f302cfc4587490">http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=681c06103eff1b03d2b2648d64f302cfc4587490</A>
&gt;
&gt; Author: Peter Dunkley&lt;<A HREF="mailto:peter.dunkley@crocodile-rcs.com">peter.dunkley@crocodile-rcs.com</A>&gt;
&gt; Committer: Peter Dunkley&lt;<A HREF="mailto:peter.dunkley@crocodile-rcs.com">peter.dunkley@crocodile-rcs.com</A>&gt;
&gt; Date:   Thu Mar  1 17:59:51 2012 +0000
&gt;
&gt; modules/app_lua: Added tmx.t_suspend() and mq.add() to app_lua
&gt;
&gt; ---
&gt;
&gt;   modules/app_lua/app_lua_exp.c |  113 +++++++++++++++++++++++++++++++++++++++++
&gt;   1 files changed, 113 insertions(+), 0 deletions(-)
&gt;
&gt; diff --git a/modules/app_lua/app_lua_exp.c b/modules/app_lua/app_lua_exp.c
&gt; index 74d4f66..587d8c0 100644
&gt; --- a/modules/app_lua/app_lua_exp.c
&gt; +++ b/modules/app_lua/app_lua_exp.c
&gt; @@ -53,6 +53,8 @@
&gt;   #include &quot;../../modules_k/uac/api.h&quot;
&gt;   #include &quot;../../modules/sanity/api.h&quot;
&gt;   #include &quot;../../modules_k/cfgutils/api.h&quot;
&gt; +#include &quot;../../modules_k/tmx/api.h&quot;
&gt; +#include &quot;../../modules/mqueue/api.h&quot;
&gt;
&gt;   #include &quot;app_lua_api.h&quot;
&gt;
&gt; @@ -78,6 +80,8 @@
&gt;   #define SR_LUA_EXP_MOD_UAC        (1&lt;&lt;19)
&gt;   #define SR_LUA_EXP_MOD_SANITY     (1&lt;&lt;20)
&gt;   #define SR_LUA_EXP_MOD_CFGUTILS   (1&lt;&lt;21)
&gt; +#define SR_LUA_EXP_MOD_TMX        (1&lt;&lt;22)
&gt; +#define SR_LUA_EXP_MOD_MQUEUE     (1&lt;&lt;23)
&gt;
&gt;   /**
&gt;    *
&gt; @@ -195,6 +199,15 @@ static sanity_api_t _lua_sanityb;
&gt;    */
&gt;   static cfgutils_api_t _lua_cfgutilsb;
&gt;
&gt; +/**
&gt; + * tmx
&gt; + */
&gt; +static tmx_api_t _lua_tmxb;
&gt; +
&gt; +/**
&gt; + * mqueue
&gt; + */
&gt; +static mq_api_t _lua_mqb;
&gt;
&gt;   /**
&gt;    *
&gt; @@ -2321,6 +2334,76 @@ static const luaL_reg _sr_cfgutils_Map [] = {
&gt;           {NULL, NULL}
&gt;   };
&gt;
&gt; +/**
&gt; + *
&gt; + */
&gt; +static int lua_sr_tmx_t_suspend(lua_State *L)
&gt; +{
&gt; +        int ret;
&gt; +        sr_lua_env_t *env_L;
&gt; +
&gt; +        env_L = sr_lua_env_get();
&gt; +
&gt; +        if(!(_sr_lua_exp_reg_mods&amp;SR_LUA_EXP_MOD_TMX))
&gt; +        {
&gt; +                LM_WARN(&quot;weird: tmx function executed but module not registered\n&quot;);
&gt; +                return app_lua_return_error(L);
&gt; +        }
&gt; +        if(env_L-&gt;msg==NULL)
&gt; +        {
&gt; +                LM_WARN(&quot;invalid parameters from Lua env\n&quot;);
&gt; +                return app_lua_return_error(L);
&gt; +        }
&gt; +
&gt; +        ret = _lua_tmxb.t_suspend(env_L-&gt;msg, NULL, NULL);
&gt; +        return app_lua_return_int(L, ret);
&gt; +}
&gt; +
&gt; +/**
&gt; + *
&gt; + */
&gt; +static const luaL_reg _sr_tmx_Map [] = {
&gt; +        {&quot;t_suspend&quot;, lua_sr_tmx_t_suspend},
&gt; +        {NULL, NULL}
&gt; +};
&gt; +
&gt; +/**
&gt; + *
&gt; + */
&gt; +static int lua_sr_mq_add(lua_State *L)
&gt; +{
&gt; +        int ret;
&gt; +        str param[3];
&gt; +
&gt; +        if(!(_sr_lua_exp_reg_mods&amp;SR_LUA_EXP_MOD_MQUEUE))
&gt; +        {
&gt; +                LM_WARN(&quot;weird: mqueue function executed but module not registered\n&quot;);
&gt; +                return app_lua_return_error(L);
&gt; +        }
&gt; +        if(lua_gettop(L)!=3)
&gt; +        {
&gt; +                LM_WARN(&quot;invalid number of parameters from Lua\n&quot;);
&gt; +                return app_lua_return_error(L);
&gt; +        }
&gt; +        
&gt; +        param[0].s = (char *) lua_tostring(L, -3);
&gt; +        param[0].len = strlen(param[0].s);
&gt; +        param[1].s = (char *) lua_tostring(L, -2);
&gt; +        param[1].len = strlen(param[1].s);
&gt; +        param[2].s = (char *) lua_tostring(L, -1);
&gt; +        param[2].len = strlen(param[2].s);
&gt; +        
&gt; +        ret = _lua_mqb.add(&amp;param[0],&amp;param[1],&amp;param[2]);
&gt; +        return app_lua_return_int(L, ret);
&gt; +}
&gt; +
&gt; +/**
&gt; + *
&gt; + */
&gt; +static const luaL_reg _sr_mqueue_Map [] = {
&gt; +        {&quot;add&quot;, lua_sr_mq_add},
&gt; +        {NULL, NULL}
&gt; +};
&gt;
&gt;   /**
&gt;    *
&gt; @@ -2553,6 +2636,26 @@ int lua_sr_exp_init_mod(void)
&gt;                   }
&gt;                   LM_DBG(&quot;loaded cfgutils api\n&quot;);
&gt;           }
&gt; +        if(_sr_lua_exp_reg_mods&amp;SR_LUA_EXP_MOD_TMX)
&gt; +        {
&gt; +                /* bind the TMX API */
&gt; +                if (load_tmx_api(&amp;_lua_tmxb)&lt;  0)
&gt; +                {
&gt; +                        LM_ERR(&quot;cannot bind to TMX API\n&quot;);
&gt; +                        return -1;
&gt; +                }
&gt; +                LM_DBG(&quot;loaded tmx api\n&quot;);
&gt; +        }
&gt; +        if(_sr_lua_exp_reg_mods&amp;SR_LUA_EXP_MOD_MQUEUE)
&gt; +        {
&gt; +                /* bind the MQUEUE API */
&gt; +                if (load_mq_api(&amp;_lua_mqb)&lt;  0)
&gt; +                {
&gt; +                        LM_ERR(&quot;cannot bind to MQUEUE API\n&quot;);
&gt; +                        return -1;
&gt; +                }
&gt; +                LM_DBG(&quot;loaded mqueue api\n&quot;);
&gt; +        }
&gt;           return 0;
&gt;   }
&gt;
&gt; @@ -2632,6 +2735,12 @@ int lua_sr_exp_register_mod(char *mname)
&gt;           } else         if(len==8&amp;&amp;  strcmp(mname, &quot;cfgutils&quot;)==0) {
&gt;                   _sr_lua_exp_reg_mods |= SR_LUA_EXP_MOD_CFGUTILS;
&gt;                   return 0;
&gt; +        } else         if(len==3&amp;&amp;  strcmp(mname, &quot;tmx&quot;)==0) {
&gt; +                _sr_lua_exp_reg_mods |= SR_LUA_EXP_MOD_TMX;
&gt; +                return 0;
&gt; +        } else         if(len==6&amp;&amp;  strcmp(mname, &quot;mqueue&quot;)==0) {
&gt; +                _sr_lua_exp_reg_mods |= SR_LUA_EXP_MOD_MQUEUE;
&gt; +                return 0;
&gt;           }
&gt;
&gt;           return -1;
&gt; @@ -2686,5 +2795,9 @@ void lua_sr_exp_openlibs(lua_State *L)
&gt;                   luaL_openlib(L, &quot;sr.sanity&quot;, _sr_sanity_Map,          0);
&gt;           if(_sr_lua_exp_reg_mods&amp;SR_LUA_EXP_MOD_CFGUTILS)
&gt;                   luaL_openlib(L, &quot;sr.cfgutils&quot;, _sr_cfgutils_Map,      0);
&gt; +        if(_sr_lua_exp_reg_mods&amp;SR_LUA_EXP_MOD_TMX)
&gt; +                luaL_openlib(L, &quot;sr.tmx&quot;, _sr_tmx_Map,                0);
&gt; +        if(_sr_lua_exp_reg_mods&amp;SR_LUA_EXP_MOD_MQUEUE)
&gt; +                luaL_openlib(L, &quot;sr.mq&quot;, _sr_mqueue_Map,              0);
&gt;   }
&gt;
&gt;
&gt;
&gt; _______________________________________________
&gt; sr-dev mailing list
&gt; <A HREF="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</A>
&gt; <A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</A>

</PRE>
</BLOCKQUOTE>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>