Begin
[mono.git] / mcs / class / Mono.Posix / Mono.Posix / Syscall.cs
1 //
2 // Mono.Posix.Syscall.cs: System calls to Posix subsystem features
3 //
4
5 using System;
6 using System.Runtime.InteropServices;
7
8 namespace Mono.Posix {
9
10         public unsafe class Syscall {
11                 [DllImport ("libc", EntryPoint="gethostname")]
12                 static unsafe extern int syscall_gethostname (byte *p, int len);
13
14                 public static string GetHostName ()
15                 {
16                         byte [] buf = new byte [256];
17                         unsafe {
18                                 fixed (byte *p = &buf [0]){
19                                         gethostname (p, 256);
20                                 }
21                         }
22                         return new String(Encoding.UTF8.GetChars (buf));
23                 }
24         }
25 }