Skip to content

Commit

Permalink
Updated XADMaster and fixed the repos quicklook issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Rauchfuss committed Sep 22, 2010
1 parent fc49a1d commit f3140e3
Show file tree
Hide file tree
Showing 24 changed files with 410 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-(NSString *)MIMECharset;
-(float)confidence;

#ifdef __APPLE__
-(NSStringEncoding)encoding;
#endif

@end
Binary file not shown.
4 changes: 2 additions & 2 deletions Frameworks/XADMaster.framework/Versions/A/Headers/BWT.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ typedef struct MTFState
int table[256];
} MTFState;

void ResetMTFDecoder(MTFState *mtf);
int DecodeMTF(MTFState *mtf,int symbol);
void ResetMTFDecoder(MTFState *self);
int DecodeMTF(MTFState *self,int symbol);
void DecodeMTFBlock(uint8_t *block,int blocklen);
void DecodeM1FFNBlock(uint8_t *block,int blocklen,int order);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

@interface CSBlockStreamHandle:CSStreamHandle
{
uint8_t *currblock;
off_t blockstartpos;
int blocklength;
BOOL endofblocks;
uint8_t *_currblock;
off_t _blockstartpos;
int _blocklength;
BOOL _endofblocks;
}

// Intializers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#define CSFileHandle XADFileHandle

extern NSString *CSCannotOpenFileException;
extern NSString *CSFileErrorException;

@interface CSFileHandle:CSHandle
Expand All @@ -24,6 +25,7 @@ extern NSString *CSFileErrorException;
-(id)initWithFilePointer:(FILE *)file closeOnDealloc:(BOOL)closeondealloc name:(NSString *)descname;
-(id)initAsCopyOf:(CSFileHandle *)other;
-(void)dealloc;
-(void)close;

// Public methods
-(FILE *)filePointer;
Expand Down
11 changes: 11 additions & 0 deletions Frameworks/XADMaster.framework/Versions/A/Headers/CSHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
#define CSHandle XADHandle


// Kludge 64-bit support for Mingw. TODO: Should this be used on Linux too?
#if defined(__MINGW32__) && !defined(__CYGWIN__)
#include <unistd.h>
#include <fcntl.h>
#define off_t off64_t
#define fseeko fseeko64
#define lseek lseek64
#define ftello ftello64
#endif


extern NSString *CSOutOfMemoryException;
extern NSString *CSEndOfFileException;
Expand All @@ -26,6 +36,7 @@ extern NSString *CSNotSupportedException;
-(id)initWithName:(NSString *)descname;
-(id)initAsCopyOf:(CSHandle *)other;
-(void)dealloc;
-(void)close;


// Methods implemented by subclasses
Expand Down
177 changes: 137 additions & 40 deletions Frameworks/XADMaster.framework/Versions/A/Headers/CSInputBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,173 @@ typedef struct CSInputBuffer
BOOL eof;

uint8_t *buffer;
int bufsize,bufbytes,currbyte,currbit;
unsigned int bufsize,bufbytes,currbyte;

uint32_t bits;
unsigned int numbits;
} CSInputBuffer;



// Allocation and management

CSInputBuffer *CSInputBufferAlloc(CSHandle *parent,int size);
CSInputBuffer *CSInputBufferAllocWithBuffer(uint8_t *buffer,int length,off_t startoffs);
CSInputBuffer *CSInputBufferAllocWithBuffer(const uint8_t *buffer,int length,off_t startoffs);
CSInputBuffer *CSInputBufferAllocEmpty();
void CSInputBufferFree(CSInputBuffer *buf);
void CSInputBufferFree(CSInputBuffer *self);

void CSInputSetMemoryBuffer(CSInputBuffer *self,uint8_t *buffer,int length,off_t startoffs);



void CSInputSetMemoryBuffer(CSInputBuffer *buf,uint8_t *buffer,int length,off_t startoffs);
// Buffer and file positioning

