The list of libraries supported in policy extensions.
- Basic library
- String library
- Regular Expression Patterns - Character Classes
- Regular Expression Patterns - Pattern Items
- Table library
- Math library
- Bitwise library
- Operating System library
- Citrix ADC library
Basic library
| |
---|
assert(v[,message]) | Issues an error, with an optional message, when v is false. |
error(message) | Terminates a function and reports the error message. |
ipairs(a) | Iterator for an array a. Returns an index and value for each iteration. |
pairs(t) | Iterator for a table t. Returns a key and value for each iteration. |
tonumber(e[,base]) | Converts e to a number, with an optional base. |
tostring(v) | Converts v to a string |
type(v) | Returns the type of v: number, string, boolean, table, etc. |
getmetatable (object) | Returns nil if the object does not have a metatable. Otherwise, if the object’s metatable has a “__metatable” field, returns the associated value. Otherwise, returns the metatable of the given object. |
setmetatable (table, metatable) | Sets the metatable for the given table. (You cannot change the metatable of other types from Lua, only from C.) If metatable is nil, removes the metatable of the given table. If the original metatable has a “__metatable” field, raises an error. |
select (index, ···) | Returns all arguments after argument number index. If index is string “#”, then it returns the total number of extra arguments it received. |
pcall (f [, arg1, ···]) | Calls function f with the given arguments in protected mode. It returns status code as first result which tells whether call succeeded or not. If call succeeded, then along with status code it also returns all results from the call, otherwise returns error message. |
xpcall (f, msgh [, arg1, ···]) | This function is similar to pcall, except that it also takes an argument for error handling. |
_VERSION | Returns the current interpreter version. |
String library
| |
---|
string.byte(s[,i[,j]]) | Returns the byte values for s[i] to s[j]. Default i = 1 and j = i |
string.char(…) | Returns a string constructed of the integer parameters. |
string.find(s,pattern[,init[,plain]) | Looks for the first match of a regular expression pattern in s. Return the first and last indices of match or nil. init is index to start, default 1. plain = true means pattern is not a regex. |
string.format(form,…) | Returns a formatted version of the parameters. |
string.gmatch(s,pattern) | Iterator for searching s with the regex pattern. Returns matching values. |
string.gsub(s,pattern,repl[,n]) | Returns a copy of s in which all (or n) occurences of the pattern have been replaced by repl. |
string.len(s) | Returns the string length. |
string.lower(s) | Returns a copy of the string converted to lowercase. |
string.match(s,pattern[,init]) | Looks for the first match of the regex pattern in s and returns the captures or the whole pattern. init is the index to start, default 1. |
string.rep(s,n[,sep]) | Returns a string that is n copies of s, with separator sep, default no separator |
string.reverse(s) | Returns a string that is s reversed. |
string.sub(s,i[,j]) | Returns the substring of s from s[i] to s[j], default j is the end of the string. |
string.upper(s) | Returns a copy of the string converted to uppercase. |
string.dump (function) | Returns a string containing a binary representation of the given function. |
Regular expression patterns - character classes
| |
---|
x | the character x, except for magic characters ^$()%.[]*+-?) |
. | any character |
%a | any letter |
%c | any control character |
%d | any digit |
%g | any printable character except space |
%l | any lowercase letter |
%p | any punctuation character |
%s | any white space character |
%u | any uppercase letter |
%w | any alphanumber letter |
%x | an escaped magic character x (for example %%) |
[set] | a set of characters: sequence of individual characters, ranges x-y, and % classes |
[^set] | characters not in the set. |
Regular expression patterns - pattern items
| |
---|
X | a character class |
X* | 0 or more longest repetitions of characters in X |
X+ | 1 or more repetitions of characgers in X |
X- | 0 or more shortest repetitions of characters in X |
X? | 0 or 1 character in X |
%n | n=1 to 9; matches nth captured string |
%bxy | matches substring between two balanced characters x and y. Example %b() matches substring between two balanced parentheses. |
%f[set] | matches an empty string at at any position such that the next character belongs to set and the previous character does not belong to set. |
A pattern is a sequence of pattern items. ^pattern matches the beginning of a string and pattern$ matches the end of the string.
Matched substrings can be captured using (pattern). Parentheses with no pattern () capture the current string position (a number).
Table library
| |
---|
table.concat(list[,sep[,i[,j]]]) | Returns a string list[i] .. sep .. list[i+1] .. sep . . . list[j]. Default sep is the empty string. Default i is 1, j is #list. |
table.insert(list,[pos,]value) | Inserts value into list at index pos. Default for pos is #list (end of the list). |
table.pack(…) | Returns an array containing the parameters starting at index 1, and a key n with the total number of parameters. |
table.remove(list[,pos]) | Removes from list the element at position pos, shifting elements to fill the position. Returns the removed element. Default for posis #list (end of the list.) |
table.sort(list[,comp]) | Sort the elements of list in place. comp is the comparison function to use. Default for comp is <. |
table.unpack(list[,i[,j]]) | Returns list[i] through list[j]. Default for i is 1 and j is #list<c/ode>. |
Math library
Various trigonometric and logarithmic functions not shown.
| |
---|
math.abs(x) | Returns the absolute value of x. |
math.ceil(x) | Returns the smallest integer >= x. |
math.floor(x) | Returns the largest integer <= x. |
math.fmod(x,y) | Returns the remainder of x/y rounding the quotient towards zero. |
math.huge | A value >= any other number. |
math.max(x,…) | Returns the maximum argument. |
math.min(x,…) | Returns the minimum argument. |
math.modf(x) | Returns the integral and fractional parts of x. |
math.random() | Returns a pseudo-random number between 0 and 1. |
math.random(m) | Returns a pseudo-random integer between 1 and m. |
math.random(m, n) | Returns a pseudo-random integer betwen m and n. |
math.randomseed(x) | Sets the pseudo-random number generator set to x. |
math.sqrt(x) | Returns the square root of x (x^0.5) |
math.acos(x) | Returns the arc cosine of x (in radians). |
math.asin(x) | Returns the arc sine of x (in radians). |
math.atan(x) | Returns the arc tangent of x (in radians). |
math.atan2(y, x) | Returns the arc tangent of y/x (in radians). |
math.cos(x) | Returns the cosine of x. |
math.cosh(x) | Returns the hyperbolic cosine of x. |
math.sin(x) | Returns the sine of x. |
math.sinh(x) | Returns the hyperbolic sine of x. |
math.tan(x) | Returns the tangent of x. |
math.tanh(x) | Returns the hyperbolic tangent of x. |
math.deg(x) | Returns the angle x (given in radians) in degrees. |
math.exp(x) | Returns the value e^x. |
math.frexp (x) | Returns m and e such that x = m2e, e is an integer and the absolute value of m is in the range [0.5, 1). |
math.ldexp (m, e) | Returns m2e (e should be an integer). |
math.log (x [, base]) | Returns the logarithm of x in the given base. The default for base is e. |
math.pow (x, y) | Returns x^y. |
math.rad (x) | Returns the angle x (given in degrees) in radians. |
math.pi | The value of π. |
Bitwise library
Unless otherwise stated:
- All functions accept numeric arguments in the range (-2^51,+2^51).
- Each argument is normalized to the remainder of its division by 2^32 and truncated to an integer (in some unspecified way), so that its final value falls in the range [0,2^32 - 1].
- All results are in the range [0,2^32 - 1].
| |
---|
bit32.arshift(x,disp) | Returns x arithmetically shifted disp bits to the right (+disp) or left (-disp). |
bit32.band(…) | Returns the bitwise and of the arguments. |
bit32.bnot(x) | Returns the bitwise negation of x. |
bit32.bor(…) | Returns the bitwise or of the arguments. |
bit32.btest(…) | Returns true if the bitwise and of the arguments is not zero. |
bit32.bxor(…) | Returns the bitwise exclusive or of the arguments. |
bit32.extract(n,field[,width]) | Returns the bits in n from field to field + width - 1 (bits number from most to least significant). Default for width is 1. |
bit32.replace(n,v,field[,width]) | Returns a copy of n with bits from field to field + width -1 replaced by v. Default width is 1. |
bit32.lrotate(x,disp) | Returns x rotated disp bits to the left (+disp) or right (-disp). |
bit32.lshift(x,disp) | Returns x shifted disp bits to the left (+disp) or right (-disp). |
bit32.rrotate(x,disp) | Returns x rotated disp bits to the right (+disp) or left (-disp). |
bit32.rshift(x,disp) | Returns x shifted disp bits to the right (+disp) or left (-disp). |
Operating system library
| |
---|
os.clock () | Returns an approximation of the amount in seconds of CPU time. |
os.date ([format [, time]]) | Returns a string or a table containing date and time, formatted according to the given string format. |
os.time ([table]) | Returns the current time when called without arguments, or a time representing the date and time specified by the given table. |
os.difftime (t2, t1) | Returns the number of seconds from time t1 to time t2. |
Citrix ADC library
| |
---|
ns.logger:level(message) | To log messages where level is emergency, alert, critical, error, warning, notice, info, or debug. The parameters are the same as the C printf() function: a format string, and a variable number of arguments to supply values for the % specifiers in the format string. |
发布评论