public static int uname(out Utsname buf) { _Utsname _buf; int r = sys_uname(out _buf); buf = new Utsname(); if (r == 0) { CopyUtsname(ref buf, ref _buf); } return(r); }
private static void CopyUtsname(ref Utsname to, ref _Utsname from) { try { to = new Utsname { sysname = Marshal.PtrToStringAnsi(@from.sysname), nodename = Marshal.PtrToStringAnsi(@from.nodename), release = Marshal.PtrToStringAnsi(@from.release), version = Marshal.PtrToStringAnsi(@from.version), machine = Marshal.PtrToStringAnsi(@from.machine), domainname = Marshal.PtrToStringAnsi(@from.domainname) }; } finally { free(from._buf_); from._buf_ = IntPtr.Zero; } }