+ cJSON_Delete(jsonConfig);
+
+ return ves_ip;
+}
+
+/*
+ * Dynamically allocated memory;
+ * Caller needs to free the memory after it uses the value.
+ *
+*/
+char* getVesUsernameFromConfigJson(void)
+{
+ char *stringConfig = readConfigFileInString();
+
+ if (stringConfig == NULL)
+ {
+ printf("Could not read JSON configuration file in string.");
+ return 0;
+ }
+
+ cJSON *jsonConfig = cJSON_Parse(stringConfig);
+ if (jsonConfig == NULL)
+ {
+ free(stringConfig);
+ const char *error_ptr = cJSON_GetErrorPtr();
+ if (error_ptr != NULL)
+ {
+ fprintf(stderr, "Could not parse JSON configuration! Error before: %s\n", error_ptr);
+ }
+ return NULL;
+ }
+ //we don't need the string anymore
+ free(stringConfig);
+ stringConfig = NULL;
+
+ cJSON *vesDetails = cJSON_GetObjectItemCaseSensitive(jsonConfig, "ves-endpoint-details");
+ if (!cJSON_IsObject(vesDetails))
+ {
+ printf("Configuration JSON is not as expected: ves-endpoint-details is not an object");
+ cJSON_Delete(jsonConfig);
+ return NULL;
+ }
+
+ cJSON *vesUsername = cJSON_GetObjectItemCaseSensitive(vesDetails, "ves-endpoint-username");
+ if (!cJSON_IsString(vesUsername))
+ {
+ printf("Configuration JSON is not as expected: ves-endpoint-username is not an object");
+ cJSON_Delete(jsonConfig);
+ return NULL;
+ }
+
+ char *ves_username = strdup(cJSON_GetStringValue(vesUsername));
+
+ cJSON_Delete(jsonConfig);
+
+ return ves_username;
+}
+
+/*
+ * Dynamically allocated memory;
+ * Caller needs to free the memory after it uses the value.
+ *
+*/
+char* getVesPasswordFromConfigJson(void)
+{
+ char *stringConfig = readConfigFileInString();
+
+ if (stringConfig == NULL)
+ {
+ printf("Could not read JSON configuration file in string.");
+ return 0;
+ }
+
+ cJSON *jsonConfig = cJSON_Parse(stringConfig);
+ if (jsonConfig == NULL)
+ {
+ free(stringConfig);
+ const char *error_ptr = cJSON_GetErrorPtr();
+ if (error_ptr != NULL)
+ {
+ fprintf(stderr, "Could not parse JSON configuration! Error before: %s\n", error_ptr);
+ }
+ return NULL;
+ }
+ //we don't need the string anymore
+ free(stringConfig);
+ stringConfig = NULL;
+
+ cJSON *vesDetails = cJSON_GetObjectItemCaseSensitive(jsonConfig, "ves-endpoint-details");
+ if (!cJSON_IsObject(vesDetails))
+ {
+ printf("Configuration JSON is not as expected: ves-endpoint-details is not an object");
+ cJSON_Delete(jsonConfig);
+ return NULL;
+ }
+
+ cJSON *vesPassword = cJSON_GetObjectItemCaseSensitive(vesDetails, "ves-endpoint-password");
+ if (!cJSON_IsString(vesPassword))
+ {
+ printf("Configuration JSON is not as expected: ves-endpoint-password is not an object");
+ cJSON_Delete(jsonConfig);
+ return NULL;
+ }
+
+ char *ves_password = strdup(cJSON_GetStringValue(vesPassword));
+
+ cJSON_Delete(jsonConfig);