{
if (dlen >= len)
buffer_extend(buf, dlen - len);
+ if (len >= buf->len)
+ len = buf->len;
memmove(buf->data + pos + dlen,
buf->data + pos + len,
buf->len - pos - len);
buffer_setlen(buf, buf->len + dlen - len);
}
+void buffer_consume_upto(buffer_t *buf, const char *s)
+{
+ assert (buf->data <= s && s <= buf->data + buf->len);
+ buffer_splice(buf, 0, s - buf->data, NULL, 0);
+}
+
ssize_t buffer_addvf(buffer_t *buf, const char *fmt, va_list args)
{
ssize_t len;
}
void buffer_splice(buffer_t *, ssize_t pos, ssize_t len, const void *, ssize_t);
+void buffer_consume_upto(buffer_t *, const char *s);
ssize_t buffer_addvf(buffer_t *buf, const char *fmt, va_list)
__attribute__((format(printf, 2, 0)));
* \return 1 if a match is found, 0 otherwise.
*/
static inline int m_strstart(const char *s, const char *p, const char **pp)
+{
+ if (!s)
+ return 0;
+
+ while (*p) {
+ if (ascii_tolower(*s++) != ascii_tolower(*p++))
+ return 0;
+ }
+ if (pp)
+ *pp = s;
+ return 1;
+}
+
+/** \brief Tells whether s begins with p, case insensitive.
+ *
+ * \param[in] s the input string
+ * \param[in] p the prefix
+ * \param[out] pp position in s
+ *
+ * \return 1 if a match is found, 0 otherwise.
+ */
+static inline int m_strcasestart(const char *s, const char *p, const char **pp)
{
if (!s)
return 0;