Fix broken bounds check.
[calfbox.git] / tarfile.h
blobc940cc77f8056f20136c2b17ef4d5c41ed77b056
1 /*
2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2013 Krzysztof Foltman
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CBOX_TARFILE_H
20 #define CBOX_TARFILE_H
22 #include <glib.h>
23 #include <stdint.h>
24 #include <sndfile.h>
26 struct cbox_taritem
28 gchar *filename;
29 gchar *filename_nc;
30 uint64_t offset;
31 uint64_t size;
32 int refs;
35 struct cbox_tarfile
37 int fd;
38 int refs;
39 GHashTable *items_byname;
40 GHashTable *items_byname_nc;
41 char *file_pathname;
44 struct cbox_tarpool
46 GHashTable *files;
49 struct cbox_tarfile_sndstream
51 struct cbox_tarfile *file;
52 struct cbox_taritem *item;
53 uint64_t filepos;
56 extern struct SF_VIRTUAL_IO cbox_taritem_virtual_io;
58 extern struct cbox_tarfile *cbox_tarfile_open(const char *pathname, GError **error);
60 extern struct cbox_taritem *cbox_tarfile_get_item_by_name(struct cbox_tarfile *tarfile, const char *item_filename, gboolean ignore_case);
61 extern int cbox_tarfile_openitem(struct cbox_tarfile *tarfile, struct cbox_taritem *item);
62 extern void cbox_tarfile_closeitem(struct cbox_tarfile *tarfile, struct cbox_taritem *item, int fd);
64 extern SNDFILE *cbox_tarfile_opensndfile(struct cbox_tarfile *tarfile, struct cbox_taritem *item, struct cbox_tarfile_sndstream *stream, SF_INFO *sfinfo);
65 // No need to close - it reuses the cbox_tarfile file descriptor
67 extern void cbox_tarfile_destroy(struct cbox_tarfile *tf);
69 extern struct cbox_tarpool *cbox_tarpool_new(void);
70 extern struct cbox_tarfile *cbox_tarpool_get_tarfile(struct cbox_tarpool *pool, const char *name, GError **error);
71 extern void cbox_tarpool_release_tarfile(struct cbox_tarpool *pool, struct cbox_tarfile *file);
72 extern void cbox_tarpool_destroy(struct cbox_tarpool *pool);
74 #endif