File freepops.lua
Functions
| dofile (f) | uses freepops' dofile instead of the standard one. |
| freepops.bootstrap () | Load the configuration file and the support module. |
| freepops.check_global_symbols () | Checks if the plugin has declared all required methods. |
| freepops.choose_module (d) | function that maps domains to modules. |
| freepops.dofile (file) | As the standard LUA dofile but with MODULES_PREFIX path. |
| freepops.enough_new (plugin_version_string) | Checks if this FreePOPs version is enough for the plugin. |
| freepops.export (tab) | Makes tab members globals. |
| freepops.find (file) | Searches a file in $CWD + prefixes and returns the full path or nil. |
| freepops.get_args (mailaddress) | function to extract the parameters part of a mailaddress. |
| freepops.get_domain (mailaddress) | function to extract domain part of a mailaddress. |
| freepops.get_name (mailaddress) | function to extract the username part of a mailaddress. |
| freepops.init (mailaddress) | Load the configuration file and the support module and the plugin that handles mailaddress. |
| freepops.is_version_ge (version1, version2) | Compares 2 verions in FreePOPs format. |
| freepops.load_module_for (mailaddress, loadonly) | Load needed module for handling domain. |
| freepops.loadlib (file, fname) | As the standard LUA loadlib but with MODULES_PREFIX path. |
| freepops.match_address (a, t) | Checks if the address a is matched by the strings defined in table t. |
| freepops.need_ssl () | Checks if this version of FP is SSL enabled. |
| freepops.safe_extract_domains (f) | Extracts a list of supported domain from a plugin file. |
| freepops.search_domain_in_unofficial (domain) | Searches if an unofficial plugin handles this domain. |
| freepops.set_sanity_checks () | Sets a metatable for _G that checks for wrong globals usage. |
| freepops.table_overwrite (t, t1) | Merge 2 tables. |
| freepops.version () | Gives back the version string of freepops |
Functions
- dofile (f)
-
uses freepops' dofile instead of the standard one.
Parameters
- f:
- freepops.bootstrap ()
- Load the configuration file and the support module. Is intended to be used by the C core.
- freepops.check_global_symbols ()
- Checks if the plugin has declared all required methods. This should be called after the plugin is loaded.
- freepops.choose_module (d)
-
function that maps domains to modules. These are the rules that will be honored to choose the module: 0th: if domain d is nil then fail 1st: check if a verbatim mapping exists (freepops.MODULES_MAP[d] ~= nil) 2nd: check if a plugin tagged regex matches 3rd: check if the mailaddress is a plugin name 4th: check if an unofficial plugin matches verbatim 5th: check if an unofficial plugin tagged regex matches.
Parameters
- d: string The domain.
Return value:
found, where, name, args. - freepops.dofile (file)
-
As the standard LUA dofile but with MODULES_PREFIX path.
Parameters
- file:
Return value:
number 0 if OK, nil if not. - freepops.enough_new (plugin_version_string)
-
Checks if this FreePOPs version is enough for the plugin.
Parameters
- plugin_version_string:
- freepops.export (tab)
-
Makes tab members globals.
Parameters
- tab:
- freepops.find (file)
-
Searches a file in $CWD + prefixes and returns the full path or nil. XXX $CWD should be removed, what happens if $CWD is writable by all? XXX
Parameters
- file: string The ifle name.
Return value:
string The full path or nil, then the package.path entry, then the namespace if any ("a.b.lua" -> ".../a.lua", ".../?.lua", "a" . - freepops.get_args (mailaddress)
-
function to extract the parameters part of a mailaddress.
Parameters
- mailaddress: string for example pippo@libero.it?par1=val1&par2=val2.
Return value:
table in our example {par1=val1 ; par2=val2}. - freepops.get_domain (mailaddress)
-
function to extract domain part of a mailaddress.
Parameters
- mailaddress: string for example pippo@libero.it?param=value.
Return value:
string The text between @ and (?|$). In our example 'libero.it'. - freepops.get_name (mailaddress)
-
function to extract the username part of a mailaddress.
Parameters
- mailaddress: string for example pippo@libero.it?param=value.
Return value:
string The text between ^ and @. in our example pippo. - freepops.init (mailaddress)
-
Load the configuration file and the support module and the plugin that handles mailaddress. Is intended to be used by the C core.
Parameters
- mailaddress:
- freepops.is_version_ge (version1, version2)
-
Compares 2 verions in FreePOPs format. This is the LUA regex to extract the components: "(%d+)%.(%d+)%.(%d+)".
Parameters
- version1: string A version.
- version2: string A version.
Return value:
boolean true if version1 >= version2. - freepops.load_module_for (mailaddress, loadonly)
-
Load needed module for handling domain.
Parameters
- mailaddress:
- loadonly:
- freepops.loadlib (file, fname)
-
As the standard LUA loadlib but with MODULES_PREFIX path. Load a shared library (or even a .lua file). Checks if the file has been already loaded. Should be preferred to freepops.dofile().
Parameters
- file: string The object name.
- fname: string The function to call (nil in case the object is a lua).
Return value:
function The result of a LUA loadfile or nil. - freepops.match_address (a, t)
-
Checks if the address a is matched by the strings defined in table t.
Parameters
- a:
- t:
- freepops.need_ssl ()
- Checks if this version of FP is SSL enabled. Must be called after loading the browser module.
- freepops.safe_extract_domains (f)
-
Extracts a list of supported domain from a plugin file. The plugin is executed in a protected environment, no pollution but computations are done.
Parameters
- f: string The path of the lua plugin file.
Return value:
table A couple of tables, the list of domains and the list of regexes. - freepops.search_domain_in_unofficial (domain)
-
Searches if an unofficial plugin handles this domain.
Parameters
- domain: string The domain you want to handle.
Return value:
string A couple, name and path. - freepops.set_sanity_checks ()
- Sets a metatable for _G that checks for wrong globals usage. No more globals can be declared after this function is called.
- freepops.table_overwrite (t, t1)
-
Merge 2 tables. t is destroyed, and t1 wins over t.
Parameters
- t: table The slave table.
- t1: table The master table.
Return value:
table the union (t1 wins over t). - freepops.version ()
- Gives back the version string of freepops