aboutsummaryrefslogtreecommitdiff
path: root/lib/libhts/htsbuf.h
diff options
context:
space:
mode:
authortheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
committertheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
commitc51b1189e3d5353e842991f5859ddcea0f73e426 (patch)
treeef2cb8a6184699aa614f3655dca4ce661cdc108e /lib/libhts/htsbuf.h
parentbe61ebdc9e897fe40c6f371111724de79ddee8d5 (diff)
Merged cptspiff's code-reshuffle branch.
Squashed commit due to build breakage during code-reshuffle history. Conflicts: xbmc/Util.cpp xbmc/cdrip/CDDARipper.cpp xbmc/filesystem/Directory.cpp xbmc/filesystem/File.cpp
Diffstat (limited to 'lib/libhts/htsbuf.h')
-rw-r--r--lib/libhts/htsbuf.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/libhts/htsbuf.h b/lib/libhts/htsbuf.h
new file mode 100644
index 0000000000..2ef22100ba
--- /dev/null
+++ b/lib/libhts/htsbuf.h
@@ -0,0 +1,65 @@
+/*
+ * Buffer management functions
+ * Copyright (C) 2008 Andreas Öman
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef HTSBUF_H__
+#define HTSBUF_H__
+
+#include <stdarg.h>
+#include "htsq.h"
+#include <inttypes.h>
+
+TAILQ_HEAD(htsbuf_data_queue, htsbuf_data);
+
+typedef struct htsbuf_data {
+ TAILQ_ENTRY(htsbuf_data) hd_link;
+ uint8_t *hd_data;
+ unsigned int hd_data_size; /* Size of allocation hb_data */
+ unsigned int hd_data_len; /* Number of valid bytes from hd_data */
+ unsigned int hd_data_off; /* Offset in data, used for partial writes */
+} htsbuf_data_t;
+
+typedef struct htsbuf_queue {
+ struct htsbuf_data_queue hq_q;
+ unsigned int hq_size;
+ unsigned int hq_maxsize;
+} htsbuf_queue_t;
+
+void htsbuf_queue_init(htsbuf_queue_t *hq, unsigned int maxsize);
+
+void htsbuf_queue_flush(htsbuf_queue_t *hq);
+
+void htsbuf_vqprintf(htsbuf_queue_t *hq, const char *fmt, va_list ap);
+
+void htsbuf_qprintf(htsbuf_queue_t *hq, const char *fmt, ...);
+
+void htsbuf_append(htsbuf_queue_t *hq, const char *buf, size_t len);
+
+void htsbuf_append_prealloc(htsbuf_queue_t *hq, const char *buf, size_t len);
+
+void htsbuf_data_free(htsbuf_queue_t *hq, htsbuf_data_t *hd);
+
+size_t htsbuf_read(htsbuf_queue_t *hq, char *buf, size_t len);
+
+size_t htsbuf_peek(htsbuf_queue_t *hq, char *buf, size_t len);
+
+size_t htsbuf_drop(htsbuf_queue_t *hq, size_t len);
+
+size_t htsbuf_find(htsbuf_queue_t *hq, uint8_t v);
+
+#endif /* HTSBUF_H__ */