mirror of
https://github.com/php-win-ext/php-rar.git
synced 2026-04-28 23:03:12 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c3a779c58 | |||
| 57f518d804 | |||
| 0ed5106066 | |||
| 473e865b38 | |||
| b08d2ebc66 | |||
| 198fda108f | |||
| a745071a2a |
@@ -18,7 +18,7 @@ unrar_sources="unrar/rar.cpp unrar/strlist.cpp unrar/strfn.cpp \
|
||||
unrar/volume.cpp unrar/find.cpp \
|
||||
unrar/unpack.cpp unrar/cmddata.cpp unrar/dll.cpp \
|
||||
unrar/filestr.cpp unrar/recvol.cpp unrar/rs.cpp \
|
||||
unrar/scantree.cpp"
|
||||
unrar/scantree.cpp unrar/log.cpp"
|
||||
|
||||
if test "$PHP_RAR" != "no"; then
|
||||
PHP_REQUIRE_CXX
|
||||
|
||||
+19
-5
@@ -16,15 +16,24 @@
|
||||
</maintainer>
|
||||
</maintainers>
|
||||
<release>
|
||||
<version>0.3.0</version>
|
||||
<date>2006-06-06</date>
|
||||
<version>0.3.1</version>
|
||||
<date>2006-08-28</date>
|
||||
<state>beta</state>
|
||||
<notes>
|
||||
- Updated bundled unrar to version 3.6.2 (fixes compile errors with GCC4).
|
||||
- Several minor fixes.
|
||||
- Updated bundled unrar to version 3.6.8.
|
||||
- Fixed PHP4 compatibility.
|
||||
</notes>
|
||||
</release>
|
||||
<changelog>
|
||||
<release>
|
||||
<version>0.3.0</version>
|
||||
<date>2006-06-06</date>
|
||||
<state>beta</state>
|
||||
<notes>
|
||||
- Updated bundled unrar to version 3.6.2 (fixes compile errors with GCC4).
|
||||
- Several minor fixes.
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.2</version>
|
||||
<date>2004-12-02</date>
|
||||
@@ -54,6 +63,12 @@
|
||||
<file role="src">config.m4</file>
|
||||
<file role="src">php_rar.h</file>
|
||||
<file role="src">rar.cpp</file>
|
||||
<file role="test">tests/001.phpt</file>
|
||||
<file role="test">tests/002.phpt</file>
|
||||
<file role="test">tests/003.phpt</file>
|
||||
<file role="test">tests/004.phpt</file>
|
||||
<file role="test">tests/latest_winrar.rar</file>
|
||||
<file role="test">tests/linux_rar.rar</file>
|
||||
|
||||
<dir role="src" name="/unrar/">
|
||||
|
||||
@@ -114,7 +129,6 @@
|
||||
<file role="src">log.hpp</file>
|
||||
<file role="src">match.cpp</file>
|
||||
<file role="src">match.hpp</file>
|
||||
<file role="src">memfree.hpp</file>
|
||||
<file role="src">model.cpp</file>
|
||||
<file role="src">model.hpp</file>
|
||||
<file role="src">msc.dep</file>
|
||||
|
||||
@@ -45,6 +45,16 @@ extern "C" {
|
||||
#include "php_rar.h"
|
||||
#include "unrar/rar.hpp"
|
||||
|
||||
/* PHP4 compat {{{ */
|
||||
#ifndef PHP_METHOD
|
||||
#define ZEND_MN(name) zim_##name
|
||||
#define PHP_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name))
|
||||
#define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info},
|
||||
#define PHP_ME(classname, name, arg_info, flags) ZEND_FENTRY(name, ZEND_MN(classname##_##name), arg_info, flags)
|
||||
#endif
|
||||
/* }}} */
|
||||
|
||||
|
||||
static int le_rar_file;
|
||||
#define le_rar_file_name "Rar"
|
||||
static zend_class_entry *rar_class_entry_ptr;
|
||||
|
||||
@@ -65,9 +65,7 @@ void ExtractBeEA(Archive &Arc,char *FileName)
|
||||
AttrPos+=10+NameSize+Size;
|
||||
}
|
||||
close(fd);
|
||||
#ifndef GUI
|
||||
mprintf(St(MShowEA));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -110,8 +108,6 @@ void ExtractBeEANew(Archive &Arc,char *FileName)
|
||||
AttrPos+=10+NameSize+Size;
|
||||
}
|
||||
close(fd);
|
||||
#ifndef GUI
|
||||
mprintf(St(MShowEA));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -599,6 +599,9 @@ void CommandData::ProcessSwitch(char *Switch)
|
||||
Threads=atoi(Switch+2);
|
||||
if (Threads>MaxSearchThreads)
|
||||
BadSwitch(Switch);
|
||||
else
|
||||
{
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -802,9 +805,7 @@ void CommandData::ProcessSwitch(char *Switch)
|
||||
#ifndef SFX_MODULE
|
||||
void CommandData::BadSwitch(char *Switch)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MUnknownOption),Switch);
|
||||
#endif
|
||||
ErrHandler.Exit(RAR_USER_ERROR);
|
||||
}
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ void GetPasswordText(char *Str,int MaxLength)
|
||||
OemToChar(Str,Str);
|
||||
SetConsoleMode(hConIn,ConInMode);
|
||||
SetConsoleMode(hConOut,ConOutMode);
|
||||
#elif defined(_EMX) || defined(_BEOS) || defined(__sparc) || defined(sparc)
|
||||
#elif defined(_EMX) || defined(_BEOS) || defined(__sparc) || defined(sparc) || defined (__VMS)
|
||||
fgets(Str,MaxLength-1,stdin);
|
||||
#else
|
||||
strncpy(Str,getpass(""),MaxLength-1);
|
||||
|
||||
+2
-2
@@ -53,14 +53,14 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
|
||||
Data->Cmd.VersionControl=1;
|
||||
if (!Data->Arc.Open(r->ArcName,r->ArcNameW))
|
||||
{
|
||||
delete Data;
|
||||
r->OpenResult=ERAR_EOPEN;
|
||||
delete Data;
|
||||
return(NULL);
|
||||
}
|
||||
if (!Data->Arc.IsArchive(false))
|
||||
{
|
||||
delete Data;
|
||||
r->OpenResult=Data->Cmd.DllError!=0 ? Data->Cmd.DllError:ERAR_BAD_ARCHIVE;
|
||||
delete Data;
|
||||
return(NULL);
|
||||
}
|
||||
r->Flags=Data->Arc.NewMhd.Flags;
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ void ErrorHandler::ReadError(const char *FileName)
|
||||
|
||||
bool ErrorHandler::AskRepeatRead(const char *FileName)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(GUI)
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
if (!Silent)
|
||||
{
|
||||
mprintf("\n");
|
||||
@@ -102,7 +102,7 @@ void ErrorHandler::WriteErrorFAT(const char *FileName)
|
||||
|
||||
bool ErrorHandler::AskRepeatWrite(const char *FileName)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(_WIN_CE) && !defined(GUI)
|
||||
#if !defined(SILENT) && !defined(_WIN_CE)
|
||||
if (!Silent)
|
||||
{
|
||||
mprintf("\n");
|
||||
|
||||
+21
-5
@@ -28,8 +28,22 @@ void CmdExtract::DoExtract(CommandData *Cmd)
|
||||
Cmd->ArcNames->Rewind();
|
||||
while (Cmd->GetArcName(ArcName,ArcNameW,sizeof(ArcName)))
|
||||
{
|
||||
while (ExtractArchive(Cmd)==EXTRACT_ARC_REPEAT)
|
||||
;
|
||||
while (true)
|
||||
{
|
||||
char PrevCmdPassword[MAXPASSWORD];
|
||||
strcpy(PrevCmdPassword,Cmd->Password);
|
||||
|
||||
EXTRACT_ARC_CODE Code=ExtractArchive(Cmd);
|
||||
|
||||
/*
|
||||
restore Cmd->Password which could be changed in IsArchive() call
|
||||
for next header encrypted archive
|
||||
*/
|
||||
strcpy(Cmd->Password,PrevCmdPassword);
|
||||
|
||||
if (Code!=EXTRACT_ARC_REPEAT)
|
||||
break;
|
||||
}
|
||||
if (FindFile::FastFind(ArcName,ArcNameW,&FD))
|
||||
DataIO.ProcessedArcSize+=FD.Size;
|
||||
}
|
||||
@@ -38,9 +52,7 @@ void CmdExtract::DoExtract(CommandData *Cmd)
|
||||
{
|
||||
if (!PasswordCancelled)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MExtrNoFiles));
|
||||
#endif
|
||||
}
|
||||
ErrHandler.SetErrorCode(RAR_WARNING);
|
||||
}
|
||||
@@ -143,6 +155,7 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return(EXTRACT_ARC_NEXT);
|
||||
}
|
||||
|
||||
@@ -430,7 +443,10 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
|
||||
else
|
||||
strcat(DestFileName,ExtrName);
|
||||
|
||||
if (AbsPaths && DestFileName[1]=='_' && IsPathDiv(DestFileName[2]))
|
||||
char DiskLetter=toupper(DestFileName[0]);
|
||||
|
||||
if (AbsPaths && DestFileName[1]=='_' && IsPathDiv(DestFileName[2]) &&
|
||||
DiskLetter>='A' && DiskLetter<='Z')
|
||||
DestFileName[1]=':';
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
|
||||
+2
-1
@@ -6,6 +6,8 @@ enum EXTRACT_ARC_CODE {EXTRACT_ARC_NEXT,EXTRACT_ARC_REPEAT};
|
||||
class CmdExtract
|
||||
{
|
||||
private:
|
||||
EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd);
|
||||
|
||||
ComprDataIO DataIO;
|
||||
Unpack *Unp;
|
||||
long TotalFileCount;
|
||||
@@ -31,7 +33,6 @@ class CmdExtract
|
||||
~CmdExtract();
|
||||
void DoExtract(CommandData *Cmd);
|
||||
void ExtractArchiveInit(CommandData *Cmd,Archive &Arc);
|
||||
EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd);
|
||||
bool ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize,
|
||||
bool &Repeat);
|
||||
static void UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize);
|
||||
|
||||
@@ -56,9 +56,7 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
|
||||
}
|
||||
if (Choice==5)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MAskNewName));
|
||||
#endif
|
||||
|
||||
char NewName[NM];
|
||||
#ifdef _WIN_32
|
||||
|
||||
+1
-1
@@ -432,7 +432,7 @@ bool File::RawSeek(Int64 Offset,int Method)
|
||||
return(false);
|
||||
#else
|
||||
LastWrite=false;
|
||||
#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE)
|
||||
#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE) && !defined(__VMS)
|
||||
if (fseeko(hFile,Offset,Method)!=0)
|
||||
#else
|
||||
if (fseek(hFile,(long)int64to32(Offset),Method)!=0)
|
||||
|
||||
+2
-1
@@ -300,8 +300,9 @@ bool IsLink(uint Attr)
|
||||
{
|
||||
#ifdef _UNIX
|
||||
return((Attr & 0xF000)==0xA000);
|
||||
#endif
|
||||
#else
|
||||
return(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-1
@@ -64,7 +64,10 @@ void ListArchive(CommandData *Cmd)
|
||||
}
|
||||
while(Arc.ReadHeader()>0)
|
||||
{
|
||||
switch(Arc.GetHeaderType())
|
||||
int HeaderType=Arc.GetHeaderType();
|
||||
if (HeaderType==ENDARC_HEAD)
|
||||
break;
|
||||
switch(HeaderType)
|
||||
{
|
||||
case FILE_HEAD:
|
||||
IntToExt(Arc.NewLhd.FileName,Arc.NewLhd.FileName);
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@
|
||||
#define MCHelpSwXa "\n x@ Read file names to exclude from stdin"
|
||||
#define MCHelpSwXal "\n x@<list> Exclude files in specified list file"
|
||||
#define MCHelpSwY "\n y Assume Yes on all queries"
|
||||
#define MCHelpSwZ "\n z<file> Read archive comment from file"
|
||||
#define MCHelpSwZ "\n z[file] Read archive comment from file"
|
||||
#define MBadArc "\nERROR: Bad archive %s\n"
|
||||
#define MAskPsw "Enter password (will not be echoed)"
|
||||
#define MAskPswEcho "Enter password"
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
|
||||
static char LogName[NM];
|
||||
|
||||
void InitLogOptions(char *LogName)
|
||||
{
|
||||
strcpy(::LogName,LogName);
|
||||
}
|
||||
|
||||
|
||||
#ifndef SILENT
|
||||
void Log(const char *ArcName,const char *Format,...)
|
||||
{
|
||||
safebuf char Msg[2*NM+1024];
|
||||
va_list ArgPtr;
|
||||
va_start(ArgPtr,Format);
|
||||
vsprintf(Msg,Format,ArgPtr);
|
||||
va_end(ArgPtr);
|
||||
eprintf("%s",Msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef _RAR_LOG_
|
||||
#define _RAR_LOG_
|
||||
|
||||
void InitLogOptions(char *LogName);
|
||||
|
||||
#ifndef SILENT
|
||||
void Log(const char *ArcName,const char *Format,...);
|
||||
#endif
|
||||
|
||||
#ifdef SILENT
|
||||
#ifdef __GNUC__
|
||||
#define Log(args...)
|
||||
#else
|
||||
inline void Log(const char *a,const char *b,const char *c=NULL,const char *d=NULL) {}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef _WINRAR_MEMFREE_
|
||||
#define _WINRAR_MEMFREE_
|
||||
|
||||
#ifndef USE_MEMFREE
|
||||
|
||||
#define rmalloc malloc
|
||||
#define rcalloc calloc
|
||||
#define rrealloc realloc
|
||||
#define rfree free
|
||||
#define rstrdup strdup
|
||||
|
||||
#else
|
||||
|
||||
void* rmalloc(size_t size);
|
||||
void* rcalloc(size_t nitems,size_t size);
|
||||
void* rrealloc(void *block,size_t size);
|
||||
void rfree(void *block);
|
||||
char* rstrdup(const char *s);
|
||||
|
||||
class MemoryFree
|
||||
{
|
||||
private:
|
||||
void **Allocated;
|
||||
int AllocSize;
|
||||
public:
|
||||
MemoryFree();
|
||||
~MemoryFree();
|
||||
void Free();
|
||||
void Add(void *Addr);
|
||||
void Delete(void *Addr);
|
||||
};
|
||||
|
||||
#endif //USE_MEMFREE
|
||||
|
||||
#endif
|
||||
+8
-6
@@ -194,12 +194,14 @@
|
||||
#define _stdfunction
|
||||
|
||||
#ifdef _APPLE
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN
|
||||
#endif
|
||||
#ifdef LITTLE_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#endif
|
||||
#if defined(__BIG_ENDIAN__) && !defined(BIG_ENDIAN)
|
||||
#define BIG_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#endif
|
||||
#if defined(__i386__) && !defined(LITTLE_ENDIAN)
|
||||
#define LITTLE_ENDIAN
|
||||
#undef BIG_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__sparc) || defined(sparc) || defined(__hpux)
|
||||
|
||||
+7
-5
@@ -14,15 +14,17 @@ int main(int argc, char *argv[])
|
||||
#ifdef _UNIX
|
||||
setlocale(LC_ALL,"");
|
||||
#endif
|
||||
|
||||
#if defined(_EMX) && !defined(_DJGPP)
|
||||
uni_init(0);
|
||||
#endif
|
||||
#ifndef SFX_MODULE
|
||||
setbuf(stdout,NULL);
|
||||
|
||||
#ifdef _EMX
|
||||
EnumConfigPaths(argv[0],-1);
|
||||
#endif
|
||||
#if !defined(_SFX_RTL_) && !defined(_WIN_32)
|
||||
setbuf(stdout,NULL);
|
||||
#endif
|
||||
|
||||
#if !defined(SFX_MODULE) && defined(_EMX)
|
||||
EnumConfigPaths(argv[0],-1);
|
||||
#endif
|
||||
|
||||
ErrHandler.SetSignalHandlers(true);
|
||||
|
||||
@@ -175,9 +175,7 @@ void ComprDataIO::ShowUnpRead(Int64 ArcPos,Int64 ArcSize)
|
||||
int CurPercent=ToPercent(ArcPos,ArcSize);
|
||||
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf("\b\b\b\b%3d%%",CurPercent);
|
||||
#endif
|
||||
LastPercent=CurPercent;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -253,12 +253,12 @@ bool RecVolumes::Restore(RAROptions *Cmd,const char *Name,
|
||||
|
||||
if (MissingVolumes>FoundRecVolumes)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(GUI)
|
||||
#ifndef SILENT
|
||||
mprintf(St(MRecVolCannotFix));
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
#if !defined(SILENT) && !defined(GUI)
|
||||
#ifndef SILENT
|
||||
mprintf(St(MReconstructing));
|
||||
#endif
|
||||
|
||||
@@ -298,7 +298,7 @@ bool RecVolumes::Restore(RAROptions *Cmd,const char *Name,
|
||||
}
|
||||
if (MaxRead==0)
|
||||
break;
|
||||
#if !defined(SILENT) && !defined(GUI)
|
||||
#ifndef SILENT
|
||||
int CurPercent=ToPercent(ProcessedSize,RecFileSize);
|
||||
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
|
||||
{
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@ unsigned char finalcount[8];
|
||||
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
|
||||
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
|
||||
}
|
||||
unsigned char ch='\200';
|
||||
unsigned char ch=(unsigned char)'\200';
|
||||
hash_process(context, &ch, 1, handsoff);
|
||||
while ((context->count[0] & 504) != 448) {
|
||||
ch=0;
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ bool WideToChar(const wchar *Src,char *Dest,int DestSize)
|
||||
WideToUtf(Src,Dest,DestSize);
|
||||
#else
|
||||
#ifdef MBFUNCTIONS
|
||||
if (wcstombs(Dest,Src,DestSize)==-1)
|
||||
if (wcstombs(Dest,Src,DestSize)==(size_t)-1)
|
||||
RetCode=false;
|
||||
#else
|
||||
if (UnicodeEnabled())
|
||||
@@ -53,7 +53,7 @@ bool CharToWide(const char *Src,wchar *Dest,int DestSize)
|
||||
UtfToWide(Src,Dest,DestSize);
|
||||
#else
|
||||
#ifdef MBFUNCTIONS
|
||||
if (mbstowcs(Dest,Src,DestSize)==-1)
|
||||
if (mbstowcs(Dest,Src,DestSize)==(size_t)-1)
|
||||
RetCode=false;
|
||||
#else
|
||||
if (UnicodeEnabled())
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#define RARVER_MAJOR 3
|
||||
#define RARVER_MINOR 60
|
||||
#define RARVER_BETA 2
|
||||
#define RARVER_DAY 18
|
||||
#define RARVER_MONTH 4
|
||||
#define RARVER_BETA 0
|
||||
#define RARVER_DAY 5
|
||||
#define RARVER_MONTH 8
|
||||
#define RARVER_YEAR 2006
|
||||
|
||||
@@ -124,10 +124,8 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef GUI
|
||||
if (Command=='T' || Command=='X' || Command=='E')
|
||||
mprintf(St(Command=='T' ? MTestVol:MExtrVol),Arc.FileName);
|
||||
#endif
|
||||
if (SplitHeader)
|
||||
Arc.SearchBlock(HeaderType);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user