Skip to content

Commit

Permalink
Fix oversights:
Browse files Browse the repository at this point in the history
Add XADEXPORT to public classes, and XADEXTERN to public functions.
Add missing XADStringEncodingName renames in XADPath.
Make XADAction an NS_ENUM.
  • Loading branch information
MaddTheSane committed Feb 1, 2025
1 parent 8bcbf0a commit 9b891eb
Show file tree
Hide file tree
Showing 23 changed files with 172 additions and 143 deletions.
10 changes: 5 additions & 5 deletions CSHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
#endif


extern NSExceptionName const CSOutOfMemoryException;
extern NSExceptionName const CSEndOfFileException;
extern NSExceptionName const CSNotImplementedException;
extern NSExceptionName const CSNotSupportedException;

XADEXTERN NSExceptionName const CSOutOfMemoryException;
XADEXTERN NSExceptionName const CSEndOfFileException;
XADEXTERN NSExceptionName const CSNotImplementedException;
XADEXTERN NSExceptionName const CSNotSupportedException;


XADEXPORT
@interface CSHandle:NSObject <NSCopying>
{
CSHandle *parent;
Expand Down
72 changes: 36 additions & 36 deletions CSInputBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ typedef struct CSInputBuffer

// Allocation and management

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

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

static inline CSHandle *CSInputHandle(CSInputBuffer *self)
{
Expand All @@ -57,18 +57,18 @@ static inline CSHandle *CSInputHandle(CSInputBuffer *self)

// Buffer and file positioning

void CSInputRestart(CSInputBuffer *self);
void CSInputFlush(CSInputBuffer *self);
XADEXPORT void CSInputRestart(CSInputBuffer *self);
XADEXPORT void CSInputFlush(CSInputBuffer *self);

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);
off_t CSInputBufferBitOffset(CSInputBuffer *self);
XADEXPORT void CSInputSynchronizeFileOffset(CSInputBuffer *self);
XADEXPORT void CSInputSeekToFileOffset(CSInputBuffer *self,off_t offset);
XADEXPORT void CSInputSeekToBufferOffset(CSInputBuffer *self,off_t offset);
XADEXPORT void CSInputSetStartOffset(CSInputBuffer *self,off_t offset);
XADEXPORT off_t CSInputBufferOffset(CSInputBuffer *self);
XADEXPORT off_t CSInputFileOffset(CSInputBuffer *self);
XADEXPORT off_t CSInputBufferBitOffset(CSInputBuffer *self);

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



Expand Down Expand Up @@ -129,21 +129,21 @@ static inline BOOL CSInputAtEOF(CSInputBuffer *self)

// Bitstream reading

void _CSInputFillBits(CSInputBuffer *self);
void _CSInputFillBitsLE(CSInputBuffer *self);
XADEXPORT void _CSInputFillBits(CSInputBuffer *self);
XADEXPORT 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);
XADEXPORT unsigned int CSInputNextBit(CSInputBuffer *self);
XADEXPORT unsigned int CSInputNextBitLE(CSInputBuffer *self);
XADEXPORT unsigned int CSInputNextBitString(CSInputBuffer *self,int numbits);
XADEXPORT unsigned int CSInputNextBitStringLE(CSInputBuffer *self,int numbits);
XADEXPORT unsigned int CSInputNextLongBitString(CSInputBuffer *self,int numbits);
XADEXPORT 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);
XADEXPORT void CSInputSkipBits(CSInputBuffer *self,int numbits);
XADEXPORT void CSInputSkipBitsLE(CSInputBuffer *self,int numbits);
XADEXPORT BOOL CSInputOnByteBoundary(CSInputBuffer *self);
XADEXPORT void CSInputSkipToByteBoundary(CSInputBuffer *self);
XADEXPORT void CSInputSkipTo16BitBoundary(CSInputBuffer *self);

static inline unsigned int CSInputBitsLeftInBuffer(CSInputBuffer *self)
{
Expand Down Expand Up @@ -211,14 +211,14 @@ static inline type name(CSInputBuffer *self) \
return val; \
}

