inline PPM_CONTEXT* PPM_CONTEXT::createChild(STATE* pStats,STATE& FirstState) { PPM_CONTEXT* pc = (PPM_CONTEXT*) AllocContext(); if ( pc ) { memset(pc,0,sizeof(PPM_CONTEXT)); pc->oneState()=FirstState; pc->Suffix=this; pStats->Successor=pc; } return pc; }
PPMdContext *NewPPMdContext(PPMdCoreModel *model) { PPMdContext *context=OffsetToPointer(model->alloc,AllocContext(model->alloc)); if(context) { context->LastStateIndex=0; context->Flags=0; context->Suffix=0; } return context; }
PPMdContext *NewPPMdContextAsChildOf(PPMdCoreModel *model,PPMdContext *suffixcontext,PPMdState *suffixstate,PPMdState *firststate) { PPMdContext *context=OffsetToPointer(model->alloc,AllocContext(model->alloc)); if(context) { context->LastStateIndex=0; context->Flags=0; SetPPMdContextSuffixPointer(context,suffixcontext,model); SetPPMdStateSuccessorPointer(suffixstate,context,model); if(firststate) *(PPMdContextOneState(context))=*firststate; } return context; }
static void _FASTCALL StartModelRare(int MaxOrder) { int i, k, m, Step; ::MaxOrder=OrderFall=MaxOrder; InitSubAllocator(); MinContext = MaxContext = (PPM_CONTEXT*) AllocContext(); MinContext->Suffix=NULL; MinContext->NumStats=255; FoundState = MinContext->Stats = (PPM_CONTEXT::STATE*) AllocUnits(256/2); for (i=MinContext->SummFreq=MinContext->EscFreq=0;i < 256;i++) { MinContext->Stats[i].Symbol=i; MinContext->Stats[i].Freq=0; MinContext->Stats[i].Successor=NULL; } for (i=0;i < UP_FREQ;i++) QTable[i]=i; for (m=i=UP_FREQ, k=Step=1;i < 260;i++) { QTable[i]=m; if ( !--k ) { k = ++Step; m++; } } }
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gfxintrn.h" GRAPHICS_STATUS _GraphicsStatusFlags; CONTEXT _pCurContext; #ifdef DEBUG // We keep track of all contexts CONTEXT firstContext; // The first one in the list. CONTEXT *contextEnd = &firstContext; // Where to put the next context. #endif PRIMITIVE _locPrim; FONT _CurFontPtr; #define DEFAULT_FORE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) #define DEFAULT_BACK_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) #define DEFAULT_DRAW_MODE MAKE_DRAW_MODE (DRAW_DEFAULT, 255) CONTEXT SetContext (CONTEXT Context) { CONTEXT LastContext; LastContext = _pCurContext; if (Context != LastContext) { if (LastContext) { UnsetContextFlags ( MAKE_WORD (0, GRAPHICS_ACTIVE | DRAWABLE_ACTIVE)); SetContextFlags ( MAKE_WORD (0, _GraphicsStatusFlags & (GRAPHICS_ACTIVE | DRAWABLE_ACTIVE))); DeactivateContext (); } _pCurContext = Context; if (_pCurContext) { ActivateContext (); _GraphicsStatusFlags &= ~(GRAPHICS_ACTIVE | DRAWABLE_ACTIVE); _GraphicsStatusFlags |= HIBYTE (_get_context_flags ()); SetPrimColor (&_locPrim, _get_context_fg_color ()); _CurFramePtr = _get_context_fg_frame (); _CurFontPtr = _get_context_font (); } } return (LastContext); } #ifdef DEBUG CONTEXT CreateContextAux (const char *name) #else /* if !defined(DEBUG) */ CONTEXT CreateContextAux (void) #endif /* !defined(DEBUG) */ { CONTEXT NewContext; NewContext = AllocContext (); if (NewContext) { /* initialize context */ #ifdef DEBUG NewContext->name = name; NewContext->next = NULL; *contextEnd = NewContext; contextEnd = &NewContext->next; #endif /* DEBUG */ NewContext->Mode = DEFAULT_DRAW_MODE; NewContext->ForeGroundColor = DEFAULT_FORE_COLOR; NewContext->BackGroundColor = DEFAULT_BACK_COLOR; } return NewContext; }
static VP_ContextSlot AllocContext_m (VP_cl *self ) { return VP$AllocContext(self); }
BOOL WINAPI BackupRead( HANDLE hFile, LPBYTE lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, BOOL bAbort, BOOL bProcessSecurity, LPVOID *lpContext) { BACKUPCONTEXT *pbuc; BACKUPIOFRAME bif; BOOL fSuccess = FALSE; pbuc = *lpContext; bif.pIoBuffer = lpBuffer; bif.cbRequest = nNumberOfBytesToRead; bif.pcbTransfered = lpNumberOfBytesRead; bif.fProcessSecurity = bProcessSecurity; if (bAbort) { if (pbuc != NULL) { FreeContext(lpContext); } return(TRUE); } *bif.pcbTransfered = 0; if (pbuc == INVALID_HANDLE_VALUE || bif.cbRequest == 0) { return(TRUE); } if (pbuc != NULL && mwStreamList[pbuc->StreamIndex] == BACKUP_INVALID) { FreeContext(lpContext); return(TRUE); } // Allocate our Context Control Block on first call. if (pbuc == NULL) { pbuc = AllocContext(CBMIN_BUFFER); // Alloc initial buffer } if (pbuc != NULL) { *lpContext = pbuc; do { if (pbuc->fStreamStart) { pbuc->head.Size.LowPart = 0; pbuc->head.Size.HighPart = 0; pbuc->liStreamOffset.LowPart = 0; pbuc->liStreamOffset.HighPart = 0; pbuc->fMultiStreamType = FALSE; } fSuccess = TRUE; switch (mwStreamList[pbuc->StreamIndex]) { case BACKUP_DATA: fSuccess = BackupReadData(hFile, pbuc, &bif); break; case BACKUP_ALTERNATE_DATA: fSuccess = BackupReadAlternateData(hFile, pbuc, &bif); break; case BACKUP_EA_DATA: fSuccess = BackupReadEaData(hFile, pbuc, &bif); break; case BACKUP_SECURITY_DATA: fSuccess = BackupReadSecurityData(hFile, pbuc, &bif); break; #ifdef BACKUP_OLEINFO case BACKUP_PROPERTY_DATA: fSuccess = BackupReadOleData(hFile, pbuc, &bif); break; #endif // BACKUP_OLEINFO default: pbuc->StreamIndex++; pbuc->fStreamStart = TRUE; break; } // if we're in the phase of reading the header, copy the header if (pbuc->liStreamOffset.LowPart < pbuc->cbHeader && pbuc->liStreamOffset.HighPart == 0) { DWORD cbrequest; // Send the current stream header; cbrequest = min( pbuc->cbHeader - pbuc->liStreamOffset.LowPart, bif.cbRequest); RtlCopyMemory( bif.pIoBuffer, (BYTE *) &pbuc->head + pbuc->liStreamOffset.LowPart, cbrequest); ReportTransfer(pbuc, &bif, cbrequest); } // // if we are at the end of a stream then // start at the beginning of the next stream // else { BackupTestRestartStream(pbuc); } } while (fSuccess && mwStreamList[pbuc->StreamIndex] != BACKUP_INVALID && bif.cbRequest != 0); } if (fSuccess && *bif.pcbTransfered == 0) { FreeContext(lpContext); } return(fSuccess); }
BOOL WINAPI BackupWrite( HANDLE hFile, LPBYTE lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, BOOL bAbort, BOOL bProcessSecurity, LPVOID *lpContext) { BACKUPCONTEXT *pbuc; BACKUPIOFRAME bif; BOOL fSuccess = FALSE; pbuc = *lpContext; bif.pIoBuffer = lpBuffer; bif.cbRequest = nNumberOfBytesToWrite; bif.pcbTransfered = lpNumberOfBytesWritten; bif.fProcessSecurity = bProcessSecurity; // // Allocate our Context Control Block on first call. // if (bAbort) { if (pbuc != NULL) { FreeContext(lpContext); } return(TRUE); } *bif.pcbTransfered = 0; if (pbuc == INVALID_HANDLE_VALUE) { return(TRUE); } // Allocate our Context Control Block on first call. if (pbuc == NULL) { pbuc = AllocContext(0); // No initial buffer } if (pbuc != NULL) { *lpContext = pbuc; do { DWORD cbrequest; LARGE_INTEGER licbRemain; if (pbuc->cbHeader == 0) { // we expect a stream header // fill up to the stream name BackupWriteHeader(pbuc, &bif, CB_NAMELESSHEADER); } if (bif.cbRequest == 0) { return(TRUE); } if (pbuc->cbHeader == CB_NAMELESSHEADER && pbuc->head.dwStreamNameSize != 0) { // now fill in the stream name if it exists BackupWriteHeader( pbuc, &bif, pbuc->cbHeader + pbuc->head.dwStreamNameSize); if (bif.cbRequest == 0) { return(TRUE); } } cbrequest = ComputeRequestSize(pbuc, bif.cbRequest); ComputeRemainingSize(pbuc, &licbRemain); if (pbuc->fAccessError && licbRemain.HighPart == 0 && licbRemain.LowPart == 0) { ReportTransfer(pbuc, &bif, cbrequest); continue; } pbuc->fAccessError = FALSE; switch (pbuc->head.dwStreamId) { case BACKUP_DATA: pbuc->fStreamStart = FALSE; fSuccess = BackupWriteStream(hFile, pbuc, &bif); break; case BACKUP_ALTERNATE_DATA: fSuccess = BackupWriteAlternateData(hFile, pbuc, &bif); break; case BACKUP_EA_DATA: fSuccess = BackupWriteEaData(hFile, pbuc, &bif); break; case BACKUP_SECURITY_DATA: fSuccess = BackupWriteSecurityData(hFile, pbuc, &bif); break; case BACKUP_LINK: fSuccess = BackupWriteLinkData(hFile, pbuc, &bif); break; #ifdef BACKUP_OLEINFO case BACKUP_PROPERTY_DATA: fSuccess = BackupWriteOleData(hFile, pbuc, &bif); break; #endif // BACKUP_OLEINFO default: SetLastError(ERROR_INVALID_DATA); fSuccess = FALSE; break; } BackupTestRestartStream(pbuc); } while (fSuccess && bif.cbRequest != 0); } if (fSuccess && *bif.pcbTransfered == 0) { FreeContext(lpContext); } return(fSuccess); }