summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio/axTLS/www/lua/download.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-12-03 15:17:05 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-01-08 16:26:20 +0100
commit1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch)
tree35e16f100466e4e00657199b38bb3d87d52bf73f /libs/nixio/axTLS/www/lua/download.lua
parent9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff)
Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names * Make each LuCI module its own standalone package * Deploy a shared luci.mk which is used by each module Makefile Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'libs/nixio/axTLS/www/lua/download.lua')
-rw-r--r--libs/nixio/axTLS/www/lua/download.lua75
1 files changed, 0 insertions, 75 deletions
diff --git a/libs/nixio/axTLS/www/lua/download.lua b/libs/nixio/axTLS/www/lua/download.lua
deleted file mode 100644
index 2ee1a71e93..0000000000
--- a/libs/nixio/axTLS/www/lua/download.lua
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/local/bin/lua
-
-require"luasocket"
-
-function receive (connection)
- connection:settimeout(0)
- local s, status = connection:receive (2^10)
- if status == "timeout" then
- coroutine.yield (connection)
- end
- return s, status
-end
-
-function download (host, file, outfile)
- --local f = assert (io.open (outfile, "w"))
- local c = assert (socket.connect (host, 80))
- c:send ("GET "..file.." HTTP/1.0\r\n\r\n")
- while true do
- local s, status = receive (c)
- --f:write (s)
- if status == "closed" then
- break
- end
- end
- c:close()
- --f:close()
-end
-
-local threads = {}
-function get (host, file, outfile)
- print (string.format ("Downloading %s from %s to %s", file, host, outfile))
- local co = coroutine.create (function ()
- return download (host, file, outfile)
- end)
- table.insert (threads, co)
-end
-
-function dispatcher ()
- while true do
- local n = table.getn (threads)
- if n == 0 then
- break
- end
- local connections = {}
- for i = 1, n do
- local status, res = coroutine.resume (threads[i])
- if not res then
- table.remove (threads, i)
- break
- else
- table.insert (connections, res)
- end
- end
- if table.getn (connections) == n then
- socket.select (connections)
- end
- end
-end
-
-local url = arg[1]
-if not url then
- print (string.format ("usage: %s url [times]", arg[0]))
- os.exit()
-end
-local times = arg[2] or 5
-
-url = string.gsub (url, "^http.?://", "")
-local _, _, host, file = string.find (url, "^([^/]+)(/.*)")
-local _, _, fn = string.find (file, "([^/]+)$")
-
-for i = 1, times do
- get (host, file, fn..i)
-end
-
-dispatcher ()