#endif"
ac_subdirs_all="$ac_subdirs_all src/expat"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP CXX CXXFLAGS ac_ct_CXX RANLIB ac_ct_RANLIB AR INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA STRIP IF_GNU_MAKE LN_S CXXCPP subdirs PKG_CONFIG GTK_CFLAGS GTK_LIBS GTK_CONFIG PANGOFT2_CFLAGS PANGOFT2_LIBS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS PANGOX_CFLAGS PANGOX_LIBS PANGOXFT_CFLAGS PANGOXFT_LIBS RESCOMP DEREZ SETFILE LIBICONV EXTRALIBS_ESD CORE_BASE_LIBS CORE_GUI_LIBS wxUSE_ZLIB wxUSE_REGEX wxUSE_EXPAT wxUSE_ODBC wxUSE_LIBJPEG wxUSE_LIBPNG wxUSE_LIBTIFF VENDOR OFFICIAL_BUILD WXUNIV MONOLITHIC EXTRALIBS EXTRALIBS_XML EXTRALIBS_ODBC EXTRALIBS_GUI EXTRALIBS_OPENGL UNICODE BUILD DEBUG_INFO DEBUG_FLAG SHARED TOOLKIT_LOWERCASE TOOLKIT_VERSION SAMPLES_RPATH_FLAG SAMPLES_RPATH_POSTLINK HOST_SUFFIX SET_MAKE MAKE_SET ac_ct_AR ac_ct_STRIP NM ac_ct_NM INSTALL_DIR LDFLAGS_GUI PLATFORM_UNIX PLATFORM_WIN32 PLATFORM_MSDOS PLATFORM_MAC PLATFORM_MACOSX PLATFORM_OS2 SO_SUFFIX SO_SUFFIX_MODULE LIBPREFIX DLLPREFIX DLLPREFIX_MODULE AIX_CXX_LD SHARED_LD_CC SHARED_LD_CXX SHARED_LD_MODULE_CC SHARED_LD_MODULE_CXX PIC_FLAG USE_SOVERSION USE_SOVERLINUX USE_SOVERSOLARIS USE_MACVERSION USE_SOSYMLINKS SONAME_FLAG DEPS_TRACKING GCC_PCH COND_BUILD_DEBUG COND_BUILD_DEBUG_DEBUG_FLAG_DEFAULT COND_BUILD_DEBUG_DEBUG_INFO_DEFAULT COND_BUILD_RELEASE COND_BUILD_RELEASE_DEBUG_INFO_DEFAULT COND_DEBUG_FLAG_1 COND_DEBUG_INFO_0 COND_DEBUG_INFO_1 COND_DEPS_TRACKING_0 COND_DEPS_TRACKING_1 COND_GCC_PCH_1 COND_MONOLITHIC_0 COND_MONOLITHIC_0_SHARED_0 COND_MONOLITHIC_0_SHARED_0_USE_GUI_1 COND_MONOLITHIC_0_SHARED_0_USE_GUI_1_USE_ODBC_1 COND_MONOLITHIC_0_SHARED_0_USE_HTML_1 COND_MONOLITHIC_0_SHARED_0_USE_ODBC_1 COND_MONOLITHIC_0_SHARED_1 COND_MONOLITHIC_0_SHARED_1_USE_GUI_1 COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_ODBC_1 COND_MONOLITHIC_0_SHARED_1_USE_HTML_1 COND_MONOLITHIC_0_SHARED_1_USE_ODBC_1 COND_MONOLITHIC_1 COND_MONOLITHIC_1_SHARED_0 COND_MONOLITHIC_1_SHARED_1 COND_OFFICIAL_BUILD_0_PLATFORM_WIN32_1 COND_OFFICIAL_BUILD_1_PLATFORM_WIN32_1 COND_PLATFORM_MACOSX_0_USE_SOVERSION_1 COND_PLATFORM_MACOSX_1 COND_PLATFORM_MACOSX_1_TOOLKIT_COCOA COND_PLATFORM_MACOSX_1_TOOLKIT_GTK COND_PLATFORM_MACOSX_1_TOOLKIT_MAC COND_PLATFORM_MACOSX_1_USE_SOVERSION_1 COND_PLATFORM_MAC_1 COND_PLATFORM_OS2_1 COND_PLATFORM_UNIX_0 COND_PLATFORM_UNIX_1 COND_PLATFORM_WIN32_0 COND_PLATFORM_WIN32_1 COND_SHARED_0 COND_SHARED_0_USE_GUI_1_USE_OPENGL_1 COND_SHARED_0_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN COND_SHARED_0_USE_GUI_1_WXUSE_LIBPNG_BUILTIN COND_SHARED_0_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN COND_SHARED_0_WXUSE_EXPAT_BUILTIN COND_SHARED_0_WXUSE_ODBC_BUILTIN COND_SHARED_0_WXUSE_REGEX_BUILTIN COND_SHARED_0_WXUSE_ZLIB_BUILTIN COND_SHARED_1 COND_SHARED_1_USE_GUI_1_USE_OPENGL_1 COND_TOOLKIT_COCOA COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_GTK COND_TOOLKIT_GTK_USE_GUI_1 COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_MAC COND_TOOLKIT_MAC_USE_GUI_1 COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_MGL COND_TOOLKIT_MGL_USE_GUI_1 COND_TOOLKIT_MOTIF COND_TOOLKIT_MOTIF_USE_GUI_1 COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_MSW COND_TOOLKIT_MSW_USE_GUI_1 COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_PM COND_TOOLKIT_PM_USE_GUI_1 COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_X11 COND_TOOLKIT_X11_USE_GUI_1 COND_UNICODE_1 COND_USE_EXCEPTIONS_0 COND_USE_EXCEPTIONS_1 COND_USE_GUI_0 COND_USE_GUI_1 COND_USE_GUI_1_WXUNIV_0 COND_USE_GUI_1_WXUNIV_1 COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN COND_USE_ODBC_1 COND_USE_SOSYMLINKS_1 COND_USE_SOVERLINUX_1 COND_USE_SOVERSION_0 COND_USE_SOVERSOLARIS_1 COND_WXUNIV_1 COND_WXUSE_EXPAT_BUILTIN COND_WXUSE_LIBJPEG_BUILTIN COND_WXUSE_LIBPNG_BUILTIN COND_WXUSE_LIBTIFF_BUILTIN COND_WXUSE_ODBC_BUILTIN COND_WXUSE_REGEX_BUILTIN COND_WXUSE_ZLIB_BUILTIN PATH_IFS WX_MAJOR_VERSION_NUMBER WX_MINOR_VERSION_NUMBER WX_RELEASE_NUMBER WX_LIBRARY_NAME_STATIC WX_LIBRARY_NAME_SHARED WX_LIBRARY_BASENAME_NOGUI WX_LIBRARY_BASENAME_GUI WX_LIBRARY_IMPORTLIB WX_TARGET_LIBRARY WX_LIBRARY_LINK1 WX_LIBRARY_LINK2 PROGRAM_EXT WX_LIBRARY_NAME_STATIC_GL WX_LIBRARY_NAME_SHARED_GL WX_TARGET_LIBRARY_GL WX_LIBRARY_LINK1_GL WX_LIBRARY_LINK2_GL WX_ALL WX_ALL_INSTALLED SHARED_LD WX_TARGET_LIBRARY_TYPE STATIC_FLAG WXDEBUG_DEFINE USE_GUI AFMINSTALL WIN32INSTALL TOOLKIT TOOLKIT_DIR TOOLKIT_VPATH TOOLCHAIN_NAME TOOLCHAIN_DEFS TOOLCHAIN_DLL_DEFS top_builddir_wxconfig cross_compiling WXCONFIG_EXTRALIBS WXCONFIG_LIBS WXCONFIG_LIBS_GL WXCONFIG_LIBS_STATIC WXCONFIG_LIBS_STATIC_GL WXCONFIG_INCLUDE WXCONFIG_RPATH WXCONFIG_LDFLAGS_GUI WX_LARGEFILE_FLAGS CODE_GEN_FLAGS CODE_GEN_FLAGS_CXX ALL_OBJECTS ALL_HEADERS ALL_SOURCES GUIDIST PORT_FILES DISTDIR SAMPLES_SUBDIRS LDFLAGS_GL LDFLAGS_VERSIONING LDFLAGS_EXE OPENGL_LIBS DMALLOC_LIBS WX_VERSION_TAG RESFLAGS RESPROGRAMOBJ WX_RESOURCES_MACOSX_ASCII WX_RESOURCES_MACOSX_DATA MACOSX_BUNDLE LIBWXMACRES MACRESCOMP MACSETFILE MACRESWXCONFIG GCC DLLTOOL AS LD MAKEINFO INSTALL_LIBRARY LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP CXX CXXFLAGS ac_ct_CXX RANLIB ac_ct_RANLIB AR INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA STRIP IF_GNU_MAKE LN_S CXXCPP subdirs PKG_CONFIG GTK_CFLAGS GTK_LIBS GTK_CONFIG PANGOFT2_CFLAGS PANGOFT2_LIBS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS PANGOX_CFLAGS PANGOX_LIBS PANGOXFT_CFLAGS PANGOXFT_LIBS RESCOMP DEREZ SETFILE LIBICONV EXTRALIBS_ESD CORE_BASE_LIBS CORE_GUI_LIBS wxUSE_ZLIB wxUSE_REGEX wxUSE_EXPAT wxUSE_ODBC wxUSE_LIBJPEG wxUSE_LIBPNG wxUSE_LIBTIFF VENDOR OFFICIAL_BUILD WXUNIV MONOLITHIC EXTRALIBS EXTRALIBS_XML EXTRALIBS_HTML EXTRALIBS_ODBC EXTRALIBS_GUI EXTRALIBS_OPENGL UNICODE BUILD DEBUG_INFO DEBUG_FLAG SHARED TOOLKIT_LOWERCASE TOOLKIT_VERSION SAMPLES_RPATH_FLAG SAMPLES_RPATH_POSTLINK HOST_SUFFIX SET_MAKE MAKE_SET ac_ct_AR ac_ct_STRIP NM ac_ct_NM INSTALL_DIR LDFLAGS_GUI PLATFORM_UNIX PLATFORM_WIN32 PLATFORM_MSDOS PLATFORM_MAC PLATFORM_MACOSX PLATFORM_OS2 SO_SUFFIX SO_SUFFIX_MODULE LIBPREFIX DLLPREFIX DLLPREFIX_MODULE AIX_CXX_LD SHARED_LD_CC SHARED_LD_CXX SHARED_LD_MODULE_CC SHARED_LD_MODULE_CXX PIC_FLAG USE_SOVERSION USE_SOVERLINUX USE_SOVERSOLARIS USE_MACVERSION USE_SOSYMLINKS SONAME_FLAG DEPS_TRACKING GCC_PCH COND_BUILD_DEBUG COND_BUILD_DEBUG_DEBUG_FLAG_DEFAULT COND_BUILD_DEBUG_DEBUG_INFO_DEFAULT COND_BUILD_RELEASE COND_BUILD_RELEASE_DEBUG_INFO_DEFAULT COND_DEBUG_FLAG_1 COND_DEBUG_INFO_0 COND_DEBUG_INFO_1 COND_DEPS_TRACKING_0 COND_DEPS_TRACKING_1 COND_GCC_PCH_1 COND_MONOLITHIC_0 COND_MONOLITHIC_0_SHARED_0 COND_MONOLITHIC_0_SHARED_0_USE_GUI_1 COND_MONOLITHIC_0_SHARED_0_USE_GUI_1_USE_ODBC_1 COND_MONOLITHIC_0_SHARED_0_USE_HTML_1 COND_MONOLITHIC_0_SHARED_0_USE_ODBC_1 COND_MONOLITHIC_0_SHARED_1 COND_MONOLITHIC_0_SHARED_1_USE_GUI_1 COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_ODBC_1 COND_MONOLITHIC_0_SHARED_1_USE_HTML_1 COND_MONOLITHIC_0_SHARED_1_USE_ODBC_1 COND_MONOLITHIC_1 COND_MONOLITHIC_1_SHARED_0 COND_MONOLITHIC_1_SHARED_1 COND_OFFICIAL_BUILD_0_PLATFORM_WIN32_1 COND_OFFICIAL_BUILD_1_PLATFORM_WIN32_1 COND_PLATFORM_MACOSX_0_USE_SOVERSION_1 COND_PLATFORM_MACOSX_1 COND_PLATFORM_MACOSX_1_TOOLKIT_COCOA COND_PLATFORM_MACOSX_1_TOOLKIT_GTK COND_PLATFORM_MACOSX_1_TOOLKIT_MAC COND_PLATFORM_MACOSX_1_USE_GUI_1 COND_PLATFORM_MACOSX_1_USE_SOVERSION_1 COND_PLATFORM_MAC_1 COND_PLATFORM_OS2_1 COND_PLATFORM_UNIX_0 COND_PLATFORM_UNIX_1 COND_PLATFORM_UNIX_1_USE_GUI_1 COND_PLATFORM_WIN32_0 COND_PLATFORM_WIN32_1 COND_SHARED_0 COND_SHARED_0_USE_GUI_1_USE_OPENGL_1 COND_SHARED_0_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN COND_SHARED_0_USE_GUI_1_WXUSE_LIBPNG_BUILTIN COND_SHARED_0_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN COND_SHARED_0_WXUSE_EXPAT_BUILTIN COND_SHARED_0_WXUSE_ODBC_BUILTIN COND_SHARED_0_WXUSE_REGEX_BUILTIN COND_SHARED_0_WXUSE_ZLIB_BUILTIN COND_SHARED_1 COND_SHARED_1_USE_GUI_1_USE_OPENGL_1 COND_TOOLKIT_COCOA COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_GTK COND_TOOLKIT_GTK_USE_GUI_1 COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_MAC COND_TOOLKIT_MAC_USE_GUI_1 COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_MGL COND_TOOLKIT_MGL_USE_GUI_1 COND_TOOLKIT_MOTIF COND_TOOLKIT_MOTIF_USE_GUI_1 COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_MSW COND_TOOLKIT_MSW_USE_GUI_1 COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_PM COND_TOOLKIT_PM_USE_GUI_1 COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0 COND_TOOLKIT_X11 COND_TOOLKIT_X11_USE_GUI_1 COND_UNICODE_1 COND_USE_EXCEPTIONS_0 COND_USE_EXCEPTIONS_1 COND_USE_GUI_0 COND_USE_GUI_1 COND_USE_GUI_1_WXUNIV_0 COND_USE_GUI_1_WXUNIV_1 COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN COND_USE_ODBC_1 COND_USE_SOSYMLINKS_1 COND_USE_SOVERLINUX_1 COND_USE_SOVERSION_0 COND_USE_SOVERSOLARIS_1 COND_WXUNIV_1 COND_WXUSE_EXPAT_BUILTIN COND_WXUSE_LIBJPEG_BUILTIN COND_WXUSE_LIBPNG_BUILTIN COND_WXUSE_LIBTIFF_BUILTIN COND_WXUSE_ODBC_BUILTIN COND_WXUSE_REGEX_BUILTIN COND_WXUSE_ZLIB_BUILTIN PATH_IFS WX_MAJOR_VERSION_NUMBER WX_MINOR_VERSION_NUMBER WX_RELEASE_NUMBER WX_LIBRARY_NAME_STATIC WX_LIBRARY_NAME_SHARED WX_LIBRARY_BASENAME_NOGUI WX_LIBRARY_BASENAME_GUI WX_LIBRARY_IMPORTLIB WX_TARGET_LIBRARY WX_LIBRARY_LINK1 WX_LIBRARY_LINK2 PROGRAM_EXT WX_LIBRARY_NAME_STATIC_GL WX_LIBRARY_NAME_SHARED_GL WX_TARGET_LIBRARY_GL WX_LIBRARY_LINK1_GL WX_LIBRARY_LINK2_GL WX_ALL WX_ALL_INSTALLED SHARED_LD WX_TARGET_LIBRARY_TYPE STATIC_FLAG WXDEBUG_DEFINE USE_GUI AFMINSTALL WIN32INSTALL TOOLKIT TOOLKIT_DIR TOOLKIT_VPATH TOOLCHAIN_NAME TOOLCHAIN_DEFS TOOLCHAIN_DLL_DEFS top_builddir_wxconfig cross_compiling WXCONFIG_EXTRALIBS WXCONFIG_LIBS WXCONFIG_LIBS_GL WXCONFIG_LIBS_STATIC WXCONFIG_LIBS_STATIC_GL WXCONFIG_INCLUDE WXCONFIG_RPATH WXCONFIG_LDFLAGS_GUI WX_LARGEFILE_FLAGS CODE_GEN_FLAGS CODE_GEN_FLAGS_CXX ALL_OBJECTS ALL_HEADERS ALL_SOURCES GUIDIST PORT_FILES DISTDIR SAMPLES_SUBDIRS LDFLAGS_GL LDFLAGS_VERSIONING LDFLAGS_EXE OPENGL_LIBS DMALLOC_LIBS WX_VERSION_TAG RESFLAGS RESPROGRAMOBJ WX_RESOURCES_MACOSX_ASCII WX_RESOURCES_MACOSX_DATA MACOSX_BUNDLE LIBWXMACRES MACRESCOMP MACSETFILE MACRESWXCONFIG GCC DLLTOOL AS LD MAKEINFO INSTALL_LIBRARY LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
--with-libpng use libpng (PNG image format)
--with-libjpeg use libjpeg (JPEG file format)
--with-libtiff use libtiff (TIFF file format)
+ --with-libmspack use libmspack (CHM help files loading)
--with-opengl use OpenGL (or Mesa)
--with-dmalloc use dmalloc library (http://dmalloc.com/)
--with-regex enable support for wxRegEx class
DEFAULT_wxUSE_LIBPNG=yes
DEFAULT_wxUSE_LIBJPEG=yes
DEFAULT_wxUSE_LIBTIFF=yes
+ DEFAULT_wxUSE_LIBMSPACK=yes
DEFAULT_wxUSE_ODBC=no
DEFAULT_wxUSE_OPENGL=no
fi
+ echo "$as_me:$LINENO: checking for --with-libmspack" >&5
+echo $ECHO_N "checking for --with-libmspack... $ECHO_C" >&6
+ no_cache=0
+
+# Check whether --with-libmspack or --without-libmspack was given.
+if test "${with_libmspack+set}" = set; then
+ withval="$with_libmspack"
+
+ if test "$withval" = yes; then
+ ac_cv_use_libmspack='wxUSE_LIBMSPACK=yes'
+ else
+ ac_cv_use_libmspack='wxUSE_LIBMSPACK=no'
+ fi
+
+else
+
+ LINE=`grep "wxUSE_LIBMSPACK" ${wx_arg_cache_file}`
+ if test "x$LINE" != x ; then
+ eval "DEFAULT_$LINE"
+ else
+ no_cache=1
+ fi
+
+ ac_cv_use_libmspack='wxUSE_LIBMSPACK='$DEFAULT_wxUSE_LIBMSPACK
+
+fi;
+
+ eval "$ac_cv_use_libmspack"
+ if test "$no_cache" != 1; then
+ echo $ac_cv_use_libmspack >> ${wx_arg_cache_file}.tmp
+ fi
+
+ if test "$wxUSE_LIBMSPACK" = yes; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ fi
+
+
echo "$as_me:$LINENO: checking for --with-opengl" >&5
echo $ECHO_N "checking for --with-opengl... $ECHO_C" >&6
no_cache=0
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <features.h>
+
int
main ()
{
+if test "$wxUSE_LIBMSPACK" != "no"; then
+
+ if test "${ac_cv_header_mspack_h+set}" = set; then
+ echo "$as_me:$LINENO: checking for mspack.h" >&5
+echo $ECHO_N "checking for mspack.h... $ECHO_C" >&6
+if test "${ac_cv_header_mspack_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_mspack_h" >&5
+echo "${ECHO_T}$ac_cv_header_mspack_h" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking mspack.h usability" >&5
+echo $ECHO_N "checking mspack.h usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <mspack.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking mspack.h presence" >&5
+echo $ECHO_N "checking mspack.h presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <mspack.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+ yes:no )
+ { echo "$as_me:$LINENO: WARNING: mspack.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: mspack.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: mspack.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: mspack.h: proceeding with the preprocessor's result" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+ no:yes )
+ { echo "$as_me:$LINENO: WARNING: mspack.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: mspack.h: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: mspack.h: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: mspack.h: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: mspack.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: mspack.h: proceeding with the preprocessor's result" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for mspack.h" >&5
+echo $ECHO_N "checking for mspack.h... $ECHO_C" >&6
+if test "${ac_cv_header_mspack_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_header_mspack_h=$ac_header_preproc
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_mspack_h" >&5
+echo "${ECHO_T}$ac_cv_header_mspack_h" >&6
+
+fi
+if test $ac_cv_header_mspack_h = yes; then
+ found_mspack_h=1
+fi
+
+
+ if test "x$found_mspack_h" = "x1"; then
+ echo "$as_me:$LINENO: checking for mspack_create_chm_decompressor in -lmspack" >&5
+echo $ECHO_N "checking for mspack_create_chm_decompressor in -lmspack... $ECHO_C" >&6
+if test "${ac_cv_lib_mspack_mspack_create_chm_decompressor+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmspack $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char mspack_create_chm_decompressor ();
+int
+main ()
+{
+mspack_create_chm_decompressor ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_mspack_mspack_create_chm_decompressor=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_mspack_mspack_create_chm_decompressor=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_mspack_mspack_create_chm_decompressor" >&5
+echo "${ECHO_T}$ac_cv_lib_mspack_mspack_create_chm_decompressor" >&6
+if test $ac_cv_lib_mspack_mspack_create_chm_decompressor = yes; then
+ MSPACK_LINK=" -lmspack"
+fi
+
+ fi
+ if test "x$MSPACK_LINK" = "x" ; then
+ wxUSE_LIBMSPACK=no
+ else
+ cat >>confdefs.h <<\_ACEOF
+#define wxUSE_LIBMSPACK 1
+_ACEOF
+
+ fi
+fi
+
+
+
AFMINSTALL=
WIN32INSTALL=
LIBS=`echo $LIBS | sed 's/ \+/ /g'`
EXTRALIBS="$LDFLAGS $LDFLAGS_VERSIONING $LIBS $DMALLOC_LIBS"
EXTRALIBS_XML="$EXPAT_LINK"
+EXTRALIBS_HTML="$MSPACK_LINK"
EXTRALIBS_ODBC="$ODBC_LINK"
if test "$wxUSE_GUI" = "yes"; then
EXTRALIBS_GUI=`echo $GUI_TK_LIBRARY $PNG_LINK $JPEG_LINK $TIFF_LINK | sed 's/ \+/ /g'`
+
TOOLKIT_LOWERCASE=`echo $TOOLKIT | tr [A-Z] [a-z]`
COND_PLATFORM_MACOSX_1_TOOLKIT_MAC=""
fi
+ COND_PLATFORM_MACOSX_1_USE_GUI_1="#"
+ if test "x$PLATFORM_MACOSX" = "x1" -a "x$USE_GUI" = "x1" ; then
+ COND_PLATFORM_MACOSX_1_USE_GUI_1=""
+ fi
+
COND_PLATFORM_MACOSX_1_USE_SOVERSION_1="#"
if test "x$PLATFORM_MACOSX" = "x1" -a "x$USE_SOVERSION" = "x1" ; then
COND_PLATFORM_MACOSX_1_USE_SOVERSION_1=""
COND_PLATFORM_UNIX_1=""
fi
+ COND_PLATFORM_UNIX_1_USE_GUI_1="#"
+ if test "x$PLATFORM_UNIX" = "x1" -a "x$USE_GUI" = "x1" ; then
+ COND_PLATFORM_UNIX_1_USE_GUI_1=""
+ fi
+
COND_PLATFORM_WIN32_0="#"
if test "x$PLATFORM_WIN32" = "x0" ; then
COND_PLATFORM_WIN32_0=""
s,@MONOLITHIC@,$MONOLITHIC,;t t
s,@EXTRALIBS@,$EXTRALIBS,;t t
s,@EXTRALIBS_XML@,$EXTRALIBS_XML,;t t
+s,@EXTRALIBS_HTML@,$EXTRALIBS_HTML,;t t
s,@EXTRALIBS_ODBC@,$EXTRALIBS_ODBC,;t t
s,@EXTRALIBS_GUI@,$EXTRALIBS_GUI,;t t
s,@EXTRALIBS_OPENGL@,$EXTRALIBS_OPENGL,;t t
s,@COND_PLATFORM_MACOSX_1_TOOLKIT_COCOA@,$COND_PLATFORM_MACOSX_1_TOOLKIT_COCOA,;t t
s,@COND_PLATFORM_MACOSX_1_TOOLKIT_GTK@,$COND_PLATFORM_MACOSX_1_TOOLKIT_GTK,;t t
s,@COND_PLATFORM_MACOSX_1_TOOLKIT_MAC@,$COND_PLATFORM_MACOSX_1_TOOLKIT_MAC,;t t
+s,@COND_PLATFORM_MACOSX_1_USE_GUI_1@,$COND_PLATFORM_MACOSX_1_USE_GUI_1,;t t
s,@COND_PLATFORM_MACOSX_1_USE_SOVERSION_1@,$COND_PLATFORM_MACOSX_1_USE_SOVERSION_1,;t t
s,@COND_PLATFORM_MAC_1@,$COND_PLATFORM_MAC_1,;t t
s,@COND_PLATFORM_OS2_1@,$COND_PLATFORM_OS2_1,;t t
s,@COND_PLATFORM_UNIX_0@,$COND_PLATFORM_UNIX_0,;t t
s,@COND_PLATFORM_UNIX_1@,$COND_PLATFORM_UNIX_1,;t t
+s,@COND_PLATFORM_UNIX_1_USE_GUI_1@,$COND_PLATFORM_UNIX_1_USE_GUI_1,;t t
s,@COND_PLATFORM_WIN32_0@,$COND_PLATFORM_WIN32_0,;t t
s,@COND_PLATFORM_WIN32_1@,$COND_PLATFORM_WIN32_1,;t t
s,@COND_SHARED_0@,$COND_SHARED_0,;t t
echo " zlib ${wxUSE_ZLIB}"
echo " odbc ${wxUSE_ODBC}"
echo " expat ${wxUSE_EXPAT}"
+echo " libmspack ${wxUSE_LIBMSPACK}"
echo ""
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: chm.cpp
+// Purpose: CHM (Help) support for wxHTML
+// Author: Markus Sinner
+// Copyright: (c) 2003 Herd Software Development
+// CVS-ID: $Id$
+// Licence: wxWindows Licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#if wxUSE_LIBMSPACK
+
+#include <mspack.h>
+
+#ifndef WXPRECOMP
+#include "wx/intl.h"
+#include "wx/log.h"
+#endif
+
+#include "wx/module.h"
+#include "wx/filesys.h"
+#include "wx/mstream.h"
+#include "wx/wfstream.h"
+
+#include "wx/html/forcelnk.h"
+FORCE_LINK_ME(wxhtml_chm_support)
+
+// ----------------------------------------------------------------------------
+/// wxChmTools
+/// <p>
+/// this class is used to abstract access to CHM-Archives
+/// with library mspack written by Stuart Caie
+/// http://www.kyz.uklinux.net/libmspack/
+// ----------------------------------------------------------------------------
+class wxChmTools
+{
+public:
+ /// constructor
+ wxChmTools(const wxFileName &archive);
+ /// destructor
+ ~wxChmTools();
+
+ /// Generate error-string for error-code
+ static const wxString ChmErrorMsg(int error);
+
+ /// get an array of archive-member-filenames
+ const wxArrayString *GetFileNames()
+ {
+ return m_fileNames;
+ };
+
+ /// get the name of the archive representated by this class
+ const wxString GetArchiveName()
+ {
+ return m_chmFileName;
+ };
+
+ /// Find a file in the archive
+ const wxString Find(const wxString& pattern,
+ const wxString& startfrom = wxEmptyString);
+
+ /// Extract a file in the archive into a file
+ size_t Extract(const wxString& pattern, const wxString& filename);
+
+ /// check archive for a file
+ bool Contains(const wxString& pattern);
+
+ /// get a string for the last error occured
+ const wxString GetLastErrorMessage();
+
+ /// Last Error
+ int m_lasterror;
+
+private:
+ // these vars are used by FindFirst/Next:
+ wxString m_chmFileName;
+ char *m_chmFileNameANSI;
+
+ /// mspack-pointer to mschmd_header
+ struct mschmd_header *m_archive;
+ /// mspack-pointer to mschm_decompressor
+ struct mschm_decompressor *m_decompressor;
+
+ /// Array of filenames in archive
+ wxArrayString * m_fileNames;
+
+ /// Internal function to get filepointer
+ struct mschmd_file *GetMschmdFile(const wxString& pattern);
+};
+
+
+/***
+ * constructor
+ *
+ * @param archive The filename of the archive to open
+ */
+wxChmTools::wxChmTools(const wxFileName &archive)
+{
+ m_chmFileName = archive.GetFullPath();
+
+ wxASSERT_MSG( !m_chmFileName.empty(), _T("empty archive name") );
+
+ m_archive = NULL;
+ m_decompressor = NULL;
+ m_fileNames = NULL;
+ m_lasterror = 0;
+
+ struct mschmd_header *chmh;
+ struct mschm_decompressor *chmd;
+ struct mschmd_file *file;
+
+ // Create decompressor
+ chmd = mspack_create_chm_decompressor(NULL);
+ m_decompressor = (struct mschm_decompressor *) chmd;
+
+ // NB: we must make a copy of the string because chmd->open won't call
+ // strdup() [libmspack-20030726], which would cause crashes in
+ // Unicode build when mb_str() returns temporary buffer
+ m_chmFileNameANSI = strdup((const char*)m_chmFileName.mb_str(wxConvFile));
+
+ // Open the archive and store it in class:
+ if ( (chmh = chmd->open(chmd, (char*)m_chmFileNameANSI)) )
+ {
+ m_archive = chmh;
+
+ // Create Filenamearray
+ m_fileNames = new wxArrayString;
+
+ // Store Filenames in array
+ for (file = chmh->files; file; file = file->next)
+ {
+ m_fileNames->Add(wxString::FromAscii(file->filename));
+ }
+ }
+ else
+ {
+ wxLogError(_("Failed to open CHM archive '%s'."),
+ archive.GetFullPath().c_str());
+ m_lasterror = (chmd->last_error(chmd));
+ return;
+ }
+}
+
+
+/***
+ * Destructor
+ */
+wxChmTools::~wxChmTools()
+{
+ struct mschm_decompressor *chmd = m_decompressor;
+ struct mschmd_header *chmh = m_archive;
+
+ delete m_fileNames;
+
+ // Close Archive
+ if (chmh && chmd)
+ chmd->close(chmd, chmh);
+
+ free(m_chmFileNameANSI);
+
+ // Destroy Decompressor
+ if (chmd)
+ mspack_destroy_chm_decompressor(chmd);
+}
+
+
+
+/**
+ * Checks if the given pattern matches to any
+ * filename stored in archive
+ *
+ * @param pattern The filename pattern, may include '*' and/or '?'
+ * @return true, if any file matching pattern has been found,
+ * false if not
+ */
+bool wxChmTools::Contains(const wxString& pattern)
+{
+ int count;
+ wxString pattern_tmp = wxString(pattern).MakeLower();
+
+ // loop through filearay
+ if ( m_fileNames && (count = m_fileNames->GetCount()) > 0 )
+ {
+ for (int i = 0; i < count; i++)
+ {
+ wxString tmp = m_fileNames->Item(i).MakeLower();
+ if ( tmp.Matches(pattern_tmp) || tmp.Mid(1).Matches(pattern_tmp))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+/**
+ * Find()
+ *
+ * Finds the next file descibed by a pattern in the archive, starting
+ * the file given by second parameter
+ *
+ * @param pattern The file-pattern to search for. May contain '*' and/or '?'
+ * @param startfrom The filename which the search should start after
+ * @returns The full pathname of the found file
+ */
+const wxString wxChmTools::Find(const wxString& pattern,
+ const wxString& startfrom)
+{
+ int count;
+ wxString tmp;
+ wxString pattern_tmp(pattern);
+ wxString startfrom_tmp(startfrom);
+ pattern_tmp.MakeLower();
+ startfrom_tmp.MakeLower();
+
+ if ( m_fileNames && (count = m_fileNames->GetCount()) > 0 )
+ {
+ for (int i = 0; i < count; i++)
+ {
+ tmp = m_fileNames->Item(i).MakeLower();
+ // if we find the string where the search should began
+ if ( tmp.Matches(startfrom_tmp) ||
+ tmp.Mid(1).Matches(startfrom_tmp) )
+ continue;
+ if ( tmp.Matches(pattern_tmp) ||
+ tmp.Mid(1).Matches(pattern_tmp) )
+ {
+ return tmp;
+ }
+ }
+ }
+
+ return wxEmptyString;
+}
+
+
+/**
+ * Extract ()
+ *
+ * extracts the first hit of pattern to the given position
+ *
+ * @param pattern A filename pattern (may contain * and ? chars)
+ * @param filename The FileName where to temporary extract the file to
+ * @return 0 at no file extracted<br>
+ * number of bytes extracted else
+ */
+size_t wxChmTools::Extract(const wxString& pattern, const wxString& filename)
+{
+ struct mschm_decompressor *d = m_decompressor;
+ struct mschmd_header *h = m_archive;
+ struct mschmd_file *f;
+
+ wxString tmp;
+ wxString pattern_tmp = (wxString(pattern)).MakeLower();
+
+ for (f = h->files; f; f = f->next)
+ {
+ tmp = wxString::FromAscii(f->filename).MakeLower();
+ if ( tmp.Matches(pattern_tmp) ||
+ tmp.Mid(1).Matches(pattern_tmp) )
+ {
+ // ignore leading '/'
+ if (d->extract(d, f,
+ (char*)(const char*)filename.mb_str(wxConvFile)))
+ {
+ // Error
+ m_lasterror = d->last_error(d);
+ wxLogError(_("Could not extract %s into %s: %s"),
+ wxString::FromAscii(f->filename).c_str(),
+ filename.c_str(),
+ ChmErrorMsg(m_lasterror).c_str());
+ return 0;
+ }
+ else
+ {
+ return (size_t) f->length;
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+
+/**
+ * Find a file by pattern
+ *
+ * @param pattern A filename pattern (may contain * and ? chars)
+ * @return A pointer to the file (mschmd_file*)
+ */
+struct mschmd_file *wxChmTools::GetMschmdFile(const wxString& pattern_orig)
+{
+ struct mschmd_file *f;
+ struct mschmd_header *h = (struct mschmd_header *) m_archive;
+ wxString tmp;
+ wxString pattern = wxString(pattern_orig).MakeLower();
+
+ for (f = h->files; f; f = f->next)
+ {
+ tmp = wxString::FromAscii(f->filename).MakeLower();
+ if ( tmp.Matches(pattern) || tmp.Mid(1).Matches(pattern) )
+ {
+ // ignore leading '/'
+ return f;
+ }
+ }
+
+ return NULL;
+}
+
+const wxString wxChmTools::GetLastErrorMessage()
+{
+ return ChmErrorMsg(m_lasterror);
+}
+
+const wxString wxChmTools::ChmErrorMsg(int error)
+{
+ switch (error)
+ {
+ case MSPACK_ERR_OK:
+ return _("no error");
+ case MSPACK_ERR_ARGS:
+ return _("bad arguments to library function");
+ case MSPACK_ERR_OPEN:
+ return _("error opening file");
+ case MSPACK_ERR_READ:
+ return _("read error");
+ case MSPACK_ERR_WRITE:
+ return _("write error");
+ case MSPACK_ERR_SEEK:
+ return _("seek error");
+ case MSPACK_ERR_NOMEMORY:
+ return _("out of memory");
+ case MSPACK_ERR_SIGNATURE:
+ return _("bad signature");
+ case MSPACK_ERR_DATAFORMAT:
+ return _("error in data format");
+ case MSPACK_ERR_CHECKSUM:
+ return _("checksum error");
+ case MSPACK_ERR_CRUNCH:
+ return _("compression error");
+ case MSPACK_ERR_DECRUNCH:
+ return _("decompression error");
+ }
+ return _("unknown error");
+}
+
+
+// ---------------------------------------------------------------------------
+/// wxChmInputStream
+// ---------------------------------------------------------------------------
+
+class wxChmInputStream : public wxInputStream
+{
+public:
+ /// Constructor
+ wxChmInputStream(const wxString& archive,
+ const wxString& file, bool simulate = false);
+ /// Destructor
+ ~wxChmInputStream();
+
+ /// Return the size of the accessed file in archive
+ virtual size_t GetSize() const { return m_size; }
+ /// End of Stream?
+ virtual bool Eof() const;
+ /// Set simulation-mode of HHP-File (if non is found)
+ void SimulateHHP(bool sim) { m_simulateHHP = sim; }
+
+protected:
+ /// See wxInputStream
+ virtual size_t OnSysRead(void *buffer, size_t bufsize);
+ /// See wxInputStream
+ virtual off_t OnSysSeek(off_t seek, wxSeekMode mode);
+ /// See wxInputStream
+ virtual off_t OnSysTell() const { return m_pos; }
+
+private:
+ size_t m_size;
+ off_t m_pos;
+ bool m_simulateHHP;
+
+ char * m_content;
+ wxInputStream * m_contentStream;
+
+ void CreateHHPStream();
+ bool CreateFileStream(const wxString& pattern);
+ // this void* is handle of archive . I'm sorry it is void and not proper
+ // type but I don't want to make unzip.h header public.
+
+
+ // locates the file and returns a mspack_file *
+ mspack_file *LocateFile(wxString filename);
+
+ // should store pointer to current file
+ mspack_file *m_file;
+
+ // The Chm-Class for extracting the data
+ wxChmTools *m_chm;
+
+ wxString m_fileName;
+};
+
+
+/**
+ * Constructor
+ * @param archive The name of the .chm archive. Remember that archive must
+ * be local file accesible via fopen, fread functions!
+ * @param filename The Name of the file to be extracted from archive
+ * @param simulate if true than class should simulate .HHP-File based on #SYSTEM
+ * if false than class does nothing if it doesnt find .hhp
+ */
+wxChmInputStream::wxChmInputStream(const wxString& archive,
+ const wxString& filename, bool simulate)
+ : wxInputStream()
+{
+ m_pos = 0;
+ m_size = 0;
+ m_content = NULL;
+ m_contentStream = NULL;
+ m_lasterror = wxSTREAM_NO_ERROR;
+ m_chm = new wxChmTools (wxFileName(archive));
+ m_file = NULL;
+ m_fileName = wxString(filename).MakeLower();
+ m_simulateHHP = simulate;
+
+ if ( !m_chm->Contains(m_fileName) )
+ {
+ // if the file could not be located, but was *.hhp, than we create
+ // the content of the hhp-file on the fly and store it for reading
+ // by the application
+ if ( m_fileName.Find(_T(".hhp")) != wxNOT_FOUND && m_simulateHHP )
+ {
+ // now we open an hhp-file
+ CreateHHPStream();
+ }
+ else
+ {
+ wxLogError(_("Could not locate file '%s'."), filename.c_str());
+ m_lasterror = wxSTREAM_READ_ERROR;
+ return;
+ }
+ }
+ else
+ { // file found
+ CreateFileStream(m_fileName);
+ }
+}
+
+
+wxChmInputStream::~wxChmInputStream()
+{
+ delete m_chm;
+
+ delete m_contentStream;
+
+ if (m_content)
+ {
+ free (m_content);
+ m_content=NULL;
+ }
+}
+
+bool wxChmInputStream::Eof() const
+{
+ return (m_content==NULL ||
+ m_contentStream==NULL ||
+ m_contentStream->Eof() ||
+ m_pos>m_size);
+}
+
+
+
+size_t wxChmInputStream::OnSysRead(void *buffer, size_t bufsize)
+{
+ if ( m_pos >= m_size )
+ {
+ m_lasterror = wxSTREAM_EOF;
+ return 0;
+ }
+ m_lasterror = wxSTREAM_NO_ERROR;
+
+ // If the rest to read from the stream is less
+ // than the buffer size, than only read the rest
+ if ( m_pos + bufsize > m_size )
+ bufsize = m_size - m_pos;
+
+ m_contentStream->SeekI(m_pos);
+ m_contentStream->Read(buffer, bufsize);
+ m_pos +=bufsize;
+ m_contentStream->SeekI(m_pos);
+ return bufsize;
+}
+
+
+
+
+off_t wxChmInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
+{
+ wxString mode_str = wxEmptyString;
+
+ if ( !m_contentStream || m_contentStream->Eof() )
+ {
+ m_lasterror = wxSTREAM_EOF;
+ return 0;
+ }
+ m_lasterror = wxSTREAM_NO_ERROR;
+
+ off_t nextpos;
+
+ switch ( mode )
+ {
+ case wxFromCurrent:
+ nextpos = seek + m_pos;
+ break;
+ case wxFromStart:
+ nextpos = seek;
+ break;
+ case wxFromEnd:
+ nextpos = m_size - 1 + seek;
+ break;
+ default:
+ nextpos = m_pos;
+ break; /* just to fool compiler, never happens */
+ }
+ m_pos=nextpos;
+
+ // Set current position on stream
+ m_contentStream->SeekI(m_pos);
+ return m_pos;
+}
+
+
+
+/**
+ * Help Browser tries to read the contents of the
+ * file by interpreting a .hhp file in the Archiv.
+ * For .chm doesnt include such a file, we need
+ * to rebuild the information based on stored
+ * system-files.
+ */
+void
+wxChmInputStream::CreateHHPStream()
+{
+ wxFileName file;
+ bool topic = false;
+ bool hhc = false;
+ bool hhk = false;
+ wxInputStream *i;
+ wxMemoryOutputStream *out;
+ const char *tmp;
+
+ // Try to open the #SYSTEM-File and create the HHP File out of it
+ // see http://bonedaddy.net/pabs3/chmspec/0.1/ch05s03.html#SYSTEM
+ if ( ! m_chm->Contains(_("/#SYSTEM")) )
+ {
+#ifdef DEBUG
+ wxLogDebug("Archive doesnt contain #SYSTEM file");
+#endif
+ return;
+ }
+ else
+ {
+ file = wxFileName(_T("/#SYSTEM"));
+ }
+
+ if ( CreateFileStream(_T("/#SYSTEM")) )
+ {
+ // New stream for writing a memory area to simulate the
+ // .hhp-file
+ out = new wxMemoryOutputStream();
+
+ tmp = "[OPTIONS]\r\n";
+ out->Write((const void *) tmp, strlen(tmp));
+
+ wxUint16 code;
+ wxUint16 len;
+ void *buf;
+
+ // use the actual stream for reading
+ i = m_contentStream;
+
+ /* Now read the contents, and try to get the needed information */
+
+ // First 4 Bytes are Version information, skip
+ i->SeekI(4);
+
+ while (!i->Eof())
+ {
+ // Read #SYSTEM-Code and length
+ i->Read(&code, 2);
+ i->Read(&len, 2);
+ // data
+ buf = malloc(len);
+ i->Read(buf, len);
+
+ switch (code)
+ {
+ case 0: // CONTENTS_FILE
+ tmp = "Contents file=";
+ hhc=true;
+ break;
+ case 1: // INDEX_FILE
+ tmp = "Index file=";
+ hhk = true;
+ break;
+ case 2: // DEFAULT_TOPIC
+ tmp = "Default Topic=";
+ topic = true;
+ break;
+ case 3: // TITLE
+ tmp = "Title=";
+ break;
+ // case 6: // COMPILED_FILE
+ // tmp = "Compiled File=";
+ // break;
+ case 7: // COMPILED_FILE
+ tmp = "Binary Index=YES\r\n";
+ out->Write( (const void *) tmp, strlen(tmp));
+ tmp = NULL;
+ break;
+ case 4: // STRUCT
+ default:
+ tmp=NULL;
+ }
+
+ if (tmp)
+ {
+ out->Write((const void *) tmp, strlen(tmp));
+ out->Write(buf, strlen((char*)buf));
+ out->Write("\r\n", 2);
+ }
+
+ free(buf);
+ buf=NULL;
+ }
+
+
+ // Free the old data which wont be used any more
+ delete m_contentStream;
+ if (m_content)
+ free (m_content);
+
+ // Now add entries which are missing
+ if ( !hhc && m_chm->Contains(_T("*.hhc")) )
+ {
+ tmp = "Contents File=*.hhc\r\n";
+ out->Write((const void *) tmp, strlen(tmp));
+ }
+
+ if ( !hhk && m_chm->Contains(_T("*.hhk")) )
+ {
+ tmp = "Index File=*.hhk\r\n";
+ out->Write((const void *) tmp, strlen(tmp));
+ }
+
+ // Now copy the Data from the memory
+ out->SeekO(0, wxFromEnd);
+ m_size = out->TellO();
+ out->SeekO(0, wxFromStart);
+ m_content = (char *) malloc (m_size+1);
+ out->CopyTo(m_content, m_size);
+ m_content[m_size]='\0';
+ m_size++;
+ m_contentStream = new wxMemoryInputStream(m_content, m_size);
+
+ delete out;
+ }
+}
+
+
+/**
+ * Creates a Stream pointing to a virtual file in
+ * the current archive
+ */
+bool wxChmInputStream::CreateFileStream(const wxString& pattern)
+{
+ wxFileInputStream * fin;
+ wxString tmpfile = wxFileName::CreateTempFileName(_T("chmstrm"), NULL);
+
+ if ( tmpfile.empty() )
+ {
+ wxLogError(_("Could not create temporary file '%s'"), tmpfile.c_str());
+ return false;
+ }
+
+ // try to extract the file
+ if ( m_chm->Extract(pattern, tmpfile) <= 0 )
+ {
+ wxLogError(_("Extraction of '%s' into '%s' failed."),
+ pattern.c_str(), tmpfile.c_str());
+ if ( wxFileExists(tmpfile) )
+ wxRemoveFile(tmpfile);
+ return false;
+ }
+ else
+ {
+ // Open a filestream to extracted file
+ fin = new wxFileInputStream(tmpfile);
+ m_size = fin->GetSize();
+ m_content = (char *) malloc(m_size+1);
+ fin->Read(m_content, m_size);
+ m_content[m_size]='\0';
+
+ wxRemoveFile(tmpfile);
+
+ delete fin;
+
+ m_contentStream = new wxMemoryInputStream (m_content, m_size);
+
+ return m_contentStream->IsOk();
+ }
+}
+
+
+
+// ----------------------------------------------------------------------------
+// wxChmFSHandler
+// ----------------------------------------------------------------------------
+
+class wxChmFSHandler : public wxFileSystemHandler
+{
+public:
+ /// Constructor and Destructor
+ wxChmFSHandler();
+ ~wxChmFSHandler();
+
+ /// Is able to open location?
+ virtual bool CanOpen(const wxString& location);
+ /// Open a file
+ virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
+ /// Find first occurence of spec
+ virtual wxString FindFirst(const wxString& spec, int flags = 0);
+ /// Find next occurence of spec
+ virtual wxString FindNext();
+
+private:
+ int m_lasterror;
+ wxString m_pattern;
+ wxString m_found;
+ wxChmTools * m_chm;
+};
+
+wxChmFSHandler::wxChmFSHandler() : wxFileSystemHandler()
+{
+ m_lasterror=0;
+ m_pattern=wxEmptyString;
+ m_found=wxEmptyString;
+ m_chm=NULL;
+}
+
+wxChmFSHandler::~wxChmFSHandler()
+{
+ if (m_chm)
+ delete m_chm;
+}
+
+bool wxChmFSHandler::CanOpen(const wxString& location)
+{
+ wxString p = GetProtocol(location);
+ return (p == _T("chm")) &&
+ (GetProtocol(GetLeftLocation(location)) == _T("file"));
+}
+
+wxFSFile* wxChmFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
+ const wxString& location)
+{
+ wxString right = GetRightLocation(location);
+ wxString left = GetLeftLocation(location);
+
+ wxInputStream *s;
+
+ int index;
+
+ if ( GetProtocol(left) != _T("file") )
+ {
+ wxLogError(_("CHM handler currently supports only local files!"));
+ return NULL;
+ }
+
+ // Work around javascript
+ wxString tmp = wxString(right);
+ if ( tmp.MakeLower().Contains(_T("javascipt")) && tmp.Contains(_T("\'")) )
+ {
+ right = right.AfterFirst(_T('\'')).BeforeLast(_T('\''));
+ }
+
+ // now work on the right location
+ if (right.Contains(_T("..")))
+ {
+ wxFileName abs(right);
+ abs.MakeAbsolute(_T("/"));
+ right = abs.GetFullPath();
+ }
+
+ // a workaround for absolute links to root
+ if ( (index=right.Index(_T("//"))) != wxNOT_FOUND )
+ {
+ right=wxString(right.Mid(index+1));
+ wxLogWarning(_("Link contained '//', converted to absolute link."));
+ }
+
+ wxFileName leftFilename = wxFileSystem::URLToFileName(left);
+
+ // Open a stream to read the content of the chm-file
+ s = new wxChmInputStream(leftFilename.GetFullPath(), right, true);
+
+ wxString mime = GetMimeTypeFromExt(location);
+
+ if ( s )
+ {
+ return new wxFSFile(s,
+ left + _T("#chm:") + right,
+ mime,
+ GetAnchor(location),
+ wxDateTime(wxFileModificationTime(left)));
+ }
+
+ delete s;
+ return NULL;
+}
+
+
+
+/**
+ * Doku see wxFileSystemHandler
+ */
+wxString wxChmFSHandler::FindFirst(const wxString& spec, int flags)
+{
+ wxString right = GetRightLocation(spec);
+ wxString left = GetLeftLocation(spec);
+ wxString nativename = wxFileSystem::URLToFileName(left).GetFullPath();
+
+ if ( GetProtocol(left) != _T("file") )
+ {
+ wxLogError(_("CHM handler currently supports only local files!"));
+ return wxEmptyString;
+ }
+
+ m_chm = new wxChmTools(wxFileName(nativename));
+ m_pattern = right.AfterLast(_T('/'));
+
+ wxString m_found = m_chm->Find(m_pattern);
+
+ // now fake around hhp-files which are not existing in projects...
+ if (m_found.empty() &&
+ m_pattern.Contains(_T(".hhp")) &&
+ !m_pattern.Contains(_T(".hhp.cached")))
+ {
+ m_found.Printf(_T("%s#chm:%s.hhp"),
+ left.c_str(), m_pattern.BeforeLast(_T('.')).c_str());
+ }
+
+ return m_found;
+
+}
+
+
+
+wxString wxChmFSHandler::FindNext()
+{
+ if (m_pattern.empty())
+ return wxEmptyString;
+ else
+ return m_chm->Find(m_pattern, m_found);
+}
+
+// ---------------------------------------------------------------------------
+// wxModule to register CHM handler
+// ---------------------------------------------------------------------------
+
+class wxChmSupportModule : public wxModule
+{
+ DECLARE_DYNAMIC_CLASS(wxChmSupportModule)
+
+public:
+ virtual bool OnInit()
+ {
+ wxFileSystem::AddHandler(new wxChmFSHandler);
+ return true;
+ }
+ virtual void OnExit() {}
+}
+;
+
+IMPLEMENT_DYNAMIC_CLASS(wxChmSupportModule, wxModule)
+
+#endif // wxUSE_LIBMSPACK