void CSInputRestart(CSInputBuffer *buf);
void CSInputFlush(CSInputBuffer *buf);
void CSInputSynchronizeFileOffset(CSInputBuffer *buf);
void CSInputSeekToFileOffset(CSInputBuffer *buf,off_t offset);
void CSInputSeekToBufferOffset(CSInputBuffer *buf,off_t offset);
void CSInputSetStartOffset(CSInputBuffer *buf,off_t offset);
void CSInputRestart(CSInputBuffer *self);
void CSInputFlush(CSInputBuffer *self);

off_t CSInputBufferOffset(CSInputBuffer *buf);
off_t CSInputFileOffset(CSInputBuffer *buf);
void CSInputSynchronizeFileOffset(CSInputBuffer *self);
void CSInputSeekToFileOffset(CSInputBuffer *self,off_t offset);
void CSInputSeekToBufferOffset(CSInputBuffer *self,off_t offset);
void CSInputSetStartOffset(CSInputBuffer *self,off_t offset);
off_t CSInputBufferOffset(CSInputBuffer *self);
off_t CSInputFileOffset(CSInputBuffer *self);

void _CSInputFillBuffer(CSInputBuffer *buf);
void _CSInputFillBuffer(CSInputBuffer *self);

void CSInputSkipBits(CSInputBuffer *buf,int bits);
BOOL CSInputOnByteBoundary(CSInputBuffer *buf);
void CSInputSkipToByteBoundary(CSInputBuffer *buf);
void CSInputSkipTo16BitBoundary(CSInputBuffer *buf);

int CSInputNextBit(CSInputBuffer *buf);
int CSInputNextBitLE(CSInputBuffer *buf);
unsigned int CSInputNextBitString(CSInputBuffer *buf,int bits);
unsigned int CSInputNextBitStringLE(CSInputBuffer *buf,int bits);
unsigned int CSInputPeekBitString(CSInputBuffer *buf,int bits);
unsigned int CSInputPeekBitStringLE(CSInputBuffer *buf,int bits);


// Byte reading

#define CSInputBufferLookAhead 4

static inline void _CSInputCheckAndFillBuffer(CSInputBuffer *buf)
static inline void _CSInputBufferRaiseEOF(CSInputBuffer *self)
{
[self->parent _raiseEOF];
}

static inline int _CSInputBytesLeftInBuffer(CSInputBuffer *self)
{
return self->bufbytes-self->currbyte;
}

static inline void _CSInputCheckAndFillBuffer(CSInputBuffer *self)
{
if(!buf->eof&&buf->currbyte+CSInputBufferLookAhead>=buf->bufbytes) _CSInputFillBuffer(buf);
if(!self->eof&&_CSInputBytesLeftInBuffer(self)<=CSInputBufferLookAhead) _CSInputFillBuffer(self);
}

static inline void CSInputSkipBytes(CSInputBuffer *buf,int num) { buf->currbyte+=num; }
static inline void CSInputSkipBytes(CSInputBuffer *self,int num)
{
self->currbyte+=num;
}

static inline int CSInputPeekByte(CSInputBuffer *buf,int offs)
static inline int _CSInputPeekByteWithoutEOF(CSInputBuffer *self,int offs)
{
if(buf->currbyte+offs>=buf->bufbytes) [buf->parent _raiseEOF];
return self->buffer[self->currbyte+offs];
}

return buf->buffer[buf->currbyte+offs];
static inline int CSInputPeekByte(CSInputBuffer *self,int offs)
{
if(offs>=_CSInputBytesLeftInBuffer(self)) _CSInputBufferRaiseEOF(self);
return _CSInputPeekByteWithoutEOF(self,offs);
}

static inline int CSInputNextByte(CSInputBuffer *buf)
static inline int CSInputNextByte(CSInputBuffer *self)
{
_CSInputCheckAndFillBuffer(buf);
int byte=CSInputPeekByte(buf,0);
CSInputSkipBytes(buf,1);
_CSInputCheckAndFillBuffer(self);
int byte=CSInputPeekByte(self,0);
CSInputSkipBytes(self,1);
return byte;
}

