| 740 | enum patch_operation { INVALID, ADD, REMOVE, REPLACE, MOVE, COPY, TEST }; |
| 741 | |
| 742 | static enum patch_operation decode_patch_operation(const cJSON * const patch, const cJSON_bool case_sensitive) |
| 743 | { |
| 744 | cJSON *operation = get_object_item(patch, "op", case_sensitive); |
| 745 | if (!cJSON_IsString(operation)) |
| 746 | { |
| 747 | return INVALID; |
| 748 | } |
| 749 | |
| 750 | if (strcmp(operation->valuestring, "add") == 0) |
| 751 | { |
| 752 | return ADD; |
| 753 | } |
| 754 | |
| 755 | if (strcmp(operation->valuestring, "remove") == 0) |
| 756 | { |
| 757 | return REMOVE; |
| 758 | } |
| 759 | |
| 760 | if (strcmp(operation->valuestring, "replace") == 0) |
| 761 | { |
| 762 | return REPLACE; |
| 763 | } |
| 764 | |
| 765 | if (strcmp(operation->valuestring, "move") == 0) |
| 766 | { |
| 767 | return MOVE; |
| 768 | } |
| 769 | |
| 770 | if (strcmp(operation->valuestring, "copy") == 0) |
| 771 | { |
| 772 | return COPY; |
| 773 | } |
| 774 | |
| 775 | if (strcmp(operation->valuestring, "test") == 0) |
| 776 | { |
| 777 | return TEST; |
| 778 | } |
| 779 | |
| 780 | return INVALID; |
| 781 | } |
| 782 | |
| 783 | /* overwrite and existing item with another one and free resources on the way */ |
| 784 | static void overwrite_item(cJSON * const root, const cJSON replacement) |
no test coverage detected
searching dependent graphs…