extern static unsafe NEOERR *cs_init (CSPARSE **parse, HDF *hdf);
private bool ReadColumnFormat(int column, out HDF format) { bool flag; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HDITEM))); try { HDITEM.SetMask(ptr, HDI.HDI_FORMAT); if (Windows.SendMessage(base.Handle, 0x120b, (IntPtr) column, ptr) == IntPtr.Zero) { format = HDF.HDF_LEFT; return false; } format = HDITEM.GetFormat(ptr); flag = true; } finally { Marshal.FreeHGlobal(ptr); } return flag; }
private static extern void hdf_dump( HDF *hdf, [MarshalAs(UnmanagedType.LPStr)] string prefix);
private static extern HDF* hdf_get_obj( HDF *hdf, [MarshalAs(UnmanagedType.LPStr)] string name);
private static unsafe extern string hdf_get_value(HDF *hdf, [MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string defval);
private static unsafe extern NEOERR* hdf_set_value(HDF *hdf, [MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string value);
private static extern unsafe NEOERR* hdf_init(HDF **foo);
unsafe CSFILELOAD thunk_delegate; // we have to hold onto the delegate to make sure the pinned thunk sticks around private unsafe NEOERR* csFileLoad(void* ctx, HDF* raw_hdf, STR* pFilename, STR** contents) { // Console.WriteLine("csFileLoad delegate called"); IntPtr buf = IntPtr.Zero; try { Hdf hdf = new Hdf(raw_hdf); string filename = Marshal.PtrToStringAnsi((IntPtr)pFilename); byte[] data = cur_delegate(hdf, filename); byte[] end_null = new byte[] { 0 }; buf = NeoUtil.neo_malloc(data.Length + 1); // +1 so we can null terminate Marshal.Copy(data, 0, buf, data.Length); Marshal.Copy(end_null, 0, (IntPtr)((uint)buf + data.Length), 1); // write the end_null *contents = (STR*)buf; } catch (Exception e) { // Console.WriteLine("csFileLoad Thunk Exception + " + e); // should return a neo error if (buf != IntPtr.Zero) { NeoUtil.neo_free(buf); } return NeoErr.nERR(e.ToString()); } return (NEOERR*) IntPtr.Zero; }
public static unsafe void SetFormat(IntPtr ptr, HDF fmt) { ((void*) ptr).fmt = fmt; }