CSInputNextValueImpl(int16_t,CSInputNextInt16LE,CSInt16LE)
CSInputNextValueImpl(int32_t,CSInputNextInt32LE,CSInt32LE)
CSInputNextValueImpl(uint16_t,CSInputNextUInt16LE,CSUInt16LE)
CSInputNextValueImpl(uint32_t,CSInputNextUInt32LE,CSUInt32LE)
CSInputNextValueImpl(int16_t,CSInputNextInt16BE,CSInt16BE)
CSInputNextValueImpl(int32_t,CSInputNextInt32BE,CSInt32BE)
CSInputNextValueImpl(uint16_t,CSInputNextUInt16BE,CSUInt16BE)
CSInputNextValueImpl(uint32_t,CSInputNextUInt32BE,CSUInt32BE)
XADEXPORT CSInputNextValueImpl(int16_t,CSInputNextInt16LE,CSInt16LE)
XADEXPORT CSInputNextValueImpl(int32_t,CSInputNextInt32LE,CSInt32LE)
XADEXPORT CSInputNextValueImpl(uint16_t,CSInputNextUInt16LE,CSUInt16LE)
XADEXPORT CSInputNextValueImpl(uint32_t,CSInputNextUInt32LE,CSUInt32LE)
XADEXPORT CSInputNextValueImpl(int16_t,CSInputNextInt16BE,CSInt16BE)
XADEXPORT CSInputNextValueImpl(int32_t,CSInputNextInt32BE,CSInt32BE)
XADEXPORT CSInputNextValueImpl(uint16_t,CSInputNextUInt16BE,CSUInt16BE)
XADEXPORT CSInputNextValueImpl(uint32_t,CSInputNextUInt32BE,CSUInt32BE)



Expand Down
1 change: 1 addition & 0 deletions CSMemoryHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#define CSMemoryHandle XADMemoryHandle

