From a3cecd20f812c3fc71141a487443568c861c160a Mon Sep 17 00:00:00 2001 From: Fulup Ar Foll Date: Tue, 25 Jul 2017 17:33:52 +0200 Subject: [PATCH] Update HTML test page to new template. Added Config file selection from UI. --- conf.d/app-templates | 2 +- conf.d/autobuild/agl/autobuild | 21 ++- conf.d/autobuild/linux/autobuild | 21 ++- conf.d/config.cmake | 2 + htdocs/AFB-websock.js | 7 +- htdocs/AudioBinding.js | 72 -------- htdocs/UNICENS.html | 25 +-- htdocs/Ucs2Binding.css | 7 + htdocs/Ucs2Binding.js | 162 ++++++++++++++++++ nbproject/configurations.xml | 357 +++++++++++++++++++++++++++++++++++++-- ucs2-afb/ucs_apidef.h | 44 +++-- ucs2-afb/ucs_apidef.json | 21 ++- ucs2-afb/ucs_binding.c | 58 ++++++- 13 files changed, 671 insertions(+), 128 deletions(-) delete mode 100644 htdocs/AudioBinding.js create mode 100644 htdocs/Ucs2Binding.css create mode 100644 htdocs/Ucs2Binding.js diff --git a/conf.d/app-templates b/conf.d/app-templates index db6a07f..8f3bc0b 160000 --- a/conf.d/app-templates +++ b/conf.d/app-templates @@ -1 +1 @@ -Subproject commit db6a07f636a3f2a381dfcc0f52b16f59127496f0 +Subproject commit 8f3bc0b6f25a5560a308078342a8ed3cc6dba13f diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild index 31e29f7..759f6be 100755 --- a/conf.d/autobuild/agl/autobuild +++ b/conf.d/autobuild/agl/autobuild @@ -16,10 +16,24 @@ THISFILE := $(lastword $(MAKEFILE_LIST)) BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target -.PHONY: all clean distclean configure build package +.PHONY: all clean distclean configure build package help -all: build +all: help + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build" + @echo "- package" + @echo "" + @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" clean: @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean @@ -38,9 +52,8 @@ package: build @mkdir -p ${BUILD_DIR}/$@/lib @mkdir -p ${BUILD_DIR}/$@/htdocs @mkdir -p ${BUILD_DIR}/$@/data - @[ "${DEST}" ] && mkdir -p ${DEST} @cmake --build ${BUILD_DIR} --target widget - @[ "${DEST}" ] && cp ${BUILD_DIR}/*wgt ${DEST} + @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST} ${BUILD_DIR}/Makefile: @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR} diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild index 31e29f7..759f6be 100755 --- a/conf.d/autobuild/linux/autobuild +++ b/conf.d/autobuild/linux/autobuild @@ -16,10 +16,24 @@ THISFILE := $(lastword $(MAKEFILE_LIST)) BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target -.PHONY: all clean distclean configure build package +.PHONY: all clean distclean configure build package help -all: build +all: help + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build" + @echo "- package" + @echo "" + @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" clean: @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean @@ -38,9 +52,8 @@ package: build @mkdir -p ${BUILD_DIR}/$@/lib @mkdir -p ${BUILD_DIR}/$@/htdocs @mkdir -p ${BUILD_DIR}/$@/data - @[ "${DEST}" ] && mkdir -p ${DEST} @cmake --build ${BUILD_DIR} --target widget - @[ "${DEST}" ] && cp ${BUILD_DIR}/*wgt ${DEST} + @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST} ${BUILD_DIR}/Makefile: @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR} diff --git a/conf.d/config.cmake b/conf.d/config.cmake index 5dfb013..a386fe7 100644 --- a/conf.d/config.cmake +++ b/conf.d/config.cmake @@ -74,6 +74,8 @@ add_compile_options() # --------------------------------------------------------- add_compile_options(-DCONTROL_CDEV_TX="/dev/inic-usb-ctx") add_compile_options(-DCONTROL_CDEV_RX="/dev/inic-usb-crx") +add_compile_options(-DUCS2_CFG_PATH="/etc/default/ucs:./data") + # LANG Specific compile flags set for all build types set(CMAKE_C_FLAGS "") diff --git a/htdocs/AFB-websock.js b/htdocs/AFB-websock.js index 08a7ffe..99ab3b8 100644 --- a/htdocs/AFB-websock.js +++ b/htdocs/AFB-websock.js @@ -1,7 +1,10 @@ +var urlws; +var urlhttp; + AFB = function(base, initialtoken){ -var urlws = "ws://"+window.location.host+"/"+base; -var urlhttp = "http://"+window.location.host+"/"+base; +urlws = "ws://"+window.location.host+"/"+base; +urlhttp = "http://"+window.location.host+"/"+base; /*********************************************/ /**** ****/ diff --git a/htdocs/AudioBinding.js b/htdocs/AudioBinding.js deleted file mode 100644 index 5f9ea24..0000000 --- a/htdocs/AudioBinding.js +++ /dev/null @@ -1,72 +0,0 @@ - var afb = new AFB("api", "mysecret"); - var ws; - var evtidx=0; - - function getParameterByName(name, url) { - if (!url) { - url = window.location.href; - } - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, " ")); - } - - // default soundcard is "PCH" - var devid=getParameterByName("devid"); - if (!devid) devid="hw:0"; - - var sndname=getParameterByName("sndname"); - if (!sndname) sndname="PCH"; - - var quiet=getParameterByName("quiet"); - if (!quiet) quiet="99"; - - function init() { - ws = new afb.ws(onopen, onabort); - } - - function onopen() { - document.getElementById("main").style.visibility = "visible"; - document.getElementById("connected").innerHTML = "Binder WS Active"; - document.getElementById("connected").style.background = "lightgreen"; - ws.onevent("*", gotevent); - } - - function onabort() { - document.getElementById("main").style.visibility = "hidden"; - document.getElementById("connected").innerHTML = "Connected Closed"; - document.getElementById("connected").style.background = "red"; - - } - - function replyok(obj) { - console.log("replyok:" + JSON.stringify(obj)); - document.getElementById("output").innerHTML = "OK: "+JSON.stringify(obj); - } - - function replyerr(obj) { - console.log("replyerr:" + JSON.stringify(obj)); - document.getElementById("output").innerHTML = "ERROR: "+JSON.stringify(obj); - } - - function gotevent(obj) { - console.log("gotevent:" + JSON.stringify(obj)); - document.getElementById("outevt").innerHTML = (evtidx++) +": "+JSON.stringify(obj); - } - - function send(message) { - var api = document.getElementById("api").value; - var verb = document.getElementById("verb").value; - document.getElementById("question").innerHTML = "subscribe: "+api+"/"+verb + " (" + JSON.stringify(message) +")"; - ws.call(api+"/"+verb, {data:message}).then(replyok, replyerr); - } - - - function callbinder(api, verb, query) { - console.log ("subscribe api="+api+" verb="+verb+" query=" +query); - document.getElementById("question").innerHTML = "apicall: " + api+"/"+verb +" ("+ JSON.stringify(query)+")"; - ws.call(api+"/"+verb, query).then(replyok, replyerr); - } diff --git a/htdocs/UNICENS.html b/htdocs/UNICENS.html index 73c1b66..11746c6 100644 --- a/htdocs/UNICENS.html +++ b/htdocs/UNICENS.html @@ -1,17 +1,22 @@ - Hello world test + Unicens Simple Test + - + - - -

