X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=ucs2-afb%2Fucs_binding.c;h=1c318fa17bd60b55993274ac66968055c815c025;hb=a3cecd20f812c3fc71141a487443568c861c160a;hp=efb492825bbc367b8182d55b3fe202216bf4f86f;hpb=01a3f74a836d769f7af9bb2dc4fa631b07b881fb;p=apps%2Fagl-service-unicens.git 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 +} +