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 d8a26a3..0000000 Binary files a/bzip2/vssver.scc and /dev/null differ diff --git a/clear.bat b/clear.bat index 48c615a..5319ec3 100644 --- a/clear.bat +++ b/clear.bat @@ -1 +1,4 @@ -del *.plg *.obj *.o *.sbr *.pch *.pdb *.res *.bsc *.pcc *.idb *.pdb *.ncb *.aps *.ilk 2*.log *.map *.opt *.exp *.sup *.dpbcd gebug.txt *_d.exe *_d.dll *_d.lib *_debug.dll *_debug.exe *.tlh *.tli /s \ No newline at end of file +del *.plg *.obj *.o *.sbr *.pch *.pdb *.res *.bsc *.pcc *.idb *.pdb *.ncb *.aps *.ilk 2*.log *.map *.opt *.exp *.sup *.dpbcd gebug.txt *_d.exe *_d.dll *_d.lib *_debug.dll *_debug.exe *.tlh *.tli *.scc /s +rmdir bin +rmdir release +rmdir debug \ No newline at end of file diff --git a/main.cpp b/main.cpp index 151c65d..962d473 100644 --- a/main.cpp +++ b/main.cpp @@ -10,9 +10,11 @@ void Usage() # ifdef _UNALZ_UTF8 printf(" -utf8 : convert filename's codepage to UTF-8 (default)\n"); printf(" -cp949 : convert filename's codepage to CP949\n"); + printf(" -euc-kr: convert filename's codepage to EUC-KR\n"); # else printf(" -utf8 : convert filename's codepage to UTF-8\n"); printf(" -cp949 : convert filename's codepage to CP949 (default)\n"); + printf(" -euc-kr: convert filename's codepage to EUC-KR\n"); # endif // _UNALZ_UTF8 #else // no iconv printf("USAGE : unalz sourcefile.alz [dest path] \n"); @@ -22,42 +24,52 @@ void Usage() void UnAlzCallback(const char* szMessage, INT64 nCurrent, INT64 nRange, void* param, BOOL* bHalt) { // progress - char buf[1000]; + static char szFileName[1024]={0}; INT64 percent; static INT64 nPrevPercent = -1; - int buflen; - int i; // ÆÄÀϸí Ãâ·Â.. if(szMessage) { - //printf("\n"); - printf("unalziiiing : %s ", szMessage); + printf("\n"); +#ifdef _WIN32 + sprintf(szFileName, "unalziiiing : %s (%I64dbytes) ", szMessage, nRange); +#else + sprintf(szFileName, "unalziiiing : %s (%lldbytes) ", szMessage, nRange); +#endif + printf("%s", szFileName); + fflush(stdout); nPrevPercent = -1; - return ; + return; } percent = nCurrent*100/nRange; - if(nPrevPercent==percent) return; // ³Ê¹« ÀæÀº ¾÷µ¥ÀÌÆ® ¹æÁö.. + if(nPrevPercent/10==percent/10) return; // ³Ê¹« ÀæÀº ¾÷µ¥ÀÌÆ® ¹æÁö.. nPrevPercent = percent; -#ifdef _WIN32 - sprintf(buf, "%I64d/%I64d (%I64d%%)", nCurrent, nRange, percent); -#else - sprintf(buf, "%d/%d (%d%%)", (int)nCurrent, (int)nRange, (int)percent); // int64 ¸¦ Ãâ·ÂÇÒ¶ó¸é ¾îÂîÇØ¾ß µÇ´ÂÁö? -#endif - puts(buf); - buflen = strlen(buf); + + printf("."); fflush(stdout); - for(i=0;i=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 2116ac5..0000000 Binary files a/zlib/vssver.scc and /dev/null differ