Skip to content

Commit

Permalink
Remove NLog dependancy
Browse files Browse the repository at this point in the history
  • Loading branch information
skadefro committed May 23, 2022
1 parent e63b6c3 commit ef121ef
Show file tree
Hide file tree
Showing 23 changed files with 9 additions and 10,917 deletions.
127 changes: 0 additions & 127 deletions ibm5250/Emulator/classEmulator.vb

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions ibm5250/Emulator/classLocalization.vb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Partial Class Emulator
Public Class Localization
Private Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
Public Locales As SortedList(Of String, Locale)
Public Sub New()
Locales = New SortedList(Of String, Locale)
Expand All @@ -25,18 +24,14 @@
Try
Locales.Add(loc(0), New Locale(loc(0), System.Text.Encoding.GetEncoding(loc(1)), loc(2), loc(3), loc(4)))
Catch ex As Exception
Logger.Warn("Error adding locale definition from '" & fname & "' line " & LineNumber & ": " & ex.Message)
End Try
Else
Logger.Warn("Invalid Locale definition in '" & fname & "' line " & LineNumber & ": incorrect number of fields")
End If
End If
End If
s = sr.ReadLine
Loop
End If
Catch ex As Exception
Logger.Warn(ex.Message)
Finally
If sr IsNot Nothing Then sr.Close()
End Try
Expand Down
4 changes: 0 additions & 4 deletions ibm5250/IBM5250.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Reference\GA21-9247-2.pdf" />
<None Include="Reference\SC30-3533-04.pdf" />
<None Include="Reference\SC41-5401-00.pdf" />
Expand Down
3,531 changes: 0 additions & 3,531 deletions ibm5250/NLog.xsd

This file was deleted.

4 changes: 0 additions & 4 deletions ibm5250/packages.config

This file was deleted.

4 changes: 0 additions & 4 deletions ibmiclient/IBMiClient/IBMiClient.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="LICENSE.txt">
Expand Down
3,531 changes: 0 additions & 3,531 deletions ibmiclient/IBMiClient/NLog.xsd

This file was deleted.

5 changes: 0 additions & 5 deletions ibmiclient/IBMiClient/Signon/classMessageHeader.vb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ Partial Public Class Client
Public RequestReplyID As MessageType
Public Shared HeaderLength As Integer = 20

Private Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger

Public Sub New(HeaderBytes() As Byte)
Logger.Trace("")
If HeaderBytes.Length <> HeaderLength Then Throw New ArgumentException("Incorrect number of bytes to interpret as a message header")
Dim Data As New System.IO.MemoryStream(HeaderBytes)
Me.MessageLength = ReadUInt32(Data)
Expand All @@ -48,7 +45,6 @@ Partial Public Class Client
End Sub

Friend Sub New(MsgType As MessageType)
Logger.Trace("")
Me.MessageLength = 0
Me.HeaderID = 0
Me.ServerID = &HE009 'XXX what does this mean?
Expand All @@ -72,7 +68,6 @@ Partial Public Class Client
End Sub

Public Function ToBytes() As Byte()
Logger.Trace("")
Dim Data As New System.IO.MemoryStream
Dim b() As Byte = ToBigEndianBytes(Me.MessageLength)
Data.Write(b, 0, b.Length)
Expand Down
66 changes: 4 additions & 62 deletions ibmiclient/IBMiClient/Signon/classSignon.vb
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ Partial Public Class Client
Private Port_ As Integer
Private ClientSeed_(7) As Byte 'Most recently used client seed

Private Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger

Public Sub New(Host As String, Port As Integer, UseSSL As Boolean)
Logger.Trace("Host='" & Host & "', Port='" & Port.ToString & "'")
If String.IsNullOrWhiteSpace(Host) Then Throw New ArgumentException("Host cannot be null")
If Port < 1 Then Throw New Exception("The Port parameter is not valid")
Host_ = Host
Expand Down Expand Up @@ -140,7 +137,6 @@ Partial Public Class Client
Return Connect(Host_, Port_, TimeoutMS)
End Function
Private Function Connect(Host As String, Port As Integer, TimeoutMS As Integer) As Boolean
Logger.Trace("")
If String.IsNullOrWhiteSpace(Host) Then Throw New ArgumentException("Host cannot be null")
If Port_ < 1 Then Throw New Exception("The Port parameter is not valid")
Try
Expand All @@ -155,27 +151,23 @@ Partial Public Class Client
If UseSSL_ Then CertActionDone.WaitOne() 'Wait for SSL negotiation to complete. We may be waiting for the user to accept the remote certificate, so don't time out.
ConnectDone.WaitOne() 'Wait for ConnectCallback to complete.
If ConnectException IsNot Nothing Then Throw ConnectException
Logger.Debug("Success")
Return True
Else
Throw New Exception("Failed to connect to host '" & Host & "' on port " & Port.ToString)
End If
Catch ex As Exception
Logger.Error(ex)
Try
tc.Close()
Catch exx As ObjectDisposedException
'Do nothing; this happens after we've already disconnected.
Catch exx As Exception
Logger.Error(exx)
End Try
Throw
End Try
Return False
End Function

