Started TWAIN implementation.

Marcus Meissner <marcus@jet.franken.de>
Merged into WineHQ, made sure it works without SANE.

diff --git a/configure b/configure
index ad37288..1f20bf3 100755
--- a/configure
+++ b/configure
@@ -6530,7 +6530,156 @@
 
 fi
 
-echo "$as_me:6533: checking for FT_Init_FreeType in -lfreetype" >&5
+# Extract the first word of "sane-config", so it can be a program name with args.
+set dummy sane-config; ac_word=$2
+echo "$as_me:6535: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_sane_devel+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$sane_devel"; then
+  ac_cv_prog_sane_devel="$sane_devel" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_sane_devel="sane-config"
+echo "$as_me:6550: found $ac_dir/$ac_word" >&5
+break
+done
+
+  test -z "$ac_cv_prog_sane_devel" && ac_cv_prog_sane_devel="no"
+fi
+fi
+sane_devel=$ac_cv_prog_sane_devel
+if test -n "$sane_devel"; then
+  echo "$as_me:6559: result: $sane_devel" >&5
+echo "${ECHO_T}$sane_devel" >&6
+else
+  echo "$as_me:6562: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "$sane_devel" = "no"
+then
+    SANELIBS=""
+    SANEINCL=""
+else
+    SANELIBS="`$sane_devel --libs`"
+    SANEINCL="`$sane_devel --cflags`"
+    ac_save_CPPFLAGS="$CPPFLAGS"
+    ac_save_LIBS="$LIBS"
+    CPPFLAGS="$CPPFLAGS $SANEINCL"
+    LIBS="$LIBS $SANELIBS"
+    echo "$as_me:6577: checking for sane/sane.h" >&5
+echo $ECHO_N "checking for sane/sane.h... $ECHO_C" >&6
+if test "${ac_cv_header_sane_sane_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6583 "configure"
+#include "confdefs.h"
+#include <sane/sane.h>
+_ACEOF
+if { (eval echo "$as_me:6587: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:6593: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_sane_sane_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_header_sane_sane_h=no
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:6612: result: $ac_cv_header_sane_sane_h" >&5
+echo "${ECHO_T}$ac_cv_header_sane_sane_h" >&6
+if test $ac_cv_header_sane_sane_h = yes; then
+
+	    echo "$as_me:6616: checking for sane_open in -lsane" >&5
+echo $ECHO_N "checking for sane_open in -lsane... $ECHO_C" >&6
+if test "${ac_cv_lib_sane_sane_open+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsane  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 6624 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char sane_open ();
+int
+main ()
+{
+sane_open ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6643: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6646: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6649: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6652: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_sane_sane_open=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_sane_sane_open=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:6663: result: $ac_cv_lib_sane_sane_open" >&5
+echo "${ECHO_T}$ac_cv_lib_sane_sane_open" >&6
+if test $ac_cv_lib_sane_sane_open = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_SANE 1
+EOF
+
+else
+  SANELIBS=""
+
+fi
+
+fi
+
+    LIBS="$ac_save_LIBS"
+    CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+
+echo "$as_me:6682: checking for FT_Init_FreeType in -lfreetype" >&5
 echo $ECHO_N "checking for FT_Init_FreeType in -lfreetype... $ECHO_C" >&6
 if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6538,7 +6687,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lfreetype $X_LIBS $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 6541 "configure"
+#line 6690 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -6557,16 +6706,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:6560: \"$ac_link\"") >&5
+if { (eval echo "$as_me:6709: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6563: \$? = $ac_status" >&5
+  echo "$as_me:6712: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:6566: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6715: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6569: \$? = $ac_status" >&5
+  echo "$as_me:6718: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_freetype_FT_Init_FreeType=yes
 else
@@ -6577,7 +6726,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:6580: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5
+echo "$as_me:6729: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5
 echo "${ECHO_T}$ac_cv_lib_freetype_FT_Init_FreeType" >&6
 if test $ac_cv_lib_freetype_FT_Init_FreeType = yes; then
   ft_lib=yes
@@ -6593,7 +6742,7 @@
 else
     # Extract the first word of "freetype-config", so it can be a program name with args.
 set dummy freetype-config; ac_word=$2
-echo "$as_me:6596: checking for $ac_word" >&5
+echo "$as_me:6745: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ft_devel+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6608,7 +6757,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ft_devel="freetype-config"
-echo "$as_me:6611: found $ac_dir/$ac_word" >&5
+echo "$as_me:6760: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -6617,10 +6766,10 @@
 fi
 ft_devel=$ac_cv_prog_ft_devel
 if test -n "$ft_devel"; then
-  echo "$as_me:6620: result: $ft_devel" >&5
+  echo "$as_me:6769: result: $ft_devel" >&5
 echo "${ECHO_T}$ft_devel" >&6
 else
-  echo "$as_me:6623: result: no" >&5
+  echo "$as_me:6772: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -6628,7 +6777,7 @@
     then
         # Extract the first word of "freetype2-config", so it can be a program name with args.
 set dummy freetype2-config; ac_word=$2
-echo "$as_me:6631: checking for $ac_word" >&5
+echo "$as_me:6780: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ft_devel2+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6643,7 +6792,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ft_devel2="freetype2-config"
-echo "$as_me:6646: found $ac_dir/$ac_word" >&5
+echo "$as_me:6795: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -6652,10 +6801,10 @@
 fi
 ft_devel2=$ac_cv_prog_ft_devel2
 if test -n "$ft_devel2"; then
-  echo "$as_me:6655: result: $ft_devel2" >&5
+  echo "$as_me:6804: result: $ft_devel2" >&5
 echo "${ECHO_T}$ft_devel2" >&6
 else
-  echo "$as_me:6658: result: no" >&5
+  echo "$as_me:6807: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -6685,23 +6834,23 @@
                          freetype/internal/sfnt.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:6688: checking for $ac_header" >&5
+echo "$as_me:6837: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 6694 "configure"
+#line 6843 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:6698: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:6847: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:6704: \$? = $ac_status" >&5
+  echo "$as_me:6853: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -6720,7 +6869,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:6723: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:6872: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -6731,18 +6880,18 @@
 done
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 6734 "configure"
+#line 6883 "configure"
 #include "confdefs.h"
 #include <ft2build.h>
                     #include <freetype/fttrigon.h>
 _ACEOF
-if { (eval echo "$as_me:6739: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:6888: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:6745: \$? = $ac_status" >&5
+  echo "$as_me:6894: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -6782,13 +6931,13 @@
     fi
 fi
 
-echo "$as_me:6785: checking for parport header/ppdev.h" >&5
+echo "$as_me:6934: checking for parport header/ppdev.h" >&5
 echo $ECHO_N "checking for parport header/ppdev.h... $ECHO_C" >&6
 if test "${ac_cv_c_ppdev+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 6791 "configure"
+#line 6940 "configure"
 #include "confdefs.h"
 #include <linux/ppdev.h>
 int
@@ -6800,16 +6949,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6803: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:6952: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6806: \$? = $ac_status" >&5
+  echo "$as_me:6955: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6809: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6958: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6812: \$? = $ac_status" >&5
+  echo "$as_me:6961: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_ppdev="yes"
 else
@@ -6820,7 +6969,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:6823: result: $ac_cv_c_ppdev" >&5
+echo "$as_me:6972: result: $ac_cv_c_ppdev" >&5
 echo "${ECHO_T}$ac_cv_c_ppdev" >&6
 if test "$ac_cv_c_ppdev" = "yes"
 then
@@ -6831,13 +6980,13 @@
 
 fi
 
-echo "$as_me:6834: checking for GNU style IPX support" >&5
+echo "$as_me:6983: checking for GNU style IPX support" >&5
 echo $ECHO_N "checking for GNU style IPX support... $ECHO_C" >&6
 if test "${ac_cv_c_ipx_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 6840 "configure"
+#line 6989 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
     #include <netipx/ipx.h>
@@ -6850,16 +6999,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6853: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7002: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6856: \$? = $ac_status" >&5
+  echo "$as_me:7005: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6859: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7008: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6862: \$? = $ac_status" >&5
+  echo "$as_me:7011: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_ipx_gnu="yes"
 else
@@ -6870,7 +7019,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:6873: result: $ac_cv_c_ipx_gnu" >&5
+echo "$as_me:7022: result: $ac_cv_c_ipx_gnu" >&5
 echo "${ECHO_T}$ac_cv_c_ipx_gnu" >&6
 if test "$ac_cv_c_ipx_gnu" = "yes"
 then
@@ -6883,13 +7032,13 @@
 
 if test "$ac_cv_c_ipx_gnu" = "no"
 then
- echo "$as_me:6886: checking for linux style IPX support" >&5
+ echo "$as_me:7035: checking for linux style IPX support" >&5
 echo $ECHO_N "checking for linux style IPX support... $ECHO_C" >&6
 if test "${ac_cv_c_ipx_linux+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 6892 "configure"
+#line 7041 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
      #include <asm/types.h>
@@ -6903,16 +7052,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6906: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7055: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6909: \$? = $ac_status" >&5
+  echo "$as_me:7058: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6912: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7061: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6915: \$? = $ac_status" >&5
+  echo "$as_me:7064: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_ipx_linux="yes"
 else
@@ -6923,7 +7072,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:6926: result: $ac_cv_c_ipx_linux" >&5
+echo "$as_me:7075: result: $ac_cv_c_ipx_linux" >&5
 echo "${ECHO_T}$ac_cv_c_ipx_linux" >&6
   if test "$ac_cv_c_ipx_linux" = "yes"
   then
@@ -6938,23 +7087,23 @@
 for ac_header in sys/soundcard.h machine/soundcard.h soundcard.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:6941: checking for $ac_header" >&5
+echo "$as_me:7090: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 6947 "configure"
+#line 7096 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:6951: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:7100: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:6957: \$? = $ac_status" >&5
+  echo "$as_me:7106: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -6973,7 +7122,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:6976: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:7125: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -6983,13 +7132,13 @@
 fi
 done
 
-echo "$as_me:6986: checking for Open Sound System" >&5
+echo "$as_me:7135: checking for Open Sound System" >&5
 echo $ECHO_N "checking for Open Sound System... $ECHO_C" >&6
 if test "${ac_cv_c_opensoundsystem+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 6992 "configure"
+#line 7141 "configure"
 #include "confdefs.h"
 
 	#if defined(HAVE_SYS_SOUNDCARD_H)
@@ -7014,16 +7163,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7017: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7166: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7020: \$? = $ac_status" >&5
+  echo "$as_me:7169: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7023: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7172: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7026: \$? = $ac_status" >&5
+  echo "$as_me:7175: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_opensoundsystem="yes"
 else
@@ -7033,7 +7182,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:7036: result: $ac_cv_c_opensoundsystem" >&5
+echo "$as_me:7185: result: $ac_cv_c_opensoundsystem" >&5
 echo "${ECHO_T}$ac_cv_c_opensoundsystem" >&6
 
 if test "$ac_cv_c_opensoundsystem" = "yes"
@@ -7045,13 +7194,13 @@
 
 fi
 
-echo "$as_me:7048: checking for Open Sound System/MIDI interface" >&5
+echo "$as_me:7197: checking for Open Sound System/MIDI interface" >&5
 echo $ECHO_N "checking for Open Sound System/MIDI interface... $ECHO_C" >&6
 if test "${ac_cv_c_opensoundsystem_midi+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7054 "configure"
+#line 7203 "configure"
 #include "confdefs.h"
 
 	#if defined(HAVE_SYS_SOUNDCARD_H)
@@ -7076,16 +7225,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7079: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7228: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7082: \$? = $ac_status" >&5
+  echo "$as_me:7231: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7085: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7234: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7088: \$? = $ac_status" >&5
+  echo "$as_me:7237: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_opensoundsystem_midi="yes"
 else
@@ -7095,7 +7244,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:7098: result: $ac_cv_c_opensoundsystem_midi" >&5
+echo "$as_me:7247: result: $ac_cv_c_opensoundsystem_midi" >&5
 echo "${ECHO_T}$ac_cv_c_opensoundsystem_midi" >&6
 
 if test "$ac_cv_c_opensoundsystem_midi" = "yes"
@@ -7109,7 +7258,7 @@
 
 # Extract the first word of "artsc-config", so it can be a program name with args.
 set dummy artsc-config; ac_word=$2
-echo "$as_me:7112: checking for $ac_word" >&5
+echo "$as_me:7261: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_ARTSCCONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7126,7 +7275,7 @@
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_ARTSCCONFIG="$ac_dir/$ac_word"
-   echo "$as_me:7129: found $ac_dir/$ac_word" >&5
+   echo "$as_me:7278: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -7137,14 +7286,14 @@
 ARTSCCONFIG=$ac_cv_path_ARTSCCONFIG
 
 if test -n "$ARTSCCONFIG"; then
-  echo "$as_me:7140: result: $ARTSCCONFIG" >&5
+  echo "$as_me:7289: result: $ARTSCCONFIG" >&5
 echo "${ECHO_T}$ARTSCCONFIG" >&6
 else
-  echo "$as_me:7143: result: no" >&5
+  echo "$as_me:7292: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:7147: checking for aRts Sound server" >&5
+echo "$as_me:7296: checking for aRts Sound server" >&5
 echo $ECHO_N "checking for aRts Sound server... $ECHO_C" >&6
 if test "${ac_cv_c_artsserver+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7159,7 +7308,7 @@
             save_CFLAGS="$CFLAGS"
             CFLAGS="$CFLAGS $ARTSC_CFLAGS"
             cat >conftest.$ac_ext <<_ACEOF
-#line 7162 "configure"
+#line 7311 "configure"
 #include "confdefs.h"
 
              #include <artsc.h>
@@ -7175,16 +7324,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7178: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7327: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7181: \$? = $ac_status" >&5
+  echo "$as_me:7330: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7184: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7333: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7187: \$? = $ac_status" >&5
+  echo "$as_me:7336: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
             ac_cv_c_artsserver=yes
@@ -7197,7 +7346,7 @@
             CFLAGS="$save_CFLAGS"
         fi
 fi
-echo "$as_me:7200: result: $ac_cv_c_artsserver" >&5
+echo "$as_me:7349: result: $ac_cv_c_artsserver" >&5
 echo "${ECHO_T}$ac_cv_c_artsserver" >&6
 
 if test "$ac_cv_c_artsserver" = "yes"
@@ -7212,7 +7361,7 @@
 
 fi
 
-echo "$as_me:7215: checking whether mmap64 works defined as mmap" >&5
+echo "$as_me:7364: checking whether mmap64 works defined as mmap" >&5
 echo $ECHO_N "checking whether mmap64 works defined as mmap... $ECHO_C" >&6
 if test "${ac_cv_mmap64_works+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7221,7 +7370,7 @@
   ac_cv_mmap64_works="no"
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7224 "configure"
+#line 7373 "configure"
 #include "confdefs.h"
 
 		#define _FILE_OFFSET_BITS 64
@@ -7251,15 +7400,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7254: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7403: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7257: \$? = $ac_status" >&5
+  echo "$as_me:7406: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7259: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7408: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7262: \$? = $ac_status" >&5
+  echo "$as_me:7411: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_mmap64_works="yes"
 else
@@ -7271,7 +7420,7 @@
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
-echo "$as_me:7274: result: $ac_cv_mmap64_works" >&5
+echo "$as_me:7423: result: $ac_cv_mmap64_works" >&5
 echo "${ECHO_T}$ac_cv_mmap64_works" >&6
 
 if test "$ac_cv_mmap64_works" = "yes"
@@ -7286,7 +7435,7 @@
 if test "x${GCC}" = "xyes"
 then
   CFLAGS="$CFLAGS -Wall"
-  echo "$as_me:7289: checking for gcc strength-reduce bug" >&5
+  echo "$as_me:7438: checking for gcc strength-reduce bug" >&5
 echo $ECHO_N "checking for gcc strength-reduce bug... $ECHO_C" >&6
 if test "${ac_cv_c_gcc_strength_bug+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7295,7 +7444,7 @@
   ac_cv_c_gcc_strength_bug="yes"
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7298 "configure"
+#line 7447 "configure"
 #include "confdefs.h"
 
 int	L[4] = {0,1,2,3};
@@ -7311,15 +7460,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7314: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7463: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7317: \$? = $ac_status" >&5
+  echo "$as_me:7466: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7319: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7468: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7322: \$? = $ac_status" >&5
+  echo "$as_me:7471: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_gcc_strength_bug="no"
 else
@@ -7331,14 +7480,14 @@
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
-echo "$as_me:7334: result: $ac_cv_c_gcc_strength_bug" >&5
+echo "$as_me:7483: result: $ac_cv_c_gcc_strength_bug" >&5
 echo "${ECHO_T}$ac_cv_c_gcc_strength_bug" >&6
   if test "$ac_cv_c_gcc_strength_bug" = "yes"
   then
     CFLAGS="$CFLAGS -fno-strength-reduce"
   fi
 
-    echo "$as_me:7341: checking for gcc -mpreferred-stack-boundary=2 support" >&5
+    echo "$as_me:7490: checking for gcc -mpreferred-stack-boundary=2 support" >&5
 echo $ECHO_N "checking for gcc -mpreferred-stack-boundary=2 support... $ECHO_C" >&6
 if test "${ac_cv_c_gcc_stack_boundary+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7346,7 +7495,7 @@
   saved_cflags=$CFLAGS
   CFLAGS="$CFLAGS -mpreferred-stack-boundary=2"
   cat >conftest.$ac_ext <<_ACEOF
-#line 7349 "configure"
+#line 7498 "configure"
 #include "confdefs.h"
 
 int
@@ -7358,16 +7507,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7361: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7510: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7364: \$? = $ac_status" >&5
+  echo "$as_me:7513: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7367: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7516: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7370: \$? = $ac_status" >&5
+  echo "$as_me:7519: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_gcc_stack_boundary="yes"
 else
@@ -7379,7 +7528,7 @@
   CFLAGS=$saved_cflags
 
 fi
-echo "$as_me:7382: result: $ac_cv_c_gcc_stack_boundary" >&5
+echo "$as_me:7531: result: $ac_cv_c_gcc_stack_boundary" >&5
 echo "${ECHO_T}$ac_cv_c_gcc_stack_boundary" >&6
   if test "$ac_cv_c_gcc_stack_boundary" = "yes"
   then
@@ -7387,7 +7536,7 @@
   fi
 fi
 
-echo "$as_me:7390: checking whether .type must sit inside a .def directive" >&5
+echo "$as_me:7539: checking whether .type must sit inside a .def directive" >&5
 echo $ECHO_N "checking whether .type must sit inside a .def directive... $ECHO_C" >&6
 if test "${ac_cv_c_type_in_def+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7401,7 +7550,7 @@
 	.long 0
 EOF
 cat >conftest.$ac_ext <<_ACEOF
-#line 7404 "configure"
+#line 7553 "configure"
 #include "confdefs.h"
 
 int
@@ -7413,16 +7562,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7416: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7565: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7419: \$? = $ac_status" >&5
+  echo "$as_me:7568: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7422: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7571: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7425: \$? = $ac_status" >&5
+  echo "$as_me:7574: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_type_in_def="yes"
 else
@@ -7433,7 +7582,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$saved_libs
 fi
-echo "$as_me:7436: result: $ac_cv_c_type_in_def" >&5
+echo "$as_me:7585: result: $ac_cv_c_type_in_def" >&5
 echo "${ECHO_T}$ac_cv_c_type_in_def" >&6
 if test "$ac_cv_c_type_in_def" = "yes"
 then
@@ -7444,7 +7593,7 @@
 
 fi
 
-echo "$as_me:7447: checking whether external symbols need an underscore prefix" >&5
+echo "$as_me:7596: checking whether external symbols need an underscore prefix" >&5
 echo $ECHO_N "checking whether external symbols need an underscore prefix... $ECHO_C" >&6
 if test "${ac_cv_c_extern_prefix+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7457,7 +7606,7 @@
 	.long 0
 EOF
 cat >conftest.$ac_ext <<_ACEOF
-#line 7460 "configure"
+#line 7609 "configure"
 #include "confdefs.h"
 extern int ac_test;
 int
@@ -7469,16 +7618,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7472: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7621: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7475: \$? = $ac_status" >&5
+  echo "$as_me:7624: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7478: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7627: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7481: \$? = $ac_status" >&5
+  echo "$as_me:7630: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_extern_prefix="yes"
 else
@@ -7489,7 +7638,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$saved_libs
 fi
-echo "$as_me:7492: result: $ac_cv_c_extern_prefix" >&5
+echo "$as_me:7641: result: $ac_cv_c_extern_prefix" >&5
 echo "${ECHO_T}$ac_cv_c_extern_prefix" >&6
 if test "$ac_cv_c_extern_prefix" = "yes"
 then
@@ -7500,7 +7649,7 @@
 
 fi
 
-echo "$as_me:7503: checking whether stdcall symbols need to be decorated" >&5
+echo "$as_me:7652: checking whether stdcall symbols need to be decorated" >&5
 echo $ECHO_N "checking whether stdcall symbols need to be decorated... $ECHO_C" >&6
 if test "${ac_cv_c_stdcall_decoration+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7520,7 +7669,7 @@
 EOF
 fi
 cat >conftest.$ac_ext <<_ACEOF
-#line 7523 "configure"
+#line 7672 "configure"
 #include "confdefs.h"
 extern void __attribute__((__stdcall__)) ac_test(void);
 int
@@ -7532,16 +7681,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7535: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7684: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7538: \$? = $ac_status" >&5
+  echo "$as_me:7687: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7541: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7690: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7544: \$? = $ac_status" >&5
+  echo "$as_me:7693: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_stdcall_decoration="yes"
 else
@@ -7552,7 +7701,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$saved_libs
 fi
-echo "$as_me:7555: result: $ac_cv_c_stdcall_decoration" >&5
+echo "$as_me:7704: result: $ac_cv_c_stdcall_decoration" >&5
 echo "${ECHO_T}$ac_cv_c_stdcall_decoration" >&6
 if test "$ac_cv_c_stdcall_decoration" = "yes"
 then
@@ -7563,7 +7712,7 @@
 
 fi
 
-echo "$as_me:7566: checking whether assembler accepts .string" >&5
+echo "$as_me:7715: checking whether assembler accepts .string" >&5
 echo $ECHO_N "checking whether assembler accepts .string... $ECHO_C" >&6
 if test "${ac_cv_c_asm_string+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7574,7 +7723,7 @@
 	.string "test"
 EOF
 cat >conftest.$ac_ext <<_ACEOF
-#line 7577 "configure"
+#line 7726 "configure"
 #include "confdefs.h"
 
 int
@@ -7586,16 +7735,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7589: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7738: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7592: \$? = $ac_status" >&5
+  echo "$as_me:7741: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7595: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7744: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7598: \$? = $ac_status" >&5
+  echo "$as_me:7747: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_asm_string="yes"
 else
@@ -7606,7 +7755,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$saved_libs
 fi
-echo "$as_me:7609: result: $ac_cv_c_asm_string" >&5
+echo "$as_me:7758: result: $ac_cv_c_asm_string" >&5
 echo "${ECHO_T}$ac_cv_c_asm_string" >&6
 if test "$ac_cv_c_asm_string" = "yes"
 then
@@ -7621,7 +7770,7 @@
 LDDLLFLAGS=""
 if test "$LIBEXT" = "so"
 then
-  echo "$as_me:7624: checking whether we can build a GNU style ELF dll" >&5
+  echo "$as_me:7773: checking whether we can build a GNU style ELF dll" >&5
 echo $ECHO_N "checking whether we can build a GNU style ELF dll... $ECHO_C" >&6
 if test "${ac_cv_c_dll_gnuelf+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7629,7 +7778,7 @@
   saved_cflags=$CFLAGS
   CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic"
   cat >conftest.$ac_ext <<_ACEOF
-#line 7632 "configure"
+#line 7781 "configure"
 #include "confdefs.h"
 
 int
@@ -7641,16 +7790,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7644: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7793: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7647: \$? = $ac_status" >&5
+  echo "$as_me:7796: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7650: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7799: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7653: \$? = $ac_status" >&5
+  echo "$as_me:7802: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_dll_gnuelf="yes"
 else
@@ -7662,14 +7811,14 @@
   CFLAGS=$saved_cflags
 
 fi
-echo "$as_me:7665: result: $ac_cv_c_dll_gnuelf" >&5
+echo "$as_me:7814: result: $ac_cv_c_dll_gnuelf" >&5
 echo "${ECHO_T}$ac_cv_c_dll_gnuelf" >&6
   if test "$ac_cv_c_dll_gnuelf" = "yes"
   then
     LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%)"
     LDDLLFLAGS="-Wl,-Bsymbolic"
   else
-    echo "$as_me:7672: checking whether we can build a UnixWare (Solaris) dll" >&5
+    echo "$as_me:7821: checking whether we can build a UnixWare (Solaris) dll" >&5
 echo $ECHO_N "checking whether we can build a UnixWare (Solaris) dll... $ECHO_C" >&6
 if test "${ac_cv_c_dll_unixware+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7677,7 +7826,7 @@
   saved_cflags=$CFLAGS
     CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic"
     cat >conftest.$ac_ext <<_ACEOF
-#line 7680 "configure"
+#line 7829 "configure"
 #include "confdefs.h"
 
 int
@@ -7689,16 +7838,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7692: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7841: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7695: \$? = $ac_status" >&5
+  echo "$as_me:7844: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7698: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7847: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7701: \$? = $ac_status" >&5
+  echo "$as_me:7850: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_dll_unixware="yes"
 else
@@ -7710,7 +7859,7 @@
     CFLAGS=$saved_cflags
 
 fi
-echo "$as_me:7713: result: $ac_cv_c_dll_unixware" >&5
+echo "$as_me:7862: result: $ac_cv_c_dll_unixware" >&5
 echo "${ECHO_T}$ac_cv_c_dll_unixware" >&6
     if test "$ac_cv_c_dll_unixware" = "yes"
     then
@@ -7723,7 +7872,7 @@
     LIBEXT="a"
     # Extract the first word of "dllwrap", so it can be a program name with args.
 set dummy dllwrap; ac_word=$2
-echo "$as_me:7726: checking for $ac_word" >&5
+echo "$as_me:7875: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_DLLWRAP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7738,7 +7887,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_DLLWRAP="dllwrap"
-echo "$as_me:7741: found $ac_dir/$ac_word" >&5
+echo "$as_me:7890: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -7747,10 +7896,10 @@
 fi
 DLLWRAP=$ac_cv_prog_DLLWRAP
 if test -n "$DLLWRAP"; then
-  echo "$as_me:7750: result: $DLLWRAP" >&5
+  echo "$as_me:7899: result: $DLLWRAP" >&5
 echo "${ECHO_T}$DLLWRAP" >&6
 else
-  echo "$as_me:7753: result: no" >&5
+  echo "$as_me:7902: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -7765,7 +7914,7 @@
 fi
 
 if test "$LIBEXT" = "a"; then
-  { { echo "$as_me:7768: error: could not find a way to build shared libraries.
+  { { echo "$as_me:7917: error: could not find a way to build shared libraries.
 It is currently not possible to build Wine without shared library
 (.so) support to allow transparent switch between .so and .dll files.
 If you are using Linux, you will need a newer binutils.
@@ -7793,7 +7942,7 @@
 
 wine_cv_libc_reentrant=no
 
-  echo "$as_me:7796: checking for reentrant libc: __errno_location" >&5
+  echo "$as_me:7945: checking for reentrant libc: __errno_location" >&5
 echo $ECHO_N "checking for reentrant libc: __errno_location... $ECHO_C" >&6
 if test "${wine_cv_libc_r___errno_location+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7802,7 +7951,7 @@
   wine_cv_libc_r___errno_location=yes
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7805 "configure"
+#line 7954 "configure"
 #include "confdefs.h"
 int myerrno = 0;
 char buf[256];
@@ -7810,15 +7959,15 @@
 main(){connect(0,buf,255); exit(!myerrno);}
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7813: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7962: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7816: \$? = $ac_status" >&5
+  echo "$as_me:7965: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7818: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7967: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7821: \$? = $ac_status" >&5
+  echo "$as_me:7970: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_libc_r___errno_location=yes
 else
@@ -7831,14 +7980,14 @@
 fi
 
 fi
-echo "$as_me:7834: result: $wine_cv_libc_r___errno_location" >&5
+echo "$as_me:7983: result: $wine_cv_libc_r___errno_location" >&5
 echo "${ECHO_T}$wine_cv_libc_r___errno_location" >&6
 if test "$wine_cv_libc_r___errno_location" = "yes"
 then
     wine_cv_libc_reentrant=__errno_location
 fi
 
-  echo "$as_me:7841: checking for reentrant libc: __error" >&5
+  echo "$as_me:7990: checking for reentrant libc: __error" >&5
 echo $ECHO_N "checking for reentrant libc: __error... $ECHO_C" >&6
 if test "${wine_cv_libc_r___error+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7847,7 +7996,7 @@
   wine_cv_libc_r___error=yes
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7850 "configure"
+#line 7999 "configure"
 #include "confdefs.h"
 int myerrno = 0;
 char buf[256];
@@ -7855,15 +8004,15 @@
 main(){connect(0,buf,255); exit(!myerrno);}
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7858: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8007: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7861: \$? = $ac_status" >&5
+  echo "$as_me:8010: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7863: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8012: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7866: \$? = $ac_status" >&5
+  echo "$as_me:8015: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_libc_r___error=yes
 else
@@ -7876,14 +8025,14 @@
 fi
 
 fi
-echo "$as_me:7879: result: $wine_cv_libc_r___error" >&5
+echo "$as_me:8028: result: $wine_cv_libc_r___error" >&5
 echo "${ECHO_T}$wine_cv_libc_r___error" >&6
 if test "$wine_cv_libc_r___error" = "yes"
 then
     wine_cv_libc_reentrant=__error
 fi
 
-  echo "$as_me:7886: checking for reentrant libc: ___errno" >&5
+  echo "$as_me:8035: checking for reentrant libc: ___errno" >&5
 echo $ECHO_N "checking for reentrant libc: ___errno... $ECHO_C" >&6
 if test "${wine_cv_libc_r____errno+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7892,7 +8041,7 @@
   wine_cv_libc_r____errno=yes
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7895 "configure"
+#line 8044 "configure"
 #include "confdefs.h"
 int myerrno = 0;
 char buf[256];
@@ -7900,15 +8049,15 @@
 main(){connect(0,buf,255); exit(!myerrno);}
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7903: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8052: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7906: \$? = $ac_status" >&5
+  echo "$as_me:8055: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7908: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8057: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7911: \$? = $ac_status" >&5
+  echo "$as_me:8060: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_libc_r____errno=yes
 else
@@ -7921,14 +8070,14 @@
 fi
 
 fi
-echo "$as_me:7924: result: $wine_cv_libc_r____errno" >&5
+echo "$as_me:8073: result: $wine_cv_libc_r____errno" >&5
 echo "${ECHO_T}$wine_cv_libc_r____errno" >&6
 if test "$wine_cv_libc_r____errno" = "yes"
 then
     wine_cv_libc_reentrant=___errno
 fi
 
-  echo "$as_me:7931: checking for reentrant libc: __thr_errno" >&5
+  echo "$as_me:8080: checking for reentrant libc: __thr_errno" >&5
 echo $ECHO_N "checking for reentrant libc: __thr_errno... $ECHO_C" >&6
 if test "${wine_cv_libc_r___thr_errno+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7937,7 +8086,7 @@
   wine_cv_libc_r___thr_errno=yes
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7940 "configure"
+#line 8089 "configure"
 #include "confdefs.h"
 int myerrno = 0;
 char buf[256];
@@ -7945,15 +8094,15 @@
 main(){connect(0,buf,255); exit(!myerrno);}
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7948: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8097: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7951: \$? = $ac_status" >&5
+  echo "$as_me:8100: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7953: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8102: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7956: \$? = $ac_status" >&5
+  echo "$as_me:8105: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_libc_r___thr_errno=yes
 else
@@ -7966,14 +8115,14 @@
 fi
 
 fi
-echo "$as_me:7969: result: $wine_cv_libc_r___thr_errno" >&5
+echo "$as_me:8118: result: $wine_cv_libc_r___thr_errno" >&5
 echo "${ECHO_T}$wine_cv_libc_r___thr_errno" >&6
 if test "$wine_cv_libc_r___thr_errno" = "yes"
 then
     wine_cv_libc_reentrant=__thr_errno
 fi
 
-  echo "$as_me:7976: checking for reentrant libc: __errno" >&5
+  echo "$as_me:8125: checking for reentrant libc: __errno" >&5
 echo $ECHO_N "checking for reentrant libc: __errno... $ECHO_C" >&6
 if test "${wine_cv_libc_r___errno+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7982,7 +8131,7 @@
   wine_cv_libc_r___errno=yes
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7985 "configure"
+#line 8134 "configure"
 #include "confdefs.h"
 int myerrno = 0;
 char buf[256];
@@ -7990,15 +8139,15 @@
 main(){connect(0,buf,255); exit(!myerrno);}
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7993: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8142: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7996: \$? = $ac_status" >&5
+  echo "$as_me:8145: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7998: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8147: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8001: \$? = $ac_status" >&5
+  echo "$as_me:8150: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_libc_r___errno=yes
 else
@@ -8011,7 +8160,7 @@
 fi
 
 fi
-echo "$as_me:8014: result: $wine_cv_libc_r___errno" >&5
+echo "$as_me:8163: result: $wine_cv_libc_r___errno" >&5
 echo "${ECHO_T}$wine_cv_libc_r___errno" >&6
 if test "$wine_cv_libc_r___errno" = "yes"
 then
@@ -8029,7 +8178,7 @@
 
 if test "$have_x" = "yes" -a "$wine_cv_libc_reentrant" != "no"
 then
-echo "$as_me:8032: checking for reentrant X libraries" >&5
+echo "$as_me:8181: checking for reentrant X libraries" >&5
 echo $ECHO_N "checking for reentrant X libraries... $ECHO_C" >&6
 if test "${wine_cv_x_reentrant+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8061,7 +8210,7 @@
 	fi
     fi
 fi
-echo "$as_me:8064: result: $wine_cv_x_reentrant" >&5
+echo "$as_me:8213: result: $wine_cv_x_reentrant" >&5
 echo "${ECHO_T}$wine_cv_x_reentrant" >&6
 else
     wine_cv_x_reentrant=no
@@ -8077,13 +8226,13 @@
 
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
-echo "$as_me:8080: checking for working alloca.h" >&5
+echo "$as_me:8229: checking for working alloca.h" >&5
 echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6
 if test "${ac_cv_working_alloca_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8086 "configure"
+#line 8235 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int
@@ -8095,16 +8244,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8098: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8247: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8101: \$? = $ac_status" >&5
+  echo "$as_me:8250: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8104: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8253: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8107: \$? = $ac_status" >&5
+  echo "$as_me:8256: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_working_alloca_h=yes
 else
@@ -8114,7 +8263,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:8117: result: $ac_cv_working_alloca_h" >&5
+echo "$as_me:8266: result: $ac_cv_working_alloca_h" >&5
 echo "${ECHO_T}$ac_cv_working_alloca_h" >&6
 if test $ac_cv_working_alloca_h = yes; then
 
@@ -8124,13 +8273,13 @@
 
 fi
 
-echo "$as_me:8127: checking for alloca" >&5
+echo "$as_me:8276: checking for alloca" >&5
 echo $ECHO_N "checking for alloca... $ECHO_C" >&6
 if test "${ac_cv_func_alloca_works+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8133 "configure"
+#line 8282 "configure"
 #include "confdefs.h"
 #ifdef __GNUC__
 # define alloca __builtin_alloca
@@ -8162,16 +8311,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8165: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8314: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8168: \$? = $ac_status" >&5
+  echo "$as_me:8317: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8171: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8320: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8174: \$? = $ac_status" >&5
+  echo "$as_me:8323: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func_alloca_works=yes
 else
@@ -8181,7 +8330,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:8184: result: $ac_cv_func_alloca_works" >&5
+echo "$as_me:8333: result: $ac_cv_func_alloca_works" >&5
 echo "${ECHO_T}$ac_cv_func_alloca_works" >&6
 
 if test $ac_cv_func_alloca_works = yes; then
@@ -8202,13 +8351,13 @@
 #define C_ALLOCA 1
 EOF
 
-echo "$as_me:8205: checking whether \`alloca.c' needs Cray hooks" >&5
+echo "$as_me:8354: checking whether \`alloca.c' needs Cray hooks" >&5
 echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6
 if test "${ac_cv_os_cray+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8211 "configure"
+#line 8360 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -8226,18 +8375,18 @@
 rm -f conftest*
 
 fi
-echo "$as_me:8229: result: $ac_cv_os_cray" >&5
+echo "$as_me:8378: result: $ac_cv_os_cray" >&5
 echo "${ECHO_T}$ac_cv_os_cray" >&6
 if test $ac_cv_os_cray = yes; then
   for ac_func in _getb67 GETB67 getb67; do
     as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:8234: checking for $ac_func" >&5
+echo "$as_me:8383: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8240 "configure"
+#line 8389 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func (); below.  */
@@ -8268,16 +8417,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8271: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8420: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8274: \$? = $ac_status" >&5
+  echo "$as_me:8423: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8277: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8426: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8280: \$? = $ac_status" >&5
+  echo "$as_me:8429: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -8287,7 +8436,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:8290: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:8439: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
 
@@ -8301,7 +8450,7 @@
   done
 fi
 
-echo "$as_me:8304: checking stack direction for C alloca" >&5
+echo "$as_me:8453: checking stack direction for C alloca" >&5
 echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6
 if test "${ac_cv_c_stack_direction+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8310,7 +8459,7 @@
   ac_cv_c_stack_direction=0
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8313 "configure"
+#line 8462 "configure"
 #include "confdefs.h"
 int
 find_stack_direction ()
@@ -8333,15 +8482,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:8336: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8485: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8339: \$? = $ac_status" >&5
+  echo "$as_me:8488: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:8341: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8490: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8344: \$? = $ac_status" >&5
+  echo "$as_me:8493: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_stack_direction=1
 else
@@ -8353,7 +8502,7 @@
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
-echo "$as_me:8356: result: $ac_cv_c_stack_direction" >&5
+echo "$as_me:8505: result: $ac_cv_c_stack_direction" >&5
 echo "${ECHO_T}$ac_cv_c_stack_direction" >&6
 
 cat >>confdefs.h <<EOF
@@ -8409,13 +8558,13 @@
 
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:8412: checking for $ac_func" >&5
+echo "$as_me:8561: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8418 "configure"
+#line 8567 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func (); below.  */
@@ -8446,16 +8595,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8449: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8598: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8452: \$? = $ac_status" >&5
+  echo "$as_me:8601: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8455: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8604: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8458: \$? = $ac_status" >&5
+  echo "$as_me:8607: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -8465,7 +8614,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:8468: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:8617: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -8537,23 +8686,23 @@
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:8540: checking for $ac_header" >&5
+echo "$as_me:8689: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8546 "configure"
+#line 8695 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:8550: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:8699: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:8556: \$? = $ac_status" >&5
+  echo "$as_me:8705: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -8572,7 +8721,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:8575: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:8724: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -8582,13 +8731,13 @@
 fi
 done
 
-echo "$as_me:8585: checking whether stat file-mode macros are broken" >&5
+echo "$as_me:8734: checking whether stat file-mode macros are broken" >&5
 echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6
 if test "${ac_cv_header_stat_broken+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8591 "configure"
+#line 8740 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -8627,7 +8776,7 @@
 rm -f conftest*
 
 fi
-echo "$as_me:8630: result: $ac_cv_header_stat_broken" >&5
+echo "$as_me:8779: result: $ac_cv_header_stat_broken" >&5
 echo "${ECHO_T}$ac_cv_header_stat_broken" >&6
 if test $ac_cv_header_stat_broken = yes; then
 
@@ -8637,7 +8786,7 @@
 
 fi
 
-echo "$as_me:8640: checking for $CC option to accept ANSI C" >&5
+echo "$as_me:8789: checking for $CC option to accept ANSI C" >&5
 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8645,7 +8794,7 @@
   ac_cv_prog_cc_stdc=no
 ac_save_CC=$CC
 cat >conftest.$ac_ext <<_ACEOF
-#line 8648 "configure"
+#line 8797 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 #include <stdio.h>
@@ -8694,16 +8843,16 @@
 do
   CC="$ac_save_CC $ac_arg"
   rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8697: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:8846: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8700: \$? = $ac_status" >&5
+  echo "$as_me:8849: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8703: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8852: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8706: \$? = $ac_status" >&5
+  echo "$as_me:8855: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cc_stdc=$ac_arg
 break
@@ -8720,21 +8869,21 @@
 
 case "x$ac_cv_prog_cc_stdc" in
   x|xno)
-    echo "$as_me:8723: result: none needed" >&5
+    echo "$as_me:8872: result: none needed" >&5
 echo "${ECHO_T}none needed" >&6 ;;
   *)
-    echo "$as_me:8726: result: $ac_cv_prog_cc_stdc" >&5
+    echo "$as_me:8875: result: $ac_cv_prog_cc_stdc" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
     CC="$CC $ac_cv_prog_cc_stdc" ;;
 esac
 
-echo "$as_me:8731: checking for an ANSI C-conforming const" >&5
+echo "$as_me:8880: checking for an ANSI C-conforming const" >&5
 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
 if test "${ac_cv_c_const+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8737 "configure"
+#line 8886 "configure"
 #include "confdefs.h"
 
 int
@@ -8792,16 +8941,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8795: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:8944: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8798: \$? = $ac_status" >&5
+  echo "$as_me:8947: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8801: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8950: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8804: \$? = $ac_status" >&5
+  echo "$as_me:8953: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_const=yes
 else
@@ -8811,7 +8960,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:8814: result: $ac_cv_c_const" >&5
+echo "$as_me:8963: result: $ac_cv_c_const" >&5
 echo "${ECHO_T}$ac_cv_c_const" >&6
 if test $ac_cv_c_const = no; then
 
@@ -8821,7 +8970,7 @@
 
 fi
 
-echo "$as_me:8824: checking for inline" >&5
+echo "$as_me:8973: checking for inline" >&5
 echo $ECHO_N "checking for inline... $ECHO_C" >&6
 if test "${ac_cv_c_inline+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8829,7 +8978,7 @@
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat >conftest.$ac_ext <<_ACEOF
-#line 8832 "configure"
+#line 8981 "configure"
 #include "confdefs.h"
 #ifndef __cplusplus
 static $ac_kw int static_foo () {return 0; }
@@ -8838,16 +8987,16 @@
 
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8841: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:8990: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8844: \$? = $ac_status" >&5
+  echo "$as_me:8993: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8847: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8996: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8850: \$? = $ac_status" >&5
+  echo "$as_me:8999: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_inline=$ac_kw; break
 else
@@ -8858,7 +9007,7 @@
 done
 
 fi
-echo "$as_me:8861: result: $ac_cv_c_inline" >&5
+echo "$as_me:9010: result: $ac_cv_c_inline" >&5
 echo "${ECHO_T}$ac_cv_c_inline" >&6
 case $ac_cv_c_inline in
   inline | yes) ;;
@@ -8873,13 +9022,13 @@
  ;;
 esac
 
-echo "$as_me:8876: checking for ANSI C header files" >&5
+echo "$as_me:9025: checking for ANSI C header files" >&5
 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
 if test "${ac_cv_header_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8882 "configure"
+#line 9031 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -8887,13 +9036,13 @@
 #include <float.h>
 
 _ACEOF
-if { (eval echo "$as_me:8890: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:9039: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:8896: \$? = $ac_status" >&5
+  echo "$as_me:9045: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -8915,7 +9064,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
   cat >conftest.$ac_ext <<_ACEOF
-#line 8918 "configure"
+#line 9067 "configure"
 #include "confdefs.h"
 #include <string.h>
 
@@ -8933,7 +9082,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
   cat >conftest.$ac_ext <<_ACEOF
-#line 8936 "configure"
+#line 9085 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 
@@ -8954,7 +9103,7 @@
   :
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8957 "configure"
+#line 9106 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #if ((' ' & 0x0FF) == 0x020)
@@ -8980,15 +9129,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:8983: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9132: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8986: \$? = $ac_status" >&5
+  echo "$as_me:9135: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:8988: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9137: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8991: \$? = $ac_status" >&5
+  echo "$as_me:9140: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -9001,7 +9150,7 @@
 fi
 fi
 fi
-echo "$as_me:9004: result: $ac_cv_header_stdc" >&5
+echo "$as_me:9153: result: $ac_cv_header_stdc" >&5
 echo "${ECHO_T}$ac_cv_header_stdc" >&6
 if test $ac_cv_header_stdc = yes; then
 
@@ -9017,28 +9166,28 @@
                   inttypes.h stdint.h unistd.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:9020: checking for $ac_header" >&5
+echo "$as_me:9169: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9026 "configure"
+#line 9175 "configure"
 #include "confdefs.h"
 $ac_includes_default
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9032: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9181: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9035: \$? = $ac_status" >&5
+  echo "$as_me:9184: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9038: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9187: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9041: \$? = $ac_status" >&5
+  echo "$as_me:9190: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_Header=yes"
 else
@@ -9048,7 +9197,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9051: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:9200: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -9058,13 +9207,13 @@
 fi
 done
 
-echo "$as_me:9061: checking for mode_t" >&5
+echo "$as_me:9210: checking for mode_t" >&5
 echo $ECHO_N "checking for mode_t... $ECHO_C" >&6
 if test "${ac_cv_type_mode_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9067 "configure"
+#line 9216 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9079,16 +9228,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9082: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9231: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9085: \$? = $ac_status" >&5
+  echo "$as_me:9234: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9088: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9237: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9091: \$? = $ac_status" >&5
+  echo "$as_me:9240: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_type_mode_t=yes
 else
@@ -9098,7 +9247,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9101: result: $ac_cv_type_mode_t" >&5
+echo "$as_me:9250: result: $ac_cv_type_mode_t" >&5
 echo "${ECHO_T}$ac_cv_type_mode_t" >&6
 if test $ac_cv_type_mode_t = yes; then
   :
@@ -9110,13 +9259,13 @@
 
 fi
 
-echo "$as_me:9113: checking for off_t" >&5
+echo "$as_me:9262: checking for off_t" >&5
 echo $ECHO_N "checking for off_t... $ECHO_C" >&6
 if test "${ac_cv_type_off_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9119 "configure"
+#line 9268 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9131,16 +9280,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9134: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9283: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9137: \$? = $ac_status" >&5
+  echo "$as_me:9286: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9140: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9289: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9143: \$? = $ac_status" >&5
+  echo "$as_me:9292: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_type_off_t=yes
 else
@@ -9150,7 +9299,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9153: result: $ac_cv_type_off_t" >&5
+echo "$as_me:9302: result: $ac_cv_type_off_t" >&5
 echo "${ECHO_T}$ac_cv_type_off_t" >&6
 if test $ac_cv_type_off_t = yes; then
   :
@@ -9162,13 +9311,13 @@
 
 fi
 
-echo "$as_me:9165: checking for pid_t" >&5
+echo "$as_me:9314: checking for pid_t" >&5
 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
 if test "${ac_cv_type_pid_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9171 "configure"
+#line 9320 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9183,16 +9332,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9186: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9335: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9189: \$? = $ac_status" >&5
+  echo "$as_me:9338: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9192: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9341: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9195: \$? = $ac_status" >&5
+  echo "$as_me:9344: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_type_pid_t=yes
 else
@@ -9202,7 +9351,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9205: result: $ac_cv_type_pid_t" >&5
+echo "$as_me:9354: result: $ac_cv_type_pid_t" >&5
 echo "${ECHO_T}$ac_cv_type_pid_t" >&6
 if test $ac_cv_type_pid_t = yes; then
   :
@@ -9214,13 +9363,13 @@
 
 fi
 
-echo "$as_me:9217: checking for size_t" >&5
+echo "$as_me:9366: checking for size_t" >&5
 echo $ECHO_N "checking for size_t... $ECHO_C" >&6
 if test "${ac_cv_type_size_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9223 "configure"
+#line 9372 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9235,16 +9384,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9238: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9387: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9241: \$? = $ac_status" >&5
+  echo "$as_me:9390: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9244: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9393: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9247: \$? = $ac_status" >&5
+  echo "$as_me:9396: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_type_size_t=yes
 else
@@ -9254,7 +9403,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9257: result: $ac_cv_type_size_t" >&5
+echo "$as_me:9406: result: $ac_cv_type_size_t" >&5
 echo "${ECHO_T}$ac_cv_type_size_t" >&6
 if test $ac_cv_type_size_t = yes; then
   :
@@ -9266,13 +9415,13 @@
 
 fi
 
-echo "$as_me:9269: checking for long long" >&5
+echo "$as_me:9418: checking for long long" >&5
 echo $ECHO_N "checking for long long... $ECHO_C" >&6
 if test "${ac_cv_type_long_long+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9275 "configure"
+#line 9424 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9287,16 +9436,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9290: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9439: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9293: \$? = $ac_status" >&5
+  echo "$as_me:9442: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9296: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9445: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9299: \$? = $ac_status" >&5
+  echo "$as_me:9448: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_type_long_long=yes
 else
@@ -9306,10 +9455,10 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9309: result: $ac_cv_type_long_long" >&5
+echo "$as_me:9458: result: $ac_cv_type_long_long" >&5
 echo "${ECHO_T}$ac_cv_type_long_long" >&6
 
-echo "$as_me:9312: checking size of long long" >&5
+echo "$as_me:9461: checking size of long long" >&5
 echo $ECHO_N "checking size of long long... $ECHO_C" >&6
 if test "${ac_cv_sizeof_long_long+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9318,7 +9467,7 @@
   if test "$cross_compiling" = yes; then
   # Depending upon the size, compute the lo and hi bounds.
 cat >conftest.$ac_ext <<_ACEOF
-#line 9321 "configure"
+#line 9470 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9330,21 +9479,21 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9333: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9482: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9336: \$? = $ac_status" >&5
+  echo "$as_me:9485: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9339: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9488: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9342: \$? = $ac_status" >&5
+  echo "$as_me:9491: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_lo=0 ac_mid=0
   while :; do
     cat >conftest.$ac_ext <<_ACEOF
-#line 9347 "configure"
+#line 9496 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9356,16 +9505,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9359: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9508: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9362: \$? = $ac_status" >&5
+  echo "$as_me:9511: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9365: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9514: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9368: \$? = $ac_status" >&5
+  echo "$as_me:9517: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_hi=$ac_mid; break
 else
@@ -9381,7 +9530,7 @@
 ac_hi=-1 ac_mid=-1
   while :; do
     cat >conftest.$ac_ext <<_ACEOF
-#line 9384 "configure"
+#line 9533 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9393,16 +9542,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9396: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9545: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9399: \$? = $ac_status" >&5
+  echo "$as_me:9548: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9402: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9551: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9405: \$? = $ac_status" >&5
+  echo "$as_me:9554: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_lo=$ac_mid; break
 else
@@ -9418,7 +9567,7 @@
 while test "x$ac_lo" != "x$ac_hi"; do
   ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
   cat >conftest.$ac_ext <<_ACEOF
-#line 9421 "configure"
+#line 9570 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9430,16 +9579,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9433: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9582: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9436: \$? = $ac_status" >&5
+  echo "$as_me:9585: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9439: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9588: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9442: \$? = $ac_status" >&5
+  echo "$as_me:9591: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_hi=$ac_mid
 else
@@ -9452,12 +9601,12 @@
 ac_cv_sizeof_long_long=$ac_lo
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:9455: error: cannot run test program while cross compiling" >&5
+  { { echo "$as_me:9604: error: cannot run test program while cross compiling" >&5
 echo "$as_me: error: cannot run test program while cross compiling" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9460 "configure"
+#line 9609 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -9473,15 +9622,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:9476: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9625: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9479: \$? = $ac_status" >&5
+  echo "$as_me:9628: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:9481: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9630: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9484: \$? = $ac_status" >&5
+  echo "$as_me:9633: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_sizeof_long_long=`cat conftest.val`
 else
@@ -9497,19 +9646,19 @@
   ac_cv_sizeof_long_long=0
 fi
 fi
-echo "$as_me:9500: result: $ac_cv_sizeof_long_long" >&5
+echo "$as_me:9649: result: $ac_cv_sizeof_long_long" >&5
 echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6
 cat >>confdefs.h <<EOF
 #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
 EOF
 
-echo "$as_me:9506: checking whether linux/input.h is for real" >&5
+echo "$as_me:9655: checking whether linux/input.h is for real" >&5
 echo $ECHO_N "checking whether linux/input.h is for real... $ECHO_C" >&6
 if test "${wine_cv_linux_input_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9512 "configure"
+#line 9661 "configure"
 #include "confdefs.h"
 
 	    #include <linux/input.h>
@@ -9527,16 +9676,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9530: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9679: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9533: \$? = $ac_status" >&5
+  echo "$as_me:9682: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9536: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9685: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9539: \$? = $ac_status" >&5
+  echo "$as_me:9688: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_linux_input_h=yes
 else
@@ -9547,7 +9696,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:9550: result: $wine_cv_linux_input_h" >&5
+echo "$as_me:9699: result: $wine_cv_linux_input_h" >&5
 echo "${ECHO_T}$wine_cv_linux_input_h" >&6
     if test "$wine_cv_linux_input_h" = "yes"
     then
@@ -9558,13 +9707,13 @@
 
     fi
 
-echo "$as_me:9561: checking whether we can use re-entrant gethostbyname_r Linux style" >&5
+echo "$as_me:9710: checking whether we can use re-entrant gethostbyname_r Linux style" >&5
 echo $ECHO_N "checking whether we can use re-entrant gethostbyname_r Linux style... $ECHO_C" >&6
 if test "${wine_cv_linux_gethostbyname_r_6+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9567 "configure"
+#line 9716 "configure"
 #include "confdefs.h"
 
 #include <netdb.h>
@@ -9590,16 +9739,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9593: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9742: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9596: \$? = $ac_status" >&5
+  echo "$as_me:9745: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9599: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9748: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9602: \$? = $ac_status" >&5
+  echo "$as_me:9751: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_linux_gethostbyname_r_6=yes
 else
@@ -9611,7 +9760,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:9614: result: $wine_cv_linux_gethostbyname_r_6" >&5
+echo "$as_me:9763: result: $wine_cv_linux_gethostbyname_r_6" >&5
 echo "${ECHO_T}$wine_cv_linux_gethostbyname_r_6" >&6
    if test "$wine_cv_linux_gethostbyname_r_6" = "yes"
    then
@@ -9624,13 +9773,13 @@
 
 if test "$ac_cv_header_linux_joystick_h" = "yes"
 then
-   echo "$as_me:9627: checking whether linux/joystick.h uses the Linux 2.2+ API" >&5
+   echo "$as_me:9776: checking whether linux/joystick.h uses the Linux 2.2+ API" >&5
 echo $ECHO_N "checking whether linux/joystick.h uses the Linux 2.2+ API... $ECHO_C" >&6
 if test "${wine_cv_linux_joystick_22_api+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9633 "configure"
+#line 9782 "configure"
 #include "confdefs.h"
 
 	#include <sys/ioctl.h>
@@ -9650,16 +9799,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9653: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9802: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9656: \$? = $ac_status" >&5
+  echo "$as_me:9805: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9659: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9808: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9662: \$? = $ac_status" >&5
+  echo "$as_me:9811: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_linux_joystick_22_api=yes
 else
@@ -9670,7 +9819,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:9673: result: $wine_cv_linux_joystick_22_api" >&5
+echo "$as_me:9822: result: $wine_cv_linux_joystick_22_api" >&5
 echo "${ECHO_T}$wine_cv_linux_joystick_22_api" >&6
    if test "$wine_cv_linux_joystick_22_api" = "yes"
    then
@@ -9684,13 +9833,13 @@
 
 if test "$ac_cv_header_sys_vfs_h" = "yes"
 then
-    echo "$as_me:9687: checking whether sys/vfs.h defines statfs" >&5
+    echo "$as_me:9836: checking whether sys/vfs.h defines statfs" >&5
 echo $ECHO_N "checking whether sys/vfs.h defines statfs... $ECHO_C" >&6
 if test "${wine_cv_sys_vfs_has_statfs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9693 "configure"
+#line 9842 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -9712,16 +9861,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9715: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9864: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9718: \$? = $ac_status" >&5
+  echo "$as_me:9867: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9721: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9870: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9724: \$? = $ac_status" >&5
+  echo "$as_me:9873: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_sys_vfs_has_statfs=yes
 else
@@ -9733,7 +9882,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:9736: result: $wine_cv_sys_vfs_has_statfs" >&5
+echo "$as_me:9885: result: $wine_cv_sys_vfs_has_statfs" >&5
 echo "${ECHO_T}$wine_cv_sys_vfs_has_statfs" >&6
     if test "$wine_cv_sys_vfs_has_statfs" = "yes"
     then
@@ -9747,13 +9896,13 @@
 
 if test "$ac_cv_header_sys_statfs_h" = "yes"
 then
-    echo "$as_me:9750: checking whether sys/statfs.h defines statfs" >&5
+    echo "$as_me:9899: checking whether sys/statfs.h defines statfs" >&5
 echo $ECHO_N "checking whether sys/statfs.h defines statfs... $ECHO_C" >&6
 if test "${wine_cv_sys_statfs_has_statfs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9756 "configure"
+#line 9905 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -9773,16 +9922,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9776: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9925: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9779: \$? = $ac_status" >&5
+  echo "$as_me:9928: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9782: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9931: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9785: \$? = $ac_status" >&5
+  echo "$as_me:9934: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_sys_statfs_has_statfs=yes
 else
@@ -9794,7 +9943,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:9797: result: $wine_cv_sys_statfs_has_statfs" >&5
+echo "$as_me:9946: result: $wine_cv_sys_statfs_has_statfs" >&5
 echo "${ECHO_T}$wine_cv_sys_statfs_has_statfs" >&6
     if test "$wine_cv_sys_statfs_has_statfs" = "yes"
     then
@@ -9808,13 +9957,13 @@
 
 if test "$ac_cv_header_sys_mount_h" = "yes"
 then
-    echo "$as_me:9811: checking whether sys/mount.h defines statfs" >&5
+    echo "$as_me:9960: checking whether sys/mount.h defines statfs" >&5
 echo $ECHO_N "checking whether sys/mount.h defines statfs... $ECHO_C" >&6
 if test "${wine_cv_sys_mount_has_statfs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9817 "configure"
+#line 9966 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -9834,16 +9983,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9837: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9986: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9840: \$? = $ac_status" >&5
+  echo "$as_me:9989: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9843: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9992: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9846: \$? = $ac_status" >&5
+  echo "$as_me:9995: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   wine_cv_sys_mount_has_statfs=yes
 else
@@ -9855,7 +10004,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:9858: result: $wine_cv_sys_mount_has_statfs" >&5
+echo "$as_me:10007: result: $wine_cv_sys_mount_has_statfs" >&5
 echo "${ECHO_T}$wine_cv_sys_mount_has_statfs" >&6
     if test "$wine_cv_sys_mount_has_statfs" = "yes"
     then
@@ -9867,13 +10016,13 @@
     fi
 fi
 
-echo "$as_me:9870: checking for f_bfree in struct statfs" >&5
+echo "$as_me:10019: checking for f_bfree in struct statfs" >&5
 echo $ECHO_N "checking for f_bfree in struct statfs... $ECHO_C" >&6
 if test "${ac_cv_c_statfs_f_bfree+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9876 "configure"
+#line 10025 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #ifdef HAVE_SYS_PARAM_H
@@ -9899,16 +10048,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9902: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10051: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9905: \$? = $ac_status" >&5
+  echo "$as_me:10054: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9908: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10057: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9911: \$? = $ac_status" >&5
+  echo "$as_me:10060: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_statfs_f_bfree="yes"
 else
@@ -9918,7 +10067,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9921: result: $ac_cv_c_statfs_f_bfree" >&5
+echo "$as_me:10070: result: $ac_cv_c_statfs_f_bfree" >&5
 echo "${ECHO_T}$ac_cv_c_statfs_f_bfree" >&6
 if  test "x$ac_cv_c_statfs_f_bfree" = "xyes"; then
 
@@ -9928,13 +10077,13 @@
 
 fi
 
-echo "$as_me:9931: checking for f_bavail in struct statfs" >&5
+echo "$as_me:10080: checking for f_bavail in struct statfs" >&5
 echo $ECHO_N "checking for f_bavail in struct statfs... $ECHO_C" >&6
 if test "${ac_cv_c_statfs_f_bavail+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9937 "configure"
+#line 10086 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #ifdef HAVE_SYS_PARAM_H
@@ -9960,16 +10109,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9963: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10112: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9966: \$? = $ac_status" >&5
+  echo "$as_me:10115: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9969: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10118: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9972: \$? = $ac_status" >&5
+  echo "$as_me:10121: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_statfs_f_bavail="yes"
 else
@@ -9979,7 +10128,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9982: result: $ac_cv_c_statfs_f_bavail" >&5
+echo "$as_me:10131: result: $ac_cv_c_statfs_f_bavail" >&5
 echo "${ECHO_T}$ac_cv_c_statfs_f_bavail" >&6
 if  test "x$ac_cv_c_statfs_f_bavail" = "xyes"; then
 
@@ -9989,13 +10138,13 @@
 
 fi
 
-echo "$as_me:9992: checking for msg_accrights in struct msghdr" >&5
+echo "$as_me:10141: checking for msg_accrights in struct msghdr" >&5
 echo $ECHO_N "checking for msg_accrights in struct msghdr... $ECHO_C" >&6
 if test "${ac_cv_c_msghdr_msg_accrights+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9998 "configure"
+#line 10147 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -10008,16 +10157,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10011: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10160: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10014: \$? = $ac_status" >&5
+  echo "$as_me:10163: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10017: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10166: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10020: \$? = $ac_status" >&5
+  echo "$as_me:10169: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_msghdr_msg_accrights="yes"
 else
@@ -10027,7 +10176,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:10030: result: $ac_cv_c_msghdr_msg_accrights" >&5
+echo "$as_me:10179: result: $ac_cv_c_msghdr_msg_accrights" >&5
 echo "${ECHO_T}$ac_cv_c_msghdr_msg_accrights" >&6
 if  test "x$ac_cv_c_msghdr_msg_accrights" = "xyes"; then
 
@@ -10037,13 +10186,13 @@
 
 fi
 
-echo "$as_me:10040: checking for sa_len in struct sockaddr" >&5
+echo "$as_me:10189: checking for sa_len in struct sockaddr" >&5
 echo $ECHO_N "checking for sa_len in struct sockaddr... $ECHO_C" >&6
 if test "${ac_cv_c_sockaddr_sa_len+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10046 "configure"
+#line 10195 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -10056,16 +10205,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10059: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10208: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10062: \$? = $ac_status" >&5
+  echo "$as_me:10211: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10065: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10214: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10068: \$? = $ac_status" >&5
+  echo "$as_me:10217: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_sockaddr_sa_len="yes"
 else
@@ -10075,7 +10224,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:10078: result: $ac_cv_c_sockaddr_sa_len" >&5
+echo "$as_me:10227: result: $ac_cv_c_sockaddr_sa_len" >&5
 echo "${ECHO_T}$ac_cv_c_sockaddr_sa_len" >&6
 if  test "x$ac_cv_c_sockaddr_sa_len" = "xyes"; then
 
@@ -10085,13 +10234,13 @@
 
 fi
 
-echo "$as_me:10088: checking for sun_len in struct sockaddr_un" >&5
+echo "$as_me:10237: checking for sun_len in struct sockaddr_un" >&5
 echo $ECHO_N "checking for sun_len in struct sockaddr_un... $ECHO_C" >&6
 if test "${ac_cv_c_sockaddr_un_sun_len+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10094 "configure"
+#line 10243 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -10105,16 +10254,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10108: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10257: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10111: \$? = $ac_status" >&5
+  echo "$as_me:10260: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10114: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10263: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10117: \$? = $ac_status" >&5
+  echo "$as_me:10266: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_sockaddr_un_sun_len="yes"
 else
@@ -10124,7 +10273,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:10127: result: $ac_cv_c_sockaddr_un_sun_len" >&5
+echo "$as_me:10276: result: $ac_cv_c_sockaddr_un_sun_len" >&5
 echo "${ECHO_T}$ac_cv_c_sockaddr_un_sun_len" >&6
 if  test "x$ac_cv_c_sockaddr_un_sun_len" = "xyes"; then
 
@@ -10136,13 +10285,13 @@
 
 case $target_cpu in
   *i345678986* )
-    echo "$as_me:10139: checking whether we need to define __i386__" >&5
+    echo "$as_me:10288: checking whether we need to define __i386__" >&5
 echo $ECHO_N "checking whether we need to define __i386__... $ECHO_C" >&6
 if test "${ac_cv_cpp_def_i386+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10145 "configure"
+#line 10294 "configure"
 #include "confdefs.h"
 #ifndef __i386__
 yes
@@ -10157,7 +10306,7 @@
 rm -f conftest*
 
 fi
-echo "$as_me:10160: result: $ac_cv_cpp_def_i386" >&5
+echo "$as_me:10309: result: $ac_cv_cpp_def_i386" >&5
 echo "${ECHO_T}$ac_cv_cpp_def_i386" >&6
     ;;
 esac
@@ -10211,7 +10360,7 @@
 
 MAKE_PROG_RULES=programs/Makeprog.rules
 
-ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile console/Makefile controls/Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile files/Makefile graphics/Makefile graphics/enhmetafiledrv/Makefile graphics/metafiledrv/Makefile graphics/win16drv/Makefile graphics/x11drv/Makefile if1632/Makefile include/Makefile library/Makefile libtest/Makefile loader/Makefile loader/ne/Makefile memory/Makefile misc/Makefile miscemu/Makefile msdos/Makefile objects/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winemine/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile relay32/Makefile scheduler/Makefile server/Makefile tools/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile win32/Makefile windows/Makefile windows/x11drv/Makefile"
+ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile console/Makefile controls/Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile files/Makefile graphics/Makefile graphics/enhmetafiledrv/Makefile graphics/metafiledrv/Makefile graphics/win16drv/Makefile graphics/x11drv/Makefile if1632/Makefile include/Makefile library/Makefile libtest/Makefile loader/Makefile loader/ne/Makefile memory/Makefile misc/Makefile miscemu/Makefile msdos/Makefile objects/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winemine/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile relay32/Makefile scheduler/Makefile server/Makefile tools/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile win32/Makefile windows/Makefile windows/x11drv/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -10292,7 +10441,7 @@
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:10295: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:10444: creating $CONFIG_STATUS" >&5
 echo "$as_me: creating $CONFIG_STATUS" >&6;}
 cat >$CONFIG_STATUS <<_ACEOF
 #! $SHELL
@@ -10468,7 +10617,7 @@
     echo "$ac_cs_version"; exit 0 ;;
   --he | --h)
     # Conflict between --help and --header
-    { { echo "$as_me:10471: error: ambiguous option: $1
+    { { echo "$as_me:10620: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -10487,7 +10636,7 @@
     ac_need_defaults=false;;
 
   # This is an error.
-  -*) { { echo "$as_me:10490: error: unrecognized option: $1
+  -*) { { echo "$as_me:10639: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -10595,6 +10744,7 @@
   "dlls/sti/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/sti/Makefile" ;;
   "dlls/tapi32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/tapi32/Makefile" ;;
   "dlls/ttydrv/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/ttydrv/Makefile" ;;
+  "dlls/twain/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/twain/Makefile" ;;
   "dlls/url/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/url/Makefile" ;;
   "dlls/urlmon/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/urlmon/Makefile" ;;
   "dlls/user/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/user/Makefile" ;;
@@ -10693,7 +10843,7 @@
   "programs/winetest/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS programs/winetest/tests" ;;
   "include/wine/version.h" ) CONFIG_COMMANDS="$CONFIG_COMMANDS include/wine/version.h" ;;
   "include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
-  *) { { echo "$as_me:10696: error: invalid argument: $ac_config_target" >&5
+  *) { { echo "$as_me:10846: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
@@ -10827,6 +10977,9 @@
 s,@GLU32FILES@,$GLU32FILES,;t t
 s,@CURSESLIBS@,$CURSESLIBS,;t t
 s,@CUPSLIBS@,$CUPSLIBS,;t t
+s,@sane_devel@,$sane_devel,;t t
+s,@SANELIBS@,$SANELIBS,;t t
+s,@SANEINCL@,$SANEINCL,;t t
 s,@ft_devel@,$ft_devel,;t t
 s,@ft_devel2@,$ft_devel2,;t t
 s,@FREETYPELIBS@,$FREETYPELIBS,;t t
@@ -10962,7 +11115,7 @@
   esac
 
   if test x"$ac_file" != x-; then
-    { echo "$as_me:10965: creating $ac_file" >&5
+    { echo "$as_me:11118: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
     rm -f "$ac_file"
   fi
@@ -10980,7 +11133,7 @@
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:10983: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:11136: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -10993,7 +11146,7 @@
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:10996: error: cannot find input file: $f" >&5
+           { { echo "$as_me:11149: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -11054,7 +11207,7 @@
   * )   ac_file_in=$ac_file.in ;;
   esac
 
-  test x"$ac_file" != x- && { echo "$as_me:11057: creating $ac_file" >&5
+  test x"$ac_file" != x- && { echo "$as_me:11210: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
 
   # First look for the input files in the build tree, otherwise in the
@@ -11065,7 +11218,7 @@
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:11068: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:11221: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -11078,7 +11231,7 @@
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:11081: error: cannot find input file: $f" >&5
+           { { echo "$as_me:11234: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -11195,7 +11348,7 @@
   rm -f $tmp/in
   if test x"$ac_file" != x-; then
     if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
-      { echo "$as_me:11198: $ac_file is unchanged" >&5
+      { echo "$as_me:11351: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
       ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -11246,50 +11399,50 @@
   ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
 
   case $ac_dest in
-    dlls/ddraw/d3ddevice ) test -d "dlls/ddraw/d3ddevice" || ({ echo "$as_me:11249: creating dlls/ddraw/d3ddevice" >&5
+    dlls/ddraw/d3ddevice ) test -d "dlls/ddraw/d3ddevice" || ({ echo "$as_me:11402: creating dlls/ddraw/d3ddevice" >&5
 echo "$as_me: creating dlls/ddraw/d3ddevice" >&6;} && mkdir "dlls/ddraw/d3ddevice") ;;
-    dlls/ddraw/dclipper ) test -d "dlls/ddraw/dclipper" || ({ echo "$as_me:11251: creating dlls/ddraw/dclipper" >&5
+    dlls/ddraw/dclipper ) test -d "dlls/ddraw/dclipper" || ({ echo "$as_me:11404: creating dlls/ddraw/dclipper" >&5
 echo "$as_me: creating dlls/ddraw/dclipper" >&6;} && mkdir "dlls/ddraw/dclipper") ;;
-    dlls/ddraw/ddraw ) test -d "dlls/ddraw/ddraw" || ({ echo "$as_me:11253: creating dlls/ddraw/ddraw" >&5
+    dlls/ddraw/ddraw ) test -d "dlls/ddraw/ddraw" || ({ echo "$as_me:11406: creating dlls/ddraw/ddraw" >&5
 echo "$as_me: creating dlls/ddraw/ddraw" >&6;} && mkdir "dlls/ddraw/ddraw") ;;
-    dlls/ddraw/direct3d ) test -d "dlls/ddraw/direct3d" || ({ echo "$as_me:11255: creating dlls/ddraw/direct3d" >&5
+    dlls/ddraw/direct3d ) test -d "dlls/ddraw/direct3d" || ({ echo "$as_me:11408: creating dlls/ddraw/direct3d" >&5
 echo "$as_me: creating dlls/ddraw/direct3d" >&6;} && mkdir "dlls/ddraw/direct3d") ;;
-    dlls/ddraw/dpalette ) test -d "dlls/ddraw/dpalette" || ({ echo "$as_me:11257: creating dlls/ddraw/dpalette" >&5
+    dlls/ddraw/dpalette ) test -d "dlls/ddraw/dpalette" || ({ echo "$as_me:11410: creating dlls/ddraw/dpalette" >&5
 echo "$as_me: creating dlls/ddraw/dpalette" >&6;} && mkdir "dlls/ddraw/dpalette") ;;
-    dlls/ddraw/dsurface ) test -d "dlls/ddraw/dsurface" || ({ echo "$as_me:11259: creating dlls/ddraw/dsurface" >&5
+    dlls/ddraw/dsurface ) test -d "dlls/ddraw/dsurface" || ({ echo "$as_me:11412: creating dlls/ddraw/dsurface" >&5
 echo "$as_me: creating dlls/ddraw/dsurface" >&6;} && mkdir "dlls/ddraw/dsurface") ;;
-    dlls/dinput/joystick ) test -d "dlls/dinput/joystick" || ({ echo "$as_me:11261: creating dlls/dinput/joystick" >&5
+    dlls/dinput/joystick ) test -d "dlls/dinput/joystick" || ({ echo "$as_me:11414: creating dlls/dinput/joystick" >&5
 echo "$as_me: creating dlls/dinput/joystick" >&6;} && mkdir "dlls/dinput/joystick") ;;
-    dlls/dinput/keyboard ) test -d "dlls/dinput/keyboard" || ({ echo "$as_me:11263: creating dlls/dinput/keyboard" >&5
+    dlls/dinput/keyboard ) test -d "dlls/dinput/keyboard" || ({ echo "$as_me:11416: creating dlls/dinput/keyboard" >&5
 echo "$as_me: creating dlls/dinput/keyboard" >&6;} && mkdir "dlls/dinput/keyboard") ;;
-    dlls/dinput/mouse ) test -d "dlls/dinput/mouse" || ({ echo "$as_me:11265: creating dlls/dinput/mouse" >&5
+    dlls/dinput/mouse ) test -d "dlls/dinput/mouse" || ({ echo "$as_me:11418: creating dlls/dinput/mouse" >&5
 echo "$as_me: creating dlls/dinput/mouse" >&6;} && mkdir "dlls/dinput/mouse") ;;
-    dlls/kernel/messages ) test -d "dlls/kernel/messages" || ({ echo "$as_me:11267: creating dlls/kernel/messages" >&5
+    dlls/kernel/messages ) test -d "dlls/kernel/messages" || ({ echo "$as_me:11420: creating dlls/kernel/messages" >&5
 echo "$as_me: creating dlls/kernel/messages" >&6;} && mkdir "dlls/kernel/messages") ;;
-    dlls/kernel/tests ) test -d "dlls/kernel/tests" || ({ echo "$as_me:11269: creating dlls/kernel/tests" >&5
+    dlls/kernel/tests ) test -d "dlls/kernel/tests" || ({ echo "$as_me:11422: creating dlls/kernel/tests" >&5
 echo "$as_me: creating dlls/kernel/tests" >&6;} && mkdir "dlls/kernel/tests") ;;
-    dlls/user/dde ) test -d "dlls/user/dde" || ({ echo "$as_me:11271: creating dlls/user/dde" >&5
+    dlls/user/dde ) test -d "dlls/user/dde" || ({ echo "$as_me:11424: creating dlls/user/dde" >&5
 echo "$as_me: creating dlls/user/dde" >&6;} && mkdir "dlls/user/dde") ;;
-    dlls/user/resources ) test -d "dlls/user/resources" || ({ echo "$as_me:11273: creating dlls/user/resources" >&5
+    dlls/user/resources ) test -d "dlls/user/resources" || ({ echo "$as_me:11426: creating dlls/user/resources" >&5
 echo "$as_me: creating dlls/user/resources" >&6;} && mkdir "dlls/user/resources") ;;
-    dlls/user/tests ) test -d "dlls/user/tests" || ({ echo "$as_me:11275: creating dlls/user/tests" >&5
+    dlls/user/tests ) test -d "dlls/user/tests" || ({ echo "$as_me:11428: creating dlls/user/tests" >&5
 echo "$as_me: creating dlls/user/tests" >&6;} && mkdir "dlls/user/tests") ;;
-    dlls/wineps/data ) test -d "dlls/wineps/data" || ({ echo "$as_me:11277: creating dlls/wineps/data" >&5
+    dlls/wineps/data ) test -d "dlls/wineps/data" || ({ echo "$as_me:11430: creating dlls/wineps/data" >&5
 echo "$as_me: creating dlls/wineps/data" >&6;} && mkdir "dlls/wineps/data") ;;
-    include/wine ) test -d "include/wine" || ({ echo "$as_me:11279: creating include/wine" >&5
+    include/wine ) test -d "include/wine" || ({ echo "$as_me:11432: creating include/wine" >&5
 echo "$as_me: creating include/wine" >&6;} && mkdir "include/wine") ;;
-    programs/regapi/tests ) test -d "programs/regapi/tests" || ({ echo "$as_me:11281: creating programs/regapi/tests" >&5
+    programs/regapi/tests ) test -d "programs/regapi/tests" || ({ echo "$as_me:11434: creating programs/regapi/tests" >&5
 echo "$as_me: creating programs/regapi/tests" >&6;} && mkdir "programs/regapi/tests") ;;
-    programs/winetest/tests ) test -d "programs/winetest/tests" || ({ echo "$as_me:11283: creating programs/winetest/tests" >&5
+    programs/winetest/tests ) test -d "programs/winetest/tests" || ({ echo "$as_me:11436: creating programs/winetest/tests" >&5
 echo "$as_me: creating programs/winetest/tests" >&6;} && mkdir "programs/winetest/tests") ;;
-    include/wine/version.h ) { echo "$as_me:11285: creating include/wine/version.h" >&5
+    include/wine/version.h ) { echo "$as_me:11438: creating include/wine/version.h" >&5
 echo "$as_me: creating include/wine/version.h" >&6;}
 cat >$tmp/version.h <<CEOF
 /* Generated automatically by configure; DO NOT EDIT! */
 #define WINE_RELEASE_INFO "Wine version $wine_version"
 CEOF
 if cmp -s $tmp/version.h include/wine/version.h 2>/dev/null; then
-  { echo "$as_me:11292: include/wine/version.h is unchanged" >&5
+  { echo "$as_me:11445: include/wine/version.h is unchanged" >&5
 echo "$as_me: include/wine/version.h is unchanged" >&6;}
   rm -f $tmp/version.h
 else
diff --git a/configure.ac b/configure.ac
index 3c247be..0fb3e85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -360,6 +360,30 @@
 )
 AC_SUBST(CUPSLIBS)
 
+dnl **** Check for SANE ****
+AC_CHECK_PROG(sane_devel,sane-config,sane-config,no)
+if test "$sane_devel" = "no"
+then
+    SANELIBS=""
+    SANEINCL=""
+else
+    SANELIBS="`$sane_devel --libs`"
+    SANEINCL="`$sane_devel --cflags`"
+    ac_save_CPPFLAGS="$CPPFLAGS"
+    ac_save_LIBS="$LIBS"
+    CPPFLAGS="$CPPFLAGS $SANEINCL"
+    LIBS="$LIBS $SANELIBS"
+    AC_CHECK_HEADER(sane/sane.h,[
+	    AC_CHECK_LIB(sane,sane_open,[AC_DEFINE(HAVE_SANE, 1, [Define if we have SANE development environment])],
+	    SANELIBS=""
+	    ])
+    )
+    LIBS="$ac_save_LIBS"
+    CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+AC_SUBST(SANELIBS)
+AC_SUBST(SANEINCL)
+
 dnl **** Check for FreeType 2 ****
 AC_CHECK_LIB(freetype,FT_Init_FreeType,ft_lib=yes,ft_lib=no,$X_LIBS)
 if test "$ft_lib" = "no"
@@ -1330,6 +1354,7 @@
 dlls/sti/Makefile
 dlls/tapi32/Makefile
 dlls/ttydrv/Makefile
+dlls/twain/Makefile
 dlls/url/Makefile
 dlls/urlmon/Makefile
 dlls/user/Makefile
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index f14982b..c590281 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -69,6 +69,7 @@
 	sti \
 	tapi32 \
 	ttydrv \
+	twain \
 	url \
 	urlmon \
 	user \
@@ -195,6 +196,7 @@
 	tapi32.dll$(DLLEXT) \
 	toolhelp.dll$(DLLEXT) \
 	ttydrv.dll$(DLLEXT) \
+	twain_32.dll$(DLLEXT) \
 	typelib.dll$(DLLEXT) \
 	url.dll$(DLLEXT) \
 	urlmon.dll$(DLLEXT) \
@@ -426,6 +428,9 @@
 ttydrv.dll$(DLLEXT): ttydrv/ttydrv.dll$(DLLEXT)
 	$(RM) $@ && $(LN_S) ttydrv/ttydrv.dll$(DLLEXT) $@
 
+twain_32.dll$(DLLEXT): twain/twain_32.dll$(DLLEXT)
+	$(RM) $@ && $(LN_S) twain/twain_32.dll$(DLLEXT) $@
+
 url.dll$(DLLEXT): url/url.dll$(DLLEXT)
 	$(RM) $@ && $(LN_S) url/url.dll$(DLLEXT) $@
 
@@ -690,6 +695,10 @@
   libkernel32.dll.$(LIBEXT) libntdll.dll.$(LIBEXT)
 	@cd ttydrv && $(MAKE) ttydrv.dll$(DLLEXT)
 
+twain/twain_32.dll$(DLLEXT): dummy user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) \
+  kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
+	@cd twain && $(MAKE) twain_32.dll$(DLLEXT)
+
 url/url.dll$(DLLEXT): dummy ntdll.dll$(DLLEXT)
 	@cd url && $(MAKE) url.dll$(DLLEXT)
 
diff --git a/dlls/twain/.cvsignore b/dlls/twain/.cvsignore
new file mode 100644
index 0000000..6fbf05b
--- /dev/null
+++ b/dlls/twain/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+twain_32.spec.c
diff --git a/dlls/twain/Makefile.in b/dlls/twain/Makefile.in
new file mode 100644
index 0000000..273e128
--- /dev/null
+++ b/dlls/twain/Makefile.in
@@ -0,0 +1,22 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = twain_32.dll
+EXTRALIBS = @SANELIBS@
+EXTRAINCL = @SANEINCL@
+
+LDDLLFLAGS = @LDDLLFLAGS@
+SYMBOLFILE = $(MODULE).tmp.o
+
+C_SRCS = \
+	capability.c \
+	ds_audio.c \
+	ds_ctrl.c \
+	ds_image.c \
+	dsm_ctrl.c \
+	twain32_main.c
+
+@MAKE_DLL_RULES@
+
+### Dependencies:
diff --git a/dlls/twain/README b/dlls/twain/README
new file mode 100644
index 0000000..57ad63c
--- /dev/null
+++ b/dlls/twain/README
@@ -0,0 +1,54 @@
+----- Old Corel README, probably outdated ----------------------------------
+1. INTRODUCTION
+
+This library (twain32.dll) is an implementation of TWAIN API for providing image acquisition devices (scanner or digital camera) support.  It uses SANE drivers as the backend and translates TWAIN API calls into SANE API calls.  Unlike the twain32 library on Windows platform, it combines the Data Source Manager and Data Sources into a single library.  Thus it is our responsiblity to provide a graphical user interface and capability negotiation, which usually are performed by data sources.
+
+
+2. WHAT'S IMPLEMENTED
+
+- Functions that dispatch operations specified by the operation triplets to the coresponding function.
+
+- All the operation triplets related to the Data Source Manager are implemented.  Appplication is able to enumerate data sources and open them.
+
+- The operation triplets that deal with the UI (such as DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS, MSG_DISABLEDS and MSG_ENABLEDSUIONLY) are partially implemented although it does not really do much.
+
+- The operation triplets that deal with native image transfering (DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET) are also partially implemented.  Still need to figure out how to convert the image data obtained from sane to the Windows DIB format.
+
+-  Only the CAP_ICAPXFERMECH capability is implemented.
+
+
+3. TO-DO
+
+- Image native transfer is not working correctly right now.  It crashed the application due to the invalid DIB created.  We need to fix this.
+
+- Implement other image transfer mode such as file transfer and memory transfer.
+
+- Support all required TWAIN capabilities that have not been implemented currently.  There are a fixed number of capabilities specified by the TWAIN Specification.  However, device capabilities are dynamic in SANE and there isn't a standard about the capability names.  It would be difficult to negotiate capabilities in TWAIN given that we don't know what capabilities a SANE driver would provide.  One possible solution to use a device configuration file to describe the mapping between capabilities supported by a SANE driver and those specified by TWAIN.   
+- Build a dynamic user interface that reflects the capabilities of different scanner devices.  According to the TWAIN specification, each TWAIN driver need to provide its own user interface.  However the SANE drivers do not have graphical frontends.  Building a frontend for each SANE driver is a huge task.  It is possible to have a dynamic frontend similar to xscanimage or xsane that works for all the devices.  This is possibly the most difficult part. 
+
+- check into legal issues regarding:
+  - TWAIN header file
+  - linking to SANE (maybe should dynamically link at run time?)
+
+- add autoconf rules for enabling based on whether sane is installed
+
+4. FILE LISTING
+
+twain32_main.c          Functions to regconize operation tripets and dispatch
+                        the requests to the corresponding functions.
+dsm_ctrl.c		Implementation of DG_CONTROL group operation triplets
+                        destinated for source manager.
+ds_ctrl.c               Implementation of DG_CONTROL group operation triplets
+                        destinated for data source.
+ds_image.c              Implementation of DG_IMAGE group operation triplets
+                        destinated for data source.
+ds_audio.c              Implementation of DG_AUDIO group operation triplets
+                        destinated for data source
+capability.c            Functions for negotiating capabilities
+twain.h			The original TWAIN header file
+twain_i.h		Header file for the internal twain functions	
+
+
+--
+Shi Quan He
+shiquan@cyberdude.com
diff --git a/dlls/twain/TWAIN b/dlls/twain/TWAIN
new file mode 100644
index 0000000..29bc4f3
--- /dev/null
+++ b/dlls/twain/TWAIN
@@ -0,0 +1,172 @@
+Requirements to be a TWAIN-Compliant Source
+Requirements
+TWAIN-compliant Sources must support the following:
+Operations
+----------
+DG_CONTROL / DAT_CAPABILITY / MSG_GET
+DG_CONTROL / DAT_CAPABILITY / MSG_GETCURRENT
+DG_CONTROL / DAT_CAPABILITY / MSG_GETDEFAULT
+DG_CONTROL / DAT_CAPABILITY / MSG_RESET
+DG_CONTROL / DAT_CAPABILITY / MSG_SET
+DG_CONTROL / DAT_EVENT / MSG_PROCESSEVENT
+DG_CONTROL / DAT_IDENTITY / MSG_GET
+DG_CONTROL / DAT_IDENTITY / MSG_OPENDS
+DG_CONTROL / DAT_IDENTITY / MSG_CLOSEDS
+DG_CONTROL / DAT_PENDINGXFERS / MSG_ENDXFER
+DG_CONTROL / DAT_PENDINGXFERS / MSG_GET
+DG_CONTROL / DAT_PENDINGXFERS / MSG_RESET
+DG_CONTROL / DAT_SETUPMEMXFER / MSG_GET
+DG_CONTROL / DAT_STATUS / MSG_GET
+DG_CONTROL / DAT_USERINTERFACE / MSG_DISABLEDS
+DG_CONTROL / DAT_USERINTERFACE / MSG_ENABLEDS
+DG_CONTROL / DAT_XFERGROUP / MSG_GET
+DG_IMAGE / DAT_IMAGEINFO / MSG_GET
+DG_IMAGE / DAT_IMAGELAYOUT / MSG_GET
+DG_IMAGE / DAT_IMAGELAYOUT / MSG_GETDEFAULT
+DG_IMAGE / DAT_IMAGELAYOUT / MSG_RESET
+DG_IMAGE / DAT_IMAGELAYOUT / MSG_SET
+DG_IMAGE / DAT_IMAGEMEMXFER / MSG_GET
+DG_IMAGE / DAT_IMAGENATIVEXFER / MSG_GET
+
+Capabilities
+------------
+Every Source must support all five DG_CONTROL / DAT_CAPABILITY operations on:
+CAP_XFERCOUNT
+Every Source must support DG_CONTROL / DAT_CAPABILITY MSG_GET on:
+CAP_SUPPORTEDCAPS
+CAP_UICONTROLLABLE
+Sources that supply image information must support DG_CONTROL / DAT_CAPABILITY /
+MSG_GET, MSG_GETCURRENT, MSG_GETDEFAULT on:
+ICAP_COMPRESSION
+ICAP_PLANARCHUNKY
+ICAP_PHYSICALHEIGHT
+ICAP_PHYSICALWIDTH
+ICAP_PIXELFLAVOR
+Sources that supply image information must support DG_CONTROL / DAT_CAPABILITY /
+MSG_GET, MSG_GETCURRENT, MSG_GETDEFAULT, MSG_RESET and MSG_SET on:
+ICAP_BITDEPTH
+ICAP_BITORDER
+ICAP_PIXELTYPE
+ICAP_UNITS
+ICAP_XFERMECH
+ICAP_XRESOLUTION
+ICAP_YRESOLUTION
+All Sources must implement the advertised features supported by their devices. They must
+make these features available to applications via the TWAIN protocol. For example, a Source
+thats connected to a device that has an ADF must support DG_CONTROL /
+DAT_CAPABILITY / MSG_GET, MSG_GETCURRENT, MSG_GETDEFAULT on:
+CAP_FEEDERENABLED
+CAP_FEEDERLOADED
+and DG_CONTROL / DAT_CAPABILITY / MSG_GET, MSG_GETCURRENT,
+MSG_GETDEFAULT, MSG_RESET and MSG_SET on:
+CAP_AUTOFEED
+If the ADF also supports ejecting and rewinding of pages then the Source should also support
+DG_CONTROL / DAT_CAPABILITY / MSG_GET, MSG_GETCURRENT,
+MSG_GETDEFAULT, MSG_RESET and MSG_SET on:
+CAP_CLEARPAGE
+CAP_REWINDPAGE
+
+
+*******************************************************************************
+
+From Application to Source Manager (Control Information)
+
+Data Group		Data Argument Type	Message
+DG_CONTROL		DAT_IDENTITY 		MSG_CLOSEDS
+						MSG_GETDEFAULT
+						MSG_GETFIRST
+						MSG_GETNEXT
+						MSG_OPENDS
+						MSG_USERSELECT
+DG_CONTROL		DAT_PARENT		MSG_CLOSEDSM
+						MSG_OPENDSM
+DG_CONTROL		DAT_STATUS		MSG_GET
+
+From Application to Source (Control Information)
+Data Group		Data Argument Type 	Message
+DG_CONTROL		DAT_CAPABILITY		MSG_GET
+						MSG_GETCURRENT
+						MSG_GETDEFAULT
+						MSG_QUERYSUPPORT
+						MSG_RESET
+						MSG_SET
+DG_CONTROL		DAT_CUSTOMDSDATA	MSG_GET
+						MSG_SET
+DG_CONTROL		DAT_FILESYSTEM		MSG_AUTOMATICCAPTURE
+						DIRECTORY
+						MSG_CHANGEDIRECTORY
+						MSG_COPY
+						MSG_CREATEDIRECTORY
+						MSG_DELETE
+						MSG_FORMATMEDIA
+						MSG_GETCLOSE
+						MSG_GETFIRSTFILE
+						MSG_GETINFO
+						MSG_GETNEXTFILE
+						MSG_RENAME
+DG_CONTROL		DAT_EVENT		MSG_PROCESSEVENT
+DG_CONTROL		DAT_PASSTHRU		MSG_PASSTHRU
+DG_CONTROL		DAT_PENDINGXFERS	MSG_ENDXFER
+						MSG_GET
+						MSG_RESET
+						MSG_STOPFEEDER
+DG_CONTROL		DAT_SETUPFILEXFER	MSG_GET
+						MSG_GETDEFAULT
+						MSG_RESET
+						MSG_SET
+DG_CONTROL		DAT_SETUPFILEXFER2	MSG_GET
+						MSG_GETDEFAULT
+						MSG_RESET
+						MSG_SET
+DG_CONTROL		DAT_SETUPMEMXFER	MSG_GET
+DG_CONTROL		DAT_STATUS		MSG_GET
+DG_CONTROL		DAT_USERINTERFACE	MSG_DISABLEDS
+						MSG_ENABLEDS
+						MSG_ENABLEDSUIONLY
+DG_CONTROL		DAT_XFERGROUP		MSG_GET
+						MSG_SET
+
+From Application to Source (Image Information)
+Data Group		Data Argument Type	Message
+DG_IMAGE		DAT_CIECOLOR		MSG_GET
+DG_IMAGE		DAT_EXTIMAGEINFO	MSG_GET
+DG_IMAGE		DAT_GRAYRESPONSE	MSG_RESET
+						MSG_SET
+DG_IMAGE		DAT_IMAGEFILEXFER	MSG_GET
+DG_IMAGE		DAT_IMAGEINFO		MSG_GET
+DG_IMAGE		DAT_IMAGELAYOUT		MSG_GET
+						MSG_GETDEFAULT
+						MSG_RESET
+						MSG_SET
+DG_IMAGE		DAT_IMAGEMEMXFER	MSG_GET
+DG_IMAGE		DAT_IMAGENATIVEXFER	MSG_GET
+DG_IMAGE		DAT_JPEGCOMPRESSION	MSG_GET
+						MSG_GETDEFAULT
+						MSG_RESET
+						MSG_SET
+DG_IMAGE		DAT_PALETTE8		MSG_GET
+						MSG_GETDEFAULT
+						MSG_RESET
+						MSG_SET
+DG_IMAGE		DAT_RGBRESPONSE		MSG_RESET
+						MSG_SET
+
+From Application to Source (Audio Information)
+Data Group		Data Argument Type	Message
+DG_AUDIO		DAT_AUDIOFILEXFER	MSG_GET
+DG_AUDIO		DAT_AUDIOINFO		MSG_GET
+DG_AUDIO		DAT_AUDIONATIVEXFER	MSG_GET
+
+From Source Manager to Source (Control Information)
+Data Group		Data Argument Type	Message
+DG_CONTROL		DAT_IDENTITY		MSG_CLOSEDS
+						MSG_GET
+						MSG_OPENDS
+
+From Source to Application (Control Information via the Source Manager)
+(Used by Windows Sources only)
+Data Group		Data Argument Type	Message
+DG_CONTROL		DAT_NULL		MSG_CLOSEDSOK
+						MSG_CLOSEDSREQ
+						MSG_DEVICEEVENT
+						MSG_XFERREADY
diff --git a/dlls/twain/capability.c b/dlls/twain/capability.c
new file mode 100644
index 0000000..6ac5845
--- /dev/null
+++ b/dlls/twain/capability.c
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2000 Corel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "winbase.h"
+#include "twain.h"
+#include "twain_i.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(twain);
+
+TW_UINT16 TWAIN_SaneCapability (activeDS *pSource, pTW_CAPABILITY pCapability,
+                                TW_UINT16 action)
+{
+    TW_UINT16 twCC = TWCC_SUCCESS;
+
+    TRACE("capability=%d action=%d\n", pCapability->Cap, action);
+
+    switch (pCapability->Cap)
+    {
+        case CAP_DEVICEEVENT:
+        case CAP_ALARMS:
+        case CAP_ALARMVOLUME:
+        case ACAP_AUDIOFILEFORMAT:
+        case ACAP_XFERMECH:
+        case ICAP_AUTOMATICBORDERDETECTION:
+        case ICAP_AUTOMATICDESKEW:
+        case ICAP_AUTODISCARDBLANKPAGES:
+        case ICAP_AUTOMATICROTATE:
+        case ICAP_FLIPROTATION:
+        case CAP_AUTOMATICCAPTURE:
+        case CAP_TIMEBEFOREFIRSTCAPTURE:
+        case CAP_TIMEBETWEENCAPTURES:
+        case CAP_AUTOSCAN:
+        case CAP_CLEARBUFFERS:
+        case CAP_MAXBATCHBUFFERS:
+        case ICAP_BARCODEDETECTIONENABLED:
+        case ICAP_SUPPORTEDBARCODETYPES:
+        case ICAP_BARCODEMAXSEARCHPRIORITIES:
+        case ICAP_BARCODESEARCHPRIORITIES:
+        case ICAP_BARCODESEARCHMODE:
+        case ICAP_BARCODEMAXRETRIES:
+        case ICAP_BARCODETIMEOUT:
+        case CAP_EXTENDEDCAPS:
+        case CAP_SUPPORTEDCAPS:
+        case ICAP_FILTER:
+        case ICAP_GAMMA:
+        case ICAP_PLANARCHUNKY:
+        case ICAP_BITORDERCODES:
+        case ICAP_CCITTKFACTOR:
+        case ICAP_COMPRESSION:
+        case ICAP_JPEGPIXELTYPE:
+        /*case ICAP_JPEGQUALITY:*/
+        case ICAP_PIXELFLAVORCODES:
+        case ICAP_TIMEFILL:
+        case CAP_DEVICEONLINE:
+        case CAP_DEVICETIMEDATE:
+        case CAP_SERIALNUMBER:
+        case ICAP_EXPOSURETIME:
+        case ICAP_FLASHUSED2:
+        case ICAP_IMAGEFILTER:
+        case ICAP_LAMPSTATE:
+        case ICAP_LIGHTPATH:
+        case ICAP_NOISEFILTER:
+        case ICAP_OVERSCAN:
+        case ICAP_PHYSICALHEIGHT:
+        case ICAP_PHYSICALWIDTH:
+        case ICAP_UNITS:
+        case ICAP_ZOOMFACTOR:
+        case CAP_PRINTER:
+        case CAP_PRINTERENABLED:
+        case CAP_PRINTERINDEX:
+        case CAP_PRINTERMODE:
+        case CAP_PRINTERSTRING:
+        case CAP_PRINTERSUFFIX:
+        case CAP_AUTHOR:
+        case CAP_CAPTION:
+        case CAP_TIMEDATE:
+        case ICAP_AUTOBRIGHT:
+        case ICAP_BRIGHTNESS:
+        case ICAP_CONTRAST:
+        case ICAP_HIGHLIGHT:
+        case ICAP_ORIENTATION:
+        case ICAP_ROTATION:
+        case ICAP_SHADOW:
+        case ICAP_XSCALING:
+        case ICAP_YSCALING:
+        case ICAP_BITDEPTH:
+        case ICAP_BITDEPTHREDUCTION:
+        case ICAP_BITORDER:
+        case ICAP_CUSTHALFTONE:
+        case ICAP_HALFTONES:
+        case ICAP_PIXELFLAVOR:
+        case ICAP_PIXELTYPE:
+        case ICAP_THRESHOLD:
+        case CAP_LANGUAGE:
+        case ICAP_FRAMES:
+        case ICAP_MAXFRAMES:
+        case ICAP_SUPPORTEDSIZES:
+        case CAP_AUTOFEED:
+        case CAP_CLEARPAGE:
+        case CAP_FEEDERALIGNMENT:
+        case CAP_FEEDERENABLED:
+        case CAP_FEEDERLOADED:
+        case CAP_FEEDERORDER:
+        case CAP_FEEDPAGE:
+        case CAP_PAPERBINDING:
+        case CAP_PAPERDETECTABLE:
+        case CAP_REACQUIREALLOWED:
+        case CAP_REWINDPAGE:
+        case ICAP_PATCHCODEDETECTIONENABLED:
+        case ICAP_SUPPORTEDPATCHCODETYPES:
+        case ICAP_PATCHCODEMAXSEARCHPRIORITIES:
+        case ICAP_PATCHCODESEARCHPRIORITIES:
+        case ICAP_PATCHCODESEARCHMODE:
+        case ICAP_PATCHCODEMAXRETRIES:
+        case ICAP_PATCHCODETIMEOUT:
+        case CAP_BATTERYMINUTES:
+        case CAP_BATTERYPERCENTAGE:
+        case CAP_POWERDOWNTIME:
+        case CAP_POWERSUPPLY:
+        case ICAP_XNATIVERESOLUTION:
+        case ICAP_XRESOLUTION:
+        case ICAP_YNATIVERESOLUTION:
+        case ICAP_YRESOLUTION:
+            twCC = TWCC_CAPUNSUPPORTED;
+            break;
+        case CAP_XFERCOUNT:
+            /* This is a required capability that every source need to 
+               support but we havev't implemented yet. */
+            twCC = TWCC_SUCCESS;
+            break;
+        /*case ICAP_COMPRESSION:*/
+        case ICAP_IMAGEFILEFORMAT:
+        case ICAP_TILES:
+            twCC = TWCC_CAPUNSUPPORTED;
+            break; 
+        case ICAP_XFERMECH:
+            twCC = TWAIN_ICAPXferMech (pSource, pCapability, action);
+            break;
+        case ICAP_UNDEFINEDIMAGESIZE:
+        case CAP_CAMERAPREVIEWUI:
+        case CAP_ENABLEDSUIONLY:
+        case CAP_INDICATORS:
+        case CAP_UICONTROLLABLE:
+            twCC = TWCC_CAPUNSUPPORTED;
+            break;
+        default:
+            twCC = TWRC_FAILURE;
+            
+    }
+
+    return twCC;
+}
+
+TW_BOOL TWAIN_OneValueSet (pTW_CAPABILITY pCapability, TW_UINT32 value)
+{
+    pCapability->hContainer = (TW_HANDLE)GlobalAlloc (0, sizeof(TW_ONEVALUE));
+    
+    if (pCapability->hContainer)
+    {
+        pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
+        pVal->ItemType = TWTY_UINT32;
+        pVal->Item = value;
+        GlobalUnlock ((HGLOBAL) pCapability->hContainer);
+        return TRUE;
+    }
+    else
+        return FALSE;
+}
+
+TW_BOOL TWAIN_OneValueGet (pTW_CAPABILITY pCapability, TW_UINT32 *pValue)
+{
+    pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
+
+    if (pVal)
+    {
+        *pValue = pVal->Item;
+        GlobalUnlock ((HGLOBAL) pCapability->hContainer);
+        return TRUE;
+    }
+    else
+        return FALSE;
+}
+ 
+/* ICAP_XFERMECH */
+TW_UINT16 TWAIN_ICAPXferMech (activeDS *pSource, pTW_CAPABILITY pCapability,
+                              TW_UINT16 action)
+{ 
+    TRACE("ICAP_XFERMECH\n");
+
+    switch (action)
+    {
+        case MSG_GET:
+            if (pCapability->ConType == TWON_ONEVALUE)
+            {
+                if (!TWAIN_OneValueSet (pCapability, pSource->capXferMech))
+                    return TWCC_LOWMEMORY;
+            }
+            break;
+        case MSG_SET:
+            if (pCapability->ConType == TWON_ONEVALUE)
+            {
+		TW_UINT32 xfermechtemp;
+                if (!TWAIN_OneValueGet (pCapability, &xfermechtemp))
+                    return TWCC_LOWMEMORY;
+		pSource->capXferMech = xfermechtemp;
+            }
+            else if (pCapability->ConType == TWON_ENUMERATION)
+            {
+
+            }
+            break;
+        case MSG_GETCURRENT:
+            if (!TWAIN_OneValueSet (pCapability, pSource->capXferMech))
+                return TWCC_LOWMEMORY;
+            break;
+        case MSG_GETDEFAULT:
+            if (!TWAIN_OneValueSet (pCapability, TWSX_NATIVE))
+                return TWCC_LOWMEMORY;
+            break;
+        case MSG_RESET:
+            pSource->capXferMech = TWSX_NATIVE;
+            break;
+    }
+    return TWCC_SUCCESS;
+}
diff --git a/dlls/twain/ds_audio.c b/dlls/twain/ds_audio.c
new file mode 100644
index 0000000..a9c966a
--- /dev/null
+++ b/dlls/twain/ds_audio.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000 Corel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "twain.h"
+#include "twain_i.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(twain);
+
+/* DG_AUDIO/DAT_AUDIOFILEXFER/MSG_GET */
+TW_UINT16 TWAIN_AudioFileXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_AUDIO/DAT_AUDIOINFO/MSG_GET */
+TW_UINT16 TWAIN_AudioInfoGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                              TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_AUDIO/DAT_AUDIONATIVEXFER/MSG_GET */
+TW_UINT16 TWAIN_AudioNativeXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                    TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
diff --git a/dlls/twain/ds_ctrl.c b/dlls/twain/ds_ctrl.c
new file mode 100644
index 0000000..92ceb43
--- /dev/null
+++ b/dlls/twain/ds_ctrl.c
@@ -0,0 +1,696 @@
+/*
+ * Copyright 2000 Corel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include "twain.h"
+#include "twain_i.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(twain);
+
+/* DG_CONTROL/DAT_CAPABILITY/MSG_GET */
+TW_UINT16 TWAIN_CapabilityGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                               TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
+    pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+    
+    TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GET\n");
+    
+    if (!pDest)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState < 4 || pSource->currentState > 7)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_GET);
+        twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
+        pSource->twCC = twCC; 
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_CAPABILITY/MSG_GETCURRENT */
+TW_UINT16 TWAIN_CapabilityGetCurrent (pTW_IDENTITY pOrigin,
+                                      pTW_IDENTITY pDest,TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
+    pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GETCURRENT\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState < 4 || pSource->currentState > 7)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_GETCURRENT);
+        twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
+        pSource->twCC = twCC;
+    } 
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_CAPABILITY/MSG_GETDEFAULT */
+TW_UINT16 TWAIN_CapabilityGetDefault (pTW_IDENTITY pOrigin,
+                                      pTW_IDENTITY pDest, TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
+    pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_GETDEFAULT\n");
+
+    if (!pDest)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState < 4 || pSource->currentState > 7)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_GETDEFAULT);
+        twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
+        pSource->twCC = twCC;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_CAPABILITY/MSG_QUERYSUPPORT */
+TW_UINT16 TWAIN_CapabilityQuerySupport (pTW_IDENTITY pOrigin,
+                                        pTW_IDENTITY pDest, TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_CAPABILITY/MSG_RESET */
+TW_UINT16 TWAIN_CapabilityReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
+    pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE("DG_CONTROL/DAT_CAPABILITY/MSG_RESET\n");
+
+    if (!pDest)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState < 4 || pSource->currentState > 7)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_RESET);
+        twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
+        pSource->twCC = twCC;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_CAPABILITY/MSG_SET */
+TW_UINT16 TWAIN_CapabilitySet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, 
+                               TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS, twCC = TWCC_SUCCESS;
+    pTW_CAPABILITY pCapability = (pTW_CAPABILITY) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE ("DG_CONTROL/DAT_CAPABILITY/MSG_SET\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState != 4)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        twCC = TWAIN_SaneCapability (pSource, pCapability, MSG_SET); 
+        twRC = (twCC == TWCC_SUCCESS)?TWRC_SUCCESS:TWRC_FAILURE;
+        pSource->twCC = twCC;
+    }
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_CUSTOMDSDATA/MSG_GET */
+TW_UINT16 TWAIN_CustomDSDataGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_CUSTOMDSDATA/MSG_SET */
+TW_UINT16 TWAIN_CustomDSDataSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_AUTOMATICCAPTUREDIRECTORY */
+TW_UINT16 TWAIN_AutomaticCaptureDirectory (pTW_IDENTITY pOrigin,
+                                           pTW_IDENTITY pDest,
+                                           TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_CHANGEDIRECTORY */
+TW_UINT16 TWAIN_ChangeDirectory (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_COPY */
+TW_UINT16 TWAIN_FileSystemCopy (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_CREATEDIRECTORY */
+TW_UINT16 TWAIN_CreateDirectory (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_DELETE */
+TW_UINT16 TWAIN_FileSystemDelete (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_FORMATMEDIA */
+TW_UINT16 TWAIN_FormatMedia (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                             TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETCLOSE */
+TW_UINT16 TWAIN_FileSystemGetClose (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                    TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETFIRSTFILE */
+TW_UINT16 TWAIN_FileSystemGetFirstFile (pTW_IDENTITY pOrigin,
+                                        pTW_IDENTITY pDest,
+                                        TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETINFO */
+TW_UINT16 TWAIN_FileSystemGetInfo (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                   TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_GETNEXTFILE */
+TW_UINT16 TWAIN_FileSystemGetNextFile (pTW_IDENTITY pOrigin,
+                                       pTW_IDENTITY pDest,
+                                       TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_FILESYSTEM/MSG_RENAME */
+TW_UINT16 TWAIN_FileSystemRename (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT */
+TW_UINT16 TWAIN_ProcessEvent (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                              TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_EVENT pEvent = (pTW_EVENT) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE("DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT\n");
+
+    if (!pSource)
+    {
+         twRC = TWRC_FAILURE;
+         DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState < 5 || pSource->currentState > 7)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        if (pSource->pendingEvent.TWMessage != MSG_NULL)
+        {
+            pEvent->TWMessage = pSource->pendingEvent.TWMessage;
+            pSource->pendingEvent.TWMessage = MSG_NULL;
+            twRC = TWRC_DSEVENT;
+        }
+        else
+        {
+            pEvent->TWMessage = MSG_NULL;  /* no message to the application */
+            twRC = TWRC_NOTDSEVENT;
+        }
+        pSource->twCC = TWCC_SUCCESS;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_PASSTHRU/MSG_PASSTHRU */
+TW_UINT16 TWAIN_PassThrough (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                             TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER */
+TW_UINT16 TWAIN_PendingXfersEndXfer (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                     TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
+    activeDS *pSource = TWAIN_LookupSource (pData);
+
+    TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_ENDXFER\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState != 6 && pSource->currentState != 7)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        if (pPendingXfers->Count != 0)
+        {
+            pPendingXfers->Count --;
+            pSource->currentState = 6;
+        }
+        else
+        {
+            pSource->currentState = 5;
+            /* Notify the application that it can close the data source */
+            pSource->pendingEvent.TWMessage = MSG_CLOSEDSREQ;
+        }
+        twRC = TWRC_SUCCESS;
+        pSource->twCC = TWCC_SUCCESS;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_PENDINGXFERS/MSG_GET */
+TW_UINT16 TWAIN_PendingXfersGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_GET\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState < 4 || pSource->currentState > 7)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        /* FIXME: we shouldn't return 1 here */
+        pPendingXfers->Count = 1;
+        twRC = TWRC_SUCCESS;
+        pSource->twCC = TWCC_SUCCESS;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_PENDINGXFERS/MSG_RESET */
+TW_UINT16 TWAIN_PendingXfersReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                   TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_PENDINGXFERS pPendingXfers = (pTW_PENDINGXFERS) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE("DG_CONTROL/DAT_PENDINGXFERS/MSG_RESET\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState != 6)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        pPendingXfers->Count = 0;
+        pSource->currentState = 5;
+        twRC = TWRC_SUCCESS;
+        pSource->twCC = TWCC_SUCCESS;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_PENDINGXFERS/MSG_STOPFEEDER */
+TW_UINT16 TWAIN_PendingXfersStopFeeder (pTW_IDENTITY pOrigin,
+                                        pTW_IDENTITY pDest, TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPFILEXFER/MSG_GET */
+TW_UINT16 TWAIN_SetupFileXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPXFER/MSG_GETDEFAULT */
+TW_UINT16 TWAIN_SetupFileXferGetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                         TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+
+/* DG_CONTROL/DAT_SETUPFILEXFER/MSG_RESET */
+TW_UINT16 TWAIN_SetupFileXferReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                    TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPFILEXFER/MSG_SET */
+TW_UINT16 TWAIN_SetupFileXferSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_GET */
+TW_UINT16 TWAIN_SetupFileXfer2Get (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                   TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_GETDEFAULT */
+TW_UINT16 TWAIN_SetupFileXfer2GetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                         TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_RESET */
+TW_UINT16 TWAIN_SetupFileXfer2Reset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPFILEXFER2/MSG_SET */
+TW_UINT16 TWAIN_SetupFileXfer2Set (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_SETUPMEMXFER/MSG_GET */
+TW_UINT16 TWAIN_SetupMemXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_STATUS/MSG_GET */
+TW_UINT16 TWAIN_GetDSStatus (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                             TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_FAILURE;
+    pTW_STATUS pSourceStatus = (pTW_STATUS) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE ("DG_CONTROL/DAT_STATUS/MSG_GET\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+        pSourceStatus->ConditionCode = TWCC_BADDEST;
+    }
+    else
+    {
+        twRC = TWRC_SUCCESS;
+        pSourceStatus->ConditionCode = pSource->twCC;
+        /* Reset the condition code */
+        pSource->twCC = TWCC_SUCCESS;
+    }
+ 
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_USERINTERFACE/MSG_DISABLEDS */
+TW_UINT16 TWAIN_DisableDSUserInterface (pTW_IDENTITY pOrigin,
+                                        pTW_IDENTITY pDest, TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_USERINTERFACE pUserInterface = (pTW_USERINTERFACE) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE ("DG_CONTROL/DAT_USERINTERFACE/MSG_DISABLEDS\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState != 5)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        pSource->currentState = 4;
+        twRC = TWRC_SUCCESS;
+        pSource->twCC = TWCC_SUCCESS;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS */
+TW_UINT16 TWAIN_EnableDSUserInterface (pTW_IDENTITY pOrigin,
+                                       pTW_IDENTITY pDest, TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_USERINTERFACE pUserInterface = (pTW_USERINTERFACE) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+   
+    TRACE ("DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDS\n");
+ 
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState != 4)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        if (pUserInterface->ShowUI)
+        {
+            pSource->currentState = 5; /* Transitions to state 5 */ 
+            /* FIXME: we should replace xscanimage with our own device UI */
+            system ("xscanimage");
+            pSource->currentState = 6;
+            pSource->pendingEvent.TWMessage = MSG_XFERREADY;
+        }
+        else
+        {
+            /* no UI will be displayed, so source is ready to transfer data */
+            pSource->pendingEvent.TWMessage = MSG_XFERREADY; 
+            pSource->currentState = 6; /* Transitions to state 6 directly */
+        }
+        
+        pSource->hwndOwner = pUserInterface->hParent;
+        twRC = TWRC_SUCCESS;
+        pSource->twCC = TWCC_SUCCESS;
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDSUIONLY */
+TW_UINT16 TWAIN_EnableDSUIOnly (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                TW_MEMREF pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_USERINTERFACE pUserInterface = (pTW_USERINTERFACE) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+
+    TRACE("DG_CONTROL/DAT_USERINTERFACE/MSG_ENABLEDSUIONLY\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState != 4)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        /* FIXME: we should replace xscanimage with our own UI */
+        system ("xscanimage");
+        pSource->currentState = 5;
+        twRC = TWRC_SUCCESS;
+        pSource->twCC = TWCC_SUCCESS; 
+    }
+
+    return twRC;
+}
+
+/* DG_CONTROL/DAT_XFERGROUP/MSG_GET */
+TW_UINT16 TWAIN_XferGroupGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                              TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_CONTROL/DAT_XFERGROUP/MSG_SET */
+TW_UINT16 TWAIN_XferGroupSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
diff --git a/dlls/twain/ds_image.c b/dlls/twain/ds_image.c
new file mode 100644
index 0000000..077921e
--- /dev/null
+++ b/dlls/twain/ds_image.c
@@ -0,0 +1,377 @@
+/*
+ * Copyright 2000 Corel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "twain.h"
+#include "twain_i.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(twain);
+
+/* DG_IMAGE/DAT_CIECOLOR/MSG_GET */
+TW_UINT16 TWAIN_CIEColorGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                             TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_EXTIMAGEINFO/MSG_GET */
+TW_UINT16 TWAIN_ExtImageInfoGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_GRAYRESPONSE/MSG_RESET */
+TW_UINT16 TWAIN_GrayResponseReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                   TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_GRAYRESPONSE/MSG_SET */
+TW_UINT16 TWAIN_GrayResponseSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_IMAGEFILEXFER/MSG_GET */
+TW_UINT16 TWAIN_ImageFileXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_IMAGEINFO/MSG_GET */
+TW_UINT16 TWAIN_ImageInfoGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                              TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_IMAGEINFO pImageInfo = (pTW_IMAGEINFO) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+    SANE_Status status;
+
+    TRACE("DG_IMAGE/DAT_IMAGEINFO/MSG_GET\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_BADDEST;
+    }
+    else if (pSource->currentState != 6 && pSource->currentState != 7)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        if (pSource->currentState == 6)
+        {
+            /* return general image description information about the image about to be transfer */
+            status = sane_get_parameters (pSource->deviceHandle, &pSource->sane_param);
+        }
+
+        pImageInfo->XResolution.Whole = -1;
+        pImageInfo->XResolution.Frac = 0;
+        pImageInfo->YResolution.Whole = -1;
+        pImageInfo->YResolution.Frac = 0;
+        pImageInfo->ImageWidth = pSource->sane_param.pixels_per_line;
+        pImageInfo->ImageLength = pSource->sane_param.lines;
+        if (pSource->sane_param.depth == 24)
+        {
+            pImageInfo->SamplesPerPixel = 3;
+            pImageInfo->BitsPerSample[0] = 8;
+            pImageInfo->BitsPerSample[1] = 8;
+            pImageInfo->BitsPerSample[2] = 8;
+            pImageInfo->BitsPerPixel = 24;
+            pImageInfo->Planar = TRUE;
+            pImageInfo->PixelType = TWPT_RGB;
+            pImageInfo->Compression = TWCP_NONE;
+        } 
+        else if (pSource->sane_param.depth == 8)
+        {
+            /* FIXME: fill the image info structure for 8-bit image */
+        }
+    }
+
+    return twRC;
+#endif
+}
+
+/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GET */
+TW_UINT16 TWAIN_ImageLayoutGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_GETDEFAULT */
+TW_UINT16 TWAIN_ImageLayoutGetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                       TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_RESET */
+TW_UINT16 TWAIN_ImageLayoutReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_IMAGELAYOUT/MSG_SET */
+TW_UINT16 TWAIN_ImageLayoutSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET */
+TW_UINT16 TWAIN_ImageMemXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                 TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET */
+TW_UINT16 TWAIN_ImageNativeXferGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                    TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_UINT32 pHandle = (pTW_UINT32) pData;
+    activeDS *pSource = TWAIN_LookupSource (pDest);
+    SANE_Status status;
+    SANE_Byte buffer[32*1024];
+    int buff_len;
+    HBITMAP hDIB;
+    BITMAPINFO bmpInfo;
+    VOID *pBits;
+    HDC dc;
+ 
+    TRACE("DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET\n");
+
+    if (!pSource)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_NODS;
+    }
+    else if (pSource->currentState != 6)
+    {
+        twRC = TWRC_FAILURE;
+        pSource->twCC = TWCC_SEQERROR;
+    }
+    else
+    {
+        /* Transfer an image from the source to the application */
+        status = sane_start (pSource->deviceHandle);
+        if (status != SANE_STATUS_GOOD)
+        {
+            WARN("sane_start: %s\n", sane_strstatus (status));
+            sane_cancel (pSource->deviceHandle);
+            pSource->twCC = TWCC_OPERATIONERROR;
+            return TWRC_FAILURE;
+        }
+        
+        status = sane_get_parameters (pSource->deviceHandle, &pSource->sane_param);
+        if (status != SANE_STATUS_GOOD)
+        {
+            WARN("sane_get_parameters: %s\n", sane_strstatus (status));
+            sane_cancel (pSource->deviceHandle);
+            pSource->twCC = TWCC_OPERATIONERROR;
+            return TWRC_FAILURE;
+        }
+
+        TRACE("Acquiring image %dx%dx%d bits (format=%d last=%d) from sane...\n"
+              , pSource->sane_param.pixels_per_line, pSource->sane_param.lines,
+              pSource->sane_param.depth, pSource->sane_param.format,
+              pSource->sane_param.last_frame);
+
+        ZeroMemory (&bmpInfo, sizeof (BITMAPINFO));
+        bmpInfo.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
+        bmpInfo.bmiHeader.biWidth = pSource->sane_param.pixels_per_line;
+        bmpInfo.bmiHeader.biHeight = pSource->sane_param.lines;
+        bmpInfo.bmiHeader.biPlanes = 1;
+        bmpInfo.bmiHeader.biBitCount = pSource->sane_param.depth;
+        bmpInfo.bmiHeader.biCompression = BI_RGB;
+        bmpInfo.bmiHeader.biSizeImage = 0;
+        bmpInfo.bmiHeader.biXPelsPerMeter = 0;
+        bmpInfo.bmiHeader.biYPelsPerMeter = 0;
+        bmpInfo.bmiHeader.biClrUsed = 1;
+        bmpInfo.bmiHeader.biClrImportant = 0;
+        bmpInfo.bmiColors[0].rgbBlue = 128;
+        bmpInfo.bmiColors[0].rgbGreen = 128;
+        bmpInfo.bmiColors[0].rgbRed = 128;
+        hDIB = CreateDIBSection ((dc = GetDC(pSource->hwndOwner)), &bmpInfo, 
+                                 DIB_RGB_COLORS, &pBits, 0, 0);
+        if (!hDIB)
+        {
+            sane_cancel (pSource->deviceHandle);
+            pSource->twCC = TWCC_LOWMEMORY;
+            return TWRC_FAILURE;
+        }
+            
+        do
+        {
+            status = sane_read (pSource->deviceHandle, buffer, 
+                                sizeof (buffer),  &buff_len);
+            if (status == SANE_STATUS_GOOD)
+            {
+                /* FIXME: put code for coverting the image data into DIB here */
+
+            }
+            else if (status != SANE_STATUS_EOF)
+            {
+                WARN("sane_read: %s\n", sane_strstatus (status));
+                sane_cancel (pSource->deviceHandle);
+                pSource->twCC = TWCC_OPERATIONERROR;
+                return TWRC_FAILURE;
+            }
+        } while (status == SANE_STATUS_GOOD);
+        
+        sane_cancel (pSource->deviceHandle); 
+        ReleaseDC (pSource->hwndOwner, dc);
+        *pHandle = hDIB;
+        twRC = TWRC_XFERDONE; 
+        pSource->twCC = TWCC_SUCCESS;
+        pSource->currentState = 7;
+    }
+    return twRC;
+#endif
+}
+
+/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GET */
+TW_UINT16 TWAIN_JPEGCompressionGet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                    TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_GETDEFAULT */
+TW_UINT16 TWAIN_JPEGCompressionGetDefault (pTW_IDENTITY pOrigin,
+                                           pTW_IDENTITY pDest,
+                                           TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_RESET */
+TW_UINT16 TWAIN_JPEGCompressionReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                      TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_JPEGCOMPRESSION/MSG_SET */
+TW_UINT16 TWAIN_JPEGCompressionSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                    TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_PALETTE8/MSG_GET */
+TW_UINT16 TWAIN_Palette8Get (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                             TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_PALETTE8/MSG_GETDEFAULT */
+TW_UINT16 TWAIN_Palette8GetDefault (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                    TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_PALETTE8/MSG_RESET */
+TW_UINT16 TWAIN_Palette8Reset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                               TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_PALETTE8/MSG_SET */
+TW_UINT16 TWAIN_Palette8Set (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                             TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_RGBRESPONSE/MSG_RESET */
+TW_UINT16 TWAIN_RGBResponseReset (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                  TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
+
+/* DG_IMAGE/DAT_RGBRESPONSE/MSG_SET */
+TW_UINT16 TWAIN_RGBResponseSet (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+                                TW_MEMREF pData)
+{
+    FIXME ("stub!\n");
+
+    return TWRC_FAILURE;
+}
diff --git a/dlls/twain/dsm_ctrl.c b/dlls/twain/dsm_ctrl.c
new file mode 100644
index 0000000..26db93a
--- /dev/null
+++ b/dlls/twain/dsm_ctrl.c
@@ -0,0 +1,395 @@
+/*
+ * TWAIN32 Source Manager
+ *
+ * Copyright 2000 Corel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include "winbase.h"
+#include "twain.h"
+#include "twain_i.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(twain);
+
+/* DG_CONTROL/DAT_IDENTITY/MSG_CLOSEDS */
+TW_UINT16 TWAIN_CloseDS (pTW_IDENTITY pOrigin, TW_MEMREF pData) 
+{
+#ifndef HAVE_SANE
+    DSM_twCC = TWCC_NODS;
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData;
+    activeDS *currentDS = NULL, *prevDS = NULL;
+
+    TRACE ("DG_CONTROL/DAT_IDENTITY/MSG_CLOSEDS\n");
+
+    for (currentDS = activeSources; currentDS; currentDS = currentDS->next)
+    {
+        if (currentDS->identity.Id == pIdentity->Id)
+            break;
+        prevDS = currentDS;
+    }
+    if (currentDS)
+    {
+        /* Only valid to close a data source if it is in state 4 */
+        if (currentDS->currentState == 4)
+        {
+            sane_close (currentDS->deviceHandle);
+            /* remove the data source from active data source list */
+            if (prevDS)
+                prevDS->next = currentDS->next;
+            else
+                activeSources = currentDS->next;
+            HeapFree (GetProcessHeap(), 0, currentDS);
+            twRC = TWRC_SUCCESS;
+            DSM_twCC = TWCC_SUCCESS;
+        }
+        else
+        {
+            twRC = TWRC_FAILURE;
+            DSM_twCC = TWCC_SEQERROR;
+        }
+    }
+    else
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_NODS;
+    }
+ 
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_IDENTITY/MSG_GETDEFAULT */
+TW_UINT16 TWAIN_IdentityGetDefault (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    DSM_twCC = TWCC_NODS;
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
+
+    TRACE("DG_CONTROL/DAT_IDENTITY/MSG_GETDEFAULT\n");
+
+    if (!device_list)
+    {
+        if ((sane_get_devices (&device_list, SANE_FALSE) != SANE_STATUS_GOOD))
+        {
+            DSM_twCC = TWCC_NODS;
+            return TWRC_FAILURE;
+        }
+    }
+
+    /* FIXME: the default device is not necessarily the first device.  *
+     * Users should be able to choose the default device               */
+    if (device_list && device_list[0])
+    {
+        pSourceIdentity->Id = DSM_sourceId ++;
+        strcpy (pSourceIdentity->ProductName, device_list[0]->name);
+        strcpy (pSourceIdentity->Manufacturer, device_list[0]->vendor);
+        strcpy (pSourceIdentity->ProductFamily, device_list[0]->model);
+        pSourceIdentity->ProtocolMajor = TWON_PROTOCOLMAJOR;
+        pSourceIdentity->ProtocolMinor = TWON_PROTOCOLMINOR;
+
+        twRC = TWRC_SUCCESS;
+        DSM_twCC = TWCC_SUCCESS;
+    }
+    else
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_NODS;
+    }
+ 
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_IDENTITY/MSG_GETFIRST */
+TW_UINT16 TWAIN_IdentityGetFirst (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    DSM_twCC = TWCC_NODS;
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_IDENTITY pSourceIdentity;/* = (pTW_IDENTITY) pData;*/
+    SANE_Status status;
+    
+    TRACE ("DG_CONTROL/DAT_IDENTITY/MSG_GETFIRST\n");
+
+    status = sane_get_devices (&device_list, SANE_FALSE);
+    if (status == SANE_STATUS_GOOD)
+    {
+        if (device_list[0])
+        {
+            pSourceIdentity->Id = DSM_sourceId ++;
+            strcpy (pSourceIdentity->ProductName, device_list[0]->name);
+            strcpy (pSourceIdentity->Manufacturer, device_list[0]->vendor);
+            strcpy (pSourceIdentity->ProductFamily, device_list[0]->model);
+            pSourceIdentity->ProtocolMajor = TWON_PROTOCOLMAJOR;
+            pSourceIdentity->ProtocolMinor = TWON_PROTOCOLMINOR;
+        }
+        DSM_currentDevice = 1;
+        twRC = TWRC_SUCCESS;
+        DSM_twCC = TWCC_SUCCESS;
+    }
+    else if (status == SANE_STATUS_NO_MEM)
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_LOWMEMORY;
+    }
+    else
+    {
+        WARN("sane_get_devices() failed: %s\n", sane_strstatus (status)); 
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_NODS;
+    }
+   
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT */
+TW_UINT16 TWAIN_IdentityGetNext (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    DSM_twCC = TWCC_SUCCESS;
+    return TWRC_ENDOFLIST;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
+
+    TRACE("DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT\n");
+
+    if (device_list && device_list[DSM_currentDevice])
+    {
+        pSourceIdentity->Id = DSM_sourceId ++;
+        strcpy (pSourceIdentity->ProductName, device_list[DSM_currentDevice]->name);
+        strcpy (pSourceIdentity->Manufacturer, device_list[DSM_currentDevice]->vendor);
+        strcpy (pSourceIdentity->ProductFamily, device_list[DSM_currentDevice]->model);
+        pSourceIdentity->ProtocolMajor = TWON_PROTOCOLMAJOR;
+        pSourceIdentity->ProtocolMinor = TWON_PROTOCOLMINOR;
+        DSM_currentDevice ++;
+
+        twRC = TWRC_SUCCESS;
+        DSM_twCC = TWCC_SUCCESS; 
+    }
+    else
+    {
+        DSM_twCC = TWCC_SUCCESS;
+        twRC = TWRC_ENDOFLIST;
+    }
+
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_IDENTITY/MSG_OPENDS */
+TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    DSM_twCC = TWCC_NODS;
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS, i = 0;
+    pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData;
+    activeDS *newSource;
+    SANE_Status status;
+
+    TRACE("DG_CONTROL/DAT_IDENTITY/MSG_OPENDS\n");
+
+    if (DSM_currentState != 3)
+    {
+        DSM_twCC = TWCC_SEQERROR;
+        return TWRC_FAILURE;
+    }
+
+    if (!device_list &&
+       (sane_get_devices (&device_list, SANE_FALSE) != SANE_STATUS_GOOD))
+    {
+        DSM_twCC = TWCC_NODS;
+        return TWRC_FAILURE;
+    }
+
+    if (pIdentity->ProductName[0] != '\0')
+    {
+        /* Make sure the source to be open exists in the device list */
+        for (i = 0; device_list[i]; i ++)
+        {
+            if (strcmp (device_list[i]->name, pIdentity->ProductName) == 0)
+                break;
+        }
+    }
+
+    if (device_list[i])
+    {
+        /* the source is found in the device list */
+        newSource = HeapAlloc (GetProcessHeap(), 0, sizeof (activeDS));
+        if (newSource)
+        {
+            status = sane_open(device_list[i]->name,&newSource->deviceHandle);
+            if (status == SANE_STATUS_GOOD)
+            {
+                /* Assign name and id for the opened data source */
+                strcpy (pIdentity->ProductName, device_list[i]->name);
+                pIdentity->Id = DSM_sourceId ++;
+                /* add the data source to an internal active source list */
+                newSource->next = activeSources;
+                newSource->identity.Id = pIdentity->Id;
+                strcpy (newSource->identity.ProductName, pIdentity->ProductName);
+                newSource->currentState = 4; /*transition into state 4*/
+                newSource->twCC = TWCC_SUCCESS;
+                activeSources = newSource;
+                twRC = TWRC_SUCCESS;
+                DSM_twCC = TWCC_SUCCESS;
+            }
+            else
+            {
+                twRC = TWRC_FAILURE;
+                DSM_twCC = TWCC_OPERATIONERROR;
+            }
+        }
+        else
+        {
+            twRC = TWRC_FAILURE;
+            DSM_twCC = TWCC_LOWMEMORY;
+        }
+    }
+    else
+    {
+        twRC = TWRC_FAILURE;
+        DSM_twCC = TWCC_NODS;
+    }
+ 
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_IDENTITY/MSG_USERSELECT */
+TW_UINT16 TWAIN_UserSelect (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    return TWRC_SUCCESS;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+
+    TRACE("DG_CONTROL/DAT_IDENTITY/MSG_USERSELECT\n");
+
+    /* FIXME: we should replace xscanimage with our own  User Select UI */
+    system("xscanimage");
+
+    DSM_twCC = TWCC_SUCCESS;
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_PARENT/MSG_CLOSEDSM */
+TW_UINT16 TWAIN_CloseDSM (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    activeDS *currentDS = activeSources, *nextDS;
+
+    TRACE("DG_CONTROL/DAT_PARENT/MSG_CLOSEDSM\n");
+
+    if (DSM_currentState == 3)
+    {
+        sane_exit ();
+        DSM_initialized = FALSE;
+        DSM_parentHWND = 0;
+        DSM_currentState = 2;
+
+        /* If there are data sources still open, close them now. */
+        while (currentDS != NULL)
+        {
+            nextDS = currentDS->next;
+            sane_close (currentDS->deviceHandle);
+            HeapFree (GetProcessHeap(), 0, currentDS);
+            currentDS = nextDS;
+        }
+        activeSources = NULL;
+        DSM_twCC = TWCC_SUCCESS;
+        twRC = TWRC_SUCCESS;
+    }
+    else
+    {
+        DSM_twCC = TWCC_SEQERROR;
+        twRC = TWRC_FAILURE;
+    }
+
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_PARENT/MSG_OPENDSM */
+TW_UINT16 TWAIN_OpenDSM (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+#ifndef HAVE_SANE
+    return TWRC_FAILURE;
+#else
+    TW_UINT16 twRC = TWRC_SUCCESS;
+    SANE_Status status;
+    SANE_Int version_code;
+
+    TRACE("DG_CONTROL/DAT_PARENT/MSG_OPENDSM\n");
+
+    if (DSM_currentState == 2)
+    {
+        if (!DSM_initialized)
+        {
+            DSM_initialized = TRUE;
+            status = sane_init (&version_code, NULL);
+            device_list = NULL;
+            DSM_currentDevice = 0; 
+            DSM_sourceId = 0;
+        }    
+        DSM_parentHWND = *pData;
+        DSM_currentState = 3; /* transition to state 3 */
+        DSM_twCC = TWCC_SUCCESS;
+        twRC = TWRC_SUCCESS;
+    }
+    else
+    {
+        /* operation invoked in invalid state */
+        DSM_twCC = TWCC_SEQERROR;
+        twRC = TWRC_FAILURE;
+    }
+
+    return twRC;
+#endif
+}
+
+/* DG_CONTROL/DAT_STATUS/MSG_GET */
+TW_UINT16 TWAIN_GetDSMStatus (pTW_IDENTITY pOrigin, TW_MEMREF pData)
+{
+    pTW_STATUS pSourceStatus = (pTW_STATUS) pData;
+
+    TRACE ("DG_CONTROL/DAT_STATUS/MSG_GET\n");
+
+    pSourceStatus->ConditionCode = DSM_twCC;
+    DSM_twCC = TWCC_SUCCESS;  /* clear the condition code */
+
+    return TWRC_SUCCESS;
+}
+
diff --git a/dlls/twain/twain.h b/dlls/twain/twain.h
new file mode 100644
index 0000000..ab4a78f
--- /dev/null
+++ b/dlls/twain/twain.h
@@ -0,0 +1,1876 @@
+/* ======================================================================== *\
+
+  Copyright (C) 1991, 1992 TWAIN Working Group: Aldus, Caere, Eastman-Kodak,
+  Hewlett-Packard and Logitech Corporations.  All rights reserved.
+
+  Copyright (C) 1997 TWAIN Working Group: Bell+Howell, Canon, DocuMagix, 
+  Fujitsu, Genoa Technology, Hewlett-Packard, Kofax Imaging Products, and
+  Ricoh Corporation.  All rights reserved.
+ 
+  Copyright © 1998 TWAIN Working Group: Adobe Systems Incorporated, 
+  Canon Information Systems, Eastman Kodak Company, 
+  Fujitsu Computer Products of America, Genoa Technology, 
+  Hewlett-Packard Company, Intel Corporation, Kofax Image Products, 
+  JFL Peripheral Solutions Inc., Ricoh Corporation, and Xerox Corporation.  
+  All rights reserved.
+
+  TWAIN.h -  This is the definitive include file for applications and
+          data sources written to the TWAIN specification.
+          It defines constants, data structures, messages etc.
+          for the public interface to TWAIN.
+ 
+  Revision History:
+    version 1.0, March 6, 1992.  TWAIN 1.0.
+    version 1.1, January 1993.   Tech Notes 1.1
+    version 1.5, June 1993.      Specification Update 1.5
+                                 Change DC to TW 
+                                 Change filename from DC.H to TWAIN.H
+    version 1.5, July 1993.      Remove spaces from country identifiers
+ 
+    version 1.7, July 1997       Added Capabilities and data structure for 
+                                 document imaging and digital cameras.
+                                 KHL.
+    version 1.7, July 1997       Inserted Borland compatibile structure packing
+                                 directives provided by Mentor.  JMH
+    version 1.7, Aug 1997        Expanded file tabs to spaces.  
+                                 NOTE: future authors should be sure to have 
+                                 their editors set to automatically expand tabs 
+                                 to spaces (original tab setting was 4 spaces).
+    version 1.7, Sept 1997       Added job control values
+                                 Added return codes
+    version 1.7, Sept 1997       changed definition of pRGBRESPONSE to 
+                                 pTW_RGBRESPONSE
+    version 1.7  Aug 1998        Added missing TWEI_BARCODEROTATION values
+                                 TWBCOR_ types JMH
+    version 1.8  August 1998     Added new types and definitions required
+                                 for 1.8 Specification JMH
+    version 1.8  January 1999    Changed search mode from SRCH_ to TWBD_ as
+                                 in 1.8 Specification, added TWBT_MAXICODE	JMH
+    version 1.8  January 1999    Removed undocumented duplicate AUTO<cap> JMH
+\* ======================================================================== */
+
+#ifndef TWAIN
+#define TWAIN
+
+/*  SDH - 02/08/95 - TWUNK */
+/*  Force 32-bit twain to use same packing of twain structures as existing */
+/*  16-bit twain.  This allows 16/32-bit thunking.                         */
+#ifdef  WIN32
+    #ifdef __BORLANDC__ //(Mentor June 13, 1996) if using a Borland compiler
+        #pragma option -a2  //(Mentor June 13, 1996) switch to word alignment
+    #else   //(Mentor June 13, 1996) if we're using some other compiler
+        #pragma pack (push, before_twain)
+        #pragma pack (2)
+    #endif  //(Mentor June 13, 1996)
+#else   /* WIN32 */
+#endif  /* WIN32 */
+
+/****************************************************************************
+ * TWAIN Version                                                            *
+ ****************************************************************************/
+#define TWON_PROTOCOLMINOR   8        /* Changed for Version 1.8            */
+#define TWON_PROTOCOLMAJOR   1
+
+/****************************************************************************
+ * Platform Dependent Definitions and Typedefs                              *
+ ****************************************************************************/
+
+/* Define one of the following, depending on the platform */
+/* #define _MAC_   */
+#define _UNIX_
+/*#define _MSWIN_  */
+
+#ifdef  _MSWIN_
+    typedef HANDLE         TW_HANDLE;
+    typedef LPVOID         TW_MEMREF;
+
+    /*  SDH - 05/05/95 - TWUNK */
+    /*  For common code between 16 and 32 bits.  */
+    #ifdef  WIN32
+        #define TW_HUGE
+    #else   /* WIN32 */
+        #define TW_HUGE    huge
+    #endif  /* WIN32 */
+    typedef BYTE TW_HUGE * HPBYTE;
+    typedef void TW_HUGE * HPVOID;
+#endif  /* _MSWIN_ */
+
+#ifdef  _MAC_
+    #define PASCAL         pascal
+    #define FAR
+    typedef Handle         TW_HANDLE;
+    typedef char          *TW_MEMREF;
+#endif  /* _MAC_ */
+
+#ifdef  _UNIX_
+/*    #define PASCAL         pascal */
+    #define FAR
+    typedef unsigned char *TW_HANDLE;
+    typedef unsigned char *TW_MEMREF;
+#endif  /* _UNIX_ */
+
+/****************************************************************************
+ * Type Definitions                                                         *
+ ****************************************************************************/
+
+/* String types. These include room for the strings and a NULL char,     *
+ * or, on the Mac, a length byte followed by the string.                 *
+ * TW_STR255 must hold less than 256 chars so length fits in first byte. */
+typedef char    TW_STR32[34],     FAR *pTW_STR32;
+typedef char    TW_STR64[66],     FAR *pTW_STR64;
+typedef char    TW_STR128[130],   FAR *pTW_STR128;
+typedef char    TW_STR255[256],   FAR *pTW_STR255;
+
+/* Numeric types. */
+typedef char           TW_INT8,   FAR *pTW_INT8;
+typedef short          TW_INT16,  FAR *pTW_INT16; 
+typedef long           TW_INT32,  FAR *pTW_INT32;
+typedef unsigned char  TW_UINT8,  FAR *pTW_UINT8;
+typedef unsigned short TW_UINT16, FAR *pTW_UINT16;
+typedef unsigned long  TW_UINT32, FAR *pTW_UINT32;
+typedef unsigned short TW_BOOL,   FAR *pTW_BOOL; 
+
+/* Fixed point structure type. */
+typedef struct {
+    TW_INT16     Whole;        /* maintains the sign */
+    TW_UINT16    Frac;
+} TW_FIX32,  FAR *pTW_FIX32;
+
+/****************************************************************************
+ * Structure Definitions                                                    *
+ ****************************************************************************/
+
+/* No DAT needed. */
+typedef struct {
+   TW_FIX32   X;
+   TW_FIX32   Y;
+   TW_FIX32   Z;
+} TW_CIEPOINT, FAR * pTW_CIEPOINT;
+
+/* No DAT needed. */
+typedef struct {
+   TW_FIX32   StartIn;
+   TW_FIX32   BreakIn;
+   TW_FIX32   EndIn;
+   TW_FIX32   StartOut;
+   TW_FIX32   BreakOut;
+   TW_FIX32   EndOut;
+   TW_FIX32   Gamma;
+   TW_FIX32   SampleCount;  /* if =0 use the gamma */
+} TW_DECODEFUNCTION, FAR * pTW_DECODEFUNCTION;
+
+/* No DAT needed. */
+typedef struct {
+   TW_UINT8    Index;    /* Value used to index into the color table. */
+   TW_UINT8    Channel1; /* First  tri-stimulus value (e.g Red)       */
+   TW_UINT8    Channel2; /* Second tri-stimulus value (e.g Green)     */
+   TW_UINT8    Channel3; /* Third  tri-stimulus value (e.g Blue)      */
+} TW_ELEMENT8, FAR * pTW_ELEMENT8;
+
+/* No DAT.  Defines a frame rectangle in ICAP_UNITS coordinates. */
+typedef struct {
+   TW_FIX32   Left;
+   TW_FIX32   Top;
+   TW_FIX32   Right;
+   TW_FIX32   Bottom;
+} TW_FRAME, FAR * pTW_FRAME;
+
+/* No DAT needed.  Used to manage memory buffers. */
+typedef struct {
+   TW_UINT32  Flags;  /* Any combination of the TWMF_ constants.           */
+   TW_UINT32  Length; /* Number of bytes stored in buffer TheMem.          */
+   TW_MEMREF  TheMem; /* Pointer or handle to the allocated memory buffer. */
+} TW_MEMORY, FAR * pTW_MEMORY;
+
+/* No DAT needed. */
+typedef struct {
+   TW_DECODEFUNCTION   Decode[3];
+   TW_FIX32            Mix[3][3];
+} TW_TRANSFORMSTAGE, FAR * pTW_TRANSFORMSTAGE;
+
+/* No DAT needed.  Describes version of software currently running. */
+typedef struct {
+   TW_UINT16  MajorNum;  /* Major revision number of the software. */
+   TW_UINT16  MinorNum;  /* Incremental revision number of the software. */
+   TW_UINT16  Language;  /* e.g. TWLG_SWISSFRENCH */
+   TW_UINT16  Country;   /* e.g. TWCY_SWITZERLAND */
+   TW_STR32   Info;      /* e.g. "1.0b3 Beta release" */
+} TW_VERSION, FAR * pTW_VERSION;
+
+/* TWON_ARRAY. Container for array of values (a simplified TW_ENUMERATION) */
+typedef struct {
+   TW_UINT16  ItemType;
+   TW_UINT32  NumItems;    /* How many items in ItemList           */
+   TW_UINT8   ItemList[1]; /* Array of ItemType values starts here */
+} TW_ARRAY, FAR * pTW_ARRAY;
+
+/* TWON_ENUMERATION. Container for a collection of values. */
+typedef struct {
+   TW_UINT16  ItemType;
+   TW_UINT32  NumItems;     /* How many items in ItemList                 */
+   TW_UINT32  CurrentIndex; /* Current value is in ItemList[CurrentIndex] */
+   TW_UINT32  DefaultIndex; /* Powerup value is in ItemList[DefaultIndex] */
+   TW_UINT8   ItemList[1];  /* Array of ItemType values starts here       */
+} TW_ENUMERATION, FAR * pTW_ENUMERATION;
+
+/* TWON_ONEVALUE. Container for one value. */
+typedef struct {
+   TW_UINT16  ItemType;
+   TW_UINT32  Item;
+} TW_ONEVALUE, FAR * pTW_ONEVALUE;
+
+/* TWON_RANGE. Container for a range of values. */
+typedef struct {
+   TW_UINT16  ItemType;
+   TW_UINT32  MinValue;     /* Starting value in the range.           */
+   TW_UINT32  MaxValue;     /* Final value in the range.              */
+   TW_UINT32  StepSize;     /* Increment from MinValue to MaxValue.   */
+   TW_UINT32  DefaultValue; /* Power-up value.                        */
+   TW_UINT32  CurrentValue; /* The value that is currently in effect. */
+} TW_RANGE, FAR * pTW_RANGE;
+
+/* DAT_CAPABILITY. Used by application to get/set capability from/in a data source. */
+typedef struct {
+   TW_UINT16  Cap; /* id of capability to set or get, e.g. CAP_BRIGHTNESS */
+   TW_UINT16  ConType; /* TWON_ONEVALUE, _RANGE, _ENUMERATION or _ARRAY   */
+   TW_HANDLE  hContainer; /* Handle to container of type Dat              */
+} TW_CAPABILITY, FAR * pTW_CAPABILITY;
+
+/* DAT_CIECOLOR. */
+typedef struct {
+   TW_UINT16           ColorSpace;
+   TW_INT16            LowEndian;
+   TW_INT16            DeviceDependent;
+   TW_INT32            VersionNumber;
+   TW_TRANSFORMSTAGE   StageABC;
+   TW_TRANSFORMSTAGE   StageLMN;
+   TW_CIEPOINT         WhitePoint;
+   TW_CIEPOINT         BlackPoint;
+   TW_CIEPOINT         WhitePaper;
+   TW_CIEPOINT         BlackInk;
+   TW_FIX32            Samples[1];
+} TW_CIECOLOR, FAR * pTW_CIECOLOR;
+
+/* DAT_EVENT. For passing events down from the application to the DS. */
+typedef struct {
+   TW_MEMREF  pEvent;    /* Windows pMSG or Mac pEvent.                 */
+   TW_UINT16  TWMessage; /* TW msg from data source, e.g. MSG_XFERREADY */
+} TW_EVENT, FAR * pTW_EVENT;
+
+/* DAT_GRAYRESPONSE */
+typedef struct {
+   TW_ELEMENT8         Response[1];
+} TW_GRAYRESPONSE, FAR * pTW_GRAYRESPONSE;
+
+/* DAT_IDENTITY. Identifies the program/library/code resource. */
+typedef struct {
+   TW_UINT32  Id;              /* Unique number.  In Windows, application hWnd      */
+   TW_VERSION Version;         /* Identifies the piece of code              */
+   TW_UINT16  ProtocolMajor;   /* Application and DS must set to TWON_PROTOCOLMAJOR */
+   TW_UINT16  ProtocolMinor;   /* Application and DS must set to TWON_PROTOCOLMINOR */
+   TW_UINT32  SupportedGroups; /* Bit field OR combination of DG_ constants */
+   TW_STR32   Manufacturer;    /* Manufacturer name, e.g. "Hewlett-Packard" */
+   TW_STR32   ProductFamily;   /* Product family name, e.g. "ScanJet"       */
+   TW_STR32   ProductName;     /* Product name, e.g. "ScanJet Plus"         */
+} TW_IDENTITY, FAR * pTW_IDENTITY;
+
+/* DAT_IMAGEINFO. Application gets detailed image info from DS with this. */
+typedef struct {
+   TW_FIX32   XResolution;      /* Resolution in the horizontal             */
+   TW_FIX32   YResolution;      /* Resolution in the vertical               */
+   TW_INT32   ImageWidth;       /* Columns in the image, -1 if unknown by DS*/
+   TW_INT32   ImageLength;      /* Rows in the image, -1 if unknown by DS   */
+   TW_INT16   SamplesPerPixel;  /* Number of samples per pixel, 3 for RGB   */
+   TW_INT16   BitsPerSample[8]; /* Number of bits for each sample           */
+   TW_INT16   BitsPerPixel;     /* Number of bits for each padded pixel     */
+   TW_BOOL    Planar;           /* True if Planar, False if chunky          */
+   TW_INT16   PixelType;        /* How to interp data; photo interp (TWPT_) */
+   TW_UINT16  Compression;      /* How the data is compressed (TWCP_xxxx)   */
+} TW_IMAGEINFO, FAR * pTW_IMAGEINFO;
+
+/* DAT_IMAGELAYOUT. Provides image layout information in current units. */
+typedef struct {
+   TW_FRAME   Frame;          /* Frame coords within larger document */
+   TW_UINT32  DocumentNumber;
+   TW_UINT32  PageNumber;     /* Reset when you go to next document  */
+   TW_UINT32  FrameNumber;    /* Reset when you go to next page      */
+} TW_IMAGELAYOUT, FAR * pTW_IMAGELAYOUT;
+
+/* DAT_IMAGEMEMXFER. Used to pass image data (e.g. in strips) from DS to application.*/
+typedef struct {
+   TW_UINT16  Compression;  /* How the data is compressed                */
+   TW_UINT32  BytesPerRow;  /* Number of bytes in a row of data          */
+   TW_UINT32  Columns;      /* How many columns                          */
+   TW_UINT32  Rows;         /* How many rows                             */
+   TW_UINT32  XOffset;      /* How far from the side of the image        */
+   TW_UINT32  YOffset;      /* How far from the top of the image         */
+   TW_UINT32  BytesWritten; /* How many bytes written in Memory          */
+   TW_MEMORY  Memory;       /* Mem struct used to pass actual image data */
+} TW_IMAGEMEMXFER, FAR * pTW_IMAGEMEMXFER;
+
+/* Changed in 1.1: QuantTable, HuffmanDC, HuffmanAC TW_MEMREF -> TW_MEMORY  */
+/* DAT_JPEGCOMPRESSION. Based on JPEG Draft International Std, ver 10918-1. */
+typedef struct {
+   TW_UINT16   ColorSpace;       /* One of the TWPT_xxxx values                */
+   TW_UINT32   SubSampling;      /* Two word "array" for subsampling values    */
+   TW_UINT16   NumComponents;    /* Number of color components in image        */
+   TW_UINT16   RestartFrequency; /* Frequency of restart marker codes in MDU's */
+   TW_UINT16   QuantMap[4];      /* Mapping of components to QuantTables       */
+   TW_MEMORY   QuantTable[4];    /* Quantization tables                        */
+   TW_UINT16   HuffmanMap[4];    /* Mapping of components to Huffman tables    */
+   TW_MEMORY   HuffmanDC[2];     /* DC Huffman tables                          */
+   TW_MEMORY   HuffmanAC[2];     /* AC Huffman tables                          */
+} TW_JPEGCOMPRESSION, FAR * pTW_JPEGCOMPRESSION;
+
+/* DAT_PALETTE8. Color palette when TWPT_PALETTE pixels xfer'd in mem buf. */
+typedef struct {
+   TW_UINT16    NumColors;   /* Number of colors in the color table.  */
+   TW_UINT16    PaletteType; /* TWPA_xxxx, specifies type of palette. */
+   TW_ELEMENT8  Colors[256]; /* Array of palette values starts here.  */
+} TW_PALETTE8, FAR * pTW_PALETTE8;
+
+/* DAT_PENDINGXFERS. Used with MSG_ENDXFER to indicate additional data. */
+typedef struct {
+   TW_UINT16 Count;
+   union {
+      TW_UINT32 EOJ;
+      TW_UINT32 Reserved;
+   } DUMMYUNIONNAME;
+} TW_PENDINGXFERS, FAR *pTW_PENDINGXFERS;
+
+/* DAT_RGBRESPONSE */
+typedef struct {
+   TW_ELEMENT8         Response[1];
+} TW_RGBRESPONSE, FAR * pTW_RGBRESPONSE;
+
+/* DAT_SETUPFILEXFER. Sets up DS to application data transfer via a file. */
+typedef struct {
+   TW_STR255 FileName;
+   TW_UINT16 Format;   /* Any TWFF_ constant */
+   TW_INT16  VRefNum;  /* Used for Mac only  */
+} TW_SETUPFILEXFER, FAR * pTW_SETUPFILEXFER;
+
+/* DAT_SETUPMEMXFER. Sets up DS to application data transfer via a memory buffer. */
+typedef struct {
+   TW_UINT32 MinBufSize;
+   TW_UINT32 MaxBufSize;
+   TW_UINT32 Preferred;
+} TW_SETUPMEMXFER, FAR * pTW_SETUPMEMXFER;
+
+/* DAT_STATUS. Application gets detailed status info from a data source with this. */
+typedef struct {
+   TW_UINT16  ConditionCode; /* Any TWCC_ constant     */
+   TW_UINT16  Reserved;      /* Future expansion space */
+} TW_STATUS, FAR * pTW_STATUS;
+
+/* DAT_USERINTERFACE. Coordinates UI between application and data source. */
+typedef struct {
+   TW_BOOL    ShowUI;  /* TRUE if DS should bring up its UI           */
+   TW_BOOL    ModalUI; /* For Mac only - true if the DS's UI is modal */
+   TW_HANDLE  hParent; /* For windows only - Application window handle        */
+} TW_USERINTERFACE, FAR * pTW_USERINTERFACE;
+
+/* SDH - 03/21/95 - TWUNK */
+/* DAT_TWUNKIDENTITY. Provides DS identity and 'other' information necessary */
+/*                    across thunk link. */
+typedef struct {
+   TW_IDENTITY identity;        /* Identity of data source.                 */
+   TW_STR255   dsPath;          /* Full path and file name of data source.  */
+} TW_TWUNKIDENTITY, FAR * pTW_TWUNKIDENTITY;
+
+/* SDH - 03/21/95 - TWUNK */
+/* Provides DS_Entry parameters over thunk link. */
+typedef struct
+{
+    TW_INT8     destFlag;       /* TRUE if dest is not NULL                 */
+    TW_IDENTITY dest;           /* Identity of data source (if used)        */
+    TW_INT32    dataGroup;      /* DSM_Entry dataGroup parameter            */
+    TW_INT16    dataArgType;    /* DSM_Entry dataArgType parameter          */
+    TW_INT16    message;        /* DSM_Entry message parameter              */
+    TW_INT32    pDataSize;      /* Size of pData (0 if NULL)                */
+    //  TW_MEMREF   pData;      /* Based on implementation specifics, a     */
+                                /* pData parameter makes no sense in this   */
+                                /* structure, but data (if provided) will be*/
+                                /* appended in the data block.              */
+   } TW_TWUNKDSENTRYPARAMS, FAR * pTW_TWUNKDSENTRYPARAMS;
+
+/* SDH - 03/21/95 - TWUNK */
+/* Provides DS_Entry results over thunk link. */
+typedef struct
+{
+    TW_UINT16   returnCode;     /* Thunker DsEntry return code.             */
+    TW_UINT16   conditionCode;  /* Thunker DsEntry condition code.          */
+    TW_INT32    pDataSize;      /* Size of pData (0 if NULL)                */
+    //  TW_MEMREF   pData;      /* Based on implementation specifics, a     */
+                                /* pData parameter makes no sense in this   */
+                                /* structure, but data (if provided) will be*/
+                                /* appended in the data block.              */
+} TW_TWUNKDSENTRYRETURN, FAR * pTW_TWUNKDSENTRYRETURN;
+
+/* WJD - 950818 */
+/* Added for 1.6 Specification */
+/* TWAIN 1.6 CAP_SUPPORTEDCAPSEXT structure */
+typedef struct
+{
+    TW_UINT16 Cap;   /* Which CAP/ICAP info is relevant to */
+    TW_UINT16 Properties;  /* Messages this CAP/ICAP supports */
+} TW_CAPEXT, FAR * pTW_CAPEXT;
+
+/* ----------------------------------------------------------------------- *\
+
+  Version 1.7:      Added Following data structure for Document Imaging 
+  July 1997         Enhancement.
+  KHL               TW_CUSTOMDSDATA --  For Saving and Restoring Source's 
+                                        state.
+                    TW_INFO         --  Each attribute for extended image
+                                        information.
+                    TW_EXTIMAGEINFO --  Extended image information structure.
+
+\* ----------------------------------------------------------------------- */
+
+typedef struct {
+    TW_UINT32  InfoLength;     /* Length of Information in bytes.  */
+    TW_HANDLE  hData;          /* Place holder for data, DS Allocates */
+}TW_CUSTOMDSDATA, FAR *pTW_CUSTOMDSDATA;
+
+typedef struct {
+    TW_UINT16   InfoID;
+    TW_UINT16   ItemType;
+    TW_UINT16   NumItems;
+    TW_UINT16   CondCode;
+    TW_UINT32   Item;
+}TW_INFO, FAR* pTW_INFO;
+
+typedef struct {
+    TW_UINT32   NumInfos;
+    TW_INFO     Info[1];
+}TW_EXTIMAGEINFO, FAR* pTW_EXTIMAGEINFO;
+
+/* Added 1.8 */
+
+/* DAT_AUDIOINFO, information about audio data */
+typedef struct {
+   TW_STR255  Name;       /* name of audio data */
+   TW_UINT32  Reserved;   /* reserved space */
+} TW_AUDIOINFO, FAR * pTW_AUDIOINFO;
+
+/* DAT_DEVICEEVENT, information about events */
+typedef struct {
+   TW_UINT32  Event;                  /* One of the TWDE_xxxx values. */
+   TW_STR255  DeviceName;             /* The name of the device that generated the event */
+   TW_UINT32  BatteryMinutes;         /* Battery Minutes Remaining    */
+   TW_INT16   BatteryPercentage;      /* Battery Percentage Remaining */
+   TW_INT32   PowerSupply;            /* Power Supply                 */
+   TW_FIX32   XResolution;            /* Resolution                   */
+   TW_FIX32   YResolution;            /* Resolution                   */
+   TW_UINT32  FlashUsed2;             /* Flash Used2                  */
+   TW_UINT32  AutomaticCapture;       /* Automatic Capture            */
+   TW_UINT32  TimeBeforeFirstCapture; /* Automatic Capture            */
+   TW_UINT32  TimeBetweenCaptures;    /* Automatic Capture            */
+} TW_DEVICEEVENT, FAR * pTW_DEVICEEVENT;
+
+/* DAT_FILESYSTEM, information about TWAIN file system */
+typedef struct {
+   /* DG_CONTROL / DAT_FILESYSTEM / MSG_xxxx fields     */
+   TW_STR255  InputName; /* The name of the input or source file */
+   TW_STR255  OutputName; /* The result of an operation or the name of a destination file */
+   TW_MEMREF  Context; /* Source specific data used to remember state information */
+   /* DG_CONTROL / DAT_FILESYSTEM / MSG_DELETE field    */
+   int        Recursive; /* recursively delete all sub-directories */
+   /* DG_CONTROL / DAT_FILESYSTEM / MSG_GETINFO fields  */
+   TW_INT32   FileType; /* One of the TWFT_xxxx values */
+   TW_UINT32  Size; /* Size of current FileType */
+   TW_STR32   CreateTimeDate; /* creation date of the file */
+   TW_STR32   ModifiedTimeDate; /* last date the file was modified */
+   TW_UINT32  FreeSpace; /* bytes of free space on the current device */
+   TW_INT32   NewImageSize; /* estimate of the amount of space a new image would take up */
+   TW_UINT32  NumberOfFiles; /* number of files, depends on FileType */
+   TW_UINT32  NumberOfSnippets; /**/
+   char       Reserved[512]; /**/
+} TW_FILESYSTEM, FAR * pTW_FILESYSTEM;
+
+/* DAT_PASSTHRU, device dependant data to pass through Data Source */
+typedef struct {
+   TW_MEMREF  pCommand;        /* Pointer to Command buffer */
+   TW_UINT32  CommandBytes;    /* Number of bytes in Command buffer */
+   TW_INT32   Direction;       /* One of the TWDR_xxxx values.  Defines the direction of data flow */
+   TW_MEMREF  pData;           /* Pointer to Data buffer */
+   TW_UINT32  DataBytes;       /* Number of bytes in Data buffer */
+   TW_UINT32  DataBytesXfered; /* Number of bytes successfully transferred */
+} TW_PASSTHRU, FAR * pTW_PASSTHRU;
+
+/* DAT_SETUPAUDIOFILEXFER, information required to setup an audio file transfer */
+typedef struct {
+   TW_STR255  FileName; /* full path target file */
+   TW_UINT16  Format;   /* one of TWAF_xxxx */
+   TW_INT16 VRefNum;
+} TW_SETUPAUDIOFILEXFER, FAR * pTW_SETUPAUDIOFILEXFER;
+
+/****************************************************************************
+ * Generic Constants                                                        *
+ ****************************************************************************/
+
+#define TWON_ARRAY           3 /* indicates TW_ARRAY container       */
+#define TWON_ENUMERATION     4 /* indicates TW_ENUMERATION container */
+#define TWON_ONEVALUE        5 /* indicates TW_ONEVALUE container    */
+#define TWON_RANGE           6 /* indicates TW_RANGE container       */
+
+#define TWON_ICONID          962 /* res Id of icon used in USERSELECT lbox */
+#define TWON_DSMID           461 /* res Id of the DSM version num resource */
+#define TWON_DSMCODEID       63  /* res Id of the Mac SM Code resource     */
+
+#define TWON_DONTCARE8       0xff
+#define TWON_DONTCARE16      0xffff
+#define TWON_DONTCARE32      0xffffffff
+
+/* Flags used in TW_MEMORY structure. */
+#define TWMF_APPOWNS     0x1
+#define TWMF_DSMOWNS     0x2
+#define TWMF_DSOWNS      0x4
+#define TWMF_POINTER     0x8
+#define TWMF_HANDLE      0x10
+
+/* Palette types for TW_PALETTE8 */
+#define TWPA_RGB         0
+#define TWPA_GRAY        1
+#define TWPA_CMY         2
+
+/* There are four containers used for capabilities negotiation:
+ *    TWON_ONEVALUE, TWON_RANGE, TWON_ENUMERATION, TWON_ARRAY
+ * In each container structure ItemType can be TWTY_INT8, TWTY_INT16, etc.
+ * The kind of data stored in the container can be determined by doing
+ * DCItemSize[ItemType] where the following is defined in TWAIN glue code:
+ *          DCItemSize[]= { sizeof(TW_INT8),
+ *                          sizeof(TW_INT16),
+ *                          etc.
+ *                          sizeof(TW_UINT32) };
+ *
+ */
+
+#define TWTY_INT8        0x0000    /* Means Item is a TW_INT8   */
+#define TWTY_INT16       0x0001    /* Means Item is a TW_INT16  */
+#define TWTY_INT32       0x0002    /* Means Item is a TW_INT32  */
+
+#define TWTY_UINT8       0x0003    /* Means Item is a TW_UINT8  */
+#define TWTY_UINT16      0x0004    /* Means Item is a TW_UINT16 */
+#define TWTY_UINT32      0x0005    /* Means Item is a TW_UINT32 */
+
+#define TWTY_BOOL        0x0006    /* Means Item is a TW_BOOL   */
+
+#define TWTY_FIX32       0x0007    /* Means Item is a TW_FIX32  */
+
+#define TWTY_FRAME       0x0008    /* Means Item is a TW_FRAME  */
+
+#define TWTY_STR32       0x0009    /* Means Item is a TW_STR32  */
+#define TWTY_STR64       0x000a    /* Means Item is a TW_STR64  */
+#define TWTY_STR128      0x000b    /* Means Item is a TW_STR128 */
+#define TWTY_STR255      0x000c    /* Means Item is a TW_STR255 */
+
+/****************************************************************************
+ * Capability Constants                                                     *
+ ****************************************************************************/
+
+/* ICAP_BITORDER values (BO_ means Bit Order) */
+#define TWBO_LSBFIRST    0
+#define TWBO_MSBFIRST    1
+
+/* ICAP_COMPRESSION values (CP_ means ComPression ) */
+#define TWCP_NONE        0
+#define TWCP_PACKBITS    1
+#define TWCP_GROUP31D    2 /* Follows CCITT spec (no End Of Line)          */
+#define TWCP_GROUP31DEOL 3 /* Follows CCITT spec (has End Of Line)         */
+#define TWCP_GROUP32D    4 /* Follows CCITT spec (use cap for K Factor)    */
+#define TWCP_GROUP4      5 /* Follows CCITT spec                           */
+#define TWCP_JPEG        6 /* Use capability for more info                 */
+#define TWCP_LZW         7 /* Must license from Unisys and IBM to use      */
+#define TWCP_JBIG        8 /* For Bitonal images  -- Added 1.7 KHL         */
+/* Added 1.8 */
+#define TWCP_PNG         9
+#define TWCP_RLE4        10
+#define TWCP_RLE8        11
+#define TWCP_BITFIELDS   12
+
+
+/* ICAP_IMAGEFILEFORMAT values (FF_means File Format)   */
+#define TWFF_TIFF        0    /* Tagged Image File Format     */
+#define TWFF_PICT        1    /* Macintosh PICT               */
+#define TWFF_BMP         2    /* Windows Bitmap               */
+#define TWFF_XBM         3    /* X-Windows Bitmap             */
+#define TWFF_JFIF        4    /* JPEG File Interchange Format */
+#define TWFF_FPX         5    /* Flash Pix                    */
+#define TWFF_TIFFMULTI   6    /* Multi-page tiff file         */
+#define TWFF_PNG         7
+#define TWFF_SPIFF       8
+#define TWFF_EXIF        9
+
+
+/* ICAP_FILTER values (FT_ means Filter Type) */
+#define TWFT_RED         0
+#define TWFT_GREEN       1
+#define TWFT_BLUE        2
+#define TWFT_NONE        3
+#define TWFT_WHITE       4
+#define TWFT_CYAN        5
+#define TWFT_MAGENTA     6
+#define TWFT_YELLOW      7
+#define TWFT_BLACK       8
+
+/* ICAP_LIGHTPATH values (LP_ means Light Path) */
+#define TWLP_REFLECTIVE   0
+#define TWLP_TRANSMISSIVE 1
+
+/* ICAP_LIGHTSOURCE values (LS_ means Light Source) */
+#define TWLS_RED         0
+#define TWLS_GREEN       1
+#define TWLS_BLUE        2
+#define TWLS_NONE        3
+#define TWLS_WHITE       4
+#define TWLS_UV          5
+#define TWLS_IR          6
+
+/* ICAP_ORIENTATION values (OR_ means ORientation) */
+#define TWOR_ROT0        0
+#define TWOR_ROT90       1
+#define TWOR_ROT180      2
+#define TWOR_ROT270      3
+#define TWOR_PORTRAIT    TWOR_ROT0
+#define TWOR_LANDSCAPE   TWOR_ROT270
+
+/* ICAP_PLANARCHUNKY values (PC_ means Planar/Chunky ) */
+#define TWPC_CHUNKY      0
+#define TWPC_PLANAR      1
+
+/* ICAP_PIXELFLAVOR values (PF_ means Pixel Flavor) */
+#define TWPF_CHOCOLATE   0  /* zero pixel represents darkest shade  */
+#define TWPF_VANILLA     1  /* zero pixel represents lightest shade */
+
+/* ICAP_PIXELTYPE values (PT_ means Pixel Type) */
+#define TWPT_BW          0 /* Black and White */
+#define TWPT_GRAY        1
+#define TWPT_RGB         2
+#define TWPT_PALETTE     3
+#define TWPT_CMY         4
+#define TWPT_CMYK        5
+#define TWPT_YUV         6
+#define TWPT_YUVK        7
+#define TWPT_CIEXYZ      8
+
+/* ICAP_SUPPORTEDSIZES values (SS_ means Supported Sizes) */
+#define TWSS_NONE        0
+#define TWSS_A4LETTER    1
+#define TWSS_B5LETTER    2
+#define TWSS_USLETTER    3
+#define TWSS_USLEGAL     4
+/* Added 1.5 */
+#define TWSS_A5          5
+#define TWSS_B4          6
+#define TWSS_B6          7
+//#define TWSS_B          8
+/* Added 1.7 */
+#define TWSS_USLEDGER    9
+#define TWSS_USEXECUTIVE 10
+#define TWSS_A3          11
+#define TWSS_B3          12
+#define TWSS_A6          13
+#define TWSS_C4          14
+#define TWSS_C5          15
+#define TWSS_C6          16
+/* Added 1.8 */
+#define TWSS_4A0          17
+#define TWSS_2A0          18
+#define TWSS_A0           19
+#define TWSS_A1           20
+#define TWSS_A2           21
+#define TWSS_A4           TWSS_A4LETTER
+#define TWSS_A7           22
+#define TWSS_A8           23
+#define TWSS_A9           24
+#define TWSS_A10          25
+#define TWSS_ISOB0        26
+#define TWSS_ISOB1        27
+#define TWSS_ISOB2        28
+#define TWSS_ISOB3        TWSS_B3
+#define TWSS_ISOB4        TWSS_B4
+#define TWSS_ISOB5        29
+#define TWSS_ISOB6        TWSS_B6
+#define TWSS_ISOB7        30
+#define TWSS_ISOB8        31
+#define TWSS_ISOB9        32
+#define TWSS_ISOB10       33
+#define TWSS_JISB0        34
+#define TWSS_JISB1        35
+#define TWSS_JISB2        36
+#define TWSS_JISB3        37
+#define TWSS_JISB4        38
+#define TWSS_JISB5        TWSS_B5LETTER
+#define TWSS_JISB6        39
+#define TWSS_JISB7        40
+#define TWSS_JISB8        41
+#define TWSS_JISB9        42
+#define TWSS_JISB10       43
+#define TWSS_C0           44
+#define TWSS_C1           45
+#define TWSS_C2           46
+#define TWSS_C3           47
+#define TWSS_C7           48
+#define TWSS_C8           49
+#define TWSS_C9           50
+#define TWSS_C10          51
+#define TWSS_USSTATEMENT  52
+#define TWSS_BUSINESSCARD 53
+
+/* ICAP_XFERMECH values (SX_ means Setup XFer) */
+#define TWSX_NATIVE      0
+#define TWSX_FILE        1
+#define TWSX_MEMORY      2
+
+/* ICAP_UNITS values (UN_ means UNits) */
+#define TWUN_INCHES      0
+#define TWUN_CENTIMETERS 1
+#define TWUN_PICAS       2
+#define TWUN_POINTS      3
+#define TWUN_TWIPS       4
+#define TWUN_PIXELS      5
+
+/* Added 1.5 */
+/* ICAP_BITDEPTHREDUCTION values (BR_ means Bitdepth Reduction) */
+#define TWBR_THRESHOLD     0
+#define TWBR_HALFTONE      1
+#define TWBR_CUSTHALFTONE  2
+#define TWBR_DIFFUSION     3
+
+/* Added 1.7 */
+/* ICAP_DUPLEX values */
+#define TWDX_NONE         0
+#define TWDX_1PASSDUPLEX  1
+#define TWDX_2PASSDUPLEX  2
+
+/* Added 1.7 */
+/* TWEI_BARCODETYPE values */
+#define TWBT_3OF9                 0
+#define TWBT_2OF5INTERLEAVED      1
+#define TWBT_2OF5NONINTERLEAVED   2
+#define TWBT_CODE93               3
+#define TWBT_CODE128              4
+#define TWBT_UCC128               5
+#define TWBT_CODABAR              6
+#define TWBT_UPCA                 7
+#define TWBT_UPCE                 8
+#define TWBT_EAN8                 9
+#define TWBT_EAN13                10
+#define TWBT_POSTNET              11
+#define TWBT_PDF417               12
+/* Added 1.8 */
+#define TWBT_2OF5INDUSTRIAL       13
+#define TWBT_2OF5MATRIX           14
+#define TWBT_2OF5DATALOGIC        15
+#define TWBT_2OF5IATA             16
+#define TWBT_3OF9FULLASCII        17
+#define TWBT_CODABARWITHSTARTSTOP 18
+#define TWBT_MAXICODE             19
+
+/* Added 1.7 */
+/* TWEI_DESKEWSTATUS values */
+#define TWDSK_SUCCESS     0
+#define TWDSK_REPORTONLY  1
+#define TWDSK_FAIL        2
+#define TWDSK_DISABLED    3
+
+/* Added 1.7 */
+/* TWEI_PATCHCODE values */
+#define TWPCH_PATCH1      0
+#define TWPCH_PATCH2      1
+#define TWPCH_PATCH3      2
+#define TWPCH_PATCH4      3
+#define TWPCH_PATCH6      4
+#define TWPCH_PATCHT      5
+
+/* Added 1.7 */
+/* CAP_JOBCONTROL values */
+#define TWJC_NONE   0
+#define TWJC_JSIC   1
+#define TWJC_JSIS   2
+#define TWJC_JSXC   3
+#define TWJC_JSXS   4
+                  
+/* Added 1.7 */
+/* TWEI_BARCODEROTATION values (BCOR_ means barcode rotation) */
+#define TWBCOR_ROT0   0
+#define TWBCOR_ROT90  1
+#define TWBCOR_ROT180 2
+#define TWBCOR_ROT270 3
+#define TWBCOR_ROTX   4
+
+/* Added 1.8 */
+/* ACAP_AUDIOFILEFORMAT values (AF_ means audio format) */
+#define TWAF_WAV      0
+#define TWAF_AIFF     1
+#define TWAF_AU       3
+#define TWAF_SND      4
+
+/* CAP_ALARMS values (AL_ means alarms) */
+#define TWAL_ALARM          0
+#define TWAL_FEEDERERROR    1
+#define TWAL_FEEDERWARNING  2
+#define TWAL_BARCODE        3
+#define TWAL_DOUBLEFEED     4
+#define TWAL_JAM            5
+#define TWAL_PATCHCODE      6
+#define TWAL_POWER          7
+#define TWAL_SKEW           8
+
+/* CAP_CLEARBUFFERS values (CB_ means clear buffers) */
+#define TWCB_AUTO           0
+#define TWCB_CLEAR          1
+#define TWCB_NOCLEAR        2
+
+/* CAP_DEVICEEVENT values (DE_ means device event) */
+#define TWDE_CUSTOMEVENTS           0x8000      
+#define TWDE_CHECKAUTOMATICCAPTURE  0
+#define TWDE_CHECKBATTERY           1
+#define TWDE_CHECKDEVICEONLINE      2
+#define TWDE_CHECKFLASH             3
+#define TWDE_CHECKPOWERSUPPLY       4
+#define TWDE_CHECKRESOLUTION        5
+#define TWDE_DEVICEADDED            6
+#define TWDE_DEVICEOFFLINE          7
+#define TWDE_DEVICEREADY            8
+#define TWDE_DEVICEREMOVED          9
+#define TWDE_IMAGECAPTURED          10
+#define TWDE_IMAGEDELETED           11
+#define TWDE_PAPERDOUBLEFEED        12
+#define TWDE_PAPERJAM               13
+#define TWDE_LAMPFAILURE            14
+#define TWDE_POWERSAVE              15
+#define TWDE_POWERSAVENOTIFY        16
+
+/* CAP_FEEDERALIGNMENT values (FA_ means feeder alignment) */
+#define TWFA_NONE   0
+#define TWFA_LEFT   1
+#define TWFA_CENTER 2
+#define TWFA_RIGHT  3
+
+/* CAP_FEEDERORDER values (FO_ means feeder order) */
+#define TWFO_FIRSTPAGEFIRST 0
+#define TWFO_LASTPAGEFIRST  1
+
+/* CAP_FILESYSTEM values (FS_ means file system) */
+#define TWFS_FILESYSTEM       0
+#define TWFS_RECURSIVEDELETE  1
+
+/* CAP_POWERSUPPLY values (PS_ means power supply) */
+#define TWPS_EXTERNAL 0
+#define TWPS_BATTERY  1
+
+/* CAP_PRINTER values (PR_ means printer) */
+#define TWPR_IMPRINTERTOPBEFORE     0
+#define TWPR_IMPRINTERTOPAFTER      1
+#define TWPR_IMPRINTERBOTTOMBEFORE  2
+#define TWPR_IMPRINTERBOTTOMAFTER   3
+#define TWPR_ENDORSERTOPBEFORE      4
+#define TWPR_ENDORSERTOPAFTER       5
+#define TWPR_ENDORSERBOTTOMBEFORE   6
+#define TWPR_ENDORSERBOTTOMAFTER    7
+
+/* CAP_PRINTERMODE values (PM_ means printer mode) */
+#define TWPM_SINGLESTRING     0
+#define TWPM_MULTISTRING      1
+#define TWPM_COMPOUNDSTRING   2
+
+/* ICAP_BARCODESEARCHMODE values (TWBD_ means search) */
+#define TWBD_HORZ     0
+#define TWBD_VERT     1
+#define TWBD_HORZVERT 2
+#define TWBD_VERTHORZ 3
+
+/* ICAP_FLASHUSED2 values (FL_ means flash) */
+#define TWFL_NONE     0
+#define TWFL_OFF      1
+#define TWFL_ON       2
+#define TWFL_AUTO     3
+#define TWFL_REDEYE   4
+
+/* ICAP_FLIPROTATION values (FR_ means flip rotation) */
+#define TWFR_BOOK     0
+#define TWFR_FANFOLD  1
+
+/* ICAP_IMAGEFILTER values (IF_ means image filter) */
+#define TWIF_NONE     0
+#define TWIF_AUTO     1
+#define TWIF_LOWPASS  2
+#define TWIF_BANDPASS 3
+#define TWIF_HIGHPASS 4
+#define TWIF_TEXT     TWIF_BANDPASS
+#define TWIF_FINELINE TWIF_HIGHPASS
+
+/* ICAP_NOISEFILTER values (NF_ means noise filter) */
+#define TWNF_NONE         0
+#define TWNF_AUTO         1
+#define TWNF_LONEPIXEL    2
+#define TWNF_MAJORITYRULE 3
+
+/* ICAP_OVERSCAN values (OV_ means overscan) */
+#define TWOV_NONE       0
+#define TWOV_AUTO       1
+#define TWOV_TOPBOTTOM  2
+#define TWOV_LEFTRIGHT  3
+#define TWOV_ALL        4
+
+/* TW_FILESYSTEM.FileType values (FT_ means file type) */
+#define TWFY_CAMERA         0
+#define TWFY_CAMERATOP      1
+#define TWFY_CAMERABOTTOM   2
+#define TWFY_CAMERAPREVIEW  3
+#define TWFY_DOMAIN         4
+#define TWFY_HOST           5
+#define TWFY_DIRECTORY      6
+#define TWFY_IMAGE          7
+#define TWFY_UNKNOWN        8
+
+/****************************************************************************
+ * Country Constants                                                        *
+ ****************************************************************************/
+
+#define TWCY_AFGHANISTAN   1001
+#define TWCY_ALGERIA        213
+#define TWCY_AMERICANSAMOA  684
+#define TWCY_ANDORRA        033
+#define TWCY_ANGOLA        1002
+#define TWCY_ANGUILLA      8090
+#define TWCY_ANTIGUA       8091
+#define TWCY_ARGENTINA       54
+#define TWCY_ARUBA          297
+#define TWCY_ASCENSIONI     247
+#define TWCY_AUSTRALIA       61
+#define TWCY_AUSTRIA         43
+#define TWCY_BAHAMAS       8092
+#define TWCY_BAHRAIN        973
+#define TWCY_BANGLADESH     880
+#define TWCY_BARBADOS      8093
+#define TWCY_BELGIUM         32
+#define TWCY_BELIZE         501
+#define TWCY_BENIN          229
+#define TWCY_BERMUDA       8094
+#define TWCY_BHUTAN        1003
+#define TWCY_BOLIVIA        591
+#define TWCY_BOTSWANA       267
+#define TWCY_BRITAIN          6
+#define TWCY_BRITVIRGINIS  8095
+#define TWCY_BRAZIL          55
+#define TWCY_BRUNEI         673
+#define TWCY_BULGARIA       359
+#define TWCY_BURKINAFASO   1004
+#define TWCY_BURMA         1005
+#define TWCY_BURUNDI       1006
+#define TWCY_CAMAROON       237
+#define TWCY_CANADA           2
+#define TWCY_CAPEVERDEIS    238
+#define TWCY_CAYMANIS      8096
+#define TWCY_CENTRALAFREP  1007
+#define TWCY_CHAD          1008
+#define TWCY_CHILE           56
+#define TWCY_CHINA           86
+#define TWCY_CHRISTMASIS   1009
+#define TWCY_COCOSIS       1009
+#define TWCY_COLOMBIA        57
+#define TWCY_COMOROS       1010
+#define TWCY_CONGO         1011
+#define TWCY_COOKIS        1012
+#define TWCY_COSTARICA     506
+#define TWCY_CUBA           005
+#define TWCY_CYPRUS         357
+#define TWCY_CZECHOSLOVAKIA  42
+#define TWCY_DENMARK         45
+#define TWCY_DJIBOUTI      1013
+#define TWCY_DOMINICA      8097
+#define TWCY_DOMINCANREP   8098
+#define TWCY_EASTERIS      1014
+#define TWCY_ECUADOR        593
+#define TWCY_EGYPT           20
+#define TWCY_ELSALVADOR     503
+#define TWCY_EQGUINEA      1015
+#define TWCY_ETHIOPIA       251
+#define TWCY_FALKLANDIS    1016
+#define TWCY_FAEROEIS       298
+#define TWCY_FIJIISLANDS    679
+#define TWCY_FINLAND        358
+#define TWCY_FRANCE          33
+#define TWCY_FRANTILLES     596
+#define TWCY_FRGUIANA       594
+#define TWCY_FRPOLYNEISA    689
+#define TWCY_FUTANAIS      1043
+#define TWCY_GABON          241
+#define TWCY_GAMBIA         220
+#define TWCY_GERMANY         49
+#define TWCY_GHANA          233
+#define TWCY_GIBRALTER      350
+#define TWCY_GREECE          30
+#define TWCY_GREENLAND      299
+#define TWCY_GRENADA       8099
+#define TWCY_GRENEDINES    8015
+#define TWCY_GUADELOUPE     590
+#define TWCY_GUAM           671
+#define TWCY_GUANTANAMOBAY 5399
+#define TWCY_GUATEMALA      502
+#define TWCY_GUINEA         224
+#define TWCY_GUINEABISSAU  1017
+#define TWCY_GUYANA         592
+#define TWCY_HAITI          509
+#define TWCY_HONDURAS       504
+#define TWCY_HONGKONG      852
+#define TWCY_HUNGARY         36
+#define TWCY_ICELAND        354
+#define TWCY_INDIA           91
+#define TWCY_INDONESIA       62
+#define TWCY_IRAN            98
+#define TWCY_IRAQ           964
+#define TWCY_IRELAND        353
+#define TWCY_ISRAEL         972
+#define TWCY_ITALY           39
+#define TWCY_IVORYCOAST    225
+#define TWCY_JAMAICA       8010
+#define TWCY_JAPAN           81
+#define TWCY_JORDAN         962
+#define TWCY_KENYA          254
+#define TWCY_KIRIBATI      1018
+#define TWCY_KOREA           82
+#define TWCY_KUWAIT         965
+#define TWCY_LAOS          1019
+#define TWCY_LEBANON       1020
+#define TWCY_LIBERIA        231
+#define TWCY_LIBYA          218
+#define TWCY_LIECHTENSTEIN   41
+#define TWCY_LUXENBOURG     352
+#define TWCY_MACAO          853
+#define TWCY_MADAGASCAR    1021
+#define TWCY_MALAWI         265
+#define TWCY_MALAYSIA        60
+#define TWCY_MALDIVES       960
+#define TWCY_MALI          1022
+#define TWCY_MALTA          356
+#define TWCY_MARSHALLIS     692
+#define TWCY_MAURITANIA    1023
+#define TWCY_MAURITIUS      230
+#define TWCY_MEXICO           3
+#define TWCY_MICRONESIA     691
+#define TWCY_MIQUELON       508
+#define TWCY_MONACO          33
+#define TWCY_MONGOLIA      1024
+#define TWCY_MONTSERRAT    8011
+#define TWCY_MOROCCO        212
+#define TWCY_MOZAMBIQUE    1025
+#define TWCY_NAMIBIA        264
+#define TWCY_NAURU         1026
+#define TWCY_NEPAL          977
+#define TWCY_NETHERLANDS     31
+#define TWCY_NETHANTILLES   599
+#define TWCY_NEVIS         8012
+#define TWCY_NEWCALEDONIA   687
+#define TWCY_NEWZEALAND      64
+#define TWCY_NICARAGUA      505
+#define TWCY_NIGER          227
+#define TWCY_NIGERIA        234
+#define TWCY_NIUE          1027
+#define TWCY_NORFOLKI      1028
+#define TWCY_NORWAY          47
+#define TWCY_OMAN           968
+#define TWCY_PAKISTAN        92
+#define TWCY_PALAU         1029
+#define TWCY_PANAMA         507
+#define TWCY_PARAGUAY       595
+#define TWCY_PERU            51
+#define TWCY_PHILLIPPINES    63
+#define TWCY_PITCAIRNIS    1030
+#define TWCY_PNEWGUINEA     675
+#define TWCY_POLAND          48
+#define TWCY_PORTUGAL       351
+#define TWCY_QATAR          974
+#define TWCY_REUNIONI      1031
+#define TWCY_ROMANIA         40
+#define TWCY_RWANDA         250
+#define TWCY_SAIPAN         670
+#define TWCY_SANMARINO       39
+#define TWCY_SAOTOME       1033
+#define TWCY_SAUDIARABIA    966
+#define TWCY_SENEGAL        221
+#define TWCY_SEYCHELLESIS  1034
+#define TWCY_SIERRALEONE   1035
+#define TWCY_SINGAPORE       65
+#define TWCY_SOLOMONIS     1036
+#define TWCY_SOMALI        1037
+#define TWCY_SOUTHAFRICA    27
+#define TWCY_SPAIN           34
+#define TWCY_SRILANKA        94
+#define TWCY_STHELENA      1032
+#define TWCY_STKITTS       8013
+#define TWCY_STLUCIA       8014
+#define TWCY_STPIERRE       508
+#define TWCY_STVINCENT     8015
+#define TWCY_SUDAN         1038
+#define TWCY_SURINAME       597
+#define TWCY_SWAZILAND      268
+#define TWCY_SWEDEN          46
+#define TWCY_SWITZERLAND     41
+#define TWCY_SYRIA         1039
+#define TWCY_TAIWAN         886
+#define TWCY_TANZANIA       255
+#define TWCY_THAILAND        66
+#define TWCY_TOBAGO        8016
+#define TWCY_TOGO           228
+#define TWCY_TONGAIS        676
+#define TWCY_TRINIDAD      8016
+#define TWCY_TUNISIA        216
+#define TWCY_TURKEY          90
+#define TWCY_TURKSCAICOS   8017
+#define TWCY_TUVALU        1040
+#define TWCY_UGANDA         256
+#define TWCY_USSR             7
+#define TWCY_UAEMIRATES     971
+#define TWCY_UNITEDKINGDOM   44
+#define TWCY_USA              1
+#define TWCY_URUGUAY        598
+#define TWCY_VANUATU       1041
+#define TWCY_VATICANCITY     39
+#define TWCY_VENEZUELA       58
+#define TWCY_WAKE          1042
+#define TWCY_WALLISIS      1043
+#define TWCY_WESTERNSAHARA 1044
+#define TWCY_WESTERNSAMOA  1045
+#define TWCY_YEMEN         1046
+#define TWCY_YUGOSLAVIA      38
+#define TWCY_ZAIRE          243
+#define TWCY_ZAMBIA         260
+#define TWCY_ZIMBABWE       263
+/* Added for 1.8 */
+#define TWCY_ALBANIA        355
+#define TWCY_ARMENIA        374
+#define TWCY_AZERBAIJAN     994
+#define TWCY_BELARUS        375
+#define TWCY_BOSNIAHERZGO   387
+#define TWCY_CAMBODIA       855
+#define TWCY_CROATIA        385
+#define TWCY_CZECHREPUBLIC  420
+#define TWCY_DIEGOGARCIA    246
+#define TWCY_ERITREA        291
+#define TWCY_ESTONIA        372
+#define TWCY_GEORGIA        995
+#define TWCY_LATVIA         371
+#define TWCY_LESOTHO        266
+#define TWCY_LITHUANIA      370
+#define TWCY_MACEDONIA      389
+#define TWCY_MAYOTTEIS      269
+#define TWCY_MOLDOVA        373
+#define TWCY_MYANMAR        95
+#define TWCY_NORTHKOREA     850
+#define TWCY_PUERTORICO     787
+#define TWCY_RUSSIA         7
+#define TWCY_SERBIA         381
+#define TWCY_SLOVAKIA       421
+#define TWCY_SLOVENIA       386
+#define TWCY_SOUTHKOREA     82
+#define TWCY_UKRAINE        380
+#define TWCY_USVIRGINIS     340
+#define TWCY_VIETNAM        84
+
+/****************************************************************************
+ * Language Constants                                                       *
+ ****************************************************************************/
+
+#define TWLG_DAN              0 /* Danish                 */
+#define TWLG_DUT              1 /* Dutch                  */
+#define TWLG_ENG              2 /* International English  */
+#define TWLG_FCF              3 /* French Canadian        */
+#define TWLG_FIN              4 /* Finnish                */
+#define TWLG_FRN              5 /* French                 */
+#define TWLG_GER              6 /* German                 */
+#define TWLG_ICE              7 /* Icelandic              */
+#define TWLG_ITN              8 /* Italian                */
+#define TWLG_NOR              9 /* Norwegian              */
+#define TWLG_POR             10 /* Portuguese             */
+#define TWLG_SPA             11 /* Spanish                */
+#define TWLG_SWE             12 /* Swedish                */
+#define TWLG_USA             13 /* U.S. English           */
+/* Added for 1.8 */
+#define TWLG_USERLOCALE           -1
+#define TWLG_AFRIKAANS            14  
+#define TWLG_ALBANIA              15
+#define TWLG_ARABIC               16
+#define TWLG_ARABIC_ALGERIA       17
+#define TWLG_ARABIC_BAHRAIN       18
+#define TWLG_ARABIC_EGYPT         19
+#define TWLG_ARABIC_IRAQ          20
+#define TWLG_ARABIC_JORDAN        21
+#define TWLG_ARABIC_KUWAIT        22
+#define TWLG_ARABIC_LEBANON       23
+#define TWLG_ARABIC_LIBYA         24
+#define TWLG_ARABIC_MOROCCO       25
+#define TWLG_ARABIC_OMAN          26
+#define TWLG_ARABIC_QATAR         27
+#define TWLG_ARABIC_SAUDIARABIA   28
+#define TWLG_ARABIC_SYRIA         29
+#define TWLG_ARABIC_TUNISIA       30
+#define TWLG_ARABIC_UAE           31 /* United Arabic Emirates */
+#define TWLG_ARABIC_YEMEN         32
+#define TWLG_BASQUE               33
+#define TWLG_BYELORUSSIAN         34
+#define TWLG_BULGARIAN            35
+#define TWLG_CATALAN              36
+#define TWLG_CHINESE              37
+#define TWLG_CHINESE_HONGKONG     38
+#define TWLG_CHINESE_PRC          39 /* People's Republic of China */
+#define TWLG_CHINESE_SINGAPORE    40
+#define TWLG_CHINESE_SIMPLIFIED   41
+#define TWLG_CHINESE_TAIWAN       42
+#define TWLG_CHINESE_TRADITIONAL  43
+#define TWLG_CROATIA              44
+#define TWLG_CZECH                45
+#define TWLG_DANISH               TWLG_DAN
+#define TWLG_DUTCH                TWLG_DUT
+#define TWLG_DUTCH_BELGIAN        46
+#define TWLG_ENGLISH              TWLG_ENG
+#define TWLG_ENGLISH_AUSTRALIAN   47
+#define TWLG_ENGLISH_CANADIAN     48
+#define TWLG_ENGLISH_IRELAND      49
+#define TWLG_ENGLISH_NEWZEALAND   50
+#define TWLG_ENGLISH_SOUTHAFRICA  51
+#define TWLG_ENGLISH_UK           52
+#define TWLG_ENGLISH_USA          TWLG_USA
+#define TWLG_ESTONIAN             53
+#define TWLG_FAEROESE             54
+#define TWLG_FARSI                55
+#define TWLG_FINNISH              TWLG_FIN
+#define TWLG_FRENCH               TWLG_FRN
+#define TWLG_FRENCH_BELGIAN       56
+#define TWLG_FRENCH_CANADIAN      TWLG_FCF
+#define TWLG_FRENCH_LUXEMBOURG    57
+#define TWLG_FRENCH_SWISS         58
+#define TWLG_GERMAN               TWLG_GER
+#define TWLG_GERMAN_AUSTRIAN      59
+#define TWLG_GERMAN_LUXEMBOURG    60
+#define TWLG_GERMAN_LIECHTENSTEIN 61
+#define TWLG_GERMAN_SWISS         62
+#define TWLG_GREEK                63
+#define TWLG_HEBREW               64
+#define TWLG_HUNGARIAN            65
+#define TWLG_ICELANDIC            TWLG_ICE
+#define TWLG_INDONESIAN           66
+#define TWLG_ITALIAN              TWLG_ITN
+#define TWLG_ITALIAN_SWISS        67
+#define TWLG_JAPANESE             68
+#define TWLG_KOREAN               69
+#define TWLG_KOREAN_JOHAB         70
+#define TWLG_LATVIAN              71
+#define TWLG_LITHUANIAN           72
+#define TWLG_NORWEGIAN            TWLG_NOR
+#define TWLG_NORWEGIAN_BOKMAL     73
+#define TWLG_NORWEGIAN_NYNORSK    74
+#define TWLG_POLISH               75
+#define TWLG_PORTUGUESE           TWLG_POR
+#define TWLG_PORTUGUESE_BRAZIL    76
+#define TWLG_ROMANIAN             77
+#define TWLG_RUSSIAN              78
+#define TWLG_SERBIAN_LATIN        79
+#define TWLG_SLOVAK               80
+#define TWLG_SLOVENIAN            81
+#define TWLG_SPANISH              TWLG_SPA
+#define TWLG_SPANISH_MEXICAN      82
+#define TWLG_SPANISH_MODERN       83
+#define TWLG_SWEDISH              TWLG_SWE
+#define TWLG_THAI                 84
+#define TWLG_TURKISH              85
+#define TWLG_UKRANIAN             86
+/* More stuff added for 1.8 */
+#define TWLG_ASSAMESE             87
+#define TWLG_BENGALI              88
+#define TWLG_BIHARI               89
+#define TWLG_BODO                 90
+#define TWLG_DOGRI                91
+#define TWLG_GUJARATI             92
+#define TWLG_HARYANVI             93
+#define TWLG_HINDI                94
+#define TWLG_KANNADA              95
+#define TWLG_KASHMIRI             96
+#define TWLG_MALAYALAM            97
+#define TWLG_MARATHI              98
+#define TWLG_MARWARI              99
+#define TWLG_MEGHALAYAN          100
+#define TWLG_MIZO                101
+#define TWLG_NAGA                102
+#define TWLG_ORISSI              103
+#define TWLG_PUNJABI             104
+#define TWLG_PUSHTU              105
+#define TWLG_SERBIAN_CYRILLIC    106
+#define TWLG_SIKKIMI             107
+#define TWLG_SWEDISH_FINLAND     108
+#define TWLG_TAMIL               109
+#define TWLG_TELUGU              110
+#define TWLG_TRIPURI             111
+#define TWLG_URDU                112
+#define TWLG_VIETNAMESE          113
+
+/****************************************************************************
+ * Data Groups                                                              *
+ ****************************************************************************/
+
+/* More Data Groups may be added in the future.
+ * Possible candidates include text, vector graphics, sound, etc.
+ * NOTE: Data Group constants must be powers of 2 as they are used
+ *       as bitflags when Application asks DSM to present a list of DSs.
+ */
+
+#define DG_CONTROL          0x0001L /* data pertaining to control       */
+#define DG_IMAGE            0x0002L /* data pertaining to raster images */
+/* Added 1.8 */
+#define DG_AUDIO            0x0004L /* data pertaining to audio */
+
+/****************************************************************************
+ * Data Argument Types                                                      *
+ ****************************************************************************/
+
+/*  SDH - 03/23/95 - WATCH                                                  */
+/*  The thunker requires knowledge about size of data being passed in the   */
+/*  lpData parameter to DS_Entry (which is not readily available due to     */
+/*  type LPVOID.  Thus, we key off the DAT_ argument to determine the size. */
+/*  This has a couple implications:                                         */
+/*  1) Any additional DAT_ features require modifications to the thunk code */
+/*     for thunker support.                                                 */
+/*  2) Any applications which use the custom capabailites are not supported */
+/*     under thunking since we have no way of knowing what size data (if    */
+/*     any) is being passed.                                                */
+
+#define DAT_NULL            0x0000 /* No data or structure. */
+#define DAT_CUSTOMBASE      0x8000 /* Base of custom DATs.  */
+
+/* Data Argument Types for the DG_CONTROL Data Group. */
+#define DAT_CAPABILITY      0x0001 /* TW_CAPABILITY                        */
+#define DAT_EVENT           0x0002 /* TW_EVENT                             */
+#define DAT_IDENTITY        0x0003 /* TW_IDENTITY                          */
+#define DAT_PARENT          0x0004 /* TW_HANDLE, application win handle in Windows */
+#define DAT_PENDINGXFERS    0x0005 /* TW_PENDINGXFERS                      */
+#define DAT_SETUPMEMXFER    0x0006 /* TW_SETUPMEMXFER                      */
+#define DAT_SETUPFILEXFER   0x0007 /* TW_SETUPFILEXFER                     */
+#define DAT_STATUS          0x0008 /* TW_STATUS                            */
+#define DAT_USERINTERFACE   0x0009 /* TW_USERINTERFACE                     */
+#define DAT_XFERGROUP       0x000a /* TW_UINT32                            */
+/*  SDH - 03/21/95 - TWUNK                                         */
+/*  Additional message required for thunker to request the special */
+/*  identity information.                                          */
+#define DAT_TWUNKIDENTITY   0x000b /* TW_TWUNKIDENTITY                     */
+#define DAT_CUSTOMDSDATA    0x000c /* TW_CUSTOMDSDATA.                     */
+/* Added 1.8 */
+#define DAT_DEVICEEVENT     0x000d /* TW_DEVICEEVENT                       */
+#define DAT_FILESYSTEM      0x000e /* TW_FILESYSTEM                        */
+#define DAT_PASSTHRU        0x000f /* TW_PASSTHRU                          */
+
+/* Data Argument Types for the DG_IMAGE Data Group. */
+#define DAT_IMAGEINFO       0x0101 /* TW_IMAGEINFO                         */
+#define DAT_IMAGELAYOUT     0x0102 /* TW_IMAGELAYOUT                       */
+#define DAT_IMAGEMEMXFER    0x0103 /* TW_IMAGEMEMXFER                      */
+#define DAT_IMAGENATIVEXFER 0x0104 /* TW_UINT32 loword is hDIB, PICHandle  */
+#define DAT_IMAGEFILEXFER   0x0105 /* Null data                            */
+#define DAT_CIECOLOR        0x0106 /* TW_CIECOLOR                          */
+#define DAT_GRAYRESPONSE    0x0107 /* TW_GRAYRESPONSE                      */
+#define DAT_RGBRESPONSE     0x0108 /* TW_RGBRESPONSE                       */
+#define DAT_JPEGCOMPRESSION 0x0109 /* TW_JPEGCOMPRESSION                   */
+#define DAT_PALETTE8        0x010a /* TW_PALETTE8                          */
+#define DAT_EXTIMAGEINFO    0x010b /* TW_EXTIMAGEINFO -- for 1.7 Spec.     */
+
+/* Added 1.8 */
+/* Data Argument Types for the DG_AUDIO Data Group. */
+#define DAT_AUDIOFILEXFER   0x0201 /* Null data                            */
+#define DAT_AUDIOINFO       0x0202 /* TW_AUDIOINFO                         */
+#define DAT_AUDIONATIVEXFER 0x0203 /* TW_UINT32 handle to WAV, (AIFF Mac)  */
+
+/****************************************************************************
+ * Messages                                                                 *
+ ****************************************************************************/
+
+/* All message constants are unique.
+ * Messages are grouped according to which DATs they are used with.*/
+
+#define MSG_NULL         0x0000 /* Used in TW_EVENT structure               */
+#define MSG_CUSTOMBASE   0x8000 /* Base of custom messages                  */
+
+/* Generic messages may be used with any of several DATs.                   */
+#define MSG_GET          0x0001 /* Get one or more values                   */
+#define MSG_GETCURRENT   0x0002 /* Get current value                        */
+#define MSG_GETDEFAULT   0x0003 /* Get default (e.g. power up) value        */
+#define MSG_GETFIRST     0x0004 /* Get first of a series of items, e.g. DSs */
+#define MSG_GETNEXT      0x0005 /* Iterate through a series of items.       */
+#define MSG_SET          0x0006 /* Set one or more values                   */
+#define MSG_RESET        0x0007 /* Set current value to default value       */
+#define MSG_QUERYSUPPORT 0x0008 /* Get supported operations on the cap.     */
+
+/* Messages used with DAT_NULL                                              */
+#define MSG_XFERREADY    0x0101 /* The data source has data ready           */
+#define MSG_CLOSEDSREQ   0x0102 /* Request for Application. to close DS             */
+#define MSG_CLOSEDSOK    0x0103 /* Tell the Application. to save the state.         */
+/* Added 1.8 */
+#define MSG_DEVICEEVENT  0X0104 /* Some event has taken place               */
+
+/* Messages used with a pointer to a DAT_STATUS structure                   */
+#define MSG_CHECKSTATUS  0x0201 /* Get status information                   */
+
+/* Messages used with a pointer to DAT_PARENT data                          */
+#define MSG_OPENDSM      0x0301 /* Open the DSM                             */
+#define MSG_CLOSEDSM     0x0302 /* Close the DSM                            */
+
+/* Messages used with a pointer to a DAT_IDENTITY structure                 */
+#define MSG_OPENDS       0x0401 /* Open a data source                       */
+#define MSG_CLOSEDS      0x0402 /* Close a data source                      */
+#define MSG_USERSELECT   0x0403 /* Put up a dialog of all DS                */
+
+/* Messages used with a pointer to a DAT_USERINTERFACE structure            */
+#define MSG_DISABLEDS    0x0501 /* Disable data transfer in the DS          */
+#define MSG_ENABLEDS     0x0502 /* Enable data transfer in the DS           */
+#define MSG_ENABLEDSUIONLY  0x0503  /* Enable for saving DS state only.     */
+
+/* Messages used with a pointer to a DAT_EVENT structure                    */
+#define MSG_PROCESSEVENT 0x0601
+
+/* Messages used with a pointer to a DAT_PENDINGXFERS structure             */
+#define MSG_ENDXFER      0x0701
+
+/* Added 1.8 */
+/* Messages used with a pointer to a DAT_FILESYSTEM structure               */
+#define MSG_CHANGEDIRECTORY   0x0801
+#define MSG_CREATEDIRECTORY   0x0802
+#define MSG_DELETE            0x0803
+#define MSG_FORMATMEDIA       0x0804 
+#define MSG_GETCLOSE          0x0805
+#define MSG_GETFIRSTFILE      0x0806
+#define MSG_GETINFO           0x0807
+#define MSG_GETNEXTFILE       0x0808
+#define MSG_RENAME            0x0809
+
+/* Messages used with a pointer to a DAT_PASSTHRU structure                 */
+#define MSG_PASSTHRU          0x0901
+
+/****************************************************************************
+ * Capabilities                                                             *
+ ****************************************************************************/
+
+#define CAP_CUSTOMBASE          0x8000 /* Base of custom capabilities */
+
+/* all data sources are REQUIRED to support these caps */
+#define CAP_XFERCOUNT           0x0001
+
+/* image data sources are REQUIRED to support these caps */
+#define ICAP_COMPRESSION        0x0100
+#define ICAP_PIXELTYPE          0x0101
+#define ICAP_UNITS              0x0102 /* default is TWUN_INCHES */
+#define ICAP_XFERMECH           0x0103
+
+/* all data sources MAY support these caps */
+#define CAP_AUTHOR                  0x1000
+#define CAP_CAPTION                 0x1001
+#define CAP_FEEDERENABLED           0x1002
+#define CAP_FEEDERLOADED            0x1003
+#define CAP_TIMEDATE                0x1004
+#define CAP_SUPPORTEDCAPS           0x1005
+#define CAP_EXTENDEDCAPS            0x1006
+#define CAP_AUTOFEED                0x1007
+#define CAP_CLEARPAGE               0x1008
+#define CAP_FEEDPAGE                0x1009
+#define CAP_REWINDPAGE              0x100a
+#define CAP_INDICATORS              0x100b   /* Added 1.1 */
+#define CAP_SUPPORTEDCAPSEXT        0x100c   /* Added 1.6 */
+#define CAP_PAPERDETECTABLE         0x100d   /* Added 1.6 */
+#define CAP_UICONTROLLABLE          0x100e   /* Added 1.6 */
+#define CAP_DEVICEONLINE            0x100f   /* Added 1.6 */
+#define CAP_AUTOSCAN                0x1010   /* Added 1.6 */
+#define CAP_THUMBNAILSENABLED       0x1011   /* Added 1.7 */
+#define CAP_DUPLEX                  0x1012   /* Added 1.7 */
+#define CAP_DUPLEXENABLED           0x1013   /* Added 1.7 */
+#define CAP_ENABLEDSUIONLY          0x1014   /* Added 1.7 */
+#define CAP_CUSTOMDSDATA            0x1015   /* Added 1.7 */
+#define CAP_ENDORSER                0x1016   /* Added 1.7 */
+#define CAP_JOBCONTROL              0x1017   /* Added 1.7 */
+#define CAP_ALARMS                  0x1018   /* Added 1.8 */
+#define CAP_ALARMVOLUME             0x1019   /* Added 1.8 */
+#define CAP_AUTOMATICCAPTURE        0x101a   /* Added 1.8 */
+#define CAP_TIMEBEFOREFIRSTCAPTURE  0x101b   /* Added 1.8 */
+#define CAP_TIMEBETWEENCAPTURES     0x101c   /* Added 1.8 */
+#define CAP_CLEARBUFFERS            0x101d   /* Added 1.8 */
+#define CAP_MAXBATCHBUFFERS         0x101e   /* Added 1.8 */
+#define CAP_DEVICETIMEDATE          0x101f   /* Added 1.8 */
+#define CAP_POWERSUPPLY             0x1020   /* Added 1.8 */
+#define CAP_CAMERAPREVIEWUI         0x1021   /* Added 1.8 */
+#define CAP_DEVICEEVENT             0x1022   /* Added 1.8 */
+#define CAP_PAGEMULTIPLEACQUIRE     0x1023   /* Added 1.8 */
+#define CAP_SERIALNUMBER            0x1024   /* Added 1.8 */
+#define CAP_FILESYSTEM              0x1025   /* Added 1.8 */
+#define CAP_PRINTER                 0x1026   /* Added 1.8 */
+#define CAP_PRINTERENABLED          0x1027   /* Added 1.8 */
+#define CAP_PRINTERINDEX            0x1028   /* Added 1.8 */
+#define CAP_PRINTERMODE             0x1029   /* Added 1.8 */
+#define CAP_PRINTERSTRING           0x102a   /* Added 1.8 */
+#define CAP_PRINTERSUFFIX           0x102b   /* Added 1.8 */
+#define CAP_LANGUAGE                0x102c   /* Added 1.8 */
+#define CAP_FEEDERALIGNMENT         0x102d   /* Added 1.8 */
+#define CAP_FEEDERORDER             0x102e   /* Added 1.8 */
+#define CAP_PAPERBINDING            0x102f   /* Added 1.8 */
+#define CAP_REACQUIREALLOWED        0x1030   /* Added 1.8 */
+#define CAP_PASSTHRU                0x1031   /* Added 1.8 */
+#define CAP_BATTERYMINUTES          0x1032   /* Added 1.8 */
+#define CAP_BATTERYPERCENTAGE       0x1033   /* Added 1.8 */
+#define CAP_POWERDOWNTIME           0x1034   /* Added 1.8 */
+ 
+/* image data sources MAY support these caps */
+#define ICAP_AUTOBRIGHT                   0x1100
+#define ICAP_BRIGHTNESS                   0x1101
+#define ICAP_CONTRAST                     0x1103
+#define ICAP_CUSTHALFTONE                 0x1104
+#define ICAP_EXPOSURETIME                 0x1105
+#define ICAP_FILTER                       0x1106
+#define ICAP_FLASHUSED                    0x1107
+#define ICAP_GAMMA                        0x1108
+#define ICAP_HALFTONES                    0x1109
+#define ICAP_HIGHLIGHT                    0x110a
+#define ICAP_IMAGEFILEFORMAT              0x110c
+#define ICAP_LAMPSTATE                    0x110d
+#define ICAP_LIGHTSOURCE                  0x110e
+#define ICAP_ORIENTATION                  0x1110
+#define ICAP_PHYSICALWIDTH                0x1111
+#define ICAP_PHYSICALHEIGHT               0x1112
+#define ICAP_SHADOW                       0x1113
+#define ICAP_FRAMES                       0x1114
+#define ICAP_XNATIVERESOLUTION            0x1116
+#define ICAP_YNATIVERESOLUTION            0x1117
+#define ICAP_XRESOLUTION                  0x1118
+#define ICAP_YRESOLUTION                  0x1119
+#define ICAP_MAXFRAMES                    0x111a
+#define ICAP_TILES                        0x111b
+#define ICAP_BITORDER                     0x111c
+#define ICAP_CCITTKFACTOR                 0x111d
+#define ICAP_LIGHTPATH                    0x111e
+#define ICAP_PIXELFLAVOR                  0x111f
+#define ICAP_PLANARCHUNKY                 0x1120
+#define ICAP_ROTATION                     0x1121
+#define ICAP_SUPPORTEDSIZES               0x1122
+#define ICAP_THRESHOLD                    0x1123
+#define ICAP_XSCALING                     0x1124
+#define ICAP_YSCALING                     0x1125
+#define ICAP_BITORDERCODES                0x1126
+#define ICAP_PIXELFLAVORCODES             0x1127
+#define ICAP_JPEGPIXELTYPE                0x1128
+#define ICAP_TIMEFILL                     0x112a
+#define ICAP_BITDEPTH                     0x112b
+#define ICAP_BITDEPTHREDUCTION            0x112c  /* Added 1.5 */
+#define ICAP_UNDEFINEDIMAGESIZE           0x112d  /* Added 1.6 */
+#define ICAP_IMAGEDATASET                 0x112e  /* Added 1.7 */
+#define ICAP_EXTIMAGEINFO                 0x112f  /* Added 1.7 */
+#define ICAP_MINIMUMHEIGHT                0x1130  /* Added 1.7 */
+#define ICAP_MINIMUMWIDTH                 0x1131  /* Added 1.7 */
+#define ICAP_AUTODISCARDBLANKPAGES        0x1134  /* Added 1.8 */
+#define ICAP_FLIPROTATION                 0x1136  /* Added 1.8 */
+#define ICAP_BARCODEDETECTIONENABLED      0x1137  /* Added 1.8 */
+#define ICAP_SUPPORTEDBARCODETYPES        0x1138  /* Added 1.8 */
+#define ICAP_BARCODEMAXSEARCHPRIORITIES   0x1139  /* Added 1.8 */
+#define ICAP_BARCODESEARCHPRIORITIES      0x113a  /* Added 1.8 */
+#define ICAP_BARCODESEARCHMODE            0x113b  /* Added 1.8 */
+#define ICAP_BARCODEMAXRETRIES            0x113c  /* Added 1.8 */
+#define ICAP_BARCODETIMEOUT               0x113d  /* Added 1.8 */
+#define ICAP_ZOOMFACTOR                   0x113e  /* Added 1.8 */
+#define ICAP_PATCHCODEDETECTIONENABLED    0x113f  /* Added 1.8 */
+#define ICAP_SUPPORTEDPATCHCODETYPES      0x1140  /* Added 1.8 */
+#define ICAP_PATCHCODEMAXSEARCHPRIORITIES 0x1141  /* Added 1.8 */
+#define ICAP_PATCHCODESEARCHPRIORITIES    0x1142  /* Added 1.8 */
+#define ICAP_PATCHCODESEARCHMODE          0x1143  /* Added 1.8 */
+#define ICAP_PATCHCODEMAXRETRIES          0x1144  /* Added 1.8 */
+#define ICAP_PATCHCODETIMEOUT             0x1145  /* Added 1.8 */
+#define ICAP_FLASHUSED2                   0x1146  /* Added 1.8 */
+#define ICAP_IMAGEFILTER                  0x1147  /* Added 1.8 */
+#define ICAP_NOISEFILTER                  0x1148  /* Added 1.8 */
+#define ICAP_OVERSCAN                     0x1149  /* Added 1.8 */
+#define ICAP_AUTOMATICBORDERDETECTION     0x1150  /* Added 1.8 */
+#define ICAP_AUTOMATICDESKEW              0x1151  /* Added 1.8 */
+#define ICAP_AUTOMATICROTATE              0x1152  /* Added 1.8 */
+
+/* image data sources MAY support these audio caps */
+#define ACAP_AUDIOFILEFORMAT    0x1201  /* Added 1.8 */
+#define ACAP_XFERMECH           0x1202  /* Added 1.8 */
+
+/* ----------------------------------------------------------------------- *\
+
+  Version 1.7:      Following is Extended Image Info Attributes.
+  July 1997         
+  KHL               
+
+\* ----------------------------------------------------------------------- */
+
+#define TWEI_BARCODEX               0x1200
+#define TWEI_BARCODEY               0x1201
+#define TWEI_BARCODETEXT            0x1202
+#define TWEI_BARCODETYPE            0x1203
+#define TWEI_DESHADETOP             0x1204
+#define TWEI_DESHADELEFT            0x1205
+#define TWEI_DESHADEHEIGHT          0x1206
+#define TWEI_DESHADEWIDTH           0x1207
+#define TWEI_DESHADESIZE            0x1208
+#define TWEI_SPECKLESREMOVED        0x1209
+#define TWEI_HORZLINEXCOORD         0x120A
+#define TWEI_HORZLINEYCOORD         0x120B
+#define TWEI_HORZLINELENGTH         0x120C
+#define TWEI_HORZLINETHICKNESS      0x120D
+#define TWEI_VERTLINEXCOORD         0x120E
+#define TWEI_VERTLINEYCOORD         0x120F
+#define TWEI_VERTLINELENGTH         0x1210
+#define TWEI_VERTLINETHICKNESS      0x1211
+#define TWEI_PATCHCODE              0x1212
+#define TWEI_ENDORSEDTEXT           0x1213
+#define TWEI_FORMCONFIDENCE         0x1214
+#define TWEI_FORMTEMPLATEMATCH      0x1215
+#define TWEI_FORMTEMPLATEPAGEMATCH  0x1216
+#define TWEI_FORMHORZDOCOFFSET      0x1217
+#define TWEI_FORMVERTDOCOFFSET      0x1218
+#define TWEI_BARCODECOUNT           0x1219
+#define TWEI_BARCODECONFIDENCE      0x121A
+#define TWEI_BARCODEROTATION        0x121B
+#define TWEI_BARCODETEXTLENGTH      0x121C
+#define TWEI_DESHADECOUNT           0x121D
+#define TWEI_DESHADEBLACKCOUNTOLD   0x121E
+#define TWEI_DESHADEBLACKCOUNTNEW   0x121F
+#define TWEI_DESHADEBLACKRLMIN      0x1220
+#define TWEI_DESHADEBLACKRLMAX      0x1221
+#define TWEI_DESHADEWHITECOUNTOLD   0x1222
+#define TWEI_DESHADEWHITECOUNTNEW   0x1223
+#define TWEI_DESHADEWHITERLMIN      0x1224
+#define TWEI_DESHADEWHITERLAVE      0x1225
+#define TWEI_DESHADEWHITERLMAX      0x1226
+#define TWEI_BLACKSPECKLESREMOVED   0x1227
+#define TWEI_WHITESPECKLESREMOVED   0x1228
+#define TWEI_HORZLINECOUNT          0x1229
+#define TWEI_VERTLINECOUNT          0x122A
+#define TWEI_DESKEWSTATUS           0x122B
+#define TWEI_SKEWORIGINALANGLE      0x122C
+#define TWEI_SKEWFINALANGLE         0x122D
+#define TWEI_SKEWCONFIDENCE         0x122E
+#define TWEI_SKEWWINDOWX1           0x122F
+#define TWEI_SKEWWINDOWY1           0x1230
+#define TWEI_SKEWWINDOWX2           0x1231
+#define TWEI_SKEWWINDOWY2           0x1232
+#define TWEI_SKEWWINDOWX3           0x1233
+#define TWEI_SKEWWINDOWY3           0x1234
+#define TWEI_SKEWWINDOWX4           0x1235
+#define TWEI_SKEWWINDOWY4           0x1236
+
+#define TWEJ_NONE                   0x0000
+#define TWEJ_MIDSEPARATOR           0x0001
+#define TWEJ_PATCH1                 0x0002
+#define TWEJ_PATCH2                 0x0003
+#define TWEJ_PATCH3                 0x0004
+#define TWEJ_PATCH4                 0x0005
+#define TWEJ_PATCH6                 0x0006
+#define TWEJ_PATCHT                 0x0007
+
+/***************************************************************************
+ *            Return Codes and Condition Codes section                     *
+ ***************************************************************************/
+
+/* Return Codes: DSM_Entry and DS_Entry may return any one of these values. */
+#define TWRC_CUSTOMBASE     0x8000
+
+#define TWRC_SUCCESS          0
+#define TWRC_FAILURE          1 /* Application may get TW_STATUS for info on failure */
+#define TWRC_CHECKSTATUS      2 /* "tried hard"; get status                  */
+#define TWRC_CANCEL           3
+#define TWRC_DSEVENT          4
+#define TWRC_NOTDSEVENT       5
+#define TWRC_XFERDONE         6
+#define TWRC_ENDOFLIST        7 /* After MSG_GETNEXT if nothing left         */
+#define TWRC_INFONOTSUPPORTED 8
+#define TWRC_DATANOTAVAILABLE 9
+
+/* Condition Codes: Application gets these by doing DG_CONTROL DAT_STATUS MSG_GET.  */
+#define TWCC_CUSTOMBASE         0x8000
+
+#define TWCC_SUCCESS            0 /* It worked!                                */
+#define TWCC_BUMMER             1 /* Failure due to unknown causes             */
+#define TWCC_LOWMEMORY          2 /* Not enough memory to perform operation    */
+#define TWCC_NODS               3 /* No Data Source                            */
+#define TWCC_MAXCONNECTIONS     4 /* DS is connected to max possible applications      */
+#define TWCC_OPERATIONERROR     5 /* DS or DSM reported error, application shouldn't   */
+#define TWCC_BADCAP             6 /* Unknown capability                        */
+#define TWCC_BADPROTOCOL        9 /* Unrecognized MSG DG DAT combination       */
+#define TWCC_BADVALUE           10 /* Data parameter out of range              */
+#define TWCC_SEQERROR           11 /* DG DAT MSG out of expected sequence      */
+#define TWCC_BADDEST            12 /* Unknown destination Application/Source in DSM_Entry */
+#define TWCC_CAPUNSUPPORTED     13 /* Capability not supported by source            */
+#define TWCC_CAPBADOPERATION    14 /* Operation not supported by capability         */
+#define TWCC_CAPSEQERROR        15 /* Capability has dependancy on other capability */
+/* Added 1.8 */
+#define TWCC_DENIED             16 /* File System operation is denied (file is protected) */
+#define TWCC_FILEEXISTS         17 /* Operation failed because file already exists. */
+#define TWCC_FILENOTFOUND       18 /* File not found */
+#define TWCC_NOTEMPTY           19 /* Operation failed because directory is not empty */
+#define TWCC_PAPERJAM           20  /* The feeder is jammed */
+#define TWCC_PAPERDOUBLEFEED    21  /* The feeder detected multiple pages */
+#define TWCC_FILEWRITEERROR     22  /* Error writing the file (meant for things like disk full conditions) */
+#define TWCC_CHECKDEVICEONLINE  23  /* The device went offline prior to or during this operation */
+
+
+/* bit patterns: for query the operation that are supported by the data source on a capability */
+/* Application gets these through DG_CONTROL/DAT_CAPABILITY/MSG_QUERYSUPPORT */
+/* Added 1.6 */
+#define TWQC_GET           0x0001 
+#define TWQC_SET           0x0002
+#define TWQC_GETDEFAULT    0x0004
+#define TWQC_GETCURRENT    0x0008
+#define TWQC_RESET         0x0010
+
+
+/****************************************************************************
+ * Entry Points                                                             *
+ ****************************************************************************/
+
+/**********************************************************************
+ * Function: DSM_Entry, the only entry point into the Data Source Manager.
+ *
+ * Parameters:
+ *  pOrigin Identifies the source module of the message. This could
+ *          identify an Application, a Source, or the Source Manager.
+ *
+ *  pDest   Identifies the destination module for the message.
+ *          This could identify an application or a data source.
+ *          If this is NULL, the message goes to the Source Manager.
+ *
+ *  DG      The Data Group. 
+ *          Example: DG_IMAGE.
+ *
+ *  DAT     The Data Attribute Type.
+ *          Example: DAT_IMAGEMEMXFER.
+ *    
+ *  MSG     The message.  Messages are interpreted by the destination module
+ *          with respect to the Data Group and the Data Attribute Type.  
+ *          Example: MSG_GET.
+ *
+ *  pData   A pointer to the data structure or variable identified 
+ *          by the Data Attribute Type.
+ *          Example: (TW_MEMREF)&ImageMemXfer
+ *                   where ImageMemXfer is a TW_IMAGEMEMXFER structure.
+ *                    
+ * Returns:
+ *  ReturnCode
+ *         Example: TWRC_SUCCESS.
+ *
+ ********************************************************************/
+
+/* Don't mangle the name "DSM_Entry" if we're compiling in C++! */
+#ifdef  __cplusplus
+extern "C" {
+#endif  /* __cplusplus */
+
+#ifdef  _MSWIN_
+TW_UINT16 FAR PASCAL DSM_Entry( pTW_IDENTITY pOrigin,
+                                pTW_IDENTITY pDest,
+                                TW_UINT32    DG,
+                                TW_UINT16    DAT,
+                                TW_UINT16    MSG,
+                                TW_MEMREF    pData);
+
+typedef TW_UINT16 (FAR PASCAL *DSMENTRYPROC)(pTW_IDENTITY, pTW_IDENTITY,
+                                             TW_UINT32,    TW_UINT16,
+                                             TW_UINT16,    TW_MEMREF);
+#else   /* _MSWIN_ */
+
+/*FAR PASCAL TW_UINT16 DSM_Entry( pTW_IDENTITY pOrigin,
+                                pTW_IDENTITY pDest,
+                                TW_UINT32    DG,
+                                TW_UINT16    DAT,
+                                TW_UINT16    MSG,
+                                TW_MEMREF    pData);*/
+
+typedef TW_UINT16 (*DSMENTRYPROC)(pTW_IDENTITY, pTW_IDENTITY,
+                                  TW_UINT32,    TW_UINT16,
+                                  TW_UINT16,    TW_MEMREF);
+#endif  /* _MSWIN_ */
+
+#ifdef  __cplusplus
+}
+#endif  /* cplusplus */
+
+
+/**********************************************************************
+ * Function: DS_Entry, the entry point provided by a Data Source.
+ *
+ * Parameters:
+ *  pOrigin Identifies the source module of the message. This could
+ *          identify an application or the Data Source Manager.
+ *
+ *  DG      The Data Group. 
+ *          Example: DG_IMAGE.
+ *           
+ *  DAT     The Data Attribute Type.
+ *          Example: DAT_IMAGEMEMXFER.
+ *    
+ *  MSG     The message.  Messages are interpreted by the data source
+ *          with respect to the Data Group and the Data Attribute Type.
+ *          Example: MSG_GET.
+ *
+ *  pData   A pointer to the data structure or variable identified 
+ *          by the Data Attribute Type.
+ *          Example: (TW_MEMREF)&ImageMemXfer
+ *                   where ImageMemXfer is a TW_IMAGEMEMXFER structure.
+ *                    
+ * Returns:
+ *  ReturnCode
+ *          Example: TWRC_SUCCESS.
+ *
+ * Note:
+ *  The DSPROC type is only used by an application when it calls
+ *  a Data Source directly, bypassing the Data Source Manager.
+ *
+ ********************************************************************/
+/* Don't mangle the name "DS_Entry" if we're compiling in C++! */
+#ifdef  __cplusplus
+extern "C" {
+#endif  /* __cplusplus */
+#ifdef  _MSWIN_
+  #ifdef _WIN32
+     __declspec(dllexport) TW_UINT16 FAR PASCAL DS_Entry (pTW_IDENTITY pOrigin,
+                                                          TW_UINT32    DG, 
+                                                          TW_UINT16    DAT, 
+                                                          TW_UINT16    MSG, 
+                                                          TW_MEMREF    pData);
+  #else   /* _WIN32 */
+     TW_UINT16 FAR PASCAL DS_Entry (pTW_IDENTITY pOrigin,
+                                    TW_UINT32    DG, 
+                                    TW_UINT16    DAT, 
+                                    TW_UINT16    MSG, 
+                                    TW_MEMREF    pData);
+  #endif  /* _WIN32 */
+  
+  typedef TW_UINT16 (FAR PASCAL *DSENTRYPROC) (pTW_IDENTITY pOrigin,
+                                               TW_UINT32    DG, 
+                                               TW_UINT16    DAT, 
+                                               TW_UINT16    MSG, 
+                                               TW_MEMREF    pData);
+#else   /* _MSWIN_ */
+/*FAR PASCAL TW_UINT16 DS_Entry( pTW_IDENTITY pOrigin, 
+                               TW_UINT32    DG, 
+                               TW_UINT16    DAT, 
+                               TW_UINT16    MSG, 
+                               TW_MEMREF    pData);*/
+
+typedef TW_UINT16 (*DSENTRYPROC)(pTW_IDENTITY,
+                                  TW_UINT32,    TW_UINT16,
+                                  TW_UINT16,    TW_MEMREF);
+#endif  /* _MSWIN_ */
+#ifdef  __cplusplus
+}
+#endif  /* cplusplus */
+
+/*  SDH - 02/08/95 - TWUNK */
+/*  Force 32-bit twain to use same packing of twain structures as existing */
+/*  16-bit twain.  This allows 16/32-bit thunking. */
+#ifdef  WIN32
+    #ifdef __BORLANDC__ //(Mentor June 13, 1996) if we're using a Borland compiler
+        #pragma option -a.  //(Mentor October 30, 1996) switch back to original alignment
+    #else   //(Mentor June 13, 1996) if NOT using a Borland compiler
+        #pragma pack (pop, before_twain)
+    #endif  //(Mentor June 13, 1996)
+#else   /* WIN32 */
+#endif  /* WIN32 */
+
+#endif  /* TWAIN */
diff --git a/dlls/twain/twain32_main.c b/dlls/twain/twain32_main.c
new file mode 100644
index 0000000..451c03a
--- /dev/null
+++ b/dlls/twain/twain32_main.c
@@ -0,0 +1,641 @@
+/*
+ * TWAIN32 functions
+ * 
+ * Copyright 2000 Shi Quan He <shiquan@cyberdude.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "windef.h"
+#include "winbase.h"
+#include "twain.h"
+#include "twain_i.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(twain);
+
+BOOL WINAPI
+TWAIN_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    TRACE("%x,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
+
+    switch (fdwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            DSM_currentState = 2;
+            break;
+
+        case DLL_THREAD_ATTACH:
+            break;
+
+        case DLL_THREAD_DETACH:
+            break;
+
+        case DLL_PROCESS_DETACH:
+            DSM_currentState = 1;
+            break;
+    }
+
+    return TRUE;
+}
+
+TW_UINT16 TWAIN_SourceManagerHandler (
+           pTW_IDENTITY pOrigin,
+           TW_UINT16   DAT,
+           TW_UINT16   MSG,
+           TW_MEMREF   pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+
+    switch (DAT)
+    {
+        case DAT_IDENTITY:
+            switch (MSG)
+            {
+                case MSG_CLOSEDS:
+                    twRC = TWAIN_CloseDS (pOrigin, pData);
+                    break;
+
+                case MSG_GETDEFAULT:
+                    twRC = TWAIN_IdentityGetDefault (pOrigin, pData);
+                    break;
+
+                case MSG_GETFIRST:
+                    twRC = TWAIN_IdentityGetFirst (pOrigin, pData);
+                    break;
+
+                case MSG_GETNEXT:
+                    twRC = TWAIN_IdentityGetNext (pOrigin, pData);
+                    break;
+
+                case MSG_OPENDS:
+                    twRC = TWAIN_OpenDS (pOrigin, pData);
+                    break;
+
+                case MSG_USERSELECT:
+                    twRC = TWAIN_UserSelect (pOrigin, pData);
+                    break;
+
+                default:
+                    /* Unrecognized operation triplet */
+                    twRC = TWRC_FAILURE;
+                    DSM_twCC = TWCC_BADPROTOCOL;
+                    WARN("unrecognized operation triplet\n");
+                    break;
+            }
+            break;
+
+        case DAT_PARENT:
+            switch (MSG)
+            {
+                case MSG_CLOSEDSM:
+                    twRC = TWAIN_CloseDSM (pOrigin, pData);
+                    break;
+
+                case MSG_OPENDSM:
+                    twRC = TWAIN_OpenDSM (pOrigin, pData);
+                    break;
+
+                default:
+                    /* Unrecognized operation triplet */
+                    twRC = TWRC_FAILURE;
+                    DSM_twCC = TWCC_BADPROTOCOL;
+                    WARN("unrecognized operation triplet\n");
+            } 
+            break;
+
+        case DAT_STATUS:
+            if (MSG == MSG_GET)
+            {
+                twRC = TWAIN_GetDSMStatus (pOrigin, pData);
+            }
+            else
+            {
+                twRC = TWRC_FAILURE;
+                DSM_twCC = TWCC_BADPROTOCOL;
+                WARN("unrecognized operation triplet\n");
+            }
+            break;
+
+        default:
+            twRC = TWRC_FAILURE;
+            DSM_twCC = TWCC_BADPROTOCOL;
+            WARN("unrecognized operation triplet\n");
+            break;
+    }
+
+    return twRC;
+}
+
+TW_UINT16 TWAIN_SourceControlHandler (
+           pTW_IDENTITY pOrigin,
+           pTW_IDENTITY pDest,
+           TW_UINT16    DAT,
+           TW_UINT16    MSG,
+           TW_MEMREF    pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+
+    switch (DAT)
+    {
+        case DAT_CAPABILITY:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_CapabilityGet (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETCURRENT:
+                    twRC = TWAIN_CapabilityGetCurrent (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETDEFAULT:
+                    twRC = TWAIN_CapabilityGetDefault (pOrigin, pDest, pData);
+                    break;
+                case MSG_QUERYSUPPORT:
+                    twRC = TWAIN_CapabilityQuerySupport (pOrigin, pDest, pData);
+                    break;
+                case MSG_RESET:
+                    twRC = TWAIN_CapabilityReset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_CapabilitySet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    WARN("unrecognized opertion triplet\n");
+            }
+            break;
+
+        case DAT_CUSTOMDSDATA:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_CustomDSDataGet (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_CustomDSDataSet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    break;
+            }
+            break;
+
+        case DAT_FILESYSTEM:
+            switch (MSG)
+            {
+                /*case MSG_AUTOMATICCAPTUREDIRECTORY:
+                    twRC = TWAIN_AutomaticCaptureDirectory
+                               (pOrigin, pDest, pData);
+                    break;*/
+                case MSG_CHANGEDIRECTORY:
+                    twRC = TWAIN_ChangeDirectory (pOrigin, pDest, pData);
+                    break;
+                /*case MSG_COPY:
+                    twRC = TWAIN_FileSystemCopy (pOrigin, pDest, pData);
+                    break;*/
+                case MSG_CREATEDIRECTORY:
+                    twRC = TWAIN_CreateDirectory (pOrigin, pDest, pData);
+                    break;
+                case MSG_DELETE:
+                    twRC = TWAIN_FileSystemDelete (pOrigin, pDest, pData);
+                    break;
+                case MSG_FORMATMEDIA:
+                    twRC = TWAIN_FormatMedia (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETCLOSE:
+                    twRC = TWAIN_FileSystemGetClose (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETFIRSTFILE:
+                    twRC = TWAIN_FileSystemGetFirstFile
+                               (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETINFO:
+                    twRC = TWAIN_FileSystemGetInfo (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETNEXTFILE:
+                    twRC = TWAIN_FileSystemGetNextFile
+                               (pOrigin, pDest, pData);
+                    break;
+                case MSG_RENAME:
+                    twRC = TWAIN_FileSystemRename (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    break;
+            }
+            break;
+
+        case DAT_EVENT:
+            if (MSG == MSG_PROCESSEVENT)
+                twRC = TWAIN_ProcessEvent (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_PASSTHRU:
+            if (MSG == MSG_PASSTHRU)
+                twRC = TWAIN_PassThrough (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_PENDINGXFERS:
+            switch (MSG)
+            {
+                case MSG_ENDXFER:
+                    twRC = TWAIN_PendingXfersEndXfer (pOrigin, pDest, pData);
+                    break;
+                case MSG_GET:
+                    twRC = TWAIN_PendingXfersGet (pOrigin, pDest, pData);
+                    break;
+                case MSG_RESET:
+                    twRC = TWAIN_PendingXfersReset (pOrigin, pDest, pData);
+                    break;
+                /*case MSG_STOPFEEDER:
+                    twRC = TWAIN_PendingXfersStopFeeder
+                               (pOrigin, pDest, pData);
+                    break;*/
+                default:
+                    twRC = TWRC_FAILURE;
+            }
+            break;
+
+        case DAT_SETUPFILEXFER:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_SetupFileXferGet (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETDEFAULT:
+                    twRC = TWAIN_SetupFileXferGetDefault
+                               (pOrigin, pDest, pData);
+                    break;
+                case MSG_RESET:
+                    twRC = TWAIN_SetupFileXferReset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_SetupFileXferSet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    break;
+            }
+            break;
+
+        /*case DAT_SETUPFILEXFER2:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_SetupFileXfer2Get (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETDEFAULT:
+                    twRC = TWAIN_SetupFileXfer2GetDefault
+                               (pOrigin, pDest, pData);
+                    break;
+                case MSG_RESET:
+                    twRC = TWAIN_SetupFileXfer2Reset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_SetupFileXfer2Set (pOrigin, pDest, pData);
+                    break;
+            }
+            break;*/
+        case DAT_SETUPMEMXFER:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_SetupMemXferGet (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_STATUS:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_GetDSStatus (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_USERINTERFACE:
+            switch (MSG)
+            {
+                case MSG_DISABLEDS:
+                    twRC = TWAIN_DisableDSUserInterface
+                               (pOrigin, pDest, pData);
+                    break;
+                case MSG_ENABLEDS:
+                    twRC = TWAIN_EnableDSUserInterface
+                               (pOrigin, pDest, pData);
+                    break;
+                case MSG_ENABLEDSUIONLY:
+                    twRC = TWAIN_EnableDSUIOnly (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    break;
+            }
+            break;
+
+        case DAT_XFERGROUP:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_XferGroupGet (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_XferGroupSet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    break;
+            }
+            break;
+
+        default:
+            twRC = TWRC_FAILURE;
+            break;
+    }
+
+    return twRC;
+}
+
+TW_UINT16 TWAIN_ControlGroupHandler (
+           pTW_IDENTITY pOrigin,
+           pTW_IDENTITY pDest,
+           TW_UINT16    DAT,
+           TW_UINT16    MSG,
+           TW_MEMREF    pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+
+    if (pDest)
+    {
+        /* This operation's destination is a source */
+        twRC = TWAIN_SourceControlHandler (pOrigin, pDest, DAT, MSG, pData);
+    }
+    else
+    {
+        /* This operation's destination is the Source Manager */
+        twRC = TWAIN_SourceManagerHandler (pOrigin, DAT, MSG, pData);
+    }
+
+    return twRC;
+}
+
+TW_UINT16 TWAIN_ImageGroupHandler (
+           pTW_IDENTITY pOrigin,
+           pTW_IDENTITY pDest,
+           TW_UINT16    DAT,
+           TW_UINT16    MSG,
+           TW_MEMREF    pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;
+
+    if (pDest == NULL)
+    {
+        DSM_twCC = TWCC_BADDEST;
+        return TWRC_FAILURE;
+    }
+
+    switch (DAT)
+    {
+        case DAT_CIECOLOR:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_CIEColorGet (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_EXTIMAGEINFO:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_ExtImageInfoGet (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_GRAYRESPONSE:
+            switch (MSG)
+            {
+                case MSG_RESET:
+                    twRC = TWAIN_GrayResponseReset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_GrayResponseSet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    DSM_twCC = TWCC_BADPROTOCOL;
+                    WARN("unrecognized operation triplet\n");
+                    break;
+            }
+            break;
+        case DAT_IMAGEFILEXFER:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_ImageFileXferGet (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_IMAGEINFO:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_ImageInfoGet (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_IMAGELAYOUT:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_ImageLayoutGet (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETDEFAULT:
+                    twRC = TWAIN_ImageLayoutGetDefault (pOrigin, pDest, pData);
+                    break;
+                case MSG_RESET:
+                    twRC = TWAIN_ImageLayoutReset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_ImageLayoutSet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    DSM_twCC = TWCC_BADPROTOCOL;
+                    WARN("unrecognized operation triplet\n");
+                    break;
+            }
+            break;
+
+        case DAT_IMAGEMEMXFER:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_ImageMemXferGet (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_IMAGENATIVEXFER:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_ImageNativeXferGet (pOrigin, pDest, pData);
+            else
+                twRC = TWRC_FAILURE;
+            break;
+
+        case DAT_JPEGCOMPRESSION:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_JPEGCompressionGet (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETDEFAULT:
+                    twRC = TWAIN_JPEGCompressionGetDefault
+                               (pOrigin, pDest, pData);
+                    break;
+                case MSG_RESET:
+                    twRC = TWAIN_JPEGCompressionReset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_JPEGCompressionSet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    DSM_twCC = TWCC_BADPROTOCOL;
+                    WARN("unrecognized operation triplet\n");
+                    break;
+            }
+            break;
+
+        case DAT_PALETTE8:
+            switch (MSG)
+            {
+                case MSG_GET:
+                    twRC = TWAIN_Palette8Get (pOrigin, pDest, pData);
+                    break;
+                case MSG_GETDEFAULT:
+                    twRC = TWAIN_Palette8GetDefault (pOrigin, pDest, pData);
+                    break;
+                case MSG_RESET:
+                    twRC = TWAIN_Palette8Reset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_Palette8Set (pOrigin, pDest, pData);
+                    break; 
+                default:
+                    twRC = TWRC_FAILURE;
+                    DSM_twCC = TWCC_BADPROTOCOL;
+                    WARN("unrecognized operation triplet\n");
+            }
+            break;
+
+        case DAT_RGBRESPONSE:
+            switch (MSG)
+            {
+                case MSG_RESET:
+                    twRC = TWAIN_RGBResponseReset (pOrigin, pDest, pData);
+                    break;
+                case MSG_SET:
+                    twRC = TWAIN_RGBResponseSet (pOrigin, pDest, pData);
+                    break;
+                default:
+                    twRC = TWRC_FAILURE;
+                    DSM_twCC = TWCC_BADPROTOCOL;
+                    WARN("unrecognized operation triplet\n");
+                    break;
+            }
+            break;
+
+        default:
+            twRC = TWRC_FAILURE;
+            DSM_twCC = TWCC_BADPROTOCOL;
+            WARN("unrecognized operation triplet\n");
+    }
+    return twRC;
+}
+
+TW_UINT16 TWAIN_AudioGroupHandler (
+           pTW_IDENTITY pOrigin,
+           pTW_IDENTITY pDest,
+           TW_UINT16    DAT,
+           TW_UINT16    MSG,
+           TW_MEMREF    pData)
+{
+    TW_UINT16 twRC = TWRC_FAILURE;
+
+    switch (DAT)
+    {
+        case DAT_AUDIOFILEXFER:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_AudioFileXferGet (pOrigin, pDest, pData);
+            break;
+
+        case DAT_AUDIOINFO:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_AudioInfoGet (pOrigin, pDest, pData);
+            break;
+
+        case DAT_AUDIONATIVEXFER:
+            if (MSG == MSG_GET)
+                twRC = TWAIN_AudioNativeXferGet (pOrigin, pDest, pData);
+            break;
+
+        default:
+            DSM_twCC = TWCC_BADPROTOCOL;
+            twRC = TWRC_FAILURE;
+            break;
+    }
+  
+    return twRC;
+}
+
+/* Main entry point for the TWAIN library */
+TW_UINT16 WINAPI
+DSM_Entry (pTW_IDENTITY pOrigin,
+           pTW_IDENTITY pDest,
+           TW_UINT32    DG,
+           TW_UINT16    DAT,
+           TW_UINT16    MSG,
+           TW_MEMREF    pData)
+{
+    TW_UINT16 twRC = TWRC_SUCCESS;  /* Return Code */
+
+    TRACE("(DG=%ld DAT=%d MSG=%d)\n", DG, DAT, MSG);
+    
+    switch (DG)
+    {
+        case DG_CONTROL:
+            twRC = TWAIN_ControlGroupHandler (pOrigin,pDest,DAT,MSG,pData);
+            break;
+        case DG_IMAGE:
+            twRC = TWAIN_ImageGroupHandler (pOrigin,pDest,DAT,MSG,pData);
+            break;
+        case DG_AUDIO:
+            twRC = TWAIN_AudioGroupHandler (pOrigin,pDest,DAT,MSG,pData);
+            break;
+        default:
+            DSM_twCC = TWCC_BADPROTOCOL;
+            twRC = TWRC_FAILURE;
+    }
+
+    return twRC;
+}
+
+/* A helper function that looks up a destination identity in the active 
+   source list */
+activeDS *TWAIN_LookupSource (pTW_IDENTITY pDest)
+{
+    activeDS *pSource;
+
+    for (pSource = activeSources; pSource; pSource = pSource->next)
+        if (pSource->identity.Id == pDest->Id)
+            break;
+
+    return pSource;
+}
diff --git a/dlls/twain/twain_32.spec b/dlls/twain/twain_32.spec
new file mode 100644
index 0000000..cb0a8b3
--- /dev/null
+++ b/dlls/twain/twain_32.spec
@@ -0,0 +1,12 @@
+name	twain_32
+type	win32
+init	TWAIN_LibMain
+
+import  user32.dll
+import  gdi32.dll
+import  kernel32.dll
+import  ntdll.dll
+
+debug_channels (twain)
+
+@ stdcall DSM_Entry(ptr ptr long long long ptr) DSM_Entry
diff --git a/dlls/twain/twain_i.h b/dlls/twain/twain_i.h
new file mode 100644
index 0000000..266a970
--- /dev/null
+++ b/dlls/twain/twain_i.h
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2000 Corel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _TWAIN32_H
+#define _TWAIN32_H
+
+#ifdef HAVE_SANE
+# include <sane/sane.h>
+#endif
+#include "twain.h"
+#include "windef.h"
+
+/* internel information about an active data source */
+typedef struct tagActiveDS
+{
+    struct tagActiveDS	*next;			/* next active DS */
+    TW_IDENTITY		identity;		/* identity */
+    TW_UINT16		currentState;		/* current state */
+    TW_EVENT		pendingEvent;		/* pending event to be sent to 
+                                                   application */
+    TW_UINT16		twCC;			/* condition code */
+    HWND		hwndOwner;		/* window handle of the app */
+#ifdef HAVE_SANE
+    SANE_Handle		deviceHandle;		/* device handle */
+    SANE_Parameters     sane_param;             /* parameters about the image
+                                                   transfered */
+#endif
+    /* Capabiblities */
+    TW_UINT16		capXferMech;		/* ICAP_XFERMECH */
+} activeDS; 
+
+TW_UINT16 DSM_initialized;      /* whether Source Manager is initialized */
+TW_UINT16 DSM_currentState;     /* current state of Source Manager */
+TW_UINT16 DSM_twCC;             /* current condition code of Source Manager */
+TW_INT32  DSM_parentHWND;       /* window handle of the Source's "parent" */
+TW_UINT32 DSM_sourceId;         /* source id generator */
+TW_UINT16 DSM_currentDevice;    /* keep track of device during enumeration */
+#ifdef HAVE_SANE
+const SANE_Device **device_list;/* a list of all sane devices */
+#endif
+activeDS *activeSources;	/* list of active data sources */
+
+/* Helper functions */
+extern activeDS *TWAIN_LookupSource (pTW_IDENTITY pDest);
+extern TW_UINT16 TWAIN_SaneCapability (activeDS *pSource,
+        pTW_CAPABILITY pCapability, TW_UINT16 action);
+
+/*  */
+extern TW_UINT16 TWAIN_ControlGroupHandler (
+	pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+    TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_ImageGroupHandler (
+	pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+	TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_AudioGroupHandler (
+	pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
+	TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_SourceManagerHandler (
+	pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
+
+/* Implementation of operation triplets (From Application to Source Manager) */
+extern TW_UINT16 TWAIN_CloseDS
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_IdentityGetDefault
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_IdentityGetFirst
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_IdentityGetNext
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_OpenDS
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_UserSelect
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_CloseDSM
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_OpenDSM
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+extern TW_UINT16 TWAIN_GetDSMStatus
+           (pTW_IDENTITY pOrigin, TW_MEMREF pData);
+
+/* Implementation of operation triplets
+ * From Application to Source (Control Information) */
+TW_UINT16 TWAIN_CapabilityGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_CapabilityGetCurrent
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,TW_MEMREF pData);
+TW_UINT16 TWAIN_CapabilityGetDefault
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_CapabilityQuerySupport
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_CapabilityReset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_CapabilitySet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_CustomDSDataGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_CustomDSDataSet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_AutomaticCaptureDirectory
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ChangeDirectory
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FileSystemCopy
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_CreateDirectory
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FileSystemDelete
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FormatMedia
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FileSystemGetClose
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FileSystemGetFirstFile
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FileSystemGetInfo
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FileSystemGetNextFile
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_FileSystemRename
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ProcessEvent
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_PassThrough
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_PendingXfersEndXfer
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_PendingXfersGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_PendingXfersReset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_PendingXfersStopFeeder
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXferGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXferGetDefault
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXferReset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXferSet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXfer2Get
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXfer2GetDefault
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXfer2Reset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupFileXfer2Set
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_SetupMemXferGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_GetDSStatus
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_DisableDSUserInterface
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_EnableDSUserInterface
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_EnableDSUIOnly
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_XferGroupGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_XferGroupSet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+
+/* Implementation of operation triplets 
+ * From Application to Source (Image Information) */
+TW_UINT16 TWAIN_CIEColorGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ExtImageInfoGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_GrayResponseReset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_GrayResponseSet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageFileXferGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageInfoGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageLayoutGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageLayoutGetDefault
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageLayoutReset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageLayoutSet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageMemXferGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_ImageNativeXferGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_JPEGCompressionGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_JPEGCompressionGetDefault
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_JPEGCompressionReset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_JPEGCompressionSet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_Palette8Get
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_Palette8GetDefault
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_Palette8Reset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_Palette8Set
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_RGBResponseReset
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_RGBResponseSet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+
+/* Implementation of operation triplets
+ * From Application to Source (Audio Information) */
+TW_UINT16 TWAIN_AudioFileXferGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_AudioInfoGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+TW_UINT16 TWAIN_AudioNativeXferGet
+    (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_MEMREF pData);
+
+/* Implementation of TWAIN capabilities */
+TW_UINT16 TWAIN_ICAPXferMech
+    (activeDS *pSource, pTW_CAPABILITY pCapability, TW_UINT16 action);
+
+#endif
diff --git a/include/config.h.in b/include/config.h.in
index f40a528..a70b862 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -334,6 +334,9 @@
 /* Define if you have the `rfork' function. */
 #undef HAVE_RFORK
 
+/* Define if we have SANE development environment */
+#undef HAVE_SANE
+
 /* Define if you have the <sched.h> header file. */
 #undef HAVE_SCHED_H