first files
commit
2ab52c1b3d
@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This script downloads and compiles wget-lua.
|
||||
#
|
||||
|
||||
# first, try to detect gnutls or openssl
|
||||
CONFIGURE_SSL_OPT=""
|
||||
if builtin type -p pkg-config &>/dev/null
|
||||
then
|
||||
if pkg-config gnutls
|
||||
then
|
||||
echo "Compiling wget with GnuTLS."
|
||||
CONFIGURE_SSL_OPT="--with-ssl=gnutls"
|
||||
elif pkg-config openssl
|
||||
then
|
||||
echo "Compiling wget with OpenSSL."
|
||||
CONFIGURE_SSL_OPT="--with-ssl=openssl"
|
||||
fi
|
||||
fi
|
||||
|
||||
WGET_DOWNLOAD_URL="http://warriorhq.archiveteam.org/downloads/wget-lua/wget-1.14.lua.LATEST.tar.bz2"
|
||||
|
||||
rm -rf get-wget-lua.tmp/
|
||||
mkdir -p get-wget-lua.tmp
|
||||
|
||||
cd get-wget-lua.tmp
|
||||
|
||||
if builtin type -p curl &>/dev/null
|
||||
then
|
||||
curl -L $WGET_DOWNLOAD_URL | tar -xj --strip-components=1
|
||||
elif builtin type -p wget &>/dev/null
|
||||
then
|
||||
wget --output-document=- $WGET_DOWNLOAD_URL | tar -xj --strip-components=1
|
||||
else
|
||||
echo "You need Curl or Wget to download the source files."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ./configure $CONFIGURE_SSL_OPT --disable-nls && make && src/wget -V | grep -q lua
|
||||
then
|
||||
cp src/wget ../wget-lua
|
||||
cd ../
|
||||
echo
|
||||
echo
|
||||
echo "###################################################################"
|
||||
echo
|
||||
echo "wget-lua successfully built."
|
||||
echo
|
||||
./wget-lua --help | grep -iE "gnu|warc|lua"
|
||||
rm -rf get-wget-lua.tmp
|
||||
exit 0
|
||||
else
|
||||
echo
|
||||
echo "wget-lua not successfully built."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
@ -0,0 +1,105 @@
|
||||
--[[
|
||||
Author: Julio Manuel Fernandez-Diaz
|
||||
Date: January 12, 2007
|
||||
(For Lua 5.1)
|
||||
|
||||
Modified slightly by RiciLake to avoid the unnecessary table traversal in tablecount()
|
||||
|
||||
Formats tables with cycles recursively to any depth.
|
||||
The output is returned as a string.
|
||||
References to other tables are shown as values.
|
||||
Self references are indicated.
|
||||
|
||||
The string returned is "Lua code", which can be procesed
|
||||
(in the case in which indent is composed by spaces or "--").
|
||||
Userdata and function keys and values are shown as strings,
|
||||
which logically are exactly not equivalent to the original code.
|
||||
|
||||
This routine can serve for pretty formating tables with
|
||||
proper indentations, apart from printing them:
|
||||
|
||||
print(table.show(t, "t")) -- a typical use
|
||||
|
||||
Heavily based on "Saving tables with cycles", PIL2, p. 113.
|
||||
|
||||
Arguments:
|
||||
t is the table.
|
||||
name is the name of the table (optional)
|
||||
indent is a first indentation (optional).
|
||||
--]]
|
||||
function table.show(t, name, indent)
|
||||
local cart -- a container
|
||||
local autoref -- for self references
|
||||
|
||||
--[[ counts the number of elements in a table
|
||||
local function tablecount(t)
|
||||
local n = 0
|
||||
for _, _ in pairs(t) do n = n+1 end
|
||||
return n
|
||||
end
|
||||
]]
|
||||
-- (RiciLake) returns true if the table is empty
|
||||
local function isemptytable(t) return next(t) == nil end
|
||||
|
||||
local function basicSerialize (o)
|
||||
local so = tostring(o)
|
||||
if type(o) == "function" then
|
||||
local info = debug.getinfo(o, "S")
|
||||
-- info.name is nil because o is not a calling level
|
||||
if info.what == "C" then
|
||||
return string.format("%q", so .. ", C function")
|
||||
else
|
||||
-- the information is defined through lines
|
||||
return string.format("%q", so .. ", defined in (" ..
|
||||
info.linedefined .. "-" .. info.lastlinedefined ..
|
||||
")" .. info.source)
|
||||
end
|
||||
elseif type(o) == "number" or type(o) == "boolean" then
|
||||
return so
|
||||
else
|
||||
return string.format("%q", so)
|
||||
end
|
||||
end
|
||||
|
||||
local function addtocart (value, name, indent, saved, field)
|
||||
indent = indent or ""
|
||||
saved = saved or {}
|
||||
field = field or name
|
||||
|
||||
cart = cart .. indent .. field
|
||||
|
||||
if type(value) ~= "table" then
|
||||
cart = cart .. " = " .. basicSerialize(value) .. ";\n"
|
||||
else
|
||||
if saved[value] then
|
||||
cart = cart .. " = {}; -- " .. saved[value]
|
||||
.. " (self reference)\n"
|
||||
autoref = autoref .. name .. " = " .. saved[value] .. ";\n"
|
||||
else
|
||||
saved[value] = name
|
||||
--if tablecount(value) == 0 then
|
||||
if isemptytable(value) then
|
||||
cart = cart .. " = {};\n"
|
||||
else
|
||||
cart = cart .. " = {\n"
|
||||
for k, v in pairs(value) do
|
||||
k = basicSerialize(k)
|
||||
local fname = string.format("%s[%s]", name, k)
|
||||
field = string.format("[%s]", k)
|
||||
-- three spaces between levels
|
||||
addtocart(v, fname, indent .. " ", saved, field)
|
||||
end
|
||||
cart = cart .. indent .. "};\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
name = name or "__unnamed__"
|
||||
if type(t) ~= "table" then
|
||||
return name .. " = " .. basicSerialize(t)
|
||||
end
|
||||
cart, autoref = "", ""
|
||||
addtocart(t, name, indent)
|
||||
return cart .. autoref
|
||||
end
|
@ -0,0 +1,99 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- Utility functions for encoding/decoding of URLs.
|
||||
--
|
||||
-- @release $Id: urlcode.lua,v 1.10 2008/01/21 16:11:32 carregal Exp $
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
local ipairs, next, pairs, tonumber, type = ipairs, next, pairs, tonumber, type
|
||||
local string = string
|
||||
local table = table
|
||||
|
||||
module ("cgilua.urlcode")
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- Decode an URL-encoded string (see RFC 2396)
|
||||
----------------------------------------------------------------------------
|
||||
function unescape (str)
|
||||
str = string.gsub (str, "+", " ")
|
||||
str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
|
||||
str = string.gsub (str, "\r\n", "\n")
|
||||
return str
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- URL-encode a string (see RFC 2396)
|
||||
----------------------------------------------------------------------------
|
||||
function escape (str)
|
||||
str = string.gsub (str, "\n", "\r\n")
|
||||
str = string.gsub (str, "([^0-9a-zA-Z ])", -- locale independent
|
||||
function (c) return string.format ("%%%02X", string.byte(c)) end)
|
||||
str = string.gsub (str, " ", "+")
|
||||
return str
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- Insert a (name=value) pair into table [[args]]
|
||||
-- @param args Table to receive the result.
|
||||
-- @param name Key for the table.
|
||||
-- @param value Value for the key.
|
||||
-- Multi-valued names will be represented as tables with numerical indexes
|
||||
-- (in the order they came).
|
||||
----------------------------------------------------------------------------
|
||||
function insertfield (args, name, value)
|
||||
if not args[name] then
|
||||
args[name] = value
|
||||
else
|
||||
local t = type (args[name])
|
||||
if t == "string" then
|
||||
args[name] = {
|
||||
args[name],
|
||||
value,
|
||||
}
|
||||
elseif t == "table" then
|
||||
table.insert (args[name], value)
|
||||
else
|
||||
error ("CGILua fatal error (invalid args table)!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- Parse url-encoded request data
|
||||
-- (the query part of the script URL or url-encoded post data)
|
||||
--
|
||||
-- Each decoded (name=value) pair is inserted into table [[args]]
|
||||
-- @param query String to be parsed.
|
||||
-- @param args Table where to store the pairs.
|
||||
----------------------------------------------------------------------------
|
||||
function parsequery (query, args)
|
||||
if type(query) == "string" then
|
||||
local insertfield, unescape = insertfield, unescape
|
||||
string.gsub (query, "([^&=]+)=([^&=]*)&?",
|
||||
function (key, val)
|
||||
insertfield (args, unescape(key), unescape(val))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- URL-encode the elements of a table creating a string to be used in a
|
||||
-- URL for passing data/parameters to another script
|
||||
-- @param args Table where to extract the pairs (name=value).
|
||||
-- @return String with the resulting encoding.
|
||||
----------------------------------------------------------------------------
|
||||
function encodetable (args)
|
||||
if args == nil or next(args) == nil then -- no args or empty args?
|
||||
return ""
|
||||
end
|
||||
local strp = ""
|
||||
for key, vals in pairs(args) do
|
||||
if type(vals) ~= "table" then
|
||||
vals = {vals}
|
||||
end
|
||||
for i,val in ipairs(vals) do
|
||||
strp = strp.."&"..escape(key).."="..escape(val)
|
||||
end
|
||||
end
|
||||
-- remove first &
|
||||
return string.sub(strp,2)
|
||||
end
|
Binary file not shown.
Loading…
Reference in New Issue