From ef4a54c6feceea12f598725ac6e5f1e325a82e45 Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Wed, 23 May 2018 20:08:25 +0200 Subject: Handle more metadata in the controller. Add fields that will be searched for during controller metadata section parsing. These fields are optional, so they will be copied in CtlConfigT if they are present. Otherwise, no error will be raised. The added fields are : - 'author' which should contain the author name of the configuration file. - 'date' which should contain the date of the configuration file last modification. Change-Id: Iab480533d85c4a52ea5f6a70fb6f9b8d0b866af4 Signed-off-by: Jonathan Aillet --- ctl-lib/ctl-config.c | 8 +++++--- ctl-lib/ctl-config.h | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'ctl-lib') diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c index cd3d507..4b9f2f7 100644 --- a/ctl-lib/ctl-config.c +++ b/ctl-lib/ctl-config.c @@ -159,14 +159,16 @@ CtlConfigT *CtlLoadMetaData(AFB_ApiT apiHandle, const char* filepath) { int done = json_object_object_get_ex(ctlConfigJ, "metadata", &metadataJ); if (done) { ctlHandle = calloc(1, sizeof (CtlConfigT)); - err = wrap_json_unpack(metadataJ, "{ss,ss,ss,s?s,s?o !}", + err = wrap_json_unpack(metadataJ, "{ss,ss,ss,s?s,s?o,s?s,s?s !}", "uid", &ctlHandle->uid, "version", &ctlHandle->version, "api", &ctlHandle->api, "info", &ctlHandle->info, - "require", &ctlHandle->requireJ); + "require", &ctlHandle->requireJ, + "author", &ctlHandle->author, + "date", &ctlHandle->date); if (err) { - AFB_ApiError(apiHandle, "CTL-LOAD-CONFIG:METADATA Missing something uid|api|version|[info]|[require] in:\n-- %s", json_object_get_string(metadataJ)); + AFB_ApiError(apiHandle, "CTL-LOAD-CONFIG:METADATA Missing something uid|api|version|[info]|[require]|[author]|[date] in:\n-- %s", json_object_get_string(metadataJ)); free(ctlHandle); return NULL; } diff --git a/ctl-lib/ctl-config.h b/ctl-lib/ctl-config.h index 7864714..2249dad 100644 --- a/ctl-lib/ctl-config.h +++ b/ctl-lib/ctl-config.h @@ -64,10 +64,12 @@ typedef struct ConfigSectionS { } CtlSectionT; typedef struct { - const char* api; - const char* uid; + const char *api; + const char *uid; const char *info; const char *version; + const char *author; + const char *date; json_object *configJ; json_object *requireJ; CtlSectionT *sections; -- cgit 1.2.3-korg