/**************************************************************************** REMARKS: Test the Direct3D8 device for "lameness" with respect to GLDirect. This is done on per-chipset basis, as in GLD CAD driver (DGLCONTEXT.C). If bTestForWHQL is set then the device is tested to see if it is certified, and bIsWHQL is set to indicate TRUE or FALSE. Otherwise bIsWHQL is not set. [WHQL = Windows Hardware Quality Labs] NOTE: There is a one- or two-second time penalty incurred in determining the WHQL certification date. ****************************************************************************/ BOOL IsThisD3D8Lame( IDirect3D8 *pD3D, DWORD dwAdapter, BOOL bTestForWHQL, BOOL *bIsWHQL) { DWORD dwFlags = bTestForWHQL ? 0 : D3DENUM_NO_WHQL_LEVEL; D3DADAPTER_IDENTIFIER8 d3dai; HRESULT hr; hr = IDirect3D8_GetAdapterIdentifier(pD3D, dwAdapter, dwFlags, &d3dai); if (FAILED(hr)) return TRUE; // Definitely lame if adapter details can't be obtained! if (bTestForWHQL) { *bIsWHQL = d3dai.WHQLLevel ? TRUE : FALSE; } // Vendor 1: ATI if (d3dai.VendorId == VENDORID_ATI) { // Test A: ATI Rage PRO if (IsDevice(devATIRagePro, d3dai.DeviceId, sizeof(devATIRagePro))) return TRUE; // bad mipmapping // Test B: ATI Rage II+ if (IsDevice(devATIRageIIplus, d3dai.DeviceId, sizeof(devATIRageIIplus))) return TRUE; // bad HW alpha testing } return FALSE; }
BOOL FcbCreate(xfcb FAR * lpXfcb) { sft FAR *sftp; COUNT sft_idx, FcbDrive; struct dhdr FAR *dhp; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); sft_idx = DosCreatSft(PriPathName, 0); if (sft_idx < 0) return FALSE; sftp = idx_to_sft(sft_idx); sftp->sft_attrib |= SFT_MFCB; /* check for a device */ dhp = IsDevice(PriPathName); lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; lpFcb->fcb_recsiz = (dhp ? 0 : 128); if (!dhp) lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_fsize = 0; lpFcb->fcb_date = dos_getdate(); lpFcb->fcb_time = dos_gettime(); lpFcb->fcb_rndm = 0; return TRUE; }
BOOL FcbGetFileSize(xfcb FAR * lpXfcb) { COUNT FcbDrive, hndl; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ if (IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) { return FALSE; } hndl = DosOpen(SecPathName, O_RDONLY); if (hndl >= 0) { LONG fsize; /* Get the size */ fsize = DosGetFsize(hndl); /* compute the size and update the fcb */ lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; if ((fsize % lpFcb->fcb_recsiz) != 0) ++lpFcb->fcb_rndm; /* close the file and leave */ return DosClose(hndl) == SUCCESS; } else return FALSE; }
ALCAPI void ALCAPIENTRY alcCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCsizei lSamples) { if(IsDevice(pDevice) && pDevice->IsCaptureDevice) ALCdevice_CaptureSamples(pDevice, pBuffer, lSamples); else alcSetError(ALC_INVALID_DEVICE); }
ALCAPI void ALCAPIENTRY alcCaptureStop(ALCdevice *pDevice) { if(IsDevice(pDevice) && pDevice->IsCaptureDevice) ALCdevice_StopCapture(pDevice); else alcSetError(ALC_INVALID_DEVICE); }
ALCAPI ALCboolean ALCAPIENTRY alcCaptureCloseDevice(ALCdevice *pDevice) { ALCboolean bReturn = ALC_FALSE; ALCdevice **list; if(IsDevice(pDevice) && pDevice->IsCaptureDevice) { SuspendContext(NULL); list = &g_pDeviceList; while(*list != pDevice) list = &(*list)->next; *list = (*list)->next; g_ulDeviceCount--; ProcessContext(NULL); ALCdevice_CloseCapture(pDevice); free(pDevice->szDeviceName); pDevice->szDeviceName = NULL; free(pDevice); bReturn = ALC_TRUE; } else alcSetError(ALC_INVALID_DEVICE); return bReturn; }
BOOL FcbGetFileSize(xfcb FAR * lpXfcb) { COUNT FcbDrive, FileNum; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ /* if we have an extension, can't be a device */ if (IsDevice(PriPathName) || (lpFcb->fcb_recsiz == 0)) { return FALSE; } FileNum = dos_open(PriPathName, O_RDONLY); if (FileNum >= 0) { LONG fsize; /* Get the size */ fsize = dos_getfsize(FileNum); /* compute the size and update the fcb */ lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; if ((fsize % lpFcb->fcb_recsiz) != 0) ++lpFcb->fcb_rndm; /* close the file and leave */ return dos_close(FileNum) == SUCCESS; } else return FALSE; }
bool NoEOF( ftnfile *fcb ) { //============================= // Determine if file has an EOF (SERIAL, TERMINAL). if( fcb->fileptr == NULL ) return( false ); return( IsDevice( fcb ) ); }
static void ChkDisk( ftnfile *fcb ) { //======================================= // Make sure that the file is a disk file. if( IsDevice( fcb ) ) { FSetErr( IO_BAD_OPERATION, fcb->fileptr ); } }
void SysClearEOF( ftnfile *fcb ) { //=================================== // Clear EOF on file with no EOF (SERIAL, TERMINAL). IOOk( fcb->fileptr ); #if defined( __DOS__ ) if( ( fcb->fileptr == FStdIn ) && IsDevice( fcb ) ) { // DOS bug: if a read from stdin causes eof, all subsequent reads // will also cause eof unless we write to stdout write( ((a_file *)FStdOut)->handle, 0, 0 ); } #endif }
int _FileAttrs( ftnfile *fcb ) { //================================== int attrs; attrs = 0; if( fcb->recfm == RECFM_DEFAULT ) { attrs |= DfltRecType( fcb ); } else if( fcb->recfm == RECFM_VARIABLE ) { attrs |= REC_VARIABLE; } else if( fcb->recfm == RECFM_TEXT ) { attrs |= REC_TEXT; } else { attrs |= REC_FIXED; } if( fcb->share == SHARE_DENYRW ) { attrs |= S_DENYRW; } else if( fcb->share == SHARE_DENYWR ) { attrs |= S_DENYWR; } else if( fcb->share == SHARE_DENYRD ) { attrs |= S_DENYRD; } else if( fcb->share == SHARE_DENYNO ) { attrs |= S_DENYNO; } if( fcb->cctrl == CC_YES ) { attrs |= CARRIAGE_CONTROL; } if( (fcb->accmode == ACCM_SEQUENTIAL) || (fcb->accmode == ACCM_APPEND) ) { if( !IsDevice( fcb ) ) { attrs |= TRUNC_ON_WRITE; } } if( fcb->accmode == ACCM_APPEND ) { attrs |= APPEND; } else if( fcb->accmode == ACCM_DIRECT ) { attrs |= SEEK; } if( fcb->action == ACTION_READ ) { attrs |= RDONLY; } else if( fcb->action == ACTION_WRITE ) { attrs |= WRONLY; } else { attrs |= RDWR; } return( attrs ); }
int File::DirectRead(void *Data,int Size) { #ifdef _WIN_32 const int MaxDeviceRead=20000; #endif #ifndef _WIN_CE if (HandleType==FILE_HANDLESTD) { #ifdef _WIN_32 if (Size>MaxDeviceRead) Size=MaxDeviceRead; hFile=GetStdHandle(STD_INPUT_HANDLE); #else hFile=stdin; #endif } #endif #ifdef _WIN_32 DWORD Read; if (!ReadFile(hFile,Data,Size,&Read,NULL)) { if (IsDevice() && Size>MaxDeviceRead) return(DirectRead(Data,MaxDeviceRead)); if (HandleType==FILE_HANDLESTD && GetLastError()==ERROR_BROKEN_PIPE) return(0); return(-1); } return(Read); #else if (LastWrite) { fflush(hFile); LastWrite=false; } clearerr(hFile); int ReadSize=fread(Data,1,Size,hFile); if (ferror(hFile)) return(-1); return(ReadSize); #endif }
Vector<ValueType> Vector<ValueType>::operator+( const Vector<ValueType>& otherVector) { DEBUGLOG( this, "Vector::operator+", "Vec =" << &otherVector, 1); assert(GetSize() == otherVector.GetSize()); assert(( IsHost() && otherVector.IsHost() )|| (IsDevice() && otherVector.IsDevice()) ); Vector<ValueType> result(GetSize()); if (pImpl == pImplHost) result.pImpl->Add(*(otherVector.pImpl), *pImpl); else if (pImpl == pImplDevice) { result.MoveToDevice(); result.pImpl->Add(*(otherVector.pImpl), *pImpl); } DEBUGEND(); return result; }
void CHexEditDoc::CreateSearchThread() { ASSERT(theApp.bg_search_); ASSERT(pthread2_ == NULL); ASSERT(pfile2_ == NULL); // Open copy of file to be used by background thread if (pfile1_ != NULL) { if (IsDevice()) pfile2_ = new CFileNC(); else pfile2_ = new CFile64(); if (!pfile2_->Open(pfile1_->GetFilePath(), CFile::modeRead|CFile::shareDenyNone|CFile::typeBinary) ) { TRACE1("+++ File2 open failed for %p\n", this); return; } } // Open copy of any data files in use too for (int ii = 0; ii < doc_loc::max_data_files; ++ii) { ASSERT(data_file2_[ii] == NULL); if (data_file_[ii] != NULL) data_file2_[ii] = new CFile64(data_file_[ii]->GetFilePath(), CFile::modeRead|CFile::shareDenyWrite|CFile::typeBinary); } // Create new thread search_command_ = NONE; search_state_ = STARTING; search_fin_ = false; TRACE1("+++ Creating search thread for %p\n", this); search_priority_ = THREAD_PRIORITY_LOWEST; pthread2_ = AfxBeginThread(&bg_func, this, search_priority_); ASSERT(pthread2_ != NULL); }
BOOL FcbOpen(xfcb FAR * lpXfcb) { sft FAR *sftp; struct dhdr FAR *dhp; COUNT FcbDrive, sft_idx; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); sft_idx = DosOpenSft(PriPathName, O_RDWR); if (sft_idx < 0) return FALSE; sftp = idx_to_sft(sft_idx); sftp->sft_attrib |= SFT_MFCB; /* check for a device */ lpFcb->fcb_curec = 0; lpFcb->fcb_rndm = 0; lpFcb->fcb_sftno = sft_idx; dhp = IsDevice(PriPathName); if (dhp ) { lpFcb->fcb_recsiz = 0; lpFcb->fcb_fsize = 0; lpFcb->fcb_date = dos_getdate(); lpFcb->fcb_time = dos_gettime(); } else { lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_recsiz = 128; lpFcb->fcb_fsize = sftp->sft_size; lpFcb->fcb_date = sftp->sft_date; lpFcb->fcb_time = sftp->sft_time; } return TRUE; }
static char *GetSysName( ftnfile *fcb ) { //=========================================== // Return a system file name given a user name and a file structure. char buff[_MAX_PATH]; char *p; #if defined( __DOS__ ) || defined( __WINDOWS__ ) || (defined( __OS2__ ) && defined( _M_I86 )) p = JmpBlanks( fcb->filename ); if( IsDevice( fcb ) ) { strcpy( buff, p ); } else #endif { p = _fullpath( buff, fcb->filename, _MAX_PATH ); } if( p != NULL ) { p = RMemAlloc( strlen( buff ) + sizeof( char ) ); strcpy( p, buff ); } return( p ); }
// Sets up shared members and creates the thread using bg_func (above) void CHexEditDoc::CreateAerialThread() { ASSERT(pthread3_ == NULL); ASSERT(pfile3_ == NULL); // Open copy of file to be used by background thread if (pfile1_ != NULL) { if (IsDevice()) pfile3_ = new CFileNC(); else pfile3_ = new CFile64(); if (!pfile3_->Open(pfile1_->GetFilePath(), CFile::modeRead|CFile::shareDenyNone|CFile::typeBinary) ) { TRACE1("+++ Aerial file open failed for %p\n", this); return; } } // Open copy of any data files in use too for (int ii = 0; ii < doc_loc::max_data_files; ++ii) { ASSERT(data_file3_[ii] == NULL); if (data_file_[ii] != NULL) data_file3_[ii] = new CFile64(data_file_[ii]->GetFilePath(), CFile::modeRead|CFile::shareDenyWrite|CFile::typeBinary); } // Create new thread aerial_command_ = NONE; aerial_state_ = STARTING; // pre start and very beginning aerial_fin_ = false; TRACE1("+++ Creating aerial thread for %p\n", this); pthread3_ = AfxBeginThread(&bg_func, this, THREAD_PRIORITY_LOWEST); ASSERT(pthread3_ != NULL); }
BOOL FcbDelete(xfcb FAR * lpXfcb) { COUNT FcbDrive; /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ if (IsDevice(SecPathName)) { return FALSE; } else { BYTE FAR *lpOldDta = dta; dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } do { truename(Dmatch.dm_name, SecPathName, FALSE); if (DosDelete(SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } } while (DosFindNext() == SUCCESS); dta = lpOldDta; return TRUE; } }
BOOL FcbDelete(xfcb FAR * lpXfcb) { COUNT FcbDrive; /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ /* if we have an extension, can't be a device */ if (IsDevice(PriPathName)) { return FALSE; } else { BYTE FAR *lpOldDta = dta; dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } do { if (dos_delete(Dmatch.dm_name) != SUCCESS) { dta = lpOldDta; return FALSE; } } while (dos_findnext() == SUCCESS); dta = lpOldDta; return TRUE; } }
bool Archive::IsArchive(bool EnableBroken) { Encrypted=false; #ifdef USE_QOPEN QOpen.Unload(); #endif // Important if we reuse Archive object and it has virtual QOpen // file position not matching real. For example, for 'l -v volname'. Seek(0,SEEK_SET); #ifndef SFX_MODULE if (IsDevice()) { #ifndef SHELL_EXT Log(FileName,St(MInvalidName),FileName); #endif return false; } #endif if (Read(MarkHead.Mark,SIZEOF_MARKHEAD3)!=SIZEOF_MARKHEAD3) return(false); SFXSize=0; RARFORMAT Type; if ((Type=IsSignature(MarkHead.Mark,SIZEOF_MARKHEAD3))!=RARFMT_NONE) { Format=Type; if (Format==RARFMT14) Seek(0,SEEK_SET); } else { Array<char> Buffer(MAXSFXSIZE); long CurPos=(long)Tell(); int ReadSize=Read(&Buffer[0],Buffer.Size()-16); for (int I=0;I<ReadSize;I++) if (Buffer[I]==0x52 && (Type=IsSignature((byte *)&Buffer[I],ReadSize-I))!=RARFMT_NONE) { Format=Type; if (Format==RARFMT14 && I>0 && CurPos<28 && ReadSize>31) { char *D=&Buffer[28-CurPos]; if (D[0]!=0x52 || D[1]!=0x53 || D[2]!=0x46 || D[3]!=0x58) continue; } SFXSize=CurPos+I; Seek(SFXSize,SEEK_SET); if (Format==RARFMT15 || Format==RARFMT50) Read(MarkHead.Mark,SIZEOF_MARKHEAD3); break; } if (SFXSize==0) return false; } if (Format==RARFMT_FUTURE) { #if !defined(SHELL_EXT) && !defined(SFX_MODULE) Log(FileName,St(MNewRarFormat)); #endif return false; } if (Format==RARFMT50) // RAR 5.0 signature is by one byte longer. { Read(MarkHead.Mark+SIZEOF_MARKHEAD3,1); if (MarkHead.Mark[SIZEOF_MARKHEAD3]!=0) return false; MarkHead.HeadSize=SIZEOF_MARKHEAD5; } else MarkHead.HeadSize=SIZEOF_MARKHEAD3; // Skip the archive encryption header if any and read the main header. while (ReadHeader()!=0 && GetHeaderType()!=HEAD_MAIN) SeekToNext(); // This check allows to make RS based recovery even if password is incorrect. // But we should not do it for EnableBroken or we'll get 'not RAR archive' // messages when extracting encrypted archives with wrong password. if (FailedHeaderDecryption && !EnableBroken) return false; SeekToNext(); if (BrokenHeader) { #ifndef SHELL_EXT Log(FileName,St(MMainHeaderBroken)); #endif if (!EnableBroken) return false; } /* if (MainHead.EncryptVer>VER_UNPACK) { #ifdef RARDLL Cmd->DllError=ERAR_UNKNOWN_FORMAT; #else ErrHandler.SetErrorCode(RARX_WARNING); #if !defined(SILENT) && !defined(SFX_MODULE) Log(FileName,St(MUnknownMeth),FileName); Log(FileName,St(MVerRequired),MainHead.EncryptVer/10,MainHead.EncryptVer%10); #endif #endif return(false); } */ #ifdef RARDLL // If callback function is not set, we cannot get the password, // so we skip the initial header processing for encrypted header archive. // It leads to skipped archive comment, but the rest of archive data // is processed correctly. if (Cmd->Callback==NULL) SilentOpen=true; #endif MainComment=MainHead.CommentInHeader; #ifdef USE_QOPEN if (MainHead.Locator && MainHead.QOpenOffset>0 && Cmd->QOpenMode!=QOPEN_NONE) { QOpen.Init(this,false); QOpen.Load(MainHead.QOpenOffset); } #endif // If we process non-encrypted archive or can request a password, // we set 'first volume' flag based on file attributes below. // It is necessary for RAR 2.x archives, which did not have 'first volume' // flag in main header. if (!SilentOpen || !Encrypted) { SaveFilePos SavePos(*this); int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos; while (ReadHeader()!=0) { HEADER_TYPE HeaderType=GetHeaderType(); if (HeaderType==HEAD_SERVICE) { if (SubHead.CmpName(SUBHEAD_TYPE_CMT)) MainComment=true; FirstVolume=!SubHead.SplitBefore; } else { FirstVolume=HeaderType==HEAD_FILE && !FileHead.SplitBefore; break; } SeekToNext(); } CurBlockPos=SaveCurBlockPos; NextBlockPos=SaveNextBlockPos; } if (!Volume || FirstVolume) wcscpy(FirstVolumeName,FileName); return true; }
bool Archive::IsArchive(bool EnableBroken) { Encrypted=false; #ifndef SFX_MODULE if (IsDevice()) { #ifndef SHELL_EXT Log(FileName,St(MInvalidName),FileName); #endif return(false); } #endif if (Read(MarkHead.Mark,SIZEOF_MARKHEAD)!=SIZEOF_MARKHEAD) return(false); SFXSize=0; if (IsSignature(MarkHead.Mark)) { if (OldFormat) Seek(0,SEEK_SET); } else { Array<char> Buffer(MAXSFXSIZE); long CurPos=(long)Tell(); int ReadSize=Read(&Buffer[0],Buffer.Size()-16); for (int I=0;I<ReadSize;I++) if (Buffer[I]==0x52 && IsSignature((byte *)&Buffer[I])) { if (OldFormat && I>0 && CurPos<28 && ReadSize>31) { char *D=&Buffer[28-CurPos]; if (D[0]!=0x52 || D[1]!=0x53 || D[2]!=0x46 || D[3]!=0x58) continue; } SFXSize=CurPos+I; Seek(SFXSize,SEEK_SET); if (!OldFormat) Read(MarkHead.Mark,SIZEOF_MARKHEAD); break; } if (SFXSize==0) return(false); } ReadHeader(); SeekToNext(); #ifndef SFX_MODULE if (OldFormat) { NewMhd.Flags=OldMhd.Flags & 0x3f; NewMhd.HeadSize=OldMhd.HeadSize; } else #endif { if (HeaderCRC!=NewMhd.HeadCRC) { #ifndef SHELL_EXT Log(FileName,St(MLogMainHead)); #endif Alarm(); if (!EnableBroken) return(false); } } Volume=(NewMhd.Flags & MHD_VOLUME); Solid=(NewMhd.Flags & MHD_SOLID)!=0; MainComment=(NewMhd.Flags & MHD_COMMENT)!=0; Locked=(NewMhd.Flags & MHD_LOCK)!=0; Signed=(NewMhd.PosAV!=0); Protected=(NewMhd.Flags & MHD_PROTECT)!=0; Encrypted=(NewMhd.Flags & MHD_PASSWORD)!=0; if (NewMhd.EncryptVer>UNP_VER) { #ifdef RARDLL Cmd->DllError=ERAR_UNKNOWN_FORMAT; #else ErrHandler.SetErrorCode(RARX_WARNING); #if !defined(SILENT) && !defined(SFX_MODULE) Log(FileName,St(MUnknownMeth),FileName); Log(FileName,St(MVerRequired),NewMhd.EncryptVer/10,NewMhd.EncryptVer%10); #endif #endif return(false); } #ifdef RARDLL // If callback function is not set, we cannot get the password, // so we skip the initial header processing for encrypted header archive. // It leads to skipped archive comment, but the rest of archive data // is processed correctly. if (Cmd->Callback==NULL) SilentOpen=true; #endif // If not encrypted, we'll check it below. NotFirstVolume=Encrypted && (NewMhd.Flags & MHD_FIRSTVOLUME)==0; if (!SilentOpen || !Encrypted) { SaveFilePos SavePos(*this); int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos; NotFirstVolume=false; while (ReadHeader()!=0) { int HeaderType=GetHeaderType(); if (HeaderType==NEWSUB_HEAD) { if (SubHead.CmpName(SUBHEAD_TYPE_CMT)) MainComment=true; if ((SubHead.Flags & LHD_SPLIT_BEFORE) || Volume && (NewMhd.Flags & MHD_FIRSTVOLUME)==0) NotFirstVolume=true; } else { if (HeaderType==FILE_HEAD && ((NewLhd.Flags & LHD_SPLIT_BEFORE)!=0 || Volume && NewLhd.UnpVer>=29 && (NewMhd.Flags & MHD_FIRSTVOLUME)==0)) NotFirstVolume=true; break; } SeekToNext(); } CurBlockPos=SaveCurBlockPos; NextBlockPos=SaveNextBlockPos; } if (!Volume || !NotFirstVolume) { strcpy(FirstVolumeName,FileName); wcscpy(FirstVolumeNameW,FileNameW); } return(true); }
/* alcCloseDevice Close the specified Device */ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice) { ALCboolean bReturn = ALC_FALSE; ALCdevice **list; if(IsDevice(pDevice) && !pDevice->IsCaptureDevice) { SuspendContext(NULL); list = &g_pDeviceList; while(*list != pDevice) list = &(*list)->next; *list = (*list)->next; g_ulDeviceCount--; ProcessContext(NULL); if(pDevice->NumContexts > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): destroying %u Context(s)\n", pDevice->NumContexts); #endif while(pDevice->NumContexts > 0) alcDestroyContext(pDevice->Contexts[0]); } ALCdevice_ClosePlayback(pDevice); if(pDevice->BufferCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Buffer(s)\n", pDevice->BufferCount); #endif ReleaseALBuffers(pDevice); } if(pDevice->EffectCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Effect(s)\n", pDevice->EffectCount); #endif ReleaseALEffects(pDevice); } if(pDevice->FilterCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Filter(s)\n", pDevice->FilterCount); #endif ReleaseALFilters(pDevice); } if(pDevice->DatabufferCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Databuffer(s)\n", pDevice->DatabufferCount); #endif ReleaseALDatabuffers(pDevice); } free(pDevice->Bs2b); pDevice->Bs2b = NULL; free(pDevice->szDeviceName); pDevice->szDeviceName = NULL; free(pDevice->Contexts); pDevice->Contexts = NULL; //Release device structure memset(pDevice, 0, sizeof(ALCdevice)); free(pDevice); bReturn = ALC_TRUE; } else alcSetError(ALC_INVALID_DEVICE); return bReturn; }
/* alcGetString Returns information about the Device, and error strings */ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param) { const ALCchar *value = NULL; switch (param) { case ALC_NO_ERROR: value = alcNoError; break; case ALC_INVALID_ENUM: value = alcErrInvalidEnum; break; case ALC_INVALID_VALUE: value = alcErrInvalidValue; break; case ALC_INVALID_DEVICE: value = alcErrInvalidDevice; break; case ALC_INVALID_CONTEXT: value = alcErrInvalidContext; break; case ALC_OUT_OF_MEMORY: value = alcErrOutOfMemory; break; case ALC_DEVICE_SPECIFIER: if(IsDevice(pDevice)) value = pDevice->szDeviceName; else { ProbeDeviceList(); value = alcDeviceList; } break; case ALC_ALL_DEVICES_SPECIFIER: ProbeAllDeviceList(); value = alcAllDeviceList; break; case ALC_CAPTURE_DEVICE_SPECIFIER: if(IsDevice(pDevice)) value = pDevice->szDeviceName; else { ProbeCaptureDeviceList(); value = alcCaptureDeviceList; } break; /* Default devices are always first in the list */ case ALC_DEFAULT_DEVICE_SPECIFIER: free(alcDefaultDeviceSpecifier); alcDefaultDeviceSpecifier = strdup(alcDeviceList ? alcDeviceList : ""); if(!alcDefaultDeviceSpecifier) alcSetError(ALC_OUT_OF_MEMORY); value = alcDefaultDeviceSpecifier; break; case ALC_DEFAULT_ALL_DEVICES_SPECIFIER: free(alcDefaultAllDeviceSpecifier); alcDefaultAllDeviceSpecifier = strdup(alcAllDeviceList ? alcAllDeviceList : ""); if(!alcDefaultAllDeviceSpecifier) alcSetError(ALC_OUT_OF_MEMORY); value = alcDefaultAllDeviceSpecifier; break; case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER: free(alcCaptureDefaultDeviceSpecifier); alcCaptureDefaultDeviceSpecifier = strdup(alcCaptureDeviceList ? alcCaptureDeviceList : ""); if(!alcCaptureDefaultDeviceSpecifier) alcSetError(ALC_OUT_OF_MEMORY); value = alcCaptureDefaultDeviceSpecifier; break; case ALC_EXTENSIONS: value = alcExtensionList; break; default: alcSetError(ALC_INVALID_ENUM); break; } return value; }
/* alcGetIntegerv Returns information about the Device and the version of Open AL */ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsizei size,ALCint *data) { if(IsDevice(device) && device->IsCaptureDevice) { SuspendContext(NULL); // Capture device switch (param) { case ALC_CAPTURE_SAMPLES: if ((size) && (data)) *data = ALCdevice_AvailableSamples(device); else alcSetError(ALC_INVALID_VALUE); break; case ALC_CONNECTED: if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = device->Connected; break; default: alcSetError(ALC_INVALID_ENUM); break; } ProcessContext(NULL); } else { if(data) { // Playback Device switch (param) { case ALC_MAJOR_VERSION: if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = alcMajorVersion; break; case ALC_MINOR_VERSION: if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = alcMinorVersion; break; case ALC_EFX_MAJOR_VERSION: if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = alcEFXMajorVersion; break; case ALC_EFX_MINOR_VERSION: if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = alcEFXMinorVersion; break; case ALC_MAX_AUXILIARY_SENDS: if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = (device?device->NumAuxSends:MAX_SENDS); break; case ALC_ATTRIBUTES_SIZE: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = 13; break; case ALC_ALL_ATTRIBUTES: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if (size < 13) alcSetError(ALC_INVALID_VALUE); else { int i = 0; SuspendContext(NULL); data[i++] = ALC_FREQUENCY; data[i++] = device->Frequency; data[i++] = ALC_REFRESH; data[i++] = device->Frequency / device->UpdateSize; data[i++] = ALC_SYNC; data[i++] = ALC_FALSE; data[i++] = ALC_MONO_SOURCES; data[i++] = device->lNumMonoSources; data[i++] = ALC_STEREO_SOURCES; data[i++] = device->lNumStereoSources; data[i++] = ALC_MAX_AUXILIARY_SENDS; data[i++] = device->NumAuxSends; data[i++] = 0; ProcessContext(NULL); } break; case ALC_FREQUENCY: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = device->Frequency; break; case ALC_REFRESH: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = device->Frequency / device->UpdateSize; break; case ALC_SYNC: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = ALC_FALSE; break; case ALC_MONO_SOURCES: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = device->lNumMonoSources; break; case ALC_STEREO_SOURCES: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = device->lNumStereoSources; break; case ALC_CONNECTED: if(!IsDevice(device)) alcSetError(ALC_INVALID_DEVICE); else if(size <= 0) alcSetError(ALC_INVALID_VALUE); else *data = device->Connected; break; default: alcSetError(ALC_INVALID_ENUM); break; } } else if(size) alcSetError(ALC_INVALID_VALUE); } return; }
static void SysIOInfo( ftnfile *fcb ) { //========================================= // Get system file information. struct stat info; char *sys_name; bool exist = true; if( fcb->bufflen == 0 ) { fcb->bufflen = SYS_DFLT_RECSIZE; } if( fcb->blocksize == 0 ) { fcb->blocksize = IO_BUFFER; } fcb->device = 0; if( fcb->fileptr != NULL ) { // file is open #if defined( __NETWARE__ ) if( ( ((a_file *)(fcb->fileptr))->handle == STDIN_FILENO ) || ( ((a_file *)(fcb->fileptr))->handle == STDOUT_FILENO ) || ( ((a_file *)(fcb->fileptr))->handle == STDERR_FILENO ) ) { fcb->device |= INFO_DEV; } else { #endif // for stdin, don't use file name "CON" since information will always // indicate it's a device even if stdin is redirected if( fstat( ((a_file *)(fcb->fileptr))->handle, &info ) == -1 ) { FSetSysErr( fcb->fileptr ); IOErr( IO_FILE_PROBLEM ); return; } if( S_ISCHR( info.st_mode ) ) { fcb->device |= INFO_DEV; #if defined( __DOS__ ) || defined( __WINDOWS__ ) } else { fcb->device |= INFO_VALID_DRIVE; #endif } #if defined( __NETWARE__ ) } #endif } else { if( stat( fcb->filename, &info ) == -1 ) { // if we are trying to open a file in a non-existent // directory we don't want to issue an error if( fcb->flags & FTN_FSEXIST ) { FSetSysErr( fcb->fileptr ); IOErr( IO_FILE_PROBLEM ); return; } exist = false; } else if( S_ISCHR( info.st_mode ) ) { fcb->device |= INFO_DEV; // devices always exist fcb->flags |= FTN_FSEXIST; #if !defined( __UNIX__ ) } else { fcb->device |= INFO_VALID_DRIVE; #endif } } if( ( fcb->flags & FTN_FSEXIST ) && !IsDevice( fcb ) ) { #if !defined( __UNIX__ ) // Assume the two most significant bits contain no useful information fcb->device = INFO_DRIVE & info.st_dev; // save drive letter #endif if( ( info.st_mode & S_IRUSR ) && ( info.st_mode & S_IWUSR ) ) { fcb->action = ACTION_RW; } else if( info.st_mode & S_IRUSR ) { fcb->action = ACTION_READ; } else if( info.st_mode & S_IWUSR ) { fcb->action = ACTION_WRITE; } else { // if none of the above are set, // assume read/write fcb->action = ACTION_RW; } } sys_name = GetSysName( fcb ); if( sys_name == NULL ) { if( exist ) { FSetSysErr( fcb->fileptr ); IOErr( IO_FILE_PROBLEM ); } return; } RMemFree( fcb->filename ); fcb->filename = sys_name; }
bool Archive::IsArchive(bool EnableBroken) { Encrypted=false; #ifndef SFX_MODULE if (IsDevice()) { #ifndef SHELL_EXT Log(FileName,St(MInvalidName),FileName); #endif return(false); } #endif if (Read(MarkHead.Mark,SIZEOF_MARKHEAD)!=SIZEOF_MARKHEAD) return(false); SFXSize=0; if (IsSignature(MarkHead.Mark)) { if (OldFormat) Seek(0,SEEK_SET); } else { Array<char> Buffer(0x40000); long CurPos=int64to32(Tell()); int ReadSize=Read(&Buffer[0],Buffer.Size()-16); for (int I=0;I<ReadSize;I++) if (Buffer[I]==0x52 && IsSignature((byte *)&Buffer[I])) { SFXSize=CurPos+I; Seek(SFXSize,SEEK_SET); if (!OldFormat) Read(MarkHead.Mark,SIZEOF_MARKHEAD); break; } if (SFXSize==0) return(false); } ReadHeader(); SeekToNext(); #ifndef SFX_MODULE if (OldFormat) { NewMhd.Flags=OldMhd.Flags & 0x3f; NewMhd.HeadSize=OldMhd.HeadSize; } else #endif { if (HeaderCRC!=NewMhd.HeadCRC) { #ifndef SHELL_EXT Log(FileName,St(MLogMainHead)); #endif Alarm(); if (!EnableBroken) return(false); } } Volume=(NewMhd.Flags & MHD_VOLUME); Solid=(NewMhd.Flags & MHD_SOLID)!=0; MainComment=(NewMhd.Flags & MHD_COMMENT)!=0; Locked=(NewMhd.Flags & MHD_LOCK)!=0; Signed=(NewMhd.PosAV!=0); Protected=(NewMhd.Flags & MHD_PROTECT)!=0; Encrypted=(NewMhd.Flags & MHD_PASSWORD)!=0; #ifdef RARDLL SilentOpen=true; #endif if (!SilentOpen || !Encrypted) { SaveFilePos SavePos(*this); Int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos; NotFirstVolume=false; while (ReadHeader()) { int HeaderType=GetHeaderType(); if (HeaderType==NEWSUB_HEAD) { if (SubHead.CmpName(SUBHEAD_TYPE_CMT)) MainComment=true; if ((SubHead.Flags & LHD_SPLIT_BEFORE) || Volume && (NewMhd.Flags & MHD_FIRSTVOLUME)==0) NotFirstVolume=true; } else { if (HeaderType==FILE_HEAD && ((NewLhd.Flags & LHD_SPLIT_BEFORE)!=0 || Volume && NewLhd.UnpVer>=29 && (NewMhd.Flags & MHD_FIRSTVOLUME)==0)) NotFirstVolume=true; break; } SeekToNext(); } CurBlockPos=SaveCurBlockPos; NextBlockPos=SaveNextBlockPos; } return(true); }
BOOL FcbRename(xfcb FAR * lpXfcb) { rfcb FAR *lpRenameFcb; COUNT FcbDrive; /* Build a traditional DOS file name */ lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ /* if we have an extension, can't be a device */ if (IsDevice(PriPathName)) { return FALSE; } else { BYTE FAR *lpOldDta = dta; dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } do { fcb LocalFcb; BYTE *pToName, *pszFrom; BYTE FAR *pFromPattern; COUNT nIndex; /* First, expand the find match into fcb style */ /* file name entry */ /* Fill with blanks first */ for (pToName = LocalFcb.fcb_fname, nIndex = 0; nIndex < FNAME_SIZE; nIndex++) { *pToName++ = ' '; } for (pToName = LocalFcb.fcb_fext, nIndex = 0; nIndex < FEXT_SIZE; nIndex++) { *pToName++ = ' '; } /* next move in the file name while overwriting */ /* the filler blanks */ pszFrom = Dmatch.dm_name; pToName = LocalFcb.fcb_fname; for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++) { if (*pszFrom != 0 && *pszFrom != '.') *pToName++ = *pszFrom++; else if (*pszFrom == '.') { ++pszFrom; break; } else break; } if (*pszFrom != '\0') { pToName = LocalFcb.fcb_fext; for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++) { if (*pszFrom != '\0') *pToName++ = *pszFrom++; else break; } } /* Overlay the pattern, skipping '?' */ /* I'm cheating because this assumes that the */ /* struct alignments are on byte boundaries */ pToName = LocalFcb.fcb_fname; for (pFromPattern = lpRenameFcb->renNewName, nIndex = 0; nIndex < FNAME_SIZE + FEXT_SIZE; nIndex++) { if (*pFromPattern != '?') *pToName++ = *pFromPattern++; else ++pFromPattern; } /* now to build a dos name again */ LocalFcb.fcb_drive = 0; FcbNameInit((fcb FAR *) & LocalFcb, PriPathName, &FcbDrive); if (dos_rename(Dmatch.dm_name, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } } while (dos_findnext() == SUCCESS); dta = lpOldDta; return TRUE; } }
BOOL FcbOpen(xfcb FAR * lpXfcb) { WORD sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; COUNT FcbDrive; /* get a free system file table entry */ if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ /* if we have an extension, can't be a device */ if (IsDevice(PriPathName)) { for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) { if (FcbFnameMatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) { sftp->sft_count += 1; sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; sftp->sft_flags = (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF; sftp->sft_psp = cu_psp; fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; lpFcb->fcb_recsiz = 0; lpFcb->fcb_fsize = 0; lpFcb->fcb_date = dos_getdate(); lpFcb->fcb_time = dos_gettime(); lpFcb->fcb_rndm = 0; return TRUE; } } } sftp->sft_status = dos_open(PriPathName, O_RDWR); if (sftp->sft_status >= 0) { lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; lpFcb->fcb_recsiz = 128; lpFcb->fcb_fsize = dos_getfsize(sftp->sft_status); dos_getftime(sftp->sft_status, (date FAR *) & lpFcb->fcb_date, (time FAR *) & lpFcb->fcb_time); lpFcb->fcb_rndm = 0; sftp->sft_count += 1; sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; sftp->sft_flags = 0; sftp->sft_psp = cu_psp; fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); return TRUE; } else return FALSE; }
/* alcCreateContext Create and attach a Context to a particular Device. */ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList) { ALuint attrIdx, reqStereoSources; ALCcontext *ALContext; void *temp; ALuint i; SuspendContext(NULL); if(!IsDevice(device) || device->IsCaptureDevice || !device->Connected) { alcSetError(ALC_INVALID_DEVICE); ProcessContext(NULL); return NULL; } // Reset Context Last Error code g_eLastContextError = ALC_NO_ERROR; // If a context is already running on the device, stop playback so the // device attributes can be updated if(device->NumContexts > 0) { ProcessContext(NULL); ALCdevice_StopPlayback(device); SuspendContext(NULL); } // Check for attributes if(attrList) { ALCint level = device->Bs2bLevel; ALCuint freq = device->Frequency; ALCint numMono = device->lNumMonoSources; ALCint numStereo = device->lNumStereoSources; ALCuint numSends = device->NumAuxSends; attrIdx = 0; while(attrList[attrIdx]) { if(attrList[attrIdx] == ALC_FREQUENCY) { freq = attrList[attrIdx + 1]; if(freq == 0) freq = device->Frequency; } if(attrList[attrIdx] == ALC_STEREO_SOURCES) { reqStereoSources = attrList[attrIdx + 1]; if(reqStereoSources > device->MaxNoOfSources) reqStereoSources = device->MaxNoOfSources; numStereo = reqStereoSources; numMono = device->MaxNoOfSources - numStereo; } if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS) { numSends = attrList[attrIdx + 1]; if(numSends > MAX_SENDS) numSends = MAX_SENDS; } attrIdx += 2; } device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", level); device->Frequency = GetConfigValueInt(NULL, "frequency", freq); device->lNumMonoSources = numMono; device->lNumStereoSources = numStereo; device->NumAuxSends = GetConfigValueInt(NULL, "sends", numSends); } if(ALCdevice_ResetPlayback(device) == ALC_FALSE) { alcSetError(ALC_INVALID_DEVICE); aluHandleDisconnect(device); ProcessContext(NULL); return NULL; } for(i = 0;i < device->NumContexts;i++) { ALCcontext *context = device->Contexts[i]; ALeffectslot *slot; ALsource *source; SuspendContext(context); for(slot = context->AuxiliaryEffectSlot;slot != NULL;slot = slot->next) { if(!slot->EffectState) continue; if(ALEffect_DeviceUpdate(slot->EffectState, device) == AL_FALSE) { alcSetError(ALC_INVALID_DEVICE); aluHandleDisconnect(device); ProcessContext(context); ProcessContext(NULL); ALCdevice_StopPlayback(device); return NULL; } ALEffect_Update(slot->EffectState, context, &slot->effect); } for(source = context->Source;source != NULL;source = source->next) { ALuint s = device->NumAuxSends; while(s < MAX_SENDS) { if(source->Send[s].Slot) source->Send[s].Slot->refcount--; source->Send[s].Slot = NULL; source->Send[s].WetFilter.type = 0; source->Send[s].WetFilter.filter = 0; s++; } } ProcessContext(context); } if(device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) { if(!device->Bs2b) { device->Bs2b = calloc(1, sizeof(*device->Bs2b)); bs2b_clear(device->Bs2b); } bs2b_set_srate(device->Bs2b, device->Frequency); bs2b_set_level(device->Bs2b, device->Bs2bLevel); } else { free(device->Bs2b); device->Bs2b = NULL; } temp = realloc(device->Contexts, (device->NumContexts+1) * sizeof(*device->Contexts)); if(!temp) { alcSetError(ALC_OUT_OF_MEMORY); ProcessContext(NULL); return NULL; } device->Contexts = temp; ALContext = calloc(1, sizeof(ALCcontext)); if(!ALContext) { alcSetError(ALC_OUT_OF_MEMORY); ProcessContext(NULL); return NULL; } device->Contexts[device->NumContexts++] = ALContext; ALContext->Device = device; InitContext(ALContext); ALContext->next = g_pContextList; g_pContextList = ALContext; g_ulContextCount++; ProcessContext(NULL); return ALContext; }
bool Archive::IsArchive(bool EnableBroken) { Encrypted=false; BrokenHeader=false; // Might be left from previous volume. #ifndef SFX_MODULE if (IsDevice()) { uiMsg(UIERROR_INVALIDNAME,FileName,FileName); return false; } #endif if (Read(MarkHead.Mark,SIZEOF_MARKHEAD3)!=SIZEOF_MARKHEAD3) return false; SFXSize=0; RARFORMAT Type; if ((Type=IsSignature(MarkHead.Mark,SIZEOF_MARKHEAD3))!=RARFMT_NONE) { Format=Type; if (Format==RARFMT14) Seek(Tell()-SIZEOF_MARKHEAD3,SEEK_SET); } else { Array<char> Buffer(MAXSFXSIZE); long CurPos=(long)Tell(); int ReadSize=Read(&Buffer[0],Buffer.Size()-16); for (int I=0;I<ReadSize;I++) if (Buffer[I]==0x52 && (Type=IsSignature((byte *)&Buffer[I],ReadSize-I))!=RARFMT_NONE) { Format=Type; if (Format==RARFMT14 && I>0 && CurPos<28 && ReadSize>31) { char *D=&Buffer[28-CurPos]; if (D[0]!=0x52 || D[1]!=0x53 || D[2]!=0x46 || D[3]!=0x58) continue; } SFXSize=CurPos+I; Seek(SFXSize,SEEK_SET); if (Format==RARFMT15 || Format==RARFMT50) Read(MarkHead.Mark,SIZEOF_MARKHEAD3); break; } if (SFXSize==0) return false; } if (Format==RARFMT_FUTURE) { uiMsg(UIERROR_NEWRARFORMAT,FileName); return false; } if (Format==RARFMT50) // RAR 5.0 signature is by one byte longer. { Read(MarkHead.Mark+SIZEOF_MARKHEAD3,1); if (MarkHead.Mark[SIZEOF_MARKHEAD3]!=0) return false; MarkHead.HeadSize=SIZEOF_MARKHEAD5; } else MarkHead.HeadSize=SIZEOF_MARKHEAD3; #ifdef RARDLL // If callback function is not set, we cannot get the password, // so we skip the initial header processing for encrypted header archive. // It leads to skipped archive comment, but the rest of archive data // is processed correctly. if (Cmd->Callback==NULL) SilentOpen=true; #endif // Skip the archive encryption header if any and read the main header. while (ReadHeader()!=0) { HEADER_TYPE Type=GetHeaderType(); // In RAR 5.0 we need to quit after reading HEAD_CRYPT if we wish to // avoid the password prompt. if (Type==HEAD_MAIN || SilentOpen && Type==HEAD_CRYPT) break; SeekToNext(); } // This check allows to make RS based recovery even if password is incorrect. // But we should not do it for EnableBroken or we'll get 'not RAR archive' // messages when extracting encrypted archives with wrong password. if (FailedHeaderDecryption && !EnableBroken) return false; SeekToNext(); if (BrokenHeader) // Main archive header is corrupt. { uiMsg(UIERROR_MHEADERBROKEN,FileName); if (!EnableBroken) return false; } MainComment=MainHead.CommentInHeader; // If we process non-encrypted archive or can request a password, // we set 'first volume' flag based on file attributes below. // It is necessary for RAR 2.x archives, which did not have 'first volume' // flag in main header. Also for all RAR formats we need to scan until // first file header to set "comment" flag when reading service header. // Unless we are in silent mode, we need to know about presence of comment // immediately after IsArchive call. if (!SilentOpen || !Encrypted) { SaveFilePos SavePos(*this); int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos; HEADER_TYPE SaveCurHeaderType=CurHeaderType; while (ReadHeader()!=0) { HEADER_TYPE HeaderType=GetHeaderType(); if (HeaderType==HEAD_SERVICE) FirstVolume=Volume && !SubHead.SplitBefore; else if (HeaderType==HEAD_FILE) { FirstVolume=Volume && !FileHead.SplitBefore; break; } SeekToNext(); } CurBlockPos=SaveCurBlockPos; NextBlockPos=SaveNextBlockPos; CurHeaderType=SaveCurHeaderType; } if (!Volume || FirstVolume) wcscpy(FirstVolumeName,FileName); return true; }