[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:48:02 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 55b7971685b0a28828b5933ad7add0182aafb087
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 1 14:30:26 2001 +0000
Added and modified some classes in an effort to get the borrowed
KURL fully intergrated
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@233 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/Makefile.in b/WebCore/Makefile.in
index ee929da..14cc671 100644
--- a/WebCore/Makefile.in
+++ b/WebCore/Makefile.in
@@ -29,6 +29,7 @@ SUBDIRS = \
src/kdelibs/khtml/rendering \
src/kwq/ \
src/kwq/qt \
+ src/kwq/kde \
src/kwq/tests \
src/kwq/tests/qt \
$(NULL)
diff --git a/WebCore/borrowed-classes.txt b/WebCore/borrowed-classes.txt
index 64dddca..a694298 100644
--- a/WebCore/borrowed-classes.txt
+++ b/WebCore/borrowed-classes.txt
@@ -1,8 +1,11 @@
+KURL
QArray
+QBuffer
QCollection
QColor
QDateTime
QDict
+QDir
QFile
QList
QMap
diff --git a/WebCore/config.h.in b/WebCore/config.h.in
index 151e2f7..3e7f09d 100644
--- a/WebCore/config.h.in
+++ b/WebCore/config.h.in
@@ -33,9 +33,15 @@
/* Our platform requires this to handle certain Qt memory mgmt. conventions */
#define Q_DELETING_VOID_UNDEFINED 1
+/* Define if using "borrowed" KURL */
+#undef USING_BORROWED_KURL
+
/* Define if using "borrowed" QArray */
#undef USING_BORROWED_QARRAY
+/* Define if using "borrowed" QBuffer */
+#undef USING_BORROWED_QBUFFER
+
/* Define if using "borrowed" QCollection */
#undef USING_BORROWED_QCOLLECTION
@@ -48,6 +54,9 @@
/* Define if using "borrowed" QDict */
#undef USING_BORROWED_QDICT
+/* Define if using "borrowed" QDir */
+#undef USING_BORROWED_QDIR
+
/* Define if using "borrowed" QFile */
#undef USING_BORROWED_QFILE
diff --git a/WebCore/configure b/WebCore/configure
index d9c800c..325e989 100644
--- a/WebCore/configure
+++ b/WebCore/configure
@@ -24,8 +24,12 @@ ac_help="$ac_help
ac_help="$ac_help
--enable-qt-textcodec enables Qt textcodecs (default off)"
ac_help="$ac_help
+ --enable-borrowed-kurl enabled use of borrowed KURL (default on)"
+ac_help="$ac_help
--enable-borrowed-qarray enabled use of borrowed QArray (default on)"
ac_help="$ac_help
+ --enable-borrowed-qbuffer enabled use of borrowed QBuffer (default on)"
+ac_help="$ac_help
--enable-borrowed-qcollection enabled use of borrowed QCollection (default on)"
ac_help="$ac_help
--enable-borrowed-qcolor enabled use of borrowed QColor (default on)"
@@ -34,6 +38,8 @@ ac_help="$ac_help
ac_help="$ac_help
--enable-borrowed-qdict enabled use of borrowed QDict (default on)"
ac_help="$ac_help
+ --enable-borrowed-qdir enabled use of borrowed QDir (default on)"
+ac_help="$ac_help
--enable-borrowed-qfile enabled use of borrowed QFile (default on)"
ac_help="$ac_help
--enable-borrowed-qlist enabled use of borrowed QList (default on)"
@@ -634,7 +640,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:638: checking host system type" >&5
+echo "configure:644: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -665,7 +671,7 @@ esac
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:669: checking for $ac_word" >&5
+echo "configure:675: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -695,7 +701,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:699: checking for $ac_word" >&5
+echo "configure:705: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -746,7 +752,7 @@ fi
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:750: checking for $ac_word" >&5
+echo "configure:756: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -778,7 +784,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:782: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:788: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -789,12 +795,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 793 "configure"
+#line 799 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -820,12 +826,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:824: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:830: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:829: checking whether we are using GNU C" >&5
+echo "configure:835: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -834,7 +840,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:844: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -853,7 +859,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:857: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:863: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -893,7 +899,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:897: checking for $ac_word" >&5
+echo "configure:903: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -925,7 +931,7 @@ test -n "$CXX" || CXX="gcc"
echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:929: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:935: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
ac_ext=C
# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -936,12 +942,12 @@ cross_compiling=$ac_cv_prog_cxx_cross
cat > conftest.$ac_ext << EOF
-#line 940 "configure"
+#line 946 "configure"
#include "confdefs.h"
int main(){return(0);}
EOF
-if { (eval echo configure:945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cxx_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -967,12 +973,12 @@ if test $ac_cv_prog_cxx_works = no; then
{ echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:971: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:977: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:976: checking whether we are using GNU C++" >&5
+echo "configure:982: checking whether we are using GNU C++" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -981,7 +987,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gxx=yes
else
ac_cv_prog_gxx=no
@@ -1000,7 +1006,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}"
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS=
echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:1004: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1010: checking whether ${CXX-g++} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1041,7 +1047,7 @@ CXXFLAGS=$CFLAGS
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1045: checking how to run the C preprocessor" >&5
+echo "configure:1051: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1056,13 +1062,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1060 "configure"
+#line 1066 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1072: \"$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
:
@@ -1073,13 +1079,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1077 "configure"
+#line 1083 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1083: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1089: \"$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
:
@@ -1090,13 +1096,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1094 "configure"
+#line 1100 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1100: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1106: \"$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
:
@@ -1123,7 +1129,7 @@ echo "$ac_t""$CPP" 1>&6
# Extract the first word of "flex", so it can be a program name with args.
set dummy flex; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1127: checking for $ac_word" >&5
+echo "configure:1133: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1157,7 +1163,7 @@ then
*) ac_lib=l ;;
esac
echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6
-echo "configure:1161: checking for yywrap in -l$ac_lib" >&5
+echo "configure:1167: checking for yywrap in -l$ac_lib" >&5
ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1165,7 +1171,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-l$ac_lib $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1169 "configure"
+#line 1175 "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
@@ -1176,7 +1182,7 @@ int main() {
yywrap()
; return 0; }
EOF
-if { (eval echo configure:1180: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1186: \"$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
@@ -1199,7 +1205,7 @@ fi
fi
echo $ac_n "checking lex output file root""... $ac_c" 1>&6
-echo "configure:1203: checking lex output file root" >&5
+echo "configure:1209: checking lex output file root" >&5
if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1220,7 +1226,7 @@ echo "$ac_t""$ac_cv_prog_lex_root" 1>&6
LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6
-echo "configure:1224: checking whether yytext is a pointer" >&5
+echo "configure:1230: checking whether yytext is a pointer" >&5
if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1232,14 +1238,14 @@ echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
ac_save_LIBS="$LIBS"
LIBS="$LIBS $LEXLIB"
cat > conftest.$ac_ext <<EOF
-#line 1236 "configure"
+#line 1242 "configure"
#include "confdefs.h"
`cat $LEX_OUTPUT_ROOT.c`
int main() {
; return 0; }
EOF
-if { (eval echo configure:1243: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_prog_lex_yytext_pointer=yes
else
@@ -1265,7 +1271,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1269: checking for $ac_word" >&5
+echo "configure:1275: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1306,7 +1312,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1310: checking for $ac_word" >&5
+echo "configure:1316: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1345,7 +1351,7 @@ YACCFLAGS="-d"
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1349: checking for $ac_word" >&5
+echo "configure:1355: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1381,7 +1387,7 @@ ARFLAGS="cr"
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1385: checking for $ac_word" >&5
+echo "configure:1391: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1418,7 +1424,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1422: checking for $ac_word" >&5
+echo "configure:1428: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_SED'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1455,7 +1461,7 @@ fi
# Extract the first word of "gperf", so it can be a program name with args.
set dummy gperf; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1459: checking for $ac_word" >&5
+echo "configure:1465: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_GPERF'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1487,7 +1493,7 @@ if test -z "$ac_cv_prog_GPERF"; then
fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1491: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1497: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1525,7 +1531,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1529: checking for a BSD compatible install" >&5
+echo "configure:1535: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1600,12 +1606,12 @@ 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:1604: checking whether stat file-mode macros are broken" >&5
+echo "configure:1610: 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 1609 "configure"
+#line 1615 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1660,12 +1666,12 @@ 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:1664: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1670: 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 1669 "configure"
+#line 1675 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
@@ -1673,7 +1679,7 @@ int main() {
DIR *dirp = 0;
; return 0; }
EOF
-if { (eval echo configure:1677: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1683: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
@@ -1698,7 +1704,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:1702: checking for opendir in -ldir" >&5
+echo "configure:1708: 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
@@ -1706,7 +1712,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1710 "configure"
+#line 1716 "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
@@ -1717,7 +1723,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:1721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1727: \"$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
@@ -1739,7 +1745,7 @@ fi
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1743: checking for opendir in -lx" >&5
+echo "configure:1749: 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
@@ -1747,7 +1753,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1751 "configure"
+#line 1757 "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
@@ -1758,7 +1764,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:1762: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1768: \"$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
@@ -1781,12 +1787,12 @@ fi
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1785: checking for ANSI C header files" >&5
+echo "configure:1791: 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 1790 "configure"
+#line 1796 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1794,7 +1800,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1798: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1804: \"$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*
@@ -1811,7 +1817,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 1815 "configure"
+#line 1821 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1829,7 +1835,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 1833 "configure"
+#line 1839 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1850,7 +1856,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1854 "configure"
+#line 1860 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1861,7 +1867,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1871: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1888,17 +1894,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:1892: checking for $ac_hdr" >&5
+echo "configure:1898: 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 1897 "configure"
+#line 1903 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1908: \"$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*
@@ -1928,17 +1934,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:1932: checking for $ac_hdr" >&5
+echo "configure:1938: 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 1937 "configure"
+#line 1943 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1942: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1948: \"$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*
@@ -1968,17 +1974,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:1972: checking for $ac_hdr" >&5
+echo "configure:1978: 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 1977 "configure"
+#line 1983 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1982: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1988: \"$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*
@@ -2008,17 +2014,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:2012: checking for $ac_hdr" >&5
+echo "configure:2018: 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 2017 "configure"
+#line 2023 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2022: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2028: \"$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*
@@ -2047,7 +2053,7 @@ done
echo $ac_n "checking for jpeg_mem_init in -ljpeg""... $ac_c" 1>&6
-echo "configure:2051: checking for jpeg_mem_init in -ljpeg" >&5
+echo "configure:2057: 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
@@ -2055,7 +2061,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ljpeg $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2059 "configure"
+#line 2065 "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
@@ -2066,7 +2072,7 @@ int main() {
jpeg_mem_init()
; return 0; }
EOF
-if { (eval echo configure:2070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2076: \"$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
@@ -2096,12 +2102,12 @@ fi
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2100: checking for working const" >&5
+echo "configure:2106: 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 2105 "configure"
+#line 2111 "configure"
#include "confdefs.h"
int main() {
@@ -2150,7 +2156,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
-if { (eval echo configure:2154: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2160: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@@ -2171,21 +2177,21 @@ EOF
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:2175: checking for inline" >&5
+echo "configure:2181: 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 2182 "configure"
+#line 2188 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:2189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2195: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
@@ -2211,12 +2217,12 @@ EOF
esac
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2215: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2221: 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 2220 "configure"
+#line 2226 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -2225,7 +2231,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:2229: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2235: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -2247,9 +2253,9 @@ fi
echo $ac_n "checking whether sys/stat.h declares S_ISSOCK""... $ac_c" 1>&6
-echo "configure:2251: checking whether sys/stat.h declares S_ISSOCK" >&5
+echo "configure:2257: checking whether sys/stat.h declares S_ISSOCK" >&5
cat > conftest.$ac_ext <<EOF
-#line 2253 "configure"
+#line 2259 "configure"
#include "confdefs.h"
#include <sys/stat.h>
int main() {
@@ -2263,7 +2269,7 @@ void foo() {
; return 0; }
EOF
-if { (eval echo configure:2267: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2273: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cat >> confdefs.h <<EOF
@@ -2287,12 +2293,12 @@ 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:2291: checking for $ac_func" >&5
+echo "configure:2297: 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 2296 "configure"
+#line 2302 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2315,7 +2321,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2325: \"$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
@@ -2348,12 +2354,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:2352: checking for pid_t" >&5
+echo "configure:2358: 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 2357 "configure"
+#line 2363 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2382,17 +2388,17 @@ fi
ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:2386: checking for vfork.h" >&5
+echo "configure:2392: 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 2391 "configure"
+#line 2397 "configure"
#include "confdefs.h"
#include <vfork.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2396: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2402: \"$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*
@@ -2417,18 +2423,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2421: checking for working vfork" >&5
+echo "configure:2427: 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:2427: checking for vfork" >&5
+echo "configure:2433: 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 2432 "configure"
+#line 2438 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@@ -2451,7 +2457,7 @@ vfork();
; return 0; }
EOF
-if { (eval echo configure:2455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2461: \"$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
@@ -2473,7 +2479,7 @@ fi
ac_cv_func_vfork_works=$ac_cv_func_vfork
else
cat > conftest.$ac_ext <<EOF
-#line 2477 "configure"
+#line 2483 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@@ -2568,7 +2574,7 @@ main() {
}
}
EOF
-if { (eval echo configure:2572: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2578: \"$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
@@ -2595,17 +2601,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:2599: checking for $ac_hdr" >&5
+echo "configure:2605: 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 2604 "configure"
+#line 2610 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2609: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2615: \"$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*
@@ -2632,7 +2638,7 @@ fi
done
echo $ac_n "checking for isinf in -lm""... $ac_c" 1>&6
-echo "configure:2636: checking for isinf in -lm" >&5
+echo "configure:2642: 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
@@ -2640,7 +2646,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2644 "configure"
+#line 2650 "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 +2657,7 @@ int main() {
isinf()
; 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:2661: \"$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
@@ -2677,7 +2683,7 @@ else
fi
echo $ac_n "checking for finite in -lm""... $ac_c" 1>&6
-echo "configure:2681: checking for finite in -lm" >&5
+echo "configure:2687: 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
@@ -2685,7 +2691,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2689 "configure"
+#line 2695 "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
@@ -2696,7 +2702,7 @@ int main() {
finite()
; return 0; }
EOF
-if { (eval echo configure:2700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2706: \"$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
@@ -2722,7 +2728,7 @@ else
fi
echo $ac_n "checking for _finite in -lm""... $ac_c" 1>&6
-echo "configure:2726: checking for _finite in -lm" >&5
+echo "configure:2732: 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
@@ -2730,7 +2736,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2734 "configure"
+#line 2740 "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
@@ -2741,7 +2747,7 @@ int main() {
_finite()
; return 0; }
EOF
-if { (eval echo configure:2745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2751: \"$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
@@ -2767,7 +2773,7 @@ else
fi
echo $ac_n "checking for isnan in -lm""... $ac_c" 1>&6
-echo "configure:2771: checking for isnan in -lm" >&5
+echo "configure:2777: 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
@@ -2775,7 +2781,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2779 "configure"
+#line 2785 "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
@@ -2786,7 +2792,7 @@ int main() {
isnan()
; return 0; }
EOF
-if { (eval echo configure:2790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2796: \"$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
@@ -2934,6 +2940,32 @@ fi
+# Check whether --enable-borrowed-kurl or --disable-borrowed-kurl was given.
+if test "${enable_borrowed_kurl+set}" = set; then
+ enableval="$enable_borrowed_kurl"
+ if ( test "$enableval" = "yes" ); then
+ cat >> confdefs.h <<EOF
+#define USING_BORROWED_KURL 1
+EOF
+
+fi
+
+else
+ if ( test -f borrowed-classes.txt )
+then
+BORROWED=`sed -e 's/^KURL$/yes/' borrowed-classes.txt | grep yes`
+if ( test "$BORROWED" = "yes" )
+then
+cat >> confdefs.h <<EOF
+#define USING_BORROWED_KURL 1
+EOF
+
+fi
+fi
+
+fi
+
+
# Check whether --enable-borrowed-qarray or --disable-borrowed-qarray was given.
if test "${enable_borrowed_qarray+set}" = set; then
enableval="$enable_borrowed_qarray"
@@ -2960,6 +2992,32 @@ fi
fi
+# Check whether --enable-borrowed-qbuffer or --disable-borrowed-qbuffer was given.
+if test "${enable_borrowed_qbuffer+set}" = set; then
+ enableval="$enable_borrowed_qbuffer"
+ if ( test "$enableval" = "yes" ); then
+ cat >> confdefs.h <<EOF
+#define USING_BORROWED_QBUFFER 1
+EOF
+
+fi
+
+else
+ if ( test -f borrowed-classes.txt )
+then
+BORROWED=`sed -e 's/^QBuffer$/yes/' borrowed-classes.txt | grep yes`
+if ( test "$BORROWED" = "yes" )
+then
+cat >> confdefs.h <<EOF
+#define USING_BORROWED_QBUFFER 1
+EOF
+
+fi
+fi
+
+fi
+
+
# Check whether --enable-borrowed-qcollection or --disable-borrowed-qcollection was given.
if test "${enable_borrowed_qcollection+set}" = set; then
enableval="$enable_borrowed_qcollection"
@@ -3064,6 +3122,32 @@ fi
fi
+# Check whether --enable-borrowed-qdir or --disable-borrowed-qdir was given.
+if test "${enable_borrowed_qdir+set}" = set; then
+ enableval="$enable_borrowed_qdir"
+ if ( test "$enableval" = "yes" ); then
+ cat >> confdefs.h <<EOF
+#define USING_BORROWED_QDIR 1
+EOF
+
+fi
+
+else
+ if ( test -f borrowed-classes.txt )
+then
+BORROWED=`sed -e 's/^QDir$/yes/' borrowed-classes.txt | grep yes`
+if ( test "$BORROWED" = "yes" )
+then
+cat >> confdefs.h <<EOF
+#define USING_BORROWED_QDIR 1
+EOF
+
+fi
+fi
+
+fi
+
+
# Check whether --enable-borrowed-qfile or --disable-borrowed-qfile was given.
if test "${enable_borrowed_qfile+set}" = set; then
enableval="$enable_borrowed_qfile"
@@ -3597,6 +3681,7 @@ trap 'rm -fr `echo "Makefile
src/kdelibs/khtml/rendering/Makefile
src/kwq/Makefile
src/kwq/qt/Makefile
+ src/kwq/kde/Makefile
src/kwq/tests/Makefile
src/kwq/tests/qt/Makefile
config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
@@ -3713,6 +3798,7 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile
src/kdelibs/khtml/rendering/Makefile
src/kwq/Makefile
src/kwq/qt/Makefile
+ src/kwq/kde/Makefile
src/kwq/tests/Makefile
src/kwq/tests/qt/Makefile
"}
diff --git a/WebCore/configure.in b/WebCore/configure.in
index 17f68c9..0e2eacc 100644
--- a/WebCore/configure.in
+++ b/WebCore/configure.in
@@ -244,6 +244,25 @@ dnl -------------------------------------------------------------------
dnl
dnl
+dnl KURL borrowing
+dnl
+AC_ARG_ENABLE(borrowed-kurl,
+[ --enable-borrowed-kurl enabled use of borrowed KURL (default on)],
+if ( test "$enableval" = "yes" ); then
+ AC_DEFINE_UNQUOTED(USING_BORROWED_KURL, 1)
+fi
+,
+if ( test -f borrowed-classes.txt )
+then
+BORROWED=`sed -e 's/^KURL$/yes/' borrowed-classes.txt | grep yes`
+if ( test "$BORROWED" = "yes" )
+then
+AC_DEFINE_UNQUOTED(USING_BORROWED_KURL, 1)
+fi
+fi
+)
+
+dnl
dnl QArray borrowing
dnl
AC_ARG_ENABLE(borrowed-qarray,
@@ -263,6 +282,25 @@ fi
)
dnl
+dnl QBuffer borrowing
+dnl
+AC_ARG_ENABLE(borrowed-qbuffer,
+[ --enable-borrowed-qbuffer enabled use of borrowed QBuffer (default on)],
+if ( test "$enableval" = "yes" ); then
+ AC_DEFINE_UNQUOTED(USING_BORROWED_QBUFFER, 1)
+fi
+,
+if ( test -f borrowed-classes.txt )
+then
+BORROWED=`sed -e 's/^QBuffer$/yes/' borrowed-classes.txt | grep yes`
+if ( test "$BORROWED" = "yes" )
+then
+AC_DEFINE_UNQUOTED(USING_BORROWED_QBUFFER, 1)
+fi
+fi
+)
+
+dnl
dnl QCollection borrowing
dnl
AC_ARG_ENABLE(borrowed-qcollection,
@@ -339,6 +377,25 @@ fi
)
dnl
+dnl QDir borrowing
+dnl
+AC_ARG_ENABLE(borrowed-qdir,
+[ --enable-borrowed-qdir enabled use of borrowed QDir (default on)],
+if ( test "$enableval" = "yes" ); then
+ AC_DEFINE_UNQUOTED(USING_BORROWED_QDIR, 1)
+fi
+,
+if ( test -f borrowed-classes.txt )
+then
+BORROWED=`sed -e 's/^QDir$/yes/' borrowed-classes.txt | grep yes`
+if ( test "$BORROWED" = "yes" )
+then
+AC_DEFINE_UNQUOTED(USING_BORROWED_QDIR, 1)
+fi
+fi
+)
+
+dnl
dnl QFile borrowing
dnl
AC_ARG_ENABLE(borrowed-qfile,
@@ -664,6 +721,7 @@ AC_OUTPUT(
src/kdelibs/khtml/rendering/Makefile
src/kwq/Makefile
src/kwq/qt/Makefile
+ src/kwq/kde/Makefile
src/kwq/tests/Makefile
src/kwq/tests/qt/Makefile
)
diff --git a/WebCore/kwq/KWQBuffer.h b/WebCore/kwq/KWQBuffer.h
index 4db04c7..d0ff927 100644
--- a/WebCore/kwq/KWQBuffer.h
+++ b/WebCore/kwq/KWQBuffer.h
@@ -30,6 +30,12 @@
#include <config.h>
#endif
+// USING_BORROWED_QBUFFER ======================================================
+
+#ifdef USING_BORROWED_QBUFFER
+#include <_qbuffer.h>
+#else
+
#include <KWQDef.h>
#include "qarray.h"
@@ -72,4 +78,6 @@ private:
}; // class QBuffer ============================================================
+#endif // USING_BORROWED_QBUFFER
+
#endif
diff --git a/WebCore/kwq/KWQKURL.h b/WebCore/kwq/KWQKURL.h
index 8a5533d..c527726 100644
--- a/WebCore/kwq/KWQKURL.h
+++ b/WebCore/kwq/KWQKURL.h
@@ -30,7 +30,23 @@
#include <config.h>
#endif
-class QString;
+// USING_BORROWED_KURL =========================================================
+
+#ifdef USING_BORROWED_KURL
+#include <_kurl.h>
+
+#else
+
+#include <qstring.h>
+
+// FIXME: this clever hack may need to be moved into KWQDef.h or elsewhere
+#define Fixed MacFixed
+#define Rect MacRect
+#define Boolean MacBoolean
+#include <CoreFoundation/CoreFoundation.h>
+#undef Fixed
+#undef Rect
+#undef Boolean
// class KURL ==================================================================
@@ -85,6 +101,25 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
+private:
+
+ void init();
+
+ CFURLRef urlRef;
+ bool malformed;
+ QString sURL;
+ QString sProtocol;
+ QString sHost;
+ unsigned short int iPort;
+ QString sPass;
+ QString sUser;
+ QString sRef;
+ QString sQuery;
+ QString sPath;
+
+
}; // class KURL ===============================================================
#endif
+
+#endif // USING_BORROWED_KURL
\ No newline at end of file
diff --git a/WebCore/src/kwq/qt/Makefile.in b/WebCore/kwq/kde/Makefile.in
similarity index 96%
copy from WebCore/src/kwq/qt/Makefile.in
copy to WebCore/kwq/kde/Makefile.in
index 82e0aba..2b1becc 100644
--- a/WebCore/src/kwq/qt/Makefile.in
+++ b/WebCore/kwq/kde/Makefile.in
@@ -20,7 +20,7 @@ CXXOBJECTS = $(patsubst %.cpp,%.o,$(wildcard *.cpp))
OBJECTS = $(CXXOBJECTS)
-LIBRARY = lib_qt.a
+LIBRARY = lib_kde.a
CLEAN_FILES = *.o \
*.a \
@@ -31,6 +31,8 @@ CLEAN_FILES = *.o \
CXXFLAGS = $(BASECXXFLAGS) \
-I$(TOPSRCDIR) \
+ -I../kdecore \
+ -I../qt \
-I.. \
-I. \
$(NULL)
diff --git a/WebCore/kwq/kde/_kurl.cpp b/WebCore/kwq/kde/_kurl.cpp
new file mode 100644
index 0000000..feaaea4
--- /dev/null
+++ b/WebCore/kwq/kde/_kurl.cpp
@@ -0,0 +1,1547 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 1999 Torben Weis <weis at kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "_kurl.h"
+#include <kdebug.h>
+#include <kglobal.h>
+
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <_qurl.h>
+#include <_qdir.h>
+#include <qstringlist.h>
+
+#include <qtextcodec.h>
+#include <kcharsets.h>
+
+static QTextCodec * codecForHint( int encoding_hint /* not 0 ! */ )
+{
+/*
+ FIXME: hacking this out
+ // Get the charset name from encoding_hint - but KCharsets doesn't
+ // know about "unicode"
+ QString charsetName =
+ (encoding_hint == QFont::Unicode) ? QString::fromLatin1("utf8") :
+ KGlobal::charsets()->name( (QFont::CharSet) encoding_hint );
+
+ bool ok;
+ QTextCodec * textCodec = KGlobal::charsets()->codecForName( charsetName, ok );
+ return ok ? textCodec : 0L;
+*/
+ return 0L;
+}
+
+static QString encode( const QString& segment, bool encode_slash, int encoding_hint )
+{
+ char encode_extra = encode_slash ? '/' : 0;
+ QCString local;
+ if (encoding_hint==0)
+ local = segment.local8Bit();
+ else
+ {
+ QTextCodec * textCodec = codecForHint( encoding_hint );
+ if (!textCodec)
+ local = segment.local8Bit();
+ else {
+ // FIXME: ignoring encodings for now
+ //local = textCodec->fromUnicode( segment );
+ }
+ }
+
+ int old_length = local.length();
+
+ if ( !old_length )
+ return QString::null;
+
+ // a worst case approximation
+ QChar *new_segment = new QChar[ old_length * 3 + 1 ];
+ int new_length = 0;
+
+ for ( int i = 0; i < old_length; i++ )
+ {
+ // 'unsave' and 'reserved' characters
+ // according to RFC 1738,
+ // 2.2. URL Character Encoding Issues (pp. 3-4)
+ // WABA: Added non-ascii
+ unsigned char character = local[i];
+ if ( (character <= 32) || (character >= 127) ||
+ strchr("<>#@\"&%$:,;?={}|^~[]\'`\\", character) ||
+ (character == encode_extra) )
+ {
+ new_segment[ new_length++ ] = '%';
+
+ unsigned int c = character / 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+
+ c = character % 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+
+ }
+ else
+ new_segment[ new_length++ ] = local[i];
+ }
+
+ QString result = QString(new_segment, new_length);
+ delete [] new_segment;
+ return result;
+}
+
+static char hex2int( unsigned int _char )
+{
+ if ( _char >= 'A' && _char <='F')
+ return _char - 'A' + 10;
+ if ( _char >= 'a' && _char <='f')
+ return _char - 'a' + 10;
+ if ( _char >= '0' && _char <='9')
+ return _char - '0';
+ return -1;
+}
+
+// WABA: The result of lazy_encode isn't usable for a URL which
+// needs to satisfies RFC requirements. However, the following
+// operation will make it usable again:
+// encode(decode(...))
+//
+// As a result one can see that url.prettyURL() does not result in
+// a RFC compliant URL but that the following sequence does:
+// KURL(url.prettyURL()).url()
+
+
+static QString lazy_encode( const QString& segment )
+{
+ int old_length = segment.length();
+
+ if ( !old_length )
+ return QString::null;
+
+ // a worst case approximation
+ QChar *new_segment = new QChar[ old_length * 3 + 1 ];
+ int new_length = 0;
+
+ for ( int i = 0; i < old_length; i++ )
+ {
+ unsigned int character = segment[i].unicode(); // Don't use latin1()
+ // It returns 0 for non-latin1 values
+ // Small set of really ambiguous chars
+ if ((character < 32) || // Low ASCII
+ ((character == '%') && // The escape character itself
+ (i+2 < old_length) && // But only if part of a valid escape sequence!
+ (hex2int(segment[i+1].unicode())!= -1) &&
+ (hex2int(segment[i+2].unicode())!= -1)) ||
+ (character == '?') || // Start of query delimiter
+ (character == '#') || // Start of reference delimiter
+ ((character == 32) && (i+1 == old_length))) // A trailing space
+ {
+ new_segment[ new_length++ ] = '%';
+
+ unsigned int c = character / 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+
+ c = character % 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+ }
+ else
+ new_segment[ new_length++ ] = segment[i];
+ }
+
+ QString result = QString(new_segment, new_length);
+ delete [] new_segment;
+ return result;
+}
+
+static QString decode( const QString& segment, bool *keepEncoded=0, int encoding_hint=0 )
+{
+ bool isUnicode = false; // This detects utf-16, not utf-8
+ bool isLocal = false;
+ bool isAscii = true;
+ bool bKeepEncoded = true;
+ int old_length = segment.length();
+ if ( !old_length )
+ return QString::null;
+
+ int new_length = 0;
+
+ // make a copy of the old one
+ char *new_segment = new char[ old_length + 1];
+ QChar *new_usegment = new QChar[ old_length + 1 ];
+
+ int i = 0;
+ while( i < old_length )
+ {
+ unsigned int character = segment[ i++ ].unicode();
+ if ((character == ' ') || (character > 255))
+ bKeepEncoded = false;
+ if (character == '%' )
+ {
+ char a = i+1 < old_length ? hex2int( segment[i].latin1() ) : -1;
+ char b = i+1 < old_length ? hex2int( segment[i+1].latin1() ) : -1;
+ if ((a == -1) || (b == -1)) // Only replace if sequence is valid
+ {
+ // Contains stray %, make sure to re-encode!
+ bKeepEncoded = false;
+ }
+ else
+ {
+ // Valid %xx sequence
+ character = a * 16 + b; // Replace with value of %dd
+ i += 2; // Skip dd
+ if (character > 127)
+ isLocal = true;
+ }
+ }
+ new_segment [ new_length ] = character;
+ new_usegment [ new_length ] = character;
+ new_length++;
+ if (character > 127)
+ {
+ isAscii = false;
+ if (character > 255)
+ isUnicode = true;
+ }
+ }
+ new_segment [ new_length ] = 0;
+ QString result;
+ // Encoding specified
+ if ( encoding_hint )
+ {
+ QTextCodec * textCodec = codecForHint( encoding_hint );
+ // FIXME: ignoring encodings for now
+ /*
+ if (textCodec)
+ {
+ QByteArray array;
+ array.setRawData(new_segment, new_length);
+ result = textCodec->toUnicode( array, new_length );
+ array.resetRawData(new_segment, new_length);
+ }
+ else
+ */
+ result = QString::fromLocal8Bit(new_segment, new_length);
+ }
+ // Guess the encoding, if not specified
+ else if ((!isAscii && !isUnicode) || isLocal)
+ {
+ result = QString::fromLocal8Bit(new_segment, new_length);
+ }
+ else
+ {
+ result = QString( new_usegment, new_length);
+ }
+ if (keepEncoded)
+ *keepEncoded = bKeepEncoded;
+ delete [] new_segment;
+ delete [] new_usegment;
+ return result;
+}
+
+static QString cleanpath(const QString &path, bool cleanDirSeparator=true)
+{
+ if (path.isEmpty()) return QString::null;
+ // Did we have a trailing '/'
+ int len = path.length();
+ bool slash = false;
+ if ( len > 0 && path.right(1)[0] == '/' )
+ slash = true;
+
+ // The following code cleans up directory path much like
+ // QDir::cleanDirPath() except it can be made to ignore multiple
+ // directory separators by setting the flag to false. That fixes
+ // bug# 15044, mail.altavista.com and other similar brain-dead server
+ // implementations that do not follow what has been specified in
+ // RFC 2396!! (dA)
+ QString result;
+ int cdUp, orig_pos, pos;
+
+ cdUp = 0;
+ pos = orig_pos = len;
+ while ( pos && (pos = path.findRev('/',--pos)) != -1 )
+ {
+ len = orig_pos - pos - 1;
+ if ( len == 2 && path[pos+1] == '.' && path[pos+2] == '.' )
+ cdUp++;
+ else
+ {
+ // Ignore any occurances of '.' This includes entries
+ // that simply do not make sense like /..../
+ if ( (len!=0 || !cleanDirSeparator) && (len != 1 || path[pos+1] != '.') )
+ {
+ if ( !cdUp )
+ result = path.mid(pos, len+1) + result;
+ else
+ cdUp--;
+ }
+ }
+ orig_pos = pos;
+ }
+
+ if ( result.isEmpty() )
+ result = "/";
+
+ // Restore the trailing '/'
+ len = result.length();
+ if ( len > 0 && result.right(1)[0] != '/' && slash )
+ result += "/";
+ return result;
+}
+
+bool KURL::isRelativeURL(const QString &_url)
+{
+ int len = _url.length();
+ if (!len) return true; // Very short relative URL.
+ const QChar *str = _url.unicode();
+
+ // Absolute URL must start with alpha-character
+ if (!isalpha(str[0].latin1()))
+ return true; // Relative URL
+
+ for(int i = 1; i < len; i++)
+ {
+ char c = str[i].latin1(); // Note: non-latin1 chars return 0!
+ if (c == ':')
+ return false; // Absolute URL
+
+ // Protocol part may only contain alpha, digit, + or -
+ if (!isalpha(c) && !isdigit(c) && (c != '+') && (c != '-'))
+ return true; // Relative URL
+ }
+ // URL did not contain ':'
+ return true; // Relative URL
+}
+
+KURL::List::List(const QStringList &list)
+{
+ for (QStringList::ConstIterator it = list.begin();
+ it != list.end();
+ it++)
+ {
+ append( KURL(*it) );
+ }
+}
+
+QStringList KURL::List::toStringList() const
+{
+ QStringList lst;
+ for( KURL::List::ConstIterator it = begin();
+ it != end();
+ it++)
+ {
+ lst.append( (*it).url() );
+ }
+ return lst;
+}
+
+
+KURL::KURL()
+{
+ reset();
+}
+
+KURL::~KURL()
+{
+}
+
+
+KURL::KURL( const QString &url, int encoding_hint )
+{
+ reset();
+ parse( url, encoding_hint );
+}
+
+KURL::KURL( const char * url, int encoding_hint )
+{
+ reset();
+ parse( QString::fromLatin1(url), encoding_hint );
+}
+
+KURL::KURL( const KURL& _u )
+{
+ m_strProtocol = _u.m_strProtocol;
+ m_strUser = _u.m_strUser;
+ m_strPass = _u.m_strPass;
+ m_strHost = _u.m_strHost;
+ m_strPath = _u.m_strPath;
+ m_strPath_encoded = _u.m_strPath_encoded;
+ m_strQuery_encoded = _u.m_strQuery_encoded;
+ m_strRef_encoded = _u.m_strRef_encoded;
+ m_bIsMalformed = _u.m_bIsMalformed;
+ m_iPort = _u.m_iPort;
+}
+
+#ifndef QT_NO_DATASTREAM
+QDataStream & operator<< (QDataStream & s, const KURL & a)
+{
+ s << a.m_strProtocol << a.m_strUser << a.m_strPass << a.m_strHost
+ << a.m_strPath << a.m_strPath_encoded << a.m_strQuery_encoded << a.m_strRef_encoded
+ << Q_INT8(a.m_bIsMalformed ? 1 : 0) << a.m_iPort;
+ return s;
+}
+
+QDataStream & operator>> (QDataStream & s, KURL & a)
+{
+ Q_INT8 malf;
+ s >> a.m_strProtocol >> a.m_strUser >> a.m_strPass >> a.m_strHost
+ >> a.m_strPath >> a.m_strPath_encoded >> a.m_strQuery_encoded >> a.m_strRef_encoded
+ >> malf >> a.m_iPort;
+ a.m_bIsMalformed = (malf != 0);
+
+ if ( a.m_strQuery_encoded.isEmpty() )
+ a.m_strQuery_encoded = QString::null;
+
+ return s;
+}
+#endif
+
+KURL::KURL( const QUrl &u )
+{
+ m_strProtocol = u.protocol();
+ m_strUser = u.user();
+ m_strPass = u.password();
+ m_strHost = u.host();
+ m_strPath = u.path( FALSE );
+ m_strPath_encoded = QString::null;
+ m_strQuery_encoded = u.query();
+ m_strRef_encoded = u.ref();
+ m_bIsMalformed = !u.isValid();
+ m_iPort = u.port();
+}
+
+KURL::KURL( const KURL& _u, const QString& _rel_url, int encoding_hint )
+{
+ // WORKAROUND THE RFC 1606 LOOPHOLE THAT ALLOWS
+ // http:/index.html AS A VALID SYNTAX FOR RELATIVE
+ // URLS. ( RFC 2396 section 5.2 item # 3 )
+ QString rUrl = _rel_url;
+ int len = _u.m_strProtocol.length();
+ if ( !_u.m_strHost.isEmpty() && !rUrl.isEmpty() &&
+ rUrl.find( _u.m_strProtocol, 0, false ) == 0 &&
+ rUrl[len] == ':' && (rUrl[len+1] != '/' ||
+ (rUrl[len+1] == '/' && rUrl[len+2] != '/')) )
+ {
+ rUrl.remove( 0, rUrl.find( ':' ) + 1 );
+ }
+
+ if ( rUrl.isEmpty() )
+ {
+ *this = _u;
+ }
+ else if ( rUrl[0] == '#' )
+ {
+ *this = _u;
+ setHTMLRef( decode(rUrl.mid(1), 0, encoding_hint) );
+ }
+ else if ( isRelativeURL( rUrl) )
+ {
+ *this = _u;
+ m_strQuery_encoded = QString::null;
+ m_strRef_encoded = QString::null;
+ if ( rUrl[0] == '/')
+ {
+ if ((rUrl.length() > 1) && (rUrl[1] == '/'))
+ {
+ m_strHost = QString::null;
+ }
+ m_strPath = QString::null;
+ m_strPath_encoded = QString::null;
+ }
+ else if ( rUrl[0] != '?' )
+ {
+ int pos = m_strPath.findRev( '/' );
+ if (pos >= 0)
+ m_strPath.truncate(pos);
+ m_strPath += '/';
+ if (!m_strPath_encoded.isEmpty())
+ {
+ pos = m_strPath_encoded.findRev( '/' );
+ if (pos >= 0)
+ m_strPath_encoded.truncate(pos);
+ m_strPath_encoded += '/';
+ }
+ }
+ else
+ {
+ if ( m_strPath.isEmpty() )
+ m_strPath = '/';
+ }
+ KURL tmp( url() + rUrl, encoding_hint);
+ *this = tmp;
+ cleanPath(false);
+ }
+ else
+ {
+ KURL tmp( rUrl, encoding_hint);
+ *this = tmp;
+ }
+}
+
+void KURL::reset()
+{
+ m_strProtocol = QString::null;
+ m_strUser = QString::null;
+ m_strPass = QString::null;
+ m_strHost = QString::null;
+ m_strPath = QString::null;
+ m_strPath_encoded = QString::null;
+ m_strQuery_encoded = QString::null;
+ m_strRef_encoded = QString::null;
+ m_bIsMalformed = true;
+ m_iPort = 0;
+}
+
+bool KURL::isEmpty() const
+{
+ return (m_strPath.isEmpty() && m_strProtocol.isEmpty());
+}
+
+void KURL::parse( const QString& _url, int encoding_hint )
+{
+ // Return immediately whenever the given url
+ // is empty or null.
+ if ( _url.isEmpty() )
+ {
+ m_strProtocol = _url;
+ return;
+ }
+
+ QString port;
+ int start = 0;
+ uint len = _url.length();
+ QChar* buf = new QChar[ len + 1 ];
+ QChar* orig = buf;
+ memcpy( buf, _url.unicode(), len * sizeof( QChar ) );
+
+ uint pos = 0;
+
+ // Node 1: Accept alpha or slash
+ QChar x = buf[pos++];
+ if ( x == '/' )
+ goto Node9;
+ if ( !isalpha( (int)x ) )
+ goto NodeErr;
+
+ // Node 2: Accept any amount of (alpha|digit|'+'|'-')
+ // '.' is not currently accepted, because current KURL may be confused.
+ // Proceed with :// :/ or :
+ while( (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) ||
+ buf[pos] == '+' || buf[pos] == '-') &&
+ pos < len ) pos++;
+ if ( pos == len - 1 ) // Need to always compare length()-1 otherwise KURL passes "http:" as legal!!! (DA)
+ goto NodeErr;
+ if (buf[pos] == ':' && buf[pos+1] == '/' && buf[pos+2] == '/' )
+ {
+ m_strProtocol = QString( orig, pos ).lower();
+ pos += 3;
+ }
+ else if (buf[pos] == ':' && buf[pos+1] == '/' )
+ {
+ m_strProtocol = QString( orig, pos ).lower();
+ pos++;
+ start = pos;
+ goto Node9;
+ }
+ else if ( buf[pos] == ':' )
+ {
+ m_strProtocol = QString( orig, pos ).lower();
+ pos++;
+ goto Node11;
+ }
+ else
+ goto NodeErr;
+
+ //Node 3: We need at least one character here
+ if ( pos == len )
+ goto NodeErr;
+ start = pos;
+
+ // Node 4: Accept any amount of characters.
+ if (buf[pos] == '[') // An IPv6 host follows.
+ goto Node8;
+ // Terminate on / or @ or ? or #
+ x = buf[pos];
+ while( (x != ':') && (x != '@') && (x != '/') && (x != '?') && (x != '#') && (pos < len) )
+ x = buf[++pos];
+ if ( pos == len )
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ goto NodeOk;
+ }
+ if ( x == '@' )
+ {
+ m_strUser = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ pos++;
+ goto Node7;
+ }
+ /* else if ( x == ':' )
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ pos++;
+ goto Node8a;
+ } */
+ else if ( (x == '/') || (x == '?') || (x == '#'))
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ start = pos;
+ goto Node9;
+ }
+ else if ( x != ':' )
+ goto NodeErr;
+ m_strUser = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ pos++;
+
+ // Node 5: We need at least one character
+ if ( pos == len )
+ goto NodeErr;
+ start = pos++;
+
+ // Node 6: Read everything until @, /, ? or #
+ while( (pos < len) &&
+ (buf[pos] != '@') &&
+ (buf[pos] != '/') &&
+ (buf[pos] != '?') &&
+ (buf[pos] != '#')) pos++;
+ // If we now have a '@' the ':' seperates user and password.
+ // Otherwise it seperates host and port.
+ if ( (pos == len) || (buf[pos] != '@') )
+ {
+ // Ok the : was used to separate host and port
+ m_strHost = m_strUser;
+ m_strUser = QString::null;
+ QString tmp( buf + start, pos - start );
+ char *endptr;
+ m_iPort = (unsigned short int)strtol(tmp.ascii(), &endptr, 10);
+ if ((pos == len) && (strlen(endptr) == 0))
+ goto NodeOk;
+ // there is more after the digits
+ pos -= strlen(endptr);
+ start = pos++;
+ goto Node9;
+ }
+ m_strPass = decode(QString( buf + start, pos - start), 0, encoding_hint);
+ pos++;
+
+ // Node 7: We need at least one character
+ Node7:
+ if ( pos == len )
+ goto NodeErr;
+
+ Node8:
+ if (buf[pos] == '[')
+ {
+ // IPv6 address
+ start = ++pos; // Skip '['
+
+ // Node 8b: Read everything until ] or terminate
+ while( buf[pos] != ']' && pos < len ) pos++;
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ if (pos < len) pos++; // Skip ']'
+ if (pos == len)
+ goto NodeOk;
+ }
+ else
+ {
+ // Non IPv6 address
+ start = pos++;
+
+ // Node 8b: Read everything until / : or terminate
+ while( buf[pos] != '/' && buf[pos] != ':' && pos < len ) pos++;
+ if ( pos == len )
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ goto NodeOk;
+ }
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ }
+ x = buf[pos];
+ if ( x == '/' )
+ {
+ start = pos++;
+ goto Node9;
+ }
+ else if ( x != ':' )
+ goto NodeErr;
+ pos++;
+
+ // Node 8a: Accept at least one digit
+ if ( pos == len )
+ goto NodeErr;
+ start = pos;
+ if ( !isdigit( buf[pos++] ) )
+ goto NodeErr;
+
+ // Node 8b: Accept any amount of digits
+ while( isdigit( buf[pos] ) && pos < len ) pos++;
+ port = QString( buf + start, pos - start );
+ m_iPort = port.toUShort();
+ if ( pos == len )
+ goto NodeOk;
+ start = pos++;
+
+ // Node 9: Accept any character and # or terminate
+ Node9:
+ while( buf[pos] != '#' && pos < len ) pos++;
+ if ( pos == len )
+ {
+ QString tmp( buf + start, len - start );
+ setEncodedPathAndQuery( tmp, encoding_hint );
+ // setEncodedPathAndQuery( QString( buf + start, pos - start ) );
+ goto NodeOk;
+ }
+ else if ( buf[pos] != '#' )
+ goto NodeErr;
+ setEncodedPathAndQuery( QString( buf + start, pos - start ), encoding_hint );
+ pos++;
+
+ // Node 10: Accept all the rest
+ m_strRef_encoded = QString( buf + pos, len - pos );
+ goto NodeOk;
+
+ // Node 11 We need at least one character
+ Node11:
+ start = pos;
+ if ( pos++ == len )
+ goto NodeOk; // Wrong, but since a fix was applied up top it is a non-issue here!!!!
+ // Just for the record an opaque URL such as "mailto:" is always required
+ // to have at least one more character other than a '/' following the colon.
+ // Node 12: Accept the res
+ setEncodedPathAndQuery( QString( buf + start, len - start ), encoding_hint );
+ goto NodeOk;
+
+ NodeOk:
+ delete []orig;
+ m_bIsMalformed = false; // Valid URL
+ if (m_strProtocol.isEmpty())
+ m_strProtocol = "file";
+
+ //debug("Prot=%s\nUser=%s\nPass=%s\nHost=%s\nPath=%s\nQuery=%s\nRef=%s\nPort=%i\n",
+ //m_strProtocol.ascii(), m_strUser.ascii(), m_strPass.ascii(),
+ //m_strHost.ascii(), m_strPath.ascii(), m_strQuery_encoded.ascii(),
+ //m_strRef_encoded.ascii(), m_iPort );
+ if (m_strProtocol == "file")
+ {
+ if (!m_strHost.isEmpty())
+ {
+ // File-protocol has a host name..... hmm?
+ if (m_strHost.lower() == "localhost")
+ {
+ m_strHost = QString::null; // We can ignore localhost
+ }
+ else {
+ // Pass the hostname as part of the path. Perhaps system calls
+ // just handle it.
+ m_strPath = "//"+m_strHost+m_strPath;
+ m_strPath_encoded = QString::null;
+ m_strHost = QString::null;
+ }
+ }
+ }
+ return;
+
+ NodeErr:
+ cerr << "KURL couldn't parse URL \"" << _url << "\"" << endl;
+ delete []orig;
+ reset();
+ m_strProtocol = _url;
+}
+
+KURL& KURL::operator=( const QString& _url )
+{
+ reset();
+ parse( _url );
+
+ return *this;
+}
+
+KURL& KURL::operator=( const char * _url )
+{
+ reset();
+ parse( QString::fromLatin1(_url) );
+
+ return *this;
+}
+
+KURL& KURL::operator=( const QUrl & u )
+{
+ m_strProtocol = u.protocol();
+ m_strUser = u.user();
+ m_strPass = u.password();
+ m_strHost = u.host();
+ m_strPath = u.path( FALSE );
+ m_strPath_encoded = QString::null;
+ m_strQuery_encoded = u.query();
+ m_strRef_encoded = u.ref();
+ m_bIsMalformed = !u.isValid();
+ m_iPort = u.port();
+
+ return *this;
+}
+
+KURL& KURL::operator=( const KURL& _u )
+{
+ m_strProtocol = _u.m_strProtocol;
+ m_strUser = _u.m_strUser;
+ m_strPass = _u.m_strPass;
+ m_strHost = _u.m_strHost;
+ m_strPath = _u.m_strPath;
+ m_strPath_encoded = _u.m_strPath_encoded;
+ m_strQuery_encoded = _u.m_strQuery_encoded;
+ m_strRef_encoded = _u.m_strRef_encoded;
+ m_bIsMalformed = _u.m_bIsMalformed;
+ m_iPort = _u.m_iPort;
+
+ return *this;
+}
+
+bool KURL::operator==( const KURL& _u ) const
+{
+ if ( isMalformed() || _u.isMalformed() )
+ return false;
+
+ if ( m_strProtocol == _u.m_strProtocol &&
+ m_strUser == _u.m_strUser &&
+ m_strPass == _u.m_strPass &&
+ m_strHost == _u.m_strHost &&
+ m_strPath == _u.m_strPath &&
+ // The encoded path may be null, but the URLs are still equal (David)
+ ( m_strPath_encoded.isNull() || _u.m_strPath_encoded.isNull() ||
+ m_strPath_encoded == _u.m_strPath_encoded ) &&
+ m_strQuery_encoded == _u.m_strQuery_encoded &&
+ m_strRef_encoded == _u.m_strRef_encoded &&
+ m_iPort == _u.m_iPort )
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool KURL::operator==( const QString& _u ) const
+{
+ KURL u( _u );
+ return ( *this == u );
+}
+
+bool KURL::cmp( const KURL &_u, bool _ignore_trailing ) const
+{
+ if ( isMalformed() || _u.isMalformed() )
+ return false;
+
+ if ( _ignore_trailing )
+ {
+ QString path1 = path(1);
+ QString path2 = _u.path(1);
+ if ( path1 != path2 )
+ return false;
+
+ if ( m_strProtocol == _u.m_strProtocol &&
+ m_strUser == _u.m_strUser &&
+ m_strPass == _u.m_strPass &&
+ m_strHost == _u.m_strHost &&
+ m_strQuery_encoded == _u.m_strQuery_encoded &&
+ m_strRef_encoded == _u.m_strRef_encoded &&
+ m_iPort == _u.m_iPort )
+ return true;
+
+ return false;
+ }
+
+ return ( *this == _u );
+}
+
+bool KURL::isParentOf( const KURL& _u ) const
+{
+ if ( isMalformed() || _u.isMalformed() )
+ return false;
+
+ if ( m_strProtocol == _u.m_strProtocol &&
+ m_strUser == _u.m_strUser &&
+ m_strPass == _u.m_strPass &&
+ m_strHost == _u.m_strHost &&
+ m_strQuery_encoded == _u.m_strQuery_encoded &&
+ m_strRef_encoded == _u.m_strRef_encoded &&
+ m_iPort == _u.m_iPort )
+ {
+ if ( path().isEmpty() || _u.path().isEmpty() )
+ return false; // can't work with implicit paths
+
+ QString p1( cleanpath( path() ) );
+ if ( p1[p1.length()-1] != '/' )
+ p1 += '/';
+ QString p2( cleanpath( _u.path() ) );
+ if ( p2[p2.length()-1] != '/' )
+ p2 += '/';
+
+ //kdDebug(126) << "p1=" << p1 << endl;
+ //kdDebug(126) << "p2=" << p2 << endl;
+ //kdDebug(126) << "p1.length()=" << p1.length() << endl;
+ //kdDebug(126) << "p2.left(!$)=" << p2.left( p1.length() ) << endl;
+ return p2.startsWith( p1 );
+ }
+ return false;
+}
+
+void KURL::setFileName( const QString& _txt )
+{
+ m_strRef_encoded = QString::null;
+ int i = 0;
+ while( _txt[i] == '/' ) ++i;
+ QString tmp;
+ if ( i )
+ tmp = _txt.mid( i );
+ else
+ tmp = _txt;
+
+ QString path = m_strPath;
+ if ( path.isEmpty() )
+ path = "/";
+ else
+ {
+ int lastSlash = path.findRev( '/' );
+ if ( lastSlash == -1)
+ {
+ // The first character is not a '/' ???
+ // This looks strange ...
+ path = "/";
+ }
+ else if ( path.right(1) != "/" )
+ path.truncate( lastSlash+1 ); // keep the "/"
+ }
+
+ path += tmp;
+ setPath( path );
+ cleanPath();
+}
+
+void KURL::cleanPath()
+{
+ cleanPath( true );
+}
+
+void KURL::cleanPath( bool cleanDirSeparator ) // taken from the old KURL
+{
+ m_strPath = cleanpath(m_strPath, cleanDirSeparator);
+ // WABA: Is this safe when "/../" is encoded with %?
+ m_strPath_encoded = cleanpath(m_strPath_encoded, cleanDirSeparator);
+}
+
+static QString trailingSlash( int _trailing, const QString &path )
+{
+ QString result = path;
+
+ if ( _trailing == 0 )
+ return result;
+ else if ( _trailing == 1 )
+ {
+ int len = result.length();
+ if ( len == 0 )
+ result = QString::null;
+ else if ( result[ len - 1 ] != '/' )
+ result += "/";
+ return result;
+ }
+ else if ( _trailing == -1 )
+ {
+ if ( result == "/" )
+ return result;
+ int len = result.length();
+ if ( len != 0 && result[ len - 1 ] == '/' )
+ result.truncate( len - 1 );
+ return result;
+ }
+ else {
+ assert( 0 );
+ return QString::null;
+ }
+}
+
+
+QString KURL::encodedPathAndQuery( int _trailing, bool _no_empty_path, int encoding_hint ) const
+{
+ QString tmp;
+ if (!m_strPath_encoded.isEmpty() && encoding_hint == 0)
+ {
+ tmp = trailingSlash( _trailing, m_strPath_encoded );
+ }
+ else
+ {
+ tmp = path( _trailing );
+ if ( _no_empty_path && tmp.isEmpty() )
+ tmp = "/";
+ tmp = encode( tmp, false, encoding_hint );
+ }
+
+ // TODO apply encoding_hint to the query
+ tmp += m_strQuery_encoded;
+ return tmp;
+}
+
+void KURL::setEncodedPathAndQuery( const QString& _txt, int encoding_hint )
+{
+ int pos = _txt.find( '?' );
+ if ( pos == -1 )
+ {
+ m_strPath_encoded = _txt;
+ m_strQuery_encoded = QString::null;
+ }
+ else
+ {
+ m_strPath_encoded = _txt.left( pos );
+ m_strQuery_encoded = _txt.right(_txt.length() - pos);
+ }
+ bool keepEncoded;
+ m_strPath = decode( m_strPath_encoded, &keepEncoded, encoding_hint );
+ if (!keepEncoded)
+ m_strPath_encoded = QString::null;
+}
+
+QString KURL::path( int _trailing ) const
+{
+ return trailingSlash( _trailing, path() );
+}
+
+bool KURL::isLocalFile() const
+{
+ QString fileProt = "file";
+ return ( ( m_strProtocol == fileProt ) && ( m_strHost.isEmpty()) );
+}
+
+bool KURL::hasSubURL() const
+{
+ if ( m_strProtocol.isEmpty() || m_bIsMalformed )
+ return false;
+ if (m_strRef_encoded.isEmpty())
+ return false;
+ if (m_strRef_encoded.startsWith("gzip:"))
+ return true;
+ if (m_strRef_encoded.startsWith("bzip:"))
+ return true;
+ if (m_strRef_encoded.startsWith("bzip2:"))
+ return true;
+ if (m_strRef_encoded.startsWith("tar:"))
+ return true;
+ return false;
+}
+
+// BCI: Should be removed, and the other one should have '= 0' for both args.
+QString KURL::url( int _trailing ) const
+{
+ return url( _trailing, 0 );
+}
+
+QString KURL::url( int _trailing, int encoding_hint ) const
+{
+ if( m_bIsMalformed )
+ {
+ // Return the whole url even when the url is
+ // malformed. Under such conditions the url
+ // is stored in m_strProtocol.
+ return m_strProtocol;
+ }
+
+ QString u = m_strProtocol.copy();
+ if ( hasHost() )
+ {
+ u += "://";
+ if ( hasUser() )
+ {
+ u += encode(m_strUser, true, encoding_hint);
+ if ( hasPass() )
+ {
+ u += ":";
+ u += encode(m_strPass, true, encoding_hint);
+ }
+ u += "@";
+ }
+ bool IPv6 = (m_strHost.find(':') != -1);
+ if (IPv6)
+ u += '[' + m_strHost + ']';
+ else
+ u += encode(m_strHost, true, encoding_hint);
+ if ( m_iPort != 0 ) {
+ QString buffer;
+ buffer.sprintf( ":%u", m_iPort );
+ u += buffer;
+ }
+ }
+ else
+ u += ":";
+
+ u += encodedPathAndQuery( _trailing, false, encoding_hint );
+
+ if ( hasRef() )
+ {
+ u += "#";
+ u += m_strRef_encoded;
+ }
+
+ return u;
+}
+
+QString KURL::prettyURL( int _trailing ) const
+{
+ if( m_bIsMalformed )
+ {
+ // Return the whole url even when the url is
+ // malformed. Under such conditions the url
+ // is stored in m_strProtocol.
+ return m_strProtocol;
+ }
+
+ QString u = m_strProtocol.copy();
+ if ( hasHost() )
+ {
+ u += "://";
+ if ( hasUser() )
+ {
+ u += lazy_encode(m_strUser);
+ // Don't show password!
+ u += "@";
+ }
+ bool IPv6 = (m_strHost.find(':') != -1);
+ if (IPv6)
+ u += '[' + m_strHost + ']';
+ else
+ u += lazy_encode(m_strHost);
+ if ( m_iPort != 0 ) {
+ QString buffer;
+ buffer.sprintf( ":%u", m_iPort );
+ u += buffer;
+ }
+ }
+ else
+ {
+ u += ":";
+ }
+
+ u += trailingSlash( _trailing, lazy_encode( m_strPath ) );
+
+ u += m_strQuery_encoded;
+
+ if ( hasRef() )
+ {
+ u += "#";
+ u += m_strRef_encoded;
+ }
+
+ return u;
+}
+
+KURL::List KURL::split( const KURL& _url )
+{
+ QString ref;
+ KURL::List lst;
+ KURL url = _url;
+
+ while(true)
+ {
+ KURL u = url;
+ u.m_strRef_encoded = QString::null;
+ lst.append(u);
+ if (url.hasSubURL())
+ {
+ url = KURL(url.m_strRef_encoded);
+ }
+ else
+ {
+ ref = url.m_strRef_encoded;
+ break;
+ }
+ }
+
+ // Set HTML ref in all URLs.
+ KURL::List::Iterator it;
+ for( it = lst.begin() ; it != lst.end(); ++it )
+ {
+ (*it).m_strRef_encoded = ref;
+ }
+
+ return lst;
+}
+
+KURL::List KURL::split( const QString& _url )
+{
+ return split(KURL(_url));
+}
+
+KURL KURL::join( const KURL::List & lst )
+{
+ if (lst.isEmpty()) return KURL();
+ KURL tmp;
+
+ KURL::List::ConstIterator first = lst.fromLast();
+ for( KURL::List::ConstIterator it = first; it != lst.end(); --it )
+ {
+ KURL u(*it);
+ if (it != first)
+ {
+ u.m_strRef_encoded = tmp.url();
+ }
+ tmp = u;
+ }
+
+ return tmp;
+}
+
+QString KURL::fileName( bool _strip_trailing_slash ) const
+{
+ QString fname;
+
+ int len = m_strPath.length();
+ if ( len == 0 )
+ return fname;
+
+ if ( _strip_trailing_slash )
+ {
+ while ( len >= 1 && m_strPath[ len - 1 ] == '/' )
+ len--;
+ }
+ else if ( m_strPath[ len - 1 ] == '/' )
+ return fname;
+
+ // Does the path only consist of '/' characters ?
+ if ( len == 1 && m_strPath[ 0 ] == '/' )
+ return fname;
+
+ int i = m_strPath.findRev( '/', len - 1 );
+ // If ( i == -1 ) => the first character is not a '/'
+ // So it's some URL like file:blah.tgz, return the whole path
+ if ( i == -1 ) {
+ if ( len == m_strPath.length() )
+ return m_strPath;
+ else
+ // Might get here if _strip_trailing_slash is true
+ return m_strPath.left( len );
+ }
+
+ fname = m_strPath.mid( i + 1, len - i - 1 ); // TO CHECK
+ // fname.assign( m_strPath, i + 1, len - i - 1 );
+ return fname;
+}
+
+void KURL::addPath( const QString& _txt )
+{
+ m_strPath_encoded = QString::null;
+
+ if ( _txt.isEmpty() )
+ return;
+
+ int i = 0;
+ int len = m_strPath.length();
+ // NB: avoid three '/' when building a new path from nothing
+ if ( len == 0 ) {
+ while( _txt[i] == '/' ) ++i;
+ }
+ // Add the trailing '/' if it is missing
+ else if ( _txt[0] != '/' && ( len == 0 || m_strPath[ len - 1 ] != '/' ) )
+ m_strPath += "/";
+
+ // No double '/' characters
+ i = 0;
+ if ( len != 0 && m_strPath[ len - 1 ] == '/' )
+ {
+ while( _txt[i] == '/' )
+ ++i;
+ }
+
+ m_strPath += _txt.mid( i );
+}
+
+QString KURL::directory( bool _strip_trailing_slash_from_result,
+ bool _ignore_trailing_slash_in_path ) const
+{
+ QString result;
+ if ( _ignore_trailing_slash_in_path )
+ result = path( -1 );
+ else
+ result = m_strPath;
+
+ if ( result.isEmpty() || result == "/" )
+ return result;
+
+ int i = result.findRev( "/" );
+ // If ( i == -1 ) => the first character is not a '/'
+ // So it's some URL like file:blah.tgz, with no path
+ if ( i == -1 )
+ return QString::null;
+
+ if ( i == 0 )
+ {
+ result = "/";
+ return result;
+ }
+
+ if ( _strip_trailing_slash_from_result )
+ result = m_strPath.left( i );
+ else
+ result = m_strPath.left( i + 1 );
+
+ return result;
+}
+
+
+bool KURL::cd( const QString& _dir )
+{
+ if ( _dir.isEmpty() || m_bIsMalformed )
+ return false;
+
+ if (hasSubURL())
+ {
+ KURL::List lst = split( *this );
+ KURL &u = lst.last();
+ u.cd(_dir);
+ *this = join( lst );
+ return true;
+ }
+
+ // absolute path ?
+ if ( _dir[0] == '/' )
+ {
+ m_strPath_encoded = QString::null;
+ m_strPath = _dir;
+ setHTMLRef( QString::null );
+ m_strQuery_encoded = QString::null;
+ return true;
+ }
+
+ // Users home directory on the local disk ?
+ if ( ( _dir[0] == '~' ) && ( m_strProtocol == "file" ))
+ {
+ m_strPath_encoded = QString::null;
+ m_strPath = QDir::homeDirPath().copy();
+ m_strPath += "/";
+ m_strPath += _dir.right(m_strPath.length() - 1);
+ setHTMLRef( QString::null );
+ m_strQuery_encoded = QString::null;
+ return true;
+ }
+
+ // relative path
+ // we always work on the past of the first url.
+ // Sub URLs are not touched.
+
+ // append '/' if necessary
+ QString p = path(1);
+ p += _dir;
+ p = cleanpath( p );
+ setPath( p );
+
+ setHTMLRef( QString::null );
+ m_strQuery_encoded = QString::null;
+
+ return true;
+}
+
+KURL KURL::upURL( ) const
+{
+ if (!hasSubURL())
+ {
+ KURL u(*this);
+ u.cd("../");
+ return u;
+ }
+
+ // We have a subURL.
+ KURL::List lst = split( *this );
+ if (lst.isEmpty())
+ return KURL(); // Huh?
+ while (true)
+ {
+ KURL &u = lst.last();
+ QString old = u.path();
+ u.cd("../");
+ if (u.path() != old)
+ break; // Finshed.
+ if (lst.count() == 1)
+ break; // Finished.
+ lst.remove(lst.fromLast());
+ }
+ return join( lst );
+}
+
+QString KURL::htmlRef() const
+{
+ if ( !hasSubURL() )
+ {
+ return decode( ref() );
+ }
+
+ List lst = split( *this );
+ return decode( (*lst.begin()).ref() );
+}
+
+QString KURL::encodedHtmlRef() const
+{
+ if ( !hasSubURL() )
+ {
+ return ref();
+ }
+
+ List lst = split( *this );
+ return (*lst.begin()).ref();
+}
+
+void KURL::setHTMLRef( const QString& _ref )
+{
+ if ( !hasSubURL() )
+ {
+ m_strRef_encoded = encode( _ref, true, 0 /*?*/);
+ return;
+ }
+
+ List lst = split( *this );
+
+ (*lst.begin()).setRef( encode( _ref, true, 0 /*?*/) );
+
+ *this = join( lst );
+}
+
+bool KURL::hasHTMLRef() const
+{
+ if ( !hasSubURL() )
+ {
+ return hasRef();
+ }
+
+ List lst = split( *this );
+ return (*lst.begin()).hasRef();
+}
+
+void
+KURL::setProtocol( const QString& _txt )
+{
+ m_strProtocol = _txt;
+ m_bIsMalformed = false;
+}
+
+void
+KURL::setUser( const QString& _txt )
+{
+ m_strUser = _txt;
+}
+
+void
+KURL::setPass( const QString& _txt )
+{
+ m_strPass = _txt;
+}
+
+void
+KURL::setHost( const QString& _txt )
+{
+ m_strHost = _txt;
+}
+
+void
+KURL::setPort( unsigned short int _p )
+{
+ m_iPort = _p;
+}
+
+void KURL::setPath( const QString & path )
+{
+ if (isEmpty())
+ m_bIsMalformed = false;
+ if (m_strProtocol.isEmpty())
+ m_strProtocol = "file";
+ m_strPath = path;
+ m_strPath_encoded = QString::null;
+}
+
+void KURL::setQuery( const QString &_txt, int )
+{
+ if (_txt.length() && (_txt[0] !='?'))
+ m_strQuery_encoded = "?" + _txt;
+ else
+ m_strQuery_encoded = _txt;
+}
+
+QString KURL::decode_string(const QString &str, int encoding_hint)
+{
+ return decode(str, 0, encoding_hint);
+}
+
+QString KURL::encode_string(const QString &str, int encoding_hint)
+{
+ return encode(str, false, encoding_hint);
+}
+
+QString KURL::encode_string_no_slash(const QString &str, int encoding_hint)
+{
+ return encode(str, true, encoding_hint);
+}
+
+bool urlcmp( const QString& _url1, const QString& _url2 )
+{
+ // Both empty ?
+ if ( _url1.isEmpty() && _url2.isEmpty() )
+ return true;
+ // Only one empty ?
+ if ( _url1.isEmpty() || _url2.isEmpty() )
+ return false;
+
+ KURL::List list1 = KURL::split( _url1 );
+ KURL::List list2 = KURL::split( _url2 );
+
+ // Malformed ?
+ if ( list1.isEmpty() || list2.isEmpty() )
+ return false;
+
+ return ( list1 == list2 );
+}
+
+bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref )
+{
+ // Both empty ?
+ if ( _url1.isEmpty() && _url2.isEmpty() )
+ return true;
+ // Only one empty ?
+ if ( _url1.isEmpty() || _url2.isEmpty() )
+ return false;
+
+ KURL::List list1 = KURL::split( _url1 );
+ KURL::List list2 = KURL::split( _url2 );
+
+ // Malformed ?
+ if ( list1.isEmpty() || list2.isEmpty() )
+ return false;
+
+ unsigned int size = list1.count();
+ if ( list2.count() != size )
+ return false;
+
+ if ( _ignore_ref )
+ {
+ (*list1.begin()).setRef(QString::null);
+ (*list2.begin()).setRef(QString::null);
+ }
+
+ KURL::List::Iterator it1 = list1.begin();
+ KURL::List::Iterator it2 = list2.begin();
+ for( ; it1 != list1.end() ; ++it1, ++it2 )
+ if ( !(*it1).cmp( *it2, _ignore_trailing ) )
+ return false;
+
+ return true;
+}
+
diff --git a/WebCore/kwq/kde/_kurl.h b/WebCore/kwq/kde/_kurl.h
new file mode 100644
index 0000000..e198ad5
--- /dev/null
+++ b/WebCore/kwq/kde/_kurl.h
@@ -0,0 +1,578 @@
+/* This file is part of the KDE libraries
+ * Copyright (C) 1999 Torben Weis <weis at kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ **/
+
+#ifndef __kurl_h__
+#define __kurl_h__ "$Id$"
+
+#include <qstring.h>
+#include <qvaluelist.h>
+
+class QUrl;
+class QStringList;
+
+struct KURLPrivate;
+
+/**
+ * Represent and parse a URL.
+ *
+ * A prototypical URL looks like:
+ * <pre>
+ * protocol:/user:password at hostname:port/path/to/file.ext#reference
+ * </pre>
+ *
+ * @ref KURL has some restrictions regarding the path
+ * encoding. @ref KURL works internally with the decoded path and
+ * and encoded query. For example,
+ * <pre>
+ * http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you
+ * </pre>
+ * would result in a decoded path "/cgi-bin/test me.pl"
+ * and in the encoded query "?cmd=Hello%20you".
+ * Since path is internally always encoded you may @em not use
+ * "%00" in the path, although this is OK for the query.
+ *
+ * @author Torben Weis <weis at kde.org>
+ */
+class KURL
+{
+public:
+ class List : public QValueList<KURL>
+ {
+ public:
+ List() { }
+ List(const QStringList &);
+ QStringList toStringList() const;
+ };
+ /**
+ * Construct an empty URL.
+ */
+ KURL();
+
+ /**
+ * destruktor
+ */
+ ~KURL();
+
+ /**
+ * Usual constructor, to construct from a string.
+ * @param url A URL, not a filename. If the URL does not have a protocol
+ * part, "file:" is assumed.
+ * It is dangerous to feed unix filenames into this function,
+ * this will work most of the time but not always.
+ * For example "/home/Torben%20Weis" will be considered a URL
+ * pointing to the file "/home/Torben Weis" instead of to the
+ * file "/home/Torben%20Weis".
+ * This means that if you have a usual UNIX like path you
+ * should not use this constructor.
+ * Instead create an empty url and set the path by using
+ * @ref setPath().
+ * @param encoding_hint Reserved, should be 0.
+ */
+ KURL( const QString& url, int encoding_hint = 0 );
+ /**
+ * Constructor taking a char * @p url, which is an _encoded_ representation
+ * of the URL, exactly like the usual constructor. This is useful when
+ * then URL, in its encoded form, is strictly ascii.
+ */
+ KURL( const char * url, int encoding_hint = 0 );
+ /**
+ * Copy constructor
+ */
+ KURL( const KURL& u );
+ /**
+ * Convert from a @ref QUrl.
+ */
+ KURL( const QUrl &u );
+ /**
+ * Constructor allowing relative URLs.
+ *
+ * @param _baseurl The base url.
+ * @param _rel_url A relative or absolute URL.
+ * If this is an absolute URL then @p _baseurl will be ignored.
+ * If this is a relative URL it will be combined with @p _baseurl.
+ * Note that _rel_url should be encoded too, in any case.
+ * So do NOT pass a path here (use setPath or addPath instead).
+ * @param encoding_hint Reserved, should be 0.
+ */
+ KURL( const KURL& _baseurl, const QString& _rel_url, int encoding_hint=0 );
+
+ /**
+ * Retrieve the protocol for the URL (i.e., file, http, etc.).
+ **/
+ QString protocol() const { return m_bIsMalformed ? QString::null : m_strProtocol; }
+ /**
+ * Set the protocol for the URL (i.e., file, http, etc.)
+ **/
+ void setProtocol( const QString& _txt );
+
+ /**
+ * Retrieve the decoded user name (login, user id, ...) included in the URL.
+ **/
+ QString user() const { return m_strUser; }
+ /**
+ * Set the user name (login, user id, ...) included the URL.
+ *
+ * Special characters in the user name will appear encoded in the URL.
+ **/
+ void setUser( const QString& _txt );
+ /**
+ * Test to see if this URL has a user name included in it.
+ **/
+ bool hasUser() const { return !m_strUser.isEmpty(); }
+
+ /**
+ * Retrieve the decoded password (corresponding to @ref user()) included in the URL.
+ **/
+ QString pass() const { return m_strPass; }
+ /**
+ * Set the password (corresponding to @ref user()) included in the URL.
+ *
+ * Special characters in the password will appear encoded in the URL.
+ **/
+ void setPass( const QString& _txt );
+ /**
+ * Test to see if this URL has a password included in it.
+ **/
+ bool hasPass() const { return !m_strPass.isEmpty(); }
+
+ /**
+ * Retrieve the decoded hostname included in the URL.
+ **/
+ QString host() const { return m_strHost; }
+ /**
+ * Set the hostname included in the URL.
+ *
+ * Special characters in the hostname will appear encoded in the URL.
+ **/
+ void setHost( const QString& _txt );
+ /**
+ * Test to see if this URL has a hostname included in it.
+ **/
+ bool hasHost() const { return !m_strHost.isEmpty(); }
+
+ /**
+ * Retrieve the port number included in the URL.
+ * If there is no port number specified in the URL, returns 0.
+ **/
+ unsigned short int port() const { return m_iPort; }
+ /**
+ * Set the port number included in the URL.
+ **/
+ void setPort( unsigned short int _p );
+
+ /**
+ * @return The current decoded path. This does @em not include the query.
+ *
+ */
+ QString path() const { return m_strPath; }
+
+ /**
+ * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds
+ * a trailing '/' if there is none yet and 0 returns the
+ * path unchanged. If the URL has no path, then no '/' is added
+ * anyway. And on the other side: If the path is "/", then this
+ * character won't be stripped. Reason: "ftp://weis@host" means something
+ * completely different than "ftp://weis@host/". So adding or stripping
+ * the '/' would really alter the URL, while "ftp://host/path" and
+ * "ftp://host/path/" mean the same directory.
+ *
+ * @return The current decoded path. This does not include the query.
+ */
+ QString path( int _trailing ) const;
+
+ /**
+ * path This is considered to be decoded. This means: %3f does not become decoded
+ * and the ? does not indicate the start of the query part.
+ * The query is not changed by this function.
+ */
+ void setPath( const QString& path );
+ /**
+ * Test to see if this URL has a path is included in it.
+ **/
+ bool hasPath() const { return !m_strPath.isEmpty(); }
+
+ /** Removes all multiple directory separators ('/') and
+ * resolves any "." or ".." found in the path.
+ * Calls @ref QDir::cleanDirPath but saves the trailing slash if any.
+ */
+ void cleanPath();
+
+ /**
+ * Same as above except it takes a flag that allows you
+ * to ignore the clean up of the multiple directory separators.
+ *
+ * Some servers seem not to like the removal of extra '/'
+ * eventhough it is against the specification in RFC 2396.
+ */
+ void cleanPath(bool cleanDirSeparator);
+
+ /**
+ * This is useful for HTTP. It looks first for '?' and decodes then.
+ * The encoded path is the concatenation of the current path and the query.
+ * @param encoding_hint Reserved, should be 0.
+ */
+ void setEncodedPathAndQuery( const QString& _txt, int encoding_hint = 0 );
+
+ /**
+ * @return The concatenation if the encoded path , '?' and the encoded query.
+ *
+ * @param _no_empty_path If set to true then an empty path is substituted by "/".
+ * @param encoding_hint Reserved, should be 0.
+ */
+ QString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
+
+ /**
+ * @param _txt This is considered to be encoded. This has a good reason:
+ * The query may contain the 0 character.
+ *
+ * The query should start with a '?'. If it doesn't '?' is prepended.
+ * @param encoding_hint Reserved, should be 0.
+ */
+ void setQuery( const QString& _txt, int encoding_hint = 0);
+
+ /**
+ * @return The encoded query.
+ * This has a good reason: The query may contain the 0 character.
+ * If a query is present it always starts with a '?'.
+ * A single '?' means an empty query.
+ * An empty string means no query.
+ */
+ QString query() const { return m_strQuery_encoded; }
+
+ /**
+ * The reference is @em never decoded automatically.
+ */
+ QString ref() const { return m_strRef_encoded; }
+
+ /**
+ * Set the reference part (everything after '#').
+ * @param _txt is considered encoded.
+ */
+ void setRef( const QString& _txt ) { m_strRef_encoded = _txt; }
+
+ /**
+ * @return @p true if the reference part of the URL is not empty. In a URL like
+ * http://www.kde.org/kdebase.tar#tar:/README it would return @p true, too.
+ */
+ bool hasRef() const { return !m_strRef_encoded.isEmpty(); }
+
+ /**
+ * @return The HTML-style reference.
+ */
+ QString htmlRef() const;
+
+ /**
+ * @return The HTML-style reference in its original form.
+ */
+ QString encodedHtmlRef() const;
+
+ /**
+ * Set the HTML-style reference.
+ *
+ * @param _ref This is considered to be @em not encoded in contrast to @ref setRef()
+ *
+ * @see htmlRef()
+ */
+ void setHTMLRef( const QString& _ref );
+
+ /**
+ * @return @p true if the URL has an HTML-style reference.
+ *
+ * @see htmlRef()
+ */
+ bool hasHTMLRef() const;
+
+ /**
+ * @return @p false if the URL is malformed. This function does @em not test
+ * whether sub URLs are well-formed, too.
+ */
+ bool isValid() const { return !m_bIsMalformed; }
+ /**
+ * @deprecated
+ */
+ bool isMalformed() const { return !isValid(); }
+
+ /**
+ * @return @p true if the file is a plain local file and has no filter protocols
+ * attached to it.
+ */
+ bool isLocalFile() const;
+
+ /**
+ * @return @p true if the file has at least one sub URL.
+ * Use @ref split() to get the sub URLs.
+ */
+ bool hasSubURL() const;
+
+ /**
+ * Add to the current path.
+ * Assumes that the current path is a directory. @p _txt is appended to the
+ * current path. The function adds '/' if needed while concatenating.
+ * This means it does not matter whether the current path has a trailing
+ * '/' or not. If there is none, it becomes appended. If @p _txt
+ * has a leading '/' then this one is stripped.
+ *
+ * @param _txt This is considered to be decoded
+ */
+ void addPath( const QString& _txt );
+
+ /**
+ * In comparison to @ref addPath() this function does not assume that the current path
+ * is a directory. This is only assumed if the current path ends with '/'.
+ *
+ * Any reference is reset.
+ *
+ * @param _txt This is considered to be decoded. If the current path ends with '/'
+ * then @p _txt ist just appended, otherwise all text behind the last '/'
+ * in the current path is erased and @p _txt is appended then. It does
+ * not matter whether @p _txt starts with '/' or not.
+ */
+ void setFileName( const QString&_txt );
+
+ /**
+ * @return The filename of the current path. The returned string is decoded.
+ *
+ * @param _ignore_trailing_slash_in_path This tells whether a trailing '/' should be ignored.
+ * This means that the function would return "torben" for
+ * <tt>file:/hallo/torben/</tt> and <tt>file:/hallo/torben</tt>.
+ * If the flag is set to false, then everything behind the last '/'
+ * is considered to be the filename.
+ */
+ QString fileName( bool _ignore_trailing_slash_in_path = true ) const;
+ QString filename( bool _ignore_trailing_slash_in_path = true ) const
+ {
+ return fileName(_ignore_trailing_slash_in_path);
+ }
+
+ /**
+ * @return The directory part of the current path. Everything between the last and the second last '/'
+ * is returned. For example <tt>file:/hallo/torben/</tt> would return "/hallo/torben/" while
+ * <tt>file:/hallo/torben</tt> would return "hallo/". The returned string is decoded.
+ *
+ * @param _strip_trailing_slash_from_result tells whether the returned result should end with '/' or not.
+ * If the path is empty or just "/" then this flag has no effect.
+ * @param _ignore_trailing_slash_in_path means that <tt>file:/hallo/torben</tt> and
+ * <tt>file:/hallo/torben/"</tt> would both return <tt>/hallo/</tt>
+ * or <tt>/hallo</tt> depending on the other flag
+ */
+ QString directory( bool _strip_trailing_slash_from_result = true,
+ bool _ignore_trailing_slash_in_path = true ) const;
+
+ /**
+ * Change directory by descending into the given directory.
+ * It is assumed the current URL represents a directory.
+ * If @p dir starts with a "/" the
+ * current URL will be "protocol://host/dir" otherwise @p _dir will
+ * be appended to the path. @p _dir can be ".."
+ * This function won't strip protocols. That means that when you are in
+ * file:/dir/dir2/my.tgz#tar:/ and you do cd("..") you will
+ * still be in file:/dir/dir2/my.tgz#tar:/
+ *
+ * @return true
+ */
+ bool cd( const QString& _dir );
+
+ /**
+ * @return The complete URL, with all escape sequences intact.
+ * Example: http://localhost:8080/test.cgi?test=hello%20world&name=fred
+ *
+ * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds
+ * a trailing '/' if there is none yet and 0 returns the
+ * path unchanged.
+ */
+ QString url( int _trailing = 0 ) const;
+
+ /**
+ * @return The complete URL, with all escape sequences intact, encoded
+ * in a given charset.
+ * This is used in particular for encoding URLs in UTF-8 before using them
+ * in a drag and drop operation.
+ *
+ * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds
+ * a trailing '/' if there is none yet and 0 returns the
+ * path unchanged.
+ * @param encoding_hint The charset to use for encoding (see QFont::Charset).
+ */
+ QString url( int _trailing, int encoding_hint ) const;
+
+ /**
+ * @return A human readable URL, with no non-necessary encodings/escaped
+ * characters.
+ * Example: http://localhost:8080/test.cgi?test=hello world&name=fred
+ */
+ QString prettyURL( int _trailing = 0) const;
+
+ /**
+ * Test to see if the @ref KURL is empty.
+ **/
+ bool isEmpty() const;
+
+ /**
+ * This function is useful to implement the "Up" button in a file manager for example.
+ * @ref cd() never strips a sub-protocol. That means that if you are in
+ * file:/home/x.tgz#gzip:/#tar:/ and hit the up button you expect to see
+ * file:/home. The algorithm tries to go up on the right-most URL. If that is not
+ * possible it strips the right most URL. It continues stripping URLs.
+ */
+ KURL upURL( ) const;
+
+ KURL& operator=( const KURL& _u );
+ KURL& operator=( const QString& _url );
+ KURL& operator=( const char * _url );
+ KURL& operator=( const QUrl & u );
+
+ bool operator==( const KURL& _u ) const;
+ bool operator==( const QString& _u ) const;
+ bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
+ bool operator!=( const QString& _u ) const { return !( *this == _u ); }
+
+ /**
+ * Compare this url with @p u
+ * @param ignore_trailing set to true to ignore trailing '/' characters.
+ * @return true if both urls are the same
+ * @see operator==. This function should be used if you want to
+ * ignore trailing '/' characters.
+ */
+ bool cmp( const KURL &u, bool ignore_trailing = false ) const;
+
+ /**
+ * @return true if this url is a parent of @p u (or the same URL as @p u)
+ * For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/.
+ */
+ bool isParentOf( const KURL& u ) const;
+
+ /**
+ * Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase
+ * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in
+ * http://www.kde.org and tar:/kde/README.html#ref1.
+ * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL.
+ * Since HTML-style references mark
+ * a certain position in a document this reference is appended to every URL.
+ * The idea behind this is that browsers, for example, only look at the first URL while
+ * the rest is not of interest to them.
+ *
+ * @return An empty list on error or the list of split URLs.
+ *
+ * @param _url The URL that has to be split.
+ */
+ static List split( const QString& _url );
+
+ /**
+ * A convenience function.
+ */
+ static List split( const KURL& _url );
+
+ /**
+ * Reverses @ref split(). Only the first URL may have a reference. This reference
+ * is considered to be HTML-like and is appended at the end of the resulting
+ * joined URL.
+ */
+ static KURL join( const List& _list );
+
+ /**
+ * Convenience function
+ *
+ * Convert unicoded string to local encoding and use %-style
+ * encoding for all common delimiters / non-ascii characters.
+ * @param str String to encode
+ * @param encoding_hint Reserved, should be 0.
+ **/
+ static QString encode_string(const QString &str, int encoding_hint = 0);
+
+ /**
+ * Convenience function
+ *
+ * Convert unicoded string to local encoding and use %-style
+ * encoding for all common delimiters / non-ascii characters
+ * as well as the slash '/'.
+ * @param str String to encode
+ * @param encoding_hint Reserved, should be 0.
+ **/
+ static QString encode_string_no_slash(const QString &str, int encoding_hint = 0);
+
+ /**
+ * Convenience function
+ *
+ * Decode %-style encoding and convert from local encoding to unicode.
+ *
+ * Revers of encode_string()
+ * @param str String to decode
+ * @param encoding_hint Reserved, should be 0.
+ **/
+ static QString decode_string(const QString &str, int encoding_hint = 0);
+
+ /**
+ * Convenience function
+ *
+ * Returns whether '_url' is likely to be a "relative" URL instead of
+ * an "absolute" URL.
+ * @param _url URL to examine
+ * @return true when the URL is likely to be "relative", false otherwise.
+ */
+ static bool isRelativeURL(const QString &_url);
+
+protected:
+ void reset();
+ void parse( const QString& _url, int encoding_hint = 0);
+
+private:
+ QString m_strProtocol;
+ QString m_strUser;
+ QString m_strPass;
+ QString m_strHost;
+ QString m_strPath;
+ QString m_strRef_encoded;
+ QString m_strQuery_encoded;
+ KURLPrivate* d;
+ bool m_bIsMalformed : 1;
+ int freeForUse : 7;
+ unsigned short int m_iPort;
+ QString m_strPath_encoded;
+
+#ifndef QT_NO_DATASTREAM
+ friend QDataStream & operator<< (QDataStream & s, const KURL & a);
+ friend QDataStream & operator>> (QDataStream & s, KURL & a);
+#endif
+};
+
+/**
+ * Compares URLs. They are parsed, split and compared.
+ * Two malformed URLs with the same string representation
+ * are nevertheless considered to be unequal.
+ * That means no malformed URL equals anything else.
+ */
+bool urlcmp( const QString& _url1, const QString& _url2 );
+
+/**
+ * Compares URLs. They are parsed, split and compared.
+ * Two malformed URLs with the same string representation
+ * are nevertheless considered to be unequal.
+ * That means no malformed URL equals anything else.
+ *
+ * @param _ignore_trailing Described in @ref KURL::cmp
+ * @param _ignore_ref If @p true, disables comparison of HTML-style references.
+ */
+bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref );
+
+#ifndef QT_NO_DATASTREAM
+QDataStream & operator<< (QDataStream & s, const KURL & a);
+QDataStream & operator>> (QDataStream & s, KURL & a);
+#endif
+
+#endif
diff --git a/WebCore/kwq/kdecore/kurl.h b/WebCore/kwq/kdecore/kurl.h
index 8a5533d..c527726 100644
--- a/WebCore/kwq/kdecore/kurl.h
+++ b/WebCore/kwq/kdecore/kurl.h
@@ -30,7 +30,23 @@
#include <config.h>
#endif
-class QString;
+// USING_BORROWED_KURL =========================================================
+
+#ifdef USING_BORROWED_KURL
+#include <_kurl.h>
+
+#else
+
+#include <qstring.h>
+
+// FIXME: this clever hack may need to be moved into KWQDef.h or elsewhere
+#define Fixed MacFixed
+#define Rect MacRect
+#define Boolean MacBoolean
+#include <CoreFoundation/CoreFoundation.h>
+#undef Fixed
+#undef Rect
+#undef Boolean
// class KURL ==================================================================
@@ -85,6 +101,25 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
+private:
+
+ void init();
+
+ CFURLRef urlRef;
+ bool malformed;
+ QString sURL;
+ QString sProtocol;
+ QString sHost;
+ unsigned short int iPort;
+ QString sPass;
+ QString sUser;
+ QString sRef;
+ QString sQuery;
+ QString sPath;
+
+
}; // class KURL ===============================================================
#endif
+
+#endif // USING_BORROWED_KURL
\ No newline at end of file
diff --git a/WebCore/kwq/qt/_qbuffer.cpp b/WebCore/kwq/qt/_qbuffer.cpp
new file mode 100644
index 0000000..801e51b
--- /dev/null
+++ b/WebCore/kwq/qt/_qbuffer.cpp
@@ -0,0 +1,482 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QBuffer 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QBUFFER
+
+// -------------------------------------------------------------------------
+
+#include "qbuffer.h"
+#include <stdlib.h>
+
+// REVISED: paul
+/*!
+ \class QBuffer qbuffer.h
+ \brief The QBuffer class is an I/O device that operates on a QByteArray
+
+ \ingroup io
+
+ QBuffer allows reading and writing a memory buffer. It is normally
+ used together with a QTextStream or a QDataStream. QBuffer has an
+ associated QByteArray which holds the buffer data. The size() of the
+ buffer is automatically adjusted as data is written.
+
+ The constructor \c QBuffer(QByteArray) creates a QBuffer with an
+ existing byte array. The byte array can also be set with setBuffer().
+ Writing to the QBuffer will modify the original byte array, since
+ QByteArray is \link shclass.html explicitly shared.\endlink
+
+ Use open() to open the buffer before use, and to set the mode
+ (read-only,write-only, etc.). close() closes the buffer. The buffer
+ must be closed before reopening or calling setBuffer().
+
+ The common way to use QBuffer is through \l QDataStream or \l QTextStream
+ which have constructors that take a QBuffer parameter. For
+ convenience, there are also QDataStream and QTextStream constructors
+ that take a QByteArray parameter. These constructors create and open
+ an internal QBuffer.
+
+ Note that QTextStream can also operate on a QString (a Unicode
+ string); a QBuffer cannot.
+
+ You can also use QBuffer directly through the standard QIODevice
+ functions readBlock(), writeBlock() readLine(), at(), getch(), putch() and
+ ungetch().
+
+ \sa QFile, QDataStream, QTextStream, QByteArray, \link shclass.html Shared Classes\endlink
+*/
+
+
+/*!
+ Constructs an empty buffer.
+*/
+
+QBuffer::QBuffer()
+{
+ setFlags( IO_Direct );
+ a_inc = 16; // initial increment
+ a_len = 0;
+ ioIndex = 0;
+}
+
+
+/*!
+ Constructs a buffer that operates on \a buf.
+ If you open the buffer in write mode (\c IO_WriteOnly or
+ \c IO_ReadWrite) and write something into the buffer, \a buf
+ will be modified.
+
+
+ Example:
+ \code
+ QCString str = "abc";
+ QBuffer b( str );
+ b.open( IO_WriteOnly );
+ b.at( 3 ); // position at \0
+ b.writeBlock( "def", 4 ); // write including \0
+ b.close();
+ // Now, str == "abcdef"
+ \endcode
+
+
+ \sa setBuffer()
+*/
+
+QBuffer::QBuffer( QByteArray buf ) : a(buf)
+{
+ setFlags( IO_Direct );
+ a_len = a.size();
+ a_inc = (a_len > 512) ? 512 : a_len; // initial increment
+ if ( a_inc < 16 )
+ a_inc = 16;
+ ioIndex = 0;
+}
+
+/*!
+ Destructs the buffer.
+*/
+
+QBuffer::~QBuffer()
+{
+}
+
+
+/*!
+ Replaces the buffer's contents with \a buf.
+
+ This may not be done when isOpen() is TRUE.
+
+ Note that if you open the buffer in write mode (\c IO_WriteOnly or
+ IO_ReadWrite) and write something into the buffer, \a buf is also
+ modified because QByteArray is an explicitly shared class.
+
+ \sa buffer(), open(), close()
+*/
+
+bool QBuffer::setBuffer( QByteArray buf )
+{
+ if ( isOpen() ) {
+#if defined(CHECK_STATE)
+ qWarning( "QBuffer::setBuffer: Buffer is open");
+#endif
+ return FALSE;
+ }
+ a = buf;
+ a_len = a.size();
+ a_inc = (a_len > 512) ? 512 : a_len; // initial increment
+ if ( a_inc < 16 )
+ a_inc = 16;
+ ioIndex = 0;
+ return TRUE;
+}
+
+/*!
+ \fn QByteArray QBuffer::buffer() const
+
+ Returns this buffer's byte array.
+
+ \sa setBuffer()
+*/
+
+/*!
+ \reimp
+ Opens the buffer in the mode \a m. Returns TRUE if successful,
+ otherwise FALSE. The buffer must be opened before use.
+
+ The mode parameter \a m must be a combination of the following flags.
+ <ul>
+ <li>\c IO_ReadOnly opens a buffer in read-only mode.
+ <li>\c IO_WriteOnly opens a buffer in write-only mode.
+ <li>\c IO_ReadWrite opens a buffer in read/write mode.
+ <li>\c IO_Append sets the buffer index to the end of the buffer.
+ <li>\c IO_Truncate truncates the buffer.
+ </ul>
+
+ \sa close(), isOpen()
+*/
+
+bool QBuffer::open( int m )
+{
+ if ( isOpen() ) { // buffer already open
+#if defined(CHECK_STATE)
+ qWarning( "QBuffer::open: Buffer already open" );
+#endif
+ return FALSE;
+ }
+ setMode( m );
+ if ( m & IO_Truncate ) { // truncate buffer
+ a.resize( 0 );
+ a_len = 0;
+ }
+ if ( m & IO_Append ) { // append to end of buffer
+ ioIndex = a.size();
+ } else {
+ ioIndex = 0;
+ }
+ a_inc = 16;
+ setState( IO_Open );
+ setStatus( 0 );
+ return TRUE;
+}
+
+/*!
+ \reimp
+ Closes an open buffer.
+ \sa open()
+*/
+
+void QBuffer::close()
+{
+ if ( isOpen() ) {
+ setFlags( IO_Direct );
+ ioIndex = 0;
+ a_inc = 16;
+ }
+}
+
+/*!
+ \reimp
+ The flush function does nothing for a QBuffer.
+*/
+
+void QBuffer::flush()
+{
+ return;
+}
+
+
+/*!
+ \fn int QBuffer::at() const
+ \reimp
+*/
+
+/*!
+ \fn uint QBuffer::size() const
+ \reimp
+*/
+
+/*!
+ \reimp
+*/
+
+bool QBuffer::at( int pos )
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) {
+ qWarning( "QBuffer::at: Buffer is not open" );
+ return FALSE;
+ }
+#endif
+ if ( (uint)pos > a_len ) {
+#if defined(CHECK_RANGE)
+ qWarning( "QBuffer::at: Index %d out of range", pos );
+#endif
+ return FALSE;
+ }
+ ioIndex = pos;
+ return TRUE;
+}
+
+
+/*!
+ \reimp
+*/
+
+int QBuffer::readBlock( char *p, uint len )
+{
+#if defined(CHECK_STATE)
+ CHECK_PTR( p );
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::readBlock: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::readBlock: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex + len > a.size() ) { // overflow
+ if ( (uint)ioIndex >= a.size() ) {
+ setStatus( IO_ReadError );
+ return -1;
+ } else {
+ len = a.size() - (uint)ioIndex;
+ }
+ }
+ memcpy( p, a.data()+ioIndex, len );
+ ioIndex += len;
+ return len;
+}
+
+/*!
+ \reimp
+
+ Writes \a len bytes from \a p into the buffer at the current index,
+ overwriting any characters there and extending the buffer if necessary.
+ Returns the number of bytes actually written.
+
+ Returns -1 if a serious error occurred.
+
+ \sa readBlock()
+*/
+
+int QBuffer::writeBlock( const char *p, uint len )
+{
+#if defined(CHECK_NULL)
+ if ( p == 0 && len != 0 )
+ qWarning( "QBuffer::writeBlock: Null pointer error" );
+#endif
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::writeBlock: Buffer not open" );
+ return -1;
+ }
+ if ( !isWritable() ) { // writing not permitted
+ qWarning( "QBuffer::writeBlock: Write operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex + len >= a_len ) { // overflow
+ uint new_len = a_len + a_inc*(((uint)ioIndex+len-a_len)/a_inc+1);
+ if ( !a.resize( new_len ) ) { // could not resize
+#if defined(CHECK_NULL)
+ qWarning( "QBuffer::writeBlock: Memory allocation error" );
+#endif
+ setStatus( IO_ResourceError );
+ return -1;
+ }
+ a_inc *= 2; // double increment
+ a_len = new_len;
+ a.shd->len = (uint)ioIndex + len;
+ }
+ memcpy( a.data()+ioIndex, p, len );
+ ioIndex += len;
+ if ( a.shd->len < (uint)ioIndex )
+ a.shd->len = (uint)ioIndex; // fake (not alloc'd) length
+ return len;
+}
+
+
+/*!
+ \reimp
+*/
+
+int QBuffer::readLine( char *p, uint maxlen )
+{
+#if defined(CHECK_STATE)
+ CHECK_PTR( p );
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::readLine: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::readLine: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( maxlen == 0 )
+ return 0;
+ uint start = (uint)ioIndex;
+ char *d = a.data() + ioIndex;
+ maxlen--; // make room for 0-terminator
+ if ( a.size() - (uint)ioIndex < maxlen )
+ maxlen = a.size() - (uint)ioIndex;
+ while ( maxlen-- ) {
+ if ( (*p++ = *d++) == '\n' )
+ break;
+ }
+ *p = '\0';
+ ioIndex = d - a.data();
+ return (uint)ioIndex - start;
+}
+
+
+/*!
+ \reimp
+*/
+
+int QBuffer::getch()
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::getch: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::getch: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex+1 > a.size() ) { // overflow
+ setStatus( IO_ReadError );
+ return -1;
+ }
+ return uchar(*(a.data()+ioIndex++));
+}
+
+/*!
+ \reimp
+ Writes the character \a ch into the buffer, overwriting
+ the character at the current index, extending the buffer
+ if necessary.
+
+ Returns \a ch, or -1 if some error occurred.
+
+ \sa getch(), ungetch()
+*/
+
+int QBuffer::putch( int ch )
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::putch: Buffer not open" );
+ return -1;
+ }
+ if ( !isWritable() ) { // writing not permitted
+ qWarning( "QBuffer::putch: Write operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex + 1 >= a_len ) { // overflow
+ char buf[1];
+ buf[0] = (char)ch;
+ if ( writeBlock(buf,1) != 1 )
+ return -1; // write error
+ } else {
+ *(a.data() + ioIndex++) = (char)ch;
+ if ( a.shd->len < (uint)ioIndex )
+ a.shd->len = (uint)ioIndex;
+ }
+ return ch;
+}
+
+/*!
+ \reimp
+*/
+
+int QBuffer::ungetch( int ch )
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::ungetch: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::ungetch: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( ch != -1 ) {
+ if ( ioIndex )
+ ioIndex--;
+ else
+ ch = -1;
+ }
+ return ch;
+}
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QBUFFER
+
+// -------------------------------------------------------------------------
+
diff --git a/WebCore/src/kwq/qt/_qsortedlist.h b/WebCore/kwq/qt/_qbuffer.h
similarity index 59%
copy from WebCore/src/kwq/qt/_qsortedlist.h
copy to WebCore/kwq/qt/_qbuffer.h
index 21f47b5..8187b44 100644
--- a/WebCore/src/kwq/qt/_qsortedlist.h
+++ b/WebCore/kwq/qt/_qbuffer.h
@@ -1,9 +1,9 @@
/****************************************************************************
** $Id$
**
-** Definition of QList template/macro class
+** Definition of QBuffer class
**
-** Created : 920701
+** Created : 930812
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
@@ -35,35 +35,64 @@
**
**********************************************************************/
-#ifndef QSORTEDLIST_H
-#define QSORTEDLIST_H
-
-// KWQ hacks ---------------------------------------------------------------
-
-#ifndef USING_BORROWED_QSORTEDLIST
-#define USING_BORROWED_QSORTEDLIST
-#endif
-
-#include <KWQDef.h>
-
-// -------------------------------------------------------------------------
+#ifndef QBUFFER_H
+#define QBUFFER_H
#ifndef QT_H
-#include "qlist.h"
+#include "_qiodevice.h"
+#include "qstring.h"
#endif // QT_H
-template<class type> class Q_EXPORT QSortedList : public QList<type>
+class Q_EXPORT QBuffer : public QIODevice
{
public:
- QSortedList() {}
- QSortedList( const QSortedList<type> &l ) : QList<type>(l) {}
- ~QSortedList() { clear(); }
- QSortedList<type> &operator=(const QSortedList<type> &l)
- { return (QSortedList<type>&)QList<type>::operator=(l); }
-
- virtual int compareItems( QCollection::Item s1, QCollection::Item s2 )
- { if ( *((type*)s1) == *((type*)s2) ) return 0; return ( *((type*)s1) < *((type*)s2) ? -1 : 1 ); }
-};
+ QBuffer();
+ QBuffer( QByteArray );
+ ~QBuffer();
+
+ QByteArray buffer() const;
+ bool setBuffer( QByteArray );
+
+ bool open( int );
+ void close();
+ void flush();
+
+ uint size() const;
+ int at() const;
+ bool at( int );
+
+ int readBlock( char *p, uint );
+ int writeBlock( const char *p, uint );
+ int readLine( char *p, uint );
+ int getch();
+ int putch( int );
+ int ungetch( int );
+
+protected:
+ QByteArray a;
+
+private:
+ uint a_len;
+ uint a_inc;
+
+private: // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ QBuffer( const QBuffer & );
+ QBuffer &operator=( const QBuffer & );
#endif
+};
+
+
+inline QByteArray QBuffer::buffer() const
+{ return a; }
+
+inline uint QBuffer::size() const
+{ return a.size(); }
+
+inline int QBuffer::at() const
+{ return ioIndex; }
+
+
+#endif // QBUFFER_H
diff --git a/WebCore/kwq/qt/_qdir.cpp b/WebCore/kwq/qt/_qdir.cpp
new file mode 100644
index 0000000..b481663
--- /dev/null
+++ b/WebCore/kwq/qt/_qdir.cpp
@@ -0,0 +1,1213 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QDir class
+**
+** Created : 950427
+**
+** 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+#include <qdir.h>
+
+// -------------------------------------------------------------------------
+
+#ifndef QT_NO_DIR
+#include "_qfileinfo.h"
+#include "qregexp.h"
+#include "qstringlist.h"
+#include <stdlib.h>
+#include <ctype.h>
+
+// NOT REVISED
+/*!
+ \class QDir qdir.h
+ \brief Traverses directory structures and contents in a
+ platform-independent way.
+
+ \ingroup io
+
+ A QDir can point to a file using either a relative or an absolute file
+ path. Absolute file paths begin with the directory separator ('/') or a
+ drive specification (not applicable to UNIX). Relative file names begin
+ with a directory name or a file name and specify a path relative to the
+ current directory.
+
+ An example of an absolute path is the string "/tmp/quartz", a relative
+ path might look like "src/fatlib". You can use the function isRelative()
+ to check if a QDir is using a relative or an absolute file path. You can
+ call the function convertToAbs() to convert a relative QDir to an
+ absolute one.
+
+ The directory "example" under the current directory is checked for existence
+ in the example below:
+
+ \code
+ QDir d( "example" ); // "./example"
+ if ( !d.exists() )
+ qWarning( "Cannot find the example directory" );
+ \endcode
+
+ If you always use '/' as a directory separator, Qt will translate your
+ paths to conform to the underlying operating system.
+
+ cd() and cdUp() can be used to navigate the directory tree. Note that the
+ logical cd and cdUp operations are not performed if the new directory does
+ not exist.
+
+ Example:
+ \code
+ QDir d = QDir::root(); // "/"
+ if ( !d.cd("tmp") ) { // "/tmp"
+ qWarning( "Cannot find the \"/tmp\" directory" );
+ } else {
+ QFile f( d.filePath("ex1.txt") ); // "/tmp/ex1.txt"
+ if ( !f.open(IO_ReadWrite) )
+ qWarning( "Cannot create the file %s", f.name() );
+ }
+ \endcode
+
+ To read the contents of a directory you can use the entryList() and
+ entryInfoList() functions.
+
+ Example:
+ \code
+ #include <stdio.h>
+ #include <qdir.h>
+
+ //
+ // This program scans the current directory and lists all files
+ // that are not symbolic links, sorted by size with the smallest files
+ // first.
+ //
+
+ int main( int argc, char **argv )
+ {
+ QDir d;
+ d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
+ d.setSorting( QDir::Size | QDir::Reversed );
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
+
+ printf( " BYTES FILENAME\n" ); // print header
+ while ( (fi=it.current()) ) { // for each file...
+ printf( "%10li %s\n", fi->size(), fi->fileName().data() );
+ ++it; // goto next list element
+ }
+ }
+ \endcode
+*/
+
+
+/*!
+ Constructs a QDir pointing to the current directory.
+ \sa currentDirPath()
+*/
+
+QDir::QDir()
+{
+ dPath = QString::fromLatin1(".");
+ init();
+}
+
+/*!
+ Constructs a QDir.
+
+ \arg \e path is the directory.
+ \arg \e nameFilter is the file name filter.
+ \arg \e sortSpec is the sort specification, which describes how to
+ sort the files in the directory.
+ \arg \e filterSpec is the filter specification, which describes how
+ to filter the files in the directory.
+
+ Most of these arguments (except \e path) have optional values.
+
+ Example:
+ \code
+ // lists all files in /tmp
+
+ QDir d( "/tmp" );
+ for ( int i=0; i<d.count(); i++ )
+ printf( "%s\n", d[i] );
+ \endcode
+
+ If \e path is "" or null, the directory is set to "." (the current
+ directory). If \e nameFilter is "" or null, it is set to "*" (all
+ files).
+
+ No check is made to ensure that the directory exists.
+
+ \sa exists(), setPath(), setNameFilter(), setFilter(), setSorting()
+*/
+
+QDir::QDir( const QString &path, const QString &nameFilter,
+ int sortSpec, int filterSpec )
+{
+ init();
+ dPath = cleanDirPath( path );
+ if ( dPath.isEmpty() )
+ dPath = QString::fromLatin1(".");
+ nameFilt = nameFilter;
+ if ( nameFilt.isEmpty() )
+ nameFilt = QString::fromLatin1("*");
+ filtS = (FilterSpec)filterSpec;
+ sortS = (SortSpec)sortSpec;
+}
+
+/*!
+ Constructs a QDir that is a copy of the given directory.
+ \sa operator=()
+*/
+
+QDir::QDir( const QDir &d )
+{
+ dPath = d.dPath;
+ fList = 0;
+ fiList = 0;
+ nameFilt = d.nameFilt;
+ dirty = TRUE;
+ allDirs = d.allDirs;
+ filtS = d.filtS;
+ sortS = d.sortS;
+}
+
+
+void QDir::init()
+{
+ fList = 0;
+ fiList = 0;
+ nameFilt = QString::fromLatin1("*");
+ dirty = TRUE;
+ allDirs = FALSE;
+ filtS = All;
+ sortS = SortSpec(Name | IgnoreCase);
+}
+
+/*!
+ Destructs the QDir and cleans up.
+*/
+
+QDir::~QDir()
+{
+ if ( fList )
+ delete fList;
+ if ( fiList )
+ delete fiList;
+}
+
+
+/*!
+ Sets the path of the directory. The path is cleaned of redundant ".", ".."
+ and multiple separators. No check is made to ensure that a directory
+ with this path exists.
+
+ The path can be either absolute or relative. Absolute paths begin with the
+ directory separator ('/') or a drive specification (not
+ applicable to UNIX).
+ Relative file names begin with a directory name or a file name and specify
+ a path relative to the current directory. An example of
+ an absolute path is the string "/tmp/quartz", a relative path might look like
+ "src/fatlib". You can use the function isRelative() to check if a QDir
+ is using a relative or an absolute file path. You can call the function
+ convertToAbs() to convert a relative QDir to an absolute one.
+
+ \sa path(), absPath(), exists(), cleanDirPath(), dirName(),
+ absFilePath(), isRelative(), convertToAbs()
+*/
+
+void QDir::setPath( const QString &path )
+{
+ dPath = cleanDirPath( path );
+ if ( dPath.isEmpty() )
+ dPath = QString::fromLatin1(".");
+ dirty = TRUE;
+}
+
+/*!
+ \fn QString QDir::path() const
+ Returns the path, this may contain symbolic links, but never contains
+ redundant ".", ".." or multiple separators.
+
+ The returned path can be either absolute or relative (see setPath()).
+
+ \sa setPath(), absPath(), exists(), cleanDirPath(), dirName(),
+ absFilePath(), convertSeparators()
+*/
+
+/*!
+ Returns the absolute (a path that starts with '/') path, which may
+ contain symbolic links, but never contains redundant ".", ".." or
+ multiple separators.
+
+ \sa setPath(), canonicalPath(), exists(), cleanDirPath(), dirName(),
+ absFilePath()
+*/
+
+QString QDir::absPath() const
+{
+ if ( QDir::isRelativePath(dPath) ) {
+ QString tmp = currentDirPath();
+ if ( tmp.right(1) != QString::fromLatin1("/") )
+ tmp += '/';
+ tmp += dPath;
+ return cleanDirPath( tmp );
+ } else {
+ return cleanDirPath( dPath );
+ }
+}
+
+/*!
+ Returns the name of the directory, this is NOT the same as the path, e.g.
+ a directory with the name "mail", might have the path "/var/spool/mail".
+ If the directory has no name (e.g. the root directory) a null string is
+ returned.
+
+ No check is made to ensure that a directory with this name actually exists.
+
+ \sa path(), absPath(), absFilePath(), exists(), QString::isNull()
+*/
+
+QString QDir::dirName() const
+{
+ int pos = dPath.findRev( '/' );
+ if ( pos == -1 )
+ return dPath;
+ return dPath.right( dPath.length() - pos - 1 );
+}
+
+/*!
+ Returns the path name of a file in the directory. Does NOT check if
+ the file actually exists in the directory. If the QDir is relative
+ the returned path name will also be relative. Redundant multiple separators
+ or "." and ".." directories in \e fileName will not be removed (see
+ cleanDirPath()).
+
+ If \e acceptAbsPath is TRUE a \e fileName starting with a separator
+ ('/') will be returned without change.
+ If \e acceptAbsPath is FALSE an absolute path will be appended to
+ the directory path.
+
+ \sa absFilePath(), isRelative(), canonicalPath()
+*/
+
+QString QDir::filePath( const QString &fileName,
+ bool acceptAbsPath ) const
+{
+ if ( acceptAbsPath && !isRelativePath(fileName) )
+ return QString(fileName);
+
+ QString tmp = dPath;
+ if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName &&
+ fileName[0] != '/') )
+ tmp += '/';
+ tmp += fileName;
+ return tmp;
+}
+
+/*!
+ Returns the absolute path name of a file in the directory. Does NOT check if
+ the file actually exists in the directory. Redundant multiple separators
+ or "." and ".." directories in \e fileName will NOT be removed (see
+ cleanDirPath()).
+
+ If \e acceptAbsPath is TRUE a \e fileName starting with a separator
+ ('/') will be returned without change.
+ if \e acceptAbsPath is FALSE an absolute path will be appended to
+ the directory path.
+
+ \sa filePath()
+*/
+
+QString QDir::absFilePath( const QString &fileName,
+ bool acceptAbsPath ) const
+{
+ if ( acceptAbsPath && !isRelativePath( fileName ) )
+ return fileName;
+
+ QString tmp = absPath();
+ if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName &&
+ fileName[0] != '/') )
+ tmp += '/';
+ tmp += fileName;
+ return tmp;
+}
+
+
+/*!
+ Converts the '/' separators in \a pathName to system native
+ separators. Returns the translated string.
+
+ On Windows, convertSeparators("c:/winnt/system32") returns
+ "c:\winnt\system32".
+
+ No conversion is done on UNIX.
+*/
+
+QString QDir::convertSeparators( const QString &pathName )
+{
+ QString n( pathName );
+#if defined(_OS_FATFS_) || defined(_OS_OS2EMX_)
+ for ( int i=0; i<(int)n.length(); i++ ) {
+ if ( n[i] == '/' )
+ n[i] = '\\';
+ }
+#endif
+ return n;
+}
+
+
+/*!
+ Changes directory by descending into the given directory. Returns
+ TRUE if the new directory exists and is readable. Note that the logical
+ cd operation is NOT performed if the new directory does not exist.
+
+ If \e acceptAbsPath is TRUE a path starting with a separator ('/')
+ will cd to the absolute directory, if \e acceptAbsPath is FALSE
+ any number of separators at the beginning of \e dirName will be removed.
+
+ Example:
+ \code
+ QDir d = QDir::home(); // now points to home directory
+ if ( !d.cd("c++") ) { // now points to "c++" under home directory if OK
+ QFileInfo fi( d, "c++" );
+ if ( fi.exists() ) {
+ if ( fi.isDir() )
+ qWarning( "Cannot cd into \"%s\".", (char*)d.absFilePath("c++") );
+ else
+ qWarning( "Cannot create directory \"%s\"\n"
+ "A file named \"c++\" already exists in \"%s\"",
+ (const char *)d.absFilePath("c++"),
+ (const char *)d.path() );
+ return;
+ } else {
+ qWarning( "Creating directory \"%s\"",
+ (const char *) d.absFilePath("c++") );
+ if ( !d.mkdir( "c++" ) ) {
+ qWarning("Could not create directory \"%s\"",
+ (const char *)d.absFilePath("c++") );
+ return;
+ }
+ }
+ }
+ \endcode
+
+ Calling cd( ".." ) is equivalent to calling cdUp().
+
+ \sa cdUp(), isReadable(), exists(), path()
+*/
+
+bool QDir::cd( const QString &dirName, bool acceptAbsPath )
+{
+ if ( dirName.isEmpty() || dirName==QString::fromLatin1(".") )
+ return TRUE;
+ QString old = dPath;
+ if ( acceptAbsPath && !isRelativePath(dirName) ) {
+ dPath = cleanDirPath( dirName );
+ } else {
+ if ( !isRoot() )
+ dPath += '/';
+ dPath += dirName;
+ if ( dirName.find('/') >= 0
+ || old == QString::fromLatin1(".")
+ || dirName == QString::fromLatin1("..") )
+ dPath = cleanDirPath( dPath );
+ }
+ if ( !exists() ) {
+ dPath = old; // regret
+ return FALSE;
+ }
+ dirty = TRUE;
+ return TRUE;
+}
+
+/*!
+ Changes directory by moving one directory up the path followed to arrive
+ at the current directory.
+
+ Returns TRUE if the new directory exists and is readable. Note that the
+ logical cdUp() operation is not performed if the new directory does not
+ exist.
+
+ \sa cd(), isReadable(), exists(), path()
+*/
+
+bool QDir::cdUp()
+{
+ return cd( QString::fromLatin1("..") );
+}
+
+/*!
+ \fn QString QDir::nameFilter() const
+ Returns the string set by setNameFilter()
+*/
+
+/*!
+ Sets the name filter used by entryList() and entryInfoList().
+
+ The name filter is a wildcarding filter that understands "*" and "?"
+ wildcards, You may specify several filter entries separated by a " " or a ";". If
+ you want entryList() and entryInfoList() to list all files ending with
+ ".cpp" and all files ending with ".h", you simply call
+ dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h")
+
+ \sa nameFilter(), setFilter()
+*/
+
+void QDir::setNameFilter( const QString &nameFilter )
+{
+ nameFilt = nameFilter;
+ if ( nameFilt.isEmpty() )
+ nameFilt = QString::fromLatin1("*");
+ dirty = TRUE;
+}
+
+/*!
+ \fn QDir::FilterSpec QDir::filter() const
+ Returns the value set by setFilter()
+*/
+
+/*! \enum QDir::FilterSpec
+
+ This enum describes how QDir is to select what entries in a
+ directory to return. The filter value is specified by or-ing
+ together values from the following list: <ul>
+
+ <li> \c Dirs - List directories only
+ <li> \c Files - List files only
+
+ <li> \c Drives - List disk drives (does nothing under unix)
+ <li> \c NoSymLinks - Do not list symbolic links (where they exist)
+ <li> \c Readable - List files for which the application has read access.
+ <li> \c Writable - List files for which the application has write access.
+ <li> \c Executable - List files for which the application has execute access
+ <li> \c Modified - Only list files that have been modified (does nothing
+ under unix)
+ <li> \c Hidden - List hidden files (on unix, files starting with a .)
+ <li> \c System - List system files (does nothing under unix)
+ </ul>
+
+ If you do not set any of \c Readable, \c Writable or \c Executable,
+ QDir will set all three of them. This makes the default easy to
+ write and at the same time useful.
+
+ Examples: \c Readable|Writable means list all files for which the
+ application has read access, write access or both. \c Dirs|Drives
+ means list drives, directories, all files that the application can
+ read, write or execute, and also symlinks to such files/directories.
+*/
+
+
+/*!
+ Sets the filter used by entryList() and entryInfoList(). The filter is used
+ to specify the kind of files that should be returned by entryList() and
+ entryInfoList().
+
+ \sa filter(), setNameFilter()
+*/
+
+void QDir::setFilter( int filterSpec )
+{
+ if ( filtS == (FilterSpec) filterSpec )
+ return;
+ filtS = (FilterSpec) filterSpec;
+ dirty = TRUE;
+}
+
+/*!
+ \fn QDir::SortSpec QDir::sorting() const
+
+ Returns the value set by setSorting()
+
+ \sa setSorting()
+*/
+
+/*! \enum QDir::SortSpec
+
+ This enum describes how QDir is to sort entries in a directory when
+ it returns a list of them. The sort value is specified by or-ing
+ together values from the following list: <ul>
+
+ <li> \c Name - sort by name
+ <li> \c Time - sort by time (modification time)
+ <li> \c Size - sort by file size
+ <li> \c Unsorted - do not sort
+
+ <li> \c DirsFirst - put all directories first in the list
+ <li> \c Reversed - reverse the sort order
+ <li> \c IgnoreCase - sort case-insensitively
+
+ </ul>
+
+ You can only specify one of the first four. If you specify both \c
+ DirsFirst and \c Reversed, directories are still put first but the
+ list is otherwise reversed.
+*/
+
+// ### Unsorted+DirsFirst ? Unsorted+Reversed?
+
+/*!
+ Sets the sorting order used by entryList() and entryInfoList().
+
+ The \e sortSpec is specified by or-ing values from the enum
+ SortSpec. The different values are:
+
+ One of these:
+ <dl compact>
+ <dt>Name<dd> Sort by name (alphabetical order).
+ <dt>Time<dd> Sort by time (most recent first).
+ <dt>Size<dd> Sort by size (largest first).
+ <dt>Unsorted<dd> Use the operating system order (UNIX does NOT sort
+ alphabetically).
+
+ ORed with zero or more of these:
+
+ <dt>DirsFirst<dd> Always put directory names first.
+ <dt>Reversed<dd> Reverse sort order.
+ <dt>IgnoreCase<dd> Ignore case when sorting by name.
+ </dl>
+*/
+
+void QDir::setSorting( int sortSpec )
+{
+ if ( sortS == (SortSpec) sortSpec )
+ return;
+ sortS = (SortSpec) sortSpec;
+ dirty = TRUE;
+}
+
+/*!
+ \fn bool QDir::matchAllDirs() const
+ Returns the value set by setMatchAllDirs()
+
+ \sa setMatchAllDirs()
+*/
+
+/*!
+ If \e enable is TRUE, all directories will be listed (even if they do not
+ match the filter or the name filter), otherwise only matched directories
+ will be listed.
+
+ \bug Currently, directories that do not match the filter will not be
+ included (the name filter will be ignored as expected).
+
+ \sa matchAllDirs()
+*/
+
+void QDir::setMatchAllDirs( bool enable )
+{
+ if ( (bool)allDirs == enable )
+ return;
+ allDirs = enable;
+ dirty = TRUE;
+}
+
+
+/*!
+ Returns the number of files that was found.
+ Equivalent to entryList().count().
+ \sa operator[](), entryList()
+*/
+
+uint QDir::count() const
+{
+ return entryList().count();
+}
+
+/*!
+ Returns the file name at position \e index in the list of found file
+ names.
+ Equivalent to entryList().at(index).
+
+ Returns null if the \e index is out of range or if the entryList()
+ function failed.
+
+ \sa count(), entryList()
+*/
+
+QString QDir::operator[]( int index ) const
+{
+ entryList();
+ return fList && index >= 0 && index < (int)fList->count() ?
+ (*fList)[index] : QString::null;
+}
+
+
+/*!
+ This function is included to easy porting from Qt 1.x to Qt 2.0,
+ it is the same as entryList(), but encodes the filenames as 8-bit
+ strings using QFile::encodedName().
+
+ It is more efficient to use entryList().
+*/
+QStrList QDir::encodedEntryList( int filterSpec, int sortSpec ) const
+{
+ QStrList r;
+ QStringList l = entryList(filterSpec,sortSpec);
+ for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
+ r.append( QFile::encodeName(*it) );
+ }
+ return r;
+}
+
+/*!
+ This function is included to easy porting from Qt 1.x to Qt 2.0,
+ it is the same as entryList(), but encodes the filenames as 8-bit
+ strings using QFile::encodedName().
+
+ It is more efficient to use entryList().
+*/
+QStrList QDir::encodedEntryList( const QString &nameFilter,
+ int filterSpec,
+ int sortSpec ) const
+{
+ QStrList r;
+ QStringList l = entryList(nameFilter,filterSpec,sortSpec);
+ for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
+ r.append( QFile::encodeName(*it) );
+ }
+ return r;
+}
+
+
+
+/*!
+ Returns a list of the names of all files and directories in the directory
+ indicated by the setSorting(), setFilter() and setNameFilter()
+ specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e filterSpec and \e sortSpec arguments.
+
+ Returns an empty list if the directory is unreadable or does not exist.
+
+ \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),
+ encodedEntryList()
+*/
+
+QStringList QDir::entryList( int filterSpec, int sortSpec ) const
+{
+ if ( !dirty && filterSpec == (int)DefaultFilter &&
+ sortSpec == (int)DefaultSort )
+ return *fList;
+ return entryList( nameFilt, filterSpec, sortSpec );
+}
+
+/*!
+ Returns a list of the names of all files and directories in the directory
+ indicated by the setSorting(), setFilter() and setNameFilter()
+ specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e nameFilter, \e filterSpec and \e sortSpec arguments.
+
+ Returns and empty list if the directory is unreadable or does not exist.
+
+ \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),
+ encodedEntryList()
+*/
+
+QStringList QDir::entryList( const QString &nameFilter,
+ int filterSpec, int sortSpec ) const
+{
+ if ( filterSpec == (int)DefaultFilter )
+ filterSpec = filtS;
+ if ( sortSpec == (int)DefaultSort )
+ sortSpec = sortS;
+ QDir *that = (QDir*)this; // mutable function
+ if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) )
+ return *that->fList;
+ else
+ return QStringList();
+}
+
+/*!
+ Returns a list of QFileInfo objects for all files and directories in
+ the directory pointed to using the setSorting(), setFilter() and
+ setNameFilter() specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e filterSpec and \e sortSpec arguments.
+
+ Returns 0 if the directory is unreadable or does not exist.
+
+ The returned pointer is a const pointer to a QFileInfoList. The list is
+ owned by the QDir object and will be reused on the next call to
+ entryInfoList() for the same QDir instance. If you want to keep the
+ entries of the list after a subsequent call to this function you will
+ need to copy them.
+
+ \sa entryList(), setNameFilter(), setSorting(), setFilter()
+*/
+
+const QFileInfoList *QDir::entryInfoList( int filterSpec, int sortSpec ) const
+{
+ if ( !dirty && filterSpec == (int)DefaultFilter &&
+ sortSpec == (int)DefaultSort )
+ return fiList;
+ return entryInfoList( nameFilt, filterSpec, sortSpec );
+}
+
+/*!
+ Returns a list of QFileInfo objects for all files and directories in
+ the directory pointed to using the setSorting(), setFilter() and
+ setNameFilter() specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e nameFilter, \e filterSpec and \e sortSpec arguments.
+
+ Returns 0 if the directory is unreadable or does not exist.
+
+ The returned pointer is a const pointer to a QFileInfoList. The list is
+ owned by the QDir object and will be reused on the next call to
+ entryInfoList() for the same QDir instance. If you want to keep the
+ entries of the list after a subsequent call to this function you will
+ need to copy them.
+
+ \sa entryList(), setNameFilter(), setSorting(), setFilter()
+*/
+
+const QFileInfoList *QDir::entryInfoList( const QString &nameFilter,
+ int filterSpec, int sortSpec ) const
+{
+ if ( filterSpec == (int)DefaultFilter )
+ filterSpec = filtS;
+ if ( sortSpec == (int)DefaultSort )
+ sortSpec = sortS;
+ QDir *that = (QDir*)this; // mutable function
+ if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) )
+ return that->fiList;
+ else
+ return 0;
+}
+
+/*!
+ Returns TRUE if the directory exists. (If a file with the same
+ name is found this function will of course return FALSE).
+
+ \sa QFileInfo::exists(), QFile::exists()
+*/
+
+bool QDir::exists() const
+{
+ QFileInfo fi( dPath );
+ return fi.exists() && fi.isDir();
+}
+
+/*!
+ Returns TRUE if the directory path is relative to the current directory,
+ FALSE if the path is absolute (e.g. under UNIX a path is relative if it
+ does not start with a '/').
+
+ According to Einstein this function should always return TRUE.
+
+ \sa convertToAbs()
+*/
+
+bool QDir::isRelative() const
+{
+ return isRelativePath( dPath );
+}
+
+/*!
+ Converts the directory path to an absolute path. If it is already
+ absolute nothing is done.
+
+ \sa isRelative()
+*/
+
+void QDir::convertToAbs()
+{
+ dPath = absPath();
+}
+
+/*!
+ Makes a copy of d and assigns it to this QDir.
+*/
+
+QDir &QDir::operator=( const QDir &d )
+{
+ dPath = d.dPath;
+ delete fList;
+ fList = 0;
+ delete fiList;
+ fiList = 0;
+ nameFilt = d.nameFilt;
+ dirty = TRUE;
+ allDirs = d.allDirs;
+ filtS = d.filtS;
+ sortS = d.sortS;
+ return *this;
+}
+
+/*!
+ Sets the directory path to be the given path.
+*/
+
+QDir &QDir::operator=( const QString &path )
+{
+ dPath = cleanDirPath( path );
+ dirty = TRUE;
+ return *this;
+}
+
+
+/*!
+ \fn bool QDir::operator!=( const QDir &d ) const
+ Returns TRUE if the \e d and this dir have different path or
+ different sort/filter settings, otherwise FALSE.
+*/
+
+/*!
+ Returns TRUE if the \e d and this dir have the same path and all sort
+ and filter settings are equal, otherwise FALSE.
+*/
+
+bool QDir::operator==( const QDir &d ) const
+{
+ return dPath == d.dPath &&
+ nameFilt == d.nameFilt &&
+ allDirs == d.allDirs &&
+ filtS == d.filtS &&
+ sortS == d.sortS;
+}
+
+
+/*!
+ Removes a file.
+
+ If \e acceptAbsPath is TRUE a path starting with a separator ('/')
+ will remove the file with the absolute path, if \e acceptAbsPath is FALSE
+ any number of separators at the beginning of \e fileName will be removed.
+
+ Returns TRUE if successful, otherwise FALSE.
+*/
+
+bool QDir::remove( const QString &fileName, bool acceptAbsPath )
+{
+ if ( fileName.isEmpty() ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::remove: Empty or null file name" );
+#endif
+ return FALSE;
+ }
+ QString p = filePath( fileName, acceptAbsPath );
+ return QFile::remove( p );
+}
+
+/*!
+ Checks for existence of a file.
+
+ If \e acceptAbsPaths is TRUE a path starting with a separator ('/')
+ will check the file with the absolute path, if \e acceptAbsPath is FALSE
+ any number of separators at the beginning of \e name will be removed.
+
+ Returns TRUE if the file exists, otherwise FALSE.
+
+ \sa QFileInfo::exists(), QFile::exists()
+*/
+
+bool QDir::exists( const QString &name, bool acceptAbsPath )
+{
+ if ( name.isEmpty() ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::exists: Empty or null file name" );
+#endif
+ return FALSE;
+ }
+ QString tmp = filePath( name, acceptAbsPath );
+ return QFile::exists( tmp );
+}
+
+/*!
+ Returns the native directory separator; '/' under UNIX and '\' under
+ MS-DOS, Windows NT and OS/2.
+
+ You do not need to use this function to build file paths. If you always
+ use '/', Qt will translate your paths to conform to the underlying
+ operating system.
+*/
+
+char QDir::separator()
+{
+#if defined(_OS_UNIX_)
+ return '/';
+#elif defined (_OS_FATFS_)
+ return '\\';
+#elif defined (_OS_MAC_)
+ return ':';
+#else
+ return '/';
+#endif
+}
+
+/*!
+ Returns the current directory.
+ \sa currentDirPath(), QDir::QDir()
+*/
+
+QDir QDir::current()
+{
+ return QDir( currentDirPath() );
+}
+
+/*!
+ Returns the home directory.
+ \sa homeDirPath()
+*/
+
+QDir QDir::home()
+{
+ return QDir( homeDirPath() );
+}
+
+/*!
+ Returns the root directory.
+ \sa rootDirPath() drives()
+*/
+
+QDir QDir::root()
+{
+ return QDir( rootDirPath() );
+}
+
+/*!
+ \fn QString QDir::homeDirPath()
+
+ Returns the absolute path for the user's home directory,
+ \sa home()
+*/
+
+QStringList qt_makeFilterList( const QString &filter )
+{
+ if ( filter.isEmpty() )
+ return QStringList();
+
+ QChar sep( ';' );
+ int i = filter.find( sep, 0 );
+ if ( i == -1 && filter.find( ' ', 0 ) != -1 )
+ sep = QChar( ' ' );
+
+ QStringList lst = QStringList::split( sep, filter );
+ QStringList lst2;
+ QStringList::Iterator it = lst.begin();
+
+ for ( ; it != lst.end(); ++it ) {
+ QString s = *it;
+ lst2 << s.stripWhiteSpace();
+ }
+ return lst2;
+}
+
+/*!
+ Returns TRUE if the \e fileName matches one of the wildcards in the list \e filters.
+ \sa QRegExp
+*/
+
+bool QDir::match( const QStringList &filters, const QString &fileName )
+{
+ QStringList::ConstIterator sit = filters.begin();
+ bool matched = FALSE;
+ for ( ; sit != filters.end(); ++sit ) {
+ QRegExp regexp( *sit, FALSE, TRUE );
+ if ( regexp.match( fileName ) != -1 ) {
+ matched = TRUE;
+ break;
+ }
+ }
+
+ return matched;
+}
+
+/*!
+ Returns TRUE if the \e fileName matches the wildcard \e filter.
+ \a Filter may also contain multiple wildcards separated by spaces or
+ semicolons.
+ \sa QRegExp
+*/
+
+bool QDir::match( const QString &filter, const QString &fileName )
+{
+ QStringList lst = qt_makeFilterList( filter );
+ return match( lst, fileName );
+}
+
+
+/*!
+ Removes all multiple directory separators ('/') and resolves
+ any "." or ".." found in the path.
+
+ Symbolic links are kept. This function does not return the
+ canonical path, but rather the most simplified version of the input.
+ "../stuff" becomes "stuff", "stuff/../nonsense" becomes "nonsense"
+ and "\\stuff\\more\\..\\nonsense" becomes "\\stuff\\nonsense".
+
+ \sa absPath() canonicalPath()
+*/
+
+QString QDir::cleanDirPath( const QString &filePath )
+{
+ QString name = filePath;
+ QString newPath;
+
+ if ( name.isEmpty() )
+ return name;
+
+ slashify( name );
+
+ bool addedSeparator;
+ if ( isRelativePath(name) ) {
+ addedSeparator = TRUE;
+ name.insert( 0, '/' );
+ } else {
+ addedSeparator = FALSE;
+ }
+
+ int ePos, pos, upLevel;
+
+ pos = ePos = name.length();
+ upLevel = 0;
+ int len;
+
+ while ( pos && (pos = name.findRev('/',--pos)) != -1 ) {
+ len = ePos - pos - 1;
+ if ( len == 2 && name.at(pos + 1) == '.'
+ && name.at(pos + 2) == '.' ) {
+ upLevel++;
+ } else {
+ if ( len != 0 && (len != 1 || name.at(pos + 1) != '.') ) {
+ if ( !upLevel )
+ newPath = QString::fromLatin1("/")
+ + name.mid(pos + 1, len) + newPath;
+ else
+ upLevel--;
+ }
+ }
+ ePos = pos;
+ }
+ if ( addedSeparator ) {
+ while ( upLevel-- )
+ newPath.insert( 0, QString::fromLatin1("/..") );
+ if ( !newPath.isEmpty() )
+ newPath.remove( 0, 1 );
+ else
+ newPath = QString::fromLatin1(".");
+ } else {
+ if ( newPath.isEmpty() )
+ newPath = QString::fromLatin1("/");
+#if defined(_OS_FATFS_) || defined(_OS_OS2EMX_)
+ if ( name[0] == '/' ) {
+ if ( name[1] == '/' ) // "\\machine\x\ ..."
+ newPath.insert( 0, '/' );
+ } else {
+ newPath = name.left(2) + newPath;
+ }
+#endif
+ }
+ return newPath;
+}
+
+int qt_cmp_si_sortSpec;
+
+#if defined(Q_C_CALLBACKS)
+extern "C" {
+#endif
+
+int qt_cmp_si( const void *n1, const void *n2 )
+{
+ if ( !n1 || !n2 )
+ return 0;
+
+ QDirSortItem* f1 = (QDirSortItem*)n1;
+ QDirSortItem* f2 = (QDirSortItem*)n2;
+
+ if ( qt_cmp_si_sortSpec & QDir::DirsFirst )
+ if ( f1->item->isDir() != f2->item->isDir() )
+ return f1->item->isDir() ? -1 : 1;
+
+ int r = 0;
+ int sortBy = qt_cmp_si_sortSpec & QDir::SortByMask;
+
+ switch ( sortBy ) {
+ case QDir::Time:
+ r = f1->item->lastModified().secsTo(f2->item->lastModified());
+ break;
+ case QDir::Size:
+ r = f2->item->size() - f1->item->size();
+ break;
+ default:
+ ;
+ }
+
+ if ( r == 0 && sortBy != QDir::Unsorted ) {
+ // Still not sorted - sort by name
+ bool ic = qt_cmp_si_sortSpec & QDir::IgnoreCase;
+
+ if ( f1->filename_cache.isNull() )
+ f1->filename_cache = ic ? f1->item->fileName().lower()
+ : f1->item->fileName();
+ if ( f2->filename_cache.isNull() )
+ f2->filename_cache = ic ? f2->item->fileName().lower()
+ : f2->item->fileName();
+
+ r = f1->filename_cache.compare(f2->filename_cache);
+ }
+
+ if ( r == 0 ) {
+ // Enforce an order - the order the items appear in the array
+ r = (char*)n1 - (char*)n2;
+ }
+
+ if ( qt_cmp_si_sortSpec & QDir::Reversed )
+ return -r;
+ else
+ return r;
+}
+
+#if defined(Q_C_CALLBACKS)
+}
+#endif
+
+#endif // QT_NO_DIR
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/kwq/qt/_qdir.h b/WebCore/kwq/qt/_qdir.h
new file mode 100644
index 0000000..3766c47
--- /dev/null
+++ b/WebCore/kwq/qt/_qdir.h
@@ -0,0 +1,235 @@
+/****************************************************************************
+** $Id$
+**
+** Definition of QDir class
+**
+** Created : 950427
+**
+** 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.
+**
+**********************************************************************/
+
+#ifndef QDIR_H
+#define QDIR_H
+
+#ifndef QT_H
+#include "_qstrlist.h"
+#include "_qfileinfo.h"
+#endif // QT_H
+
+#ifndef QT_NO_DIR
+typedef QList<QFileInfo> QFileInfoList;
+typedef QListIterator<QFileInfo> QFileInfoListIterator;
+class QStringList;
+
+
+class Q_EXPORT QDir
+{
+public:
+ enum FilterSpec { Dirs = 0x001,
+ Files = 0x002,
+ Drives = 0x004,
+ NoSymLinks = 0x008,
+ All = 0x007,
+ TypeMask = 0x00F,
+
+ Readable = 0x010,
+ Writable = 0x020,
+ Executable = 0x040,
+ RWEMask = 0x070,
+
+ Modified = 0x080,
+ Hidden = 0x100,
+ System = 0x200,
+ AccessMask = 0x3F0,
+
+ DefaultFilter = -1 };
+
+ enum SortSpec { Name = 0x00,
+ Time = 0x01,
+ Size = 0x02,
+ Unsorted = 0x03,
+ SortByMask = 0x03,
+
+ DirsFirst = 0x04,
+ Reversed = 0x08,
+ IgnoreCase = 0x10,
+ DefaultSort = -1 };
+
+ QDir();
+ QDir( const QString &path, const QString &nameFilter = QString::null,
+ int sortSpec = Name | IgnoreCase, int filterSpec = All );
+ QDir( const QDir & );
+
+ virtual ~QDir();
+
+ QDir &operator=( const QDir & );
+ QDir &operator=( const QString &path );
+
+ virtual void setPath( const QString &path );
+ virtual QString path() const;
+ virtual QString absPath() const;
+ virtual QString canonicalPath() const;
+
+ virtual QString dirName() const;
+ virtual QString filePath( const QString &fileName,
+ bool acceptAbsPath = TRUE ) const;
+ virtual QString absFilePath( const QString &fileName,
+ bool acceptAbsPath = TRUE ) const;
+
+ static QString convertSeparators( const QString &pathName );
+
+ virtual bool cd( const QString &dirName, bool acceptAbsPath = TRUE );
+ virtual bool cdUp();
+
+ QString nameFilter() const;
+ virtual void setNameFilter( const QString &nameFilter );
+ FilterSpec filter() const;
+ virtual void setFilter( int filterSpec );
+ SortSpec sorting() const;
+ virtual void setSorting( int sortSpec );
+
+ bool matchAllDirs() const;
+ virtual void setMatchAllDirs( bool );
+
+ uint count() const;
+ QString operator[]( int ) const;
+
+ virtual QStrList encodedEntryList( int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual QStrList encodedEntryList( const QString &nameFilter,
+ int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual QStringList entryList( int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual QStringList entryList( const QString &nameFilter,
+ int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+
+ virtual const QFileInfoList *entryInfoList( int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual const QFileInfoList *entryInfoList( const QString &nameFilter,
+ int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+
+ static const QFileInfoList *drives();
+
+ virtual bool mkdir( const QString &dirName,
+ bool acceptAbsPath = TRUE ) const;
+ virtual bool rmdir( const QString &dirName,
+ bool acceptAbsPath = TRUE ) const;
+
+ virtual bool isReadable() const;
+ virtual bool exists() const;
+ virtual bool isRoot() const;
+
+ virtual bool isRelative() const;
+ virtual void convertToAbs();
+
+ virtual bool operator==( const QDir & ) const;
+ virtual bool operator!=( const QDir & ) const;
+
+ virtual bool remove( const QString &fileName,
+ bool acceptAbsPath = TRUE );
+ virtual bool rename( const QString &name, const QString &newName,
+ bool acceptAbsPaths = TRUE );
+ virtual bool exists( const QString &name,
+ bool acceptAbsPath = TRUE );
+
+ static char separator();
+
+ static bool setCurrent( const QString &path );
+ static QDir current();
+ static QDir home();
+ static QDir root();
+ static QString currentDirPath();
+ static QString homeDirPath();
+ static QString rootDirPath();
+
+ static bool match( const QStringList &filters, const QString &fileName );
+ static bool match( const QString &filter, const QString &fileName );
+ static QString cleanDirPath( const QString &dirPath );
+ static bool isRelativePath( const QString &path );
+
+private:
+ void init();
+ virtual bool readDirEntries( const QString &nameFilter,
+ int FilterSpec, int SortSpec );
+
+ static void slashify ( QString &);
+
+ QString dPath;
+ QStringList *fList;
+ QFileInfoList *fiList;
+ QString nameFilt;
+ FilterSpec filtS;
+ SortSpec sortS;
+ uint dirty : 1;
+ uint allDirs : 1;
+};
+
+
+inline QString QDir::path() const
+{
+ return dPath;
+}
+
+inline QString QDir::nameFilter() const
+{
+ return nameFilt;
+}
+
+inline QDir::FilterSpec QDir::filter() const
+{
+ return filtS;
+}
+
+inline QDir::SortSpec QDir::sorting() const
+{
+ return sortS;
+}
+
+inline bool QDir::matchAllDirs() const
+{
+ return allDirs;
+}
+
+inline bool QDir::operator!=( const QDir &d ) const
+{
+ return !(*this == d);
+}
+
+
+struct QDirSortItem {
+ QString filename_cache;
+ QFileInfo* item;
+};
+
+#endif // QT_NO_DIR
+#endif // QDIR_H
diff --git a/WebCore/kwq/qt/_qdir_unix.cpp b/WebCore/kwq/qt/_qdir_unix.cpp
new file mode 100644
index 0000000..fdc18ad
--- /dev/null
+++ b/WebCore/kwq/qt/_qdir_unix.cpp
@@ -0,0 +1,301 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QDirclass
+**
+** Created : 950628
+**
+** 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 for Unix/X11 or for Qt/Embedded 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
+
+#include "_qdir.h"
+#ifndef QT_NO_DIR
+
+#include "_qfileinfo.h"
+#include "qregexp.h"
+#include "qstringlist.h"
+#include <stdlib.h>
+#include <ctype.h>
+
+extern QStringList qt_makeFilterList( const QString &filter );
+
+extern int qt_cmp_si_sortSpec;
+
+#if defined(Q_C_CALLBACKS)
+extern "C" {
+#endif
+
+extern int qt_cmp_si( const void *, const void * );
+
+#if defined(Q_C_CALLBACKS)
+}
+#endif
+
+
+void QDir::slashify( QString& )
+{
+}
+
+QString QDir::homeDirPath()
+{
+ QString d;
+ d = QFile::decodeName(getenv("HOME"));
+ slashify( d );
+ if ( d.isNull() )
+ d = rootDirPath();
+ return d;
+}
+
+QString QDir::canonicalPath() const
+{
+ QString r;
+
+ char cur[PATH_MAX];
+ char tmp[PATH_MAX];
+ GETCWD( cur, PATH_MAX );
+ if ( CHDIR(QFile::encodeName(dPath)) >= 0 ) {
+ GETCWD( tmp, PATH_MAX );
+ r = QFile::decodeName(tmp);
+ }
+ CHDIR( cur );
+
+ slashify( r );
+ return r;
+}
+
+bool QDir::mkdir( const QString &dirName, bool acceptAbsPath ) const
+{
+ return MKDIR( QFile::encodeName(filePath(dirName,acceptAbsPath)), 0777 )
+ == 0;
+}
+
+bool QDir::rmdir( const QString &dirName, bool acceptAbsPath ) const
+{
+ return RMDIR( QFile::encodeName(filePath(dirName,acceptAbsPath)) ) == 0;
+}
+
+bool QDir::isReadable() const
+{
+ return ACCESS( QFile::encodeName(dPath), R_OK | X_OK ) == 0;
+}
+
+bool QDir::isRoot() const
+{
+ return dPath == QString::fromLatin1("/");
+}
+
+bool QDir::rename( const QString &name, const QString &newName,
+ bool acceptAbsPaths )
+{
+ if ( name.isEmpty() || newName.isEmpty() ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::rename: Empty or null file name(s)" );
+#endif
+ return FALSE;
+ }
+ QString fn1 = filePath( name, acceptAbsPaths );
+ QString fn2 = filePath( newName, acceptAbsPaths );
+ return ::rename( QFile::encodeName(fn1),
+ QFile::encodeName(fn2) ) == 0;
+}
+
+bool QDir::setCurrent( const QString &path )
+{
+ int r;
+ r = CHDIR( QFile::encodeName(path) );
+ return r >= 0;
+}
+
+QString QDir::currentDirPath()
+{
+ QString result;
+
+ STATBUF st;
+ if ( STAT( ".", &st ) == 0 ) {
+ char currentName[PATH_MAX];
+ if ( GETCWD( currentName, PATH_MAX ) != 0 )
+ result = QFile::decodeName(currentName);
+#if defined(DEBUG)
+ if ( result.isNull() )
+ qWarning( "QDir::currentDirPath: getcwd() failed" );
+#endif
+ } else {
+#if defined(DEBUG)
+ qWarning( "QDir::currentDirPath: stat(\".\") failed" );
+#endif
+ }
+ slashify( result );
+ return result;
+}
+
+QString QDir::rootDirPath()
+{
+ QString d = QString::fromLatin1( "/" );
+ return d;
+}
+
+bool QDir::isRelativePath( const QString &path )
+{
+ int len = path.length();
+ if ( len == 0 )
+ return TRUE;
+ return path[0] != '/';
+}
+
+bool QDir::readDirEntries( const QString &nameFilter,
+ int filterSpec, int sortSpec )
+{
+ int i;
+ if ( !fList ) {
+ fList = new QStringList;
+ CHECK_PTR( fList );
+ fiList = new QFileInfoList;
+ CHECK_PTR( fiList );
+ fiList->setAutoDelete( TRUE );
+ } else {
+ fList->clear();
+ fiList->clear();
+ }
+
+ QStringList filters = qt_makeFilterList( nameFilter );
+
+ bool doDirs = (filterSpec & Dirs) != 0;
+ bool doFiles = (filterSpec & Files) != 0;
+ bool noSymLinks = (filterSpec & NoSymLinks) != 0;
+ bool doReadable = (filterSpec & Readable) != 0;
+ bool doWritable = (filterSpec & Writable) != 0;
+ bool doExecable = (filterSpec & Executable) != 0;
+ bool doHidden = (filterSpec & Hidden) != 0;
+
+#if defined(_OS_OS2EMX_)
+ //QRegExp wc( nameFilter, FALSE, TRUE ); // wild card, case insensitive
+#else
+ //QRegExp wc( nameFilter, TRUE, TRUE ); // wild card, case sensitive
+#endif
+ QFileInfo fi;
+ DIR *dir;
+ dirent *file;
+
+ dir = opendir( QFile::encodeName(dPath) );
+ if ( !dir ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::readDirEntries: Cannot read the directory: %s",
+ QFile::encodeName(dPath).data() );
+#endif
+ return FALSE;
+ }
+
+ while ( (file = readdir(dir)) ) {
+ QString fn = QFile::decodeName(file->d_name);
+ fi.setFile( *this, fn );
+ if ( !match( filters, fn ) && !(allDirs && fi.isDir()) )
+ continue;
+ if ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) ) {
+ if ( noSymLinks && fi.isSymLink() )
+ continue;
+ if ( (filterSpec & RWEMask) != 0 )
+ if ( (doReadable && !fi.isReadable()) ||
+ (doWritable && !fi.isWritable()) ||
+ (doExecable && !fi.isExecutable()) )
+ continue;
+ if ( !doHidden && fn[0] == '.' &&
+ fn != QString::fromLatin1(".")
+ && fn != QString::fromLatin1("..") )
+ continue;
+ fiList->append( new QFileInfo( fi ) );
+ }
+ }
+ if ( closedir(dir) != 0 ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::readDirEntries: Cannot close the directory: %s",
+ dPath.local8Bit().data() );
+#endif
+ }
+
+ // Sort...
+ if(fiList->count()) {
+ QDirSortItem* si= new QDirSortItem[fiList->count()];
+ QFileInfo* itm;
+ i=0;
+ for (itm = fiList->first(); itm; itm = fiList->next())
+ si[i++].item = itm;
+ qt_cmp_si_sortSpec = sortSpec;
+ qsort( si, i, sizeof(si[0]), qt_cmp_si );
+ // put them back in the list
+ fiList->setAutoDelete( FALSE );
+ fiList->clear();
+ int j;
+ for ( j=0; j<i; j++ ) {
+ fiList->append( si[j].item );
+ fList->append( si[j].item->fileName() );
+ }
+ delete [] si;
+ fiList->setAutoDelete( TRUE );
+ }
+
+ if ( filterSpec == (FilterSpec)filtS && sortSpec == (SortSpec)sortS &&
+ nameFilter == nameFilt )
+ dirty = FALSE;
+ else
+ dirty = TRUE;
+ return TRUE;
+}
+
+const QFileInfoList * QDir::drives()
+{
+ // at most one instance of QFileInfoList is leaked, and this variable
+ // points to that list
+ static QFileInfoList * knownMemoryLeak = 0;
+
+ if ( !knownMemoryLeak ) {
+ knownMemoryLeak = new QFileInfoList;
+ // non-win32 versions both use just one root directory
+ knownMemoryLeak->append( new QFileInfo( rootDirPath() ) );
+ }
+
+ return knownMemoryLeak;
+}
+#endif //QT_NO_DIR
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/kwq/qt/_qfileinfo.cpp b/WebCore/kwq/qt/_qfileinfo.cpp
new file mode 100644
index 0000000..ddf20c0
--- /dev/null
+++ b/WebCore/kwq/qt/_qfileinfo.cpp
@@ -0,0 +1,471 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QFileInfo class
+**
+** Created : 950628
+**
+** 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
+
+#include "_qfileinfo.h"
+#include "qdatetime.h"
+#include "_qdir.h"
+
+extern bool qt_file_access( const QString& fn, int t );
+
+// NOT REVISED
+/*!
+ \class QFileInfo qfileinfo.h
+ \brief The QFileInfo class provides system-independent file information.
+
+ \ingroup io
+
+ QFileInfo provides information about a file's name and position (path) in
+ the file system, its access rights and whether it is a directory or a
+ symbolic link. Its size and last modified/read times are also available.
+
+ To speed up performance QFileInfo caches information about the file. Since
+ files can be changed by other users or programs, or even by other parts of
+ the same program there is a function that refreshes the file information;
+ refresh(). If you would rather like a QFileInfo to access the file system
+ every time you request information from it, you can call the function
+ setCaching( FALSE ).
+
+ A QFileInfo can point to a file using either a relative or an absolute
+ file path. Absolute file paths begin with the directory separator
+ ('/') or a drive specification (not applicable to UNIX).
+ Relative file names begin with a directory name or a file name and specify
+ a path relative to the current directory. An example of
+ an absolute path is the string "/tmp/quartz". A relative path might look like
+ "src/fatlib". You can use the function isRelative() to check if a QFileInfo
+ is using a relative or an absolute file path. You can call the function
+ convertToAbs() to convert a relative QFileInfo to an absolute one.
+
+ If you need to read and traverse directories, see the QDir class.
+*/
+
+
+/*!
+ Constructs a new empty QFileInfo.
+*/
+
+QFileInfo::QFileInfo()
+{
+ fic = 0;
+ cache = TRUE;
+}
+
+/*!
+ Constructs a new QFileInfo that gives information about the given file.
+ The string given can be an absolute or a relative file path.
+
+ \sa bool setFile(QString ), isRelative(), QDir::setCurrent(),
+ QDir::isRelativePath()
+*/
+
+QFileInfo::QFileInfo( const QString &file )
+{
+ fn = file;
+ slashify( fn );
+ fic = 0;
+ cache = TRUE;
+}
+
+/*!
+ Constructs a new QFileInfo that gives information about \e file.
+
+ If the file has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+
+QFileInfo::QFileInfo( const QFile &file )
+{
+ fn = file.name();
+ slashify( fn );
+ fic = 0;
+ cache = TRUE;
+}
+
+/*!
+ Constructs a new QFileInfo that gives information about the file
+ named \e fileName in the directory \e d.
+
+ If the directory has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+#ifndef QT_NO_DIR
+QFileInfo::QFileInfo( const QDir &d, const QString &fileName )
+{
+ fn = d.filePath( fileName );
+ slashify( fn );
+ fic = 0;
+ cache = TRUE;
+}
+#endif
+/*!
+ Constructs a new QFileInfo that is a copy of \e fi.
+*/
+
+QFileInfo::QFileInfo( const QFileInfo &fi )
+{
+ fn = fi.fn;
+ if ( fi.fic ) {
+ fic = new QFileInfoCache;
+ *fic = *fi.fic;
+ } else {
+ fic = 0;
+ }
+ cache = fi.cache;
+}
+
+/*!
+ Destructs the QFileInfo.
+*/
+
+QFileInfo::~QFileInfo()
+{
+ delete fic;
+}
+
+
+/*!
+ Makes a copy of \e fi and assigns it to this QFileInfo.
+*/
+
+QFileInfo &QFileInfo::operator=( const QFileInfo &fi )
+{
+ fn = fi.fn;
+ if ( !fi.fic ) {
+ delete fic;
+ fic = 0;
+ } else {
+ if ( !fic ) {
+ fic = new QFileInfoCache;
+ CHECK_PTR( fic );
+ }
+ *fic = *fi.fic;
+ }
+ cache = fi.cache;
+ return *this;
+}
+
+
+/*!
+ Sets the file to obtain information about.
+
+ The string given can be an absolute or a relative file path. Absolute file
+ paths begin with the directory separator (e.g. '/' under UNIX) or a drive
+ specification (not applicable to UNIX). Relative file names begin with a
+ directory name or a file name and specify a path relative to the current
+ directory.
+
+ Example:
+ \code
+ #include <qfileinfo.h>
+ #include <qdir.h>
+
+ void test()
+ {
+ QString absolute = "/liver/aorta";
+ QString relative = "liver/aorta";
+ QFileInfo fi1( absolute );
+ QFileInfo fi2( relative );
+
+ QDir::setCurrent( QDir::rootDirPath() );
+ // fi1 and fi2 now point to the same file
+
+ QDir::setCurrent( "/tmp" );
+ // fi1 now points to "/liver/aorta",
+ // while fi2 points to "/tmp/liver/aorta"
+ }
+ \endcode
+
+ \sa isRelative(), QDir::setCurrent(), QDir::isRelativePath()
+*/
+
+void QFileInfo::setFile( const QString &file )
+{
+ fn = file;
+ slashify( fn );
+ delete fic;
+ fic = 0;
+}
+
+/*!
+ Sets the file to obtain information about.
+
+ If the file has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+
+void QFileInfo::setFile( const QFile &file )
+{
+ fn = file.name();
+ slashify( fn );
+ delete fic;
+ fic = 0;
+}
+
+/*!
+ Sets the file to obtains information about to \e fileName in the
+ directory \e d.
+
+ If the directory has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+#ifndef QT_NO_DIR
+void QFileInfo::setFile( const QDir &d, const QString &fileName )
+{
+ fn = d.filePath( fileName );
+ slashify( fn );
+ delete fic;
+ fic = 0;
+}
+#endif
+
+/*!
+ Returns TRUE if the file pointed to exists, otherwise FALSE.
+*/
+
+bool QFileInfo::exists() const
+{
+ return qt_file_access( fn, F_OK );
+}
+
+/*!
+ Refresh the information about the file, i.e. read in information from the
+ file system the next time a cached property is fetched.
+
+ \sa setCaching()
+*/
+
+void QFileInfo::refresh() const
+{
+ QFileInfo *that = (QFileInfo*)this; // Mutable function
+ delete that->fic;
+ that->fic = 0;
+}
+
+/*!
+ \fn bool QFileInfo::caching() const
+ Returns TRUE if caching is enabled.
+ \sa setCaching(), refresh()
+*/
+
+/*!
+ Enables caching of file information if \e enable is TRUE, or disables it
+ if \e enable is FALSE.
+
+ When caching is enabled, QFileInfo reads the file information the first
+ time
+
+ Caching is enabled by default.
+
+ \sa refresh(), caching()
+*/
+
+void QFileInfo::setCaching( bool enable )
+{
+ if ( cache == enable )
+ return;
+ cache = enable;
+ if ( cache ) {
+ delete fic;
+ fic = 0;
+ }
+}
+
+
+/*!
+ Returns the name, i.e. the file name including the path (which can be
+ absolute or relative).
+
+ \sa isRelative(), absFilePath()
+*/
+
+QString QFileInfo::filePath() const
+{
+ return fn;
+}
+
+/*!
+ Returns the base name of the file.
+
+ The base name consists of all characters in the file name up to (but not
+ including) the first '.' character. The path is not included.
+
+ Example:
+ \code
+ QFileInfo fi( "/tmp/abdomen.lower" );
+ QString base = fi.baseName(); // base = "abdomen"
+ \endcode
+
+ \sa fileName(), extension()
+*/
+
+QString QFileInfo::baseName() const
+{
+ QString tmp = fileName();
+ int pos = tmp.find( '.' );
+ if ( pos == -1 )
+ return tmp;
+ else
+ return tmp.left( pos );
+}
+
+/*!
+ Returns the extension name of the file.
+
+ If \a complete is TRUE (the default), extension() returns the string
+ of all characters in the file name after (but not including) the
+ first '.' character. For a file named "archive.tar.gz" this
+ returns "tar.gz".
+
+ If \a complete is FALSE, extension() returns the string of all
+ characters in the file name after (but not including) the last '.'
+ character. For a file named "archive.tar.gz" this returns "gz".
+
+ Example:
+ \code
+ QFileInfo fi( "lex.yy.c" );
+ QString ext = fi.extension(); // ext = "yy.c"
+ QString ext = fi.extension( FALSE ); // ext = "c"
+ \endcode
+
+ \sa fileName(), baseName()
+
+*/
+
+QString QFileInfo::extension( bool complete ) const
+{
+ QString s = fileName();
+ int pos = complete ? s.find( '.' ) : s.findRev( '.' );
+ if ( pos < 0 )
+ return QString::fromLatin1( "" );
+ else
+ return s.right( s.length() - pos - 1 );
+}
+
+/*!
+ Returns the directory path of the file.
+
+ If the QFileInfo is relative and \e absPath is FALSE, the QDir will be
+ relative, otherwise it will be absolute.
+
+ \sa dirPath(), filePath(), fileName(), isRelative()
+*/
+#ifndef QT_NO_DIR
+QDir QFileInfo::dir( bool absPath ) const
+{
+ return QDir( dirPath(absPath) );
+}
+#endif
+
+
+/*!
+ Returns TRUE if the file is readable.
+ \sa isWritable(), isExecutable(), permission()
+*/
+
+bool QFileInfo::isReadable() const
+{
+ return qt_file_access( fn, R_OK );
+}
+
+/*!
+ Returns TRUE if the file is writable.
+ \sa isReadable(), isExecutable(), permission()
+*/
+
+bool QFileInfo::isWritable() const
+{
+ return qt_file_access( fn, W_OK );
+}
+
+/*!
+ Returns TRUE if the file is executable.
+ \sa isReadable(), isWritable(), permission()
+*/
+
+bool QFileInfo::isExecutable() const
+{
+ return qt_file_access( fn, X_OK );
+}
+
+
+/*!
+ Returns TRUE if the file path name is relative to the current directory,
+ FALSE if the path is absolute (e.g. under UNIX a path is relative if it
+ does not start with a '/').
+
+ According to Einstein this function should always return TRUE.
+*/
+#ifndef QT_NO_DIR
+bool QFileInfo::isRelative() const
+{
+ return QDir::isRelativePath( fn );
+}
+
+/*!
+ Converts the file path name to an absolute path.
+
+ If it is already absolute nothing is done.
+
+ \sa filePath(), isRelative()
+*/
+
+bool QFileInfo::convertToAbs()
+{
+ if ( isRelative() )
+ fn = absFilePath();
+ return QDir::isRelativePath( fn );
+}
+#endif
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/kwq/qt/_qfileinfo.h b/WebCore/kwq/qt/_qfileinfo.h
new file mode 100644
index 0000000..8543e1c
--- /dev/null
+++ b/WebCore/kwq/qt/_qfileinfo.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+** $Id$
+**
+** Definition of QFileInfo class
+**
+** Created : 950628
+**
+** 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.
+**
+**********************************************************************/
+
+#ifndef QFILEINFO_H
+#define QFILEINFO_H
+
+#ifndef QT_H
+#include "qfile.h"
+#include "qdatetime.h"
+#endif // QT_H
+
+
+class QDir;
+struct QFileInfoCache;
+
+
+class Q_EXPORT QFileInfo // file information class
+{
+public:
+ enum PermissionSpec {
+ ReadUser = 0400, WriteUser = 0200, ExeUser = 0100,
+ ReadGroup = 0040, WriteGroup = 0020, ExeGroup = 0010,
+ ReadOther = 0004, WriteOther = 0002, ExeOther = 0001 };
+
+ QFileInfo();
+ QFileInfo( const QString &file );
+ QFileInfo( const QFile & );
+#ifndef QT_NO_DIR
+ QFileInfo( const QDir &, const QString &fileName );
+#endif
+ QFileInfo( const QFileInfo & );
+ ~QFileInfo();
+
+ QFileInfo &operator=( const QFileInfo & );
+
+ void setFile( const QString &file );
+ void setFile( const QFile & );
+#ifndef QT_NO_DIR
+ void setFile( const QDir &, const QString &fileName );
+#endif
+ bool exists() const;
+ void refresh() const;
+ bool caching() const;
+ void setCaching( bool );
+
+ QString filePath() const;
+ QString fileName() const;
+#ifndef QT_NO_DIR //###
+ QString absFilePath() const;
+#endif
+ QString baseName() const;
+ QString extension( bool complete = TRUE ) const;
+
+#ifndef QT_NO_DIR //###
+ QString dirPath( bool absPath = FALSE ) const;
+#endif
+#ifndef QT_NO_DIR
+ QDir dir( bool absPath = FALSE ) const;
+#endif
+ bool isReadable() const;
+ bool isWritable() const;
+ bool isExecutable() const;
+
+#ifndef QT_NO_DIR //###
+ bool isRelative() const;
+ bool convertToAbs();
+#endif
+
+ bool isFile() const;
+ bool isDir() const;
+ bool isSymLink() const;
+
+ QString readLink() const;
+
+ QString owner() const;
+ uint ownerId() const;
+ QString group() const;
+ uint groupId() const;
+
+ bool permission( int permissionSpec ) const;
+
+ uint size() const;
+
+ QDateTime lastModified() const;
+ QDateTime lastRead() const;
+
+private:
+ void doStat() const;
+ static void slashify( QString & );
+ static void makeAbs( QString & );
+
+ QString fn;
+ QFileInfoCache *fic;
+ bool cache;
+};
+
+
+inline bool QFileInfo::caching() const
+{
+ return cache;
+}
+
+
+#endif // QFILEINFO_H
diff --git a/WebCore/kwq/qt/_qfileinfo_unix.cpp b/WebCore/kwq/qt/_qfileinfo_unix.cpp
new file mode 100644
index 0000000..5183b17
--- /dev/null
+++ b/WebCore/kwq/qt/_qfileinfo_unix.cpp
@@ -0,0 +1,438 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QFileInfo class
+**
+** Created : 950628
+**
+** 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 for Unix/X11 or for Qt/Embedded 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
+
+#if defined(_OS_SUN_)
+#define readlink _qt_hide_readlink
+#endif
+
+#include <pwd.h>
+#include <grp.h>
+
+#include "_qfileinfo.h"
+#include "qdatetime.h"
+#include "_qdir.h"
+
+#if defined(_OS_SUN_)
+#undef readlink
+extern "C" int readlink( const char *, void *, uint );
+#endif
+
+
+void QFileInfo::slashify( QString& )
+{
+ return;
+}
+
+
+void QFileInfo::makeAbs( QString & )
+{
+ return;
+}
+
+extern bool qt_file_access( const QString& fn, int t );
+
+/*!
+ Returns TRUE if we are pointing to a real file.
+ \sa isDir(), isSymLink()
+*/
+bool QFileInfo::isFile() const
+{
+ if ( !fic || !cache )
+ doStat();
+ return fic ? (fic->st.st_mode & STAT_MASK) == STAT_REG : FALSE;
+}
+
+/*!
+ Returns TRUE if we are pointing to a directory or a symbolic link to
+ a directory.
+ \sa isFile(), isSymLink()
+*/
+
+bool QFileInfo::isDir() const
+{
+ if ( !fic || !cache )
+ doStat();
+ return fic ? (fic->st.st_mode & STAT_MASK) == STAT_DIR : FALSE;
+}
+
+/*!
+ Returns TRUE if we are pointing to a symbolic link.
+ \sa isFile(), isDir(), readLink()
+*/
+
+bool QFileInfo::isSymLink() const
+{
+ if ( !fic || !cache )
+ doStat();
+ return fic ? fic->isSymLink : FALSE;
+}
+
+
+/*!
+ Returns the name a symlink points to, or a null QString if the
+ object does not refer to a symbolic link.
+
+ This name may not represent an existing file; it is only a string.
+ QFileInfo::exists() returns TRUE if the symlink points to an
+ existing file.
+
+ \sa exists(), isSymLink(), isDir(), isFile()
+*/
+
+QString QFileInfo::readLink() const
+{
+ QString r;
+
+#if defined(_OS_UNIX_) && !defined(_OS_OS2EMX_)
+ char s[PATH_MAX+1];
+ if ( !isSymLink() )
+ return QString();
+ int len = readlink( QFile::encodeName(fn).data(), s, PATH_MAX );
+ if ( len >= 0 ) {
+ s[len] = '\0';
+ r = QFile::decodeName(s);
+ }
+#endif
+
+ return r;
+}
+
+static const uint nobodyID = (uint) -2;
+
+/*!
+ Returns the owner of the file.
+
+ On systems where files do not have owners this function returns 0.
+
+ Note that this function can be time-consuming under UNIX. (in the order
+ of milliseconds on a 486 DX2/66 running Linux).
+
+ \sa ownerId(), group(), groupId()
+*/
+
+QString QFileInfo::owner() const
+{
+ passwd *pw = getpwuid( ownerId() );
+ if ( pw )
+ return QFile::decodeName( pw->pw_name );
+ return QString::null;
+}
+
+/*!
+ Returns the id of the owner of the file.
+
+ On systems where files do not have owners this function returns ((uint) -2).
+
+ \sa owner(), group(), groupId()
+*/
+
+uint QFileInfo::ownerId() const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ return fic->st.st_uid;
+ return nobodyID;
+}
+
+/*!
+ Returns the group the file belongs to.
+
+ On systems where files do not have groups this function always
+ returns 0.
+
+ Note that this function can be time-consuming under UNIX (in the order of
+ milliseconds on a 486 DX2/66 running Linux).
+
+ \sa groupId(), owner(), ownerId()
+*/
+
+QString QFileInfo::group() const
+{
+ struct group *gr = getgrgid( groupId() );
+ if ( gr )
+ return QFile::decodeName( gr->gr_name );
+ return QString::null;
+}
+
+/*!
+ Returns the id of the group the file belongs to.
+
+ On systems where files do not have groups this function always
+ returns ((uind) -2).
+
+ \sa group(), owner(), ownerId()
+*/
+
+uint QFileInfo::groupId() const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ return fic->st.st_gid;
+ return nobodyID;
+}
+
+
+/*!
+ \fn bool QFileInfo::permission( int permissionSpec ) const
+
+ Tests for file permissions. The \e permissionSpec argument can be several
+ flags of type PermissionSpec or'ed together to check for permission
+ combinations.
+
+ On systems where files do not have permissions this function always
+ returns TRUE.
+
+ Example:
+ \code
+ QFileInfo fi( "/tmp/tonsils" );
+ if ( fi.permission( QFileInfo::WriteUser | QFileInfo::ReadGroup ) )
+ qWarning( "Tonsils can be changed by me, and the group can read them.");
+ if ( fi.permission( QFileInfo::WriteGroup | QFileInfo::WriteOther ) )
+ qWarning( "Danger! Tonsils can be changed by the group or others!" );
+ \endcode
+
+ \sa isReadable(), isWritable(), isExecutable()
+*/
+
+bool QFileInfo::permission( int permissionSpec ) const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic ) {
+ uint mask = 0;
+ if ( permissionSpec & ReadUser)
+ mask |= S_IRUSR;
+ if ( permissionSpec & WriteUser)
+ mask |= S_IWUSR;
+ if ( permissionSpec & ExeUser)
+ mask |= S_IXUSR;
+ if ( permissionSpec & ReadGroup)
+ mask |= S_IRGRP;
+ if ( permissionSpec & WriteGroup)
+ mask |= S_IWGRP;
+ if ( permissionSpec & ExeGroup)
+ mask |= S_IXGRP;
+ if ( permissionSpec & ReadOther)
+ mask |= S_IROTH;
+ if ( permissionSpec & WriteOther)
+ mask |= S_IWOTH;
+ if ( permissionSpec & ExeOther)
+ mask |= S_IXOTH;
+ if ( mask ) {
+ return (fic->st.st_mode & mask) == mask;
+ } else {
+#if defined(CHECK_NULL)
+ qWarning( "QFileInfo::permission: permissionSpec is 0" );
+#endif
+ return TRUE;
+ }
+ } else {
+ return FALSE;
+ }
+}
+
+/*!
+ Returns the file size in bytes, or 0 if the file does not exist if the size
+ cannot be fetched.
+*/
+
+uint QFileInfo::size() const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ return (uint)fic->st.st_size;
+ else
+ return 0;
+}
+
+
+/*!
+ Returns the date and time when the file was last modified.
+ \sa lastRead()
+*/
+
+QDateTime QFileInfo::lastModified() const
+{
+ QDateTime dt;
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ dt.setTime_t( fic->st.st_mtime );
+ return dt;
+}
+
+/*!
+ Returns the date and time when the file was last read (accessed).
+
+ On systems that do not support last read times, the modification time is
+ returned.
+
+ \sa lastModified()
+*/
+
+QDateTime QFileInfo::lastRead() const
+{
+ QDateTime dt;
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ dt.setTime_t( fic->st.st_atime );
+ return dt;
+}
+
+
+void QFileInfo::doStat() const
+{
+ QFileInfo *that = ((QFileInfo*)this); // mutable function
+ if ( !that->fic )
+ that->fic = new QFileInfoCache;
+ STATBUF *b = &that->fic->st;
+ that->fic->isSymLink = FALSE;
+
+#if defined(_OS_UNIX_) && defined(S_IFLNK)
+ if ( ::lstat(QFile::encodeName(fn),b) == 0 ) {
+ if ( S_ISLNK( b->st_mode ) )
+ that->fic->isSymLink = TRUE;
+ else
+ return;
+ }
+#endif
+ int r;
+
+ r = STAT( QFile::encodeName(fn), b );
+
+ if ( r != 0 && !that->fic->isSymLink ) {
+ delete that->fic;
+ that->fic = 0;
+ }
+}
+
+/*!
+ Returns the directory path of the file.
+
+ If \e absPath is TRUE an absolute path is always returned.
+
+ \sa dir(), filePath(), fileName(), isRelative()
+*/
+#ifndef QT_NO_DIR
+QString QFileInfo::dirPath( bool absPath ) const
+{
+ QString s;
+ if ( absPath )
+ s = absFilePath();
+ else
+ s = fn;
+ int pos = s.findRev( '/' );
+ if ( pos == -1 ) {
+ return QString::fromLatin1(".");
+ } else {
+ if ( pos == 0 )
+ return QString::fromLatin1( "/" );
+ return s.left( pos );
+ }
+}
+#endif
+/*!
+ Returns the name of the file, the file path is not included.
+
+ Example:
+ \code
+ QFileInfo fi( "/tmp/abdomen.lower" );
+ QString name = fi.fileName(); // name = "abdomen.lower"
+ \endcode
+
+ \sa isRelative(), filePath(), baseName(), extension()
+*/
+
+QString QFileInfo::fileName() const
+{
+ int p = fn.findRev( '/' );
+ if ( p == -1 ) {
+ return fn;
+ } else {
+ return fn.mid(p+1);
+ }
+}
+
+/*!
+ Returns the absolute path name.
+
+ The absolute path name is the file name including the absolute path. If
+ the QFileInfo is absolute (i.e. not relative) this function will return
+ the same string as filePath().
+
+ Note that this function can be time-consuming under UNIX. (in the order
+ of milliseconds on a 486 DX2/66 running Linux).
+
+ \sa isRelative(), filePath()
+*/
+#ifndef QT_NO_DIR
+QString QFileInfo::absFilePath() const
+{
+ if ( QDir::isRelativePath(fn) ) {
+ QString tmp = QDir::currentDirPath();
+ tmp += '/';
+ tmp += fn;
+ makeAbs( tmp );
+ return QDir::cleanDirPath( tmp );
+ } else {
+ QString tmp = fn;
+ makeAbs( tmp );
+ return QDir::cleanDirPath( tmp );
+ }
+
+}
+#endif
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/kwq/qt/_qgarray.h b/WebCore/kwq/qt/_qgarray.h
index 89b77d7..3157c89 100644
--- a/WebCore/kwq/qt/_qgarray.h
+++ b/WebCore/kwq/qt/_qgarray.h
@@ -27,7 +27,7 @@
class QGArray // generic array
{
-//friend class QBuffer;
+friend class QBuffer;
public:
//### DO NOT USE THIS. IT IS PUBLIC BUT DO NOT USE IT IN NEW CODE.
struct array_data : public QShared { // shared array
diff --git a/WebCore/kwq/qt/_qstrlist.h b/WebCore/kwq/qt/_qstrlist.h
index ffcd178..10ff372 100644
--- a/WebCore/kwq/qt/_qstrlist.h
+++ b/WebCore/kwq/qt/_qstrlist.h
@@ -40,6 +40,10 @@
// KWQ hacks ---------------------------------------------------------------
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#ifndef USING_BORROWED_QSTRINGLIST
#define USING_BORROWED_QSTRINGLIST
#endif
diff --git a/WebCore/kwq/qt/_qurl.cpp b/WebCore/kwq/qt/_qurl.cpp
new file mode 100644
index 0000000..3c5ca9e
--- /dev/null
+++ b/WebCore/kwq/qt/_qurl.cpp
@@ -0,0 +1,1152 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QUrl class
+**
+** Created : 950429
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the kernel 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 "_qurl.h"
+
+#ifndef QT_NO_DIR
+
+#include <stdlib.h>
+
+struct QUrlPrivate
+{
+ QString protocol;
+ QString user;
+ QString pass;
+ QString host;
+ QString path, cleanPath;
+ QString refEncoded;
+ QString queryEncoded;
+ bool isValid;
+ int port;
+ bool cleanPathDirty;
+};
+
+/*!
+ Replaces backslashes with slashes and removes multiple occurrences
+ of slashes or backslashes if \c allowMultiple is FALSE.
+*/
+
+static void slashify( QString& s, bool allowMultiple = TRUE )
+{
+ bool justHadSlash = FALSE;
+ for ( int i = 0; i < (int)s.length(); i++ ) {
+ if ( !allowMultiple && justHadSlash &&
+ ( s[ i ] == '/' || s[ i ] == '\\' ) ) {
+ s.remove( i, 1 );
+ --i;
+ continue;
+ }
+ if ( s[ i ] == '\\' )
+ s[ i ] = '/';
+ if ( s[ i ] == '/' )
+ justHadSlash = TRUE;
+ else
+ justHadSlash = FALSE;
+ }
+}
+
+// NOT REVISED
+/*!
+ \class QUrl qurl.h
+
+ \brief The QUrl class provides mainly an URL parser and
+ simplifies working with URLs.
+
+ \ingroup misc
+
+ The QUrl class is provided for a easy working with URLs.
+ It does all parsing, decoding, encoding and so on.
+
+ Mention that URL has some restrictions regarding the path
+ encoding. URL works intern with the decoded path and
+ and encoded query. For example in
+
+ http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you
+
+ would result in a decoded path "/cgi-bin/test me.pl"
+ and in the encoded query "cmd=Hello%20you".
+ Since path is internally always encoded you may NOT use
+ "%00" in the path while this is ok for the query.
+
+ QUrl is normally used like that:
+
+ \code
+ QUrl u( "http://www.trolltech.com" );
+ // or
+ QUrl u( "file:/home/myself/Mail", "Inbox" );
+ \endcode
+
+ Then you can access the parts of the URL, change them and do
+ some more stuff.
+
+ To allow easy working with QUrl and QString together, QUrl implements
+ the needed cast and assign operators. So you can do following:
+
+ \code
+ QUrl u( "http://www.trolltech.com" );
+ QString s = u;
+ // or
+ QString s( "http://www.trolltech.com" );
+ QUrl u( s );
+ \endcode
+
+ If you want to use an URL to work on a hierarchical structures
+ (e.g. locally or remote filesystem) the class QUrlOperator, which is derived
+ fro QUrl, may be interesting for you.
+
+ \sa QUrlOperator
+*/
+
+
+/*!
+ Constructs an empty URL which, is invalid.
+*/
+
+QUrl::QUrl()
+{
+ d = new QUrlPrivate;
+ d->isValid = FALSE;
+ d->port = -1;
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Constructs and URL using \a url and parses this string.
+
+ You can pass strings like "/home/qt", in this case the protocol
+ "file" is assumed.
+*/
+
+QUrl::QUrl( const QString& url )
+{
+ d = new QUrlPrivate;
+ d->protocol = "file";
+ d->port = -1;
+ parse( url );
+}
+
+/*!
+ Copy constructor. Copies the data of \a url.
+*/
+
+QUrl::QUrl( const QUrl& url )
+{
+ d = new QUrlPrivate;
+ *d = *url.d;
+}
+
+/*!
+ Returns TRUE, if \a url is relative, else it returns FALSE.
+*/
+
+bool QUrl::isRelativeUrl( const QString &url )
+{
+ int colon = url.find( ":" );
+ int slash = url.find( "/" );
+
+ return ( slash != 0 && ( colon == -1 || ( slash != -1 && colon > slash ) ) );
+}
+
+/*!
+ Constructs and URL taking \a url as base (context) and
+ \a relUrl as relative URL to \a url. If \a relUrl is not relative,
+ \a relUrl is taken as new URL.
+
+ For example, the path of
+
+ \code
+ QUrl u( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );
+ \endcode
+
+ will be "/qt/srource/qt-2.1.0.tar.gz".
+
+ And
+
+ \code
+ QUrl u( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );
+ \endcode
+
+ will result in a new URL, "ftp://ftp.trolltech.com/usr/local",
+
+ And
+
+ \code
+ QUrl u( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );
+ \endcode
+
+ will result in a new URL, with "/usr/local" as path
+ and "file" as protocol.
+
+ Normally it is expected that the path of \a url points to
+ a directory, even if the path has no slash at the end. But
+ if you want that the constructor handles the last
+ part of the path as filename, if there is no slash at the end,
+ and let it replace by the filename of \a relUrl
+ (if it contains one), set \a checkSlash to TRUE.
+*/
+
+QUrl::QUrl( const QUrl& url, const QString& relUrl, bool checkSlash )
+{
+ d = new QUrlPrivate;
+ QString rel = relUrl;
+ slashify( rel );
+
+ if ( !isRelativeUrl( rel ) ) {
+ if ( rel[ 0 ] == QChar( '/' ) ) {
+ *this = url;
+ setEncodedPathAndQuery( rel );
+ } else {
+ *this = rel;
+ }
+ } else {
+ if ( rel[ 0 ] == '#' ) {
+ *this = url;
+ rel.remove( 0, 1 );
+ decode( rel );
+ setRef( rel );
+ } else if ( rel[ 0 ] == '?' ) {
+ *this = url;
+ rel.remove( 0, 1 );
+ setQuery( rel );
+ } else {
+ decode( rel );
+ *this = url;
+ if ( !checkSlash || d->cleanPath[ (int)path().length() - 1 ] == '/' ) {
+ QString p = url.path();
+ if ( p.isEmpty() )
+ p = "/";
+ if ( p.right( 1 ) != "/" )
+ p += "/";
+ p += rel;
+ d->path = p;
+ d->cleanPathDirty = TRUE;
+ } else {
+ setFileName( rel );
+ }
+ }
+ }
+}
+
+/*!
+ Destructor.
+*/
+
+QUrl::~QUrl()
+{
+ delete d;
+ d = 0;
+}
+
+/*!
+ Returns the protocol of the URL. It is something like
+ "file" or "ftp".
+*/
+
+QString QUrl::protocol() const
+{
+ return d->protocol;
+}
+
+/*!
+ Sets the protocol of the URL. This could be e.g.
+ "file", "ftp", or something similar.
+*/
+
+void QUrl::setProtocol( const QString& protocol )
+{
+ d->protocol = protocol;
+}
+
+/*!
+ Returns the username of the URL.
+*/
+
+QString QUrl::user() const
+{
+ return d->user;
+}
+
+/*!
+ Sets the username of the URL.
+*/
+
+void QUrl::setUser( const QString& user )
+{
+ d->user = user;
+}
+
+/*!
+ Returns TRUE, if the URL contains an username,
+ else FALSE;
+*/
+
+bool QUrl::hasUser() const
+{
+ return !d->user.isEmpty();
+}
+
+/*!
+ Returns the password of the URL.
+*/
+
+QString QUrl::password() const
+{
+ return d->pass;
+}
+
+/*!
+ Sets the password of the URL.
+*/
+
+void QUrl::setPassword( const QString& pass )
+{
+ d->pass = pass;
+}
+
+/*!
+ Returns TRUE, if the URL contains a password,
+ else FALSE;
+*/
+
+bool QUrl::hasPassword() const
+{
+ return !d->pass.isEmpty();
+}
+
+/*!
+ Returns the hostname of the URL.
+*/
+
+QString QUrl::host() const
+{
+ return d->host;
+}
+
+/*!
+ Sets the hostname of the URL.
+*/
+
+void QUrl::setHost( const QString& host )
+{
+ d->host = host;
+}
+
+/*!
+ Returns TRUE, if the URL contains a hostname,
+ else FALSE;
+*/
+
+bool QUrl::hasHost() const
+{
+ return !d->host.isEmpty();
+}
+
+/*!
+ Returns the port of the URL.
+*/
+
+int QUrl::port() const
+{
+ return d->port;
+}
+
+/*!
+ Sets the port of the URL.
+*/
+
+void QUrl::setPort( int port )
+{
+ d->port = port;
+}
+
+/*!
+ Sets the path or the URL.
+*/
+
+void QUrl::setPath( const QString& path )
+{
+ d->path = path;
+ slashify( d->path );
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Returns TRUE, if the URL contains a path,
+ else FALSE.
+*/
+
+bool QUrl::hasPath() const
+{
+ return !d->path.isEmpty();
+}
+
+/*!
+ Sets the query of the URL. Must be encoded.
+*/
+
+void QUrl::setQuery( const QString& txt )
+{
+ d->queryEncoded = txt;
+}
+
+/*!
+ Returns the query (encoded) of the URL.
+*/
+
+QString QUrl::query() const
+{
+ return d->queryEncoded;
+}
+
+/*!
+ Returns the reference (encoded) of the URL.
+*/
+
+QString QUrl::ref() const
+{
+ return d->refEncoded;
+}
+
+/*!
+ Sets the reference of the URL. Must be encoded.
+*/
+
+void QUrl::setRef( const QString& txt )
+{
+ d->refEncoded = txt;
+}
+
+/*!
+ Returns TRUE, if the URL has a reference, else it returns FALSE.
+*/
+
+bool QUrl::hasRef() const
+{
+ return !d->refEncoded.isEmpty();
+}
+
+/*!
+ Returns TRUE if the URL is valid, else FALSE.
+ An URL is e.g. invalid if there was a parse error.
+*/
+
+bool QUrl::isValid() const
+{
+ return d->isValid;
+}
+
+/*!
+ Resets all values if the URL to its default values
+ and invalidates it.
+*/
+
+void QUrl::reset()
+{
+ d->protocol = "file";
+ d->user = "";
+ d->pass = "";
+ d->host = "";
+ d->path = "";
+ d->queryEncoded = "";
+ d->refEncoded = "";
+ d->isValid = TRUE;
+ d->port = -1;
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Parses the \a url.
+*/
+
+bool QUrl::parse( const QString& url )
+{
+ QString url_( url );
+ slashify( url_ );
+
+ if ( url_.isEmpty() ) {
+ d->isValid = FALSE;
+ return FALSE;
+ }
+
+ d->cleanPathDirty = TRUE;
+ d->isValid = TRUE;
+ QString oldProtocol = d->protocol;
+ d->protocol = QString::null;
+
+ const int Init = 0;
+ const int Protocol = 1;
+ const int Separator1= 2; // :
+ const int Separator2= 3; // :/
+ const int Separator3= 4; // :// or more slashes
+ const int User = 5;
+ const int Pass = 6;
+ const int Host = 7;
+ const int Path = 8;
+ const int Ref = 9;
+ const int Query = 10;
+ const int Port = 11;
+ const int Done = 12;
+
+ const int InputAlpha= 1;
+ const int InputDigit= 2;
+ const int InputSlash= 3;
+ const int InputColon= 4;
+ const int InputAt = 5;
+ const int InputHash = 6;
+ const int InputQuery= 7;
+
+ static uchar table[ 12 ][ 8 ] = {
+ /* None InputAlpha InputDigit InputSlash InputColon InputAt InputHash InputQuery */
+ { 0, Protocol, 0, Path, 0, 0, 0, 0, }, // Init
+ { 0, Protocol, Protocol, 0, Separator1, 0, 0, 0, }, // Protocol
+ { 0, Path, Path, Separator2, 0, 0, 0, 0, }, // Separator1
+ { 0, Path, Path, Separator3, 0, 0, 0, 0, }, // Separator2
+ { 0, User, User, Separator3, Pass, Host, 0, 0, }, // Separator3
+ { 0, User, User, User, Pass, Host, User, User, }, // User
+ { 0, Pass, Pass, Pass, Pass, Host, Pass, Pass, }, // Pass
+ { 0, Host, Host, Path, Port, Host, Ref, Query, }, // Host
+ { 0, Path, Path, Path, Path, Path, Ref, Query, }, // Path
+ { 0, Ref, Ref, Ref, Ref, Ref, Ref, Query, }, // Ref
+ { 0, Query, Query, Query, Query, Query, Query, Query, }, // Query
+ { 0, 0, Port, Path, 0, 0, 0, 0, } // Port
+ };
+
+ bool relPath = FALSE;
+
+ relPath = FALSE;
+ bool forceRel = FALSE;
+
+ // if :/ is at pos 1, we have only one letter
+ // before that separator => that's a drive letter!
+ int cs = url_.find( ":/" );
+ if ( cs == 1 )
+ relPath = forceRel = TRUE;
+
+ int hasNoHost = -1;
+ if ( cs != -1 ) // if a protocol is there, find out if there is a host or directly the path after it
+ hasNoHost = url_.find( "///", cs );
+ table[ 4 ][ 1 ] = User;
+ table[ 4 ][ 2 ] = User;
+ if ( cs == -1 || forceRel ) { // we have a relative file
+ if ( url.find( ':' ) == -1 || forceRel ) {
+ table[ 0 ][ 1 ] = Path;
+ // Filenames may also begin with a digit
+ table[ 0 ][ 2 ] = Path;
+ } else {
+ table[ 0 ][ 1 ] = Protocol;
+ }
+ relPath = TRUE;
+ } else { // some checking
+ table[ 0 ][ 1 ] = Protocol;
+
+ // find the part between the protocol and the path as the meaning
+ // of that part is dependend on some chars
+ ++cs;
+ while ( url_[ cs ] == '/' )
+ ++cs;
+ int slash = url_.find( "/", cs );
+ if ( slash == -1 )
+ slash = url_.length() - 1;
+ QString tmp = url_.mid( cs, slash - cs + 1 );
+
+ if ( !tmp.isEmpty() ) { // if this part exists
+
+ // look for the @ in this part
+ int at = tmp.find( "@" );
+ if ( at != -1 )
+ at += cs;
+ // we have no @, which means host[:port], so directly
+ // after the protocol the host starts, or if the protocol
+ // is file or there were more than 2 slashes, it´s the
+ // path
+ if ( at == -1 ) {
+ if ( url_.left( 4 ) == "file" || hasNoHost != -1 )
+ table[ 4 ][ 1 ] = Path;
+ else
+ table[ 4 ][ 1 ] = Host;
+ table[ 4 ][ 2 ] = table[ 4 ][ 1 ];
+ }
+ }
+ }
+
+ int state = Init; // parse state
+ int input; // input token
+
+ QChar c = url_[ 0 ];
+ int i = 0;
+ QString port;
+
+ while ( TRUE ) {
+ switch ( c ) {
+ case '?':
+ input = InputQuery;
+ break;
+ case '#':
+ input = InputHash;
+ break;
+ case '@':
+ input = InputAt;
+ break;
+ case ':':
+ input = InputColon;
+ break;
+ case '/':
+ input = InputSlash;
+ break;
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9': case '0':
+ input = InputDigit;
+ break;
+ default:
+ input = InputAlpha;
+ }
+
+ state = table[ state ][ input ];
+
+ switch ( state ) {
+ case Protocol:
+ d->protocol += c;
+ break;
+ case User:
+ d->user += c;
+ break;
+ case Pass:
+ d->pass += c;
+ break;
+ case Host:
+ d->host += c;
+ break;
+ case Path:
+ d->path += c;
+ break;
+ case Ref:
+ d->refEncoded += c;
+ break;
+ case Query:
+ d->queryEncoded += c;
+ break;
+ case Port:
+ port += c;
+ break;
+ default:
+ break;
+ }
+
+ ++i;
+ if ( i > (int)url_.length() - 1 || state == Done || state == 0 )
+ break;
+ c = url_[ i ];
+
+ }
+
+ if ( !port.isEmpty() ) {
+ port.remove( 0, 1 );
+ d->port = atoi( port.latin1() );
+ }
+
+ // error
+ if ( i < (int)url_.length() - 1 ) {
+ d->isValid = FALSE;
+ return FALSE;
+ }
+
+
+ if ( d->protocol.isEmpty() )
+ d->protocol = oldProtocol;
+
+ if ( d->path.isEmpty() )
+ d->path = "/";
+
+ // hack for windows
+ if ( d->path.length() == 2 && d->path[ 1 ] == ':' )
+ d->path += "/";
+
+ // #### do some corrections, should be done nicer too
+ if ( !d->pass.isEmpty() && d->pass[ 0 ] == ':' )
+ d->pass.remove( 0, 1 );
+ if ( !d->path.isEmpty() ) {
+ if ( d->path[ 0 ] == '@' || d->path[ 0 ] == ':' )
+ d->path.remove( 0, 1 );
+ if ( d->path[ 0 ] != '/' && !relPath && d->path[ 1 ] != ':' )
+ d->path.prepend( "/" );
+ }
+ if ( !d->refEncoded.isEmpty() && d->refEncoded[ 0 ] == '#' )
+ d->refEncoded.remove( 0, 1 );
+ if ( !d->queryEncoded.isEmpty() && d->queryEncoded[ 0 ] == '?' )
+ d->queryEncoded.remove( 0, 1 );
+ if ( !d->host.isEmpty() && d->host[ 0 ] == '@' )
+ d->host.remove( 0, 1 );
+
+#if defined(_OS_WIN32_)
+ // hack for windows file://machine/path syntax
+ if ( d->protocol == "file" ) {
+ if ( url.left( 7 ) == "file://" &&
+ ( d->path.length() < 8 || d->path[ 7 ] != '/' ) &&
+ d->path[ 1 ] != '/' )
+ d->path.prepend( "/" );
+ }
+#endif
+
+ decode( d->path );
+ d->cleanPathDirty = TRUE;
+
+#if 0
+ qDebug( "URL: %s", url.latin1() );
+ qDebug( "protocol: %s", d->protocol.latin1() );
+ qDebug( "user: %s", d->user.latin1() );
+ qDebug( "pass: %s", d->pass.latin1() );
+ qDebug( "host: %s", d->host.latin1() );
+ qDebug( "path: %s", path().latin1() );
+ qDebug( "ref: %s", d->refEncoded.latin1() );
+ qDebug( "query: %s", d->queryEncoded.latin1() );
+ qDebug( "port: %d\n\n----------------------------\n\n", d->port );
+#endif
+
+ return TRUE;
+}
+
+/*!
+ Assign operator. Parses \a url and assigns the resulting
+ data to this class.
+
+ You can pass strings like "/home/qt", in this case the protocol
+ "file" is assumed.
+*/
+
+QUrl& QUrl::operator=( const QString& url )
+{
+ reset();
+ parse( url );
+
+ return *this;
+}
+
+/*!
+ Assign operator. Assigns the data of \a url to this class.
+*/
+
+QUrl& QUrl::operator=( const QUrl& url )
+{
+ *d = *url.d;
+ return *this;
+}
+
+/*!
+ Compares this URL with \a url and returns TRUE if
+ they are equal, else FALSE.
+*/
+
+bool QUrl::operator==( const QUrl& url ) const
+{
+ if ( !isValid() || !url.isValid() )
+ return FALSE;
+
+ if ( d->protocol == url.d->protocol &&
+ d->user == url.d->user &&
+ d->pass == url.d->pass &&
+ d->host == url.d->host &&
+ d->path == url.d->path &&
+ d->queryEncoded == url.d->queryEncoded &&
+ d->refEncoded == url.d->refEncoded &&
+ d->isValid == url.d->isValid &&
+ d->port == url.d->port )
+ return TRUE;
+
+ return FALSE;
+}
+
+/*!
+ Compares this URL with \a url. \a url is parsed
+ first. Returns TRUE if \a url is equal to this url,
+ else FALSE:
+*/
+
+bool QUrl::operator==( const QString& url ) const
+{
+ QUrl u( url );
+ return ( *this == u );
+}
+
+/*!
+ Sets the filename of the URL to \a name. If this
+ url contains a fileName(), this is replaced by
+ \a name. See the documentation of fileName()
+ for a more detail discussion, about what is handled
+ as file name and what as directory path.
+*/
+
+void QUrl::setFileName( const QString& name )
+{
+ QString fn( name );
+ slashify( fn );
+
+ while ( fn[ 0 ] == '/' )
+ fn.remove( 0, 1 );
+
+ QString p = path().isEmpty() ?
+ QString( "/" ) : path();
+ if ( !path().isEmpty() ) {
+ int slash = p.findRev( QChar( '/' ) );
+ if ( slash == -1 ) {
+ p = "/";
+ } else if ( p[ (int)p.length() - 1 ] != '/' )
+ p.truncate( slash + 1 );
+ }
+
+ p += fn;
+ if ( !d->queryEncoded.isEmpty() )
+ p += "?" + d->queryEncoded;
+ setEncodedPathAndQuery( p );
+}
+
+/*!
+ Returns the encoded path plus the query (encoded too).
+*/
+
+QString QUrl::encodedPathAndQuery()
+{
+ QString p = path();
+ if ( p.isEmpty() )
+ p = "/";
+
+ encode( p );
+
+ if ( !d->queryEncoded.isEmpty() ) {
+ p += "?";
+ p += d->queryEncoded;
+ }
+
+ return p;
+}
+
+/*!
+ Sets path and query. Both have to be encoded.
+*/
+
+void QUrl::setEncodedPathAndQuery( const QString& path )
+{
+ d->cleanPathDirty = TRUE;
+ int pos = path.find( '?' );
+ if ( pos == -1 ) {
+ d->path = path;
+ d->queryEncoded = "";
+ } else {
+ d->path = path.left( pos );
+ d->queryEncoded = path.mid( pos + 1 );
+ }
+
+ decode( d->path );
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Returns the path of the URL. If \a correct is TRUE,
+ the path is cleaned (deals with too many or few
+ slashes, cleans things like "/../..", etc). Else exactly the path
+ which was parsed or set is returned.
+*/
+
+QString QUrl::path( bool correct ) const
+{
+ if ( !correct )
+ return d->path;
+
+ if ( d->cleanPathDirty ) {
+ bool check = TRUE;
+ if ( QDir::isRelativePath( d->path ) ) {
+ d->cleanPath = d->path;
+ } else if ( isLocalFile() ) {
+#if defined(_OS_WIN32_)
+ // hack for stuff like \\machine\path and //machine/path on windows
+ if ( ( d->path.left( 1 ) == "/" || d->path.left( 1 ) == "\\" ) &&
+ d->path.length() > 1 ) {
+ d->cleanPath = d->path;
+ bool share = d->cleanPath[ 1 ] == '\\' || d->cleanPath[ 1 ] == '/';
+ slashify( d->cleanPath, FALSE );
+ d->cleanPath = QDir::cleanDirPath( d->cleanPath );
+ if ( share ) {
+ check = FALSE;
+ d->cleanPath.prepend( "/" );
+ }
+ }
+#endif
+ if ( check ) {
+ QFileInfo fi( d->path );
+ if ( !fi.exists() )
+ d->cleanPath = d->path;
+ else if ( fi.isDir() ) {
+ QString dir = QDir::cleanDirPath( QDir( d->path ).canonicalPath() ) + "/";
+ if ( dir == "//" )
+ d->cleanPath = "/";
+ else
+ d->cleanPath = dir;
+ } else {
+ QString p = QDir::cleanDirPath( fi.dir().canonicalPath() );
+ d->cleanPath = p + "/" + fi.fileName();
+ }
+ }
+ } else {
+ if ( d->path != "/" && d->path[ (int)d->path.length() - 1 ] == '/' )
+ d->cleanPath = QDir::cleanDirPath( d->path ) + "/";
+ else
+ d->cleanPath = QDir::cleanDirPath( d->path );
+ }
+
+ if ( check )
+ slashify( d->cleanPath, FALSE );
+ d->cleanPathDirty = FALSE;
+ }
+
+ return d->cleanPath;
+}
+
+/*!
+ Returns TRUE, if the URL is a local file, else
+ it returns FALSE;
+*/
+
+bool QUrl::isLocalFile() const
+{
+ return d->protocol == "file";
+}
+
+/*!
+ Returns the filename of the URL. If the path of the URL
+ doesn't have a slash at the end, the part between the last slash
+ and the end of the path string is handled as filename. If the
+ path has a slash at the end, an empty string is returned here.
+*/
+
+QString QUrl::fileName() const
+{
+ if ( d->path.isEmpty() )
+ return QString::null;
+
+ return QFileInfo( d->path ).fileName();
+}
+
+/*!
+ Adds the path \a pa to the path of the URL.
+*/
+
+void QUrl::addPath( const QString& pa )
+{
+ if ( pa.isEmpty() )
+ return;
+
+ QString p( pa );
+ slashify( p );
+
+ if ( path().isEmpty() ) {
+ if ( p[ 0 ] != QChar( '/' ) )
+ d->path = "/" + p;
+ else
+ d->path = p;
+ } else {
+ if ( p[ 0 ] != QChar( '/' ) && d->path[ (int)d->path.length() - 1 ] != '/' )
+ d->path += "/" + p;
+ else
+ d->path += p;
+ }
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Returns the directory path of the URL. This is the part
+ of the path of this URL without the fileName(). See
+ the documentation of fileName() for a discussion
+ what is handled as file name and what as directory path.
+*/
+
+QString QUrl::dirPath() const
+{
+ if ( path().isEmpty() )
+ return QString::null;
+
+ QString s = path();
+ // ### If anything is broken with regards to the directories in QFileDialog
+ // et al, then this is probably the place to look
+// if ( s.right( 1 ) != "/" )
+// s += "/";
+ s = QFileInfo( s ).dirPath();
+
+// s = QFileInfo( s ).dirPath( TRUE );
+// if ( s[ (int)s.length() - 1 ] != '/' )
+// s += "/";
+ return s;
+}
+
+/*!
+ Encodes the string \a url.
+*/
+
+void QUrl::encode( QString& url )
+{
+ int oldlen = url.length();
+
+ if ( !oldlen )
+ return;
+
+ QString newUrl;
+ int newlen = 0;
+
+ for ( int i = 0; i < oldlen ;++i ) {
+ ushort inCh = url[ i ].unicode();
+
+ if ( inCh >= 128 ||
+ QString( "<>#@\"&%$:,;?={}|^~[]\'`\\ \n\t\r" ).contains(inCh) ) {
+ newUrl[ newlen++ ] = QChar( '%' );
+
+ ushort c = inCh / 16;
+ c += c > 9 ? 'A' - 10 : '0';
+ newUrl[ newlen++ ] = c;
+
+ c = inCh % 16;
+ c += c > 9 ? 'A' - 10 : '0';
+ newUrl[ newlen++ ] = c;
+ } else {
+ newUrl[ newlen++ ] = url[ i ];
+ }
+ }
+
+ url = newUrl;
+}
+
+static ushort hex_to_int( ushort c )
+{
+ if ( c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ if ( c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ if ( c >= '0' && c <= '9')
+ return c - '0';
+ return 0;
+}
+
+/*!
+ Decodes the string \a url.
+*/
+
+void QUrl::decode( QString& url )
+{
+ int oldlen = url.length();
+ if ( !oldlen )
+ return;
+
+ int newlen = 0;
+
+ QString newUrl;
+
+ int i = 0;
+ while ( i < oldlen ) {
+ ushort c = url[ i++ ].unicode();
+ if ( c == '%' ) {
+ c = hex_to_int( url[ i ].unicode() ) * 16 + hex_to_int( url[ i + 1 ].unicode() );
+ i += 2;
+ }
+ newUrl [ newlen++ ] = c;
+ }
+
+ url = newUrl;
+}
+
+/*! Composes a string of the URL and returns it. If \a encodedPath is
+ TRUE, the path in the returned string will be encoded. If \a
+ forcePrependProtocol is TRUE, the protocol (file:/) is also
+ prepended to local filenames, else no protocol is prepended for
+ local filenames.
+*/
+
+QString QUrl::toString( bool encodedPath, bool forcePrependProtocol ) const
+{
+ QString res, p = path();
+ if ( encodedPath )
+ encode( p );
+
+ if ( isLocalFile() ) {
+ if ( forcePrependProtocol )
+ res = d->protocol + ":" + p;
+ else
+ res = p;
+ } else if ( d->protocol == "mailto" ) {
+ res = d->protocol + ":" + p;
+ } else {
+ res = d->protocol + "://";
+ if ( !d->user.isEmpty() || !d->pass.isEmpty() ) {
+ if ( !d->user.isEmpty() )
+ res += d->user;
+ if ( !d->pass.isEmpty() )
+ res += ":" + d->pass;
+ res += "@";
+ }
+ res += d->host;
+ if ( d->port != -1 )
+ res += ":" + QString( "%1" ).arg( d->port );
+ res += p;
+ }
+
+ if ( !d->refEncoded.isEmpty() )
+ res += "#" + d->refEncoded;
+ if ( !d->queryEncoded.isEmpty() )
+ res += "?" + d->queryEncoded;
+
+ return res;
+}
+
+/*!
+ Composes a string of the URL and returns it.
+
+ \sa QUrl::toString()
+*/
+
+QUrl::operator QString() const
+{
+ return toString();
+}
+
+/*!
+ Goes one directory up.
+*/
+
+bool QUrl::cdUp()
+{
+ d->path += "/..";
+ d->cleanPathDirty = TRUE;
+ return TRUE;
+}
+
+#endif // QT_NO_NETWORKPROTOCOL
diff --git a/WebCore/kwq/qt/_qurl.h b/WebCore/kwq/qt/_qurl.h
new file mode 100644
index 0000000..3b212aa
--- /dev/null
+++ b/WebCore/kwq/qt/_qurl.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+** $Id$
+**
+** Definition of QUrl class
+**
+** Created : 950429
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the kernel 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.
+**
+**********************************************************************/
+
+#ifndef QURL_H
+#define QURL_H
+
+#ifndef QT_H
+#include "qstring.h"
+#include "_qdir.h"
+#endif // QT_H
+
+struct QUrlPrivate;
+
+class Q_EXPORT QUrl
+{
+public:
+ QUrl();
+ QUrl( const QString& url );
+ QUrl( const QUrl& url );
+ QUrl( const QUrl& url, const QString& relUrl, bool checkSlash = FALSE );
+ virtual ~QUrl();
+
+ QString protocol() const;
+ virtual void setProtocol( const QString& protocol );
+
+ QString user() const;
+ virtual void setUser( const QString& user );
+ bool hasUser() const;
+
+ QString password() const;
+ virtual void setPassword( const QString& pass );
+ bool hasPassword() const;
+
+ QString host() const;
+ virtual void setHost( const QString& user );
+ bool hasHost() const;
+
+ int port() const;
+ virtual void setPort( int port );
+
+ QString path( bool correct = TRUE ) const;
+ virtual void setPath( const QString& path );
+ bool hasPath() const;
+
+ virtual void setEncodedPathAndQuery( const QString& enc );
+ QString encodedPathAndQuery();
+
+ virtual void setQuery( const QString& txt );
+ QString query() const;
+
+ QString ref() const;
+ virtual void setRef( const QString& txt );
+ bool hasRef() const;
+
+ bool isValid() const;
+ bool isLocalFile() const;
+
+ virtual void addPath( const QString& path );
+ virtual void setFileName( const QString& txt );
+
+ QString fileName() const;
+ QString dirPath() const;
+
+ QUrl& operator=( const QUrl& url );
+ QUrl& operator=( const QString& url );
+
+ bool operator==( const QUrl& url ) const;
+ bool operator==( const QString& url ) const;
+
+ static void decode( QString& url );
+ static void encode( QString& url );
+
+ operator QString() const;
+ virtual QString toString( bool encodedPath = FALSE, bool forcePrependProtocol = TRUE ) const;
+
+ virtual bool cdUp();
+
+ static bool isRelativeUrl( const QString &url );
+
+protected:
+ virtual void reset();
+ virtual bool parse( const QString& url );
+
+private:
+ QUrlPrivate *d;
+
+};
+
+#endif
diff --git a/WebCore/kwq/qt/qbuffer.h b/WebCore/kwq/qt/qbuffer.h
index 4db04c7..d0ff927 100644
--- a/WebCore/kwq/qt/qbuffer.h
+++ b/WebCore/kwq/qt/qbuffer.h
@@ -30,6 +30,12 @@
#include <config.h>
#endif
+// USING_BORROWED_QBUFFER ======================================================
+
+#ifdef USING_BORROWED_QBUFFER
+#include <_qbuffer.h>
+#else
+
#include <KWQDef.h>
#include "qarray.h"
@@ -72,4 +78,6 @@ private:
}; // class QBuffer ============================================================
+#endif // USING_BORROWED_QBUFFER
+
#endif
diff --git a/WebCore/kwq/qt/qdir.h b/WebCore/kwq/qt/qdir.h
index 4fa412f..47e5a2c 100644
--- a/WebCore/kwq/qt/qdir.h
+++ b/WebCore/kwq/qt/qdir.h
@@ -30,6 +30,13 @@
#include <config.h>
#endif
+// USING_BORROWED_QDIR =========================================================
+
+#ifdef USING_BORROWED_QDIR
+#include <_qdir.h>
+#else
+
+#include <KWQDef.h>
#include "qstring.h"
#include "qstringlist.h"
#include "qfile.h"
@@ -68,4 +75,6 @@ public:
}; // class QDir ===============================================================
+#endif // USING_BORROWED_QDIR
+
#endif
diff --git a/WebCore/src/kwq/qt/Makefile.in b/WebCore/src/kwq/kde/Makefile.in
similarity index 96%
copy from WebCore/src/kwq/qt/Makefile.in
copy to WebCore/src/kwq/kde/Makefile.in
index 82e0aba..2b1becc 100644
--- a/WebCore/src/kwq/qt/Makefile.in
+++ b/WebCore/src/kwq/kde/Makefile.in
@@ -20,7 +20,7 @@ CXXOBJECTS = $(patsubst %.cpp,%.o,$(wildcard *.cpp))
OBJECTS = $(CXXOBJECTS)
-LIBRARY = lib_qt.a
+LIBRARY = lib_kde.a
CLEAN_FILES = *.o \
*.a \
@@ -31,6 +31,8 @@ CLEAN_FILES = *.o \
CXXFLAGS = $(BASECXXFLAGS) \
-I$(TOPSRCDIR) \
+ -I../kdecore \
+ -I../qt \
-I.. \
-I. \
$(NULL)
diff --git a/WebCore/src/kwq/kde/_kurl.cpp b/WebCore/src/kwq/kde/_kurl.cpp
new file mode 100644
index 0000000..feaaea4
--- /dev/null
+++ b/WebCore/src/kwq/kde/_kurl.cpp
@@ -0,0 +1,1547 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 1999 Torben Weis <weis at kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "_kurl.h"
+#include <kdebug.h>
+#include <kglobal.h>
+
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <_qurl.h>
+#include <_qdir.h>
+#include <qstringlist.h>
+
+#include <qtextcodec.h>
+#include <kcharsets.h>
+
+static QTextCodec * codecForHint( int encoding_hint /* not 0 ! */ )
+{
+/*
+ FIXME: hacking this out
+ // Get the charset name from encoding_hint - but KCharsets doesn't
+ // know about "unicode"
+ QString charsetName =
+ (encoding_hint == QFont::Unicode) ? QString::fromLatin1("utf8") :
+ KGlobal::charsets()->name( (QFont::CharSet) encoding_hint );
+
+ bool ok;
+ QTextCodec * textCodec = KGlobal::charsets()->codecForName( charsetName, ok );
+ return ok ? textCodec : 0L;
+*/
+ return 0L;
+}
+
+static QString encode( const QString& segment, bool encode_slash, int encoding_hint )
+{
+ char encode_extra = encode_slash ? '/' : 0;
+ QCString local;
+ if (encoding_hint==0)
+ local = segment.local8Bit();
+ else
+ {
+ QTextCodec * textCodec = codecForHint( encoding_hint );
+ if (!textCodec)
+ local = segment.local8Bit();
+ else {
+ // FIXME: ignoring encodings for now
+ //local = textCodec->fromUnicode( segment );
+ }
+ }
+
+ int old_length = local.length();
+
+ if ( !old_length )
+ return QString::null;
+
+ // a worst case approximation
+ QChar *new_segment = new QChar[ old_length * 3 + 1 ];
+ int new_length = 0;
+
+ for ( int i = 0; i < old_length; i++ )
+ {
+ // 'unsave' and 'reserved' characters
+ // according to RFC 1738,
+ // 2.2. URL Character Encoding Issues (pp. 3-4)
+ // WABA: Added non-ascii
+ unsigned char character = local[i];
+ if ( (character <= 32) || (character >= 127) ||
+ strchr("<>#@\"&%$:,;?={}|^~[]\'`\\", character) ||
+ (character == encode_extra) )
+ {
+ new_segment[ new_length++ ] = '%';
+
+ unsigned int c = character / 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+
+ c = character % 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+
+ }
+ else
+ new_segment[ new_length++ ] = local[i];
+ }
+
+ QString result = QString(new_segment, new_length);
+ delete [] new_segment;
+ return result;
+}
+
+static char hex2int( unsigned int _char )
+{
+ if ( _char >= 'A' && _char <='F')
+ return _char - 'A' + 10;
+ if ( _char >= 'a' && _char <='f')
+ return _char - 'a' + 10;
+ if ( _char >= '0' && _char <='9')
+ return _char - '0';
+ return -1;
+}
+
+// WABA: The result of lazy_encode isn't usable for a URL which
+// needs to satisfies RFC requirements. However, the following
+// operation will make it usable again:
+// encode(decode(...))
+//
+// As a result one can see that url.prettyURL() does not result in
+// a RFC compliant URL but that the following sequence does:
+// KURL(url.prettyURL()).url()
+
+
+static QString lazy_encode( const QString& segment )
+{
+ int old_length = segment.length();
+
+ if ( !old_length )
+ return QString::null;
+
+ // a worst case approximation
+ QChar *new_segment = new QChar[ old_length * 3 + 1 ];
+ int new_length = 0;
+
+ for ( int i = 0; i < old_length; i++ )
+ {
+ unsigned int character = segment[i].unicode(); // Don't use latin1()
+ // It returns 0 for non-latin1 values
+ // Small set of really ambiguous chars
+ if ((character < 32) || // Low ASCII
+ ((character == '%') && // The escape character itself
+ (i+2 < old_length) && // But only if part of a valid escape sequence!
+ (hex2int(segment[i+1].unicode())!= -1) &&
+ (hex2int(segment[i+2].unicode())!= -1)) ||
+ (character == '?') || // Start of query delimiter
+ (character == '#') || // Start of reference delimiter
+ ((character == 32) && (i+1 == old_length))) // A trailing space
+ {
+ new_segment[ new_length++ ] = '%';
+
+ unsigned int c = character / 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+
+ c = character % 16;
+ c += (c > 9) ? ('A' - 10) : '0';
+ new_segment[ new_length++ ] = c;
+ }
+ else
+ new_segment[ new_length++ ] = segment[i];
+ }
+
+ QString result = QString(new_segment, new_length);
+ delete [] new_segment;
+ return result;
+}
+
+static QString decode( const QString& segment, bool *keepEncoded=0, int encoding_hint=0 )
+{
+ bool isUnicode = false; // This detects utf-16, not utf-8
+ bool isLocal = false;
+ bool isAscii = true;
+ bool bKeepEncoded = true;
+ int old_length = segment.length();
+ if ( !old_length )
+ return QString::null;
+
+ int new_length = 0;
+
+ // make a copy of the old one
+ char *new_segment = new char[ old_length + 1];
+ QChar *new_usegment = new QChar[ old_length + 1 ];
+
+ int i = 0;
+ while( i < old_length )
+ {
+ unsigned int character = segment[ i++ ].unicode();
+ if ((character == ' ') || (character > 255))
+ bKeepEncoded = false;
+ if (character == '%' )
+ {
+ char a = i+1 < old_length ? hex2int( segment[i].latin1() ) : -1;
+ char b = i+1 < old_length ? hex2int( segment[i+1].latin1() ) : -1;
+ if ((a == -1) || (b == -1)) // Only replace if sequence is valid
+ {
+ // Contains stray %, make sure to re-encode!
+ bKeepEncoded = false;
+ }
+ else
+ {
+ // Valid %xx sequence
+ character = a * 16 + b; // Replace with value of %dd
+ i += 2; // Skip dd
+ if (character > 127)
+ isLocal = true;
+ }
+ }
+ new_segment [ new_length ] = character;
+ new_usegment [ new_length ] = character;
+ new_length++;
+ if (character > 127)
+ {
+ isAscii = false;
+ if (character > 255)
+ isUnicode = true;
+ }
+ }
+ new_segment [ new_length ] = 0;
+ QString result;
+ // Encoding specified
+ if ( encoding_hint )
+ {
+ QTextCodec * textCodec = codecForHint( encoding_hint );
+ // FIXME: ignoring encodings for now
+ /*
+ if (textCodec)
+ {
+ QByteArray array;
+ array.setRawData(new_segment, new_length);
+ result = textCodec->toUnicode( array, new_length );
+ array.resetRawData(new_segment, new_length);
+ }
+ else
+ */
+ result = QString::fromLocal8Bit(new_segment, new_length);
+ }
+ // Guess the encoding, if not specified
+ else if ((!isAscii && !isUnicode) || isLocal)
+ {
+ result = QString::fromLocal8Bit(new_segment, new_length);
+ }
+ else
+ {
+ result = QString( new_usegment, new_length);
+ }
+ if (keepEncoded)
+ *keepEncoded = bKeepEncoded;
+ delete [] new_segment;
+ delete [] new_usegment;
+ return result;
+}
+
+static QString cleanpath(const QString &path, bool cleanDirSeparator=true)
+{
+ if (path.isEmpty()) return QString::null;
+ // Did we have a trailing '/'
+ int len = path.length();
+ bool slash = false;
+ if ( len > 0 && path.right(1)[0] == '/' )
+ slash = true;
+
+ // The following code cleans up directory path much like
+ // QDir::cleanDirPath() except it can be made to ignore multiple
+ // directory separators by setting the flag to false. That fixes
+ // bug# 15044, mail.altavista.com and other similar brain-dead server
+ // implementations that do not follow what has been specified in
+ // RFC 2396!! (dA)
+ QString result;
+ int cdUp, orig_pos, pos;
+
+ cdUp = 0;
+ pos = orig_pos = len;
+ while ( pos && (pos = path.findRev('/',--pos)) != -1 )
+ {
+ len = orig_pos - pos - 1;
+ if ( len == 2 && path[pos+1] == '.' && path[pos+2] == '.' )
+ cdUp++;
+ else
+ {
+ // Ignore any occurances of '.' This includes entries
+ // that simply do not make sense like /..../
+ if ( (len!=0 || !cleanDirSeparator) && (len != 1 || path[pos+1] != '.') )
+ {
+ if ( !cdUp )
+ result = path.mid(pos, len+1) + result;
+ else
+ cdUp--;
+ }
+ }
+ orig_pos = pos;
+ }
+
+ if ( result.isEmpty() )
+ result = "/";
+
+ // Restore the trailing '/'
+ len = result.length();
+ if ( len > 0 && result.right(1)[0] != '/' && slash )
+ result += "/";
+ return result;
+}
+
+bool KURL::isRelativeURL(const QString &_url)
+{
+ int len = _url.length();
+ if (!len) return true; // Very short relative URL.
+ const QChar *str = _url.unicode();
+
+ // Absolute URL must start with alpha-character
+ if (!isalpha(str[0].latin1()))
+ return true; // Relative URL
+
+ for(int i = 1; i < len; i++)
+ {
+ char c = str[i].latin1(); // Note: non-latin1 chars return 0!
+ if (c == ':')
+ return false; // Absolute URL
+
+ // Protocol part may only contain alpha, digit, + or -
+ if (!isalpha(c) && !isdigit(c) && (c != '+') && (c != '-'))
+ return true; // Relative URL
+ }
+ // URL did not contain ':'
+ return true; // Relative URL
+}
+
+KURL::List::List(const QStringList &list)
+{
+ for (QStringList::ConstIterator it = list.begin();
+ it != list.end();
+ it++)
+ {
+ append( KURL(*it) );
+ }
+}
+
+QStringList KURL::List::toStringList() const
+{
+ QStringList lst;
+ for( KURL::List::ConstIterator it = begin();
+ it != end();
+ it++)
+ {
+ lst.append( (*it).url() );
+ }
+ return lst;
+}
+
+
+KURL::KURL()
+{
+ reset();
+}
+
+KURL::~KURL()
+{
+}
+
+
+KURL::KURL( const QString &url, int encoding_hint )
+{
+ reset();
+ parse( url, encoding_hint );
+}
+
+KURL::KURL( const char * url, int encoding_hint )
+{
+ reset();
+ parse( QString::fromLatin1(url), encoding_hint );
+}
+
+KURL::KURL( const KURL& _u )
+{
+ m_strProtocol = _u.m_strProtocol;
+ m_strUser = _u.m_strUser;
+ m_strPass = _u.m_strPass;
+ m_strHost = _u.m_strHost;
+ m_strPath = _u.m_strPath;
+ m_strPath_encoded = _u.m_strPath_encoded;
+ m_strQuery_encoded = _u.m_strQuery_encoded;
+ m_strRef_encoded = _u.m_strRef_encoded;
+ m_bIsMalformed = _u.m_bIsMalformed;
+ m_iPort = _u.m_iPort;
+}
+
+#ifndef QT_NO_DATASTREAM
+QDataStream & operator<< (QDataStream & s, const KURL & a)
+{
+ s << a.m_strProtocol << a.m_strUser << a.m_strPass << a.m_strHost
+ << a.m_strPath << a.m_strPath_encoded << a.m_strQuery_encoded << a.m_strRef_encoded
+ << Q_INT8(a.m_bIsMalformed ? 1 : 0) << a.m_iPort;
+ return s;
+}
+
+QDataStream & operator>> (QDataStream & s, KURL & a)
+{
+ Q_INT8 malf;
+ s >> a.m_strProtocol >> a.m_strUser >> a.m_strPass >> a.m_strHost
+ >> a.m_strPath >> a.m_strPath_encoded >> a.m_strQuery_encoded >> a.m_strRef_encoded
+ >> malf >> a.m_iPort;
+ a.m_bIsMalformed = (malf != 0);
+
+ if ( a.m_strQuery_encoded.isEmpty() )
+ a.m_strQuery_encoded = QString::null;
+
+ return s;
+}
+#endif
+
+KURL::KURL( const QUrl &u )
+{
+ m_strProtocol = u.protocol();
+ m_strUser = u.user();
+ m_strPass = u.password();
+ m_strHost = u.host();
+ m_strPath = u.path( FALSE );
+ m_strPath_encoded = QString::null;
+ m_strQuery_encoded = u.query();
+ m_strRef_encoded = u.ref();
+ m_bIsMalformed = !u.isValid();
+ m_iPort = u.port();
+}
+
+KURL::KURL( const KURL& _u, const QString& _rel_url, int encoding_hint )
+{
+ // WORKAROUND THE RFC 1606 LOOPHOLE THAT ALLOWS
+ // http:/index.html AS A VALID SYNTAX FOR RELATIVE
+ // URLS. ( RFC 2396 section 5.2 item # 3 )
+ QString rUrl = _rel_url;
+ int len = _u.m_strProtocol.length();
+ if ( !_u.m_strHost.isEmpty() && !rUrl.isEmpty() &&
+ rUrl.find( _u.m_strProtocol, 0, false ) == 0 &&
+ rUrl[len] == ':' && (rUrl[len+1] != '/' ||
+ (rUrl[len+1] == '/' && rUrl[len+2] != '/')) )
+ {
+ rUrl.remove( 0, rUrl.find( ':' ) + 1 );
+ }
+
+ if ( rUrl.isEmpty() )
+ {
+ *this = _u;
+ }
+ else if ( rUrl[0] == '#' )
+ {
+ *this = _u;
+ setHTMLRef( decode(rUrl.mid(1), 0, encoding_hint) );
+ }
+ else if ( isRelativeURL( rUrl) )
+ {
+ *this = _u;
+ m_strQuery_encoded = QString::null;
+ m_strRef_encoded = QString::null;
+ if ( rUrl[0] == '/')
+ {
+ if ((rUrl.length() > 1) && (rUrl[1] == '/'))
+ {
+ m_strHost = QString::null;
+ }
+ m_strPath = QString::null;
+ m_strPath_encoded = QString::null;
+ }
+ else if ( rUrl[0] != '?' )
+ {
+ int pos = m_strPath.findRev( '/' );
+ if (pos >= 0)
+ m_strPath.truncate(pos);
+ m_strPath += '/';
+ if (!m_strPath_encoded.isEmpty())
+ {
+ pos = m_strPath_encoded.findRev( '/' );
+ if (pos >= 0)
+ m_strPath_encoded.truncate(pos);
+ m_strPath_encoded += '/';
+ }
+ }
+ else
+ {
+ if ( m_strPath.isEmpty() )
+ m_strPath = '/';
+ }
+ KURL tmp( url() + rUrl, encoding_hint);
+ *this = tmp;
+ cleanPath(false);
+ }
+ else
+ {
+ KURL tmp( rUrl, encoding_hint);
+ *this = tmp;
+ }
+}
+
+void KURL::reset()
+{
+ m_strProtocol = QString::null;
+ m_strUser = QString::null;
+ m_strPass = QString::null;
+ m_strHost = QString::null;
+ m_strPath = QString::null;
+ m_strPath_encoded = QString::null;
+ m_strQuery_encoded = QString::null;
+ m_strRef_encoded = QString::null;
+ m_bIsMalformed = true;
+ m_iPort = 0;
+}
+
+bool KURL::isEmpty() const
+{
+ return (m_strPath.isEmpty() && m_strProtocol.isEmpty());
+}
+
+void KURL::parse( const QString& _url, int encoding_hint )
+{
+ // Return immediately whenever the given url
+ // is empty or null.
+ if ( _url.isEmpty() )
+ {
+ m_strProtocol = _url;
+ return;
+ }
+
+ QString port;
+ int start = 0;
+ uint len = _url.length();
+ QChar* buf = new QChar[ len + 1 ];
+ QChar* orig = buf;
+ memcpy( buf, _url.unicode(), len * sizeof( QChar ) );
+
+ uint pos = 0;
+
+ // Node 1: Accept alpha or slash
+ QChar x = buf[pos++];
+ if ( x == '/' )
+ goto Node9;
+ if ( !isalpha( (int)x ) )
+ goto NodeErr;
+
+ // Node 2: Accept any amount of (alpha|digit|'+'|'-')
+ // '.' is not currently accepted, because current KURL may be confused.
+ // Proceed with :// :/ or :
+ while( (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) ||
+ buf[pos] == '+' || buf[pos] == '-') &&
+ pos < len ) pos++;
+ if ( pos == len - 1 ) // Need to always compare length()-1 otherwise KURL passes "http:" as legal!!! (DA)
+ goto NodeErr;
+ if (buf[pos] == ':' && buf[pos+1] == '/' && buf[pos+2] == '/' )
+ {
+ m_strProtocol = QString( orig, pos ).lower();
+ pos += 3;
+ }
+ else if (buf[pos] == ':' && buf[pos+1] == '/' )
+ {
+ m_strProtocol = QString( orig, pos ).lower();
+ pos++;
+ start = pos;
+ goto Node9;
+ }
+ else if ( buf[pos] == ':' )
+ {
+ m_strProtocol = QString( orig, pos ).lower();
+ pos++;
+ goto Node11;
+ }
+ else
+ goto NodeErr;
+
+ //Node 3: We need at least one character here
+ if ( pos == len )
+ goto NodeErr;
+ start = pos;
+
+ // Node 4: Accept any amount of characters.
+ if (buf[pos] == '[') // An IPv6 host follows.
+ goto Node8;
+ // Terminate on / or @ or ? or #
+ x = buf[pos];
+ while( (x != ':') && (x != '@') && (x != '/') && (x != '?') && (x != '#') && (pos < len) )
+ x = buf[++pos];
+ if ( pos == len )
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ goto NodeOk;
+ }
+ if ( x == '@' )
+ {
+ m_strUser = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ pos++;
+ goto Node7;
+ }
+ /* else if ( x == ':' )
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ pos++;
+ goto Node8a;
+ } */
+ else if ( (x == '/') || (x == '?') || (x == '#'))
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ start = pos;
+ goto Node9;
+ }
+ else if ( x != ':' )
+ goto NodeErr;
+ m_strUser = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ pos++;
+
+ // Node 5: We need at least one character
+ if ( pos == len )
+ goto NodeErr;
+ start = pos++;
+
+ // Node 6: Read everything until @, /, ? or #
+ while( (pos < len) &&
+ (buf[pos] != '@') &&
+ (buf[pos] != '/') &&
+ (buf[pos] != '?') &&
+ (buf[pos] != '#')) pos++;
+ // If we now have a '@' the ':' seperates user and password.
+ // Otherwise it seperates host and port.
+ if ( (pos == len) || (buf[pos] != '@') )
+ {
+ // Ok the : was used to separate host and port
+ m_strHost = m_strUser;
+ m_strUser = QString::null;
+ QString tmp( buf + start, pos - start );
+ char *endptr;
+ m_iPort = (unsigned short int)strtol(tmp.ascii(), &endptr, 10);
+ if ((pos == len) && (strlen(endptr) == 0))
+ goto NodeOk;
+ // there is more after the digits
+ pos -= strlen(endptr);
+ start = pos++;
+ goto Node9;
+ }
+ m_strPass = decode(QString( buf + start, pos - start), 0, encoding_hint);
+ pos++;
+
+ // Node 7: We need at least one character
+ Node7:
+ if ( pos == len )
+ goto NodeErr;
+
+ Node8:
+ if (buf[pos] == '[')
+ {
+ // IPv6 address
+ start = ++pos; // Skip '['
+
+ // Node 8b: Read everything until ] or terminate
+ while( buf[pos] != ']' && pos < len ) pos++;
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ if (pos < len) pos++; // Skip ']'
+ if (pos == len)
+ goto NodeOk;
+ }
+ else
+ {
+ // Non IPv6 address
+ start = pos++;
+
+ // Node 8b: Read everything until / : or terminate
+ while( buf[pos] != '/' && buf[pos] != ':' && pos < len ) pos++;
+ if ( pos == len )
+ {
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ goto NodeOk;
+ }
+ m_strHost = decode(QString( buf + start, pos - start ), 0, encoding_hint);
+ }
+ x = buf[pos];
+ if ( x == '/' )
+ {
+ start = pos++;
+ goto Node9;
+ }
+ else if ( x != ':' )
+ goto NodeErr;
+ pos++;
+
+ // Node 8a: Accept at least one digit
+ if ( pos == len )
+ goto NodeErr;
+ start = pos;
+ if ( !isdigit( buf[pos++] ) )
+ goto NodeErr;
+
+ // Node 8b: Accept any amount of digits
+ while( isdigit( buf[pos] ) && pos < len ) pos++;
+ port = QString( buf + start, pos - start );
+ m_iPort = port.toUShort();
+ if ( pos == len )
+ goto NodeOk;
+ start = pos++;
+
+ // Node 9: Accept any character and # or terminate
+ Node9:
+ while( buf[pos] != '#' && pos < len ) pos++;
+ if ( pos == len )
+ {
+ QString tmp( buf + start, len - start );
+ setEncodedPathAndQuery( tmp, encoding_hint );
+ // setEncodedPathAndQuery( QString( buf + start, pos - start ) );
+ goto NodeOk;
+ }
+ else if ( buf[pos] != '#' )
+ goto NodeErr;
+ setEncodedPathAndQuery( QString( buf + start, pos - start ), encoding_hint );
+ pos++;
+
+ // Node 10: Accept all the rest
+ m_strRef_encoded = QString( buf + pos, len - pos );
+ goto NodeOk;
+
+ // Node 11 We need at least one character
+ Node11:
+ start = pos;
+ if ( pos++ == len )
+ goto NodeOk; // Wrong, but since a fix was applied up top it is a non-issue here!!!!
+ // Just for the record an opaque URL such as "mailto:" is always required
+ // to have at least one more character other than a '/' following the colon.
+ // Node 12: Accept the res
+ setEncodedPathAndQuery( QString( buf + start, len - start ), encoding_hint );
+ goto NodeOk;
+
+ NodeOk:
+ delete []orig;
+ m_bIsMalformed = false; // Valid URL
+ if (m_strProtocol.isEmpty())
+ m_strProtocol = "file";
+
+ //debug("Prot=%s\nUser=%s\nPass=%s\nHost=%s\nPath=%s\nQuery=%s\nRef=%s\nPort=%i\n",
+ //m_strProtocol.ascii(), m_strUser.ascii(), m_strPass.ascii(),
+ //m_strHost.ascii(), m_strPath.ascii(), m_strQuery_encoded.ascii(),
+ //m_strRef_encoded.ascii(), m_iPort );
+ if (m_strProtocol == "file")
+ {
+ if (!m_strHost.isEmpty())
+ {
+ // File-protocol has a host name..... hmm?
+ if (m_strHost.lower() == "localhost")
+ {
+ m_strHost = QString::null; // We can ignore localhost
+ }
+ else {
+ // Pass the hostname as part of the path. Perhaps system calls
+ // just handle it.
+ m_strPath = "//"+m_strHost+m_strPath;
+ m_strPath_encoded = QString::null;
+ m_strHost = QString::null;
+ }
+ }
+ }
+ return;
+
+ NodeErr:
+ cerr << "KURL couldn't parse URL \"" << _url << "\"" << endl;
+ delete []orig;
+ reset();
+ m_strProtocol = _url;
+}
+
+KURL& KURL::operator=( const QString& _url )
+{
+ reset();
+ parse( _url );
+
+ return *this;
+}
+
+KURL& KURL::operator=( const char * _url )
+{
+ reset();
+ parse( QString::fromLatin1(_url) );
+
+ return *this;
+}
+
+KURL& KURL::operator=( const QUrl & u )
+{
+ m_strProtocol = u.protocol();
+ m_strUser = u.user();
+ m_strPass = u.password();
+ m_strHost = u.host();
+ m_strPath = u.path( FALSE );
+ m_strPath_encoded = QString::null;
+ m_strQuery_encoded = u.query();
+ m_strRef_encoded = u.ref();
+ m_bIsMalformed = !u.isValid();
+ m_iPort = u.port();
+
+ return *this;
+}
+
+KURL& KURL::operator=( const KURL& _u )
+{
+ m_strProtocol = _u.m_strProtocol;
+ m_strUser = _u.m_strUser;
+ m_strPass = _u.m_strPass;
+ m_strHost = _u.m_strHost;
+ m_strPath = _u.m_strPath;
+ m_strPath_encoded = _u.m_strPath_encoded;
+ m_strQuery_encoded = _u.m_strQuery_encoded;
+ m_strRef_encoded = _u.m_strRef_encoded;
+ m_bIsMalformed = _u.m_bIsMalformed;
+ m_iPort = _u.m_iPort;
+
+ return *this;
+}
+
+bool KURL::operator==( const KURL& _u ) const
+{
+ if ( isMalformed() || _u.isMalformed() )
+ return false;
+
+ if ( m_strProtocol == _u.m_strProtocol &&
+ m_strUser == _u.m_strUser &&
+ m_strPass == _u.m_strPass &&
+ m_strHost == _u.m_strHost &&
+ m_strPath == _u.m_strPath &&
+ // The encoded path may be null, but the URLs are still equal (David)
+ ( m_strPath_encoded.isNull() || _u.m_strPath_encoded.isNull() ||
+ m_strPath_encoded == _u.m_strPath_encoded ) &&
+ m_strQuery_encoded == _u.m_strQuery_encoded &&
+ m_strRef_encoded == _u.m_strRef_encoded &&
+ m_iPort == _u.m_iPort )
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool KURL::operator==( const QString& _u ) const
+{
+ KURL u( _u );
+ return ( *this == u );
+}
+
+bool KURL::cmp( const KURL &_u, bool _ignore_trailing ) const
+{
+ if ( isMalformed() || _u.isMalformed() )
+ return false;
+
+ if ( _ignore_trailing )
+ {
+ QString path1 = path(1);
+ QString path2 = _u.path(1);
+ if ( path1 != path2 )
+ return false;
+
+ if ( m_strProtocol == _u.m_strProtocol &&
+ m_strUser == _u.m_strUser &&
+ m_strPass == _u.m_strPass &&
+ m_strHost == _u.m_strHost &&
+ m_strQuery_encoded == _u.m_strQuery_encoded &&
+ m_strRef_encoded == _u.m_strRef_encoded &&
+ m_iPort == _u.m_iPort )
+ return true;
+
+ return false;
+ }
+
+ return ( *this == _u );
+}
+
+bool KURL::isParentOf( const KURL& _u ) const
+{
+ if ( isMalformed() || _u.isMalformed() )
+ return false;
+
+ if ( m_strProtocol == _u.m_strProtocol &&
+ m_strUser == _u.m_strUser &&
+ m_strPass == _u.m_strPass &&
+ m_strHost == _u.m_strHost &&
+ m_strQuery_encoded == _u.m_strQuery_encoded &&
+ m_strRef_encoded == _u.m_strRef_encoded &&
+ m_iPort == _u.m_iPort )
+ {
+ if ( path().isEmpty() || _u.path().isEmpty() )
+ return false; // can't work with implicit paths
+
+ QString p1( cleanpath( path() ) );
+ if ( p1[p1.length()-1] != '/' )
+ p1 += '/';
+ QString p2( cleanpath( _u.path() ) );
+ if ( p2[p2.length()-1] != '/' )
+ p2 += '/';
+
+ //kdDebug(126) << "p1=" << p1 << endl;
+ //kdDebug(126) << "p2=" << p2 << endl;
+ //kdDebug(126) << "p1.length()=" << p1.length() << endl;
+ //kdDebug(126) << "p2.left(!$)=" << p2.left( p1.length() ) << endl;
+ return p2.startsWith( p1 );
+ }
+ return false;
+}
+
+void KURL::setFileName( const QString& _txt )
+{
+ m_strRef_encoded = QString::null;
+ int i = 0;
+ while( _txt[i] == '/' ) ++i;
+ QString tmp;
+ if ( i )
+ tmp = _txt.mid( i );
+ else
+ tmp = _txt;
+
+ QString path = m_strPath;
+ if ( path.isEmpty() )
+ path = "/";
+ else
+ {
+ int lastSlash = path.findRev( '/' );
+ if ( lastSlash == -1)
+ {
+ // The first character is not a '/' ???
+ // This looks strange ...
+ path = "/";
+ }
+ else if ( path.right(1) != "/" )
+ path.truncate( lastSlash+1 ); // keep the "/"
+ }
+
+ path += tmp;
+ setPath( path );
+ cleanPath();
+}
+
+void KURL::cleanPath()
+{
+ cleanPath( true );
+}
+
+void KURL::cleanPath( bool cleanDirSeparator ) // taken from the old KURL
+{
+ m_strPath = cleanpath(m_strPath, cleanDirSeparator);
+ // WABA: Is this safe when "/../" is encoded with %?
+ m_strPath_encoded = cleanpath(m_strPath_encoded, cleanDirSeparator);
+}
+
+static QString trailingSlash( int _trailing, const QString &path )
+{
+ QString result = path;
+
+ if ( _trailing == 0 )
+ return result;
+ else if ( _trailing == 1 )
+ {
+ int len = result.length();
+ if ( len == 0 )
+ result = QString::null;
+ else if ( result[ len - 1 ] != '/' )
+ result += "/";
+ return result;
+ }
+ else if ( _trailing == -1 )
+ {
+ if ( result == "/" )
+ return result;
+ int len = result.length();
+ if ( len != 0 && result[ len - 1 ] == '/' )
+ result.truncate( len - 1 );
+ return result;
+ }
+ else {
+ assert( 0 );
+ return QString::null;
+ }
+}
+
+
+QString KURL::encodedPathAndQuery( int _trailing, bool _no_empty_path, int encoding_hint ) const
+{
+ QString tmp;
+ if (!m_strPath_encoded.isEmpty() && encoding_hint == 0)
+ {
+ tmp = trailingSlash( _trailing, m_strPath_encoded );
+ }
+ else
+ {
+ tmp = path( _trailing );
+ if ( _no_empty_path && tmp.isEmpty() )
+ tmp = "/";
+ tmp = encode( tmp, false, encoding_hint );
+ }
+
+ // TODO apply encoding_hint to the query
+ tmp += m_strQuery_encoded;
+ return tmp;
+}
+
+void KURL::setEncodedPathAndQuery( const QString& _txt, int encoding_hint )
+{
+ int pos = _txt.find( '?' );
+ if ( pos == -1 )
+ {
+ m_strPath_encoded = _txt;
+ m_strQuery_encoded = QString::null;
+ }
+ else
+ {
+ m_strPath_encoded = _txt.left( pos );
+ m_strQuery_encoded = _txt.right(_txt.length() - pos);
+ }
+ bool keepEncoded;
+ m_strPath = decode( m_strPath_encoded, &keepEncoded, encoding_hint );
+ if (!keepEncoded)
+ m_strPath_encoded = QString::null;
+}
+
+QString KURL::path( int _trailing ) const
+{
+ return trailingSlash( _trailing, path() );
+}
+
+bool KURL::isLocalFile() const
+{
+ QString fileProt = "file";
+ return ( ( m_strProtocol == fileProt ) && ( m_strHost.isEmpty()) );
+}
+
+bool KURL::hasSubURL() const
+{
+ if ( m_strProtocol.isEmpty() || m_bIsMalformed )
+ return false;
+ if (m_strRef_encoded.isEmpty())
+ return false;
+ if (m_strRef_encoded.startsWith("gzip:"))
+ return true;
+ if (m_strRef_encoded.startsWith("bzip:"))
+ return true;
+ if (m_strRef_encoded.startsWith("bzip2:"))
+ return true;
+ if (m_strRef_encoded.startsWith("tar:"))
+ return true;
+ return false;
+}
+
+// BCI: Should be removed, and the other one should have '= 0' for both args.
+QString KURL::url( int _trailing ) const
+{
+ return url( _trailing, 0 );
+}
+
+QString KURL::url( int _trailing, int encoding_hint ) const
+{
+ if( m_bIsMalformed )
+ {
+ // Return the whole url even when the url is
+ // malformed. Under such conditions the url
+ // is stored in m_strProtocol.
+ return m_strProtocol;
+ }
+
+ QString u = m_strProtocol.copy();
+ if ( hasHost() )
+ {
+ u += "://";
+ if ( hasUser() )
+ {
+ u += encode(m_strUser, true, encoding_hint);
+ if ( hasPass() )
+ {
+ u += ":";
+ u += encode(m_strPass, true, encoding_hint);
+ }
+ u += "@";
+ }
+ bool IPv6 = (m_strHost.find(':') != -1);
+ if (IPv6)
+ u += '[' + m_strHost + ']';
+ else
+ u += encode(m_strHost, true, encoding_hint);
+ if ( m_iPort != 0 ) {
+ QString buffer;
+ buffer.sprintf( ":%u", m_iPort );
+ u += buffer;
+ }
+ }
+ else
+ u += ":";
+
+ u += encodedPathAndQuery( _trailing, false, encoding_hint );
+
+ if ( hasRef() )
+ {
+ u += "#";
+ u += m_strRef_encoded;
+ }
+
+ return u;
+}
+
+QString KURL::prettyURL( int _trailing ) const
+{
+ if( m_bIsMalformed )
+ {
+ // Return the whole url even when the url is
+ // malformed. Under such conditions the url
+ // is stored in m_strProtocol.
+ return m_strProtocol;
+ }
+
+ QString u = m_strProtocol.copy();
+ if ( hasHost() )
+ {
+ u += "://";
+ if ( hasUser() )
+ {
+ u += lazy_encode(m_strUser);
+ // Don't show password!
+ u += "@";
+ }
+ bool IPv6 = (m_strHost.find(':') != -1);
+ if (IPv6)
+ u += '[' + m_strHost + ']';
+ else
+ u += lazy_encode(m_strHost);
+ if ( m_iPort != 0 ) {
+ QString buffer;
+ buffer.sprintf( ":%u", m_iPort );
+ u += buffer;
+ }
+ }
+ else
+ {
+ u += ":";
+ }
+
+ u += trailingSlash( _trailing, lazy_encode( m_strPath ) );
+
+ u += m_strQuery_encoded;
+
+ if ( hasRef() )
+ {
+ u += "#";
+ u += m_strRef_encoded;
+ }
+
+ return u;
+}
+
+KURL::List KURL::split( const KURL& _url )
+{
+ QString ref;
+ KURL::List lst;
+ KURL url = _url;
+
+ while(true)
+ {
+ KURL u = url;
+ u.m_strRef_encoded = QString::null;
+ lst.append(u);
+ if (url.hasSubURL())
+ {
+ url = KURL(url.m_strRef_encoded);
+ }
+ else
+ {
+ ref = url.m_strRef_encoded;
+ break;
+ }
+ }
+
+ // Set HTML ref in all URLs.
+ KURL::List::Iterator it;
+ for( it = lst.begin() ; it != lst.end(); ++it )
+ {
+ (*it).m_strRef_encoded = ref;
+ }
+
+ return lst;
+}
+
+KURL::List KURL::split( const QString& _url )
+{
+ return split(KURL(_url));
+}
+
+KURL KURL::join( const KURL::List & lst )
+{
+ if (lst.isEmpty()) return KURL();
+ KURL tmp;
+
+ KURL::List::ConstIterator first = lst.fromLast();
+ for( KURL::List::ConstIterator it = first; it != lst.end(); --it )
+ {
+ KURL u(*it);
+ if (it != first)
+ {
+ u.m_strRef_encoded = tmp.url();
+ }
+ tmp = u;
+ }
+
+ return tmp;
+}
+
+QString KURL::fileName( bool _strip_trailing_slash ) const
+{
+ QString fname;
+
+ int len = m_strPath.length();
+ if ( len == 0 )
+ return fname;
+
+ if ( _strip_trailing_slash )
+ {
+ while ( len >= 1 && m_strPath[ len - 1 ] == '/' )
+ len--;
+ }
+ else if ( m_strPath[ len - 1 ] == '/' )
+ return fname;
+
+ // Does the path only consist of '/' characters ?
+ if ( len == 1 && m_strPath[ 0 ] == '/' )
+ return fname;
+
+ int i = m_strPath.findRev( '/', len - 1 );
+ // If ( i == -1 ) => the first character is not a '/'
+ // So it's some URL like file:blah.tgz, return the whole path
+ if ( i == -1 ) {
+ if ( len == m_strPath.length() )
+ return m_strPath;
+ else
+ // Might get here if _strip_trailing_slash is true
+ return m_strPath.left( len );
+ }
+
+ fname = m_strPath.mid( i + 1, len - i - 1 ); // TO CHECK
+ // fname.assign( m_strPath, i + 1, len - i - 1 );
+ return fname;
+}
+
+void KURL::addPath( const QString& _txt )
+{
+ m_strPath_encoded = QString::null;
+
+ if ( _txt.isEmpty() )
+ return;
+
+ int i = 0;
+ int len = m_strPath.length();
+ // NB: avoid three '/' when building a new path from nothing
+ if ( len == 0 ) {
+ while( _txt[i] == '/' ) ++i;
+ }
+ // Add the trailing '/' if it is missing
+ else if ( _txt[0] != '/' && ( len == 0 || m_strPath[ len - 1 ] != '/' ) )
+ m_strPath += "/";
+
+ // No double '/' characters
+ i = 0;
+ if ( len != 0 && m_strPath[ len - 1 ] == '/' )
+ {
+ while( _txt[i] == '/' )
+ ++i;
+ }
+
+ m_strPath += _txt.mid( i );
+}
+
+QString KURL::directory( bool _strip_trailing_slash_from_result,
+ bool _ignore_trailing_slash_in_path ) const
+{
+ QString result;
+ if ( _ignore_trailing_slash_in_path )
+ result = path( -1 );
+ else
+ result = m_strPath;
+
+ if ( result.isEmpty() || result == "/" )
+ return result;
+
+ int i = result.findRev( "/" );
+ // If ( i == -1 ) => the first character is not a '/'
+ // So it's some URL like file:blah.tgz, with no path
+ if ( i == -1 )
+ return QString::null;
+
+ if ( i == 0 )
+ {
+ result = "/";
+ return result;
+ }
+
+ if ( _strip_trailing_slash_from_result )
+ result = m_strPath.left( i );
+ else
+ result = m_strPath.left( i + 1 );
+
+ return result;
+}
+
+
+bool KURL::cd( const QString& _dir )
+{
+ if ( _dir.isEmpty() || m_bIsMalformed )
+ return false;
+
+ if (hasSubURL())
+ {
+ KURL::List lst = split( *this );
+ KURL &u = lst.last();
+ u.cd(_dir);
+ *this = join( lst );
+ return true;
+ }
+
+ // absolute path ?
+ if ( _dir[0] == '/' )
+ {
+ m_strPath_encoded = QString::null;
+ m_strPath = _dir;
+ setHTMLRef( QString::null );
+ m_strQuery_encoded = QString::null;
+ return true;
+ }
+
+ // Users home directory on the local disk ?
+ if ( ( _dir[0] == '~' ) && ( m_strProtocol == "file" ))
+ {
+ m_strPath_encoded = QString::null;
+ m_strPath = QDir::homeDirPath().copy();
+ m_strPath += "/";
+ m_strPath += _dir.right(m_strPath.length() - 1);
+ setHTMLRef( QString::null );
+ m_strQuery_encoded = QString::null;
+ return true;
+ }
+
+ // relative path
+ // we always work on the past of the first url.
+ // Sub URLs are not touched.
+
+ // append '/' if necessary
+ QString p = path(1);
+ p += _dir;
+ p = cleanpath( p );
+ setPath( p );
+
+ setHTMLRef( QString::null );
+ m_strQuery_encoded = QString::null;
+
+ return true;
+}
+
+KURL KURL::upURL( ) const
+{
+ if (!hasSubURL())
+ {
+ KURL u(*this);
+ u.cd("../");
+ return u;
+ }
+
+ // We have a subURL.
+ KURL::List lst = split( *this );
+ if (lst.isEmpty())
+ return KURL(); // Huh?
+ while (true)
+ {
+ KURL &u = lst.last();
+ QString old = u.path();
+ u.cd("../");
+ if (u.path() != old)
+ break; // Finshed.
+ if (lst.count() == 1)
+ break; // Finished.
+ lst.remove(lst.fromLast());
+ }
+ return join( lst );
+}
+
+QString KURL::htmlRef() const
+{
+ if ( !hasSubURL() )
+ {
+ return decode( ref() );
+ }
+
+ List lst = split( *this );
+ return decode( (*lst.begin()).ref() );
+}
+
+QString KURL::encodedHtmlRef() const
+{
+ if ( !hasSubURL() )
+ {
+ return ref();
+ }
+
+ List lst = split( *this );
+ return (*lst.begin()).ref();
+}
+
+void KURL::setHTMLRef( const QString& _ref )
+{
+ if ( !hasSubURL() )
+ {
+ m_strRef_encoded = encode( _ref, true, 0 /*?*/);
+ return;
+ }
+
+ List lst = split( *this );
+
+ (*lst.begin()).setRef( encode( _ref, true, 0 /*?*/) );
+
+ *this = join( lst );
+}
+
+bool KURL::hasHTMLRef() const
+{
+ if ( !hasSubURL() )
+ {
+ return hasRef();
+ }
+
+ List lst = split( *this );
+ return (*lst.begin()).hasRef();
+}
+
+void
+KURL::setProtocol( const QString& _txt )
+{
+ m_strProtocol = _txt;
+ m_bIsMalformed = false;
+}
+
+void
+KURL::setUser( const QString& _txt )
+{
+ m_strUser = _txt;
+}
+
+void
+KURL::setPass( const QString& _txt )
+{
+ m_strPass = _txt;
+}
+
+void
+KURL::setHost( const QString& _txt )
+{
+ m_strHost = _txt;
+}
+
+void
+KURL::setPort( unsigned short int _p )
+{
+ m_iPort = _p;
+}
+
+void KURL::setPath( const QString & path )
+{
+ if (isEmpty())
+ m_bIsMalformed = false;
+ if (m_strProtocol.isEmpty())
+ m_strProtocol = "file";
+ m_strPath = path;
+ m_strPath_encoded = QString::null;
+}
+
+void KURL::setQuery( const QString &_txt, int )
+{
+ if (_txt.length() && (_txt[0] !='?'))
+ m_strQuery_encoded = "?" + _txt;
+ else
+ m_strQuery_encoded = _txt;
+}
+
+QString KURL::decode_string(const QString &str, int encoding_hint)
+{
+ return decode(str, 0, encoding_hint);
+}
+
+QString KURL::encode_string(const QString &str, int encoding_hint)
+{
+ return encode(str, false, encoding_hint);
+}
+
+QString KURL::encode_string_no_slash(const QString &str, int encoding_hint)
+{
+ return encode(str, true, encoding_hint);
+}
+
+bool urlcmp( const QString& _url1, const QString& _url2 )
+{
+ // Both empty ?
+ if ( _url1.isEmpty() && _url2.isEmpty() )
+ return true;
+ // Only one empty ?
+ if ( _url1.isEmpty() || _url2.isEmpty() )
+ return false;
+
+ KURL::List list1 = KURL::split( _url1 );
+ KURL::List list2 = KURL::split( _url2 );
+
+ // Malformed ?
+ if ( list1.isEmpty() || list2.isEmpty() )
+ return false;
+
+ return ( list1 == list2 );
+}
+
+bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref )
+{
+ // Both empty ?
+ if ( _url1.isEmpty() && _url2.isEmpty() )
+ return true;
+ // Only one empty ?
+ if ( _url1.isEmpty() || _url2.isEmpty() )
+ return false;
+
+ KURL::List list1 = KURL::split( _url1 );
+ KURL::List list2 = KURL::split( _url2 );
+
+ // Malformed ?
+ if ( list1.isEmpty() || list2.isEmpty() )
+ return false;
+
+ unsigned int size = list1.count();
+ if ( list2.count() != size )
+ return false;
+
+ if ( _ignore_ref )
+ {
+ (*list1.begin()).setRef(QString::null);
+ (*list2.begin()).setRef(QString::null);
+ }
+
+ KURL::List::Iterator it1 = list1.begin();
+ KURL::List::Iterator it2 = list2.begin();
+ for( ; it1 != list1.end() ; ++it1, ++it2 )
+ if ( !(*it1).cmp( *it2, _ignore_trailing ) )
+ return false;
+
+ return true;
+}
+
diff --git a/WebCore/src/kwq/kde/_kurl.h b/WebCore/src/kwq/kde/_kurl.h
new file mode 100644
index 0000000..e198ad5
--- /dev/null
+++ b/WebCore/src/kwq/kde/_kurl.h
@@ -0,0 +1,578 @@
+/* This file is part of the KDE libraries
+ * Copyright (C) 1999 Torben Weis <weis at kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ **/
+
+#ifndef __kurl_h__
+#define __kurl_h__ "$Id$"
+
+#include <qstring.h>
+#include <qvaluelist.h>
+
+class QUrl;
+class QStringList;
+
+struct KURLPrivate;
+
+/**
+ * Represent and parse a URL.
+ *
+ * A prototypical URL looks like:
+ * <pre>
+ * protocol:/user:password at hostname:port/path/to/file.ext#reference
+ * </pre>
+ *
+ * @ref KURL has some restrictions regarding the path
+ * encoding. @ref KURL works internally with the decoded path and
+ * and encoded query. For example,
+ * <pre>
+ * http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you
+ * </pre>
+ * would result in a decoded path "/cgi-bin/test me.pl"
+ * and in the encoded query "?cmd=Hello%20you".
+ * Since path is internally always encoded you may @em not use
+ * "%00" in the path, although this is OK for the query.
+ *
+ * @author Torben Weis <weis at kde.org>
+ */
+class KURL
+{
+public:
+ class List : public QValueList<KURL>
+ {
+ public:
+ List() { }
+ List(const QStringList &);
+ QStringList toStringList() const;
+ };
+ /**
+ * Construct an empty URL.
+ */
+ KURL();
+
+ /**
+ * destruktor
+ */
+ ~KURL();
+
+ /**
+ * Usual constructor, to construct from a string.
+ * @param url A URL, not a filename. If the URL does not have a protocol
+ * part, "file:" is assumed.
+ * It is dangerous to feed unix filenames into this function,
+ * this will work most of the time but not always.
+ * For example "/home/Torben%20Weis" will be considered a URL
+ * pointing to the file "/home/Torben Weis" instead of to the
+ * file "/home/Torben%20Weis".
+ * This means that if you have a usual UNIX like path you
+ * should not use this constructor.
+ * Instead create an empty url and set the path by using
+ * @ref setPath().
+ * @param encoding_hint Reserved, should be 0.
+ */
+ KURL( const QString& url, int encoding_hint = 0 );
+ /**
+ * Constructor taking a char * @p url, which is an _encoded_ representation
+ * of the URL, exactly like the usual constructor. This is useful when
+ * then URL, in its encoded form, is strictly ascii.
+ */
+ KURL( const char * url, int encoding_hint = 0 );
+ /**
+ * Copy constructor
+ */
+ KURL( const KURL& u );
+ /**
+ * Convert from a @ref QUrl.
+ */
+ KURL( const QUrl &u );
+ /**
+ * Constructor allowing relative URLs.
+ *
+ * @param _baseurl The base url.
+ * @param _rel_url A relative or absolute URL.
+ * If this is an absolute URL then @p _baseurl will be ignored.
+ * If this is a relative URL it will be combined with @p _baseurl.
+ * Note that _rel_url should be encoded too, in any case.
+ * So do NOT pass a path here (use setPath or addPath instead).
+ * @param encoding_hint Reserved, should be 0.
+ */
+ KURL( const KURL& _baseurl, const QString& _rel_url, int encoding_hint=0 );
+
+ /**
+ * Retrieve the protocol for the URL (i.e., file, http, etc.).
+ **/
+ QString protocol() const { return m_bIsMalformed ? QString::null : m_strProtocol; }
+ /**
+ * Set the protocol for the URL (i.e., file, http, etc.)
+ **/
+ void setProtocol( const QString& _txt );
+
+ /**
+ * Retrieve the decoded user name (login, user id, ...) included in the URL.
+ **/
+ QString user() const { return m_strUser; }
+ /**
+ * Set the user name (login, user id, ...) included the URL.
+ *
+ * Special characters in the user name will appear encoded in the URL.
+ **/
+ void setUser( const QString& _txt );
+ /**
+ * Test to see if this URL has a user name included in it.
+ **/
+ bool hasUser() const { return !m_strUser.isEmpty(); }
+
+ /**
+ * Retrieve the decoded password (corresponding to @ref user()) included in the URL.
+ **/
+ QString pass() const { return m_strPass; }
+ /**
+ * Set the password (corresponding to @ref user()) included in the URL.
+ *
+ * Special characters in the password will appear encoded in the URL.
+ **/
+ void setPass( const QString& _txt );
+ /**
+ * Test to see if this URL has a password included in it.
+ **/
+ bool hasPass() const { return !m_strPass.isEmpty(); }
+
+ /**
+ * Retrieve the decoded hostname included in the URL.
+ **/
+ QString host() const { return m_strHost; }
+ /**
+ * Set the hostname included in the URL.
+ *
+ * Special characters in the hostname will appear encoded in the URL.
+ **/
+ void setHost( const QString& _txt );
+ /**
+ * Test to see if this URL has a hostname included in it.
+ **/
+ bool hasHost() const { return !m_strHost.isEmpty(); }
+
+ /**
+ * Retrieve the port number included in the URL.
+ * If there is no port number specified in the URL, returns 0.
+ **/
+ unsigned short int port() const { return m_iPort; }
+ /**
+ * Set the port number included in the URL.
+ **/
+ void setPort( unsigned short int _p );
+
+ /**
+ * @return The current decoded path. This does @em not include the query.
+ *
+ */
+ QString path() const { return m_strPath; }
+
+ /**
+ * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds
+ * a trailing '/' if there is none yet and 0 returns the
+ * path unchanged. If the URL has no path, then no '/' is added
+ * anyway. And on the other side: If the path is "/", then this
+ * character won't be stripped. Reason: "ftp://weis@host" means something
+ * completely different than "ftp://weis@host/". So adding or stripping
+ * the '/' would really alter the URL, while "ftp://host/path" and
+ * "ftp://host/path/" mean the same directory.
+ *
+ * @return The current decoded path. This does not include the query.
+ */
+ QString path( int _trailing ) const;
+
+ /**
+ * path This is considered to be decoded. This means: %3f does not become decoded
+ * and the ? does not indicate the start of the query part.
+ * The query is not changed by this function.
+ */
+ void setPath( const QString& path );
+ /**
+ * Test to see if this URL has a path is included in it.
+ **/
+ bool hasPath() const { return !m_strPath.isEmpty(); }
+
+ /** Removes all multiple directory separators ('/') and
+ * resolves any "." or ".." found in the path.
+ * Calls @ref QDir::cleanDirPath but saves the trailing slash if any.
+ */
+ void cleanPath();
+
+ /**
+ * Same as above except it takes a flag that allows you
+ * to ignore the clean up of the multiple directory separators.
+ *
+ * Some servers seem not to like the removal of extra '/'
+ * eventhough it is against the specification in RFC 2396.
+ */
+ void cleanPath(bool cleanDirSeparator);
+
+ /**
+ * This is useful for HTTP. It looks first for '?' and decodes then.
+ * The encoded path is the concatenation of the current path and the query.
+ * @param encoding_hint Reserved, should be 0.
+ */
+ void setEncodedPathAndQuery( const QString& _txt, int encoding_hint = 0 );
+
+ /**
+ * @return The concatenation if the encoded path , '?' and the encoded query.
+ *
+ * @param _no_empty_path If set to true then an empty path is substituted by "/".
+ * @param encoding_hint Reserved, should be 0.
+ */
+ QString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
+
+ /**
+ * @param _txt This is considered to be encoded. This has a good reason:
+ * The query may contain the 0 character.
+ *
+ * The query should start with a '?'. If it doesn't '?' is prepended.
+ * @param encoding_hint Reserved, should be 0.
+ */
+ void setQuery( const QString& _txt, int encoding_hint = 0);
+
+ /**
+ * @return The encoded query.
+ * This has a good reason: The query may contain the 0 character.
+ * If a query is present it always starts with a '?'.
+ * A single '?' means an empty query.
+ * An empty string means no query.
+ */
+ QString query() const { return m_strQuery_encoded; }
+
+ /**
+ * The reference is @em never decoded automatically.
+ */
+ QString ref() const { return m_strRef_encoded; }
+
+ /**
+ * Set the reference part (everything after '#').
+ * @param _txt is considered encoded.
+ */
+ void setRef( const QString& _txt ) { m_strRef_encoded = _txt; }
+
+ /**
+ * @return @p true if the reference part of the URL is not empty. In a URL like
+ * http://www.kde.org/kdebase.tar#tar:/README it would return @p true, too.
+ */
+ bool hasRef() const { return !m_strRef_encoded.isEmpty(); }
+
+ /**
+ * @return The HTML-style reference.
+ */
+ QString htmlRef() const;
+
+ /**
+ * @return The HTML-style reference in its original form.
+ */
+ QString encodedHtmlRef() const;
+
+ /**
+ * Set the HTML-style reference.
+ *
+ * @param _ref This is considered to be @em not encoded in contrast to @ref setRef()
+ *
+ * @see htmlRef()
+ */
+ void setHTMLRef( const QString& _ref );
+
+ /**
+ * @return @p true if the URL has an HTML-style reference.
+ *
+ * @see htmlRef()
+ */
+ bool hasHTMLRef() const;
+
+ /**
+ * @return @p false if the URL is malformed. This function does @em not test
+ * whether sub URLs are well-formed, too.
+ */
+ bool isValid() const { return !m_bIsMalformed; }
+ /**
+ * @deprecated
+ */
+ bool isMalformed() const { return !isValid(); }
+
+ /**
+ * @return @p true if the file is a plain local file and has no filter protocols
+ * attached to it.
+ */
+ bool isLocalFile() const;
+
+ /**
+ * @return @p true if the file has at least one sub URL.
+ * Use @ref split() to get the sub URLs.
+ */
+ bool hasSubURL() const;
+
+ /**
+ * Add to the current path.
+ * Assumes that the current path is a directory. @p _txt is appended to the
+ * current path. The function adds '/' if needed while concatenating.
+ * This means it does not matter whether the current path has a trailing
+ * '/' or not. If there is none, it becomes appended. If @p _txt
+ * has a leading '/' then this one is stripped.
+ *
+ * @param _txt This is considered to be decoded
+ */
+ void addPath( const QString& _txt );
+
+ /**
+ * In comparison to @ref addPath() this function does not assume that the current path
+ * is a directory. This is only assumed if the current path ends with '/'.
+ *
+ * Any reference is reset.
+ *
+ * @param _txt This is considered to be decoded. If the current path ends with '/'
+ * then @p _txt ist just appended, otherwise all text behind the last '/'
+ * in the current path is erased and @p _txt is appended then. It does
+ * not matter whether @p _txt starts with '/' or not.
+ */
+ void setFileName( const QString&_txt );
+
+ /**
+ * @return The filename of the current path. The returned string is decoded.
+ *
+ * @param _ignore_trailing_slash_in_path This tells whether a trailing '/' should be ignored.
+ * This means that the function would return "torben" for
+ * <tt>file:/hallo/torben/</tt> and <tt>file:/hallo/torben</tt>.
+ * If the flag is set to false, then everything behind the last '/'
+ * is considered to be the filename.
+ */
+ QString fileName( bool _ignore_trailing_slash_in_path = true ) const;
+ QString filename( bool _ignore_trailing_slash_in_path = true ) const
+ {
+ return fileName(_ignore_trailing_slash_in_path);
+ }
+
+ /**
+ * @return The directory part of the current path. Everything between the last and the second last '/'
+ * is returned. For example <tt>file:/hallo/torben/</tt> would return "/hallo/torben/" while
+ * <tt>file:/hallo/torben</tt> would return "hallo/". The returned string is decoded.
+ *
+ * @param _strip_trailing_slash_from_result tells whether the returned result should end with '/' or not.
+ * If the path is empty or just "/" then this flag has no effect.
+ * @param _ignore_trailing_slash_in_path means that <tt>file:/hallo/torben</tt> and
+ * <tt>file:/hallo/torben/"</tt> would both return <tt>/hallo/</tt>
+ * or <tt>/hallo</tt> depending on the other flag
+ */
+ QString directory( bool _strip_trailing_slash_from_result = true,
+ bool _ignore_trailing_slash_in_path = true ) const;
+
+ /**
+ * Change directory by descending into the given directory.
+ * It is assumed the current URL represents a directory.
+ * If @p dir starts with a "/" the
+ * current URL will be "protocol://host/dir" otherwise @p _dir will
+ * be appended to the path. @p _dir can be ".."
+ * This function won't strip protocols. That means that when you are in
+ * file:/dir/dir2/my.tgz#tar:/ and you do cd("..") you will
+ * still be in file:/dir/dir2/my.tgz#tar:/
+ *
+ * @return true
+ */
+ bool cd( const QString& _dir );
+
+ /**
+ * @return The complete URL, with all escape sequences intact.
+ * Example: http://localhost:8080/test.cgi?test=hello%20world&name=fred
+ *
+ * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds
+ * a trailing '/' if there is none yet and 0 returns the
+ * path unchanged.
+ */
+ QString url( int _trailing = 0 ) const;
+
+ /**
+ * @return The complete URL, with all escape sequences intact, encoded
+ * in a given charset.
+ * This is used in particular for encoding URLs in UTF-8 before using them
+ * in a drag and drop operation.
+ *
+ * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds
+ * a trailing '/' if there is none yet and 0 returns the
+ * path unchanged.
+ * @param encoding_hint The charset to use for encoding (see QFont::Charset).
+ */
+ QString url( int _trailing, int encoding_hint ) const;
+
+ /**
+ * @return A human readable URL, with no non-necessary encodings/escaped
+ * characters.
+ * Example: http://localhost:8080/test.cgi?test=hello world&name=fred
+ */
+ QString prettyURL( int _trailing = 0) const;
+
+ /**
+ * Test to see if the @ref KURL is empty.
+ **/
+ bool isEmpty() const;
+
+ /**
+ * This function is useful to implement the "Up" button in a file manager for example.
+ * @ref cd() never strips a sub-protocol. That means that if you are in
+ * file:/home/x.tgz#gzip:/#tar:/ and hit the up button you expect to see
+ * file:/home. The algorithm tries to go up on the right-most URL. If that is not
+ * possible it strips the right most URL. It continues stripping URLs.
+ */
+ KURL upURL( ) const;
+
+ KURL& operator=( const KURL& _u );
+ KURL& operator=( const QString& _url );
+ KURL& operator=( const char * _url );
+ KURL& operator=( const QUrl & u );
+
+ bool operator==( const KURL& _u ) const;
+ bool operator==( const QString& _u ) const;
+ bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
+ bool operator!=( const QString& _u ) const { return !( *this == _u ); }
+
+ /**
+ * Compare this url with @p u
+ * @param ignore_trailing set to true to ignore trailing '/' characters.
+ * @return true if both urls are the same
+ * @see operator==. This function should be used if you want to
+ * ignore trailing '/' characters.
+ */
+ bool cmp( const KURL &u, bool ignore_trailing = false ) const;
+
+ /**
+ * @return true if this url is a parent of @p u (or the same URL as @p u)
+ * For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/.
+ */
+ bool isParentOf( const KURL& u ) const;
+
+ /**
+ * Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase
+ * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in
+ * http://www.kde.org and tar:/kde/README.html#ref1.
+ * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL.
+ * Since HTML-style references mark
+ * a certain position in a document this reference is appended to every URL.
+ * The idea behind this is that browsers, for example, only look at the first URL while
+ * the rest is not of interest to them.
+ *
+ * @return An empty list on error or the list of split URLs.
+ *
+ * @param _url The URL that has to be split.
+ */
+ static List split( const QString& _url );
+
+ /**
+ * A convenience function.
+ */
+ static List split( const KURL& _url );
+
+ /**
+ * Reverses @ref split(). Only the first URL may have a reference. This reference
+ * is considered to be HTML-like and is appended at the end of the resulting
+ * joined URL.
+ */
+ static KURL join( const List& _list );
+
+ /**
+ * Convenience function
+ *
+ * Convert unicoded string to local encoding and use %-style
+ * encoding for all common delimiters / non-ascii characters.
+ * @param str String to encode
+ * @param encoding_hint Reserved, should be 0.
+ **/
+ static QString encode_string(const QString &str, int encoding_hint = 0);
+
+ /**
+ * Convenience function
+ *
+ * Convert unicoded string to local encoding and use %-style
+ * encoding for all common delimiters / non-ascii characters
+ * as well as the slash '/'.
+ * @param str String to encode
+ * @param encoding_hint Reserved, should be 0.
+ **/
+ static QString encode_string_no_slash(const QString &str, int encoding_hint = 0);
+
+ /**
+ * Convenience function
+ *
+ * Decode %-style encoding and convert from local encoding to unicode.
+ *
+ * Revers of encode_string()
+ * @param str String to decode
+ * @param encoding_hint Reserved, should be 0.
+ **/
+ static QString decode_string(const QString &str, int encoding_hint = 0);
+
+ /**
+ * Convenience function
+ *
+ * Returns whether '_url' is likely to be a "relative" URL instead of
+ * an "absolute" URL.
+ * @param _url URL to examine
+ * @return true when the URL is likely to be "relative", false otherwise.
+ */
+ static bool isRelativeURL(const QString &_url);
+
+protected:
+ void reset();
+ void parse( const QString& _url, int encoding_hint = 0);
+
+private:
+ QString m_strProtocol;
+ QString m_strUser;
+ QString m_strPass;
+ QString m_strHost;
+ QString m_strPath;
+ QString m_strRef_encoded;
+ QString m_strQuery_encoded;
+ KURLPrivate* d;
+ bool m_bIsMalformed : 1;
+ int freeForUse : 7;
+ unsigned short int m_iPort;
+ QString m_strPath_encoded;
+
+#ifndef QT_NO_DATASTREAM
+ friend QDataStream & operator<< (QDataStream & s, const KURL & a);
+ friend QDataStream & operator>> (QDataStream & s, KURL & a);
+#endif
+};
+
+/**
+ * Compares URLs. They are parsed, split and compared.
+ * Two malformed URLs with the same string representation
+ * are nevertheless considered to be unequal.
+ * That means no malformed URL equals anything else.
+ */
+bool urlcmp( const QString& _url1, const QString& _url2 );
+
+/**
+ * Compares URLs. They are parsed, split and compared.
+ * Two malformed URLs with the same string representation
+ * are nevertheless considered to be unequal.
+ * That means no malformed URL equals anything else.
+ *
+ * @param _ignore_trailing Described in @ref KURL::cmp
+ * @param _ignore_ref If @p true, disables comparison of HTML-style references.
+ */
+bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref );
+
+#ifndef QT_NO_DATASTREAM
+QDataStream & operator<< (QDataStream & s, const KURL & a);
+QDataStream & operator>> (QDataStream & s, KURL & a);
+#endif
+
+#endif
diff --git a/WebCore/src/kwq/kdecore/kurl.h b/WebCore/src/kwq/kdecore/kurl.h
index 8a5533d..c527726 100644
--- a/WebCore/src/kwq/kdecore/kurl.h
+++ b/WebCore/src/kwq/kdecore/kurl.h
@@ -30,7 +30,23 @@
#include <config.h>
#endif
-class QString;
+// USING_BORROWED_KURL =========================================================
+
+#ifdef USING_BORROWED_KURL
+#include <_kurl.h>
+
+#else
+
+#include <qstring.h>
+
+// FIXME: this clever hack may need to be moved into KWQDef.h or elsewhere
+#define Fixed MacFixed
+#define Rect MacRect
+#define Boolean MacBoolean
+#include <CoreFoundation/CoreFoundation.h>
+#undef Fixed
+#undef Rect
+#undef Boolean
// class KURL ==================================================================
@@ -85,6 +101,25 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
+private:
+
+ void init();
+
+ CFURLRef urlRef;
+ bool malformed;
+ QString sURL;
+ QString sProtocol;
+ QString sHost;
+ unsigned short int iPort;
+ QString sPass;
+ QString sUser;
+ QString sRef;
+ QString sQuery;
+ QString sPath;
+
+
}; // class KURL ===============================================================
#endif
+
+#endif // USING_BORROWED_KURL
\ No newline at end of file
diff --git a/WebCore/src/kwq/qt/_qbuffer.cpp b/WebCore/src/kwq/qt/_qbuffer.cpp
new file mode 100644
index 0000000..801e51b
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qbuffer.cpp
@@ -0,0 +1,482 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QBuffer 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QBUFFER
+
+// -------------------------------------------------------------------------
+
+#include "qbuffer.h"
+#include <stdlib.h>
+
+// REVISED: paul
+/*!
+ \class QBuffer qbuffer.h
+ \brief The QBuffer class is an I/O device that operates on a QByteArray
+
+ \ingroup io
+
+ QBuffer allows reading and writing a memory buffer. It is normally
+ used together with a QTextStream or a QDataStream. QBuffer has an
+ associated QByteArray which holds the buffer data. The size() of the
+ buffer is automatically adjusted as data is written.
+
+ The constructor \c QBuffer(QByteArray) creates a QBuffer with an
+ existing byte array. The byte array can also be set with setBuffer().
+ Writing to the QBuffer will modify the original byte array, since
+ QByteArray is \link shclass.html explicitly shared.\endlink
+
+ Use open() to open the buffer before use, and to set the mode
+ (read-only,write-only, etc.). close() closes the buffer. The buffer
+ must be closed before reopening or calling setBuffer().
+
+ The common way to use QBuffer is through \l QDataStream or \l QTextStream
+ which have constructors that take a QBuffer parameter. For
+ convenience, there are also QDataStream and QTextStream constructors
+ that take a QByteArray parameter. These constructors create and open
+ an internal QBuffer.
+
+ Note that QTextStream can also operate on a QString (a Unicode
+ string); a QBuffer cannot.
+
+ You can also use QBuffer directly through the standard QIODevice
+ functions readBlock(), writeBlock() readLine(), at(), getch(), putch() and
+ ungetch().
+
+ \sa QFile, QDataStream, QTextStream, QByteArray, \link shclass.html Shared Classes\endlink
+*/
+
+
+/*!
+ Constructs an empty buffer.
+*/
+
+QBuffer::QBuffer()
+{
+ setFlags( IO_Direct );
+ a_inc = 16; // initial increment
+ a_len = 0;
+ ioIndex = 0;
+}
+
+
+/*!
+ Constructs a buffer that operates on \a buf.
+ If you open the buffer in write mode (\c IO_WriteOnly or
+ \c IO_ReadWrite) and write something into the buffer, \a buf
+ will be modified.
+
+
+ Example:
+ \code
+ QCString str = "abc";
+ QBuffer b( str );
+ b.open( IO_WriteOnly );
+ b.at( 3 ); // position at \0
+ b.writeBlock( "def", 4 ); // write including \0
+ b.close();
+ // Now, str == "abcdef"
+ \endcode
+
+
+ \sa setBuffer()
+*/
+
+QBuffer::QBuffer( QByteArray buf ) : a(buf)
+{
+ setFlags( IO_Direct );
+ a_len = a.size();
+ a_inc = (a_len > 512) ? 512 : a_len; // initial increment
+ if ( a_inc < 16 )
+ a_inc = 16;
+ ioIndex = 0;
+}
+
+/*!
+ Destructs the buffer.
+*/
+
+QBuffer::~QBuffer()
+{
+}
+
+
+/*!
+ Replaces the buffer's contents with \a buf.
+
+ This may not be done when isOpen() is TRUE.
+
+ Note that if you open the buffer in write mode (\c IO_WriteOnly or
+ IO_ReadWrite) and write something into the buffer, \a buf is also
+ modified because QByteArray is an explicitly shared class.
+
+ \sa buffer(), open(), close()
+*/
+
+bool QBuffer::setBuffer( QByteArray buf )
+{
+ if ( isOpen() ) {
+#if defined(CHECK_STATE)
+ qWarning( "QBuffer::setBuffer: Buffer is open");
+#endif
+ return FALSE;
+ }
+ a = buf;
+ a_len = a.size();
+ a_inc = (a_len > 512) ? 512 : a_len; // initial increment
+ if ( a_inc < 16 )
+ a_inc = 16;
+ ioIndex = 0;
+ return TRUE;
+}
+
+/*!
+ \fn QByteArray QBuffer::buffer() const
+
+ Returns this buffer's byte array.
+
+ \sa setBuffer()
+*/
+
+/*!
+ \reimp
+ Opens the buffer in the mode \a m. Returns TRUE if successful,
+ otherwise FALSE. The buffer must be opened before use.
+
+ The mode parameter \a m must be a combination of the following flags.
+ <ul>
+ <li>\c IO_ReadOnly opens a buffer in read-only mode.
+ <li>\c IO_WriteOnly opens a buffer in write-only mode.
+ <li>\c IO_ReadWrite opens a buffer in read/write mode.
+ <li>\c IO_Append sets the buffer index to the end of the buffer.
+ <li>\c IO_Truncate truncates the buffer.
+ </ul>
+
+ \sa close(), isOpen()
+*/
+
+bool QBuffer::open( int m )
+{
+ if ( isOpen() ) { // buffer already open
+#if defined(CHECK_STATE)
+ qWarning( "QBuffer::open: Buffer already open" );
+#endif
+ return FALSE;
+ }
+ setMode( m );
+ if ( m & IO_Truncate ) { // truncate buffer
+ a.resize( 0 );
+ a_len = 0;
+ }
+ if ( m & IO_Append ) { // append to end of buffer
+ ioIndex = a.size();
+ } else {
+ ioIndex = 0;
+ }
+ a_inc = 16;
+ setState( IO_Open );
+ setStatus( 0 );
+ return TRUE;
+}
+
+/*!
+ \reimp
+ Closes an open buffer.
+ \sa open()
+*/
+
+void QBuffer::close()
+{
+ if ( isOpen() ) {
+ setFlags( IO_Direct );
+ ioIndex = 0;
+ a_inc = 16;
+ }
+}
+
+/*!
+ \reimp
+ The flush function does nothing for a QBuffer.
+*/
+
+void QBuffer::flush()
+{
+ return;
+}
+
+
+/*!
+ \fn int QBuffer::at() const
+ \reimp
+*/
+
+/*!
+ \fn uint QBuffer::size() const
+ \reimp
+*/
+
+/*!
+ \reimp
+*/
+
+bool QBuffer::at( int pos )
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) {
+ qWarning( "QBuffer::at: Buffer is not open" );
+ return FALSE;
+ }
+#endif
+ if ( (uint)pos > a_len ) {
+#if defined(CHECK_RANGE)
+ qWarning( "QBuffer::at: Index %d out of range", pos );
+#endif
+ return FALSE;
+ }
+ ioIndex = pos;
+ return TRUE;
+}
+
+
+/*!
+ \reimp
+*/
+
+int QBuffer::readBlock( char *p, uint len )
+{
+#if defined(CHECK_STATE)
+ CHECK_PTR( p );
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::readBlock: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::readBlock: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex + len > a.size() ) { // overflow
+ if ( (uint)ioIndex >= a.size() ) {
+ setStatus( IO_ReadError );
+ return -1;
+ } else {
+ len = a.size() - (uint)ioIndex;
+ }
+ }
+ memcpy( p, a.data()+ioIndex, len );
+ ioIndex += len;
+ return len;
+}
+
+/*!
+ \reimp
+
+ Writes \a len bytes from \a p into the buffer at the current index,
+ overwriting any characters there and extending the buffer if necessary.
+ Returns the number of bytes actually written.
+
+ Returns -1 if a serious error occurred.
+
+ \sa readBlock()
+*/
+
+int QBuffer::writeBlock( const char *p, uint len )
+{
+#if defined(CHECK_NULL)
+ if ( p == 0 && len != 0 )
+ qWarning( "QBuffer::writeBlock: Null pointer error" );
+#endif
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::writeBlock: Buffer not open" );
+ return -1;
+ }
+ if ( !isWritable() ) { // writing not permitted
+ qWarning( "QBuffer::writeBlock: Write operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex + len >= a_len ) { // overflow
+ uint new_len = a_len + a_inc*(((uint)ioIndex+len-a_len)/a_inc+1);
+ if ( !a.resize( new_len ) ) { // could not resize
+#if defined(CHECK_NULL)
+ qWarning( "QBuffer::writeBlock: Memory allocation error" );
+#endif
+ setStatus( IO_ResourceError );
+ return -1;
+ }
+ a_inc *= 2; // double increment
+ a_len = new_len;
+ a.shd->len = (uint)ioIndex + len;
+ }
+ memcpy( a.data()+ioIndex, p, len );
+ ioIndex += len;
+ if ( a.shd->len < (uint)ioIndex )
+ a.shd->len = (uint)ioIndex; // fake (not alloc'd) length
+ return len;
+}
+
+
+/*!
+ \reimp
+*/
+
+int QBuffer::readLine( char *p, uint maxlen )
+{
+#if defined(CHECK_STATE)
+ CHECK_PTR( p );
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::readLine: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::readLine: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( maxlen == 0 )
+ return 0;
+ uint start = (uint)ioIndex;
+ char *d = a.data() + ioIndex;
+ maxlen--; // make room for 0-terminator
+ if ( a.size() - (uint)ioIndex < maxlen )
+ maxlen = a.size() - (uint)ioIndex;
+ while ( maxlen-- ) {
+ if ( (*p++ = *d++) == '\n' )
+ break;
+ }
+ *p = '\0';
+ ioIndex = d - a.data();
+ return (uint)ioIndex - start;
+}
+
+
+/*!
+ \reimp
+*/
+
+int QBuffer::getch()
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::getch: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::getch: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex+1 > a.size() ) { // overflow
+ setStatus( IO_ReadError );
+ return -1;
+ }
+ return uchar(*(a.data()+ioIndex++));
+}
+
+/*!
+ \reimp
+ Writes the character \a ch into the buffer, overwriting
+ the character at the current index, extending the buffer
+ if necessary.
+
+ Returns \a ch, or -1 if some error occurred.
+
+ \sa getch(), ungetch()
+*/
+
+int QBuffer::putch( int ch )
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::putch: Buffer not open" );
+ return -1;
+ }
+ if ( !isWritable() ) { // writing not permitted
+ qWarning( "QBuffer::putch: Write operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( (uint)ioIndex + 1 >= a_len ) { // overflow
+ char buf[1];
+ buf[0] = (char)ch;
+ if ( writeBlock(buf,1) != 1 )
+ return -1; // write error
+ } else {
+ *(a.data() + ioIndex++) = (char)ch;
+ if ( a.shd->len < (uint)ioIndex )
+ a.shd->len = (uint)ioIndex;
+ }
+ return ch;
+}
+
+/*!
+ \reimp
+*/
+
+int QBuffer::ungetch( int ch )
+{
+#if defined(CHECK_STATE)
+ if ( !isOpen() ) { // buffer not open
+ qWarning( "QBuffer::ungetch: Buffer not open" );
+ return -1;
+ }
+ if ( !isReadable() ) { // reading not permitted
+ qWarning( "QBuffer::ungetch: Read operation not permitted" );
+ return -1;
+ }
+#endif
+ if ( ch != -1 ) {
+ if ( ioIndex )
+ ioIndex--;
+ else
+ ch = -1;
+ }
+ return ch;
+}
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QBUFFER
+
+// -------------------------------------------------------------------------
+
diff --git a/WebCore/src/kwq/qt/_qsortedlist.h b/WebCore/src/kwq/qt/_qbuffer.h
similarity index 59%
copy from WebCore/src/kwq/qt/_qsortedlist.h
copy to WebCore/src/kwq/qt/_qbuffer.h
index 21f47b5..8187b44 100644
--- a/WebCore/src/kwq/qt/_qsortedlist.h
+++ b/WebCore/src/kwq/qt/_qbuffer.h
@@ -1,9 +1,9 @@
/****************************************************************************
** $Id$
**
-** Definition of QList template/macro class
+** Definition of QBuffer class
**
-** Created : 920701
+** Created : 930812
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
@@ -35,35 +35,64 @@
**
**********************************************************************/
-#ifndef QSORTEDLIST_H
-#define QSORTEDLIST_H
-
-// KWQ hacks ---------------------------------------------------------------
-
-#ifndef USING_BORROWED_QSORTEDLIST
-#define USING_BORROWED_QSORTEDLIST
-#endif
-
-#include <KWQDef.h>
-
-// -------------------------------------------------------------------------
+#ifndef QBUFFER_H
+#define QBUFFER_H
#ifndef QT_H
-#include "qlist.h"
+#include "_qiodevice.h"
+#include "qstring.h"
#endif // QT_H
-template<class type> class Q_EXPORT QSortedList : public QList<type>
+class Q_EXPORT QBuffer : public QIODevice
{
public:
- QSortedList() {}
- QSortedList( const QSortedList<type> &l ) : QList<type>(l) {}
- ~QSortedList() { clear(); }
- QSortedList<type> &operator=(const QSortedList<type> &l)
- { return (QSortedList<type>&)QList<type>::operator=(l); }
-
- virtual int compareItems( QCollection::Item s1, QCollection::Item s2 )
- { if ( *((type*)s1) == *((type*)s2) ) return 0; return ( *((type*)s1) < *((type*)s2) ? -1 : 1 ); }
-};
+ QBuffer();
+ QBuffer( QByteArray );
+ ~QBuffer();
+
+ QByteArray buffer() const;
+ bool setBuffer( QByteArray );
+
+ bool open( int );
+ void close();
+ void flush();
+
+ uint size() const;
+ int at() const;
+ bool at( int );
+
+ int readBlock( char *p, uint );
+ int writeBlock( const char *p, uint );
+ int readLine( char *p, uint );
+ int getch();
+ int putch( int );
+ int ungetch( int );
+
+protected:
+ QByteArray a;
+
+private:
+ uint a_len;
+ uint a_inc;
+
+private: // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ QBuffer( const QBuffer & );
+ QBuffer &operator=( const QBuffer & );
#endif
+};
+
+
+inline QByteArray QBuffer::buffer() const
+{ return a; }
+
+inline uint QBuffer::size() const
+{ return a.size(); }
+
+inline int QBuffer::at() const
+{ return ioIndex; }
+
+
+#endif // QBUFFER_H
diff --git a/WebCore/src/kwq/qt/_qdir.cpp b/WebCore/src/kwq/qt/_qdir.cpp
new file mode 100644
index 0000000..b481663
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qdir.cpp
@@ -0,0 +1,1213 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QDir class
+**
+** Created : 950427
+**
+** 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+#include <qdir.h>
+
+// -------------------------------------------------------------------------
+
+#ifndef QT_NO_DIR
+#include "_qfileinfo.h"
+#include "qregexp.h"
+#include "qstringlist.h"
+#include <stdlib.h>
+#include <ctype.h>
+
+// NOT REVISED
+/*!
+ \class QDir qdir.h
+ \brief Traverses directory structures and contents in a
+ platform-independent way.
+
+ \ingroup io
+
+ A QDir can point to a file using either a relative or an absolute file
+ path. Absolute file paths begin with the directory separator ('/') or a
+ drive specification (not applicable to UNIX). Relative file names begin
+ with a directory name or a file name and specify a path relative to the
+ current directory.
+
+ An example of an absolute path is the string "/tmp/quartz", a relative
+ path might look like "src/fatlib". You can use the function isRelative()
+ to check if a QDir is using a relative or an absolute file path. You can
+ call the function convertToAbs() to convert a relative QDir to an
+ absolute one.
+
+ The directory "example" under the current directory is checked for existence
+ in the example below:
+
+ \code
+ QDir d( "example" ); // "./example"
+ if ( !d.exists() )
+ qWarning( "Cannot find the example directory" );
+ \endcode
+
+ If you always use '/' as a directory separator, Qt will translate your
+ paths to conform to the underlying operating system.
+
+ cd() and cdUp() can be used to navigate the directory tree. Note that the
+ logical cd and cdUp operations are not performed if the new directory does
+ not exist.
+
+ Example:
+ \code
+ QDir d = QDir::root(); // "/"
+ if ( !d.cd("tmp") ) { // "/tmp"
+ qWarning( "Cannot find the \"/tmp\" directory" );
+ } else {
+ QFile f( d.filePath("ex1.txt") ); // "/tmp/ex1.txt"
+ if ( !f.open(IO_ReadWrite) )
+ qWarning( "Cannot create the file %s", f.name() );
+ }
+ \endcode
+
+ To read the contents of a directory you can use the entryList() and
+ entryInfoList() functions.
+
+ Example:
+ \code
+ #include <stdio.h>
+ #include <qdir.h>
+
+ //
+ // This program scans the current directory and lists all files
+ // that are not symbolic links, sorted by size with the smallest files
+ // first.
+ //
+
+ int main( int argc, char **argv )
+ {
+ QDir d;
+ d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
+ d.setSorting( QDir::Size | QDir::Reversed );
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
+
+ printf( " BYTES FILENAME\n" ); // print header
+ while ( (fi=it.current()) ) { // for each file...
+ printf( "%10li %s\n", fi->size(), fi->fileName().data() );
+ ++it; // goto next list element
+ }
+ }
+ \endcode
+*/
+
+
+/*!
+ Constructs a QDir pointing to the current directory.
+ \sa currentDirPath()
+*/
+
+QDir::QDir()
+{
+ dPath = QString::fromLatin1(".");
+ init();
+}
+
+/*!
+ Constructs a QDir.
+
+ \arg \e path is the directory.
+ \arg \e nameFilter is the file name filter.
+ \arg \e sortSpec is the sort specification, which describes how to
+ sort the files in the directory.
+ \arg \e filterSpec is the filter specification, which describes how
+ to filter the files in the directory.
+
+ Most of these arguments (except \e path) have optional values.
+
+ Example:
+ \code
+ // lists all files in /tmp
+
+ QDir d( "/tmp" );
+ for ( int i=0; i<d.count(); i++ )
+ printf( "%s\n", d[i] );
+ \endcode
+
+ If \e path is "" or null, the directory is set to "." (the current
+ directory). If \e nameFilter is "" or null, it is set to "*" (all
+ files).
+
+ No check is made to ensure that the directory exists.
+
+ \sa exists(), setPath(), setNameFilter(), setFilter(), setSorting()
+*/
+
+QDir::QDir( const QString &path, const QString &nameFilter,
+ int sortSpec, int filterSpec )
+{
+ init();
+ dPath = cleanDirPath( path );
+ if ( dPath.isEmpty() )
+ dPath = QString::fromLatin1(".");
+ nameFilt = nameFilter;
+ if ( nameFilt.isEmpty() )
+ nameFilt = QString::fromLatin1("*");
+ filtS = (FilterSpec)filterSpec;
+ sortS = (SortSpec)sortSpec;
+}
+
+/*!
+ Constructs a QDir that is a copy of the given directory.
+ \sa operator=()
+*/
+
+QDir::QDir( const QDir &d )
+{
+ dPath = d.dPath;
+ fList = 0;
+ fiList = 0;
+ nameFilt = d.nameFilt;
+ dirty = TRUE;
+ allDirs = d.allDirs;
+ filtS = d.filtS;
+ sortS = d.sortS;
+}
+
+
+void QDir::init()
+{
+ fList = 0;
+ fiList = 0;
+ nameFilt = QString::fromLatin1("*");
+ dirty = TRUE;
+ allDirs = FALSE;
+ filtS = All;
+ sortS = SortSpec(Name | IgnoreCase);
+}
+
+/*!
+ Destructs the QDir and cleans up.
+*/
+
+QDir::~QDir()
+{
+ if ( fList )
+ delete fList;
+ if ( fiList )
+ delete fiList;
+}
+
+
+/*!
+ Sets the path of the directory. The path is cleaned of redundant ".", ".."
+ and multiple separators. No check is made to ensure that a directory
+ with this path exists.
+
+ The path can be either absolute or relative. Absolute paths begin with the
+ directory separator ('/') or a drive specification (not
+ applicable to UNIX).
+ Relative file names begin with a directory name or a file name and specify
+ a path relative to the current directory. An example of
+ an absolute path is the string "/tmp/quartz", a relative path might look like
+ "src/fatlib". You can use the function isRelative() to check if a QDir
+ is using a relative or an absolute file path. You can call the function
+ convertToAbs() to convert a relative QDir to an absolute one.
+
+ \sa path(), absPath(), exists(), cleanDirPath(), dirName(),
+ absFilePath(), isRelative(), convertToAbs()
+*/
+
+void QDir::setPath( const QString &path )
+{
+ dPath = cleanDirPath( path );
+ if ( dPath.isEmpty() )
+ dPath = QString::fromLatin1(".");
+ dirty = TRUE;
+}
+
+/*!
+ \fn QString QDir::path() const
+ Returns the path, this may contain symbolic links, but never contains
+ redundant ".", ".." or multiple separators.
+
+ The returned path can be either absolute or relative (see setPath()).
+
+ \sa setPath(), absPath(), exists(), cleanDirPath(), dirName(),
+ absFilePath(), convertSeparators()
+*/
+
+/*!
+ Returns the absolute (a path that starts with '/') path, which may
+ contain symbolic links, but never contains redundant ".", ".." or
+ multiple separators.
+
+ \sa setPath(), canonicalPath(), exists(), cleanDirPath(), dirName(),
+ absFilePath()
+*/
+
+QString QDir::absPath() const
+{
+ if ( QDir::isRelativePath(dPath) ) {
+ QString tmp = currentDirPath();
+ if ( tmp.right(1) != QString::fromLatin1("/") )
+ tmp += '/';
+ tmp += dPath;
+ return cleanDirPath( tmp );
+ } else {
+ return cleanDirPath( dPath );
+ }
+}
+
+/*!
+ Returns the name of the directory, this is NOT the same as the path, e.g.
+ a directory with the name "mail", might have the path "/var/spool/mail".
+ If the directory has no name (e.g. the root directory) a null string is
+ returned.
+
+ No check is made to ensure that a directory with this name actually exists.
+
+ \sa path(), absPath(), absFilePath(), exists(), QString::isNull()
+*/
+
+QString QDir::dirName() const
+{
+ int pos = dPath.findRev( '/' );
+ if ( pos == -1 )
+ return dPath;
+ return dPath.right( dPath.length() - pos - 1 );
+}
+
+/*!
+ Returns the path name of a file in the directory. Does NOT check if
+ the file actually exists in the directory. If the QDir is relative
+ the returned path name will also be relative. Redundant multiple separators
+ or "." and ".." directories in \e fileName will not be removed (see
+ cleanDirPath()).
+
+ If \e acceptAbsPath is TRUE a \e fileName starting with a separator
+ ('/') will be returned without change.
+ If \e acceptAbsPath is FALSE an absolute path will be appended to
+ the directory path.
+
+ \sa absFilePath(), isRelative(), canonicalPath()
+*/
+
+QString QDir::filePath( const QString &fileName,
+ bool acceptAbsPath ) const
+{
+ if ( acceptAbsPath && !isRelativePath(fileName) )
+ return QString(fileName);
+
+ QString tmp = dPath;
+ if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName &&
+ fileName[0] != '/') )
+ tmp += '/';
+ tmp += fileName;
+ return tmp;
+}
+
+/*!
+ Returns the absolute path name of a file in the directory. Does NOT check if
+ the file actually exists in the directory. Redundant multiple separators
+ or "." and ".." directories in \e fileName will NOT be removed (see
+ cleanDirPath()).
+
+ If \e acceptAbsPath is TRUE a \e fileName starting with a separator
+ ('/') will be returned without change.
+ if \e acceptAbsPath is FALSE an absolute path will be appended to
+ the directory path.
+
+ \sa filePath()
+*/
+
+QString QDir::absFilePath( const QString &fileName,
+ bool acceptAbsPath ) const
+{
+ if ( acceptAbsPath && !isRelativePath( fileName ) )
+ return fileName;
+
+ QString tmp = absPath();
+ if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName &&
+ fileName[0] != '/') )
+ tmp += '/';
+ tmp += fileName;
+ return tmp;
+}
+
+
+/*!
+ Converts the '/' separators in \a pathName to system native
+ separators. Returns the translated string.
+
+ On Windows, convertSeparators("c:/winnt/system32") returns
+ "c:\winnt\system32".
+
+ No conversion is done on UNIX.
+*/
+
+QString QDir::convertSeparators( const QString &pathName )
+{
+ QString n( pathName );
+#if defined(_OS_FATFS_) || defined(_OS_OS2EMX_)
+ for ( int i=0; i<(int)n.length(); i++ ) {
+ if ( n[i] == '/' )
+ n[i] = '\\';
+ }
+#endif
+ return n;
+}
+
+
+/*!
+ Changes directory by descending into the given directory. Returns
+ TRUE if the new directory exists and is readable. Note that the logical
+ cd operation is NOT performed if the new directory does not exist.
+
+ If \e acceptAbsPath is TRUE a path starting with a separator ('/')
+ will cd to the absolute directory, if \e acceptAbsPath is FALSE
+ any number of separators at the beginning of \e dirName will be removed.
+
+ Example:
+ \code
+ QDir d = QDir::home(); // now points to home directory
+ if ( !d.cd("c++") ) { // now points to "c++" under home directory if OK
+ QFileInfo fi( d, "c++" );
+ if ( fi.exists() ) {
+ if ( fi.isDir() )
+ qWarning( "Cannot cd into \"%s\".", (char*)d.absFilePath("c++") );
+ else
+ qWarning( "Cannot create directory \"%s\"\n"
+ "A file named \"c++\" already exists in \"%s\"",
+ (const char *)d.absFilePath("c++"),
+ (const char *)d.path() );
+ return;
+ } else {
+ qWarning( "Creating directory \"%s\"",
+ (const char *) d.absFilePath("c++") );
+ if ( !d.mkdir( "c++" ) ) {
+ qWarning("Could not create directory \"%s\"",
+ (const char *)d.absFilePath("c++") );
+ return;
+ }
+ }
+ }
+ \endcode
+
+ Calling cd( ".." ) is equivalent to calling cdUp().
+
+ \sa cdUp(), isReadable(), exists(), path()
+*/
+
+bool QDir::cd( const QString &dirName, bool acceptAbsPath )
+{
+ if ( dirName.isEmpty() || dirName==QString::fromLatin1(".") )
+ return TRUE;
+ QString old = dPath;
+ if ( acceptAbsPath && !isRelativePath(dirName) ) {
+ dPath = cleanDirPath( dirName );
+ } else {
+ if ( !isRoot() )
+ dPath += '/';
+ dPath += dirName;
+ if ( dirName.find('/') >= 0
+ || old == QString::fromLatin1(".")
+ || dirName == QString::fromLatin1("..") )
+ dPath = cleanDirPath( dPath );
+ }
+ if ( !exists() ) {
+ dPath = old; // regret
+ return FALSE;
+ }
+ dirty = TRUE;
+ return TRUE;
+}
+
+/*!
+ Changes directory by moving one directory up the path followed to arrive
+ at the current directory.
+
+ Returns TRUE if the new directory exists and is readable. Note that the
+ logical cdUp() operation is not performed if the new directory does not
+ exist.
+
+ \sa cd(), isReadable(), exists(), path()
+*/
+
+bool QDir::cdUp()
+{
+ return cd( QString::fromLatin1("..") );
+}
+
+/*!
+ \fn QString QDir::nameFilter() const
+ Returns the string set by setNameFilter()
+*/
+
+/*!
+ Sets the name filter used by entryList() and entryInfoList().
+
+ The name filter is a wildcarding filter that understands "*" and "?"
+ wildcards, You may specify several filter entries separated by a " " or a ";". If
+ you want entryList() and entryInfoList() to list all files ending with
+ ".cpp" and all files ending with ".h", you simply call
+ dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h")
+
+ \sa nameFilter(), setFilter()
+*/
+
+void QDir::setNameFilter( const QString &nameFilter )
+{
+ nameFilt = nameFilter;
+ if ( nameFilt.isEmpty() )
+ nameFilt = QString::fromLatin1("*");
+ dirty = TRUE;
+}
+
+/*!
+ \fn QDir::FilterSpec QDir::filter() const
+ Returns the value set by setFilter()
+*/
+
+/*! \enum QDir::FilterSpec
+
+ This enum describes how QDir is to select what entries in a
+ directory to return. The filter value is specified by or-ing
+ together values from the following list: <ul>
+
+ <li> \c Dirs - List directories only
+ <li> \c Files - List files only
+
+ <li> \c Drives - List disk drives (does nothing under unix)
+ <li> \c NoSymLinks - Do not list symbolic links (where they exist)
+ <li> \c Readable - List files for which the application has read access.
+ <li> \c Writable - List files for which the application has write access.
+ <li> \c Executable - List files for which the application has execute access
+ <li> \c Modified - Only list files that have been modified (does nothing
+ under unix)
+ <li> \c Hidden - List hidden files (on unix, files starting with a .)
+ <li> \c System - List system files (does nothing under unix)
+ </ul>
+
+ If you do not set any of \c Readable, \c Writable or \c Executable,
+ QDir will set all three of them. This makes the default easy to
+ write and at the same time useful.
+
+ Examples: \c Readable|Writable means list all files for which the
+ application has read access, write access or both. \c Dirs|Drives
+ means list drives, directories, all files that the application can
+ read, write or execute, and also symlinks to such files/directories.
+*/
+
+
+/*!
+ Sets the filter used by entryList() and entryInfoList(). The filter is used
+ to specify the kind of files that should be returned by entryList() and
+ entryInfoList().
+
+ \sa filter(), setNameFilter()
+*/
+
+void QDir::setFilter( int filterSpec )
+{
+ if ( filtS == (FilterSpec) filterSpec )
+ return;
+ filtS = (FilterSpec) filterSpec;
+ dirty = TRUE;
+}
+
+/*!
+ \fn QDir::SortSpec QDir::sorting() const
+
+ Returns the value set by setSorting()
+
+ \sa setSorting()
+*/
+
+/*! \enum QDir::SortSpec
+
+ This enum describes how QDir is to sort entries in a directory when
+ it returns a list of them. The sort value is specified by or-ing
+ together values from the following list: <ul>
+
+ <li> \c Name - sort by name
+ <li> \c Time - sort by time (modification time)
+ <li> \c Size - sort by file size
+ <li> \c Unsorted - do not sort
+
+ <li> \c DirsFirst - put all directories first in the list
+ <li> \c Reversed - reverse the sort order
+ <li> \c IgnoreCase - sort case-insensitively
+
+ </ul>
+
+ You can only specify one of the first four. If you specify both \c
+ DirsFirst and \c Reversed, directories are still put first but the
+ list is otherwise reversed.
+*/
+
+// ### Unsorted+DirsFirst ? Unsorted+Reversed?
+
+/*!
+ Sets the sorting order used by entryList() and entryInfoList().
+
+ The \e sortSpec is specified by or-ing values from the enum
+ SortSpec. The different values are:
+
+ One of these:
+ <dl compact>
+ <dt>Name<dd> Sort by name (alphabetical order).
+ <dt>Time<dd> Sort by time (most recent first).
+ <dt>Size<dd> Sort by size (largest first).
+ <dt>Unsorted<dd> Use the operating system order (UNIX does NOT sort
+ alphabetically).
+
+ ORed with zero or more of these:
+
+ <dt>DirsFirst<dd> Always put directory names first.
+ <dt>Reversed<dd> Reverse sort order.
+ <dt>IgnoreCase<dd> Ignore case when sorting by name.
+ </dl>
+*/
+
+void QDir::setSorting( int sortSpec )
+{
+ if ( sortS == (SortSpec) sortSpec )
+ return;
+ sortS = (SortSpec) sortSpec;
+ dirty = TRUE;
+}
+
+/*!
+ \fn bool QDir::matchAllDirs() const
+ Returns the value set by setMatchAllDirs()
+
+ \sa setMatchAllDirs()
+*/
+
+/*!
+ If \e enable is TRUE, all directories will be listed (even if they do not
+ match the filter or the name filter), otherwise only matched directories
+ will be listed.
+
+ \bug Currently, directories that do not match the filter will not be
+ included (the name filter will be ignored as expected).
+
+ \sa matchAllDirs()
+*/
+
+void QDir::setMatchAllDirs( bool enable )
+{
+ if ( (bool)allDirs == enable )
+ return;
+ allDirs = enable;
+ dirty = TRUE;
+}
+
+
+/*!
+ Returns the number of files that was found.
+ Equivalent to entryList().count().
+ \sa operator[](), entryList()
+*/
+
+uint QDir::count() const
+{
+ return entryList().count();
+}
+
+/*!
+ Returns the file name at position \e index in the list of found file
+ names.
+ Equivalent to entryList().at(index).
+
+ Returns null if the \e index is out of range or if the entryList()
+ function failed.
+
+ \sa count(), entryList()
+*/
+
+QString QDir::operator[]( int index ) const
+{
+ entryList();
+ return fList && index >= 0 && index < (int)fList->count() ?
+ (*fList)[index] : QString::null;
+}
+
+
+/*!
+ This function is included to easy porting from Qt 1.x to Qt 2.0,
+ it is the same as entryList(), but encodes the filenames as 8-bit
+ strings using QFile::encodedName().
+
+ It is more efficient to use entryList().
+*/
+QStrList QDir::encodedEntryList( int filterSpec, int sortSpec ) const
+{
+ QStrList r;
+ QStringList l = entryList(filterSpec,sortSpec);
+ for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
+ r.append( QFile::encodeName(*it) );
+ }
+ return r;
+}
+
+/*!
+ This function is included to easy porting from Qt 1.x to Qt 2.0,
+ it is the same as entryList(), but encodes the filenames as 8-bit
+ strings using QFile::encodedName().
+
+ It is more efficient to use entryList().
+*/
+QStrList QDir::encodedEntryList( const QString &nameFilter,
+ int filterSpec,
+ int sortSpec ) const
+{
+ QStrList r;
+ QStringList l = entryList(nameFilter,filterSpec,sortSpec);
+ for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
+ r.append( QFile::encodeName(*it) );
+ }
+ return r;
+}
+
+
+
+/*!
+ Returns a list of the names of all files and directories in the directory
+ indicated by the setSorting(), setFilter() and setNameFilter()
+ specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e filterSpec and \e sortSpec arguments.
+
+ Returns an empty list if the directory is unreadable or does not exist.
+
+ \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),
+ encodedEntryList()
+*/
+
+QStringList QDir::entryList( int filterSpec, int sortSpec ) const
+{
+ if ( !dirty && filterSpec == (int)DefaultFilter &&
+ sortSpec == (int)DefaultSort )
+ return *fList;
+ return entryList( nameFilt, filterSpec, sortSpec );
+}
+
+/*!
+ Returns a list of the names of all files and directories in the directory
+ indicated by the setSorting(), setFilter() and setNameFilter()
+ specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e nameFilter, \e filterSpec and \e sortSpec arguments.
+
+ Returns and empty list if the directory is unreadable or does not exist.
+
+ \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),
+ encodedEntryList()
+*/
+
+QStringList QDir::entryList( const QString &nameFilter,
+ int filterSpec, int sortSpec ) const
+{
+ if ( filterSpec == (int)DefaultFilter )
+ filterSpec = filtS;
+ if ( sortSpec == (int)DefaultSort )
+ sortSpec = sortS;
+ QDir *that = (QDir*)this; // mutable function
+ if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) )
+ return *that->fList;
+ else
+ return QStringList();
+}
+
+/*!
+ Returns a list of QFileInfo objects for all files and directories in
+ the directory pointed to using the setSorting(), setFilter() and
+ setNameFilter() specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e filterSpec and \e sortSpec arguments.
+
+ Returns 0 if the directory is unreadable or does not exist.
+
+ The returned pointer is a const pointer to a QFileInfoList. The list is
+ owned by the QDir object and will be reused on the next call to
+ entryInfoList() for the same QDir instance. If you want to keep the
+ entries of the list after a subsequent call to this function you will
+ need to copy them.
+
+ \sa entryList(), setNameFilter(), setSorting(), setFilter()
+*/
+
+const QFileInfoList *QDir::entryInfoList( int filterSpec, int sortSpec ) const
+{
+ if ( !dirty && filterSpec == (int)DefaultFilter &&
+ sortSpec == (int)DefaultSort )
+ return fiList;
+ return entryInfoList( nameFilt, filterSpec, sortSpec );
+}
+
+/*!
+ Returns a list of QFileInfo objects for all files and directories in
+ the directory pointed to using the setSorting(), setFilter() and
+ setNameFilter() specifications.
+
+ The the filter and sorting specifications can be overridden using the
+ \e nameFilter, \e filterSpec and \e sortSpec arguments.
+
+ Returns 0 if the directory is unreadable or does not exist.
+
+ The returned pointer is a const pointer to a QFileInfoList. The list is
+ owned by the QDir object and will be reused on the next call to
+ entryInfoList() for the same QDir instance. If you want to keep the
+ entries of the list after a subsequent call to this function you will
+ need to copy them.
+
+ \sa entryList(), setNameFilter(), setSorting(), setFilter()
+*/
+
+const QFileInfoList *QDir::entryInfoList( const QString &nameFilter,
+ int filterSpec, int sortSpec ) const
+{
+ if ( filterSpec == (int)DefaultFilter )
+ filterSpec = filtS;
+ if ( sortSpec == (int)DefaultSort )
+ sortSpec = sortS;
+ QDir *that = (QDir*)this; // mutable function
+ if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) )
+ return that->fiList;
+ else
+ return 0;
+}
+
+/*!
+ Returns TRUE if the directory exists. (If a file with the same
+ name is found this function will of course return FALSE).
+
+ \sa QFileInfo::exists(), QFile::exists()
+*/
+
+bool QDir::exists() const
+{
+ QFileInfo fi( dPath );
+ return fi.exists() && fi.isDir();
+}
+
+/*!
+ Returns TRUE if the directory path is relative to the current directory,
+ FALSE if the path is absolute (e.g. under UNIX a path is relative if it
+ does not start with a '/').
+
+ According to Einstein this function should always return TRUE.
+
+ \sa convertToAbs()
+*/
+
+bool QDir::isRelative() const
+{
+ return isRelativePath( dPath );
+}
+
+/*!
+ Converts the directory path to an absolute path. If it is already
+ absolute nothing is done.
+
+ \sa isRelative()
+*/
+
+void QDir::convertToAbs()
+{
+ dPath = absPath();
+}
+
+/*!
+ Makes a copy of d and assigns it to this QDir.
+*/
+
+QDir &QDir::operator=( const QDir &d )
+{
+ dPath = d.dPath;
+ delete fList;
+ fList = 0;
+ delete fiList;
+ fiList = 0;
+ nameFilt = d.nameFilt;
+ dirty = TRUE;
+ allDirs = d.allDirs;
+ filtS = d.filtS;
+ sortS = d.sortS;
+ return *this;
+}
+
+/*!
+ Sets the directory path to be the given path.
+*/
+
+QDir &QDir::operator=( const QString &path )
+{
+ dPath = cleanDirPath( path );
+ dirty = TRUE;
+ return *this;
+}
+
+
+/*!
+ \fn bool QDir::operator!=( const QDir &d ) const
+ Returns TRUE if the \e d and this dir have different path or
+ different sort/filter settings, otherwise FALSE.
+*/
+
+/*!
+ Returns TRUE if the \e d and this dir have the same path and all sort
+ and filter settings are equal, otherwise FALSE.
+*/
+
+bool QDir::operator==( const QDir &d ) const
+{
+ return dPath == d.dPath &&
+ nameFilt == d.nameFilt &&
+ allDirs == d.allDirs &&
+ filtS == d.filtS &&
+ sortS == d.sortS;
+}
+
+
+/*!
+ Removes a file.
+
+ If \e acceptAbsPath is TRUE a path starting with a separator ('/')
+ will remove the file with the absolute path, if \e acceptAbsPath is FALSE
+ any number of separators at the beginning of \e fileName will be removed.
+
+ Returns TRUE if successful, otherwise FALSE.
+*/
+
+bool QDir::remove( const QString &fileName, bool acceptAbsPath )
+{
+ if ( fileName.isEmpty() ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::remove: Empty or null file name" );
+#endif
+ return FALSE;
+ }
+ QString p = filePath( fileName, acceptAbsPath );
+ return QFile::remove( p );
+}
+
+/*!
+ Checks for existence of a file.
+
+ If \e acceptAbsPaths is TRUE a path starting with a separator ('/')
+ will check the file with the absolute path, if \e acceptAbsPath is FALSE
+ any number of separators at the beginning of \e name will be removed.
+
+ Returns TRUE if the file exists, otherwise FALSE.
+
+ \sa QFileInfo::exists(), QFile::exists()
+*/
+
+bool QDir::exists( const QString &name, bool acceptAbsPath )
+{
+ if ( name.isEmpty() ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::exists: Empty or null file name" );
+#endif
+ return FALSE;
+ }
+ QString tmp = filePath( name, acceptAbsPath );
+ return QFile::exists( tmp );
+}
+
+/*!
+ Returns the native directory separator; '/' under UNIX and '\' under
+ MS-DOS, Windows NT and OS/2.
+
+ You do not need to use this function to build file paths. If you always
+ use '/', Qt will translate your paths to conform to the underlying
+ operating system.
+*/
+
+char QDir::separator()
+{
+#if defined(_OS_UNIX_)
+ return '/';
+#elif defined (_OS_FATFS_)
+ return '\\';
+#elif defined (_OS_MAC_)
+ return ':';
+#else
+ return '/';
+#endif
+}
+
+/*!
+ Returns the current directory.
+ \sa currentDirPath(), QDir::QDir()
+*/
+
+QDir QDir::current()
+{
+ return QDir( currentDirPath() );
+}
+
+/*!
+ Returns the home directory.
+ \sa homeDirPath()
+*/
+
+QDir QDir::home()
+{
+ return QDir( homeDirPath() );
+}
+
+/*!
+ Returns the root directory.
+ \sa rootDirPath() drives()
+*/
+
+QDir QDir::root()
+{
+ return QDir( rootDirPath() );
+}
+
+/*!
+ \fn QString QDir::homeDirPath()
+
+ Returns the absolute path for the user's home directory,
+ \sa home()
+*/
+
+QStringList qt_makeFilterList( const QString &filter )
+{
+ if ( filter.isEmpty() )
+ return QStringList();
+
+ QChar sep( ';' );
+ int i = filter.find( sep, 0 );
+ if ( i == -1 && filter.find( ' ', 0 ) != -1 )
+ sep = QChar( ' ' );
+
+ QStringList lst = QStringList::split( sep, filter );
+ QStringList lst2;
+ QStringList::Iterator it = lst.begin();
+
+ for ( ; it != lst.end(); ++it ) {
+ QString s = *it;
+ lst2 << s.stripWhiteSpace();
+ }
+ return lst2;
+}
+
+/*!
+ Returns TRUE if the \e fileName matches one of the wildcards in the list \e filters.
+ \sa QRegExp
+*/
+
+bool QDir::match( const QStringList &filters, const QString &fileName )
+{
+ QStringList::ConstIterator sit = filters.begin();
+ bool matched = FALSE;
+ for ( ; sit != filters.end(); ++sit ) {
+ QRegExp regexp( *sit, FALSE, TRUE );
+ if ( regexp.match( fileName ) != -1 ) {
+ matched = TRUE;
+ break;
+ }
+ }
+
+ return matched;
+}
+
+/*!
+ Returns TRUE if the \e fileName matches the wildcard \e filter.
+ \a Filter may also contain multiple wildcards separated by spaces or
+ semicolons.
+ \sa QRegExp
+*/
+
+bool QDir::match( const QString &filter, const QString &fileName )
+{
+ QStringList lst = qt_makeFilterList( filter );
+ return match( lst, fileName );
+}
+
+
+/*!
+ Removes all multiple directory separators ('/') and resolves
+ any "." or ".." found in the path.
+
+ Symbolic links are kept. This function does not return the
+ canonical path, but rather the most simplified version of the input.
+ "../stuff" becomes "stuff", "stuff/../nonsense" becomes "nonsense"
+ and "\\stuff\\more\\..\\nonsense" becomes "\\stuff\\nonsense".
+
+ \sa absPath() canonicalPath()
+*/
+
+QString QDir::cleanDirPath( const QString &filePath )
+{
+ QString name = filePath;
+ QString newPath;
+
+ if ( name.isEmpty() )
+ return name;
+
+ slashify( name );
+
+ bool addedSeparator;
+ if ( isRelativePath(name) ) {
+ addedSeparator = TRUE;
+ name.insert( 0, '/' );
+ } else {
+ addedSeparator = FALSE;
+ }
+
+ int ePos, pos, upLevel;
+
+ pos = ePos = name.length();
+ upLevel = 0;
+ int len;
+
+ while ( pos && (pos = name.findRev('/',--pos)) != -1 ) {
+ len = ePos - pos - 1;
+ if ( len == 2 && name.at(pos + 1) == '.'
+ && name.at(pos + 2) == '.' ) {
+ upLevel++;
+ } else {
+ if ( len != 0 && (len != 1 || name.at(pos + 1) != '.') ) {
+ if ( !upLevel )
+ newPath = QString::fromLatin1("/")
+ + name.mid(pos + 1, len) + newPath;
+ else
+ upLevel--;
+ }
+ }
+ ePos = pos;
+ }
+ if ( addedSeparator ) {
+ while ( upLevel-- )
+ newPath.insert( 0, QString::fromLatin1("/..") );
+ if ( !newPath.isEmpty() )
+ newPath.remove( 0, 1 );
+ else
+ newPath = QString::fromLatin1(".");
+ } else {
+ if ( newPath.isEmpty() )
+ newPath = QString::fromLatin1("/");
+#if defined(_OS_FATFS_) || defined(_OS_OS2EMX_)
+ if ( name[0] == '/' ) {
+ if ( name[1] == '/' ) // "\\machine\x\ ..."
+ newPath.insert( 0, '/' );
+ } else {
+ newPath = name.left(2) + newPath;
+ }
+#endif
+ }
+ return newPath;
+}
+
+int qt_cmp_si_sortSpec;
+
+#if defined(Q_C_CALLBACKS)
+extern "C" {
+#endif
+
+int qt_cmp_si( const void *n1, const void *n2 )
+{
+ if ( !n1 || !n2 )
+ return 0;
+
+ QDirSortItem* f1 = (QDirSortItem*)n1;
+ QDirSortItem* f2 = (QDirSortItem*)n2;
+
+ if ( qt_cmp_si_sortSpec & QDir::DirsFirst )
+ if ( f1->item->isDir() != f2->item->isDir() )
+ return f1->item->isDir() ? -1 : 1;
+
+ int r = 0;
+ int sortBy = qt_cmp_si_sortSpec & QDir::SortByMask;
+
+ switch ( sortBy ) {
+ case QDir::Time:
+ r = f1->item->lastModified().secsTo(f2->item->lastModified());
+ break;
+ case QDir::Size:
+ r = f2->item->size() - f1->item->size();
+ break;
+ default:
+ ;
+ }
+
+ if ( r == 0 && sortBy != QDir::Unsorted ) {
+ // Still not sorted - sort by name
+ bool ic = qt_cmp_si_sortSpec & QDir::IgnoreCase;
+
+ if ( f1->filename_cache.isNull() )
+ f1->filename_cache = ic ? f1->item->fileName().lower()
+ : f1->item->fileName();
+ if ( f2->filename_cache.isNull() )
+ f2->filename_cache = ic ? f2->item->fileName().lower()
+ : f2->item->fileName();
+
+ r = f1->filename_cache.compare(f2->filename_cache);
+ }
+
+ if ( r == 0 ) {
+ // Enforce an order - the order the items appear in the array
+ r = (char*)n1 - (char*)n2;
+ }
+
+ if ( qt_cmp_si_sortSpec & QDir::Reversed )
+ return -r;
+ else
+ return r;
+}
+
+#if defined(Q_C_CALLBACKS)
+}
+#endif
+
+#endif // QT_NO_DIR
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/src/kwq/qt/_qdir.h b/WebCore/src/kwq/qt/_qdir.h
new file mode 100644
index 0000000..3766c47
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qdir.h
@@ -0,0 +1,235 @@
+/****************************************************************************
+** $Id$
+**
+** Definition of QDir class
+**
+** Created : 950427
+**
+** 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.
+**
+**********************************************************************/
+
+#ifndef QDIR_H
+#define QDIR_H
+
+#ifndef QT_H
+#include "_qstrlist.h"
+#include "_qfileinfo.h"
+#endif // QT_H
+
+#ifndef QT_NO_DIR
+typedef QList<QFileInfo> QFileInfoList;
+typedef QListIterator<QFileInfo> QFileInfoListIterator;
+class QStringList;
+
+
+class Q_EXPORT QDir
+{
+public:
+ enum FilterSpec { Dirs = 0x001,
+ Files = 0x002,
+ Drives = 0x004,
+ NoSymLinks = 0x008,
+ All = 0x007,
+ TypeMask = 0x00F,
+
+ Readable = 0x010,
+ Writable = 0x020,
+ Executable = 0x040,
+ RWEMask = 0x070,
+
+ Modified = 0x080,
+ Hidden = 0x100,
+ System = 0x200,
+ AccessMask = 0x3F0,
+
+ DefaultFilter = -1 };
+
+ enum SortSpec { Name = 0x00,
+ Time = 0x01,
+ Size = 0x02,
+ Unsorted = 0x03,
+ SortByMask = 0x03,
+
+ DirsFirst = 0x04,
+ Reversed = 0x08,
+ IgnoreCase = 0x10,
+ DefaultSort = -1 };
+
+ QDir();
+ QDir( const QString &path, const QString &nameFilter = QString::null,
+ int sortSpec = Name | IgnoreCase, int filterSpec = All );
+ QDir( const QDir & );
+
+ virtual ~QDir();
+
+ QDir &operator=( const QDir & );
+ QDir &operator=( const QString &path );
+
+ virtual void setPath( const QString &path );
+ virtual QString path() const;
+ virtual QString absPath() const;
+ virtual QString canonicalPath() const;
+
+ virtual QString dirName() const;
+ virtual QString filePath( const QString &fileName,
+ bool acceptAbsPath = TRUE ) const;
+ virtual QString absFilePath( const QString &fileName,
+ bool acceptAbsPath = TRUE ) const;
+
+ static QString convertSeparators( const QString &pathName );
+
+ virtual bool cd( const QString &dirName, bool acceptAbsPath = TRUE );
+ virtual bool cdUp();
+
+ QString nameFilter() const;
+ virtual void setNameFilter( const QString &nameFilter );
+ FilterSpec filter() const;
+ virtual void setFilter( int filterSpec );
+ SortSpec sorting() const;
+ virtual void setSorting( int sortSpec );
+
+ bool matchAllDirs() const;
+ virtual void setMatchAllDirs( bool );
+
+ uint count() const;
+ QString operator[]( int ) const;
+
+ virtual QStrList encodedEntryList( int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual QStrList encodedEntryList( const QString &nameFilter,
+ int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual QStringList entryList( int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual QStringList entryList( const QString &nameFilter,
+ int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+
+ virtual const QFileInfoList *entryInfoList( int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+ virtual const QFileInfoList *entryInfoList( const QString &nameFilter,
+ int filterSpec = DefaultFilter,
+ int sortSpec = DefaultSort ) const;
+
+ static const QFileInfoList *drives();
+
+ virtual bool mkdir( const QString &dirName,
+ bool acceptAbsPath = TRUE ) const;
+ virtual bool rmdir( const QString &dirName,
+ bool acceptAbsPath = TRUE ) const;
+
+ virtual bool isReadable() const;
+ virtual bool exists() const;
+ virtual bool isRoot() const;
+
+ virtual bool isRelative() const;
+ virtual void convertToAbs();
+
+ virtual bool operator==( const QDir & ) const;
+ virtual bool operator!=( const QDir & ) const;
+
+ virtual bool remove( const QString &fileName,
+ bool acceptAbsPath = TRUE );
+ virtual bool rename( const QString &name, const QString &newName,
+ bool acceptAbsPaths = TRUE );
+ virtual bool exists( const QString &name,
+ bool acceptAbsPath = TRUE );
+
+ static char separator();
+
+ static bool setCurrent( const QString &path );
+ static QDir current();
+ static QDir home();
+ static QDir root();
+ static QString currentDirPath();
+ static QString homeDirPath();
+ static QString rootDirPath();
+
+ static bool match( const QStringList &filters, const QString &fileName );
+ static bool match( const QString &filter, const QString &fileName );
+ static QString cleanDirPath( const QString &dirPath );
+ static bool isRelativePath( const QString &path );
+
+private:
+ void init();
+ virtual bool readDirEntries( const QString &nameFilter,
+ int FilterSpec, int SortSpec );
+
+ static void slashify ( QString &);
+
+ QString dPath;
+ QStringList *fList;
+ QFileInfoList *fiList;
+ QString nameFilt;
+ FilterSpec filtS;
+ SortSpec sortS;
+ uint dirty : 1;
+ uint allDirs : 1;
+};
+
+
+inline QString QDir::path() const
+{
+ return dPath;
+}
+
+inline QString QDir::nameFilter() const
+{
+ return nameFilt;
+}
+
+inline QDir::FilterSpec QDir::filter() const
+{
+ return filtS;
+}
+
+inline QDir::SortSpec QDir::sorting() const
+{
+ return sortS;
+}
+
+inline bool QDir::matchAllDirs() const
+{
+ return allDirs;
+}
+
+inline bool QDir::operator!=( const QDir &d ) const
+{
+ return !(*this == d);
+}
+
+
+struct QDirSortItem {
+ QString filename_cache;
+ QFileInfo* item;
+};
+
+#endif // QT_NO_DIR
+#endif // QDIR_H
diff --git a/WebCore/src/kwq/qt/_qdir_unix.cpp b/WebCore/src/kwq/qt/_qdir_unix.cpp
new file mode 100644
index 0000000..fdc18ad
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qdir_unix.cpp
@@ -0,0 +1,301 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QDirclass
+**
+** Created : 950628
+**
+** 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 for Unix/X11 or for Qt/Embedded 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
+
+#include "_qdir.h"
+#ifndef QT_NO_DIR
+
+#include "_qfileinfo.h"
+#include "qregexp.h"
+#include "qstringlist.h"
+#include <stdlib.h>
+#include <ctype.h>
+
+extern QStringList qt_makeFilterList( const QString &filter );
+
+extern int qt_cmp_si_sortSpec;
+
+#if defined(Q_C_CALLBACKS)
+extern "C" {
+#endif
+
+extern int qt_cmp_si( const void *, const void * );
+
+#if defined(Q_C_CALLBACKS)
+}
+#endif
+
+
+void QDir::slashify( QString& )
+{
+}
+
+QString QDir::homeDirPath()
+{
+ QString d;
+ d = QFile::decodeName(getenv("HOME"));
+ slashify( d );
+ if ( d.isNull() )
+ d = rootDirPath();
+ return d;
+}
+
+QString QDir::canonicalPath() const
+{
+ QString r;
+
+ char cur[PATH_MAX];
+ char tmp[PATH_MAX];
+ GETCWD( cur, PATH_MAX );
+ if ( CHDIR(QFile::encodeName(dPath)) >= 0 ) {
+ GETCWD( tmp, PATH_MAX );
+ r = QFile::decodeName(tmp);
+ }
+ CHDIR( cur );
+
+ slashify( r );
+ return r;
+}
+
+bool QDir::mkdir( const QString &dirName, bool acceptAbsPath ) const
+{
+ return MKDIR( QFile::encodeName(filePath(dirName,acceptAbsPath)), 0777 )
+ == 0;
+}
+
+bool QDir::rmdir( const QString &dirName, bool acceptAbsPath ) const
+{
+ return RMDIR( QFile::encodeName(filePath(dirName,acceptAbsPath)) ) == 0;
+}
+
+bool QDir::isReadable() const
+{
+ return ACCESS( QFile::encodeName(dPath), R_OK | X_OK ) == 0;
+}
+
+bool QDir::isRoot() const
+{
+ return dPath == QString::fromLatin1("/");
+}
+
+bool QDir::rename( const QString &name, const QString &newName,
+ bool acceptAbsPaths )
+{
+ if ( name.isEmpty() || newName.isEmpty() ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::rename: Empty or null file name(s)" );
+#endif
+ return FALSE;
+ }
+ QString fn1 = filePath( name, acceptAbsPaths );
+ QString fn2 = filePath( newName, acceptAbsPaths );
+ return ::rename( QFile::encodeName(fn1),
+ QFile::encodeName(fn2) ) == 0;
+}
+
+bool QDir::setCurrent( const QString &path )
+{
+ int r;
+ r = CHDIR( QFile::encodeName(path) );
+ return r >= 0;
+}
+
+QString QDir::currentDirPath()
+{
+ QString result;
+
+ STATBUF st;
+ if ( STAT( ".", &st ) == 0 ) {
+ char currentName[PATH_MAX];
+ if ( GETCWD( currentName, PATH_MAX ) != 0 )
+ result = QFile::decodeName(currentName);
+#if defined(DEBUG)
+ if ( result.isNull() )
+ qWarning( "QDir::currentDirPath: getcwd() failed" );
+#endif
+ } else {
+#if defined(DEBUG)
+ qWarning( "QDir::currentDirPath: stat(\".\") failed" );
+#endif
+ }
+ slashify( result );
+ return result;
+}
+
+QString QDir::rootDirPath()
+{
+ QString d = QString::fromLatin1( "/" );
+ return d;
+}
+
+bool QDir::isRelativePath( const QString &path )
+{
+ int len = path.length();
+ if ( len == 0 )
+ return TRUE;
+ return path[0] != '/';
+}
+
+bool QDir::readDirEntries( const QString &nameFilter,
+ int filterSpec, int sortSpec )
+{
+ int i;
+ if ( !fList ) {
+ fList = new QStringList;
+ CHECK_PTR( fList );
+ fiList = new QFileInfoList;
+ CHECK_PTR( fiList );
+ fiList->setAutoDelete( TRUE );
+ } else {
+ fList->clear();
+ fiList->clear();
+ }
+
+ QStringList filters = qt_makeFilterList( nameFilter );
+
+ bool doDirs = (filterSpec & Dirs) != 0;
+ bool doFiles = (filterSpec & Files) != 0;
+ bool noSymLinks = (filterSpec & NoSymLinks) != 0;
+ bool doReadable = (filterSpec & Readable) != 0;
+ bool doWritable = (filterSpec & Writable) != 0;
+ bool doExecable = (filterSpec & Executable) != 0;
+ bool doHidden = (filterSpec & Hidden) != 0;
+
+#if defined(_OS_OS2EMX_)
+ //QRegExp wc( nameFilter, FALSE, TRUE ); // wild card, case insensitive
+#else
+ //QRegExp wc( nameFilter, TRUE, TRUE ); // wild card, case sensitive
+#endif
+ QFileInfo fi;
+ DIR *dir;
+ dirent *file;
+
+ dir = opendir( QFile::encodeName(dPath) );
+ if ( !dir ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::readDirEntries: Cannot read the directory: %s",
+ QFile::encodeName(dPath).data() );
+#endif
+ return FALSE;
+ }
+
+ while ( (file = readdir(dir)) ) {
+ QString fn = QFile::decodeName(file->d_name);
+ fi.setFile( *this, fn );
+ if ( !match( filters, fn ) && !(allDirs && fi.isDir()) )
+ continue;
+ if ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) ) {
+ if ( noSymLinks && fi.isSymLink() )
+ continue;
+ if ( (filterSpec & RWEMask) != 0 )
+ if ( (doReadable && !fi.isReadable()) ||
+ (doWritable && !fi.isWritable()) ||
+ (doExecable && !fi.isExecutable()) )
+ continue;
+ if ( !doHidden && fn[0] == '.' &&
+ fn != QString::fromLatin1(".")
+ && fn != QString::fromLatin1("..") )
+ continue;
+ fiList->append( new QFileInfo( fi ) );
+ }
+ }
+ if ( closedir(dir) != 0 ) {
+#if defined(CHECK_NULL)
+ qWarning( "QDir::readDirEntries: Cannot close the directory: %s",
+ dPath.local8Bit().data() );
+#endif
+ }
+
+ // Sort...
+ if(fiList->count()) {
+ QDirSortItem* si= new QDirSortItem[fiList->count()];
+ QFileInfo* itm;
+ i=0;
+ for (itm = fiList->first(); itm; itm = fiList->next())
+ si[i++].item = itm;
+ qt_cmp_si_sortSpec = sortSpec;
+ qsort( si, i, sizeof(si[0]), qt_cmp_si );
+ // put them back in the list
+ fiList->setAutoDelete( FALSE );
+ fiList->clear();
+ int j;
+ for ( j=0; j<i; j++ ) {
+ fiList->append( si[j].item );
+ fList->append( si[j].item->fileName() );
+ }
+ delete [] si;
+ fiList->setAutoDelete( TRUE );
+ }
+
+ if ( filterSpec == (FilterSpec)filtS && sortSpec == (SortSpec)sortS &&
+ nameFilter == nameFilt )
+ dirty = FALSE;
+ else
+ dirty = TRUE;
+ return TRUE;
+}
+
+const QFileInfoList * QDir::drives()
+{
+ // at most one instance of QFileInfoList is leaked, and this variable
+ // points to that list
+ static QFileInfoList * knownMemoryLeak = 0;
+
+ if ( !knownMemoryLeak ) {
+ knownMemoryLeak = new QFileInfoList;
+ // non-win32 versions both use just one root directory
+ knownMemoryLeak->append( new QFileInfo( rootDirPath() ) );
+ }
+
+ return knownMemoryLeak;
+}
+#endif //QT_NO_DIR
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/src/kwq/qt/_qfileinfo.cpp b/WebCore/src/kwq/qt/_qfileinfo.cpp
new file mode 100644
index 0000000..ddf20c0
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qfileinfo.cpp
@@ -0,0 +1,471 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QFileInfo class
+**
+** Created : 950628
+**
+** 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
+
+#include "_qfileinfo.h"
+#include "qdatetime.h"
+#include "_qdir.h"
+
+extern bool qt_file_access( const QString& fn, int t );
+
+// NOT REVISED
+/*!
+ \class QFileInfo qfileinfo.h
+ \brief The QFileInfo class provides system-independent file information.
+
+ \ingroup io
+
+ QFileInfo provides information about a file's name and position (path) in
+ the file system, its access rights and whether it is a directory or a
+ symbolic link. Its size and last modified/read times are also available.
+
+ To speed up performance QFileInfo caches information about the file. Since
+ files can be changed by other users or programs, or even by other parts of
+ the same program there is a function that refreshes the file information;
+ refresh(). If you would rather like a QFileInfo to access the file system
+ every time you request information from it, you can call the function
+ setCaching( FALSE ).
+
+ A QFileInfo can point to a file using either a relative or an absolute
+ file path. Absolute file paths begin with the directory separator
+ ('/') or a drive specification (not applicable to UNIX).
+ Relative file names begin with a directory name or a file name and specify
+ a path relative to the current directory. An example of
+ an absolute path is the string "/tmp/quartz". A relative path might look like
+ "src/fatlib". You can use the function isRelative() to check if a QFileInfo
+ is using a relative or an absolute file path. You can call the function
+ convertToAbs() to convert a relative QFileInfo to an absolute one.
+
+ If you need to read and traverse directories, see the QDir class.
+*/
+
+
+/*!
+ Constructs a new empty QFileInfo.
+*/
+
+QFileInfo::QFileInfo()
+{
+ fic = 0;
+ cache = TRUE;
+}
+
+/*!
+ Constructs a new QFileInfo that gives information about the given file.
+ The string given can be an absolute or a relative file path.
+
+ \sa bool setFile(QString ), isRelative(), QDir::setCurrent(),
+ QDir::isRelativePath()
+*/
+
+QFileInfo::QFileInfo( const QString &file )
+{
+ fn = file;
+ slashify( fn );
+ fic = 0;
+ cache = TRUE;
+}
+
+/*!
+ Constructs a new QFileInfo that gives information about \e file.
+
+ If the file has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+
+QFileInfo::QFileInfo( const QFile &file )
+{
+ fn = file.name();
+ slashify( fn );
+ fic = 0;
+ cache = TRUE;
+}
+
+/*!
+ Constructs a new QFileInfo that gives information about the file
+ named \e fileName in the directory \e d.
+
+ If the directory has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+#ifndef QT_NO_DIR
+QFileInfo::QFileInfo( const QDir &d, const QString &fileName )
+{
+ fn = d.filePath( fileName );
+ slashify( fn );
+ fic = 0;
+ cache = TRUE;
+}
+#endif
+/*!
+ Constructs a new QFileInfo that is a copy of \e fi.
+*/
+
+QFileInfo::QFileInfo( const QFileInfo &fi )
+{
+ fn = fi.fn;
+ if ( fi.fic ) {
+ fic = new QFileInfoCache;
+ *fic = *fi.fic;
+ } else {
+ fic = 0;
+ }
+ cache = fi.cache;
+}
+
+/*!
+ Destructs the QFileInfo.
+*/
+
+QFileInfo::~QFileInfo()
+{
+ delete fic;
+}
+
+
+/*!
+ Makes a copy of \e fi and assigns it to this QFileInfo.
+*/
+
+QFileInfo &QFileInfo::operator=( const QFileInfo &fi )
+{
+ fn = fi.fn;
+ if ( !fi.fic ) {
+ delete fic;
+ fic = 0;
+ } else {
+ if ( !fic ) {
+ fic = new QFileInfoCache;
+ CHECK_PTR( fic );
+ }
+ *fic = *fi.fic;
+ }
+ cache = fi.cache;
+ return *this;
+}
+
+
+/*!
+ Sets the file to obtain information about.
+
+ The string given can be an absolute or a relative file path. Absolute file
+ paths begin with the directory separator (e.g. '/' under UNIX) or a drive
+ specification (not applicable to UNIX). Relative file names begin with a
+ directory name or a file name and specify a path relative to the current
+ directory.
+
+ Example:
+ \code
+ #include <qfileinfo.h>
+ #include <qdir.h>
+
+ void test()
+ {
+ QString absolute = "/liver/aorta";
+ QString relative = "liver/aorta";
+ QFileInfo fi1( absolute );
+ QFileInfo fi2( relative );
+
+ QDir::setCurrent( QDir::rootDirPath() );
+ // fi1 and fi2 now point to the same file
+
+ QDir::setCurrent( "/tmp" );
+ // fi1 now points to "/liver/aorta",
+ // while fi2 points to "/tmp/liver/aorta"
+ }
+ \endcode
+
+ \sa isRelative(), QDir::setCurrent(), QDir::isRelativePath()
+*/
+
+void QFileInfo::setFile( const QString &file )
+{
+ fn = file;
+ slashify( fn );
+ delete fic;
+ fic = 0;
+}
+
+/*!
+ Sets the file to obtain information about.
+
+ If the file has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+
+void QFileInfo::setFile( const QFile &file )
+{
+ fn = file.name();
+ slashify( fn );
+ delete fic;
+ fic = 0;
+}
+
+/*!
+ Sets the file to obtains information about to \e fileName in the
+ directory \e d.
+
+ If the directory has a relative path, the QFileInfo will also have one.
+
+ \sa isRelative()
+*/
+#ifndef QT_NO_DIR
+void QFileInfo::setFile( const QDir &d, const QString &fileName )
+{
+ fn = d.filePath( fileName );
+ slashify( fn );
+ delete fic;
+ fic = 0;
+}
+#endif
+
+/*!
+ Returns TRUE if the file pointed to exists, otherwise FALSE.
+*/
+
+bool QFileInfo::exists() const
+{
+ return qt_file_access( fn, F_OK );
+}
+
+/*!
+ Refresh the information about the file, i.e. read in information from the
+ file system the next time a cached property is fetched.
+
+ \sa setCaching()
+*/
+
+void QFileInfo::refresh() const
+{
+ QFileInfo *that = (QFileInfo*)this; // Mutable function
+ delete that->fic;
+ that->fic = 0;
+}
+
+/*!
+ \fn bool QFileInfo::caching() const
+ Returns TRUE if caching is enabled.
+ \sa setCaching(), refresh()
+*/
+
+/*!
+ Enables caching of file information if \e enable is TRUE, or disables it
+ if \e enable is FALSE.
+
+ When caching is enabled, QFileInfo reads the file information the first
+ time
+
+ Caching is enabled by default.
+
+ \sa refresh(), caching()
+*/
+
+void QFileInfo::setCaching( bool enable )
+{
+ if ( cache == enable )
+ return;
+ cache = enable;
+ if ( cache ) {
+ delete fic;
+ fic = 0;
+ }
+}
+
+
+/*!
+ Returns the name, i.e. the file name including the path (which can be
+ absolute or relative).
+
+ \sa isRelative(), absFilePath()
+*/
+
+QString QFileInfo::filePath() const
+{
+ return fn;
+}
+
+/*!
+ Returns the base name of the file.
+
+ The base name consists of all characters in the file name up to (but not
+ including) the first '.' character. The path is not included.
+
+ Example:
+ \code
+ QFileInfo fi( "/tmp/abdomen.lower" );
+ QString base = fi.baseName(); // base = "abdomen"
+ \endcode
+
+ \sa fileName(), extension()
+*/
+
+QString QFileInfo::baseName() const
+{
+ QString tmp = fileName();
+ int pos = tmp.find( '.' );
+ if ( pos == -1 )
+ return tmp;
+ else
+ return tmp.left( pos );
+}
+
+/*!
+ Returns the extension name of the file.
+
+ If \a complete is TRUE (the default), extension() returns the string
+ of all characters in the file name after (but not including) the
+ first '.' character. For a file named "archive.tar.gz" this
+ returns "tar.gz".
+
+ If \a complete is FALSE, extension() returns the string of all
+ characters in the file name after (but not including) the last '.'
+ character. For a file named "archive.tar.gz" this returns "gz".
+
+ Example:
+ \code
+ QFileInfo fi( "lex.yy.c" );
+ QString ext = fi.extension(); // ext = "yy.c"
+ QString ext = fi.extension( FALSE ); // ext = "c"
+ \endcode
+
+ \sa fileName(), baseName()
+
+*/
+
+QString QFileInfo::extension( bool complete ) const
+{
+ QString s = fileName();
+ int pos = complete ? s.find( '.' ) : s.findRev( '.' );
+ if ( pos < 0 )
+ return QString::fromLatin1( "" );
+ else
+ return s.right( s.length() - pos - 1 );
+}
+
+/*!
+ Returns the directory path of the file.
+
+ If the QFileInfo is relative and \e absPath is FALSE, the QDir will be
+ relative, otherwise it will be absolute.
+
+ \sa dirPath(), filePath(), fileName(), isRelative()
+*/
+#ifndef QT_NO_DIR
+QDir QFileInfo::dir( bool absPath ) const
+{
+ return QDir( dirPath(absPath) );
+}
+#endif
+
+
+/*!
+ Returns TRUE if the file is readable.
+ \sa isWritable(), isExecutable(), permission()
+*/
+
+bool QFileInfo::isReadable() const
+{
+ return qt_file_access( fn, R_OK );
+}
+
+/*!
+ Returns TRUE if the file is writable.
+ \sa isReadable(), isExecutable(), permission()
+*/
+
+bool QFileInfo::isWritable() const
+{
+ return qt_file_access( fn, W_OK );
+}
+
+/*!
+ Returns TRUE if the file is executable.
+ \sa isReadable(), isWritable(), permission()
+*/
+
+bool QFileInfo::isExecutable() const
+{
+ return qt_file_access( fn, X_OK );
+}
+
+
+/*!
+ Returns TRUE if the file path name is relative to the current directory,
+ FALSE if the path is absolute (e.g. under UNIX a path is relative if it
+ does not start with a '/').
+
+ According to Einstein this function should always return TRUE.
+*/
+#ifndef QT_NO_DIR
+bool QFileInfo::isRelative() const
+{
+ return QDir::isRelativePath( fn );
+}
+
+/*!
+ Converts the file path name to an absolute path.
+
+ If it is already absolute nothing is done.
+
+ \sa filePath(), isRelative()
+*/
+
+bool QFileInfo::convertToAbs()
+{
+ if ( isRelative() )
+ fn = absFilePath();
+ return QDir::isRelativePath( fn );
+}
+#endif
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/src/kwq/qt/_qfileinfo.h b/WebCore/src/kwq/qt/_qfileinfo.h
new file mode 100644
index 0000000..8543e1c
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qfileinfo.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+** $Id$
+**
+** Definition of QFileInfo class
+**
+** Created : 950628
+**
+** 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.
+**
+**********************************************************************/
+
+#ifndef QFILEINFO_H
+#define QFILEINFO_H
+
+#ifndef QT_H
+#include "qfile.h"
+#include "qdatetime.h"
+#endif // QT_H
+
+
+class QDir;
+struct QFileInfoCache;
+
+
+class Q_EXPORT QFileInfo // file information class
+{
+public:
+ enum PermissionSpec {
+ ReadUser = 0400, WriteUser = 0200, ExeUser = 0100,
+ ReadGroup = 0040, WriteGroup = 0020, ExeGroup = 0010,
+ ReadOther = 0004, WriteOther = 0002, ExeOther = 0001 };
+
+ QFileInfo();
+ QFileInfo( const QString &file );
+ QFileInfo( const QFile & );
+#ifndef QT_NO_DIR
+ QFileInfo( const QDir &, const QString &fileName );
+#endif
+ QFileInfo( const QFileInfo & );
+ ~QFileInfo();
+
+ QFileInfo &operator=( const QFileInfo & );
+
+ void setFile( const QString &file );
+ void setFile( const QFile & );
+#ifndef QT_NO_DIR
+ void setFile( const QDir &, const QString &fileName );
+#endif
+ bool exists() const;
+ void refresh() const;
+ bool caching() const;
+ void setCaching( bool );
+
+ QString filePath() const;
+ QString fileName() const;
+#ifndef QT_NO_DIR //###
+ QString absFilePath() const;
+#endif
+ QString baseName() const;
+ QString extension( bool complete = TRUE ) const;
+
+#ifndef QT_NO_DIR //###
+ QString dirPath( bool absPath = FALSE ) const;
+#endif
+#ifndef QT_NO_DIR
+ QDir dir( bool absPath = FALSE ) const;
+#endif
+ bool isReadable() const;
+ bool isWritable() const;
+ bool isExecutable() const;
+
+#ifndef QT_NO_DIR //###
+ bool isRelative() const;
+ bool convertToAbs();
+#endif
+
+ bool isFile() const;
+ bool isDir() const;
+ bool isSymLink() const;
+
+ QString readLink() const;
+
+ QString owner() const;
+ uint ownerId() const;
+ QString group() const;
+ uint groupId() const;
+
+ bool permission( int permissionSpec ) const;
+
+ uint size() const;
+
+ QDateTime lastModified() const;
+ QDateTime lastRead() const;
+
+private:
+ void doStat() const;
+ static void slashify( QString & );
+ static void makeAbs( QString & );
+
+ QString fn;
+ QFileInfoCache *fic;
+ bool cache;
+};
+
+
+inline bool QFileInfo::caching() const
+{
+ return cache;
+}
+
+
+#endif // QFILEINFO_H
diff --git a/WebCore/src/kwq/qt/_qfileinfo_unix.cpp b/WebCore/src/kwq/qt/_qfileinfo_unix.cpp
new file mode 100644
index 0000000..5183b17
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qfileinfo_unix.cpp
@@ -0,0 +1,438 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QFileInfo class
+**
+** Created : 950628
+**
+** 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 for Unix/X11 or for Qt/Embedded 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.
+**
+**********************************************************************/
+
+// KWQ hacks ---------------------------------------------------------------
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
+
+#if defined(_OS_SUN_)
+#define readlink _qt_hide_readlink
+#endif
+
+#include <pwd.h>
+#include <grp.h>
+
+#include "_qfileinfo.h"
+#include "qdatetime.h"
+#include "_qdir.h"
+
+#if defined(_OS_SUN_)
+#undef readlink
+extern "C" int readlink( const char *, void *, uint );
+#endif
+
+
+void QFileInfo::slashify( QString& )
+{
+ return;
+}
+
+
+void QFileInfo::makeAbs( QString & )
+{
+ return;
+}
+
+extern bool qt_file_access( const QString& fn, int t );
+
+/*!
+ Returns TRUE if we are pointing to a real file.
+ \sa isDir(), isSymLink()
+*/
+bool QFileInfo::isFile() const
+{
+ if ( !fic || !cache )
+ doStat();
+ return fic ? (fic->st.st_mode & STAT_MASK) == STAT_REG : FALSE;
+}
+
+/*!
+ Returns TRUE if we are pointing to a directory or a symbolic link to
+ a directory.
+ \sa isFile(), isSymLink()
+*/
+
+bool QFileInfo::isDir() const
+{
+ if ( !fic || !cache )
+ doStat();
+ return fic ? (fic->st.st_mode & STAT_MASK) == STAT_DIR : FALSE;
+}
+
+/*!
+ Returns TRUE if we are pointing to a symbolic link.
+ \sa isFile(), isDir(), readLink()
+*/
+
+bool QFileInfo::isSymLink() const
+{
+ if ( !fic || !cache )
+ doStat();
+ return fic ? fic->isSymLink : FALSE;
+}
+
+
+/*!
+ Returns the name a symlink points to, or a null QString if the
+ object does not refer to a symbolic link.
+
+ This name may not represent an existing file; it is only a string.
+ QFileInfo::exists() returns TRUE if the symlink points to an
+ existing file.
+
+ \sa exists(), isSymLink(), isDir(), isFile()
+*/
+
+QString QFileInfo::readLink() const
+{
+ QString r;
+
+#if defined(_OS_UNIX_) && !defined(_OS_OS2EMX_)
+ char s[PATH_MAX+1];
+ if ( !isSymLink() )
+ return QString();
+ int len = readlink( QFile::encodeName(fn).data(), s, PATH_MAX );
+ if ( len >= 0 ) {
+ s[len] = '\0';
+ r = QFile::decodeName(s);
+ }
+#endif
+
+ return r;
+}
+
+static const uint nobodyID = (uint) -2;
+
+/*!
+ Returns the owner of the file.
+
+ On systems where files do not have owners this function returns 0.
+
+ Note that this function can be time-consuming under UNIX. (in the order
+ of milliseconds on a 486 DX2/66 running Linux).
+
+ \sa ownerId(), group(), groupId()
+*/
+
+QString QFileInfo::owner() const
+{
+ passwd *pw = getpwuid( ownerId() );
+ if ( pw )
+ return QFile::decodeName( pw->pw_name );
+ return QString::null;
+}
+
+/*!
+ Returns the id of the owner of the file.
+
+ On systems where files do not have owners this function returns ((uint) -2).
+
+ \sa owner(), group(), groupId()
+*/
+
+uint QFileInfo::ownerId() const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ return fic->st.st_uid;
+ return nobodyID;
+}
+
+/*!
+ Returns the group the file belongs to.
+
+ On systems where files do not have groups this function always
+ returns 0.
+
+ Note that this function can be time-consuming under UNIX (in the order of
+ milliseconds on a 486 DX2/66 running Linux).
+
+ \sa groupId(), owner(), ownerId()
+*/
+
+QString QFileInfo::group() const
+{
+ struct group *gr = getgrgid( groupId() );
+ if ( gr )
+ return QFile::decodeName( gr->gr_name );
+ return QString::null;
+}
+
+/*!
+ Returns the id of the group the file belongs to.
+
+ On systems where files do not have groups this function always
+ returns ((uind) -2).
+
+ \sa group(), owner(), ownerId()
+*/
+
+uint QFileInfo::groupId() const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ return fic->st.st_gid;
+ return nobodyID;
+}
+
+
+/*!
+ \fn bool QFileInfo::permission( int permissionSpec ) const
+
+ Tests for file permissions. The \e permissionSpec argument can be several
+ flags of type PermissionSpec or'ed together to check for permission
+ combinations.
+
+ On systems where files do not have permissions this function always
+ returns TRUE.
+
+ Example:
+ \code
+ QFileInfo fi( "/tmp/tonsils" );
+ if ( fi.permission( QFileInfo::WriteUser | QFileInfo::ReadGroup ) )
+ qWarning( "Tonsils can be changed by me, and the group can read them.");
+ if ( fi.permission( QFileInfo::WriteGroup | QFileInfo::WriteOther ) )
+ qWarning( "Danger! Tonsils can be changed by the group or others!" );
+ \endcode
+
+ \sa isReadable(), isWritable(), isExecutable()
+*/
+
+bool QFileInfo::permission( int permissionSpec ) const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic ) {
+ uint mask = 0;
+ if ( permissionSpec & ReadUser)
+ mask |= S_IRUSR;
+ if ( permissionSpec & WriteUser)
+ mask |= S_IWUSR;
+ if ( permissionSpec & ExeUser)
+ mask |= S_IXUSR;
+ if ( permissionSpec & ReadGroup)
+ mask |= S_IRGRP;
+ if ( permissionSpec & WriteGroup)
+ mask |= S_IWGRP;
+ if ( permissionSpec & ExeGroup)
+ mask |= S_IXGRP;
+ if ( permissionSpec & ReadOther)
+ mask |= S_IROTH;
+ if ( permissionSpec & WriteOther)
+ mask |= S_IWOTH;
+ if ( permissionSpec & ExeOther)
+ mask |= S_IXOTH;
+ if ( mask ) {
+ return (fic->st.st_mode & mask) == mask;
+ } else {
+#if defined(CHECK_NULL)
+ qWarning( "QFileInfo::permission: permissionSpec is 0" );
+#endif
+ return TRUE;
+ }
+ } else {
+ return FALSE;
+ }
+}
+
+/*!
+ Returns the file size in bytes, or 0 if the file does not exist if the size
+ cannot be fetched.
+*/
+
+uint QFileInfo::size() const
+{
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ return (uint)fic->st.st_size;
+ else
+ return 0;
+}
+
+
+/*!
+ Returns the date and time when the file was last modified.
+ \sa lastRead()
+*/
+
+QDateTime QFileInfo::lastModified() const
+{
+ QDateTime dt;
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ dt.setTime_t( fic->st.st_mtime );
+ return dt;
+}
+
+/*!
+ Returns the date and time when the file was last read (accessed).
+
+ On systems that do not support last read times, the modification time is
+ returned.
+
+ \sa lastModified()
+*/
+
+QDateTime QFileInfo::lastRead() const
+{
+ QDateTime dt;
+ if ( !fic || !cache )
+ doStat();
+ if ( fic )
+ dt.setTime_t( fic->st.st_atime );
+ return dt;
+}
+
+
+void QFileInfo::doStat() const
+{
+ QFileInfo *that = ((QFileInfo*)this); // mutable function
+ if ( !that->fic )
+ that->fic = new QFileInfoCache;
+ STATBUF *b = &that->fic->st;
+ that->fic->isSymLink = FALSE;
+
+#if defined(_OS_UNIX_) && defined(S_IFLNK)
+ if ( ::lstat(QFile::encodeName(fn),b) == 0 ) {
+ if ( S_ISLNK( b->st_mode ) )
+ that->fic->isSymLink = TRUE;
+ else
+ return;
+ }
+#endif
+ int r;
+
+ r = STAT( QFile::encodeName(fn), b );
+
+ if ( r != 0 && !that->fic->isSymLink ) {
+ delete that->fic;
+ that->fic = 0;
+ }
+}
+
+/*!
+ Returns the directory path of the file.
+
+ If \e absPath is TRUE an absolute path is always returned.
+
+ \sa dir(), filePath(), fileName(), isRelative()
+*/
+#ifndef QT_NO_DIR
+QString QFileInfo::dirPath( bool absPath ) const
+{
+ QString s;
+ if ( absPath )
+ s = absFilePath();
+ else
+ s = fn;
+ int pos = s.findRev( '/' );
+ if ( pos == -1 ) {
+ return QString::fromLatin1(".");
+ } else {
+ if ( pos == 0 )
+ return QString::fromLatin1( "/" );
+ return s.left( pos );
+ }
+}
+#endif
+/*!
+ Returns the name of the file, the file path is not included.
+
+ Example:
+ \code
+ QFileInfo fi( "/tmp/abdomen.lower" );
+ QString name = fi.fileName(); // name = "abdomen.lower"
+ \endcode
+
+ \sa isRelative(), filePath(), baseName(), extension()
+*/
+
+QString QFileInfo::fileName() const
+{
+ int p = fn.findRev( '/' );
+ if ( p == -1 ) {
+ return fn;
+ } else {
+ return fn.mid(p+1);
+ }
+}
+
+/*!
+ Returns the absolute path name.
+
+ The absolute path name is the file name including the absolute path. If
+ the QFileInfo is absolute (i.e. not relative) this function will return
+ the same string as filePath().
+
+ Note that this function can be time-consuming under UNIX. (in the order
+ of milliseconds on a 486 DX2/66 running Linux).
+
+ \sa isRelative(), filePath()
+*/
+#ifndef QT_NO_DIR
+QString QFileInfo::absFilePath() const
+{
+ if ( QDir::isRelativePath(fn) ) {
+ QString tmp = QDir::currentDirPath();
+ tmp += '/';
+ tmp += fn;
+ makeAbs( tmp );
+ return QDir::cleanDirPath( tmp );
+ } else {
+ QString tmp = fn;
+ makeAbs( tmp );
+ return QDir::cleanDirPath( tmp );
+ }
+
+}
+#endif
+
+// KWQ hacks ---------------------------------------------------------------
+
+#endif // USING_BORROWED_QDIR
+
+// -------------------------------------------------------------------------
diff --git a/WebCore/src/kwq/qt/_qgarray.h b/WebCore/src/kwq/qt/_qgarray.h
index 89b77d7..3157c89 100644
--- a/WebCore/src/kwq/qt/_qgarray.h
+++ b/WebCore/src/kwq/qt/_qgarray.h
@@ -27,7 +27,7 @@
class QGArray // generic array
{
-//friend class QBuffer;
+friend class QBuffer;
public:
//### DO NOT USE THIS. IT IS PUBLIC BUT DO NOT USE IT IN NEW CODE.
struct array_data : public QShared { // shared array
diff --git a/WebCore/src/kwq/qt/_qstrlist.h b/WebCore/src/kwq/qt/_qstrlist.h
index ffcd178..10ff372 100644
--- a/WebCore/src/kwq/qt/_qstrlist.h
+++ b/WebCore/src/kwq/qt/_qstrlist.h
@@ -40,6 +40,10 @@
// KWQ hacks ---------------------------------------------------------------
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#ifndef USING_BORROWED_QSTRINGLIST
#define USING_BORROWED_QSTRINGLIST
#endif
diff --git a/WebCore/src/kwq/qt/_qurl.cpp b/WebCore/src/kwq/qt/_qurl.cpp
new file mode 100644
index 0000000..3c5ca9e
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qurl.cpp
@@ -0,0 +1,1152 @@
+/****************************************************************************
+** $Id$
+**
+** Implementation of QUrl class
+**
+** Created : 950429
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the kernel 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 "_qurl.h"
+
+#ifndef QT_NO_DIR
+
+#include <stdlib.h>
+
+struct QUrlPrivate
+{
+ QString protocol;
+ QString user;
+ QString pass;
+ QString host;
+ QString path, cleanPath;
+ QString refEncoded;
+ QString queryEncoded;
+ bool isValid;
+ int port;
+ bool cleanPathDirty;
+};
+
+/*!
+ Replaces backslashes with slashes and removes multiple occurrences
+ of slashes or backslashes if \c allowMultiple is FALSE.
+*/
+
+static void slashify( QString& s, bool allowMultiple = TRUE )
+{
+ bool justHadSlash = FALSE;
+ for ( int i = 0; i < (int)s.length(); i++ ) {
+ if ( !allowMultiple && justHadSlash &&
+ ( s[ i ] == '/' || s[ i ] == '\\' ) ) {
+ s.remove( i, 1 );
+ --i;
+ continue;
+ }
+ if ( s[ i ] == '\\' )
+ s[ i ] = '/';
+ if ( s[ i ] == '/' )
+ justHadSlash = TRUE;
+ else
+ justHadSlash = FALSE;
+ }
+}
+
+// NOT REVISED
+/*!
+ \class QUrl qurl.h
+
+ \brief The QUrl class provides mainly an URL parser and
+ simplifies working with URLs.
+
+ \ingroup misc
+
+ The QUrl class is provided for a easy working with URLs.
+ It does all parsing, decoding, encoding and so on.
+
+ Mention that URL has some restrictions regarding the path
+ encoding. URL works intern with the decoded path and
+ and encoded query. For example in
+
+ http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you
+
+ would result in a decoded path "/cgi-bin/test me.pl"
+ and in the encoded query "cmd=Hello%20you".
+ Since path is internally always encoded you may NOT use
+ "%00" in the path while this is ok for the query.
+
+ QUrl is normally used like that:
+
+ \code
+ QUrl u( "http://www.trolltech.com" );
+ // or
+ QUrl u( "file:/home/myself/Mail", "Inbox" );
+ \endcode
+
+ Then you can access the parts of the URL, change them and do
+ some more stuff.
+
+ To allow easy working with QUrl and QString together, QUrl implements
+ the needed cast and assign operators. So you can do following:
+
+ \code
+ QUrl u( "http://www.trolltech.com" );
+ QString s = u;
+ // or
+ QString s( "http://www.trolltech.com" );
+ QUrl u( s );
+ \endcode
+
+ If you want to use an URL to work on a hierarchical structures
+ (e.g. locally or remote filesystem) the class QUrlOperator, which is derived
+ fro QUrl, may be interesting for you.
+
+ \sa QUrlOperator
+*/
+
+
+/*!
+ Constructs an empty URL which, is invalid.
+*/
+
+QUrl::QUrl()
+{
+ d = new QUrlPrivate;
+ d->isValid = FALSE;
+ d->port = -1;
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Constructs and URL using \a url and parses this string.
+
+ You can pass strings like "/home/qt", in this case the protocol
+ "file" is assumed.
+*/
+
+QUrl::QUrl( const QString& url )
+{
+ d = new QUrlPrivate;
+ d->protocol = "file";
+ d->port = -1;
+ parse( url );
+}
+
+/*!
+ Copy constructor. Copies the data of \a url.
+*/
+
+QUrl::QUrl( const QUrl& url )
+{
+ d = new QUrlPrivate;
+ *d = *url.d;
+}
+
+/*!
+ Returns TRUE, if \a url is relative, else it returns FALSE.
+*/
+
+bool QUrl::isRelativeUrl( const QString &url )
+{
+ int colon = url.find( ":" );
+ int slash = url.find( "/" );
+
+ return ( slash != 0 && ( colon == -1 || ( slash != -1 && colon > slash ) ) );
+}
+
+/*!
+ Constructs and URL taking \a url as base (context) and
+ \a relUrl as relative URL to \a url. If \a relUrl is not relative,
+ \a relUrl is taken as new URL.
+
+ For example, the path of
+
+ \code
+ QUrl u( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );
+ \endcode
+
+ will be "/qt/srource/qt-2.1.0.tar.gz".
+
+ And
+
+ \code
+ QUrl u( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );
+ \endcode
+
+ will result in a new URL, "ftp://ftp.trolltech.com/usr/local",
+
+ And
+
+ \code
+ QUrl u( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );
+ \endcode
+
+ will result in a new URL, with "/usr/local" as path
+ and "file" as protocol.
+
+ Normally it is expected that the path of \a url points to
+ a directory, even if the path has no slash at the end. But
+ if you want that the constructor handles the last
+ part of the path as filename, if there is no slash at the end,
+ and let it replace by the filename of \a relUrl
+ (if it contains one), set \a checkSlash to TRUE.
+*/
+
+QUrl::QUrl( const QUrl& url, const QString& relUrl, bool checkSlash )
+{
+ d = new QUrlPrivate;
+ QString rel = relUrl;
+ slashify( rel );
+
+ if ( !isRelativeUrl( rel ) ) {
+ if ( rel[ 0 ] == QChar( '/' ) ) {
+ *this = url;
+ setEncodedPathAndQuery( rel );
+ } else {
+ *this = rel;
+ }
+ } else {
+ if ( rel[ 0 ] == '#' ) {
+ *this = url;
+ rel.remove( 0, 1 );
+ decode( rel );
+ setRef( rel );
+ } else if ( rel[ 0 ] == '?' ) {
+ *this = url;
+ rel.remove( 0, 1 );
+ setQuery( rel );
+ } else {
+ decode( rel );
+ *this = url;
+ if ( !checkSlash || d->cleanPath[ (int)path().length() - 1 ] == '/' ) {
+ QString p = url.path();
+ if ( p.isEmpty() )
+ p = "/";
+ if ( p.right( 1 ) != "/" )
+ p += "/";
+ p += rel;
+ d->path = p;
+ d->cleanPathDirty = TRUE;
+ } else {
+ setFileName( rel );
+ }
+ }
+ }
+}
+
+/*!
+ Destructor.
+*/
+
+QUrl::~QUrl()
+{
+ delete d;
+ d = 0;
+}
+
+/*!
+ Returns the protocol of the URL. It is something like
+ "file" or "ftp".
+*/
+
+QString QUrl::protocol() const
+{
+ return d->protocol;
+}
+
+/*!
+ Sets the protocol of the URL. This could be e.g.
+ "file", "ftp", or something similar.
+*/
+
+void QUrl::setProtocol( const QString& protocol )
+{
+ d->protocol = protocol;
+}
+
+/*!
+ Returns the username of the URL.
+*/
+
+QString QUrl::user() const
+{
+ return d->user;
+}
+
+/*!
+ Sets the username of the URL.
+*/
+
+void QUrl::setUser( const QString& user )
+{
+ d->user = user;
+}
+
+/*!
+ Returns TRUE, if the URL contains an username,
+ else FALSE;
+*/
+
+bool QUrl::hasUser() const
+{
+ return !d->user.isEmpty();
+}
+
+/*!
+ Returns the password of the URL.
+*/
+
+QString QUrl::password() const
+{
+ return d->pass;
+}
+
+/*!
+ Sets the password of the URL.
+*/
+
+void QUrl::setPassword( const QString& pass )
+{
+ d->pass = pass;
+}
+
+/*!
+ Returns TRUE, if the URL contains a password,
+ else FALSE;
+*/
+
+bool QUrl::hasPassword() const
+{
+ return !d->pass.isEmpty();
+}
+
+/*!
+ Returns the hostname of the URL.
+*/
+
+QString QUrl::host() const
+{
+ return d->host;
+}
+
+/*!
+ Sets the hostname of the URL.
+*/
+
+void QUrl::setHost( const QString& host )
+{
+ d->host = host;
+}
+
+/*!
+ Returns TRUE, if the URL contains a hostname,
+ else FALSE;
+*/
+
+bool QUrl::hasHost() const
+{
+ return !d->host.isEmpty();
+}
+
+/*!
+ Returns the port of the URL.
+*/
+
+int QUrl::port() const
+{
+ return d->port;
+}
+
+/*!
+ Sets the port of the URL.
+*/
+
+void QUrl::setPort( int port )
+{
+ d->port = port;
+}
+
+/*!
+ Sets the path or the URL.
+*/
+
+void QUrl::setPath( const QString& path )
+{
+ d->path = path;
+ slashify( d->path );
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Returns TRUE, if the URL contains a path,
+ else FALSE.
+*/
+
+bool QUrl::hasPath() const
+{
+ return !d->path.isEmpty();
+}
+
+/*!
+ Sets the query of the URL. Must be encoded.
+*/
+
+void QUrl::setQuery( const QString& txt )
+{
+ d->queryEncoded = txt;
+}
+
+/*!
+ Returns the query (encoded) of the URL.
+*/
+
+QString QUrl::query() const
+{
+ return d->queryEncoded;
+}
+
+/*!
+ Returns the reference (encoded) of the URL.
+*/
+
+QString QUrl::ref() const
+{
+ return d->refEncoded;
+}
+
+/*!
+ Sets the reference of the URL. Must be encoded.
+*/
+
+void QUrl::setRef( const QString& txt )
+{
+ d->refEncoded = txt;
+}
+
+/*!
+ Returns TRUE, if the URL has a reference, else it returns FALSE.
+*/
+
+bool QUrl::hasRef() const
+{
+ return !d->refEncoded.isEmpty();
+}
+
+/*!
+ Returns TRUE if the URL is valid, else FALSE.
+ An URL is e.g. invalid if there was a parse error.
+*/
+
+bool QUrl::isValid() const
+{
+ return d->isValid;
+}
+
+/*!
+ Resets all values if the URL to its default values
+ and invalidates it.
+*/
+
+void QUrl::reset()
+{
+ d->protocol = "file";
+ d->user = "";
+ d->pass = "";
+ d->host = "";
+ d->path = "";
+ d->queryEncoded = "";
+ d->refEncoded = "";
+ d->isValid = TRUE;
+ d->port = -1;
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Parses the \a url.
+*/
+
+bool QUrl::parse( const QString& url )
+{
+ QString url_( url );
+ slashify( url_ );
+
+ if ( url_.isEmpty() ) {
+ d->isValid = FALSE;
+ return FALSE;
+ }
+
+ d->cleanPathDirty = TRUE;
+ d->isValid = TRUE;
+ QString oldProtocol = d->protocol;
+ d->protocol = QString::null;
+
+ const int Init = 0;
+ const int Protocol = 1;
+ const int Separator1= 2; // :
+ const int Separator2= 3; // :/
+ const int Separator3= 4; // :// or more slashes
+ const int User = 5;
+ const int Pass = 6;
+ const int Host = 7;
+ const int Path = 8;
+ const int Ref = 9;
+ const int Query = 10;
+ const int Port = 11;
+ const int Done = 12;
+
+ const int InputAlpha= 1;
+ const int InputDigit= 2;
+ const int InputSlash= 3;
+ const int InputColon= 4;
+ const int InputAt = 5;
+ const int InputHash = 6;
+ const int InputQuery= 7;
+
+ static uchar table[ 12 ][ 8 ] = {
+ /* None InputAlpha InputDigit InputSlash InputColon InputAt InputHash InputQuery */
+ { 0, Protocol, 0, Path, 0, 0, 0, 0, }, // Init
+ { 0, Protocol, Protocol, 0, Separator1, 0, 0, 0, }, // Protocol
+ { 0, Path, Path, Separator2, 0, 0, 0, 0, }, // Separator1
+ { 0, Path, Path, Separator3, 0, 0, 0, 0, }, // Separator2
+ { 0, User, User, Separator3, Pass, Host, 0, 0, }, // Separator3
+ { 0, User, User, User, Pass, Host, User, User, }, // User
+ { 0, Pass, Pass, Pass, Pass, Host, Pass, Pass, }, // Pass
+ { 0, Host, Host, Path, Port, Host, Ref, Query, }, // Host
+ { 0, Path, Path, Path, Path, Path, Ref, Query, }, // Path
+ { 0, Ref, Ref, Ref, Ref, Ref, Ref, Query, }, // Ref
+ { 0, Query, Query, Query, Query, Query, Query, Query, }, // Query
+ { 0, 0, Port, Path, 0, 0, 0, 0, } // Port
+ };
+
+ bool relPath = FALSE;
+
+ relPath = FALSE;
+ bool forceRel = FALSE;
+
+ // if :/ is at pos 1, we have only one letter
+ // before that separator => that's a drive letter!
+ int cs = url_.find( ":/" );
+ if ( cs == 1 )
+ relPath = forceRel = TRUE;
+
+ int hasNoHost = -1;
+ if ( cs != -1 ) // if a protocol is there, find out if there is a host or directly the path after it
+ hasNoHost = url_.find( "///", cs );
+ table[ 4 ][ 1 ] = User;
+ table[ 4 ][ 2 ] = User;
+ if ( cs == -1 || forceRel ) { // we have a relative file
+ if ( url.find( ':' ) == -1 || forceRel ) {
+ table[ 0 ][ 1 ] = Path;
+ // Filenames may also begin with a digit
+ table[ 0 ][ 2 ] = Path;
+ } else {
+ table[ 0 ][ 1 ] = Protocol;
+ }
+ relPath = TRUE;
+ } else { // some checking
+ table[ 0 ][ 1 ] = Protocol;
+
+ // find the part between the protocol and the path as the meaning
+ // of that part is dependend on some chars
+ ++cs;
+ while ( url_[ cs ] == '/' )
+ ++cs;
+ int slash = url_.find( "/", cs );
+ if ( slash == -1 )
+ slash = url_.length() - 1;
+ QString tmp = url_.mid( cs, slash - cs + 1 );
+
+ if ( !tmp.isEmpty() ) { // if this part exists
+
+ // look for the @ in this part
+ int at = tmp.find( "@" );
+ if ( at != -1 )
+ at += cs;
+ // we have no @, which means host[:port], so directly
+ // after the protocol the host starts, or if the protocol
+ // is file or there were more than 2 slashes, it´s the
+ // path
+ if ( at == -1 ) {
+ if ( url_.left( 4 ) == "file" || hasNoHost != -1 )
+ table[ 4 ][ 1 ] = Path;
+ else
+ table[ 4 ][ 1 ] = Host;
+ table[ 4 ][ 2 ] = table[ 4 ][ 1 ];
+ }
+ }
+ }
+
+ int state = Init; // parse state
+ int input; // input token
+
+ QChar c = url_[ 0 ];
+ int i = 0;
+ QString port;
+
+ while ( TRUE ) {
+ switch ( c ) {
+ case '?':
+ input = InputQuery;
+ break;
+ case '#':
+ input = InputHash;
+ break;
+ case '@':
+ input = InputAt;
+ break;
+ case ':':
+ input = InputColon;
+ break;
+ case '/':
+ input = InputSlash;
+ break;
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9': case '0':
+ input = InputDigit;
+ break;
+ default:
+ input = InputAlpha;
+ }
+
+ state = table[ state ][ input ];
+
+ switch ( state ) {
+ case Protocol:
+ d->protocol += c;
+ break;
+ case User:
+ d->user += c;
+ break;
+ case Pass:
+ d->pass += c;
+ break;
+ case Host:
+ d->host += c;
+ break;
+ case Path:
+ d->path += c;
+ break;
+ case Ref:
+ d->refEncoded += c;
+ break;
+ case Query:
+ d->queryEncoded += c;
+ break;
+ case Port:
+ port += c;
+ break;
+ default:
+ break;
+ }
+
+ ++i;
+ if ( i > (int)url_.length() - 1 || state == Done || state == 0 )
+ break;
+ c = url_[ i ];
+
+ }
+
+ if ( !port.isEmpty() ) {
+ port.remove( 0, 1 );
+ d->port = atoi( port.latin1() );
+ }
+
+ // error
+ if ( i < (int)url_.length() - 1 ) {
+ d->isValid = FALSE;
+ return FALSE;
+ }
+
+
+ if ( d->protocol.isEmpty() )
+ d->protocol = oldProtocol;
+
+ if ( d->path.isEmpty() )
+ d->path = "/";
+
+ // hack for windows
+ if ( d->path.length() == 2 && d->path[ 1 ] == ':' )
+ d->path += "/";
+
+ // #### do some corrections, should be done nicer too
+ if ( !d->pass.isEmpty() && d->pass[ 0 ] == ':' )
+ d->pass.remove( 0, 1 );
+ if ( !d->path.isEmpty() ) {
+ if ( d->path[ 0 ] == '@' || d->path[ 0 ] == ':' )
+ d->path.remove( 0, 1 );
+ if ( d->path[ 0 ] != '/' && !relPath && d->path[ 1 ] != ':' )
+ d->path.prepend( "/" );
+ }
+ if ( !d->refEncoded.isEmpty() && d->refEncoded[ 0 ] == '#' )
+ d->refEncoded.remove( 0, 1 );
+ if ( !d->queryEncoded.isEmpty() && d->queryEncoded[ 0 ] == '?' )
+ d->queryEncoded.remove( 0, 1 );
+ if ( !d->host.isEmpty() && d->host[ 0 ] == '@' )
+ d->host.remove( 0, 1 );
+
+#if defined(_OS_WIN32_)
+ // hack for windows file://machine/path syntax
+ if ( d->protocol == "file" ) {
+ if ( url.left( 7 ) == "file://" &&
+ ( d->path.length() < 8 || d->path[ 7 ] != '/' ) &&
+ d->path[ 1 ] != '/' )
+ d->path.prepend( "/" );
+ }
+#endif
+
+ decode( d->path );
+ d->cleanPathDirty = TRUE;
+
+#if 0
+ qDebug( "URL: %s", url.latin1() );
+ qDebug( "protocol: %s", d->protocol.latin1() );
+ qDebug( "user: %s", d->user.latin1() );
+ qDebug( "pass: %s", d->pass.latin1() );
+ qDebug( "host: %s", d->host.latin1() );
+ qDebug( "path: %s", path().latin1() );
+ qDebug( "ref: %s", d->refEncoded.latin1() );
+ qDebug( "query: %s", d->queryEncoded.latin1() );
+ qDebug( "port: %d\n\n----------------------------\n\n", d->port );
+#endif
+
+ return TRUE;
+}
+
+/*!
+ Assign operator. Parses \a url and assigns the resulting
+ data to this class.
+
+ You can pass strings like "/home/qt", in this case the protocol
+ "file" is assumed.
+*/
+
+QUrl& QUrl::operator=( const QString& url )
+{
+ reset();
+ parse( url );
+
+ return *this;
+}
+
+/*!
+ Assign operator. Assigns the data of \a url to this class.
+*/
+
+QUrl& QUrl::operator=( const QUrl& url )
+{
+ *d = *url.d;
+ return *this;
+}
+
+/*!
+ Compares this URL with \a url and returns TRUE if
+ they are equal, else FALSE.
+*/
+
+bool QUrl::operator==( const QUrl& url ) const
+{
+ if ( !isValid() || !url.isValid() )
+ return FALSE;
+
+ if ( d->protocol == url.d->protocol &&
+ d->user == url.d->user &&
+ d->pass == url.d->pass &&
+ d->host == url.d->host &&
+ d->path == url.d->path &&
+ d->queryEncoded == url.d->queryEncoded &&
+ d->refEncoded == url.d->refEncoded &&
+ d->isValid == url.d->isValid &&
+ d->port == url.d->port )
+ return TRUE;
+
+ return FALSE;
+}
+
+/*!
+ Compares this URL with \a url. \a url is parsed
+ first. Returns TRUE if \a url is equal to this url,
+ else FALSE:
+*/
+
+bool QUrl::operator==( const QString& url ) const
+{
+ QUrl u( url );
+ return ( *this == u );
+}
+
+/*!
+ Sets the filename of the URL to \a name. If this
+ url contains a fileName(), this is replaced by
+ \a name. See the documentation of fileName()
+ for a more detail discussion, about what is handled
+ as file name and what as directory path.
+*/
+
+void QUrl::setFileName( const QString& name )
+{
+ QString fn( name );
+ slashify( fn );
+
+ while ( fn[ 0 ] == '/' )
+ fn.remove( 0, 1 );
+
+ QString p = path().isEmpty() ?
+ QString( "/" ) : path();
+ if ( !path().isEmpty() ) {
+ int slash = p.findRev( QChar( '/' ) );
+ if ( slash == -1 ) {
+ p = "/";
+ } else if ( p[ (int)p.length() - 1 ] != '/' )
+ p.truncate( slash + 1 );
+ }
+
+ p += fn;
+ if ( !d->queryEncoded.isEmpty() )
+ p += "?" + d->queryEncoded;
+ setEncodedPathAndQuery( p );
+}
+
+/*!
+ Returns the encoded path plus the query (encoded too).
+*/
+
+QString QUrl::encodedPathAndQuery()
+{
+ QString p = path();
+ if ( p.isEmpty() )
+ p = "/";
+
+ encode( p );
+
+ if ( !d->queryEncoded.isEmpty() ) {
+ p += "?";
+ p += d->queryEncoded;
+ }
+
+ return p;
+}
+
+/*!
+ Sets path and query. Both have to be encoded.
+*/
+
+void QUrl::setEncodedPathAndQuery( const QString& path )
+{
+ d->cleanPathDirty = TRUE;
+ int pos = path.find( '?' );
+ if ( pos == -1 ) {
+ d->path = path;
+ d->queryEncoded = "";
+ } else {
+ d->path = path.left( pos );
+ d->queryEncoded = path.mid( pos + 1 );
+ }
+
+ decode( d->path );
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Returns the path of the URL. If \a correct is TRUE,
+ the path is cleaned (deals with too many or few
+ slashes, cleans things like "/../..", etc). Else exactly the path
+ which was parsed or set is returned.
+*/
+
+QString QUrl::path( bool correct ) const
+{
+ if ( !correct )
+ return d->path;
+
+ if ( d->cleanPathDirty ) {
+ bool check = TRUE;
+ if ( QDir::isRelativePath( d->path ) ) {
+ d->cleanPath = d->path;
+ } else if ( isLocalFile() ) {
+#if defined(_OS_WIN32_)
+ // hack for stuff like \\machine\path and //machine/path on windows
+ if ( ( d->path.left( 1 ) == "/" || d->path.left( 1 ) == "\\" ) &&
+ d->path.length() > 1 ) {
+ d->cleanPath = d->path;
+ bool share = d->cleanPath[ 1 ] == '\\' || d->cleanPath[ 1 ] == '/';
+ slashify( d->cleanPath, FALSE );
+ d->cleanPath = QDir::cleanDirPath( d->cleanPath );
+ if ( share ) {
+ check = FALSE;
+ d->cleanPath.prepend( "/" );
+ }
+ }
+#endif
+ if ( check ) {
+ QFileInfo fi( d->path );
+ if ( !fi.exists() )
+ d->cleanPath = d->path;
+ else if ( fi.isDir() ) {
+ QString dir = QDir::cleanDirPath( QDir( d->path ).canonicalPath() ) + "/";
+ if ( dir == "//" )
+ d->cleanPath = "/";
+ else
+ d->cleanPath = dir;
+ } else {
+ QString p = QDir::cleanDirPath( fi.dir().canonicalPath() );
+ d->cleanPath = p + "/" + fi.fileName();
+ }
+ }
+ } else {
+ if ( d->path != "/" && d->path[ (int)d->path.length() - 1 ] == '/' )
+ d->cleanPath = QDir::cleanDirPath( d->path ) + "/";
+ else
+ d->cleanPath = QDir::cleanDirPath( d->path );
+ }
+
+ if ( check )
+ slashify( d->cleanPath, FALSE );
+ d->cleanPathDirty = FALSE;
+ }
+
+ return d->cleanPath;
+}
+
+/*!
+ Returns TRUE, if the URL is a local file, else
+ it returns FALSE;
+*/
+
+bool QUrl::isLocalFile() const
+{
+ return d->protocol == "file";
+}
+
+/*!
+ Returns the filename of the URL. If the path of the URL
+ doesn't have a slash at the end, the part between the last slash
+ and the end of the path string is handled as filename. If the
+ path has a slash at the end, an empty string is returned here.
+*/
+
+QString QUrl::fileName() const
+{
+ if ( d->path.isEmpty() )
+ return QString::null;
+
+ return QFileInfo( d->path ).fileName();
+}
+
+/*!
+ Adds the path \a pa to the path of the URL.
+*/
+
+void QUrl::addPath( const QString& pa )
+{
+ if ( pa.isEmpty() )
+ return;
+
+ QString p( pa );
+ slashify( p );
+
+ if ( path().isEmpty() ) {
+ if ( p[ 0 ] != QChar( '/' ) )
+ d->path = "/" + p;
+ else
+ d->path = p;
+ } else {
+ if ( p[ 0 ] != QChar( '/' ) && d->path[ (int)d->path.length() - 1 ] != '/' )
+ d->path += "/" + p;
+ else
+ d->path += p;
+ }
+ d->cleanPathDirty = TRUE;
+}
+
+/*!
+ Returns the directory path of the URL. This is the part
+ of the path of this URL without the fileName(). See
+ the documentation of fileName() for a discussion
+ what is handled as file name and what as directory path.
+*/
+
+QString QUrl::dirPath() const
+{
+ if ( path().isEmpty() )
+ return QString::null;
+
+ QString s = path();
+ // ### If anything is broken with regards to the directories in QFileDialog
+ // et al, then this is probably the place to look
+// if ( s.right( 1 ) != "/" )
+// s += "/";
+ s = QFileInfo( s ).dirPath();
+
+// s = QFileInfo( s ).dirPath( TRUE );
+// if ( s[ (int)s.length() - 1 ] != '/' )
+// s += "/";
+ return s;
+}
+
+/*!
+ Encodes the string \a url.
+*/
+
+void QUrl::encode( QString& url )
+{
+ int oldlen = url.length();
+
+ if ( !oldlen )
+ return;
+
+ QString newUrl;
+ int newlen = 0;
+
+ for ( int i = 0; i < oldlen ;++i ) {
+ ushort inCh = url[ i ].unicode();
+
+ if ( inCh >= 128 ||
+ QString( "<>#@\"&%$:,;?={}|^~[]\'`\\ \n\t\r" ).contains(inCh) ) {
+ newUrl[ newlen++ ] = QChar( '%' );
+
+ ushort c = inCh / 16;
+ c += c > 9 ? 'A' - 10 : '0';
+ newUrl[ newlen++ ] = c;
+
+ c = inCh % 16;
+ c += c > 9 ? 'A' - 10 : '0';
+ newUrl[ newlen++ ] = c;
+ } else {
+ newUrl[ newlen++ ] = url[ i ];
+ }
+ }
+
+ url = newUrl;
+}
+
+static ushort hex_to_int( ushort c )
+{
+ if ( c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ if ( c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ if ( c >= '0' && c <= '9')
+ return c - '0';
+ return 0;
+}
+
+/*!
+ Decodes the string \a url.
+*/
+
+void QUrl::decode( QString& url )
+{
+ int oldlen = url.length();
+ if ( !oldlen )
+ return;
+
+ int newlen = 0;
+
+ QString newUrl;
+
+ int i = 0;
+ while ( i < oldlen ) {
+ ushort c = url[ i++ ].unicode();
+ if ( c == '%' ) {
+ c = hex_to_int( url[ i ].unicode() ) * 16 + hex_to_int( url[ i + 1 ].unicode() );
+ i += 2;
+ }
+ newUrl [ newlen++ ] = c;
+ }
+
+ url = newUrl;
+}
+
+/*! Composes a string of the URL and returns it. If \a encodedPath is
+ TRUE, the path in the returned string will be encoded. If \a
+ forcePrependProtocol is TRUE, the protocol (file:/) is also
+ prepended to local filenames, else no protocol is prepended for
+ local filenames.
+*/
+
+QString QUrl::toString( bool encodedPath, bool forcePrependProtocol ) const
+{
+ QString res, p = path();
+ if ( encodedPath )
+ encode( p );
+
+ if ( isLocalFile() ) {
+ if ( forcePrependProtocol )
+ res = d->protocol + ":" + p;
+ else
+ res = p;
+ } else if ( d->protocol == "mailto" ) {
+ res = d->protocol + ":" + p;
+ } else {
+ res = d->protocol + "://";
+ if ( !d->user.isEmpty() || !d->pass.isEmpty() ) {
+ if ( !d->user.isEmpty() )
+ res += d->user;
+ if ( !d->pass.isEmpty() )
+ res += ":" + d->pass;
+ res += "@";
+ }
+ res += d->host;
+ if ( d->port != -1 )
+ res += ":" + QString( "%1" ).arg( d->port );
+ res += p;
+ }
+
+ if ( !d->refEncoded.isEmpty() )
+ res += "#" + d->refEncoded;
+ if ( !d->queryEncoded.isEmpty() )
+ res += "?" + d->queryEncoded;
+
+ return res;
+}
+
+/*!
+ Composes a string of the URL and returns it.
+
+ \sa QUrl::toString()
+*/
+
+QUrl::operator QString() const
+{
+ return toString();
+}
+
+/*!
+ Goes one directory up.
+*/
+
+bool QUrl::cdUp()
+{
+ d->path += "/..";
+ d->cleanPathDirty = TRUE;
+ return TRUE;
+}
+
+#endif // QT_NO_NETWORKPROTOCOL
diff --git a/WebCore/src/kwq/qt/_qurl.h b/WebCore/src/kwq/qt/_qurl.h
new file mode 100644
index 0000000..3b212aa
--- /dev/null
+++ b/WebCore/src/kwq/qt/_qurl.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+** $Id$
+**
+** Definition of QUrl class
+**
+** Created : 950429
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the kernel 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.
+**
+**********************************************************************/
+
+#ifndef QURL_H
+#define QURL_H
+
+#ifndef QT_H
+#include "qstring.h"
+#include "_qdir.h"
+#endif // QT_H
+
+struct QUrlPrivate;
+
+class Q_EXPORT QUrl
+{
+public:
+ QUrl();
+ QUrl( const QString& url );
+ QUrl( const QUrl& url );
+ QUrl( const QUrl& url, const QString& relUrl, bool checkSlash = FALSE );
+ virtual ~QUrl();
+
+ QString protocol() const;
+ virtual void setProtocol( const QString& protocol );
+
+ QString user() const;
+ virtual void setUser( const QString& user );
+ bool hasUser() const;
+
+ QString password() const;
+ virtual void setPassword( const QString& pass );
+ bool hasPassword() const;
+
+ QString host() const;
+ virtual void setHost( const QString& user );
+ bool hasHost() const;
+
+ int port() const;
+ virtual void setPort( int port );
+
+ QString path( bool correct = TRUE ) const;
+ virtual void setPath( const QString& path );
+ bool hasPath() const;
+
+ virtual void setEncodedPathAndQuery( const QString& enc );
+ QString encodedPathAndQuery();
+
+ virtual void setQuery( const QString& txt );
+ QString query() const;
+
+ QString ref() const;
+ virtual void setRef( const QString& txt );
+ bool hasRef() const;
+
+ bool isValid() const;
+ bool isLocalFile() const;
+
+ virtual void addPath( const QString& path );
+ virtual void setFileName( const QString& txt );
+
+ QString fileName() const;
+ QString dirPath() const;
+
+ QUrl& operator=( const QUrl& url );
+ QUrl& operator=( const QString& url );
+
+ bool operator==( const QUrl& url ) const;
+ bool operator==( const QString& url ) const;
+
+ static void decode( QString& url );
+ static void encode( QString& url );
+
+ operator QString() const;
+ virtual QString toString( bool encodedPath = FALSE, bool forcePrependProtocol = TRUE ) const;
+
+ virtual bool cdUp();
+
+ static bool isRelativeUrl( const QString &url );
+
+protected:
+ virtual void reset();
+ virtual bool parse( const QString& url );
+
+private:
+ QUrlPrivate *d;
+
+};
+
+#endif
diff --git a/WebCore/src/kwq/qt/qbuffer.h b/WebCore/src/kwq/qt/qbuffer.h
index 4db04c7..d0ff927 100644
--- a/WebCore/src/kwq/qt/qbuffer.h
+++ b/WebCore/src/kwq/qt/qbuffer.h
@@ -30,6 +30,12 @@
#include <config.h>
#endif
+// USING_BORROWED_QBUFFER ======================================================
+
+#ifdef USING_BORROWED_QBUFFER
+#include <_qbuffer.h>
+#else
+
#include <KWQDef.h>
#include "qarray.h"
@@ -72,4 +78,6 @@ private:
}; // class QBuffer ============================================================
+#endif // USING_BORROWED_QBUFFER
+
#endif
diff --git a/WebCore/src/kwq/qt/qdir.h b/WebCore/src/kwq/qt/qdir.h
index 4fa412f..47e5a2c 100644
--- a/WebCore/src/kwq/qt/qdir.h
+++ b/WebCore/src/kwq/qt/qdir.h
@@ -30,6 +30,13 @@
#include <config.h>
#endif
+// USING_BORROWED_QDIR =========================================================
+
+#ifdef USING_BORROWED_QDIR
+#include <_qdir.h>
+#else
+
+#include <KWQDef.h>
#include "qstring.h"
#include "qstringlist.h"
#include "qfile.h"
@@ -68,4 +75,6 @@ public:
}; // class QDir ===============================================================
+#endif // USING_BORROWED_QDIR
+
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list