//--------------------------------------------------------------------// // M e t h o d // // a n a l y s e F o n t H d d r // //--------------------------------------------------------------------// // // // Provide an interpretation of the contents of a PCL XL soft font // // header. // // // //--------------------------------------------------------------------// public Boolean analyseFontHddr(Int32 hddrLen, Byte [] buf, Int32 fileOffset, ref Int32 bufRem, ref Int32 bufOffset, PrnParseLinkData linkData, PrnParseOptions options, DataTable table) { Int32 binDataLen; Boolean validSegs = false; PrnParseConstants.eContType contType; Boolean continuation = false; //----------------------------------------------------------------// // // // Initialise. // // // //----------------------------------------------------------------// _table = table; _buf = buf; _fileOffset = fileOffset; _analysisLevel = linkData.AnalysisLevel; _options = options; contType = linkData.getContType(); _indxOffsetFormat = _options.IndxGenOffsetFormat; _showBinData = _options.FlagPCLXLMiscBinData; //----------------------------------------------------------------// if (contType == PrnParseConstants.eContType.None) { _nextStage = eStage.Start; _validHddr = true; _firstSeg = true; _hddrLen = hddrLen; _hddrRem = hddrLen; _hddrPos = fileOffset + bufOffset; } else { contType = PrnParseConstants.eContType.None; linkData.resetContData(); } //----------------------------------------------------------------// if (_nextStage == eStage.Start) { if (bufRem < _cHddrDescLen) { //--------------------------------------------------------// // // // Font header descriptor is not all in buffer. // // Initiate continuation. // // // //--------------------------------------------------------// contType = PrnParseConstants.eContType.PCLXLFontHddr; linkData.setBacktrack(contType, -bufRem); } else { _nextStage = eStage.ShowHddr; } } if (_nextStage == eStage.ShowHddr) { //------------------------------------------------------------// // // // Process font header. // // // //------------------------------------------------------------// processFontHeader(ref bufRem, ref bufOffset); bufRem = bufRem - _cHddrDescLen; _hddrRem = _hddrRem - _cHddrDescLen; bufOffset = bufOffset + _cHddrDescLen; if (_validHddr) { _nextStage = eStage.ShowData; } else { _nextStage = eStage.BadSeqA; } } if (_nextStage == eStage.ShowData) { //------------------------------------------------------------// // // // Output details of segmented data: // // // //------------------------------------------------------------// Int32 dummy = 0; continuation = _parseSegs.processSegData(_buf, _fileOffset, false, _firstSeg, true, ref bufRem, ref bufOffset, ref _hddrDataRem, ref _hddrRem, ref dummy, ref validSegs, linkData, _options, _table); _firstSeg = false; } if (_nextStage == eStage.EndOK) { //------------------------------------------------------------// // // // End of processing of valid header. // // // //------------------------------------------------------------// return(_validHddr); } if (_nextStage == eStage.BadSeqA) { //------------------------------------------------------------// // // // Inconsistency found. // // // //------------------------------------------------------------// _nextStage = eStage.BadSeqB; PrnParseCommon.addTextRow( PrnParseRowTypes.eType.MsgError, _table, PrnParseConstants.eOvlShow.None, "", "", "", "Processing of header abandoned!"); } if ((_nextStage == eStage.BadSeqB) && (_hddrRem != 0)) { //------------------------------------------------------------// // // // Header does not appear to be valid. // // Treat remainder of header as a binary sequence without // // interpretation. // // Check if remainder of download sequence is within the // // buffer. // // // //------------------------------------------------------------// if (_hddrRem > bufRem) { //--------------------------------------------------------// // // // Remainder of sequence is not in buffer. // // Initiate continuation. // // // //--------------------------------------------------------// contType = PrnParseConstants.eContType.PCLXLFontHddr; binDataLen = bufRem; _hddrRem = _hddrRem - bufRem; linkData.setContinuation(contType); } else { contType = PrnParseConstants.eContType.None; linkData.resetContData(); binDataLen = _hddrRem; _hddrRem = 0; } if ((binDataLen) != 0) { //--------------------------------------------------------// // // // Some, or all, of the download data is contained within // // the current 'block'. // // // //--------------------------------------------------------// PrnParseData.processBinary( _table, PrnParseConstants.eOvlShow.None, buf, fileOffset, bufOffset, binDataLen, "PCLXL Binary", _showBinData, false, true, _indxOffsetFormat, _analysisLevel); bufRem = bufRem - binDataLen; bufOffset = bufOffset + binDataLen; } } return(_validHddr); }
//--------------------------------------------------------------------// // M e t h o d // // f i n d P J L T e r m i n a t o r // //--------------------------------------------------------------------// // // // Search for PJL terminator character. // // This should be a LineFeed (<LF>, 0x0a) character, but may be an // // Escape character (<Esc>, 0x1b) signalling return to PCL. // // // // This is to make sure that the termination character is in the // // buffer before processing the command, so that we don't have to // // cater for doing a 'continuation' read part way through processing // // the command. // // // // Initiate continuation action if terminator is not found in buffer, // // subject to a maximum command length (to prevent recursive // // continuation actions). // // // //--------------------------------------------------------------------// private Boolean findPJLTerminator( Int32 bufRem, Int32 bufOffset, ref Int32 commandLen, ref Boolean continuation) { PrnParseConstants.eContType contType = PrnParseConstants.eContType.None; Byte crntByte; Int32 cmdLen, rem, offset; Boolean foundTerm, foundLF; continuation = false; foundTerm = false; foundLF = false; rem = bufRem - _lenPJLIntro; offset = bufOffset + _lenPJLIntro; cmdLen = _lenPJLIntro; //----------------------------------------------------------------// // // // Search for termination character. // // // //----------------------------------------------------------------// while ((!foundTerm) && (rem > 0) && (cmdLen < _maxPJLCmdLen)) { crntByte = _buf[offset]; if (crntByte == PrnParseConstants.asciiLF) { foundLF = true; foundTerm = true; offset++; cmdLen++; rem--; } else if (crntByte == PrnParseConstants.asciiEsc) { foundTerm = true; } else { offset++; cmdLen++; rem--; } } if ((!foundTerm) && (cmdLen != _maxPJLCmdLen)) { //------------------------------------------------------------// // // // Termination character not found before buffer exhausted, // // or maximum command length exceeded. // // Initiate (backtracking) continuation action. // // // //------------------------------------------------------------// continuation = true; contType = PrnParseConstants.eContType.PJL; _linkData.setBacktrack(contType, -bufRem); commandLen = 0; } else { commandLen = cmdLen; } return(foundLF); }