| 759 | }; |
| 760 | |
| 761 | static enum patch_operation decode_patch_operation(const cJSON *const patch, const cJSON_bool case_sensitive) |
| 762 | { |
| 763 | cJSON *operation = get_object_item(patch, "op", case_sensitive); |
| 764 | if (!cJSON_IsString(operation)) |
| 765 | { |
| 766 | return INVALID; |
| 767 | } |
| 768 | |
| 769 | if (strcmp(operation->valuestring, "add") == 0) |
| 770 | { |
| 771 | return ADD; |
| 772 | } |
| 773 | |
| 774 | if (strcmp(operation->valuestring, "remove") == 0) |
| 775 | { |
| 776 | return REMOVE; |
| 777 | } |
| 778 | |
| 779 | if (strcmp(operation->valuestring, "replace") == 0) |
| 780 | { |
| 781 | return REPLACE; |
| 782 | } |
| 783 | |
| 784 | if (strcmp(operation->valuestring, "move") == 0) |
| 785 | { |
| 786 | return MOVE; |
| 787 | } |
| 788 | |
| 789 | if (strcmp(operation->valuestring, "copy") == 0) |
| 790 | { |
| 791 | return COPY; |
| 792 | } |
| 793 | |
| 794 | if (strcmp(operation->valuestring, "test") == 0) |
| 795 | { |
| 796 | return TEST; |
| 797 | } |
| 798 | |
| 799 | return INVALID; |
| 800 | } |
| 801 | |
| 802 | /* overwrite and existing item with another one and free resources on the way */ |
| 803 | static void overwrite_item(cJSON *const root, const cJSON replacement) |
no test coverage detected