static inline BOOL CSInputAtEOF(CSInputBuffer *buf)
static inline BOOL CSInputAtEOF(CSInputBuffer *self)
{
_CSInputCheckAndFillBuffer(buf);
return buf->currbyte>=buf->bufbytes;
_CSInputCheckAndFillBuffer(self);
return _CSInputBytesLeftInBuffer(self)<=0;
}




// Bitstream reading

void _CSInputFillBits(CSInputBuffer *self);
void _CSInputFillBitsLE(CSInputBuffer *self);

unsigned int CSInputNextBit(CSInputBuffer *self);
unsigned int CSInputNextBitLE(CSInputBuffer *self);
unsigned int CSInputNextBitString(CSInputBuffer *self,int numbits);
unsigned int CSInputNextBitStringLE(CSInputBuffer *self,int numbits);
unsigned int CSInputNextLongBitString(CSInputBuffer *self,int numbits);
unsigned int CSInputNextLongBitStringLE(CSInputBuffer *self,int numbits);

void CSInputSkipBits(CSInputBuffer *self,int numbits);
void CSInputSkipBitsLE(CSInputBuffer *self,int numbits);
BOOL CSInputOnByteBoundary(CSInputBuffer *self);
void CSInputSkipToByteBoundary(CSInputBuffer *self);
void CSInputSkipTo16BitBoundary(CSInputBuffer *self);

static inline unsigned int CSInputBitsLeftInBuffer(CSInputBuffer *self)
{
_CSInputCheckAndFillBuffer(self);
return _CSInputBytesLeftInBuffer(self)*8+(self->numbits&7);
}

static inline void _CSInputCheckAndFillBits(CSInputBuffer *self,int numbits)
{
if(numbits>self->numbits) _CSInputFillBits(self);
}

static inline void _CSInputCheckAndFillBitsLE(CSInputBuffer *self,int numbits)
{
if(numbits>self->numbits) _CSInputFillBitsLE(self);
}

static inline unsigned int CSInputPeekBitString(CSInputBuffer *self,int numbits)
{
_CSInputCheckAndFillBits(self,numbits);
return self->bits>>(32-numbits);
}

static inline unsigned int CSInputPeekBitStringLE(CSInputBuffer *self,int numbits)
{
_CSInputCheckAndFillBitsLE(self,numbits);
return self->bits&((1<<numbits)-1);
}

static inline void CSInputSkipPeekedBits(CSInputBuffer *self,int numbits)
{
int numbytes=(numbits-(self->numbits&7)+7)>>3;
CSInputSkipBytes(self,numbytes);

if(_CSInputBytesLeftInBuffer(self)<0) _CSInputBufferRaiseEOF(self);

self->bits<<=numbits;
self->numbits-=numbits;
}

static inline void CSInputSkipPeekedBitsLE(CSInputBuffer *self,int numbits)
{
int numbytes=(numbits-(self->numbits&7)+7)>>3;
CSInputSkipBytes(self,numbytes);

if(_CSInputBytesLeftInBuffer(self)<0) _CSInputBufferRaiseEOF(self);

self->bits>>=numbits;
self->numbits-=numbits;
}




// Multibyte reading

