1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// RegisterArc.h
2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#ifndef __REGISTER_ARC_H
4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define __REGISTER_ARC_H
5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../Archive/IArchive.h"
7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
8baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CArcInfo
9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{
10f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  UInt16 Flags;
11f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  Byte Id;
12f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  Byte SignatureSize;
13f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  UInt16 SignatureOffset;
14f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
15f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  const Byte *Signature;
16cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  const char *Name;
17cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  const char *Ext;
18cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  const char *AddExt;
19cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
20cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  Func_CreateInArchive CreateInArchive;
21cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  Func_CreateOutArchive CreateOutArchive;
22cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  Func_IsArc IsArc;
23cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
24cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  bool IsMultiSignature() const { return (Flags & NArcInfoFlags::kMultiSignature) != 0; }
25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync};
26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
27cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbeckyvoid RegisterArc(const CArcInfo *arcInfo) throw();
28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
29cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
30cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#define IMP_CreateArcIn_2(c) \
31cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  static IInArchive *CreateArc() { return new c; }
32cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
33f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define IMP_CreateArcIn IMP_CreateArcIn_2(CHandler())
34cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
35cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#ifdef EXTRACT_ONLY
36cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  #define IMP_CreateArcOut
37f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  #define CreateArcOut NULL
38cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#else
39f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  #define IMP_CreateArcOut static IOutArchive *CreateArcOut() { return new CHandler(); }
40cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#endif
41cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
42f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
43f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  static const CArcInfo g_ArcInfo = { flags, id, sigSize, offs, sig, n, e, ae, crIn, crOut, isArc } ; \
44f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
45f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_R(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
46f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
47f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  struct CRegisterArc { CRegisterArc() { RegisterArc(&g_ArcInfo); }}; \
48f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  static CRegisterArc g_RegisterArc;
49f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
50f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
51f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_I_CLS(cls, n, e, ae, id, sig, offs, flags, isArc) \
52f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  IMP_CreateArcIn_2(cls) \
53f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, NULL, isArc)
54f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
55f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_I_CLS_NO_SIG(cls, n, e, ae, id, offs, flags, isArc) \
56f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  IMP_CreateArcIn_2(cls) \
57f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  REGISTER_ARC_R(n, e, ae, id, 0, NULL, offs, flags, CreateArc, NULL, isArc)
58f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
59f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_I(n, e, ae, id, sig, offs, flags, isArc) \
60f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  REGISTER_ARC_I_CLS(CHandler(), n, e, ae, id, sig, offs, flags, isArc)
61f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
62f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_I_NO_SIG(n, e, ae, id, offs, flags, isArc) \
63f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  REGISTER_ARC_I_CLS_NO_SIG(CHandler(), n, e, ae, id, offs, flags, isArc)
64f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
65f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
66f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_IO(n, e, ae, id, sig, offs, flags, isArc) \
67f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  IMP_CreateArcIn \
68f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  IMP_CreateArcOut \
69f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc)
70f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
71f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka#define REGISTER_ARC_IO_DECREMENT_SIG(n, e, ae, id, sig, offs, flags, isArc) \
72f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  IMP_CreateArcIn \
73f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  IMP_CreateArcOut \
74f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  REGISTER_ARC_V(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc) \
75f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  struct CRegisterArcDecSig { CRegisterArcDecSig() { sig[0]--; RegisterArc(&g_ArcInfo); }}; \
76f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka  static CRegisterArcDecSig g_RegisterArc;
77f955a79a9fffb09826cf7547f70d08c3798a2f50Tetsuo Osaka
78baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif
79