From 06b37f8d1693432633adf7f53e77aecb8653819e Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Tue, 5 May 2020 20:22:33 +0200 Subject: [PATCH] v0.23 --- UnAlz.cpp | 56 ++++++++++++++++++++++++++--------------------- UnAlz.h | 6 +++-- bzip2/vssver.scc | Bin 144 -> 0 bytes clear.bat | 5 ++++- main.cpp | 49 +++++++++++++++++++++++++++-------------- makefile | 2 +- makefile.freebsd | 3 +-- zlib/vssver.scc | Bin 320 -> 0 bytes 8 files changed, 74 insertions(+), 47 deletions(-) delete mode 100644 bzip2/vssver.scc delete mode 100644 zlib/vssver.scc diff --git a/UnAlz.cpp b/UnAlz.cpp index 71928e1..dd1722b 100644 --- a/UnAlz.cpp +++ b/UnAlz.cpp @@ -10,31 +10,22 @@ # include #endif -// le16toh µîµî.. -#if (defined(__FreeBSD__) || defined(__DARWIN__)) -# include -#endif - -#ifdef __linux__ // __BYTE_ORDER °¡Á®¿À±â -# include -#endif - #ifdef _UNALZ_ICONV // code page support # include #endif -#ifdef __linux__ // iconv.h ¶§¹®¿¡ ÇÊ¿ä -# include -#endif - -#ifndef _WIN32 // WIN32 ´Â ¹«Á¶°Ç LITTLE À̴ϱî ÇÊ¿ä¾ø´Ù. -# define swapint64(Data) (INT64) ( (((Data)&0x00000000000000FFLL) << 56) | (((Data)&0x000000000000FF00LL) << 40) | (((Data)&0x0000000000FF0000LL) << 24) | (((Data)&0x00000000FF000000LL) << 8) | (((Data)&0x000000FF00000000LL) >> 8) | (((Data)&0x0000FF0000000000LL) >> 24) | (((Data)&0x00FF000000000000LL) >> 40) | (((Data)&0xFF00000000000000LL) >> 56) ) -# define swapint32(a) ((((a)&0xff)<<24)+(((a>>8)&0xff)<<16)+(((a>>16)&0xff)<<8)+(((a>>24)&0xff))) -# define swapint16(a) (((a)&0xff)<<8)+(((a>>8)&0xff)) +#ifdef __linux__ // __BYTE_ORDER °¡Á®¿À±â +# include // iconv.h ¶§¹®¿¡ ÇÊ¿ä #endif -//// byte-order : little to host //// +#define swapint64(Data) (INT64) ( (((Data)&0x00000000000000FFLL) << 56) | (((Data)&0x000000000000FF00LL) << 40) | (((Data)&0x0000000000FF0000LL) << 24) | (((Data)&0x00000000FF000000LL) << 8) | (((Data)&0x000000FF00000000LL) >> 8) | (((Data)&0x0000FF0000000000LL) >> 24) | (((Data)&0x00FF000000000000LL) >> 40) | (((Data)&0xFF00000000000000LL) >> 56) ) +#define swapint32(a) ((((a)&0xff)<<24)+(((a>>8)&0xff)<<16)+(((a>>16)&0xff)<<8)+(((a>>24)&0xff))) +#define swapint16(a) (((a)&0xff)<<8)+(((a>>8)&0xff)) + +//////////////////////////////////////////////////////////////////////////// +//// byte-order : little to host //// +//////////////////////////////////////////////////////////////////////////// #ifdef _WIN32 // little to little inline UINT16 unalz_le16toh(UINT16 a){return a;} @@ -42,13 +33,23 @@ inline UINT64 unalz_le64toh(UINT64 a){return a;} #endif -#if (defined(__FreeBSD__) || defined(__DARWIN__)) +#ifdef __FreeBSD__ +# include inline UINT16 unalz_le16toh(UINT16 a){return le16toh(a);} inline UINT32 unalz_le32toh(UINT32 a){return le32toh(a);} inline UINT64 unalz_le64toh(UINT64 a){return le64toh(a);} #endif -#ifdef __linux__ // ¸®´ª½º¿¡¼­ little À» host ·Î ¹Ù²Ù´Â ÇÔ¼ö¸¦ ¸ð¸£°Ú´Ù.. ±×·¡¼­ ±×³É define µÈ°É·Î ÆÇ´ÜÇÑ´Ù. +#ifdef __APPLE__ +# include + inline UINT16 unalz_le16toh(UINT16 a){return NXSwapShort(a);} + inline UINT32 unalz_le32toh(UINT32 a){return NXSwapLong(a);} + inline UINT64 unalz_le64toh(UINT64 a){return NXSwapLongLong(a);} +#endif + + +#ifdef __linux__ +# include # if __BYTE_ORDER == __BIG_ENDIAN inline UINT16 unalz_le16toh(UINT16 a){return swapint16(a);} inline UINT32 unalz_le32toh(UINT32 a){return swapint32(a);} @@ -58,6 +59,10 @@ inline UINT32 unalz_le32toh(UINT32 a){return (a);} inline UINT64 unalz_le64toh(UINT64 a){return (a);} # endif +//# include +// inline UINT16 unalz_le16toh(UINT16 a){return le16_to_cpu(a);} +// inline UINT32 unalz_le32toh(UINT32 a){return le32_to_cpu(a);} +// inline UINT64 unalz_le64toh(UINT64 a){return le64_to_cpu(a);} #endif @@ -633,7 +638,7 @@ BOOL CUnAlz::ExtractCurrentFile(const char* szDestPathName, const char* szDestFi } #endif // CALLBACK ¼¼Æà - if(m_pFuncCallBack) m_pFuncCallBack(m_posCur->fileName, 0,0,m_pCallbackParam, NULL); + if(m_pFuncCallBack) m_pFuncCallBack(m_posCur->fileName, 0,m_posCur->uncompressedSize,m_pCallbackParam, NULL); ret = ExtractTo(&dest); if(dest.fp!=NULL)fclose(dest.fp); @@ -1239,7 +1244,8 @@ BOOL CUnAlz::FOpen(const char* szPathName) char* temp = strdup(szPathName); // ÆÄÀÏ¸í º¹»ç.. int i; int nLen = strlen(szPathName); - UINT32 dwFileSizeLow,dwFileSizeHigh; + UINT64 nFileSizeLow; + UINT32 dwFileSizeHigh; m_nFileCount = 0; m_nCurFile = 0; m_nVirtualFilePos = 0; @@ -1251,17 +1257,17 @@ BOOL CUnAlz::FOpen(const char* szPathName) #ifdef _WIN32 m_files[i].fp = CreateFileA(temp, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if(m_files[i].fp==INVALID_HANDLE_VALUE) break; - dwFileSizeLow = GetFileSize(m_files[i].fp, (DWORD*)&dwFileSizeHigh); + nFileSizeLow = GetFileSize(m_files[i].fp, (DWORD*)&dwFileSizeHigh); #else m_files[i].fp = fopen(temp, "rb"); if(m_files[i].fp==NULL) break; dwFileSizeHigh=0; fseek(m_files[i].fp,0,SEEK_END); - dwFileSizeLow=ftell(m_files[i].fp); // _LARGEFILE64_SOURCE ȣȯ¼º ¹®Á¦ ¹ß»ý.. T.T + nFileSizeLow=ftell(m_files[i].fp); fseek(m_files[i].fp,0,SEEK_SET); #endif m_nFileCount++; - m_files[i].nFileSize = ((INT64)dwFileSizeLow) + (((INT64)dwFileSizeHigh)<<32); + m_files[i].nFileSize = ((INT64)nFileSizeLow) + (((INT64)dwFileSizeHigh)<<32); if(i==0) m_files[i].nMultivolHeaderSize = 0; else m_files[i].nMultivolHeaderSize = MULTIVOL_HEAD_SIZE; m_files[i].nMultivolTailSize = MULTIVOL_TAIL_SIZE; diff --git a/UnAlz.h b/UnAlz.h index e554d35..e73303d 100644 --- a/UnAlz.h +++ b/UnAlz.h @@ -38,6 +38,7 @@ - ºò¿£µð¾È, ÄÚµåÆäÀÌÁö º¯È¯ °ü·Ã ¼Ò½º Á¤¸® 2004/10/25 - by yongari : __LP64__ , ºò¿£µð¾È(le64toh/le132oh/le16toh) °ü·Ã À̽´ ¼öÁ¤ 2004/10/26 - BSD/LINUX : byte-order, libiconv À̽´ Á¤¸® + 2004/10/30 - Á¤¸® & Á¤¸®.. ÇÒÀÏ : ( * Ç¥´Â ÇÑ°Å ) @@ -127,7 +128,8 @@ using namespace std; #endif #ifndef ASSERT # include -# define ASSERT(x) assert(x) +//# define ASSERT(x) assert(x) +# define ASSERT(x) {printf("assert file:%s line:%d\n", __FILE__, __LINE__);} #endif @@ -142,7 +144,7 @@ namespace UNALZ # pragma pack(1) #endif -static const char UNALZ_VERSION[] = "CUnAlz0.21"; +static const char UNALZ_VERSION[] = "CUnAlz0.23"; static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004 hardkoder@gmail.com"; diff --git a/bzip2/vssver.scc b/bzip2/vssver.scc deleted file mode 100644 index d8a26a34b417a66e27b2cf04a6574f2548d8d9cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmXpJVq}o$H#QZpXL9PlTX*Jb%`f%sJGY+|WMu$@w@eHSy19ZsI(d;s#F zhy`$UPN=argc) {Usage();return 0;} // ¿É¼Ç¸¸ ¾²¸é ¾î¼¶ó°í.. if(destcodepage) unalz.SetDestCodepage(destcodepage); diff --git a/makefile b/makefile index 2125895..4ce2ccd 100644 --- a/makefile +++ b/makefile @@ -7,7 +7,6 @@ CFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 LDFLAGS= #CFLAGS = -DDARWIN #LDFLAGS=-liconv -SRCS=main.cpp UnAlz.cpp UnAlzBz2decompress.c UnAlzBzip2.cpp UnAlzbzlib.c #nothing: all: @@ -31,6 +30,7 @@ posix: unalz $(CPP) -c UnAlz.cpp -c main.cpp $(CFLAGS) -D_UNALZ_ICONV $(CPP) $(LINKOBJ) $(LDFLAGS) -liconv -o $(BIN) + posix-utf8: unalz $(CPP) -c UnAlz.cpp -c main.cpp $(CFLAGS) -D_UNALZ_ICONV -D_UNALZ_UTF8 $(CPP) $(LINKOBJ) $(LDFLAGS) -liconv -o $(BIN) diff --git a/makefile.freebsd b/makefile.freebsd index f44670a..51217fd 100644 --- a/makefile.freebsd +++ b/makefile.freebsd @@ -2,8 +2,7 @@ PROG= unalz NOMAN= -SRCS= main.cpp UnAlz.cpp UnAlzBz2decompress.c UnAlzBzip2.cpp \ - UnAlzbzlib.c +SRCS= main.cpp UnAlz.cpp UnAlzBz2decompress.c UnAlzBzip2.cpp UnAlzbzlib.c LDADD+= -lz -lbz2 -liconv -lstdc++ .include diff --git a/zlib/vssver.scc b/zlib/vssver.scc deleted file mode 100644 index 2116ac560415b268bc51a294648333e72286f9ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 320 zcmXpJVq}o$H#QZpXL9PlTX*Jb%`f%ON>2PjtPEgqgo%OS@UJC0U8mlOU(=qi%!1MzPI`D-Oy?sU1Hn*ie90rH(^er1O7?*jRnbA{x)<|eNJ$pZk@ C|8GM8