diff --git a/include/loader.h b/include/loader.h index fd734ca..d5dc82f 100644 --- a/include/loader.h +++ b/include/loader.h @@ -4,11 +4,11 @@ #include "cJSON.h" #include "config.h" -enum SpecJsonError { +enum SpecParseError { // The `spec.json` file exists but cannot be open. - SJE_JSON_CANNOT_OPEN = 1, + SPE_PARSE_CANNOT_OPEN = 1, // The JSON of the corresponding file is not syntactically valid JSON. - SJE_JSON_INVALID, + SPE_PARSE_INVALID, }; /* @@ -17,9 +17,9 @@ Reads in the `spec.json` file relative to the paths of the provided @Config. A spec directory does not necessarily contain a `spec.json` file. If this file cannot be found, the @parsed pointer is set to NULL with a success return code. -@return: 0 on success and a @SpecJsonError otherwise. +@return: 0 on success and a @SpecParseError otherwise. */ -enum SpecJsonError +enum SpecParseError read_spec_json(const struct Config *const config, cJSON **parsed); #endif /* _BOOTSTRAP_LOADER_H */ diff --git a/main.c b/main.c index 12e37be..99aef14 100644 --- a/main.c +++ b/main.c @@ -43,11 +43,11 @@ int main(int argc, char **argv) { cJSON *parsed = 0; switch (read_spec_json(config, &parsed)) { - case SJE_JSON_CANNOT_OPEN: + case SPE_PARSE_CANNOT_OPEN: fprintf(stderr, "Found `spec.json` but could not open."); retval = EXIT_FAILURE; goto config_cleanup; - case SJE_JSON_INVALID: + case SPE_PARSE_INVALID: fprintf(stderr, "`spec.json` does not conform to bootstrap format."); retval = EXIT_FAILURE; goto config_cleanup; diff --git a/src/loader.c b/src/loader.c index 883267c..5e71481 100644 --- a/src/loader.c +++ b/src/loader.c @@ -27,13 +27,13 @@ static int find_spec_json(const struct Config *const config, FILE **handle) { return retval; } -enum SpecJsonError +enum SpecParseError read_spec_json(const struct Config *const config, cJSON **parsed) { FILE *handle = 0; int retval = find_spec_json(config, &handle); if (retval != 0) { - return SJE_JSON_CANNOT_OPEN; + return SPE_PARSE_CANNOT_OPEN; } // The `spec.json` file does not exist. @@ -57,7 +57,7 @@ read_spec_json(const struct Config *const config, cJSON **parsed) { // Can use `cJSON_GetErrorPtr()` to get the actual error message. if (!*parsed) { - return SJE_JSON_INVALID; + return SPE_PARSE_INVALID; } return 0; diff --git a/test/test_loader.h b/test/test_loader.h index b9b1283..5300c2c 100644 --- a/test/test_loader.h +++ b/test/test_loader.h @@ -26,7 +26,7 @@ static void test_read_spec_json_missing() { }; cJSON *parsed = 0; - enum SpecJsonError retval = read_spec_json(&config, &parsed); + enum SpecParseError retval = read_spec_json(&config, &parsed); sput_fail_unless(retval == 0, "no spec.json, success"); sput_fail_unless(parsed == 0, "no spec.json, no parsed"); @@ -47,7 +47,7 @@ static void test_read_spec_json_minimal() { }; cJSON *parsed = 0; - enum SpecJsonError retval = read_spec_json(&config, &parsed); + enum SpecParseError retval = read_spec_json(&config, &parsed); sput_fail_unless(retval == 0, "minimal spec.json, success"); sput_fail_unless(parsed != 0, "minimal spec.json, parsed"); @@ -68,8 +68,8 @@ static void test_read_spec_json_invalid() { }; cJSON *parsed = 0; - enum SpecJsonError retval = read_spec_json(&config, &parsed); - sput_fail_unless(retval == SJE_JSON_INVALID, "invalid spec.json, JSON_INVALID"); + enum SpecParseError retval = read_spec_json(&config, &parsed); + sput_fail_unless(retval == SPE_PARSE_INVALID, "invalid spec.json, JSON_INVALID"); sput_fail_unless(parsed == 0, "invalid spec.json, not parsed"); free(cwd);