From 55edb65608a8b8984331ff8ceea80f06e4f890cf Mon Sep 17 00:00:00 2001 From: soukoku Date: Fri, 11 Apr 2014 23:16:33 -0400 Subject: [PATCH] Just for fun. --- NTwain/Triplets/PInvoke.Linux.cs | 489 +++++++++++++++---------------- NTwain/Triplets/PInvoke.cs | 362 +++++++++++++++++++---- 2 files changed, 544 insertions(+), 307 deletions(-) diff --git a/NTwain/Triplets/PInvoke.Linux.cs b/NTwain/Triplets/PInvoke.Linux.cs index 80d386d..88f18c7 100644 --- a/NTwain/Triplets/PInvoke.Linux.cs +++ b/NTwain/Triplets/PInvoke.Linux.cs @@ -7,280 +7,277 @@ namespace NTwain.Triplets { static partial class PInvoke { - // not sure if the signatures are correct yet - // so just a placeholder for now + static partial class NativeMethods + { + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + ref IntPtr data); - //static partial class NativeMethods - //{ - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // ref IntPtr data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + ref DataGroups data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // ref DataGroups data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWAudioInfo data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWAudioInfo data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWCapability data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWCapability data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWCustomDSData data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWCustomDSData data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWDeviceEvent data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWDeviceEvent data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWCallback data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWCallback data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWCallback2 data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWCallback2 data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWEntryPoint data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWEntryPoint data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWEvent data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWEvent data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWFileSystem data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWFileSystem data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + IntPtr zero, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWIdentity data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // IntPtr zero, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWIdentity data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWPassThru data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWPassThru data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWPendingXfers data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWPendingXfers data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWSetupFileXfer data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWSetupFileXfer data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWSetupMemXfer data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWSetupMemXfer data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWStatusUtf8 data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWStatusUtf8 data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWUserInterface data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWUserInterface data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWCieColor data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWCieColor data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWExtImageInfo data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWExtImageInfo data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWFilter data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWFilter data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWGrayResponse data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWGrayResponse data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWImageInfo data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWImageInfo data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWImageLayout data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWImageLayout data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWImageMemXfer data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWImageMemXfer data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWJpegCompression data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWJpegCompression data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWPalette8 data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWPalette8 data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWRgbResponse data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWRgbResponse data); + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + [In, Out]TWStatus data); - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // [In, Out]TWStatus data); - - // [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] - // public static extern ReturnCode DsmEntryLinux( - // [In, Out]TWIdentity origin, - // [In, Out]TWIdentity destination, - // DataGroups dg, - // DataArgumentType dat, - // Message msg, - // ref TWMemory data); - //} + [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")] + public static extern ReturnCode DsmEntryLinux( + [In, Out]TWIdentity origin, + [In, Out]TWIdentity destination, + DataGroups dg, + DataArgumentType dat, + Message msg, + ref TWMemory data); + } } } diff --git a/NTwain/Triplets/PInvoke.cs b/NTwain/Triplets/PInvoke.cs index 100621c..e7f65e7 100644 --- a/NTwain/Triplets/PInvoke.cs +++ b/NTwain/Triplets/PInvoke.cs @@ -21,7 +21,7 @@ namespace NTwain.Triplets // in essence it only exists in 64 bit systems and thus // the 2 sets of identical pinvokes :( - public static readonly bool CanUseTwainDSM = CheckIfCanUseNewDSM(); + public static readonly bool CanUseNewDSM = CheckIfCanUseNewDSM(); private static bool CheckIfCanUseNewDSM() { @@ -47,8 +47,16 @@ namespace NTwain.Triplets Message msg, ref IntPtr data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); } - else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); } + else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, dg, dat, msg, ref data); + } + throw new PlatformNotSupportedException(); } public static ReturnCode DsmEntry( @@ -59,8 +67,16 @@ namespace NTwain.Triplets Message msg, ref DataGroups data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); } - else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); } + else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, dg, dat, msg, ref data); + } + throw new PlatformNotSupportedException(); } public static ReturnCode DsmEntry( @@ -69,8 +85,16 @@ namespace NTwain.Triplets Message msg, TWAudioInfo data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -80,8 +104,16 @@ namespace NTwain.Triplets Message msg, TWCapability data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -91,8 +123,16 @@ namespace NTwain.Triplets Message msg, TWCustomDSData data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -102,8 +142,16 @@ namespace NTwain.Triplets Message msg, TWDeviceEvent data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -113,8 +161,16 @@ namespace NTwain.Triplets Message msg, TWCallback data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -124,8 +180,16 @@ namespace NTwain.Triplets Message msg, TWCallback2 data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -135,8 +199,16 @@ namespace NTwain.Triplets Message msg, TWEntryPoint data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -146,8 +218,16 @@ namespace NTwain.Triplets Message msg, TWEvent data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -157,8 +237,16 @@ namespace NTwain.Triplets Message msg, TWFileSystem data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); + } + throw new PlatformNotSupportedException(); } public static ReturnCode DsmEntry( @@ -166,8 +254,16 @@ namespace NTwain.Triplets Message msg, TWIdentity data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } - else { return NativeMethods.DsmEntry32(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } + else { return NativeMethods.DsmEntry32(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -177,8 +273,16 @@ namespace NTwain.Triplets Message msg, TWPassThru data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -188,8 +292,16 @@ namespace NTwain.Triplets Message msg, TWPendingXfers data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -199,8 +311,16 @@ namespace NTwain.Triplets Message msg, TWSetupFileXfer data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -210,8 +330,16 @@ namespace NTwain.Triplets Message msg, TWSetupMemXfer data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -221,8 +349,16 @@ namespace NTwain.Triplets Message msg, TWStatusUtf8 data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -232,8 +368,16 @@ namespace NTwain.Triplets Message msg, TWUserInterface data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -243,8 +387,16 @@ namespace NTwain.Triplets Message msg, TWCieColor data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -254,8 +406,16 @@ namespace NTwain.Triplets Message msg, TWExtImageInfo data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); + } + throw new PlatformNotSupportedException(); } public static ReturnCode DsmEntry( @@ -264,8 +424,16 @@ namespace NTwain.Triplets Message msg, TWFilter data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); + } + throw new PlatformNotSupportedException(); } public static ReturnCode DsmEntry( @@ -274,8 +442,16 @@ namespace NTwain.Triplets Message msg, TWGrayResponse data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -285,8 +461,16 @@ namespace NTwain.Triplets Message msg, TWImageInfo data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -296,8 +480,16 @@ namespace NTwain.Triplets Message msg, TWImageLayout data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -307,8 +499,16 @@ namespace NTwain.Triplets Message msg, TWImageMemXfer data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -318,8 +518,16 @@ namespace NTwain.Triplets Message msg, TWJpegCompression data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -329,8 +537,16 @@ namespace NTwain.Triplets Message msg, TWPalette8 data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -340,8 +556,16 @@ namespace NTwain.Triplets Message msg, TWRgbResponse data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -351,8 +575,16 @@ namespace NTwain.Triplets Message msg, TWStatus data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); + } + throw new PlatformNotSupportedException(); } @@ -363,8 +595,16 @@ namespace NTwain.Triplets Message msg, ref TWMemory data) { - if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, dat, msg, ref data); } - else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, dat, msg, ref data); } + if (IsWin) + { + if (CanUseNewDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, dat, msg, ref data); } + else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, dat, msg, ref data); } + } + else if (IsLinux) + { + return NativeMethods.DsmEntryLinux(origin, destination, DataGroups.Control, dat, msg, ref data); + } + throw new PlatformNotSupportedException(); }