Example #1
0
        //--------------------------------------------------------------------//
        //                                                        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);
        }
Example #2
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // a d d D a t a R o w                                                //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Adds a row, with numeric offset value, to the output table.        //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void addDataRow(
            PrnParseRowTypes.eType rowType,
            DataTable table,
            PrnParseConstants.eOvlShow makeOvlShow,
            PrnParseConstants.eOptOffsetFormats indxOffsetFormat,
            Int32 offset,
            Int32 level,
            String type,
            String seq,
            String desc)
        {
            if (_parseType == PrnParse.eParseType.ScanForPDL)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Output inhibited.                                          //
                //                                                            //
                //------------------------------------------------------------//
            }
            else if ((_parseType == PrnParse.eParseType.MakeOverlay)
                     &&
                     (makeOvlShow ==
                      PrnParseConstants.eOvlShow.None))
            {
                //------------------------------------------------------------//
                //                                                            //
                // Output inhibited.                                          //
                //                                                            //
                //------------------------------------------------------------//
            }
            else if ((!_showMacroData) && (_macroLevel > 0))
            {
                //------------------------------------------------------------//
                //                                                            //
                // Output inhibited (e.g. don't show PCL macro contents); do  //
                // nothing.                                                   //
                //                                                            //
                //------------------------------------------------------------//
            }
            else
            {
                DataRow row;

                String offsetText;

                row = table.NewRow();

                if (offset < 0)
                {
                    if (offset ==
                        (Int32)PrnParseConstants.eOffsetPosition.StartOfFile)
                    {
                        offsetText = "<Start>";
                    }
                    else if (offset ==
                             (Int32)PrnParseConstants.eOffsetPosition.EndOfFile)
                    {
                        offsetText = "<End>";
                    }
                    else
                    {
                        offsetText = "";
                    }
                }
                else
                {
                    if (indxOffsetFormat ==
                        PrnParseConstants.eOptOffsetFormats.Decimal)
                    {
                        if (level == 0)
                        {
                            offsetText = String.Format("{0:d10}", offset);
                        }
                        else
                        {
                            offsetText = String.Format("{0:d2}", level) + ":" +
                                         String.Format("{0:d10}", offset);
                        }
                    }
                    else
                    {
                        if (level == 0)
                        {
                            offsetText = String.Format("{0:x8}", offset);
                        }
                        else
                        {
                            offsetText = String.Format("{0:x2}", level) + ":" +
                                         String.Format("{0:x8}", offset);
                        }
                    }
                }

                if ((_parseType == PrnParse.eParseType.MakeOverlay) &&
                    (makeOvlShow != PrnParseConstants.eOvlShow.None))
                {
                    row[_colName_Action] = makeOvlShow.ToString();
                }

                row[_colName_RowType] = (Int32)rowType;
                // row[_colName_RowType] = rowType.ToString(); // **** DIAG ************
                row[_colName_Offset] = offsetText;
                row[_colName_Type]   = type;
                row[_colName_Seq]    = seq;
                row[_colName_Desc]   = desc;

                table.Rows.Add(row);
            }
        }
Example #3
0
        //--------------------------------------------------------------------//
        //                                                        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);
        }