[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:47:11 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 28f7f958b45e34bb64f7a175a2df6d4b517f7777
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 25 23:17:46 2001 +0000

    Added support for QFile.
    This involved bringing over more files from Qt, and adding
    some special voodoo to configure for sys/stat.h
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@195 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/aclocal.m4 b/WebCore/aclocal.m4
index 5336618..03b0361 100644
--- a/WebCore/aclocal.m4
+++ b/WebCore/aclocal.m4
@@ -22,3 +22,33 @@ dnl
 dnl
 dnl -------------------------------------------------------------------
 dnl
+dnl Sets the top directory for the build
+dnl
+dnl Usage: 
+dnl
+AC_DEFUN(AC_CHECK_ISSOCK, [
+AC_MSG_CHECKING([whether sys/stat.h declares S_ISSOCK])
+AC_TRY_COMPILE([#include <sys/stat.h>] ,[
+#ifndef S_ISSOCK
+#define S_ISSOCK no workie
+#endif
+void foo() {
+    int mode = S_ISSOCK(0);
+}
+], [
+    AC_DEFINE_UNQUOTED(HAVE_S_ISSOCK,1)
+    AC_MSG_RESULT([yes])
+] , [
+    AC_MSG_RESULT([no])
+])
+])dnl
+dnl
+dnl -------------------------------------------------------------------
+dnl
+dnl#ifndef S_ISSOCK
+dnl#define S_ISSOCK does not compile
+dnl#endif
+dnlint main() {
+dnl    int i = S_ISSOCK(0);
+dnl    return 0;
+dnl}
diff --git a/WebCore/configure b/WebCore/configure
index 089ef9f..5528423 100644
--- a/WebCore/configure
+++ b/WebCore/configure
@@ -1557,17 +1557,73 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x,"
 
 
 
+echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
+echo "configure:1562: 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 1567 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(S_ISBLK) && defined(S_IFDIR)
+# if S_ISBLK (S_IFDIR)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISBLK) && defined(S_IFCHR)
+# if S_ISBLK (S_IFCHR)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISLNK) && defined(S_IFREG)
+# if S_ISLNK (S_IFREG)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISSOCK) && defined(S_IFREG)
+# if S_ISSOCK (S_IFREG)
+You lose.
+# endif
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "You lose" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_header_stat_broken=yes
+else
+  rm -rf conftest*
+  ac_cv_header_stat_broken=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_header_stat_broken" 1>&6
+if test $ac_cv_header_stat_broken = yes; then
+  cat >> confdefs.h <<\EOF
+#define STAT_MACROS_BROKEN 1
+EOF
+
+fi
+ 
 ac_header_dirent=no
 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1566: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1622: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1571 "configure"
+#line 1627 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -1575,7 +1631,7 @@ int main() {
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:1579: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1635: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -1600,7 +1656,7 @@ done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1604: checking for opendir in -ldir" >&5
+echo "configure:1660: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1608,7 +1664,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1612 "configure"
+#line 1668 "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
@@ -1619,7 +1675,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1641,7 +1697,7 @@ fi
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1645: checking for opendir in -lx" >&5
+echo "configure:1701: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1649,7 +1705,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1653 "configure"
+#line 1709 "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
@@ -1660,7 +1716,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1683,12 +1739,12 @@ fi
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1687: checking for ANSI C header files" >&5
+echo "configure:1743: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1692 "configure"
+#line 1748 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1696,7 +1752,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1700: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1756: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1713,7 +1769,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1717 "configure"
+#line 1773 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1731,7 +1787,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1735 "configure"
+#line 1791 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1752,7 +1808,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1756 "configure"
+#line 1812 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1763,7 +1819,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:1767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1790,17 +1846,17 @@ for ac_hdr in sys/param.h sys/mman.h sys/time.h sys/cdefs.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1794: checking for $ac_hdr" >&5
+echo "configure:1850: 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 1799 "configure"
+#line 1855 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1804: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1860: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1830,17 +1886,17 @@ for ac_hdr in fnmatch.h sysent.h strings.h sys/stat.h sys/select.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1834: checking for $ac_hdr" >&5
+echo "configure:1890: 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 1839 "configure"
+#line 1895 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1844: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1900: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1870,17 +1926,17 @@ for ac_hdr in sys/socket.h socketbits.h sigaction.h paths.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1874: checking for $ac_hdr" >&5
+echo "configure:1930: 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 1879 "configure"
+#line 1935 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1884: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1940: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1910,17 +1966,17 @@ for ac_hdr in malloc.h limits.h dlfcn.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1914: checking for $ac_hdr" >&5
+echo "configure:1970: 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 1919 "configure"
+#line 1975 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1924: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1980: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1949,7 +2005,7 @@ done
 
 
 echo $ac_n "checking for jpeg_mem_init in -ljpeg""... $ac_c" 1>&6
-echo "configure:1953: checking for jpeg_mem_init in -ljpeg" >&5
+echo "configure:2009: checking for jpeg_mem_init in -ljpeg" >&5
 ac_lib_var=`echo jpeg'_'jpeg_mem_init | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1957,7 +2013,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ljpeg  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1961 "configure"
+#line 2017 "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
@@ -1968,7 +2024,7 @@ int main() {
 jpeg_mem_init()
 ; return 0; }
 EOF
-if { (eval echo configure:1972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2028: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1998,12 +2054,12 @@ fi
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2002: checking for working const" >&5
+echo "configure:2058: 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 2007 "configure"
+#line 2063 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2052,7 +2108,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:2056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -2073,21 +2129,21 @@ EOF
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:2077: checking for inline" >&5
+echo "configure:2133: 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 2084 "configure"
+#line 2140 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:2091: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2147: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -2113,12 +2169,12 @@ EOF
 esac
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2117: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2173: 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 2122 "configure"
+#line 2178 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2127,7 +2183,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2131: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2187: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2148,16 +2204,53 @@ EOF
 fi
 
 
+echo $ac_n "checking whether sys/stat.h declares S_ISSOCK""... $ac_c" 1>&6
+echo "configure:2209: checking whether sys/stat.h declares S_ISSOCK" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2211 "configure"
+#include "confdefs.h"
+#include <sys/stat.h> 
+int main() {
+
+#ifndef S_ISSOCK
+#define S_ISSOCK no workie
+#endif
+void foo() {
+    int mode = S_ISSOCK(0);
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:2225: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  
+    cat >> confdefs.h <<EOF
+#define HAVE_S_ISSOCK 1
+EOF
+
+    echo "$ac_t""yes" 1>&6
+ 
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+    echo "$ac_t""no" 1>&6
+
+fi
+rm -f conftest*
+
+
 
 for ac_func in socket vsnprintf seteuid setegid random strfmon stpcpy mkstemp gettimeofday setenv unsetenv mkstemps
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2156: checking for $ac_func" >&5
+echo "configure:2249: 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 2161 "configure"
+#line 2254 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2180,7 +2273,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2213,12 +2306,12 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2217: checking for pid_t" >&5
+echo "configure:2310: 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 2222 "configure"
+#line 2315 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2247,17 +2340,17 @@ fi
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:2251: checking for vfork.h" >&5
+echo "configure:2344: checking for vfork.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 2256 "configure"
+#line 2349 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2261: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2354: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2282,18 +2375,18 @@ else
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2286: checking for working vfork" >&5
+echo "configure:2379: checking for working vfork" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
   echo $ac_n "checking for vfork""... $ac_c" 1>&6
-echo "configure:2292: checking for vfork" >&5
+echo "configure:2385: checking for vfork" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2297 "configure"
+#line 2390 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vfork(); below.  */
@@ -2316,7 +2409,7 @@ vfork();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2413: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_vfork=yes"
 else
@@ -2338,7 +2431,7 @@ fi
 ac_cv_func_vfork_works=$ac_cv_func_vfork
 else
   cat > conftest.$ac_ext <<EOF
-#line 2342 "configure"
+#line 2435 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -2433,7 +2526,7 @@ main() {
   }
 }
 EOF
-if { (eval echo configure:2437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_vfork_works=yes
 else
@@ -2460,17 +2553,17 @@ for ac_hdr in ieeefp.h float.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2464: checking for $ac_hdr" >&5
+echo "configure:2557: 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 2469 "configure"
+#line 2562 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2474: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2567: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2497,7 +2590,7 @@ fi
 done
 
 echo $ac_n "checking for isinf in -lm""... $ac_c" 1>&6
-echo "configure:2501: checking for isinf in -lm" >&5
+echo "configure:2594: checking for isinf in -lm" >&5
 ac_lib_var=`echo m'_'isinf | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2505,7 +2598,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2509 "configure"
+#line 2602 "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
@@ -2516,7 +2609,7 @@ int main() {
 isinf()
 ; return 0; }
 EOF
-if { (eval echo configure:2520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2542,7 +2635,7 @@ else
 fi
 
 echo $ac_n "checking for finite in -lm""... $ac_c" 1>&6
-echo "configure:2546: checking for finite in -lm" >&5
+echo "configure:2639: checking for finite in -lm" >&5
 ac_lib_var=`echo m'_'finite | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2550,7 +2643,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2554 "configure"
+#line 2647 "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
@@ -2561,7 +2654,7 @@ int main() {
 finite()
 ; return 0; }
 EOF
-if { (eval echo configure:2565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2587,7 +2680,7 @@ else
 fi
 
 echo $ac_n "checking for _finite in -lm""... $ac_c" 1>&6
-echo "configure:2591: checking for _finite in -lm" >&5
+echo "configure:2684: checking for _finite in -lm" >&5
 ac_lib_var=`echo m'_'_finite | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2595,7 +2688,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2599 "configure"
+#line 2692 "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
@@ -2606,7 +2699,7 @@ int main() {
 _finite()
 ; return 0; }
 EOF
-if { (eval echo configure:2610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2632,7 +2725,7 @@ else
 fi
 
 echo $ac_n "checking for isnan in -lm""... $ac_c" 1>&6
-echo "configure:2636: checking for isnan in -lm" >&5
+echo "configure:2729: checking for isnan in -lm" >&5
 ac_lib_var=`echo m'_'isnan | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2640,7 +2733,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2644 "configure"
+#line 2737 "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
@@ -2651,7 +2744,7 @@ int main() {
 isnan()
 ; return 0; }
 EOF
-if { (eval echo configure:2655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
diff --git a/WebCore/configure.in b/WebCore/configure.in
index 624c16d..439e235 100644
--- a/WebCore/configure.in
+++ b/WebCore/configure.in
@@ -118,6 +118,7 @@ dnl Checks for header files.
 dnl -------------------------------------------------------------------
 dnl
 
+AC_HEADER_STAT 
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_CHECK_HEADERS(sys/param.h sys/mman.h sys/time.h sys/cdefs.h)
@@ -142,6 +143,7 @@ dnl
 AC_C_CONST
 AC_C_INLINE
 AC_HEADER_TIME
+AC_CHECK_ISSOCK
 
 dnl
 dnl -------------------------------------------------------------------
diff --git a/WebCore/kwq/KWQFile.h b/WebCore/kwq/KWQFile.h
index f1cfece..f67b7df 100644
--- a/WebCore/kwq/KWQFile.h
+++ b/WebCore/kwq/KWQFile.h
@@ -30,18 +30,125 @@
 #include <config.h>
 #endif
 
+#include <KWQDef.h>
+
+#ifdef _KWQ_COMPLETE_
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#if !defined(PATH_MAX)
+#if defined(MAXPATHLEN)
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+#undef STATBUF
+#undef STAT
+#undef STAT_REG
+#undef STAT_DIR
+#undef STAT_LNK
+#undef STAT_MASK
+#undef FILENO
+#undef OPEN
+#undef CLOSE
+#undef LSEEK
+#undef READ
+#undef WRITE
+#undef ACCESS
+#undef GETCWD
+#undef CHDIR
+#undef MKDIR
+#undef RMDIR
+#undef OPEN_RDONLY
+#undef OPEN_WRONLY
+#undef OPEN_CREAT
+#undef OPEN_TRUNC
+#undef OPEN_APPEND
+#undef OPEN_TEXT
+#undef OPEN_BINARY
+
+#define STATBUF	struct stat
+#define STATBUF4TSTAT	struct stat
+#define STAT		::stat
+#define FSTAT		::fstat
+#define STAT_REG	S_IFREG
+#define STAT_DIR	S_IFDIR
+#define STAT_MASK	S_IFMT
+#if defined(S_IFLNK)
+# define STAT_LNK	S_IFLNK
+#endif
+#define FILENO		fileno
+#define OPEN		::open
+#define CLOSE		::close
+#define LSEEK		::lseek
+#define READ		::read
+#define WRITE		::write
+#define ACCESS		::access
+#define GETCWD	::getcwd
+#define CHDIR		::chdir
+#define MKDIR		::mkdir
+#define RMDIR		::rmdir
+#define OPEN_RDONLY	O_RDONLY
+#define OPEN_WRONLY	O_WRONLY
+#define OPEN_RDWR	O_RDWR
+#define OPEN_CREAT	O_CREAT
+#define OPEN_TRUNC	O_TRUNC
+#define OPEN_APPEND	O_APPEND
+#if defined(O_TEXT)
+# define OPEN_TEXT	O_TEXT
+# define OPEN_BINARY O_BINARY
+#endif
+
+#define F_OK	0
+
+struct QFileInfoCache
+{
+    STATBUF st;
+    bool isSymLink;
+};
+
+
+#endif // _KWQ_COMPLETE_
+
+
+#include "_qiodevice.h"
 #include "qstring.h"
+#include "qcstring.h"
+
 
 // class QFile =================================================================
 
-class QFile {
+class QFile : public QIODevice {
 public:
 
     // typedefs ----------------------------------------------------------------
+
+#ifdef _KWQ_COMPLETE_
+    typedef QCString(*EncoderFn)(const QString &);
+    typedef QString(*DecoderFn)(const QCString &);
+#endif
+
     // enums -------------------------------------------------------------------
     // constants ---------------------------------------------------------------
     // static member functions -------------------------------------------------
 
+#ifdef _KWQ_COMPLETE_
+    static QCString encodeName(const QString &);
+    static QString decodeName(const QCString &);
+    static void setEncodingFunction(EncoderFn);
+    static void setDecodingFunction(DecoderFn);
+    static bool exists(const QString &);
+    static bool remove(const QString &fileName);
+#endif
+
     // constructors, copy constructors, and destructors ------------------------
 
     QFile();
@@ -51,15 +158,53 @@ public:
     // member functions --------------------------------------------------------
 
     bool exists() const;
-    static bool exists(const QString &);
     bool open(int);
     void close();
-    uint size() const;
     int readBlock(char *, uint);
+    uint size() const;
+
+
+#ifdef _KWQ_COMPLETE_
+    bool remove();
+
+    QString	name() const;
+    void setName(const QString &);
+
+    bool open(int, FILE *);
+    bool open(int, int);
+    void flush();
+
+    int  at() const;
+    bool at(int);
+    bool atEnd() const;
+
+    int writeBlock(const char *, uint);
+    int writeBlock(const QByteArray &);
+    int readLine(char *, uint);
+    int readLine(QString &, uint);
+
+    int getch();
+    int putch(int);
+    int ungetch(int);
+
+    int  handle() const;
+#endif
 
     // operators ---------------------------------------------------------------
 
 // protected -------------------------------------------------------------------
+
+#ifdef _KWQ_COMPLETE_
+protected:
+    QString fn;
+    FILE *fh;
+    int fd;
+    int length;
+    bool ext_f;
+    void *d;
+#endif
+
+
 // private ---------------------------------------------------------------------
 
 private:
@@ -68,6 +213,23 @@ private:
     QFile(const QFile &);
     QFile &operator=(const QFile &);
 
+#ifdef _KWQ_COMPLETE_
+    void init();
+    QCString ungetchBuffer;
+#endif
+
 }; // class QFile ==============================================================
 
+#ifdef _KWQ_COMPLETE_
+
+inline int QFile::at() const
+{
+    return ioIndex;
+}
+
+inline QString QFile::name() const
+{ return fn; }
+
+#endif
+
 #endif
diff --git a/WebCore/kwq/Makefile.in b/WebCore/kwq/Makefile.in
index c22651d..47f4358 100644
--- a/WebCore/kwq/Makefile.in
+++ b/WebCore/kwq/Makefile.in
@@ -31,6 +31,7 @@ MMOBJECTS = \
 	KWQPixmap.o \
 	KWQWMatrix.o \
 	KWQWidget.o \
+	KWQFile.o \
 # FIXME: add back in when this file builds ->  KWQString.o \
 	$(NULL)
 
diff --git a/WebCore/kwq/qt/_qfile.cpp b/WebCore/kwq/qt/_qfile.cpp
new file mode 100644
index 0000000..e662273
--- /dev/null
+++ b/WebCore/kwq/qt/_qfile.cpp
@@ -0,0 +1,697 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QFile class
+**
+** Created : 930812
+**
+** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
+**
+** This file is part of the tools module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales at trolltech.com for
+**   information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info at trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "qfile.h"
+
+extern bool qt_file_access( const QString& fn, int t );
+
+QFile::QFile()
+{
+    init();
+}
+
+QFile::QFile( const QString &name )
+    : fn(name)
+{
+    init();
+}
+
+QFile::~QFile()
+{
+    close();
+}
+
+void QFile::init()
+{
+    setFlags( IO_Direct );
+    setStatus( IO_Ok );
+    fh	   = 0;
+    fd	   = 0;
+    length = 0;
+    ioIndex = 0;
+    ext_f  = FALSE;				// not an external file handle
+}
+
+void QFile::setName( const QString &name )
+{
+    if ( isOpen() ) {
+#if defined(CHECK_STATE)
+	qWarning( "QFile::setName: File is open" );
+#endif
+	close();
+    }
+    fn = name;
+}
+
+bool QFile::exists() const
+{
+    return qt_file_access( fn, F_OK );
+}
+
+bool QFile::exists( const QString &fileName )
+{
+    return qt_file_access( fileName, F_OK );
+}
+
+bool QFile::remove()
+{
+    close();
+    return remove( fn );
+}
+
+#if defined(_OS_MAC_) || defined(_OS_MSDOS_) || defined(_OS_WIN32_) || defined(_OS_OS2_)
+#define HAS_TEXT_FILEMODE			// has translate/text filemode
+#endif
+#if defined(O_NONBLOCK)
+#define HAS_ASYNC_FILEMODE
+#define OPEN_ASYNC O_NONBLOCK
+#elif defined(O_NDELAY)
+#define HAS_ASYNC_FILEMODE
+#define OPEN_ASYNC O_NDELAY
+#endif
+
+void QFile::flush()
+{
+    if ( isOpen() && fh )			// can only flush open/buffered
+	fflush( fh );				//   file
+}
+
+bool QFile::atEnd() const
+{
+    if ( !isOpen() ) {
+#if defined(CHECK_STATE)
+	qWarning( "QFile::atEnd: File is not open" );
+#endif
+	return FALSE;
+    }
+    if ( isDirectAccess() && !isTranslated() ) {
+	if ( at() < length )
+	    return FALSE;
+    }
+    return QIODevice::atEnd();
+}
+
+int QFile::readLine( char *p, uint maxlen )
+{
+    if ( maxlen == 0 )				// application bug?
+	return 0;
+#if defined(CHECK_STATE)
+    CHECK_PTR( p );
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::readLine: File not open" );
+	return -1;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::readLine: Read operation not permitted" );
+	return -1;
+    }
+#endif
+    int nread;					// number of bytes read
+    if ( isRaw() ) {				// raw file
+	nread = QIODevice::readLine( p, maxlen );
+    } else {					// buffered file
+	p = fgets( p, maxlen, fh );
+	if ( p ) {
+	    nread = qstrlen( p );
+	    ioIndex += nread;
+	} else {
+	    nread = -1;
+	    setStatus(IO_ReadError);
+	}
+    }
+    return nread;
+}
+
+int QFile::readLine( QString& s, uint maxlen )
+{
+    QByteArray ba(maxlen);
+    int l = readLine(ba.data(),maxlen);
+    if ( l >= 0 ) {
+	ba.truncate(l);
+	s = QString(ba);
+    }
+    return l;
+}
+
+
+int QFile::getch()
+{
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::getch: File not open" );
+	return EOF;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::getch: Read operation not permitted" );
+	return EOF;
+    }
+#endif
+
+    int ch;
+
+    if ( !ungetchBuffer.isEmpty() ) {
+	int len = ungetchBuffer.length();
+	ch = ungetchBuffer[ len-1 ];
+	ungetchBuffer.truncate( len - 1 );
+	return ch;
+    }
+
+    if ( isRaw() ) {				// raw file (inefficient)
+	char buf[1];
+	ch = readBlock( buf, 1 ) == 1 ? buf[0] : EOF;
+    } else {					// buffered file
+	if ( (ch = getc( fh )) != EOF )
+	    ioIndex++;
+	else
+	    setStatus(IO_ReadError);
+    }
+    return ch;
+}
+
+int QFile::putch( int ch )
+{
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::putch: File not open" );
+	return EOF;
+    }
+    if ( !isWritable() ) {			// writing not permitted
+	qWarning( "QFile::putch: Write operation not permitted" );
+	return EOF;
+    }
+#endif
+    if ( isRaw() ) {				// raw file (inefficient)
+	char buf[1];
+	buf[0] = ch;
+	ch = writeBlock( buf, 1 ) == 1 ? ch : EOF;
+    } else {					// buffered file
+	if ( (ch = putc( ch, fh )) != EOF ) {
+	    ioIndex++;
+	    if ( ioIndex > length )		// update file length
+		length = ioIndex;
+	} else {
+	    setStatus(IO_WriteError);
+	}
+    }
+    return ch;
+}
+
+int QFile::ungetch( int ch )
+{
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::ungetch: File not open" );
+	return EOF;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::ungetch: Read operation not permitted" );
+	return EOF;
+    }
+#endif
+    if ( ch == EOF )				// cannot unget EOF
+	return ch;
+
+    if ( isSequentialAccess() && !fh) {
+	// pipe or similar => we cannot ungetch, so do it manually
+	ungetchBuffer +=ch;
+	return ch;
+    }
+
+    if ( isRaw() ) {				// raw file (very inefficient)
+	char buf[1];
+	at( ioIndex-1 );
+	buf[0] = ch;
+	if ( writeBlock(buf, 1) == 1 )
+	    at ( ioIndex-1 );
+	else
+	    ch = EOF;
+    } else {					// buffered file
+	if ( (ch = ungetc(ch, fh)) != EOF )
+	    ioIndex--;
+	else
+	    setStatus( IO_ReadError );
+    }
+    return ch;
+}
+
+
+static QCString locale_encoder( const QString &fileName )
+{
+    return fileName.local8Bit();
+}
+
+
+static QFile::EncoderFn encoder = locale_encoder;
+
+QCString QFile::encodeName( const QString &fileName )
+{
+    return (*encoder)(fileName);
+}
+
+void QFile::setEncodingFunction( EncoderFn f )
+{
+    encoder = f;
+}
+
+static
+QString locale_decoder( const QCString &localFileName )
+{
+    return QString::fromLocal8Bit(localFileName);
+}
+
+static QFile::DecoderFn decoder = locale_decoder;
+
+QString QFile::decodeName( const QCString &localFileName )
+{
+    return (*decoder)(localFileName);
+}
+
+void QFile::setDecodingFunction( DecoderFn f )
+{
+    decoder = f;
+}
+
+
+bool qt_file_access( const QString& fn, int t )
+{
+    if ( fn.isEmpty() )
+	return FALSE;
+    return ACCESS( QFile::encodeName(fn), t ) == 0;
+}
+
+bool QFile::remove( const QString &fileName )
+{
+    if ( fileName.isEmpty() ) {
+#if defined(CHECK_NULL)
+	qWarning( "QFile::remove: Empty or null file name" );
+#endif
+	return FALSE;
+    }
+    return unlink( QFile::encodeName(fileName) ) == 0;	
+    // unlink more common in UNIX
+}
+
+#if defined(O_NONBLOCK)
+# define HAS_ASYNC_FILEMODE
+# define OPEN_ASYNC O_NONBLOCK
+#elif defined(O_NDELAY)
+# define HAS_ASYNC_FILEMODE
+# define OPEN_ASYNC O_NDELAY
+#endif
+
+bool QFile::open( int m )
+{
+    if ( isOpen() ) {				// file already open
+#if defined(CHECK_STATE)
+	qWarning( "QFile::open: File already open" );
+#endif
+	return FALSE;
+    }
+    if ( fn.isNull() ) {			// no file name defined
+#if defined(CHECK_NULL)
+	qWarning( "QFile::open: No file name specified" );
+#endif
+	return FALSE;
+    }
+    init();					// reset params
+    setMode( m );
+    if ( !(isReadable() || isWritable()) ) {
+#if defined(CHECK_RANGE)
+	qWarning( "QFile::open: File access not specified" );
+#endif
+	return FALSE;
+    }
+    bool ok = TRUE;
+    STATBUF st;
+    if ( isRaw() ) {				// raw file I/O
+	int oflags = OPEN_RDONLY;
+	if ( isReadable() && isWritable() )
+	    oflags = OPEN_RDWR;
+	else if ( isWritable() )
+	    oflags = OPEN_WRONLY;
+	if ( flags() & IO_Append ) {		// append to end of file?
+	    if ( flags() & IO_Truncate )
+		oflags |= (OPEN_CREAT | OPEN_TRUNC);
+	    else
+		oflags |= (OPEN_APPEND | OPEN_CREAT);
+	    setFlags( flags() | IO_WriteOnly ); // append implies write
+	} else if ( isWritable() ) {		// create/trunc if writable
+	    if ( flags() & IO_Truncate )
+		oflags |= (OPEN_CREAT | OPEN_TRUNC);
+	    else
+		oflags |= OPEN_CREAT;
+	}
+#if defined(HAS_TEXT_FILEMODE)
+	if ( isTranslated() )
+	    oflags |= OPEN_TEXT;
+	else
+	    oflags |= OPEN_BINARY;
+#endif
+#if defined(HAS_ASYNC_FILEMODE)
+	if ( isAsynchronous() )
+	    oflags |= OPEN_ASYNC;
+#endif
+	fd = OPEN( QFile::encodeName(fn), oflags, 0666 );
+
+	if ( fd != -1 ) {			// open successful
+	    FSTAT( fd, &st ); // get the stat for later usage
+	} else {
+	    ok = FALSE;
+	}
+    } else {					// buffered file I/O
+	QCString perm;
+	char perm2[4];
+	bool try_create = FALSE;
+	if ( flags() & IO_Append ) {		// append to end of file?
+	    setFlags( flags() | IO_WriteOnly ); // append implies write
+	    perm = isReadable() ? "a+" : "a";
+	} else {
+	    if ( isReadWrite() ) {
+		if ( flags() & IO_Truncate ) {
+		    perm = "w+";
+		} else {
+		    perm = "r+";
+		    try_create = TRUE;		// try to create if not exists
+		}
+	    } else if ( isReadable() ) {
+		perm = "r";
+	    } else if ( isWritable() ) {
+		perm = "w";
+	    }
+	}
+	qstrcpy( perm2, perm );
+#if defined(HAS_TEXT_FILEMODE)
+	if ( isTranslated() )
+	    strcat( perm2, "t" );
+	else
+	    strcat( perm2, "b" );
+#endif
+	while (1) { // At most twice
+
+	    fh = fopen( QFile::encodeName(fn), perm2 );
+
+	    if ( !fh && try_create ) {
+		perm2[0] = 'w';			// try "w+" instead of "r+"
+		try_create = FALSE;
+	    } else {
+		break;
+	    }
+	}
+	if ( fh ) {
+	    FSTAT( FILENO(fh), &st ); // get the stat for later usage
+	} else {
+	    ok = FALSE;
+	}
+    }
+    if ( ok ) {
+	setState( IO_Open );
+	// on successful open the file stat was got; now test what type
+	// of file we have
+	if ( (st.st_mode & STAT_MASK) != STAT_REG ) {
+	    // non-seekable
+	    setType( IO_Sequential );
+	    length = INT_MAX;
+	    ioIndex  = (flags() & IO_Append) == 0 ? 0 : length;
+	} else {
+	    length = (int)st.st_size;
+	    ioIndex  = (flags() & IO_Append) == 0 ? 0 : length;
+	    if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) {
+		// try if you can read from it (if you can, it's a sequential
+		// device; e.g. a file in the /proc filesystem)
+		int c = getch();
+		if ( c != -1 ) {
+		    ungetch(c);
+		    setType( IO_Sequential );
+		    length = INT_MAX;
+		}
+	    }
+	}
+    } else {
+	init();
+	if ( errno == EMFILE )			// no more file handles/descrs
+	    setStatus( IO_ResourceError );
+	else
+	    setStatus( IO_OpenError );
+    }
+    return ok;
+}
+
+bool QFile::open( int m, FILE *f )
+{
+    if ( isOpen() ) {
+#if defined(CHECK_RANGE)
+	qWarning( "QFile::open: File already open" );
+#endif
+	return FALSE;
+    }
+    init();
+    setMode( m &~IO_Raw );
+    setState( IO_Open );
+    fh = f;
+    ext_f = TRUE;
+    STATBUF st;
+    FSTAT( FILENO(fh), &st );
+    ioIndex = (int)ftell( fh );
+    if ( (st.st_mode & STAT_MASK) != STAT_REG || f == stdin ) { //stdin is non seekable
+	// non-seekable
+	setType( IO_Sequential );
+	length = INT_MAX;
+    } else {
+	length = (int)st.st_size;
+	if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) {
+	    // try if you can read from it (if you can, it's a sequential
+	    // device; e.g. a file in the /proc filesystem)
+	    int c = getch();
+	    if ( c != -1 ) {
+		ungetch(c);
+		setType( IO_Sequential );
+		length = INT_MAX;
+	    }
+	}
+    }
+    return TRUE;
+}
+
+bool QFile::open( int m, int f )
+{
+    if ( isOpen() ) {
+#if defined(CHECK_RANGE)
+	qWarning( "QFile::open: File already open" );
+#endif
+	return FALSE;
+    }
+    init();
+    setMode( m |IO_Raw );
+    setState( IO_Open );
+    fd = f;
+    ext_f = TRUE;
+    STATBUF st;
+    FSTAT( fd, &st );
+    ioIndex  = (int)LSEEK(fd, 0, SEEK_CUR);
+    if ( (st.st_mode & STAT_MASK) != STAT_REG || f == 0 ) { // stdin is not seekable...
+	// non-seekable
+	setType( IO_Sequential );
+	length = INT_MAX;
+    } else {
+	length = (int)st.st_size;
+	if ( length == 0 && isReadable() ) {
+	    // try if you can read from it (if you can, it's a sequential
+	    // device; e.g. a file in the /proc filesystem)
+	    int c = getch();
+	    if ( c != -1 ) {
+		ungetch(c);
+		setType( IO_Sequential );
+		length = INT_MAX;
+	    }
+	    resetStatus();
+	}
+    }
+    return TRUE;
+}
+
+uint QFile::size() const
+{
+    STATBUF st;
+    if ( isOpen() ) {
+	FSTAT( fh ? FILENO(fh) : fd, &st );
+    } else {
+	STAT( QFile::encodeName(fn), &st );
+    }
+    return st.st_size;
+}
+
+bool QFile::at( int pos )
+{
+    if ( !isOpen() ) {
+#if defined(CHECK_STATE)
+	qWarning( "QFile::at: File is not open" );
+#endif
+	return FALSE;
+    }
+    bool ok;
+    if ( isRaw() ) {				// raw file
+	pos = (int)LSEEK(fd, pos, SEEK_SET);
+	ok = pos != -1;
+    } else {					// buffered file
+	ok = fseek(fh, pos, SEEK_SET) == 0;
+    }
+    if ( ok )
+	ioIndex = pos;
+#if defined(CHECK_RANGE)
+    else
+	qWarning( "QFile::at: Cannot set file position %d", pos );
+#endif
+    return ok;
+}
+
+int QFile::readBlock( char *p, uint len )
+{
+#if defined(CHECK_NULL)
+    if ( !p )
+	qWarning( "QFile::readBlock: Null pointer error" );
+#endif
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::readBlock: File not open" );
+	return -1;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::readBlock: Read operation not permitted" );
+	return -1;
+    }
+#endif
+    int nread = 0;					// number of bytes read
+    if ( !ungetchBuffer.isEmpty() ) {
+	// need to add these to the returned string.
+	int l = ungetchBuffer.length();
+	while( nread < l ) {
+	    *p = ungetchBuffer[ l - nread - 1 ];
+	    p++;
+	    nread++;
+	}
+	ungetchBuffer.truncate( l - nread );
+    }
+
+    if ( nread < (int)len ) {
+	if ( isRaw() ) {				// raw file
+	    nread += READ( fd, p, len-nread );
+	    if ( len && nread <= 0 ) {
+		nread = 0;
+		setStatus(IO_ReadError);
+	    }
+	} else {					// buffered file
+	    nread += fread( p, 1, len-nread, fh );
+	    if ( (uint)nread != len ) {
+		if ( ferror( fh ) || nread==0 )
+		    setStatus(IO_ReadError);
+	    }
+	}
+    }
+    ioIndex += nread;
+    return nread;
+}
+
+int QFile::writeBlock( const char *p, uint len )
+{
+#if defined(CHECK_NULL)
+    if ( p == 0 && len != 0 )
+	qWarning( "QFile::writeBlock: Null pointer error" );
+#endif
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::writeBlock: File not open" );
+	return -1;
+    }
+    if ( !isWritable() ) {			// writing not permitted
+	qWarning( "QFile::writeBlock: Write operation not permitted" );
+	return -1;
+    }
+#endif
+    int nwritten;				// number of bytes written
+    if ( isRaw() )				// raw file
+	nwritten = WRITE( fd, p, len );
+    else					// buffered file
+	nwritten = fwrite( p, 1, len, fh );
+    if ( nwritten != (int)len ) {		// write error
+	if ( errno == ENOSPC )			// disk is full
+	    setStatus( IO_ResourceError );
+	else
+	    setStatus( IO_WriteError );
+	if ( isRaw() )				// recalc file position
+	    ioIndex = (int)LSEEK( fd, 0, SEEK_CUR );
+	else
+	    ioIndex = fseek( fh, 0, SEEK_CUR );
+    } else {
+	ioIndex += nwritten;
+    }
+    if ( ioIndex > length )			// update file length
+	length = ioIndex;
+    return nwritten;
+}
+
+int QFile::handle() const
+{
+    if ( !isOpen() )
+	return -1;
+    else if ( fh )
+	return FILENO( fh );
+    else
+	return fd;
+}
+
+void QFile::close()
+{
+    bool ok = FALSE;
+    if ( isOpen() ) {				// file is not open
+	if ( fh ) {				// buffered file
+	    if ( ext_f )
+		ok = fflush( fh ) != -1;	// flush instead of closing
+	    else
+		ok = fclose( fh ) != -1;
+	} else {				// raw file
+	    if ( ext_f )
+		ok = TRUE;			// cannot close
+	    else
+		ok = CLOSE( fd ) != -1;
+	}
+	init();					// restore internal state
+    }
+    if (!ok)
+	setStatus (IO_UnspecifiedError);
+
+    return;
+}
diff --git a/WebCore/kwq/qt/_qiodevice.cpp b/WebCore/kwq/qt/_qiodevice.cpp
new file mode 100644
index 0000000..81f91a5
--- /dev/null
+++ b/WebCore/kwq/qt/_qiodevice.cpp
@@ -0,0 +1,638 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QIODevice class
+**
+** Created : 940913
+**
+** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
+**
+** This file is part of the tools module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales at trolltech.com for
+**   information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info at trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "_qiodevice.h"
+
+// NOT REVISED
+/*!
+  \class QIODevice qiodevice.h
+
+  \brief The QIODevice class is the base class of I/O devices.
+
+  \ingroup io
+
+  An I/O device represents a medium that one can read bytes from
+  and/or write bytes to.  The QIODevice class is the abstract
+  superclass of all such devices; classes like QFile, QBuffer and
+  QSocket inherit QIODevice and implement virtual functions like
+  write() appropriately.
+
+  While applications sometimes use QIODevice directly, mostly it is
+  better to go through QTextStream and QDataStream, which provide
+  stream operations on any QIODevice subclass.  QTextStream provides
+  text-oriented stream functionality (for human-readable ASCII files,
+  for example), while QDataStream deals with binary data in a totally
+  platform-independent manner.
+
+  The public member functions in QIODevice roughly fall into two
+  groups: The action functions and the state access functions.  The
+  most important action functions are: <ul>
+
+  <li> open() opens a device for reading and/or writing, depending on
+  the argument to open().
+
+  <li> close() closes the device and tidies up.
+
+  <li> readBlock() reads a block of data from the device.
+
+  <li> writeBlock() writes a block of data to the device.
+
+  <li> readLine() reads a line (of text, usually) from the device.
+
+  <li> flush() ensures that all buffered data are written to the real device.
+
+  </ul>There are also some other, less used, action functions: <ul>
+
+  <li> getch() reads a single character.
+
+  <li> ungetch() forgets the last call to getch(), if possible.
+
+  <li> putch() writes a single character.
+
+  <li> size() returns the size of the device, if there is one.
+
+  <li> at() returns the current read/write pointer, if there is one
+  for this device, or it moves the pointer.
+
+  <li> atEnd() says whether there is more to read, if that is a
+  meaningful question for this device.
+
+  <li> reset() moves the read/write pointer to the start of the
+  device, if that is possible for this device.
+
+  </ul>The state access are all "get" functions.  The QIODevice subclass
+  calls setState() to update the state, and simple access functions
+  tell the user of the device what the device's state is.  Here are
+  the settings, and their associated access functions: <ul>
+
+  <li> Access type.  Some devices are direct access (it is possible to
+  read/write anywhere) while others are sequential.  QIODevice
+  provides the access functions isDirectAccess(), isSequentialAccess()
+  and isCombinedAccess() to tell users what a given I/O device
+  supports.
+
+  <li> Buffering.  Some devices are accessed in raw mode while others
+  are buffered.  Buffering usually provides greater efficiency,
+  particularly for small read/write operations.  isBuffered() tells
+  the user whether a given device is buffered.  (This can often be set
+  by the application in the call to open().)
+
+  <li> Synchronicity.  Synchronous devices work there and then, for
+  example files.  When you read from a file, the file delivers its
+  data right away.  Others, such as a socket connected to a HTTP
+  server, may not deliver the data until seconds after you ask to read
+  it.  isSynchronous() and isAsynchronous() tells the user how this
+  device operates.
+
+  <li> CR/LF translation.  For simplicity, applications often like to
+  see just a single CR/LF style, and QIODevice subclasses can provide
+  that.  isTranslated() returns TRUE if this object translates CR/LF
+  to just LF.  (This can often be set by the application in the call
+  to open().)
+
+  <li> Accessibility.  Some files cannot be written, for example.
+  isReadable(), isWritable and isReadWrite() tells the application
+  whether it can read from and write to a given device.  (This can
+  often be set by the application in the call to open().)
+
+  <li> Finally, isOpen() returns TRUE if the device is open.  This can
+  quite obviously be set using open() :)
+
+  </ul>
+
+  QIODevice provides numerous pure virtual functions you need to
+  implement when subclassing it.  Here is a skeleton subclass with all
+  the members you are certain to need, and some it's likely that you
+  will need:
+
+  \code
+    class YourDevice : public QIODevice
+    {
+    public:
+	YourDevice();
+       ~YourDevice();
+
+	bool open( int mode );
+	void close();
+	void flush();
+
+	uint size() const;
+	int  at() const;	// not a pure virtual function
+	bool at( int );		// not a pure virtual function
+	bool atEnd() const;	// not a pure virtual function
+
+	int readBlock( char *data, uint maxlen );
+	int writeBlock( const char *data, uint len );
+	int readLine( char *data, uint maxlen );
+
+	int getch();
+	int putch( int );
+	int ungetch( int );
+    };
+  \endcode
+
+  The three non-pure virtual functions can be ignored if your device
+  is sequential (e.g. an RS-232 port).
+
+  \sa QDataStream, QTextStream
+*/
+
+
+/*!
+  Constructs an I/O device.
+*/
+
+QIODevice::QIODevice()
+{
+    ioMode = 0;					// initial mode
+    ioSt = IO_Ok;
+    ioIndex = 0;
+}
+
+/*!
+  Destructs the I/O device.
+*/
+
+QIODevice::~QIODevice()
+{
+}
+
+
+/*!
+  \fn int QIODevice::flags() const
+  Returns the current I/O device flags setting.
+
+  Flags consists of mode flags and state flags.
+
+  \sa mode(), state()
+*/
+
+/*!
+  \fn int QIODevice::mode() const
+  Returns bits OR'ed together that specify the current operation mode.
+
+  These are the flags that were given to the open() function.
+
+  The flags are: \c IO_ReadOnly, \c IO_WriteOnly, \c IO_ReadWrite,
+  \c IO_Append, \c IO_Truncate and \c IO_Translate.
+*/
+
+/*!
+  \fn int QIODevice::state() const
+  Returns bits OR'ed together that specify the current state.
+
+  The flags are: \c IO_Open.
+
+  Subclasses may define more flags.
+*/
+
+/*!
+  \fn bool QIODevice::isDirectAccess() const
+  Returns TRUE if the I/O device is a direct access (not sequential) device,
+  otherwise FALSE.
+  \sa isSequentialAccess()
+*/
+
+/*!
+  \fn bool QIODevice::isSequentialAccess() const
+  Returns TRUE if the I/O device is a sequential access (not direct) device,
+  otherwise FALSE.  Operations involving size() and at(int) are not valid
+  on sequential devices.
+  \sa isDirectAccess()
+*/
+
+/*!
+  \fn bool QIODevice::isCombinedAccess() const
+  Returns TRUE if the I/O device is a combined access (both direct and
+  sequential) device,  otherwise FALSE.
+
+  This access method is currently not in use.
+*/
+
+/*!
+  \fn bool QIODevice::isBuffered() const
+  Returns TRUE if the I/O device is a buffered (not raw) device, otherwise
+  FALSE.
+  \sa isRaw()
+*/
+
+/*!
+  \fn bool QIODevice::isRaw() const
+  Returns TRUE if the I/O device is a raw (not buffered) device, otherwise
+  FALSE.
+  \sa isBuffered()
+*/
+
+/*!
+  \fn bool QIODevice::isSynchronous() const
+  Returns TRUE if the I/O device is a synchronous device, otherwise
+  FALSE.
+  \sa isAsynchronous()
+*/
+
+/*!
+  \fn bool QIODevice::isAsynchronous() const
+  Returns TRUE if the I/O device is a asynchronous device, otherwise
+  FALSE.
+
+  This mode is currently not in use.
+
+  \sa isSynchronous()
+*/
+
+/*!
+  \fn bool QIODevice::isTranslated() const
+  Returns TRUE if the I/O device translates carriage-return and linefeed
+  characters.
+
+  A QFile is translated if it is opened with the \c IO_Translate mode
+  flag.
+*/
+
+/*!
+  \fn bool QIODevice::isReadable() const
+  Returns TRUE if the I/O device was opened using \c IO_ReadOnly or
+  \c IO_ReadWrite mode.
+  \sa isWritable(), isReadWrite()
+*/
+
+/*!
+  \fn bool QIODevice::isWritable() const
+  Returns TRUE if the I/O device was opened using \c IO_WriteOnly or
+  \c IO_ReadWrite mode.
+  \sa isReadable(), isReadWrite()
+*/
+
+/*!
+  \fn bool QIODevice::isReadWrite() const
+  Returns TRUE if the I/O device was opened using \c IO_ReadWrite mode.
+  \sa isReadable(), isWritable()
+*/
+
+/*!
+  \fn bool QIODevice::isInactive() const
+  Returns TRUE if the I/O device state is 0, i.e. the device is not open.
+  \sa isOpen()
+*/
+
+/*!
+  \fn bool QIODevice::isOpen() const
+  Returns TRUE if the I/O device state has been opened, otherwise FALSE.
+  \sa isInactive()
+*/
+
+
+/*!
+  \fn int QIODevice::status() const
+  Returns the I/O device status.
+
+  The I/O device status returns an error code.	If open() returns FALSE
+  or readBlock() or writeBlock() return -1, this function can be called to
+  get the reason why the operation did not succeed.
+
+  The status codes are:
+  <ul>
+  <li>\c IO_Ok The operation was successful.
+  <li>\c IO_ReadError Could not read from the device.
+  <li>\c IO_WriteError Could not write to the device.
+  <li>\c IO_FatalError A fatal unrecoverable error occurred.
+  <li>\c IO_OpenError Could not open the device.
+  <li>\c IO_ConnectError Could not connect to the device.
+  <li>\c IO_AbortError The operation was unexpectedly aborted.
+  <li>\c IO_TimeOutError The operation timed out.
+  <li>\c IO_OnCloseError An unspecified error happened on close.
+  </ul>
+
+  \sa resetStatus()
+*/
+
+/*!
+  \fn void QIODevice::resetStatus()
+
+  Sets the I/O device status to \c IO_Ok.
+
+  \sa status()
+*/
+
+
+/*!
+  \fn void QIODevice::setFlags( int f )
+  \internal
+  Used by subclasses to set the device flags.
+*/
+
+/*!
+  \internal
+  Used by subclasses to set the device type.
+*/
+
+void QIODevice::setType( int t )
+{
+#if defined(CHECK_RANGE)
+    if ( (t & IO_TypeMask) != t )
+	qWarning( "QIODevice::setType: Specified type out of range" );
+#endif
+    ioMode &= ~IO_TypeMask;			// reset type bits
+    ioMode |= t;
+}
+
+/*!
+  \internal
+  Used by subclasses to set the device mode.
+*/
+
+void QIODevice::setMode( int m )
+{
+#if defined(CHECK_RANGE)
+    if ( (m & IO_ModeMask) != m )
+	qWarning( "QIODevice::setMode: Specified mode out of range" );
+#endif
+    ioMode &= ~IO_ModeMask;			// reset mode bits
+    ioMode |= m;
+}
+
+/*!
+  \internal
+  Used by subclasses to set the device state.
+*/
+
+void QIODevice::setState( int s )
+{
+#if defined(CHECK_RANGE)
+    if ( ((uint)s & IO_StateMask) != (uint)s )
+	qWarning( "QIODevice::setState: Specified state out of range" );
+#endif
+    ioMode &= ~IO_StateMask;			// reset state bits
+    ioMode |= (uint)s;
+}
+
+/*!
+  \internal
+  Used by subclasses to set the device status (not state).
+*/
+
+void QIODevice::setStatus( int s )
+{
+    ioSt = s;
+}
+
+
+/*!
+  \fn bool QIODevice::open( int mode )
+  Opens the I/O device using the specified \e mode.
+  Returns TRUE if successful, or FALSE if the device could not be opened.
+
+  The mode parameter \e m must be a combination of the following flags.
+  <ul>
+  <li>\c IO_Raw specified raw (unbuffered) file access.
+  <li>\c IO_ReadOnly opens a file in read-only mode.
+  <li>\c IO_WriteOnly opens a file in write-only mode.
+  <li>\c IO_ReadWrite opens a file in read/write mode.
+  <li>\c IO_Append sets the file index to the end of the file.
+  <li>\c IO_Truncate truncates the file.
+  <li>\c IO_Translate enables carriage returns and linefeed translation
+  for text files under MS-DOS, Window, OS/2 and Macintosh.  On Unix systems 
+  this flag has no effect. Use with caution as it will also transform every linefeed
+  written to the file into a CRLF pair. This is likely to corrupt your file when
+  writing binary data to it. Cannot be combined with \c IO_Raw.
+  </ul>
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa close()
+*/
+
+/*!
+  \fn void QIODevice::close()
+  Closes the I/O device.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa open()
+*/
+
+/*!
+  \fn void QIODevice::flush()
+
+  Flushes an open I/O device.
+
+  This virtual function must be reimplemented by all subclasses.
+*/
+
+
+/*!
+  \fn uint QIODevice::size() const
+  Virtual function that returns the size of the I/O device.
+  \sa at()
+*/
+
+/*!
+  Virtual function that returns the current I/O device index.
+
+  This index is the data read/write head of the I/O device.
+
+  \sa size()
+*/
+
+int QIODevice::at() const
+{
+    return ioIndex;
+}
+
+/*!
+  Virtual function that sets the I/O device index to \e pos.
+  \sa size()
+*/
+
+bool QIODevice::at( int pos )
+{
+#if defined(CHECK_RANGE)
+    if ( (uint)pos > size() ) {
+	qWarning( "QIODevice::at: Index %d out of range", pos );
+	return FALSE;
+    }
+#endif
+    ioIndex = pos;
+    return TRUE;
+}
+
+/*!
+  Virtual function that returns TRUE if the I/O device index is at the
+  end of the input.
+*/
+
+bool QIODevice::atEnd() const
+{
+    if ( isSequentialAccess() || isTranslated() ) {
+	QIODevice* that = (QIODevice*)this;
+	int c = that->getch();
+	bool result = c < 0;
+	that->ungetch(c);
+	return result;
+    } else {
+	return at() == (int)size();
+    }
+}
+
+/*!
+  \fn bool QIODevice::reset()
+  Sets the device index to 0.
+  \sa at()
+*/
+
+
+/*!
+  \fn int QIODevice::readBlock( char *data, uint maxlen )
+  Reads at most \e maxlen bytes from the I/O device into \e data and
+  returns the number of bytes actually read.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa writeBlock()
+*/
+
+/*!
+  This convenience function returns all of the remaining data in the
+  device.  Note that this only works for direct access devices, such
+  as QFile.
+  
+  \sa isDirectAccess() 
+*/
+QByteArray QIODevice::readAll()
+{
+    int n = size()-at();
+    QByteArray ba(size()-at());
+    char* c = ba.data();
+    while ( n ) {
+	int r = readBlock( c, n );
+	if ( r < 0 )
+	    return QByteArray();
+	n -= r;
+	c += r;
+    }
+    return ba;
+}
+
+/*!
+  \fn int QIODevice::writeBlock( const char *data, uint len )
+  Writes \e len bytes from \e p to the I/O device and returns the number of
+  bytes actually written.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa readBlock()
+*/
+
+/*!
+  This convenience function is the same as calling
+  writeBlock( data.data(), data.size() ).
+*/
+int QIODevice::writeBlock( const QByteArray& data )
+{
+    return writeBlock( data.data(), data.size() );
+}
+
+/*!
+  Reads a line of text, up to \e maxlen bytes including a terminating
+  \0.  If there is a newline at the end if the line, it is not stripped.
+
+  Returns the number of bytes read, or -1 in case of error.
+
+  This virtual function can be reimplemented much more efficiently by
+  the most subclasses.
+
+  \sa readBlock(), QTextStream::readLine()
+*/
+
+int QIODevice::readLine( char *data, uint maxlen )
+{
+    if ( maxlen == 0 )				// application bug?
+	return 0;
+    int pos = at();				// get current position
+    int s  = (int)size();			// size of I/O device
+    char *p = data;
+    if ( pos >= s )
+	return 0;
+    while ( pos++ < s && --maxlen ) {		// read one byte at a time
+	readBlock( p, 1 );
+	if ( *p++ == '\n' )			// end of line
+	    break;
+    }
+    *p++ = '\0';
+    return (int)((long)p - (long)data);
+}
+
+
+/*!
+  \fn int QIODevice::getch()
+
+  Reads a single byte/character from the I/O device.
+
+  Returns the byte/character read, or -1 if the end of the I/O device has been
+  reached.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa putch(), ungetch()
+*/
+
+/*!
+  \fn int QIODevice::putch( int ch )
+
+  Writes the character \e ch to the I/O device.
+
+  Returns \e ch, or -1 if some error occurred.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa getch(), ungetch()
+*/
+
+/*!
+  \fn int QIODevice::ungetch( int ch )
+
+  Puts the character \e ch back into the I/O device and decrements the
+  index if it is not zero.
+
+  This function is normally called to "undo" a getch() operation.
+
+  Returns \e ch, or -1 if some error occurred.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa getch(), putch()
+*/
diff --git a/WebCore/kwq/qt/_qiodevice.h b/WebCore/kwq/qt/_qiodevice.h
index 4843159..0c826c1 100644
--- a/WebCore/kwq/qt/_qiodevice.h
+++ b/WebCore/kwq/qt/_qiodevice.h
@@ -38,18 +38,8 @@
 #ifndef QIODEVICE_H
 #define QIODEVICE_H
 
-// KWQ hacks ---------------------------------------------------------------
-
-#ifndef _KWQ_COMPLETE_
-#define _KWQ_COMPLETE_
-#endif
-
-#include <KWQDef.h>
-
-// -------------------------------------------------------------------------
-
 #ifndef QT_H
-#include "qglobal.h"
+#include <KWQDef.h>
 #include "qcstring.h"
 #endif // QT_H
 
diff --git a/WebCore/kwq/qt/qfile.h b/WebCore/kwq/qt/qfile.h
index f1cfece..f67b7df 100644
--- a/WebCore/kwq/qt/qfile.h
+++ b/WebCore/kwq/qt/qfile.h
@@ -30,18 +30,125 @@
 #include <config.h>
 #endif
 
+#include <KWQDef.h>
+
+#ifdef _KWQ_COMPLETE_
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#if !defined(PATH_MAX)
+#if defined(MAXPATHLEN)
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+#undef STATBUF
+#undef STAT
+#undef STAT_REG
+#undef STAT_DIR
+#undef STAT_LNK
+#undef STAT_MASK
+#undef FILENO
+#undef OPEN
+#undef CLOSE
+#undef LSEEK
+#undef READ
+#undef WRITE
+#undef ACCESS
+#undef GETCWD
+#undef CHDIR
+#undef MKDIR
+#undef RMDIR
+#undef OPEN_RDONLY
+#undef OPEN_WRONLY
+#undef OPEN_CREAT
+#undef OPEN_TRUNC
+#undef OPEN_APPEND
+#undef OPEN_TEXT
+#undef OPEN_BINARY
+
+#define STATBUF	struct stat
+#define STATBUF4TSTAT	struct stat
+#define STAT		::stat
+#define FSTAT		::fstat
+#define STAT_REG	S_IFREG
+#define STAT_DIR	S_IFDIR
+#define STAT_MASK	S_IFMT
+#if defined(S_IFLNK)
+# define STAT_LNK	S_IFLNK
+#endif
+#define FILENO		fileno
+#define OPEN		::open
+#define CLOSE		::close
+#define LSEEK		::lseek
+#define READ		::read
+#define WRITE		::write
+#define ACCESS		::access
+#define GETCWD	::getcwd
+#define CHDIR		::chdir
+#define MKDIR		::mkdir
+#define RMDIR		::rmdir
+#define OPEN_RDONLY	O_RDONLY
+#define OPEN_WRONLY	O_WRONLY
+#define OPEN_RDWR	O_RDWR
+#define OPEN_CREAT	O_CREAT
+#define OPEN_TRUNC	O_TRUNC
+#define OPEN_APPEND	O_APPEND
+#if defined(O_TEXT)
+# define OPEN_TEXT	O_TEXT
+# define OPEN_BINARY O_BINARY
+#endif
+
+#define F_OK	0
+
+struct QFileInfoCache
+{
+    STATBUF st;
+    bool isSymLink;
+};
+
+
+#endif // _KWQ_COMPLETE_
+
+
+#include "_qiodevice.h"
 #include "qstring.h"
+#include "qcstring.h"
+
 
 // class QFile =================================================================
 
-class QFile {
+class QFile : public QIODevice {
 public:
 
     // typedefs ----------------------------------------------------------------
+
+#ifdef _KWQ_COMPLETE_
+    typedef QCString(*EncoderFn)(const QString &);
+    typedef QString(*DecoderFn)(const QCString &);
+#endif
+
     // enums -------------------------------------------------------------------
     // constants ---------------------------------------------------------------
     // static member functions -------------------------------------------------
 
+#ifdef _KWQ_COMPLETE_
+    static QCString encodeName(const QString &);
+    static QString decodeName(const QCString &);
+    static void setEncodingFunction(EncoderFn);
+    static void setDecodingFunction(DecoderFn);
+    static bool exists(const QString &);
+    static bool remove(const QString &fileName);
+#endif
+
     // constructors, copy constructors, and destructors ------------------------
 
     QFile();
@@ -51,15 +158,53 @@ public:
     // member functions --------------------------------------------------------
 
     bool exists() const;
-    static bool exists(const QString &);
     bool open(int);
     void close();
-    uint size() const;
     int readBlock(char *, uint);
+    uint size() const;
+
+
+#ifdef _KWQ_COMPLETE_
+    bool remove();
+
+    QString	name() const;
+    void setName(const QString &);
+
+    bool open(int, FILE *);
+    bool open(int, int);
+    void flush();
+
+    int  at() const;
+    bool at(int);
+    bool atEnd() const;
+
+    int writeBlock(const char *, uint);
+    int writeBlock(const QByteArray &);
+    int readLine(char *, uint);
+    int readLine(QString &, uint);
+
+    int getch();
+    int putch(int);
+    int ungetch(int);
+
+    int  handle() const;
+#endif
 
     // operators ---------------------------------------------------------------
 
 // protected -------------------------------------------------------------------
+
+#ifdef _KWQ_COMPLETE_
+protected:
+    QString fn;
+    FILE *fh;
+    int fd;
+    int length;
+    bool ext_f;
+    void *d;
+#endif
+
+
 // private ---------------------------------------------------------------------
 
 private:
@@ -68,6 +213,23 @@ private:
     QFile(const QFile &);
     QFile &operator=(const QFile &);
 
+#ifdef _KWQ_COMPLETE_
+    void init();
+    QCString ungetchBuffer;
+#endif
+
 }; // class QFile ==============================================================
 
+#ifdef _KWQ_COMPLETE_
+
+inline int QFile::at() const
+{
+    return ioIndex;
+}
+
+inline QString QFile::name() const
+{ return fn; }
+
+#endif
+
 #endif
diff --git a/WebCore/src/kwq/Makefile.in b/WebCore/src/kwq/Makefile.in
index c22651d..47f4358 100644
--- a/WebCore/src/kwq/Makefile.in
+++ b/WebCore/src/kwq/Makefile.in
@@ -31,6 +31,7 @@ MMOBJECTS = \
 	KWQPixmap.o \
 	KWQWMatrix.o \
 	KWQWidget.o \
+	KWQFile.o \
 # FIXME: add back in when this file builds ->  KWQString.o \
 	$(NULL)
 
diff --git a/WebCore/src/kwq/qt/_qfile.cpp b/WebCore/src/kwq/qt/_qfile.cpp
new file mode 100644
index 0000000..e662273
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qfile.cpp
@@ -0,0 +1,697 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QFile class
+**
+** Created : 930812
+**
+** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
+**
+** This file is part of the tools module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales at trolltech.com for
+**   information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info at trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "qfile.h"
+
+extern bool qt_file_access( const QString& fn, int t );
+
+QFile::QFile()
+{
+    init();
+}
+
+QFile::QFile( const QString &name )
+    : fn(name)
+{
+    init();
+}
+
+QFile::~QFile()
+{
+    close();
+}
+
+void QFile::init()
+{
+    setFlags( IO_Direct );
+    setStatus( IO_Ok );
+    fh	   = 0;
+    fd	   = 0;
+    length = 0;
+    ioIndex = 0;
+    ext_f  = FALSE;				// not an external file handle
+}
+
+void QFile::setName( const QString &name )
+{
+    if ( isOpen() ) {
+#if defined(CHECK_STATE)
+	qWarning( "QFile::setName: File is open" );
+#endif
+	close();
+    }
+    fn = name;
+}
+
+bool QFile::exists() const
+{
+    return qt_file_access( fn, F_OK );
+}
+
+bool QFile::exists( const QString &fileName )
+{
+    return qt_file_access( fileName, F_OK );
+}
+
+bool QFile::remove()
+{
+    close();
+    return remove( fn );
+}
+
+#if defined(_OS_MAC_) || defined(_OS_MSDOS_) || defined(_OS_WIN32_) || defined(_OS_OS2_)
+#define HAS_TEXT_FILEMODE			// has translate/text filemode
+#endif
+#if defined(O_NONBLOCK)
+#define HAS_ASYNC_FILEMODE
+#define OPEN_ASYNC O_NONBLOCK
+#elif defined(O_NDELAY)
+#define HAS_ASYNC_FILEMODE
+#define OPEN_ASYNC O_NDELAY
+#endif
+
+void QFile::flush()
+{
+    if ( isOpen() && fh )			// can only flush open/buffered
+	fflush( fh );				//   file
+}
+
+bool QFile::atEnd() const
+{
+    if ( !isOpen() ) {
+#if defined(CHECK_STATE)
+	qWarning( "QFile::atEnd: File is not open" );
+#endif
+	return FALSE;
+    }
+    if ( isDirectAccess() && !isTranslated() ) {
+	if ( at() < length )
+	    return FALSE;
+    }
+    return QIODevice::atEnd();
+}
+
+int QFile::readLine( char *p, uint maxlen )
+{
+    if ( maxlen == 0 )				// application bug?
+	return 0;
+#if defined(CHECK_STATE)
+    CHECK_PTR( p );
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::readLine: File not open" );
+	return -1;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::readLine: Read operation not permitted" );
+	return -1;
+    }
+#endif
+    int nread;					// number of bytes read
+    if ( isRaw() ) {				// raw file
+	nread = QIODevice::readLine( p, maxlen );
+    } else {					// buffered file
+	p = fgets( p, maxlen, fh );
+	if ( p ) {
+	    nread = qstrlen( p );
+	    ioIndex += nread;
+	} else {
+	    nread = -1;
+	    setStatus(IO_ReadError);
+	}
+    }
+    return nread;
+}
+
+int QFile::readLine( QString& s, uint maxlen )
+{
+    QByteArray ba(maxlen);
+    int l = readLine(ba.data(),maxlen);
+    if ( l >= 0 ) {
+	ba.truncate(l);
+	s = QString(ba);
+    }
+    return l;
+}
+
+
+int QFile::getch()
+{
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::getch: File not open" );
+	return EOF;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::getch: Read operation not permitted" );
+	return EOF;
+    }
+#endif
+
+    int ch;
+
+    if ( !ungetchBuffer.isEmpty() ) {
+	int len = ungetchBuffer.length();
+	ch = ungetchBuffer[ len-1 ];
+	ungetchBuffer.truncate( len - 1 );
+	return ch;
+    }
+
+    if ( isRaw() ) {				// raw file (inefficient)
+	char buf[1];
+	ch = readBlock( buf, 1 ) == 1 ? buf[0] : EOF;
+    } else {					// buffered file
+	if ( (ch = getc( fh )) != EOF )
+	    ioIndex++;
+	else
+	    setStatus(IO_ReadError);
+    }
+    return ch;
+}
+
+int QFile::putch( int ch )
+{
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::putch: File not open" );
+	return EOF;
+    }
+    if ( !isWritable() ) {			// writing not permitted
+	qWarning( "QFile::putch: Write operation not permitted" );
+	return EOF;
+    }
+#endif
+    if ( isRaw() ) {				// raw file (inefficient)
+	char buf[1];
+	buf[0] = ch;
+	ch = writeBlock( buf, 1 ) == 1 ? ch : EOF;
+    } else {					// buffered file
+	if ( (ch = putc( ch, fh )) != EOF ) {
+	    ioIndex++;
+	    if ( ioIndex > length )		// update file length
+		length = ioIndex;
+	} else {
+	    setStatus(IO_WriteError);
+	}
+    }
+    return ch;
+}
+
+int QFile::ungetch( int ch )
+{
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::ungetch: File not open" );
+	return EOF;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::ungetch: Read operation not permitted" );
+	return EOF;
+    }
+#endif
+    if ( ch == EOF )				// cannot unget EOF
+	return ch;
+
+    if ( isSequentialAccess() && !fh) {
+	// pipe or similar => we cannot ungetch, so do it manually
+	ungetchBuffer +=ch;
+	return ch;
+    }
+
+    if ( isRaw() ) {				// raw file (very inefficient)
+	char buf[1];
+	at( ioIndex-1 );
+	buf[0] = ch;
+	if ( writeBlock(buf, 1) == 1 )
+	    at ( ioIndex-1 );
+	else
+	    ch = EOF;
+    } else {					// buffered file
+	if ( (ch = ungetc(ch, fh)) != EOF )
+	    ioIndex--;
+	else
+	    setStatus( IO_ReadError );
+    }
+    return ch;
+}
+
+
+static QCString locale_encoder( const QString &fileName )
+{
+    return fileName.local8Bit();
+}
+
+
+static QFile::EncoderFn encoder = locale_encoder;
+
+QCString QFile::encodeName( const QString &fileName )
+{
+    return (*encoder)(fileName);
+}
+
+void QFile::setEncodingFunction( EncoderFn f )
+{
+    encoder = f;
+}
+
+static
+QString locale_decoder( const QCString &localFileName )
+{
+    return QString::fromLocal8Bit(localFileName);
+}
+
+static QFile::DecoderFn decoder = locale_decoder;
+
+QString QFile::decodeName( const QCString &localFileName )
+{
+    return (*decoder)(localFileName);
+}
+
+void QFile::setDecodingFunction( DecoderFn f )
+{
+    decoder = f;
+}
+
+
+bool qt_file_access( const QString& fn, int t )
+{
+    if ( fn.isEmpty() )
+	return FALSE;
+    return ACCESS( QFile::encodeName(fn), t ) == 0;
+}
+
+bool QFile::remove( const QString &fileName )
+{
+    if ( fileName.isEmpty() ) {
+#if defined(CHECK_NULL)
+	qWarning( "QFile::remove: Empty or null file name" );
+#endif
+	return FALSE;
+    }
+    return unlink( QFile::encodeName(fileName) ) == 0;	
+    // unlink more common in UNIX
+}
+
+#if defined(O_NONBLOCK)
+# define HAS_ASYNC_FILEMODE
+# define OPEN_ASYNC O_NONBLOCK
+#elif defined(O_NDELAY)
+# define HAS_ASYNC_FILEMODE
+# define OPEN_ASYNC O_NDELAY
+#endif
+
+bool QFile::open( int m )
+{
+    if ( isOpen() ) {				// file already open
+#if defined(CHECK_STATE)
+	qWarning( "QFile::open: File already open" );
+#endif
+	return FALSE;
+    }
+    if ( fn.isNull() ) {			// no file name defined
+#if defined(CHECK_NULL)
+	qWarning( "QFile::open: No file name specified" );
+#endif
+	return FALSE;
+    }
+    init();					// reset params
+    setMode( m );
+    if ( !(isReadable() || isWritable()) ) {
+#if defined(CHECK_RANGE)
+	qWarning( "QFile::open: File access not specified" );
+#endif
+	return FALSE;
+    }
+    bool ok = TRUE;
+    STATBUF st;
+    if ( isRaw() ) {				// raw file I/O
+	int oflags = OPEN_RDONLY;
+	if ( isReadable() && isWritable() )
+	    oflags = OPEN_RDWR;
+	else if ( isWritable() )
+	    oflags = OPEN_WRONLY;
+	if ( flags() & IO_Append ) {		// append to end of file?
+	    if ( flags() & IO_Truncate )
+		oflags |= (OPEN_CREAT | OPEN_TRUNC);
+	    else
+		oflags |= (OPEN_APPEND | OPEN_CREAT);
+	    setFlags( flags() | IO_WriteOnly ); // append implies write
+	} else if ( isWritable() ) {		// create/trunc if writable
+	    if ( flags() & IO_Truncate )
+		oflags |= (OPEN_CREAT | OPEN_TRUNC);
+	    else
+		oflags |= OPEN_CREAT;
+	}
+#if defined(HAS_TEXT_FILEMODE)
+	if ( isTranslated() )
+	    oflags |= OPEN_TEXT;
+	else
+	    oflags |= OPEN_BINARY;
+#endif
+#if defined(HAS_ASYNC_FILEMODE)
+	if ( isAsynchronous() )
+	    oflags |= OPEN_ASYNC;
+#endif
+	fd = OPEN( QFile::encodeName(fn), oflags, 0666 );
+
+	if ( fd != -1 ) {			// open successful
+	    FSTAT( fd, &st ); // get the stat for later usage
+	} else {
+	    ok = FALSE;
+	}
+    } else {					// buffered file I/O
+	QCString perm;
+	char perm2[4];
+	bool try_create = FALSE;
+	if ( flags() & IO_Append ) {		// append to end of file?
+	    setFlags( flags() | IO_WriteOnly ); // append implies write
+	    perm = isReadable() ? "a+" : "a";
+	} else {
+	    if ( isReadWrite() ) {
+		if ( flags() & IO_Truncate ) {
+		    perm = "w+";
+		} else {
+		    perm = "r+";
+		    try_create = TRUE;		// try to create if not exists
+		}
+	    } else if ( isReadable() ) {
+		perm = "r";
+	    } else if ( isWritable() ) {
+		perm = "w";
+	    }
+	}
+	qstrcpy( perm2, perm );
+#if defined(HAS_TEXT_FILEMODE)
+	if ( isTranslated() )
+	    strcat( perm2, "t" );
+	else
+	    strcat( perm2, "b" );
+#endif
+	while (1) { // At most twice
+
+	    fh = fopen( QFile::encodeName(fn), perm2 );
+
+	    if ( !fh && try_create ) {
+		perm2[0] = 'w';			// try "w+" instead of "r+"
+		try_create = FALSE;
+	    } else {
+		break;
+	    }
+	}
+	if ( fh ) {
+	    FSTAT( FILENO(fh), &st ); // get the stat for later usage
+	} else {
+	    ok = FALSE;
+	}
+    }
+    if ( ok ) {
+	setState( IO_Open );
+	// on successful open the file stat was got; now test what type
+	// of file we have
+	if ( (st.st_mode & STAT_MASK) != STAT_REG ) {
+	    // non-seekable
+	    setType( IO_Sequential );
+	    length = INT_MAX;
+	    ioIndex  = (flags() & IO_Append) == 0 ? 0 : length;
+	} else {
+	    length = (int)st.st_size;
+	    ioIndex  = (flags() & IO_Append) == 0 ? 0 : length;
+	    if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) {
+		// try if you can read from it (if you can, it's a sequential
+		// device; e.g. a file in the /proc filesystem)
+		int c = getch();
+		if ( c != -1 ) {
+		    ungetch(c);
+		    setType( IO_Sequential );
+		    length = INT_MAX;
+		}
+	    }
+	}
+    } else {
+	init();
+	if ( errno == EMFILE )			// no more file handles/descrs
+	    setStatus( IO_ResourceError );
+	else
+	    setStatus( IO_OpenError );
+    }
+    return ok;
+}
+
+bool QFile::open( int m, FILE *f )
+{
+    if ( isOpen() ) {
+#if defined(CHECK_RANGE)
+	qWarning( "QFile::open: File already open" );
+#endif
+	return FALSE;
+    }
+    init();
+    setMode( m &~IO_Raw );
+    setState( IO_Open );
+    fh = f;
+    ext_f = TRUE;
+    STATBUF st;
+    FSTAT( FILENO(fh), &st );
+    ioIndex = (int)ftell( fh );
+    if ( (st.st_mode & STAT_MASK) != STAT_REG || f == stdin ) { //stdin is non seekable
+	// non-seekable
+	setType( IO_Sequential );
+	length = INT_MAX;
+    } else {
+	length = (int)st.st_size;
+	if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) {
+	    // try if you can read from it (if you can, it's a sequential
+	    // device; e.g. a file in the /proc filesystem)
+	    int c = getch();
+	    if ( c != -1 ) {
+		ungetch(c);
+		setType( IO_Sequential );
+		length = INT_MAX;
+	    }
+	}
+    }
+    return TRUE;
+}
+
+bool QFile::open( int m, int f )
+{
+    if ( isOpen() ) {
+#if defined(CHECK_RANGE)
+	qWarning( "QFile::open: File already open" );
+#endif
+	return FALSE;
+    }
+    init();
+    setMode( m |IO_Raw );
+    setState( IO_Open );
+    fd = f;
+    ext_f = TRUE;
+    STATBUF st;
+    FSTAT( fd, &st );
+    ioIndex  = (int)LSEEK(fd, 0, SEEK_CUR);
+    if ( (st.st_mode & STAT_MASK) != STAT_REG || f == 0 ) { // stdin is not seekable...
+	// non-seekable
+	setType( IO_Sequential );
+	length = INT_MAX;
+    } else {
+	length = (int)st.st_size;
+	if ( length == 0 && isReadable() ) {
+	    // try if you can read from it (if you can, it's a sequential
+	    // device; e.g. a file in the /proc filesystem)
+	    int c = getch();
+	    if ( c != -1 ) {
+		ungetch(c);
+		setType( IO_Sequential );
+		length = INT_MAX;
+	    }
+	    resetStatus();
+	}
+    }
+    return TRUE;
+}
+
+uint QFile::size() const
+{
+    STATBUF st;
+    if ( isOpen() ) {
+	FSTAT( fh ? FILENO(fh) : fd, &st );
+    } else {
+	STAT( QFile::encodeName(fn), &st );
+    }
+    return st.st_size;
+}
+
+bool QFile::at( int pos )
+{
+    if ( !isOpen() ) {
+#if defined(CHECK_STATE)
+	qWarning( "QFile::at: File is not open" );
+#endif
+	return FALSE;
+    }
+    bool ok;
+    if ( isRaw() ) {				// raw file
+	pos = (int)LSEEK(fd, pos, SEEK_SET);
+	ok = pos != -1;
+    } else {					// buffered file
+	ok = fseek(fh, pos, SEEK_SET) == 0;
+    }
+    if ( ok )
+	ioIndex = pos;
+#if defined(CHECK_RANGE)
+    else
+	qWarning( "QFile::at: Cannot set file position %d", pos );
+#endif
+    return ok;
+}
+
+int QFile::readBlock( char *p, uint len )
+{
+#if defined(CHECK_NULL)
+    if ( !p )
+	qWarning( "QFile::readBlock: Null pointer error" );
+#endif
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::readBlock: File not open" );
+	return -1;
+    }
+    if ( !isReadable() ) {			// reading not permitted
+	qWarning( "QFile::readBlock: Read operation not permitted" );
+	return -1;
+    }
+#endif
+    int nread = 0;					// number of bytes read
+    if ( !ungetchBuffer.isEmpty() ) {
+	// need to add these to the returned string.
+	int l = ungetchBuffer.length();
+	while( nread < l ) {
+	    *p = ungetchBuffer[ l - nread - 1 ];
+	    p++;
+	    nread++;
+	}
+	ungetchBuffer.truncate( l - nread );
+    }
+
+    if ( nread < (int)len ) {
+	if ( isRaw() ) {				// raw file
+	    nread += READ( fd, p, len-nread );
+	    if ( len && nread <= 0 ) {
+		nread = 0;
+		setStatus(IO_ReadError);
+	    }
+	} else {					// buffered file
+	    nread += fread( p, 1, len-nread, fh );
+	    if ( (uint)nread != len ) {
+		if ( ferror( fh ) || nread==0 )
+		    setStatus(IO_ReadError);
+	    }
+	}
+    }
+    ioIndex += nread;
+    return nread;
+}
+
+int QFile::writeBlock( const char *p, uint len )
+{
+#if defined(CHECK_NULL)
+    if ( p == 0 && len != 0 )
+	qWarning( "QFile::writeBlock: Null pointer error" );
+#endif
+#if defined(CHECK_STATE)
+    if ( !isOpen() ) {				// file not open
+	qWarning( "QFile::writeBlock: File not open" );
+	return -1;
+    }
+    if ( !isWritable() ) {			// writing not permitted
+	qWarning( "QFile::writeBlock: Write operation not permitted" );
+	return -1;
+    }
+#endif
+    int nwritten;				// number of bytes written
+    if ( isRaw() )				// raw file
+	nwritten = WRITE( fd, p, len );
+    else					// buffered file
+	nwritten = fwrite( p, 1, len, fh );
+    if ( nwritten != (int)len ) {		// write error
+	if ( errno == ENOSPC )			// disk is full
+	    setStatus( IO_ResourceError );
+	else
+	    setStatus( IO_WriteError );
+	if ( isRaw() )				// recalc file position
+	    ioIndex = (int)LSEEK( fd, 0, SEEK_CUR );
+	else
+	    ioIndex = fseek( fh, 0, SEEK_CUR );
+    } else {
+	ioIndex += nwritten;
+    }
+    if ( ioIndex > length )			// update file length
+	length = ioIndex;
+    return nwritten;
+}
+
+int QFile::handle() const
+{
+    if ( !isOpen() )
+	return -1;
+    else if ( fh )
+	return FILENO( fh );
+    else
+	return fd;
+}
+
+void QFile::close()
+{
+    bool ok = FALSE;
+    if ( isOpen() ) {				// file is not open
+	if ( fh ) {				// buffered file
+	    if ( ext_f )
+		ok = fflush( fh ) != -1;	// flush instead of closing
+	    else
+		ok = fclose( fh ) != -1;
+	} else {				// raw file
+	    if ( ext_f )
+		ok = TRUE;			// cannot close
+	    else
+		ok = CLOSE( fd ) != -1;
+	}
+	init();					// restore internal state
+    }
+    if (!ok)
+	setStatus (IO_UnspecifiedError);
+
+    return;
+}
diff --git a/WebCore/src/kwq/qt/_qiodevice.cpp b/WebCore/src/kwq/qt/_qiodevice.cpp
new file mode 100644
index 0000000..81f91a5
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qiodevice.cpp
@@ -0,0 +1,638 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QIODevice class
+**
+** Created : 940913
+**
+** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
+**
+** This file is part of the tools module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales at trolltech.com for
+**   information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info at trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "_qiodevice.h"
+
+// NOT REVISED
+/*!
+  \class QIODevice qiodevice.h
+
+  \brief The QIODevice class is the base class of I/O devices.
+
+  \ingroup io
+
+  An I/O device represents a medium that one can read bytes from
+  and/or write bytes to.  The QIODevice class is the abstract
+  superclass of all such devices; classes like QFile, QBuffer and
+  QSocket inherit QIODevice and implement virtual functions like
+  write() appropriately.
+
+  While applications sometimes use QIODevice directly, mostly it is
+  better to go through QTextStream and QDataStream, which provide
+  stream operations on any QIODevice subclass.  QTextStream provides
+  text-oriented stream functionality (for human-readable ASCII files,
+  for example), while QDataStream deals with binary data in a totally
+  platform-independent manner.
+
+  The public member functions in QIODevice roughly fall into two
+  groups: The action functions and the state access functions.  The
+  most important action functions are: <ul>
+
+  <li> open() opens a device for reading and/or writing, depending on
+  the argument to open().
+
+  <li> close() closes the device and tidies up.
+
+  <li> readBlock() reads a block of data from the device.
+
+  <li> writeBlock() writes a block of data to the device.
+
+  <li> readLine() reads a line (of text, usually) from the device.
+
+  <li> flush() ensures that all buffered data are written to the real device.
+
+  </ul>There are also some other, less used, action functions: <ul>
+
+  <li> getch() reads a single character.
+
+  <li> ungetch() forgets the last call to getch(), if possible.
+
+  <li> putch() writes a single character.
+
+  <li> size() returns the size of the device, if there is one.
+
+  <li> at() returns the current read/write pointer, if there is one
+  for this device, or it moves the pointer.
+
+  <li> atEnd() says whether there is more to read, if that is a
+  meaningful question for this device.
+
+  <li> reset() moves the read/write pointer to the start of the
+  device, if that is possible for this device.
+
+  </ul>The state access are all "get" functions.  The QIODevice subclass
+  calls setState() to update the state, and simple access functions
+  tell the user of the device what the device's state is.  Here are
+  the settings, and their associated access functions: <ul>
+
+  <li> Access type.  Some devices are direct access (it is possible to
+  read/write anywhere) while others are sequential.  QIODevice
+  provides the access functions isDirectAccess(), isSequentialAccess()
+  and isCombinedAccess() to tell users what a given I/O device
+  supports.
+
+  <li> Buffering.  Some devices are accessed in raw mode while others
+  are buffered.  Buffering usually provides greater efficiency,
+  particularly for small read/write operations.  isBuffered() tells
+  the user whether a given device is buffered.  (This can often be set
+  by the application in the call to open().)
+
+  <li> Synchronicity.  Synchronous devices work there and then, for
+  example files.  When you read from a file, the file delivers its
+  data right away.  Others, such as a socket connected to a HTTP
+  server, may not deliver the data until seconds after you ask to read
+  it.  isSynchronous() and isAsynchronous() tells the user how this
+  device operates.
+
+  <li> CR/LF translation.  For simplicity, applications often like to
+  see just a single CR/LF style, and QIODevice subclasses can provide
+  that.  isTranslated() returns TRUE if this object translates CR/LF
+  to just LF.  (This can often be set by the application in the call
+  to open().)
+
+  <li> Accessibility.  Some files cannot be written, for example.
+  isReadable(), isWritable and isReadWrite() tells the application
+  whether it can read from and write to a given device.  (This can
+  often be set by the application in the call to open().)
+
+  <li> Finally, isOpen() returns TRUE if the device is open.  This can
+  quite obviously be set using open() :)
+
+  </ul>
+
+  QIODevice provides numerous pure virtual functions you need to
+  implement when subclassing it.  Here is a skeleton subclass with all
+  the members you are certain to need, and some it's likely that you
+  will need:
+
+  \code
+    class YourDevice : public QIODevice
+    {
+    public:
+	YourDevice();
+       ~YourDevice();
+
+	bool open( int mode );
+	void close();
+	void flush();
+
+	uint size() const;
+	int  at() const;	// not a pure virtual function
+	bool at( int );		// not a pure virtual function
+	bool atEnd() const;	// not a pure virtual function
+
+	int readBlock( char *data, uint maxlen );
+	int writeBlock( const char *data, uint len );
+	int readLine( char *data, uint maxlen );
+
+	int getch();
+	int putch( int );
+	int ungetch( int );
+    };
+  \endcode
+
+  The three non-pure virtual functions can be ignored if your device
+  is sequential (e.g. an RS-232 port).
+
+  \sa QDataStream, QTextStream
+*/
+
+
+/*!
+  Constructs an I/O device.
+*/
+
+QIODevice::QIODevice()
+{
+    ioMode = 0;					// initial mode
+    ioSt = IO_Ok;
+    ioIndex = 0;
+}
+
+/*!
+  Destructs the I/O device.
+*/
+
+QIODevice::~QIODevice()
+{
+}
+
+
+/*!
+  \fn int QIODevice::flags() const
+  Returns the current I/O device flags setting.
+
+  Flags consists of mode flags and state flags.
+
+  \sa mode(), state()
+*/
+
+/*!
+  \fn int QIODevice::mode() const
+  Returns bits OR'ed together that specify the current operation mode.
+
+  These are the flags that were given to the open() function.
+
+  The flags are: \c IO_ReadOnly, \c IO_WriteOnly, \c IO_ReadWrite,
+  \c IO_Append, \c IO_Truncate and \c IO_Translate.
+*/
+
+/*!
+  \fn int QIODevice::state() const
+  Returns bits OR'ed together that specify the current state.
+
+  The flags are: \c IO_Open.
+
+  Subclasses may define more flags.
+*/
+
+/*!
+  \fn bool QIODevice::isDirectAccess() const
+  Returns TRUE if the I/O device is a direct access (not sequential) device,
+  otherwise FALSE.
+  \sa isSequentialAccess()
+*/
+
+/*!
+  \fn bool QIODevice::isSequentialAccess() const
+  Returns TRUE if the I/O device is a sequential access (not direct) device,
+  otherwise FALSE.  Operations involving size() and at(int) are not valid
+  on sequential devices.
+  \sa isDirectAccess()
+*/
+
+/*!
+  \fn bool QIODevice::isCombinedAccess() const
+  Returns TRUE if the I/O device is a combined access (both direct and
+  sequential) device,  otherwise FALSE.
+
+  This access method is currently not in use.
+*/
+
+/*!
+  \fn bool QIODevice::isBuffered() const
+  Returns TRUE if the I/O device is a buffered (not raw) device, otherwise
+  FALSE.
+  \sa isRaw()
+*/
+
+/*!
+  \fn bool QIODevice::isRaw() const
+  Returns TRUE if the I/O device is a raw (not buffered) device, otherwise
+  FALSE.
+  \sa isBuffered()
+*/
+
+/*!
+  \fn bool QIODevice::isSynchronous() const
+  Returns TRUE if the I/O device is a synchronous device, otherwise
+  FALSE.
+  \sa isAsynchronous()
+*/
+
+/*!
+  \fn bool QIODevice::isAsynchronous() const
+  Returns TRUE if the I/O device is a asynchronous device, otherwise
+  FALSE.
+
+  This mode is currently not in use.
+
+  \sa isSynchronous()
+*/
+
+/*!
+  \fn bool QIODevice::isTranslated() const
+  Returns TRUE if the I/O device translates carriage-return and linefeed
+  characters.
+
+  A QFile is translated if it is opened with the \c IO_Translate mode
+  flag.
+*/
+
+/*!
+  \fn bool QIODevice::isReadable() const
+  Returns TRUE if the I/O device was opened using \c IO_ReadOnly or
+  \c IO_ReadWrite mode.
+  \sa isWritable(), isReadWrite()
+*/
+
+/*!
+  \fn bool QIODevice::isWritable() const
+  Returns TRUE if the I/O device was opened using \c IO_WriteOnly or
+  \c IO_ReadWrite mode.
+  \sa isReadable(), isReadWrite()
+*/
+
+/*!
+  \fn bool QIODevice::isReadWrite() const
+  Returns TRUE if the I/O device was opened using \c IO_ReadWrite mode.
+  \sa isReadable(), isWritable()
+*/
+
+/*!
+  \fn bool QIODevice::isInactive() const
+  Returns TRUE if the I/O device state is 0, i.e. the device is not open.
+  \sa isOpen()
+*/
+
+/*!
+  \fn bool QIODevice::isOpen() const
+  Returns TRUE if the I/O device state has been opened, otherwise FALSE.
+  \sa isInactive()
+*/
+
+
+/*!
+  \fn int QIODevice::status() const
+  Returns the I/O device status.
+
+  The I/O device status returns an error code.	If open() returns FALSE
+  or readBlock() or writeBlock() return -1, this function can be called to
+  get the reason why the operation did not succeed.
+
+  The status codes are:
+  <ul>
+  <li>\c IO_Ok The operation was successful.
+  <li>\c IO_ReadError Could not read from the device.
+  <li>\c IO_WriteError Could not write to the device.
+  <li>\c IO_FatalError A fatal unrecoverable error occurred.
+  <li>\c IO_OpenError Could not open the device.
+  <li>\c IO_ConnectError Could not connect to the device.
+  <li>\c IO_AbortError The operation was unexpectedly aborted.
+  <li>\c IO_TimeOutError The operation timed out.
+  <li>\c IO_OnCloseError An unspecified error happened on close.
+  </ul>
+
+  \sa resetStatus()
+*/
+
+/*!
+  \fn void QIODevice::resetStatus()
+
+  Sets the I/O device status to \c IO_Ok.
+
+  \sa status()
+*/
+
+
+/*!
+  \fn void QIODevice::setFlags( int f )
+  \internal
+  Used by subclasses to set the device flags.
+*/
+
+/*!
+  \internal
+  Used by subclasses to set the device type.
+*/
+
+void QIODevice::setType( int t )
+{
+#if defined(CHECK_RANGE)
+    if ( (t & IO_TypeMask) != t )
+	qWarning( "QIODevice::setType: Specified type out of range" );
+#endif
+    ioMode &= ~IO_TypeMask;			// reset type bits
+    ioMode |= t;
+}
+
+/*!
+  \internal
+  Used by subclasses to set the device mode.
+*/
+
+void QIODevice::setMode( int m )
+{
+#if defined(CHECK_RANGE)
+    if ( (m & IO_ModeMask) != m )
+	qWarning( "QIODevice::setMode: Specified mode out of range" );
+#endif
+    ioMode &= ~IO_ModeMask;			// reset mode bits
+    ioMode |= m;
+}
+
+/*!
+  \internal
+  Used by subclasses to set the device state.
+*/
+
+void QIODevice::setState( int s )
+{
+#if defined(CHECK_RANGE)
+    if ( ((uint)s & IO_StateMask) != (uint)s )
+	qWarning( "QIODevice::setState: Specified state out of range" );
+#endif
+    ioMode &= ~IO_StateMask;			// reset state bits
+    ioMode |= (uint)s;
+}
+
+/*!
+  \internal
+  Used by subclasses to set the device status (not state).
+*/
+
+void QIODevice::setStatus( int s )
+{
+    ioSt = s;
+}
+
+
+/*!
+  \fn bool QIODevice::open( int mode )
+  Opens the I/O device using the specified \e mode.
+  Returns TRUE if successful, or FALSE if the device could not be opened.
+
+  The mode parameter \e m must be a combination of the following flags.
+  <ul>
+  <li>\c IO_Raw specified raw (unbuffered) file access.
+  <li>\c IO_ReadOnly opens a file in read-only mode.
+  <li>\c IO_WriteOnly opens a file in write-only mode.
+  <li>\c IO_ReadWrite opens a file in read/write mode.
+  <li>\c IO_Append sets the file index to the end of the file.
+  <li>\c IO_Truncate truncates the file.
+  <li>\c IO_Translate enables carriage returns and linefeed translation
+  for text files under MS-DOS, Window, OS/2 and Macintosh.  On Unix systems 
+  this flag has no effect. Use with caution as it will also transform every linefeed
+  written to the file into a CRLF pair. This is likely to corrupt your file when
+  writing binary data to it. Cannot be combined with \c IO_Raw.
+  </ul>
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa close()
+*/
+
+/*!
+  \fn void QIODevice::close()
+  Closes the I/O device.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa open()
+*/
+
+/*!
+  \fn void QIODevice::flush()
+
+  Flushes an open I/O device.
+
+  This virtual function must be reimplemented by all subclasses.
+*/
+
+
+/*!
+  \fn uint QIODevice::size() const
+  Virtual function that returns the size of the I/O device.
+  \sa at()
+*/
+
+/*!
+  Virtual function that returns the current I/O device index.
+
+  This index is the data read/write head of the I/O device.
+
+  \sa size()
+*/
+
+int QIODevice::at() const
+{
+    return ioIndex;
+}
+
+/*!
+  Virtual function that sets the I/O device index to \e pos.
+  \sa size()
+*/
+
+bool QIODevice::at( int pos )
+{
+#if defined(CHECK_RANGE)
+    if ( (uint)pos > size() ) {
+	qWarning( "QIODevice::at: Index %d out of range", pos );
+	return FALSE;
+    }
+#endif
+    ioIndex = pos;
+    return TRUE;
+}
+
+/*!
+  Virtual function that returns TRUE if the I/O device index is at the
+  end of the input.
+*/
+
+bool QIODevice::atEnd() const
+{
+    if ( isSequentialAccess() || isTranslated() ) {
+	QIODevice* that = (QIODevice*)this;
+	int c = that->getch();
+	bool result = c < 0;
+	that->ungetch(c);
+	return result;
+    } else {
+	return at() == (int)size();
+    }
+}
+
+/*!
+  \fn bool QIODevice::reset()
+  Sets the device index to 0.
+  \sa at()
+*/
+
+
+/*!
+  \fn int QIODevice::readBlock( char *data, uint maxlen )
+  Reads at most \e maxlen bytes from the I/O device into \e data and
+  returns the number of bytes actually read.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa writeBlock()
+*/
+
+/*!
+  This convenience function returns all of the remaining data in the
+  device.  Note that this only works for direct access devices, such
+  as QFile.
+  
+  \sa isDirectAccess() 
+*/
+QByteArray QIODevice::readAll()
+{
+    int n = size()-at();
+    QByteArray ba(size()-at());
+    char* c = ba.data();
+    while ( n ) {
+	int r = readBlock( c, n );
+	if ( r < 0 )
+	    return QByteArray();
+	n -= r;
+	c += r;
+    }
+    return ba;
+}
+
+/*!
+  \fn int QIODevice::writeBlock( const char *data, uint len )
+  Writes \e len bytes from \e p to the I/O device and returns the number of
+  bytes actually written.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa readBlock()
+*/
+
+/*!
+  This convenience function is the same as calling
+  writeBlock( data.data(), data.size() ).
+*/
+int QIODevice::writeBlock( const QByteArray& data )
+{
+    return writeBlock( data.data(), data.size() );
+}
+
+/*!
+  Reads a line of text, up to \e maxlen bytes including a terminating
+  \0.  If there is a newline at the end if the line, it is not stripped.
+
+  Returns the number of bytes read, or -1 in case of error.
+
+  This virtual function can be reimplemented much more efficiently by
+  the most subclasses.
+
+  \sa readBlock(), QTextStream::readLine()
+*/
+
+int QIODevice::readLine( char *data, uint maxlen )
+{
+    if ( maxlen == 0 )				// application bug?
+	return 0;
+    int pos = at();				// get current position
+    int s  = (int)size();			// size of I/O device
+    char *p = data;
+    if ( pos >= s )
+	return 0;
+    while ( pos++ < s && --maxlen ) {		// read one byte at a time
+	readBlock( p, 1 );
+	if ( *p++ == '\n' )			// end of line
+	    break;
+    }
+    *p++ = '\0';
+    return (int)((long)p - (long)data);
+}
+
+
+/*!
+  \fn int QIODevice::getch()
+
+  Reads a single byte/character from the I/O device.
+
+  Returns the byte/character read, or -1 if the end of the I/O device has been
+  reached.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa putch(), ungetch()
+*/
+
+/*!
+  \fn int QIODevice::putch( int ch )
+
+  Writes the character \e ch to the I/O device.
+
+  Returns \e ch, or -1 if some error occurred.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa getch(), ungetch()
+*/
+
+/*!
+  \fn int QIODevice::ungetch( int ch )
+
+  Puts the character \e ch back into the I/O device and decrements the
+  index if it is not zero.
+
+  This function is normally called to "undo" a getch() operation.
+
+  Returns \e ch, or -1 if some error occurred.
+
+  This virtual function must be reimplemented by all subclasses.
+
+  \sa getch(), putch()
+*/
diff --git a/WebCore/src/kwq/qt/_qiodevice.h b/WebCore/src/kwq/qt/_qiodevice.h
index 4843159..0c826c1 100644
--- a/WebCore/src/kwq/qt/_qiodevice.h
+++ b/WebCore/src/kwq/qt/_qiodevice.h
@@ -38,18 +38,8 @@
 #ifndef QIODEVICE_H
 #define QIODEVICE_H
 
-// KWQ hacks ---------------------------------------------------------------
-
-#ifndef _KWQ_COMPLETE_
-#define _KWQ_COMPLETE_
-#endif
-
-#include <KWQDef.h>
-
-// -------------------------------------------------------------------------
-
 #ifndef QT_H
-#include "qglobal.h"
+#include <KWQDef.h>
 #include "qcstring.h"
 #endif // QT_H
 
diff --git a/WebCore/src/kwq/qt/qfile.h b/WebCore/src/kwq/qt/qfile.h
index f1cfece..f67b7df 100644
--- a/WebCore/src/kwq/qt/qfile.h
+++ b/WebCore/src/kwq/qt/qfile.h
@@ -30,18 +30,125 @@
 #include <config.h>
 #endif
 
+#include <KWQDef.h>
+
+#ifdef _KWQ_COMPLETE_
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#if !defined(PATH_MAX)
+#if defined(MAXPATHLEN)
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+#undef STATBUF
+#undef STAT
+#undef STAT_REG
+#undef STAT_DIR
+#undef STAT_LNK
+#undef STAT_MASK
+#undef FILENO
+#undef OPEN
+#undef CLOSE
+#undef LSEEK
+#undef READ
+#undef WRITE
+#undef ACCESS
+#undef GETCWD
+#undef CHDIR
+#undef MKDIR
+#undef RMDIR
+#undef OPEN_RDONLY
+#undef OPEN_WRONLY
+#undef OPEN_CREAT
+#undef OPEN_TRUNC
+#undef OPEN_APPEND
+#undef OPEN_TEXT
+#undef OPEN_BINARY
+
+#define STATBUF	struct stat
+#define STATBUF4TSTAT	struct stat
+#define STAT		::stat
+#define FSTAT		::fstat
+#define STAT_REG	S_IFREG
+#define STAT_DIR	S_IFDIR
+#define STAT_MASK	S_IFMT
+#if defined(S_IFLNK)
+# define STAT_LNK	S_IFLNK
+#endif
+#define FILENO		fileno
+#define OPEN		::open
+#define CLOSE		::close
+#define LSEEK		::lseek
+#define READ		::read
+#define WRITE		::write
+#define ACCESS		::access
+#define GETCWD	::getcwd
+#define CHDIR		::chdir
+#define MKDIR		::mkdir
+#define RMDIR		::rmdir
+#define OPEN_RDONLY	O_RDONLY
+#define OPEN_WRONLY	O_WRONLY
+#define OPEN_RDWR	O_RDWR
+#define OPEN_CREAT	O_CREAT
+#define OPEN_TRUNC	O_TRUNC
+#define OPEN_APPEND	O_APPEND
+#if defined(O_TEXT)
+# define OPEN_TEXT	O_TEXT
+# define OPEN_BINARY O_BINARY
+#endif
+
+#define F_OK	0
+
+struct QFileInfoCache
+{
+    STATBUF st;
+    bool isSymLink;
+};
+
+
+#endif // _KWQ_COMPLETE_
+
+
+#include "_qiodevice.h"
 #include "qstring.h"
+#include "qcstring.h"
+
 
 // class QFile =================================================================
 
-class QFile {
+class QFile : public QIODevice {
 public:
 
     // typedefs ----------------------------------------------------------------
+
+#ifdef _KWQ_COMPLETE_
+    typedef QCString(*EncoderFn)(const QString &);
+    typedef QString(*DecoderFn)(const QCString &);
+#endif
+
     // enums -------------------------------------------------------------------
     // constants ---------------------------------------------------------------
     // static member functions -------------------------------------------------
 
+#ifdef _KWQ_COMPLETE_
+    static QCString encodeName(const QString &);
+    static QString decodeName(const QCString &);
+    static void setEncodingFunction(EncoderFn);
+    static void setDecodingFunction(DecoderFn);
+    static bool exists(const QString &);
+    static bool remove(const QString &fileName);
+#endif
+
     // constructors, copy constructors, and destructors ------------------------
 
     QFile();
@@ -51,15 +158,53 @@ public:
     // member functions --------------------------------------------------------
 
     bool exists() const;
-    static bool exists(const QString &);
     bool open(int);
     void close();
-    uint size() const;
     int readBlock(char *, uint);
+    uint size() const;
+
+
+#ifdef _KWQ_COMPLETE_
+    bool remove();
+
+    QString	name() const;
+    void setName(const QString &);
+
+    bool open(int, FILE *);
+    bool open(int, int);
+    void flush();
+
+    int  at() const;
+    bool at(int);
+    bool atEnd() const;
+
+    int writeBlock(const char *, uint);
+    int writeBlock(const QByteArray &);
+    int readLine(char *, uint);
+    int readLine(QString &, uint);
+
+    int getch();
+    int putch(int);
+    int ungetch(int);
+
+    int  handle() const;
+#endif
 
     // operators ---------------------------------------------------------------
 
 // protected -------------------------------------------------------------------
+
+#ifdef _KWQ_COMPLETE_
+protected:
+    QString fn;
+    FILE *fh;
+    int fd;
+    int length;
+    bool ext_f;
+    void *d;
+#endif
+
+
 // private ---------------------------------------------------------------------
 
 private:
@@ -68,6 +213,23 @@ private:
     QFile(const QFile &);
     QFile &operator=(const QFile &);
 
+#ifdef _KWQ_COMPLETE_
+    void init();
+    QCString ungetchBuffer;
+#endif
+
 }; // class QFile ==============================================================
 
+#ifdef _KWQ_COMPLETE_
+
+inline int QFile::at() const
+{
+    return ioIndex;
+}
+
+inline QString QFile::name() const
+{ return fn; }
+
+#endif
+
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list