Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. '#####################################################################################################
    
  2. ' Server_Telnet - Remote
    
  3. '#####################################################################################################
    
  4. ' This is a part of CIC4U
    
  5. ' CIC4U - Command Interpreter Console - Version 4 - UNIX
    
  6. '#####################################################################################################
    
  7. ' (c) Copyright and Rightcopies - 2007 By.: /_\ DeltaLab's - Deutschland
    
  8. ' Autor: Martin Wiemann
    
  9. '=====================================================================================================
    
  10. ' All rights reserved!
    
  11. '#####################################################################################################
    
  12. 
    
  13. 
    
  14. '-----------------------------------------------------------------------------------------------------
    
  15. Dim Shared G_UserSSID As String
    
  16. Dim Shared G_FromAPID As ULongInt
    
  17. Dim Shared G_FromAPData As Long
    
  18. Dim Shared G_APID As ULongInt
    
  19. Dim Shared LBreak       As String                   'Zeilenumbruch-Constante
    
  20. LBreak = Chr(13) & Chr(10)                          'Zeilenumbruch-Konstante Festlegen
    
  21. Dim Shared HelloMSG As String
    
  22. 
    
  23. 
    
  24. Declare Function    F_MakeBackSpaceString(V_Len As Long) As String
    
  25. Declare Function    F_MakeColorString(V_Color As Long) As String
    
  26. Declare Sub         F_Thread (Byval V_SID As Any Ptr)
    
  27. Declare Function    F_GetDefConString() As String
    
  28. 
    
  29. #INCLUDE "../net/TSNE_V2.bi"
    
  30. Declare Sub TSNE_Disconnected (Byval V_TSNEID As Uinteger)
    
  31. Declare Sub TSNE_Connected (Byval V_TSNEID As Uinteger)
    
  32. Declare Sub TSNE_NewConnection (Byval V_TSNEID As Uinteger, Byval V_RequestID As Socket)
    
  33. Declare Sub TSNE_NewData (Byval V_TSNEID As Uinteger, Byref V_Data As String)
    
  34. 
    
  35. 
    
  36. '-----------------------------------------------------------------------------------------------------
    
  37. #INCLUDE "../c4kernel.bi"
    
  38. #INCLUDE "../cic4u_kernel_function.bi"
    
  39. 
    
  40. 
    
  41. '-----------------------------------------------------------------------------------------------------
    
  42. Dim Shared C4K As C4Kernel_Type Ptr
    
  43. Type Client_Type
    
  44.     V_Socket As Uinteger
    
  45.     T_Data As String
    
  46.     V_IPA As String
    
  47.     V_TimeOut As Double
    
  48.     V_Username As String
    
  49.     V_UserSSID As String
    
  50.     V_LoginTime As Double
    
  51.     V_LoginC As Long
    
  52.     
    
  53.     V_OptMode As Long
    
  54.     V_OptModeNeo As Long
    
  55.     V_OptModeStart As Long
    
  56.     V_OptBinary As Long
    
  57.     V_OptEcho As Long
    
  58.     V_OptGoAhead As Long
    
  59.     V_OptStatus As Long
    
  60.     V_OptTimingMark As Long
    
  61.     V_OptTerminalType As Long
    
  62.     V_OptTerminalSpeed As Long
    
  63.     V_OptWindowSize As Long
    
  64. 
    
  65.     V_ValWindow_Width As Long
    
  66.     V_ValWindow_Height As Long
    
  67.     V_ValTerminalType As String
    
  68.     V_ValTerminalSpeed As String
    
  69.     V_ValTerminalLocation As String
    
  70. End Type
    
  71. 
    
  72. 
    
  73. Dim Shared G_Server As Uinteger
    
  74. Dim Shared G_ClientD() As Client_Type
    
  75. Dim Shared G_ClientDC As Client_Type
    
  76. Dim Shared G_ClientC As Uinteger
    
  77. 
    
  78. 
    
  79. Dim Shared G_Server_Port As Ushort
    
  80. Dim Shared G_Server_MaxClients As Uinteger
    
  81. Dim Shared G_Server_TimeOut As Double
    
  82. 
    
  83. 
    
  84. Dim Shared G_MUTX_Client As Any Ptr
    
  85. 
    
  86. '-----------------------------------------------------------------------------------------------------
    
  87. Function CIC4U_IVersion Cdecl () As String Export
    
  88. CIC4U_IVersion = "1.00.0___" & __DATE__ & "_" & __TIME__
    
  89. End Function
    
  90. 
    
  91. 
    
  92. '-----------------------------------------------------------------------------------------------------
    
  93. Function CIC4U_IDescription Cdecl () As String Export
    
  94. CIC4U_IDescription = "Telnet Command Line Interface Server"
    
  95. End Function
    
  96. 
    
  97. 
    
  98. '-----------------------------------------------------------------------------------------------------
    
  99. Function CIC4U_IHelp Cdecl (Byref V_CMD As String) As String Export
    
  100. CIC4U_IHelp = "No help available"
    
  101. End Function
    
  102. 
    
  103. 
    
  104. '-----------------------------------------------------------------------------------------------------
    
  105. Function CIC4U_IDriverLevel Cdecl () As Long Export
    
  106. CIC4U_IDriverLevel = 10
    
  107. End Function
    
  108. 
    
  109. 
    
  110. '-----------------------------------------------------------------------------------------------------
    
  111. Function CIC4U_Event Cdecl (Byref V_FromAPID As ULongInt, Byref V_FromAPData As Long, Byref V_APData As Long, Byref V_MSG As ULongInt, Byref V_SubMSG As Long, Byref BV_Data1 As String, Byref BV_Data2 As String) As Double Export
    
  112. CIC4U_Event = F_BCID(-1)
    
  113. Dim CID As Long
    
  114. CID = V_APData
    
  115. If CID <= 0 Or CID > G_ClientC Then Return F_BCID(-6)
    
  116. Dim TCT As Client_Type
    
  117. TCT = G_ClientD(CID)
    
  118. If TCT.V_Socket = 0 Then Return F_BCID(-6)
    
  119. Dim D As String
    
  120. Select Case V_MSG
    
  121.     Case 0
    
  122.         Select Case V_SubMSG
    
  123.             Case 1: D = LBreak & F_MakeColorString(7) & BV_Data1
    
  124.             Case 2: D = F_MakeColorString(2) & "[=]" & LBreak & F_MakeColorString(7) & BV_Data1
    
  125.             Case 3: D = LBreak & F_MakeColorString(6) & BV_Data1
    
  126.             Case 4: D = F_MakeColorString(1) & "[F]" & LBreak & F_MakeColorString(7) & BV_Data1
    
  127.             Case 5: D = F_MakeColorString(3) & "[W]" & LBreak & F_MakeColorString(7) & BV_Data1
    
  128.             Case 6: D = F_MakeColorString(1) & "[F]" & LBreak
    
  129.             Case 7: D = F_MakeColorString(2) & "[=]" & LBreak
    
  130.             Case 8
    
  131.                 Select Case BV_Data2
    
  132.                     Case "0"
    
  133.                     Case Else: D = F_MakeColorString(7)
    
  134.                 End Select
    
  135.                 D = D & BV_Data2
    
  136.             Case 9
    
  137.             Case 10
    
  138.             Case 11
    
  139.             Case 12
    
  140.         End Select
    
  141. End Select
    
  142. TSNE_Data_Send TCT.V_Socket, D
    
  143. End Function
    
  144. 
    
  145. 
    
  146. '-----------------------------------------------------------------------------------------------------
    
  147. Function CIC4U_Init Cdecl (Byref V_KernelRef As C4Kernel_Type Ptr, Byref V_APID As ULongInt, Byref V_FromAPID As ULongInt, Byref V_FromAPData As Long, Byref V_FromUserSSID As String, Byref V_CMD As String, Byref B_SelfTerm As Long) As Double Export
    
  148. C4K = V_KernelRef
    
  149. CIC4U_Init = F_BCID(-1)
    
  150. G_APID = V_APID
    
  151. G_FromAPID = V_FromAPID
    
  152. G_FromAPData = V_FromAPData
    
  153. G_Server_Port = 2304
    
  154. G_Server_MaxClients = 100
    
  155. G_Server_TimeOut = 1000
    
  156. C4K->C4A_Add(V_FromAPID, V_FromAPData, "Init Server_Telnet...")
    
  157. With G_ClientDC
    
  158.     .V_OptMode = 0
    
  159.     .V_OptModeNeo = 0
    
  160.     .V_OptBinary = 0
    
  161.     .V_OptEcho = 1
    
  162.     .V_OptGoAhead = 0
    
  163.     .V_OptStatus = 0
    
  164.     .V_OptTimingMark = 0
    
  165.     .V_OptTerminalType = 0
    
  166.     .V_OptTerminalSpeed = 0
    
  167.     .V_OptWindowSize = 0
    
  168.     .V_ValWindow_Width = 80
    
  169.     .V_ValWindow_Height = 24
    
  170. End With
    
  171. Dim BV As Long
    
  172. HelloMSG = LBreak & F_MakeColorString(7)
    
  173. HelloMSG = HelloMSG & " #######################" & LBreak
    
  174. HelloMSG = HelloMSG & " ##" & F_MakeColorString(4) & " MESA CLUSTER GRID " & F_MakeColorString(7) & "##" & LBreak
    
  175. HelloMSG = HelloMSG & " #######################" & LBreak
    
  176. HelloMSG = HelloMSG & F_MakeColorString(7)
    
  177. G_MUTX_Client = Mutexcreate
    
  178. BV = TSNE_Create_Server(G_Server, G_Server_Port, 10, @TSNE_NewConnection)
    
  179. If BV = 0 Then
    
  180.     C4K->C4A_Add(V_FromAPID, V_FromAPData, "Server_Telnet running!")
    
  181. Else: C4K->C4A_Add(V_FromAPID, V_FromAPData, "[FEHLER] " & TSNE_GetGURUCode(BV))
    
  182. End If
    
  183. TSNE_WaitClose(G_Server)
    
  184. C4K->C4A_Add(V_FromAPID, V_FromAPData, "Server_Telnet terminated!")
    
  185. Return F_BCID(0)
    
  186. End Function
    
  187. 
    
  188. 
    
  189. '-----------------------------------------------------------------------------------------------------
    
  190. Function CIC4U_Term Cdecl () As Double Export
    
  191. CIC4U_Term = F_BCID(-1)
    
  192. TSNE_Disconnect(G_Server)
    
  193. TSNE_WaitClose(G_Server)
    
  194. Dim X As Integer
    
  195. Dim TSock As Integer
    
  196. For X = 1 To G_ClientC
    
  197.     TSock = G_ClientD(X).V_Socket
    
  198.     TSNE_Disconnect(TSock)
    
  199. Next
    
  200. For X = 1 To G_ClientC
    
  201.     TSock = G_ClientD(X).V_Socket
    
  202.     TSNE_WaitClose(TSock)
    
  203. Next
    
  204. Mutexdestroy(G_MUTX_Client)
    
  205. CIC4U_Term = F_BCID(0)
    
  206. End Function
    
  207. 
    
  208. 
    
  209. '-----------------------------------------------------------------------------------------------------
    
  210. Sub CIC4U_Destruct () Destructor
    
  211. Dim BV As Double
    
  212. BV = CIC4U_Term()
    
  213. End Sub
    
  214. 
    
  215. 
    
  216. '-----------------------------------------------------------------------------------------------------
    
  217. Function CIC4U_Loop Cdecl (Byref B_Exit As Long, Byref B_ProcDone As ULongInt, Byref B_ProgFail As ULongInt) As Double Export
    
  218. CIC4U_Loop = F_BCID(-1)
    
  219. Return F_BCID(0)
    
  220. End Function
    
  221. 
    
  222. 
    
  223. '-----------------------------------------------------------------------------------------------------
    
  224. Sub TSNE_Disconnected (Byval V_TSNEID As Uinteger)
    
  225. 'C4K->C4A_Add(G_FromAPID, G_FromAPData, ""[DIS])
    
  226. Dim TCT As Client_Type
    
  227. Dim BV As Double
    
  228. Dim X As Uinteger
    
  229. Mutexlock(G_MUTX_Client)
    
  230. For X = 1 To G_ClientC
    
  231.     If G_ClientD(X).V_Socket > 0 Then
    
  232.         If G_ClientD(X).V_Socket = V_TSNEID Then
    
  233.             TSNE_Disconnect(V_TSNEID)
    
  234.             TCT = G_ClientD(X)
    
  235.             If TCT.V_UserSSID <> "" Then BV = C4K->C4A_User_Logout(TCT.V_UserSSID)
    
  236.             G_ClientD(X).V_Socket = 0
    
  237.             Exit For
    
  238.         End If
    
  239.     End If
    
  240. Next
    
  241. Mutexunlock(G_MUTX_Client)
    
  242. End Sub
    
  243. 
    
  244. 
    
  245. '-----------------------------------------------------------------------------------------------------
    
  246. Sub TSNE_Connected (Byval V_TSNEID As Uinteger)
    
  247. 'C4K->C4A_Add(G_FromAPID, G_FromAPData, ""[CON])
    
  248. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(250) & Chr(1)           'Echo
    
  249. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(252) & Chr(1)           'Echo
    
  250. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(250) & Chr(3)           'SGA
    
  251. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(252) & Chr(3)           'SGA
    
  252. 
    
  253. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(251) & Chr(5)           'Status
    
  254. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(253) & Chr(24)          'TerminalType
    
  255. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(253) & Chr(31)          'WindowSize
    
  256. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(253) & Chr(32)          'TerminalSpeed
    
  257. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(253) & Chr(33)          'FlowControl
    
  258. TSNE_Data_Send V_TSNEID, Chr(255) & Chr(253) & Chr(35)          'DisplayLocation
    
  259. TSNE_Data_Send V_TSNEID, Chr(27) & "[2J"
    
  260. TSNE_Data_Send V_TSNEID, HelloMSG & LBreak
    
  261. TSNE_Data_Send V_TSNEID, "USERNAME:"
    
  262. End Sub
    
  263. 
    
  264. 
    
  265. 
    
  266. '-----------------------------------------------------------------------------------------------------
    
  267. Sub TSNE_NewConnection (Byval V_TSNEID As Uinteger, Byval V_RequestID As Socket)
    
  268. Print "[CON]"
    
  269. 'C4K->C4A_Add(G_FromAPID, G_FromAPData, "[NCO] >" & V_RequestID & "<")
    
  270. Dim TCID As Long
    
  271. Dim TClient As Uinteger
    
  272. Dim X As Long
    
  273. Dim BV As Long
    
  274. TCID = 0
    
  275. Mutexlock(G_MUTX_Client)
    
  276. For X = 1 To G_ClientC
    
  277.     If G_ClientD(X).V_Socket = 0 Then
    
  278.         TCID = X
    
  279.         Exit For
    
  280.     End If
    
  281. Next 
    
  282. If TCID = 0 Then
    
  283.     If G_ClientC < G_Server_MaxClients Then
    
  284.         G_ClientC += 1
    
  285.         TCID = G_ClientC
    
  286.         Redim Preserve G_ClientD(G_ClientC) As Client_Type
    
  287.     End If
    
  288. End If
    
  289. Mutexunlock(G_MUTX_Client)
    
  290. Dim T As String
    
  291. If TCID > 0 Then
    
  292.     BV = TSNE_Create_Accept(V_RequestID, TClient, T, @TSNE_Disconnected, @TSNE_Connected, @TSNE_NewData)
    
  293.     Mutexlock(G_MUTX_Client)
    
  294.     G_ClientD(TCID) = G_ClientDC
    
  295.     G_ClientD(TCID).V_Socket = TClient
    
  296.     G_ClientD(TCID).V_IPA = T
    
  297.     G_ClientD(TCID).V_TimeOut = Timer + G_Server_TimeOut
    
  298.     Mutexunlock(G_MUTX_Client)
    
  299. Else
    
  300. '   C4K->C4A_Add(G_FromAPID, G_FromAPData, "[REQ] -> NO "FREE)
    
  301. '   Print "[REQ] No Free -> Create New -> SERVER FULL! KILL "NEW!
    
  302.     BV = TSNE_Create_Accept(V_RequestID, TClient, T, 0, 0, 0)
    
  303.     TSNE_Data_Send(TClient,  F_MakeColorString(3) & "SERVER-FULL!")
    
  304.     TSNE_Disconnect(TClient)
    
  305. End If
    
  306. End Sub
    
  307. 
    
  308. 
    
  309. '-----------------------------------------------------------------------------------------------------
    
  310. Sub TSNE_NewData (Byval V_TSNEID As Uinteger, Byref V_Data As String)
    
  311. 'C4K->C4A_Add(G_FromAPID, G_FromAPData, ""[NDA])
    
  312. Dim X As Uinteger
    
  313. Dim ID As Long
    
  314. Mutexlock(G_MUTX_Client)
    
  315. For X = 1 To G_ClientC
    
  316.     If G_ClientD(X).V_Socket > 0 Then
    
  317.         If G_ClientD(X).V_Socket = V_TSNEID Then
    
  318.             ID = X
    
  319.             Exit For
    
  320.         End If
    
  321.     End If
    
  322. Next
    
  323. Mutexunlock(G_MUTX_Client)
    
  324. 'Print "[NDA]: >" & ID & "<___>" & V_Data & "<"
    
  325. If ID <= 0 Then Exit Sub
    
  326. Mutexlock(G_MUTX_Client)
    
  327. G_ClientD(ID).V_TimeOut = Timer + G_Server_TimeOut
    
  328. Mutexunlock(G_MUTX_Client)
    
  329. Dim TCT As Client_Type
    
  330. Dim Y As Long
    
  331. Dim DD() As String
    
  332. Dim DC As Long
    
  333. Dim BV As Double
    
  334. For Y = 1 To Len(V_Data)
    
  335.     Mutexlock(G_MUTX_Client)
    
  336.     TCT = G_ClientD(ID)
    
  337.     Mutexunlock(G_MUTX_Client)
    
  338. '   Print "C:     >" & TCT.V_OptMode & "<___>" & asc(mid(V_Data, y, 1)) & "<"
    
  339.     If TCT.V_OptMode = 0 Then
    
  340.         Select Case Asc(Mid(V_Data, Y, 1))
    
  341.             Case 8, 127
    
  342.                 If TCT.T_Data <> "" Then
    
  343.                     TCT.T_Data = Left(TCT.T_Data, Len(TCT.T_Data) - 1)
    
  344.                     If TCT.V_OptEcho = 1 Then TSNE_Data_Send(V_TSNEID, Chr(8) & " " & Chr(8))
    
  345.                 End If
    
  346.             Case 10
    
  347.             Case 13
    
  348.                 If TCT.T_Data <> "" Then
    
  349.                     If TCT.V_UserSSID = "" Then
    
  350.                         F_SplitString TCT.T_Data, DD(), DC, " ", 1, 0, 0
    
  351.                         If TCT.V_Username <> "" Then
    
  352.                             TSNE_Data_Send V_TSNEID, Chr(255) & Chr(250) & Chr(1)           'Echo
    
  353.                             TSNE_Data_Send V_TSNEID, Chr(255) & Chr(252) & Chr(1)           'Echo
    
  354.                             TCT.V_UserSSID = C4K->C4A_User_Login(TCT.V_Username, DD(1), 0, TCT.V_IPA)
    
  355.                             If Len(TCT.V_UserSSID) = 3 Then
    
  356.                                 BV = Val(TCT.V_UserSSID)
    
  357.                                 TCT.V_UserSSID = ""
    
  358.                             End If
    
  359.                             If TCT.V_UserSSID <> "" Then
    
  360.                                 If TCT.V_OptEcho = 1 Then TSNE_Data_Send(V_TSNEID, F_MakeBackSpaceString(Len(TCT.T_Data) + 9))
    
  361.                                 TSNE_Data_Send(V_TSNEID, F_MakeColorString(2) & "Login OK!" & F_MakeColorString(7) & "   " & F_MakeColorString(4) & "WIN THE GAME!" & F_MakeColorString(7) & LBreak & LBreak)
    
  362.                                 TSNE_Data_Send(V_TSNEID, F_MakeColorString(2) & " =[DEFCON: " & F_GetDefConString & F_MakeColorString(2) & " ]=" & F_MakeColorString(7) & LBreak & LBreak)
    
  363.                                 TSNE_Data_Send(V_TSNEID, F_MakeColorString(6) & ">" & F_MakeColorString(7))
    
  364.                             Else
    
  365.                                 If TCT.V_OptEcho = 1 Then TSNE_Data_Send(V_TSNEID, F_MakeBackSpaceString(Len(TCT.T_Data) + 9))
    
  366.                                 TCT.V_Username = ""
    
  367.                                 TCT.V_LoginC += 1
    
  368.                                 TSNE_Data_Send(V_TSNEID, F_MakeColorString(1) & C4K->C4A_BCID_Description(BV) & F_MakeColorString(7) & LBreak)
    
  369.                                 If TCT.V_LoginC = 2 Then
    
  370.                                     TSNE_Data_Send(V_TSNEID, F_MakeColorString(3) & "= COMMUNICATION TERMINATED! =")
    
  371.                                     TSNE_Disconnect(V_TSNEID)
    
  372.                                     Exit For
    
  373.                                 Else
    
  374.                                     TSNE_Data_Send(V_TSNEID, "USERNAME:")
    
  375.                                 End If
    
  376.                             End If
    
  377.                         Else
    
  378.                             TCT.V_Username = DD(1)
    
  379.                             If TCT.V_OptEcho = 1 Then TSNE_Data_Send(V_TSNEID, F_MakeBackSpaceString(Len(TCT.T_Data) + 9))
    
  380.                             TSNE_Data_Send V_TSNEID, Chr(255) & Chr(251) & Chr(1)           'Echo
    
  381.                             TSNE_Data_Send V_TSNEID, Chr(255) & Chr(253) & Chr(1)           'Echo
    
  382.                             TSNE_Data_Send(V_TSNEID, "PASSWORD:")
    
  383.                         End If
    
  384.                     Else
    
  385.                         TSNE_Data_Send(V_TSNEID, LBreak)
    
  386.                         BV = C4K->C4A_Execute(TCT.V_UserSSID, G_APID, X, TCT.T_Data)
    
  387.                         If Fix(BV) <> 0 Then TSNE_Data_Send(V_TSNEID, C4K->C4A_BCID_Description(BV) & LBreak)
    
  388.                         TSNE_Data_Send(V_TSNEID, LBreak & F_MakeColorString(6) & ">" & F_MakeColorString(7))
    
  389.                     End If
    
  390.                     TCT.T_Data = ""
    
  391.                 End If
    
  392.             Case 32 To 126, 167,176,178 To 181, 196, 214, 220, 223, 228
    
  393.                 If TCT.V_OptEcho = 1 Then
    
  394. '                   Print ""SEND
    
  395.                     If TCT.V_UserSSID = "" And TCT.V_Username <> "" Then
    
  396.                         TSNE_Data_Send(V_TSNEID, F_MakeColorString(4) & "*" & F_MakeColorString(7))
    
  397.                     Else: TSNE_Data_Send(V_TSNEID, Mid(V_Data, Y, 1))
    
  398.                     End If
    
  399.                 End If
    
  400.                 TCT.T_Data += Mid(V_Data, Y, 1)
    
  401. '               Print ""[ & TCT.T_Data & ""]
    
  402.             Case 65'up
    
  403.             Case 66'down
    
  404.             Case 67'right
    
  405.             Case 68'left
    
  406.             Case 255: TCT.V_OptMode = 1
    
  407.             Case Else
    
  408.                 If Asc(Mid(V_Data, Y, 1)) = 27 And Mid(V_Data, Y + 1, 1) = "[" Then
    
  409.                     'Print "C:      " & asc(mid(V_Data, y + 2, 1))
    
  410.                     Select Case Mid(V_Data, Y + 2, 1)
    
  411.                         Case "A"
    
  412.                             Y += 3
    
  413.                         Case "B"
    
  414.                             Y += 3
    
  415.                         Case "C"
    
  416.                             Y += 3
    
  417.                         Case "D"
    
  418.                             Y += 3
    
  419.                     End Select
    
  420.                 End If
    
  421.         End Select
    
  422.     Else
    
  423.         If TCT.V_OptModeNeo = 0 Then
    
  424.             TCT.V_OptMode = 0
    
  425.             Select Case Asc(Mid(V_Data, Y, 1))
    
  426.                 Case 240
    
  427.                 Case 241
    
  428.                 Case 242
    
  429.                 Case 243
    
  430.                 Case 244
    
  431.                 Case 245
    
  432.                 Case 246
    
  433.                 Case 247
    
  434.                 Case 248
    
  435.                 Case 249
    
  436.                 Case 250
    
  437.                     TCT.V_OptModeNeo = 1
    
  438.                     TCT.V_OptMode = 1
    
  439.                     TCT.V_OptModeStart = Y + 1
    
  440.                 Case 251, 252, 253, 254
    
  441.                     Y += 1
    
  442.                     Select Case Asc(Mid(V_Data, Y, 1))
    
  443.                         Case 0 'Binary
    
  444.                     '       Select Case asc(Mid(V_Data, Y - 1, 1))
    
  445.                     '           case 251: TCT.V_OptBinary = 0
    
  446.                     '           case 252: If TCT.V_OptBinary = 1 Then TCT.V_OptBinary = 0 Else TCT.V_OptBinary = 1
    
  447.                     '           case 253: TCT.V_OptBinary = 1
    
  448.                     '           case 254: TCT.V_OptBinary = 0
    
  449.                     '       End Select
    
  450.                     '       Print "Binary: " & asc(Mid(V_Data, Y - 1, 1))
    
  451.                         Case 1 'Echo
    
  452.                             Select Case Asc(Mid(V_Data, Y - 1, 1))
    
  453.                                 Case 251: TCT.V_OptEcho = 1
    
  454.                                 Case 252: TCT.V_OptEcho = 1
    
  455.                                 Case 253: TCT.V_OptEcho = 1: TSNE_Data_Send(V_TSNEID, Chr(255) & Chr(251) & Chr(1))
    
  456.                                 Case 254: TCT.V_OptEcho = 0
    
  457.                             End Select
    
  458.                     '       Print "ECHO: " & TCT.V_OptEcho
    
  459.                         Case 2 'Transmission & Echoing
    
  460.                         Case 3 'Supress GO AHEAD (SGA)
    
  461.                     '       Select Case asc(Mid(V_Data, Y - 1, 1))
    
  462.                     '           case 251: TCT.V_OptGoAhead = 0
    
  463.                     '           case 252: If TCT.V_OptGoAhead = 1 Then TCT.V_OptGoAhead = 0 Else TCT.V_OptGoAhead = 1
    
  464.                     '           case 253: TCT.V_OptGoAhead = 1
    
  465.                     '           case 254: TCT.V_OptGoAhead = 0
    
  466.                     '       End Select
    
  467.                     '       Print "Go AHEAD: " & asc(Mid(V_Data, Y - 1, 1))
    
  468.                         Case 5 'Status
    
  469.                     '       Select Case asc(Mid(V_Data, Y - 1, 1))
    
  470.                     '           case 251: TCT.V_OptStatus = 0
    
  471.                     '           case 252: If TCT.V_OptStatus = 1 Then TCT.V_OptStatus = 0 Else TCT.V_OptStatus = 1
    
  472.                     '           case 253: TCT.V_OptStatus = 1
    
  473.                     '           case 254: TCT.V_OptStatus = 0
    
  474.                     '       End Select
    
  475.                     '       Print "Status: " & asc(Mid(V_Data, Y - 1, 1))
    
  476.                         Case 6 'TIMING-Mark
    
  477.                     '       Select Case asc(Mid(V_Data, Y - 1, 1))
    
  478.                     '           case 251: TCT.V_OptTimingMark = 0
    
  479.                     '           case 252: If TCT.V_OptTimingMark = 1 Then TCT.V_OptTimingMark = 0 Else TCT.V_OptTimingMark = 1
    
  480.                     '           case 253: TCT.V_OptTimingMark = 1
    
  481.                     '           case 254: TCT.V_OptTimingMark = 0
    
  482.                     '       End Select
    
  483.                     '       Print "Timing-Mark: " & asc(Mid(V_Data, Y - 1, 1))
    
  484.                         Case 24 'Terminal Type
    
  485.                             Select Case Asc(Mid(V_Data, Y - 1, 1))
    
  486.                                 Case 251: TSNE_Data_Send(V_TSNEID, Chr(255) & Chr(250) & Chr(24) & Chr(1) & Chr(255) & Chr(240))
    
  487.                                 Case 252
    
  488.                                 Case 253
    
  489.                                 Case 254
    
  490.                             End Select
    
  491.                     '       Print "Terminal-Type: " & asc(Mid(V_Data, Y - 1, 1))
    
  492.                         Case 31 'Window Size
    
  493.                             Select Case Asc(Mid(V_Data, Y - 1, 1))
    
  494.                                 Case 251: TSNE_Data_Send(V_TSNEID, Chr(255) & Chr(250) & Chr(31) & Chr(1) & Chr(255) & Chr(240))
    
  495.                                 Case 252
    
  496.                                 Case 253
    
  497.                                 Case 254
    
  498.                             End Select
    
  499.                     '       Print "Window-Size: " & asc(Mid(V_Data, Y - 1, 1))
    
  500.                         Case 32 'Terminal Speed
    
  501.                             Select Case Asc(Mid(V_Data, Y - 1, 1))
    
  502.                                 Case 251: TSNE_Data_Send(V_TSNEID, Chr(255) & Chr(250) & Chr(32) & Chr(1) & Chr(255) & Chr(240))
    
  503.                                 Case 252
    
  504.                                 Case 253
    
  505.                                 Case 254
    
  506.                             End Select
    
  507.                     '       Print "Terminal-Speed: " & asc(Mid(V_Data, Y - 1, 1))
    
  508.                         Case 33 'Flow-Control
    
  509.                             Select Case Asc(Mid(V_Data, Y - 1, 1))
    
  510.                                 Case 251
    
  511.                                 Case 252
    
  512.                                 Case 253
    
  513.                                 Case 254
    
  514.                             End Select
    
  515.                     '       Print "Flow-Control: " & asc(Mid(V_Data, Y - 1, 1))
    
  516.                         Case 35 'Display-Location
    
  517.                             Select Case Asc(Mid(V_Data, Y - 1, 1))
    
  518.                                 Case 251
    
  519.                                 Case 252
    
  520.                                 Case 253
    
  521.                                 Case 254
    
  522.                             End Select
    
  523.                     '       Print "Flow-Control: " & asc(Mid(V_Data, Y - 1, 1))
    
  524.                         Case 39 'Environment
    
  525.                             Select Case Asc(Mid(V_Data, Y - 1, 1))
    
  526.                                 Case 251: TSNE_Data_Send(V_TSNEID, Chr(255) & Chr(250) & Chr(39) & Chr(1) & Chr(255) & Chr(240))
    
  527.                                 Case 252
    
  528.                                 Case 253
    
  529.                                 Case 254
    
  530.                             End Select
    
  531.                     '       Print "Environment: " & asc(Mid(V_Data, Y - 1, 1))
    
  532.                         Case Else
    
  533.                     '       Print "OPT:    " & asc(mid(V_Data, y, 1)) & " - " &  asc(mid(TData, y + 1, 1))
    
  534.                     End Select
    
  535.             End Select
    
  536.         Else
    
  537.             If Asc(Mid(V_Data, Y, 1)) = 255 And Asc(Mid(V_Data, Y + 1, 1)) = 250 Then
    
  538.                 'Print "OPT_Spec:" & asc(mid(TData, TCT.V_OptModeStart, 1))
    
  539.                 Select Case Asc(Mid(V_Data, TCT.V_OptModeStart, 1))
    
  540.                     Case 24
    
  541.                         TCT.V_ValTerminalType = Mid(V_Data, TCT.V_OptModeStart + 2, Y - TCT.V_OptModeStart - 2)
    
  542.                     '   Print "Terminal-Type: >" & TCT.V_ValTerminalType & "<"
    
  543.                     Case 31
    
  544.                         TCT.V_ValWindow_Width = Asc(Mid(V_Data, Y - 4, 1)) * 255 + Asc(Mid(V_Data, Y - 3, 1))
    
  545.                         TCT.V_ValWindow_Height = Asc(Mid(V_Data, Y - 2, 1)) * 255 + Asc(Mid(V_Data, Y - 1, 1))
    
  546.                     '   Print "Window: >" & TCT.V_ValWindow_Width & " x " & TCT.V_ValWindow_Height & "<"
    
  547.                     Case 32
    
  548.                         TCT.V_ValTerminalSpeed = Mid(V_Data, TCT.V_OptModeStart + 2, Y - TCT.V_OptModeStart - 2)
    
  549.                     '   Print "Terminal-Speed: >" & TCT.V_ValTerminalSpeed & "<"
    
  550.                     Case 35
    
  551.                         TCT.V_ValTerminalLocation = Mid(V_Data, TCT.V_OptModeStart, Y - TCT.V_OptModeStart)
    
  552.                     '   Print "Terminal-Location: >" & TCT.V_ValTerminalLocation & "<"
    
  553.                     Case 39
    
  554.                         TCT.V_ValTerminalLocation = Mid(V_Data, TCT.V_OptModeStart, Y - TCT.V_OptModeStart)
    
  555.                     '   Print "Environment: >?<"
    
  556.                 End Select
    
  557.                 TCT.V_OptModeNeo = 0
    
  558.                 TCT.V_OptMode = 0
    
  559.             End If
    
  560.         End If
    
  561.     End If
    
  562.     Mutexlock(G_MUTX_Client)
    
  563.     G_ClientD(ID) = TCT
    
  564.     Mutexunlock(G_MUTX_Client)
    
  565. Next
    
  566. End Sub
    
  567. 
    
  568. 
    
  569. '-----------------------------------------------------------------------------------------------------
    
  570. Function CIC4U_Execute Cdecl (Byref V_FromAPID As ULongInt, Byref V_FromAPData As Long, Byref V_FromUserSSID As String, Byref V_CMD As String) As Double Export
    
  571. CIC4U_Execute = F_BCID(-1)
    
  572. End Function
    
  573. 
    
  574. 
    
  575. '-----------------------------------------------------------------------------------------------------
    
  576. Function F_MakeBackSpaceString(V_Len As Long) As String
    
  577. Dim X As Long
    
  578. Dim O As String
    
  579. For X = 1 To V_Len
    
  580.     O = O & Chr(8) & " " & Chr(8)
    
  581. Next
    
  582. Return O
    
  583. End Function
    
  584. 
    
  585. 
    
  586. '-----------------------------------------------------------------------------------------------------
    
  587. Function F_MakeColorString(V_Color As Long) As String
    
  588. '0 = Schwarz
    
  589. '1 = Rot
    
  590. '2 = Grün
    
  591. '3 = Gelb
    
  592. '4 = Blau
    
  593. '5 = Lila
    
  594. '6 = Cyan
    
  595. '7 = Grau
    
  596. Return Chr(27) & "[3" & V_Color & "m"
    
  597. End Function
    
  598. 
    
  599. 
    
  600. '-----------------------------------------------------------------------------------------------------
    
  601. Function F_GetDefConString() As String
    
  602. Dim D As String
    
  603. Dim DefID As Long
    
  604. DefID = C4K->C4A_KernelDefCon()
    
  605. Dim X As Long
    
  606. Dim CoID As String
    
  607. For X = 5 To 1 Step -1
    
  608.     Select Case X
    
  609.         Case 5: CoID = "7"
    
  610.         Case 4: CoID = "4"
    
  611.         Case 3: CoID = "2"
    
  612.         Case 2: CoID = "3"
    
  613.         Case 1: CoID = "1"
    
  614.     End Select
    
  615.     If X <> DefID Then
    
  616.         D = D & Chr(27) & "[40;3" & CoID & "m[" & Str(X) & "]"
    
  617.     Else: D = D & Chr(27) & "[4" & CoID & ";30m[" & Str(X) & "]"
    
  618.     End If
    
  619. Next
    
  620. D = D & Chr(27) & "[40;37m"
    
  621. Return D
    
  622. End Function
    
  623.