1 /*$
2  Copyright (C) 2013-2020 Azel.
3 
4  This file is part of AzPainter.
5 
6  AzPainter is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  AzPainter is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 $*/
19 
20 #ifndef MLIB_IOFILEBUF_H
21 #define MLIB_IOFILEBUF_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct _mIOFileBuf mIOFileBuf;
28 
29 enum MIOFILEBUF_ENDIAN
30 {
31 	MIOFILEBUF_ENDIAN_SYSTEM,
32 	MIOFILEBUF_ENDIAN_LITTLE,
33 	MIOFILEBUF_ENDIAN_BIG
34 };
35 
36 void mIOFileBuf_close(mIOFileBuf *p);
37 
38 mIOFileBuf *mIOFileBuf_openRead_filename(const char *filename);
39 mIOFileBuf *mIOFileBuf_openRead_buf(const void *buf,uint32_t bufsize);
40 mIOFileBuf *mIOFileBuf_openRead_FILE(void *fp);
41 
42 void mIOFileBuf_setEndian(mIOFileBuf *p,int type);
43 
44 int mIOFileBuf_read(mIOFileBuf *p,void *buf,int size);
45 mBool mIOFileBuf_readEmpty(mIOFileBuf *p,int size);
46 mBool mIOFileBuf_readSize(mIOFileBuf *p,void *buf,int size);
47 
48 mBool mIOFileBuf_readByte(mIOFileBuf *p,void *buf);
49 mBool mIOFileBuf_read16(mIOFileBuf *p,void *buf);
50 mBool mIOFileBuf_read32(mIOFileBuf *p,void *buf);
51 
52 void mIOFileBuf_setPos(mIOFileBuf *p,uint32_t pos);
53 mBool mIOFileBuf_seekCur(mIOFileBuf *p,int seek);
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif
60