OLD | NEW |
1 /* crypto/store/str_lib.c -*- mode:C; c-file-style: "eay" -*- */ | 1 /* crypto/store/str_lib.c -*- mode:C; c-file-style: "eay" -*- */ |
2 /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | 2 /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
3 * project 2003. | 3 * project 2003. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 2003 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2003 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 | 1663 |
1664 if (context && context->attributes) | 1664 if (context && context->attributes) |
1665 { | 1665 { |
1666 return context->attributes->code == STORE_ATTR_END; | 1666 return context->attributes->code == STORE_ATTR_END; |
1667 } | 1667 } |
1668 STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); | 1668 STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER); |
1669 return 0; | 1669 return 0; |
1670 } | 1670 } |
1671 | 1671 |
1672 static int attr_info_compare_compute_range( | 1672 static int attr_info_compare_compute_range( |
1673 » unsigned char *abits, unsigned char *bbits, | 1673 » const unsigned char *abits, const unsigned char *bbits, |
1674 unsigned int *alowp, unsigned int *ahighp, | 1674 unsigned int *alowp, unsigned int *ahighp, |
1675 unsigned int *blowp, unsigned int *bhighp) | 1675 unsigned int *blowp, unsigned int *bhighp) |
1676 { | 1676 { |
1677 unsigned int alow = (unsigned int)-1, ahigh = 0; | 1677 unsigned int alow = (unsigned int)-1, ahigh = 0; |
1678 unsigned int blow = (unsigned int)-1, bhigh = 0; | 1678 unsigned int blow = (unsigned int)-1, bhigh = 0; |
1679 int i, res = 0; | 1679 int i, res = 0; |
1680 | 1680 |
1681 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1681 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) |
1682 { | 1682 { |
1683 if (res == 0) | 1683 if (res == 0) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 } | 1732 } |
1733 if (ahigh + alow < bhigh + blow) res = -1; | 1733 if (ahigh + alow < bhigh + blow) res = -1; |
1734 if (ahigh + alow > bhigh + blow) res = 1; | 1734 if (ahigh + alow > bhigh + blow) res = 1; |
1735 if (alowp) *alowp = alow; | 1735 if (alowp) *alowp = alow; |
1736 if (ahighp) *ahighp = ahigh; | 1736 if (ahighp) *ahighp = ahigh; |
1737 if (blowp) *blowp = blow; | 1737 if (blowp) *blowp = blow; |
1738 if (bhighp) *bhighp = bhigh; | 1738 if (bhighp) *bhighp = bhigh; |
1739 return res; | 1739 return res; |
1740 } | 1740 } |
1741 | 1741 |
1742 int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1742 int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a, |
| 1743 » » » const STORE_ATTR_INFO * const *b) |
1743 { | 1744 { |
1744 if (a == b) return 0; | 1745 if (a == b) return 0; |
1745 if (!a) return -1; | 1746 if (!a) return -1; |
1746 if (!b) return 1; | 1747 if (!b) return 1; |
1747 » return attr_info_compare_compute_range(a->set, b->set, 0, 0, 0, 0); | 1748 » return attr_info_compare_compute_range((*a)->set, (*b)->set, 0, 0, 0, 0)
; |
1748 } | 1749 } |
| 1750 |
1749 int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1751 int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
1750 { | 1752 { |
1751 unsigned int alow, ahigh, blow, bhigh; | 1753 unsigned int alow, ahigh, blow, bhigh; |
1752 | 1754 |
1753 if (a == b) return 1; | 1755 if (a == b) return 1; |
1754 if (!a) return 0; | 1756 if (!a) return 0; |
1755 if (!b) return 0; | 1757 if (!b) return 0; |
1756 attr_info_compare_compute_range(a->set, b->set, | 1758 attr_info_compare_compute_range(a->set, b->set, |
1757 &alow, &ahigh, &blow, &bhigh); | 1759 &alow, &ahigh, &blow, &bhigh); |
1758 if (alow >= blow && ahigh <= bhigh) | 1760 if (alow >= blow && ahigh <= bhigh) |
1759 return 1; | 1761 return 1; |
1760 return 0; | 1762 return 0; |
1761 } | 1763 } |
| 1764 |
1762 int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1765 int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
1763 { | 1766 { |
1764 unsigned char *abits, *bbits; | 1767 unsigned char *abits, *bbits; |
1765 int i; | 1768 int i; |
1766 | 1769 |
1767 if (a == b) return 1; | 1770 if (a == b) return 1; |
1768 if (!a) return 0; | 1771 if (!a) return 0; |
1769 if (!b) return 0; | 1772 if (!b) return 0; |
1770 abits = a->set; | 1773 abits = a->set; |
1771 bbits = b->set; | 1774 bbits = b->set; |
1772 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) | 1775 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++) |
1773 { | 1776 { |
1774 if (*abits && (*bbits & *abits) != *abits) | 1777 if (*abits && (*bbits & *abits) != *abits) |
1775 return 0; | 1778 return 0; |
1776 } | 1779 } |
1777 return 1; | 1780 return 1; |
1778 } | 1781 } |
| 1782 |
1779 int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) | 1783 int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b) |
1780 { | 1784 { |
1781 STORE_ATTR_TYPES i; | 1785 STORE_ATTR_TYPES i; |
1782 | 1786 |
1783 if (a == b) return 1; | 1787 if (a == b) return 1; |
1784 if (!STORE_ATTR_INFO_in(a, b)) return 0; | 1788 if (!STORE_ATTR_INFO_in(a, b)) return 0; |
1785 for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) | 1789 for (i = 1; i < STORE_ATTR_TYPE_NUM; i++) |
1786 if (ATTR_IS_SET(a, i)) | 1790 if (ATTR_IS_SET(a, i)) |
1787 { | 1791 { |
1788 switch(i) | 1792 switch(i) |
(...skipping 26 matching lines...) Expand all Loading... |
1815 b->values[i].number)) | 1819 b->values[i].number)) |
1816 return 0; | 1820 return 0; |
1817 break; | 1821 break; |
1818 default: | 1822 default: |
1819 break; | 1823 break; |
1820 } | 1824 } |
1821 } | 1825 } |
1822 | 1826 |
1823 return 1; | 1827 return 1; |
1824 } | 1828 } |
OLD | NEW |