]> git.saurik.com Git - wxWidgets.git/commitdiff
1. the common helper functions are now in src/unix/utilsunx.cpp
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 6 Mar 1999 00:11:27 +0000 (00:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 6 Mar 1999 00:11:27 +0000 (00:11 +0000)
2. POSIX threads are in src/unix/threadpsx.cpp
3. some more functions are detected using configure and not  guessed from the
   platform type

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1867 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

15 files changed:
configure
configure.in
include/wx/thread.h
include/wx/unix/execute.h [new file with mode: 0644]
setup/setup.hin
src/common/utilscmn.cpp
src/gtk.inc
src/gtk/threadno.cpp
src/gtk/utilsgtk.cpp
src/gtk1/threadno.cpp
src/gtk1/utilsgtk.cpp
src/motif/app.cpp
src/motif/utils.cpp
src/unix/threadpsx.cpp [new file with mode: 0644]
src/unix/utilsunx.cpp [new file with mode: 0644]

index 377258541f4f2bfd3d330328c4dab5ef7c6327de..52a5ef28a7c5cdf6990c586de8c40a5e2e52cbcc 100755 (executable)
--- a/configure
+++ b/configure
@@ -2923,15 +2923,16 @@ fi
 
 fi
 
-for ac_func in vsnprintf
+
+for ac_func in vsnprintf vfork
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2930: checking for $ac_func" >&5
+echo "configure:2931: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2935 "configure"
+#line 2936 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2954,7 +2955,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2982,12 +2983,12 @@ done
 for ac_func in nanosleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2986: checking for $ac_func" >&5
+echo "configure:2987: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2991 "configure"
+#line 2992 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3010,7 +3011,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:3014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3035,7 +3036,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for nanosleep in -lposix4""... $ac_c" 1>&6
-echo "configure:3039: checking for nanosleep in -lposix4" >&5
+echo "configure:3040: checking for nanosleep in -lposix4" >&5
 ac_lib_var=`echo posix4'_'nanosleep | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3043,7 +3044,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3047 "configure"
+#line 3048 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3054,7 +3055,7 @@ int main() {
 nanosleep()
 ; return 0; }
 EOF
-if { (eval echo configure:3058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3075,20 +3076,83 @@ EOF
 
 else
   echo "$ac_t""no" 1>&6
+for ac_func in usleep
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3083: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 3088 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3111: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+ cat >> confdefs.h <<\EOF
+#define HAVE_USLEEP 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+echo "configure: warning: Sleep() function will not work" 1>&2
+  
+fi
+done
+
 fi
 
+
 fi
 done
 
-for ac_func in usleep
+
+for ac_func in uname gethostname
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3087: checking for $ac_func" >&5
+echo "configure:3151: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3092 "configure"
+#line 3156 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3111,7 +3175,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:3115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3129,7 +3193,7 @@ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
   cat >> confdefs.h <<EOF
 #define $ac_tr_func 1
 EOF
+ break
 else
   echo "$ac_t""no" 1>&6
 fi
@@ -3148,17 +3212,17 @@ for ac_hdr in iostream
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3152: checking for $ac_hdr" >&5
+echo "configure:3216: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3157 "configure"
+#line 3221 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3162: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3226: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3199,12 +3263,12 @@ cross_compiling=$ac_cv_prog_cc_cross
 
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3203: checking for uid_t in sys/types.h" >&5
+echo "configure:3267: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3208 "configure"
+#line 3272 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3233,7 +3297,7 @@ EOF
 fi
 
 echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:3237: checking type of array argument to getgroups" >&5
+echo "configure:3301: checking type of array argument to getgroups" >&5
 if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3241,7 +3305,7 @@ else
   ac_cv_type_getgroups=cross
 else
   cat > conftest.$ac_ext <<EOF
-#line 3245 "configure"
+#line 3309 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Rendell for this test.  */
@@ -3266,7 +3330,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:3270: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
     ac_cv_type_getgroups=gid_t
 else
@@ -3280,7 +3344,7 @@ fi
 
 if test $ac_cv_type_getgroups = cross; then
         cat > conftest.$ac_ext <<EOF
-#line 3284 "configure"
+#line 3348 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 EOF
@@ -3304,12 +3368,12 @@ EOF
 
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3308: checking for mode_t" >&5
+echo "configure:3372: checking for mode_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3313 "configure"
+#line 3377 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3337,12 +3401,12 @@ EOF
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3341: checking for off_t" >&5
+echo "configure:3405: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3346 "configure"
+#line 3410 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3370,12 +3434,12 @@ EOF
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3374: checking for pid_t" >&5
+echo "configure:3438: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3379 "configure"
+#line 3443 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3403,12 +3467,12 @@ EOF
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3407: checking return type of signal handlers" >&5
+echo "configure:3471: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3412 "configure"
+#line 3476 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3425,7 +3489,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:3429: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3493: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -3444,12 +3508,12 @@ EOF
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3448: checking for size_t" >&5
+echo "configure:3512: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3453 "configure"
+#line 3517 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3477,12 +3541,12 @@ EOF
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3481: checking for uid_t in sys/types.h" >&5
+echo "configure:3545: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3486 "configure"
+#line 3550 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3513,12 +3577,12 @@ fi
 
 
 echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:3517: checking whether stat file-mode macros are broken" >&5
+echo "configure:3581: checking whether stat file-mode macros are broken" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3522 "configure"
+#line 3586 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -3569,12 +3633,12 @@ EOF
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:3573: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:3637: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3578 "configure"
+#line 3642 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -3583,7 +3647,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:3587: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -3604,12 +3668,12 @@ EOF
 fi
 
 echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:3608: checking for st_blksize in struct stat" >&5
+echo "configure:3672: checking for st_blksize in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3613 "configure"
+#line 3677 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -3617,7 +3681,7 @@ int main() {
 struct stat s; s.st_blksize;
 ; return 0; }
 EOF
-if { (eval echo configure:3621: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blksize=yes
 else
@@ -3638,12 +3702,12 @@ EOF
 fi
 
 echo $ac_n "checking for st_blocks in struct stat""... $ac_c" 1>&6
-echo "configure:3642: checking for st_blocks in struct stat" >&5
+echo "configure:3706: checking for st_blocks in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3647 "configure"
+#line 3711 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -3651,7 +3715,7 @@ int main() {
 struct stat s; s.st_blocks;
 ; return 0; }
 EOF
-if { (eval echo configure:3655: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3719: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blocks=yes
 else
@@ -3674,12 +3738,12 @@ else
 fi
 
 echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:3678: checking for st_rdev in struct stat" >&5
+echo "configure:3742: checking for st_rdev in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3683 "configure"
+#line 3747 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -3687,7 +3751,7 @@ int main() {
 struct stat s; s.st_rdev;
 ; return 0; }
 EOF
-if { (eval echo configure:3691: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3755: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_rdev=yes
 else
@@ -3708,12 +3772,12 @@ EOF
 fi
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:3712: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:3776: checking whether struct tm is in sys/time.h or time.h" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3717 "configure"
+#line 3781 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -3721,7 +3785,7 @@ int main() {
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:3725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3789: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -3742,12 +3806,12 @@ EOF
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:3746: checking for tm_zone in struct tm" >&5
+echo "configure:3810: checking for tm_zone in struct tm" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3751 "configure"
+#line 3815 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -3755,7 +3819,7 @@ int main() {
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:3759: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3823: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -3775,12 +3839,12 @@ EOF
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:3779: checking for tzname" >&5
+echo "configure:3843: checking for tzname" >&5
 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3784 "configure"
+#line 3848 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -3790,7 +3854,7 @@ int main() {
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:3794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -3814,12 +3878,12 @@ fi
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3818: checking for working const" >&5
+echo "configure:3882: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3823 "configure"
+#line 3887 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3868,7 +3932,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:3872: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3936: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3889,21 +3953,21 @@ EOF
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:3893: checking for inline" >&5
+echo "configure:3957: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 3900 "configure"
+#line 3964 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:3907: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3971: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -3929,14 +3993,14 @@ EOF
 esac
 
 echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
-echo "configure:3933: checking whether char is unsigned" >&5
+echo "configure:3997: checking whether char is unsigned" >&5
 if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$GCC" = yes; then
   # GCC predefines this symbol on systems where it applies.
 cat > conftest.$ac_ext <<EOF
-#line 3940 "configure"
+#line 4004 "configure"
 #include "confdefs.h"
 #ifdef __CHAR_UNSIGNED__
   yes
@@ -3958,7 +4022,7 @@ if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 3962 "configure"
+#line 4026 "configure"
 #include "confdefs.h"
 /* volatile prevents gcc2 from optimizing the test away on sparcs.  */
 #if !defined(__STDC__) || __STDC__ != 1
@@ -3968,7 +4032,7 @@ main() {
   volatile char c = 255; exit(c < 0);
 }
 EOF
-if { (eval echo configure:3972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4036: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_char_unsigned=yes
 else
@@ -3992,7 +4056,7 @@ EOF
 fi
 
 echo $ac_n "checking for long double""... $ac_c" 1>&6
-echo "configure:3996: checking for long double" >&5
+echo "configure:4060: checking for long double" >&5
 if eval "test \"`echo '$''{'ac_cv_c_long_double'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4003,7 +4067,7 @@ if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 4007 "configure"
+#line 4071 "configure"
 #include "confdefs.h"
 int main() {
 /* The Stardent Vistra knows sizeof(long double), but does not support it.  */
@@ -4011,7 +4075,7 @@ long double foo = 0.0;
 /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
 exit(sizeof(long double) < sizeof(double)); }
 EOF
-if { (eval echo configure:4015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4079: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_long_double=yes
 else
@@ -4036,14 +4100,14 @@ fi
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:4040: checking whether byte ordering is bigendian" >&5
+echo "configure:4104: checking whether byte ordering is bigendian" >&5
 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_bigendian=unknown
 # See if sys/param.h defines the BYTE_ORDER macro.
 cat > conftest.$ac_ext <<EOF
-#line 4047 "configure"
+#line 4111 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -4054,11 +4118,11 @@ int main() {
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:4058: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4122: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   # It does; now see whether it defined to BIG_ENDIAN or not.
 cat > conftest.$ac_ext <<EOF
-#line 4062 "configure"
+#line 4126 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -4069,7 +4133,7 @@ int main() {
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:4073: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
 else
@@ -4089,7 +4153,7 @@ if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 4093 "configure"
+#line 4157 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -4102,7 +4166,7 @@ main () {
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:4106: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_bigendian=no
 else
@@ -4127,7 +4191,7 @@ fi
 
 
 echo $ac_n "checking size of int *""... $ac_c" 1>&6
-echo "configure:4131: checking size of int *" >&5
+echo "configure:4195: checking size of int *" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int_p'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4135,7 +4199,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 4139 "configure"
+#line 4203 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4146,7 +4210,7 @@ main()
   exit(0);
 }
 EOF
-if { (eval echo configure:4150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int_p=`cat conftestval`
 else
@@ -4166,7 +4230,7 @@ EOF
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:4170: checking size of int" >&5
+echo "configure:4234: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4174,7 +4238,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 4178 "configure"
+#line 4242 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4185,7 +4249,7 @@ main()
   exit(0);
 }
 EOF
-if { (eval echo configure:4189: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4253: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -4205,7 +4269,7 @@ EOF
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:4209: checking size of long" >&5
+echo "configure:4273: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4213,7 +4277,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 4217 "configure"
+#line 4281 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4224,7 +4288,7 @@ main()
   exit(0);
 }
 EOF
-if { (eval echo configure:4228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -4244,7 +4308,7 @@ EOF
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:4248: checking size of long long" >&5
+echo "configure:4312: checking size of long long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4252,7 +4316,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 4256 "configure"
+#line 4320 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -4263,7 +4327,7 @@ main()
   exit(0);
 }
 EOF
-if { (eval echo configure:4267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -4287,7 +4351,7 @@ EOF
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:4291: checking for long file names" >&5
+echo "configure:4355: checking for long file names" >&5
 if eval "test \"`echo '$''{'ac_cv_sys_long_file_names'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4338,7 +4402,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4342: checking for $ac_word" >&5
+echo "configure:4406: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4371,7 +4435,7 @@ test -n "$YACC" || YACC="yacc"
 # Extract the first word of "flex", so it can be a program name with args.
 set dummy flex; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4375: checking for $ac_word" >&5
+echo "configure:4439: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4404,7 +4468,7 @@ then
   *) ac_lib=l ;;
   esac
   echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6
-echo "configure:4408: checking for yywrap in -l$ac_lib" >&5
+echo "configure:4472: checking for yywrap in -l$ac_lib" >&5
 ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4412,7 +4476,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$ac_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4416 "configure"
+#line 4480 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4423,7 +4487,7 @@ int main() {
 yywrap()
 ; return 0; }
 EOF
-if { (eval echo configure:4427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4446,7 +4510,7 @@ fi
 fi
 
 echo $ac_n "checking lex output file root""... $ac_c" 1>&6
-echo "configure:4450: checking lex output file root" >&5
+echo "configure:4514: checking lex output file root" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4467,7 +4531,7 @@ echo "$ac_t""$ac_cv_prog_lex_root" 1>&6
 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
 
 echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6
-echo "configure:4471: checking whether yytext is a pointer" >&5
+echo "configure:4535: checking whether yytext is a pointer" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4479,14 +4543,14 @@ echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
 ac_save_LIBS="$LIBS"
 LIBS="$LIBS $LEXLIB"
 cat > conftest.$ac_ext <<EOF
-#line 4483 "configure"
+#line 4547 "configure"
 #include "confdefs.h"
 `cat $LEX_OUTPUT_ROOT.c`
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:4490: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_prog_lex_yytext_pointer=yes
 else
@@ -4513,12 +4577,12 @@ DL_LIBRARY=
 for ac_func in dlopen
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4517: checking for $ac_func" >&5
+echo "configure:4581: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4522 "configure"
+#line 4586 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4541,7 +4605,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4566,7 +4630,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4570: checking for dlopen in -ldl" >&5
+echo "configure:4634: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4574,7 +4638,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4578 "configure"
+#line 4642 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4585,7 +4649,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:4589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4607,7 +4671,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
-echo "configure:4611: checking for dld_link in -ldld" >&5
+echo "configure:4675: checking for dld_link in -ldld" >&5
 ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4615,7 +4679,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4619 "configure"
+#line 4683 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4626,7 +4690,7 @@ int main() {
 dld_link()
 ; return 0; }
 EOF
-if { (eval echo configure:4630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4650,12 +4714,12 @@ else
 for ac_func in shl_load
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4654: checking for $ac_func" >&5
+echo "configure:4718: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4659 "configure"
+#line 4723 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4678,7 +4742,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4718,7 +4782,7 @@ done
 
 
 echo $ac_n "checking for underscore before symbols""... $ac_c" 1>&6
-echo "configure:4722: checking for underscore before symbols" >&5
+echo "configure:4786: checking for underscore before symbols" >&5
 if eval "test \"`echo '$''{'libltdl_cv_uscore'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4740,7 +4804,7 @@ if test x"$libltdl_cv_uscore" = xyes; then
   if test x"$ac_cv_func_dlopen" = xyes ||
      test x"$ac_cv_lib_dl_dlopen" = xyes ; then
        echo $ac_n "checking whether we have to add an underscore for dlsym""... $ac_c" 1>&6
-echo "configure:4744: checking whether we have to add an underscore for dlsym" >&5
+echo "configure:4808: checking whether we have to add an underscore for dlsym" >&5
 if eval "test \"`echo '$''{'libltdl_cv_need_uscore'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4749,7 +4813,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 4753 "configure"
+#line 4817 "configure"
 #include "confdefs.h"
 
 #include <dlfcn.h>
@@ -4760,7 +4824,7 @@ main() { void *self, *ptr1, *ptr2; self=dlopen(NULL,RTLD_LAZY);
     if(ptr1 && !ptr2) exit(0); } exit(1); }
 
 EOF
-if { (eval echo configure:4764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4828: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   libltdl_cv_need_uscore=no
 else
@@ -4789,12 +4853,12 @@ fi
 for ac_func in strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4793: checking for $ac_func" >&5
+echo "configure:4857: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4798 "configure"
+#line 4862 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4817,7 +4881,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4854,7 +4918,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:4858: checking host system type" >&5
+echo "configure:4922: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -5101,7 +5165,7 @@ DEFAULT_wxUSE_WCSRTOMBS=0
 
 
 echo $ac_n "checking "for gtk"""... $ac_c" 1>&6
-echo "configure:5105: checking "for gtk"" >&5
+echo "configure:5169: checking "for gtk"" >&5
 # Check whether --with-gtk or --without-gtk was given.
 if test "${with_gtk+set}" = set; then
   withval="$with_gtk"
@@ -5131,7 +5195,7 @@ fi
 
 
 echo $ac_n "checking "for qt"""... $ac_c" 1>&6
-echo "configure:5135: checking "for qt"" >&5
+echo "configure:5199: checking "for qt"" >&5
 # Check whether --with-qt or --without-qt was given.
 if test "${with_qt+set}" = set; then
   withval="$with_qt"
@@ -5161,7 +5225,7 @@ fi
 
 
 echo $ac_n "checking "for motif"""... $ac_c" 1>&6
-echo "configure:5165: checking "for motif"" >&5
+echo "configure:5229: checking "for motif"" >&5
 # Check whether --with-motif or --without-motif was given.
 if test "${with_motif+set}" = set; then
   withval="$with_motif"
@@ -5192,7 +5256,7 @@ fi
 
 
 echo $ac_n "checking "for shared"""... $ac_c" 1>&6
-echo "configure:5196: checking "for shared"" >&5
+echo "configure:5260: checking "for shared"" >&5
 # Check whether --with-shared or --without-shared was given.
 if test "${with_shared+set}" = set; then
   withval="$with_shared"
@@ -5222,7 +5286,7 @@ fi
 
 
 echo $ac_n "checking "for optimise"""... $ac_c" 1>&6
-echo "configure:5226: checking "for optimise"" >&5
+echo "configure:5290: checking "for optimise"" >&5
 # Check whether --with-optimise or --without-optimise was given.
 if test "${with_optimise+set}" = set; then
   withval="$with_optimise"
@@ -5252,7 +5316,7 @@ fi
 
 
 echo $ac_n "checking "for debug_flag"""... $ac_c" 1>&6
-echo "configure:5256: checking "for debug_flag"" >&5
+echo "configure:5320: checking "for debug_flag"" >&5
 # Check whether --with-debug_flag or --without-debug_flag was given.
 if test "${with_debug_flag+set}" = set; then
   withval="$with_debug_flag"
@@ -5282,7 +5346,7 @@ fi
 
 
 echo $ac_n "checking "for debug_info"""... $ac_c" 1>&6
-echo "configure:5286: checking "for debug_info"" >&5
+echo "configure:5350: checking "for debug_info"" >&5
 # Check whether --with-debug_info or --without-debug_info was given.
 if test "${with_debug_info+set}" = set; then
   withval="$with_debug_info"
@@ -5312,7 +5376,7 @@ fi
 
 
 echo $ac_n "checking "for debug_gdb"""... $ac_c" 1>&6
-echo "configure:5316: checking "for debug_gdb"" >&5
+echo "configure:5380: checking "for debug_gdb"" >&5
 # Check whether --with-debug_gdb or --without-debug_gdb was given.
 if test "${with_debug_gdb+set}" = set; then
   withval="$with_debug_gdb"
@@ -5342,7 +5406,7 @@ fi
 
 
 echo $ac_n "checking "for mem_tracing"""... $ac_c" 1>&6
-echo "configure:5346: checking "for mem_tracing"" >&5
+echo "configure:5410: checking "for mem_tracing"" >&5
 # Check whether --with-mem_tracing or --without-mem_tracing was given.
 if test "${with_mem_tracing+set}" = set; then
   withval="$with_mem_tracing"
@@ -5372,7 +5436,7 @@ fi
 
 
 echo $ac_n "checking "for dmalloc"""... $ac_c" 1>&6
-echo "configure:5376: checking "for dmalloc"" >&5
+echo "configure:5440: checking "for dmalloc"" >&5
 # Check whether --with-dmalloc or --without-dmalloc was given.
 if test "${with_dmalloc+set}" = set; then
   withval="$with_dmalloc"
@@ -5402,7 +5466,7 @@ fi
 
 
 echo $ac_n "checking "for profile"""... $ac_c" 1>&6
-echo "configure:5406: checking "for profile"" >&5
+echo "configure:5470: checking "for profile"" >&5
 # Check whether --with-profile or --without-profile was given.
 if test "${with_profile+set}" = set; then
   withval="$with_profile"
@@ -5432,7 +5496,7 @@ fi
 
 
 echo $ac_n "checking "for apple_ieee"""... $ac_c" 1>&6
-echo "configure:5436: checking "for apple_ieee"" >&5
+echo "configure:5500: checking "for apple_ieee"" >&5
 # Check whether --with-apple_ieee or --without-apple_ieee was given.
 if test "${with_apple_ieee+set}" = set; then
   withval="$with_apple_ieee"
@@ -5462,7 +5526,7 @@ fi
 
 
 echo $ac_n "checking "for threads"""... $ac_c" 1>&6
-echo "configure:5466: checking "for threads"" >&5
+echo "configure:5530: checking "for threads"" >&5
 # Check whether --with-threads or --without-threads was given.
 if test "${with_threads+set}" = set; then
   withval="$with_threads"
@@ -5492,7 +5556,7 @@ fi
 
 
 echo $ac_n "checking "for dynlib"""... $ac_c" 1>&6
-echo "configure:5496: checking "for dynlib"" >&5
+echo "configure:5560: checking "for dynlib"" >&5
 # Check whether --with-dynlib or --without-dynlib was given.
 if test "${with_dynlib+set}" = set; then
   withval="$with_dynlib"
@@ -5523,7 +5587,7 @@ fi
 
 
 echo $ac_n "checking "for zlib"""... $ac_c" 1>&6
-echo "configure:5527: checking "for zlib"" >&5
+echo "configure:5591: checking "for zlib"" >&5
 # Check whether --with-zlib or --without-zlib was given.
 if test "${with_zlib+set}" = set; then
   withval="$with_zlib"
@@ -5553,7 +5617,7 @@ fi
 
 
 echo $ac_n "checking "for libpng"""... $ac_c" 1>&6
-echo "configure:5557: checking "for libpng"" >&5
+echo "configure:5621: checking "for libpng"" >&5
 # Check whether --with-libpng or --without-libpng was given.
 if test "${with_libpng+set}" = set; then
   withval="$with_libpng"
@@ -5583,7 +5647,7 @@ fi
 
 
 echo $ac_n "checking "for libjpeg"""... $ac_c" 1>&6
-echo "configure:5587: checking "for libjpeg"" >&5
+echo "configure:5651: checking "for libjpeg"" >&5
 # Check whether --with-libjpeg or --without-libjpeg was given.
 if test "${with_libjpeg+set}" = set; then
   withval="$with_libjpeg"
@@ -5613,7 +5677,7 @@ fi
 
 
 echo $ac_n "checking "for odbc"""... $ac_c" 1>&6
-echo "configure:5617: checking "for odbc"" >&5
+echo "configure:5681: checking "for odbc"" >&5
 # Check whether --with-odbc or --without-odbc was given.
 if test "${with_odbc+set}" = set; then
   withval="$with_odbc"
@@ -5644,7 +5708,7 @@ fi
 
 
 echo $ac_n "checking "for timedate"""... $ac_c" 1>&6
-echo "configure:5648: checking "for timedate"" >&5
+echo "configure:5712: checking "for timedate"" >&5
 # Check whether --with-timedate or --without-timedate was given.
 if test "${with_timedate+set}" = set; then
   withval="$with_timedate"
@@ -5674,7 +5738,7 @@ fi
 
 
 echo $ac_n "checking "for intl"""... $ac_c" 1>&6
-echo "configure:5678: checking "for intl"" >&5
+echo "configure:5742: checking "for intl"" >&5
 # Check whether --with-intl or --without-intl was given.
 if test "${with_intl+set}" = set; then
   withval="$with_intl"
@@ -5704,7 +5768,7 @@ fi
 
 
 echo $ac_n "checking "for config"""... $ac_c" 1>&6
-echo "configure:5708: checking "for config"" >&5
+echo "configure:5772: checking "for config"" >&5
 # Check whether --with-config or --without-config was given.
 if test "${with_config+set}" = set; then
   withval="$with_config"
@@ -5734,7 +5798,7 @@ fi
 
 
 echo $ac_n "checking "for streams"""... $ac_c" 1>&6
-echo "configure:5738: checking "for streams"" >&5
+echo "configure:5802: checking "for streams"" >&5
 # Check whether --with-streams or --without-streams was given.
 if test "${with_streams+set}" = set; then
   withval="$with_streams"
@@ -5764,7 +5828,7 @@ fi
 
 
 echo $ac_n "checking "for serial"""... $ac_c" 1>&6
-echo "configure:5768: checking "for serial"" >&5
+echo "configure:5832: checking "for serial"" >&5
 # Check whether --with-serial or --without-serial was given.
 if test "${with_serial+set}" = set; then
   withval="$with_serial"
@@ -5794,7 +5858,7 @@ fi
 
 
 echo $ac_n "checking "for sockets"""... $ac_c" 1>&6
-echo "configure:5798: checking "for sockets"" >&5
+echo "configure:5862: checking "for sockets"" >&5
 # Check whether --with-sockets or --without-sockets was given.
 if test "${with_sockets+set}" = set; then
   withval="$with_sockets"
@@ -5825,7 +5889,7 @@ fi
 
 
 echo $ac_n "checking "for afmfonts"""... $ac_c" 1>&6
-echo "configure:5829: checking "for afmfonts"" >&5
+echo "configure:5893: checking "for afmfonts"" >&5
 # Check whether --with-afmfonts or --without-afmfonts was given.
 if test "${with_afmfonts+set}" = set; then
   withval="$with_afmfonts"
@@ -5855,7 +5919,7 @@ fi
 
 
 echo $ac_n "checking "for normalized"""... $ac_c" 1>&6
-echo "configure:5859: checking "for normalized"" >&5
+echo "configure:5923: checking "for normalized"" >&5
 # Check whether --with-normalized or --without-normalized was given.
 if test "${with_normalized+set}" = set; then
   withval="$with_normalized"
@@ -5885,7 +5949,7 @@ fi
 
 
 echo $ac_n "checking "for postscript"""... $ac_c" 1>&6
-echo "configure:5889: checking "for postscript"" >&5
+echo "configure:5953: checking "for postscript"" >&5
 # Check whether --with-postscript or --without-postscript was given.
 if test "${with_postscript+set}" = set; then
   withval="$with_postscript"
@@ -5916,7 +5980,7 @@ fi
 
 
 echo $ac_n "checking "for unicode"""... $ac_c" 1>&6
-echo "configure:5920: checking "for unicode"" >&5
+echo "configure:5984: checking "for unicode"" >&5
 # Check whether --with-unicode or --without-unicode was given.
 if test "${with_unicode+set}" = set; then
   withval="$with_unicode"
@@ -5946,7 +6010,7 @@ fi
 
 
 echo $ac_n "checking "for wcsrtombs"""... $ac_c" 1>&6
-echo "configure:5950: checking "for wcsrtombs"" >&5
+echo "configure:6014: checking "for wcsrtombs"" >&5
 # Check whether --with-wcsrtombs or --without-wcsrtombs was given.
 if test "${with_wcsrtombs+set}" = set; then
   withval="$with_wcsrtombs"
@@ -5977,7 +6041,7 @@ fi
 
 
 echo $ac_n "checking "for wxresources"""... $ac_c" 1>&6
-echo "configure:5981: checking "for wxresources"" >&5
+echo "configure:6045: checking "for wxresources"" >&5
 # Check whether --with-wxresources or --without-wxresources was given.
 if test "${with_wxresources+set}" = set; then
   withval="$with_wxresources"
@@ -6007,7 +6071,7 @@ fi
 
 
 echo $ac_n "checking "for prologio"""... $ac_c" 1>&6
-echo "configure:6011: checking "for prologio"" >&5
+echo "configure:6075: checking "for prologio"" >&5
 # Check whether --with-prologio or --without-prologio was given.
 if test "${with_prologio+set}" = set; then
   withval="$with_prologio"
@@ -6037,7 +6101,7 @@ fi
 
 
 echo $ac_n "checking "for RPC"""... $ac_c" 1>&6
-echo "configure:6041: checking "for RPC"" >&5
+echo "configure:6105: checking "for RPC"" >&5
 # Check whether --with-rpc or --without-rpc was given.
 if test "${with_rpc+set}" = set; then
   withval="$with_rpc"
@@ -6068,7 +6132,7 @@ fi
 
 
 echo $ac_n "checking "for IPC"""... $ac_c" 1>&6
-echo "configure:6072: checking "for IPC"" >&5
+echo "configure:6136: checking "for IPC"" >&5
 # Check whether --with-ipc or --without-ipc was given.
 if test "${with_ipc+set}" = set; then
   withval="$with_ipc"
@@ -6098,7 +6162,7 @@ fi
 
 
 echo $ac_n "checking "for resources"""... $ac_c" 1>&6
-echo "configure:6102: checking "for resources"" >&5
+echo "configure:6166: checking "for resources"" >&5
 # Check whether --with-resources or --without-resources was given.
 if test "${with_resources+set}" = set; then
   withval="$with_resources"
@@ -6128,7 +6192,7 @@ fi
 
 
 echo $ac_n "checking "for clipboard"""... $ac_c" 1>&6
-echo "configure:6132: checking "for clipboard"" >&5
+echo "configure:6196: checking "for clipboard"" >&5
 # Check whether --with-clipboard or --without-clipboard was given.
 if test "${with_clipboard+set}" = set; then
   withval="$with_clipboard"
@@ -6158,7 +6222,7 @@ fi
 
 
 echo $ac_n "checking "for tooltips"""... $ac_c" 1>&6
-echo "configure:6162: checking "for tooltips"" >&5
+echo "configure:6226: checking "for tooltips"" >&5
 # Check whether --with-tooltips or --without-tooltips was given.
 if test "${with_tooltips+set}" = set; then
   withval="$with_tooltips"
@@ -6188,7 +6252,7 @@ fi
 
 
 echo $ac_n "checking "for dnd"""... $ac_c" 1>&6
-echo "configure:6192: checking "for dnd"" >&5
+echo "configure:6256: checking "for dnd"" >&5
 # Check whether --with-dnd or --without-dnd was given.
 if test "${with_dnd+set}" = set; then
   withval="$with_dnd"
@@ -6219,7 +6283,7 @@ fi
 
 
 echo $ac_n "checking "for mdi"""... $ac_c" 1>&6
-echo "configure:6223: checking "for mdi"" >&5
+echo "configure:6287: checking "for mdi"" >&5
 # Check whether --with-mdi or --without-mdi was given.
 if test "${with_mdi+set}" = set; then
   withval="$with_mdi"
@@ -6249,7 +6313,7 @@ fi
 
 
 echo $ac_n "checking "for docview"""... $ac_c" 1>&6
-echo "configure:6253: checking "for docview"" >&5
+echo "configure:6317: checking "for docview"" >&5
 # Check whether --with-docview or --without-docview was given.
 if test "${with_docview+set}" = set; then
   withval="$with_docview"
@@ -6279,7 +6343,7 @@ fi
 
 
 echo $ac_n "checking "for printarch"""... $ac_c" 1>&6
-echo "configure:6283: checking "for printarch"" >&5
+echo "configure:6347: checking "for printarch"" >&5
 # Check whether --with-printarch or --without-printarch was given.
 if test "${with_printarch+set}" = set; then
   withval="$with_printarch"
@@ -6309,7 +6373,7 @@ fi
 
 
 echo $ac_n "checking "for help"""... $ac_c" 1>&6
-echo "configure:6313: checking "for help"" >&5
+echo "configure:6377: checking "for help"" >&5
 # Check whether --with-help or --without-help was given.
 if test "${with_help+set}" = set; then
   withval="$with_help"
@@ -6347,7 +6411,7 @@ fi
 
 if test "$USE_LINUX" = 1; then
   echo $ac_n "checking for gettext in -lc""... $ac_c" 1>&6
-echo "configure:6351: checking for gettext in -lc" >&5
+echo "configure:6415: checking for gettext in -lc" >&5
 ac_lib_var=`echo c'_'gettext | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6355,7 +6419,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6359 "configure"
+#line 6423 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6366,7 +6430,7 @@ int main() {
 gettext()
 ; return 0; }
 EOF
-if { (eval echo configure:6370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6434: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6437,7 +6501,7 @@ fi
   # Extract the first word of "gtk-config", so it can be a program name with args.
 set dummy gtk-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:6441: checking for $ac_word" >&5
+echo "configure:6505: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6468,7 +6532,7 @@ fi
 
   min_gtk_version=1.0.4
   echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6
-echo "configure:6472: checking for GTK - version >= $min_gtk_version" >&5
+echo "configure:6536: checking for GTK - version >= $min_gtk_version" >&5
   no_gtk=""
   if test "$GTK_CONFIG" != "no" ; then
     GTK_CFLAGS=`$GTK_CONFIG --cflags`
@@ -6481,7 +6545,7 @@ echo "configure:6472: checking for GTK - version >= $min_gtk_version" >&5
   echo $ac_n "cross compiling; assumed OK... $ac_c"
 else
   cat > conftest.$ac_ext <<EOF
-#line 6485 "configure"
+#line 6549 "configure"
 #include "confdefs.h"
 
 #include <gtk/gtk.h>
@@ -6505,7 +6569,7 @@ main ()
 }
 
 EOF
-if { (eval echo configure:6509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -6545,7 +6609,7 @@ fi
 
 if test "$wxUSE_QT" = 1; then
    echo $ac_n "checking for Qt includes""... $ac_c" 1>&6
-echo "configure:6549: checking for Qt includes" >&5
+echo "configure:6613: checking for Qt includes" >&5
    
 ac_find_includes=
 for ac_dir in $SEARCH_INCLUDE;
@@ -6559,7 +6623,7 @@ for ac_dir in $SEARCH_INCLUDE;
    if test "$ac_find_includes" != "" ; then
      echo "$ac_t""found $ac_find_includes" 1>&6
      echo $ac_n "checking for Qt library""... $ac_c" 1>&6
-echo "configure:6563: checking for Qt library" >&5
+echo "configure:6627: checking for Qt library" >&5
      
 ac_find_libraries=
 for ac_dir in $SEARCH_LIB;
@@ -6610,7 +6674,7 @@ fi
 
 if test "$wxUSE_MOTIF" = 1; then
    echo $ac_n "checking for Motif/Lesstif includes""... $ac_c" 1>&6
-echo "configure:6614: checking for Motif/Lesstif includes" >&5
+echo "configure:6678: checking for Motif/Lesstif includes" >&5
    
 ac_find_includes=
 for ac_dir in $SEARCH_INCLUDE;
@@ -6624,7 +6688,7 @@ for ac_dir in $SEARCH_INCLUDE;
    if test "$ac_find_includes" != "" ; then
      echo "$ac_t""found $ac_find_includes" 1>&6
      echo $ac_n "checking for Motif/Lesstif library""... $ac_c" 1>&6
-echo "configure:6628: checking for Motif/Lesstif library" >&5
+echo "configure:6692: checking for Motif/Lesstif library" >&5
      
 ac_find_libraries=
 for ac_dir in $SEARCH_LIB;
@@ -6661,7 +6725,7 @@ for ac_dir in $SEARCH_LIB;
        CHECK_INCLUDE="$CHECK_INCLUDE $ac_path_to_include"
        echo "$ac_t""found at $ac_find_libraries" 1>&6
        echo $ac_n "checking for Xt library""... $ac_c" 1>&6
-echo "configure:6665: checking for Xt library" >&5
+echo "configure:6729: checking for Xt library" >&5
        
 ac_find_libraries=
 for ac_dir in $SEARCH_LIB;
@@ -6687,7 +6751,7 @@ for ac_dir in $SEARCH_LIB;
          CHECK_LINK="$CHECK_LIB $ac_path_to_link"
          echo "$ac_t""found at $ac_find_libraries" 1>&6
          echo $ac_n "checking for Xpm library""... $ac_c" 1>&6
-echo "configure:6691: checking for Xpm library" >&5
+echo "configure:6755: checking for Xpm library" >&5
          
 ac_find_libraries=
 for ac_dir in $SEARCH_LIB;
@@ -6859,7 +6923,7 @@ if test "$wxUSE_LIBJPEG" = 1 ; then
 EOF
 
   echo $ac_n "checking for  in -ljpeg""... $ac_c" 1>&6
-echo "configure:6863: checking for  in -ljpeg" >&5
+echo "configure:6927: checking for  in -ljpeg" >&5
 ac_lib_var=`echo jpeg'_' | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6867,7 +6931,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ljpeg  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6871 "configure"
+#line 6935 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6878,7 +6942,7 @@ int main() {
 ()
 ; return 0; }
 EOF
-if { (eval echo configure:6882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6968,12 +7032,12 @@ if test "$wxUSE_DYNLIB_CLASS" = "1"; then
             for ac_func in dlopen
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6972: checking for $ac_func" >&5
+echo "configure:7036: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6977 "configure"
+#line 7041 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6996,7 +7060,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:7000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7064: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7021,7 +7085,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:7025: checking for dlopen in -ldl" >&5
+echo "configure:7089: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7029,7 +7093,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7033 "configure"
+#line 7097 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7040,7 +7104,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:7044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7069,12 +7133,12 @@ done
     for ac_func in shl_load
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7073: checking for $ac_func" >&5
+echo "configure:7137: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7078 "configure"
+#line 7142 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7097,7 +7161,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:7101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7271,7 +7335,7 @@ UNIX_THREAD=""
 if test "$wxUSE_THREADS" = "1"; then
      
      echo $ac_n "checking for pthread_create in -lpthread-0.7""... $ac_c" 1>&6
-echo "configure:7275: checking for pthread_create in -lpthread-0.7" >&5
+echo "configure:7339: checking for pthread_create in -lpthread-0.7" >&5
 ac_lib_var=`echo pthread-0.7'_'pthread_create | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7279,7 +7343,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpthread-0.7  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7283 "configure"
+#line 7347 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7290,7 +7354,7 @@ int main() {
 pthread_create()
 ; return 0; }
 EOF
-if { (eval echo configure:7294: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7306,7 +7370,7 @@ fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   
-       UNIX_THREAD="gtk/threadpsx.cpp"
+       UNIX_THREAD="unix/threadpsx.cpp"
        THREADS_LINK="pthread-0.7"
      
 else
@@ -7314,17 +7378,17 @@ else
 
        ac_safe=`echo "sys/prctl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/prctl.h""... $ac_c" 1>&6
-echo "configure:7318: checking for sys/prctl.h" >&5
+echo "configure:7382: checking for sys/prctl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7323 "configure"
+#line 7387 "configure"
 #include "confdefs.h"
 #include <sys/prctl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7328: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7392: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7350,7 +7414,7 @@ fi
 
           
      echo $ac_n "checking for pthread_setcanceltype in -lpthread""... $ac_c" 1>&6
-echo "configure:7354: checking for pthread_setcanceltype in -lpthread" >&5
+echo "configure:7418: checking for pthread_setcanceltype in -lpthread" >&5
 ac_lib_var=`echo pthread'_'pthread_setcanceltype | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7358,7 +7422,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpthread  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7362 "configure"
+#line 7426 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7369,7 +7433,7 @@ int main() {
 pthread_setcanceltype()
 ; return 0; }
 EOF
-if { (eval echo configure:7373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7385,7 +7449,7 @@ fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   
-       UNIX_THREAD="gtk/threadpsx.cpp"
+       UNIX_THREAD="unix/threadpsx.cpp"
        THREADS_LINK="pthread"
      
 else
@@ -7398,7 +7462,7 @@ fi
 
     if test "x$THREADS_LINK" = "x"; then
                 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:7402: checking for pthread_create in -lc_r" >&5
+echo "configure:7466: checking for pthread_create in -lc_r" >&5
 ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7406,7 +7470,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc_r  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7410 "configure"
+#line 7474 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7417,7 +7481,7 @@ int main() {
 pthread_create()
 ; return 0; }
 EOF
-if { (eval echo configure:7421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7433,7 +7497,7 @@ fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   
-                        UNIX_THREAD="gtk/threadpsx.cpp"
+                        UNIX_THREAD="unix/threadpsx.cpp"
                         THREADS_LINK="c_r"
                     
 else
@@ -7450,10 +7514,6 @@ EOF
     fi
 fi
 
-if test "$wxUSE_MOTIF" = "1"; then
-  UNIX_THREAD="motif/thread.cpp"
-fi
-
 if test -z "$UNIX_THREAD"; then
   wxUSE_THREADS=0
 fi
@@ -7461,7 +7521,7 @@ fi
 if test "$wxUSE_THREADS" = "1"; then
   THREADS_LINK2=""
   echo $ac_n "checking for sched_yield in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:7465: checking for sched_yield in -l$THREADS_LINK" >&5
+echo "configure:7525: checking for sched_yield in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'sched_yield | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7469,7 +7529,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7473 "configure"
+#line 7533 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7480,7 +7540,7 @@ int main() {
 sched_yield()
 ; return 0; }
 EOF
-if { (eval echo configure:7484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7502,7 +7562,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for sched_yield in -l"posix4"""... $ac_c" 1>&6
-echo "configure:7506: checking for sched_yield in -l"posix4"" >&5
+echo "configure:7566: checking for sched_yield in -l"posix4"" >&5
 ac_lib_var=`echo "posix4"'_'sched_yield | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7510,7 +7570,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l"posix4"  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7514 "configure"
+#line 7574 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7521,7 +7581,7 @@ int main() {
 sched_yield()
 ; return 0; }
 EOF
-if { (eval echo configure:7525: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7551,7 +7611,7 @@ fi
 
 
   echo $ac_n "checking for sched_get_priority_min in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:7555: checking for sched_get_priority_min in -l$THREADS_LINK" >&5
+echo "configure:7615: checking for sched_get_priority_min in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'sched_get_priority_min | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7559,7 +7619,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7563 "configure"
+#line 7623 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7570,7 +7630,7 @@ int main() {
 sched_get_priority_min()
 ; return 0; }
 EOF
-if { (eval echo configure:7574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7634: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7592,7 +7652,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for sched_get_priority_min in -l"posix4"""... $ac_c" 1>&6
-echo "configure:7596: checking for sched_get_priority_min in -l"posix4"" >&5
+echo "configure:7656: checking for sched_get_priority_min in -l"posix4"" >&5
 ac_lib_var=`echo "posix4"'_'sched_get_priority_min | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7600,7 +7660,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l"posix4"  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7604 "configure"
+#line 7664 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7611,7 +7671,7 @@ int main() {
 sched_get_priority_min()
 ; return 0; }
 EOF
-if { (eval echo configure:7615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7641,7 +7701,7 @@ fi
 
 
   echo $ac_n "checking for pthread_cancel in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:7645: checking for pthread_cancel in -l$THREADS_LINK" >&5
+echo "configure:7705: checking for pthread_cancel in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'pthread_cancel | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7649,7 +7709,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7653 "configure"
+#line 7713 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7660,7 +7720,7 @@ int main() {
 pthread_cancel()
 ; return 0; }
 EOF
-if { (eval echo configure:7664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8238,3 +8298,4 @@ test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
 
 mv ${OSTYPE}.system.cache.tmp ${OSTYPE}.system.cache
 
+
index 30088adaf45820eb77a893a043070c2a786f37e0..2de2e3cb879001a539528ec5a890711e9a74b07a 100644 (file)
@@ -449,14 +449,28 @@ AC_SUBST(GTK_JOYSTICK)
 
 dnl check for vprintf/vsprintf() which are GNU extensions
 AC_FUNC_VPRINTF
-dnl check for vsnprintf() which is another GNU extension
-AC_CHECK_FUNCS(vsnprintf)
+
+dnl check for several standard functions we use if they are available
+AC_CHECK_FUNCS(vsnprintf vfork)
 
 dnl check for usleep() and nanosleep() which is better in MT programs
-AC_CHECK_FUNCS(nanosleep,
-        AC_DEFINE(HAVE_NANOSLEEP),
-        [AC_CHECK_LIB(posix4, nanosleep, AC_DEFINE(HAVE_NANOSLEEP))])
-AC_CHECK_FUNCS(usleep)
+dnl AC_CHECK_FUNCS(nanosleep, AC_DEFINE(HAVE_NANOSLEEP),
+dnl                [
+dnl                 AC_CHECK_LIB(posix4, nanosleep,
+dnl                    AC_DEFINE(HAVE_NANOSLEEP),
+dnl                    AC_CHECK_FUNCS(usleep))
+dnl                ]
+dnl               )
+AC_CHECK_FUNCS(nanosleep, AC_DEFINE(HAVE_NANOSLEEP),
+[AC_CHECK_LIB(posix4, nanosleep, AC_DEFINE(HAVE_NANOSLEEP),
+ [AC_CHECK_FUNCS(usleep, AC_DEFINE(HAVE_USLEEP),
+                         AC_MSG_WARN(Sleep() function will not work)
+  )]
+ )]
+)
+
+dnl check for uname (POSIX) and gethostname (BSD)
+AC_CHECK_FUNCS(uname gethostname, break)
 
 AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
@@ -1383,7 +1397,7 @@ if test "$wxUSE_THREADS" = "1"; then
      dnl For glibc 2 users who have the old libc 5 too
 
      AC_CHECK_LIB(pthread-0.7, pthread_create, [
-       UNIX_THREAD="gtk/threadpsx.cpp"
+       UNIX_THREAD="unix/threadpsx.cpp"
        THREADS_LINK="pthread-0.7"
      ],[
        AC_CHECK_HEADER(sys/prctl.h, [
@@ -1394,7 +1408,7 @@ if test "$wxUSE_THREADS" = "1"; then
      dnl the case for pthread_setcanceltype.
 
      AC_CHECK_LIB(pthread, pthread_setcanceltype, [
-       UNIX_THREAD="gtk/threadpsx.cpp"
+       UNIX_THREAD="unix/threadpsx.cpp"
        THREADS_LINK="pthread"
      ])
     ])
@@ -1403,7 +1417,7 @@ if test "$wxUSE_THREADS" = "1"; then
         dnl thread functions are in libc_r under FreeBSD
         AC_CHECK_LIB(c_r, pthread_create,
                     [
-                        UNIX_THREAD="gtk/threadpsx.cpp"
+                        UNIX_THREAD="unix/threadpsx.cpp"
                         THREADS_LINK="c_r"
                     ])
     fi
@@ -1413,10 +1427,6 @@ if test "$wxUSE_THREADS" = "1"; then
     fi
 fi
 
-if test "$wxUSE_MOTIF" = "1"; then
-  UNIX_THREAD="motif/thread.cpp"
-fi
-
 if test -z "$UNIX_THREAD"; then
   wxUSE_THREADS=0
 fi
@@ -1580,3 +1590,4 @@ AC_CONFIG_HEADER(./include/wx/gtk/setup.h:./setup/setup.hin)
 AC_OUTPUT(./setup/substit ./wx-config:./wx-config.in,./setup/general/createall)
 
 AC_OVERRIDES_DONE
+
index 491bf986de9b41f7519f8ae13042301edc294fd3..821f4a4a3d3f24d8369904d07ba0f90667046f33 100644 (file)
@@ -352,6 +352,8 @@ void WXDLLEXPORT wxMutexGuiLeave();
 
 #else // !wxUSE_THREADS
 
+#include <wx/defs.h> // for WXDLLEXPORT
+
 // no thread support
 inline void WXDLLEXPORT wxMutexGuiEnter() { }
 inline void WXDLLEXPORT wxMutexGuiLeave() { }
diff --git a/include/wx/unix/execute.h b/include/wx/unix/execute.h
new file mode 100644 (file)
index 0000000..77a821e
--- /dev/null
@@ -0,0 +1,32 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        unix/execute.h
+// Purpose:     private details of wxExecute() implementation
+// Author:      Vadim Zeitlin
+// Id:          $Id$
+// Copyright:   (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_UNIX_EXECUTE_H
+#define _WX_UNIX_EXECUTE_H
+
+// if pid > 0, the execution is async and the data is freed in the callback
+// executed when the process terminates, if pid < 0, the execution is
+// synchronous and the caller (wxExecute) frees the data
+struct wxEndProcessData
+{
+    int pid,                // pid of the process
+        tag;                // port dependent value
+    wxProcess *process;     // if !NULL: notified on process termination
+    int  exitcode;          // the exit code
+};
+
+// this function is called when the process terminates from port specific
+// callback function and is common to all ports (src/unix/utilsunx.cpp)
+extern void wxHandleProcessTermination(wxEndProcessData *proc_data);
+
+// this function is called to associate the port-specific callback with the
+// child process. The return valus is port-specific.
+extern int wxAddProcessCallback(wxEndProcessData *proc_data, int fd);
+
+#endif // _WX_UNIX_EXECUTE_H
index 3e81506da50c7fe4b8515ed28f4a77cd3660eb5e..1e35223473ab6a8cb5dc93bd7de198c33861bb6f 100644 (file)
 /* Define if you have nanosleep() */
 #undef HAVE_NANOSLEEP
 
-/* Define if you have usleep() */
-#undef HAVE_USLEEP
+/* Define if you have vfork() */
+#undef HAVE_VFORK
+
+/* Define if you have uname() */
+#undef HAVE_UNAME
+
+/* Define if you have gethostname() */
+#undef HAVE_GETHOSTNAME
 
 /* Define if you have sched_yield */
 #undef HAVE_SCHED_YIELD
index 57fcf3bd32171acdbcb48a155c9770cb478207de..f15e7f0bbd3b2bb100ac5ef9ab7860309be4f487 100644 (file)
@@ -801,19 +801,6 @@ int isascii( int c )
 }
 #endif
 
-// Overloaded functions, taking a wxString
-bool wxGetHostName(wxString& name)
-{
-    bool success = wxGetHostName(wxBuffer, 500);
-    if (success)
-    {
-        name = wxBuffer;
-        return TRUE;
-    }
-    else
-        return FALSE;
-}
-
 bool wxGetUserId(wxString& buf)
 {
     bool success = wxGetUserId(wxBuffer, 500);
@@ -838,3 +825,13 @@ bool wxGetUserName(wxString& buf)
         return FALSE;
 }
 
+bool wxGetHostName(wxString& buf)
+{
+    static const size_t hostnameSize = 257;
+    bool ok = wxGetHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
+
+    buf.UngetWriteBuf();
+
+    return ok;
+}
+
index f721b4dc66340b567ac8394e4103cb49878a7e7a..96d9e38020e70dd16b89e9d2d415810348837bae 100644 (file)
@@ -124,6 +124,8 @@ LIB_CPP_SRC=\
  gtk/utilsgtk.cpp \
  gtk/utilsres.cpp \
  gtk/window.cpp \
+\
+ unix/utilsunx.cpp \
 \
  generic/choicdgg.cpp \
  generic/dcpsg.cpp \
index 72994404561dc15534cf8ad07fd9fe1d8f0e882a..4ac3f05954e56e85e1a96eb94b923191f27727a7 100644 (file)
@@ -8,8 +8,9 @@
 // Copyright:   (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
+
 #ifdef __GNUG__
-#pragma implementation "thread.h"
+    #pragma implementation "thread.h"
 #endif
 
 #include "wx/wx.h"
 
 wxMutex::wxMutex()
 {
-  m_locked = 0;
+    m_locked = 0;
 }
 
 wxMutex::~wxMutex()
 {
-  if (m_locked)
-    wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)\n", m_locked );
+    if (m_locked)
+        wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)", m_locked );
 }
 
 wxMutexError wxMutex::Lock()
 {
-  m_locked++;
-  return wxMUTEX_NO_ERROR;
+    m_locked++;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::TryLock()
 {
-  if (m_locked > 0)
-    return wxMUTEX_BUSY;
-  m_locked++;
-  return wxMUTEX_NO_ERROR;
+    if (m_locked > 0)
+        return wxMUTEX_BUSY;
+    m_locked++;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::Unlock()
 {
-  if (m_locked == 0)
-    return wxMUTEX_UNLOCKED;
-  m_locked--;
-  return wxMUTEX_NO_ERROR;
+    if (m_locked == 0)
+        return wxMUTEX_UNLOCKED;
+    m_locked--;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxCondition::wxCondition()
@@ -63,9 +64,9 @@ void wxCondition::Wait(wxMutex& WXUNUSED(mutex))
 }
 
 bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec),
-                      unsigned long WXUNUSED(nsec))
+        unsigned long WXUNUSED(nsec))
 {
-  return FALSE;
+    return FALSE;
 }
 
 void wxCondition::Signal()
@@ -76,31 +77,32 @@ void wxCondition::Broadcast()
 {
 }
 
-struct wxThreadInternal {
-       int thread_id;
-       void* exit_status;
+struct wxThreadInternal
+{
+    int thread_id;
+    void* exit_status;
 };
 
 wxThreadError wxThread::Create()
 {
-  p_internal->exit_status = Entry();
-  OnExit();
-  return wxTHREAD_NO_ERROR;
+    p_internal->exit_status = Entry();
+    OnExit();
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Destroy()
 {
-  return wxTHREAD_NOT_RUNNING;
+    return wxTHREAD_NOT_RUNNING;
 }
 
 wxThreadError wxThread::Pause()
 {
-  return wxTHREAD_NOT_RUNNING;
+    return wxTHREAD_NOT_RUNNING;
 }
 
 wxThreadError wxThread::Resume()
 {
-  return wxTHREAD_NOT_RUNNING;
+    return wxTHREAD_NOT_RUNNING;
 }
 
 void wxThread::DeferDestroy( bool WXUNUSED(on) )
@@ -113,27 +115,27 @@ void wxThread::TestDestroy()
 
 void *wxThread::Join()
 {
-  return p_internal->exit_status;
+    return p_internal->exit_status;
 }
 
 unsigned long wxThread::GetID() const
 {
-  return 0;
+    return 0;
 }
 
 bool wxThread::IsMain()
 {
-  return TRUE;
+    return TRUE;
 }
 
 bool wxThread::IsRunning() const
 {
-  return FALSE;
+    return FALSE;
 }
 
 bool wxThread::IsAlive() const
 {
-  return FALSE;
+    return FALSE;
 }
 
 void wxThread::SetPriority(int WXUNUSED(prio)) { }
@@ -143,36 +145,35 @@ wxMutex *wxMainMutex; // controls access to all GUI functions
 
 wxThread::wxThread()
 {
-  p_internal = new wxThreadInternal();
+    p_internal = new wxThreadInternal();
 }
 
 wxThread::~wxThread()
 {
-  Destroy();
-  Join();
-  delete p_internal;
+    Destroy();
+    Join();
+    delete p_internal;
 }
 
 // The default callback just joins the thread and throws away the result.
 void wxThread::OnExit()
 {
-  Join();
+    Join();
 }
 
-
 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
 
-bool wxThreadModule::OnInit() 
+bool wxThreadModule::OnInit()
 {
-  wxMainMutex = new wxMutex();
-  wxMainMutex->Lock();
-  return TRUE;
+    wxMainMutex = new wxMutex();
+    wxMainMutex->Lock();
+    return TRUE;
 }
 
 void wxThreadModule::OnExit()
 {
-  wxMainMutex->Unlock();
-  delete wxMainMutex;
+    wxMainMutex->Unlock();
+    delete wxMainMutex;
 }
 
 
index a85d45a6208ca32b4537f5dfb4b70131943dfa69..d9ceaf81f4eb4e7951e6a521463018749f070e94 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Robert Roebling
 // Id:          $Id$
 // Copyright:   (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence:           wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/utils.h"
@@ -15,6 +15,8 @@
 
 #include "wx/process.h"
 
+#include "wx/unix/execute.h"
+
 #include <stdarg.h>
 #include <dirent.h>
 #include <string.h>
@@ -27,7 +29,6 @@
 #include <netdb.h>
 #include <signal.h>
 #include <fcntl.h>          // for O_WRONLY and friends
-#include <time.h>           // nanosleep() and/or usleep()
 
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gtk/gtkfeatures.h>
 #include <gdk/gdkx.h>
 
-#ifdef __SVR4__
-  #include <sys/systeminfo.h>
-#endif
-
-// many versions of Unices have this function, but it is not defined in system
-// headers - please add your system here if it is the case for your OS.
-// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this.
-#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
-                         !defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
-     defined(__osf__)
-    extern "C"
-    {
-        void usleep(unsigned long usec);
-    };
-#endif // Unices without usleep()
-
-// many versions of Unices have this function, but it is not defined in system
-// headers - please add your system here if it is the case for your OS.
-// SunOS (and Solaris) and DG-UX are like this.
-#if defined(__SOLARIS__) || defined(__osf__)
-    extern "C"
-    {
-        pid_t wait4(pid_t pid, int *statusp, int options,
-                    struct rusage *rusage);
-    }
-
-    #define wxWait4(pid, stat, flags, rusage) wait4(pid, stat, flags, rusage)
-#elif defined(__sgi) || defined(__HPUX__)
-    // no wait4() at all on these systems
-    // TODO verify whether wait3() really works in this situation
-    #define wxWait4(pid, stat, flags, rusage) wait3(stat, flags, rusage)
-#else
-    // other Unices: assume have wait4(), although it's not standard (but
-    // Linux and FreeBSD do have it)
-    #define wxWait4(pid, stat, flags, rusage) wait4(pid, stat, flags, rusage)
-#endif // wait4()
-
-//------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // misc.
-//------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
-void wxBell(void)
+void wxBell()
 {
     gdk_beep();
 }
 
-void wxSleep(int nSecs)
-{
-    sleep(nSecs);
-}
-
-void wxUsleep(unsigned long milliseconds)
-{
-#if defined(HAVE_NANOSLEEP)
-    timespec tmReq;
-    tmReq.tv_sec = milliseconds / 1000;
-    tmReq.tv_nsec = (milliseconds % 1000) * 1000 * 1000;
-
-    // we're not interested in remaining time nor in return value
-    (void)nanosleep(&tmReq, (timespec *)NULL);
-#elif defined(HAVE_USLEEP)
-    // uncomment this if you feel brave or if you are sure that your version
-    // of Solaris has a safe usleep() function but please notice that usleep()
-    // is known to lead to crashes in MT programs in Solaris 2.[67] and is not
-    // documented as MT-Safe
-    #if defined(__SUN__) && defined(wxUSE_THREADS)
-        #error "usleep() cannot be used in MT programs under Solaris."
-    #endif // Sun
-
-    usleep(milliseconds * 1000); // usleep(3) wants microseconds
-#else // !sleep function
-    #error "usleep() or nanosleep() function required for wxUsleep"
-#endif // sleep function
-}
-
-int wxKill(long pid, int sig)
-{
-    return kill(pid, sig);
-}
+// ----------------------------------------------------------------------------
+// display characterstics
+// ----------------------------------------------------------------------------
 
 void wxDisplaySize( int *width, int *height )
 {
@@ -126,12 +60,12 @@ void wxGetMousePosition( int* x, int* y )
     gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
 }
 
-bool wxColourDisplay(void)
+bool wxColourDisplay()
 {
     return TRUE;
 }
 
-int wxDisplayDepth(void)
+int wxDisplayDepth()
 {
     return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth;
 }
@@ -144,312 +78,28 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
   return wxGTK;
 }
 
-//------------------------------------------------------------------------
-// user and home routines
-//------------------------------------------------------------------------
-
-const char* wxGetHomeDir( wxString *home  )
-{
-    *home = wxGetUserHome( wxString() );
-    if (home->IsNull()) *home = "/";
-    return *home;
-}
-
-char *wxGetUserHome( const wxString &user )
-{
-    struct passwd *who = (struct passwd *) NULL;
-
-    if (user.IsNull() || (user== ""))
-    {
-        register char *ptr;
-
-        if ((ptr = getenv("HOME")) != NULL)
-       {
-            return ptr;
-       }
-        if ((ptr = getenv("USER")) != NULL || (ptr = getenv("LOGNAME")) != NULL)
-       {
-            who = getpwnam(ptr);
-        }
-
-        /* We now make sure the the user exists! */
-        if (who == NULL)
-       {
-            who = getpwuid(getuid());
-       }
-    }
-    else
-    {
-      who = getpwnam (user);
-    }
-
-    return who ? who->pw_dir : (char*)NULL;
-}
-
-//------------------------------------------------------------------------
-// id routines
-//------------------------------------------------------------------------
-
-bool wxGetHostName(char *buf, int sz)
-{
-    *buf = '\0';
-#if defined(__SVR4__) && !defined(__sgi)
-    //KB: does this return the fully qualified host.domain name?
-    return (sysinfo(SI_HOSTNAME, buf, sz) != -1);
-#else /* BSD Sockets */
-    char name[255], domain[255];
-    //struct hostent *h;
-    // Get hostname
-    if (gethostname(name, sizeof(name)/sizeof(char)-1) == -1)
-        return FALSE;
-    if (getdomainname(domain, sizeof(domain)/sizeof(char)-1) == -1)
-        return FALSE;
-    // Get official full name of host
-    // doesn't return the full qualified name, replaced by following
-    // code (KB)
-    // strncpy(buf, (h=gethostbyname(name))!=NULL ? h->h_name : name, sz-1);
-    if((unsigned)sz > strlen(name)+strlen(domain)+1)
-    {
-        strcpy(buf, name);
-        if(strcmp(domain,"(none)") == 0) // standalone machine
-        {
-            strcat(buf,".");
-            strcat(buf,domain);
-        }
-    }
-    else
-        return FALSE;
-    return TRUE;
-#endif
-}
-
-bool wxGetUserId(char *buf, int sz)
-{
-    struct passwd *who;
-
-    *buf = '\0';
-    if ((who = getpwuid(getuid ())) != NULL) {
-        strncpy (buf, who->pw_name, sz-1);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-bool wxGetUserName(char *buf, int sz)
-{
-    struct passwd *who;
-    char *comma;
-
-    *buf = '\0';
-    if ((who = getpwuid (getuid ())) != NULL) {
-       comma = strchr(who->pw_gecos,'c');
-       if(comma) *comma = '\0'; // cut off non-name comment fields
-       strncpy (buf, who->pw_gecos, sz - 1);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-//------------------------------------------------------------------------
-// error and debug output routines
-//------------------------------------------------------------------------
-
-void wxDebugMsg( const char *format, ... )
-{
-  va_list ap;
-  va_start( ap, format );
-  vfprintf( stderr, format, ap );
-  fflush( stderr );
-  va_end(ap);
-}
-
-void wxError( const wxString &msg, const wxString &title )
-{
-  fprintf( stderr, "Error " );
-  if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
-  if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
-  fprintf( stderr, ".\n" );
-}
-
-void wxFatalError( const wxString &msg, const wxString &title )
-{
-  fprintf( stderr, "Error " );
-  if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
-  if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
-  fprintf( stderr, ".\n" );
-  exit(3); // the same exit code as for abort()
-}
-
-//------------------------------------------------------------------------
-// directory routines
-//------------------------------------------------------------------------
-
-bool wxDirExists( const wxString& dir )
-{
-    char buf[500];
-    strcpy( buf, WXSTRINGCAST(dir) );
-    struct stat sbuf;
-    return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE);
-}
-
-//------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // subprocess routines
-//------------------------------------------------------------------------
-
-// if pid > 0, the execution is async and the data is freed in
-// GTK_EndProcessDetector, if pid < 0, the execution is synchronous and the
-// caller (wxExecute) frees the data
-struct wxEndProcessData
-{
-    gint pid, tag;
-    wxProcess *process;
-    int  exitcode;
-};
+// ----------------------------------------------------------------------------
 
 static void GTK_EndProcessDetector(gpointer data, gint source,
                                    GdkInputCondition WXUNUSED(condition) )
 {
     wxEndProcessData *proc_data = (wxEndProcessData *)data;
-    int pid;
-
-    pid = (proc_data->pid > 0) ? proc_data->pid : -(proc_data->pid);
 
-    int status = 0;
-    wxWait4(pid, &status, 0, (rusage *) NULL);
+    wxHandleProcessTermination(proc_data);
 
     close(source);
     gdk_input_remove(proc_data->tag);
-
-    if (proc_data->process)
-        proc_data->process->OnTerminate(proc_data->pid, status);
-
-    if (proc_data->pid > 0)
-    {
-        delete proc_data;
-    }
-    else
-    {
-        // wxExecute() will know about it
-        proc_data->exitcode = status;
-
-        proc_data->pid = 0;
-    }
 }
 
-long wxExecute( char **argv, bool sync, wxProcess *process )
+int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
 {
-    wxEndProcessData *data = new wxEndProcessData;
-    int end_proc_detect[2];
-
-    wxCHECK_MSG( *argv, 0, "can't exec empty command" );
-
-    /* Create pipes */
-    if (pipe(end_proc_detect) == -1)
-    {
-        wxLogSysError( _("Pipe creation failed") );
-        return 0;
-    }
+    int tag = gdk_input_add(fd,
+                            GDK_INPUT_READ,
+                            GTK_EndProcessDetector,
+                            (gpointer)proc_data);
 
-    /* fork the process */
-#if defined(sun) || defined(__ultrix) || defined(__bsdi__)
-    pid_t pid = vfork();
-#else
-    pid_t pid = fork();
-#endif
-    if (pid == -1)
-    {
-        wxLogSysError( _("Fork failed") );
-        return 0;
-    }
-    else if (pid == 0)
-    {
-        // we're in child
-        close(end_proc_detect[0]); // close reading side
-
-        // These three lines close the open file descriptors to to avoid any
-        // input/output which might block the process or irritate the user. If
-        // one wants proper IO for the subprocess, the "right thing to do is
-        // to start an xterm executing it.
-        close(STDIN_FILENO);
-        close(STDOUT_FILENO);
-
-        // leave stderr opened, it won't do any hurm
-#if 0
-        close(STDERR_FILENO);
-
-        // some programs complain about stderr not being open, so redirect
-        // them:
-        open("/dev/null", O_RDONLY);  // stdin
-        open("/dev/null", O_WRONLY);  // stdout
-        open("/dev/null", O_WRONLY);  // stderr
-#endif
-
-#ifdef _AIX
-        execvp ((const char *)*argv, (const char **)argv);
-#else
-        execvp (*argv, argv);
-#endif
-
-        // there is no return after successful exec()
-        fprintf(stderr, _("Can't execute '%s'\n"), *argv);
-
-        _exit(-1);
-    }
-    else
-    {
-        // we're in parent
-        close(end_proc_detect[1]); // close writing side
-        data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
-                                  GTK_EndProcessDetector, (gpointer)data);
-        if ( sync )
-        {
-            wxASSERT_MSG( !process, "wxProcess param ignored for sync exec" );
-            data->process = NULL;
-
-            // sync execution: indicate it by negating the pid
-            data->pid = -pid;
-
-            // it will be set to 0 from GTK_EndProcessDetector
-            while (data->pid != 0)
-                wxYield();
-
-            int exitcode = data->exitcode;
-
-            delete data;
-
-            return exitcode;
-        }
-        else
-        {
-            // async execution, nothing special to do - caller will be
-            // notified about the process terminationif process != NULL, data
-            // will be deleted in GTK_EndProcessDetector
-            data->process = process;
-            data->pid = pid;
-
-            return pid;
-        }
-    }
+    return tag;
 }
 
-long wxExecute( const wxString& command, bool sync, wxProcess *process )
-{
-    static const char *IFS = " \t\n";
-
-    wxCHECK_MSG( !command.IsEmpty(), 0, "can't exec empty command" );
-
-    int argc = 0;
-    char *argv[127];
-    char *tmp = new char[command.Len() + 1];
-    strcpy(tmp, command);
-
-    argv[argc++] = strtok(tmp, IFS);
-    while ((argv[argc++] = strtok((char *) NULL, IFS)) != NULL)
-        /* loop */ ;
-
-    long lRc = wxExecute(argv, sync, process);
-
-    delete [] tmp;
-
-    return lRc;
-}
index 72994404561dc15534cf8ad07fd9fe1d8f0e882a..4ac3f05954e56e85e1a96eb94b923191f27727a7 100644 (file)
@@ -8,8 +8,9 @@
 // Copyright:   (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
+
 #ifdef __GNUG__
-#pragma implementation "thread.h"
+    #pragma implementation "thread.h"
 #endif
 
 #include "wx/wx.h"
 
 wxMutex::wxMutex()
 {
-  m_locked = 0;
+    m_locked = 0;
 }
 
 wxMutex::~wxMutex()
 {
-  if (m_locked)
-    wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)\n", m_locked );
+    if (m_locked)
+        wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)", m_locked );
 }
 
 wxMutexError wxMutex::Lock()
 {
-  m_locked++;
-  return wxMUTEX_NO_ERROR;
+    m_locked++;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::TryLock()
 {
-  if (m_locked > 0)
-    return wxMUTEX_BUSY;
-  m_locked++;
-  return wxMUTEX_NO_ERROR;
+    if (m_locked > 0)
+        return wxMUTEX_BUSY;
+    m_locked++;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxMutexError wxMutex::Unlock()
 {
-  if (m_locked == 0)
-    return wxMUTEX_UNLOCKED;
-  m_locked--;
-  return wxMUTEX_NO_ERROR;
+    if (m_locked == 0)
+        return wxMUTEX_UNLOCKED;
+    m_locked--;
+    return wxMUTEX_NO_ERROR;
 }
 
 wxCondition::wxCondition()
@@ -63,9 +64,9 @@ void wxCondition::Wait(wxMutex& WXUNUSED(mutex))
 }
 
 bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec),
-                      unsigned long WXUNUSED(nsec))
+        unsigned long WXUNUSED(nsec))
 {
-  return FALSE;
+    return FALSE;
 }
 
 void wxCondition::Signal()
@@ -76,31 +77,32 @@ void wxCondition::Broadcast()
 {
 }
 
-struct wxThreadInternal {
-       int thread_id;
-       void* exit_status;
+struct wxThreadInternal
+{
+    int thread_id;
+    void* exit_status;
 };
 
 wxThreadError wxThread::Create()
 {
-  p_internal->exit_status = Entry();
-  OnExit();
-  return wxTHREAD_NO_ERROR;
+    p_internal->exit_status = Entry();
+    OnExit();
+    return wxTHREAD_NO_ERROR;
 }
 
 wxThreadError wxThread::Destroy()
 {
-  return wxTHREAD_NOT_RUNNING;
+    return wxTHREAD_NOT_RUNNING;
 }
 
 wxThreadError wxThread::Pause()
 {
-  return wxTHREAD_NOT_RUNNING;
+    return wxTHREAD_NOT_RUNNING;
 }
 
 wxThreadError wxThread::Resume()
 {
-  return wxTHREAD_NOT_RUNNING;
+    return wxTHREAD_NOT_RUNNING;
 }
 
 void wxThread::DeferDestroy( bool WXUNUSED(on) )
@@ -113,27 +115,27 @@ void wxThread::TestDestroy()
 
 void *wxThread::Join()
 {
-  return p_internal->exit_status;
+    return p_internal->exit_status;
 }
 
 unsigned long wxThread::GetID() const
 {
-  return 0;
+    return 0;
 }
 
 bool wxThread::IsMain()
 {
-  return TRUE;
+    return TRUE;
 }
 
 bool wxThread::IsRunning() const
 {
-  return FALSE;
+    return FALSE;
 }
 
 bool wxThread::IsAlive() const
 {
-  return FALSE;
+    return FALSE;
 }
 
 void wxThread::SetPriority(int WXUNUSED(prio)) { }
@@ -143,36 +145,35 @@ wxMutex *wxMainMutex; // controls access to all GUI functions
 
 wxThread::wxThread()
 {
-  p_internal = new wxThreadInternal();
+    p_internal = new wxThreadInternal();
 }
 
 wxThread::~wxThread()
 {
-  Destroy();
-  Join();
-  delete p_internal;
+    Destroy();
+    Join();
+    delete p_internal;
 }
 
 // The default callback just joins the thread and throws away the result.
 void wxThread::OnExit()
 {
-  Join();
+    Join();
 }
 
-
 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
 
-bool wxThreadModule::OnInit() 
+bool wxThreadModule::OnInit()
 {
-  wxMainMutex = new wxMutex();
-  wxMainMutex->Lock();
-  return TRUE;
+    wxMainMutex = new wxMutex();
+    wxMainMutex->Lock();
+    return TRUE;
 }
 
 void wxThreadModule::OnExit()
 {
-  wxMainMutex->Unlock();
-  delete wxMainMutex;
+    wxMainMutex->Unlock();
+    delete wxMainMutex;
 }
 
 
index a85d45a6208ca32b4537f5dfb4b70131943dfa69..d9ceaf81f4eb4e7951e6a521463018749f070e94 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Robert Roebling
 // Id:          $Id$
 // Copyright:   (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence:           wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/utils.h"
@@ -15,6 +15,8 @@
 
 #include "wx/process.h"
 
+#include "wx/unix/execute.h"
+
 #include <stdarg.h>
 #include <dirent.h>
 #include <string.h>
@@ -27,7 +29,6 @@
 #include <netdb.h>
 #include <signal.h>
 #include <fcntl.h>          // for O_WRONLY and friends
-#include <time.h>           // nanosleep() and/or usleep()
 
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gtk/gtkfeatures.h>
 #include <gdk/gdkx.h>
 
-#ifdef __SVR4__
-  #include <sys/systeminfo.h>
-#endif
-
-// many versions of Unices have this function, but it is not defined in system
-// headers - please add your system here if it is the case for your OS.
-// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this.
-#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
-                         !defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
-     defined(__osf__)
-    extern "C"
-    {
-        void usleep(unsigned long usec);
-    };
-#endif // Unices without usleep()
-
-// many versions of Unices have this function, but it is not defined in system
-// headers - please add your system here if it is the case for your OS.
-// SunOS (and Solaris) and DG-UX are like this.
-#if defined(__SOLARIS__) || defined(__osf__)
-    extern "C"
-    {
-        pid_t wait4(pid_t pid, int *statusp, int options,
-                    struct rusage *rusage);
-    }
-
-    #define wxWait4(pid, stat, flags, rusage) wait4(pid, stat, flags, rusage)
-#elif defined(__sgi) || defined(__HPUX__)
-    // no wait4() at all on these systems
-    // TODO verify whether wait3() really works in this situation
-    #define wxWait4(pid, stat, flags, rusage) wait3(stat, flags, rusage)
-#else
-    // other Unices: assume have wait4(), although it's not standard (but
-    // Linux and FreeBSD do have it)
-    #define wxWait4(pid, stat, flags, rusage) wait4(pid, stat, flags, rusage)
-#endif // wait4()
-
-//------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // misc.
-//------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
-void wxBell(void)
+void wxBell()
 {
     gdk_beep();
 }
 
-void wxSleep(int nSecs)
-{
-    sleep(nSecs);
-}
-
-void wxUsleep(unsigned long milliseconds)
-{
-#if defined(HAVE_NANOSLEEP)
-    timespec tmReq;
-    tmReq.tv_sec = milliseconds / 1000;
-    tmReq.tv_nsec = (milliseconds % 1000) * 1000 * 1000;
-
-    // we're not interested in remaining time nor in return value
-    (void)nanosleep(&tmReq, (timespec *)NULL);
-#elif defined(HAVE_USLEEP)
-    // uncomment this if you feel brave or if you are sure that your version
-    // of Solaris has a safe usleep() function but please notice that usleep()
-    // is known to lead to crashes in MT programs in Solaris 2.[67] and is not
-    // documented as MT-Safe
-    #if defined(__SUN__) && defined(wxUSE_THREADS)
-        #error "usleep() cannot be used in MT programs under Solaris."
-    #endif // Sun
-
-    usleep(milliseconds * 1000); // usleep(3) wants microseconds
-#else // !sleep function
-    #error "usleep() or nanosleep() function required for wxUsleep"
-#endif // sleep function
-}
-
-int wxKill(long pid, int sig)
-{
-    return kill(pid, sig);
-}
+// ----------------------------------------------------------------------------
+// display characterstics
+// ----------------------------------------------------------------------------
 
 void wxDisplaySize( int *width, int *height )
 {
@@ -126,12 +60,12 @@ void wxGetMousePosition( int* x, int* y )
     gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
 }
 
-bool wxColourDisplay(void)
+bool wxColourDisplay()
 {
     return TRUE;
 }
 
-int wxDisplayDepth(void)
+int wxDisplayDepth()
 {
     return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth;
 }
@@ -144,312 +78,28 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
   return wxGTK;
 }
 
-//------------------------------------------------------------------------
-// user and home routines
-//------------------------------------------------------------------------
-
-const char* wxGetHomeDir( wxString *home  )
-{
-    *home = wxGetUserHome( wxString() );
-    if (home->IsNull()) *home = "/";
-    return *home;
-}
-
-char *wxGetUserHome( const wxString &user )
-{
-    struct passwd *who = (struct passwd *) NULL;
-
-    if (user.IsNull() || (user== ""))
-    {
-        register char *ptr;
-
-        if ((ptr = getenv("HOME")) != NULL)
-       {
-            return ptr;
-       }
-        if ((ptr = getenv("USER")) != NULL || (ptr = getenv("LOGNAME")) != NULL)
-       {
-            who = getpwnam(ptr);
-        }
-
-        /* We now make sure the the user exists! */
-        if (who == NULL)
-       {
-            who = getpwuid(getuid());
-       }
-    }
-    else
-    {
-      who = getpwnam (user);
-    }
-
-    return who ? who->pw_dir : (char*)NULL;
-}
-
-//------------------------------------------------------------------------
-// id routines
-//------------------------------------------------------------------------
-
-bool wxGetHostName(char *buf, int sz)
-{
-    *buf = '\0';
-#if defined(__SVR4__) && !defined(__sgi)
-    //KB: does this return the fully qualified host.domain name?
-    return (sysinfo(SI_HOSTNAME, buf, sz) != -1);
-#else /* BSD Sockets */
-    char name[255], domain[255];
-    //struct hostent *h;
-    // Get hostname
-    if (gethostname(name, sizeof(name)/sizeof(char)-1) == -1)
-        return FALSE;
-    if (getdomainname(domain, sizeof(domain)/sizeof(char)-1) == -1)
-        return FALSE;
-    // Get official full name of host
-    // doesn't return the full qualified name, replaced by following
-    // code (KB)
-    // strncpy(buf, (h=gethostbyname(name))!=NULL ? h->h_name : name, sz-1);
-    if((unsigned)sz > strlen(name)+strlen(domain)+1)
-    {
-        strcpy(buf, name);
-        if(strcmp(domain,"(none)") == 0) // standalone machine
-        {
-            strcat(buf,".");
-            strcat(buf,domain);
-        }
-    }
-    else
-        return FALSE;
-    return TRUE;
-#endif
-}
-
-bool wxGetUserId(char *buf, int sz)
-{
-    struct passwd *who;
-
-    *buf = '\0';
-    if ((who = getpwuid(getuid ())) != NULL) {
-        strncpy (buf, who->pw_name, sz-1);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-bool wxGetUserName(char *buf, int sz)
-{
-    struct passwd *who;
-    char *comma;
-
-    *buf = '\0';
-    if ((who = getpwuid (getuid ())) != NULL) {
-       comma = strchr(who->pw_gecos,'c');
-       if(comma) *comma = '\0'; // cut off non-name comment fields
-       strncpy (buf, who->pw_gecos, sz - 1);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-//------------------------------------------------------------------------
-// error and debug output routines
-//------------------------------------------------------------------------
-
-void wxDebugMsg( const char *format, ... )
-{
-  va_list ap;
-  va_start( ap, format );
-  vfprintf( stderr, format, ap );
-  fflush( stderr );
-  va_end(ap);
-}
-
-void wxError( const wxString &msg, const wxString &title )
-{
-  fprintf( stderr, "Error " );
-  if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
-  if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
-  fprintf( stderr, ".\n" );
-}
-
-void wxFatalError( const wxString &msg, const wxString &title )
-{
-  fprintf( stderr, "Error " );
-  if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
-  if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
-  fprintf( stderr, ".\n" );
-  exit(3); // the same exit code as for abort()
-}
-
-//------------------------------------------------------------------------
-// directory routines
-//------------------------------------------------------------------------
-
-bool wxDirExists( const wxString& dir )
-{
-    char buf[500];
-    strcpy( buf, WXSTRINGCAST(dir) );
-    struct stat sbuf;
-    return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE);
-}
-
-//------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // subprocess routines
-//------------------------------------------------------------------------
-
-// if pid > 0, the execution is async and the data is freed in
-// GTK_EndProcessDetector, if pid < 0, the execution is synchronous and the
-// caller (wxExecute) frees the data
-struct wxEndProcessData
-{
-    gint pid, tag;
-    wxProcess *process;
-    int  exitcode;
-};
+// ----------------------------------------------------------------------------
 
 static void GTK_EndProcessDetector(gpointer data, gint source,
                                    GdkInputCondition WXUNUSED(condition) )
 {
     wxEndProcessData *proc_data = (wxEndProcessData *)data;
-    int pid;
-
-    pid = (proc_data->pid > 0) ? proc_data->pid : -(proc_data->pid);
 
-    int status = 0;
-    wxWait4(pid, &status, 0, (rusage *) NULL);
+    wxHandleProcessTermination(proc_data);
 
     close(source);
     gdk_input_remove(proc_data->tag);
-
-    if (proc_data->process)
-        proc_data->process->OnTerminate(proc_data->pid, status);
-
-    if (proc_data->pid > 0)
-    {
-        delete proc_data;
-    }
-    else
-    {
-        // wxExecute() will know about it
-        proc_data->exitcode = status;
-
-        proc_data->pid = 0;
-    }
 }
 
-long wxExecute( char **argv, bool sync, wxProcess *process )
+int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
 {
-    wxEndProcessData *data = new wxEndProcessData;
-    int end_proc_detect[2];
-
-    wxCHECK_MSG( *argv, 0, "can't exec empty command" );
-
-    /* Create pipes */
-    if (pipe(end_proc_detect) == -1)
-    {
-        wxLogSysError( _("Pipe creation failed") );
-        return 0;
-    }
+    int tag = gdk_input_add(fd,
+                            GDK_INPUT_READ,
+                            GTK_EndProcessDetector,
+                            (gpointer)proc_data);
 
-    /* fork the process */
-#if defined(sun) || defined(__ultrix) || defined(__bsdi__)
-    pid_t pid = vfork();
-#else
-    pid_t pid = fork();
-#endif
-    if (pid == -1)
-    {
-        wxLogSysError( _("Fork failed") );
-        return 0;
-    }
-    else if (pid == 0)
-    {
-        // we're in child
-        close(end_proc_detect[0]); // close reading side
-
-        // These three lines close the open file descriptors to to avoid any
-        // input/output which might block the process or irritate the user. If
-        // one wants proper IO for the subprocess, the "right thing to do is
-        // to start an xterm executing it.
-        close(STDIN_FILENO);
-        close(STDOUT_FILENO);
-
-        // leave stderr opened, it won't do any hurm
-#if 0
-        close(STDERR_FILENO);
-
-        // some programs complain about stderr not being open, so redirect
-        // them:
-        open("/dev/null", O_RDONLY);  // stdin
-        open("/dev/null", O_WRONLY);  // stdout
-        open("/dev/null", O_WRONLY);  // stderr
-#endif
-
-#ifdef _AIX
-        execvp ((const char *)*argv, (const char **)argv);
-#else
-        execvp (*argv, argv);
-#endif
-
-        // there is no return after successful exec()
-        fprintf(stderr, _("Can't execute '%s'\n"), *argv);
-
-        _exit(-1);
-    }
-    else
-    {
-        // we're in parent
-        close(end_proc_detect[1]); // close writing side
-        data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
-                                  GTK_EndProcessDetector, (gpointer)data);
-        if ( sync )
-        {
-            wxASSERT_MSG( !process, "wxProcess param ignored for sync exec" );
-            data->process = NULL;
-
-            // sync execution: indicate it by negating the pid
-            data->pid = -pid;
-
-            // it will be set to 0 from GTK_EndProcessDetector
-            while (data->pid != 0)
-                wxYield();
-
-            int exitcode = data->exitcode;
-
-            delete data;
-
-            return exitcode;
-        }
-        else
-        {
-            // async execution, nothing special to do - caller will be
-            // notified about the process terminationif process != NULL, data
-            // will be deleted in GTK_EndProcessDetector
-            data->process = process;
-            data->pid = pid;
-
-            return pid;
-        }
-    }
+    return tag;
 }
 
-long wxExecute( const wxString& command, bool sync, wxProcess *process )
-{
-    static const char *IFS = " \t\n";
-
-    wxCHECK_MSG( !command.IsEmpty(), 0, "can't exec empty command" );
-
-    int argc = 0;
-    char *argv[127];
-    char *tmp = new char[command.Len() + 1];
-    strcpy(tmp, command);
-
-    argv[argc++] = strtok(tmp, IFS);
-    while ((argv[argc++] = strtok((char *) NULL, IFS)) != NULL)
-        /* loop */ ;
-
-    long lRc = wxExecute(argv, sync, process);
-
-    delete [] tmp;
-
-    return lRc;
-}
index 0b8b01a03ad8f1bad6b4eb7d4be9191187147862..97e2911eb03d0b964c5366f9330fed7b3a411cd4 100644 (file)
@@ -603,6 +603,12 @@ bool wxYield()
 {
     while (wxTheApp && wxTheApp->Pending())
         wxTheApp->Dispatch();
+
+    // VZ: is it the same as this (taken from old wxExecute)?
+#if 0
+    XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+#endif
+
     return TRUE;
 }
 
index 94820453fb528f4fa9d1dd46a50df3a8434c735e..e981f6e89daca5df03293110dfb91c3de1bab64d 100644 (file)
@@ -6,14 +6,16 @@
 // Created:     17/09/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:    wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-// Note: this is done in utilscmn.cpp now.
-// #pragma implementation
-// #pragma implementation "utils.h"
-#endif
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
 
 #include "wx/setup.h"
 #include "wx/utils.h"
 #include <netdb.h>
 #include <signal.h>
 
-#if defined(__SOLARIS__) || defined(__SVR4__) && !defined(__HPUX__)
-#include <sys/systeminfo.h>
-#endif
-
 #if (defined(__SUNCC__) || defined(__CLCC__))
-#include <sysent.h>
+    #include <sysent.h>
 #endif
 
 #include <Xm/Xm.h>
 
 #include "wx/motif/private.h"
 
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
 // Yuck this is really BOTH site and platform dependent
 // so we should use some other strategy!
 #ifdef sun
-define DEFAULT_XRESOURCE_DIR "/usr/openwin/lib/app-defaults"
+    #define DEFAULT_XRESOURCE_DIR "/usr/openwin/lib/app-defaults"
 #else
-define DEFAULT_XRESOURCE_DIR "/usr/lib/X11/app-defaults"
+    #define DEFAULT_XRESOURCE_DIR "/usr/lib/X11/app-defaults"
 #endif
 
 static char *GetIniFile (char *dest, const char *filename);
 
 extern wxList wxTopLevelWindows;
 
-// Get full hostname (eg. DoDo.BSn-Germany.crg.de)
-bool wxGetHostName(char *buf, int maxSize)
-{
-#if defined(__SOLARIS__) || defined(__SVR4__) && !defined(__HPUX__)
-    return (sysinfo (SI_HOSTNAME, buf, maxSize) != -1);
-#else /* BSD Sockets */
-    char name[255];
-    struct hostent *h;
-    
-    // Get hostname
-    if (gethostname (name, sizeof (name) / sizeof (char) - 1) == -1)
-        return FALSE;
-    // Get official full name of host
-    strncpy (buf
-        ,(h = gethostbyname (name)) != NULL ? h->h_name : name
-        ,maxSize - 1);
-    return TRUE;
-#endif
-}
+// ============================================================================
+// implementation
+// ============================================================================
 
-// Get user ID e.g. jacs
-bool wxGetUserId(char *buf, int maxSize)
-{
-#ifdef VMS
-    *buf = '\0'; // return empty string
-    return FALSE;
-#else
-    struct passwd *who;
-    
-    if ((who = getpwuid (getuid ())) != NULL)
-    {
-        strncpy (buf, who->pw_name, maxSize - 1);
-        return TRUE;
-    }
-    return FALSE;
-#endif
-}
-
-// Get user name e.g. Julian Smart
-bool wxGetUserName(char *buf, int maxSize)
-{
-#ifdef VMS
-    *buf = '\0'; // return empty string
-    return FALSE;
-#else
-    struct passwd *who;
-    
-    if ((who = getpwuid (getuid ())) != NULL)
-    {
-        strncpy (buf, who->pw_gecos, maxSize - 1);
-        return TRUE;
-    }
-    return FALSE;
-#endif
-}
-
-int wxKill(long pid, int sig)
-{
-    int unixSignal = 0;
-    switch (sig)
-    {
-    case wxSIGTERM:
-    default:
-        unixSignal = SIGTERM;
-    }
-    return kill( (int)pid, unixSignal);
-}
-
-//
-// Execute a program in an Interactive Shell
-//
-bool wxShell(const wxString& command)
-{
-#ifdef VMS
-    return(FALSE);
-#else
-#if defined(sun) || defined(__ultrix) || defined(__bsdi__)
-    pid_t pid = vfork ();
-#else
-    pid_t pid = fork ();
-#endif
-    switch( pid ) {
-    case -1:                   /* error */
-        return(FALSE);
-    case 0:                    /* child */
-        // Generic X windows terminal window
-        if (command != "")
-            execlp("xterm", "-e", (char *) (const char*) command, NULL);
-        else
-            execlp("xterm", NULL);
-        _exit(127);
-    }
-    return TRUE;
-#endif
-    // End VMS
-}
-
-// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
-long wxGetFreeMemory()
-{
-    return -1;
-}
-
-void wxSleep(int nSecs)
-{
-    sleep(nSecs);
-}
+// ----------------------------------------------------------------------------
+// async event processing
+// ----------------------------------------------------------------------------
 
 // Consume all events until no more left
 void wxFlushEvents()
 {
     Display *display = (Display*) wxGetDisplay();
-    
+
     XSync (display, FALSE);
     XEvent event;
     // XtAppPending returns availability of events AND timers/inputs, which
-    // are processed via callbacks, so XtAppNextEvent will not return if 
+    // are processed via callbacks, so XtAppNextEvent will not return if
     // there are no events. So added '& XtIMXEvent' - Sergey.
     while (XtAppPending ((XtAppContext) wxTheApp->GetAppContext()) & XtIMXEvent)
     {
@@ -184,36 +86,70 @@ void wxFlushEvents()
     }
 }
 
-// Output a debug message, in a system dependent fashion.
-void wxDebugMsg(const char *fmt ...)
+// Check whether this window wants to process messages, e.g. Stop button
+// in long calculations.
+bool wxCheckForInterrupt(wxWindow *wnd)
 {
-    va_list ap;
-    char buffer[BUFSIZ];
-    
-    if (!wxTheApp->GetWantDebugOutput())
-        return ;
-    
-    va_start (ap, fmt);
-    
-    vsprintf (buffer, fmt, ap);
-    cerr << buffer;
-    
-    va_end (ap);
+    wxCHECK_MSG( wnd, FALSE, "NULL window in wxCheckForInterrupt" );
+
+    Display *dpy=(Display*) wnd->GetXDisplay();
+    Window win=(Window) wnd->GetXWindow();
+    XEvent event;
+    XFlush(dpy);
+    if (wnd->GetMainWidget())
+    {
+        XmUpdateDisplay((Widget)(wnd->GetMainWidget()));
+    }
+
+    bool hadEvents = FALSE;
+    while( XCheckMaskEvent(dpy,
+                           ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|
+                           PointerMotionMask|KeyPressMask|KeyReleaseMask,
+                           &event) )
+    {
+        if ( event.xany.window == win )
+        {
+            hadEvents = TRUE;
+
+            XtDispatchEvent(&event);
+        }
+    }
+
+    return hadEvents;
 }
 
-// Non-fatal error: pop up message box and (possibly) continue
-void wxError(const wxString& msg, const wxString& title)
+// ----------------------------------------------------------------------------
+// wxExecute stuff
+// ----------------------------------------------------------------------------
+
+static void xt_notify_end_process(XtPointer client, int *fid,
+                                  XtInputId *id)
 {
-    cerr << (const char*) title << ": " << (const char*) msg << "\n";
+    wxEndProcessData *proc_data = (wxEndProcessData *)data;
+
+    wxHandleProcessTermination(proc_data);
+
+    // VZ: I think they should be the same...
+    wxASSERT( (int)*id == proc_data->tag );
+
+    XtRemoveInput(*id);
 }
 
-// Fatal error: pop up message box and abort
-void wxFatalError(const wxString& msg, const wxString& title)
+int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
 {
-    cerr << (const char*) title << ": " << (const char*) msg << "\n";
-    exit (1);
+    XtInputId id = XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(),
+                                 fd,
+                                 (XtPointer *) XtInputReadMask,
+                                 (XtInputCallbackProc) xt_notify_end_process,
+                                 (XtPointer) process_data);
+
+    return (int)id;
 }
 
+// ----------------------------------------------------------------------------
+// misc
+// ----------------------------------------------------------------------------
+
 // Emit a beeeeeep
 void wxBell()
 {
@@ -223,19 +159,53 @@ void wxBell()
 
 int wxGetOsVersion(int *majorVsn, int *minorVsn)
 {
-    // TODO
+    // FIXME TODO
     // This code is WRONG!! Does NOT return the
     // Motif version of the libs but the X protocol
-    // version! @@@@@ Fix ME!!!!!!!!!
+    // version!
     Display *display = XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
     if (majorVsn)
         *majorVsn = ProtocolVersion (display);
     if (minorVsn)
         *minorVsn = ProtocolRevision (display);
+
     return wxMOTIF_X;
 }
 
+// ----------------------------------------------------------------------------
 // Reading and writing resources (eg WIN.INI, .Xdefaults)
+// ----------------------------------------------------------------------------
+
+// Read $HOME for what it says is home, if not
+// read $USER or $LOGNAME for user name else determine
+// the Real User, then determine the Real home dir.
+static char * GetIniFile (char *dest, const char *filename)
+{
+    char *home = NULL;
+    if (filename && wxIsAbsolutePath(filename))
+    {
+        strcpy(dest, filename);
+    }
+    else if ((home = wxGetUserHome("")) != NULL)
+    {
+        strcpy(dest, home);
+        if (dest[strlen(dest) - 1] != '/')
+            strcat (dest, "/");
+        if (filename == NULL)
+        {
+            if ((filename = getenv ("XENVIRONMENT")) == NULL)
+                filename = ".Xdefaults";
+        }
+        else if (*filename != '.')
+            strcat (dest, ".");
+        strcat (dest, filename);
+    } else
+    {
+        dest[0] = '\0';
+    }
+    return dest;
+}
+
 #if wxUSE_RESOURCES
 
 static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
@@ -244,7 +214,7 @@ static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
         strcpy(buf, name);
         return buf; // Exists so ...
     }
-    
+
     if (*name == '/')
         strcpy(buf, name);
     else {
@@ -253,7 +223,7 @@ static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
         strcat (buf, "/");
         strcat (buf, (const char*) wxFileNameFromPath (name));
     }
-    
+
     if (create) {
         // Touch the file to create it
         FILE *fd = fopen (buf, "w");
@@ -271,18 +241,18 @@ static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
 
 wxList wxResourceCache (wxKEY_STRING);
 
-void 
+void
 wxFlushResources (void)
 {
     char nameBuffer[512];
-    
+
     wxNode *node = wxResourceCache.First ();
     while (node)
     {
         const char *file = node->GetKeyString();
         // If file doesn't exist, create it first.
         (void)GetResourcePath(nameBuffer, file, TRUE);
-        
+
         XrmDatabase database = (XrmDatabase) node->Data ();
         XrmPutFileDatabase (database, nameBuffer);
         XrmDestroyDatabase (database);
@@ -299,9 +269,9 @@ void wxXMergeDatabases (wxApp * theApp, Display * display);
 bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
 {
     char buffer[500];
-    
+
     (void) GetIniFile (buffer, file);
-    
+
     XrmDatabase database;
     wxNode *node = wxResourceCache.Find (buffer);
     if (node)
@@ -311,12 +281,12 @@ bool wxWriteResource(const wxString& section, const wxString& entry, const wxStr
         database = XrmGetFileDatabase (buffer);
         wxResourceCache.Append (buffer, (wxObject *) database);
     }
-    
+
     char resName[300];
     strcpy (resName, (const char*) section);
     strcat (resName, ".");
     strcat (resName, (const char*) entry);
-    
+
     XrmPutStringResource (&database, resName, value);
     return TRUE;
 }
@@ -349,17 +319,17 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value,
         Display *display = (Display*) wxGetDisplay();
         wxXMergeDatabases (wxTheApp, display);
     }
-    
+
     XrmDatabase database;
-    
+
     if (file != "")
     {
         char buffer[500];
-        
+
         // Is this right? Trying to get it to look in the user's
         // home directory instead of current directory -- JACS
         (void) GetIniFile (buffer, file);
-        
+
         wxNode *node = wxResourceCache.Find (buffer);
         if (node)
             database = (XrmDatabase) node->Data ();
@@ -371,14 +341,14 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value,
     }
     else
         database = wxResourceDatabase;
-    
+
     XrmValue xvalue;
     char *str_type[20];
     char buf[150];
     strcpy (buf, section);
     strcat (buf, ".");
     strcat (buf, entry);
-    
+
     Bool success = XrmGetResource (database, buf, "*", str_type,
         &xvalue);
     // Try different combinations of upper/lower case, just in case...
@@ -392,7 +362,7 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value,
     {
         if (*value)
             delete[] *value;
-        
+
         *value = new char[xvalue.size + 1];
         strncpy (*value, xvalue.addr, (int) xvalue.size);
         return TRUE;
@@ -433,7 +403,7 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c
     if (succ)
     {
         // Handle True, False here
-        // True, Yes, Enables, Set or  Activated 
+        // True, Yes, Enables, Set or  Activated
         if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
             *value = TRUE;
         // False, No, Disabled, Reset, Cleared, Deactivated
@@ -453,24 +423,24 @@ void wxXMergeDatabases (wxApp * theApp, Display * display)
 {
     XrmDatabase homeDB, serverDB, applicationDB;
     char filenamebuf[1024];
-    
+
     char *filename = &filenamebuf[0];
     char *environment;
     wxString classname = theApp->GetClassName();
     char name[256];
     (void) strcpy (name, "/usr/lib/X11/app-defaults/");
     (void) strcat (name, (const char*) classname);
-    
+
     /* Get application defaults file, if any */
     applicationDB = XrmGetFileDatabase (name);
     (void) XrmMergeDatabases (applicationDB, &wxResourceDatabase);
-    
+
     /* Merge server defaults, created by xrdb, loaded as a property of the root
     * window when the server initializes and loaded into the display
     * structure on XOpenDisplay;
     * if not defined, use .Xdefaults
     */
-    
+
     if (XResourceManagerString (display) != NULL)
     {
         serverDB = XrmGetStringDatabase (XResourceManagerString (display));
@@ -481,11 +451,11 @@ void wxXMergeDatabases (wxApp * theApp, Display * display)
         serverDB = XrmGetFileDatabase (filename);
     }
     XrmMergeDatabases (serverDB, &wxResourceDatabase);
-    
+
     /* Open XENVIRONMENT file, or if not defined, the .Xdefaults,
     * and merge into existing database
     */
-    
+
     if ((environment = getenv ("XENVIRONMENT")) == NULL)
     {
         size_t len;
@@ -507,30 +477,30 @@ void wxXMergeDatabases (wxApp * theApp, Display * display)
 * Not yet used but may be useful.
 *
 */
-void 
+void
 wxSetDefaultResources (const Widget w, const char **resourceSpec, const char *name)
 {
     int i;
-    Display *dpy = XtDisplay (w);      // Retrieve the display pointer
-    
-    XrmDatabase rdb = NULL;    // A resource data base
-    
+    Display *dpy = XtDisplay (w);    // Retrieve the display pointer
+
+    XrmDatabase rdb = NULL;    // A resource data base
+
     // Create an empty resource database
     rdb = XrmGetStringDatabase ("");
-    
+
     // Add the Component resources, prepending the name of the component
-    
+
     i = 0;
     while (resourceSpec[i] != NULL)
     {
         char buf[1000];
-        
+
         sprintf (buf, "*%s%s", name, resourceSpec[i++]);
         XrmPutLineResource (&rdb, buf);
     }
-    
+
     // Merge them into the Xt database, with lowest precendence
-    
+
     if (rdb)
     {
 #if (XlibSpecificationRelease>=5)
@@ -547,20 +517,24 @@ wxSetDefaultResources (const Widget w, const char **resourceSpec, const char *na
 
 #endif // wxUSE_RESOURCES
 
+// ----------------------------------------------------------------------------
+// busy cursor stuff
+// ----------------------------------------------------------------------------
+
 static int wxBusyCursorCount = 0;
 
 // Helper function
-static void 
+static void
 wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
 {
     Display *display = (Display*) win->GetXDisplay();
-    
+
     Window xwin = (Window) win->GetXWindow();
     if (!xwin)
        return;
 
     XSetWindowAttributes attrs;
-    
+
     if (cursor)
     {
         attrs.cursor = (Cursor) cursor->GetXCursor(display);
@@ -575,9 +549,9 @@ wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
     }
     if (xwin)
         XChangeWindowAttributes (display, xwin, CWCursor, &attrs);
-    
+
     XFlush (display);
-    
+
     for(wxNode *node = win->GetChildren().First (); node; node = node->Next())
     {
         wxWindow *child = (wxWindow *) node->Data ();
@@ -604,7 +578,7 @@ void wxEndBusyCursor()
 {
     if (wxBusyCursorCount == 0)
         return;
-    
+
     wxBusyCursorCount--;
     if (wxBusyCursorCount == 0)
     {
@@ -620,81 +594,22 @@ void wxEndBusyCursor()
 bool wxIsBusy()
 {
     return (wxBusyCursorCount > 0);
-}    
-
-const char* wxGetHomeDir( wxString *home  )
-{
-    *home = wxGetUserHome( wxString() );
-    if (home->IsNull()) *home = "/";
-    return *home;
-};
-
-char *wxGetUserHome (const wxString& user)
-{
-#ifdef VMS
-    return(NULL);
-#else
-    struct passwd *who = NULL;
-    
-    if (user == "") {
-        register char *ptr;
-        
-        if ((ptr = getenv("HOME")) != NULL) 
-            return ptr;
-        if ((ptr = getenv("USER")) != NULL ||
-            (ptr = getenv("LOGNAME")) != NULL)
-        {
-            who = getpwnam( ptr );
-        }
-        // We now make sure the the user exists!
-        if (who == NULL)
-            who = getpwuid( getuid() );
-    } else
-        who = getpwnam ((const char*) user);
-    
-    return who ? who->pw_dir : (char*) NULL;
-#endif
-    // ifdef VMS
 }
 
-// Check whether this window wants to process messages, e.g. Stop button
-// in long calculations.
-bool wxCheckForInterrupt(wxWindow *wnd)
-{
-    if(wnd){
-        Display *dpy=(Display*) wnd->GetXDisplay();
-        Window win=(Window) wnd->GetXWindow();
-        XEvent event;
-        XFlush(dpy);
-        if(wnd->GetMainWidget()){
-            XmUpdateDisplay((Widget)(wnd->GetMainWidget()));
-        }
-        while(XCheckMaskEvent(dpy,
-            ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|
-            PointerMotionMask|KeyPressMask|KeyReleaseMask,
-            &event)){
-            if(event.xany.window==win)
-                XtDispatchEvent(&event);
-            //         else
-            //                 XBell(dpy,50);
-        }
-        return TRUE;//*** temporary?
-    }
-    else{
-        wxMessageBox("wnd==NULL !!!");
-        return FALSE;//*** temporary?
-    }
-}
+// ----------------------------------------------------------------------------
+// display info
+// ----------------------------------------------------------------------------
 
 void wxGetMousePosition( int* x, int* y )
 {
     XMotionEvent xev;
     Window root, child;
     XQueryPointer((Display*) wxGetDisplay(),
-        DefaultRootWindow((Display*) wxGetDisplay()), &root, &child,
-        &(xev.x_root), &(xev.y_root),
-        &(xev.x),      &(xev.y),
-        &(xev.state));
+                  DefaultRootWindow((Display*) wxGetDisplay()),
+                  &root, &child,
+                  &(xev.x_root), &(xev.y_root),
+                  &(xev.x),      &(xev.y),
+                  &(xev.state));
     *x = xev.x_root;
     *y = xev.y_root;
 };
@@ -702,18 +617,14 @@ void wxGetMousePosition( int* x, int* y )
 // Return TRUE if we have a colour display
 bool wxColourDisplay()
 {
-    Display *dpy = (Display*) wxGetDisplay();
-    
-    if (DefaultDepth (dpy, DefaultScreen (dpy)) < 2)
-        return FALSE;
-    else
-        return TRUE;
+    return wxDisplayDepth() > 1;
 }
 
 // Returns depth of screen
 int wxDisplayDepth()
 {
     Display *dpy = (Display*) wxGetDisplay();
+
     return DefaultDepth (dpy, DefaultScreen (dpy));
 }
 
@@ -721,12 +632,14 @@ int wxDisplayDepth()
 void wxDisplaySize(int *width, int *height)
 {
     Display *dpy = (Display*) wxGetDisplay();
-    
-    *width = DisplayWidth (dpy, DefaultScreen (dpy));
-    *height = DisplayHeight (dpy, DefaultScreen (dpy));
+
+    if ( width )
+        *width = DisplayWidth (dpy, DefaultScreen (dpy));
+    if ( height )
+        *height = DisplayHeight (dpy, DefaultScreen (dpy));
 }
 
-/* Configurable display in Motif */
+// Configurable display in Motif
 static WXDisplay *gs_currentDisplay = NULL;
 static wxString gs_displayName;
 
@@ -734,7 +647,7 @@ WXDisplay *wxGetDisplay()
 {
     if (gs_currentDisplay)
         return gs_currentDisplay;
-    
+
     if (wxTheApp && wxTheApp->GetTopLevelWidget())
         return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
     else if (wxTheApp)
@@ -746,34 +659,38 @@ WXDisplay *wxGetDisplay()
 bool wxSetDisplay(const wxString& display_name)
 {
     gs_displayName = display_name;
-    
-    if (display_name.IsNull() || display_name.IsEmpty())
+
+    if ( !display_name )
     {
         gs_currentDisplay = NULL;
+
         return TRUE;
     }
     else
     {
         Cardinal argc = 0;
-        
+
         Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(),
             (const char*) display_name,
             (const char*) wxTheApp->GetAppName(),
             (const char*) wxTheApp->GetClassName(),
             NULL,
-# if XtSpecificationRelease < 5
-            0, &argc, NULL);
-# else
-        0, (int *)&argc, NULL);
-# endif
-        
+#if XtSpecificationRelease < 5
+            0, &argc,
+#else
+            0, (int *)&argc,
+#endif
+            NULL);
+
         if (display)
         {
             gs_currentDisplay = (WXDisplay*) display;
             return TRUE;
-        } else
+        }
+        else
             return FALSE;
     }
+
     return FALSE;
 }
 
@@ -782,6 +699,10 @@ wxString wxGetDisplayName()
     return gs_displayName;
 }
 
+// ----------------------------------------------------------------------------
+// accelerators
+// ----------------------------------------------------------------------------
+
 // Find the letter corresponding to the mnemonic, for Motif
 char wxFindMnemonic (const char *s)
 {
@@ -815,21 +736,21 @@ char * wxFindAccelerator (char *s)
     s++;
     /*
     Now we need to format it as X standard:
-    
+
       input            output
-      
+
         F7           --> <Key>F7
         Ctrl+N       --> Ctrl<Key>N
         Alt+k        --> Meta<Key>k
         Ctrl+Shift+A --> Ctrl Shift<Key>A
-        
+
     */
-    
+
     wxBuffer[0] = '\0';
     char *tmp = copystring (s);
     s = tmp;
     char *p = s;
-    
+
     while (1)
     {
         while (*p && *p != '+')
@@ -869,272 +790,252 @@ XmString wxFindAcceleratorText (char *s)
     return text;
 }
 
+// ----------------------------------------------------------------------------
+// keycode translations
+// ----------------------------------------------------------------------------
+
 #include <X11/keysym.h>
 
+// FIXME what about tables??
+
 int wxCharCodeXToWX(KeySym keySym)
 {
     int id;
-    switch (keySym) {
-    case XK_Shift_L:
-    case XK_Shift_R:
-        id = WXK_SHIFT; break;
-    case XK_Control_L:
-    case XK_Control_R:
-        id = WXK_CONTROL; break;
-    case XK_BackSpace:
-        id = WXK_BACK; break;
-    case XK_Delete:
-        id = WXK_DELETE; break;
-    case XK_Clear:
-        id = WXK_CLEAR; break;
-    case XK_Tab:
-        id = WXK_TAB; break;
-    case XK_numbersign:
-        id = '#'; break;
-    case XK_Return:
-        id = WXK_RETURN; break;
-    case XK_Escape:
-        id = WXK_ESCAPE; break;
-    case XK_Pause:
-    case XK_Break:
-        id = WXK_PAUSE; break;
-    case XK_Num_Lock:
-        id = WXK_NUMLOCK; break;
-    case XK_Scroll_Lock:
-        id = WXK_SCROLL; break;
-        
-    case XK_Home:
-        id = WXK_HOME; break;
-    case XK_End:
-        id = WXK_END; break;
-    case XK_Left:
-        id = WXK_LEFT; break;
-    case XK_Right:
-        id = WXK_RIGHT; break;
-    case XK_Up:
-        id = WXK_UP; break;
-    case XK_Down:
-        id = WXK_DOWN; break;
-    case XK_Next:
-        id = WXK_NEXT; break;
-    case XK_Prior:
-        id = WXK_PRIOR; break;
-    case XK_Menu:
-        id = WXK_MENU; break;
-    case XK_Select:
-        id = WXK_SELECT; break;
-    case XK_Cancel:
-        id = WXK_CANCEL; break;
-    case XK_Print:
-        id = WXK_PRINT; break;
-    case XK_Execute:
-        id = WXK_EXECUTE; break;
-    case XK_Insert:
-        id = WXK_INSERT; break;
-    case XK_Help:
-        id = WXK_HELP; break;
-        
-    case XK_KP_Multiply:
-        id = WXK_MULTIPLY; break;
-    case XK_KP_Add:
-        id = WXK_ADD; break;
-    case XK_KP_Subtract:
-        id = WXK_SUBTRACT; break;
-    case XK_KP_Divide:
-        id = WXK_DIVIDE; break;
-    case XK_KP_Decimal:
-        id = WXK_DECIMAL; break;
-    case XK_KP_Equal:
-        id = '='; break;
-    case XK_KP_Space:
-        id = ' '; break;
-    case XK_KP_Tab:
-        id = WXK_TAB; break;
-    case XK_KP_Enter:
-        id = WXK_RETURN; break;
-    case XK_KP_0:
-        id = WXK_NUMPAD0; break;
-    case XK_KP_1:
-        id = WXK_NUMPAD1; break;
-    case XK_KP_2:
-        id = WXK_NUMPAD2; break;
-    case XK_KP_3:
-        id = WXK_NUMPAD3; break;
-    case XK_KP_4:
-        id = WXK_NUMPAD4; break;
-    case XK_KP_5:
-        id = WXK_NUMPAD5; break;
-    case XK_KP_6:
-        id = WXK_NUMPAD6; break;
-    case XK_KP_7:
-        id = WXK_NUMPAD7; break;
-    case XK_KP_8:
-        id = WXK_NUMPAD8; break;
-    case XK_KP_9:
-        id = WXK_NUMPAD9; break;
-    case XK_F1:
-        id = WXK_F1; break;
-    case XK_F2:
-        id = WXK_F2; break;
-    case XK_F3:
-        id = WXK_F3; break;
-    case XK_F4:
-        id = WXK_F4; break;
-    case XK_F5:
-        id = WXK_F5; break;
-    case XK_F6:
-        id = WXK_F6; break;
-    case XK_F7:
-        id = WXK_F7; break;
-    case XK_F8:
-        id = WXK_F8; break;
-    case XK_F9:
-        id = WXK_F9; break;
-    case XK_F10:
-        id = WXK_F10; break;
-    case XK_F11:
-        id = WXK_F11; break;
-    case XK_F12:
-        id = WXK_F12; break;
-    case XK_F13:
-        id = WXK_F13; break;
-    case XK_F14:
-        id = WXK_F14; break;
-    case XK_F15:
-        id = WXK_F15; break;
-    case XK_F16:
-        id = WXK_F16; break;
-    case XK_F17:
-        id = WXK_F17; break;
-    case XK_F18:
-        id = WXK_F18; break;
-    case XK_F19:
-        id = WXK_F19; break;
-    case XK_F20:
-        id = WXK_F20; break;
-    case XK_F21:
-        id = WXK_F21; break;
-    case XK_F22:
-        id = WXK_F22; break;
-    case XK_F23:
-        id = WXK_F23; break;
-    case XK_F24:
-        id = WXK_F24; break;
-    default:
-        id = (keySym <= 255) ? (int)keySym : -1;
-  } // switch
-  return id;
+    switch (keySym)
+    {
+        case XK_Shift_L:
+        case XK_Shift_R:
+            id = WXK_SHIFT; break;
+        case XK_Control_L:
+        case XK_Control_R:
+            id = WXK_CONTROL; break;
+        case XK_BackSpace:
+            id = WXK_BACK; break;
+        case XK_Delete:
+            id = WXK_DELETE; break;
+        case XK_Clear:
+            id = WXK_CLEAR; break;
+        case XK_Tab:
+            id = WXK_TAB; break;
+        case XK_numbersign:
+            id = '#'; break;
+        case XK_Return:
+            id = WXK_RETURN; break;
+        case XK_Escape:
+            id = WXK_ESCAPE; break;
+        case XK_Pause:
+        case XK_Break:
+            id = WXK_PAUSE; break;
+        case XK_Num_Lock:
+            id = WXK_NUMLOCK; break;
+        case XK_Scroll_Lock:
+            id = WXK_SCROLL; break;
+
+        case XK_Home:
+            id = WXK_HOME; break;
+        case XK_End:
+            id = WXK_END; break;
+        case XK_Left:
+            id = WXK_LEFT; break;
+        case XK_Right:
+            id = WXK_RIGHT; break;
+        case XK_Up:
+            id = WXK_UP; break;
+        case XK_Down:
+            id = WXK_DOWN; break;
+        case XK_Next:
+            id = WXK_NEXT; break;
+        case XK_Prior:
+            id = WXK_PRIOR; break;
+        case XK_Menu:
+            id = WXK_MENU; break;
+        case XK_Select:
+            id = WXK_SELECT; break;
+        case XK_Cancel:
+            id = WXK_CANCEL; break;
+        case XK_Print:
+            id = WXK_PRINT; break;
+        case XK_Execute:
+            id = WXK_EXECUTE; break;
+        case XK_Insert:
+            id = WXK_INSERT; break;
+        case XK_Help:
+            id = WXK_HELP; break;
+
+        case XK_KP_Multiply:
+            id = WXK_MULTIPLY; break;
+        case XK_KP_Add:
+            id = WXK_ADD; break;
+        case XK_KP_Subtract:
+            id = WXK_SUBTRACT; break;
+        case XK_KP_Divide:
+            id = WXK_DIVIDE; break;
+        case XK_KP_Decimal:
+            id = WXK_DECIMAL; break;
+        case XK_KP_Equal:
+            id = '='; break;
+        case XK_KP_Space:
+            id = ' '; break;
+        case XK_KP_Tab:
+            id = WXK_TAB; break;
+        case XK_KP_Enter:
+            id = WXK_RETURN; break;
+        case XK_KP_0:
+            id = WXK_NUMPAD0; break;
+        case XK_KP_1:
+            id = WXK_NUMPAD1; break;
+        case XK_KP_2:
+            id = WXK_NUMPAD2; break;
+        case XK_KP_3:
+            id = WXK_NUMPAD3; break;
+        case XK_KP_4:
+            id = WXK_NUMPAD4; break;
+        case XK_KP_5:
+            id = WXK_NUMPAD5; break;
+        case XK_KP_6:
+            id = WXK_NUMPAD6; break;
+        case XK_KP_7:
+            id = WXK_NUMPAD7; break;
+        case XK_KP_8:
+            id = WXK_NUMPAD8; break;
+        case XK_KP_9:
+            id = WXK_NUMPAD9; break;
+        case XK_F1:
+            id = WXK_F1; break;
+        case XK_F2:
+            id = WXK_F2; break;
+        case XK_F3:
+            id = WXK_F3; break;
+        case XK_F4:
+            id = WXK_F4; break;
+        case XK_F5:
+            id = WXK_F5; break;
+        case XK_F6:
+            id = WXK_F6; break;
+        case XK_F7:
+            id = WXK_F7; break;
+        case XK_F8:
+            id = WXK_F8; break;
+        case XK_F9:
+            id = WXK_F9; break;
+        case XK_F10:
+            id = WXK_F10; break;
+        case XK_F11:
+            id = WXK_F11; break;
+        case XK_F12:
+            id = WXK_F12; break;
+        case XK_F13:
+            id = WXK_F13; break;
+        case XK_F14:
+            id = WXK_F14; break;
+        case XK_F15:
+            id = WXK_F15; break;
+        case XK_F16:
+            id = WXK_F16; break;
+        case XK_F17:
+            id = WXK_F17; break;
+        case XK_F18:
+            id = WXK_F18; break;
+        case XK_F19:
+            id = WXK_F19; break;
+        case XK_F20:
+            id = WXK_F20; break;
+        case XK_F21:
+            id = WXK_F21; break;
+        case XK_F22:
+            id = WXK_F22; break;
+        case XK_F23:
+            id = WXK_F23; break;
+        case XK_F24:
+            id = WXK_F24; break;
+        default:
+            id = (keySym <= 255) ? (int)keySym : -1;
+    }
+
+    return id;
 }
 
 KeySym wxCharCodeWXToX(int id)
 {
     KeySym keySym;
-    
-    switch (id) {
-    case WXK_CANCEL:            keySym = XK_Cancel; break;
-    case WXK_BACK:              keySym = XK_BackSpace; break;
-    case WXK_TAB:              keySym = XK_Tab; break;
-    case WXK_CLEAR:            keySym = XK_Clear; break;
-    case WXK_RETURN:           keySym = XK_Return; break;
-    case WXK_SHIFT:            keySym = XK_Shift_L; break;
-    case WXK_CONTROL:          keySym = XK_Control_L; break;
-    case WXK_MENU :            keySym = XK_Menu; break;
-    case WXK_PAUSE:            keySym = XK_Pause; break;
-    case WXK_ESCAPE:           keySym = XK_Escape; break;
-    case WXK_SPACE:            keySym = ' '; break;
-    case WXK_PRIOR:            keySym = XK_Prior; break;
-    case WXK_NEXT :            keySym = XK_Next; break;
-    case WXK_END:              keySym = XK_End; break;
-    case WXK_HOME :            keySym = XK_Home; break;
-    case WXK_LEFT :            keySym = XK_Left; break;
-    case WXK_UP:               keySym = XK_Up; break;
-    case WXK_RIGHT:            keySym = XK_Right; break;
-    case WXK_DOWN :            keySym = XK_Down; break;
-    case WXK_SELECT:           keySym = XK_Select; break;
-    case WXK_PRINT:            keySym = XK_Print; break;
-    case WXK_EXECUTE:          keySym = XK_Execute; break;
-    case WXK_INSERT:           keySym = XK_Insert; break;
-    case WXK_DELETE:           keySym = XK_Delete; break;
-    case WXK_HELP :            keySym = XK_Help; break;
-    case WXK_NUMPAD0:          keySym = XK_KP_0; break;
-    case WXK_NUMPAD1:          keySym = XK_KP_1; break;
-    case WXK_NUMPAD2:          keySym = XK_KP_2; break;
-    case WXK_NUMPAD3:          keySym = XK_KP_3; break;
-    case WXK_NUMPAD4:          keySym = XK_KP_4; break;
-    case WXK_NUMPAD5:          keySym = XK_KP_5; break;
-    case WXK_NUMPAD6:          keySym = XK_KP_6; break;
-    case WXK_NUMPAD7:          keySym = XK_KP_7; break;
-    case WXK_NUMPAD8:          keySym = XK_KP_8; break;
-    case WXK_NUMPAD9:          keySym = XK_KP_9; break;
-    case WXK_MULTIPLY:         keySym = XK_KP_Multiply; break;
-    case WXK_ADD:              keySym = XK_KP_Add; break;
-    case WXK_SUBTRACT:         keySym = XK_KP_Subtract; break;
-    case WXK_DECIMAL:          keySym = XK_KP_Decimal; break;
-    case WXK_DIVIDE:           keySym = XK_KP_Divide; break;
-    case WXK_F1:               keySym = XK_F1; break;
-    case WXK_F2:               keySym = XK_F2; break;
-    case WXK_F3:               keySym = XK_F3; break;
-    case WXK_F4:               keySym = XK_F4; break;
-    case WXK_F5:               keySym = XK_F5; break;
-    case WXK_F6:               keySym = XK_F6; break;
-    case WXK_F7:               keySym = XK_F7; break;
-    case WXK_F8:               keySym = XK_F8; break;
-    case WXK_F9:               keySym = XK_F9; break;
-    case WXK_F10:              keySym = XK_F10; break;
-    case WXK_F11:              keySym = XK_F11; break;
-    case WXK_F12:              keySym = XK_F12; break;
-    case WXK_F13:              keySym = XK_F13; break;
-    case WXK_F14:              keySym = XK_F14; break;
-    case WXK_F15:              keySym = XK_F15; break;
-    case WXK_F16:              keySym = XK_F16; break;
-    case WXK_F17:              keySym = XK_F17; break;
-    case WXK_F18:              keySym = XK_F18; break;
-    case WXK_F19:              keySym = XK_F19; break;
-    case WXK_F20:              keySym = XK_F20; break;
-    case WXK_F21:              keySym = XK_F21; break;
-    case WXK_F22:              keySym = XK_F22; break;
-    case WXK_F23:              keySym = XK_F23; break;
-    case WXK_F24:              keySym = XK_F24; break;
-    case WXK_NUMLOCK:          keySym = XK_Num_Lock; break;
-    case WXK_SCROLL:           keySym = XK_Scroll_Lock; break;
-    default:                    keySym = id <= 255 ? (KeySym)id : 0;
-    } // switch
-    return keySym;
-}
 
-// Read $HOME for what it says is home, if not
-// read $USER or $LOGNAME for user name else determine
-// the Real User, then determine the Real home dir.
-static char * GetIniFile (char *dest, const char *filename)
-{
-    char *home = NULL;
-    if (filename && wxIsAbsolutePath(filename))
-    {
-        strcpy(dest, filename);
-    }
-    else if ((home = wxGetUserHome("")) != NULL)
-    {
-        strcpy(dest, home);
-        if (dest[strlen(dest) - 1] != '/')
-            strcat (dest, "/");
-        if (filename == NULL)
-        {
-            if ((filename = getenv ("XENVIRONMENT")) == NULL)
-                filename = ".Xdefaults";
-        }
-        else if (*filename != '.')
-            strcat (dest, ".");
-        strcat (dest, filename);
-    } else
+    switch (id)
     {
-        dest[0] = '\0';    
+        case WXK_CANCEL:            keySym = XK_Cancel; break;
+        case WXK_BACK:              keySym = XK_BackSpace; break;
+        case WXK_TAB:            keySym = XK_Tab; break;
+        case WXK_CLEAR:        keySym = XK_Clear; break;
+        case WXK_RETURN:        keySym = XK_Return; break;
+        case WXK_SHIFT:        keySym = XK_Shift_L; break;
+        case WXK_CONTROL:        keySym = XK_Control_L; break;
+        case WXK_MENU :        keySym = XK_Menu; break;
+        case WXK_PAUSE:        keySym = XK_Pause; break;
+        case WXK_ESCAPE:        keySym = XK_Escape; break;
+        case WXK_SPACE:        keySym = ' '; break;
+        case WXK_PRIOR:        keySym = XK_Prior; break;
+        case WXK_NEXT :        keySym = XK_Next; break;
+        case WXK_END:        keySym = XK_End; break;
+        case WXK_HOME :        keySym = XK_Home; break;
+        case WXK_LEFT :        keySym = XK_Left; break;
+        case WXK_UP:        keySym = XK_Up; break;
+        case WXK_RIGHT:        keySym = XK_Right; break;
+        case WXK_DOWN :        keySym = XK_Down; break;
+        case WXK_SELECT:        keySym = XK_Select; break;
+        case WXK_PRINT:        keySym = XK_Print; break;
+        case WXK_EXECUTE:        keySym = XK_Execute; break;
+        case WXK_INSERT:        keySym = XK_Insert; break;
+        case WXK_DELETE:        keySym = XK_Delete; break;
+        case WXK_HELP :        keySym = XK_Help; break;
+        case WXK_NUMPAD0:        keySym = XK_KP_0; break;
+        case WXK_NUMPAD1:        keySym = XK_KP_1; break;
+        case WXK_NUMPAD2:        keySym = XK_KP_2; break;
+        case WXK_NUMPAD3:        keySym = XK_KP_3; break;
+        case WXK_NUMPAD4:        keySym = XK_KP_4; break;
+        case WXK_NUMPAD5:        keySym = XK_KP_5; break;
+        case WXK_NUMPAD6:        keySym = XK_KP_6; break;
+        case WXK_NUMPAD7:        keySym = XK_KP_7; break;
+        case WXK_NUMPAD8:        keySym = XK_KP_8; break;
+        case WXK_NUMPAD9:        keySym = XK_KP_9; break;
+        case WXK_MULTIPLY:        keySym = XK_KP_Multiply; break;
+        case WXK_ADD:        keySym = XK_KP_Add; break;
+        case WXK_SUBTRACT:        keySym = XK_KP_Subtract; break;
+        case WXK_DECIMAL:        keySym = XK_KP_Decimal; break;
+        case WXK_DIVIDE:        keySym = XK_KP_Divide; break;
+        case WXK_F1:        keySym = XK_F1; break;
+        case WXK_F2:        keySym = XK_F2; break;
+        case WXK_F3:        keySym = XK_F3; break;
+        case WXK_F4:        keySym = XK_F4; break;
+        case WXK_F5:        keySym = XK_F5; break;
+        case WXK_F6:        keySym = XK_F6; break;
+        case WXK_F7:        keySym = XK_F7; break;
+        case WXK_F8:        keySym = XK_F8; break;
+        case WXK_F9:        keySym = XK_F9; break;
+        case WXK_F10:        keySym = XK_F10; break;
+        case WXK_F11:        keySym = XK_F11; break;
+        case WXK_F12:        keySym = XK_F12; break;
+        case WXK_F13:        keySym = XK_F13; break;
+        case WXK_F14:        keySym = XK_F14; break;
+        case WXK_F15:        keySym = XK_F15; break;
+        case WXK_F16:        keySym = XK_F16; break;
+        case WXK_F17:        keySym = XK_F17; break;
+        case WXK_F18:        keySym = XK_F18; break;
+        case WXK_F19:        keySym = XK_F19; break;
+        case WXK_F20:        keySym = XK_F20; break;
+        case WXK_F21:        keySym = XK_F21; break;
+        case WXK_F22:        keySym = XK_F22; break;
+        case WXK_F23:        keySym = XK_F23; break;
+        case WXK_F24:        keySym = XK_F24; break;
+        case WXK_NUMLOCK:    keySym = XK_Num_Lock; break;
+        case WXK_SCROLL:     keySym = XK_Scroll_Lock; break;
+        default:             keySym = id <= 255 ? (KeySym)id : 0;
     }
-    return dest;
+
+    return keySym;
 }
 
-/*
-* Some colour manipulation routines
-*/
+// ----------------------------------------------------------------------------
+// Some colour manipulation routines
+// ----------------------------------------------------------------------------
 
 void wxHSVToXColor(wxHSV *hsv,XColor *rgb)
 {
@@ -1153,7 +1054,7 @@ void wxHSVToXColor(wxHSV *hsv,XColor *rgb)
     p = v * (wxMAX_RGB - s) / wxMAX_RGB;
     q = v * (wxMAX_RGB - s * f / 60) / wxMAX_RGB;
     t = v * (wxMAX_RGB - s * (60 - f) / 60) / wxMAX_RGB;
-    switch (i) 
+    switch (i)
     {
     case 0: r = v, g = t, b = p; break;
     case 1: r = q, g = v, b = p; break;
@@ -1179,14 +1080,14 @@ void wxXColorToHSV(wxHSV *hsv,XColor *rgb)
     if (maxv) s = (maxv - minv) * wxMAX_RGB / maxv;
     else s = 0;
     if (s == 0) h = 0;
-    else 
+    else
     {
         int rc, gc, bc, hex;
         rc = (maxv - r) * wxMAX_RGB / (maxv - minv);
         gc = (maxv - g) * wxMAX_RGB / (maxv - minv);
         bc = (maxv - b) * wxMAX_RGB / (maxv - minv);
-        if (r == maxv) { h = bc - gc, hex = 0; } 
-        else if (g == maxv) { h = rc - bc, hex = 2; } 
+        if (r == maxv) { h = bc - gc, hex = 0; }
+        else if (g == maxv) { h = rc - bc, hex = 2; }
         else if (b == maxv) { h = gc - rc, hex = 4; }
         h = hex * 60 + (h * 60 / wxMAX_RGB);
         if (h < 0) h += 360;
@@ -1199,19 +1100,19 @@ void wxXColorToHSV(wxHSV *hsv,XColor *rgb)
 void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc)
 {
     int llp;
-    
+
     int screen = DefaultScreen(d);
     int num_colors = DisplayCells(d,screen);
-    
+
     XColor *color_defs = new XColor[num_colors];
     for(llp = 0;llp < num_colors;llp++) color_defs[llp].pixel = llp;
     XQueryColors(d,cmp,color_defs,num_colors);
-    
+
     wxHSV hsv_defs, hsv;
     wxXColorToHSV(&hsv,xc);
-    
+
     int diff, min_diff, pixel = 0;
-    
+
     for(llp = 0;llp < num_colors;llp++)
     {
         wxXColorToHSV(&hsv_defs,&color_defs[llp]);
@@ -1222,14 +1123,14 @@ void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc)
         if (min_diff > diff) { min_diff = diff; pixel = llp; }
         if (min_diff == 0) break;
     }
-    
+
     xc -> red = color_defs[pixel].red;
     xc -> green = color_defs[pixel].green;
     xc -> blue = color_defs[pixel].blue;
     xc -> flags = DoRed | DoGreen | DoBlue;
     if (!XAllocColor(d,cmp,xc))
         cout << "wxAllocNearestColor : Warning : Cannot find nearest color !\n";
-    
+
     delete[] color_defs;
 }
 
@@ -1258,7 +1159,7 @@ void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
     // Therefore SetBackgroundColour computes the foreground colour, and
     // SetForegroundColour changes the foreground colour. The ordering is
     // important.
-    
+
     XtVaSetValues ((Widget) widget,
         XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
         NULL);
@@ -1268,18 +1169,17 @@ void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, boo
 {
     wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
         (wxColour*) NULL);
-    
+
     XtVaSetValues ((Widget) widget,
         XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
         XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
         XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
         XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
         NULL);
-    
+
     if (changeArmColour)
         XtVaSetValues ((Widget) widget,
         XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
         NULL);
 }
 
-
diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp
new file mode 100644 (file)
index 0000000..3a7c469
--- /dev/null
@@ -0,0 +1,773 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        threadpsx.cpp
+// Purpose:     wxThread (Posix) Implementation
+// Author:      Original from Wolfram Gloger/Guilhem Lavaux
+// Modified by:
+// Created:     04/22/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Wolfram Gloger (1996, 1997)
+//                  Guilhem Lavaux (1998)
+//                  Vadim Zeitlin (1999)
+//                  Robert Roebling (1999)
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declaration
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+    #pragma implementation "thread.h"
+#endif
+
+#include "wx/thread.h"
+
+#if !wxUSE_THREADS
+    #error This file needs wxUSE_THREADS
+#endif
+
+#include "wx/module.h"
+#include "wx/utils.h"
+#include "wx/log.h"
+#include "wx/intl.h"
+#include "wx/dynarray.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <errno.h>
+#include <time.h>
+
+#ifdef HAVE_SCHED_H
+    #include <sched.h>
+#endif
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+enum thread_state
+{
+    STATE_NEW,          // didn't start execution yet (=> RUNNING)
+    STATE_RUNNING,
+    STATE_PAUSED,
+    STATE_CANCELED,
+    STATE_EXITED
+};
+
+WX_DEFINE_ARRAY(wxThread *, wxArrayThread);
+
+// -----------------------------------------------------------------------------
+// global data
+// -----------------------------------------------------------------------------
+
+// we keep the list of all threads created by the application to be able to
+// terminate them on exit if there are some left - otherwise the process would
+// be left in memory
+static wxArrayThread gs_allThreads;
+
+// the id of the main thread
+static pthread_t gs_tidMain;
+
+// the key for the pointer to the associated wxThread object
+static pthread_key_t gs_keySelf;
+
+// this mutex must be acquired before any call to a GUI function
+static wxMutex *gs_mutexGui;
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+//--------------------------------------------------------------------
+// wxMutex (Posix implementation)
+//--------------------------------------------------------------------
+
+class wxMutexInternal
+{
+public:
+    pthread_mutex_t p_mutex;
+};
+
+wxMutex::wxMutex()
+{
+    p_internal = new wxMutexInternal;
+    pthread_mutex_init( &(p_internal->p_mutex), (const pthread_mutexattr_t*) NULL );
+    m_locked = 0;
+}
+
+wxMutex::~wxMutex()
+{
+    if (m_locked > 0)
+        wxLogDebug("Freeing a locked mutex (%d locks)", m_locked);
+
+    pthread_mutex_destroy( &(p_internal->p_mutex) );
+    delete p_internal;
+}
+
+wxMutexError wxMutex::Lock()
+{
+    int err = pthread_mutex_lock( &(p_internal->p_mutex) );
+    if (err == EDEADLK)
+    {
+        wxLogDebug("Locking this mutex would lead to deadlock!");
+
+        return wxMUTEX_DEAD_LOCK;
+    }
+
+    m_locked++;
+
+    return wxMUTEX_NO_ERROR;
+}
+
+wxMutexError wxMutex::TryLock()
+{
+    if (m_locked)
+    {
+        return wxMUTEX_BUSY;
+    }
+
+    int err = pthread_mutex_trylock( &(p_internal->p_mutex) );
+    switch (err)
+    {
+        case EBUSY: return wxMUTEX_BUSY;
+    }
+
+    m_locked++;
+
+    return wxMUTEX_NO_ERROR;
+}
+
+wxMutexError wxMutex::Unlock()
+{
+    if (m_locked > 0)
+    {
+        m_locked--;
+    }
+    else
+    {
+        wxLogDebug("Unlocking not locked mutex.");
+
+        return wxMUTEX_UNLOCKED;
+    }
+
+    pthread_mutex_unlock( &(p_internal->p_mutex) );
+
+    return wxMUTEX_NO_ERROR;
+}
+
+//--------------------------------------------------------------------
+// wxCondition (Posix implementation)
+//--------------------------------------------------------------------
+
+class wxConditionInternal
+{
+public:
+  pthread_cond_t p_condition;
+};
+
+wxCondition::wxCondition()
+{
+    p_internal = new wxConditionInternal;
+    pthread_cond_init( &(p_internal->p_condition), (const pthread_condattr_t *) NULL );
+}
+
+wxCondition::~wxCondition()
+{
+    pthread_cond_destroy( &(p_internal->p_condition) );
+
+    delete p_internal;
+}
+
+void wxCondition::Wait(wxMutex& mutex)
+{
+    pthread_cond_wait( &(p_internal->p_condition), &(mutex.p_internal->p_mutex) );
+}
+
+bool wxCondition::Wait(wxMutex& mutex, unsigned long sec, unsigned long nsec)
+{
+    struct timespec tspec;
+
+    tspec.tv_sec = time(0L)+sec;
+    tspec.tv_nsec = nsec;
+    return (pthread_cond_timedwait(&(p_internal->p_condition), &(mutex.p_internal->p_mutex), &tspec) != ETIMEDOUT);
+}
+
+void wxCondition::Signal()
+{
+    pthread_cond_signal( &(p_internal->p_condition) );
+}
+
+void wxCondition::Broadcast()
+{
+    pthread_cond_broadcast( &(p_internal->p_condition) );
+}
+
+//--------------------------------------------------------------------
+// wxThread (Posix implementation)
+//--------------------------------------------------------------------
+
+class wxThreadInternal
+{
+public:
+    wxThreadInternal();
+    ~wxThreadInternal();
+
+    // thread entry function
+    static void *PthreadStart(void *ptr);
+
+    // thread actions
+        // start the thread
+    wxThreadError Run();
+        // ask the thread to terminate
+    void Cancel();
+        // wake up threads waiting for our termination
+    void SignalExit();
+        // go to sleep until Resume() is called
+    void Pause();
+        // resume the thread
+    void Resume();
+
+    // accessors
+        // priority
+    int GetPriority() const { return m_prio; }
+    void SetPriority(int prio) { m_prio = prio; }
+        // state
+    thread_state GetState() const { return m_state; }
+    void SetState(thread_state state) { m_state = state; }
+        // id
+    pthread_t GetId() const { return thread_id; }
+        // "cancelled" flag
+    bool WasCancelled() const { return m_cancelled; }
+
+//private: -- should be!
+    pthread_t thread_id;
+
+private:
+    thread_state m_state;    // see thread_state enum
+    int          m_prio;     // in wxWindows units: from 0 to 100
+
+    // set when the thread should terminate
+    bool m_cancelled;
+
+    // this (mutex, cond) pair is used to synchronize the main thread and this
+    // thread in several situations:
+    //  1. The thread function blocks until condition is signaled by Run() when
+    //     it's initially created - this allows create thread in "suspended"
+    //     state
+    //  2. The Delete() function blocks until the condition is signaled when the
+    //     thread exits.
+    wxMutex     m_mutex;
+    wxCondition m_cond;
+
+    // another (mutex, cond) pair for Pause()/Resume() usage
+    //
+    // VZ: it's possible that we might reuse the mutex and condition from above
+    //     for this too, but as I'm not at all sure that it won't create subtle
+    //     problems with race conditions between, say, Pause() and Delete() I
+    //     prefer this may be a bit less efficient but much safer solution
+    wxMutex     m_mutexSuspend;
+    wxCondition m_condSuspend;
+};
+
+void *wxThreadInternal::PthreadStart(void *ptr)
+{
+    wxThread *thread = (wxThread *)ptr;
+    wxThreadInternal *pthread = thread->p_internal;
+
+    if ( pthread_setspecific(gs_keySelf, thread) != 0 )
+    {
+        wxLogError(_("Can not start thread: error writing TLS."));
+
+        return (void *)-1;
+    }
+
+    // wait for the condition to be signaled from Run()
+    // mutex state: currently locked by the thread which created us
+    pthread->m_cond.Wait(pthread->m_mutex);
+
+    // mutex state: locked again on exit of Wait()
+
+    // call the main entry
+    void* status = thread->Entry();
+
+    // terminate the thread
+    thread->Exit(status);
+
+    wxFAIL_MSG("wxThread::Exit() can't return.");
+
+    return NULL;
+}
+
+wxThreadInternal::wxThreadInternal()
+{
+    m_state = STATE_NEW;
+    m_cancelled = FALSE;
+
+    // this mutex is locked during almost all thread lifetime - it will only be
+    // unlocked in the very end
+    m_mutex.Lock();
+
+    // this mutex is used in Pause()/Resume() and is also locked all the time
+    // unless the thread is paused
+    m_mutexSuspend.Lock();
+}
+
+wxThreadInternal::~wxThreadInternal()
+{
+    m_mutexSuspend.Unlock();
+
+    // note that m_mutex will be unlocked by the thread which waits for our
+    // termination
+}
+
+wxThreadError wxThreadInternal::Run()
+{
+    wxCHECK_MSG( GetState() == STATE_NEW, wxTHREAD_RUNNING,
+                 "thread may only be started once after successful Create()" );
+
+    // the mutex was locked on Create(), so we will be able to lock it again
+    // only when the thread really starts executing and enters the wait -
+    // otherwise we might signal the condition before anybody is waiting for it
+    wxMutexLocker lock(m_mutex);
+    m_cond.Signal();
+
+    m_state = STATE_RUNNING;
+
+    return wxTHREAD_NO_ERROR;
+
+    // now the mutex is unlocked back - but just to allow Wait() function to
+    // terminate by relocking it, so the net result is that the worker thread
+    // starts executing and the mutex is still locked
+}
+
+void wxThreadInternal::Cancel()
+{
+    // if the thread we're waiting for is waiting for the GUI mutex, we will
+    // deadlock so make sure we release it temporarily
+    if ( wxThread::IsMain() )
+        wxMutexGuiLeave();
+
+    // nobody ever writes this variable so it's safe to not use any
+    // synchronization here
+    m_cancelled = TRUE;
+
+    // entering Wait() releases the mutex thus allowing SignalExit() to acquire
+    // it and to signal us its termination
+    m_cond.Wait(m_mutex);
+
+    // mutex is still in the locked state - relocked on exit from Wait(), so
+    // unlock it - we don't need it any more, the thread has already terminated
+    m_mutex.Unlock();
+
+    // reacquire GUI mutex
+    if ( wxThread::IsMain() )
+        wxMutexGuiEnter();
+}
+
+void wxThreadInternal::SignalExit()
+{
+    // as mutex is currently locked, this will block until some other thread
+    // (normally the same which created this one) unlocks it by entering Wait()
+    m_mutex.Lock();
+
+    // wake up all the threads waiting for our termination
+    m_cond.Broadcast();
+
+    // after this call mutex will be finally unlocked
+    m_mutex.Unlock();
+}
+
+void wxThreadInternal::Pause()
+{
+    wxCHECK_RET( m_state == STATE_PAUSED,
+                 "thread must first be paused with wxThread::Pause()." );
+
+    // wait until the condition is signaled from Resume()
+    m_condSuspend.Wait(m_mutexSuspend);
+}
+
+void wxThreadInternal::Resume()
+{
+    wxCHECK_RET( m_state == STATE_PAUSED,
+                 "can't resume thread which is not suspended." );
+
+    // we will be able to lock this mutex only when Pause() starts waiting
+    wxMutexLocker lock(m_mutexSuspend);
+    m_condSuspend.Signal();
+
+    SetState(STATE_RUNNING);
+}
+
+// -----------------------------------------------------------------------------
+// static functions
+// -----------------------------------------------------------------------------
+
+wxThread *wxThread::This()
+{
+    return (wxThread *)pthread_getspecific(gs_keySelf);
+}
+
+bool wxThread::IsMain()
+{
+    return (bool)pthread_equal(pthread_self(), gs_tidMain);
+}
+
+void wxThread::Yield()
+{
+    sched_yield();
+}
+
+void wxThread::Sleep(unsigned long milliseconds)
+{
+    wxUsleep(milliseconds);
+}
+
+// -----------------------------------------------------------------------------
+// creating thread
+// -----------------------------------------------------------------------------
+
+wxThread::wxThread()
+{
+    // add this thread to the global list of all threads
+    gs_allThreads.Add(this);
+
+    p_internal = new wxThreadInternal();
+}
+
+wxThreadError wxThread::Create()
+{
+    if (p_internal->GetState() != STATE_NEW)
+        return wxTHREAD_RUNNING;
+
+    // set up the thread attribute: right now, we only set thread priority
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+
+    int prio;
+    if ( pthread_attr_getschedpolicy(&attr, &prio) != 0 )
+    {
+        wxLogError(_("Can not retrieve thread scheduling policy."));
+    }
+
+    int min_prio = sched_get_priority_min(prio),
+        max_prio = sched_get_priority_max(prio);
+
+    if ( min_prio == -1 || max_prio == -1 )
+    {
+        wxLogError(_("Can not get priority range for scheduling policy %d."),
+                   prio);
+    }
+    else
+    {
+        struct sched_param sp;
+        pthread_attr_getschedparam(&attr, &sp);
+        sp.sched_priority = min_prio +
+                           (p_internal->GetPriority()*(max_prio-min_prio))/100;
+        pthread_attr_setschedparam(&attr, &sp);
+    }
+
+    // create the new OS thread object
+    int rc = pthread_create(&p_internal->thread_id, &attr,
+                            wxThreadInternal::PthreadStart, (void *)this);
+    pthread_attr_destroy(&attr);
+
+    if ( rc != 0 )
+    {
+        p_internal->SetState(STATE_EXITED);
+        return wxTHREAD_NO_RESOURCE;
+    }
+
+    return wxTHREAD_NO_ERROR;
+}
+
+wxThreadError wxThread::Run()
+{
+    return p_internal->Run();
+}
+
+// -----------------------------------------------------------------------------
+// misc accessors
+// -----------------------------------------------------------------------------
+
+void wxThread::SetPriority(unsigned int prio)
+{
+    wxCHECK_RET( (WXTHREAD_MIN_PRIORITY <= prio) &&
+                 (prio <= WXTHREAD_MAX_PRIORITY), "invalid thread priority" );
+
+    wxCriticalSectionLocker lock(m_critsect);
+
+    switch ( p_internal->GetState() )
+    {
+        case STATE_NEW:
+            // thread not yet started, priority will be set when it is
+            p_internal->SetPriority(prio);
+            break;
+
+        case STATE_RUNNING:
+        case STATE_PAUSED:
+            {
+                struct sched_param sparam;
+                sparam.sched_priority = prio;
+
+                if ( pthread_setschedparam(p_internal->GetId(),
+                                           SCHED_OTHER, &sparam) != 0 )
+                {
+                    wxLogError(_("Failed to set thread priority %d."), prio);
+                }
+            }
+            break;
+
+        case STATE_EXITED:
+        default:
+            wxFAIL_MSG("impossible to set thread priority in this state");
+    }
+}
+
+unsigned int wxThread::GetPriority() const
+{
+    wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
+
+    return p_internal->GetPriority();
+}
+
+unsigned long wxThread::GetID() const
+{
+    return (unsigned long)p_internal->thread_id;
+}
+
+// -----------------------------------------------------------------------------
+// pause/resume
+// -----------------------------------------------------------------------------
+
+wxThreadError wxThread::Pause()
+{
+    wxCriticalSectionLocker lock(m_critsect);
+
+    if ( p_internal->GetState() != STATE_RUNNING )
+    {
+        wxLogDebug("Can't pause thread which is not running.");
+
+        return wxTHREAD_NOT_RUNNING;
+    }
+
+    p_internal->SetState(STATE_PAUSED);
+
+    return wxTHREAD_NO_ERROR;
+}
+
+wxThreadError wxThread::Resume()
+{
+    wxCriticalSectionLocker lock(m_critsect);
+
+    if ( p_internal->GetState() == STATE_PAUSED )
+    {
+        p_internal->Resume();
+
+        return wxTHREAD_NO_ERROR;
+    }
+    else
+    {
+        wxLogDebug("Attempt to resume a thread which is not paused.");
+
+        return wxTHREAD_MISC_ERROR;
+    }
+}
+
+// -----------------------------------------------------------------------------
+// exiting thread
+// -----------------------------------------------------------------------------
+
+wxThread::ExitCode wxThread::Delete()
+{
+    m_critsect.Enter();
+    thread_state state = p_internal->GetState();
+    m_critsect.Leave();
+
+    switch ( state )
+    {
+        case STATE_NEW:
+        case STATE_EXITED:
+            // nothing to do
+            break;
+
+        case STATE_PAUSED:
+            // resume the thread first
+            Resume();
+
+            // fall through
+
+        default:
+            // set the flag telling to the thread to stop and wait
+            p_internal->Cancel();
+    }
+
+    return NULL;
+}
+
+wxThreadError wxThread::Kill()
+{
+    switch ( p_internal->GetState() )
+    {
+        case STATE_NEW:
+        case STATE_EXITED:
+            return wxTHREAD_NOT_RUNNING;
+
+        default:
+            if ( pthread_cancel(p_internal->GetId()) != 0 )
+            {
+                wxLogError(_("Failed to terminate a thread."));
+
+                return wxTHREAD_MISC_ERROR;
+            }
+
+            return wxTHREAD_NO_ERROR;
+    }
+}
+
+void wxThread::Exit(void *status)
+{
+    // first call user-level clean up code
+    OnExit();
+
+    // next wake up the threads waiting for us (OTOH, this function won't return
+    // until someone waited for us!)
+    p_internal->SignalExit();
+
+    p_internal->SetState(STATE_EXITED);
+
+    // delete both C++ thread object and terminate the OS thread object
+    delete this;
+    pthread_exit(status);
+}
+
+// also test whether we were paused
+bool wxThread::TestDestroy()
+{
+    wxCriticalSectionLocker lock((wxCriticalSection&)m_critsect);
+
+    if ( p_internal->GetState() == STATE_PAUSED )
+    {
+        // leave the crit section or the other threads will stop too if they try
+        // to call any of (seemingly harmless) IsXXX() functions while we sleep
+        m_critsect.Leave();
+
+        p_internal->Pause();
+
+        // enter it back before it's finally left in lock object dtor
+        m_critsect.Enter();
+    }
+
+    return p_internal->WasCancelled();
+}
+
+wxThread::~wxThread()
+{
+    // remove this thread from the global array
+    gs_allThreads.Remove(this);
+}
+
+// -----------------------------------------------------------------------------
+// state tests
+// -----------------------------------------------------------------------------
+
+bool wxThread::IsRunning() const
+{
+    wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
+
+    return p_internal->GetState() == STATE_RUNNING;
+}
+
+bool wxThread::IsAlive() const
+{
+    wxCriticalSectionLocker lock((wxCriticalSection&)m_critsect);
+
+    switch ( p_internal->GetState() )
+    {
+        case STATE_RUNNING:
+        case STATE_PAUSED:
+            return TRUE;
+
+        default:
+            return FALSE;
+    }
+}
+
+//--------------------------------------------------------------------
+// wxThreadModule
+//--------------------------------------------------------------------
+
+class wxThreadModule : public wxModule
+{
+public:
+    virtual bool OnInit();
+    virtual void OnExit();
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxThreadModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
+
+bool wxThreadModule::OnInit()
+{
+    if ( pthread_key_create(&gs_keySelf, NULL /* dtor function */) != 0 )
+    {
+        wxLogError(_("Thread module initialization failed: "
+                     "failed to create pthread key."));
+
+        return FALSE;
+    }
+
+    gs_mutexGui = new wxMutex();
+
+    //wxThreadGuiInit();
+
+    gs_tidMain = pthread_self();
+    gs_mutexGui->Lock();
+
+    return TRUE;
+}
+
+void wxThreadModule::OnExit()
+{
+    wxASSERT_MSG( wxThread::IsMain(), "only main thread can be here" );
+
+    // terminate any threads left
+    size_t count = gs_allThreads.GetCount();
+    if ( count != 0u )
+        wxLogDebug("Some threads were not terminated by the application.");
+
+    for ( size_t n = 0u; n < count; n++ )
+    {
+        gs_allThreads[n]->Delete();
+    }
+
+    // destroy GUI mutex
+    gs_mutexGui->Unlock();
+
+    //wxThreadGuiExit();
+
+    delete gs_mutexGui;
+
+    // and free TLD slot
+    (void)pthread_key_delete(gs_keySelf);
+}
+
+// ----------------------------------------------------------------------------
+// global functions
+// ----------------------------------------------------------------------------
+
+void wxMutexGuiEnter()
+{
+  gs_mutexGui->Lock();
+}
+
+void wxMutexGuiLeave()
+{
+  gs_mutexGui->Unlock();
+}
diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp
new file mode 100644 (file)
index 0000000..4bc1442
--- /dev/null
@@ -0,0 +1,439 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        utilsunx.cpp
+// Purpose:     generic Unix implementation of many wx functions
+// Author:      Vadim Zeitlin
+// Id:          $Id$
+// Copyright:   (c) 1998 Robert Roebling, Vadim Zeitlin
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "wx/defs.h"
+#include "wx/string.h"
+
+#include "wx/intl.h"
+#include "wx/log.h"
+
+#include "wx/utils.h"
+#include "wx/process.h"
+
+#include "wx/unix/execute.h"
+
+#include <stdarg.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <pwd.h>
+#include <errno.h>
+#include <netdb.h>
+#include <signal.h>
+#include <fcntl.h>          // for O_WRONLY and friends
+#include <time.h>           // nanosleep() and/or usleep()
+
+#ifdef HAVE_UNAME
+    #include <sys/utsname.h> // for uname()
+#endif // HAVE_UNAME
+
+// ----------------------------------------------------------------------------
+// conditional compilation
+// ----------------------------------------------------------------------------
+
+// many versions of Unices have this function, but it is not defined in system
+// headers - please add your system here if it is the case for your OS.
+// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this.
+#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
+                         !defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
+     defined(__osf__)
+    extern "C"
+    {
+        void usleep(unsigned long usec);
+    };
+#endif // Unices without usleep()
+
+// many versions of Unices have this function, but it is not defined in system
+// headers - please add your system here if it is the case for your OS.
+// SunOS (and Solaris) and DG-UX are like this.
+#if defined(__SOLARIS__) || defined(__osf__)
+    extern "C"
+    {
+        pid_t wait4(pid_t pid, int *statusp, int options,
+                    struct rusage *rusage);
+    }
+
+    #define wxWait4(pid, stat, flags, rusage) wait4(pid, stat, flags, rusage)
+#elif defined(__sgi) || defined(__HPUX__)
+    // no wait4() at all on these systems
+    // TODO verify whether wait3() really works in this situation
+    #define wxWait4(pid, stat, flags, rusage) wait3(stat, flags, rusage)
+#else
+    // other Unices: assume have wait4(), although it's not standard (but
+    // Linux and FreeBSD do have it)
+    #define wxWait4(pid, stat, flags, rusage) wait4(pid, stat, flags, rusage)
+#endif // wait4()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// sleeping
+// ----------------------------------------------------------------------------
+
+void wxSleep(int nSecs)
+{
+    sleep(nSecs);
+}
+
+void wxUsleep(unsigned long milliseconds)
+{
+#if defined(HAVE_NANOSLEEP)
+    timespec tmReq;
+    tmReq.tv_sec = milliseconds / 1000;
+    tmReq.tv_nsec = (milliseconds % 1000) * 1000 * 1000;
+
+    // we're not interested in remaining time nor in return value
+    (void)nanosleep(&tmReq, (timespec *)NULL);
+#elif defined(HAVE_USLEEP)
+    // uncomment this if you feel brave or if you are sure that your version
+    // of Solaris has a safe usleep() function but please notice that usleep()
+    // is known to lead to crashes in MT programs in Solaris 2.[67] and is not
+    // documented as MT-Safe
+    #if defined(__SUN__) && defined(wxUSE_THREADS)
+        #error "usleep() cannot be used in MT programs under Solaris."
+    #endif // Sun
+
+    usleep(milliseconds * 1000); // usleep(3) wants microseconds
+#else // !sleep function
+    #error "usleep() or nanosleep() function required for wxUsleep"
+#endif // sleep function
+}
+
+// ----------------------------------------------------------------------------
+// process management
+// ----------------------------------------------------------------------------
+
+int wxKill(long pid, int sig)
+{
+    return kill(pid, sig);
+}
+
+long wxExecute( const wxString& command, bool sync, wxProcess *process )
+{
+    static const char *IFS = " \t\n";
+
+    wxCHECK_MSG( !command.IsEmpty(), 0, "can't exec empty command" );
+
+    int argc = 0;
+    char *argv[127];
+    char *tmp = new char[command.Len() + 1];
+    strcpy(tmp, command);
+
+    argv[argc++] = strtok(tmp, IFS);
+    while ((argv[argc++] = strtok((char *) NULL, IFS)) != NULL)
+        /* loop */ ;
+
+    long lRc = wxExecute(argv, sync, process);
+
+    delete [] tmp;
+
+    return lRc;
+}
+
+bool wxShell(const wxString& command)
+{
+    wxString cmd;
+    if ( !!command )
+        cmd.Printf("xterm -e %s", command.c_str());
+    else
+        cmd = command;
+
+    return wxExecute(cmd) != 0;
+}
+
+void wxHandleProcessTermination(wxEndProcessData *proc_data)
+{
+    int pid = (proc_data->pid > 0) ? proc_data->pid : -(proc_data->pid);
+
+    int status = 0;
+    wxWait4(pid, &status, 0, (rusage *) NULL);
+
+    if (proc_data->process)
+        proc_data->process->OnTerminate(proc_data->pid, status);
+
+    if (proc_data->pid > 0)
+    {
+        delete proc_data;
+    }
+    else
+    {
+        // wxExecute() will know about it
+        proc_data->exitcode = status;
+
+        proc_data->pid = 0;
+    }
+}
+
+long wxExecute( char **argv, bool sync, wxProcess *process )
+{
+    wxCHECK_MSG( *argv, 0, "can't exec empty command" );
+
+    int end_proc_detect[2];
+
+    // create pipes
+    if (pipe(end_proc_detect) == -1)
+    {
+        wxLogSysError( _("Pipe creation failed") );
+        return 0;
+    }
+
+    // fork the process
+#ifdef HAVE_VFORK
+    pid_t pid = vfork();
+#else
+    pid_t pid = fork();
+#endif
+    if (pid == -1)
+    {
+        wxLogSysError( _("Fork failed") );
+        return 0;
+    }
+    else if (pid == 0)
+    {
+        // we're in child
+        close(end_proc_detect[0]); // close reading side
+
+        // These three lines close the open file descriptors to to avoid any
+        // input/output which might block the process or irritate the user. If
+        // one wants proper IO for the subprocess, the "right thing to do is
+        // to start an xterm executing it.
+        if (sync == 0)
+        {
+            // leave stderr opened, it won't do any hurm
+            for ( int fd = 0; fd < FD_SETSIZE; fd++ )
+            {
+                if ( fd != end_proc_detect[1] && fd != STDERR_FILENO )
+                    close(fd);
+            }
+        }
+
+#if 0
+        close(STDERR_FILENO);
+
+        // some programs complain about stderr not being open, so redirect
+        // them:
+        open("/dev/null", O_RDONLY);  // stdin
+        open("/dev/null", O_WRONLY);  // stdout
+        open("/dev/null", O_WRONLY);  // stderr
+#endif
+
+#ifdef _AIX
+        execvp ((const char *)*argv, (const char **)argv);
+#else
+        execvp (*argv, argv);
+#endif
+
+        // there is no return after successful exec()
+        fprintf(stderr, _("Can't execute '%s'\n"), *argv);
+
+        _exit(-1);
+    }
+    else
+    {
+        // we're in parent
+        close(end_proc_detect[1]); // close writing side
+
+        wxEndProcessData *data = new wxEndProcessData;
+        data->tag = wxAddProcessCallback(data, end_proc_detect[0]);
+
+        if ( sync )
+        {
+            wxASSERT_MSG( !process, "wxProcess param ignored for sync exec" );
+            data->process = NULL;
+
+            // sync execution: indicate it by negating the pid
+            data->pid = -pid;
+
+            // it will be set to 0 from GTK_EndProcessDetector
+            while (data->pid != 0)
+                wxYield();
+
+            int exitcode = data->exitcode;
+
+            delete data;
+
+            return exitcode;
+        }
+        else
+        {
+            // async execution, nothing special to do - caller will be
+            // notified about the process terminationif process != NULL, data
+            // will be deleted in GTK_EndProcessDetector
+            data->process = process;
+            data->pid = pid;
+
+            return pid;
+        }
+    }
+}
+
+// ----------------------------------------------------------------------------
+// file and directory functions
+// ----------------------------------------------------------------------------
+
+const char* wxGetHomeDir( wxString *home  )
+{
+    *home = wxGetUserHome( wxString() );
+    if ( home->IsEmpty() )
+        *home = "/";
+
+    return home->c_str();
+}
+
+char *wxGetUserHome( const wxString &user )
+{
+    struct passwd *who = (struct passwd *) NULL;
+
+    if (user.IsNull() || (user== ""))
+    {
+        register char *ptr;
+
+        if ((ptr = getenv("HOME")) != NULL)
+        {
+            return ptr;
+        }
+        if ((ptr = getenv("USER")) != NULL || (ptr = getenv("LOGNAME")) != NULL)
+        {
+            who = getpwnam(ptr);
+        }
+
+        // We now make sure the the user exists!
+        if (who == NULL)
+        {
+            who = getpwuid(getuid());
+        }
+    }
+    else
+    {
+      who = getpwnam (user);
+    }
+
+    return who ? who->pw_dir : (char*)NULL;
+}
+
+// ----------------------------------------------------------------------------
+// id routines
+// ----------------------------------------------------------------------------
+
+bool wxGetHostName(char *buf, int sz)
+{
+    wxCHECK_MSG( buf, FALSE, "NULL pointer in wxGetHostName" );
+
+    *buf = '\0';
+
+    // we're using uname() which is POSIX instead of less standard sysinfo()
+#if defined(HAVE_UNAME)
+    utsname uts;
+    bool ok = uname(&uts) != -1;
+    if ( ok )
+    {
+        strncpy(buf, uts.nodename, sz - 1);
+        buf[sz] = '\0';
+    }
+#elif defined(HAVE_GETHOSTNAME)
+    bool ok = gethostname(buf, sz) != -1;
+#else
+    wxFAIL_MSG("don't know host name for this machibe");
+
+    bool ok = FALSE;
+#endif
+
+    if ( !ok )
+    {
+        wxLogSysError(_("Cannot get the hostname"));
+    }
+
+    return ok;
+}
+
+bool wxGetUserId(char *buf, int sz)
+{
+    struct passwd *who;
+
+    *buf = '\0';
+    if ((who = getpwuid(getuid ())) != NULL)
+    {
+        strncpy (buf, who->pw_name, sz - 1);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+bool wxGetUserName(char *buf, int sz)
+{
+    struct passwd *who;
+    char *comma;
+
+    *buf = '\0';
+    if ((who = getpwuid (getuid ())) != NULL) {
+       comma = strchr(who->pw_gecos, ',');
+       if (comma)
+           *comma = '\0'; // cut off non-name comment fields
+       strncpy (buf, who->pw_gecos, sz - 1);
+       return TRUE;
+    }
+
+    return FALSE;
+}
+
+// ----------------------------------------------------------------------------
+// error and debug output routines (deprecated, use wxLog)
+// ----------------------------------------------------------------------------
+
+void wxDebugMsg( const char *format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  vfprintf( stderr, format, ap );
+  fflush( stderr );
+  va_end(ap);
+}
+
+void wxError( const wxString &msg, const wxString &title )
+{
+  fprintf( stderr, _("Error ") );
+  if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
+  if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
+  fprintf( stderr, ".\n" );
+}
+
+void wxFatalError( const wxString &msg, const wxString &title )
+{
+  fprintf( stderr, _("Error ") );
+  if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
+  if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
+  fprintf( stderr, ".\n" );
+  exit(3); // the same exit code as for abort()
+}
+
+//------------------------------------------------------------------------
+// directory routines
+//------------------------------------------------------------------------
+
+bool wxDirExists( const wxString& dir )
+{
+    char buf[500];
+    strcpy( buf, WXSTRINGCAST(dir) );
+    struct stat sbuf;
+    return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE);
+}