#define CSInputNextValueImpl(type,name,conv) \
static inline type name(CSInputBuffer *buf) \
static inline type name(CSInputBuffer *self) \
{ \
_CSInputCheckAndFillBuffer(buf); \
type val=conv(buf->buffer+buf->currbyte); \
CSInputSkipBytes(buf,sizeof(type)); \
_CSInputCheckAndFillBuffer(self); \
type val=conv(self->buffer+self->currbyte); \
CSInputSkipBytes(self,sizeof(type)); \
return val; \
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
-(void)endStream;
-(BOOL)_prepareStreamSeekTo:(off_t)offs;
-(void)setStreamLength:(off_t)length;
-(void)setInputBuffer:(CSInputBuffer *)inputbuffer;

@end
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#import "CSStreamHandle.h"

#ifndef __MACTYPES__
#define Byte zlibByte
#include <zlib.h>
#undef Byte
#else
#include <zlib.h>
#endif

#define CSZlibHandle XADZlibHandle

Expand Down
24 changes: 24 additions & 0 deletions Frameworks/XADMaster.framework/Versions/A/Headers/Checksums.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,27 @@
-(BOOL)isChecksumCorrect;

@end

#define CSChecksumWrapperHandle XADChecksumWrapperHandle

@interface CSChecksumWrapperHandle:CSHandle
{
CSHandle *parent,*checksum;
}

-(id)initWithHandle:(CSHandle *)handle checksumHandle:(CSHandle *)checksumhandle;
-(void)dealloc;

-(off_t)fileSize;
-(off_t)offsetInFile;
-(BOOL)atEndOfFile;
-(void)seekToFileOffset:(off_t)offs;
-(void)seekToEndOfFile;
-(void)pushBackByte:(int)byte;
-(int)readAtMost:(int)num toBuffer:(void *)buffer;
-(void)writeBytes:(int)num fromBuffer:(const void *)buffer;

-(BOOL)hasChecksum;
-(BOOL)isChecksumCorrect;

@end
16 changes: 8 additions & 8 deletions Frameworks/XADMaster.framework/Versions/A/Headers/LZW.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ typedef struct LZW
} LZW;

LZW *AllocLZW(int maxsymbols,int reservedsymbols);
void FreeLZW(LZW *lzw);
void ClearLZWTable(LZW *lzw);
int NextLZWSymbol(LZW *lzw,int symbol);
int LZWOutputLength(LZW *lzw);
int LZWOutputToBuffer(LZW *lzw,uint8_t *buffer);
int LZWReverseOutputToBuffer(LZW *lzw,uint8_t *buffer);
int LZWSymbolCount(LZW *lzw);
int LZWSymbolListFull(LZW *lzw);
void FreeLZW(LZW *self);
void ClearLZWTable(LZW *self);
int NextLZWSymbol(LZW *self,int symbol);
int LZWOutputLength(LZW *self);
int LZWOutputToBuffer(LZW *self,uint8_t *buffer);
int LZWReverseOutputToBuffer(LZW *self,uint8_t *buffer);
int LZWSymbolCount(LZW *self);
int LZWSymbolListFull(LZW *self);

#endif

17 changes: 17 additions & 0 deletions Frameworks/XADMaster.framework/Versions/A/Headers/NSDateXAD.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#import <Foundation/Foundation.h>
#import <sys/time.h>

#ifdef __MINGW32__
#include <windows.h>
#endif

@interface NSDate (XAD)

Expand All @@ -9,4 +14,16 @@
+(NSDate *)XADDateWithWindowsFileTime:(uint64_t)filetime;
+(NSDate *)XADDateWithWindowsFileTimeLow:(uint32_t)low high:(uint32_t)high;

#ifndef __MINGW32__
-(struct timeval)timevalStruct;
#endif

#ifdef __APPLE__
-(UTCDateTime)UTCDateTime;
#endif

#ifdef __MINGW32__
-(FILETIME)FILETIME;
#endif

@end
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ typedef struct PPMdModelVariantH

void StartPPMdModelVariantH(PPMdModelVariantH *self,CSInputBuffer *input,
PPMdSubAllocatorVariantH *alloc,int maxorder,BOOL sevenzip);
void RestartPPMdVariantHRangeCoder(PPMdModelVariantH *self,CSInputBuffer *input,BOOL sevenzip);
int NextPPMdVariantHByte(PPMdModelVariantH *self);
Loading

0 comments on commit f3140e3

Please sign in to comment.