mirror of
https://github.com/claunia/Claunia.IO.git
synced 2025-12-16 19:24:44 +00:00
Implement FreeBSD's uname(3)
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2015-05-03 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Claunia.IO.csproj:
|
||||
* Interop/FreeBSD/Interop.FreeBSD.uname.cs:
|
||||
Implement FreeBSD's uname(3)
|
||||
|
||||
2015-05-03 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Claunia.IO.csproj:
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<Compile Include="Interop\Linux\Interop.Linux.stat.cs" />
|
||||
<Compile Include="Interop\FreeBSD\Interop.FreeBSD.Errors.cs" />
|
||||
<Compile Include="Interop\FreeBSD\Interop.FreeBSD.Libraries.cs" />
|
||||
<Compile Include="Interop\FreeBSD\Interop.FreeBSD.uname.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
76
Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs
Normal file
76
Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// Interop.FreeBSD.uname.cs
|
||||
//
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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
|
||||
{
|
||||
/// <summary>
|
||||
/// OS X uname structure
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
internal struct utsname
|
||||
{
|
||||
/// <summary>
|
||||
/// System name
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string sysname;
|
||||
/// <summary>
|
||||
/// Node name
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string nodename;
|
||||
/// <summary>
|
||||
/// Release level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string release;
|
||||
/// <summary>
|
||||
/// Version level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string version;
|
||||
/// <summary>
|
||||
/// Hardware level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string machine;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets system identification
|
||||
/// Calls to system's uname(3)
|
||||
/// </summary>
|
||||
/// <param name="name"><see cref="utsname"/>.</param>
|
||||
/// <returns>On success, 0. On failure, -1, and errno is set.</returns>
|
||||
[DllImport("libc", SetLastError = true)]
|
||||
internal static extern int uname(out utsname name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user