summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-lua.c
AgeCommit message (Collapse)AuthorFilesLines
2018-12-18More accurate log messages.guppy_6.99.3guppy/6.99.36.99.3Romain Forlot1-31/+37
Change-Id: I8a6700f342df4211e3354e61dfcb687d75186160 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-18Make available the unsubscribe from a LUA scriptRomain Forlot1-0/+31
Until now only the subscribe operation was available from a LUA script, this implements the missing unsubscribe. Change-Id: I9e6e9c727cd65fe5f167d06e7c871575f3e705c4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-17Shared library: update to a v3 shared libraryRomain Forlot1-70/+57
- AFB_BINDING_VERSION = 3 - remove preprocessor variables - mandatory lua - name of library is ctl-utilities - does not work with v2 versions - remove afb-definitions.h - use of the GNUinstalldirs module to set the destination directories. Change-Id: Ifdf12885ffad5003ecbbcf3639af63060f0ebc7e Signed-off-by: Clément Bénier <clement.benier@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13memleak fixesRomain Forlot1-1/+2
Change-Id: I575d87bf0770f24f2c7ddd6fba9b7917aad62c6d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Retrieve by default an int64 instead of intRomain Forlot1-1/+1
This avoids to cast to int an int64, used by example to retrieve a nanosecond timestamp variable. Change-Id: I4337f37009059f19b8ad6a910c76e844493d22f3 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13New function to retrieve Api's name from LUARomain Forlot1-0/+15
Change-Id: I1678dced50f1cdaf3f2a3c9caff4aa5afa0c5b49 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Handle number and boolean to subcall an api's verbRomain Forlot1-8/+7
An improvment was made to handle string for synchronous subcalls and now it handles also number and boolean for both sync and async subcalls. Change-Id: Iafaf9d01b8abd83423b1809a9e0e5433d44d6ded Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13AFB:servsync: add string for query argumentClément Bénier1-2/+7
for query argument add string that will be converted to json object Change-Id: I75b669a6c02838fd31017b82e9093966f3eea0e6 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
2018-12-13ctl-lua: Fixed memory corruptionThierry Bultel1-5/+6
fixed a malloc random crash when loading the configuration files. A write of one byte was done outside of an allocated area. Namely, strncat always writes n+1 bytes, thus a best practice is to always calculate n as this: buffer_size-strlen(s)-1 Change-Id: Icb568f324d466fc6eef40c3e251ce6b8a7006d95 Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-12-13Migration to v3Romain Forlot1-13/+10
This makes controller fully compatible with binding v3 and also keeps the compatibility with the Pre-V3 + DYNAPI bindings. Change-Id: Iaa47e51b9cb964bbe2f050784fca355c780673f8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13New function returning the binding root directoryRomain Forlot1-0/+15
Change-Id: If4d8416c87c668ebc55d3866ccd038c652317b43 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Change the default GLOB patternRomain Forlot1-2/+3
Change the default GLOB pattern because the lua should be found in var directory by default. Change-Id: I8be0e85c97459553e1d6a9f58efa394eb311a514 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix wrong computed lengthRomain Forlot1-2/+2
Change-Id: I020a1619c94a3a22d66e6657f64d4cedda3a1e62 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13More precise log message when loading a Lua fileRomain Forlot1-8/+13
This will indicates what is the error at the LUA file loading Change-Id: I258bf43a2200577998e05cf7b2253bdd510a468e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Release arguments once C function returned.Romain Forlot1-1/+2
There was a leack after poping arguments from Lua interpreter. Now when a Lua2C function is called, if there is something to keep from the argument then you should call json_object_get() on it to preserve it. Change-Id: I43e79ed73a507ac2ca7ed4cdc3f16ec009392194 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Use prefix variable to find controller's pluginsRomain Forlot1-10/+11
Prefix is the most reliable variable to find files or variables for a controller, so this lets you access it wherever it is needed without using global hardcoded variables. This helps to search for controller's plugins in several locations depending on environment variables and hardcoded variables (CONTROL_PLUGIN_PATH, CONTROL_CONFIG_PATH). This implies also a change a LUA interpreter loading step to correctly set the package.path variables with the environment variables, too. Correct the missing 'extern' in function declarations. Depends-On: Ic448ff017e6158bec05895d63688b8968b5c6434 Change-Id: I0ad19242612559d1f4b66b6f9af9e7032d4675a8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13ctl-lua: typo fixClément Bénier1-43/+43
change LUA_FIST_ARG into LUA_FIRST_ARG Change-Id: Ie084e78f68dd0a29c4dfc8387200be9af5180647 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
2018-12-13asynchronism for test: LockWait addedClément Bénier1-8/+25
added LockWait to wait for incoming events, as soon as an event is received, the wait is unlocked You can indicate the timeout Change-Id: If29ca754618edb5b9fdc32c1c40b47016c6fc88a Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
2018-12-13Change LUA package path at LUA interpreter loadRomain Forlot1-0/+33
Set package.path lua variable use the CONTROL_PLUGIN_PATH as it could have to find external lua packages in those directories. Change-Id: Iebea763782cfc024c5fef1fdbefe8ed80dbc4dbb Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fixed null value when push Lua argumentsSebastien Douheret1-13/+13
Still print a notice message when pushing a null object because having a null object in LUA may be problematic and it's always a good idea to warn developer. Also use json_object_to_json_string (safer than json_object_get_string in case of object is not a string) to dump json object in notice/debug messages. Change-Id: Ia3c252f38cbeca872b8f8fab1589da85d71a51ec Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2018-12-13Adjust to compile with incoming bindings v3José Bollo1-2/+4
Change-Id: I0a3a1db6dacf017ecea5b91dc35eb3ec2d86515d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-12-13Fixed crash due to call to json_object_putSebastien Douheret1-1/+0
Call to json_object_put seems no longer needed in LuaAfbSuccess. Change-Id: I2ee850605633b953217b3ad52a4a11059e841be3 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2018-12-13Fix segfault when printing long message from luaSebastien Douheret1-4/+6
Change-Id: Idb3cb8ebe94cc1670e8757c6ff713ab7ef107a8b Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2018-12-13Fixed spelling of AFB_ReqSuccessSebastien Douheret1-2/+2
Also change event message from notice to debug level. Change-Id: I8dc891343ee7f744ea0e3c07455806eaf34c1d7e Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2018-12-13Fixed build warnings with gcc >= 7.3Sebastien Douheret1-1/+1
Reduced the number of warnings in native host configuration (here Tumbleweed) in order to not hide true/real warnings that may appear in the future. Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2018-12-13Increase lua script max message sizeJonathan Aillet1-1/+1
Increase lua script max message size to avoid app-controller warning messages when a lua print message is too long with 4a-softmixer. Change-Id: I3c2496ea3e5bd971b7682328f7a6227e36b6d706 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Fixed compilation warnings with gcc-7.2.0Thierry Bultel1-2/+2
Replaced some 'size_t' by 'int' Change-Id: Iaf58b4b65f9aa2e82c0a87af45f21ca62fa4d84e Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-12-13Make action item from a LUA action mandatoryRomain Forlot1-13/+1
It is already mandatory from a JSON schema point of view so here it should be the same. Also it simplifies the process avoiding the guess and deduction... Change-Id: I3197b4c7798589f4c62814407909270cdabd1dae Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Good usage of strncat and strncpyRomain Forlot1-16/+25
This change ensure that there are no write over the destination buffer size Change-Id: Ic213e70fab83dfae39a8ff030c823a6ce68aab64 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Update to the new JSON syntaxRomain Forlot1-1/+1
Change-Id: I4ee750f4d95e9fe47352e6cd1dfaeaa94c292e30 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix wrong error message.Romain Forlot1-2/+2
Signature was wrong since last modification about controller and lua integration that now transport source informations. Change-Id: I8f98415b55978e6b7221415ad6169e8d2bc1c959 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix: Dyn API Action loading procedureRomain Forlot1-364/+388
Change-Id: Ibb7dbc32580100c588d06e283abb57cc37875312 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13FormatRomain Forlot1-179/+145
Change-Id: Ied901f39cd6814e5afd9811248b0a1fb401f3e76 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Improve way to loading an actionRomain Forlot1-94/+14
Split and cleaner function that load from JSON object an object CtlActionT that could be used by the controller. Also use a new syntax that reduce the number of JSON fields to parse based on a URI syntax. Change-Id: Iabc447368ca56e3a4279fb728ba2f546e11c961b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Upgrade config schemaRomain Forlot1-136/+183
Change the way to load LUA scripts. They are now considerate as Plugin and loads with them. This imply rework of how to search and find plugins as well as the way to load LUA. Also load an harcoded LUA scripts providing LUA helpers and managing global variables lock unlock mechanism Change-Id: I64e38aa27278d0cfdca787155db2d0c89953f905 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix conversion compilation warningRomain Forlot1-1/+1
Change-Id: I0d5350c1e454bc118e4470ae7ff0eafe253cd2bf Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Old audio controller traces left behindRomain Forlot1-1/+1
Change-Id: I2423376e9c0c616ba62439b387f7da23f710dbb0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Linting: Initialize fullprefix variableRomain Forlot1-1/+1
Change-Id: I24b0b0f87f1315220cf668c170fc3c13a85f46bb Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix memory leakRomain Forlot1-0/+4
Change-Id: I5ba04ecfb7809f9132e7958c5044b3d821830e8a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Change prefix generation, simpler is betterRomain Forlot1-3/+5
Change-Id: Ieb4801b9162f9f8f374b352fb66bed82a8854b7f Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Get back on track l2c functions.Romain Forlot1-6/+9
Change-Id: I8425f0de60a35b4e287c8829fe72cbca80bc55df Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Avoid compile warning, memory leaks, lintingRomain Forlot1-0/+2
Change-Id: Ida18aeab20d5b894609c1a9c2f6fc2a71a0b4a23 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Protect exec when no files found.Romain Forlot1-28/+31
ScanForConfig return null when no files found which isn't handled until now. Change-Id: I70d6b4a45be9d434aca049e3cd3260dfc38a7ff7 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Get back lua2c functions parsed at plugin loadRomain Forlot1-2/+10
Format JSON unpack operations Change-Id: Iaed0988d8536ad1df60a32a610e69e35485fc9f8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix: strncpy does't add null char at the endRomain Forlot1-5/+5
Fix: handle null response from CtlScanConfig() Change-Id: Icbe2a649886998078adda35b0d0dfd1c46e8fe31 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13fix: wrong usage of strncat and strncpy functionRomain Forlot1-19/+19
3rd arguments match strlen of 2nd arguments and should not match the maximum length of destination variable. Change-Id: Ifebf6097bb995d0cf2c5633eb94d52d4517ade7b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Modifiy timer to supper DynAPIFulup Ar Foll1-5/+11
th Please enter the commit message for your changes. Lines starting Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2018-12-13fix build errorRonan Le Martret1-1/+1
* error: format not a string literal and no format arguments [-Werror=format-security] Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2018-12-13Fix issue with compiling in API-V2Fulup Ar Foll1-1/+8
2018-12-13FormatingRomain Forlot1-58/+58
Change-Id: I2b805a60b67db1a72b429093256999673e2c3964 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>