2012-11-05 02:49:08 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef compat_h_
|
2014-10-25 03:29:21 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#endif
|
|
|
|
|
2019-03-01 08:51:50 +00:00
|
|
|
#include "vfs.h"
|
|
|
|
|
2014-09-30 04:17:06 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2019-03-01 08:51:50 +00:00
|
|
|
buildvfs_FILE fil; //0:no file open, !=0:open file (either stand-alone or zip)
|
2014-09-30 04:17:06 +00:00
|
|
|
int32_t comptyp; //0:raw data (can be ZIP or stand-alone), 8:PKZIP LZ77 *flate
|
|
|
|
int32_t seek0; //0:stand-alone file, !=0: start of zip compressed stream data
|
|
|
|
int32_t compleng;//Global variable for compression FIFO
|
|
|
|
int32_t comptell;//Global variable for compression FIFO
|
|
|
|
int32_t leng; //Uncompressed file size (bytes)
|
|
|
|
int32_t pos; //Current uncompressed relative file position (0<=pos<=leng)
|
|
|
|
int32_t endpos; //Temp global variable for kzread
|
|
|
|
int32_t jmpplc; //Store place where decompression paused
|
|
|
|
int32_t i; //For stand-alone/ZIP comptyp#0, this is like "uncomptell"
|
|
|
|
//For ZIP comptyp#8&btype==0 "<64K store", this saves i state
|
|
|
|
int32_t bfinal; //LZ77 decompression state (for later calls)
|
|
|
|
} kzfilestate;
|
|
|
|
|
|
|
|
extern kzfilestate kzfs;
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
//ZIP functions:
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t kzaddstack (const char *);
|
2007-01-29 01:18:16 +00:00
|
|
|
extern void kzuninit ();
|
2014-02-10 10:59:42 +00:00
|
|
|
extern intptr_t kzopen (const char *);
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t kzread (void *, int32_t);
|
|
|
|
extern int32_t kzseek (int32_t, int32_t);
|
2014-09-30 04:17:06 +00:00
|
|
|
|
|
|
|
static inline int32_t kztell(void) { return kzfs.fil ? kzfs.pos : -1; }
|
|
|
|
static inline int32_t kzeof(void) { return kzfs.fil ? kzfs.pos >= kzfs.leng : -1; }
|
|
|
|
static inline int32_t kzfilelength(void) { return kzfs.fil ? kzfs.leng : 0; }
|
|
|
|
static inline int32_t kzgetc(void) { char ch; return kzread(&ch, 1) ? ch : -1; }
|
|
|
|
static inline void kzclose(void) { MAYBE_FCLOSE_AND_NULL(kzfs.fil); }
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
extern void kzfindfilestart (const char *); //pass wildcard string
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t kzfindfile (char *); //you alloc buf, returns 1:found,0:~found
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2014-09-30 04:17:06 +00:00
|
|
|
//like stricmp(st0,st1) except: '/' == '\'
|
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
extern uint8_t toupperlookup[256];
|
2014-09-30 04:17:06 +00:00
|
|
|
static inline int32_t filnamcmp(const char *j, const char *i)
|
|
|
|
{
|
|
|
|
// If we reach at the end of both strings, we are done
|
2015-01-16 06:30:51 +00:00
|
|
|
while (*i && *j && (toupperlookup[*i] == toupperlookup[*j]))
|
2014-09-30 04:17:06 +00:00
|
|
|
i++, j++;
|
2015-01-16 06:30:51 +00:00
|
|
|
return *i != '\0' || *j != '\0';
|
2014-09-30 04:17:06 +00:00
|
|
|
}
|
2014-10-25 03:29:21 +00:00
|
|
|
extern int32_t wildmatch(const char *match, const char *wild);
|