X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fo1-interface.git;a=blobdiff_plain;f=ntsimulator%2Fsrc%2Futils%2Futils.c;h=15bb4260cd3d095049546ea52a2e6928515e0f15;hp=7d1d2a0cbda1efb27af7336efe738dea8efcd4d6;hb=610985b805c2b5c730bbc247ccbf76dd624792d0;hpb=a19f893a70c03dee9312e1208301d079409d84ac diff --git a/ntsimulator/src/utils/utils.c b/ntsimulator/src/utils/utils.c index 7d1d2a0..15bb426 100644 --- a/ntsimulator/src/utils/utils.c +++ b/ntsimulator/src/utils/utils.c @@ -452,7 +452,7 @@ void writeConfigFile(char *config) } } -int getFaultNotificationDelayPeriodFromConfigJson(void) +int getFaultNotificationDelayPeriodFromConfigJson(int *period_array, int *count) { char *stringConfig = readConfigFileInString(); int notificationDelay = 0; @@ -487,18 +487,34 @@ int getFaultNotificationDelayPeriodFromConfigJson(void) } cJSON *faultNotifDelay = cJSON_GetObjectItemCaseSensitive(notifConfig, "fault-notification-delay-period"); - if (!cJSON_IsNumber(faultNotifDelay)) + if (!cJSON_IsArray(faultNotifDelay)) { - printf("Configuration JSON is not as expected: fault-notification-delay-period is not a number"); + printf("Configuration JSON is not as expected: fault-notification-delay-period is not an array."); cJSON_Delete(jsonConfig); return SR_ERR_OPERATION_FAILED; } - notificationDelay = (int)(faultNotifDelay->valuedouble); + cJSON *iterator = NULL; + *count = 0; + int i = 0; + + cJSON_ArrayForEach(iterator, faultNotifDelay) + { + if (cJSON_IsNumber(iterator)) + { + period_array[i++] = iterator->valueint; + } + else + { + printf("Invalid number in array!"); + } + } + + *count = i; cJSON_Delete(jsonConfig); - return notificationDelay; + return SR_ERR_OK; } int getVesHeartbeatPeriodFromConfigJson(void)