/* COPYRIGHT(C) 2004-2005 hardkoder , http://www.kipple.pe.kr ÀúÀÛ±Ç Á¤º¸ : ( BSD License ) - ÀÌ ¼Ò½º´Â ÀÚÀ¯·ÎÀÌ »ç¿ë/¼öÁ¤/Àç¹èÆ÷ °¡´ÉÇÕ´Ï´Ù. - ´Ü, ´ç½ÅÀÌ ¸¸µé¾ú´Ù°í ÁÖÀåÇϰųª °ÅÁþ¸»ÇÏ¸é ¾ÈµÊ. - ¼Ò½ºÀÇ ¿À·ù¸¦ ã¾Ò°Å³ª, ¹®Á¦Á¡À» ¼öÁ¤ÇÏ¿´À» °æ¿ì ÀÌ¿¡ ´ëÇÑ ³»¿ëÀ» ¾Ë·ÁÁÖ¸é Á¤¸» °í¸¶¿ï²¬.. - ÀÚ½ÅÀÇ ÇÁ·Î±×·¥¿¡ ÀÌ ¼Ò½º¸¦ »ç¿ëÇÏ¿´À» °æ¿ì ¿ø ÀúÀÛÀÚ¿¡°Ô ¾Ë·ÁÁÖ¸é ¿ø ÀúÀÛÀÚ°¡ °í¸¶¿ö ÇÒ²¬.. ¼Ò½º ¼³¸í : - .ALZ ÀÇ ¾ÐÃàÀ» ÇØÁ¦Çϱâ À§ÇÑ ¸ðµâ. - ALZ´Â BZIP2º¯Çü(º¯ÇüÀ̶ó°í ¹¹ °³¼±ÇÑ°Ô ¾Æ´Ï°í, Çì´õ³ª CRC Á¤º¸µîÀ» »©¼­ Å©±â¸¦ ÁÙÀÎ °ÍÀÓ)°ú, DEFLATE ¾ÐÃà ¾Ë°í¸®Áò¿¡ ZIP°ú À¯»çÇÑ Çì´õ¸¦ ¸¸µé¾î¼­ ¾º¿î Æ÷¸ËÀÓ. ( bzip2 ´Â 4.9x ¿¡¼­ »ç¿ëÇÏ¿´°í, deflate ´Â 5.x ºÎÅÍ »ç¿ëÇÏ¿´À½. 5.x ºÎÅÍ´Â bzip2´Â ³Ê¹« ´À·Á¼­ »ç¿ë ¾ÈÇÔ ) - UnAlzBz2decompress.c ¿Í UnAlzbzlib.c ´Â ¿ø·¡ÀÇ bzip2 ¼Ò½º¿¡¼­ alz ¿ëÀ¸·Î ¼öÁ¤µÈ ÆÄÀÏÀÓ ( deflate ´Â º¯ÇüÀÌ ¾ÈµÇ¾ú±â ¶§¹®¿¡ ±×³É zlib ¸¦ ½áµµ µÇÁö¸¸.. bzip2 ´Â º¯ÇüÀÌ µÇ¾î¼­ ¿ø·¡ÀÇ bzip2 ¼Ò½º¸¦ ±×´ë·Î ¾²¸é ¾ÈµÈ´Ù. ) - ÀÌ ¼Ò½º´Â 4Ä­ ÅÇÀ» »ç¿ë ÇÏ¿´À½. °³¹ß ¼ø¼­ : 2004/02/06 - http://www.wotsit.org/ ¿¡¼­ ZIP File Format Specification version 4.5 [PKWARE Inc.] ¸¦ ´Ù¿î·Îµå ¹Þ¾Æ¼­ ºÐ¼®. 2004/02/07 - µµÅ¥¸ÕÆ®·Î unzip Ŭ·¡½º ´ëÃæ ±¸Çö 2004/02/08 - unzip Ŭ·¡½º¸¦ alzip Æ÷¸Ë¿¡ ¸ÂÃß¾î º¯Çü ¹× Å×½ºÆ® - deflate, rawdata ¾ÐÃà ÇØÁ¦ ±¸Çö. - ´ÙÀÌ¾Ë·Î±× ¹Ú½º ²®µ¥±â ¾º¿ò. 2004/02/08 - bzip2 ´ëÃæ Áö¿ø 2004/03/01 - bzip2 °ÅÀÇ ¿Ïº® Áö¿ø Ò¬ - callback ±¸Çö.. 2004/03/07 - À¯Æ¿ ÇÔ¼ö Ãß°¡ ( ExtractCurrentFileToBuf() ) 2004/10/03 - ºÐÇÒ ¾ÐÃà ÇØÁ¦ ±â´É Ãß°¡ ( FILE I/O ¿¡ ´ëÇÑ ·¡ÆÛ Å¬·¡½º ±¸Çö ) - 2GB ÀÌ»óÀÇ ÆÄÀÏ Ã³¸® Áö¿ø (WINDOWS ONLY) 2004/10/22 - ´ÙÁß Ç÷§Æû(BSD/LINUX)Áö¿øÀ» À§ÇÑ ¼öÁ¤ ( BSD/LINUX ÀÇ °æ¿ì 2GB ÀÌÇÏÀÇ ÆÄÀϸ¸ Áö¿ø ) - unalz 0.20 2004/10/23 - by xxfree86 : DARWIN ÄÄÆÄÀÏ Áö¿ø, °æ·Î¸í¿¡ "\\" Æ÷ÇԽà ¹®Á¦Á¡ ¼öÁ¤ 2004/10/24 - by aqua0125 : ÄÚµåÆäÀÌÁö º¯È¯Ã³¸®, 64bit ÆÄÀÏ Ã³¸® - ºò¿£µð¾È, ÄÚµåÆäÀÌÁö º¯È¯ °ü·Ã ¼Ò½º Á¤¸® 2004/10/25 - by yongari : __LP64__ , ºò¿£µð¾È(le64toh/le132oh/le16toh) °ü·Ã À̽´ ¼öÁ¤ 2004/10/26 - BSD/LINUX : byte-order, libiconv À̽´ Á¤¸® - unalz 0.22 2004/10/30 - Á¤¸® & Á¤¸®.. - unalz 0.23 2004/11/14 - by xxfree86 : ¾ÏÈ£ °É¸° ÆÄÀÏ Ã³¸® Ãß°¡ - unalz 0.30 2004/11/27 - cygwin¿¡¼­ ÄÄÆÄÀÏ µÇµµ·Ï ¼öÁ¤ - ¾Ïȣó¸® ºÎºÐ¿¡ ÀϺΠ»ç¿ëµÈ GPL ÀÇ CZipArchive Äڵ带 "ZIP File Format Specification version 4.5" ¹®¼­¸¦ Âü°íÇؼ­ ´Ù½Ã ÄÚµù & Á¤¸® - ¾ÏÈ£°É¸° ÆÄÀÏ°ú ¾È°É¸° ÆÄÀÏ ¼¯¿´À»¶§ ó¸® - ÆÄÀÏÀÇ µÞºÎºÐÀÌ Àß·Á¼­ ¼Õ»óµÈ ÆÄÀϵµ ¸ÖÂÄÇÑ ºÎºÐ±îÁö´Â ¾ÐÃàÀ» Ç®µµ·Ï ¼öÁ¤ - unalz 0.31 2005/01/08 - ¾ÏÈ£ À߸ø ÀԷ½à Çѹø üũÈÄ µÎ¹ø°´Â Á¤»ó ¾ÏÈ£¸¦ ÀÔ·ÂÇؼ­ Ç®Áö ¸øÇÏ°Ô µÇ´ø ¹ö±× ¼öÁ¤ 2005/02/05 - ¾ÐÃà ÇØÁ¦ÈÄ deflate ÀÇ ÆÄÀÏ CRC È®ÀÎ ±â´É Ãß°¡ 2005/03/07 - bzip2, raw ÆÄÀÏ¿¡ ´ëÇÑ ÆÄÀÏ CRC È®ÀÎ ±â´É Ãß°¡ 2005/03/13 - ALZ ÆÄÀÏÀÌ ¾Æ´Ò°æ¿ì ¿¡·¯ ÄÚµå(ERR_NOT_ALZ_FILE) Ãß°¡ 2005/06/16 - GetFileList() ÇÔ¼ö ¹ö±× ¼öÁ¤(¸®ÅÏŸÀÔ º¯°æ) 2005/06/18 - by goweol : utf-8 »ç¿ë½Ã ÆÄÀÏÀ̸§¿¡¼­ ¹öÆÛ ¿À¹öÇÃ·Î¿ì ¹ß»ýÇÏ´ø ¹ö±× ¼öÁ¤ - unalz 0.4 2005/06/22 - by goweol : -l ¿É¼ÇÀ¸·Î ÆÄÀÏ ¸®½ºÆà ±â´É Ãß°¡ - UnAlzUtils.cpp/h ÆÄÀÏÀ» ÇÁ·ÎÁ§Æ®¿¡ Ãß°¡ 2005/06/29 - by xxfree86 : MacOSX 10.4.1 gcc 4.0 ¿¡¼­ iconv °ü·Ã ÄÄÆÄÀÏ ¿¡·¯ ¼öÁ¤ - ºò¿£µð¾È¿¡¼­ CRC üũ½Ã ¿¡·¯ ¹ß»ýÇÏ´Â ¹®Á¦Á¡ ¼öÁ¤(?) 2005/07/02 - unalz Ä¿¸Çµå ¶óÀÎ ¹æ½Ä º¯°æ, ¾ÐÃàÇ® ´ë»ó ÆÄÀÏ ÁöÁ¤ ±â´É Ãß°¡.. - ¾ÐÃà ÇØÁ¦µÈ ÆÄÀϽð£À» ¿ø·¡ ½Ã°£À¸·Î ¼¼ÆÃÇÏ´Â ÄÚµå Ãß°¡ - from unalz_wcx_01i.zip 2005/07/09 - unalz 0.5 2005/07/24 - -d ·Î ´ë»ó °æ·Î¸¦ "/" ·Î ½ÃÀ۵Ǵ Àý´ë°æ·Î·Î ÁöÁ¤Çϸé ÇÁ·Î±×·¥ÀÌ Á×´ø ¹ö±× ¼öÁ¤(Pavel Roskin) - pipemode Ãß°¡ - ¸Þ½ÃÁö¾øÀÌ ÆÄÀÌÇÁ·Î Ãâ·ÂÇÑ´Ù(Pavel Roskin) - ¸®½ºÆ® ¸ðµå¿¡¼­ ÆÄÀÏ ³¯ÀÚ/½Ã°£À» ½Ã½ºÅÛ ·ÎÄÉÀÏ ¼³Á¤¿¡ µû¶ó¼­ Ç¥½Ã(Pavel Roskin) - Ä¿¸Çµå¶óÀο¡¼­ -pwd ¿É¼ÇÀ¸·Î ¾ÏÈ£ ÁöÁ¤±â´É Ãß°¡ - unalz 0.51 2005/07/27 - main() ¿¡ setlocale() Ãß°¡ - unalz 0.52 2005/10/15 - NetBSD ¿¡¼­ ÄÄÆÄÀÏ µÇµµ·Ï ¼öÁ¤ ( by minskim@bawi ) - unalz 0.53 2005/11/21 - ÆÄÀϸí ó¸®ÂÊ¿¡ ÀÖ´Â Buffer overflow ¹®Á¦ ¼öÁ¤ ( by Ulf Harnhammar ) - unalz 0.54 ±â´É : - alz ÆÄÀÏÀÇ ¾ÐÃà ÇØÁ¦ (deflate/º¯Çü bzip2/raw) - ºÐÇÒ ¾ÐÃà ÆÄÀÏ Áö¿ø (alz, a00, a01.. ) - ´Ù¾çÇÑ Ç÷¡Æû Áö¿ø (Win32/POSIX(BSD/LINUX/DARWIN)) - ¾ÏÈ£°É¸° ÆÄÀÏÀÇ ¾ÐÃà ÇØÁ¦ - µÞºÎºÐÀÌ À߸° ÆÄÀϵµ ¸ÖÂÄÇÑ ºÎºÐ±îÁö ¾ÐÃà ÇØÁ¦ °¡´É - CRC üũ±â´É ÄÄÆÄÀÏ ¿É¼Ç ( -DXXXX ) - _WIN32 : WIN32 - _UNALZ_ICONV : iconv ¸¦ »ç¿ëÇؼ­ code ÆäÀÌÁö º¯È¯ Áö¿ø - _UNALZ_UTF8 : _UNALZ_ICONV ¸¦ »ç¿ëÇÒ °æ¿ì ±âº» ÄÚµåÆäÀÌÁö¸¦ "UTF-8" ·Î ÁöÁ¤ */ #ifndef _UNALZ_H_ #define _UNALZ_H_ #include using namespace std; #ifndef INT64 #ifdef _WIN32 # define INT64 __int64 #else # define INT64 long long #endif #endif #ifndef UINT64 #ifdef _WIN32 # define UINT64 unsigned __int64 #else # define UINT64 unsigned long long #endif #endif #ifndef UINT32 typedef unsigned int UINT32; #endif #ifndef UINT16 typedef unsigned short UINT16; #endif #ifndef SHORT typedef short SHORT; #endif #ifndef BYTE typedef unsigned char BYTE; #endif #ifndef CHAR typedef char CHAR; #endif #ifndef BYTE typedef unsigned char BYTE; #endif #ifndef UINT typedef unsigned int UINT; #endif #ifndef LONG typedef long LONG; #endif #ifndef ULONG typedef unsigned long ULONG; // same as DWORD? i don't know. #endif #ifndef BOOL # ifndef BOOL_DEFINED // ÀÌ¹Ì BOOL ÀÌ DEFINE µÇ¾î ÀÖÀ¸¸é BOOL_DEFINED ¸¦ define Çؼ­ ÄÄÆÄÀÏ ¿¡·¯¸¦ ¸·À» ¼ö ÀÖ´Ù. typedef int BOOL; # endif #endif #ifndef FALSE # define FALSE 0 #endif #ifndef TRUE # define TRUE 1 #endif #ifndef HANDLE # ifdef _WIN32 typedef void *HANDLE; # else typedef FILE *HANDLE; # endif #endif #ifndef ASSERT # include //# define ASSERT(x) assert(x) # define ASSERT(x) {printf("unalz assert at file:%s line:%d\n", __FILE__, __LINE__);} #endif namespace UNALZ { #ifdef _WIN32 # pragma pack(push, UNALZ, 1) // structure packing #else # pragma pack(1) #endif static const char UNALZ_VERSION[] = "CUnAlz0.53"; static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004-2005 by hardkoder ( http://www.kipple.pe.kr ) "; enum {ENCR_HEADER_LEN=12}; // xf86 // ¸Ç ÆÄÀÏ ¾Õ.. struct SAlzHeader { UINT32 unknown; // ?? }; /* union _UGeneralPurposeBitFlag // zip ¿¡¼­¸¸ »ç¿ë.. { SHORT data; struct { BYTE bit0 : 1; BYTE bit1 : 1; BYTE bit2 : 1; BYTE bit3 : 1; BYTE bit4 : 1; BYTE bit5 : 1; }; }; */ enum COMPRESSION_METHOD ///< ¾ÐÃà ¹æ¹ý.. { COMP_NOCOMP = 0, COMP_BZIP2 = 1, COMP_DEFLATE = 2, COMP_UNKNOWN = 3, // unknown! }; enum ALZ_FILE_ATTRIBUTE { ALZ_FILEATTR_READONLY = 0x1, ALZ_FILEATTR_HIDDEN = 0x2, ALZ_FILEATTR_DIRECTORY = 0x10, ALZ_FILEATTR_FILE = 0x20, }; enum ALZ_FILE_DESCRIPTOR { ALZ_FILE_DESCRIPTOR_ENCRYPTED = 0x01, // ¾ÏÈ£ °É¸° ÆÄÀÏ ALZ_FILE_DESCRIPTOR_FILESIZEFIELD_1BYTE = 0x10, // ÆÄÀÏ Å©±â ÇʵåÀÇ Å©±â ALZ_FILE_DESCRIPTOR_FILESIZEFIELD_2BYTE = 0x20, ALZ_FILE_DESCRIPTOR_FILESIZEFIELD_4BYTE = 0x40, ALZ_FILE_DESCRIPTOR_FILESIZEFIELD_8BYTE = 0x80, }; struct _SLocalFileHeaderHead ///< °íÁ¤ Çì´õ. { SHORT fileNameLength; BYTE fileAttribute; // from http://www.zap.pe.kr, enum FILE_ATTRIBUE Âü°í UINT32 fileTimeDate; // dos file time BYTE fileDescriptor; ///< ÆÄÀÏ Å©±â ÇʵåÀÇ Å©±â : 0x10, 0x20, 0x40, 0x80 °¢°¢ 1byte, 2byte, 4byte, 8byte. ///< fileDescriptor & 1 == ¾ÏÈ£°É·È´ÂÁö ¿©ºÎ BYTE unknown2[1]; ///< ??? /* SHORT versionNeededToExtract; _UGeneralPurposeBitFlag generalPurposeBitFlag; SHORT compressionMethod; SHORT lastModFileTime; SHORT lastModFileDate; UINT32 crc32; UINT32 compressedSize; UINT32 uncompressedSize; SHORT fileNameLength; SHORT extraFieldLength; */ }; /* struct _SDataDescriptor { UINT32 crc32; UINT32 compressed; UINT32 uncompressed; }; */ struct SLocalFileHeader { SLocalFileHeader() { memset(this, 0, sizeof(*this)); } //~SLocalFileHeader() { if(fileName) free(fileName); if(extraField) free(extraField); } void Clear() { if(fileName) free(fileName); fileName=NULL; if(extraField) free(extraField);extraField=NULL; } _SLocalFileHeaderHead head; BYTE compressionMethod; ///< ¾ÐÃà ¹æ¹ý : 2 - deflate, 1 - º¯Çü bzip2, 0 - ¾ÐÃà ¾ÈÇÔ. BYTE unknown; UINT32 fileCRC; ///< ÆÄÀÏÀÇ CRC, ÃÖ»óÀ§ ¹ÙÀÌÆ®´Â ¾ÏÈ£ üũ¿ëÀ¸·Îµµ »ç¿ëµÈ´Ù. INT64 compressedSize; INT64 uncompressedSize; CHAR* fileName; BYTE* extraField; // _SDataDescriptor dataDescriptor; INT64 dwFileDataPos; ///< file data °¡ ÀúÀåµÈ À§Ä¡.. BYTE encChk[ENCR_HEADER_LEN]; // xf86 }; struct _SCentralDirectoryStructureHead { UINT32 dwUnknown; ///< Ç×»ó NULL ÀÌ´øµ¥.. UINT32 dwUnknown2; ///< ¾Æ¸¶µµ crc UINT32 dwCLZ03; ///< "CLZ0x03" - 0x035a4c43 ³¡À» Ç¥½ÃÇϴµí. /* SHORT versionMadeBy; SHORT versionNeededToExtract; _UGeneralPurposeBitFlag generalPurposeBitFlag; SHORT compressionMethod; SHORT lastModFileTime; SHORT lastModFileDate; UINT32 crc32; UINT32 compressedSize; UINT32 uncompressedSize; SHORT fileNameLength; SHORT extraFieldLength; SHORT fileCommentLength; SHORT diskNumberStart; SHORT internalFileAttributes; UINT32 externalFileAttributes; UINT32 relativeOffsetOfLocalHeader; */ }; struct SCentralDirectoryStructure { SCentralDirectoryStructure() { memset(this, 0, sizeof(*this)); } //~SCentralDirectoryStructure() { if(fileName) free(fileName); if(extraField) free(extraField);if(fileComment)free(fileComment); } _SCentralDirectoryStructureHead head; /* CHAR* fileName; BYTE* extraField; CHAR* fileComment; */ }; /* struct _SEndOfCentralDirectoryRecordHead { SHORT numberOfThisDisk; SHORT numberOfTheDiskWithTheStartOfTheCentralDirectory; SHORT centralDirectoryOnThisDisk; SHORT totalNumberOfEntriesInTheCentralDirectoryOnThisDisk; UINT32 sizeOfTheCentralDirectory; UINT32 offsetOfStartOfCentralDirectoryWithREspectoTotheStartingDiskNumber; SHORT zipFileCommentLength; }; */ /* struct SEndOfCentralDirectoryRecord { SEndOfCentralDirectoryRecord() { memset(this, 0, sizeof(*this)); } ~SEndOfCentralDirectoryRecord() { if(fileComment) free(fileComment); } _SEndOfCentralDirectoryRecordHead head; CHAR* fileComment; }; */ #ifdef _WIN32 # pragma pack(pop, UNALZ) ///< PACKING ¿ø»ó º¹±¸ #else # ifdef __LP64__ // 64bit ´Â ÆÐÅ·ÀÌ 8byte ¸Â³ª ? À߸𸣰ڴÙ..... # pragma pack(8) # else # pragma pack(4) # endif #endif ///< PROGRESS CALLBACK FUNCTION - ¾ÐÃà ÇØÁ¦ ÁøÇà »óȲÀ» ¾Ë°í ½ÍÀ¸¸é ÀÌ°É ¾²¸é µÈ´Ù. typedef void (_UnAlzCallback)(const char* szMessage, INT64 nCurrent, INT64 nRange, void* param, BOOL* bHalt); class CUnAlz { public: CUnAlz(); ~CUnAlz(); BOOL Open(const char* szPathName); void Close(); BOOL SetCurrentFile(const char* szFileName); BOOL ExtractCurrentFile(const char* szDestPathName, const char* szDestFileName=NULL); BOOL ExtractCurrentFileToBuf(BYTE* pDestBuf, int nBufSize); // pDestBuf=NULL ÀÏ °æ¿ì Å×½ºÆ®¸¸ ¼öÇàÇÑ´Ù. BOOL ExtractAll(const char* szDestPathName); void SetCallback(_UnAlzCallback* pFunc, void* param=NULL); void SetPipeMode(BOOL bPipeMode) {m_bPipeMode=bPipeMode;} void setPassword(char *passwd) { if(strlen(passwd) == 0) return; strcpy(m_szPasswd, passwd); }; // xf86 BOOL chkValidPassword(); // xf86 BOOL IsEncrypted() { return m_bIsEncrypted; }; #ifdef _UNALZ_ICONV void SetDestCodepage(const char* szToCodepage) { strcpy(m_szToCodepage, szToCodepage); } #endif public : ///< WIN32 Àü¿ë ( UNICODE 󸮿ë ) #ifdef _WIN32 #ifndef __GNUWIN32__ #ifndef LPCWSTR typedef const wchar_t* LPCWSTR; #endif BOOL Open(LPCWSTR szPathName); BOOL SetCurrentFile(LPCWSTR szFileName); static BOOL IsFolder(LPCWSTR szPathName); #endif // __GNUWIN32__ #endif // _WIN32 public : typedef vector FileList; ///< ÆÄÀÏ ¸ñ·Ï. FileList* GetFileList() { return &m_fileList; }; ///< file ¸ñ·Ï ¸®ÅÏ void SetCurrentFile(FileList::iterator newPos); ///< low level Á¢±Ù.. FileList::iterator GetCurFileHeader() { return m_posCur; }; ///< ÇöÀç (SetCurrentFile() ·Î ¼¼ÆõÈ) ÆÄÀÏ Á¤º¸ public : enum ERR ///< ¿¡·¯ ÄÚµå - Á¤¸® ÇÊ¿ä.. { ERR_NOERR, ERR_CANT_OPEN_FILE, ///< ¼Ò½º ÆÄÀÏ ¿­±â ½ÇÆÐ ERR_CANT_OPEN_DEST_FILE, ///< ´ë»ó ÆÄÀÏ ¿­±â ½ÇÆÐ // ERR_CANT_CREATE_DEST_PATH, ///< ´ë»ó °æ·Î ¸¸µé±â ½ÇÆÐ ERR_CORRUPTED_FILE, ///< ±úÁø ÆÄÀÏ? ERR_NOT_ALZ_FILE, ///< ALZ ÆÄÀÏÀÌ ¾Æ´Ï´Ù. ERR_CANT_READ_SIG, ///< signature Àб⠽ÇÆÐ ERR_CANT_READ_FILE, ERR_AT_READ_HEADER, ERR_INVALID_FILENAME_LENGTH, ERR_INVALID_EXTRAFIELD_LENGTH, ERR_CANT_READ_CENTRAL_DIRECTORY_STRUCTURE_HEAD, ERR_INVALID_FILENAME_SIZE, ERR_INVALID_EXTRAFIELD_SIZE, ERR_INVALID_FILECOMMENT_SIZE, ERR_CANT_READ_HEADER, ERR_MEM_ALLOC_FAILED, ERR_FILE_READ_ERROR, ERR_INFLATE_FAILED, ERR_BZIP2_FAILED, ERR_INVALID_FILE_CRC, ERR_UNKNOWN_COMPRESSION_METHOD, ERR_ICONV_CANT_OPEN, ERR_ICONV_INVALID_MULTISEQUENCE_OF_CHARACTERS, ERR_ICONV_INCOMPLETE_MULTIBYTE_SEQUENCE, ERR_ICONV_NOT_ENOUGH_SPACE_OF_BUFFER_TO_CONVERT, ERR_ICONV_ETC, ERR_PASSWD_NOT_SET, ERR_INVALID_PASSWD, ERR_USER_ABORTED, }; ERR GetLastErr(){return m_nErr;} const char* GetLastErrStr(){return LastErrToStr(m_nErr);} const char* LastErrToStr(ERR nERR); enum SIGNATURE ///< zip file signature - little endian { SIG_ERROR = 0x00, SIG_EOF = 0x01, SIG_ALZ_FILE_HEADER = 0x015a4c41, ///< ALZ 0x01 SIG_LOCAL_FILE_HEADER = 0x015a4c42, ///< BLZ 0x01 SIG_CENTRAL_DIRECTORY_STRUCTURE = 0x015a4c43, ///< CLZ 0x01 SIG_ENDOF_CENTRAL_DIRECTORY_RECORD = 0x025a4c43, ///< CLZ 0x02 }; public : static BOOL DigPath(const CHAR* szPathName); static BOOL IsFolder(const CHAR* szPathName); static const char* GetVersion() { return UNALZ_VERSION; } static const char* GetCopyright() { return UNALZ_COPYRIGHT; } BOOL IsHalted() { return m_bHalt; } // by xf86 private : SIGNATURE ReadSignature(); BOOL ReadAlzFileHeader(); BOOL ReadLocalFileheader(); BOOL ReadCentralDirectoryStructure(); BOOL ReadEndofCentralDirectoryRecord(); private : enum EXTRACT_TYPE ///< ¾ÐÃà ÇØÁ¦ ŸÀÔ. { ET_FILE, ///< FILE* ET_MEM, ///< memory buffer }; struct SExtractDest ///< ¾ÐÃà ÇØÁ¦ ´ë»ó. { SExtractDest() { memset(this, 0, sizeof(SExtractDest)); } EXTRACT_TYPE nType; ///< ´ë»óÀÌ ÆÄÀÏÀΰ¡ ¸Þ¸ð¸® Àΰ¡.. FILE* fp; ///< ET_FILE ÀÏ °æ¿ì ´ë»ó FILE* BYTE* buf; ///< ET_MEM ÀÏ °æ¿ì ´ë»ó Æ÷ÀÎÅÍ UINT32 bufsize; ///< ET_MEM ÀÏ °æ¿ì ´ë»ó ¹öÆÛÀÇ Å©±â UINT32 bufpos; ///< ET_MEM ÀÏ °æ¿ì ´ë»ó ¹öÆÛ¿¡ ¾²°í ÀÖ´Â À§Ä¡ }; int WriteToDest(SExtractDest* dest, BYTE* buf, int nSize); private : BOOL ExtractTo(SExtractDest* dest); //BOOL ExtractDeflate(FILE* fp, SLocalFileHeader& file); //BOOL ExtractBzip2_bak(FILE* fp, SLocalFileHeader& file); - ½ÇÆÐÇÑ(À߸øµÈ) ¹æ¹ý BOOL ExtractDeflate2(SExtractDest* dest, SLocalFileHeader& file); BOOL ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file); BOOL ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file); private : // bzip2 ÆÄÀÏ Ã³¸® ÇÔ¼ö.. typedef void MYBZFILE; MYBZFILE* BZ2_bzReadOpen(int* bzerror, CUnAlz* f, int verbosity, int _small, void* unused, int nUnused); int BZ2_bzread(MYBZFILE* b, void* buf, int len ); int BZ2_bzRead(int* bzerror, MYBZFILE* b, void* buf, int len); void BZ2_bzReadClose( int *bzerror, MYBZFILE *b ); private : // ºÐÇÒ ¾ÐÃà ÆÄÀÏ Ã³¸®¸¦ À§ÇÑ ·¡ÆÛ(lapper^^?) Ŭ·¡½º BOOL FOpen(const char* szPathName); void FClose(); INT64 FTell(); BOOL FEof(); BOOL FSeek(INT64 offset); BOOL FRead(void* buffer, UINT32 nBytesToRead, int* pTotRead=NULL); BOOL IsDataDescr() { return m_bIsDataDescr; }; // xf86 int getPasswordLen() { return strlen(m_szPasswd); }; enum {MAX_FILES=1000}; ///< ó¸® °¡´ÉÇÑ ºÐÇÒ ¾ÐÃà ÆÄÀÏ ¼ö. enum {MULTIVOL_TAIL_SIZE=16,MULTIVOL_HEAD_SIZE=8}; ///< ºÐÇÒ ¾ÐÃà½Ã ²Ã¶ûÁö, Çì´õ Å©±â struct SFile ///< ºÐÇÒ ÆÄÀÏ Á¤º¸ { HANDLE fp; INT64 nFileSize; int nMultivolHeaderSize; int nMultivolTailSize; }; SFile m_files[MAX_FILES]; ///< ºÐÇÒ ÆÄÀÏ ÀúÀå array - ¹«½ÄÇÑ°¡? int m_nCurFile; ///< m_files ¿¡¼­ ÇöÀç ó¸®ÁßÀÎ ÆÄÀÏÀÇ À§Ä¡. int m_nFileCount; ///< ºÐÇÒ ÆÄÀÏ °¹¼ö.. INT64 m_nVirtualFilePos; ///< ¸ÖƼº¼·ý¿¡¼­ÀÇ °¡»óÀÇ À§Ä¡ INT64 m_nCurFilePos; ///< ÇöÀç ÆÄÀÏÀÇ ¹°¸®Àû À§Ä¡. BOOL m_bIsEOF; ///< ÆÄÀÏÀÇ ³¡±îÁö (ºÐÇÒ ÆÄÀÏ Æ÷ÇÔÇؼ­) ¿Ô³ª? BOOL m_bIsEncrypted; // xf86 BOOL m_bIsDataDescr; char m_szPasswd[512]; BOOL m_bPipeMode; ///< pipemode - ¸Þ½ÃÁö Ãâ·Â¾øÀÌ stdout À¸·Î¸¸ Ãâ·Â private : /* from CZipArchive void CryptDecodeBuffer(UINT32 uCount, CHAR *buf); void CryptInitKeys(); void CryptUpdateKeys(CHAR c); BOOL CryptCheck(CHAR *buf); CHAR CryptDecryptCHAR(); void CryptDecode(CHAR &c); UINT32 CryptCRC32(UINT32 l, CHAR c); */ private : // encryption ó¸® BOOL IsEncryptedFile(BYTE fileDescriptor); BOOL IsEncryptedFile(); void InitCryptKeys(const CHAR* szPassword); void UpdateKeys(BYTE c); BOOL CryptCheck(const BYTE* buf); BYTE DecryptByte(); void DecryptingData(int nSize, BYTE* data); UINT32 CRC32(UINT32 l, BYTE c); UINT32 m_key[3]; private : FileList m_fileList; ///< ¾ÐÃàÆÄÀÏ ³»ÀÇ ÆÄÀÏ ¸ñ·Ï ERR m_nErr; FileList::iterator m_posCur; ///< ÇöÀç ÆÄÀÏ _UnAlzCallback* m_pFuncCallBack; void* m_pCallbackParam; BOOL m_bHalt; #ifdef _UNALZ_ICONV char m_szToCodepage[256]; ///< codepage char m_szFromCodepage[256]; ///< "CP949" #endif }; } using namespace UNALZ; #endif