summaryrefslogtreecommitdiffstats
path: root/ctl-lib
AgeCommit message (Collapse)AuthorFilesLines
2019-12-04Improve plugin search pathJonathan Aillet4-50/+303
In controller 'plugin' section, use only paths available with 'spath' key to search for plugins. Multiple paths can be specified using ':' character as separator. Environment variables can be used in paths. If a path is not absolute, it will be added two times to search paths list, one with binder root directory as prefix, and one with binding parent directory. BUG-AGL: SPEC-3011 Change-Id: I1e3fd64d523d36a0e0982bbd31d66ae8d9960d3c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2019-11-06Change LuaAfbEventPush to Handle tableicefish_8.99.1icefish/8.99.18.99.1Frederic Marec1-2/+1
Prevent table overflow Bug-AGL: SPEC-2374 Change-Id: Ibce96446735cd0caeeefa91fff57245943023047 Signed-off-by: Frederic Marec <frederic.marec@iot.bzh>
2019-10-01Pkg config files: use CMAKE_INSTALL_LIBDIR varClément Bénier2-2/+2
library folders may be lib or lib64 so use cmake CMAKE_INSTALL_LIBDIR variable instead of lib Bug-AGL: SPEC-2846 Change-Id: I805cf4f97a189dc2a489694f682f303e3982a753 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
2019-07-17Correct a return in 'CtlConfigExec' functionhalibut_8.0.3halibut_8.0.2halibut_8.0.1halibut_8.0.0halibut/8.0.3halibut/8.0.2halibut/8.0.1halibut/8.0.08.0.38.0.28.0.18.0.0Jonathan Aillet1-1/+1
Avoid a 'return -0' when an error has been caught during first section callback execution. Bug-AGL: SPEC-2568 Change-Id: Ic407f8be0afd0236b1880b6c33e5339470f68b33 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2019-07-17Add prints when loading sectionsJonathan Aillet1-10/+18
Add error/warning prints when calling loading sections callbacks. Move to next section if no callback is registered. Also, at section callback calls, return an error directly when the error is caught. Bug-AGL: SPEC-2568 Change-Id: I68495239b5b8e3b7ee03fcacc666a2b77375d616 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2019-07-05ctl-plugin.c: Get rid of nested functionhalibut_7.99.3halibut/7.99.37.99.3Romain Forlot1-23/+23
Nested C function is only valid in a non-standard extension of GCC. So this is not valid in C++ or any other compiler (i.e. Clang) Bug-AGL: SPEC-2113 Change-Id: If82395cad304e889ee8a97a39cf0c4f1dacbf1cd Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-06-04Add prints when calling section callbackshalibut_7.99.2halibut/7.99.27.99.2Jonathan Aillet1-6/+15
Add error/warning prints when calling controller section callbacks. Move to next section if no callback is registered. Also, at section callback calls, return an error directly when the error is caught. Bug-AGL: SPEC-2469 Change-Id: I5808087d55b77d22a3878fd60015bc09063ac717 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2019-04-30Inject binding v3 root api into controller pluginsRomain Forlot1-3/+6
Inject v3 api root into the controller plugins to be able to use the weak pointer to the v3 binding root. Bug-AGL: SPEC-2369 Change-Id: Icbad4ccda3d27882e6ceaac4d0a2b43d41540c7d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-04-29Fix: wrong string length size usedRomain Forlot1-2/+2
Fix: wrong string length size used to register l2c functions leading to have striped functions named registered. Change-Id: I741ccd08f75da154d9fc1b22d5eacc3c00e66b8c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-04-02Use the action API rather than the source oneRomain Forlot1-1/+1
Action's API member is the API calling the LUA function. It is better to use it instead of the source one which is user set up and may be non valid. Change-Id: Ia4638eb378ef7275bac016afaabef19a5eac2b9a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-02-26Rework 'ActionExecOne' to prevent race issuesJonathan Aillet1-11/+78
Use afb asynchronous calls to prevent issue when calling from an event handler. Also use subcall when in a request to pass on identity/events of/to the original caller. Change-Id: I821f92a2974415296cf19023b37f4639f7baaf5a Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2019-01-24Adds more details about the library migrationRomain Forlot3-6/+39
- adds the controller binder definitions migration to binder functions definitions and instructions using a sed script to migrate the old functions definition. - adds requirement reminder to af-binder version >= FF - fix wrong git submodule name given as example - Use AGLVERSION variable to set the PROJECT_VERSION. AGLVERSION could then be overwriten using command-line. - Use ${libdir} instead of CMake variable to set the Libs pkg-config variable. Bug-AGL: SPEC-1689 Change-Id: If03f35bab9501fbcb97244836692301c36d6d74c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-01-16Remove useless magic number checkguppy_6.99.4guppy/6.99.46.99.4Romain Forlot1-8/+1
This check is now deprecated since it complicates the mechanism and is not needed. If the retrieved struct isn't a good pointer then you got a bigger problem and that should fail then. Change-Id: If14b766ad3c96568625209043a6658fc8f17dc5f Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-01-10New installation instructionsRomain Forlot1-1/+1
New installation instructions for the appcontroller library And remove the the submodule occurences. Bug-AGL: SPEC-1689 Change-Id: Idaa6f9191ce521b551ddd7e7d4aa4430f0aeb399 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-01-03Adding packaging filesRomain Forlot1-4/+41
Add necessary files to build native packages for AGL supported linux distributions Bug-AGL: SPEC-2097 Change-Id: Ife6d1ec8a05f40e0bd70e741859133003716b37a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-27Set afb-helpers lib as an explicit dependencysandbox/claneys/shared-libRomain Forlot1-1/+1
Set afb-helpers lib as an explicit dependency in the pkg-config file. This avoid cyclic dependency problems at link as long as you use pkg-config to retrieve your link flags. Bug-AGL: SPEC-1689 Change-Id: Ieeee46de30cc38fefcfd0014f35dd078f865c8b2 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
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-17Update since the conversion to libraryRomain Forlot3-71/+73
Use the latest submodule git master branch revision. Some modifications has been lost since like the getter/setter functions and the plugin loading process. Change-Id: Ic0079f73bac46fba71f3de523a0f28371f85c1e6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-17Change to static lib and add default compile flagsRomain Forlot1-12/+8
Use the same compilation flags than in a Yocto build and make more robust the installation of the library Change-Id: Idb6b44a1772bc85080f6e700d40a3df12677f58a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-17Shared library: update to a v3 shared libraryRomain Forlot15-737/+353
- 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 Forlot2-3/+4
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-13Fix: compiling a controller without LUA supportRomain Forlot2-0/+6
Bug-AGL: SPEC-1979 Change-Id: I92c22136a7e6bca6557a306824f7dc8c0ae2bf47 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix Parse pluginFrederic Marec1-1/+2
Fix PluginParse in ctlplugin to handle json_object case Change-Id: Iaeacaaef3dc09ca28229e16aed992003aa3b02cf Signed-off-by: Frederic Marec <frederic.marec@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-13Reworked pluginConfig functionRomain Forlot1-55/+38
Reorganize the code to factorize some parts in pluginParse instead of pluginConfig. Also check the validity of the ctlConfig retrieved variable from the api Change-Id: I640adb7021c262b00f8f4284df9c07dd663fd9f3 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Retrieve plugin list from api rather than a globalRomain Forlot5-13/+9
Change-Id: Iba7c564eea48495c76de8ca919725a2e4b332fd6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Add setter/getter for user free defined pointerRomain Forlot3-2/+18
Change-Id: I617f758890c3508f55d568b0e5c57c8c5d4d5dd1 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Pass the plugin to action.Romain Forlot2-0/+2
Pass the plugin to action using source structure. Plugin pointer is now accessible from anywhere in the plugin callbacks. Clean deprecated function. Change-Id: Idf50728af0b3573a45c4731d4343cf67741b662c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Abort if one required API is missingRomain Forlot1-1/+2
AFB returns a missing API as a warning and doesn't abort the process. It is a binding duty to know if it should exit or not. Here a missing API is considerate as an error and abort the binder. Change-Id: Id11bcc34fd5fa8fd8a9a5cbd70d6d3340190dc1d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Correct an error when no plugins are definedJonathan Aillet1-1/+1
Correct an error when 'PluginConfig' function is called while no plugins are defined in passed json. Change-Id: I281a18f601f8ca1b7dfedfe48d1de37f4e9eded4 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Decrease print level when no onload actionJonathan Aillet1-1/+1
Decrease print level when 'OnloadConfig' function is called while no onload action are defined in passed json. Change-Id: I173cb9b6824f7f32cf33a6755ed52f9dcf093ee6 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Add a 'params' fields for controller pluginsJonathan Aillet2-3/+5
Add a 'params' fields for controller plugins. Can be used to send specific parameters to plugins functions (onload, init, ...). Change-Id: Ifb16f06a20453ef2bd1bc8a72bc2841dc12e323c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Call wasn't done correctly in 'CtlConfigExec'Jonathan Aillet1-1/+1
Call wasn't done correctly in 'CtlConfigExec', some functions were not call by 'CtlConfigExec' when it should be ... Change-Id: I5ce44e616042868c349bd5637c56267b8eff72e1 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Add ctlPlugins array to the ctlConfig structureRomain Forlot3-2/+10
This lets you add new actions to a section from a plugin, typically at its init step. Change-Id: I33a61c6162d25332d680d8a0e2d1841a457e0e80 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Add an Init step to the plugins loadRomain Forlot2-1/+11
The onload step could be considered as a preinit step. Init stage happens once all plugins are loaded and so you can refer to them to add new actions or configuration elements. Change-Id: I7986265bb1227208d0648bb2c56a1172b164faf1 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Change loading configuration object behaviorRomain Forlot5-22/+59
This changes the default behavior when loading actions. Now, it appends the new actions to the old ones instead of replacing them when called several times. If there were no actions previously loaded then it just loads normally the actions. Change-Id: Ica58a3edf4a9bf18ae31c6b6a5fa329e7ec5478b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix: compatibility with binder FF.RC4Romain Forlot1-2/+6
binder FF.RC4 provides the missing define afb_service_call[_sync]_legacy which doesn't fit with define in the controller as the first argument API is already given by the app framework binder. Change-Id: Ia2d01b172386d96354d356e66817b166985fa646 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix: Wrong variable definitionRomain Forlot1-1/+1
Variable is already defined earlier with all function scope. Redefining here make the variable value wrong at the ending return statement. Change-Id: I85269d1f60a7e1b844d19dd902149fa25da50844 Signed-off-by: Romain Forlot <romain.forlot@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 Forlot6-33/+119
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-13Adds v3 function to get binding settingsRomain Forlot2-1/+9
Adds v3 function to get binding settings waiting the real migration of the controller to v3 Change-Id: Iece3fcbcb81de807927765097c964e3272165947 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-13Add path to the installed widget path.Romain Forlot1-8/+24
This resolves the link to the binding library then set the directory path to the widget installation location. Change-Id: Iaad0d8aad6e3b8bfdcdedde19fb7906adf5f9610 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13New defaults useful functions on lua tableRomain Forlot1-0/+21
Add a function that returns the size of a table as the operator '#' isn't considered are safe or accurate. Add another function to deep copy a table. Change-Id: Ia549315e305dd7d02b975a3e8a1278c4ab709eec Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>