diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-11-16 22:45:10 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-11-16 22:45:10 +0000 |
commit | cbed72fb47c8c0eda6322574c678389b795cd23c (patch) | |
tree | d6c2798764c258017c14e5ef375f62bba49a7e45 /libs | |
parent | 8b8d9030357e739eb1ae1a6b52a723c8fee8c4a6 (diff) |
* luci/themes: fix log pages
* luci/modules/admin-full: add dmesg page
* luci/i18n: add "dmesg" translations
* luci/libs/util: add cmatch(), register string functions in string class
* luci/libs/sys: add dmesg()
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/util.lua | 20 | ||||
-rw-r--r-- | libs/sys/luasrc/sys.lua | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 109ccab28..ea1fccbc1 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -261,6 +261,16 @@ function trim(str) return (str:gsub("^%s*(.-)%s*$", "%1")) end +--- Count the occurences of given substring in given string. +-- @param str String to search in +-- @param pattern String containing pattern to find +-- @return Number of found occurences +function cmatch(str, pat) + local count = 0 + for _ in str:gmatch(pat) do count = count + 1 end + return count +end + --- Parse certain units from the given string and return the canonical integer -- value or 0 if the unit is unknown. Upper- or lower case is irrelevant. -- Recognized units are: @@ -320,6 +330,16 @@ function parse_units(ustr) return val end +-- also register functions above in the central string class for convenience +string.escape = escape +string.pcdata = pcdata +string.striptags = striptags +string.split = split +string.trim = trim +string.cmatch = cmatch +string.parse_units = parse_units + + --- Appends numerically indexed tables or single objects to a given table. -- @param src Target table -- @param ... Objects to insert diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index 413aa4c11..52ed0c36d 100644 --- a/libs/sys/luasrc/sys.lua +++ b/libs/sys/luasrc/sys.lua @@ -204,6 +204,12 @@ function syslog() return luci.util.exec("logread") end +--- Retrieves the output of the "dmesg" command. +-- @return String containing the current log buffer +function dmesg() + return luci.util.exec("dmesg") +end + --- Generates a random id with specified length. -- @param bytes Number of bytes for the unique id -- @return String containing hex encoded id |