summaryrefslogtreecommitdiffstats
path: root/include/plist/plist.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/plist/plist.h')
-rw-r--r--include/plist/plist.h183
1 files changed, 183 insertions, 0 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h
index 29b1fce..ab91612 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -762,6 +762,189 @@ extern "C"
762 #define PLIST_IS_KEY(__plist) _PLIST_IS_TYPE(__plist, KEY) 762 #define PLIST_IS_KEY(__plist) _PLIST_IS_TYPE(__plist, KEY)
763 #define PLIST_IS_UID(__plist) _PLIST_IS_TYPE(__plist, UID) 763 #define PLIST_IS_UID(__plist) _PLIST_IS_TYPE(__plist, UID)
764 764
765 /**
766 * Helper function to check the value of a PLIST_BOOL node.
767 *
768 * @param boolnode node of type PLIST_BOOL
769 * @return 1 if the boolean node has a value of TRUE, 0 if FALSE,
770 * or -1 if the node is not of type PLIST_BOOL
771 */
772 int plist_bool_val_is_true(plist_t boolnode);
773
774 /**
775 * Helper function to compare the value of a PLIST_UINT node against
776 * a given value.
777 *
778 * @param uintnode node of type PLIST_UINT
779 * @param cmpval value to compare against
780 * @return 0 if the node's value and cmpval are equal,
781 * 1 if the node's value is greater than cmpval,
782 * or -1 if the node's value is less than cmpval.
783 */
784 int plist_uint_val_compare(plist_t uintnode, uint64_t cmpval);
785
786 /**
787 * Helper function to compare the value of a PLIST_UID node against
788 * a given value.
789 *
790 * @param uidnode node of type PLIST_UID
791 * @param cmpval value to compare against
792 * @return 0 if the node's value and cmpval are equal,
793 * 1 if the node's value is greater than cmpval,
794 * or -1 if the node's value is less than cmpval.
795 */
796 int plist_uid_val_compare(plist_t uidnode, uint64_t cmpval);
797
798 /**
799 * Helper function to compare the value of a PLIST_REAL node against
800 * a given value.
801 *
802 * @note WARNING: Comparing floating point values can give inaccurate
803 * results because of the nature of floating point values on computer
804 * systems. While this function is designed to be as accurate as
805 * possible, please don't rely on it too much.
806 *
807 * @param realnode node of type PLIST_REAL
808 * @param cmpval value to compare against
809 * @return 0 if the node's value and cmpval are (almost) equal,
810 * 1 if the node's value is greater than cmpval,
811 * or -1 if the node's value is less than cmpval.
812 */
813 int plist_real_val_compare(plist_t realnode, double cmpval);
814
815 /**
816 * Helper function to compare the value of a PLIST_DATE node against
817 * a given set of seconds and fraction of a second since epoch.
818 *
819 * @param datenode node of type PLIST_DATE
820 * @param cmpsec number of seconds since epoch to compare against
821 * @param cmpusec fraction of a second in microseconds to compare against
822 * @return 0 if the node's date is equal to the supplied values,
823 * 1 if the node's date is greater than the supplied values,
824 * or -1 if the node's date is less than the supplied values.
825 */
826 int plist_date_val_compare(plist_t datenode, int32_t cmpsec, int32_t cmpusec);
827
828 /**
829 * Helper function to compare the value of a PLIST_STRING node against
830 * a given value.
831 * This function basically behaves like strcmp.
832 *
833 * @param strnode node of type PLIST_STRING
834 * @param cmpval value to compare against
835 * @return 0 if the node's value and cmpval are equal,
836 * > 0 if the node's value is lexicographically greater than cmpval,
837 * or < 0 if the node's value is lexicographically less than cmpval.
838 */
839 int plist_string_val_compare(plist_t strnode, const char* cmpval);
840
841 /**
842 * Helper function to compare the value of a PLIST_STRING node against
843 * a given value, while not comparing more than n characters.
844 * This function basically behaves like strncmp.
845 *
846 * @param strnode node of type PLIST_STRING
847 * @param cmpval value to compare against
848 * @param n maximum number of characters to compare
849 * @return 0 if the node's value and cmpval are equal,
850 * > 0 if the node's value is lexicographically greater than cmpval,
851 * or < 0 if the node's value is lexicographically less than cmpval.
852 */
853 int plist_string_val_compare_with_size(plist_t strnode, const char* cmpval, size_t n);
854
855 /**
856 * Helper function to match a given substring in the value of a
857 * PLIST_STRING node.
858 *
859 * @param strnode node of type PLIST_STRING
860 * @param substr value to match
861 * @return 1 if the node's value contains the given substring,
862 * or 0 if not.
863 */
864 int plist_string_val_contains(plist_t strnode, const char* substr);
865
866 /**
867 * Helper function to compare the value of a PLIST_KEY node against
868 * a given value.
869 * This function basically behaves like strcmp.
870 *
871 * @param keynode node of type PLIST_KEY
872 * @param cmpval value to compare against
873 * @return 0 if the node's value and cmpval are equal,
874 * > 0 if the node's value is lexicographically greater than cmpval,
875 * or < 0 if the node's value is lexicographically less than cmpval.
876 */
877 int plist_key_val_compare(plist_t keynode, const char* cmpval);
878
879 /**
880 * Helper function to compare the value of a PLIST_KEY node against
881 * a given value, while not comparing more than n characters.
882 * This function basically behaves like strncmp.
883 *
884 * @param keynode node of type PLIST_KEY
885 * @param cmpval value to compare against
886 * @param n maximum number of characters to compare
887 * @return 0 if the node's value and cmpval are equal,
888 * > 0 if the node's value is lexicographically greater than cmpval,
889 * or < 0 if the node's value is lexicographically less than cmpval.
890 */
891 int plist_key_val_compare_with_size(plist_t keynode, const char* cmpval, size_t n);
892
893 /**
894 * Helper function to match a given substring in the value of a
895 * PLIST_KEY node.
896 *
897 * @param keynode node of type PLIST_KEY
898 * @param substr value to match
899 * @return 1 if the node's value contains the given substring,
900 * or 0 if not.
901 */
902 int plist_key_val_contains(plist_t keynode, const char* substr);
903
904 /**
905 * Helper function to compare the data of a PLIST_DATA node against
906 * a given blob and size.
907 * This function basically behaves like memcmp after making sure the
908 * size of the node's data value is equal to the size of cmpval (n),
909 * making this a "full match" comparison.
910 *
911 * @param datanode node of type PLIST_DATA
912 * @param cmpval data blob to compare against
913 * @param n size of data blob passed in cmpval
914 * @return 0 if the node's data blob and cmpval are equal,
915 * > 0 if the node's value is lexicographically greater than cmpval,
916 * or < 0 if the node's value is lexicographically less than cmpval.
917 */
918 int plist_data_val_compare(plist_t datanode, const uint8_t* cmpval, size_t n);
919
920 /**
921 * Helper function to compare the data of a PLIST_DATA node against
922 * a given blob and size, while no more than n bytes are compared.
923 * This function basically behaves like memcmp after making sure the
924 * size of the node's data value is at least n, making this a
925 * "starts with" comparison.
926 *
927 * @param datanode node of type PLIST_DATA
928 * @param cmpval data blob to compare against
929 * @param n size of data blob passed in cmpval
930 * @return 0 if the node's value and cmpval are equal,
931 * > 0 if the node's value is lexicographically greater than cmpval,
932 * or < 0 if the node's value is lexicographically less than cmpval.
933 */
934 int plist_data_val_compare_with_size(plist_t datanode, const uint8_t* cmpval, size_t n);
935
936 /**
937 * Helper function to match a given data blob within the value of a
938 * PLIST_DATA node.
939 *
940 * @param datanode node of type PLIST_KEY
941 * @param cmpval data blob to match
942 * @param n size of data blob passed in cmpval
943 * @return 1 if the node's value contains the given data blob
944 * or 0 if not.
945 */
946 int plist_data_val_contains(plist_t datanode, const uint8_t* cmpval, size_t n);
947
765 /*@}*/ 948 /*@}*/
766 949
767#ifdef __cplusplus 950#ifdef __cplusplus