Utility Functions
Dir
A directory object that iterates over its files and subdirectories (non-recursive)
function
description
Creates a directory object; opens a directory, returning an iterator over the files/subdirectories within the directory
Gets the next file within the directory
Closes the directory
Dir.open(pathname [,extension])
Description
- Creates a directory object; opens a directory, returning an iterator over the directory's files and subdirectories (non-recursive)
Parameters
pathname : string
- The pathname of the directory
extension (optional) : string
- If given, only file with this extension will be returned
Returns
userdata : the directory object
Example
dir:__call()
Description
- Gets the next file/subdirectory within the directory
Returns
string : a filename of the next file/subdirectory within the directory; returns nil if all files iterated
Example
dir:close()
Description
Closes the directory. Called automatically on garbage collection of dir.
Non Method Functions
function
description
Gets the version of Wireshark
Formats an absolute timestamp into a human-readable date
Formats a relative timestamp into a human-readable form
Reports a failure to the user, shown in a message box with an error icon
Writes a log message with critical severity to the Lua console and stdout
Writes a log message with warning severity to the Lua console and stdout
Writes a log message with normal severity to the Lua console and stdout
Writes a log message with informational severity to the Lua console and stdout
Writes a log message with debug severity to the Lua console and stdout
Loads a Lua file and compiles it into a Lua chunk
Opens the named file and executes its contents as a Lua chunk
Gets the personal configuration directory
Gets the global configuration directory
Registers a tshark statistics function, called with the -z option
get_version()
Description
- Gets the version of Wireshark
Returns
string : the version number (e.g., "1.6.0")
format_date(timestamp)
Description
- Formats an absolute timestamp into a human-readable date
Parameters
timestamp : string
- A timestamp value to convert.
Returns
string : The formatted date
format_time(timestamp)
Description
- Formats a relative timestamp into a human-readable form
Parameters
timestamp : string
- A timestamp value to convert
Returns
string : The formatted time
report_failure(text)
Description
- Reports a failure to the user, shown in a message box with an error icon
Parameters
text : string
- the text to display in the message box
critical(text)
Description
- Writes a log message with critical severity to the Lua console and stdout
Parameters
text : string
- the text message to be logged
warn(text)
Description
- Writes a log message with warning severity to the Lua console and stdout
Parameters
text : string
- the text message to be logged
message(text)
Description
- Writes a log message with normal severity to the Lua console and stdout
Parameters
text : string
- the text message to be logged
info(text)
Description
- Writes a log message with informational severity to the Lua console and stdout
Parameters
text : string
- the text message to be logged
debug(text)
Description
- Writes a log message with debug severity to the Lua console and stdout
See Bug 5976. This function hides Lua's debug table.
Parameters
text : string
- the text message to be logged
- Writes a log message with debug severity to the Lua console and stdout
loadfile(filename)
Description
Loads a Lua file and compiles it into a Lua chunk (similar to the standard loadfile but searches additional directories)
Parameters
filename : string
- Name of the file to be loaded. If the file does not exist in the current directory, the user and system directories are searched.
Returns
function : The compiled chunk as a function; otherwise returns nil plus the error message.
Errors
- File not found or file contains invalid Lua
Example
dofile(filename)
Description
Opens the named file and executes its contents as a Lua chunk (similar to the standard dofile but searches additional directories)
Parameter
filename : string
- Name of the file to be run. If the file does not exist in the current directory, the user and system directories are searched.
Returns
- all values returned by the Lua chunk
Errors
- File not found or file contains invalid Lua
persconffile_path([filename])
Description
- Gets the personal configuration directory
Parameters
filename (optional) : string
- A filename (or directory name) that is appended to the path with the appropriate path separator
Returns
string : The full pathname for a file in the personal configuration directory
Example
datafile_path([filename])
Description
- Gets the global configuration directory
Parameters
filename (optional)
- A filename (or directory name) that is appended to the path with the appropriate path separator
Returns
string : The full pathname for a file in Wireshark's global configuration directory
Example
register_stat_cmd_arg(argument, action)
Description
Registers a tshark statistics function, called with the -z option
Parameters
argument : string
- name of option argument
action : function
- function to be called when the command is invoked
