| 1065 | } |
| 1066 | |
| 1067 | CJSON_PUBLIC(int) cJSONUtils_ApplyPatchesCaseSensitive(cJSON * const object, const cJSON * const patches) |
| 1068 | { |
| 1069 | const cJSON *current_patch = NULL; |
| 1070 | int status = 0; |
| 1071 | |
| 1072 | if (!cJSON_IsArray(patches)) |
| 1073 | { |
| 1074 | /* malformed patches. */ |
| 1075 | return 1; |
| 1076 | } |
| 1077 | |
| 1078 | if (patches != NULL) |
| 1079 | { |
| 1080 | current_patch = patches->child; |
| 1081 | } |
| 1082 | |
| 1083 | while (current_patch != NULL) |
| 1084 | { |
| 1085 | status = apply_patch(object, current_patch, true); |
| 1086 | if (status != 0) |
| 1087 | { |
| 1088 | return status; |
| 1089 | } |
| 1090 | current_patch = current_patch->next; |
| 1091 | } |
| 1092 | |
| 1093 | return 0; |
| 1094 | } |
| 1095 | |
| 1096 | static void compose_patch(cJSON * const patches, const unsigned char * const operation, const unsigned char * const path, const unsigned char *suffix, const cJSON * const value) |
| 1097 | { |
searching dependent graphs…