ACF Libraries: Difference between revisions

From Alpine Linux
Line 70: Line 70:
== validator.lua ==
== validator.lua ==
This contains multiple different functions that each will validate input in there own way.  
This contains multiple different functions that each will validate input in there own way.  
*is_ipv4
*'''is_ipv4'''
**takes input and checks if it is a valid ip address
**takes input and checks if it is a valid ip address
***has 3 "." and 4 valid numbers less than 255
***has 3 "." and 4 valid numbers less than 255
*is_mac
*'''is_mac'''
**takes input and checks if it is a valid mac address
**takes input and checks if it is a valid mac address
***Correct hex numbers with ":" and 6 fields
***Correct hex numbers with ":" and 6 fields
*is_integer
*'''is_integer'''
**is the number >= 0 and a whole number
**is the number >= 0 and a whole number
*is_integer_in_range
*'''is_integer_in_range'''
**is the number >= 0 and within the range specified
**is the number >= 0 and within the range specified
*is_port
*'''is_port'''
**is the number a valid ip port number 1<n<65535
**is the number a valid ip port number 1<n<65535


== web_elements.lua ==
== web_elements.lua ==

Revision as of 14:36, 6 November 2007

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

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

menubuilder.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
    • takes input and checks if it is a valid ip address
      • has 3 "." and 4 valid numbers less than 255
  • is_mac
    • takes input and checks if it is a valid mac address
      • Correct hex numbers with ":" and 6 fields
  • is_integer
    • is the number >= 0 and a whole number
  • is_integer_in_range
    • is the number >= 0 and within the range specified
  • is_port
    • is the number a valid ip port number 1<n<65535

web_elements.lua