Private Sub ConnectCallback(ByVal ar As IAsyncResult)
Logger.Trace("")
Try
' Complete the connection.
tc.EndConnect(ar)
Expand All @@ -189,7 +181,6 @@ Partial Public Class Client
End If
ConnectDone.Set() 'Signal that the connection attempt has completed.
Catch ex As Exception
Logger.Error(ex)
ConnectException = ex
CertActionDone.Set() 'Signal that SSL authentication has completed so we don't wait forever.
ConnectDone.Set() 'Signal that the connection attempt has completed. Don't move this to a Finally block or Disconnect() will hang waiting for the signal.
Expand All @@ -198,9 +189,8 @@ Partial Public Class Client
End Sub

Private Function ServerCertificateValidationCallback(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
Logger.Trace("")
Try
If sslPolicyErrors = sslPolicyErrors.None Then
If sslPolicyErrors = SslPolicyErrors.None Then
Return True
Else
Dim Store As New X509Store(StoreName.TrustedPeople, StoreLocation.CurrentUser)
Expand All @@ -213,9 +203,9 @@ Partial Public Class Client

'We didn't find the cert in the store, so prompt the user.
Dim Reasons As New List(Of String)
If sslPolicyErrors And sslPolicyErrors.RemoteCertificateNotAvailable Then Reasons.Add("Remote certificate not available")
If sslPolicyErrors And sslPolicyErrors.RemoteCertificateNameMismatch Then Reasons.Add("Remote certificate name mismatch")
If sslPolicyErrors And sslPolicyErrors.RemoteCertificateChainErrors Then Reasons.Add("Remote certificate chain errors")
If sslPolicyErrors And SslPolicyErrors.RemoteCertificateNotAvailable Then Reasons.Add("Remote certificate not available")
If sslPolicyErrors And SslPolicyErrors.RemoteCertificateNameMismatch Then Reasons.Add("Remote certificate name mismatch")
If sslPolicyErrors And SslPolicyErrors.RemoteCertificateChainErrors Then Reasons.Add("Remote certificate chain errors")
Dim tmpDate As Date
If Date.TryParse(certificate.GetEffectiveDateString, tmpDate) Then
If tmpDate > Now Then Reasons.Add("Remote certificate is not yet valid")
Expand Down Expand Up @@ -263,15 +253,13 @@ Partial Public Class Client
End If
End If
Catch ex As Exception
Logger.Error(ex)
Return False
Finally
CertActionDone.Set()
End Try
End Function

Private Sub SayGoodBye()
Logger.Trace("")
If tc IsNot Nothing Then
Dim Bye As New MessageHeader(MessageType.EndServerRequest)
Dim b() As Byte = Bye.ToBytes
Expand All @@ -280,25 +268,17 @@ Partial Public Class Client
End Sub

Private Sub Disconnect()
Logger.Trace("")
Try
If tc IsNot Nothing Then tc.Close()
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub

Public Function Get_Server_Attributes(TimeoutMS As Integer) As ServerInfo
Logger.Trace("")
Connect(TimeoutMS)
Dim AttributeReply As Signon.Exchange_Attribute_Reply = Get_Server_AttributesX(TimeoutMS)
SayGoodBye()
Disconnect()
Logger.Debug("Server Version: V" & AttributeReply.ServerVersion_Version.ToString & "R" & AttributeReply.ServerVersion_Release.ToString & "M" & AttributeReply.ServerVersion_Modification.ToString)
Logger.Debug("Server Level: " & AttributeReply.ServerLevel)
Logger.Debug("Server Seed: " & BitConverter.ToString(AttributeReply.ServerSeed))
Logger.Debug("Password Level: " & AttributeReply.PasswordLevel)
Logger.Debug("Job Name: " & AttributeReply.JobName.Trim)
Dim Result As New ServerInfo
Result.Host = Me.Host_
Result.Version = AttributeReply.ServerVersion_Version
Expand All @@ -312,12 +292,10 @@ Partial Public Class Client
End Function

Private Function Get_Server_AttributesX(TimeoutMS As Integer) As Signon.Exchange_Attribute_Reply
Logger.Trace("")
Dim MsgHeader As New Signon.MessageHeader(MessageType.ExchangeAttributeRequest)
Dim AttributeRequest As New Signon.Exchange_Attribute_Request(MsgHeader)
Array.Copy(AttributeRequest.ClientSeed, ClientSeed_, ClientSeed_.Length)
Dim b() As Byte = AttributeRequest.ToBytes
Logger.Debug("Request: " & BitConverter.ToString(b))
stream.Write(b, 0, b.Length)

Dim o As Object = GetReply(TimeoutMS)
Expand All @@ -338,13 +316,6 @@ Partial Public Class Client
Dim InfoReply As Signon.Info_Reply = Get_Signon_InfoX(UserName, Password, TimeoutMS)
SayGoodBye()
Disconnect()
Logger.Debug("ResultCode: " & InfoReply.ResultCode.ToString)
Logger.Debug("ResultText: " & InfoReply.ResultText)
Logger.Debug("CurrentSignonDate: " & InfoReply.CurrentSignonDate.ToString)
Logger.Debug("LastSignonDate: " & InfoReply.LastSignonDate.ToString)
Logger.Debug("ExpirationDate: " & InfoReply.ExpirationDate.ToString)
Logger.Debug("ExpirationWarning: " & InfoReply.ExpirationWarning.ToString)
Logger.Debug("ServerCCSID: " & InfoReply.ServerCCSID.ToString)
Dim Result As New SignonInfo
Result.Code = InfoReply.ResultCode
Result.Text = InfoReply.ResultText
Expand All @@ -355,15 +326,6 @@ Partial Public Class Client
'XXX more props here?
Result.Messages = New List(Of SignonInfoMessage)
For Each Msg As Signon.Info_Message In InfoReply.Messages
Logger.Debug(" -Message-")
Logger.Debug(" Severity: " & Msg.Severity.ToString)
Logger.Debug(" ReasonCode: " & Msg.ReasonCode)
Logger.Debug(" ReasonText: " & Msg.ReasonText)
Logger.Debug(" FileName: " & Msg.FileName)
Logger.Debug(" LibraryName: " & Msg.LibraryName)
Logger.Debug(" Text: " & Msg.Text)
Logger.Debug(" Help: " & Msg.Help)
Logger.Debug("")
Dim ResultMessage As New SignonInfoMessage
ResultMessage.Severity = CInt(Msg.Severity)
ResultMessage.ReasonCode = Msg.ReasonCode
Expand All @@ -378,13 +340,11 @@ Partial Public Class Client
End Function

Private Function Get_Signon_InfoX(UserName As String, Password As String, TimeoutMS As Integer) As Signon.Info_Reply
Logger.Trace("")
Dim AttributeReply As Signon.Exchange_Attribute_Reply = Get_Server_AttributesX(TimeoutMS)

Dim MsgHeader As New Signon.MessageHeader(MessageType.InfoRequest)
Dim InfoReq As New Signon.Info_Request(MsgHeader, ClientSeed_, AttributeReply.ServerSeed, UserName, Password, AttributeReply.PasswordLevel, AttributeReply.ServerLevel)
Dim b() As Byte = InfoReq.ToBytes
Logger.Debug("Request: " & BitConverter.ToString(b))
stream.Write(b, 0, b.Length)

Dim o As Object = GetReply(TimeoutMS)
Expand All @@ -397,28 +357,16 @@ Partial Public Class Client
End Function

Public Function Change_Password(UserName As String, Password As String, NewPassword As String, TimeoutMS As Integer) As ChangePasswordInfo
Logger.Trace("")
Connect(TimeoutMS)
Dim ChangePasswordReply As Signon.Change_Password_Reply = Change_PasswordX(UserName, Password, NewPassword, TimeoutMS)
SayGoodBye()
Disconnect()
Logger.Debug("ResultCode: " & ChangePasswordReply.ResultCode.ToString)
Logger.Debug("ResultText: " & ChangePasswordReply.ResultText)
'XXX more props here?
Dim Result As New ChangePasswordInfo
Result.Code = ChangePasswordReply.ResultCode
Result.Text = ChangePasswordReply.ResultText
Result.Messages = New List(Of SignonInfoMessage)
For Each Msg As Signon.Info_Message In ChangePasswordReply.Messages
Logger.Debug(" -Message-")
Logger.Debug(" Severity: " & Msg.Severity.ToString)
Logger.Debug(" ReasonCode: " & Msg.ReasonCode)
Logger.Debug(" ReasonText: " & Msg.ReasonText)
Logger.Debug(" FileName: " & Msg.FileName)
Logger.Debug(" LibraryName: " & Msg.LibraryName)
Logger.Debug(" Text: " & Msg.Text)
Logger.Debug(" Help: " & Msg.Help)
Logger.Debug("")
Dim InfoMsg As New SignonInfoMessage
InfoMsg.Severity = Msg.Severity
InfoMsg.ReasonCode = Msg.ReasonCode
Expand All @@ -433,13 +381,11 @@ Partial Public Class Client
End Function

Private Function Change_PasswordX(UserName As String, Password As String, NewPassword As String, TimeoutMS As Integer) As Signon.Change_Password_Reply
Logger.Trace("")
Dim AttributeReply As Signon.Exchange_Attribute_Reply = Get_Server_AttributesX(TimeoutMS)

Dim MsgHeader As New Signon.MessageHeader(MessageType.ChangePasswordRequest)
Dim ChangePasswordRequest As New Signon.Change_Password_Request(MsgHeader, ClientSeed_, AttributeReply.ServerSeed, UserName, Password, NewPassword, AttributeReply.PasswordLevel, AttributeReply.ServerLevel)
Dim b() As Byte = ChangePasswordRequest.ToBytes
Logger.Debug("Request: " & BitConverter.ToString(b))
stream.Write(b, 0, b.Length)

Dim o As Object = GetReply(TimeoutMS)
Expand All @@ -452,7 +398,6 @@ Partial Public Class Client
End Function

Private Function GetReply(TimeoutMS As Integer) As Object
Logger.Trace("")
Try
Dim b() As Byte
b = ReadTCPBytes(stream, MessageHeader.HeaderLength, TimeoutMS)
Expand All @@ -469,13 +414,11 @@ Partial Public Class Client
Throw New Exception("Unimplemented Reply type: " & Header.RequestReplyID.ToString)
End Select
Catch ex As Exception
Logger.Error(ex)
End Try
Return Nothing
End Function

Private Function ReadTCPBytes(ByRef s As System.IO.Stream, ByVal ExpectedBytes As Integer, ByVal TimeoutMS As Integer) As Byte()
Logger.Trace("ExpectedBytes='" & ExpectedBytes.ToString & "'")
If Not s.CanRead Then Throw New Exception("Supplied stream is not readable")
Dim start As Date = Now
Dim BytesRead As Integer = 0
Expand All @@ -485,7 +428,6 @@ Partial Public Class Client
If BytesRead >= ExpectedBytes Then Exit Do
Threading.Thread.CurrentThread.Join(100)
Loop
Logger.Debug("Expected bytes=" & ExpectedBytes.ToString & ", Actual bytes=" & BytesRead.ToString)
If BytesRead < ExpectedBytes Then Throw New Exception("Insufficient data received from the server")
Return b
End Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ Partial Public Class Client
'Derived fields
Friend ResultText As String

Private Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger

Public Sub New(ByVal MsgHeader As MessageHeader, ByVal DataBytes() As Byte)
Logger.Trace("")
If MsgHeader.RequestReplyID <> MessageType.ChangePasswordReply Then Throw New ArgumentException("The supplied header is not the correct message type")
Me.Header = MsgHeader
If DataBytes.Length < 4 Then Throw New ArgumentException("The supplied data buffer is too short to contain a result code")
Expand Down Expand Up @@ -65,7 +62,6 @@ Partial Public Class Client
'Case CodePoints.ServerCCSID
' Me.ServerCCSID = ReadUInt32(Data)
Case Else
Logger.Debug("Unexpected codepoint: " & CodePoint.ToString)
'Read the rest of the record and throw it away
Dim b(RecLen - 6 - 1) As Byte
Data.Read(b, 0, b.Length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ Public Class Client
Private ServerSeed() As Byte
Private ClientSeed() As Byte

Private Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger

Public Sub New(ByVal MsgHeader As MessageHeader, ClientSeed() As Byte, ServerSeed() As Byte, UserName As String, Password As String, NewPassword As String, PasswordLevel As Byte, ServerLevel As UInt16)
Logger.Trace("")
If MsgHeader.RequestReplyID <> MessageType.ChangePasswordRequest Then Throw New ArgumentException("The supplied header is not the correct message type")
Me.Header = MsgHeader
Me.UserID = UserName.ToUpper
Expand Down Expand Up @@ -68,7 +65,6 @@ Public Class Client
End Sub

Public Function ToBytes() As Byte()
Logger.Trace("")
Dim Data As New System.IO.MemoryStream
Dim b() As Byte = Me.Header.ToBytes()
Data.Write(b, 0, b.Length)
Expand Down
Loading

0 comments on commit ef121ef

Please sign in to comment.