Skip to content

Instantly share code, notes, and snippets.

@teamday
Created September 25, 2018 20:35
Show Gist options
  • Save teamday/2e4cfb6c0f99d940d812e1c1d5fd06f1 to your computer and use it in GitHub Desktop.
Save teamday/2e4cfb6c0f99d940d812e1c1d5fd06f1 to your computer and use it in GitHub Desktop.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
partial class Interop
{
const string LIBC = "libc";
[DllImport(LIBC, EntryPoint = "getenv")]
private static extern IntPtr getenv_core(string name);
internal static string getenv(string name)
{
return Marshal.PtrToStringAnsi(getenv_core(name));
}
[DllImport(LIBC)]
internal static extern unsafe int snprintf(byte* str, IntPtr size, string format, string arg1);
[DllImport(LIBC)]
internal static extern unsafe int snprintf(byte* str, IntPtr size, string format, int arg1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment