├── .travis.yml ├── 3rd_party ├── CMakeLists.txt └── unrar-4.0.7 │ ├── CMakeLists.txt │ ├── UnRAR.vcproj │ ├── UnRARDll.vcproj │ ├── arccmt.cpp │ ├── archive.cpp │ ├── archive.hpp │ ├── arcread.cpp │ ├── array.hpp │ ├── beosea.cpp │ ├── cmddata.cpp │ ├── cmddata.hpp │ ├── coder.cpp │ ├── coder.hpp │ ├── compress.hpp │ ├── consio.cpp │ ├── consio.hpp │ ├── crc.cpp │ ├── crc.hpp │ ├── crypt.cpp │ ├── crypt.hpp │ ├── dll.cpp │ ├── dll.def │ ├── dll.hpp │ ├── dll.rc │ ├── encname.cpp │ ├── encname.hpp │ ├── errhnd.cpp │ ├── errhnd.hpp │ ├── extinfo.cpp │ ├── extinfo.hpp │ ├── extract.cpp │ ├── extract.hpp │ ├── filcreat.cpp │ ├── filcreat.hpp │ ├── file.cpp │ ├── file.hpp │ ├── filefn.cpp │ ├── filefn.hpp │ ├── filestr.cpp │ ├── filestr.hpp │ ├── find.cpp │ ├── find.hpp │ ├── getbits.cpp │ ├── getbits.hpp │ ├── global.cpp │ ├── global.hpp │ ├── headers.hpp │ ├── isnt.cpp │ ├── isnt.hpp │ ├── license.txt │ ├── list.cpp │ ├── list.hpp │ ├── loclang.hpp │ ├── log.cpp │ ├── log.hpp │ ├── makefile.bcc │ ├── makefile.dj │ ├── makefile.dmc │ ├── makefile.unix │ ├── match.cpp │ ├── match.hpp │ ├── model.cpp │ ├── model.hpp │ ├── msc.dep │ ├── options.cpp │ ├── options.hpp │ ├── os.hpp │ ├── os2ea.cpp │ ├── pathfn.cpp │ ├── pathfn.hpp │ ├── rar.cpp │ ├── rar.hpp │ ├── rardefs.hpp │ ├── rarlang.hpp │ ├── raros.hpp │ ├── rarpch.cpp │ ├── rartypes.hpp │ ├── rarvm.cpp │ ├── rarvm.hpp │ ├── rarvmtbl.cpp │ ├── rawread.cpp │ ├── rawread.hpp │ ├── rdwrfn.cpp │ ├── rdwrfn.hpp │ ├── readme.txt │ ├── recvol.cpp │ ├── recvol.hpp │ ├── resource.cpp │ ├── resource.hpp │ ├── rijndael.cpp │ ├── rijndael.hpp │ ├── rs.cpp │ ├── rs.hpp │ ├── savepos.cpp │ ├── savepos.hpp │ ├── scantree.cpp │ ├── scantree.hpp │ ├── sha1.cpp │ ├── sha1.hpp │ ├── smallfn.cpp │ ├── smallfn.hpp │ ├── strfn.cpp │ ├── strfn.hpp │ ├── strlist.cpp │ ├── strlist.hpp │ ├── suballoc.cpp │ ├── suballoc.hpp │ ├── system.cpp │ ├── system.hpp │ ├── timefn.cpp │ ├── timefn.hpp │ ├── ulinks.cpp │ ├── ulinks.hpp │ ├── unicode.cpp │ ├── unicode.hpp │ ├── unios2.cpp │ ├── unpack.cpp │ ├── unpack.hpp │ ├── unpack15.cpp │ ├── unpack20.cpp │ ├── uowners.cpp │ ├── version.hpp │ ├── volume.cpp │ ├── volume.hpp │ ├── win32acl.cpp │ └── win32stm.cpp ├── CMakeLists.txt ├── README.md ├── appveyor.yml ├── kde_service_menu └── stream-unrar.desktop ├── stream_unrar.cpp └── unrar.patch /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | compiler: 8 | - gcc 9 | - clang 10 | 11 | matrix: 12 | include: 13 | - os: linux 14 | addons: 15 | apt: 16 | sources: 17 | - ubuntu-toolchain-r-test 18 | - george-edison55-precise-backports 19 | packages: 20 | - cmake-data 21 | - cmake 22 | - g++-6 23 | env: 24 | - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" 25 | - os: osx 26 | osx_image: xcode8.3 27 | env: 28 | - MATRIX_EVAL="" 29 | 30 | before_install: 31 | - eval "${MATRIX_EVAL}" 32 | 33 | script: 34 | - cmake . -DCMAKE_BUILD_TYPE=Release 35 | - make 36 | -------------------------------------------------------------------------------- /3rd_party/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(unrar-4.0.7) 2 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND UNRAR_SRC 2 | archive.cpp 3 | arcread.cpp 4 | cmddata.cpp 5 | consio.cpp 6 | crc.cpp 7 | crypt.cpp 8 | dll.cpp 9 | encname.cpp 10 | errhnd.cpp 11 | extinfo.cpp 12 | extract.cpp 13 | filcreat.cpp 14 | file.cpp 15 | filefn.cpp 16 | filestr.cpp 17 | find.cpp 18 | getbits.cpp 19 | global.cpp 20 | isnt.cpp 21 | list.cpp 22 | match.cpp 23 | options.cpp 24 | pathfn.cpp 25 | rar.cpp 26 | rarpch.cpp 27 | rarvm.cpp 28 | rawread.cpp 29 | rdwrfn.cpp 30 | recvol.cpp 31 | resource.cpp 32 | rijndael.cpp 33 | rs.cpp 34 | savepos.cpp 35 | scantree.cpp 36 | sha1.cpp 37 | smallfn.cpp 38 | strfn.cpp 39 | strlist.cpp 40 | system.cpp 41 | timefn.cpp 42 | ulinks.cpp 43 | unicode.cpp 44 | unpack.cpp 45 | volume.cpp 46 | ) 47 | 48 | # OS2/BeOS, etc unsupported 49 | #os2ea.cpp 50 | #beosea.cpp 51 | #unios2.cpp 52 | 53 | add_library(unrar SHARED ${UNRAR_SRC} ${UNRAR_PLATFORM_SRC}) 54 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/arccmt.cpp: -------------------------------------------------------------------------------- 1 | bool IsAnsiComment(const char *Data,int Size); 2 | 3 | bool Archive::GetComment(Array *CmtData,Array *CmtDataW) 4 | { 5 | if (!MainComment) 6 | return(false); 7 | SaveFilePos SavePos(*this); 8 | 9 | #ifndef SFX_MODULE 10 | ushort CmtLength; 11 | if (OldFormat) 12 | { 13 | Seek(SFXSize+SIZEOF_OLDMHD,SEEK_SET); 14 | CmtLength=GetByte(); 15 | CmtLength+=(GetByte()<<8); 16 | } 17 | else 18 | #endif 19 | { 20 | if (NewMhd.Flags & MHD_COMMENT) 21 | { 22 | // Old style (RAR 2.9) archive comment embedded into the main 23 | // archive header. 24 | Seek(SFXSize+SIZEOF_MARKHEAD+SIZEOF_NEWMHD,SEEK_SET); 25 | ReadHeader(); 26 | } 27 | else 28 | { 29 | // Current (RAR 3.0+) version of archive comment. 30 | Seek(SFXSize+SIZEOF_MARKHEAD+NewMhd.HeadSize,SEEK_SET); 31 | return(SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData,CmtDataW)!=0); 32 | } 33 | #ifndef SFX_MODULE 34 | // Old style (RAR 2.9) comment header embedded into the main 35 | // archive header. 36 | if (CommHead.HeadCRC!=HeaderCRC) 37 | { 38 | Log(FileName,St(MLogCommHead)); 39 | Alarm(); 40 | return(false); 41 | } 42 | CmtLength=CommHead.HeadSize-SIZEOF_COMMHEAD; 43 | #endif 44 | } 45 | #ifndef SFX_MODULE 46 | if (OldFormat && (OldMhd.Flags & MHD_PACK_COMMENT) || !OldFormat && CommHead.Method!=0x30) 47 | { 48 | if (!OldFormat && (CommHead.UnpVer < 15 || CommHead.UnpVer > UNP_VER || CommHead.Method > 0x35)) 49 | return(false); 50 | ComprDataIO DataIO; 51 | Unpack Unpack(&DataIO); 52 | Unpack.Init(); 53 | DataIO.SetTestMode(true); 54 | uint UnpCmtLength; 55 | if (OldFormat) 56 | { 57 | #ifdef NOCRYPT 58 | return(false); 59 | #else 60 | UnpCmtLength=GetByte(); 61 | UnpCmtLength+=(GetByte()<<8); 62 | CmtLength-=2; 63 | DataIO.SetCmt13Encryption(); 64 | #endif 65 | } 66 | else 67 | UnpCmtLength=CommHead.UnpSize; 68 | DataIO.SetFiles(this,NULL); 69 | DataIO.EnableShowProgress(false); 70 | DataIO.SetPackedSizeToRead(CmtLength); 71 | Unpack.SetDestSize(UnpCmtLength); 72 | Unpack.DoUnpack(CommHead.UnpVer,false); 73 | 74 | if (!OldFormat && ((~DataIO.UnpFileCRC)&0xffff)!=CommHead.CommCRC) 75 | { 76 | Log(FileName,St(MLogCommBrk)); 77 | Alarm(); 78 | return(false); 79 | } 80 | else 81 | { 82 | byte *UnpData; 83 | size_t UnpDataSize; 84 | DataIO.GetUnpackedData(&UnpData,&UnpDataSize); 85 | CmtData->Alloc(UnpDataSize); 86 | memcpy(&((*CmtData)[0]),UnpData,UnpDataSize); 87 | } 88 | } 89 | else 90 | { 91 | CmtData->Alloc(CmtLength); 92 | 93 | Read(&((*CmtData)[0]),CmtLength); 94 | if (!OldFormat && CommHead.CommCRC!=(~CRC(0xffffffff,&((*CmtData)[0]),CmtLength)&0xffff)) 95 | { 96 | Log(FileName,St(MLogCommBrk)); 97 | Alarm(); 98 | CmtData->Reset(); 99 | return(false); 100 | } 101 | } 102 | #endif 103 | #if defined(_WIN_ALL) && !defined(_WIN_CE) 104 | if (CmtData->Size()>0) 105 | { 106 | size_t CmtSize=CmtData->Size(); 107 | char *DataA=(char *)CmtData->Addr(); 108 | OemToCharBuffA(DataA,DataA,(DWORD)CmtSize); 109 | 110 | if (CmtDataW!=NULL) 111 | { 112 | CmtDataW->Alloc(CmtSize+1); 113 | CmtData->Push(0); 114 | CharToWide(DataA,CmtDataW->Addr(),CmtSize+1); 115 | CmtData->Alloc(CmtSize); 116 | CmtDataW->Alloc(wcslen(CmtDataW->Addr())); 117 | } 118 | } 119 | #endif 120 | return(CmtData->Size()>0); 121 | } 122 | 123 | 124 | size_t Archive::ReadCommentData(Array *CmtData,Array *CmtDataW) 125 | { 126 | bool Unicode=SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE; 127 | if (!ReadSubData(CmtData,NULL)) 128 | return(0); 129 | size_t CmtSize=CmtData->Size(); 130 | if (Unicode) 131 | { 132 | CmtSize/=2; 133 | Array DataW(CmtSize+1); 134 | RawToWide(CmtData->Addr(),DataW.Addr(),CmtSize); 135 | DataW[CmtSize]=0; 136 | size_t DestSize=CmtSize*4; 137 | CmtData->Alloc(DestSize+1); 138 | WideToChar(DataW.Addr(),(char *)CmtData->Addr(),DestSize); 139 | (*CmtData)[DestSize]=0; 140 | CmtSize=strlen((char *)CmtData->Addr()); 141 | CmtData->Alloc(CmtSize); 142 | if (CmtDataW!=NULL) 143 | { 144 | *CmtDataW=DataW; 145 | CmtDataW->Alloc(CmtSize); 146 | } 147 | } 148 | else 149 | if (CmtDataW!=NULL) 150 | { 151 | CmtData->Push(0); 152 | CmtDataW->Alloc(CmtSize+1); 153 | CharToWide((char *)CmtData->Addr(),CmtDataW->Addr(),CmtSize+1); 154 | CmtData->Alloc(CmtSize); 155 | CmtDataW->Alloc(wcslen(CmtDataW->Addr())); 156 | } 157 | return(CmtSize); 158 | } 159 | 160 | 161 | void Archive::ViewComment() 162 | { 163 | #ifndef GUI 164 | if (Cmd->DisableComment) 165 | return; 166 | Array CmtBuf; 167 | if (GetComment(&CmtBuf,NULL)) 168 | { 169 | size_t CmtSize=CmtBuf.Size(); 170 | char *ChPtr=(char *)memchr(&CmtBuf[0],0x1A,CmtSize); 171 | if (ChPtr!=NULL) 172 | CmtSize=ChPtr-(char *)&CmtBuf[0]; 173 | mprintf("\n"); 174 | OutComment((char *)&CmtBuf[0],CmtSize); 175 | } 176 | #endif 177 | } 178 | 179 | 180 | #ifndef SFX_MODULE 181 | // Used for archives created by old RAR versions up to and including RAR 2.9. 182 | // New RAR versions store file comments in separate headers and such comments 183 | // are displayed in ListNewSubHeader function. 184 | void Archive::ViewFileComment() 185 | { 186 | if (!(NewLhd.Flags & LHD_COMMENT) || Cmd->DisableComment || OldFormat) 187 | return; 188 | #ifndef GUI 189 | mprintf(St(MFileComment)); 190 | #endif 191 | const int MaxSize=0x8000; 192 | Array CmtBuf(MaxSize); 193 | SaveFilePos SavePos(*this); 194 | Seek(CurBlockPos+SIZEOF_NEWLHD+NewLhd.NameSize,SEEK_SET); 195 | int64 SaveCurBlockPos=CurBlockPos; 196 | int64 SaveNextBlockPos=NextBlockPos; 197 | 198 | size_t Size=ReadHeader(); 199 | 200 | CurBlockPos=SaveCurBlockPos; 201 | NextBlockPos=SaveNextBlockPos; 202 | 203 | if (Size<7 || CommHead.HeadType!=COMM_HEAD) 204 | return; 205 | if (CommHead.HeadCRC!=HeaderCRC) 206 | { 207 | #ifndef GUI 208 | Log(FileName,St(MLogCommHead)); 209 | #endif 210 | return; 211 | } 212 | if (CommHead.UnpVer < 15 || CommHead.UnpVer > UNP_VER || 213 | CommHead.Method > 0x30 || CommHead.UnpSize > MaxSize) 214 | return; 215 | Read(&CmtBuf[0],CommHead.UnpSize); 216 | if (CommHead.CommCRC!=((~CRC(0xffffffff,&CmtBuf[0],CommHead.UnpSize)&0xffff))) 217 | { 218 | Log(FileName,St(MLogBrokFCmt)); 219 | } 220 | else 221 | { 222 | OutComment(&CmtBuf[0],CommHead.UnpSize); 223 | #ifndef GUI 224 | mprintf("\n"); 225 | #endif 226 | } 227 | } 228 | #endif 229 | 230 | 231 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/archive.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #ifndef SHELL_EXT 4 | #include "arccmt.cpp" 5 | #endif 6 | 7 | 8 | Archive::Archive(RAROptions *InitCmd) 9 | { 10 | Cmd=InitCmd==NULL ? &DummyCmd:InitCmd; 11 | OpenShared=Cmd->OpenShared; 12 | OldFormat=false; 13 | Solid=false; 14 | Volume=false; 15 | MainComment=false; 16 | Locked=false; 17 | Signed=false; 18 | NotFirstVolume=false; 19 | SFXSize=0; 20 | LatestTime.Reset(); 21 | Protected=false; 22 | Encrypted=false; 23 | FailedHeaderDecryption=false; 24 | BrokenFileHeader=false; 25 | LastReadBlock=0; 26 | 27 | CurBlockPos=0; 28 | NextBlockPos=0; 29 | 30 | RecoveryPos=SIZEOF_MARKHEAD; 31 | RecoverySectors=-1; 32 | 33 | memset(&NewMhd,0,sizeof(NewMhd)); 34 | NewMhd.HeadType=MAIN_HEAD; 35 | NewMhd.HeadSize=SIZEOF_NEWMHD; 36 | HeaderCRC=0; 37 | VolWrite=0; 38 | AddingFilesSize=0; 39 | AddingHeadersSize=0; 40 | #if !defined(SHELL_EXT) && !defined(NOCRYPT) 41 | *HeadersSalt=0; 42 | *SubDataSalt=0; 43 | #endif 44 | *FirstVolumeName=0; 45 | *FirstVolumeNameW=0; 46 | 47 | Splitting=false; 48 | NewArchive=false; 49 | 50 | SilentOpen=false; 51 | 52 | } 53 | 54 | 55 | #ifndef SHELL_EXT 56 | void Archive::CheckArc(bool EnableBroken) 57 | { 58 | if (!IsArchive(EnableBroken)) 59 | { 60 | Log(FileName,St(MBadArc),FileName); 61 | ErrHandler.Exit(FATAL_ERROR); 62 | } 63 | } 64 | #endif 65 | 66 | 67 | #if !defined(SHELL_EXT) && !defined(SFX_MODULE) 68 | void Archive::CheckOpen(const char *Name,const wchar *NameW) 69 | { 70 | TOpen(Name,NameW); 71 | CheckArc(false); 72 | } 73 | #endif 74 | 75 | 76 | bool Archive::WCheckOpen(const char *Name,const wchar *NameW) 77 | { 78 | if (!WOpen(Name,NameW)) 79 | return(false); 80 | if (!IsArchive(false)) 81 | { 82 | #ifndef SHELL_EXT 83 | Log(FileName,St(MNotRAR),FileName); 84 | #endif 85 | Close(); 86 | return(false); 87 | } 88 | return(true); 89 | } 90 | 91 | 92 | bool Archive::IsSignature(byte *D) 93 | { 94 | bool Valid=false; 95 | if (D[0]==0x52) 96 | #ifndef SFX_MODULE 97 | if (D[1]==0x45 && D[2]==0x7e && D[3]==0x5e) 98 | { 99 | OldFormat=true; 100 | Valid=true; 101 | } 102 | else 103 | #endif 104 | if (D[1]==0x61 && D[2]==0x72 && D[3]==0x21 && D[4]==0x1a && D[5]==0x07 && D[6]==0x00) 105 | { 106 | OldFormat=false; 107 | Valid=true; 108 | } 109 | return(Valid); 110 | } 111 | 112 | 113 | bool Archive::IsArchive(bool EnableBroken) 114 | { 115 | Encrypted=false; 116 | #ifndef SFX_MODULE 117 | if (IsDevice()) 118 | { 119 | #ifndef SHELL_EXT 120 | Log(FileName,St(MInvalidName),FileName); 121 | #endif 122 | return(false); 123 | } 124 | #endif 125 | if (Read(MarkHead.Mark,SIZEOF_MARKHEAD)!=SIZEOF_MARKHEAD) 126 | return(false); 127 | SFXSize=0; 128 | if (IsSignature(MarkHead.Mark)) 129 | { 130 | if (OldFormat) 131 | Seek(0,SEEK_SET); 132 | } 133 | else 134 | { 135 | Array Buffer(MAXSFXSIZE); 136 | long CurPos=(long)Tell(); 137 | int ReadSize=Read(&Buffer[0],Buffer.Size()-16); 138 | for (int I=0;I0 && CurPos<28 && ReadSize>31) 142 | { 143 | char *D=&Buffer[28-CurPos]; 144 | if (D[0]!=0x52 || D[1]!=0x53 || D[2]!=0x46 || D[3]!=0x58) 145 | continue; 146 | } 147 | SFXSize=CurPos+I; 148 | Seek(SFXSize,SEEK_SET); 149 | if (!OldFormat) 150 | Read(MarkHead.Mark,SIZEOF_MARKHEAD); 151 | break; 152 | } 153 | if (SFXSize==0) 154 | return(false); 155 | } 156 | ReadHeader(); 157 | SeekToNext(); 158 | #ifndef SFX_MODULE 159 | if (OldFormat) 160 | { 161 | NewMhd.Flags=OldMhd.Flags & 0x3f; 162 | NewMhd.HeadSize=OldMhd.HeadSize; 163 | } 164 | else 165 | #endif 166 | { 167 | if (HeaderCRC!=NewMhd.HeadCRC) 168 | { 169 | #ifndef SHELL_EXT 170 | Log(FileName,St(MLogMainHead)); 171 | #endif 172 | Alarm(); 173 | if (!EnableBroken) 174 | return(false); 175 | } 176 | } 177 | Volume=(NewMhd.Flags & MHD_VOLUME); 178 | Solid=(NewMhd.Flags & MHD_SOLID)!=0; 179 | MainComment=(NewMhd.Flags & MHD_COMMENT)!=0; 180 | Locked=(NewMhd.Flags & MHD_LOCK)!=0; 181 | Signed=(NewMhd.PosAV!=0); 182 | Protected=(NewMhd.Flags & MHD_PROTECT)!=0; 183 | Encrypted=(NewMhd.Flags & MHD_PASSWORD)!=0; 184 | 185 | if (NewMhd.EncryptVer>UNP_VER) 186 | { 187 | #ifdef RARDLL 188 | Cmd->DllError=ERAR_UNKNOWN_FORMAT; 189 | #else 190 | ErrHandler.SetErrorCode(WARNING); 191 | #if !defined(SILENT) && !defined(SFX_MODULE) 192 | Log(FileName,St(MUnknownMeth),FileName); 193 | Log(FileName,St(MVerRequired),NewMhd.EncryptVer/10,NewMhd.EncryptVer%10); 194 | #endif 195 | #endif 196 | return(false); 197 | } 198 | #ifdef RARDLL 199 | // If callback function is not set, we cannot get the password, 200 | // so we skip the initial header processing for encrypted header archive. 201 | // It leads to skipped archive comment, but the rest of archive data 202 | // is processed correctly. 203 | if (Cmd->Callback==NULL) 204 | SilentOpen=true; 205 | #endif 206 | 207 | // If not encrypted, we'll check it below. 208 | NotFirstVolume=Encrypted && (NewMhd.Flags & MHD_FIRSTVOLUME)==0; 209 | 210 | if (!SilentOpen || !Encrypted) 211 | { 212 | SaveFilePos SavePos(*this); 213 | int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos; 214 | 215 | NotFirstVolume=false; 216 | while (ReadHeader()!=0) 217 | { 218 | int HeaderType=GetHeaderType(); 219 | if (HeaderType==NEWSUB_HEAD) 220 | { 221 | if (SubHead.CmpName(SUBHEAD_TYPE_CMT)) 222 | MainComment=true; 223 | if ((SubHead.Flags & LHD_SPLIT_BEFORE) || 224 | Volume && (NewMhd.Flags & MHD_FIRSTVOLUME)==0) 225 | NotFirstVolume=true; 226 | } 227 | else 228 | { 229 | if (HeaderType==FILE_HEAD && ((NewLhd.Flags & LHD_SPLIT_BEFORE)!=0 || 230 | Volume && NewLhd.UnpVer>=29 && (NewMhd.Flags & MHD_FIRSTVOLUME)==0)) 231 | NotFirstVolume=true; 232 | break; 233 | } 234 | SeekToNext(); 235 | } 236 | CurBlockPos=SaveCurBlockPos; 237 | NextBlockPos=SaveNextBlockPos; 238 | } 239 | if (!Volume || !NotFirstVolume) 240 | { 241 | strcpy(FirstVolumeName,FileName); 242 | wcscpy(FirstVolumeNameW,FileNameW); 243 | } 244 | 245 | return(true); 246 | } 247 | 248 | 249 | 250 | 251 | void Archive::SeekToNext() 252 | { 253 | Seek(NextBlockPos,SEEK_SET); 254 | } 255 | 256 | 257 | #ifndef SFX_MODULE 258 | int Archive::GetRecoverySize(bool Required) 259 | { 260 | if (!Protected) 261 | return(0); 262 | if (RecoverySectors!=-1 || !Required) 263 | return(RecoverySectors); 264 | SaveFilePos SavePos(*this); 265 | Seek(SFXSize,SEEK_SET); 266 | SearchSubBlock(SUBHEAD_TYPE_RR); 267 | return(RecoverySectors); 268 | } 269 | #endif 270 | 271 | 272 | 273 | 274 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/archive.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_ARCHIVE_ 2 | #define _RAR_ARCHIVE_ 3 | 4 | class Pack; 5 | 6 | enum {EN_LOCK=1,EN_VOL=2,EN_FIRSTVOL=4}; 7 | 8 | class Archive:public File 9 | { 10 | private: 11 | bool IsSignature(byte *D); 12 | void UpdateLatestTime(FileHeader *CurBlock); 13 | void ConvertNameCase(char *Name); 14 | void ConvertNameCase(wchar *Name); 15 | void ConvertUnknownHeader(); 16 | size_t ReadOldHeader(); 17 | void UnexpEndArcMsg(); 18 | 19 | #if !defined(SHELL_EXT) && !defined(NOCRYPT) 20 | CryptData HeadersCrypt; 21 | byte HeadersSalt[SALT_SIZE]; 22 | #endif 23 | #ifndef SHELL_EXT 24 | ComprDataIO SubDataIO; 25 | byte SubDataSalt[SALT_SIZE]; 26 | #endif 27 | RAROptions *Cmd,DummyCmd; 28 | 29 | MarkHeader MarkHead; 30 | OldMainHeader OldMhd; 31 | 32 | int RecoverySectors; 33 | int64 RecoveryPos; 34 | 35 | bool FailedHeaderDecryption; 36 | 37 | RarTime LatestTime; 38 | int LastReadBlock; 39 | int CurHeaderType; 40 | 41 | bool SilentOpen; 42 | public: 43 | Archive(RAROptions *InitCmd=NULL); 44 | bool IsArchive(bool EnableBroken); 45 | size_t SearchBlock(int BlockType); 46 | size_t SearchSubBlock(const char *Type); 47 | int ReadBlock(int BlockType); 48 | void WriteBlock(int BlockType,BaseBlock *wb=NULL); 49 | int PrepareNamesToWrite(char *Name,wchar *NameW,char *DestName,byte *DestNameW); 50 | void SetLhdSize(); 51 | size_t ReadHeader(); 52 | void CheckArc(bool EnableBroken); 53 | void CheckOpen(const char *Name,const wchar *NameW=NULL); 54 | bool WCheckOpen(const char *Name,const wchar *NameW=NULL); 55 | bool GetComment(Array *CmtData,Array *CmtDataW); 56 | void ViewComment(); 57 | void ViewFileComment(); 58 | void SetLatestTime(RarTime *NewTime); 59 | void SeekToNext(); 60 | bool CheckAccess(); 61 | bool IsArcDir(); 62 | bool IsArcLabel(); 63 | void ConvertAttributes(); 64 | int GetRecoverySize(bool Required); 65 | void VolSubtractHeaderSize(size_t SubSize); 66 | void AddSubData(byte *SrcData,size_t DataSize,File *SrcFile,const char *Name,bool AllowSplit); 67 | bool ReadSubData(Array *UnpData,File *DestFile); 68 | int GetHeaderType() {return(CurHeaderType);}; 69 | size_t ReadCommentData(Array *CmtData,Array *CmtDataW); 70 | void WriteCommentData(byte *Data,size_t DataSize,bool FileComment); 71 | RAROptions* GetRAROptions() {return(Cmd);} 72 | void SetSilentOpen(bool Mode) {SilentOpen=Mode;} 73 | 74 | BaseBlock ShortBlock; 75 | MainHeader NewMhd; 76 | FileHeader NewLhd; 77 | EndArcHeader EndArcHead; 78 | SubBlockHeader SubBlockHead; 79 | FileHeader SubHead; 80 | CommentHeader CommHead; 81 | ProtectHeader ProtectHead; 82 | AVHeader AVHead; 83 | SignHeader SignHead; 84 | UnixOwnersHeader UOHead; 85 | MacFInfoHeader MACHead; 86 | EAHeader EAHead; 87 | StreamHeader StreamHead; 88 | 89 | int64 CurBlockPos; 90 | int64 NextBlockPos; 91 | 92 | bool OldFormat; 93 | bool Solid; 94 | bool Volume; 95 | bool MainComment; 96 | bool Locked; 97 | bool Signed; 98 | bool NotFirstVolume; 99 | bool Protected; 100 | bool Encrypted; 101 | size_t SFXSize; 102 | bool BrokenFileHeader; 103 | 104 | bool Splitting; 105 | 106 | ushort HeaderCRC; 107 | 108 | int64 VolWrite; 109 | int64 AddingFilesSize; 110 | size_t AddingHeadersSize; 111 | 112 | bool NewArchive; 113 | 114 | char FirstVolumeName[NM]; 115 | wchar FirstVolumeNameW[NM]; 116 | }; 117 | 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/array.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_ARRAY_ 2 | #define _RAR_ARRAY_ 3 | 4 | extern ErrorHandler ErrHandler; 5 | 6 | template class Array 7 | { 8 | private: 9 | T *Buffer; 10 | size_t BufSize; 11 | size_t AllocSize; 12 | public: 13 | Array(); 14 | Array(size_t Size); 15 | ~Array(); 16 | inline void CleanData(); 17 | inline T& operator [](size_t Item); 18 | inline size_t Size(); // Returns the size in items, not in bytes. 19 | void Add(size_t Items); 20 | void Alloc(size_t Items); 21 | void Reset(); 22 | void operator = (Array &Src); 23 | void Push(T Item); 24 | T* Addr() {return(Buffer);} 25 | }; 26 | 27 | template void Array::CleanData() 28 | { 29 | Buffer=NULL; 30 | BufSize=0; 31 | AllocSize=0; 32 | } 33 | 34 | 35 | template Array::Array() 36 | { 37 | CleanData(); 38 | } 39 | 40 | 41 | template Array::Array(size_t Size) 42 | { 43 | Buffer=(T *)malloc(sizeof(T)*Size); 44 | if (Buffer==NULL && Size!=0) 45 | ErrHandler.MemoryError(); 46 | 47 | AllocSize=BufSize=Size; 48 | } 49 | 50 | 51 | template Array::~Array() 52 | { 53 | if (Buffer!=NULL) 54 | free(Buffer); 55 | } 56 | 57 | 58 | template inline T& Array::operator [](size_t Item) 59 | { 60 | return(Buffer[Item]); 61 | } 62 | 63 | 64 | template inline size_t Array::Size() 65 | { 66 | return(BufSize); 67 | } 68 | 69 | 70 | template void Array::Add(size_t Items) 71 | { 72 | BufSize+=Items; 73 | if (BufSize>AllocSize) 74 | { 75 | size_t Suggested=AllocSize+AllocSize/4+32; 76 | size_t NewSize=Max(BufSize,Suggested); 77 | 78 | Buffer=(T *)realloc(Buffer,NewSize*sizeof(T)); 79 | if (Buffer==NULL) 80 | ErrHandler.MemoryError(); 81 | AllocSize=NewSize; 82 | } 83 | } 84 | 85 | 86 | template void Array::Alloc(size_t Items) 87 | { 88 | if (Items>AllocSize) 89 | Add(Items-BufSize); 90 | else 91 | BufSize=Items; 92 | } 93 | 94 | 95 | template void Array::Reset() 96 | { 97 | if (Buffer!=NULL) 98 | { 99 | free(Buffer); 100 | Buffer=NULL; 101 | } 102 | BufSize=0; 103 | AllocSize=0; 104 | } 105 | 106 | 107 | template void Array::operator =(Array &Src) 108 | { 109 | Reset(); 110 | Alloc(Src.BufSize); 111 | if (Src.BufSize!=0) 112 | memcpy((void *)Buffer,(void *)Src.Buffer,Src.BufSize*sizeof(T)); 113 | } 114 | 115 | 116 | template void Array::Push(T Item) 117 | { 118 | Add(1); 119 | (*this)[Size()-1]=Item; 120 | } 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/beosea.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | void ExtractBeEA(Archive &Arc,char *FileName) 4 | { 5 | if (Arc.HeaderCRC!=Arc.EAHead.HeadCRC) 6 | { 7 | Log(Arc.FileName,St(MEABroken),FileName); 8 | ErrHandler.SetErrorCode(CRC_ERROR); 9 | return; 10 | } 11 | if (Arc.EAHead.Method<0x31 || Arc.EAHead.Method>0x35 || Arc.EAHead.UnpVer>PACK_VER) 12 | { 13 | Log(Arc.FileName,St(MEAUnknHeader),FileName); 14 | return; 15 | } 16 | 17 | ComprDataIO DataIO; 18 | Unpack Unpack(&DataIO); 19 | Unpack.Init(); 20 | 21 | Array UnpData(Arc.EAHead.UnpSize); 22 | DataIO.SetUnpackToMemory(&UnpData[0],Arc.EAHead.UnpSize); 23 | DataIO.SetPackedSizeToRead(Arc.EAHead.DataSize); 24 | DataIO.EnableShowProgress(false); 25 | DataIO.SetFiles(&Arc,NULL); 26 | Unpack.SetDestSize(Arc.EAHead.UnpSize); 27 | Unpack.DoUnpack(Arc.EAHead.UnpVer,false); 28 | 29 | if (Arc.EAHead.EACRC!=~DataIO.UnpFileCRC) 30 | { 31 | Log(Arc.FileName,St(MEABroken),FileName); 32 | ErrHandler.SetErrorCode(CRC_ERROR); 33 | return; 34 | } 35 | int fd = open(FileName,O_WRONLY); 36 | if (fd==-1) 37 | { 38 | Log(Arc.FileName,St(MCannotSetEA),FileName); 39 | ErrHandler.SetErrorCode(WARNING); 40 | return; 41 | } 42 | 43 | int AttrPos=0; 44 | while (AttrPos=sizeof(Name)) 52 | { 53 | Log(Arc.FileName,St(MCannotSetEA),FileName); 54 | ErrHandler.SetErrorCode(WARNING); 55 | break; 56 | } 57 | memcpy(Name,CurItem+10,NameSize); 58 | Name[NameSize]=0; 59 | if (fs_write_attr(fd,Name,Type,0,CurItem+10+NameSize,Size)==-1) 60 | { 61 | Log(Arc.FileName,St(MCannotSetEA),FileName); 62 | ErrHandler.SetErrorCode(WARNING); 63 | break; 64 | } 65 | AttrPos+=10+NameSize+Size; 66 | } 67 | close(fd); 68 | mprintf(St(MShowEA)); 69 | } 70 | 71 | 72 | void ExtractBeEANew(Archive &Arc,char *FileName) 73 | { 74 | Array SubData; 75 | if (!Arc.ReadSubData(&SubData,NULL)) 76 | return; 77 | 78 | int fd = open(FileName,O_WRONLY); 79 | if (fd==-1) 80 | { 81 | Log(Arc.FileName,St(MCannotSetEA),FileName); 82 | ErrHandler.SetErrorCode(WARNING); 83 | return; 84 | } 85 | 86 | int AttrPos=0; 87 | while (AttrPos=sizeof(Name)) 95 | { 96 | Log(Arc.FileName,St(MCannotSetEA),FileName); 97 | ErrHandler.SetErrorCode(WARNING); 98 | break; 99 | } 100 | memcpy(Name,CurItem+10,NameSize); 101 | Name[NameSize]=0; 102 | if (fs_write_attr(fd,Name,Type,0,CurItem+10+NameSize,Size)==-1) 103 | { 104 | Log(Arc.FileName,St(MCannotSetEA),FileName); 105 | ErrHandler.SetErrorCode(WARNING); 106 | break; 107 | } 108 | AttrPos+=10+NameSize+Size; 109 | } 110 | close(fd); 111 | mprintf(St(MShowEA)); 112 | } 113 | 114 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/cmddata.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_CMDDATA_ 2 | #define _RAR_CMDDATA_ 3 | 4 | #define DefaultStoreList "7z;ace;arj;bz2;cab;gz;jpeg;jpg;lha;lzh;mp3;rar;taz;tgz;z;zip" 5 | 6 | class CommandData:public RAROptions 7 | { 8 | private: 9 | void ProcessSwitchesString(char *Str); 10 | void ProcessSwitch(char *Switch,wchar *SwitchW=NULL); 11 | void BadSwitch(char *Switch); 12 | bool ExclCheckArgs(StringList *Args,bool Dir,char *CheckName,bool CheckFullPath,int MatchMode); 13 | uint GetExclAttr(char *Str); 14 | 15 | bool FileLists; 16 | bool NoMoreSwitches; 17 | bool BareOutput; 18 | public: 19 | CommandData(); 20 | ~CommandData(); 21 | void Init(); 22 | void Close(); 23 | void ParseArg(char *Arg,wchar *ArgW); 24 | void ParseDone(); 25 | void ParseEnvVar(); 26 | void ReadConfig(int argc,char *argv[]); 27 | bool IsConfigEnabled(int argc,char *argv[]); 28 | void OutTitle(); 29 | void OutHelp(); 30 | bool IsSwitch(int Ch); 31 | bool ExclCheck(char *CheckName,bool Dir,bool CheckFullPath,bool CheckInclList); 32 | bool ExclDirByAttr(uint FileAttr); 33 | bool TimeCheck(RarTime &ft); 34 | bool SizeCheck(int64 Size); 35 | bool AnyFiltersActive(); 36 | int IsProcessFile(FileHeader &NewLhd,bool *ExactMatch=NULL,int MatchType=MATCH_WILDSUBPATH); 37 | void ProcessCommand(); 38 | void AddArcName(const char *Name,const wchar *NameW); 39 | bool GetArcName(char *Name,wchar *NameW,int MaxSize); 40 | bool CheckWinSize(); 41 | 42 | int GetRecoverySize(char *Str,int DefSize); 43 | 44 | char Command[NM+16]; 45 | wchar CommandW[NM+16]; 46 | 47 | char ArcName[NM]; 48 | wchar ArcNameW[NM]; 49 | 50 | StringList *FileArgs; 51 | StringList *ExclArgs; 52 | StringList *InclArgs; 53 | StringList *ArcNames; 54 | StringList *StoreArgs; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/coder.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | inline unsigned int RangeCoder::GetChar() 4 | { 5 | return(UnpackRead->GetChar()); 6 | } 7 | 8 | 9 | void RangeCoder::InitDecoder(Unpack *UnpackRead) 10 | { 11 | RangeCoder::UnpackRead=UnpackRead; 12 | 13 | low=code=0; 14 | range=uint(-1); 15 | for (int i=0;i < 4;i++) 16 | code=(code << 8) | GetChar(); 17 | } 18 | 19 | 20 | // (int) cast before "low" added only to suppress compiler warnings. 21 | #define ARI_DEC_NORMALIZE(code,low,range,read) \ 22 | { \ 23 | while ((low^(low+range))GetChar(); \ 26 | range <<= 8; \ 27 | low <<= 8; \ 28 | } \ 29 | } 30 | 31 | 32 | inline int RangeCoder::GetCurrentCount() 33 | { 34 | return (code-low)/(range /= SubRange.scale); 35 | } 36 | 37 | 38 | inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT) 39 | { 40 | return (code-low)/(range >>= SHIFT); 41 | } 42 | 43 | 44 | inline void RangeCoder::Decode() 45 | { 46 | low += range*SubRange.LowCount; 47 | range *= SubRange.HighCount-SubRange.LowCount; 48 | } 49 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/coder.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Contents: 'Carryless rangecoder' by Dmitry Subbotin * 3 | ****************************************************************************/ 4 | 5 | const uint TOP=1 << 24, BOT=1 << 15; 6 | 7 | class RangeCoder 8 | { 9 | public: 10 | void InitDecoder(Unpack *UnpackRead); 11 | inline int GetCurrentCount(); 12 | inline uint GetCurrentShiftCount(uint SHIFT); 13 | inline void Decode(); 14 | inline void PutChar(unsigned int c); 15 | inline unsigned int GetChar(); 16 | 17 | uint low, code, range; 18 | struct SUBRANGE 19 | { 20 | uint LowCount, HighCount, scale; 21 | } SubRange; 22 | 23 | Unpack *UnpackRead; 24 | }; 25 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/compress.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_COMPRESS_ 2 | #define _RAR_COMPRESS_ 3 | 4 | class ComprDataIO; 5 | class PackingFileTable; 6 | 7 | #define MAX_LZ_MATCH 0x101 8 | 9 | #define CODEBUFSIZE 0x4000 10 | #define MAXWINSIZE 0x400000 11 | #define MAXWINMASK (MAXWINSIZE-1) 12 | 13 | #define LOW_DIST_REP_COUNT 16 14 | 15 | #define NC 299 /* alphabet = {0, 1, 2, ..., NC - 1} */ 16 | #define DC 60 17 | #define LDC 17 18 | #define RC 28 19 | #define HUFF_TABLE_SIZE (NC+DC+RC+LDC) 20 | #define BC 20 21 | 22 | #define NC20 298 /* alphabet = {0, 1, 2, ..., NC - 1} */ 23 | #define DC20 48 24 | #define RC20 28 25 | #define BC20 19 26 | #define MC20 257 27 | 28 | // Largest alphabet size among all values listed above. 29 | #define LARGEST_TABLE_SIZE 299 30 | 31 | enum {CODE_HUFFMAN,CODE_LZ,CODE_LZ2,CODE_REPEATLZ,CODE_CACHELZ, 32 | CODE_STARTFILE,CODE_ENDFILE,CODE_VM,CODE_VMDATA}; 33 | 34 | 35 | enum FilterType { 36 | FILTER_NONE, FILTER_PPM /*dummy*/, FILTER_E8, FILTER_E8E9, 37 | FILTER_UPCASETOLOW, FILTER_AUDIO, FILTER_RGB, FILTER_DELTA, 38 | FILTER_ITANIUM, FILTER_E8E9V2 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/consio.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #ifndef GUI 4 | #include "log.cpp" 5 | #endif 6 | 7 | static int KbdAnsi(char *Addr,int Size); 8 | 9 | #if !defined(GUI) && !defined(SILENT) 10 | static void RawPrint(char *Msg,MESSAGE_TYPE MessageType); 11 | static uint GetKey(); 12 | #endif 13 | 14 | static MESSAGE_TYPE MsgStream=MSG_STDOUT; 15 | static bool Sound=false; 16 | const int MaxMsgSize=2*NM+2048; 17 | 18 | void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound) 19 | { 20 | ::MsgStream=MsgStream; 21 | ::Sound=Sound; 22 | } 23 | 24 | #if !defined(GUI) && !defined(SILENT) 25 | void mprintf(const char *fmt,...) 26 | { 27 | if (MsgStream==MSG_NULL || MsgStream==MSG_ERRONLY) 28 | return; 29 | safebuf char Msg[MaxMsgSize]; 30 | va_list argptr; 31 | va_start(argptr,fmt); 32 | vsprintf(Msg,fmt,argptr); 33 | RawPrint(Msg,MsgStream); 34 | va_end(argptr); 35 | } 36 | #endif 37 | 38 | 39 | #if !defined(GUI) && !defined(SILENT) 40 | void eprintf(const char *fmt,...) 41 | { 42 | if (MsgStream==MSG_NULL) 43 | return; 44 | safebuf char Msg[MaxMsgSize]; 45 | va_list argptr; 46 | va_start(argptr,fmt); 47 | vsprintf(Msg,fmt,argptr); 48 | RawPrint(Msg,MSG_STDERR); 49 | va_end(argptr); 50 | } 51 | #endif 52 | 53 | 54 | #if !defined(GUI) && !defined(SILENT) 55 | void RawPrint(char *Msg,MESSAGE_TYPE MessageType) 56 | { 57 | File OutFile; 58 | switch(MessageType) 59 | { 60 | case MSG_STDOUT: 61 | OutFile.SetHandleType(FILE_HANDLESTD); 62 | break; 63 | case MSG_STDERR: 64 | case MSG_ERRONLY: 65 | OutFile.SetHandleType(FILE_HANDLEERR); 66 | break; 67 | default: 68 | return; 69 | } 70 | #ifdef _WIN_ALL 71 | CharToOemA(Msg,Msg); 72 | 73 | char OutMsg[MaxMsgSize],*OutPos=OutMsg; 74 | for (int I=0;Msg[I]!=0;I++) 75 | { 76 | if (Msg[I]=='\n' && (I==0 || Msg[I-1]!='\r')) 77 | *(OutPos++)='\r'; 78 | *(OutPos++)=Msg[I]; 79 | } 80 | *OutPos=0; 81 | strcpy(Msg,OutMsg); 82 | #endif 83 | #if defined(_UNIX) || defined(_EMX) 84 | char OutMsg[MaxMsgSize],*OutPos=OutMsg; 85 | for (int I=0;Msg[I]!=0;I++) 86 | if (Msg[I]!='\r') 87 | *(OutPos++)=Msg[I]; 88 | *OutPos=0; 89 | strcpy(Msg,OutMsg); 90 | #endif 91 | 92 | OutFile.Write(Msg,strlen(Msg)); 93 | } 94 | #endif 95 | 96 | 97 | #ifndef SILENT 98 | void Alarm() 99 | { 100 | #ifndef SFX_MODULE 101 | if (Sound) 102 | putchar('\007'); 103 | #endif 104 | } 105 | #endif 106 | 107 | 108 | #ifndef SILENT 109 | #ifndef GUI 110 | void GetPasswordText(wchar *Str,uint MaxLength) 111 | { 112 | if (MaxLength==0) 113 | return; 114 | #ifdef _WIN_ALL 115 | HANDLE hConIn=GetStdHandle(STD_INPUT_HANDLE); 116 | HANDLE hConOut=GetStdHandle(STD_OUTPUT_HANDLE); 117 | DWORD ConInMode,ConOutMode; 118 | DWORD Read=0; 119 | GetConsoleMode(hConIn,&ConInMode); 120 | GetConsoleMode(hConOut,&ConOutMode); 121 | SetConsoleMode(hConIn,ENABLE_LINE_INPUT); 122 | SetConsoleMode(hConOut,ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT); 123 | 124 | ReadConsoleW(hConIn,Str,MaxLength-1,&Read,NULL); 125 | Str[Read]=0; 126 | SetConsoleMode(hConIn,ConInMode); 127 | SetConsoleMode(hConOut,ConOutMode); 128 | #else 129 | char StrA[MAXPASSWORD]; 130 | #if defined(_EMX) || defined(_BEOS) || defined(__sparc) || defined(sparc) || defined (__VMS) 131 | fgets(StrA,ASIZE(StrA)-1,stdin); 132 | #else 133 | strncpyz(StrA,getpass(""),ASIZE(StrA)); 134 | #endif 135 | CharToWide(StrA,Str,MaxLength); 136 | #endif 137 | Str[MaxLength-1]=0; 138 | RemoveLF(Str); 139 | } 140 | #endif 141 | #endif 142 | 143 | 144 | #ifndef SILENT 145 | bool GetPassword(PASSWORD_TYPE Type,const char *FileName,const wchar *FileNameW,wchar *Password,uint MaxLength) 146 | { 147 | Alarm(); 148 | while (true) 149 | { 150 | char PromptStr[NM+256]; 151 | #if defined(_EMX) || defined(_BEOS) 152 | strcpy(PromptStr,St(MAskPswEcho)); 153 | #else 154 | strcpy(PromptStr,St(MAskPsw)); 155 | #endif 156 | if (Type!=PASSWORD_GLOBAL) 157 | { 158 | strcat(PromptStr,St(MFor)); 159 | char *NameOnly=PointToName(FileName); 160 | if (strlen(PromptStr)+strlen(NameOnly)4 ? "\n":" "):", "); 243 | int KeyPos=ItemKeyPos[I]; 244 | for (int J=0;J>1)^0xEDB88320L : (C>>1); 12 | CRCTab[I]=C; 13 | } 14 | } 15 | 16 | 17 | uint CRC(uint StartCRC,const void *Addr,size_t Size) 18 | { 19 | if (CRCTab[1]==0) 20 | InitCRC(); 21 | byte *Data=(byte *)Addr; 22 | 23 | #if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32) && defined(ALLOW_NOT_ALIGNED_INT) 24 | while (Size>0 && ((long)Data & 7)) 25 | { 26 | StartCRC=CRCTab[(byte)(StartCRC^Data[0])]^(StartCRC>>8); 27 | Size--; 28 | Data++; 29 | } 30 | while (Size>=8) 31 | { 32 | StartCRC^=*(uint32 *)Data; 33 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 34 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 35 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 36 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 37 | StartCRC^=*(uint32 *)(Data+4); 38 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 39 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 40 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 41 | StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8); 42 | Data+=8; 43 | Size-=8; 44 | } 45 | #endif 46 | 47 | for (size_t I=0;I>8); 49 | return(StartCRC); 50 | } 51 | 52 | #ifndef SFX_MODULE 53 | ushort OldCRC(ushort StartCRC,const void *Addr,size_t Size) 54 | { 55 | byte *Data=(byte *)Addr; 56 | for (size_t I=0;I>15))&0xffff; 60 | } 61 | return(StartCRC); 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/crc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_CRC_ 2 | #define _RAR_CRC_ 3 | 4 | extern uint CRCTab[256]; 5 | 6 | void InitCRC(); 7 | uint CRC(uint StartCRC,const void *Addr,size_t Size); 8 | ushort OldCRC(ushort StartCRC,const void *Addr,size_t Size); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/crypt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_CRYPT_ 2 | #define _RAR_CRYPT_ 3 | 4 | enum { OLD_DECODE=0,OLD_ENCODE=1,NEW_CRYPT=2 }; 5 | 6 | 7 | struct CryptKeyCacheItem 8 | { 9 | #ifndef _SFX_RTL_ 10 | CryptKeyCacheItem() 11 | { 12 | *Password=0; 13 | } 14 | 15 | ~CryptKeyCacheItem() 16 | { 17 | memset(AESKey,0,sizeof(AESKey)); 18 | memset(AESInit,0,sizeof(AESInit)); 19 | memset(Password,0,sizeof(Password)); 20 | } 21 | #endif 22 | byte AESKey[16],AESInit[16]; 23 | wchar Password[MAXPASSWORD]; 24 | bool SaltPresent; 25 | byte Salt[SALT_SIZE]; 26 | bool HandsOffHash; 27 | }; 28 | 29 | class CryptData 30 | { 31 | private: 32 | void Encode13(byte *Data,uint Count); 33 | void Decode13(byte *Data,uint Count); 34 | void Crypt15(byte *Data,uint Count); 35 | void UpdKeys(byte *Buf); 36 | void Swap(byte *Ch1,byte *Ch2); 37 | void SetOldKeys(const char *Password); 38 | 39 | Rijndael rin; 40 | 41 | byte SubstTable[256]; 42 | uint Key[4]; 43 | ushort OldKey[4]; 44 | byte PN1,PN2,PN3; 45 | 46 | byte AESKey[16],AESInit[16]; 47 | 48 | static CryptKeyCacheItem Cache[4]; 49 | static int CachePos; 50 | public: 51 | void SetCryptKeys(const wchar *Password,const byte *Salt,bool Encrypt,bool OldOnly,bool HandsOffHash); 52 | void SetAV15Encryption(); 53 | void SetCmt13Encryption(); 54 | void EncryptBlock20(byte *Buf); 55 | void DecryptBlock20(byte *Buf); 56 | void EncryptBlock(byte *Buf,size_t Size); 57 | void DecryptBlock(byte *Buf,size_t Size); 58 | void Crypt(byte *Data,uint Count,int Method); 59 | static void SetSalt(byte *Salt,int SaltSize); 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/dll.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | RAROpenArchive 3 | RAROpenArchiveEx 4 | RARCloseArchive 5 | RARReadHeader 6 | RARReadHeaderEx 7 | RARProcessFile 8 | RARSetCallback 9 | RARSetChangeVolProc 10 | RARSetProcessDataProc 11 | RARSetPassword 12 | RARGetDllVersion 13 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/dll.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _UNRAR_DLL_ 2 | #define _UNRAR_DLL_ 3 | 4 | #pragma pack(1) 5 | 6 | #define ERAR_END_ARCHIVE 10 7 | #define ERAR_NO_MEMORY 11 8 | #define ERAR_BAD_DATA 12 9 | #define ERAR_BAD_ARCHIVE 13 10 | #define ERAR_UNKNOWN_FORMAT 14 11 | #define ERAR_EOPEN 15 12 | #define ERAR_ECREATE 16 13 | #define ERAR_ECLOSE 17 14 | #define ERAR_EREAD 18 15 | #define ERAR_EWRITE 19 16 | #define ERAR_SMALL_BUF 20 17 | #define ERAR_UNKNOWN 21 18 | #define ERAR_MISSING_PASSWORD 22 19 | 20 | #define RAR_OM_LIST 0 21 | #define RAR_OM_EXTRACT 1 22 | #define RAR_OM_LIST_INCSPLIT 2 23 | 24 | #define RAR_SKIP 0 25 | #define RAR_TEST 1 26 | #define RAR_EXTRACT 2 27 | 28 | #define RAR_VOL_ASK 0 29 | #define RAR_VOL_NOTIFY 1 30 | 31 | #define RAR_DLL_VERSION 5 32 | 33 | #ifdef _UNIX 34 | #define CALLBACK 35 | #define PASCAL 36 | #define LONG long 37 | #define HANDLE void * 38 | #define LPARAM ssize_t 39 | #define UINT unsigned int 40 | #define DLLIMPORT extern 41 | #else 42 | // Windows 43 | #define DLLIMPORT __declspec(dllimport) 44 | #endif 45 | 46 | struct RARHeaderData 47 | { 48 | char ArcName[260]; 49 | char FileName[260]; 50 | unsigned int Flags; 51 | unsigned int PackSize; 52 | unsigned int UnpSize; 53 | unsigned int HostOS; 54 | unsigned int FileCRC; 55 | unsigned int FileTime; 56 | unsigned int UnpVer; 57 | unsigned int Method; 58 | unsigned int FileAttr; 59 | char *CmtBuf; 60 | unsigned int CmtBufSize; 61 | unsigned int CmtSize; 62 | unsigned int CmtState; 63 | }; 64 | 65 | 66 | struct RARHeaderDataEx 67 | { 68 | char ArcName[1024]; 69 | wchar_t ArcNameW[1024]; 70 | char FileName[1024]; 71 | wchar_t FileNameW[1024]; 72 | unsigned int Flags; 73 | unsigned int PackSize; 74 | unsigned int PackSizeHigh; 75 | unsigned int UnpSize; 76 | unsigned int UnpSizeHigh; 77 | unsigned int HostOS; 78 | unsigned int FileCRC; 79 | unsigned int FileTime; 80 | unsigned int UnpVer; 81 | unsigned int Method; 82 | unsigned int FileAttr; 83 | char *CmtBuf; 84 | unsigned int CmtBufSize; 85 | unsigned int CmtSize; 86 | unsigned int CmtState; 87 | unsigned int Reserved[1024]; 88 | }; 89 | 90 | 91 | struct RAROpenArchiveData 92 | { 93 | char *ArcName; 94 | unsigned int OpenMode; 95 | unsigned int OpenResult; 96 | char *CmtBuf; 97 | unsigned int CmtBufSize; 98 | unsigned int CmtSize; 99 | unsigned int CmtState; 100 | }; 101 | 102 | typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2); 103 | 104 | struct RAROpenArchiveDataEx 105 | { 106 | char *ArcName; 107 | wchar_t *ArcNameW; 108 | unsigned int OpenMode; 109 | unsigned int OpenResult; 110 | char *CmtBuf; 111 | unsigned int CmtBufSize; 112 | unsigned int CmtSize; 113 | unsigned int CmtState; 114 | unsigned int Flags; 115 | UNRARCALLBACK Callback; 116 | LPARAM UserData; 117 | unsigned int Reserved[28]; 118 | }; 119 | 120 | enum UNRARCALLBACK_MESSAGES { 121 | UCM_CHANGEVOLUME,UCM_PROCESSDATA,UCM_NEEDPASSWORD 122 | }; 123 | 124 | typedef int (PASCAL *CHANGEVOLPROC)(char *ArcName,int Mode); 125 | typedef int (PASCAL *PROCESSDATAPROC)(unsigned char *Addr,int Size); 126 | 127 | #ifdef __cplusplus 128 | extern "C" { 129 | #endif 130 | 131 | DLLIMPORT HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData); 132 | DLLIMPORT HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData); 133 | DLLIMPORT int PASCAL RARCloseArchive(HANDLE hArcData); 134 | DLLIMPORT int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData); 135 | DLLIMPORT int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData); 136 | DLLIMPORT int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName); 137 | DLLIMPORT int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar_t *DestPath,wchar_t *DestName); 138 | DLLIMPORT void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,LPARAM UserData); 139 | DLLIMPORT void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc); 140 | DLLIMPORT void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc); 141 | DLLIMPORT void PASCAL RARSetPassword(HANDLE hArcData,char *Password); 142 | DLLIMPORT int PASCAL RARGetDllVersion(); 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | #pragma pack() 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/dll.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vlovich/stream-unrar/15d59960b5e787ebcd6276362fb5a8c268f8211f/3rd_party/unrar-4.0.7/dll.rc -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/encname.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | EncodeFileName::EncodeFileName() 4 | { 5 | Flags=0; 6 | FlagBits=0; 7 | FlagsPos=0; 8 | DestSize=0; 9 | } 10 | 11 | 12 | 13 | 14 | void EncodeFileName::Decode(char *Name,byte *EncName,size_t EncSize,wchar *NameW, 15 | size_t MaxDecSize) 16 | { 17 | size_t EncPos=0,DecPos=0; 18 | byte HighByte=EncName[EncPos++]; 19 | while (EncPos>6) 27 | { 28 | case 0: 29 | NameW[DecPos++]=EncName[EncPos++]; 30 | break; 31 | case 1: 32 | NameW[DecPos++]=EncName[EncPos++]+(HighByte<<8); 33 | break; 34 | case 2: 35 | NameW[DecPos++]=EncName[EncPos]+(EncName[EncPos+1]<<8); 36 | EncPos+=2; 37 | break; 38 | case 3: 39 | { 40 | int Length=EncName[EncPos++]; 41 | if (Length & 0x80) 42 | { 43 | byte Correction=EncName[EncPos++]; 44 | for (Length=(Length&0x7f)+2;Length>0 && DecPos0 && DecPosProcessEA) 27 | ExtractOS2EA(Arc,Name); 28 | break; 29 | #endif 30 | #ifdef _UNIX 31 | case UO_HEAD: 32 | if (Cmd->ProcessOwners) 33 | ExtractUnixOwner(Arc,Name); 34 | break; 35 | #endif 36 | #ifdef _BEOS 37 | case BEEA_HEAD: 38 | if (Cmd->ProcessEA) 39 | ExtractBeEA(Arc,Name); 40 | break; 41 | #endif 42 | #ifdef _WIN_ALL 43 | case NTACL_HEAD: 44 | if (Cmd->ProcessOwners) 45 | ExtractACL(Arc,Name,NameW); 46 | break; 47 | case STREAM_HEAD: 48 | ExtractStreams(Arc,Name,NameW); 49 | break; 50 | #endif 51 | } 52 | } 53 | #endif 54 | 55 | 56 | void SetExtraInfoNew(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW) 57 | { 58 | #if defined(_EMX) && !defined(_DJGPP) 59 | if (Cmd->ProcessEA && Arc.SubHead.CmpName(SUBHEAD_TYPE_OS2EA)) 60 | ExtractOS2EANew(Arc,Name); 61 | #endif 62 | #ifdef _UNIX 63 | if (Cmd->ProcessOwners && Arc.SubHead.CmpName(SUBHEAD_TYPE_UOWNER)) 64 | ExtractUnixOwnerNew(Arc,Name); 65 | #endif 66 | #ifdef _BEOS 67 | if (Cmd->ProcessEA && Arc.SubHead.CmpName(SUBHEAD_TYPE_UOWNER)) 68 | ExtractUnixOwnerNew(Arc,Name); 69 | #endif 70 | #ifdef _WIN_ALL 71 | if (Cmd->ProcessOwners && Arc.SubHead.CmpName(SUBHEAD_TYPE_ACL)) 72 | ExtractACLNew(Arc,Name,NameW); 73 | if (Arc.SubHead.CmpName(SUBHEAD_TYPE_STREAM)) 74 | ExtractStreamsNew(Arc,Name,NameW); 75 | #endif 76 | } 77 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/extinfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_EXTINFO_ 2 | #define _RAR_EXTINFO_ 3 | 4 | 5 | void SetExtraInfo(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW); 6 | void SetExtraInfoNew(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/extract.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_EXTRACT_ 2 | #define _RAR_EXTRACT_ 3 | 4 | enum EXTRACT_ARC_CODE {EXTRACT_ARC_NEXT,EXTRACT_ARC_REPEAT}; 5 | 6 | class CmdExtract 7 | { 8 | private: 9 | EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd); 10 | RarTime StartTime; // time when extraction started 11 | 12 | ComprDataIO DataIO; 13 | Unpack *Unp; 14 | unsigned long TotalFileCount; 15 | 16 | unsigned long FileCount; 17 | unsigned long MatchedArgs; 18 | bool FirstFile; 19 | bool AllMatchesExact; 20 | bool ReconstructDone; 21 | 22 | // If any non-zero solid file was successfully unpacked before current. 23 | // If true and if current encrypted file is broken, obviously 24 | // the password is correct and we can report broken CRC without 25 | // any wrong password hints. 26 | bool AnySolidDataUnpackedWell; 27 | 28 | char ArcName[NM]; 29 | wchar ArcNameW[NM]; 30 | 31 | wchar Password[MAXPASSWORD]; 32 | bool PasswordAll; 33 | bool PrevExtracted; 34 | char DestFileName[NM]; 35 | wchar DestFileNameW[NM]; 36 | bool PasswordCancelled; 37 | public: 38 | CmdExtract(); 39 | ~CmdExtract(); 40 | void DoExtract(CommandData *Cmd); 41 | void ExtractArchiveInit(CommandData *Cmd,Archive &Arc); 42 | bool ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderSize, 43 | bool &Repeat); 44 | static void UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize); 45 | 46 | bool SignatureFound; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/filcreat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_FILECREATE_ 2 | #define _RAR_FILECREATE_ 3 | 4 | bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW, 5 | OVERWRITE_MODE Mode,bool *UserReject,int64 FileSize=INT64NDF, 6 | uint FileTime=0); 7 | bool GetAutoRenamedName(char *Name,wchar *NameW); 8 | 9 | #if defined(_WIN_ALL) && !defined(_WIN_CE) 10 | bool UpdateExistingShortName(wchar *Name); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/file.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_FILE_ 2 | #define _RAR_FILE_ 3 | 4 | #ifdef _WIN_ALL 5 | typedef HANDLE FileHandle; 6 | #define BAD_HANDLE INVALID_HANDLE_VALUE 7 | #else 8 | typedef FILE* FileHandle; 9 | #define BAD_HANDLE NULL 10 | #endif 11 | 12 | class RAROptions; 13 | 14 | enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD,FILE_HANDLEERR}; 15 | 16 | enum FILE_ERRORTYPE {FILE_SUCCESS,FILE_NOTFOUND,FILE_READERROR}; 17 | 18 | struct FileStat 19 | { 20 | uint FileAttr; 21 | uint FileTime; 22 | int64 FileSize; 23 | bool IsDir; 24 | }; 25 | 26 | 27 | class File 28 | { 29 | private: 30 | void AddFileToList(FileHandle hFile); 31 | 32 | FileHandle hFile; 33 | bool LastWrite; 34 | FILE_HANDLETYPE HandleType; 35 | bool SkipClose; 36 | bool IgnoreReadErrors; 37 | bool NewFile; 38 | bool AllowDelete; 39 | bool AllowExceptions; 40 | #ifdef _WIN_ALL 41 | bool NoSequentialRead; 42 | #endif 43 | protected: 44 | bool OpenShared; 45 | public: 46 | char FileName[NM]; 47 | wchar FileNameW[NM]; 48 | 49 | FILE_ERRORTYPE ErrorType; 50 | 51 | uint CloseCount; 52 | public: 53 | File(); 54 | virtual ~File(); 55 | void operator = (File &SrcFile); 56 | bool Open(const char *Name,const wchar *NameW=NULL,bool OpenShared=false,bool Update=false); 57 | void TOpen(const char *Name,const wchar *NameW=NULL); 58 | bool WOpen(const char *Name,const wchar *NameW=NULL); 59 | bool Create(const char *Name,const wchar *NameW=NULL,bool ShareRead=true); 60 | void TCreate(const char *Name,const wchar *NameW=NULL,bool ShareRead=true); 61 | bool WCreate(const char *Name,const wchar *NameW=NULL,bool ShareRead=true); 62 | bool Close(); 63 | void Flush(); 64 | bool Delete(); 65 | bool Rename(const char *NewName,const wchar *NewNameW=NULL); 66 | void Write(const void *Data,size_t Size); 67 | int Read(void *Data,size_t Size); 68 | int DirectRead(void *Data,size_t Size); 69 | void Seek(int64 Offset,int Method); 70 | bool RawSeek(int64 Offset,int Method); 71 | int64 Tell(); 72 | void Prealloc(int64 Size); 73 | byte GetByte(); 74 | void PutByte(byte Byte); 75 | bool Truncate(); 76 | void SetOpenFileTime(RarTime *ftm,RarTime *ftc=NULL,RarTime *fta=NULL); 77 | void SetCloseFileTime(RarTime *ftm,RarTime *fta=NULL); 78 | static void SetCloseFileTimeByName(const char *Name,RarTime *ftm,RarTime *fta); 79 | void GetOpenFileTime(RarTime *ft); 80 | bool IsOpened() {return(hFile!=BAD_HANDLE);}; 81 | int64 FileLength(); 82 | void SetHandleType(FILE_HANDLETYPE Type); 83 | FILE_HANDLETYPE GetHandleType() {return(HandleType);}; 84 | bool IsDevice(); 85 | void fprintf(const char *fmt,...); 86 | static bool RemoveCreated(); 87 | FileHandle GetHandle() {return(hFile);}; 88 | void SetIgnoreReadErrors(bool Mode) {IgnoreReadErrors=Mode;}; 89 | char *GetName() {return(FileName);} 90 | int64 Copy(File &Dest,int64 Length=INT64NDF); 91 | void SetAllowDelete(bool Allow) {AllowDelete=Allow;} 92 | void SetExceptions(bool Allow) {AllowExceptions=Allow;} 93 | #ifdef _WIN_ALL 94 | void RemoveSequentialFlag() {NoSequentialRead=true;} 95 | #endif 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/filefn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_FILEFN_ 2 | #define _RAR_FILEFN_ 3 | 4 | enum MKDIR_CODE {MKDIR_SUCCESS,MKDIR_ERROR,MKDIR_BADPATH}; 5 | 6 | MKDIR_CODE MakeDir(const char *Name,const wchar *NameW,bool SetAttr,uint Attr); 7 | bool CreatePath(const char *Path,bool SkipLastName); 8 | bool CreatePath(const wchar *Path,bool SkipLastName); 9 | bool CreatePath(const char *Path,const wchar *PathW,bool SkipLastName); 10 | void SetDirTime(const char *Name,const wchar *NameW,RarTime *ftm,RarTime *ftc,RarTime *fta); 11 | bool IsRemovable(const char *Name); 12 | 13 | #ifndef SFX_MODULE 14 | int64 GetFreeDisk(const char *Name); 15 | #endif 16 | 17 | 18 | bool FileExist(const char *Name,const wchar *NameW=NULL); 19 | bool FileExist(const wchar *Name); 20 | bool WildFileExist(const char *Name,const wchar *NameW=NULL); 21 | bool IsDir(uint Attr); 22 | bool IsUnreadable(uint Attr); 23 | bool IsLabel(uint Attr); 24 | bool IsLink(uint Attr); 25 | void SetSFXMode(const char *FileName); 26 | void EraseDiskContents(const char *FileName); 27 | bool IsDeleteAllowed(uint FileAttr); 28 | void PrepareToDelete(const char *Name,const wchar *NameW=NULL); 29 | uint GetFileAttr(const char *Name,const wchar *NameW=NULL); 30 | bool SetFileAttr(const char *Name,const wchar *NameW,uint Attr); 31 | char* MkTemp(char *Name); 32 | wchar* MkTemp(wchar *Name); 33 | 34 | enum CALCCRC_SHOWMODE {CALCCRC_SHOWNONE,CALCCRC_SHOWTEXT,CALCCRC_SHOWALL}; 35 | uint CalcFileCRC(File *SrcFile,int64 Size=INT64NDF,CALCCRC_SHOWMODE ShowMode=CALCCRC_SHOWNONE); 36 | 37 | bool RenameFile(const char *SrcName,const wchar *SrcNameW,const char *DestName,const wchar *DestNameW); 38 | bool DelFile(const char *Name); 39 | bool DelFile(const char *Name,const wchar *NameW); 40 | bool DelDir(const char *Name); 41 | bool DelDir(const char *Name,const wchar *NameW); 42 | 43 | #if defined(_WIN_ALL) && !defined(_WIN_CE) 44 | bool SetFileCompression(char *Name,wchar *NameW,bool State); 45 | #endif 46 | 47 | 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/filestr.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | static bool IsUnicode(byte *Data,int Size); 4 | 5 | bool ReadTextFile( 6 | const char *Name, 7 | const wchar *NameW, 8 | StringList *List, 9 | bool Config, 10 | bool AbortOnError, 11 | RAR_CHARSET SrcCharset, 12 | bool Unquote, 13 | bool SkipComments, 14 | bool ExpandEnvStr) 15 | { 16 | char FileName[NM]; 17 | *FileName=0; 18 | if (Name!=NULL) 19 | if (Config) 20 | GetConfigName(Name,FileName,true); 21 | else 22 | strcpy(FileName,Name); 23 | 24 | wchar FileNameW[NM]; 25 | *FileNameW=0; 26 | 27 | #ifdef _WIN_ALL 28 | if (NameW!=NULL) 29 | if (Config) 30 | GetConfigName(NameW,FileNameW,true); 31 | else 32 | wcscpy(FileNameW,NameW); 33 | #endif 34 | 35 | File SrcFile; 36 | if (FileName!=NULL && *FileName!=0 || FileNameW!=NULL && *FileNameW!=0) 37 | { 38 | bool OpenCode=AbortOnError ? SrcFile.WOpen(FileName,FileNameW):SrcFile.Open(FileName,FileNameW); 39 | 40 | if (!OpenCode) 41 | { 42 | if (AbortOnError) 43 | ErrHandler.Exit(OPEN_ERROR); 44 | return(false); 45 | } 46 | } 47 | else 48 | SrcFile.SetHandleType(FILE_HANDLESTD); 49 | 50 | unsigned int DataSize=0,ReadSize; 51 | const int ReadBlock=1024; 52 | Array Data(ReadBlock+5); 53 | while ((ReadSize=SrcFile.Read(&Data[DataSize],ReadBlock))!=0) 54 | { 55 | DataSize+=ReadSize; 56 | Data.Add(ReadSize); 57 | } 58 | 59 | memset(&Data[DataSize],0,5); 60 | 61 | if (SrcCharset==RCH_UNICODE || 62 | SrcCharset==RCH_DEFAULT && IsUnicode((byte *)&Data[0],DataSize)) 63 | { 64 | // Unicode in native system format, can be more than 2 bytes per character. 65 | Array DataW(Data.Size()/2+1); 66 | for (size_t I=2;I AnsiName; 75 | 76 | while (*CurStr!=0) 77 | { 78 | wchar *NextStr=CurStr,*CmtPtr=NULL; 79 | while (*NextStr!='\r' && *NextStr!='\n' && *NextStr!=0) 80 | { 81 | if (SkipComments && NextStr[0]=='/' && NextStr[1]=='/') 82 | { 83 | *NextStr=0; 84 | CmtPtr=NextStr; 85 | } 86 | NextStr++; 87 | } 88 | *NextStr=0; 89 | for (wchar *SpacePtr=(CmtPtr ? CmtPtr:NextStr)-1;SpacePtr>=CurStr;SpacePtr--) 90 | { 91 | if (*SpacePtr!=' ' && *SpacePtr!='\t') 92 | break; 93 | *SpacePtr=0; 94 | } 95 | if (*CurStr) 96 | { 97 | // Length and AddSize must be defined as signed, because AddSize 98 | // can be negative. 99 | int Length=(int)wcslen(CurStr); 100 | int AddSize=4*(Length-(int)AnsiName.Size()+1); 101 | 102 | if (AddSize>0) 103 | AnsiName.Add(AddSize); 104 | if (Unquote && *CurStr=='\"' && CurStr[Length-1]=='\"') 105 | { 106 | CurStr[Length-1]=0; 107 | CurStr++; 108 | } 109 | WideToChar(CurStr,&AnsiName[0],AnsiName.Size()); 110 | 111 | bool Expanded=false; 112 | #if defined(_WIN_ALL) && !defined(_WIN_CE) 113 | if (ExpandEnvStr && *CurStr=='%') 114 | { 115 | // Expanding environment variables in Windows version. 116 | 117 | char ExpName[NM]; 118 | wchar ExpNameW[NM]; 119 | *ExpNameW=0; 120 | int ret,retw=1; 121 | ret=ExpandEnvironmentStringsA(&AnsiName[0],ExpName,ASIZE(ExpName)); 122 | if (ret!=0 && WinNT()) 123 | retw=ExpandEnvironmentStringsW(CurStr,ExpNameW,ASIZE(ExpNameW)); 124 | Expanded=ret!=0 && retAddString(ExpName,ExpNameW); 128 | } 129 | #endif 130 | if (!Expanded) 131 | List->AddString(&AnsiName[0],CurStr); 132 | } 133 | CurStr=NextStr+1; 134 | while (*CurStr=='\r' || *CurStr=='\n') 135 | CurStr++; 136 | } 137 | } 138 | else 139 | { 140 | char *CurStr=&Data[0]; 141 | while (*CurStr!=0) 142 | { 143 | char *NextStr=CurStr,*CmtPtr=NULL; 144 | while (*NextStr!='\r' && *NextStr!='\n' && *NextStr!=0) 145 | { 146 | if (SkipComments && NextStr[0]=='/' && NextStr[1]=='/') 147 | { 148 | *NextStr=0; 149 | CmtPtr=NextStr; 150 | } 151 | NextStr++; 152 | } 153 | *NextStr=0; 154 | for (char *SpacePtr=(CmtPtr ? CmtPtr:NextStr)-1;SpacePtr>=CurStr;SpacePtr--) 155 | { 156 | if (*SpacePtr!=' ' && *SpacePtr!='\t') 157 | break; 158 | *SpacePtr=0; 159 | } 160 | if (*CurStr) 161 | { 162 | if (Unquote && *CurStr=='\"') 163 | { 164 | size_t Length=strlen(CurStr); 165 | if (CurStr[Length-1]=='\"') 166 | { 167 | CurStr[Length-1]=0; 168 | CurStr++; 169 | } 170 | } 171 | #if defined(_WIN_ALL) 172 | if (SrcCharset==RCH_OEM) 173 | OemToCharA(CurStr,CurStr); 174 | #endif 175 | 176 | bool Expanded=false; 177 | #if defined(_WIN_ALL) && !defined(_WIN_CE) 178 | if (ExpandEnvStr && *CurStr=='%') 179 | { 180 | // Expanding environment variables in Windows version. 181 | char ExpName[NM]; 182 | int ret=ExpandEnvironmentStringsA(CurStr,ExpName,ASIZE(ExpName)); 183 | Expanded=ret!=0 && retAddString(ExpName); 186 | } 187 | #endif 188 | if (!Expanded) 189 | List->AddString(CurStr); 190 | } 191 | CurStr=NextStr+1; 192 | while (*CurStr=='\r' || *CurStr=='\n') 193 | CurStr++; 194 | } 195 | } 196 | return(true); 197 | } 198 | 199 | 200 | bool IsUnicode(byte *Data,int Size) 201 | { 202 | if (Size<4 || Data[0]!=0xff || Data[1]!=0xfe) 203 | return(false); 204 | for (int I=2;I>3; 27 | InBit=Bits&7; 28 | } 29 | 30 | // Return 16 bits from current position in the buffer. 31 | // Bit at (InAddr,InBit) has the highest position in returning data. 32 | uint getbits() 33 | { 34 | uint BitField=(uint)InBuf[InAddr] << 16; 35 | BitField|=(uint)InBuf[InAddr+1] << 8; 36 | BitField|=(uint)InBuf[InAddr+2]; 37 | BitField >>= (8-InBit); 38 | return(BitField & 0xffff); 39 | } 40 | 41 | void faddbits(uint Bits); 42 | uint fgetbits(); 43 | 44 | // Check if buffer has enough space for IncPtr bytes. Returns 'true' 45 | // if buffer will be overflown. 46 | bool Overflow(uint IncPtr) 47 | { 48 | return(InAddr+IncPtr>=MAX_SIZE); 49 | } 50 | }; 51 | #endif 52 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/global.cpp: -------------------------------------------------------------------------------- 1 | #define INCLUDEGLOBAL 2 | 3 | 4 | #include "rar.hpp" 5 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/global.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_GLOBAL_ 2 | #define _RAR_GLOBAL_ 3 | 4 | #ifdef INCLUDEGLOBAL 5 | #define EXTVAR 6 | #else 7 | #define EXTVAR extern 8 | #endif 9 | 10 | EXTVAR ErrorHandler ErrHandler; 11 | 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/isnt.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #ifdef _WIN_ALL 4 | DWORD WinNT() 5 | { 6 | static int dwPlatformId=-1; 7 | static DWORD dwMajorVersion,dwMinorVersion; 8 | if (dwPlatformId==-1) 9 | { 10 | OSVERSIONINFO WinVer; 11 | WinVer.dwOSVersionInfoSize=sizeof(WinVer); 12 | GetVersionEx(&WinVer); 13 | dwPlatformId=WinVer.dwPlatformId; 14 | dwMajorVersion=WinVer.dwMajorVersion; 15 | dwMinorVersion=WinVer.dwMinorVersion; 16 | } 17 | DWORD Result=0; 18 | if (dwPlatformId==VER_PLATFORM_WIN32_NT) 19 | Result=dwMajorVersion*0x100+dwMinorVersion; 20 | 21 | 22 | return(Result); 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/isnt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_ISNT_ 2 | #define _RAR_ISNT_ 3 | 4 | enum WINNT_VERSION { 5 | WNT_NONE=0,WNT_NT351=0x0333,WNT_NT4=0x0400,WNT_W2000=0x0500, 6 | WNT_WXP=0x0501,WNT_W2003=0x0502,WNT_VISTA=0x0600,WNT_W7=0x0601 7 | }; 8 | 9 | DWORD WinNT(); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/license.txt: -------------------------------------------------------------------------------- 1 | ****** ***** ****** UnRAR - free utility for RAR archives 2 | ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | ****** ******* ****** License for use and distribution of 4 | ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | ** ** ** ** ** ** FREE portable version 6 | ~~~~~~~~~~~~~~~~~~~~~ 7 | 8 | The source code of UnRAR utility is freeware. This means: 9 | 10 | 1. All copyrights to RAR and the utility UnRAR are exclusively 11 | owned by the author - Alexander Roshal. 12 | 13 | 2. The UnRAR sources may be used in any software to handle RAR 14 | archives without limitations free of charge, but cannot be used 15 | to re-create the RAR compression algorithm, which is proprietary. 16 | Distribution of modified UnRAR sources in separate form or as a 17 | part of other software is permitted, provided that it is clearly 18 | stated in the documentation and source comments that the code may 19 | not be used to develop a RAR (WinRAR) compatible archiver. 20 | 21 | 3. The UnRAR utility may be freely distributed. It is allowed 22 | to distribute UnRAR inside of other software packages. 23 | 24 | 4. THE RAR ARCHIVER AND THE UnRAR UTILITY ARE DISTRIBUTED "AS IS". 25 | NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE AT 26 | YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, 27 | DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING 28 | OR MISUSING THIS SOFTWARE. 29 | 30 | 5. Installing and using the UnRAR utility signifies acceptance of 31 | these terms and conditions of the license. 32 | 33 | 6. If you don't agree with terms of the license you must remove 34 | UnRAR files from your storage devices and cease to use the 35 | utility. 36 | 37 | Thank you for your interest in RAR and UnRAR. 38 | 39 | 40 | Alexander L. Roshal -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/list.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_LIST_ 2 | #define _RAR_LIST_ 3 | 4 | void ListArchive(CommandData *Cmd); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/log.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | 4 | static char LogName[NM]; 5 | 6 | void InitLogOptions(char *LogName) 7 | { 8 | strcpy(::LogName,LogName); 9 | } 10 | 11 | 12 | #ifndef SILENT 13 | void Log(const char *ArcName,const char *Format,...) 14 | { 15 | safebuf char Msg[2*NM+1024]; 16 | va_list ArgPtr; 17 | va_start(ArgPtr,Format); 18 | vsprintf(Msg,Format,ArgPtr); 19 | va_end(ArgPtr); 20 | eprintf("%s",Msg); 21 | } 22 | #endif 23 | 24 | 25 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/log.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_LOG_ 2 | #define _RAR_LOG_ 3 | 4 | void InitLogOptions(char *LogName); 5 | 6 | #ifndef SILENT 7 | void Log(const char *ArcName,const char *Format,...); 8 | #endif 9 | 10 | #ifdef SILENT 11 | #ifdef __GNUC__ 12 | #define Log(args...) 13 | #else 14 | inline void Log(const char *a,const char *b,const char *c=NULL,const char *d=NULL) {} 15 | #endif 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/makefile.dj: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for DJGPP - unrar 3 | # 4 | # Note: you have to 'make clean' before you can build 5 | # the sfx module 6 | # 7 | 8 | # DOS32 using DJGPP 2.03 Patchlevel 2 and GCC 2.95.3 9 | CXX = gpp 10 | CXXFLAGS = -O2 -Wno-deprecated 11 | #DEFINES = -D_MSC_VER -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 12 | 13 | ########################## 14 | 15 | .PHONY: all clean veryclean 16 | 17 | COMPILE=$(CXX) $(CXXFLAGS) $(DEFINES) 18 | LINK=$(CXX) 19 | 20 | UNRAR_OBJ=filestr.o recvol.o rs.o scantree.o 21 | 22 | OBJECTS=rar.o strlist.o strfn.o pathfn.o savepos.o smallfn.o global.o \ 23 | file.o filefn.o filcreat.o archive.o arcread.o unicode.o \ 24 | system.o isnt.o crypt.o crc.o rawread.o encname.o \ 25 | resource.o match.o timefn.o rdwrfn.o consio.o options.o \ 26 | ulinks.o errhnd.o rarvm.o rijndael.o getbits.o sha1.o \ 27 | extinfo.o extract.o volume.o list.o find.o unpack.o cmddata.o 28 | 29 | .cpp.o: 30 | $(COMPILE) -D$(WHAT) -c $< 31 | 32 | all: unrar 33 | 34 | unrar: WHAT=UNRAR 35 | unrar: $(OBJECTS) $(UNRAR_OBJ) 36 | $(LINK) -Wl,-s -o unrar.exe $(LDFLAGS) $(OBJECTS) $(UNRAR_OBJ) $(LIBS) 37 | exe2coff unrar.exe 38 | cp -u $(DJDIR)/bin/cwsdstub.exe . 39 | copy /b cwsdstub.exe+unrar unrar.exe 40 | -upx --ultra-brute unrar.exe 41 | 42 | sfx: WHAT=SFX_MODULE 43 | sfx: $(OBJECTS) 44 | $(LINK) -Wl,-s -o default.sfx $(LDFLAGS) $(OBJECTS) -DSFX_MODULE 45 | 46 | clean: 47 | $(RM) $(OBJECTS) $(UNRAR_OBJ) 48 | 49 | veryclean: clean 50 | $(RM) unrar.exe default.sfx cwsdstub.exe unrar 51 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/makefile.dmc: -------------------------------------------------------------------------------- 1 | # Makefile for Digital Mars C++ Compiler 2 | # http://www.rarlab.com 3 | # http://www.digitalmars.com 4 | # 5 | # DEFINES: UNRAR RARDLL GUI SFX_MODULE SILENT 6 | 7 | NAME = unrar 8 | EXT = exe 9 | 10 | CPP = dmc 11 | 12 | LINK = link 13 | 14 | # -------------- 15 | # Release Build 16 | # -------------- 17 | DEFINES = -DNDEBUG -D_MSC_VER -DUNRAR 18 | CPPFLAGS = -o+all -ff -Nc -g- -Ae 19 | LNKFLAGS = /EXETYPE:NT /MACHINE:i386 /SUBSYSTEM:CONSOLE /NOLOGO /NODEBUG /NOCODEVIEW /PACKFUNCTIONS 20 | 21 | # -------------- 22 | # Debug Build 23 | # -------------- 24 | #DEFINES = -D_DEBUG -D_MSC_VER -DUNRAR 25 | #CPPFLAGS = -o+none -Nc -S -gf -Ae 26 | #LNKFLAGS = /EXETYPE:NT /MACHINE:i386 /SUBSYSTEM:CONSOLE /NOLOGO /DEBUG 27 | 28 | OBJ = rar.obj strlist.obj strfn.obj pathfn.obj savepos.obj smallfn.o global.obj \ 29 | file.obj filefn.obj filcreat.obj archive.obj arcread.obj unicode.obj \ 30 | system.obj isnt.obj crypt.obj crc.obj rawread.obj encname.obj \ 31 | resource.obj match.obj timefn.obj rdwrfn.obj consio.obj options.obj \ 32 | ulinks.obj errhnd.obj rarvm.obj rijndael.obj getbits.obj sha1.obj \ 33 | extinfo.obj extract.obj volume.obj find.obj unpack.obj cmddata.obj \ 34 | filestr.obj recvol.obj rs.obj scantree.obj \ 35 | list.obj \ 36 | # dll.obj \ 37 | 38 | LIB = kernel32.lib+user32.lib+advapi32.lib 39 | 40 | #DEF = dll.def 41 | 42 | link: $(OBJ) 43 | $(LINK) $(LNKFLAGS) $(OBJ), $(NAME).$(EXT), $(NAME).map, $(LIB), $(DEF) 44 | 45 | .c.obj: 46 | $(CPP) $(CPPFLAGS) $(DEFINES) -c $< -o $@ 47 | 48 | .cpp.obj: 49 | $(CPP) $(CPPFLAGS) $(DEFINES) -c $< -o $@ 50 | 51 | clean: 52 | del $(OBJ) 53 | del $(NAME).$(EXT) 54 | del $(NAME).map 55 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/makefile.unix: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for UNIX - unrar 3 | # 4 | # Note: you have to 'make clean' before you can build 5 | # the sfx module 6 | # 7 | 8 | # Linux using GCC 9 | #CXX=g++ 10 | #CXXFLAGS=-O2 11 | DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 12 | STRIP=strip 13 | DESTDIR=/usr 14 | 15 | # Linux using LCC 16 | #CXX=lcc 17 | #CXXFLAGS=-O2 18 | #DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 19 | #STRIP=strip 20 | #DESTDIR=/usr 21 | 22 | # HP UX using aCC 23 | #CXX=aCC 24 | #CXXFLAGS=-AA +O2 +Onolimit 25 | #DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 26 | #STRIP=strip 27 | #DESTDIR=/usr 28 | 29 | # IRIX using GCC 30 | #CXX=g++ 31 | #CXXFLAGS=-O2 32 | #DEFINES=-DBIG_ENDIAN -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_BSD_COMPAT -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 33 | #STRIP=strip 34 | #DESTDIR=/usr 35 | 36 | # IRIX using MIPSPro (experimental) 37 | #CXX=CC 38 | #CXXFLAGS=-O2 -mips3 -woff 1234,1156,3284 -LANG:std 39 | #DEFINES=-DBIG_ENDIAN -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_BSD_COMPAT -Dint64=int64_t 40 | #STRIP=strip 41 | #DESTDIR=/usr 42 | 43 | # AIX using xlC (IBM VisualAge C++ 5.0) 44 | #CXX=xlC 45 | #CXXFLAGS=-O -qinline -qro -qroconst -qmaxmem=16384 -qcpluscmt 46 | #DEFINES=-D_LARGE_FILES -D_LARGE_FILE_API 47 | #LIBS=-lbsd 48 | #STRIP=strip 49 | #DESTDIR=/usr 50 | 51 | # Solaris using CC 52 | #CXX=CC 53 | #CXXFLAGS=-fast -erroff=wvarhidemem 54 | #DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 55 | #STRIP=strip 56 | #DESTDIR=/usr 57 | 58 | # Solaris using GCC (optimized for UltraSPARC 1 CPU) 59 | #CXX=g++ 60 | #CXXFLAGS=-O3 -mcpu=v9 -mtune=ultrasparc -m32 61 | #DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 62 | #STRIP=/usr/ccs/bin/strip 63 | #DESTDIR=/usr 64 | 65 | # Tru64 5.1B using GCC3 66 | #CXX=g++ 67 | #CXXFLAGS=-O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_XOPEN_SOURCE=500 68 | #STRIP=strip 69 | #LDFLAGS=-rpath /usr/local/gcc/lib 70 | #DESTDIR=/usr 71 | 72 | # Tru64 5.1B using DEC C++ 73 | #CXX=cxx 74 | #CXXFLAGS=-O4 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dint64=long 75 | #STRIP=strip 76 | #LDFLAGS= 77 | #DESTDIR=/usr 78 | 79 | # QNX 6.x using GCC 80 | #CXX=g++ 81 | #CXXFLAGS=-O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fexceptions 82 | #STRIP=strip 83 | #LDFLAGS=-fexceptions 84 | #DESTDIR=/usr 85 | 86 | # Cross-compile 87 | # Linux using arm-linux-g++ 88 | #CXX=arm-linux-g++ 89 | #CXXFLAGS=-O2 90 | #DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 91 | #STRIP=arm-linux-strip 92 | #LDFLAGS=-static 93 | #DESTDIR=/usr 94 | 95 | ########################## 96 | 97 | COMPILE=$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) 98 | LINK=$(CXX) 99 | 100 | WHAT=UNRAR 101 | 102 | UNRAR_OBJ=filestr.o recvol.o rs.o scantree.o 103 | LIB_OBJ=filestr.o scantree.o dll.o 104 | 105 | OBJECTS=rar.o strlist.o strfn.o pathfn.o savepos.o smallfn.o global.o file.o filefn.o filcreat.o \ 106 | archive.o arcread.o unicode.o system.o isnt.o crypt.o crc.o rawread.o encname.o \ 107 | resource.o match.o timefn.o rdwrfn.o consio.o options.o ulinks.o errhnd.o rarvm.o \ 108 | rijndael.o getbits.o sha1.o extinfo.o extract.o volume.o list.o find.o unpack.o cmddata.o 109 | 110 | .cpp.o: 111 | $(COMPILE) -D$(WHAT) -c $< 112 | 113 | all: unrar 114 | 115 | install: install-unrar 116 | 117 | uninstall: uninstall-unrar 118 | 119 | clean: 120 | @rm -f *.o *.bak *~ 121 | 122 | unrar: $(OBJECTS) $(UNRAR_OBJ) 123 | @rm -f unrar 124 | $(LINK) -o unrar $(LDFLAGS) $(OBJECTS) $(UNRAR_OBJ) $(LIBS) 125 | $(STRIP) unrar 126 | 127 | sfx: WHAT=SFX_MODULE 128 | sfx: $(OBJECTS) 129 | @rm -f default.sfx 130 | $(LINK) -o default.sfx $(LDFLAGS) $(OBJECTS) 131 | $(STRIP) default.sfx 132 | 133 | lib: WHAT=RARDLL 134 | lib: $(OBJECTS) $(LIB_OBJ) 135 | @rm -f libunrar.so 136 | $(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ) 137 | 138 | install-unrar: 139 | install -D unrar $(DESTDIR)/bin/unrar 140 | 141 | uninstall-unrar: 142 | rm -f $(DESTDIR)/bin/unrar 143 | 144 | install-lib: 145 | install libunrar.so $(DESTDIR)/lib 146 | 147 | uninstall-lib: 148 | rm -f $(DESTDIR)/lib/libunrar.so 149 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/match.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_MATCH_ 2 | #define _RAR_MATCH_ 3 | 4 | enum { 5 | MATCH_NAMES, // Paths are ignored. 6 | // Compares names only using wildcards. 7 | 8 | MATCH_SUBPATHONLY, // Paths must match either exactly or path in wildcard 9 | // must be present in the beginning of file path. 10 | // For example, "c:\path1\*" or "c:\path1" will match 11 | // "c:\path1\path2\file". 12 | // Names are not compared. 13 | 14 | MATCH_EXACT, // Paths must match exactly. 15 | // Names must match exactly. 16 | 17 | MATCH_EXACTPATH, // Paths must match exactly. 18 | // Names are compared using wildcards. 19 | 20 | MATCH_SUBPATH, // Names must be the same, but path in mask is allowed 21 | // to be only a part of name path. In other words, 22 | // we match all files matching the file mask 23 | // in current folder and subfolders. 24 | 25 | MATCH_WILDSUBPATH // Works as MATCH_SUBPATH if file mask contains 26 | // wildcards and as MATCH_EXACTPATH otherwise. 27 | }; 28 | 29 | #define MATCH_MODEMASK 0x0000ffff 30 | #define MATCH_FORCECASESENSITIVE 0x80000000 31 | 32 | bool CmpName(const char *Wildcard,const char *Name,int CmpMode); 33 | bool CmpName(const wchar *Wildcard,const wchar *Name,int CmpMode); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/model.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_PPMMODEL_ 2 | #define _RAR_PPMMODEL_ 3 | 4 | #include "coder.hpp" 5 | #include "suballoc.hpp" 6 | 7 | const int MAX_O=64; /* maximum allowed model order */ 8 | 9 | const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS, 10 | INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124; 11 | 12 | #ifndef STRICT_ALIGNMENT_REQUIRED 13 | #pragma pack(1) 14 | #endif 15 | 16 | struct SEE2_CONTEXT 17 | { // SEE-contexts for PPM-contexts with masked symbols 18 | ushort Summ; 19 | byte Shift, Count; 20 | void init(int InitVal) 21 | { 22 | Summ=InitVal << (Shift=PERIOD_BITS-4); 23 | Count=4; 24 | } 25 | uint getMean() 26 | { 27 | uint RetVal=SHORT16(Summ) >> Shift; 28 | Summ -= RetVal; 29 | return RetVal+(RetVal == 0); 30 | } 31 | void update() 32 | { 33 | if (Shift < PERIOD_BITS && --Count == 0) 34 | { 35 | Summ += Summ; 36 | Count=3 << Shift++; 37 | } 38 | } 39 | }; 40 | 41 | 42 | class ModelPPM; 43 | struct PPM_CONTEXT; 44 | 45 | struct STATE 46 | { 47 | byte Symbol; 48 | byte Freq; 49 | PPM_CONTEXT* Successor; 50 | }; 51 | 52 | struct FreqData 53 | { 54 | ushort SummFreq; 55 | STATE _PACK_ATTR * Stats; 56 | }; 57 | 58 | struct PPM_CONTEXT 59 | { 60 | ushort NumStats; 61 | union 62 | { 63 | FreqData U; 64 | STATE OneState; 65 | }; 66 | 67 | PPM_CONTEXT* Suffix; 68 | inline void encodeBinSymbol(ModelPPM *Model,int symbol); // MaxOrder: 69 | inline void encodeSymbol1(ModelPPM *Model,int symbol); // ABCD context 70 | inline void encodeSymbol2(ModelPPM *Model,int symbol); // BCD suffix 71 | inline void decodeBinSymbol(ModelPPM *Model); // BCDE successor 72 | inline bool decodeSymbol1(ModelPPM *Model); // other orders: 73 | inline bool decodeSymbol2(ModelPPM *Model); // BCD context 74 | inline void update1(ModelPPM *Model,STATE* p); // CD suffix 75 | inline void update2(ModelPPM *Model,STATE* p); // BCDE successor 76 | void rescale(ModelPPM *Model); 77 | inline PPM_CONTEXT* createChild(ModelPPM *Model,STATE* pStats,STATE& FirstState); 78 | inline SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,int Diff); 79 | }; 80 | 81 | #ifndef STRICT_ALIGNMENT_REQUIRED 82 | #ifdef _AIX 83 | #pragma pack(pop) 84 | #else 85 | #pragma pack() 86 | #endif 87 | #endif 88 | 89 | const uint UNIT_SIZE=Max(sizeof(PPM_CONTEXT),sizeof(RAR_MEM_BLK)); 90 | const uint FIXED_UNIT_SIZE=12; 91 | 92 | /* 93 | inline PPM_CONTEXT::PPM_CONTEXT(STATE* pStats,PPM_CONTEXT* ShorterContext): 94 | NumStats(1), Suffix(ShorterContext) { pStats->Successor=this; } 95 | inline PPM_CONTEXT::PPM_CONTEXT(): NumStats(0) {} 96 | */ 97 | 98 | template 99 | inline void _PPMD_SWAP(T& t1,T& t2) { T tmp=t1; t1=t2; t2=tmp; } 100 | 101 | 102 | class ModelPPM 103 | { 104 | private: 105 | friend struct PPM_CONTEXT; 106 | 107 | SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont; 108 | 109 | struct PPM_CONTEXT *MinContext, *MedContext, *MaxContext; 110 | STATE* FoundState; // found next state transition 111 | int NumMasked, InitEsc, OrderFall, MaxOrder, RunLength, InitRL; 112 | byte CharMask[256], NS2Indx[256], NS2BSIndx[256], HB2Flag[256]; 113 | byte EscCount, PrevSuccess, HiBitsFlag; 114 | ushort BinSumm[128][64]; // binary SEE-contexts 115 | 116 | RangeCoder Coder; 117 | SubAllocator SubAlloc; 118 | 119 | void RestartModelRare(); 120 | void StartModelRare(int MaxOrder); 121 | inline PPM_CONTEXT* CreateSuccessors(bool Skip,STATE* p1); 122 | 123 | inline void UpdateModel(); 124 | inline void ClearMask(); 125 | public: 126 | ModelPPM(); 127 | void CleanUp(); // reset PPM variables after data error 128 | bool DecodeInit(Unpack *UnpackRead,int &EscChar); 129 | int DecodeChar(); 130 | }; 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/options.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | RAROptions::RAROptions() 4 | { 5 | Init(); 6 | } 7 | 8 | 9 | RAROptions::~RAROptions() 10 | { 11 | // It is important for security reasons, so we do not have the unnecessary 12 | // password data left in memory. 13 | memset(this,0,sizeof(RAROptions)); 14 | } 15 | 16 | 17 | void RAROptions::Init() 18 | { 19 | memset(this,0,sizeof(RAROptions)); 20 | WinSize=0x400000; 21 | Overwrite=OVERWRITE_DEFAULT; 22 | Method=3; 23 | MsgStream=MSG_STDOUT; 24 | ConvertNames=NAMES_ORIGINALCASE; 25 | ProcessEA=true; 26 | xmtime=EXTTIME_HIGH3; 27 | CurVolNum=0; 28 | FileSizeLess=INT64NDF; 29 | FileSizeMore=INT64NDF; 30 | } 31 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/options.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_OPTIONS_ 2 | #define _RAR_OPTIONS_ 3 | 4 | #define DEFAULT_RECOVERY -1 5 | 6 | #define DEFAULT_RECVOLUMES -10 7 | 8 | enum PATH_EXCL_MODE { 9 | EXCL_UNCHANGED, // Process paths as is (default). 10 | EXCL_SKIPWHOLEPATH, // -ep (exclude the path completely) 11 | EXCL_BASEPATH, // -ep1 (exclude the base part of path) 12 | EXCL_SAVEFULLPATH, // -ep2 (the full path without the disk letter) 13 | EXCL_ABSPATH, // -ep3 (the full path with the disk letter) 14 | 15 | EXCL_SKIPABSPATH // Works as EXCL_BASEPATH for fully qualified paths 16 | // and as EXCL_UNCHANGED for relative paths. 17 | // Used by WinRAR GUI only. 18 | }; 19 | 20 | enum {SOLID_NONE=0,SOLID_NORMAL=1,SOLID_COUNT=2,SOLID_FILEEXT=4, 21 | SOLID_VOLUME_DEPENDENT=8,SOLID_VOLUME_INDEPENDENT=16}; 22 | 23 | enum {ARCTIME_NONE,ARCTIME_KEEP,ARCTIME_LATEST}; 24 | 25 | enum EXTTIME_MODE { 26 | EXTTIME_NONE,EXTTIME_1S,EXTTIME_HIGH1,EXTTIME_HIGH2,EXTTIME_HIGH3 27 | }; 28 | 29 | enum {NAMES_ORIGINALCASE,NAMES_UPPERCASE,NAMES_LOWERCASE}; 30 | 31 | enum MESSAGE_TYPE {MSG_STDOUT,MSG_STDERR,MSG_ERRONLY,MSG_NULL}; 32 | 33 | enum RECURSE_MODE 34 | { 35 | RECURSE_NONE=0, // no recurse switches 36 | RECURSE_DISABLE, // switch -r- 37 | RECURSE_ALWAYS, // switch -r 38 | RECURSE_WILDCARDS, // switch -r0 39 | }; 40 | 41 | enum OVERWRITE_MODE 42 | { 43 | OVERWRITE_DEFAULT=0, // ask for extraction, silently overwrite for archiving 44 | OVERWRITE_ALL, 45 | OVERWRITE_NONE, 46 | OVERWRITE_AUTORENAME, 47 | OVERWRITE_FORCE_ASK 48 | }; 49 | 50 | enum RAR_CHARSET { RCH_DEFAULT=0,RCH_ANSI,RCH_OEM,RCH_UNICODE }; 51 | 52 | #define MAX_FILTERS 16 53 | enum FilterState {FILTER_DEFAULT=0,FILTER_AUTO,FILTER_FORCE,FILTER_DISABLE}; 54 | 55 | 56 | struct FilterMode 57 | { 58 | FilterState State; 59 | int Param1; 60 | int Param2; 61 | }; 62 | 63 | 64 | class RAROptions 65 | { 66 | public: 67 | RAROptions(); 68 | ~RAROptions(); 69 | void Init(); 70 | 71 | uint ExclFileAttr; 72 | uint InclFileAttr; 73 | bool InclAttrSet; 74 | uint WinSize; 75 | char TempPath[NM]; 76 | char ExtrPath[NM]; 77 | wchar ExtrPathW[NM]; 78 | char CommentFile[NM]; 79 | wchar CommentFileW[NM]; 80 | RAR_CHARSET CommentCharset; 81 | RAR_CHARSET FilelistCharset; 82 | char ArcPath[NM]; 83 | wchar ArcPathW[NM]; 84 | wchar Password[MAXPASSWORD]; 85 | bool EncryptHeaders; 86 | char LogName[NM]; 87 | MESSAGE_TYPE MsgStream; 88 | bool Sound; 89 | OVERWRITE_MODE Overwrite; 90 | int Method; 91 | int Recovery; 92 | int RecVolNumber; 93 | bool DisablePercentage; 94 | bool DisableCopyright; 95 | bool DisableDone; 96 | int Solid; 97 | int SolidCount; 98 | bool ClearArc; 99 | bool AddArcOnly; 100 | bool AV; 101 | bool DisableComment; 102 | bool FreshFiles; 103 | bool UpdateFiles; 104 | PATH_EXCL_MODE ExclPath; 105 | RECURSE_MODE Recurse; 106 | int64 VolSize; 107 | Array NextVolSizes; 108 | uint CurVolNum; 109 | bool AllYes; 110 | bool DisableViewAV; 111 | bool DisableSortSolid; 112 | int ArcTime; 113 | int ConvertNames; 114 | bool ProcessOwners; 115 | bool SaveLinks; 116 | int Priority; 117 | int SleepTime; 118 | bool KeepBroken; 119 | bool OpenShared; 120 | bool DeleteFiles; 121 | bool SyncFiles; 122 | bool ProcessEA; 123 | bool SaveStreams; 124 | bool SetCompressedAttr; 125 | bool IgnoreGeneralAttr; 126 | RarTime FileTimeBefore; 127 | RarTime FileTimeAfter; 128 | int64 FileSizeLess; 129 | int64 FileSizeMore; 130 | bool OldNumbering; 131 | bool Lock; 132 | bool Test; 133 | bool VolumePause; 134 | FilterMode FilterModes[MAX_FILTERS]; 135 | char EmailTo[NM]; 136 | uint VersionControl; 137 | bool NoEndBlock; 138 | bool AppendArcNameToPath; 139 | bool Shutdown; 140 | EXTTIME_MODE xmtime; 141 | EXTTIME_MODE xctime; 142 | EXTTIME_MODE xatime; 143 | EXTTIME_MODE xarctime; 144 | char CompressStdin[NM]; 145 | 146 | #ifdef PACK_SMP 147 | uint Threads; 148 | #endif 149 | 150 | 151 | 152 | 153 | 154 | 155 | #ifdef RARDLL 156 | char DllDestName[NM]; 157 | wchar DllDestNameW[NM]; 158 | int DllOpMode; 159 | int DllError; 160 | LPARAM UserData; 161 | UNRARCALLBACK Callback; 162 | CHANGEVOLPROC ChangeVolProc; 163 | PROCESSDATAPROC ProcessDataProc; 164 | #endif 165 | }; 166 | #endif 167 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/os.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_OS_ 2 | #define _RAR_OS_ 3 | 4 | #define FALSE 0 5 | #define TRUE 1 6 | 7 | #ifdef __EMX__ 8 | #define INCL_BASE 9 | #endif 10 | 11 | #if defined(RARDLL) && !defined(SILENT) 12 | #define SILENT 13 | #endif 14 | 15 | #if defined(_WIN_ALL) || defined(_EMX) 16 | #define ENABLE_BAD_ALLOC 17 | #endif 18 | 19 | 20 | #if defined(_WIN_ALL) || defined(_EMX) 21 | 22 | #define LITTLE_ENDIAN 23 | #define NM 1024 24 | 25 | #ifdef _WIN_ALL 26 | 27 | #define STRICT 28 | #define UNICODE 29 | #undef WINVER 30 | #undef _WIN32_WINNT 31 | #define WINVER 0x0500 32 | #define _WIN32_WINNT 0x0500 33 | 34 | 35 | #define WIN32_LEAN_AND_MEAN 36 | 37 | #include 38 | #include 39 | 40 | #ifndef _WIN_CE 41 | #include 42 | #include 43 | #include 44 | 45 | 46 | #endif // _WIN_CE 47 | 48 | 49 | #endif // _WIN_ALL 50 | 51 | #ifndef _WIN_CE 52 | #include 53 | #include 54 | #include 55 | #endif // _WIN_CE 56 | 57 | #if !defined(_EMX) && !defined(_MSC_VER) && !defined(_WIN_CE) 58 | #include 59 | #endif 60 | #ifdef _MSC_VER 61 | #if _MSC_VER<1500 62 | #define for if (0) ; else for 63 | #endif 64 | #ifndef _WIN_CE 65 | #include 66 | #endif 67 | #else 68 | #include 69 | #endif // _MSC_VER 70 | 71 | #ifndef _WIN_CE 72 | #include 73 | #endif // _WIN_CE 74 | 75 | #if defined(ENABLE_BAD_ALLOC) && !defined(_WIN_CE) 76 | #include 77 | #endif 78 | 79 | #ifdef _EMX 80 | #include 81 | #include 82 | #include 83 | #include 84 | #ifdef _DJGPP 85 | #include 86 | #else 87 | #include 88 | #include 89 | #include 90 | #endif 91 | #else 92 | #if defined(_MSC_VER) || defined(__MINGW32__) 93 | #include 94 | #else 95 | #include 96 | #endif 97 | #endif 98 | 99 | #include 100 | #include 101 | #include 102 | #include 103 | #include 104 | #ifndef _WIN_CE 105 | #include 106 | #include 107 | #include 108 | #include 109 | #include 110 | #endif 111 | 112 | /* 113 | #ifdef _WIN_ALL 114 | #pragma hdrstop 115 | #endif // _WIN_ALL 116 | */ 117 | 118 | #define ENABLE_ACCESS 119 | 120 | #define DefConfigName "rar.ini" 121 | #define DefLogName "rar.log" 122 | 123 | 124 | #define PATHDIVIDER "\\" 125 | #define PATHDIVIDERW L"\\" 126 | #define CPATHDIVIDER '\\' 127 | #define MASKALL "*" 128 | #define MASKALLW L"*" 129 | 130 | #define READBINARY "rb" 131 | #define READTEXT "rt" 132 | #define UPDATEBINARY "r+b" 133 | #define CREATEBINARY "w+b" 134 | #define APPENDTEXT "at" 135 | 136 | #if defined(_WIN_ALL) 137 | #ifdef _MSC_VER 138 | #define _stdfunction __cdecl 139 | 140 | #ifdef SFX_MODULE 141 | // We want to keep SFX module small, so let compiler to decide. 142 | #define _forceinline inline 143 | #else 144 | #define _forceinline __forceinline 145 | #endif 146 | 147 | #else 148 | #define _stdfunction _USERENTRY 149 | #define _forceinline inline 150 | #endif 151 | #else 152 | #define _stdfunction 153 | #define _forceinline inline 154 | #endif 155 | 156 | #endif 157 | 158 | #ifdef _UNIX 159 | 160 | #define NM 1024 161 | 162 | #ifdef _BEOS 163 | #include 164 | #include 165 | #endif 166 | 167 | #include 168 | #include 169 | #include 170 | #include 171 | #if defined(__QNXNTO__) 172 | #include 173 | #endif 174 | #if defined(__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined(__APPLE__) 175 | #include 176 | #include 177 | #else 178 | #endif 179 | #include 180 | #include 181 | #include 182 | #include 183 | #include 184 | #include 185 | #include 186 | #include 187 | #include 188 | #include 189 | #include 190 | #include 191 | #include 192 | #include 193 | #include 194 | 195 | #ifdef S_IFLNK 196 | #define SAVE_LINKS 197 | #endif 198 | 199 | #define ENABLE_ACCESS 200 | 201 | #define DefConfigName ".rarrc" 202 | #define DefLogName ".rarlog" 203 | 204 | 205 | #define PATHDIVIDER "/" 206 | #define PATHDIVIDERW L"/" 207 | #define CPATHDIVIDER '/' 208 | #define MASKALL "*" 209 | #define MASKALLW L"*" 210 | 211 | #define READBINARY "r" 212 | #define READTEXT "r" 213 | #define UPDATEBINARY "r+" 214 | #define CREATEBINARY "w+" 215 | #define APPENDTEXT "a" 216 | 217 | #define _stdfunction 218 | #define _forceinline inline 219 | 220 | #ifdef _APPLE 221 | #if defined(__BIG_ENDIAN__) && !defined(BIG_ENDIAN) 222 | #define BIG_ENDIAN 223 | #undef LITTLE_ENDIAN 224 | #endif 225 | #if defined(__i386__) && !defined(LITTLE_ENDIAN) 226 | #define LITTLE_ENDIAN 227 | #undef BIG_ENDIAN 228 | #endif 229 | #endif 230 | 231 | #if defined(__sparc) || defined(sparc) || defined(__hpux) 232 | #ifndef BIG_ENDIAN 233 | #define BIG_ENDIAN 234 | #endif 235 | #endif 236 | 237 | #endif 238 | 239 | typedef const char* MSGID; 240 | 241 | #define safebuf static 242 | 243 | #if !defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN) 244 | #if defined(__i386) || defined(i386) || defined(__i386__) 245 | #define LITTLE_ENDIAN 246 | #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN 247 | #define LITTLE_ENDIAN 248 | #elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN 249 | #define BIG_ENDIAN 250 | #else 251 | #error "Neither LITTLE_ENDIAN nor BIG_ENDIAN are defined. Define one of them." 252 | #endif 253 | #endif 254 | 255 | #if defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) 256 | #if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN 257 | #undef LITTLE_ENDIAN 258 | #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN 259 | #undef BIG_ENDIAN 260 | #else 261 | #error "Both LITTLE_ENDIAN and BIG_ENDIAN are defined. Undef one of them." 262 | #endif 263 | #endif 264 | 265 | #if !defined(BIG_ENDIAN) && !defined(_WIN_CE) && defined(_WIN_ALL) 266 | /* allow not aligned integer access, increases speed in some operations */ 267 | #define ALLOW_NOT_ALIGNED_INT 268 | #endif 269 | 270 | #if defined(__sparc) || defined(sparc) || defined(__sparcv9) 271 | /* prohibit not aligned access to data structures in text comression 272 | algorithm, increases memory requirements */ 273 | #define STRICT_ALIGNMENT_REQUIRED 274 | #endif 275 | 276 | #endif // _RAR_OS_ 277 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/os2ea.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | 5 | void ExtractOS2EA(Archive &Arc,char *FileName) 6 | { 7 | if (_osmode != OS2_MODE) 8 | { 9 | mprintf(St(MSkipEA)); 10 | return; 11 | } 12 | 13 | if (Arc.HeaderCRC!=Arc.EAHead.HeadCRC) 14 | { 15 | Log(Arc.FileName,St(MEABroken),FileName); 16 | ErrHandler.SetErrorCode(CRC_ERROR); 17 | return; 18 | } 19 | 20 | if (Arc.EAHead.Method<0x31 || Arc.EAHead.Method>0x35 || Arc.EAHead.UnpVer>PACK_VER) 21 | { 22 | Log(Arc.FileName,St(MEAUnknHeader),FileName); 23 | ErrHandler.SetErrorCode(WARNING); 24 | return; 25 | } 26 | 27 | struct StructEAOP2 28 | { 29 | char *GEAPtr; 30 | char *FEAPtr; 31 | unsigned long Error; 32 | } EAOP2; 33 | 34 | ComprDataIO DataIO; 35 | Unpack Unpack(&DataIO); 36 | Unpack.Init(); 37 | 38 | Array UnpData(Arc.EAHead.UnpSize); 39 | DataIO.SetUnpackToMemory(&UnpData[0],Arc.EAHead.UnpSize); 40 | DataIO.SetPackedSizeToRead(Arc.EAHead.DataSize); 41 | DataIO.EnableShowProgress(false); 42 | DataIO.SetFiles(&Arc,NULL); 43 | Unpack.SetDestSize(Arc.EAHead.UnpSize); 44 | Unpack.DoUnpack(Arc.EAHead.UnpVer,false); 45 | 46 | if (Arc.EAHead.EACRC!=~DataIO.UnpFileCRC) 47 | { 48 | Log(Arc.FileName,St(MEABroken),FileName); 49 | ErrHandler.SetErrorCode(CRC_ERROR); 50 | return; 51 | } 52 | 53 | EAOP2.FEAPtr=(char *)&UnpData[0]; 54 | EAOP2.GEAPtr=NULL; 55 | if (DosSetPathInfo((unsigned char *)FileName,2,&EAOP2,sizeof(EAOP2),0x10)!=0) 56 | { 57 | Log(Arc.FileName,St(MCannotSetEA),FileName); 58 | ErrHandler.SetErrorCode(WARNING); 59 | } 60 | File::SetCloseFileTimeByName(FileName,&Arc.NewLhd.mtime,&Arc.NewLhd.atime); 61 | mprintf(St(MShowEA)); 62 | } 63 | 64 | 65 | void ExtractOS2EANew(Archive &Arc,char *FileName) 66 | { 67 | if (_osmode != OS2_MODE) 68 | { 69 | mprintf(St(MSkipEA)); 70 | return; 71 | } 72 | 73 | Array SubData; 74 | if (!Arc.ReadSubData(&SubData,NULL)) 75 | return; 76 | 77 | struct StructEAOP2 78 | { 79 | char *GEAPtr; 80 | char *FEAPtr; 81 | unsigned long Error; 82 | } EAOP2; 83 | 84 | EAOP2.FEAPtr=(char *)&SubData[0]; 85 | EAOP2.GEAPtr=NULL; 86 | if (DosSetPathInfo((unsigned char *)FileName,2,&EAOP2,sizeof(EAOP2),0x10)!=0) 87 | { 88 | Log(Arc.FileName,St(MCannotSetEA),FileName); 89 | ErrHandler.SetErrorCode(WARNING); 90 | } 91 | File::SetCloseFileTimeByName(FileName,&Arc.NewLhd.mtime,&Arc.NewLhd.atime); 92 | mprintf(St(MShowEA)); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/pathfn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_PATHFN_ 2 | #define _RAR_PATHFN_ 3 | 4 | char* PointToName(const char *Path); 5 | wchar* PointToName(const wchar *Path); 6 | char* PointToLastChar(const char *Path); 7 | wchar* PointToLastChar(const wchar *Path); 8 | char* ConvertPath(const char *SrcPath,char *DestPath); 9 | wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath); 10 | void SetExt(char *Name,const char *NewExt); 11 | void SetExt(wchar *Name,const wchar *NewExt); 12 | void SetSFXExt(char *SFXName); 13 | void SetSFXExt(wchar *SFXName); 14 | char *GetExt(const char *Name); 15 | wchar *GetExt(const wchar *Name); 16 | bool CmpExt(const char *Name,const char *Ext); 17 | bool CmpExt(const wchar *Name,const wchar *Ext); 18 | bool IsWildcard(const char *Str,const wchar *StrW=NULL); 19 | bool IsPathDiv(int Ch); 20 | bool IsDriveDiv(int Ch); 21 | int GetPathDisk(const char *Path); 22 | int GetPathDisk(const wchar *Path); 23 | void AddEndSlash(char *Path); 24 | void AddEndSlash(wchar *Path); 25 | void GetFilePath(const char *FullName,char *Path,int MaxLength); 26 | void GetFilePath(const wchar *FullName,wchar *Path,int MaxLength); 27 | void RemoveNameFromPath(char *Path); 28 | void RemoveNameFromPath(wchar *Path); 29 | void GetAppDataPath(char *Path); 30 | void GetAppDataPath(wchar *Path); 31 | void GetRarDataPath(char *Path); 32 | void GetRarDataPath(wchar *Path); 33 | bool EnumConfigPaths(wchar *Path,int Number); 34 | bool EnumConfigPaths(char *Path,int Number); 35 | void GetConfigName(const char *Name,char *FullName,bool CheckExist); 36 | void GetConfigName(const wchar *Name,wchar *FullName,bool CheckExist); 37 | char* GetVolNumPart(char *ArcName); 38 | wchar* GetVolNumPart(wchar *ArcName); 39 | void NextVolumeName(char *ArcName,wchar *ArcNameW,uint MaxLength,bool OldNumbering); 40 | bool IsNameUsable(const char *Name); 41 | void MakeNameUsable(char *Name,bool Extended); 42 | void MakeNameUsable(wchar *Name,bool Extended); 43 | char* UnixSlashToDos(char *SrcName,char *DestName=NULL,uint MaxLength=NM); 44 | char* DosSlashToUnix(char *SrcName,char *DestName=NULL,uint MaxLength=NM); 45 | wchar* UnixSlashToDos(wchar *SrcName,wchar *DestName=NULL,uint MaxLength=NM); 46 | wchar* DosSlashToUnix(wchar *SrcName,wchar *DestName=NULL,uint MaxLength=NM); 47 | void ConvertNameToFull(const char *Src,char *Dest); 48 | void ConvertNameToFull(const wchar *Src,wchar *Dest); 49 | bool IsFullPath(const char *Path); 50 | bool IsFullPath(const wchar *Path); 51 | bool IsDiskLetter(const char *Path); 52 | bool IsDiskLetter(const wchar *Path); 53 | void GetPathRoot(const char *Path,char *Root); 54 | void GetPathRoot(const wchar *Path,wchar *Root); 55 | int ParseVersionFileName(char *Name,wchar *NameW,bool Truncate); 56 | char* VolNameToFirstName(const char *VolName,char *FirstName,bool NewNumbering); 57 | wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,bool NewNumbering); 58 | wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW,size_t DestSize); 59 | char* GetAsciiName(const wchar *NameW,char *Name,size_t DestSize); 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rar.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #if !defined(GUI) && !defined(RARDLL) 4 | int main(int argc, char *argv[]) 5 | { 6 | 7 | #ifdef _UNIX 8 | setlocale(LC_ALL,""); 9 | #endif 10 | 11 | #if defined(_EMX) && !defined(_DJGPP) 12 | uni_init(0); 13 | #endif 14 | 15 | #if !defined(_SFX_RTL_) && !defined(_WIN_ALL) 16 | setbuf(stdout,NULL); 17 | #endif 18 | 19 | #if !defined(SFX_MODULE) && defined(_EMX) 20 | EnumConfigPaths(argv[0],-1); 21 | #endif 22 | 23 | ErrHandler.SetSignalHandlers(true); 24 | 25 | RARInitData(); 26 | 27 | #ifdef SFX_MODULE 28 | char ModuleNameA[NM]; 29 | wchar ModuleNameW[NM]; 30 | #ifdef _WIN_ALL 31 | GetModuleFileNameW(NULL,ModuleNameW,ASIZE(ModuleNameW)); 32 | WideToChar(ModuleNameW,ModuleNameA); 33 | #else 34 | strcpy(ModuleNameA,argv[0]); 35 | *ModuleNameW=0; 36 | #endif 37 | #endif 38 | 39 | #ifdef _WIN_ALL 40 | SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT|SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); 41 | 42 | 43 | #endif 44 | 45 | #if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT) 46 | bool ShutdownOnClose; 47 | #endif 48 | 49 | #ifdef ALLOW_EXCEPTIONS 50 | try 51 | #endif 52 | { 53 | 54 | CommandData Cmd; 55 | #ifdef SFX_MODULE 56 | strcpy(Cmd.Command,"X"); 57 | char *Switch=NULL; 58 | #ifdef _SFX_RTL_ 59 | char *CmdLine=GetCommandLineA(); 60 | if (CmdLine!=NULL && *CmdLine=='\"') 61 | CmdLine=strchr(CmdLine+1,'\"'); 62 | if (CmdLine!=NULL && (CmdLine=strpbrk(CmdLine," /"))!=NULL) 63 | { 64 | while (IsSpace(*CmdLine)) 65 | CmdLine++; 66 | Switch=CmdLine; 67 | } 68 | #else 69 | Switch=argc>1 ? argv[1]:NULL; 70 | #endif 71 | if (Switch!=NULL && Cmd.IsSwitch(Switch[0])) 72 | { 73 | int UpperCmd=etoupper(Switch[1]); 74 | switch(UpperCmd) 75 | { 76 | case 'T': 77 | case 'V': 78 | Cmd.Command[0]=UpperCmd; 79 | break; 80 | case '?': 81 | Cmd.OutHelp(); 82 | break; 83 | } 84 | } 85 | Cmd.AddArcName(ModuleNameA,ModuleNameW); 86 | #else 87 | if (Cmd.IsConfigEnabled(argc,argv)) 88 | { 89 | Cmd.ReadConfig(argc,argv); 90 | Cmd.ParseEnvVar(); 91 | } 92 | for (int I=1;I(y)) ? (x):(y)) 6 | 7 | #define ASIZE(x) (sizeof(x)/sizeof(x[0])) 8 | 9 | #define MAXPASSWORD 128 10 | #define MAXSFXSIZE 0x100000 11 | 12 | #define DefSFXName "default.sfx" 13 | #define DefSortListName "rarfiles.lst" 14 | 15 | #ifndef FA_RDONLY 16 | #define FA_RDONLY 0x01 17 | #define FA_HIDDEN 0x02 18 | #define FA_SYSTEM 0x04 19 | #define FA_LABEL 0x08 20 | #define FA_DIREC 0x10 21 | #define FA_ARCH 0x20 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rarlang.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_LANG_ 2 | #define _RAR_LANG_ 3 | 4 | #ifdef USE_RC 5 | #include "rarres.hpp" 6 | #else 7 | #include "loclang.hpp" 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/raros.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RAROS_ 2 | #define _RAR_RAROS_ 3 | 4 | #ifdef __EMX__ 5 | #define _EMX 6 | #endif 7 | 8 | #ifdef __DJGPP__ 9 | #define _DJGPP 10 | #define _EMX 11 | #endif 12 | 13 | #if defined(__WIN32__) || defined(_WIN32) 14 | #define _WIN_ALL // Defined for all Windows platforms, 32 and 64 bit, mobile and desktop. 15 | #ifdef _M_X64 16 | #define _WIN_64 17 | #else 18 | #define _WIN_32 19 | #endif 20 | #endif 21 | 22 | #ifdef _WIN32_WCE 23 | #define _WIN_ALL 24 | #define _WIN_CE 25 | #ifdef WM_FILECHANGEINFO 26 | #define PC2002 27 | #else 28 | #undef PC2002 29 | #endif 30 | #endif 31 | 32 | #ifdef __BEOS__ 33 | #define _UNIX 34 | #define _BEOS 35 | #endif 36 | 37 | #ifdef __APPLE__ 38 | #define _UNIX 39 | #define _APPLE 40 | #endif 41 | 42 | #if !defined(_EMX) && !defined(_WIN_ALL) && !defined(_BEOS) && !defined(_APPLE) 43 | #define _UNIX 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rarpch.cpp: -------------------------------------------------------------------------------- 1 | // We use rarpch.cpp to create precompiled headers for MS Visual C++. 2 | #include "rar.hpp" 3 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rartypes.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_TYPES_ 2 | #define _RAR_TYPES_ 3 | 4 | typedef unsigned char byte; // unsigned 8 bits 5 | typedef unsigned short ushort; // preferably 16 bits, but can be more 6 | typedef unsigned int uint; // 32 bits or more 7 | 8 | #define PRESENT_INT32 // undefine if signed 32 bits is not available 9 | 10 | typedef unsigned int uint32; // 32 bits exactly 11 | typedef signed int int32; // signed 32 bits exactly 12 | 13 | // If compiler does not support 64 bit variables, we can define 14 | // uint64 and int64 as 32 bit, but it will limit the maximum processed 15 | // file size to 2 GB. 16 | #if defined(__BORLANDC__) || defined(_MSC_VER) 17 | typedef unsigned __int64 uint64; // unsigned 64 bits 18 | typedef signed __int64 int64; // signed 64 bits 19 | #else 20 | typedef unsigned long long uint64; // unsigned 64 bits 21 | typedef signed long long int64; // signed 64 bits 22 | #endif 23 | 24 | 25 | #if defined(_WIN_ALL) || defined(__GNUC__) || defined(__sgi) || defined(_AIX) || defined(__sun) || defined(__hpux) || defined(_OSF_SOURCE) 26 | typedef wchar_t wchar; 27 | #else 28 | typedef ushort wchar; 29 | #endif 30 | 31 | // Get lowest 16 bits. 32 | #define SHORT16(x) (sizeof(ushort)==2 ? (ushort)(x):((x)&0xffff)) 33 | 34 | // Get lowest 32 bits. 35 | #define UINT32(x) (sizeof(uint32)==4 ? (uint32)(x):((x)&0xffffffff)) 36 | 37 | // Make 64 bit integer from two 32 bit. 38 | #define INT32TO64(high,low) ((((uint64)(high))<<32)+((uint64)low)) 39 | 40 | // Special int64 value, large enough to never be found in real life. 41 | // We use it in situations, when we need to indicate that parameter 42 | // is not defined and probably should be calculated inside of function. 43 | // Lower part is intentionally 0x7fffffff, not 0xffffffff, to make it 44 | // compatible with 32 bit int64. 45 | #define INT64NDF INT32TO64(0x7fffffff,0x7fffffff) 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rarvm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_VM_ 2 | #define _RAR_VM_ 3 | 4 | #define VM_STANDARDFILTERS 5 | 6 | #ifndef SFX_MODULE 7 | #define VM_OPTIMIZE 8 | #endif 9 | 10 | 11 | #define VM_MEMSIZE 0x40000 12 | #define VM_MEMMASK (VM_MEMSIZE-1) 13 | #define VM_GLOBALMEMADDR 0x3C000 14 | #define VM_GLOBALMEMSIZE 0x2000 15 | #define VM_FIXEDGLOBALSIZE 64 16 | 17 | enum VM_Commands 18 | { 19 | VM_MOV, VM_CMP, VM_ADD, VM_SUB, VM_JZ, VM_JNZ, VM_INC, VM_DEC, 20 | VM_JMP, VM_XOR, VM_AND, VM_OR, VM_TEST, VM_JS, VM_JNS, VM_JB, 21 | VM_JBE, VM_JA, VM_JAE, VM_PUSH, VM_POP, VM_CALL, VM_RET, VM_NOT, 22 | VM_SHL, VM_SHR, VM_SAR, VM_NEG, VM_PUSHA,VM_POPA, VM_PUSHF,VM_POPF, 23 | VM_MOVZX,VM_MOVSX,VM_XCHG, VM_MUL, VM_DIV, VM_ADC, VM_SBB, VM_PRINT, 24 | 25 | #ifdef VM_OPTIMIZE 26 | VM_MOVB, VM_MOVD, VM_CMPB, VM_CMPD, 27 | 28 | VM_ADDB, VM_ADDD, VM_SUBB, VM_SUBD, VM_INCB, VM_INCD, VM_DECB, VM_DECD, 29 | VM_NEGB, VM_NEGD, 30 | #endif 31 | 32 | VM_STANDARD 33 | }; 34 | 35 | enum VM_StandardFilters { 36 | VMSF_NONE, VMSF_E8, VMSF_E8E9, VMSF_ITANIUM, VMSF_RGB, VMSF_AUDIO, 37 | VMSF_DELTA, VMSF_UPCASE 38 | }; 39 | 40 | enum VM_Flags {VM_FC=1,VM_FZ=2,VM_FS=0x80000000}; 41 | 42 | enum VM_OpType {VM_OPREG,VM_OPINT,VM_OPREGMEM,VM_OPNONE}; 43 | 44 | struct VM_PreparedOperand 45 | { 46 | VM_OpType Type; 47 | uint Data; 48 | uint Base; 49 | uint *Addr; 50 | }; 51 | 52 | struct VM_PreparedCommand 53 | { 54 | VM_Commands OpCode; 55 | bool ByteMode; 56 | VM_PreparedOperand Op1,Op2; 57 | }; 58 | 59 | 60 | struct VM_PreparedProgram 61 | { 62 | VM_PreparedProgram() 63 | { 64 | AltCmd=NULL; 65 | FilteredDataSize=0; 66 | CmdCount=0; 67 | } 68 | 69 | Array Cmd; 70 | VM_PreparedCommand *AltCmd; 71 | int CmdCount; 72 | 73 | Array GlobalData; 74 | Array StaticData; // static data contained in DB operators 75 | uint InitR[7]; 76 | 77 | byte *FilteredData; 78 | uint FilteredDataSize; 79 | }; 80 | 81 | class RarVM:private BitInput 82 | { 83 | private: 84 | inline uint GetValue(bool ByteMode,uint *Addr); 85 | inline void SetValue(bool ByteMode,uint *Addr,uint Value); 86 | inline uint* GetOperand(VM_PreparedOperand *CmdOp); 87 | void DecodeArg(VM_PreparedOperand &Op,bool ByteMode); 88 | #ifdef VM_OPTIMIZE 89 | void Optimize(VM_PreparedProgram *Prg); 90 | #endif 91 | bool ExecuteCode(VM_PreparedCommand *PreparedCode,uint CodeSize); 92 | #ifdef VM_STANDARDFILTERS 93 | VM_StandardFilters IsStandardFilter(byte *Code,uint CodeSize); 94 | void ExecuteStandardFilter(VM_StandardFilters FilterType); 95 | uint FilterItanium_GetBits(byte *Data,int BitPos,int BitCount); 96 | void FilterItanium_SetBits(byte *Data,uint BitField,int BitPos,int BitCount); 97 | #endif 98 | 99 | byte *Mem; 100 | uint R[8]; 101 | uint Flags; 102 | public: 103 | RarVM(); 104 | ~RarVM(); 105 | void Init(); 106 | void Prepare(byte *Code,uint CodeSize,VM_PreparedProgram *Prg); 107 | void Execute(VM_PreparedProgram *Prg); 108 | void SetLowEndianValue(uint *Addr,uint Value); 109 | void SetMemory(uint Pos,byte *Data,uint DataSize); 110 | static uint ReadData(BitInput &Inp); 111 | }; 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rarvmtbl.cpp: -------------------------------------------------------------------------------- 1 | #define VMCF_OP0 0 2 | #define VMCF_OP1 1 3 | #define VMCF_OP2 2 4 | #define VMCF_OPMASK 3 5 | #define VMCF_BYTEMODE 4 6 | #define VMCF_JUMP 8 7 | #define VMCF_PROC 16 8 | #define VMCF_USEFLAGS 32 9 | #define VMCF_CHFLAGS 64 10 | 11 | static byte VM_CmdFlags[]= 12 | { 13 | /* VM_MOV */ VMCF_OP2 | VMCF_BYTEMODE , 14 | /* VM_CMP */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 15 | /* VM_ADD */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 16 | /* VM_SUB */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 17 | /* VM_JZ */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 18 | /* VM_JNZ */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 19 | /* VM_INC */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS , 20 | /* VM_DEC */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS , 21 | /* VM_JMP */ VMCF_OP1 | VMCF_JUMP , 22 | /* VM_XOR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 23 | /* VM_AND */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 24 | /* VM_OR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 25 | /* VM_TEST */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 26 | /* VM_JS */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 27 | /* VM_JNS */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 28 | /* VM_JB */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 29 | /* VM_JBE */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 30 | /* VM_JA */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 31 | /* VM_JAE */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS , 32 | /* VM_PUSH */ VMCF_OP1 , 33 | /* VM_POP */ VMCF_OP1 , 34 | /* VM_CALL */ VMCF_OP1 | VMCF_PROC , 35 | /* VM_RET */ VMCF_OP0 | VMCF_PROC , 36 | /* VM_NOT */ VMCF_OP1 | VMCF_BYTEMODE , 37 | /* VM_SHL */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 38 | /* VM_SHR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 39 | /* VM_SAR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS , 40 | /* VM_NEG */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS , 41 | /* VM_PUSHA */ VMCF_OP0 , 42 | /* VM_POPA */ VMCF_OP0 , 43 | /* VM_PUSHF */ VMCF_OP0 | VMCF_USEFLAGS , 44 | /* VM_POPF */ VMCF_OP0 | VMCF_CHFLAGS , 45 | /* VM_MOVZX */ VMCF_OP2 , 46 | /* VM_MOVSX */ VMCF_OP2 , 47 | /* VM_XCHG */ VMCF_OP2 | VMCF_BYTEMODE , 48 | /* VM_MUL */ VMCF_OP2 | VMCF_BYTEMODE , 49 | /* VM_DIV */ VMCF_OP2 | VMCF_BYTEMODE , 50 | /* VM_ADC */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS , 51 | /* VM_SBB */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS , 52 | /* VM_PRINT */ VMCF_OP0 53 | }; 54 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rawread.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | RawRead::RawRead(File *SrcFile) 4 | { 5 | RawRead::SrcFile=SrcFile; 6 | ReadPos=0; 7 | DataSize=0; 8 | #ifndef SHELL_EXT 9 | Crypt=NULL; 10 | #endif 11 | } 12 | 13 | 14 | void RawRead::Read(size_t Size) 15 | { 16 | #if !defined(SHELL_EXT) && !defined(NOCRYPT) 17 | if (Crypt!=NULL) 18 | { 19 | size_t CurSize=Data.Size(); 20 | size_t SizeToRead=Size-(CurSize-DataSize); 21 | if (SizeToRead>0) 22 | { 23 | size_t AlignedReadSize=SizeToRead+((~SizeToRead+1)&0xf); 24 | Data.Add(AlignedReadSize); 25 | size_t ReadSize=SrcFile->Read(&Data[CurSize],AlignedReadSize); 26 | Crypt->DecryptBlock(&Data[CurSize],AlignedReadSize); 27 | DataSize+=ReadSize==0 ? 0:Size; 28 | } 29 | else 30 | DataSize+=Size; 31 | } 32 | else 33 | #endif 34 | if (Size!=0) 35 | { 36 | Data.Add(Size); 37 | DataSize+=SrcFile->Read(&Data[DataSize],Size); 38 | } 39 | } 40 | 41 | 42 | void RawRead::Read(byte *SrcData,size_t Size) 43 | { 44 | if (Size!=0) 45 | { 46 | Data.Add(Size); 47 | memcpy(&Data[DataSize],SrcData,Size); 48 | DataSize+=Size; 49 | } 50 | } 51 | 52 | 53 | void RawRead::Get(byte &Field) 54 | { 55 | if (ReadPos2 ? CRC(0xffffffff,&Data[2],(ProcessedOnly ? ReadPos:DataSize)-2):0xffffffff); 126 | } 127 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rawread.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RAWREAD_ 2 | #define _RAR_RAWREAD_ 3 | 4 | class RawRead 5 | { 6 | private: 7 | Array Data; 8 | File *SrcFile; 9 | size_t DataSize; 10 | size_t ReadPos; 11 | #ifndef SHELL_EXT 12 | CryptData *Crypt; 13 | #endif 14 | public: 15 | RawRead(File *SrcFile); 16 | void Read(size_t Size); 17 | void Read(byte *SrcData,size_t Size); 18 | void Get(byte &Field); 19 | void Get(ushort &Field); 20 | void Get(uint &Field); 21 | void Get8(int64 &Field); 22 | void Get(byte *Field,size_t Size); 23 | void Get(wchar *Field,size_t Size); 24 | uint GetCRC(bool ProcessedOnly); 25 | size_t Size() {return DataSize;} 26 | size_t PaddedSize() {return Data.Size()-DataSize;} 27 | #ifndef SHELL_EXT 28 | void SetCrypt(CryptData *Crypt) {RawRead::Crypt=Crypt;} 29 | #endif 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rdwrfn.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | ComprDataIO::ComprDataIO() 4 | { 5 | Init(); 6 | } 7 | 8 | 9 | void ComprDataIO::Init() 10 | { 11 | UnpackFromMemory=false; 12 | UnpackToMemory=false; 13 | UnpPackedSize=0; 14 | ShowProgress=true; 15 | TestMode=false; 16 | SkipUnpCRC=false; 17 | PackVolume=false; 18 | UnpVolume=false; 19 | NextVolumeMissing=false; 20 | SrcFile=NULL; 21 | DestFile=NULL; 22 | UnpWrSize=0; 23 | Command=NULL; 24 | Encryption=0; 25 | Decryption=0; 26 | TotalPackRead=0; 27 | CurPackRead=CurPackWrite=CurUnpRead=CurUnpWrite=0; 28 | PackFileCRC=UnpFileCRC=PackedCRC=0xffffffff; 29 | LastPercent=-1; 30 | SubHead=NULL; 31 | SubHeadPos=NULL; 32 | CurrentCommand=0; 33 | ProcessedArcSize=TotalArcSize=0; 34 | } 35 | 36 | 37 | 38 | 39 | int ComprDataIO::UnpRead(byte *Addr,size_t Count) 40 | { 41 | int RetCode=0,TotalRead=0; 42 | byte *ReadAddr; 43 | ReadAddr=Addr; 44 | while (Count > 0) 45 | { 46 | Archive *SrcArc=(Archive *)SrcFile; 47 | 48 | size_t ReadSize=((int64)Count>UnpPackedSize) ? (size_t)UnpPackedSize:Count; 49 | if (UnpackFromMemory) 50 | { 51 | memcpy(Addr,UnpackFromMemoryAddr,UnpackFromMemorySize); 52 | RetCode=(int)UnpackFromMemorySize; 53 | UnpackFromMemorySize=0; 54 | } 55 | else 56 | { 57 | if (!SrcFile->IsOpened()) 58 | return(-1); 59 | RetCode=SrcFile->Read(ReadAddr,ReadSize); 60 | FileHeader *hd=SubHead!=NULL ? SubHead:&SrcArc->NewLhd; 61 | if (hd->Flags & LHD_SPLIT_AFTER) 62 | PackedCRC=CRC(PackedCRC,ReadAddr,RetCode); 63 | } 64 | CurUnpRead+=RetCode; 65 | TotalRead+=RetCode; 66 | #ifndef NOVOLUME 67 | // These variable are not used in NOVOLUME mode, so it is better 68 | // to exclude commands below to avoid compiler warnings. 69 | ReadAddr+=RetCode; 70 | Count-=RetCode; 71 | #endif 72 | UnpPackedSize-=RetCode; 73 | if (UnpPackedSize == 0 && UnpVolume) 74 | { 75 | #ifndef NOVOLUME 76 | if (!MergeArchive(*SrcArc,this,true,CurrentCommand)) 77 | #endif 78 | { 79 | NextVolumeMissing=true; 80 | return(-1); 81 | } 82 | } 83 | else 84 | break; 85 | } 86 | Archive *SrcArc=(Archive *)SrcFile; 87 | if (SrcArc!=NULL) 88 | ShowUnpRead(SrcArc->CurBlockPos+CurUnpRead,UnpArcSize); 89 | if (RetCode!=-1) 90 | { 91 | RetCode=TotalRead; 92 | #ifndef NOCRYPT 93 | if (Decryption) 94 | #ifndef SFX_MODULE 95 | if (Decryption<20) 96 | Decrypt.Crypt(Addr,RetCode,(Decryption==15) ? NEW_CRYPT : OLD_DECODE); 97 | else 98 | if (Decryption==20) 99 | for (int I=0;IGetRAROptions(); 126 | if (Cmd->DllOpMode!=RAR_SKIP) 127 | { 128 | if (Cmd->Callback!=NULL && 129 | Cmd->Callback(UCM_PROCESSDATA,Cmd->UserData,(LPARAM)Addr,Count)==-1) 130 | ErrHandler.Exit(USER_BREAK); 131 | if (Cmd->ProcessDataProc!=NULL) 132 | { 133 | // Here we preserve ESP value. It is necessary for those developers, 134 | // who still define ProcessDataProc callback as "C" type function, 135 | // even though in year 2001 we announced in unrar.dll whatsnew.txt 136 | // that it will be PASCAL type (for compatibility with Visual Basic). 137 | #if defined(_MSC_VER) 138 | #ifndef _WIN_64 139 | __asm mov ebx,esp 140 | #endif 141 | #elif defined(_WIN_ALL) && defined(__BORLANDC__) 142 | _EBX=_ESP; 143 | #endif 144 | int RetCode=Cmd->ProcessDataProc(Addr,(int)Count); 145 | 146 | // Restore ESP after ProcessDataProc with wrongly defined calling 147 | // convention broken it. 148 | #if defined(_MSC_VER) 149 | #ifndef _WIN_64 150 | __asm mov esp,ebx 151 | #endif 152 | #elif defined(_WIN_ALL) && defined(__BORLANDC__) 153 | _ESP=_EBX; 154 | #endif 155 | if (RetCode==0) 156 | ErrHandler.Exit(USER_BREAK); 157 | } 158 | } 159 | #endif // RARDLL 160 | 161 | UnpWrAddr=Addr; 162 | UnpWrSize=Count; 163 | if (UnpackToMemory) 164 | { 165 | if (Count <= UnpackToMemorySize) 166 | { 167 | memcpy(UnpackToMemoryAddr,Addr,Count); 168 | UnpackToMemoryAddr+=Count; 169 | UnpackToMemorySize-=Count; 170 | } 171 | } 172 | else 173 | if (!TestMode) 174 | DestFile->Write(Addr,Count); 175 | CurUnpWrite+=Count; 176 | if (!SkipUnpCRC) 177 | #ifndef SFX_MODULE 178 | if (((Archive *)SrcFile)->OldFormat) 179 | UnpFileCRC=OldCRC((ushort)UnpFileCRC,Addr,Count); 180 | else 181 | #endif 182 | UnpFileCRC=CRC(UnpFileCRC,Addr,Count); 183 | ShowUnpWrite(); 184 | Wait(); 185 | } 186 | 187 | #if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64) 188 | // Restore the run time stack check for unrar.dll. 189 | #pragma runtime_checks( "s", restore ) 190 | #endif 191 | 192 | 193 | 194 | 195 | 196 | 197 | void ComprDataIO::ShowUnpRead(int64 ArcPos,int64 ArcSize) 198 | { 199 | if (ShowProgress && SrcFile!=NULL) 200 | { 201 | if (TotalArcSize!=0) 202 | { 203 | // important when processing several archives or multivolume archive 204 | ArcSize=TotalArcSize; 205 | ArcPos+=ProcessedArcSize; 206 | } 207 | 208 | Archive *SrcArc=(Archive *)SrcFile; 209 | RAROptions *Cmd=SrcArc->GetRAROptions(); 210 | 211 | int CurPercent=ToPercent(ArcPos,ArcSize); 212 | if (!Cmd->DisablePercentage && CurPercent!=LastPercent) 213 | { 214 | mprintf("\b\b\b\b%3d%%",CurPercent); 215 | LastPercent=CurPercent; 216 | } 217 | } 218 | } 219 | 220 | 221 | void ComprDataIO::ShowUnpWrite() 222 | { 223 | } 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | void ComprDataIO::SetFiles(File *SrcFile,File *DestFile) 233 | { 234 | if (SrcFile!=NULL) 235 | ComprDataIO::SrcFile=SrcFile; 236 | if (DestFile!=NULL) 237 | ComprDataIO::DestFile=DestFile; 238 | LastPercent=-1; 239 | } 240 | 241 | 242 | void ComprDataIO::GetUnpackedData(byte **Data,size_t *Size) 243 | { 244 | *Data=UnpWrAddr; 245 | *Size=UnpWrSize; 246 | } 247 | 248 | 249 | void ComprDataIO::SetEncryption(int Method,const wchar *Password,const byte *Salt,bool Encrypt,bool HandsOffHash) 250 | { 251 | if (Encrypt) 252 | { 253 | Encryption=*Password ? Method:0; 254 | #ifndef NOCRYPT 255 | Crypt.SetCryptKeys(Password,Salt,Encrypt,false,HandsOffHash); 256 | #endif 257 | } 258 | else 259 | { 260 | Decryption=*Password ? Method:0; 261 | #ifndef NOCRYPT 262 | Decrypt.SetCryptKeys(Password,Salt,Encrypt,Method<29,HandsOffHash); 263 | #endif 264 | } 265 | } 266 | 267 | 268 | #if !defined(SFX_MODULE) && !defined(NOCRYPT) 269 | void ComprDataIO::SetAV15Encryption() 270 | { 271 | Decryption=15; 272 | Decrypt.SetAV15Encryption(); 273 | } 274 | #endif 275 | 276 | 277 | #if !defined(SFX_MODULE) && !defined(NOCRYPT) 278 | void ComprDataIO::SetCmt13Encryption() 279 | { 280 | Decryption=13; 281 | Decrypt.SetCmt13Encryption(); 282 | } 283 | #endif 284 | 285 | 286 | 287 | 288 | void ComprDataIO::SetUnpackToMemory(byte *Addr,uint Size) 289 | { 290 | UnpackToMemory=true; 291 | UnpackToMemoryAddr=Addr; 292 | UnpackToMemorySize=Size; 293 | } 294 | 295 | 296 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rdwrfn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_DATAIO_ 2 | #define _RAR_DATAIO_ 3 | 4 | class CmdAdd; 5 | class Unpack; 6 | 7 | 8 | class ComprDataIO 9 | { 10 | private: 11 | void ShowUnpRead(int64 ArcPos,int64 ArcSize); 12 | void ShowUnpWrite(); 13 | 14 | 15 | bool UnpackFromMemory; 16 | size_t UnpackFromMemorySize; 17 | byte *UnpackFromMemoryAddr; 18 | 19 | bool UnpackToMemory; 20 | size_t UnpackToMemorySize; 21 | byte *UnpackToMemoryAddr; 22 | 23 | size_t UnpWrSize; 24 | byte *UnpWrAddr; 25 | 26 | int64 UnpPackedSize; 27 | 28 | bool ShowProgress; 29 | bool TestMode; 30 | bool SkipUnpCRC; 31 | 32 | File *SrcFile; 33 | File *DestFile; 34 | 35 | CmdAdd *Command; 36 | 37 | FileHeader *SubHead; 38 | int64 *SubHeadPos; 39 | 40 | #ifndef NOCRYPT 41 | CryptData Crypt; 42 | CryptData Decrypt; 43 | #endif 44 | 45 | 46 | int LastPercent; 47 | 48 | char CurrentCommand; 49 | 50 | public: 51 | ComprDataIO(); 52 | void Init(); 53 | int UnpRead(byte *Addr,size_t Count); 54 | void UnpWrite(byte *Addr,size_t Count); 55 | void EnableShowProgress(bool Show) {ShowProgress=Show;} 56 | void GetUnpackedData(byte **Data,size_t *Size); 57 | void SetPackedSizeToRead(int64 Size) {UnpPackedSize=Size;} 58 | void SetTestMode(bool Mode) {TestMode=Mode;} 59 | void SetSkipUnpCRC(bool Skip) {SkipUnpCRC=Skip;} 60 | void SetFiles(File *SrcFile,File *DestFile); 61 | void SetCommand(CmdAdd *Cmd) {Command=Cmd;} 62 | void SetSubHeader(FileHeader *hd,int64 *Pos) {SubHead=hd;SubHeadPos=Pos;} 63 | void SetEncryption(int Method,const wchar *Password,const byte *Salt,bool Encrypt,bool HandsOffHash); 64 | void SetAV15Encryption(); 65 | void SetCmt13Encryption(); 66 | void SetUnpackToMemory(byte *Addr,uint Size); 67 | void SetCurrentCommand(char Cmd) {CurrentCommand=Cmd;} 68 | 69 | bool PackVolume; 70 | bool UnpVolume; 71 | bool NextVolumeMissing; 72 | int64 TotalPackRead; 73 | int64 UnpArcSize; 74 | int64 CurPackRead,CurPackWrite,CurUnpRead,CurUnpWrite; 75 | 76 | // Size of already processed archives. 77 | // Used to calculate the total operation progress. 78 | int64 ProcessedArcSize; 79 | 80 | int64 TotalArcSize; 81 | 82 | uint PackFileCRC,UnpFileCRC,PackedCRC; 83 | 84 | int Encryption; 85 | int Decryption; 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Portable UnRAR version 3 | 4 | 5 | 1. General 6 | 7 | This package includes freeware Unrar C++ source and a few makefiles 8 | (makefile.bcc, makefile.msc+msc.dep, makefile.unix). Unrar source 9 | is subset of RAR and generated from RAR source automatically, 10 | by a small program removing blocks like '#ifndef UNRAR ... #endif'. 11 | Such method is not perfect and you may find some RAR related 12 | stuff unnecessary in Unrar, especially in header files. 13 | 14 | If you wish to port Unrar to a new platform, you may need to edit 15 | '#define LITTLE_ENDIAN' in os.hpp and data type definitions 16 | in rartypes.hpp. 17 | 18 | if computer architecture does not allow not aligned data access, 19 | you need to undefine ALLOW_NOT_ALIGNED_INT and define 20 | STRICT_ALIGNMENT_REQUIRED in os.h. Note that it will increase memory 21 | requirements. 22 | 23 | If you use Borland C++ makefile (makefile.bcc), you need to define 24 | BASEPATHCC environment (or makefile) variable containing 25 | the path to Borland C++ installation. 26 | 27 | Makefile.unix contains numerous compiler option sets. 28 | GCC Linux is selected by default. If you need to compile Unrar 29 | for other platforms, uncomment corresponding lines. 30 | 31 | UnRAR.vcproj and UnRARDll.vcproj are projects for Microsoft Visual C++. 32 | UnRARDll.vcproj lets to build unrar.dll library. 33 | 34 | 35 | 2. Unrar binaries 36 | 37 | If you compiled Unrar for OS, which is not present in "Downloads" 38 | and "RAR extras" on www.rarlab.com, we will appreciate if you send 39 | us the compiled executable to place it to our site. 40 | 41 | 42 | 3. Acknowledgements 43 | 44 | This source includes parts of code written by the following authors: 45 | 46 | Dmitry Shkarin PPMII v.H text compression 47 | Dmitry Subbotin Carryless rangecoder 48 | Szymon Stefanek AES encryption 49 | Brian Gladman AES encryption 50 | Steve Reid SHA-1 hash function 51 | Marcus Herbert makefile.unix file 52 | Tomasz Klim fixes for libunrar.so 53 | Robert Riebisch makefile.dj and patches for DJGPP 54 | 55 | 56 | 4. Legal stuff 57 | 58 | Unrar source may be used in any software to handle RAR archives 59 | without limitations free of charge, but cannot be used to re-create 60 | the RAR compression algorithm, which is proprietary. Distribution 61 | of modified Unrar source in separate form or as a part of other 62 | software is permitted, provided that it is clearly stated in 63 | the documentation and source comments that the code may not be used 64 | to develop a RAR (WinRAR) compatible archiver. 65 | 66 | More detailed license text is available in license.txt. 67 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/recvol.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RECVOL_ 2 | #define _RAR_RECVOL_ 3 | 4 | class RecVolumes 5 | { 6 | private: 7 | File *SrcFile[256]; 8 | Array Buf; 9 | public: 10 | RecVolumes(); 11 | ~RecVolumes(); 12 | void Make(RAROptions *Cmd,char *ArcName,wchar *ArcNameW); 13 | bool Restore(RAROptions *Cmd,const char *Name,const wchar *NameW,bool Silent); 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/resource.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | 4 | 5 | #ifndef RARDLL 6 | const char *St(MSGID StringId) 7 | { 8 | return(StringId); 9 | } 10 | #endif 11 | 12 | 13 | #ifndef RARDLL 14 | const wchar *StW(MSGID StringId) 15 | { 16 | static wchar StrTable[8][512]; 17 | static int StrNum=0; 18 | if (++StrNum >= sizeof(StrTable)/sizeof(StrTable[0])) 19 | StrNum=0; 20 | wchar *Str=StrTable[StrNum]; 21 | *Str=0; 22 | CharToWide(StringId,Str,ASIZE(StrTable[0])); 23 | return(Str); 24 | } 25 | #endif 26 | 27 | 28 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/resource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RESOURCE_ 2 | #define _RAR_RESOURCE_ 3 | 4 | #ifdef RARDLL 5 | #define St(x) ( "") 6 | #define StW(x) (L"") 7 | #else 8 | const char *St (MSGID StringId); 9 | const wchar *StW (MSGID StringId); 10 | #endif 11 | 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rijndael.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RIJNDAEL_H_ 2 | #define _RIJNDAEL_H_ 3 | 4 | /************************************************************************** 5 | * This code is based on Szymon Stefanek AES implementation: * 6 | * http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael-cpplib.tar.gz * 7 | * * 8 | * Dynamic tables generation is based on the Brian Gladman's work: * 9 | * http://fp.gladman.plus.com/cryptography_technology/rijndael * 10 | **************************************************************************/ 11 | 12 | #define _MAX_KEY_COLUMNS (256/32) 13 | #define _MAX_ROUNDS 14 14 | #define MAX_IV_SIZE 16 15 | 16 | class Rijndael 17 | { 18 | public: 19 | enum Direction { Encrypt , Decrypt }; 20 | private: 21 | void keySched(byte key[_MAX_KEY_COLUMNS][4]); 22 | void keyEncToDec(); 23 | void encrypt(const byte a[16], byte b[16]); 24 | void decrypt(const byte a[16], byte b[16]); 25 | void GenerateTables(); 26 | 27 | Direction m_direction; 28 | byte m_initVector[MAX_IV_SIZE]; 29 | byte m_expandedKey[_MAX_ROUNDS+1][4][4]; 30 | public: 31 | Rijndael(); 32 | void init(Direction dir,const byte *key,byte *initVector); 33 | size_t blockEncrypt(const byte *input, size_t inputLen, byte *outBuffer); 34 | size_t blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer); 35 | }; 36 | 37 | #endif // _RIJNDAEL_H_ 38 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/rs.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #define Clean(D,S) {for (int I=0;I<(S);I++) (D)[I]=0;} 4 | 5 | RSCoder::RSCoder(int ParSize) 6 | { 7 | RSCoder::ParSize=ParSize; // Store the number of recovery volumes. 8 | FirstBlockDone=false; 9 | gfInit(); 10 | pnInit(); 11 | } 12 | 13 | 14 | // Initialize logarithms and exponents Galois field tables. 15 | void RSCoder::gfInit() 16 | { 17 | for (int I=0,J=1;I0;J--) 85 | ShiftReg[J]=ShiftReg[J-1]^gfMult(GXPol[J],D); 86 | ShiftReg[0]=gfMult(GXPol[0],D); 87 | } 88 | for (int I=0;I0;I--) 133 | ELPol[I]^=gfMult(M,ELPol[I-1]); 134 | 135 | ErrCount=0; 136 | 137 | // Find roots of error locator polynomial. 138 | for (int Root=MAXPAR-DataSize;Root0) 161 | for (int I=0;I=0 && DataPosCloseCount) 14 | SaveFile->Seek(SavePos,SEEK_SET); 15 | } 16 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/savepos.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SAVEPOS_ 2 | #define _RAR_SAVEPOS_ 3 | 4 | class SaveFilePos 5 | { 6 | private: 7 | File *SaveFile; 8 | int64 SavePos; 9 | uint CloseCount; 10 | public: 11 | SaveFilePos(File &SaveFile); 12 | ~SaveFilePos(); 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/scantree.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SCANTREE_ 2 | #define _RAR_SCANTREE_ 3 | 4 | enum SCAN_DIRS 5 | { 6 | SCAN_SKIPDIRS, // Skip directories, but recurse for files if recursion mode is enabled. 7 | SCAN_GETDIRS, // Get subdirectories in recurse mode. 8 | SCAN_GETDIRSTWICE, // Get the directory name both before and after the list of files it contains. 9 | SCAN_GETCURDIRS // Get subdirectories in current directory even in RECURSE_NONE mode. 10 | }; 11 | 12 | enum SCAN_CODE { SCAN_SUCCESS,SCAN_DONE,SCAN_ERROR,SCAN_NEXT }; 13 | 14 | #define MAXSCANDEPTH (NM/2) 15 | 16 | class CommandData; 17 | 18 | class ScanTree 19 | { 20 | private: 21 | bool GetNextMask(); 22 | SCAN_CODE FindProc(FindData *FD); 23 | 24 | FindFile *FindStack[MAXSCANDEPTH]; 25 | int Depth; 26 | 27 | int SetAllMaskDepth; 28 | 29 | StringList *FileMasks; 30 | RECURSE_MODE Recurse; 31 | bool GetLinks; 32 | SCAN_DIRS GetDirs; 33 | int Errors; 34 | 35 | // set when processing paths like c:\ (root directory without wildcards) 36 | bool ScanEntireDisk; 37 | 38 | char CurMask[NM]; 39 | wchar CurMaskW[NM]; 40 | char OrigCurMask[NM]; 41 | wchar OrigCurMaskW[NM]; 42 | bool SearchAllInRoot; 43 | size_t SpecPathLength; 44 | size_t SpecPathLengthW; 45 | 46 | char ErrArcName[NM]; 47 | 48 | CommandData *Cmd; 49 | public: 50 | ScanTree(StringList *FileMasks,RECURSE_MODE Recurse,bool GetLinks,SCAN_DIRS GetDirs); 51 | ~ScanTree(); 52 | SCAN_CODE GetNext(FindData *FindData); 53 | size_t GetSpecPathLength() {return(SpecPathLength);}; 54 | size_t GetSpecPathLengthW() {return(SpecPathLengthW);}; 55 | int GetErrors() {return(Errors);}; 56 | void SetErrArcName(const char *Name) {strcpy(ErrArcName,Name);} 57 | void SetCommandData(CommandData *Cmd) {ScanTree::Cmd=Cmd;} 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/sha1.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SHA1_ 2 | #define _RAR_SHA1_ 3 | 4 | #define HW 5 5 | 6 | typedef struct { 7 | uint32 state[5]; 8 | uint32 count[2]; 9 | unsigned char buffer[64]; 10 | } hash_context; 11 | 12 | void hash_initial( hash_context * c ); 13 | void hash_process( hash_context * c, unsigned char * data, size_t len, 14 | bool handsoff); 15 | void hash_final( hash_context * c, uint32[HW], bool handsoff); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/smallfn.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | int ToPercent(int64 N1,int64 N2) 4 | { 5 | if (N2=0 && (Str[I]=='\r' || Str[I]=='\n' || Str[I]==' ' || Str[I]=='\t');I--) 90 | Str[I]=0; 91 | return(Str); 92 | } 93 | 94 | 95 | char* RemoveLF(char *Str) 96 | { 97 | for (int I=(int)strlen(Str)-1;I>=0 && (Str[I]=='\r' || Str[I]=='\n');I--) 98 | Str[I]=0; 99 | return(Str); 100 | } 101 | 102 | 103 | wchar* RemoveLF(wchar *Str) 104 | { 105 | for (int I=(int)wcslen(Str)-1;I>=0 && (Str[I]=='\r' || Str[I]=='\n');I--) 106 | Str[I]=0; 107 | return(Str); 108 | } 109 | 110 | 111 | unsigned char loctolower(unsigned char ch) 112 | { 113 | #ifdef _WIN_ALL 114 | // Convert to LPARAM first to avoid a warning in 64 bit mode. 115 | return((int)(LPARAM)CharLowerA((LPSTR)ch)); 116 | #else 117 | return(tolower(ch)); 118 | #endif 119 | } 120 | 121 | 122 | unsigned char loctoupper(unsigned char ch) 123 | { 124 | #ifdef _WIN_ALL 125 | // Convert to LPARAM first to avoid a warning in 64 bit mode. 126 | return((int)(LPARAM)CharUpperA((LPSTR)ch)); 127 | #else 128 | return(toupper(ch)); 129 | #endif 130 | } 131 | 132 | 133 | // toupper with English only results if English input is provided. 134 | // It avoids Turkish (small i) -> (big I with dot) conversion problem. 135 | // We do not define 'ch' as 'int' to avoid necessity to cast all 136 | // signed chars passed to this function to unsigned char. 137 | unsigned char etoupper(unsigned char ch) 138 | { 139 | if (ch=='i') 140 | return('I'); 141 | return(toupper(ch)); 142 | } 143 | 144 | 145 | // Unicode version of etoupper. 146 | wchar etoupperw(wchar ch) 147 | { 148 | if (ch=='i') 149 | return('I'); 150 | return(toupperw(ch)); 151 | } 152 | 153 | 154 | // We do not want to cast every signed char to unsigned when passing to 155 | // isdigit, so we implement the replacement. Shall work for Unicode too. 156 | // If chars are signed, conversion from char to int could generate negative 157 | // values, resulting in undefined behavior in standard isdigit. 158 | bool IsDigit(int ch) 159 | { 160 | return(ch>='0' && ch<='9'); 161 | } 162 | 163 | 164 | // We do not want to cast every signed char to unsigned when passing to 165 | // isspace, so we implement the replacement. Shall work for Unicode too. 166 | // If chars are signed, conversion from char to int could generate negative 167 | // values, resulting in undefined behavior in standard isspace. 168 | bool IsSpace(int ch) 169 | { 170 | return(ch==' ' || ch=='\t'); 171 | } 172 | 173 | 174 | // We do not want to cast every signed char to unsigned when passing to 175 | // isspace, so we implement the replacement. Shall work for Unicode too. 176 | // If chars are signed, conversion from char to int could generate negative 177 | // values, resulting in undefined behavior in standard function. 178 | bool IsAlpha(int ch) 179 | { 180 | return(ch>='A' && ch<='Z' || ch>='a' && ch<='z'); 181 | } 182 | 183 | 184 | 185 | 186 | 187 | bool LowAscii(const char *Str) 188 | { 189 | for (int I=0;Str[I]!=0;I++) 190 | if ((byte)Str[I]<32 || (byte)Str[I]>127) 191 | return(false); 192 | return(true); 193 | } 194 | 195 | 196 | bool LowAscii(const wchar *Str) 197 | { 198 | for (int I=0;Str[I]!=0;I++) 199 | { 200 | // We convert wchar_t to uint just in case if some compiler 201 | // uses the signed wchar_t. 202 | if ((uint)Str[I]<32 || (uint)Str[I]>127) 203 | return(false); 204 | } 205 | return(true); 206 | } 207 | 208 | 209 | 210 | 211 | int stricompc(const char *Str1,const char *Str2) 212 | { 213 | #if defined(_UNIX) 214 | return(strcmp(Str1,Str2)); 215 | #else 216 | return(stricomp(Str1,Str2)); 217 | #endif 218 | } 219 | 220 | 221 | #ifndef SFX_MODULE 222 | int wcsicompc(const wchar *Str1,const wchar *Str2) 223 | { 224 | #if defined(_UNIX) 225 | return(wcscmp(Str1,Str2)); 226 | #else 227 | return(wcsicomp(Str1,Str2)); 228 | #endif 229 | } 230 | #endif 231 | 232 | 233 | // safe strncpy: copies maxlen-1 max and always returns zero terminated dest 234 | char* strncpyz(char *dest, const char *src, size_t maxlen) 235 | { 236 | if (maxlen>0) 237 | { 238 | strncpy(dest,src,maxlen-1); 239 | dest[maxlen-1]=0; 240 | } 241 | return(dest); 242 | } 243 | 244 | 245 | // Safe wcsncpy: copies maxlen-1 max and always returns zero terminated dest. 246 | wchar* wcsncpyz(wchar *dest, const wchar *src, size_t maxlen) 247 | { 248 | if (maxlen>0) 249 | { 250 | wcsncpy(dest,src,maxlen-1); 251 | dest[maxlen-1]=0; 252 | } 253 | return(dest); 254 | } 255 | 256 | 257 | void itoa(int64 n,char *Str) 258 | { 259 | char NumStr[50]; 260 | size_t Pos=0; 261 | 262 | do 263 | { 264 | NumStr[Pos++]=char(n%10)+'0'; 265 | n=n/10; 266 | } while (n!=0); 267 | 268 | for (size_t I=0;I='0' && *Str<='9') 279 | { 280 | n=n*10+*Str-'0'; 281 | Str++; 282 | } 283 | return(n); 284 | } 285 | 286 | 287 | void itoa(int64 n,wchar *Str) 288 | { 289 | wchar NumStr[50]; 290 | size_t Pos=0; 291 | 292 | do 293 | { 294 | NumStr[Pos++]=wchar(n%10)+'0'; 295 | n=n/10; 296 | } while (n!=0); 297 | 298 | for (size_t I=0;I='0' && *Str<='9') 308 | { 309 | n=n*10+*Str-'0'; 310 | Str++; 311 | } 312 | return(n); 313 | } 314 | 315 | 316 | const wchar* GetWide(const char *Src) 317 | { 318 | const size_t MaxLength=NM; 319 | static wchar StrTable[4][MaxLength]; 320 | static uint StrNum=0; 321 | if (++StrNum >= ASIZE(StrTable)) 322 | StrNum=0; 323 | wchar *Str=StrTable[StrNum]; 324 | CharToWide(Src,Str,MaxLength); 325 | Str[MaxLength-1]=0; 326 | return(Str); 327 | } 328 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/strfn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_STRFN_ 2 | #define _RAR_STRFN_ 3 | 4 | const char *NullToEmpty(const char *Str); 5 | const wchar *NullToEmpty(const wchar *Str); 6 | char *IntNameToExt(const char *Name); 7 | void ExtToInt(const char *Src,char *Dest); 8 | void IntToExt(const char *Src,char *Dest); 9 | char* strlower(char *Str); 10 | char* strupper(char *Str); 11 | int stricomp(const char *Str1,const char *Str2); 12 | int strnicomp(const char *Str1,const char *Str2,size_t N); 13 | char* RemoveEOL(char *Str); 14 | char* RemoveLF(char *Str); 15 | wchar* RemoveLF(wchar *Str); 16 | unsigned char loctolower(unsigned char ch); 17 | unsigned char loctoupper(unsigned char ch); 18 | 19 | char* strncpyz(char *dest, const char *src, size_t maxlen); 20 | wchar* wcsncpyz(wchar *dest, const wchar *src, size_t maxlen); 21 | 22 | unsigned char etoupper(unsigned char ch); 23 | wchar etoupperw(wchar ch); 24 | 25 | bool IsDigit(int ch); 26 | bool IsSpace(int ch); 27 | bool IsAlpha(int ch); 28 | 29 | 30 | 31 | bool LowAscii(const char *Str); 32 | bool LowAscii(const wchar *Str); 33 | 34 | 35 | int stricompc(const char *Str1,const char *Str2); 36 | #ifndef SFX_MODULE 37 | int wcsicompc(const wchar *Str1,const wchar *Str2); 38 | #endif 39 | 40 | void itoa(int64 n,char *Str); 41 | int64 atoil(char *Str); 42 | void itoa(int64 n,wchar *Str); 43 | int64 atoil(wchar *Str); 44 | const wchar* GetWide(const char *Src); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/strlist.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | StringList::StringList() 4 | { 5 | Reset(); 6 | } 7 | 8 | 9 | void StringList::Reset() 10 | { 11 | Rewind(); 12 | StringData.Reset(); 13 | StringDataW.Reset(); 14 | StringsCount=0; 15 | SavePosNumber=0; 16 | } 17 | 18 | 19 | void StringList::AddString(const char *Str) 20 | { 21 | AddString(Str,NULL); 22 | } 23 | 24 | 25 | void StringList::AddString(const wchar *Str) 26 | { 27 | AddString(NULL,Str); 28 | } 29 | 30 | 31 | 32 | 33 | void StringList::AddString(const char *Str,const wchar *StrW) 34 | { 35 | if (Str==NULL) 36 | Str=""; 37 | if (StrW==NULL) 38 | StrW=L""; 39 | 40 | size_t PrevSize=StringData.Size(); 41 | StringData.Add(strlen(Str)+1); 42 | strcpy(&StringData[PrevSize],Str); 43 | 44 | size_t PrevSizeW=StringDataW.Size(); 45 | StringDataW.Add(wcslen(StrW)+1); 46 | wcscpy(&StringDataW[PrevSizeW],StrW); 47 | 48 | StringsCount++; 49 | } 50 | 51 | 52 | bool StringList::GetString(char *Str,size_t MaxLength) 53 | { 54 | return(GetString(Str,NULL,MaxLength)); 55 | } 56 | 57 | 58 | bool StringList::GetString(wchar *Str,size_t MaxLength) 59 | { 60 | return(GetString(NULL,Str,MaxLength)); 61 | } 62 | 63 | 64 | bool StringList::GetString(char *Str,wchar *StrW,size_t MaxLength) 65 | { 66 | char *StrPtr; 67 | wchar *StrPtrW; 68 | if (!GetString(&StrPtr,&StrPtrW)) 69 | return(false); 70 | if (Str!=NULL) 71 | strncpy(Str,StrPtr,MaxLength); 72 | if (StrW!=NULL) 73 | wcsncpy(StrW,StrPtrW,MaxLength); 74 | return(true); 75 | } 76 | 77 | 78 | #ifndef SFX_MODULE 79 | bool StringList::GetString(char *Str,wchar *StrW,size_t MaxLength,int StringNum) 80 | { 81 | SavePosition(); 82 | Rewind(); 83 | bool RetCode=true; 84 | while (StringNum-- >=0) 85 | if (!GetString(Str,StrW,MaxLength)) 86 | { 87 | RetCode=false; 88 | break; 89 | } 90 | RestorePosition(); 91 | return(RetCode); 92 | } 93 | #endif 94 | 95 | 96 | char* StringList::GetString() 97 | { 98 | char *Str; 99 | GetString(&Str,NULL); 100 | return(Str); 101 | } 102 | 103 | 104 | wchar* StringList::GetStringW() 105 | { 106 | wchar *StrW; 107 | GetString(NULL,&StrW); 108 | return(StrW); 109 | } 110 | 111 | 112 | bool StringList::GetString(char **Str,wchar **StrW) 113 | { 114 | // First check would be enough, because both buffers grow synchronously, 115 | // but we check both for extra fail proof. 116 | if (CurPos>=StringData.Size() || CurPosW>=StringDataW.Size()) 117 | { 118 | // No more strings left unprocessed. 119 | if (Str!=NULL) 120 | *Str=NULL; 121 | if (StrW!=NULL) 122 | *StrW=NULL; 123 | return(false); 124 | } 125 | 126 | // We move ASCII and Unicode buffer pointers synchronously. 127 | 128 | char *CurStr=&StringData[CurPos]; 129 | CurPos+=strlen(CurStr)+1; 130 | if (Str!=NULL) 131 | *Str=CurStr; 132 | 133 | wchar *CurStrW=&StringDataW[CurPosW]; 134 | CurPosW+=wcslen(CurStrW)+1; 135 | if (StrW!=NULL) 136 | *StrW=CurStrW; 137 | 138 | return(true); 139 | } 140 | 141 | 142 | void StringList::Rewind() 143 | { 144 | CurPos=0; 145 | CurPosW=0; 146 | } 147 | 148 | 149 | // Return the total size of usual and Unicode characters stored in the list. 150 | size_t StringList::GetCharCount() 151 | { 152 | return(StringData.Size()+StringDataW.Size()); 153 | } 154 | 155 | 156 | #ifndef SFX_MODULE 157 | bool StringList::Search(char *Str,wchar *StrW,bool CaseSensitive) 158 | { 159 | SavePosition(); 160 | Rewind(); 161 | bool Found=false; 162 | char *CurStr; 163 | wchar *CurStrW; 164 | while (GetString(&CurStr,&CurStrW)) 165 | { 166 | if (Str!=NULL && CurStr!=NULL) 167 | if ((CaseSensitive ? strcmp(Str,CurStr):stricomp(Str,CurStr))!=0) 168 | continue; 169 | if (StrW!=NULL && CurStrW!=NULL) 170 | if ((CaseSensitive ? wcscmp(StrW,CurStrW):wcsicomp(StrW,CurStrW))!=0) 171 | continue; 172 | Found=true; 173 | break; 174 | } 175 | RestorePosition(); 176 | return(Found); 177 | } 178 | #endif 179 | 180 | 181 | #ifndef SFX_MODULE 182 | void StringList::SavePosition() 183 | { 184 | if (SavePosNumber0) 198 | { 199 | SavePosNumber--; 200 | CurPos=SaveCurPos[SavePosNumber]; 201 | CurPosW=SaveCurPosW[SavePosNumber]; 202 | } 203 | } 204 | #endif 205 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/strlist.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_STRLIST_ 2 | #define _RAR_STRLIST_ 3 | 4 | class StringList 5 | { 6 | private: 7 | Array StringData; 8 | size_t CurPos; 9 | 10 | Array StringDataW; 11 | size_t CurPosW; 12 | 13 | uint StringsCount; 14 | 15 | size_t SaveCurPos[16],SaveCurPosW[16],SavePosNumber; 16 | public: 17 | StringList(); 18 | void Reset(); 19 | void AddString(const char *Str); 20 | void AddString(const wchar *Str); 21 | void AddString(const char *Str,const wchar *StrW); 22 | bool GetString(char *Str,size_t MaxLength); 23 | bool GetString(wchar *Str,size_t MaxLength); 24 | bool GetString(char *Str,wchar *StrW,size_t MaxLength); 25 | bool GetString(char *Str,wchar *StrW,size_t MaxLength,int StringNum); 26 | char* GetString(); 27 | wchar* GetStringW(); 28 | bool GetString(char **Str,wchar **StrW); 29 | void Rewind(); 30 | uint ItemsCount() {return(StringsCount);}; 31 | size_t GetCharCount(); 32 | bool Search(char *Str,wchar *StrW,bool CaseSensitive); 33 | void SavePosition(); 34 | void RestorePosition(); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/suballoc.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * This file is part of PPMd project * 3 | * Written and distributed to public domain by Dmitry Shkarin 1997, * 4 | * 1999-2000 * 5 | * Contents: interface to memory allocation routines * 6 | ****************************************************************************/ 7 | #if !defined(_SUBALLOC_H_) 8 | #define _SUBALLOC_H_ 9 | 10 | const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4; 11 | const int N_INDEXES=N1+N2+N3+N4; 12 | 13 | #if defined(__GNUC__) && !defined(STRICT_ALIGNMENT_REQUIRED) 14 | #define _PACK_ATTR __attribute__ ((packed)) 15 | #else 16 | #define _PACK_ATTR 17 | #endif /* defined(__GNUC__) */ 18 | 19 | #ifndef STRICT_ALIGNMENT_REQUIRED 20 | #pragma pack(1) 21 | #endif 22 | 23 | struct RAR_MEM_BLK 24 | { 25 | ushort Stamp, NU; 26 | RAR_MEM_BLK* next, * prev; 27 | void insertAt(RAR_MEM_BLK* p) 28 | { 29 | next=(prev=p)->next; 30 | p->next=next->prev=this; 31 | } 32 | void remove() 33 | { 34 | prev->next=next; 35 | next->prev=prev; 36 | } 37 | } _PACK_ATTR; 38 | 39 | #ifndef STRICT_ALIGNMENT_REQUIRED 40 | #ifdef _AIX 41 | #pragma pack(pop) 42 | #else 43 | #pragma pack() 44 | #endif 45 | #endif 46 | 47 | 48 | struct RAR_NODE 49 | { 50 | RAR_NODE* next; 51 | }; 52 | 53 | class SubAllocator 54 | { 55 | private: 56 | inline void InsertNode(void* p,int indx); 57 | inline void* RemoveNode(int indx); 58 | inline uint U2B(int NU); 59 | inline void SplitBlock(void* pv,int OldIndx,int NewIndx); 60 | uint GetUsedMemory(); 61 | inline void GlueFreeBlocks(); 62 | void* AllocUnitsRare(int indx); 63 | inline RAR_MEM_BLK* MBPtr(RAR_MEM_BLK *BasePtr,int Items); 64 | 65 | long SubAllocatorSize; 66 | byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount; 67 | byte *HeapStart,*LoUnit, *HiUnit; 68 | struct RAR_NODE FreeList[N_INDEXES]; 69 | public: 70 | SubAllocator(); 71 | ~SubAllocator() {StopSubAllocator();} 72 | void Clean(); 73 | bool StartSubAllocator(int SASize); 74 | void StopSubAllocator(); 75 | void InitSubAllocator(); 76 | inline void* AllocContext(); 77 | inline void* AllocUnits(int NU); 78 | inline void* ExpandUnits(void* ptr,int OldNU); 79 | inline void* ShrinkUnits(void* ptr,int OldNU,int NewNU); 80 | inline void FreeUnits(void* ptr,int OldNU); 81 | long GetAllocatedMemory() {return(SubAllocatorSize);}; 82 | 83 | byte *pText, *UnitsStart,*HeapEnd,*FakeUnitsStart; 84 | }; 85 | 86 | 87 | #endif /* !defined(_SUBALLOC_H_) */ 88 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/system.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #ifndef _WIN_CE 4 | static int SleepTime=0; 5 | 6 | void InitSystemOptions(int SleepTime) 7 | { 8 | ::SleepTime=SleepTime; 9 | } 10 | #endif 11 | 12 | 13 | #if !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(SETUP) 14 | void SetPriority(int Priority) 15 | { 16 | #ifdef _WIN_ALL 17 | uint PriorityClass; 18 | int PriorityLevel; 19 | if (Priority<1 || Priority>15) 20 | return; 21 | 22 | if (Priority==1) 23 | { 24 | PriorityClass=IDLE_PRIORITY_CLASS; 25 | PriorityLevel=THREAD_PRIORITY_IDLE; 26 | } 27 | else 28 | if (Priority<7) 29 | { 30 | PriorityClass=IDLE_PRIORITY_CLASS; 31 | PriorityLevel=Priority-4; 32 | } 33 | else 34 | if (Priority==7) 35 | { 36 | PriorityClass=BELOW_NORMAL_PRIORITY_CLASS; 37 | PriorityLevel=THREAD_PRIORITY_ABOVE_NORMAL; 38 | } 39 | else 40 | if (Priority<10) 41 | { 42 | PriorityClass=NORMAL_PRIORITY_CLASS; 43 | PriorityLevel=Priority-7; 44 | } 45 | else 46 | if (Priority==10) 47 | { 48 | PriorityClass=ABOVE_NORMAL_PRIORITY_CLASS; 49 | PriorityLevel=THREAD_PRIORITY_NORMAL; 50 | } 51 | else 52 | { 53 | PriorityClass=HIGH_PRIORITY_CLASS; 54 | PriorityLevel=Priority-13; 55 | } 56 | SetPriorityClass(GetCurrentProcess(),PriorityClass); 57 | SetThreadPriority(GetCurrentThread(),PriorityLevel); 58 | 59 | // Background mode for Vista, too slow for real life use. 60 | // if (WinNT()>=WNT_VISTA && Priority==1) 61 | // SetPriorityClass(GetCurrentProcess(),PROCESS_MODE_BACKGROUND_BEGIN); 62 | 63 | #endif 64 | } 65 | #endif 66 | 67 | 68 | #ifndef SETUP 69 | void Wait() 70 | { 71 | #if defined(_WIN_ALL) && !defined(_WIN_CE) && !defined(SFX_MODULE) 72 | if (SleepTime!=0) 73 | Sleep(SleepTime); 74 | #endif 75 | } 76 | #endif 77 | 78 | 79 | 80 | 81 | #if defined(_WIN_ALL) && !defined(_WIN_CE) && !defined(SFX_MODULE) && !defined(SHELL_EXT) && !defined(SETUP) 82 | void Shutdown() 83 | { 84 | HANDLE hToken; 85 | TOKEN_PRIVILEGES tkp; 86 | if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken)) 87 | { 88 | LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid); 89 | tkp.PrivilegeCount = 1; 90 | tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 91 | 92 | AdjustTokenPrivileges(hToken,FALSE,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0); 93 | } 94 | ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE|EWX_POWEROFF,SHTDN_REASON_FLAG_PLANNED); 95 | } 96 | #endif 97 | 98 | 99 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/system.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SYSTEM_ 2 | #define _RAR_SYSTEM_ 3 | 4 | #ifdef _WIN_ALL 5 | #ifndef BELOW_NORMAL_PRIORITY_CLASS 6 | #define BELOW_NORMAL_PRIORITY_CLASS 0x00004000 7 | #define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000 8 | #endif 9 | #ifndef PROCESS_MODE_BACKGROUND_BEGIN 10 | #define PROCESS_MODE_BACKGROUND_BEGIN 0x00100000 11 | #define PROCESS_MODE_BACKGROUND_END 0x00200000 12 | #endif 13 | #ifndef SHTDN_REASON_MAJOR_APPLICATION 14 | #define SHTDN_REASON_MAJOR_APPLICATION 0x00040000 15 | #define SHTDN_REASON_FLAG_PLANNED 0x80000000 16 | #define SHTDN_REASON_MINOR_MAINTENANCE 0x00000001 17 | #endif 18 | #endif 19 | 20 | void InitSystemOptions(int SleepTime); 21 | void SetPriority(int Priority); 22 | void Wait(); 23 | bool EmailFile(char *FileName,char *MailTo); 24 | void Shutdown(); 25 | 26 | 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/timefn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_TIMEFN_ 2 | #define _RAR_TIMEFN_ 3 | 4 | struct RarLocalTime 5 | { 6 | uint Year; 7 | uint Month; 8 | uint Day; 9 | uint Hour; 10 | uint Minute; 11 | uint Second; 12 | uint Reminder; // Part of time smaller than 1 second, represented in 100-nanosecond intervals. 13 | uint wDay; 14 | uint yDay; 15 | }; 16 | 17 | 18 | class RarTime 19 | { 20 | private: 21 | RarLocalTime rlt; 22 | public: 23 | RarTime(); 24 | #ifdef _WIN_ALL 25 | RarTime& operator =(FILETIME &ft); 26 | void GetWin32(FILETIME *ft); 27 | #endif 28 | #if defined(_UNIX) || defined(_EMX) 29 | RarTime& operator =(time_t ut); 30 | time_t GetUnix(); 31 | #endif 32 | bool operator == (RarTime &rt); 33 | bool operator < (RarTime &rt); 34 | bool operator <= (RarTime &rt); 35 | bool operator > (RarTime &rt); 36 | bool operator >= (RarTime &rt); 37 | void GetLocal(RarLocalTime *lt) {*lt=rlt;} 38 | void SetLocal(RarLocalTime *lt) {rlt=*lt;} 39 | int64 GetRaw(); 40 | void SetRaw(int64 RawTime); 41 | uint GetDos(); 42 | void SetDos(uint DosTime); 43 | void GetText(char *DateStr,bool FullYear); 44 | void SetIsoText(char *TimeText); 45 | void SetAgeText(char *TimeText); 46 | void SetCurrentTime(); 47 | void Reset() {rlt.Year=0;} 48 | bool IsSet() {return(rlt.Year!=0);} 49 | }; 50 | 51 | const char *GetMonthName(int Month); 52 | bool IsLeapYear(int Year); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/ulinks.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | 4 | 5 | bool ExtractLink(ComprDataIO &DataIO,Archive &Arc,const char *LinkName,uint &LinkCRC,bool Create) 6 | { 7 | #if defined(SAVE_LINKS) && defined(_UNIX) 8 | char LinkTarget[NM]; 9 | if (IsLink(Arc.NewLhd.FileAttr)) 10 | { 11 | int DataSize=Min(Arc.NewLhd.PackSize,sizeof(LinkTarget)-1); 12 | DataIO.UnpRead((byte *)LinkTarget,DataSize); 13 | LinkTarget[DataSize]=0; 14 | if (Create) 15 | { 16 | CreatePath(LinkName,NULL,true); 17 | if (symlink(LinkTarget,LinkName)==-1) // Error. 18 | if (errno==EEXIST) 19 | Log(Arc.FileName,St(MSymLinkExists),LinkName); 20 | else 21 | { 22 | Log(Arc.FileName,St(MErrCreateLnk),LinkName); 23 | ErrHandler.SetErrorCode(WARNING); 24 | } 25 | // We do not set time of created symlink, because utime changes 26 | // time of link target and lutimes is not available on all Linux 27 | // systems at the moment of writing this code. 28 | } 29 | int NameSize=Min(DataSize,strlen(LinkTarget)); 30 | LinkCRC=CRC(0xffffffff,LinkTarget,NameSize); 31 | return(true); 32 | } 33 | #endif 34 | return(false); 35 | } 36 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/ulinks.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_ULINKS_ 2 | #define _RAR_ULINKS_ 3 | 4 | void SaveLinkData(ComprDataIO &DataIO,Archive &TempArc,FileHeader &hd, 5 | const char *Name); 6 | bool ExtractLink(ComprDataIO &DataIO,Archive &Arc,const char *LinkName, 7 | uint &LinkCRC,bool Create); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/unicode.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_UNICODE_ 2 | #define _RAR_UNICODE_ 3 | 4 | #ifndef _EMX 5 | #define MBFUNCTIONS 6 | #endif 7 | 8 | #if defined(MBFUNCTIONS) || defined(_WIN_ALL) || defined(_EMX) && !defined(_DJGPP) 9 | #define UNICODE_SUPPORTED 10 | #endif 11 | 12 | #if !defined(SFX_MODULE) && (defined(_MSC_VER) || defined(__BORLANDC__)) 13 | // If C_UNICODE_RTL is defined, we can use library Unicode functions like 14 | // wcscpy. Otherwise, for compatibility with old compilers or for removing 15 | // RTL to reduce SFX module size, we need need to use our own implementations. 16 | #define C_UNICODE_RTL 17 | #endif 18 | 19 | #ifdef _WIN_ALL 20 | #define DBCS_SUPPORTED 21 | #endif 22 | 23 | #ifdef _EMX 24 | int uni_init(int codepage); 25 | int uni_done(); 26 | #endif 27 | 28 | #ifdef __BORLANDC__ 29 | // Borland C++ Builder 5 uses the old style swprintf without the buffer size, 30 | // so we replace it with snwprintf in our custom sprintfw definition. 31 | #define sprintfw snwprintf 32 | #elif defined (__OpenBSD__) 33 | #define sprintfw(s,...) *(s)=0 34 | #else 35 | #define sprintfw swprintf 36 | #endif 37 | 38 | bool WideToChar(const wchar *Src,char *Dest,size_t DestSize=0x1000000); 39 | bool CharToWide(const char *Src,wchar *Dest,size_t DestSize=0x1000000); 40 | byte* WideToRaw(const wchar *Src,byte *Dest,size_t SrcSize=0x1000000); 41 | wchar* RawToWide(const byte *Src,wchar *Dest,size_t DestSize=0x1000000); 42 | void WideToUtf(const wchar *Src,char *Dest,size_t DestSize); 43 | void UtfToWide(const char *Src,wchar *Dest,size_t DestSize); 44 | bool UnicodeEnabled(); 45 | 46 | int wcsicomp(const wchar *s1,const wchar *s2); 47 | int wcsnicomp(const wchar *s1,const wchar *s2,size_t n); 48 | wchar* wcslower(wchar *Str); 49 | wchar* wcsupper(wchar *Str); 50 | int toupperw(int ch); 51 | int atoiw(const wchar *s); 52 | 53 | #ifdef DBCS_SUPPORTED 54 | class SupportDBCS 55 | { 56 | public: 57 | SupportDBCS(); 58 | void Init(); 59 | 60 | char* charnext(const char *s); 61 | size_t strlend(const char *s); 62 | char *strchrd(const char *s, int c); 63 | char *strrchrd(const char *s, int c); 64 | void copychrd(char *dest,const char *src); 65 | 66 | bool IsLeadByte[256]; 67 | bool DBCSMode; 68 | }; 69 | 70 | extern SupportDBCS gdbcs; 71 | 72 | inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);} 73 | inline size_t strlend(const char *s) {return (uint)(gdbcs.DBCSMode ? gdbcs.strlend(s):strlen(s));} 74 | inline char* strchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strchrd(s,c):strchr(s,c));} 75 | inline char* strrchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strrchrd(s,c):strrchr(s,c));} 76 | inline void copychrd(char *dest,const char *src) {if (gdbcs.DBCSMode) gdbcs.copychrd(dest,src); else *dest=*src;} 77 | inline bool IsDBCSMode() {return(gdbcs.DBCSMode);} 78 | inline void InitDBCS() {gdbcs.Init();} 79 | 80 | #else 81 | #define charnext(s) ((s)+1) 82 | #define strlend strlen 83 | #define strchrd strchr 84 | #define strrchrd strrchr 85 | #define IsDBCSMode() (true) 86 | inline void copychrd(char *dest,const char *src) {*dest=*src;} 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/unios2.cpp: -------------------------------------------------------------------------------- 1 | // (c) 2001,2004 by Max Alekseyev 2 | // ver. 2.1 3 | 4 | #include 5 | 6 | #define INCL_DOSMODULEMGR 7 | #include 8 | 9 | typedef void* UconvObject; 10 | typedef unsigned short UniChar; 11 | 12 | int uni_init(int codepage); 13 | 14 | int uni_done(); 15 | 16 | int uni_toucs( /* translate to Unicode */ 17 | char*, /* I - input string */ 18 | size_t, /* I - length of input string (chars) */ 19 | UniChar*, /* O - output Unicode string */ 20 | size_t* ); /* O - length of output string (UniChars) */ 21 | 22 | int uni_fromucs( /* translate from Unicode */ 23 | UniChar*, /* I - input Unicode string */ 24 | size_t, /* I - length of input string (UniChars) */ 25 | char*, /* O - output string */ 26 | size_t* ); /* O - length of output string (chars) */ 27 | 28 | /* IMPLEMENTATION */ 29 | 30 | static int (*uniMapCpToUcsCp) ( 31 | unsigned long, /* I - Codepage to convert */ 32 | UniChar*, /* O - Output buffer */ 33 | size_t ); /* I - UniChars in output buffer */ 34 | 35 | static int (*uniCreateUconvObject) ( 36 | UniChar*, /* I - Unicode name of uconv table */ 37 | UconvObject* );/* O - Uconv object handle */ 38 | 39 | static int (*uniFreeUconvObject) ( 40 | UconvObject ); /* I - Uconv object handle */ 41 | 42 | static int (*uniUconvToUcs) ( 43 | UconvObject, /* I - Uconv object handle */ 44 | void**, /* IO - Input buffer */ 45 | size_t*, /* IO - Input buffer size (bytes) */ 46 | UniChar**, /* IO - Output buffer size */ 47 | size_t*, /* IO - Output size (chars) */ 48 | size_t* ); /* IO - Substitution count */ 49 | 50 | static int (*uniUconvFromUcs) ( 51 | UconvObject, /* I - Uconv object handle */ 52 | UniChar**, /* IO - Input buffer */ 53 | size_t*, /* IO - Input buffer size (bytes) */ 54 | void**, /* IO - Output buffer size */ 55 | size_t*, /* IO - Output size (chars) */ 56 | size_t* ); /* IO - Substitution count */ 57 | 58 | static int uni_ready = 0; 59 | static HMODULE uni_UCONV; 60 | static UconvObject uni_obj; 61 | 62 | int uni_init(int codepage) { 63 | UniChar unistr[256]; 64 | 65 | uni_ready = 0; 66 | 67 | if(!&DosLoadModule) { 68 | /* DOS enviroment detected */ 69 | return -1; 70 | } 71 | 72 | if( DosLoadModule(0,0,(PCSZ)"UCONV",&uni_UCONV) ) { 73 | /* no Unicode API found (obsolete OS/2 version) */ 74 | return -2; 75 | } 76 | 77 | if( !DosQueryProcAddr(uni_UCONV,0,(PCSZ)"UniMapCpToUcsCp", (PPFN)&uniMapCpToUcsCp ) && 78 | !DosQueryProcAddr(uni_UCONV,0,(PCSZ)"UniUconvToUcs", (PPFN)&uniUconvToUcs ) && 79 | !DosQueryProcAddr(uni_UCONV,0,(PCSZ)"UniUconvFromUcs", (PPFN)&uniUconvFromUcs ) && 80 | !DosQueryProcAddr(uni_UCONV,0,(PCSZ)"UniCreateUconvObject",(PPFN)&uniCreateUconvObject) && 81 | !DosQueryProcAddr(uni_UCONV,0,(PCSZ)"UniFreeUconvObject", (PPFN)&uniFreeUconvObject ) 82 | ) { 83 | unistr[0] = 0; 84 | if( (!codepage || !uniMapCpToUcsCp(codepage, unistr, 256)) && !uniCreateUconvObject(unistr,&uni_obj) ) { 85 | uni_ready = 1; 86 | return 0; 87 | } 88 | } 89 | DosFreeModule(uni_UCONV); 90 | return -2; 91 | } 92 | 93 | int uni_toucs(char* src, size_t srclen, UniChar* dst, size_t* dstlen) { 94 | size_t srcbytes, srcsize, dstsize, subsc=0; 95 | 96 | if(!uni_ready) return -1; 97 | 98 | dstsize = srcbytes = srclen * sizeof(UniChar); 99 | 100 | if( uniUconvToUcs(uni_obj,(void**)&src,&srclen,&dst,&dstsize,&subsc) ) { 101 | return -1; 102 | } 103 | *dstlen = srcbytes - dstsize; 104 | return 0; 105 | } 106 | 107 | int uni_fromucs(UniChar* src, size_t srclen, char* dst, size_t* dstlen) { 108 | size_t srcbytes, srcsize, dstsize, subsc=0; 109 | 110 | if(!uni_ready) return -1; 111 | 112 | dstsize = srcbytes = *dstlen; 113 | 114 | if( uniUconvFromUcs(uni_obj,&src,&srclen,(void**)&dst,&dstsize,&subsc) ) { 115 | return -1; 116 | } 117 | *dstlen = srcbytes - dstsize; 118 | return 0; 119 | } 120 | 121 | int uni_done() { 122 | if( uni_ready ) { 123 | uniFreeUconvObject(uni_obj); 124 | DosFreeModule(uni_UCONV); 125 | uni_ready = 0; 126 | } 127 | return 0; 128 | } 129 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/unpack.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_UNPACK_ 2 | #define _RAR_UNPACK_ 3 | 4 | enum BLOCK_TYPES {BLOCK_LZ,BLOCK_PPM}; 5 | 6 | // Maximum allowed number of compressed bits processed in quick mode. 7 | #define MAX_QUICK_DECODE_BITS 10 8 | 9 | // Decode compressed bit fields to alphabet numbers. 10 | struct DecodeTable 11 | { 12 | // Real size of DecodeNum table. 13 | uint MaxNum; 14 | 15 | // Left aligned start and upper limit codes defining code space 16 | // ranges for bit lengths. DecodeLen[BitLength-1] defines the start of 17 | // range for bit length and DecodeLen[BitLength] defines next code 18 | // after the end of range or in other words the upper limit code 19 | // for specified bit length. 20 | uint DecodeLen[16]; 21 | 22 | // Every item of this array contains the sum of all preceding items. 23 | // So it contains the start position in code list for every bit length. 24 | uint DecodePos[16]; 25 | 26 | // Number of compressed bits processed in quick mode. 27 | // Must not exceed MAX_QUICK_DECODE_BITS. 28 | uint QuickBits; 29 | 30 | // Translates compressed bits (up to QuickBits length) 31 | // to bit length in quick mode. 32 | byte QuickLen[1< Filters; 112 | 113 | // Filters stack, several entrances of same filter are possible. 114 | Array PrgStack; 115 | 116 | // Lengths of preceding data blocks, one length of one last block 117 | // for every filter. Used to reduce the size required to write 118 | // the data block length if lengths are repeating. 119 | Array OldFilterLengths; 120 | 121 | int LastFilter; 122 | 123 | bool TablesRead; 124 | 125 | DecodeTable LD; // Decode literals. 126 | DecodeTable DD; // Decode distances. 127 | DecodeTable LDD; // Decode lower bits of distances. 128 | DecodeTable RD; // Decode repeating distances. 129 | DecodeTable BD; // Decod bit lengths in Huffman table. 130 | 131 | unsigned int OldDist[4],OldDistPtr; 132 | unsigned int LastDist,LastLength; 133 | 134 | unsigned int UnpPtr,WrPtr; 135 | 136 | // Top border of read packed data. 137 | int ReadTop; 138 | 139 | // Border to call UnpReadBuf. We use it instead of (ReadTop-C) 140 | // for optimization reasons. Ensures that we have C bytes in buffer 141 | // unless we are at the end of file. 142 | int ReadBorder; 143 | 144 | unsigned char UnpOldTable[HUFF_TABLE_SIZE]; 145 | 146 | int UnpBlockType; 147 | 148 | byte *Window; 149 | bool ExternalWindow; 150 | 151 | 152 | int64 DestUnpSize; 153 | 154 | bool Suspended; 155 | bool UnpAllBuf; 156 | bool UnpSomeRead; 157 | int64 WrittenFileSize; 158 | bool FileExtracted; 159 | 160 | int PrevLowDist,LowDistRepCount; 161 | 162 | /***************************** Unpack v 1.5 *********************************/ 163 | void Unpack15(bool Solid); 164 | void ShortLZ(); 165 | void LongLZ(); 166 | void HuffDecode(); 167 | void GetFlagsBuf(); 168 | void OldUnpInitData(int Solid); 169 | void InitHuff(); 170 | void CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace); 171 | void OldCopyString(unsigned int Distance,unsigned int Length); 172 | uint DecodeNum(uint Num,uint StartPos,uint *DecTab,uint *PosTab); 173 | void OldUnpWriteBuf(); 174 | 175 | unsigned int ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256]; 176 | unsigned int Place[256],PlaceA[256],PlaceB[256],PlaceC[256]; 177 | unsigned int NToPl[256],NToPlB[256],NToPlC[256]; 178 | unsigned int FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3; 179 | int Buf60,NumHuf,StMode,LCount,FlagsCnt; 180 | unsigned int Nhfb,Nlzb,MaxDist3; 181 | /***************************** Unpack v 1.5 *********************************/ 182 | 183 | /***************************** Unpack v 2.0 *********************************/ 184 | void Unpack20(bool Solid); 185 | 186 | DecodeTable MD[4]; // Decode multimedia data, up to 4 channels. 187 | 188 | unsigned char UnpOldTable20[MC20*4]; 189 | int UnpAudioBlock,UnpChannels,UnpCurChannel,UnpChannelDelta; 190 | void CopyString20(unsigned int Length,unsigned int Distance); 191 | bool ReadTables20(); 192 | void UnpInitData20(int Solid); 193 | void ReadLastTables(); 194 | byte DecodeAudio(int Delta); 195 | struct AudioVariables AudV[4]; 196 | /***************************** Unpack v 2.0 *********************************/ 197 | 198 | public: 199 | Unpack(ComprDataIO *DataIO); 200 | ~Unpack(); 201 | void Init(byte *Window=NULL); 202 | void DoUnpack(int Method,bool Solid); 203 | bool IsFileExtracted() {return(FileExtracted);} 204 | void SetDestSize(int64 DestSize) {DestUnpSize=DestSize;FileExtracted=false;} 205 | void SetSuspended(bool Suspended) {Unpack::Suspended=Suspended;} 206 | 207 | unsigned int GetChar() 208 | { 209 | if (InAddr>BitInput::MAX_SIZE-30) 210 | UnpReadBuf(); 211 | return(InBuf[InAddr++]); 212 | } 213 | }; 214 | 215 | #endif 216 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/uowners.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | void ExtractUnixOwner(Archive &Arc,char *FileName) 4 | { 5 | if (Arc.HeaderCRC!=Arc.UOHead.HeadCRC) 6 | { 7 | Log(Arc.FileName,St(MOwnersBroken),FileName); 8 | ErrHandler.SetErrorCode(CRC_ERROR); 9 | return; 10 | } 11 | 12 | struct passwd *pw; 13 | if ((pw=getpwnam(Arc.UOHead.OwnerName))==NULL) 14 | { 15 | Log(Arc.FileName,St(MErrGetOwnerID),Arc.UOHead.OwnerName); 16 | ErrHandler.SetErrorCode(WARNING); 17 | return; 18 | } 19 | uid_t OwnerID=pw->pw_uid; 20 | 21 | struct group *gr; 22 | if ((gr=getgrnam(Arc.UOHead.GroupName))==NULL) 23 | { 24 | Log(Arc.FileName,St(MErrGetGroupID),Arc.UOHead.GroupName); 25 | ErrHandler.SetErrorCode(CRC_ERROR); 26 | return; 27 | } 28 | uint Attr=GetFileAttr(FileName,NULL); 29 | gid_t GroupID=gr->gr_gid; 30 | #if defined(SAVE_LINKS) && !defined(_APPLE) 31 | if (lchown(FileName,OwnerID,GroupID)!=0) 32 | #else 33 | if (chown(FileName,OwnerID,GroupID)!=0) 34 | #endif 35 | { 36 | Log(Arc.FileName,St(MSetOwnersError),FileName); 37 | ErrHandler.SetErrorCode(CREATE_ERROR); 38 | } 39 | SetFileAttr(FileName,NULL,Attr); 40 | } 41 | 42 | 43 | void ExtractUnixOwnerNew(Archive &Arc,char *FileName) 44 | { 45 | char *OwnerName=(char *)&Arc.SubHead.SubData[0]; 46 | int OwnerSize=strlen(OwnerName)+1; 47 | int GroupSize=Arc.SubHead.SubData.Size()-OwnerSize; 48 | char GroupName[NM]; 49 | strncpy(GroupName,(char *)&Arc.SubHead.SubData[OwnerSize],GroupSize); 50 | GroupName[GroupSize]=0; 51 | 52 | struct passwd *pw; 53 | if ((pw=getpwnam(OwnerName))==NULL) 54 | { 55 | Log(Arc.FileName,St(MErrGetOwnerID),OwnerName); 56 | ErrHandler.SetErrorCode(WARNING); 57 | return; 58 | } 59 | uid_t OwnerID=pw->pw_uid; 60 | 61 | struct group *gr; 62 | if ((gr=getgrnam(GroupName))==NULL) 63 | { 64 | Log(Arc.FileName,St(MErrGetGroupID),GroupName); 65 | ErrHandler.SetErrorCode(CRC_ERROR); 66 | return; 67 | } 68 | uint Attr=GetFileAttr(FileName,NULL); 69 | gid_t GroupID=gr->gr_gid; 70 | #if defined(SAVE_LINKS) && !defined(_APPLE) 71 | if (lchown(FileName,OwnerID,GroupID)!=0) 72 | #else 73 | if (chown(FileName,OwnerID,GroupID)!=0) 74 | #endif 75 | { 76 | Log(Arc.FileName,St(MSetOwnersError),FileName); 77 | ErrHandler.SetErrorCode(CREATE_ERROR); 78 | } 79 | SetFileAttr(FileName,NULL,Attr); 80 | } 81 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/version.hpp: -------------------------------------------------------------------------------- 1 | #define RARVER_MAJOR 4 2 | #define RARVER_MINOR 0 3 | #define RARVER_BETA 0 4 | #define RARVER_DAY 2 5 | #define RARVER_MONTH 3 6 | #define RARVER_YEAR 2011 7 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/volume.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | 4 | 5 | 6 | #if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64) 7 | // Disable the run time stack check for unrar.dll, so we can manipulate 8 | // with ChangeVolProc call type below. Run time check would intercept 9 | // a wrong ESP before we restore it. 10 | #pragma runtime_checks( "s", off ) 11 | #endif 12 | 13 | bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Command) 14 | { 15 | RAROptions *Cmd=Arc.GetRAROptions(); 16 | 17 | int HeaderType=Arc.GetHeaderType(); 18 | FileHeader *hd=HeaderType==NEWSUB_HEAD ? &Arc.SubHead:&Arc.NewLhd; 19 | bool SplitHeader=(HeaderType==FILE_HEAD || HeaderType==NEWSUB_HEAD) && 20 | (hd->Flags & LHD_SPLIT_AFTER)!=0; 21 | 22 | if (DataIO!=NULL && SplitHeader && hd->UnpVer>=20 && 23 | hd->FileCRC!=0xffffffff && DataIO->PackedCRC!=~hd->FileCRC) 24 | { 25 | Log(Arc.FileName,St(MDataBadCRC),hd->FileName,Arc.FileName); 26 | } 27 | 28 | int64 PosBeforeClose=Arc.Tell(); 29 | 30 | if (DataIO!=NULL) 31 | DataIO->ProcessedArcSize+=Arc.FileLength(); 32 | 33 | Arc.Close(); 34 | 35 | char NextName[NM]; 36 | wchar NextNameW[NM]; 37 | strcpy(NextName,Arc.FileName); 38 | wcscpy(NextNameW,Arc.FileNameW); 39 | NextVolumeName(NextName,NextNameW,ASIZE(NextName),(Arc.NewMhd.Flags & MHD_NEWNUMBERING)==0 || Arc.OldFormat); 40 | 41 | #if !defined(SFX_MODULE) && !defined(RARDLL) 42 | bool RecoveryDone=false; 43 | #endif 44 | bool FailedOpen=false,OldSchemeTested=false; 45 | 46 | while (!Arc.Open(NextName,NextNameW)) 47 | { 48 | // We need to open a new volume which size was not calculated 49 | // in total size before, so we cannot calculate the total progress 50 | // anymore. Let's reset the total size to zero and stop 51 | // the total progress. 52 | if (DataIO!=NULL) 53 | DataIO->TotalArcSize=0; 54 | 55 | if (!OldSchemeTested) 56 | { 57 | // Checking for new style volumes renamed by user to old style 58 | // name format. Some users did it for unknown reason. 59 | char AltNextName[NM]; 60 | wchar AltNextNameW[NM]; 61 | strcpy(AltNextName,Arc.FileName); 62 | wcscpy(AltNextNameW,Arc.FileNameW); 63 | NextVolumeName(AltNextName,AltNextNameW,ASIZE(AltNextName),true); 64 | OldSchemeTested=true; 65 | if (Arc.Open(AltNextName,AltNextNameW)) 66 | { 67 | strcpy(NextName,AltNextName); 68 | wcscpy(NextNameW,AltNextNameW); 69 | break; 70 | } 71 | } 72 | #ifdef RARDLL 73 | if (Cmd->Callback==NULL && Cmd->ChangeVolProc==NULL || 74 | Cmd->Callback!=NULL && Cmd->Callback(UCM_CHANGEVOLUME,Cmd->UserData,(LPARAM)NextName,RAR_VOL_ASK)==-1) 75 | { 76 | Cmd->DllError=ERAR_EOPEN; 77 | FailedOpen=true; 78 | break; 79 | } 80 | if (Cmd->ChangeVolProc!=NULL) 81 | { 82 | // Here we preserve ESP value. It is necessary for those developers, 83 | // who still define ChangeVolProc callback as "C" type function, 84 | // even though in year 2001 we announced in unrar.dll whatsnew.txt 85 | // that it will be PASCAL type (for compatibility with Visual Basic). 86 | #if defined(_MSC_VER) 87 | #ifndef _WIN_64 88 | __asm mov ebx,esp 89 | #endif 90 | #elif defined(_WIN_ALL) && defined(__BORLANDC__) 91 | _EBX=_ESP; 92 | #endif 93 | int RetCode=Cmd->ChangeVolProc(NextName,RAR_VOL_ASK); 94 | 95 | // Restore ESP after ChangeVolProc with wrongly defined calling 96 | // convention broken it. 97 | #if defined(_MSC_VER) 98 | #ifndef _WIN_64 99 | __asm mov esp,ebx 100 | #endif 101 | #elif defined(_WIN_ALL) && defined(__BORLANDC__) 102 | _ESP=_EBX; 103 | #endif 104 | if (RetCode==0) 105 | { 106 | Cmd->DllError=ERAR_EOPEN; 107 | FailedOpen=true; 108 | break; 109 | } 110 | } 111 | #else // RARDLL 112 | 113 | #if !defined(SFX_MODULE) && !defined(_WIN_CE) 114 | if (!RecoveryDone) 115 | { 116 | RecVolumes RecVol; 117 | RecVol.Restore(Cmd,Arc.FileName,Arc.FileNameW,true); 118 | RecoveryDone=true; 119 | continue; 120 | } 121 | #endif 122 | 123 | #ifndef GUI 124 | if (!Cmd->VolumePause && !IsRemovable(NextName)) 125 | { 126 | FailedOpen=true; 127 | break; 128 | } 129 | #endif 130 | #ifndef SILENT 131 | if (Cmd->AllYes || !AskNextVol(NextName,NextNameW)) 132 | #endif 133 | { 134 | FailedOpen=true; 135 | break; 136 | } 137 | 138 | #endif // RARDLL 139 | } 140 | if (FailedOpen) 141 | { 142 | #if !defined(SILENT) && !defined(_WIN_CE) 143 | Log(Arc.FileName,St(MAbsNextVol),NextName); 144 | #endif 145 | Arc.Open(Arc.FileName,Arc.FileNameW); 146 | Arc.Seek(PosBeforeClose,SEEK_SET); 147 | return(false); 148 | } 149 | Arc.CheckArc(true); 150 | #ifdef RARDLL 151 | if (Cmd->Callback!=NULL && 152 | Cmd->Callback(UCM_CHANGEVOLUME,Cmd->UserData,(LPARAM)NextName,RAR_VOL_NOTIFY)==-1) 153 | return(false); 154 | if (Cmd->ChangeVolProc!=NULL) 155 | { 156 | #if defined(_WIN_ALL) && !defined(_MSC_VER) && !defined(__MINGW32__) 157 | _EBX=_ESP; 158 | #endif 159 | int RetCode=Cmd->ChangeVolProc(NextName,RAR_VOL_NOTIFY); 160 | #if defined(_WIN_ALL) && !defined(_MSC_VER) && !defined(__MINGW32__) 161 | _ESP=_EBX; 162 | #endif 163 | if (RetCode==0) 164 | return(false); 165 | } 166 | #endif 167 | 168 | if (Command=='T' || Command=='X' || Command=='E') 169 | mprintf(St(Command=='T' ? MTestVol:MExtrVol),Arc.FileName); 170 | if (SplitHeader) 171 | Arc.SearchBlock(HeaderType); 172 | else 173 | Arc.ReadHeader(); 174 | if (Arc.GetHeaderType()==FILE_HEAD) 175 | { 176 | Arc.ConvertAttributes(); 177 | Arc.Seek(Arc.NextBlockPos-Arc.NewLhd.FullPackSize,SEEK_SET); 178 | } 179 | #ifndef GUI 180 | if (ShowFileName) 181 | { 182 | char OutName[NM]; 183 | IntToExt(Arc.NewLhd.FileName,OutName); 184 | #ifdef UNICODE_SUPPORTED 185 | bool WideName=(Arc.NewLhd.Flags & LHD_UNICODE) && UnicodeEnabled(); 186 | if (WideName) 187 | { 188 | wchar NameW[NM]; 189 | ConvertPath(Arc.NewLhd.FileNameW,NameW); 190 | char Name[NM]; 191 | if (WideToChar(NameW,Name) && IsNameUsable(Name)) 192 | strcpy(OutName,Name); 193 | } 194 | #endif 195 | mprintf(St(MExtrPoints),OutName); 196 | if (!Cmd->DisablePercentage) 197 | mprintf(" "); 198 | } 199 | #endif 200 | if (DataIO!=NULL) 201 | { 202 | if (HeaderType==ENDARC_HEAD) 203 | DataIO->UnpVolume=false; 204 | else 205 | { 206 | DataIO->UnpVolume=(hd->Flags & LHD_SPLIT_AFTER)!=0; 207 | DataIO->SetPackedSizeToRead(hd->FullPackSize); 208 | } 209 | #ifdef SFX_MODULE 210 | DataIO->UnpArcSize=Arc.FileLength(); 211 | #endif 212 | 213 | // Reset the size of packed data read from current volume. It is used 214 | // to display the total progress and preceding volumes are already 215 | // compensated with ProcessedArcSize, so we need to reset this variable. 216 | DataIO->CurUnpRead=0; 217 | 218 | DataIO->PackedCRC=0xffffffff; 219 | // DataIO->SetFiles(&Arc,NULL); 220 | } 221 | return(true); 222 | } 223 | 224 | #if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64) 225 | // Restore the run time stack check for unrar.dll. 226 | #pragma runtime_checks( "s", restore ) 227 | #endif 228 | 229 | 230 | 231 | 232 | 233 | 234 | #ifndef SILENT 235 | bool AskNextVol(char *ArcName,wchar *ArcNameW) 236 | { 237 | eprintf(St(MAskNextVol),ArcName); 238 | if (Ask(St(MContinueQuit))==2) 239 | return(false); 240 | return(true); 241 | } 242 | #endif 243 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/volume.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_VOLUME_ 2 | #define _RAR_VOLUME_ 3 | 4 | void SplitArchive(Archive &Arc,FileHeader *fh,int64 *HeaderPos, 5 | ComprDataIO *DataIO); 6 | bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName, 7 | char Command); 8 | void SetVolWrite(Archive &Dest,int64 VolSize); 9 | bool AskNextVol(char *ArcName,wchar *ArcNameW); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/win32acl.cpp: -------------------------------------------------------------------------------- 1 | static void SetPrivileges(); 2 | 3 | static bool ReadSacl=false; 4 | 5 | 6 | 7 | #ifndef SFX_MODULE 8 | void ExtractACL(Archive &Arc,char *FileName,wchar *FileNameW) 9 | { 10 | if (!WinNT()) 11 | return; 12 | 13 | SetPrivileges(); 14 | 15 | if (Arc.HeaderCRC!=Arc.EAHead.HeadCRC) 16 | { 17 | Log(Arc.FileName,St(MACLBroken),FileName); 18 | ErrHandler.SetErrorCode(CRC_ERROR); 19 | return; 20 | } 21 | 22 | if (Arc.EAHead.Method<0x31 || Arc.EAHead.Method>0x35 || Arc.EAHead.UnpVer>PACK_VER) 23 | { 24 | Log(Arc.FileName,St(MACLUnknown),FileName); 25 | ErrHandler.SetErrorCode(WARNING); 26 | return; 27 | } 28 | 29 | ComprDataIO DataIO; 30 | Unpack Unpack(&DataIO); 31 | Unpack.Init(); 32 | 33 | Array UnpData(Arc.EAHead.UnpSize); 34 | DataIO.SetUnpackToMemory(&UnpData[0],Arc.EAHead.UnpSize); 35 | DataIO.SetPackedSizeToRead(Arc.EAHead.DataSize); 36 | DataIO.EnableShowProgress(false); 37 | DataIO.SetFiles(&Arc,NULL); 38 | Unpack.SetDestSize(Arc.EAHead.UnpSize); 39 | Unpack.DoUnpack(Arc.EAHead.UnpVer,false); 40 | 41 | if (Arc.EAHead.EACRC!=~DataIO.UnpFileCRC) 42 | { 43 | Log(Arc.FileName,St(MACLBroken),FileName); 44 | ErrHandler.SetErrorCode(CRC_ERROR); 45 | return; 46 | } 47 | 48 | SECURITY_INFORMATION si=OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION| 49 | DACL_SECURITY_INFORMATION; 50 | if (ReadSacl) 51 | si|=SACL_SECURITY_INFORMATION; 52 | SECURITY_DESCRIPTOR *sd=(SECURITY_DESCRIPTOR *)&UnpData[0]; 53 | 54 | int SetCode; 55 | if (FileNameW!=NULL) 56 | SetCode=SetFileSecurityW(FileNameW,si,sd); 57 | else 58 | SetCode=SetFileSecurityA(FileName,si,sd); 59 | 60 | if (!SetCode) 61 | { 62 | Log(Arc.FileName,St(MACLSetError),FileName); 63 | ErrHandler.SysErrMsg(); 64 | ErrHandler.SetErrorCode(WARNING); 65 | } 66 | } 67 | #endif 68 | 69 | 70 | void ExtractACLNew(Archive &Arc,char *FileName,wchar *FileNameW) 71 | { 72 | if (!WinNT()) 73 | return; 74 | 75 | Array SubData; 76 | if (!Arc.ReadSubData(&SubData,NULL)) 77 | return; 78 | 79 | SetPrivileges(); 80 | 81 | SECURITY_INFORMATION si=OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION| 82 | DACL_SECURITY_INFORMATION; 83 | if (ReadSacl) 84 | si|=SACL_SECURITY_INFORMATION; 85 | SECURITY_DESCRIPTOR *sd=(SECURITY_DESCRIPTOR *)&SubData[0]; 86 | 87 | int SetCode; 88 | if (FileNameW!=NULL) 89 | SetCode=SetFileSecurityW(FileNameW,si,sd); 90 | else 91 | SetCode=SetFileSecurityA(FileName,si,sd); 92 | 93 | if (!SetCode) 94 | { 95 | Log(Arc.FileName,St(MACLSetError),FileName); 96 | ErrHandler.SysErrMsg(); 97 | ErrHandler.SetErrorCode(WARNING); 98 | } 99 | } 100 | 101 | 102 | void SetPrivileges() 103 | { 104 | static bool InitDone=false; 105 | if (InitDone) 106 | return; 107 | InitDone=true; 108 | 109 | HANDLE hToken; 110 | 111 | if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) 112 | return; 113 | 114 | TOKEN_PRIVILEGES tp; 115 | tp.PrivilegeCount = 1; 116 | tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 117 | 118 | if (LookupPrivilegeValue(NULL,SE_SECURITY_NAME,&tp.Privileges[0].Luid)) 119 | if (AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL) && 120 | GetLastError() == ERROR_SUCCESS) 121 | ReadSacl=true; 122 | 123 | if (LookupPrivilegeValue(NULL,SE_RESTORE_NAME,&tp.Privileges[0].Luid)) 124 | AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL); 125 | 126 | CloseHandle(hToken); 127 | } 128 | -------------------------------------------------------------------------------- /3rd_party/unrar-4.0.7/win32stm.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ifndef SFX_MODULE 5 | void ExtractStreams(Archive &Arc,char *FileName,wchar *FileNameW) 6 | { 7 | if (!WinNT()) 8 | return; 9 | 10 | if (Arc.HeaderCRC!=Arc.StreamHead.HeadCRC) 11 | { 12 | #ifndef SILENT 13 | Log(Arc.FileName,St(MStreamBroken),FileName); 14 | #endif 15 | ErrHandler.SetErrorCode(CRC_ERROR); 16 | return; 17 | } 18 | 19 | if (Arc.StreamHead.Method<0x31 || Arc.StreamHead.Method>0x35 || Arc.StreamHead.UnpVer>PACK_VER) 20 | { 21 | #ifndef SILENT 22 | Log(Arc.FileName,St(MStreamUnknown),FileName); 23 | #endif 24 | ErrHandler.SetErrorCode(WARNING); 25 | return; 26 | } 27 | 28 | char StreamName[NM+2]; 29 | if (FileName[0]!=0 && FileName[1]==0) 30 | { 31 | strcpy(StreamName,".\\"); 32 | strcpy(StreamName+2,FileName); 33 | } 34 | else 35 | strcpy(StreamName,FileName); 36 | if (strlen(StreamName)+strlen((char *)Arc.StreamHead.StreamName)>=sizeof(StreamName) || 37 | Arc.StreamHead.StreamName[0]!=':') 38 | { 39 | #ifndef SILENT 40 | Log(Arc.FileName,St(MStreamBroken),FileName); 41 | #endif 42 | ErrHandler.SetErrorCode(CRC_ERROR); 43 | return; 44 | } 45 | 46 | ConvertPath((char *)Arc.StreamHead.StreamName+1,(char *)Arc.StreamHead.StreamName+1); 47 | 48 | strcat(StreamName,(char *)Arc.StreamHead.StreamName); 49 | 50 | FindData fd; 51 | bool Found=FindFile::FastFind(FileName,FileNameW,&fd); 52 | 53 | if (fd.FileAttr & FILE_ATTRIBUTE_READONLY) 54 | SetFileAttr(FileName,FileNameW,fd.FileAttr & ~FILE_ATTRIBUTE_READONLY); 55 | 56 | File CurFile; 57 | if (CurFile.WCreate(StreamName)) 58 | { 59 | ComprDataIO DataIO; 60 | Unpack Unpack(&DataIO); 61 | Unpack.Init(); 62 | 63 | Array UnpData(Arc.StreamHead.UnpSize); 64 | DataIO.SetPackedSizeToRead(Arc.StreamHead.DataSize); 65 | DataIO.EnableShowProgress(false); 66 | DataIO.SetFiles(&Arc,&CurFile); 67 | Unpack.SetDestSize(Arc.StreamHead.UnpSize); 68 | Unpack.DoUnpack(Arc.StreamHead.UnpVer,false); 69 | 70 | if (Arc.StreamHead.StreamCRC!=~DataIO.UnpFileCRC) 71 | { 72 | #ifndef SILENT 73 | Log(Arc.FileName,St(MStreamBroken),StreamName); 74 | #endif 75 | ErrHandler.SetErrorCode(CRC_ERROR); 76 | } 77 | else 78 | CurFile.Close(); 79 | } 80 | File HostFile; 81 | if (Found && HostFile.Open(FileName,FileNameW,true,true)) 82 | SetFileTime(HostFile.GetHandle(),&fd.ftCreationTime,&fd.ftLastAccessTime, 83 | &fd.ftLastWriteTime); 84 | if (fd.FileAttr & FILE_ATTRIBUTE_READONLY) 85 | SetFileAttr(FileName,FileNameW,fd.FileAttr); 86 | } 87 | #endif 88 | 89 | 90 | void ExtractStreamsNew(Archive &Arc,char *FileName,wchar *FileNameW) 91 | { 92 | if (!WinNT()) 93 | return; 94 | 95 | wchar NameW[NM]; 96 | if (FileNameW!=NULL && *FileNameW!=0) 97 | wcscpy(NameW,FileNameW); 98 | else 99 | CharToWide(FileName,NameW); 100 | wchar StreamNameW[NM+2]; 101 | if (NameW[0]!=0 && NameW[1]==0) 102 | { 103 | wcscpy(StreamNameW,L".\\"); 104 | wcscpy(StreamNameW+2,NameW); 105 | } 106 | else 107 | wcscpy(StreamNameW,NameW); 108 | 109 | wchar *DestName=StreamNameW+wcslen(StreamNameW); 110 | byte *SrcName=&Arc.SubHead.SubData[0]; 111 | size_t DestSize=Arc.SubHead.SubData.Size()/2; 112 | 113 | if (wcslen(StreamNameW)+DestSize>=ASIZE(StreamNameW)) 114 | { 115 | #if !defined(SILENT) && !defined(SFX_MODULE) 116 | Log(Arc.FileName,St(MStreamBroken),FileName); 117 | #endif 118 | ErrHandler.SetErrorCode(CRC_ERROR); 119 | return; 120 | } 121 | 122 | RawToWide(SrcName,DestName,DestSize); 123 | DestName[DestSize]=0; 124 | 125 | if (*DestName!=':') 126 | { 127 | #if !defined(SILENT) && !defined(SFX_MODULE) 128 | Log(Arc.FileName,St(MStreamBroken),FileName); 129 | #endif 130 | ErrHandler.SetErrorCode(CRC_ERROR); 131 | return; 132 | } 133 | 134 | ConvertPath(DestName+1,DestName+1); 135 | 136 | FindData fd; 137 | bool Found=FindFile::FastFind(FileName,FileNameW,&fd); 138 | 139 | if (fd.FileAttr & FILE_ATTRIBUTE_READONLY) 140 | SetFileAttr(FileName,FileNameW,fd.FileAttr & ~FILE_ATTRIBUTE_READONLY); 141 | char StreamName[NM]; 142 | WideToChar(StreamNameW,StreamName); 143 | File CurFile; 144 | if (CurFile.WCreate(StreamName,StreamNameW) && Arc.ReadSubData(NULL,&CurFile)) 145 | CurFile.Close(); 146 | File HostFile; 147 | if (Found && HostFile.Open(FileName,FileNameW,true,true)) 148 | SetFileTime(HostFile.GetHandle(),&fd.ftCreationTime,&fd.ftLastAccessTime, 149 | &fd.ftLastWriteTime); 150 | 151 | // Restoring original file attributes. Important if file was read only 152 | // or did not have "Archive" attribute 153 | SetFileAttr(FileName,FileNameW,fd.FileAttr); 154 | } 155 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(stream-unrar) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | add_definitions(-DRARDLL) 7 | 8 | add_subdirectory(3rd_party) 9 | include_directories(3rd_party/unrar-4.0.7) 10 | 11 | list(APPEND EXE_SRC stream_unrar.cpp) 12 | 13 | add_executable(stream-unrar ${EXE_SRC}) 14 | target_link_libraries(stream-unrar unrar) 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://ci.appveyor.com/api/projects/status/6wuhiw66etu5h4h9/branch/master?svg=true)](https://ci.appveyor.com/project/vlovich/stream-unrar/branch/master) 2 | [![Build Status](https://travis-ci.org/vlovich/stream-unrar.svg?branch=master)](https://travis-ci.org/vlovich/stream-unrar) 3 | 4 | Introduction 5 | --- 6 | Stream unrar allows you to begin extraction of non-corrupt multi-part archives that are (in the most common use) being downloaded from newsgroups (Usenet). This is particularly useful with videos which tend to take longer to download in full, but for which it is usually possible 7 | 8 | Allows monitoring within specific directories or specifying the first part of a multi-part archive explicitly. This program supports the "rar, r00, r01..." and "part01.rar, part02.rar..." naming schemes. 9 | 10 | If a part of the multi-part archive is missing, then it will silently wait until the part becomes available, and then continue extraction. 11 | 12 | This is really only useful if you can ensure that each part of the archive is non-corrupt as it becomes available on the filesystem (e.g. Usenet) 13 | 14 | This is a free, open-source, and more importantly cross-platform alternative to a feature found in NZBPlayer. It is designed to be combined with binary newsgroup readers (i.e. HellaNZB, NZBGet) and media players (i.e. VLC, MPlayer). 15 | 16 | Common Usage 17 | --- 18 | Currently the proof of concept works best with the following arguments: 19 | 20 | stream_unrar -m -e 21 | 22 | What it does 23 | --- 24 | Begin extraction right as the first archive of multi-part rar archive become available. This allows you to begin watching movies or listening to music downloaded through places like newsgroups as soon as the first file is downloaded, which is usually takes only a few minutes. 25 | 26 | When to use it 27 | --- 28 | 29 | Download speed > bitrate of media. Otherwise, you'll have to wait until such a point as you can be confident that it will finish downloading before you've finishing playing it or the files won't extract fast enough to be played real-time. 30 | Parts download consecutively & not corrupt - not suitable for bittorrent where the files appear before they are completely downloaded. Also, they are downloaded out of order. 31 | Your media player supports partially complete files (Videolan works perfectly for me). Even though it may say that the movie has 0 minutes, it should play through perfectly. However, you may experience that seeking doesn't work very well - in this case, you may have to wait until several more parts are extracted so that the video player can find the index. 32 | Speed guide for stream-like behaviour: 33 | 34 | SD video would require about a 200 KB/s sustained rate 35 | 720p video would require about a 500 KB/s sustained rate 36 | 1080p video would require about a 750 KB/s sustained rate 37 | Installation 38 | Simply extract the binary (or copy the compiled binaries) onto your path. Also, your best bet is to place the rar dynamic library (unrar.dll for Windows, libunrar.so for Linux) in the same directory as the executable. 39 | 40 | If you wish to use them implicitly on the command line (i.e. not have to specify the full path to the binary every time), you could place both so they appear on your path. The way I have it currently set up on my machine, is that both the executable and library are in my home directory with symlinks created in /usr/local/bin & /usr/lib. 41 | 42 | Deprecated 43 | --- 44 | In theory, you should be able to use the following syntax to extract a single passworded multi-part archive: 45 | 46 | stream_unrar -a 47 | 48 | 49 | -d -p password. 50 | This configuration is not really as well tested (especially the -p option which has never been tested). Unless there is a convincing request, this capability will disappear in the near future. 51 | 52 | Disclaimer 53 | --- 54 | Music and videos as mentioned above refer works which are legally obtained. I am not endorsing you to break any copyright laws that may be applicable where you live. 55 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | platform: x64 2 | configuration: Release 3 | os: Visual Studio 2015 4 | before_build: 5 | - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="%P" -DCMAKE_BUILD_TYPE=Release 6 | 7 | build: 8 | project: stream-unrar.vcxproj 9 | parallel: true 10 | -------------------------------------------------------------------------------- /kde_service_menu/stream-unrar.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | Encoding=UTF-8 4 | ServiceTypes=KonqPopupMenu/Plugin,application/x-rar 5 | Icon=utilities-file-archiver 6 | Actions=StreamUnrar; 7 | 8 | [Desktop Action StreamUnrar] 9 | Name=Extract while downloading 10 | Icon=utilities-file-archiver 11 | Exec=konsole --title "stream-unrar" -e stream-unrar -a %f -d "$(dirname %f)" 12 | -------------------------------------------------------------------------------- /unrar.patch: -------------------------------------------------------------------------------- 1 | *** unrar/dll.hpp 2007-09-10 04:49:28.000000000 -0700 2 | --- unrar.h 2008-01-17 16:49:31.000000000 -0800 3 | *************** 4 | *** 33,38 **** 5 | --- 33,42 ---- 6 | #define LONG long 7 | #define HANDLE void * 8 | #define UINT unsigned int 9 | + #define DLLIMPORT extern 10 | + #else 11 | + // Windows 12 | + #define DLLIMPORT __declspec(dllimport) 13 | #endif 14 | 15 | struct RARHeaderData 16 | *************** 17 | *** 109,115 **** 18 | UCM_CHANGEVOLUME,UCM_PROCESSDATA,UCM_NEEDPASSWORD 19 | }; 20 | 21 | ! typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LONG UserData,LONG P1,LONG P2); 22 | 23 | typedef int (PASCAL *CHANGEVOLPROC)(char *ArcName,int Mode); 24 | typedef int (PASCAL *PROCESSDATAPROC)(unsigned char *Addr,int Size); 25 | --- 113,119 ---- 26 | UCM_CHANGEVOLUME,UCM_PROCESSDATA,UCM_NEEDPASSWORD 27 | }; 28 | 29 | ! typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,void * UserData,size_t P1,size_t P2); 30 | 31 | typedef int (PASCAL *CHANGEVOLPROC)(char *ArcName,int Mode); 32 | typedef int (PASCAL *PROCESSDATAPROC)(unsigned char *Addr,int Size); 33 | *************** 34 | *** 118,135 **** 35 | extern "C" { 36 | #endif 37 | 38 | ! HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData); 39 | ! HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData); 40 | ! int PASCAL RARCloseArchive(HANDLE hArcData); 41 | ! int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData); 42 | ! int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData); 43 | ! int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName); 44 | ! int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar_t *DestPath,wchar_t *DestName); 45 | ! void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,LONG UserData); 46 | ! void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc); 47 | ! void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc); 48 | ! void PASCAL RARSetPassword(HANDLE hArcData,char *Password); 49 | ! int PASCAL RARGetDllVersion(); 50 | 51 | #ifdef __cplusplus 52 | } 53 | --- 122,140 ---- 54 | extern "C" { 55 | #endif 56 | 57 | ! DLLIMPORT HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData); 58 | ! 59 | ! DLLIMPORT HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData); 60 | ! DLLIMPORT int PASCAL RARCloseArchive(HANDLE hArcData); 61 | ! DLLIMPORT int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData); 62 | ! DLLIMPORT int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData); 63 | ! DLLIMPORT int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName); 64 | ! DLLIMPORT int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar_t *DestPath,wchar_t *DestName); 65 | ! DLLIMPORT void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,void * UserData); 66 | ! DLLIMPORT void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc); 67 | ! DLLIMPORT void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc); 68 | ! DLLIMPORT void PASCAL RARSetPassword(HANDLE hArcData,char *Password); 69 | ! DLLIMPORT int PASCAL RARGetDllVersion(); 70 | 71 | #ifdef __cplusplus 72 | } 73 | --------------------------------------------------------------------------------