Lines Matching refs:root
43 static int ber_dump_element(struct ber *ber, struct ber_element *root);
44 static void ber_dump_header(struct ber *ber, struct ber_element *root);
762 ber_write_elements(struct ber *ber, struct ber_element *root) in ber_write_elements() argument
767 len = ber_calc_len(root); in ber_write_elements()
783 if (ber_dump_element(ber, root) == -1) in ber_write_elements()
809 struct ber_element *root = elm; in ber_read_elements() local
811 if (root == NULL) { in ber_read_elements()
812 if ((root = ber_get_element(0)) == NULL) in ber_read_elements()
816 DPRINTF("read ber elements, root %p\n", root); in ber_read_elements()
818 if (ber_read_element(ber, root) == -1) { in ber_read_elements()
821 ber_free_elements(root); in ber_read_elements()
825 return root; in ber_read_elements()
829 ber_free_elements(struct ber_element *root) in ber_free_elements() argument
831 if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE || in ber_free_elements()
832 root->be_encoding == BER_TYPE_SET)) in ber_free_elements()
833 ber_free_elements(root->be_sub); in ber_free_elements()
834 if (root->be_next) in ber_free_elements()
835 ber_free_elements(root->be_next); in ber_free_elements()
836 if (root->be_free && (root->be_encoding == BER_TYPE_OCTETSTRING || in ber_free_elements()
837 root->be_encoding == BER_TYPE_BITSTRING || in ber_free_elements()
838 root->be_encoding == BER_TYPE_OBJECT)) in ber_free_elements()
839 free(root->be_val); in ber_free_elements()
840 free(root); in ber_free_elements()
844 ber_calc_len(struct ber_element *root) in ber_calc_len() argument
851 if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE || in ber_calc_len()
852 root->be_encoding == BER_TYPE_SET)) in ber_calc_len()
853 root->be_len = ber_calc_len(root->be_sub); in ber_calc_len()
856 if (root->be_type > BER_TYPE_SINGLE_MAX) in ber_calc_len()
857 for (t = root->be_type; t > 0; t >>= 7) in ber_calc_len()
859 if (root->be_len >= BER_TAG_MORE) in ber_calc_len()
860 for (s = root->be_len; s > 0; s >>= 8) in ber_calc_len()
864 if (root->be_next) in ber_calc_len()
865 size += ber_calc_len(root->be_next); in ber_calc_len()
868 if (root->be_type == BER_TYPE_EOC && root->be_len == 0) in ber_calc_len()
871 return (root->be_len + size); in ber_calc_len()
879 ber_dump_element(struct ber *ber, struct ber_element *root) in ber_dump_element() argument
885 ber_dump_header(ber, root); in ber_dump_element()
887 switch (root->be_encoding) { in ber_dump_element()
891 l = (unsigned long long)root->be_numeric; in ber_dump_element()
892 for (i = root->be_len; i > 0; i--) { in ber_dump_element()
901 ber_write(ber, root->be_val, root->be_len); in ber_dump_element()
908 if (root->be_sub && ber_dump_element(ber, root->be_sub) == -1) in ber_dump_element()
913 if (root->be_next == NULL) in ber_dump_element()
915 return ber_dump_element(ber, root->be_next); in ber_dump_element()
919 ber_dump_header(struct ber *ber, struct ber_element *root) in ber_dump_header() argument
927 if (root->be_type <= BER_TYPE_SINGLE_MAX) { in ber_dump_header()
928 id = root->be_type | (root->be_class << BER_CLASS_SHIFT); in ber_dump_header()
929 if (root->be_encoding == BER_TYPE_SEQUENCE || in ber_dump_header()
930 root->be_encoding == BER_TYPE_SET) in ber_dump_header()
935 id = BER_TAG_MASK | (root->be_class << BER_CLASS_SHIFT); in ber_dump_header()
936 if (root->be_encoding == BER_TYPE_SEQUENCE || in ber_dump_header()
937 root->be_encoding == BER_TYPE_SET) in ber_dump_header()
942 for (t = 0, type = root->be_type; type > 0; type >>= 7) in ber_dump_header()
952 if (root->be_len < BER_TAG_MORE) { in ber_dump_header()
954 ber_putc(ber, root->be_len); in ber_dump_header()
956 for (t = 0, size = root->be_len; size > 0; size >>= 8) in ber_dump_header()