diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -15,6 +15,12 @@ return -1; \ } +#define JSON_GET_OPT_STRING(j, s) cJSON *const s = cJSON_GetObjectItem(j, #s); \ + if (s != NULL && !cJSON_IsString(s)) { \ + fprintf(stderr, #s " is no string\n"); \ + return -1; \ + } + #define JSON_GET_ARRAY(j, s) JSON_GET(j, s); \ if (!cJSON_IsArray(s)) { \ fprintf(stderr, #s " is no array\n"); \ @@ -28,13 +34,17 @@ process_layer(cJSON *json) { JSON_GET_STRING(json, type); JSON_GET_STRING(json, name); + JSON_GET_OPT_STRING(json, class); JSON_GET(json, opacity); JSON_GET(json, visible); cJSON *const parallaxx = cJSON_GetObjectItem(json, "parallaxx"); cJSON *const parallaxy = cJSON_GetObjectItem(json, "parallaxy"); - printf("{\"%s\",'%c',%f,%d,%f,%f,", + printf("{\"%s\",%c%s%c,'%c',%f,%d,%f,%f,", name->valuestring, + class ? '"' : 'N', + class ? class->valuestring : "UL", + class ? '"' : 'L', type->valuestring[0], opacity->valuedouble, cJSON_IsTrue(visible), |