diff options
| author | 2009-11-10 23:37:43 +0100 | |
|---|---|---|
| committer | 2009-11-10 23:37:43 +0100 | |
| commit | ff536344bc04ab9ec3763968b82997d07312acd6 (patch) | |
| tree | 48aa02beef8c8a0dc686683f7a1294871149646f /src/plist.c | |
| parent | 51c24ae543bda324e4f16e17d189c8d8cd545fc1 (diff) | |
| download | libplist-ff536344bc04ab9ec3763968b82997d07312acd6.tar.gz libplist-ff536344bc04ab9ec3763968b82997d07312acd6.tar.bz2 | |
Remove deprecated functions from API.
Diffstat (limited to 'src/plist.c')
| -rw-r--r-- | src/plist.c | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/src/plist.c b/src/plist.c index 9628e38..eac7cc0 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -786,192 +786,3 @@ void plist_set_date_val(plist_t node, int32_t sec, int32_t usec) | |||
| 786 | plist_set_element_val(node, PLIST_DATE, &val, sizeof(GTimeVal)); | 786 | plist_set_element_val(node, PLIST_DATE, &val, sizeof(GTimeVal)); |
| 787 | } | 787 | } |
| 788 | 788 | ||
| 789 | //DEPRECATED API BELOW | ||
| 790 | |||
| 791 | |||
| 792 | static plist_t plist_add_sub_element(plist_t node, plist_type type, const void *value, uint64_t length) | ||
| 793 | { | ||
| 794 | //only structured types can have children | ||
| 795 | plist_type node_type = plist_get_node_type(node); | ||
| 796 | if (node_type == PLIST_DICT || node_type == PLIST_ARRAY) | ||
| 797 | { | ||
| 798 | //only structured types are allowed to have nulll value | ||
| 799 | if (value || (!value && (type == PLIST_DICT || type == PLIST_ARRAY))) | ||
| 800 | { | ||
| 801 | |||
| 802 | plist_t subnode = NULL; | ||
| 803 | |||
| 804 | //now handle value | ||
| 805 | plist_data_t data = plist_new_plist_data(); | ||
| 806 | data->type = type; | ||
| 807 | data->length = length; | ||
| 808 | |||
| 809 | switch (type) | ||
| 810 | { | ||
| 811 | case PLIST_BOOLEAN: | ||
| 812 | data->boolval = *((char *) value); | ||
| 813 | break; | ||
| 814 | case PLIST_UINT: | ||
| 815 | data->intval = *((uint64_t *) value); | ||
| 816 | break; | ||
| 817 | case PLIST_REAL: | ||
| 818 | data->realval = *((double *) value); | ||
| 819 | break; | ||
| 820 | case PLIST_KEY: | ||
| 821 | case PLIST_STRING: | ||
| 822 | data->strval = strdup((char *) value); | ||
| 823 | break; | ||
| 824 | case PLIST_DATA: | ||
| 825 | data->buff = (uint8_t *) malloc(length); | ||
| 826 | memcpy(data->buff, value, length); | ||
| 827 | break; | ||
| 828 | case PLIST_DATE: | ||
| 829 | data->timeval.tv_sec = ((GTimeVal *) value)->tv_sec; | ||
| 830 | data->timeval.tv_usec = ((GTimeVal *) value)->tv_usec; | ||
| 831 | break; | ||
| 832 | case PLIST_ARRAY: | ||
| 833 | case PLIST_DICT: | ||
| 834 | default: | ||
| 835 | break; | ||
| 836 | } | ||
| 837 | |||
| 838 | subnode = plist_new_node(data); | ||
| 839 | if (node) | ||
| 840 | g_node_append(node, subnode); | ||
| 841 | return subnode; | ||
| 842 | } | ||
| 843 | else | ||
| 844 | return NULL; | ||
| 845 | } | ||
| 846 | return NULL; | ||
| 847 | } | ||
| 848 | |||
| 849 | |||
| 850 | plist_t plist_get_first_child(plist_t node) | ||
| 851 | { | ||
| 852 | return (plist_t) g_node_first_child((GNode *) node); | ||
| 853 | } | ||
| 854 | |||
| 855 | plist_t plist_get_next_sibling(plist_t node) | ||
| 856 | { | ||
| 857 | return (plist_t) g_node_next_sibling((GNode *) node); | ||
| 858 | } | ||
| 859 | |||
| 860 | plist_t plist_get_prev_sibling(plist_t node) | ||
| 861 | { | ||
| 862 | return (plist_t) g_node_prev_sibling((GNode *) node); | ||
| 863 | } | ||
| 864 | |||
| 865 | plist_t plist_get_array_nth_el(plist_t node, uint32_t n) | ||
| 866 | { | ||
| 867 | plist_t ret = NULL; | ||
| 868 | if (node && PLIST_ARRAY == plist_get_node_type(node)) | ||
| 869 | { | ||
| 870 | uint32_t i = 0; | ||
| 871 | plist_t temp = plist_get_first_child(node); | ||
| 872 | |||
| 873 | while (i <= n && temp) | ||
| 874 | { | ||
| 875 | if (i == n) | ||
| 876 | ret = temp; | ||
| 877 | temp = plist_get_next_sibling(temp); | ||
| 878 | i++; | ||
| 879 | } | ||
| 880 | } | ||
| 881 | return ret; | ||
| 882 | } | ||
| 883 | |||
| 884 | plist_t plist_get_dict_el_from_key(plist_t node, const char *key) | ||
| 885 | { | ||
| 886 | plist_t ret = NULL; | ||
| 887 | if (node && PLIST_DICT == plist_get_node_type(node)) | ||
| 888 | { | ||
| 889 | |||
| 890 | plist_t key_node = plist_find_node_by_key(node, key); | ||
| 891 | ret = plist_get_next_sibling(key_node); | ||
| 892 | } | ||
| 893 | return ret; | ||
| 894 | } | ||
| 895 | |||
| 896 | void plist_add_sub_node(plist_t node, plist_t subnode) | ||
| 897 | { | ||
| 898 | if (node && subnode) | ||
| 899 | { | ||
| 900 | plist_type type = plist_get_node_type(node); | ||
| 901 | if (type == PLIST_DICT || type == PLIST_ARRAY) | ||
| 902 | g_node_append(node, subnode); | ||
| 903 | } | ||
| 904 | } | ||
| 905 | |||
| 906 | void plist_add_sub_key_el(plist_t node, const char *val) | ||
| 907 | { | ||
| 908 | plist_add_sub_element(node, PLIST_KEY, val, strlen(val)); | ||
| 909 | } | ||
| 910 | |||
| 911 | void plist_add_sub_string_el(plist_t node, const char *val) | ||
| 912 | { | ||
| 913 | plist_add_sub_element(node, PLIST_STRING, val, strlen(val)); | ||
| 914 | } | ||
| 915 | |||
| 916 | void plist_add_sub_bool_el(plist_t node, uint8_t val) | ||
| 917 | { | ||
| 918 | plist_add_sub_element(node, PLIST_BOOLEAN, &val, sizeof(uint8_t)); | ||
| 919 | } | ||
| 920 | |||
| 921 | void plist_add_sub_uint_el(plist_t node, uint64_t val) | ||
| 922 | { | ||
| 923 | plist_add_sub_element(node, PLIST_UINT, &val, sizeof(uint64_t)); | ||
| 924 | } | ||
| 925 | |||
| 926 | void plist_add_sub_real_el(plist_t node, double val) | ||
| 927 | { | ||
| 928 | plist_add_sub_element(node, PLIST_REAL, &val, sizeof(double)); | ||
| 929 | } | ||
| 930 | |||
| 931 | void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length) | ||
| 932 | { | ||
| 933 | plist_add_sub_element(node, PLIST_DATA, val, length); | ||
| 934 | } | ||
| 935 | |||
| 936 | void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec) | ||
| 937 | { | ||
| 938 | GTimeVal val = { sec, usec }; | ||
| 939 | plist_add_sub_element(node, PLIST_DATE, &val, sizeof(GTimeVal)); | ||
| 940 | } | ||
| 941 | |||
| 942 | static plist_t plist_find_node(plist_t plist, plist_type type, const void *value, uint64_t length) | ||
| 943 | { | ||
| 944 | plist_t current = NULL; | ||
| 945 | |||
| 946 | if (!plist) | ||
| 947 | return NULL; | ||
| 948 | |||
| 949 | for (current = (plist_t)g_node_first_child(plist); current; current = (plist_t)g_node_next_sibling(current)) | ||
| 950 | { | ||
| 951 | |||
| 952 | plist_data_t data = plist_get_data(current); | ||
| 953 | |||
| 954 | if (data->type == type && data->length == length && compare_node_value(type, data, value, length)) | ||
| 955 | { | ||
| 956 | return current; | ||
| 957 | } | ||
| 958 | if (data->type == PLIST_DICT || data->type == PLIST_ARRAY) | ||
| 959 | { | ||
| 960 | plist_t sub = plist_find_node(current, type, value, length); | ||
| 961 | if (sub) | ||
| 962 | return sub; | ||
| 963 | } | ||
| 964 | } | ||
| 965 | return NULL; | ||
| 966 | } | ||
| 967 | |||
| 968 | plist_t plist_find_node_by_key(plist_t plist, const char *value) | ||
| 969 | { | ||
| 970 | return plist_find_node(plist, PLIST_KEY, value, strlen(value)); | ||
| 971 | } | ||
| 972 | |||
| 973 | plist_t plist_find_node_by_string(plist_t plist, const char *value) | ||
| 974 | { | ||
| 975 | return plist_find_node(plist, PLIST_STRING, value, strlen(value)); | ||
| 976 | } | ||
| 977 | |||
