//--------------------------------------------------------------------// // M e t h o d // // p a r s e B u f f e r // //--------------------------------------------------------------------// // // // Parse provided buffer, assuming that the current print language is // // PJL. // // // //--------------------------------------------------------------------// public Boolean parseBuffer( Byte [] buf, ref Int32 fileOffset, ref Int32 bufRem, ref Int32 bufOffset, ref ToolCommonData.ePrintLang crntPDL, ref Boolean endReached, PrnParseLinkData linkData, PrnParseOptions options, DataTable table) { Boolean seqInvalid; //----------------------------------------------------------------// // // // Initialise. // // // //----------------------------------------------------------------// _buf = buf; _linkData = linkData; _options = options; _table = table; _fileOffset = fileOffset; _analysisLevel = _linkData.AnalysisLevel; seqInvalid = false; //----------------------------------------------------------------// _indxOffsetFormat = _options.IndxGenOffsetFormat; _options.getOptCharSet(ref _indxCharSetName, ref _indxCharSetSubAct, ref _valCharSetSubCode); _endOffset = _options.ValCurFOffsetEnd; _showPML = _options.FlagPMLWithinPJL; //----------------------------------------------------------------// if (linkData.isContinuation()) { seqInvalid = parseContinuation(ref bufRem, ref bufOffset, ref crntPDL, ref endReached); } else { seqInvalid = parseSequences(ref bufRem, ref bufOffset, ref crntPDL, ref endReached); } return(seqInvalid); }
//--------------------------------------------------------------------// // M e t h o d // // v i e w F i l e A c t i o n // //--------------------------------------------------------------------// // // // View file contents. // // // //--------------------------------------------------------------------// private void viewFileAction(PrnParseOptions options, DataTable table) { Int32 blockLen, sliceLen, blockStart = 0; Int32 offsetStart = 0, offsetEnd = -1, offsetCrnt; String offsetFormat; String offsetStr; Boolean rowLimitReached = false; Boolean endReached = false; Byte[] buf = new Byte[PrnParseConstants.bufSize]; //----------------------------------------------------------------// if (options.IndxGenOffsetFormat == PrnParseConstants.eOptOffsetFormats.Hexadecimal) { offsetFormat = "{0:x8}"; } else { offsetFormat = "{0:d10}"; } options.getOptCharSet(ref _indxCharSetName, ref _indxCharSetSubAct, ref _valCharSetSubCode); //----------------------------------------------------------------// // // // Check for start conditions specific to current file. // // // //----------------------------------------------------------------// options.getOptCurFOffsets(ref offsetStart, ref offsetEnd); blockStart = offsetStart; _ipStream.Seek(offsetStart, SeekOrigin.Begin); if (offsetStart != 0) { addRow(table, "Comment", "Start Offset = " + offsetStart + " (0x" + offsetStart.ToString("X8") + ") requested", ""); } if (offsetEnd != -1) { addRow(table, "Comment", "End Offset = " + offsetEnd + " (0x" + offsetEnd.ToString("X8") + ") requested", ""); } //----------------------------------------------------------------// while (!endReached && !rowLimitReached) { //------------------------------------------------------------// // // // Read next 'block' of file. // // If end-of-file detected, block will be less than full. // // // //------------------------------------------------------------// blockLen = _binReader.Read(buf, 0, PrnParseConstants.bufSize); if (blockLen == 0) { endReached = true; } else { //--------------------------------------------------------// // // // Split the current 'block' into 'slices'. // // Each 'slice' will provide one line of the output // // display; the last 'slice' may be less than a full line.// // Other slices may also be less than a full line if the // // option to split slices when LineFeed or FormFeed // // characters are encountered is in force. // // // //--------------------------------------------------------// sliceLen = PrnParseConstants.viewBytesPerLine; for (int i = 0; ((i < blockLen) && (!endReached)); i += sliceLen) { if ((i + PrnParseConstants.viewBytesPerLine) > blockLen) { //------------------------------------------------// // // // Last slice of data is less than full. // // // //------------------------------------------------// sliceLen = blockLen - i; } else { sliceLen = PrnParseConstants.viewBytesPerLine; } //----------------------------------------------------// // // // Extract required details from current slice. // // // //----------------------------------------------------// offsetCrnt = blockStart + i; offsetStr = String.Format(offsetFormat, offsetCrnt); sliceLen = viewFileSlice(buf, offsetStr, i, sliceLen, table); if ((offsetEnd != -1) && (offsetCrnt > offsetEnd)) { endReached = true; } } //--------------------------------------------------------// // // // Increment 'block' offset value. // // // //--------------------------------------------------------// blockStart = blockStart + blockLen; if ((offsetEnd != -1) && (blockStart > offsetEnd)) { endReached = true; } } } }