ACF Libraries
ACF Libraries
Because of using lua, a very small language, the need arises to build everything from scratch. This can lead to some confusion, apprehension, or just feeling overwhelmed. Here is documentation on what we have now in the form of libraries and common functions. We hope to build some more and use this information to get the juices flowing in regard to ACF.
Some of these are lua libs or ones written for ACF.
ed.lua
fs.lua
Used for various filespecific functions
is_dir (function)
INPUT:
This library function required the following inputs/parameters.
- Path to directory
- Example: /var/log/snort
OUTPUT:
This library function deliverers the following output/parameters.
- nil or "directory"
- If inputstring is a existing directory, the output is "directory" (not nil)
CODING EXAMPLE:
-- Include/Call for this library require("fs") -- Check if url is a folder liboutput = fs.is_dir("/var/log/snort")
If directory exist 'liboutput' would contain string:
directory
In directory is missing 'liboutput' would contain nil (nothing).
is_file (function)
INPUT:
This library function required the following inputs/parameters.
- Path to file
- Example: /var/log/messages
OUTPUT:
This library function deliverers the following output/parameters.
- nil or "file"
- If inputstring is a existing file, the output is "file" (not nil)
CODING EXAMPLE:
-- Include/Call for this library require("fs") -- Check if url is a file liboutput = fs.is_file("/var/log/messages")
If file exist 'liboutput' would contain string:
file
In file is missing 'liboutput' would contain nil (nothing).
read_file / read_file_as_array (function)
INPUT:
This library function required the following inputs/parameters.
- Path to file
- Example: /var/log/messages
OUTPUT:
This library function deliverers the following output/parameters.
- Filecontent
- The filecontent is presented as a string (output comes as a table if 'read_file_as_array' is used)
CODING EXAMPLE:
-- Include/Call for this library require("fs") -- Get filecontent liboutput = fs.read_file("/var/log/messages")
'liboutput' could contain something like:
Nov 6 13:17:01 inspiron /USR/SBIN/CRON[21751]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Nov 6 13:43:31 inspiron -- MARK --
CODING EXAMPLE (read_file_as_array):
If 'read_file_as_array' is used, you could do something like this see the output:
for a,b in ipairs(liboutput) do print(a,b) end
The output would look something like:
1 Nov 6 13:17:01 inspiron /USR/SBIN/CRON[21751]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) 2 Nov 6 13:43:31 inspiron -- MARK --
write_file (function)
INPUT:
This library function required the following inputs/parameters.
- Path to file
- Example: /root/mynotes
- String
- Content that should be written to file
OUTPUT:
This library function deliverers the following output/parameters.
- Output is written to file
- The content of the inputstring is written to the file.
- Data is appended to file (not sure)
CODING EXAMPLE:
-- Include/Call for this library require("fs") -- Write to file fs.write_file("/var/log/messages", "Hello World!")
find (function)
Lets you search for dir entries matching filespec.
Could be compared to 'find / -type d | grep tmp' (not sure)
INPUT:
This library function required the following inputs/parameters.
- SearchString
- This string is what we are searching for in the dirnames.
- Path
- This path is where we start searching
- Search is recursive (not sure)
OUTPUT:
This library function deliverers the following output/parameters.
- SearchResult
- The SearchResult as a table (array)
CODING EXAMPLE:
-- Include/Call for this library require("fs") -- Search for dir liboutput = fs.find("tmp", "/")
You could do something like this see the output:
for a,b in ipairs(liboutput) do print(a,b) end
The output would look something like:
1 /usr/tmp 2 /usr/tmp/apk_add
html.lua
join.lua (not working)
INPUT:
This library required the following inputs/parameters.
- Delimiter
- Could be one or more chars.
- Array
- Data which is to be joined into a string.
OUTPUT:
This library deliverers the following output/parameters.
- String
- Could be something like "Word, Word, Word, Word"
CODING EXAMPLE:
-- Set variable/Call for this library
ourlib = require("join")
-- Create a array of data (Not sure if the next row is correct)
arraytojoin = "Bird", "Fish", "Cow", "Hammer"
-- Process the data (note the delimiter)
liboutput = ourlib(";", arraytojoin)
'liboutput' would contain:
Bird;Fish;Cow;Hammer
log_view.lua
service_controller.lua
service_model.lua
session.lua
split.lua
INPUT:
This library required the following inputs/parameters.
- Delimiter
- Could be one or more chars.
- String or line from a file: bobo~foo~bar~baz~1
- Data is to be split into a table
OUTPUT:
This library deliverers the following output/parameters.
- Table
- { 1 = "bobo", 2 = "foo", 3 = "bar", 4 = "baz", 5 = 1}
CODING EXAMPLE:
-- Set variable/Call for this library strsplit = require("split") -- Grab the line from a file or input it into the funtcion
line = "bobo~foo~bar~baz~1"
-- Process the data (note the delimiter) t = ourlib("~", line)
't' would contain:
{ 1 = "bobo", 2 = "foo", 3 = "bar", 4 = "baz", 5 = 1}
for a,b in ipairs(t) do print(a,b) end
1 bobo
2 foo
3 bar
4 baz
5 1
validator.lua
This contains multiple different functions that each will validate input in there own way.
is_ipv4 (function)
INPUT:
This library function required the following inputs/parameters.
- String in form of ip address
- Example: 192.168.24.10
OUTPUT:
This library function deliverers the following output/parameters.
- false or "true"
CODING EXAMPLE:
-- Include/Call for this library require("validator") -- Check if url is a folder liboutput = validator.is_ip("192.168.24.10")
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain false.
is_mac (function)
INPUT:
This library function required the following inputs/parameters.
- String in form of mac address
- Example: 00:ca:ba:de:00:12
OUTPUT:
This library function deliverers the following output/parameters.
- false or "true"
CODING EXAMPLE:
-- Include/Call for this library require("validator") -- Check if url is a folder liboutput = validator.is_mac("00:ca:ba:de:00:12")
If the string is a valid mac address 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain false.
is_integer(function)
INPUT:
This library function required the following inputs/parameters.
- Number
- Example: 100
OUTPUT:
This library function deliverers the following output/parameters.
- false or "true"
CODING EXAMPLE:
-- Include/Call for this library require("validator") -- Check if url is a folder liboutput = validator.is_integer("100")
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain false.
is_integer_in_range (function)
INPUT:
This library function required the following inputs/parameters.
- 3 numbers --- number to test, min, max
- Example: (10,5,12)
OUTPUT:
This library function deliverers the following output/parameters.
- false or "true"
CODING EXAMPLE:
-- Include/Call for this library require("validator") -- Check if url is a folder liboutput = validator.is_integer_in_range(10,5,15)
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain false.
is_port (function)
INPUT:
This library function required the following inputs/parameters.
- Number - is it between 1 and 65535
- Example: 45
OUTPUT:
This library function deliverers the following output/parameters.
- false or "true"
CODING EXAMPLE:
-- Include/Call for this library require("validator") -- Check if url is a folder liboutput = validator.is_port("45")
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain false.
web_elements.lua
render_table
INPUT:
This library function required the following inputs/parameters.
- Element
- The element should be type 'table'
- Element could be: group, label, html, log, link, form
- Level
- Level should be a 'number'
OUTPUT:
This library function deliverers the following output/parameters.
- HTML
- HTML formated output/elements
- The output is partially generated by html.lua
somefunction (function)
INPUT:
This library function required the following inputs/parameters.
- ?
- ?
OUTPUT:
This library function deliverers the following output/parameters.
- ?
- ?
CODING EXAMPLE:
-- Include/Call for this library require("fs") -- Check ? liboutput = fs.somefunction(?)
'liboutput' could contain:
?