| 1797 | } |
| 1798 | |
| 1799 | int |
| 1800 | MIMEField::value_get_index(const char *value, int length) const |
| 1801 | { |
| 1802 | int retval = -1; |
| 1803 | |
| 1804 | // if field doesn't support commas and there is just one instance, just compare the value |
| 1805 | if (!this->supports_commas() && !this->has_dups()) { |
| 1806 | if (this->m_len_value == static_cast<uint32_t>(length) && strncasecmp(value, this->m_ptr_value, length) == 0) { |
| 1807 | retval = 0; |
| 1808 | } |
| 1809 | } else { |
| 1810 | HdrCsvIter iter; |
| 1811 | int tok_len; |
| 1812 | int index = 0; |
| 1813 | const char *tok = iter.get_first(this, &tok_len); |
| 1814 | |
| 1815 | while (tok) { |
| 1816 | if (tok_len == length && strncasecmp(tok, value, length) == 0) { |
| 1817 | retval = index; |
| 1818 | break; |
| 1819 | } else { |
| 1820 | index++; |
| 1821 | } |
| 1822 | tok = iter.get_next(&tok_len); |
| 1823 | } |
| 1824 | } |
| 1825 | |
| 1826 | return retval; |
| 1827 | } |
| 1828 | |
| 1829 | std::string_view |
| 1830 | MIMEField::value_get() const |
no test coverage detected