diff --git a/src/htsbuf.c b/src/htsbuf.c index 91a368ac..68cc9850 100644 --- a/src/htsbuf.c +++ b/src/htsbuf.c @@ -23,6 +23,7 @@ #include #include #include "htsbuf.h" +#include "tvhead.h" #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -118,6 +119,7 @@ htsbuf_append(htsbuf_queue_t *hq, const void *buf, size_t len) memcpy(hd->hd_data, buf, len); } + /** * */ @@ -275,3 +277,21 @@ htsbuf_appendq(htsbuf_queue_t *hq, htsbuf_queue_t *src) TAILQ_INSERT_TAIL(&hq->hq_q, hd, hd_link); } } + + +/** + * + */ +uint32_t +htsbuf_crc32(htsbuf_queue_t *hq, uint32_t crc) +{ + htsbuf_data_t *hd; + + TAILQ_FOREACH(hd, &hq->hq_q, hd_link) + crc = crc32(hd->hd_data + hd->hd_data_off, + hd->hd_data_len - hd->hd_data_off, + crc); + return crc; +} + + diff --git a/src/htsbuf.h b/src/htsbuf.h index ed1c0244..856f275b 100644 --- a/src/htsbuf.h +++ b/src/htsbuf.h @@ -66,4 +66,6 @@ size_t htsbuf_drop(htsbuf_queue_t *hq, size_t len); size_t htsbuf_find(htsbuf_queue_t *hq, uint8_t v); +uint32_t htsbuf_crc32(htsbuf_queue_t *q, uint32_t crc); + #endif /* HTSBUF_H__ */