/// <summary> /// peek at current location in input array for a 5250 data stream header. If is /// a valid header, return a DataStreamHeader. Otherwise, return null. /// </summary> /// <param name="InputArray"></param> /// <returns></returns> public static DataStreamHeader PeekDataStreamHeader(this InputByteArray InputArray) { DataStreamHeader dsh = null; if (InputArray.IsDataStreamHeader( ) == true) { var buf = new InputByteArray(InputArray.PeekBytesLenient(100)); var rv = DataStreamHeader.Factory(buf); dsh = rv.Item1; } return(dsh); }
/// <summary> /// look at the current bytes of the input array. Determine what type of data /// stream command is starting. /// </summary> /// <param name="InputArray"></param> /// <returns></returns> public static TypeServerData?PeekServerCommand( InputByteArray InputArray) { TypeServerData?typeData = null; if (InputArray.IsEof() == true) { typeData = TypeServerData.eof; } else if (InputArray.PeekTelnetCommandCode() != null) { typeData = TypeServerData.telnetCommand; } else if (InputArray.IsDataStreamHeader() == true) { typeData = TypeServerData.workstationHeader; } return(typeData); }
ParseWorkstationCommandList( InputByteArray InputArray, SessionSettings SessionSettings) { var wrkstnCmdList = new WorkstationCommandList(); DataStreamHeader dsh = null; bool gotEOR = false; bool needMoreBytes = false; string errmsg = null; if (InputArray.IsDataStreamHeader()) { var rv = DataStreamHeader.Factory(InputArray); dsh = rv.Item1; errmsg = rv.Item2; } bool lastCmdWasTelnet_EOR = false; bool gotWorkstationCommand = true; gotEOR = false; while ((InputArray.IsEof( ) == false) && (gotEOR == false) && (gotWorkstationCommand == true)) { // no input data to process. lastCmdWasTelnet_EOR = false; gotWorkstationCommand = false; // check for IAC EOR var telCode = InputArray.PeekTelnetCommandCode(CommandCode.EOR); if (telCode != null) { var telCmd = InputArray.NextTelnetCommand(); lastCmdWasTelnet_EOR = true; gotEOR = true; } // process the input as workstation data stream commands. else { var rv = ParseAndProcessWorkstationCommand(InputArray); var workstationCommand = rv.Item1; var howRead = rv.Item2; if (workstationCommand != null) { wrkstnCmdList.Add(workstationCommand); gotWorkstationCommand = true; } } } // read available bytes from input stream. if (InputArray.IsEof() && (lastCmdWasTelnet_EOR == false)) { needMoreBytes = true; } return(new Tuple <DataStreamHeader, WorkstationCommandList, bool, bool>( dsh, wrkstnCmdList, gotEOR, needMoreBytes)); }