There isn't a board for VB.net, so I hope this is appropriate.
I've written a subroutine to read the XTRN.DAT file, ported from something od Digital Man's. I'd appreciate someone casting an eye over it and giving any advice/criticism as appropriate. There were some things I didn't quite *get* but I think I have most of it.
Much appreciated
-+- Start Code ---
'/****************************************************************************/ '/* Reads data from XTRN.DAT in the node directory And fills the appropriate */ '/* global variables.*/
'/* Initializes starttime variable with current time.*/ '/****************************************************************************/ ' Ported from Digital Man's xsdk.c
' by BoonDock (John Dovey) <
dovey.john@gmail.com>
' BoonDock@Vert/Elgato
' gatofuego.synchronetbbs.org
Dim xuser_name As String
Dim xsys_name As String
Dim xsys_op As String
Dim xsys_guru As String
Dim xctrl_dir As String
Dim xdata_dir As String
Dim xsys_nodes As Integer
Dim xnode_num As Integer
Dim xtimeleft As Integer
Dim xuser_misc As String
Dim xuser_rows As Integer
Dim xuser_cdt As Integer
Dim xuser_level As Integer
Dim xtransfer_level As String
Dim xuser_birth As String
Dim xuser_sex As String
Dim xuser_number As Integer
Dim xuser_phone As String
Dim xcom_port As Integer
Dim xcom_irq As Integer
Dim xcom_base As String
Dim xcom_rate As ULong
Dim xmdm_misc As String
Const MDM_FLOWCTRL = 1 << 0 ' /* Use flow control With modem*/
Const MDM_STAYHIGH = 1 << 1 ' /* Stay at highest DTE rate */ Dim xmdm_init As String
Dim xmdm_spec As String
Dim xmdm_term As String
Dim xmdm_dial As String
Dim xmdm_offh As String
Dim xmdm_answ As String
Dim xmsr As ULong
Dim xtotal_xtrns As Integer
Dim xuser_flags1 As String
Dim xuser_flags2 As String
Dim xuser_exempt As String
Dim xuser_rest As String
Dim xuser_expire As Long
Dim xuser_address As String
Dim xuser_location As String
Dim xuser_postcode As String
Dim xuser_flags3 As String
Dim xuser_flags4 As String
Dim xTime_Slice As String
Dim xuser_realname As String
Dim xuser_dce As Long
Dim xexec_dir As String
Dim xtext_dir As String
Dim xtemp_dir As String
Dim xsys_id As String
Dim xnode_misc As Long
Dim xclient_socket As Integer
Sub InitData()
Dim i As Integer
Dim Node_Dir As String
'Node_Dir = "/users/john/source/repos/smc"
Node_Dir = Environ("SBBSNODE") '/* Sets node_dir to node directory environment variable defined by synchronet. */
If Node_Dir.Length < 2 Then Node_Dir = "."
Dim Xtrn As String
Xtrn = Node_Dir & "/" & "XTRN.DAT"
Dim Str As String() = File.ReadAllLines(Xtrn)
xuser_name = Trim(Left(Str(0), 25)) ' /* username */
xsys_name = Trim(Left(Str(1), 40)) ' /* system name */
xsys_op = Trim(Left(Str(2), 40)) ' /* system operator */
xsys_guru = Trim(Left(Str(3), 40)) ' /* system guru */
xctrl_dir = Trim(Left(Str(4), 40)) ' /* ctrl dir */
If xctrl_dir(0) = "." Then
xctrl_dir = Node_Dir & "/" & xctrl_dir
End If
xdata_dir = Trim(Left(Str(5), 40)) ' /* data dir */
If xdata_dir(0) = "." Then
xdata_dir = Node_Dir & "/" & xdata_dir
End If
xsys_nodes = Val(Trim(Str(6))) ' /* total nodes */
xnode_num = Val(Trim(Str(7))) ' /* current node */
xtimeleft = Val(Trim(Str(8))) ' /* time left */
xuser_misc = Trim(Str(9)) ' /* ANSI? (Yes, Mono, Or No) */
If xuser_misc(0) = "Y" Then
xuser_misc = "ANSI|COLOR"
ElseIf xuser_misc(0) = "M" Then
xuser_misc = "ANSI"
End If
xuser_rows = Val(Trim(Str(10))) ' /* screen lines */
xuser_cdt = Val(Trim(Str(11))) ' /* credits */
xuser_level = Val(Trim(Str(12))) ' /* level */
xtransfer_level = Trim(Str(13)) ' /* was transfer level, left For compat. */
xuser_birth = Trim(Left(Str(14), 10)) ' /* birthdate */
xuser_sex = Trim(Str(15)) ' /* sex */
'user_sex =str[0];
xuser_number = Val((Trim(Str(16)))) ' /* user number */
xuser_phone = Trim(Left(Str(17), 12)) ' /* user phone number */
xcom_port = Val(Trim(Str(18))) ' /* com port (0 If local Or no modem) */
xcom_irq = Val(Trim(Str(19))) ' /* com (UART) irq */
xcom_base = Trim(Str(20)) ' /* com (UART) base address In hex */
xcom_rate = Val(Trim(Str(21))) ' /* com rate */
xmdm_misc = Trim(Str(22)) ' /* hardware flow control (Y/N) */ If UCase(xmdm_misc(0)) = "Y" Then
xmdm_misc = MDM_FLOWCTRL
End If
If UCase(Trim(Str(23))(0)) = "Y" Then ' /* locked DTE rate (Y/N) */ xmdm_misc = MDM_STAYHIGH
End If
xmdm_init = Trim(Left(Str(24), 63)) ' /* modem initialization String */ xmdm_spec = Trim(Left(Str(25), 63)) ' /* modem special init String */ xmdm_term = Trim(Left(Str(26), 63)) ' /* modem terminal mode String */ xmdm_dial = Trim(Left(Str(27), 63)) ' /* modem dial String */
xmdm_offh = Trim(Left(Str(28), 63)) ' /* modem off-hook String */ xmdm_answ = Trim(Left(Str(29), 63)) ' /* modem answer String */
xmsr = Val(Trim(Str(30))) ' /* memory address Of modem status register */
xtotal_xtrns = Val(Trim(Str(31))) ' If (!fgets(Str, 81, Stream)) /* total Then Number Of external programs */
If xtotal_xtrns < 1 Or xtotal_xtrns = vbNull Then xtotal_xtrns = 0
Dim y As Integer = Val(xtotal_xtrns) - 1
Dim xprog_xtns(y) As String
For x As Integer = 0 To y
xprog_xtns(x) = Trim(Str(32 + x))
Next
i = xtotal_xtrns + 31 ' Continue on after the random number of Xternal Programs
xuser_flags1 = Trim(Left(Str(i + 1), 26)) ' /* user's main flags */ xuser_flags2 = Trim(Left(Str(i + 2), 26)) ' /* user's xfer flags */ xuser_exempt = Trim(Left(Str(i + 3), 26)) ' /* user's exemptions */ xuser_rest = Trim(Left(Str(i + 4), 26)) ' /* user's restrictions */ xuser_expire = Val(Trim(Str(i + 5))) ' /* user's expiration date */ xuser_address = Trim(Left(Str(i + 6), 30)) ' /* user's address */ xuser_location = Trim(Left(Str(i + 7), 30)) ' /* user's location (city, state) */
xuser_postcode = Trim(Left(Str(i + 8), 10)) ' /* user's zip/postal code */ xuser_flags3 = Trim(Left(Str(i + 9), 26)) ' Flags 3
xuser_flags4 = Trim(Left(Str(i + 10), 26)) ' Flgs 4
xTime_Slice = Trim(Str(i + 11)) ' If (fgets(Str, 81, Stream)) /* Time - slice Then API Type */
xuser_realname = Trim(Left(Str(i + 12), 25)) ' Real Name
xuser_dce = Val(Trim(Str(i + 13))) ' DCE
xexec_dir = Trim(Str(i + 14)) ' /* exec dir */
'If (!str[0])
'sprintf(exec_dir, "%s../exec/", ctrl_dir);
'Else {
If xexec_dir(0) = "." Then
xexec_dir = Node_Dir & "/" & xexec_dir
End If
xtext_dir = Trim(Str(i + 15)) ' /* text dir */
'If (!str[0])
'sprintf(text_dir, "%s../text/", ctrl_dir);
'Else {
If xtext_dir(0) = "." Then
xtext_dir = Node_Dir & "/" & xtext_dir
End If
xtemp_dir = Trim(Left(Str(i + 16), 50)) ' /* temp dir */
If xtemp_dir.Length < 2 Then
xtemp_dir = Node_Dir & "/temp/"
End If
If (xtemp_dir(0) <> "/" Or xtemp_dir(0) <> "\") And xtemp_dir(1) <> ":" Then xtemp_dir = Node_Dir & "/temp"
End If
xsys_id = Trim(Left(Str(i + 17), 8)) ' System ID
xnode_misc = Val(Trim(Str(i + 18))) ' Misc
'If (Str[0])
'node_misc = (uint)ahtoul(str);
'Else
'node_misc = NM_LOWPRIO;
xclient_socket = Val(Trim(Str(i + 19))) ' Socket
'Test
Console.WriteLine("User Name: {0}", xuser_name)
Console.WriteLine("xsys_name: {0}", xsys_name)
Console.WriteLine("xsys_op: {0}", xsys_op)
Console.WriteLine("xsys_guru: {0}", xsys_guru)
Console.WriteLine("xctrl_dir: {0}", xctrl_dir)
Console.WriteLine("xdata_dir: {0}", xdata_dir)
Console.WriteLine("xsys_nodes: {0}", xsys_nodes)
Console.WriteLine("xnode_num: {0}", xnode_num)
Console.WriteLine("xtimeleft: {0}", xtimeleft)
Console.WriteLine("xuser_misc: {0}", xuser_misc)
Console.WriteLine("xuser_rows: {0}", xuser_rows)
Console.WriteLine("xuser_cdt: {0}", xuser_cdt)
Console.WriteLine("xuser_level: {0}", xuser_level) Console.WriteLine("xtransfer_level: {0}", xtransfer_level) Console.WriteLine("xuser_birth: {0}", xuser_birth) Console.WriteLine("xuser_sex: {0}", xuser_sex)
Console.WriteLine("xuser_number: {0}", xuser_number) Console.WriteLine("xuser_phone: {0}", xuser_phone) Console.WriteLine("xcom_port: {0}", xcom_port)
Console.WriteLine("xcom_irq: {0}", xcom_irq)
Console.WriteLine("xcom_base: {0}", xcom_base)
Console.WriteLine("xcom_rate: {0}", xcom_rate)
Console.WriteLine("xmdm_misc: {0}", xmdm_misc)
Console.WriteLine("xmdm_init: {0}", xmdm_init)
Console.WriteLine("xmdm_spec: {0}", xmdm_spec)
Console.WriteLine("xmdm_term: {0}", xmdm_term)
Console.WriteLine("xmdm_dial: {0}", xmdm_dial)
Console.WriteLine("xmdm_offh: {0}", xmdm_offh)
Console.WriteLine("xmdm_answ: {0}", xmdm_answ)
Console.WriteLine("xmsr: {0}", xmsr)
Console.WriteLine("xtotal_xtrns: {0}", xtotal_xtrns)
For x = 0 To xtotal_xtrns - 1
Console.WriteLine("xprog_xtns [{1}]: {0}", xprog_xtns(x), x)
Next
Console.WriteLine("xuser_flags1: {0}", xuser_flags1) Console.WriteLine("xuser_flags2: {0}", xuser_flags2) Console.WriteLine("xuser_exempt: {0}", xuser_exempt) Console.WriteLine("xuser_rest: {0}", xuser_rest) Console.WriteLine("xuser_expire: {0}", xuser_expire) Console.WriteLine("xuser_address: {0}", xuser_address) Console.WriteLine("xuser_location: {0}", xuser_location) Console.WriteLine("xuser_postcode: {0}", xuser_postcode) Console.WriteLine("xuser_flags3: {0}", xuser_flags3) Console.WriteLine("xuser_flags4: {0}", xuser_flags4) Console.WriteLine("xTime_Slice: {0}", xTime_Slice) Console.WriteLine("xuser_realname: {0}", xuser_realname) Console.WriteLine("xuser_dce: {0}", xuser_dce)
Console.WriteLine("xexec_dir: {0}", xexec_dir)
Console.WriteLine("xtext_dir: {0}", xtext_dir)
Console.WriteLine("xtemp_dir: {0}", xtemp_dir)
Console.WriteLine("xsys_id: {0}", xsys_id)
Console.WriteLine("xnode_misc: {0}", xnode_misc) Console.WriteLine("xclient_socket: {0}", xclient_socket)
End Sub
Boondock
BoonDock
Pedasi/Panama
... The writer does the most who gives the reader the most
---
þ Synchronet þ Sent from El Gato de Fuego * The Fire Cat * elgato.synchronetbbs.org