Hello world test

- + +

Unicens Simple Test

+ + +

+ Selected HAL +
+
    -
  1. +
  2. @@ -26,8 +31,8 @@
    diff --git a/htdocs/Ucs2Binding.css b/htdocs/Ucs2Binding.css new file mode 100644 index 0000000..1052aa7 --- /dev/null +++ b/htdocs/Ucs2Binding.css @@ -0,0 +1,7 @@ +pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; } +.string { color: green; } +.number { color: darkorange; } +.boolean { color: blue; } +.null { color: magenta; } +.key { color: red; } + diff --git a/htdocs/Ucs2Binding.js b/htdocs/Ucs2Binding.js new file mode 100644 index 0000000..11b8a1a --- /dev/null +++ b/htdocs/Ucs2Binding.js @@ -0,0 +1,162 @@ + var afb = new AFB("api", "mysecret"); + var ws; + var ucs2_config="ConfigNotSelected"; + var evtidx=0; + var numid=0; + + function syntaxHighlight(json) { + if (typeof json !== 'string') { + json = JSON.stringify(json, undefined, 2); + } + json = json.replace(/&/g, '&').replace(//g, '>'); + return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { + var cls = 'number'; + if (/^"/.test(match)) { + if (/:$/.test(match)) { + cls = 'key'; + } else { + cls = 'string'; + } + } else if (/true|false/.test(match)) { + cls = 'boolean'; + } else if (/null/.test(match)) { + cls = 'null'; + } + return '' + match + ''; + }); + } + + function basename(path) { + return path.split('/').reverse()[0]; + } + + function getParameterByName(name, url) { + if (!url) { + url = window.location.href; + } + name = name.replace(/[\[\]]/g, "\\$&"); + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, " ")); + } + + // default soundcard is "PCH" + var devid=getParameterByName("devid"); + if (!devid) devid="hw:1"; + + var haldev=getParameterByName("haldev"); + if (!haldev) haldev="scarlett-usb"; + + var sndname=getParameterByName("sndname"); + if (!sndname) sndname="PCH"; + + var mode=getParameterByName("mode"); + if (!mode) mode="0"; + + + + + function replyok(obj) { + console.log("replyok:" + JSON.stringify(obj)); + document.getElementById("output").innerHTML = "OK: "+ syntaxHighlight(obj); + } + + function replyerr(obj) { + console.log("replyerr:" + JSON.stringify(obj)); + document.getElementById("output").innerHTML = "ERROR: "+ syntaxHighlight(obj); + } + + function gotevent(obj) { + console.log("gotevent:" + JSON.stringify(obj)); + document.getElementById("outevt").innerHTML = (evtidx++) +": "+JSON.stringify(obj); + } + + function send(message) { + var api = document.getElementById("api").value; + var verb = document.getElementById("verb").value; + document.getElementById("question").innerHTML = "subscribe: "+api+"/"+verb + " (" + JSON.stringify(message) +")"; + ws.call(api+"/"+verb, {data:message}).then(replyok, replyerr); + } + + + // On button click from HTML page + function callbinder(api, verb, query) { + console.log ("subscribe api="+api+" verb="+verb+" query=" +query); + var question = urlws +"/" +api +"/" +verb + "?query=" + JSON.stringify(query); + document.getElementById("question").innerHTML = syntaxHighlight(question); + ws.call(api+"/"+verb, query).then(replyok, replyerr); + } + + + // Retreive Select value and Text from the binder + // Note: selection of value/text for a given context is huggly!!! + function querySelectList (elemid, api, verb, query) { + + console.log("querySelectList elemid=%s api=%s verb=%s query=%s", elemid, api, verb, query); + + var selectobj = document.getElementById(elemid); + if (!selectobj) { + console.log ("****** elemid=%s does not exit in HTML page ****", elemid); + return; + } + + // onlick update selected HAL api + selectobj.onclick=function(){ + ucs2_config= this.value; + console.log ("Default Selection=" + ucs2_config); + }; + + function gotit (result) { + + // display response as for normal onclick action + replyok(result); + var response=result.response; + + // fulfill select with avaliable active HAL + for (idx=0; idx UcsXml.c + UcsXml_Private.c ucs_lib_interf.c ucs_vol_interf.c @@ -105,6 +106,63 @@ ucs_xrm_res.c ucs_xrmpool.c + + + ucs_alm.c + ucs_amd.c + ucs_ams.c + ucs_amsmessage.c + ucs_amspool.c + ucs_amtp.c + ucs_attach.c + ucs_base.c + ucs_bc_diag.c + ucs_class.c + ucs_cmd.c + ucs_dec.c + ucs_dl.c + ucs_eh.c + ucs_encoder.c + ucs_epm.c + ucs_exc.c + ucs_factory.c + ucs_fsm.c + ucs_gpio.c + ucs_i2c.c + ucs_inic.c + ucs_inic_res.c + ucs_jobs.c + ucs_lldpool.c + ucs_message.c + ucs_mgr.c + ucs_misc.c + ucs_net.c + ucs_nodedis.c + ucs_nodeobserver.c + ucs_nsm.c + ucs_obs.c + ucs_pmchannel.c + ucs_pmcmd.c + ucs_pmevent.c + ucs_pmfifo.c + ucs_pmfifos.c + ucs_pmp.c + ucs_pool.c + ucs_prog.c + ucs_rsm.c + ucs_rtm.c + ucs_scheduler.c + ucs_segmentation.c + ucs_smm.c + ucs_sys_diag.c + ucs_telqueue.c + ucs_timer.c + ucs_transceiver.c + ucs_xrm.c + ucs_xrm_res.c + ucs_xrmpool.c + + @@ -141,7 +199,8 @@ - + + true @@ -214,12 +273,12 @@ - ../../../opt/include /usr/include/json-c + ../../../opt/include + /usr/include/p11-kit-1 ucs2-interface - ucs2-lib/inc - ucs2-lib/cfg - ucs2-lib/src/ucs-xml + ucs2-lib/unicens/inc + ucs2-lib/cfg_agl ucs2-vol/inc ucs2-vol/cfg ucs2-vol/src/ucs-xml @@ -228,6 +287,8 @@ CONTROL_CDEV_RX="/dev/inic-usb-crx" CONTROL_CDEV_TX="/dev/inic-usb-ctx" + NDEBUG + UCS2_CFG_PATH="/etc/default/ucs:./data" _REENTRANT _THREAD_SAFE @@ -251,29 +312,43 @@ + + + + /usr/include/p11-kit-1 + ucs2-lib/unicens/inc + ucs2-lib/cfg_agl + build/ucs2-lib + + + UCS2_CFG_PATH="/etc/default/ucs:./data" + + + - ../../../opt/include /usr/include/json-c + ../../../opt/include + /usr/include/p11-kit-1 ucs2-vol/inc ucs2-vol/cfg ucs2-vol/src/ucs-xml - ucs2-lib/inc - ucs2-lib/cfg - ucs2-lib/src/ucs-xml + ucs2-lib/unicens/inc + ucs2-lib/cfg_agl build/ucs2-vol/src CONTROL_CDEV_RX="/dev/inic-usb-crx" CONTROL_CDEV_TX="/dev/inic-usb-ctx" + UCS2_CFG_PATH="/etc/default/ucs:./data" _REENTRANT _THREAD_SAFE - + /usr/include/json-c ../../../opt/include @@ -286,10 +361,13 @@ ucs2-vol/src/ucs-xml build/ucs2-afb + + UCS2_CFG_PATH="/etc/default/ucs:./data" + - + /usr/include/json-c ../../../opt/include @@ -302,6 +380,9 @@ ucs2-vol/src/ucs-xml build/ucs2-afb + + UCS2_CFG_PATH="/etc/default/ucs:./data" + @@ -321,19 +402,26 @@ - + + + + + - + - + - + @@ -548,6 +636,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ucs2-afb/ucs_apidef.h b/ucs2-afb/ucs_apidef.h index c8ce266..c23f066 100644 --- a/ucs2-afb/ucs_apidef.h +++ b/ucs2-afb/ucs_apidef.h @@ -24,19 +24,23 @@ static const char _afb_description_v2_UNICENS[] = "or\":{\"permission\":\"urn:AGL:permission:UNICENS:public:monitor\"}},\"r" "esponses\":{\"200\":{\"description\":\"A complex object array response\"" ",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/" - "schemas/afb-reply\"}}}}}},\"paths\":{\"/configure\":{\"description\":\"c" - "onfigure Unicens2 lib from NetworkConfig.XML.\",\"get\":{\"x-permissions" - "\":{\"$ref\":\"#/components/x-permissions/config\"},\"parameters\":[{\"i" - "n\":\"query\",\"name\":\"filename\",\"required\":true,\"schema\":{\"type" - "\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/respons" - "es/200\"}}}},\"/volume\":{\"description\":\"Set Master Volume.\",\"get\"" - ":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"" - "parameters\":[{\"in\":\"query\",\"name\":\"value\",\"required\":true,\"s" - "chema\":{\"type\":\"integer\"}}],\"responses\":{\"200\":{\"$ref\":\"#/co" - "mponents/responses/200\"}}}},\"/monitor\":{\"description\":\"Subscribe t" - "o Unicens Event.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x" - "-permissions/monitor\"},\"responses\":{\"200\":{\"$ref\":\"#/components/" - "responses/200\"}}}}}}" + "schemas/afb-reply\"}}}}}},\"paths\":{\"/listconfig\":{\"description\":\"" + "List Config Files\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/" + "x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\"name\":\"cfg" + "path\",\"required\":false,\"schema\":{\"type\":\"string\"}}],\"responses" + "\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/initialise\"" + ":{\"description\":\"configure Unicens2 lib from NetworkConfig.XML.\",\"g" + "et\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/config\"}" + ",\"parameters\":[{\"in\":\"query\",\"name\":\"filename\",\"required\":tr" + "ue,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"" + "#/components/responses/200\"}}}},\"/volume\":{\"description\":\"Set Mast" + "er Volume.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permi" + "ssions/monitor\"},\"parameters\":[{\"in\":\"query\",\"name\":\"value\",\"" + "required\":true,\"schema\":{\"type\":\"integer\"}}],\"responses\":{\"200" + "\":{\"$ref\":\"#/components/responses/200\"}}}},\"/monitor\":{\"descript" + "ion\":\"Subscribe to Unicens Event.\",\"get\":{\"x-permissions\":{\"$ref" + "\":\"#/components/x-permissions/monitor\"},\"responses\":{\"200\":{\"$re" + "f\":\"#/components/responses/200\"}}}}}}" ; static const struct afb_auth _afb_auths_v2_UNICENS[] = { @@ -44,14 +48,22 @@ static const struct afb_auth _afb_auths_v2_UNICENS[] = { { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" } }; - void ucs2_configure(struct afb_req req); + void ucs2_listconfig(struct afb_req req); + void ucs2_initialise(struct afb_req req); void ucs2_volume(struct afb_req req); void ucs2_monitor(struct afb_req req); static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = { { - .verb = "configure", - .callback = ucs2_configure, + .verb = "listconfig", + .callback = ucs2_listconfig, + .auth = &_afb_auths_v2_UNICENS[0], + .info = NULL, + .session = AFB_SESSION_NONE_V2 + }, + { + .verb = "initialise", + .callback = ucs2_initialise, .auth = &_afb_auths_v2_UNICENS[0], .info = NULL, .session = AFB_SESSION_NONE_V2 diff --git a/ucs2-afb/ucs_apidef.json b/ucs2-afb/ucs_apidef.json index 274ce73..c200f74 100644 --- a/ucs2-afb/ucs_apidef.json +++ b/ucs2-afb/ucs_apidef.json @@ -102,7 +102,26 @@ } }, "paths": { - "/configure": { + "/listconfig": { + "description": "List Config Files", + "get": { + "x-permissions": { + "$ref": "#/components/x-permissions/config" + }, + "parameters": [ + { + "in": "query", + "name": "cfgpath", + "required": false, + "schema": { "type": "string" } + } + ], + "responses": { + "200": {"$ref": "#/components/responses/200"} + } + } + }, + "/initialise": { "description": "configure Unicens2 lib from NetworkConfig.XML.", "get": { "x-permissions": { diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c index efb4928..1c318fa 100644 --- a/ucs2-afb/ucs_binding.c +++ b/ucs2-afb/ucs_binding.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "ucs_binding.h" #include "ucs_interface.h" @@ -379,7 +380,6 @@ STATIC int volSndCmd (struct afb_req request, struct json_object *commandJ, ucsC return 1; } - PUBLIC void ucs2_volume (struct afb_req request) { struct json_object *queryJ; int err; @@ -423,7 +423,7 @@ PUBLIC void ucs2_volume (struct afb_req request) { } -PUBLIC void ucs2_configure (struct afb_req request) { +PUBLIC void ucs2_initialise (struct afb_req request) { static UcsXmlVal_t *ucsConfig; static ucsContextT ucsContext; @@ -473,7 +473,59 @@ PUBLIC void ucs2_configure (struct afb_req request) { return; } + +// List Avaliable Configuration Files +PUBLIC void ucs2_listconfig (struct afb_req request) { + struct json_object *queryJ, *tmpJ, *responseJ; + DIR *dirHandle; + char *dirPath, *dirList; + int error=0; + + queryJ = afb_req_json(request); + if (queryJ && json_object_object_get_ex (queryJ, "cfgpath" , &tmpJ)) { + strdup (json_object_get_string(tmpJ)); + } else { + dirList = strdup (UCS2_CFG_PATH); + AFB_NOTICE ("fgpath:missing uses UCS2_CFG_PATH=%s", UCS2_CFG_PATH); + } + + responseJ = json_object_new_array(); + for (dirPath= strtok(dirList, ":"); dirPath && *dirPath; dirPath=strtok(NULL,":")) { + struct dirent *dirEnt; + + dirHandle = opendir (dirPath); + if (!dirHandle) { + AFB_NOTICE ("ucs2_listconfig dir=%s not readable", dirPath); + error++; + continue; + } + + AFB_NOTICE ("ucs2_listconfig scanning: %s", dirPath); + while ((dirEnt = readdir(dirHandle)) != NULL) { + // Unknown type is accepted to support dump filesystems + if (dirEnt->d_type == DT_REG || dirEnt->d_type == DT_UNKNOWN) { + struct json_object *pathJ = json_object_new_object(); + json_object_object_add(pathJ, "dirpath", json_object_new_string(dirPath)); + json_object_object_add(pathJ, "basename", json_object_new_string(dirEnt->d_name)); + json_object_array_add(responseJ, pathJ); + } + } + } + + free (dirList); + + if (!error) afb_req_success(request,responseJ,NULL); + else { + char info[40]; + snprintf (info, sizeof(info), "[%d] where not scanned", error); + afb_req_success(request,responseJ, info); + } + + return; +} + PUBLIC void ucs2_monitor (struct afb_req request) { afb_req_success(request,NULL,"UNICENS-to_be_done"); -} \ No newline at end of file +} + -- 2.16.6