1 /*
2  * OpenBOR - http://www.LavaLit.com
3  * -----------------------------------------------------------------------
4  * All rights reserved, see LICENSE in OpenBOR root for details.
5  *
6  * Copyright (c) 2004 - 2011 OpenBOR Team
7  */
8 
9 #ifndef SPK_SUPPORTED
10 
11 #ifndef PACKFILE_H
12 #define PACKFILE_H
13 
14 #include <stdio.h>
15 #include <dirent.h>
16 
17 #if DOS || PSP || DC || LINUX || GP2X || DINGOO || WII
18 #include <unistd.h>
19 #define O_BINARY 0
20 #endif
21 
22 #ifdef SDL
23 #include <SDL.h>
24 #endif
25 
26 #ifdef PSP
27 #include "image.h"
28 #endif
29 
30 //
31 // Structure used for handling packfiles
32 //
33 typedef struct pnamestruct{
34 	unsigned int pns_len;	    // Length of the struct in bytes
35 	unsigned int filestart;	    // Start position of referenced file
36 	unsigned int filesize;	    // Size of referenced file
37 	char		 namebuf[80];	// Buffer to hold the file's name
38 }pnamestruct;
39 
40 typedef struct fileliststruct{
41 	char filename[128];
42 	int nTracks;
43 	char bgmFileName[256][80];
44 	int bgmTrack;
45 	unsigned int bgmTracks[256];
46 #ifdef SDL
47 	SDL_Surface *preview;
48 #elif PSP
49 	Image *preview;
50 #endif
51 }fileliststruct;
52 
53 #define	NUMPACKHANDLES	8
54 #define PACKVERSION	0x00000000
55 #define testpackfile(filename, packfilename) closepackfile(openpackfile(filename, packfilename))
56 
57 extern int printFileUsageStatistics;
58 
59 // All of these return -1 on error
60 int openpackfile(const char *filename, const char *packfilename);
61 int readpackfile(int handle, void *buf, int len);
62 int closepackfile(int handle);
63 int seekpackfile(int handle, int offset, int whence);
64 int pak_init();
65 void pak_term();
66 void packfile_mode(int mode);
67 int pakopen(const char *filename, int mode);
68 int pakread(int fd, void *buf, int len);
69 void pakclose(int fd);
70 int paklseek(int fd, int n, int whence);
71 int openreadaheadpackfile(const char *filename, const char *packfilename, int readaheadsize, int prebuffersize);
72 int readpackfile_noblock(int fd, void *buf, int len);
73 int packfileeof(int fd);
74 int packfile_supported(struct dirent* ds);
75 void packfile_music_read(struct fileliststruct* filelist, int dListTotal);
76 int packfile_music_play(struct fileliststruct* filelist, FILE *bgmFile, int bgmLoop, int curPos, int scrPos);
77 void freefilenamecache(void);
78 
79 #endif
80 
81 #endif
82