Skip to content

Commit 9b891eb

Browse files
committed
Fix oversights:
Add XADEXPORT to public classes, and XADEXTERN to public functions. Add missing XADStringEncodingName renames in XADPath. Make XADAction an NS_ENUM.
1 parent 8bcbf0a commit 9b891eb

23 files changed

Lines changed: 172 additions & 143 deletions

CSHandle.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
#endif
4343

4444

45-
extern NSExceptionName const CSOutOfMemoryException;
46-
extern NSExceptionName const CSEndOfFileException;
47-
extern NSExceptionName const CSNotImplementedException;
48-
extern NSExceptionName const CSNotSupportedException;
49-
45+
XADEXTERN NSExceptionName const CSOutOfMemoryException;
46+
XADEXTERN NSExceptionName const CSEndOfFileException;
47+
XADEXTERN NSExceptionName const CSNotImplementedException;
48+
XADEXTERN NSExceptionName const CSNotSupportedException;
5049

5150

51+
XADEXPORT
5252
@interface CSHandle:NSObject <NSCopying>
5353
{
5454
CSHandle *parent;

CSInputBuffer.h

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ typedef struct CSInputBuffer
4141

4242
// Allocation and management
4343

44-
CSInputBuffer *CSInputBufferAlloc(CSHandle *parent,int size);
45-
CSInputBuffer *CSInputBufferAllocWithBuffer(const uint8_t *buffer,int length,off_t startoffs);
46-
CSInputBuffer *CSInputBufferAllocEmpty(void);
47-
void CSInputBufferFree(CSInputBuffer *self);
44+
XADEXPORT CSInputBuffer *CSInputBufferAlloc(CSHandle *parent,int size);
45+
XADEXPORT CSInputBuffer *CSInputBufferAllocWithBuffer(const uint8_t *buffer,int length,off_t startoffs);
46+
XADEXPORT CSInputBuffer *CSInputBufferAllocEmpty(void);
47+
XADEXPORT void CSInputBufferFree(CSInputBuffer *self);
4848

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

5151
static inline CSHandle *CSInputHandle(CSInputBuffer *self)
5252
{
@@ -57,18 +57,18 @@ static inline CSHandle *CSInputHandle(CSInputBuffer *self)
5757

5858
// Buffer and file positioning
5959

60-
void CSInputRestart(CSInputBuffer *self);
61-
void CSInputFlush(CSInputBuffer *self);
60+
XADEXPORT void CSInputRestart(CSInputBuffer *self);
61+
XADEXPORT void CSInputFlush(CSInputBuffer *self);
6262

63-
void CSInputSynchronizeFileOffset(CSInputBuffer *self);
64-
void CSInputSeekToFileOffset(CSInputBuffer *self,off_t offset);
65-
void CSInputSeekToBufferOffset(CSInputBuffer *self,off_t offset);
66-
void CSInputSetStartOffset(CSInputBuffer *self,off_t offset);
67-
off_t CSInputBufferOffset(CSInputBuffer *self);
68-
off_t CSInputFileOffset(CSInputBuffer *self);
69-
off_t CSInputBufferBitOffset(CSInputBuffer *self);
63+
XADEXPORT void CSInputSynchronizeFileOffset(CSInputBuffer *self);
64+
XADEXPORT void CSInputSeekToFileOffset(CSInputBuffer *self,off_t offset);
65+
XADEXPORT void CSInputSeekToBufferOffset(CSInputBuffer *self,off_t offset);
66+
XADEXPORT void CSInputSetStartOffset(CSInputBuffer *self,off_t offset);
67+
XADEXPORT off_t CSInputBufferOffset(CSInputBuffer *self);
68+
XADEXPORT off_t CSInputFileOffset(CSInputBuffer *self);
69+
XADEXPORT off_t CSInputBufferBitOffset(CSInputBuffer *self);
7070

71-
void _CSInputFillBuffer(CSInputBuffer *self);
71+
XADEXPORT void _CSInputFillBuffer(CSInputBuffer *self);
7272

7373

7474

@@ -129,21 +129,21 @@ static inline BOOL CSInputAtEOF(CSInputBuffer *self)
129129

130130
// Bitstream reading
131131

132-
void _CSInputFillBits(CSInputBuffer *self);
133-
void _CSInputFillBitsLE(CSInputBuffer *self);
132+
XADEXPORT void _CSInputFillBits(CSInputBuffer *self);
133+
XADEXPORT void _CSInputFillBitsLE(CSInputBuffer *self);
134134

135-
unsigned int CSInputNextBit(CSInputBuffer *self);
136-
unsigned int CSInputNextBitLE(CSInputBuffer *self);
137-
unsigned int CSInputNextBitString(CSInputBuffer *self,int numbits);
138-
unsigned int CSInputNextBitStringLE(CSInputBuffer *self,int numbits);
139-
unsigned int CSInputNextLongBitString(CSInputBuffer *self,int numbits);
140-
unsigned int CSInputNextLongBitStringLE(CSInputBuffer *self,int numbits);
135+
XADEXPORT unsigned int CSInputNextBit(CSInputBuffer *self);
136+
XADEXPORT unsigned int CSInputNextBitLE(CSInputBuffer *self);
137+
XADEXPORT unsigned int CSInputNextBitString(CSInputBuffer *self,int numbits);
138+
XADEXPORT unsigned int CSInputNextBitStringLE(CSInputBuffer *self,int numbits);
139+
XADEXPORT unsigned int CSInputNextLongBitString(CSInputBuffer *self,int numbits);
140+
XADEXPORT unsigned int CSInputNextLongBitStringLE(CSInputBuffer *self,int numbits);
141141

142-
void CSInputSkipBits(CSInputBuffer *self,int numbits);
143-
void CSInputSkipBitsLE(CSInputBuffer *self,int numbits);
144-
BOOL CSInputOnByteBoundary(CSInputBuffer *self);
145-
void CSInputSkipToByteBoundary(CSInputBuffer *self);
146-
void CSInputSkipTo16BitBoundary(CSInputBuffer *self);
142+
XADEXPORT void CSInputSkipBits(CSInputBuffer *self,int numbits);
143+
XADEXPORT void CSInputSkipBitsLE(CSInputBuffer *self,int numbits);
144+
XADEXPORT BOOL CSInputOnByteBoundary(CSInputBuffer *self);
145+
XADEXPORT void CSInputSkipToByteBoundary(CSInputBuffer *self);
146+
XADEXPORT void CSInputSkipTo16BitBoundary(CSInputBuffer *self);
147147

148148
static inline unsigned int CSInputBitsLeftInBuffer(CSInputBuffer *self)
149149
{
@@ -211,14 +211,14 @@ static inline type name(CSInputBuffer *self) \
211211
return val; \
212212
}
213213

214-
CSInputNextValueImpl(int16_t,CSInputNextInt16LE,CSInt16LE)
215-
CSInputNextValueImpl(int32_t,CSInputNextInt32LE,CSInt32LE)
216-
CSInputNextValueImpl(uint16_t,CSInputNextUInt16LE,CSUInt16LE)
217-
CSInputNextValueImpl(uint32_t,CSInputNextUInt32LE,CSUInt32LE)
218-
CSInputNextValueImpl(int16_t,CSInputNextInt16BE,CSInt16BE)
219-
CSInputNextValueImpl(int32_t,CSInputNextInt32BE,CSInt32BE)
220-
CSInputNextValueImpl(uint16_t,CSInputNextUInt16BE,CSUInt16BE)
221-
CSInputNextValueImpl(uint32_t,CSInputNextUInt32BE,CSUInt32BE)
214+
XADEXPORT CSInputNextValueImpl(int16_t,CSInputNextInt16LE,CSInt16LE)
215+
XADEXPORT CSInputNextValueImpl(int32_t,CSInputNextInt32LE,CSInt32LE)
216+
XADEXPORT CSInputNextValueImpl(uint16_t,CSInputNextUInt16LE,CSUInt16LE)
217+
XADEXPORT CSInputNextValueImpl(uint32_t,CSInputNextUInt32LE,CSUInt32LE)
218+
XADEXPORT CSInputNextValueImpl(int16_t,CSInputNextInt16BE,CSInt16BE)
219+
XADEXPORT CSInputNextValueImpl(int32_t,CSInputNextInt32BE,CSInt32BE)
220+
XADEXPORT CSInputNextValueImpl(uint16_t,CSInputNextUInt16BE,CSUInt16BE)
221+
XADEXPORT CSInputNextValueImpl(uint32_t,CSInputNextUInt32BE,CSUInt32BE)
222222

223223

224224

CSMemoryHandle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#define CSMemoryHandle XADMemoryHandle
2727

28+
XADEXPORT
2829
@interface CSMemoryHandle:CSHandle
2930
{
3031
NSData *backingdata;

CSStreamHandle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#define CSStreamHandle XADStreamHandle
2828

29+
XADEXPORT
2930
@interface CSStreamHandle:CSHandle
3031
{
3132
off_t streampos,streamlength;

CSSubHandle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#define CSSubHandle XADSubHandle
2727

28+
XADEXPORT
2829
@interface CSSubHandle:CSHandle
2930
{
3031
off_t start,end;

XADArchive.h

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@
2727
#import "XADException.h"
2828
#pragma clang diagnostic pop
2929

30-
//TODO: wrap in an emum
31-
typedef int XADAction;
32-
//typedef off_t xadSize; // deprecated
30+
#if __has_feature(modules)
31+
# define XAD_NO_DEPRECATED
32+
#endif
3333

34-
#define XADAbortAction 0
35-
#define XADRetryAction 1
36-
#define XADSkipAction 2
37-
#define XADOverwriteAction 3
38-
#define XADRenameAction 4
34+
typedef NS_ENUM(int, XADAction) {
35+
XADActionAbort = 0,
36+
XADActionRetry = 1,
37+
XADActionSkip = 2,
38+
XADActionOverwrite = 3,
39+
XADActionRename = 4
40+
};
41+
//typedef off_t xadSize; // deprecated
3942

40-
extern NSString *const XADResourceDataKey;
41-
extern NSString *const XADFinderFlags;
43+
XADEXTERN NSString *const XADResourceDataKey;
44+
XADEXTERN NSString *const XADFinderFlags;
4245

4346

4447
@class UniversalDetector;
@@ -76,6 +79,7 @@ extern NSString *const XADFinderFlags;
7679

7780
@end
7881

82+
XADEXPORT
7983
@interface XADArchive:NSObject <XADArchiveDelegate, XADUnarchiverDelegate, XADArchiveParserDelegate>
8084
{
8185
XADArchiveParser *parser;
@@ -192,24 +196,24 @@ dataFork:(BOOL)datafork resourceFork:(BOOL)resfork;
192196

193197
// Deprecated
194198

195-
+(NSArray *)volumesForFile:(NSString *)filename;
199+
+(NSArray *)volumesForFile:(NSString *)filename DEPRECATED_ATTRIBUTE;
196200

197-
-(int)sizeOfEntry:(int)n;
198-
-(void *)xadFileInfoForEntry:(int)n;
199-
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override;
200-
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override resourceFork:(BOOL)resfork;
201-
-(void)fixWritePermissions;
201+
-(int)sizeOfEntry:(int)n DEPRECATED_ATTRIBUTE;
202+
-(void *)xadFileInfoForEntry:(int)n DEPRECATED_ATTRIBUTE;
203+
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override DEPRECATED_ATTRIBUTE;
204+
-(BOOL)extractEntry:(int)n to:(NSString *)destination overrideWritePermissions:(BOOL)override resourceFork:(BOOL)resfork DEPRECATED_ATTRIBUTE;
205+
-(void)fixWritePermissions DEPRECATED_ATTRIBUTE;
202206

203207
@end
204208

205209

206210
#ifndef XAD_NO_DEPRECATED
207211

208-
#define XADAbort XADAbortAction
209-
#define XADRetry XADRetryAction
210-
#define XADSkip XADSkipAction
211-
#define XADOverwrite XADOverwriteAction
212-
#define XADRename XADRenameAction
212+
static const XADAction XADAbort API_DEPRECATED_WITH_REPLACEMENT("XADActionAbort", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionAbort;
213+
static const XADAction XADRetry API_DEPRECATED_WITH_REPLACEMENT("XADActionRetry", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRetry;
214+
static const XADAction XADSkip API_DEPRECATED_WITH_REPLACEMENT("XADActionSkip", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionSkip;
215+
static const XADAction XADOverwrite API_DEPRECATED_WITH_REPLACEMENT("XADActionOverwrite", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionOverwrite;
216+
static const XADAction XADRename API_DEPRECATED_WITH_REPLACEMENT("XADActionRename", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRename;
213217

214218
typedef XADError xadERROR;
215219
typedef off_t xadSize;
@@ -243,10 +247,10 @@ typedef off_t xadSize;
243247
#define XADEncodingError 0x0019 /* text encoding was defective */
244248
#endif
245249

246-
#define XADAbort XADAbortAction
247-
#define XADRetry XADRetryAction
248-
#define XADSkip XADSkipAction
249-
#define XADOverwrite XADOverwriteAction
250-
#define XADRename XADRenameAction
251-
252250
#endif
251+
252+
static const XADAction XADAbortAction API_DEPRECATED_WITH_REPLACEMENT("XADActionAbort", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionAbort;
253+
static const XADAction XADRetryAction API_DEPRECATED_WITH_REPLACEMENT("XADActionRetry", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRetry;
254+
static const XADAction XADSkipAction API_DEPRECATED_WITH_REPLACEMENT("XADActionSkip", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionSkip;
255+
static const XADAction XADOverwriteAction API_DEPRECATED_WITH_REPLACEMENT("XADActionOverwrite", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionOverwrite;
256+
static const XADAction XADRenameAction API_DEPRECATED_WITH_REPLACEMENT("XADActionRename", macosx(10.0, 10.8), ios(3.0, 8.0)) = XADActionRename;

XADArchive.m

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,8 @@ -(NSDictionary *)attributesOfEntry:(int)n withResourceFork:(BOOL)resfork
673673
{
674674
lasterror=[XADException parseException:e];
675675
XADAction action=[delegate archive:self extractionOfResourceForkForEntryDidFail:n error:lasterror];
676-
if(action==XADSkipAction) break;
677-
else if(action!=XADRetryAction) return nil;
676+
if(action==XADActionSkip) break;
677+
else if(action!=XADActionRetry) return nil;
678678
}
679679
}
680680
}
@@ -835,8 +835,8 @@ -(BOOL)extractEntry:(int)n to:(NSString *)destination deferDirectories:(BOOL)def
835835
{
836836
XADAction action=[delegate archive:self nameDecodingDidFailForEntry:n
837837
data:[[[self dataForkParserDictionaryForEntry:n] objectForKey:XADFileNameKey] data]];
838-
if(action==XADSkipAction) return YES;
839-
else if(action!=XADRetryAction)
838+
if(action==XADActionSkip) return YES;
839+
else if(action!=XADActionRetry)
840840
{
841841
lasterror=XADBreakError;
842842
return NO;
@@ -859,8 +859,8 @@ -(BOOL)extractEntry:(int)n to:(NSString *)destination deferDirectories:(BOOL)def
859859
{
860860
XADAction action=[delegate archive:self extractionOfEntryDidFail:n error:lasterror];
861861

862-
if(action==XADSkipAction) return YES;
863-
else if(action!=XADRetryAction) return NO;
862+
if(action==XADActionSkip) return YES;
863+
else if(action!=XADActionRetry) return NO;
864864
}
865865
else return NO;
866866
}
@@ -901,8 +901,8 @@ -(BOOL)extractArchiveEntry:(int)n to:(NSString *)destination
901901
{
902902
XADAction action=[delegate archive:self extractionOfEntryDidFail:n error:err];
903903

904-
if(action==XADSkipAction) return YES;
905-
else if(action!=XADRetryAction) return NO;
904+
if(action==XADActionSkip) return YES;
905+
else if(action!=XADActionRetry) return NO;
906906
}
907907
else return NO;
908908
}
@@ -924,8 +924,8 @@ -(BOOL)_extractEntry:(int)n as:(NSString *)destfile deferDirectories:(BOOL)defer
924924
else if(delegate)
925925
{
926926
XADAction action=[delegate archive:self creatingDirectoryDidFailForEntry:n];
927-
if(action==XADSkipAction) return YES;
928-
else if(action!=XADRetryAction)
927+
if(action==XADActionSkip) return YES;
928+
else if(action!=XADActionRetry)
929929
{
930930
lasterror=XADBreakError;
931931
return NO;
@@ -955,10 +955,10 @@ -(BOOL)_extractEntry:(int)n as:(NSString *)destfile deferDirectories:(BOOL)defer
955955
}
956956
else action=[delegate archive:self entry:n collidesWithFile:destfile newFilename:&newname];
957957

958-
if(action==XADOverwriteAction&&!dir) break;
959-
else if(action==XADSkipAction) return YES;
960-
else if(action==XADRenameAction) destfile=[[destfile stringByDeletingLastPathComponent] stringByAppendingPathComponent:newname];
961-
else if(action!=XADRetryAction)
958+
if(action==XADActionOverwrite&&!dir) break;
959+
else if(action==XADActionSkip) return YES;
960+
else if(action==XADActionRename) destfile=[[destfile stringByDeletingLastPathComponent] stringByAppendingPathComponent:newname];
961+
else if(action!=XADActionRetry)
962962
{
963963
lasterror=XADBreakError;
964964
return NO;
@@ -1175,7 +1175,7 @@ -(XADAction)archive:(XADArchive *)archive nameDecodingDidFailForEntry:(NSInteger
11751175
[terminateddata release];
11761176
return action;
11771177
} else {
1178-
return XADAbortAction;
1178+
return XADActionAbort;
11791179
}
11801180
}
11811181

@@ -1202,7 +1202,7 @@ -(XADAction)archive:(XADArchive *)arc entry:(NSInteger)n collidesWithFile:(NSStr
12021202
if ([delegate respondsToSelector:@selector(archive:entry:collidesWithFile:newFilename:)]) {
12031203
return [delegate archive:arc entry:n collidesWithFile:file newFilename:newname];
12041204
} else {
1205-
return XADOverwriteAction;
1205+
return XADActionOverwrite;
12061206
}
12071207
}
12081208

@@ -1211,7 +1211,7 @@ -(XADAction)archive:(XADArchive *)arc entry:(NSInteger)n collidesWithDirectory:(
12111211
if ([delegate respondsToSelector:@selector(archive:entry:collidesWithDirectory:newFilename:)]) {
12121212
return [delegate archive:arc entry:n collidesWithDirectory:file newFilename:newname];
12131213
} else {
1214-
return XADSkipAction;
1214+
return XADActionSkip;
12151215
}
12161216
}
12171217

@@ -1220,7 +1220,7 @@ -(XADAction)archive:(XADArchive *)arc creatingDirectoryDidFailForEntry:(NSIntege
12201220
if ([delegate respondsToSelector:@selector(archive:creatingDirectoryDidFailForEntry:)]) {
12211221
return [delegate archive:arc creatingDirectoryDidFailForEntry:n];
12221222
} else {
1223-
return XADAbortAction;
1223+
return XADActionAbort;
12241224
}
12251225
}
12261226

@@ -1257,7 +1257,7 @@ -(XADAction)archive:(XADArchive *)arc extractionOfEntryDidFail:(NSInteger)n erro
12571257
if ([delegate respondsToSelector:@selector(archive:extractionOfEntryDidFail:error:)]) {
12581258
return [delegate archive:arc extractionOfEntryDidFail:n error:error];
12591259
} else {
1260-
return XADAbortAction;
1260+
return XADActionAbort;
12611261
}
12621262
}
12631263

@@ -1266,7 +1266,7 @@ -(XADAction)archive:(XADArchive *)arc extractionOfResourceForkForEntryDidFail:(N
12661266
if ([delegate respondsToSelector:@selector(archive:extractionOfResourceForkForEntryDidFail:error:)]) {
12671267
return [delegate archive:arc extractionOfResourceForkForEntryDidFail:n error:error];
12681268
} else {
1269-
return XADAbortAction;
1269+
return XADActionAbort;
12701270
}
12711271
}
12721272

XADArchiveParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ XADEXTERN XADArchiveKeys const XADParserClass;
101101

102102
@protocol XADArchiveParserDelegate;
103103

104+
XADEXPORT
104105
@interface XADArchiveParser:NSObject
105106
{
106107
CSHandle *sourcehandle;
@@ -152,8 +153,7 @@ resourceFork:(XADResourceFork *)fork name:(NSString *)name propertiesToAdd:(NSMu
152153

153154
@property (nonatomic, retain) CSHandle *handle;
154155
@property (retain) XADResourceFork *resourceFork;
155-
-(NSString *)name;
156-
-(void)setName:(NSString *)newname;
156+
@property (nonatomic, copy) NSString *name;
157157
-(NSString *)filename;
158158
-(void)setFilename:(NSString *)filename;
159159
-(NSArray *)allFilenames;
@@ -162,7 +162,7 @@ resourceFork:(XADResourceFork *)fork name:(NSString *)name propertiesToAdd:(NSMu
162162
@property (assign) id<XADArchiveParserDelegate> delegate;
163163

164164
@property (readonly, copy) NSDictionary *properties;
165-
-(NSString *)currentFilename;
165+
@property (nonatomic, readonly, copy) NSString *currentFilename;
166166

167167
@property (readonly, nonatomic, getter=isEncrypted) BOOL encrypted;
168168
@property (nonatomic, copy) NSString *password;

0 commit comments

Comments
 (0)