summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/common.lua b/common.lua
index 89153d8..d7d3640 100644
--- a/common.lua
+++ b/common.lua
@@ -6,6 +6,30 @@ local stringformat = string.format
local verboselvl = 0
local colorize = false
+local table_mirrored = function (t, only)
+ local ret = { }
+
+ if t ~= nil then
+ for k, v in next, t do
+ ret [k] = v
+ if only == false then
+ ret [v] = k
+ end
+ end
+ end
+
+ return ret
+end
+
+local status do
+ local codes =
+ { ok = 0
+ , error = -1
+ }
+
+ status = { codes = table_mirrored (codes) }
+end
+
--- check if stderr is pipe; use color otherwise
local ok, unistd = pcall (require, "posix.unistd")
if ok then
@@ -102,5 +126,6 @@ return
, trim_whitespace = trim_whitespace
, unescape_string = unescape_string
, internalize_value = internalize_value
+ , status = status
}