/// <summary> /// Cоздание массива компьютеров /// </summary> private void CreateArrayOfComputers() { for (int i = 0; i < NumberOfComputers; i++) { string line = text.ReadLine(); string[] parsedLine = line.Split(' '); if (parsedLine.Count() > 3) { throw new IncorrectInputDataException(); } OS installedOs = default(OS); switch (parsedLine[0]) { case "Windows": installedOs = new Windows(); break; case "MacOS": installedOs = new MacOS(); break; case "Linux": installedOs = new Linux(); break; default: throw new IncorrectInputDataException(); } ArrayOfComputer[i] = new Computer(installedOs, parsedLine[1] == "1"); } }
/// <summary> /// Create a new host using the hostname "localhost", /// the username of the current user, no password, and /// a port of 22. /// </summary> public Host() { Hostname = "localhost"; Username = System.Environment.UserName; Port = 22; Environment = new Linux(); }
internal static string TryDetectConfigPath(int processId) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return(Windows.TryDetectConfigPath(processId)); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { return(Linux.TryDetectConfigPath(processId)); } return(null); }
internal static uint gss_display_name( out uint minorStatus, IntPtr inputName, out GssBufferStruct NameBuffer, out GssOidDesc nameType) { return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Environment.Is64BitProcess ? Win64.gss_display_name(out minorStatus, inputName, out NameBuffer, out nameType) : Win32.gss_display_name(out minorStatus, inputName, out NameBuffer, out nameType) : Linux.gss_display_name(out minorStatus, inputName, out NameBuffer, out nameType)); }
internal static uint gss_import_name( out uint minorStatus, ref GssBufferStruct inputNameBuffer, ref GssOidDesc inputNameType, out IntPtr outputName) { return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Environment.Is64BitProcess ? Win64.gss_import_name(out minorStatus, ref inputNameBuffer, ref inputNameType, out outputName) : Win32.gss_import_name(out minorStatus, ref inputNameBuffer, ref inputNameType, out outputName) : Linux.gss_import_name(out minorStatus, ref inputNameBuffer, ref inputNameType, out outputName)); }
/// <summary> /// Loads symbol in a platform specific way. /// </summary> /// <param name="symbolName"></param> /// <returns></returns> public IntPtr LoadSymbol(string symbolName) { if (PlatformApis.IsLinux) { return(Linux.dlsym(this.handle, symbolName)); } if (PlatformApis.IsMacOSX) { return(MacOSX.dlsym(this.handle, symbolName)); } throw new InvalidOperationException("Unsupported platform."); }
public async Task <int> Collect(IConsole console, int processId, string output, DumpType type) { if (processId == 0) { console.Error.WriteLine("ProcessId is required."); return(1); } try { // Get the process Process process = Process.GetProcessById(processId); if (output == null) { // Build timestamp based file path string timestamp = $"{DateTime.Now:yyyyMMdd_HHmmss}"; output = Path.Combine(Directory.GetCurrentDirectory(), RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"dump_{timestamp}.dmp" : $"core_{timestamp}"); } if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Matches createdump's output on Linux string dumpType = type == DumpType.Mini ? "minidump" : "minidump with heap"; console.Out.WriteLine($"Writing {dumpType} to {output}"); await Windows.CollectDumpAsync(process, output, type); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { await Linux.CollectDumpAsync(process, output, type); } else { throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}"); } } catch (Exception ex) when (ex is FileNotFoundException || ex is DirectoryNotFoundException || ex is UnauthorizedAccessException || ex is PlatformNotSupportedException || ex is InvalidDataException || ex is InvalidOperationException || ex is NotSupportedException) { console.Error.WriteLine($"{ex.Message}"); return(1); } console.Out.WriteLine($"Complete"); return(0); }
/// <summary> /// The init window. /// </summary> /// <param name="argc"> /// The argc. /// </param> /// <param name="argv"> /// The argv. /// </param> internal static void InitWindow(int argc, string[] argv) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_init(argc, argv); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_init(argc, argv); } }
/// <summary> /// The set title. /// </summary> /// <param name="window"> /// The window. /// </param> /// <param name="title"> /// The title. /// </param> internal static void SetTitle(IntPtr window, string title) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_window_set_title(window, title); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_window_set_title(window, title); } }
/// <summary> /// The show all. /// </summary> /// <param name="window"> /// The window. /// </param> internal static void ShowAll(IntPtr window) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_widget_show_all(window); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_widget_show_all(window); } }
/// <summary> /// The set size request. /// </summary> /// <param name="window"> /// The window. /// </param> /// <param name="width"> /// The width. /// </param> /// <param name="height"> /// The height. /// </param> internal static void SetSizeRequest(IntPtr window, int width, int height) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_widget_set_size_request(window, width, height); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_widget_set_size_request(window, width, height); } }
/// <summary> /// The set window size. /// </summary> /// <param name="window"> /// The window. /// </param> /// <param name="width"> /// The width. /// </param> /// <param name="height"> /// The height. /// </param> internal static void SetWindowSize(IntPtr window, int width, int height) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_window_resize(window, width, height); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_window_resize(window, width, height); } }
/// <summary> /// The set window position. /// </summary> /// <param name="window"> /// The window. /// </param> /// <param name="position"> /// The position. /// </param> internal static void SetWindowPosition(IntPtr window, GtkWindowPosition position) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_window_set_position(window, position); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_window_set_position(window, position); } }
/// <summary> /// The set window resizable. /// </summary> /// <param name="window"> /// The window. /// </param> /// <param name="resizable"> /// The resizable. /// </param> internal static void SetWindowResizable(IntPtr window, bool resizable) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_window_set_resizable(window, resizable); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_window_set_resizable(window, resizable); } }
/// <summary> /// The set window maximize. /// </summary> /// <param name="window"> /// The window. /// </param> internal static void SetWindowMaximize(IntPtr window) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_window_maximize(window); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_window_maximize(window); } }
/// <summary> /// The set fullscreen. /// </summary> /// <param name="window"> /// The window. /// </param> internal static void SetFullscreen(IntPtr window) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_window_fullscreen(window); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_window_fullscreen(window); } }
/// <summary> /// The add configure event. /// </summary> /// <param name="window"> /// The window. /// </param> internal static void AddConfigureEvent(IntPtr window) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_widget_add_events(window, GtkEvent.GdkConfigure); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_widget_add_events(window, GtkEvent.GdkConfigure); } }
/// <summary> /// The connect signal. /// </summary> /// <param name="window"> /// The window. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="callback"> /// The callback. /// </param> /// <param name="key"> /// The key. /// </param> /// <param name="data"> /// The data. /// </param> /// <param name="flags"> /// The flags. /// </param> internal static void ConnectSignal(IntPtr window, string name, Delegate callback, int key, IntPtr data, int flags) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.g_signal_connect_data(window, name, callback, key, data, flags); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.g_signal_connect_data(window, name, callback, key, data, flags); } }
/// <summary> /// The quit. /// </summary> internal static void Quit() { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_main_quit(); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_main_quit(); } }
internal static uint gss_inquire_name( out uint minorStatus, IntPtr name, out int mechName, out GssOidSet oids, out IntPtr attrs) { return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Environment.Is64BitProcess ? Win64.gss_inquire_name(out minorStatus, name, out mechName, out oids, out attrs) : Win32.gss_inquire_name(out minorStatus, name, out mechName, out oids, out attrs) : Linux.gss_inquire_name(out minorStatus, name, out mechName, out oids, out attrs)); }
public override int GetHashCode() { unchecked { var hashCode = (Test != null ? Test.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Suit != null ? Suit.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Linux.GetHashCode(); hashCode = (hashCode * 397) ^ Windows10.GetHashCode(); hashCode = (hashCode * 397) ^ Windows7.GetHashCode(); hashCode = (hashCode * 397) ^ Osx.GetHashCode(); return(hashCode); } }
public void Close() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (this.handle != IntPtr.Zero) { Windows.FreeLibrary(this.handle); this.handle = IntPtr.Zero; } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { if (InteropRuntimeConfig.IsRunningOnMono) { if (this.handle != IntPtr.Zero) { Mono.dlclose(this.handle); this.handle = IntPtr.Zero; } } else if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Core")) { if (this.handle != IntPtr.Zero) { CoreCLR.dlclose(this.handle); this.handle = IntPtr.Zero; } } else { if (this.handle != IntPtr.Zero) { Linux.dlclose(this.handle); this.handle = IntPtr.Zero; } } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { if (this.handle != IntPtr.Zero) { MacOSX.dlclose(this.handle); this.handle = IntPtr.Zero; } } else { throw new InvalidOperationException("Unsupported platform."); } bLibOpen = false; }
/// <summary> /// Loads symbol in a platform specific way. /// </summary> /// <param name="symbolName"></param> /// <returns></returns> private IntPtr LoadSymbol(string symbolName) { if (PlatformApis.IsWindows) { // See http://stackoverflow.com/questions/10473310 for background on this. //if (PlatformApis.Is64Bit) //{ // return Windows.GetProcAddress(this.handle, symbolName); //} //else //{ // // Yes, we could potentially predict the size... but it's a lot simpler to just try // // all the candidates. Most functions have a suffix of @0, @4 or @8 so we won't be trying // // many options - and if it takes a little bit longer to fail if we've really got the wrong // // library, that's not a big problem. This is only called once per function in the native library. // symbolName = "_" + symbolName + "@"; // for (int stackSize = 0; stackSize < 128; stackSize += 4) // { // IntPtr candidate = Windows.GetProcAddress(this.handle, symbolName + stackSize); // if (candidate != IntPtr.Zero) // { // return candidate; // } // } // // Fail. // return IntPtr.Zero; //} // VLFD.dll 比较特殊 // 虽然是32位的,但符号和64位相同 return(Windows.GetProcAddress(this.handle, symbolName)); } if (PlatformApis.IsLinux) { if (PlatformApis.IsMono) { return(Mono.dlsym(this.handle, symbolName)); } if (PlatformApis.IsNetCore) { return(CoreCLR.dlsym(this.handle, symbolName)); } return(Linux.dlsym(this.handle, symbolName)); } if (PlatformApis.IsMacOSX) { return(MacOSX.dlsym(this.handle, symbolName)); } throw new InvalidOperationException("Unsupported platform."); }
public static IntPtr LoadLibrary(string libname) { if (CurrentPlatform.OS == OS.Windows) { return(Windows.LoadLibraryW(libname)); } if (CurrentPlatform.OS == OS.MacOSX) { return(OSX.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY)); } return(Linux.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY)); }
public static IntPtr LoadLibrary(string libname) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { return(Windows.LoadLibraryW(libname)); } if (Environment.OSVersion.Platform == PlatformID.MacOSX) { return(OSX.dlopen(libname, RTLD_LAZY)); } return(Linux.dlopen(libname, RTLD_LAZY)); }
public static IntPtr LoadLibrary(string libname) { if (Environment.OSVersion.IsWindows()) { return(Windows.LoadLibraryW(libname)); } if (Environment.OSVersion.IsMacOSX()) { return(OSX.dlopen(libname, RTLD_LAZY)); } return(Linux.dlopen(libname, RTLD_LAZY)); }
/// <summary> /// The new window. /// </summary> /// <param name="type"> /// The type. /// </param> /// <returns> /// The <see cref="IntPtr"/>. /// </returns> internal static IntPtr NewWindow(GtkWindowType type) { if (CefRuntime.Platform == CefRuntimePlatform.Windows) { return(Win.gtk_window_new(type)); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { return(Linux.gtk_window_new(type)); } return(IntPtr.Zero); }
public static IntPtr LoadLibrary(string libname) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return(Windows.LoadLibraryW(libname)); } if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { return(OSX.dlopen(libname, RTLD_LAZY)); } return(Linux.dlopen(libname, RTLD_LAZY)); }
public static IntPtr LoadLibrary(string libname) { if (IsWindows) { return(Windows.LoadLibraryW(libname)); } if (IsOSX) { return(OSX.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY)); } return(Linux.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY)); }
/// <summary> /// Returns the size of a window, given its window handle. /// </summary> public static Rectangle GetClientRectangle(IntPtr windowHandle, bool sizeOnly = true) { switch (PlatformId) { case PlatformIdSubset.Windows: return(Windows.GetClientRect(windowHandle)); case PlatformIdSubset.Linux: return(Linux.GetClientRect(windowHandle, sizeOnly)); default: return(new Rectangle(0, 0, 300, 300)); } }
public async Task <int> Collect(IConsole console, int processId, string outputDirectory) { if (processId == 0) { console.Error.WriteLine("ProcessId is required."); return(1); } // System.CommandLine has a bug in the default value handling if (outputDirectory == null) { outputDirectory = Directory.GetCurrentDirectory(); } // Get the process Process process = null; try { process = Process.GetProcessById(processId); } catch (Exception ex) when(ex is ArgumentException || ex is InvalidOperationException) { console.Error.WriteLine($"Invalid process id: {processId}"); return(1); } // Generate the file name string fileName = Path.Combine(outputDirectory, $"{process.ProcessName}-{process.Id}-{DateTime.Now:yyyyMMdd-HHmmss-fff}.dmp"); console.Out.WriteLine($"Collecting memory dump for {process.ProcessName} (ID: {process.Id}) ..."); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { await Windows.CollectDumpAsync(process, fileName); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { await Linux.CollectDumpAsync(process, fileName); } else { console.Error.WriteLine($"Unsupported operating system {RuntimeInformation.OSDescription}"); return(1); } console.Out.WriteLine($"Dump saved to {fileName}"); return(0); }
/// <summary> /// The get window size. /// </summary> /// <param name="window"> /// The window. /// </param> /// <param name="width"> /// The width. /// </param> /// <param name="height"> /// The height. /// </param> internal static void GetWindowSize(IntPtr window, out int width, out int height) { width = 0; height = 0; if (CefRuntime.Platform == CefRuntimePlatform.Windows) { Win.gtk_window_get_size(window, out width, out height); } if (CefRuntime.Platform == CefRuntimePlatform.Linux) { Linux.gtk_window_get_size(window, out width, out height); } }
static void Main(string[] args) { Linux lnx = new Linux(ConfigurationManager.AppSettings["sshUsername"], ConfigurationManager.AppSettings["sshPassword"], ConfigurationManager.AppSettings["sshHostname"]); ///multiple commands //List<String> toRun = new List<string>(); //string commands = ConfigurationManager.AppSettings["sshCommands"]; //foreach (string word in commands.Split(';')) //{ // Console.WriteLine(lnx.ExecuteComand(word)); //} //change password of current user //lnx.ChangePassword("blah"); Console.ReadLine(); }
private void Initialisation(int n, int[,] nn, Random rnd) { neighbours = nn; this.n = n; myNetwork = new OS[n]; for (int i = 0; i < n; i++) { if (rnd.Next(0, 2) < 1) { myNetwork[i] = new Linux(); } else { myNetwork[i] = new Windows(); } myNetwork[i].rnd = new Random(); myNetwork[i].rnd = rnd; myNetwork[i].SetVirus(); } }
public static void GetDefaultLinuxPlatform(Linux obj, string unitTestContent) { obj.ClassName = "Linux.Default"; obj.PlatformSubType = "Generic"; obj.Edition = ""; obj.Version = ""; }
public static void GetSusePlatform(Linux obj) { GetSusePlatform( obj, null); }
public static void GetSusePlatform(Linux obj, string unitTestContent) { //Version list is available at http://en.wikipedia.org/wiki/SUSE_Linux //Unique version variations for parsing include (multi-line): // SUSE LINUX 10.0 (X86-64) OSS // VERSION = 10.0 List<string> lines; if (unitTestContent != null) lines = ParseString(unitTestContent); else lines = ParseFile("/etc/" + obj.VersionFile); int pt = lines[1].IndexOf(" "); obj.Version = lines[0].Substring(pt+1, lines[0].Length - 1); obj.ClassName = "Linux.Suse"; obj.PlatformSubType = "Suse"; obj.Edition = ""; obj.Version = lines[1].Substring(11, lines[1].Length - 11); }
public static void GetRedHatPlatform(Linux obj, string unitTestContent) { //Version list is available at ... //Unique version variations for parsing include: // Red Hat Enterprise Linux Server release 5 (Tikanga) // Red Hat Enterprise Linux AS release 4 (Nahant Update 3) // Red Hat Advanced Server Linux AS release 2.1 (Pensacola) // Red Hat Enterprise Linux ES release 3 (Taroon Update 4) List<string> lines; if (unitTestContent != null) lines = ParseString(unitTestContent); else lines = ParseFile("/etc/" + obj.VersionFile); int pt = lines[0].IndexOf("release"); int pt2 = lines[0].IndexOf("("); int pt3 = lines[0].IndexOf(")"); int pt4 = lines[0].IndexOf("Linux"); obj.ClassName = "Linux.RedHat"; obj.PlatformSubType = lines[0].Substring(0, pt4-1); obj.Edition = lines[0].Substring(pt2+1, pt3-1-pt2); obj.Version = lines[0].Substring(pt+8, pt2 - 1 - pt + 8).Trim(); }
public static void GetSlackwarePlatform(Linux obj, string unitTestContent) { //Version list is available at ... //Unique version variations for parsing include: // Slackware 13.0.0.0.0 List<string> lines; if (unitTestContent != null) lines = ParseString(unitTestContent); else lines = ParseFile("/etc/" + obj.VersionFile); obj.ClassName = "Linux.Slackware"; obj.PlatformSubType = "Slackware"; obj.Edition = ""; int pt = lines[0].IndexOf(" "); obj.Version = lines[0].Substring(pt+1, lines[0].Length - 1); }
public static void GetMandrivaPlatform(Linux obj, string unitTestContent) { //Formerly known as Mandrake Linux //Version list is available at http://en.wikipedia.org/wiki/Mandriva_Linux //Unique version variations for parsing include: // Mandriva Linux release 2010.0 (Official) for i586 List<string> lines; if (unitTestContent != null) lines = ParseString(unitTestContent); else lines = ParseFile("/etc/" + obj.VersionFile); obj.ClassName = "Linux.Mandriva"; obj.PlatformSubType = "Mandriva"; obj.Edition = ""; int pt = lines[0].IndexOf("release"); int pt2 = lines[0].IndexOf("("); obj.Version = lines[0].Substring(pt+8, pt2-1).Trim(); switch (obj.Version) { case "2010.0": obj.Edition = "Mandriva Linux 2010"; break; case "2009.1": obj.Edition = "Mandriva Linux 2009 Spring"; break; case "2009.0": obj.Edition = "Mandriva Linux 2009"; break; case "2008.1": obj.Edition = "Mandriva Linux 2008 Spring"; break; case "2008.0": obj.Edition = "Mandriva Linux 2008"; break; case "2007.1": obj.Edition = "Mandriva Linux 2007 Spring"; break; case "2007": obj.Edition = "Mandriva Linux 2007"; break; case "2006.0": obj.Edition = "Mandriva Linux 2006"; break; case "10.2": obj.Edition = "Limited Edition 2005"; break; case "10.1": obj.Edition = "Community and Official"; break; case "10.0": obj.Edition = "Community and Official"; break; case "9.2": obj.Edition = "FiveStar"; break; case "9.1": obj.Edition = "Bamboo"; break; case "9.0": obj.Edition = "Dolphin"; break; case "8.2": obj.Edition = "Bluebird"; break; case "8.1": obj.Edition = "Vitamin"; break; case "8.0": obj.Edition = "Traktopel"; break; case "7.2": obj.Edition = "Odyssey"; break; case "7.1": obj.Edition = "Helium"; break; case "7.0": obj.Edition = "Air"; break; case "6.1": obj.Edition = "Helios"; break; case "6.0": obj.Edition = "Venus"; break; case "5.3": obj.Edition = "Festen"; break; case "5.2": obj.Edition = "Leeloo"; break; case "5.1": obj.Edition = "Venice"; break; default: obj.Edition = "Unknown"; break; } }
public static void GetGentooPlatform(Linux obj, string unitTestContent) { //Version list available at http://gentest.neysx.org/proj/en/releng/#doc_chap6 //Versioning is primarily based on date. //Unique version variations for parsing include: // Gentoo Base System release 1.12.11.1 List<string> lines; if (unitTestContent != null) lines = ParseString(unitTestContent); else lines = ParseFile(obj.VersionFile); obj.ClassName = "Linux.Gentoo"; obj.PlatformSubType = "Gentoo"; obj.Edition = ""; obj.Version = lines[0].Split().Last(); }
public static void GetFedoraPlatform(Linux obj, string unitTestContent) { //Version list available at http://fedoraproject.org/wiki/Releases //Unique version variations for parsing include: // Fedora release 8 (Werewolf) // Fedora Core release 6 (Zod) List<string> lines; if (unitTestContent != null) lines = ParseString(unitTestContent); else lines = ParseFile("/etc/" + obj.VersionFile); int pt = lines[0].IndexOf("release"); int pt2 = lines[0].IndexOf("("); int pt3 = lines[0].IndexOf(")"); obj.ClassName = "Linux.Fedora"; obj.PlatformSubType = lines[0].Substring(0,pt-1).Trim(); obj.Version = lines[0].Substring(pt+8, pt2-1).Trim(); obj.Edition = lines[0].Substring(pt2+1,pt3-1).Trim(); }
public static void GetDebianPlatform(Linux obj, string unitTestContent) { //Version list available at: http://www.debian.org/releases/ //There is no accurate way to determine the version information //in Debian. The community mixes the versions regularly and //argues that programs should not rely on this information, //instead using the dependencies to determine if a program will //work. Unfortunately, this viewpoint does little for generic //informational purposes, version based bug reporting, etc. They //have not standardized this process, even for the //lsb_release package. The information provided in // /etc/debian_version is often incorrect and should not be used. obj.ClassName = "Linux.Debian"; obj.PlatformSubType = "Debian"; obj.Edition = ""; obj.Version = ""; }
public static void GetUbuntuPlatform(Linux obj, string unitTestContent) { //Version list is available at http://en.wikipedia.org/wiki/Ubuntu_(Linux_distribution) //Unique version variations for parsing include (multi-line): // DISTRIB_ID=Ubuntu // DISTRIB_RELEASE = 9.04 // DISTRIB_CODENAME=jaunty // DISTRIB_DESCRIPTION = Ubuntu 9.04 //Because Ubuntu can identify variants, we'll use the DISTRIB_ID //to identify the variant (such as KUbuntu, XUbuntu) instead of //a static string setting. List<string> lines; if (unitTestContent == null) lines = ParseFile("/etc/" + obj.VersionFile); else lines = ParseString(unitTestContent); obj.ClassName = "Linux.Ubuntu"; int pt = lines[0].IndexOf("="); obj.PlatformSubType = lines[0].Substring(pt+1).Trim(); int pt1 = lines[2].IndexOf("="); obj.Edition = lines[2].Substring(pt1+1).Trim(); int pt2 = lines[1].IndexOf("="); obj.Version = lines[1].Substring(pt2+1).Trim(); }
public static void GetArchPlatform(Linux obj, string unitTestContent) { // Arch is not versioned. It is a single rolling version. // The existance of the arch-release file determines arch // is being used. The actual file is blank. obj.ClassName = "Linux.Arch"; obj.PlatformSubType = "Arch"; obj.Edition = ""; obj.Version = "Current"; }
public static void GetUbuntuPlatform(Linux obj) { GetUbuntuPlatform( obj, null); }