diff --git a/Claunia.IO/ChangeLog b/Claunia.IO/ChangeLog index 1655fa9..f0c25ab 100644 --- a/Claunia.IO/ChangeLog +++ b/Claunia.IO/ChangeLog @@ -1,3 +1,9 @@ +2015-05-03 Natalia Portillo + + * Claunia.IO.csproj: + * Interop/FreeBSD/Interop.FreeBSD.uname.cs: + Implement FreeBSD's uname(3) + 2015-05-03 Natalia Portillo * Claunia.IO.csproj: diff --git a/Claunia.IO/Claunia.IO.csproj b/Claunia.IO/Claunia.IO.csproj index 58dbbe5..301ad0d 100644 --- a/Claunia.IO/Claunia.IO.csproj +++ b/Claunia.IO/Claunia.IO.csproj @@ -62,6 +62,7 @@ + diff --git a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs new file mode 100644 index 0000000..9896350 --- /dev/null +++ b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs @@ -0,0 +1,76 @@ +// +// Interop.FreeBSD.uname.cs +// +// Author: +// Natalia Portillo +// +// Copyright (c) 2015 © Claunia.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class FreeBSD + { + /// + /// OS X uname structure + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + internal struct utsname + { + /// + /// System name + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string sysname; + /// + /// Node name + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string nodename; + /// + /// Release level + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string release; + /// + /// Version level + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string version; + /// + /// Hardware level + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string machine; + } + + /// + /// Gets system identification + /// Calls to system's uname(3) + /// + /// . + /// On success, 0. On failure, -1, and errno is set. + [DllImport("libc", SetLastError = true)] + internal static extern int uname(out utsname name); + } +} +