XADEXPORT
@interface CSMemoryHandle:CSHandle
{
NSData *backingdata;
Expand Down
1 change: 1 addition & 0 deletions CSStreamHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#define CSStreamHandle XADStreamHandle

XADEXPORT
@interface CSStreamHandle:CSHandle
{
off_t streampos,streamlength;
Expand Down
1 change: 1 addition & 0 deletions CSSubHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#define CSSubHandle XADSubHandle

XADEXPORT
@interface CSSubHandle:CSHandle
{
off_t start,end;
Expand Down
58 changes: 31 additions & 27 deletions XADArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@
#import "XADException.h"
#pragma clang diagnostic pop

//TODO: wrap in an emum
typedef int XADAction;
//typedef off_t xadSize; // deprecated
#if __has_feature(modules)
# define XAD_NO_DEPRECATED
#endif

#define XADAbortAction 0
#define XADRetryAction 1
#define XADSkipAction 2
#define XADOverwriteAction 3
#define XADRenameAction 4
typedef NS_ENUM(int, XADAction) {
XADActionAbort = 0,
XADActionRetry = 1,
XADActionSkip = 2,
XADActionOverwrite = 3,
XADActionRename = 4
};
//typedef off_t xadSize; // deprecated

extern NSString *const XADResourceDataKey;
extern NSString *const XADFinderFlags;
XADEXTERN NSString *const XADResourceDataKey;
XADEXTERN NSString *const XADFinderFlags;


@class UniversalDetector;
Expand Down Expand Up @@ -76,6 +79,7 @@ extern NSString *const XADFinderFlags;

@end

XADEXPORT
@interface XADArchive:NSObject <XADArchiveDelegate, XADUnarchiverDelegate, XADArchiveParserDelegate>
{
XADArchiveParser *parser;
Expand Down Expand Up @@ -192,24 +196,24 @@ dataFork:(BOOL)datafork resourceFork:(BOOL)resfork;

// Deprecated

+(NSArray *)volumesForFile:(NSString *)filename;
+(NSArray *)volumesForFile:(NSString *)filename DEPRECATED_ATTRIBUTE;

-(int)sizeOfEntry:(int)n;
-(void *)xadFileInfoForEntry:(int)n;
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override;
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override resourceFork:(BOOL)resfork;
-(void)fixWritePermissions;
-(int)sizeOfEntry:(int)n DEPRECATED_ATTRIBUTE;
-(void *)xadFileInfoForEntry:(int)n DEPRECATED_ATTRIBUTE;
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override DEPRECATED_ATTRIBUTE;
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override resourceFork:(BOOL)resfork DEPRECATED_ATTRIBUTE;
-(void)fixWritePermissions DEPRECATED_ATTRIBUTE;

@end


#ifndef XAD_NO_DEPRECATED

#define XADAbort XADAbortAction
#define XADRetry XADRetryAction
#define XADSkip XADSkipAction
#define XADOverwrite XADOverwriteAction
#define XADRename XADRenameAction
static const XADAction XADAbort API_DEPRECATED_WITH_REPLACEMENT("XADActionAbort", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionAbort;
static const XADAction XADRetry API_DEPRECATED_WITH_REPLACEMENT("XADActionRetry", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRetry;
static const XADAction XADSkip API_DEPRECATED_WITH_REPLACEMENT("XADActionSkip", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionSkip;
static const XADAction XADOverwrite API_DEPRECATED_WITH_REPLACEMENT("XADActionOverwrite", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionOverwrite;
static const XADAction XADRename API_DEPRECATED_WITH_REPLACEMENT("XADActionRename", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRename;

typedef XADError xadERROR;
typedef off_t xadSize;
Expand Down Expand Up @@ -243,10 +247,10 @@ typedef off_t xadSize;
#define XADEncodingError 0x0019 /* text encoding was defective */
#endif

#define XADAbort XADAbortAction
#define XADRetry XADRetryAction
#define XADSkip XADSkipAction
#define XADOverwrite XADOverwriteAction
#define XADRename XADRenameAction

#endif

static const XADAction XADAbortAction API_DEPRECATED_WITH_REPLACEMENT("XADActionAbort", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionAbort;
static const XADAction XADRetryAction API_DEPRECATED_WITH_REPLACEMENT("XADActionRetry", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRetry;
static const XADAction XADSkipAction API_DEPRECATED_WITH_REPLACEMENT("XADActionSkip", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionSkip;
static const XADAction XADOverwriteAction API_DEPRECATED_WITH_REPLACEMENT("XADActionOverwrite", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionOverwrite;
static const XADAction XADRenameAction API_DEPRECATED_WITH_REPLACEMENT("XADActionRename", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRename;
40 changes: 20 additions & 20 deletions XADArchive.m
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ -(NSDictionary *)attributesOfEntry:(int)n withResourceFork:(BOOL)resfork
{
lasterror=[XADException parseException:e];
XADAction action=[delegate archive:self extractionOfResourceForkForEntryDidFail:n error:lasterror];
if(action==XADSkipAction) break;
else if(action!=XADRetryAction) return nil;
if(action==XADActionSkip) break;
else if(action!=XADActionRetry) return nil;
}
}
}
Expand Down Expand Up @@ -835,8 +835,8 @@ -(BOOL)extractEntry:(int)n to:(NSString *)destination deferDirectories:(BOOL)def
{
XADAction action=[delegate archive:self nameDecodingDidFailForEntry:n
data:[[[self dataForkParserDictionaryForEntry:n] objectForKey:XADFileNameKey] data]];
if(action==XADSkipAction) return YES;
else if(action!=XADRetryAction)
if(action==XADActionSkip) return YES;
else if(action!=XADActionRetry)
{
lasterror=XADBreakError;
return NO;
Expand All @@ -859,8 +859,8 @@ -(BOOL)extractEntry:(int)n to:(NSString *)destination deferDirectories:(BOOL)def
{
XADAction action=[delegate archive:self extractionOfEntryDidFail:n error:lasterror];

if(action==XADSkipAction) return YES;
else if(action!=XADRetryAction) return NO;
if(action==XADActionSkip) return YES;
else if(action!=XADActionRetry) return NO;
}
else return NO;
}
Expand Down Expand Up @@ -901,8 +901,8 @@ -(BOOL)extractArchiveEntry:(int)n to:(NSString *)destination
{
XADAction action=[delegate archive:self extractionOfEntryDidFail:n error:err];

if(action==XADSkipAction) return YES;
else if(action!=XADRetryAction) return NO;
if(action==XADActionSkip) return YES;
else if(action!=XADActionRetry) return NO;
}
else return NO;
}
Expand All @@ -924,8 +924,8 @@ -(BOOL)_extractEntry:(int)n as:(NSString *)destfile deferDirectories:(BOOL)defer
else if(delegate)
{
XADAction action=[delegate archive:self creatingDirectoryDidFailForEntry:n];
if(action==XADSkipAction) return YES;
else if(action!=XADRetryAction)
if(action==XADActionSkip) return YES;
else if(action!=XADActionRetry)
{
lasterror=XADBreakError;
return NO;
Expand Down Expand Up @@ -955,10 +955,10 @@ -(BOOL)_extractEntry:(int)n as:(NSString *)destfile deferDirectories:(BOOL)defer
}
else action=[delegate archive:self entry:n collidesWithFile:destfile newFilename:&newname];

if(action==XADOverwriteAction&&!dir) break;
else if(action==XADSkipAction) return YES;
else if(action==XADRenameAction) destfile=[[destfile stringByDeletingLastPathComponent] stringByAppendingPathComponent:newname];
else if(action!=XADRetryAction)
if(action==XADActionOverwrite&&!dir) break;
else if(action==XADActionSkip) return YES;
else if(action==XADActionRename) destfile=[[destfile stringByDeletingLastPathComponent] stringByAppendingPathComponent:newname];
else if(action!=XADActionRetry)
{
lasterror=XADBreakError;
return NO;
Expand Down Expand Up @@ -1175,7 +1175,7 @@ -(XADAction)archive:(XADArchive *)archive nameDecodingDidFailForEntry:(NSInteger
[terminateddata release];
return action;
} else {
return XADAbortAction;
return XADActionAbort;
}
}

Expand All @@ -1202,7 +1202,7 @@ -(XADAction)archive:(XADArchive *)arc entry:(NSInteger)n collidesWithFile:(NSStr
if ([delegate respondsToSelector:@selector(archive:entry:collidesWithFile:newFilename:)]) {
return [delegate archive:arc entry:n collidesWithFile:file newFilename:newname];
} else {
return XADOverwriteAction;
return XADActionOverwrite;
}
}

Expand All @@ -1211,7 +1211,7 @@ -(XADAction)archive:(XADArchive *)arc entry:(NSInteger)n collidesWithDirectory:(
if ([delegate respondsToSelector:@selector(archive:entry:collidesWithDirectory:newFilename:)]) {
return [delegate archive:arc entry:n collidesWithDirectory:file newFilename:newname];
} else {
return XADSkipAction;
return XADActionSkip;
}
}

Expand All @@ -1220,7 +1220,7 @@ -(XADAction)archive:(XADArchive *)arc creatingDirectoryDidFailForEntry:(NSIntege
if ([delegate respondsToSelector:@selector(archive:creatingDirectoryDidFailForEntry:)]) {
return [delegate archive:arc creatingDirectoryDidFailForEntry:n];
} else {
return XADAbortAction;
return XADActionAbort;
}
}

Expand Down Expand Up @@ -1257,7 +1257,7 @@ -(XADAction)archive:(XADArchive *)arc extractionOfEntryDidFail:(NSInteger)n erro
if ([delegate respondsToSelector:@selector(archive:extractionOfEntryDidFail:error:)]) {
return [delegate archive:arc extractionOfEntryDidFail:n error:error];
} else {
return XADAbortAction;
return XADActionAbort;
}
}

Expand All @@ -1266,7 +1266,7 @@ -(XADAction)archive:(XADArchive *)arc extractionOfResourceForkForEntryDidFail:(N
if ([delegate respondsToSelector:@selector(archive:extractionOfResourceForkForEntryDidFail:error:)]) {
return [delegate archive:arc extractionOfResourceForkForEntryDidFail:n error:error];
} else {
return XADAbortAction;
return XADActionAbort;
}
}

Expand Down
6 changes: 3 additions & 3 deletions XADArchiveParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ XADEXTERN XADArchiveKeys const XADParserClass;

@protocol XADArchiveParserDelegate;

XADEXPORT
@interface XADArchiveParser:NSObject
{
CSHandle *sourcehandle;
Expand Down Expand Up @@ -152,8 +153,7 @@ resourceFork:(XADResourceFork *)fork name:(NSString *)name propertiesToAdd:(NSMu

@property (nonatomic, retain) CSHandle *handle;
@property (retain) XADResourceFork *resourceFork;
-(NSString *)name;
-(void)setName:(NSString *)newname;
@property (nonatomic, copy) NSString *name;
-(NSString *)filename;
-(void)setFilename:(NSString *)filename;
-(NSArray *)allFilenames;
Expand All @@ -162,7 +162,7 @@ resourceFork:(XADResourceFork *)fork name:(NSString *)name propertiesToAdd:(NSMu
@property (assign) id<XADArchiveParserDelegate> delegate;

@property (readonly, copy) NSDictionary *properties;
-(NSString *)currentFilename;
@property (nonatomic, readonly, copy) NSString *currentFilename;

@property (readonly, nonatomic, getter=isEncrypted) BOOL encrypted;
@property (nonatomic, copy) NSString *password;
Expand Down
Loading

0 comments on commit 9b891eb

Please sign in to comment.