Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
ref - Made some cleanups
Browse files Browse the repository at this point in the history
---

Type: ref
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 29, 2023
1 parent 273321e commit efa49c2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 54 deletions.
17 changes: 8 additions & 9 deletions RetroKS/Console/ColorSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ static class ColorSet
private static string answerColor;
private static string currentStepMessage = "Color for input: ";
private static int stepCurrent = 0;
private static int i;

// Variables
public static string[] answersColor = new string[8];

public static void UseDefaults()
public static void UseDefaults(int i)
{
// Use default settings in current step.
if (i == 0)
Expand Down Expand Up @@ -145,19 +144,19 @@ public static void SetColorSteps()
else if (ColorInitialize.availableColors.Contains(answerColor))
{
answersColor[i] = answerColor;
advanceStep();
AdvanceStep();
}
else if (string.IsNullOrEmpty(answerColor))
{
// Nothing written, use defaults.
UseDefaults();
advanceStep();
UseDefaults(i);
AdvanceStep();
}
else
{
TextWriterColor.Wln("The {0} color is not found. Your answers is case-sensitive.", "neutralText", answerColor);
UseDefaults();
advanceStep();
UseDefaults(i);
AdvanceStep();
}
}
else if (i == 8)
Expand Down Expand Up @@ -196,11 +195,11 @@ public static void SetColorSteps()

}

public static void advanceStep()
public static void AdvanceStep()
{

// Advance a step
stepCurrent = stepCurrent + 1;
stepCurrent++;
if (stepCurrent == 1)
{
currentStepMessage = "Color for license: ";
Expand Down
29 changes: 10 additions & 19 deletions RetroKS/Kernel/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,16 @@ static class Kernel
{

// Variables
public static string Hddsize; // The size of simulated Hard Drive
public static string Dsize; // Same as above, but in bytes
public static string Hddmodel; // Model of hard drive
public static string Cpuname; // CPU name
public static string Cpuspeed; // CPU Clock Speed
public static string SysMem; // Memory of simulated system
public static string BIOSCaption; // BIOS Caption
public static string BIOSMan; // BIOS Manufacturer
public static string BIOSSMBIOSVersion; // BIOS Version from SMBIOS
public static string BIOSVersion; // BIOS Version (some AMI BIOSes output "AMIINT - 10")
public static string KernelVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
public static string[] BootArgs; // Array for boot arguments
public static string[] AvailableArgs = new string[] { "motd", "nohwprobe", "chkn=1", "preadduser", "hostname", "quiet", "gpuprobe", "cmdinject", "debug", "help" };
public static string[] availableCMDLineArgs = new string[] { "createConf", "promptArgs" }; // Array for available command-line arguments
public static string slotsUsedName; // Lists slots by names
public static int slotsUsedNum; // Lists slots by numbers
public static string[] Capacities; // Capacity (in MB)
public static int totalSlots; // Total slots
public static StreamReader configReader; // Configuration file
public static string[] BootArgs;
public static string[] AvailableArgs =
new string[] { "motd", "nohwprobe", "chkn=1", "preadduser", "hostname", "quiet", "gpuprobe", "cmdinject", "debug", "help" };
public static string[] availableCMDLineArgs =
new string[] { "createConf", "promptArgs" };
public static string slotsUsedName;
public static int slotsUsedNum;
public static int totalSlots;
public static StreamReader configReader;
public static string Host;
public static string MOTD;
public readonly static string NewLine = Environment.NewLine;
Expand Down Expand Up @@ -179,4 +170,4 @@ public static void KernelMain()
}

}
}
}
28 changes: 6 additions & 22 deletions RetroKS/Network/NetworkTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,22 @@ static class NetworkTools

public static long adapterNumber;

public static void getProperties()
public static void GetProperties()
{

var proper = IPGlobalProperties.GetIPGlobalProperties();
var adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
adapterNumber = adapterNumber + 1L;
adapterNumber++;
if (adapter.Supports(NetworkInterfaceComponent.IPv4) == false)
{
if (Flags.DebugMode == true)
{
DebugWriter.Wdbg("{0} doesn't support IPv4 because ASSERT(adapter.Supp(IPv4) = True) = False.", true, adapter.Description);
}
goto Cont;
continue;
}
else if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet | adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet3Megabit | adapter.NetworkInterfaceType == NetworkInterfaceType.FastEthernetFx | adapter.NetworkInterfaceType == NetworkInterfaceType.FastEthernetT | adapter.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet | adapter.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)




{
var adapterProperties = adapter.GetIPProperties();
var p = adapterProperties.GetIPv4Properties();
Expand All @@ -59,30 +54,19 @@ public static void getProperties()
{
TextWriterColor.Wln("Failed to get statistics for adapter {0}", "neutralText", adapter.Description);
}
TextWriterColor.Wln("Adapter Number: {0}" + Kernel.NewLine + "Adapter Name: {1}" + Kernel.NewLine + "Maximum Transmission Unit: {2} Units" + Kernel.NewLine + "DHCP Enabled: {3}" + Kernel.NewLine + "Non-unicast packets: {4}/{5}" + Kernel.NewLine + "Unicast packets: {6}/{7}" + Kernel.NewLine + "Error incoming/outgoing packets: {8}/{9}", "neutralText", adapterNumber, adapter.Description, p.Mtu, p.IsDhcpEnabled, s.NonUnicastPacketsSent, s.NonUnicastPacketsReceived, s.UnicastPacketsSent, s.UnicastPacketsReceived, s.IncomingPacketsWithErrors, s.OutgoingPacketsWithErrors);







TextWriterColor.Wln("Adapter Number: {0}" + Kernel.NewLine + "Adapter Name: {1}" + Kernel.NewLine + "Maximum Transmission Unit: {2} Units" + Kernel.NewLine + "Non-unicast packets: {3}/{4}" + Kernel.NewLine + "Unicast packets: {5}/{6}" + Kernel.NewLine + "Error incoming/outgoing packets: {7}/{8}", "neutralText", adapterNumber, adapter.Description, p.Mtu, s.NonUnicastPacketsSent, s.NonUnicastPacketsReceived, s.UnicastPacketsSent, s.UnicastPacketsReceived, s.IncomingPacketsWithErrors, s.OutgoingPacketsWithErrors);
}
else
{
if (Flags.DebugMode == true)
{
DebugWriter.Wdbg("Adapter {0} doesn't belong in netinfo because the type is {1}", true, adapter.Description, adapter.NetworkInterfaceType);
}
goto Cont;
continue;
}

Cont:
;

}

}

}
}
}
4 changes: 1 addition & 3 deletions RetroKS/RetroKS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -51,7 +50,6 @@
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<Reference Include="System" />
Expand All @@ -75,6 +73,6 @@
<None Include="Paomedia-Small-N-Flat-Terminal.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Terminaux" Version="1.1.1" />
<PackageReference Include="Terminaux" Version="1.10.1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion RetroKS/Shell/GetCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ public static void ExecuteCommand(string requestedCommand)
else if (requestedCommand == "netinfo")
{

NetworkTools.getProperties();
NetworkTools.GetProperties();
}

else if (requestedCommand.Substring(0, index) == "mkdir" | requestedCommand.Substring(0, index) == "md")
Expand Down

0 comments on commit efa49c2

Please sign in to comment.