From 3e71473630cdf9f1751434468d2568ec7156ca83 Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 28 Jun 2012 20:09:36 +0000 Subject: [PATCH] Update scripting.xml to reflect Lua 5.2 Changed links to Lua reference manual to point to appropriate sections for 5.2. Books (Reference Manual and Programming in Lua, 2nd ed.) have not been updated to 5.2 yet, so those were left alone. Documented the change in API for linking C libs (luaL_newlib and luaL_Reg vs luaL_register and luaL_reg). --- docs/scripting.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/scripting.xml b/docs/scripting.xml index 956142bb7..6f0d876ad 100644 --- a/docs/scripting.xml +++ b/docs/scripting.xml @@ -104,7 +104,7 @@ Scripts are written in the embedded - Lua programming language.Lua programming languageNmap Scripting Engine + Lua programming language, version 5.2.Lua programming languageNmap Scripting Engine The language itself is well documented in the books Programming @@ -117,8 +117,8 @@ Lua 5.1 Reference Manual. -The reference manual is also - freely available +The reference manual, updated for Lua 5.2, is also + freely available online, as is the first edition of Programming in Lua. Given the availability of these excellent general @@ -893,7 +893,7 @@ http://nmap.org/nsedoc/scripts/afp-showmount.html and, or, and not operators to build Boolean expressions. The operators have the same - precedence + precedence as in Lua: not is the highest, followed by and and then or. You can alter precedence by using parentheses. Because expressions contain @@ -1458,7 +1458,7 @@ action refer to . script writing more powerful and convenient. These libraries (sometimes called modules) are compiled if necessary and installed along with Nmap. They have their own directory, nselib, which is installed in the configured Nmap data directory. Scripts need only - require the default libraries in order to use them. + require the default libraries in order to use them. @@ -1513,10 +1513,10 @@ action refer to . Programming in Lua, Second Edition, so this is a short summary. C modules consist of functions that follow the protocol of the - lua_CFunction + lua_CFunction type. The functions are registered with Lua and assembled into a library by calling the - luaL_registerluaL_register + luaL_newlibluaL_newlib function. A special initialization function provides the interface between the module and the rest of the NSE code. By convention the initialization function is named in the form @@ -1550,24 +1550,24 @@ static int l_md5(lua_State *L); does not have to be visible to other compiled code. Only an address is required to register it with Lua. Later in the file, l_md5 is entered into an array of type - luaL_reg and associated with the name + luaL_Reg and associated with the name md5: -static const struct luaL_reg openssllib[] = { +static const struct luaL_Reg openssllib[] = { { "md5", l_md5 }, { NULL, NULL } }; This function will now be known as md5 to NSE. Next the library is registered with a call to - luaL_register inside the initialization + luaL_newlib inside the initialization function luaopen_openssl, as shown next. Some lines relating to the registration of OpenSSL BIGNUM types have been omitted: LUALIB_API int luaopen_openssl(lua_State *L) { - luaL_register(L, OPENSSLLIBNAME, openssllib); + luaL_newlib(L, openssllib); return 1; } @@ -3027,7 +3027,7 @@ mutexfn = nmap.mutex(object) The mutexfn returned is a function which works as a mutex for the object passed in. This object can be any Lua data + url="http://www.lua.org/manual/5.2/manual.html#2.1">Lua data type except nil, Boolean, and number. The returned function allows you to lock, try to lock, and release the @@ -3153,7 +3153,7 @@ end condvarfn returned is a function which works as a condition variable for the object passed in. This object can be any Lua data + url="http://www.lua.org/manual/5.2/manual.html#2.1">Lua data type except nil, Boolean, and number. The returned function allows you to wait, signal, and broadcast on the @@ -3577,7 +3577,7 @@ end It then loads the standard Lua libraries and compiled NSE libraries. The standard Lua libraries are documented in the Lua Reference + url="http://www.lua.org/manual/5.2/manual.html">Lua Reference Manual. The standard Lua libraries available to NSE are debug, io,