MCPcopy Create free account
hub / github.com/Netis/cloud-probe / decode_patch_operation

Function decode_patch_operation

cpworker/src/cJSON/cJSON_Utils.c:761–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759};
760
761static 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 */
803static void overwrite_item(cJSON *const root, const cJSON replacement)

Callers 1

apply_patchFunction · 0.85

Calls 2

cJSON_IsStringFunction · 0.85
get_object_itemFunction · 0.70

Tested by

no test coverage detected