SharpHammer / SharpHammer / core.cs

using System;
using System.Security;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace SharpHammer
{
	#region log

	public enum log_type
	{
		Text = 0,
		Error = 1,
		Warning = 2,
		Info = 3,
		Load = 4
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct log_stats
	{
		public UInt32 msgs_cnt;
		public UInt32 errors_cnt;
		public UInt32 warnings_cnt;
	}

	#endregion

	#region error_codes
	public enum result_t
	{
		RET_ABORT = 2,
		RET_OK = 1,
		RET_FAIL = 0,
		RET_OUTOFMEMORY = -1,
		RET_WARNING = -2,
		RET_INVALIDARG = -3,
		RET_FILE_ERROR = -4,
		RET_NOT_IMPL = -5,
		RET_NOT_SUPPORTED = -6,
		RET_INVALIDCALL = -7
	}
	#endregion

	#region timer
	[StructLayout(LayoutKind.Sequential)]
	public struct timer
	{
		public float t;
		public float dt;
		public float rate;
		public linked_list node;
	}
	#endregion

	#region linked_list
	[StructLayout(LayoutKind.Sequential)]
	public struct linked_list
	{
		IntPtr next;
		IntPtr prev;
		IntPtr data;
	}
	#endregion

	#region file-mgr
	enum seek_mode
	{
		SEEK_MODE_START,
		SEEK_MODE_END,
		SEEK_MODE_CUR
	}
	enum file_type
	{
		FILE_TYPE_MEM,
		FILE_TYPE_DSK
	}
	enum file_mode
	{
		FILE_MODE_WRITE,
		FILE_MODE_READ
	}
	#endregion

	[SuppressUnmanagedCodeSecurity]
	public class core
	{
		public const string NativeDll = "dh_core.dll";

		#region core
		// core_init
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern result_t core_init(
			[MarshalAs(UnmanagedType.Bool)] bool trace_mem);

		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void core_release(
			[MarshalAs(UnmanagedType.Bool)] bool report_leaks);

		#endregion

		#region log
		// pfn_log_handler
		public delegate void pfn_log_handler(log_type param0,
			[In] [MarshalAs(UnmanagedType.LPStr)] string param1, IntPtr param2);

		// log_outputconsole
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern result_t log_outputconsole(
			[MarshalAs(UnmanagedType.Bool)]bool enable);
		// log_outputfile
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern result_t log_outputfile(
			[MarshalAs(UnmanagedType.Bool)]bool enable,
			[In] [MarshalAs(UnmanagedType.LPStr)] string log_filepath);
		// log_outputdebugger
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern result_t log_outputdebugger(
			[MarshalAs(UnmanagedType.Bool)]bool enable);
		// log_outputfunc
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern result_t log_outputfunc(uint enable,
			pfn_log_handler log_fn, IntPtr param);
		// log_isconsole
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		public static extern bool log_isconsole();
		// log_isfile
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		public static extern bool log_isfile();
		// log_isdebugger
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		public static extern bool log_isdebugger();
		// log_isoutputfunc
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		public static extern bool log_isoutputfunc();
		// log_print
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void log_print(log_type type,
			[In] [MarshalAs(UnmanagedType.LPStr)] string text);
		// log_getstats
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void log_getstats(ref log_stats stats);
		// log_init
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern result_t log_init();
		// log_release
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void Release();
		#endregion

		#region timer
		// timer_initmgr
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern result_t timer_initmgr();
		// timer_releasemgr
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void timer_releasemgr();
		// timer_add
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern IntPtr timer_add(
			[MarshalAs(UnmanagedType.Bool)] bool start);
		// timer_remove
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void timer_remove(IntPtr tm);
		// timer_update
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void timer_update(UInt64 tick);
		// timer_querytick
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern UInt64 timer_querytick();
		// timer_queryfreq
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern UInt64 timer_queryfreq();
		// timer_calctm
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern Double timer_calctm(UInt64 tick1, UInt64 tick2);
		// timer_pauseall
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void timer_pauseall();
		// timer_resumeall
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void timer_resumeall();
		#endregion

		#region file-mgr
		// io_addvdir
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void io_addvdir(
			[MarshalAs(UnmanagedType.LPStr)] string directory, bool monitor);
		// io_clearvdirs
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void io_clearvdirs();
		// io_addpak
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void io_addpak(IntPtr pak);
		// io_clearpaks
		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
		public static extern void io_clearpaks();
		// io_file_createmem
		// io_file_openmem
		// io_file_attachmem
		// io_file_detachmem
		// io_file_createdisk
		// io_file_opendisk
		// io_file_close
		// io_file_seek
		// io_file_read
		// io_file_write
		// io_file_getsize
		// io_file_getpos
		// io_file_getpath
		// io_file_isopen
		// io_file_gettype
		// io_file_getmode
		// io_mon_reg
		// io_mon_unreg
		// io_mon_update
		#endregion
	}
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.