-
Notifications
You must be signed in to change notification settings - Fork 20
/
MagicNative.cs
49 lines (35 loc) · 2.28 KB
/
MagicNative.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Runtime.InteropServices;
namespace HeyRed.Mime
{
internal static class MagicNative
{
private const string MAGIC_LIB_PATH = "libmagic-1";
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr magic_open(MagicOpenFlags flags);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int magic_load(IntPtr magic_cookie, string filename);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern void magic_close(IntPtr magic_cookie);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr magic_file(IntPtr magic_cookie, string filename);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr magic_buffer(IntPtr magic_cookie, byte[] buffer, int length);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr magic_error(IntPtr magic_cookie);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern MagicOpenFlags magic_getflags(IntPtr magic_cookie);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int magic_setflags(IntPtr magic_cookie, MagicOpenFlags flags);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int magic_check(IntPtr magic_cookie, string dbPath);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int magic_compile(IntPtr magic_cookie, string dbPath);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int magic_getparam(IntPtr magic_cookie, MagicParams param, out int value);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int magic_setparam(IntPtr magic_cookie, MagicParams param, ref int value);
[DllImport(MAGIC_LIB_PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int magic_version();
}
}