1 // RegisterArc.h 2 3 #ifndef __REGISTER_ARC_H 4 #define __REGISTER_ARC_H 5 6 #include "../Archive/IArchive.h" 7 8 struct CArcInfo 9 { 10 const char *Name; 11 const char *Ext; 12 const char *AddExt; 13 14 Byte ClassId; 15 16 Byte SignatureSize; 17 Byte Signature[20]; 18 UInt16 SignatureOffset; 19 20 UInt16 Flags; 21 22 Func_CreateInArchive CreateInArchive; 23 Func_CreateOutArchive CreateOutArchive; 24 Func_IsArc IsArc; 25 IsMultiSignatureCArcInfo26 bool IsMultiSignature() const { return (Flags & NArcInfoFlags::kMultiSignature) != 0; } 27 }; 28 29 void RegisterArc(const CArcInfo *arcInfo) throw(); 30 31 #define REGISTER_ARC_NAME(x) CRegister ## x 32 33 #define REGISTER_ARC(x) struct REGISTER_ARC_NAME(x) { \ 34 REGISTER_ARC_NAME(x)() { RegisterArc(&g_ArcInfo); }}; \ 35 static REGISTER_ARC_NAME(x) g_RegisterArc; 36 37 #define REGISTER_ARC_DEC_SIG(x) struct REGISTER_ARC_NAME(x) { \ 38 REGISTER_ARC_NAME(x)() { g_ArcInfo.Signature[0]--; RegisterArc(&g_ArcInfo); }}; \ 39 static REGISTER_ARC_NAME(x) g_RegisterArc; 40 41 42 #define IMP_CreateArcIn_2(c) \ 43 static IInArchive *CreateArc() { return new c; } 44 45 #define IMP_CreateArcIn IMP_CreateArcIn_2(CHandler) 46 47 #ifdef EXTRACT_ONLY 48 #define IMP_CreateArcOut 49 #define REF_CreateArc_Pair CreateArc, NULL 50 #else 51 #define IMP_CreateArcOut static IOutArchive *CreateArcOut() { return new CHandler; } 52 #define REF_CreateArc_Pair CreateArc, CreateArcOut 53 #endif 54 55 #endif 56