libvmime-0.9.1/0000755000175000017500000000000011607302336013630 5ustar mnordstrmnordstrlibvmime-0.9.1/m4/0000755000175000017500000000000011607302336014150 5ustar mnordstrmnordstrlibvmime-0.9.1/m4/lib-link.m40000644000175000017500000007205511374031010016111 0ustar mnordstrmnordstr# lib-link.m4 serial 13 (gettext-0.17) dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_PREREQ(2.54) dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and dnl augments the CPPFLAGS variable. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" ac_cv_lib[]Name[]_cppflags="$INC[]NAME" ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" ]) LIB[]NAME="$ac_cv_lib[]Name[]_libs" LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" INC[]NAME="$ac_cv_lib[]Name[]_cppflags" LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the dnl results of this search when this library appears as a dependency. HAVE_LIB[]NAME=yes undefine([Name]) undefine([NAME]) ]) dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) dnl searches for libname and the libraries corresponding to explicit and dnl implicit dependencies, together with the specified include files and dnl the ability to compile and link the specified testcode. If found, it dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. AC_LIB_LINKFLAGS_BODY([$1], [$2]) dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, dnl because if the user has installed lib[]Name and not disabled its use dnl via --without-lib[]Name-prefix, he wants to use it. ac_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" LIBS="$LIBS $LIB[]NAME" AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) LIBS="$ac_save_LIBS" ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else HAVE_LIB[]NAME=no dnl If $LIB[]NAME didn't lead to a usable library, we don't need dnl $INC[]NAME either. CPPFLAGS="$ac_save_CPPFLAGS" LIB[]NAME= LTLIB[]NAME= LIB[]NAME[]_PREFIX= fi AC_SUBST([HAVE_LIB]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) undefine([Name]) undefine([NAME]) ]) dnl Determine the platform dependent parameters needed to use rpath: dnl acl_libext, dnl acl_shlibext, dnl acl_hardcode_libdir_flag_spec, dnl acl_hardcode_libdir_separator, dnl acl_hardcode_direct, dnl acl_hardcode_minus_L. AC_DEFUN([AC_LIB_RPATH], [ dnl Tell automake >= 1.10 to complain if config.rpath is missing. m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done ]) wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. AC_ARG_ENABLE(rpath, [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Autoconf >= 2.61 supports dots in --with options. define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix], [ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) dnl Search the library and its dependencies in $additional_libdir and dnl $LDFLAGS. Using breadth-first-seach. LIB[]NAME= LTLIB[]NAME= INC[]NAME= LIB[]NAME[]_PREFIX= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='$1 $2' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" else dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined dnl that this library doesn't exist. So just drop it. : fi else dnl Search the library lib$name in $additional_libdir and $LDFLAGS dnl and the already constructed $LIBNAME/$LTLIBNAME. found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" dnl The same code as in the loop below: dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then dnl Found the library. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl Use an explicit option to hardcode DIR into the resulting dnl binary. dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. if test "$acl_hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else dnl Rely on "-L$found_dir". dnl But don't add it if it's already contained in the LDFLAGS dnl or the already constructed $LIBNAME haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then dnl Linking with a static library. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" else dnl We shouldn't come here, but anyway it's good to have a dnl fallback. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" fi fi dnl Assume the include files are nearby. additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` LIB[]NAME[]_PREFIX="$basedir" additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then dnl Potentially add $additional_includedir to $INCNAME. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's /usr/local/include and we are using GCC on Linux, dnl 3. if it's already present in $CPPFLAGS or the already dnl constructed $INCNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INC[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $INCNAME. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" fi fi fi fi fi dnl Look for dependencies. if test -n "$found_la"; then dnl Read the .la file. It defines the variables dnl dlname, library_names, old_library, dependency_libs, current, dnl age, revision, installed, dlopen, dlpreopen, libdir. save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" dnl We use only dependency_libs. for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's /usr/local/lib and we are using GCC on Linux, dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LIBNAME. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) dnl For those cases where a variable contains several -L and -l options dnl referring to unknown libraries and directories, this macro determines the dnl necessary additional linker options for the runtime path. dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) dnl sets LDADDVAR to linker options needed together with LIBSVALUE. dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, dnl otherwise linking without libtool is assumed. AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], [ AC_REQUIRE([AC_LIB_RPATH]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) $1= if test "$enable_rpath" != no; then if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode directories into the resulting dnl binary. rpathdirs= next= for opt in $2; do if test -n "$next"; then dir="$next" dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= else case $opt in -L) next=yes ;; -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= ;; *) next= ;; esac fi done if test "X$rpathdirs" != "X"; then if test -n ""$3""; then dnl libtool is used for linking. Use -R options. for dir in $rpathdirs; do $1="${$1}${$1:+ }-R$dir" done else dnl The linker is used for linking directly. if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user dnl must pass all path elements in one option. alldirs= for dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="$flag" else dnl The -rpath options are cumulative. for dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="${$1}${$1:+ }$flag" done fi fi fi fi fi AC_SUBST([$1]) ]) libvmime-0.9.1/m4/lib-ld.m40000644000175000017500000000653111250723262015561 0ustar mnordstrmnordstr# lib-ld.m4 serial 3 (gettext-0.13) dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Subroutines of libtool.m4, dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision dnl with libtool.m4. dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]* | [A-Za-z]:[\\/]*)] [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(acl_cv_path_LD, [if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_LIB_PROG_LD_GNU ]) libvmime-0.9.1/m4/iconv.m40000644000175000017500000000642611250723262015537 0ustar mnordstrmnordstr# iconv.m4 serial AM4 (gettext-0.11.3) dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], [ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_LIB_LINKFLAGS_BODY([iconv]) ]) AC_DEFUN([AM_ICONV_LINK], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_func_iconv=yes) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_lib_iconv=yes am_cv_func_iconv=yes) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_RESULT([$LIBICONV]) else dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV dnl either. CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi AC_SUBST(LIBICONV) AC_SUBST(LTLIBICONV) ]) AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL(am_cv_proto_iconv, [ AC_TRY_COMPILE([ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([$]{ac_t:- }[$]am_cv_proto_iconv) AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, [Define as const if the declaration of iconv() needs const.]) fi ]) libvmime-0.9.1/m4/libgnutls.m40000644000175000017500000001502311250723262016415 0ustar mnordstrmnordstrdnl Autoconf macros for libgnutls dnl $id$ # Modified for LIBGNUTLS -- nmav # Configure paths for LIBGCRYPT # Shamelessly stolen from the one of XDELTA by Owen Taylor # Werner Koch 99-12-09 dnl AM_PATH_LIBGNUTLS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libgnutls, and define LIBGNUTLS_CFLAGS and LIBGNUTLS_LIBS dnl AC_DEFUN([AM_PATH_LIBGNUTLS], [dnl dnl Get the cflags and libraries from the libgnutls-config script dnl AC_ARG_WITH(libgnutls-prefix, [ --with-libgnutls-prefix=PFX Prefix where libgnutls is installed (optional)], libgnutls_config_prefix="$withval", libgnutls_config_prefix="") if test x$libgnutls_config_prefix != x ; then if test x${LIBGNUTLS_CONFIG+set} != xset ; then LIBGNUTLS_CONFIG=$libgnutls_config_prefix/bin/libgnutls-config fi fi AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no) min_libgnutls_version=ifelse([$1], ,0.1.0,$1) AC_MSG_CHECKING(for libgnutls - version >= $min_libgnutls_version) no_libgnutls="" if test "$LIBGNUTLS_CONFIG" = "no" ; then no_libgnutls=yes else LIBGNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --cflags` LIBGNUTLS_LIBS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --libs` libgnutls_config_version=`$LIBGNUTLS_CONFIG $libgnutls_config_args --version` ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS" LIBS="$LIBS $LIBGNUTLS_LIBS" dnl dnl Now check if the installed libgnutls is sufficiently new. Also sanity dnl checks the results of libgnutls-config to some extent dnl rm -f conf.libgnutlstest AC_TRY_RUN([ #include #include #include #include int main () { system ("touch conf.libgnutlstest"); if( strcmp( gnutls_check_version(NULL), "$libgnutls_config_version" ) ) { printf("\n*** 'libgnutls-config --version' returned %s, but LIBGNUTLS (%s)\n", "$libgnutls_config_version", gnutls_check_version(NULL) ); printf("*** was found! If libgnutls-config was correct, then it is best\n"); printf("*** to remove the old version of LIBGNUTLS. You may also be able to fix the error\n"); printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); printf("*** required on your system.\n"); printf("*** If libgnutls-config was wrong, set the environment variable LIBGNUTLS_CONFIG\n"); printf("*** to point to the correct copy of libgnutls-config, and remove the file config.cache\n"); printf("*** before re-running configure\n"); } else if ( strcmp(gnutls_check_version(NULL), LIBGNUTLS_VERSION ) ) { printf("\n*** LIBGNUTLS header file (version %s) does not match\n", LIBGNUTLS_VERSION); printf("*** library (version %s)\n", gnutls_check_version(NULL) ); } else { if ( gnutls_check_version( "$min_libgnutls_version" ) ) { return 0; } else { printf("no\n*** An old version of LIBGNUTLS (%s) was found.\n", gnutls_check_version(NULL) ); printf("*** You need a version of LIBGNUTLS newer than %s. The latest version of\n", "$min_libgnutls_version" ); printf("*** LIBGNUTLS is always available from ftp://gnutls.hellug.gr/pub/gnutls.\n"); printf("*** \n"); printf("*** If you have already installed a sufficiently new version, this error\n"); printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n"); printf("*** being found. The easiest way to fix this is to remove the old version\n"); printf("*** of LIBGNUTLS, but you can also set the LIBGNUTLS_CONFIG environment to point to the\n"); printf("*** correct copy of libgnutls-config. (In this case, you will have to\n"); printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); printf("*** so that the correct libraries are found at run-time))\n"); } } return 1; } ],, no_libgnutls=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi if test "x$no_libgnutls" = x ; then AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else if test -f conf.libgnutlstest ; then : else AC_MSG_RESULT(no) fi if test "$LIBGNUTLS_CONFIG" = "no" ; then echo "*** The libgnutls-config script installed by LIBGNUTLS could not be found" echo "*** If LIBGNUTLS was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the LIBGNUTLS_CONFIG environment variable to the" echo "*** full path to libgnutls-config." else if test -f conf.libgnutlstest ; then : else echo "*** Could not run libgnutls test program, checking why..." CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS" LIBS="$LIBS $LIBGNUTLS_LIBS" AC_TRY_LINK([ #include #include #include #include ], [ return !!gnutls_check_version(NULL); ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding LIBGNUTLS or finding the wrong" echo "*** version of LIBGNUTLS. If it is not finding LIBGNUTLS, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" echo "***" ], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means LIBGNUTLS was incorrectly installed" echo "*** or that you have moved LIBGNUTLS since it was installed. In the latter case, you" echo "*** may want to edit the libgnutls-config script: $LIBGNUTLS_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi LIBGNUTLS_CFLAGS="" LIBGNUTLS_LIBS="" ifelse([$3], , :, [$3]) fi rm -f conf.libgnutlstest AC_SUBST(LIBGNUTLS_CFLAGS) AC_SUBST(LIBGNUTLS_LIBS) ]) dnl *-*wedit:notab*-* Please keep this as the last line. libvmime-0.9.1/m4/acx_pthread.m40000644000175000017500000002203311250723262016673 0ustar mnordstrmnordstrdnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) dnl dnl This macro figures out how to build C programs using POSIX threads. dnl It sets the PTHREAD_LIBS output variable to the threads library and dnl linker flags, and the PTHREAD_CFLAGS output variable to any special dnl C compiler flags that are needed. (The user can also force certain dnl compiler flags/libs to be tested by setting these environment dnl variables.) dnl dnl Also sets PTHREAD_CC to any special C compiler that is needed for dnl multi-threaded programs (defaults to the value of CC otherwise). dnl (This is necessary on AIX to use the special cc_r compiler alias.) dnl dnl NOTE: You are assumed to not only compile your program with these dnl flags, but also link it with them as well. e.g. you should link dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS dnl $LIBS dnl dnl If you are only building threads programs, you may wish to use dnl these variables in your default LIBS, CFLAGS, and CC: dnl dnl LIBS="$PTHREAD_LIBS $LIBS" dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" dnl CC="$PTHREAD_CC" dnl dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). dnl dnl ACTION-IF-FOUND is a list of shell commands to run if a threads dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the dnl default action will define HAVE_PTHREAD. dnl dnl Please let the authors know if this macro fails on any platform, or dnl if you have any other suggestions or comments. This macro was based dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. dnl We are also grateful for the helpful feedback of numerous users. dnl dnl @category InstalledPackages dnl @author Steven G. Johnson dnl @version 2005-01-14 dnl @license GPLWithACException AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_SAVE AC_LANG_C acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) AC_MSG_RESULT($acx_pthread_ok) if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthread or # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [acx_pthread_ok=yes]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($acx_pthread_ok) if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_TRY_LINK([#include ], [int attr=$attr;], [attr_name=$attr; break]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with cc_r AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else acx_pthread_ok=no $2 fi AC_LANG_RESTORE ])dnl ACX_PTHREAD libvmime-0.9.1/m4/lib-prefix.m40000644000175000017500000001503611374031010016445 0ustar mnordstrmnordstr# lib-prefix.m4 serial 5 (gettext-0.15) dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't dnl require excessive bracketing. ifdef([AC_HELP_STRING], [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed dnl to access previously installed libraries. The basic assumption is that dnl a user will want packages to use other packages he previously installed dnl with the same --prefix option. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate dnl libraries, but is otherwise very convenient. AC_DEFUN([AC_LIB_PREFIX], [ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib-prefix], [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) if test $use_additional = yes; then dnl Potentially add $additional_includedir to $CPPFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's already present in $CPPFLAGS, dnl 3. if it's /usr/local/include and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $CPPFLAGS. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi dnl Potentially add $additional_libdir to $LDFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's already present in $LDFLAGS, dnl 3. if it's /usr/local/lib and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= for x in $LDFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LDFLAGS. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi ]) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, dnl acl_final_exec_prefix, containing the values to which $prefix and dnl $exec_prefix will expand at the end of the configure script. AC_DEFUN([AC_LIB_PREPARE_PREFIX], [ dnl Unfortunately, prefix and exec_prefix get only finally determined dnl at the end of configure. if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" ]) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the dnl variables prefix and exec_prefix bound to the values they will have dnl at the end of the configure script. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], [ acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" $1 exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" ]) dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing dnl the basename of the libdir, either "lib" or "lib64". AC_DEFUN([AC_LIB_PREPARE_MULTILIB], [ dnl There is no formal standard regarding lib and lib64. The current dnl practice is that on a system supporting 32-bit and 64-bit instruction dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit dnl libraries go under $prefix/lib. We determine the compiler's default dnl mode by looking at the compiler's library search path. If at least dnl of its elements ends in /lib64 or points to a directory whose absolute dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the dnl default, namely "lib". acl_libdirstem=lib searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ]) libvmime-0.9.1/src/0000755000175000017500000000000011607302336014417 5ustar mnordstrmnordstrlibvmime-0.9.1/src/mdn/0000755000175000017500000000000011607302336015175 5ustar mnordstrmnordstrlibvmime-0.9.1/src/mdn/MDNHelper.cpp0000644000175000017500000002205611250723263017464 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mdn/MDNHelper.hpp" #include "vmime/exception.hpp" #include "vmime/stringContentHandler.hpp" #include "vmime/contentTypeField.hpp" #include "vmime/path.hpp" #include "vmime/dateTime.hpp" namespace vmime { namespace mdn { void MDNHelper::attachMDNRequest(ref msg, const mailboxList& mailboxes) { ref
hdr = msg->getHeader(); hdr->DispositionNotificationTo()->setValue(mailboxes); } void MDNHelper::attachMDNRequest(ref msg, const mailbox& mbox) { mailboxList mboxList; mboxList.appendMailbox(mbox.clone().dynamicCast ()); attachMDNRequest(msg, mboxList); } const std::vector MDNHelper::getPossibleMDNs(const ref msg) { std::vector result; const ref hdr = msg->getHeader(); if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO)) { const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue() .dynamicCast (); for (int i = 0 ; i < dnto.getMailboxCount() ; ++i) result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i))); } return (result); } bool MDNHelper::isMDN(const ref msg) { const ref hdr = msg->getHeader(); // A MDN message implies the following: // - a Content-Type field is present and its value is "multipart/report" // - a "report-type" parameter is present in the Content-Type field, // and its value is "disposition-notification" if (hdr->hasField(fields::CONTENT_TYPE)) { const contentTypeField& ctf = *(hdr->ContentType() .dynamicCast ()); const mediaType type = *ctf.getValue().dynamicCast (); if (type.getType() == vmime::mediaTypes::MULTIPART && type.getSubType() == vmime::mediaTypes::MULTIPART_REPORT) { if (ctf.hasParameter("report-type") && ctf.getReportType() == "disposition-notification") { return (true); } } } return (false); } receivedMDNInfos MDNHelper::getReceivedMDN(const ref msg) { if (!isMDN(msg)) throw exceptions::invalid_argument(); return receivedMDNInfos(msg); } bool MDNHelper::needConfirmation(const ref msg) { ref hdr = msg->getHeader(); // No "Return-Path" field if (!hdr->hasField(fields::RETURN_PATH)) return true; // More than one address in Disposition-Notification-To if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO)) { const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue() .dynamicCast (); if (dnto.getMailboxCount() > 1) return true; else if (dnto.getMailboxCount() == 0) return false; // Return-Path != Disposition-Notification-To const mailbox& mbox = *dnto.getMailboxAt(0); const path& rp = *hdr->ReturnPath()->getValue().dynamicCast (); if (mbox.getEmail() != rp.getLocalPart() + "@" + rp.getDomain()) return true; } // User confirmation not needed return false; } ref MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos, const string& text, const charset& ch, const mailbox& expeditor, const disposition& dispo, const string& reportingUA, const std::vector & reportingUAProducts) { // Create a new message ref msg = vmime::create (); // Fill-in header fields ref
hdr = msg->getHeader(); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MULTIPART, vmime::mediaTypes::MULTIPART_REPORT)); hdr->ContentType().dynamicCast ()->setReportType("disposition-notification"); hdr->Disposition()->setValue(dispo); addressList to; to.appendAddress(vmime::create (mdnInfos.getRecipient())); hdr->To()->setValue(to); hdr->From()->setValue(expeditor); hdr->Subject()->setValue(vmime::text(word("Disposition notification"))); hdr->Date()->setValue(datetime::now()); hdr->MimeVersion()->setValue(string(SUPPORTED_MIME_VERSION)); msg->getBody()->appendPart(createFirstMDNPart(mdnInfos, text, ch)); msg->getBody()->appendPart(createSecondMDNPart(mdnInfos, dispo, reportingUA, reportingUAProducts)); msg->getBody()->appendPart(createThirdMDNPart(mdnInfos)); return (msg); } ref MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */, const string& text, const charset& ch) { ref part = vmime::create (); // Header ref
hdr = part->getHeader(); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT, vmime::mediaTypes::TEXT_PLAIN)); hdr->ContentType().dynamicCast ()->setCharset(ch); // Body part->getBody()->setContents(vmime::create (text)); return (part); } ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, const disposition& dispo, const string& reportingUA, const std::vector & reportingUAProducts) { ref part = vmime::create (); // Header ref
hdr = part->getHeader(); hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MESSAGE, vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION)); // Body // // The body of a message/disposition-notification consists of one or // more "fields" formatted according to the ABNF of [RFC-MSGFMT] header // "fields". The syntax of the message/disposition-notification content // is as follows: // // disposition-notification-content = [ reporting-ua-field CRLF ] // [ mdn-gateway-field CRLF ] // [ original-recipient-field CRLF ] // final-recipient-field CRLF // [ original-message-id-field CRLF ] // disposition-field CRLF // *( failure-field CRLF ) // *( error-field CRLF ) // *( warning-field CRLF ) // *( extension-field CRLF ) // header fields; // -- Reporting-UA (optional) if (!reportingUA.empty()) { string ruaText; ruaText = reportingUA; for (unsigned int i = 0 ; i < reportingUAProducts.size() ; ++i) { if (i == 0) ruaText += "; "; else ruaText += ", "; ruaText += reportingUAProducts[i]; } ref rua = headerFieldFactory::getInstance()-> create(vmime::fields::REPORTING_UA); rua->setValue(ruaText); fields.appendField(rua); } // -- Final-Recipient ref fr = headerFieldFactory::getInstance()-> create(vmime::fields::FINAL_RECIPIENT); fr->setValue("rfc822; " + mdnInfos.getRecipient().getEmail()); fields.appendField(fr); // -- Original-Message-ID if (mdnInfos.getMessage()->getHeader()->hasField(vmime::fields::MESSAGE_ID)) { fields.OriginalMessageId()->setValueConst (mdnInfos.getMessage()->getHeader()->MessageId()->getValue()); } // -- Disposition fields.Disposition()->setValue(dispo); std::ostringstream oss; utility::outputStreamAdapter vos(oss); fields.generate(vos); part->getBody()->setContents(vmime::create (oss.str())); return (part); } ref MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos) { ref part = vmime::create (); // Header ref
hdr = part->getHeader(); hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT, vmime::mediaTypes::TEXT_RFC822_HEADERS)); // Body: original message headers std::ostringstream oss; utility::outputStreamAdapter vos(oss); mdnInfos.getMessage()->getHeader()->generate(vos); part->getBody()->setContents(vmime::create (oss.str())); return (part); } } // mdn } // vmime libvmime-0.9.1/src/mdn/sendableMDNInfos.cpp0000644000175000017500000000340311250723263021014 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mdn/sendableMDNInfos.hpp" namespace vmime { namespace mdn { sendableMDNInfos::sendableMDNInfos(const ref msg, const mailbox& mbox) : m_msg(msg), m_mailbox(mbox) { } sendableMDNInfos::sendableMDNInfos(const sendableMDNInfos& other) : MDNInfos() { copyFrom(other); } sendableMDNInfos& sendableMDNInfos::operator=(const sendableMDNInfos& other) { copyFrom(other); return (*this); } const ref sendableMDNInfos::getMessage() const { return (m_msg); } const mailbox& sendableMDNInfos::getRecipient() const { return (m_mailbox); } void sendableMDNInfos::copyFrom(const sendableMDNInfos& other) { m_msg = other.m_msg; m_mailbox = other.m_mailbox; } } // mdn } // vmime libvmime-0.9.1/src/mdn/MDNInfos.cpp0000644000175000017500000000223611250723263017321 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mdn/MDNInfos.hpp" namespace vmime { namespace mdn { MDNInfos::~MDNInfos() { } } // mdn } // vmime libvmime-0.9.1/src/mdn/receivedMDNInfos.cpp0000644000175000017500000000562011250723263021030 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mdn/receivedMDNInfos.hpp" namespace vmime { namespace mdn { receivedMDNInfos::receivedMDNInfos(const ref msg) : m_msg(msg) { extract(); } receivedMDNInfos::receivedMDNInfos(const receivedMDNInfos& other) : MDNInfos() { copyFrom(other); } receivedMDNInfos& receivedMDNInfos::operator=(const receivedMDNInfos& other) { copyFrom(other); return (*this); } const ref receivedMDNInfos::getMessage() const { return (m_msg); } const messageId receivedMDNInfos::getOriginalMessageId() const { return (m_omid); } const disposition receivedMDNInfos::getDisposition() const { return (m_disp); } void receivedMDNInfos::copyFrom(const receivedMDNInfos& other) { m_msg = other.m_msg; m_omid = other.m_omid; m_disp = other.m_disp; } void receivedMDNInfos::extract() { const ref bdy = m_msg->getBody(); for (int i = 0 ; i < bdy->getPartCount() ; ++i) { const ref part = bdy->getPartAt(i); if (!part->getHeader()->hasField(fields::CONTENT_TYPE)) continue; const mediaType& type = *part->getHeader()->ContentType()-> getValue().dynamicCast (); // Extract from second part (message/disposition-notification) if (type.getType() == vmime::mediaTypes::MESSAGE && type.getSubType() == vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION) { std::ostringstream oss; utility::outputStreamAdapter vos(oss); part->getBody()->getContents()->extract(vos); // Body actually contains fields header fields; fields.parse(oss.str()); try { m_omid = *fields.OriginalMessageId()->getValue().dynamicCast (); } catch (exceptions::no_such_field&) { /* Ignore */ } try { m_disp = *fields.Disposition()->getValue().dynamicCast (); } catch (exceptions::no_such_field&) { /* Ignore */ } } } } } // mdn } // vmime libvmime-0.9.1/src/net/0000755000175000017500000000000011607302336015205 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/tls/0000755000175000017500000000000011607302336016007 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/tls/TLSSecuredConnectionInfos.cpp0000644000175000017500000000336511250723263023516 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/tls/TLSSecuredConnectionInfos.hpp" #include "vmime/net/tls/TLSSession.hpp" namespace vmime { namespace net { namespace tls { TLSSecuredConnectionInfos::TLSSecuredConnectionInfos (const string& host, const port_t port, ref tlsSession, ref tlsSocket) : m_host(host), m_port(port), m_tlsSession(tlsSession), m_tlsSocket(tlsSocket) { } const string TLSSecuredConnectionInfos::getHost() const { return m_host; } port_t TLSSecuredConnectionInfos::getPort() const { return m_port; } ref TLSSecuredConnectionInfos::getPeerCertificates() const { return m_tlsSocket->getPeerCertificates(); } } // tls } // net } // vmime libvmime-0.9.1/src/net/tls/TLSSocket.cpp0000644000175000017500000002005011314151075020320 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include "vmime/net/tls/TLSSocket.hpp" #include "vmime/net/tls/TLSSession.hpp" #include "vmime/platform.hpp" #include "vmime/security/cert/X509Certificate.hpp" namespace vmime { namespace net { namespace tls { TLSSocket::TLSSocket(ref session, ref sok) : m_session(session), m_wrapped(sok), m_connected(false), m_handshaking(false), m_ex(NULL) { gnutls_transport_set_ptr(*m_session->m_gnutlsSession, this); gnutls_transport_set_push_function(*m_session->m_gnutlsSession, gnutlsPushFunc); gnutls_transport_set_pull_function(*m_session->m_gnutlsSession, gnutlsPullFunc); } TLSSocket::~TLSSocket() { try { disconnect(); } catch (...) { // Don't throw exception in destructor } } void TLSSocket::connect(const string& address, const port_t port) { m_wrapped->connect(address, port); handshake(NULL); m_connected = true; } void TLSSocket::disconnect() { if (m_connected) { gnutls_bye(*m_session->m_gnutlsSession, GNUTLS_SHUT_RDWR); m_wrapped->disconnect(); m_connected = false; } } bool TLSSocket::isConnected() const { return m_wrapped->isConnected() && m_connected; } TLSSocket::size_type TLSSocket::getBlockSize() const { return 16384; // 16 KB } void TLSSocket::receive(string& buffer) { const int size = receiveRaw(m_buffer, sizeof(m_buffer)); buffer = vmime::string(m_buffer, size); } void TLSSocket::send(const string& buffer) { sendRaw(buffer.data(), buffer.length()); } TLSSocket::size_type TLSSocket::receiveRaw(char* buffer, const size_type count) { const ssize_t ret = gnutls_record_recv (*m_session->m_gnutlsSession, buffer, static_cast (count)); if (m_ex) internalThrow(); if (ret < 0) { if (ret == GNUTLS_E_AGAIN) return 0; TLSSession::throwTLSException("gnutls_record_recv", ret); } return static_cast (ret); } void TLSSocket::sendRaw(const char* buffer, const size_type count) { gnutls_record_send (*m_session->m_gnutlsSession, buffer, static_cast (count)); if (m_ex) internalThrow(); } void TLSSocket::handshake(ref toHandler) { if (toHandler) toHandler->resetTimeOut(); // Start handshaking process m_handshaking = true; m_toHandler = toHandler; try { while (true) { const int ret = gnutls_handshake(*m_session->m_gnutlsSession); if (m_ex) internalThrow(); if (ret < 0) { if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) { // Non-fatal error platform::getHandler()->wait(); } else { TLSSession::throwTLSException("gnutls_handshake", ret); } } else { // Successful handshake break; } } } catch (...) { m_handshaking = false; m_toHandler = NULL; throw; } m_handshaking = false; m_toHandler = NULL; // Verify server's certificate(s) ref certs = getPeerCertificates(); if (certs == NULL) throw exceptions::tls_exception("No peer certificate."); m_session->getCertificateVerifier()->verify(certs); m_connected = true; } ssize_t TLSSocket::gnutlsPushFunc (gnutls_transport_ptr trspt, const void* data, size_t len) { TLSSocket* sok = reinterpret_cast (trspt); try { sok->m_wrapped->sendRaw (reinterpret_cast (data), static_cast (len)); } catch (exception& e) { // Workaround for bad behaviour when throwing C++ exceptions // from C functions (GNU TLS) sok->m_ex = e.clone(); return -1; } return len; } ssize_t TLSSocket::gnutlsPullFunc (gnutls_transport_ptr trspt, void* data, size_t len) { TLSSocket* sok = reinterpret_cast (trspt); try { // Workaround for cross-platform asynchronous handshaking: // gnutls_handshake() only returns GNUTLS_E_AGAIN if recv() // returns -1 and errno is set to EGAIN... if (sok->m_handshaking) { while (true) { const ssize_t ret = static_cast (sok->m_wrapped->receiveRaw (reinterpret_cast (data), static_cast (len))); if (ret == 0) { // No data available yet platform::getHandler()->wait(); } else { return ret; } // Check whether the time-out delay is elapsed if (sok->m_toHandler && sok->m_toHandler->isTimeOut()) { if (!sok->m_toHandler->handleTimeOut()) throw exceptions::operation_timed_out(); sok->m_toHandler->resetTimeOut(); } } } else { const ssize_t n = static_cast (sok->m_wrapped->receiveRaw (reinterpret_cast (data), static_cast (len))); if (n == 0) return GNUTLS_E_AGAIN; // This seems like a hack, really... return n; } } catch (exception& e) { // Workaround for bad behaviour when throwing C++ exceptions // from C functions (GNU TLS) sok->m_ex = e.clone(); return -1; } } ref TLSSocket::getPeerCertificates() const { unsigned int certCount = 0; const gnutls_datum* rawData = gnutls_certificate_get_peers (*m_session->m_gnutlsSession, &certCount); if (rawData == NULL) return NULL; // Try X.509 gnutls_x509_crt* x509Certs = new gnutls_x509_crt[certCount]; for (unsigned int i = 0; i < certCount; ++i) { gnutls_x509_crt_init(x509Certs + i); int res = gnutls_x509_crt_import(x509Certs[i], rawData + i, GNUTLS_X509_FMT_DER); if (res < 0) { // XXX more fine-grained error reporting? delete [] x509Certs; return NULL; } } { std::vector > certs; bool error = false; for (unsigned int i = 0 ; i < certCount ; ++i) { size_t dataSize = 0; gnutls_x509_crt_export(x509Certs[i], GNUTLS_X509_FMT_DER, NULL, &dataSize); std::vector data(dataSize); gnutls_x509_crt_export(x509Certs[i], GNUTLS_X509_FMT_DER, &data[0], &dataSize); ref cert = security::cert::X509Certificate::import(&data[0], dataSize); if (cert != NULL) certs.push_back(cert); else error = true; gnutls_x509_crt_deinit(x509Certs[i]); } delete [] x509Certs; if (error) return NULL; return vmime::create (certs); } delete [] x509Certs; return NULL; } // Following is a workaround for C++ exceptions to pass correctly between // C and C++ calls. // // gnutls_record_recv() calls TLSSocket::gnutlsPullFunc, and exceptions // thrown by the socket can not be caught. #ifndef VMIME_BUILDING_DOC class TLSSocket_DeleteExWrapper : public object { public: TLSSocket_DeleteExWrapper(exception* ex) : m_ex(ex) { } ~TLSSocket_DeleteExWrapper() { delete m_ex; } private: exception* m_ex; }; #endif // VMIME_BUILDING_DOC void TLSSocket::internalThrow() { static std::vector > exToDelete; if (m_ex) { // Reset the current exception pointer to prevent the same // exception from being thrown again later exception* ex = m_ex; m_ex = NULL; // To avoid memory leaks exToDelete.push_back(vmime::create (ex)); throw *ex; } } } // tls } // net } // vmime libvmime-0.9.1/src/net/tls/TLSSession.cpp0000644000175000017500000002243511433160364020527 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include "vmime/config.hpp" #if VMIME_HAVE_PTHREAD # include # include # include #endif // VMIME_HAVE_PTHREAD #include "vmime/net/tls/TLSSession.hpp" #include "vmime/exception.hpp" // Enable GnuTLS debugging by defining GNUTLS_DEBUG //#define GNUTLS_DEBUG 1 #if VMIME_DEBUG && GNUTLS_DEBUG #include #endif // VMIME_DEBUG && GNUTLS_DEBUG #if VMIME_HAVE_PTHREAD && defined(GCRY_THREAD_OPTION_PTHREAD_IMPL) extern "C" { GCRY_THREAD_OPTION_PTHREAD_IMPL; } #endif // VMIME_HAVE_PTHREAD && defined(GCRY_THREAD_OPTION_PTHREAD_IMPL namespace vmime { namespace net { namespace tls { #ifndef VMIME_BUILDING_DOC // Initialize GNU TLS library struct TLSGlobal { TLSGlobal() { #if VMIME_HAVE_PTHREAD && defined(GCRY_THREAD_OPTION_PTHREAD_IMPL) gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif // VMIME_HAVE_PTHREAD && defined(GCRY_THREAD_OPTION_PTHREAD_IMPL gnutls_global_init(); //gnutls_global_init_extra(); #if VMIME_DEBUG && GNUTLS_DEBUG gnutls_global_set_log_function(TLSLogFunc); gnutls_global_set_log_level(10); #endif // VMIME_DEBUG && GNUTLS_DEBUG gnutls_anon_allocate_client_credentials(&anonCred); gnutls_certificate_allocate_credentials(&certCred); } ~TLSGlobal() { gnutls_anon_free_client_credentials(anonCred); gnutls_certificate_free_credentials(certCred); gnutls_global_deinit(); } #if VMIME_DEBUG && GNUTLS_DEBUG static void TLSLogFunc(int level, const char *str) { std::cerr << "GNUTLS: [" << level << "] " << str << std::endl; } #endif // VMIME_DEBUG && GNUTLS_DEBUG gnutls_anon_client_credentials anonCred; gnutls_certificate_credentials certCred; }; static TLSGlobal g_gnutlsGlobal; #endif // VMIME_BUILDING_DOC TLSSession::TLSSession(ref cv) : m_certVerifier(cv) { int res; m_gnutlsSession = new gnutls_session; if (gnutls_init(m_gnutlsSession, GNUTLS_CLIENT) != 0) throw std::bad_alloc(); // Sets some default priority on the ciphers, key exchange methods, // macs and compression methods. gnutls_set_default_priority(*m_gnutlsSession); // Sets the priority on the certificate types supported by gnutls. // Priority is higher for types specified before others. After // specifying the types you want, you must append a 0. const int certTypePriority[] = { GNUTLS_CRT_X509, 0 }; res = gnutls_certificate_type_set_priority (*m_gnutlsSession, certTypePriority); if (res < 0) { throwTLSException ("gnutls_certificate_type_set_priority", res); } // Sets the priority on the protocol types const int protoPriority[] = { GNUTLS_TLS1, GNUTLS_SSL3, 0 }; res = gnutls_protocol_set_priority(*m_gnutlsSession, protoPriority); if (res < 0) { throwTLSException ("gnutls_certificate_type_set_priority", res); } // Priority on the ciphers const int cipherPriority[] = { GNUTLS_CIPHER_ARCFOUR_128, GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_AES_128_CBC, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_ARCFOUR_40, GNUTLS_CIPHER_RC2_40_CBC, GNUTLS_CIPHER_DES_CBC, 0 }; gnutls_cipher_set_priority(*m_gnutlsSession, cipherPriority); // Priority on MACs const int macPriority[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0}; gnutls_mac_set_priority(*m_gnutlsSession, macPriority); // Priority on key exchange methods const int kxPriority[] = { GNUTLS_KX_RSA, GNUTLS_KX_DHE_DSS, GNUTLS_KX_DHE_RSA, GNUTLS_KX_ANON_DH, GNUTLS_KX_SRP, GNUTLS_KX_RSA_EXPORT, GNUTLS_KX_SRP_RSA, GNUTLS_KX_SRP_DSS, 0 }; gnutls_kx_set_priority(*m_gnutlsSession, kxPriority); // Priority on compression methods const int compressionPriority[] = { GNUTLS_COMP_ZLIB, //GNUTLS_COMP_LZO, GNUTLS_COMP_NULL, 0 }; gnutls_compression_set_priority(*m_gnutlsSession, compressionPriority); // Initialize credentials gnutls_credentials_set(*m_gnutlsSession, GNUTLS_CRD_ANON, g_gnutlsGlobal.anonCred); gnutls_credentials_set(*m_gnutlsSession, GNUTLS_CRD_CERTIFICATE, g_gnutlsGlobal.certCred); } TLSSession::TLSSession(const TLSSession&) : object() { // Not used } TLSSession::~TLSSession() { if (m_gnutlsSession) { gnutls_deinit(*m_gnutlsSession); delete m_gnutlsSession; m_gnutlsSession = NULL; } } ref TLSSession::getSocket(ref sok) { return vmime::create (thisRef().dynamicCast (), sok); } ref TLSSession::getCertificateVerifier() { return m_certVerifier; } void TLSSession::throwTLSException(const string& fname, const int code) { string msg = fname + "() returned "; #define ERROR(x) \ case x: msg += #x; break; switch (code) { ERROR(GNUTLS_E_SUCCESS) ERROR(GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM) ERROR(GNUTLS_E_UNKNOWN_CIPHER_TYPE) ERROR(GNUTLS_E_LARGE_PACKET) ERROR(GNUTLS_E_UNSUPPORTED_VERSION_PACKET) ERROR(GNUTLS_E_UNEXPECTED_PACKET_LENGTH) ERROR(GNUTLS_E_INVALID_SESSION) ERROR(GNUTLS_E_FATAL_ALERT_RECEIVED) ERROR(GNUTLS_E_UNEXPECTED_PACKET) ERROR(GNUTLS_E_WARNING_ALERT_RECEIVED) ERROR(GNUTLS_E_ERROR_IN_FINISHED_PACKET) ERROR(GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET) ERROR(GNUTLS_E_UNKNOWN_CIPHER_SUITE) ERROR(GNUTLS_E_UNWANTED_ALGORITHM) ERROR(GNUTLS_E_MPI_SCAN_FAILED) ERROR(GNUTLS_E_DECRYPTION_FAILED) ERROR(GNUTLS_E_MEMORY_ERROR) ERROR(GNUTLS_E_DECOMPRESSION_FAILED) ERROR(GNUTLS_E_COMPRESSION_FAILED) ERROR(GNUTLS_E_AGAIN) ERROR(GNUTLS_E_EXPIRED) ERROR(GNUTLS_E_DB_ERROR) ERROR(GNUTLS_E_SRP_PWD_ERROR) ERROR(GNUTLS_E_INSUFFICIENT_CREDENTIALS) ERROR(GNUTLS_E_HASH_FAILED) ERROR(GNUTLS_E_BASE64_DECODING_ERROR) ERROR(GNUTLS_E_MPI_PRINT_FAILED) ERROR(GNUTLS_E_REHANDSHAKE) ERROR(GNUTLS_E_GOT_APPLICATION_DATA) ERROR(GNUTLS_E_RECORD_LIMIT_REACHED) ERROR(GNUTLS_E_ENCRYPTION_FAILED) ERROR(GNUTLS_E_PK_ENCRYPTION_FAILED) ERROR(GNUTLS_E_PK_DECRYPTION_FAILED) ERROR(GNUTLS_E_PK_SIGN_FAILED) ERROR(GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION) ERROR(GNUTLS_E_KEY_USAGE_VIOLATION) ERROR(GNUTLS_E_NO_CERTIFICATE_FOUND) ERROR(GNUTLS_E_INVALID_REQUEST) ERROR(GNUTLS_E_SHORT_MEMORY_BUFFER) ERROR(GNUTLS_E_INTERRUPTED) ERROR(GNUTLS_E_PUSH_ERROR) ERROR(GNUTLS_E_PULL_ERROR) ERROR(GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER) ERROR(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) ERROR(GNUTLS_E_PKCS1_WRONG_PAD) ERROR(GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION) ERROR(GNUTLS_E_INTERNAL_ERROR) ERROR(GNUTLS_E_DH_PRIME_UNACCEPTABLE) ERROR(GNUTLS_E_FILE_ERROR) ERROR(GNUTLS_E_TOO_MANY_EMPTY_PACKETS) ERROR(GNUTLS_E_UNKNOWN_PK_ALGORITHM) ERROR(GNUTLS_E_INIT_LIBEXTRA) ERROR(GNUTLS_E_LIBRARY_VERSION_MISMATCH) ERROR(GNUTLS_E_NO_TEMPORARY_RSA_PARAMS) ERROR(GNUTLS_E_LZO_INIT_FAILED) ERROR(GNUTLS_E_NO_COMPRESSION_ALGORITHMS) ERROR(GNUTLS_E_NO_CIPHER_SUITES) ERROR(GNUTLS_E_OPENPGP_GETKEY_FAILED) ERROR(GNUTLS_E_PK_SIG_VERIFY_FAILED) ERROR(GNUTLS_E_ILLEGAL_SRP_USERNAME) ERROR(GNUTLS_E_SRP_PWD_PARSING_ERROR) ERROR(GNUTLS_E_NO_TEMPORARY_DH_PARAMS) ERROR(GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) ERROR(GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND) ERROR(GNUTLS_E_ASN1_DER_ERROR) ERROR(GNUTLS_E_ASN1_VALUE_NOT_FOUND) ERROR(GNUTLS_E_ASN1_GENERIC_ERROR) ERROR(GNUTLS_E_ASN1_VALUE_NOT_VALID) ERROR(GNUTLS_E_ASN1_TAG_ERROR) ERROR(GNUTLS_E_ASN1_TAG_IMPLICIT) ERROR(GNUTLS_E_ASN1_TYPE_ANY_ERROR) ERROR(GNUTLS_E_ASN1_SYNTAX_ERROR) ERROR(GNUTLS_E_ASN1_DER_OVERFLOW) //ERROR(GNUTLS_E_OPENPGP_TRUSTDB_VERSION_UNSUPPORTED) ERROR(GNUTLS_E_OPENPGP_UID_REVOKED) ERROR(GNUTLS_E_CERTIFICATE_ERROR) //ERROR(GNUTLS_E_X509_CERTIFICATE_ERROR) ERROR(GNUTLS_E_CERTIFICATE_KEY_MISMATCH) ERROR(GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE) ERROR(GNUTLS_E_X509_UNKNOWN_SAN) ERROR(GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED) ERROR(GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE) ERROR(GNUTLS_E_UNKNOWN_HASH_ALGORITHM) ERROR(GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE) ERROR(GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE) ERROR(GNUTLS_E_INVALID_PASSWORD) ERROR(GNUTLS_E_MAC_VERIFY_FAILED) ERROR(GNUTLS_E_CONSTRAINT_ERROR) ERROR(GNUTLS_E_BASE64_ENCODING_ERROR) ERROR(GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY) //ERROR(GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY) ERROR(GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY) ERROR(GNUTLS_E_OPENPGP_KEYRING_ERROR) ERROR(GNUTLS_E_X509_UNSUPPORTED_OID) //ERROR(GNUTLS_E_RANDOM_FAILED) ERROR(GNUTLS_E_UNIMPLEMENTED_FEATURE) default: msg += "unknown error"; break; } #undef ERROR throw exceptions::tls_exception(msg); } } // tls } // net } // vmime libvmime-0.9.1/src/net/builtinServices.inl0000644000175000017500000000465611250723263021076 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // Include registration helpers #include "src/net/serviceRegistration.inl" #ifndef VMIME_BUILDING_DOC #if VMIME_BUILTIN_MESSAGING_PROTO_POP3 #include "vmime/net/pop3/POP3Store.hpp" REGISTER_SERVICE(pop3::POP3Store, pop3, TYPE_STORE); #if VMIME_HAVE_TLS_SUPPORT #include "vmime/net/pop3/POP3SStore.hpp" REGISTER_SERVICE(pop3::POP3SStore, pop3s, TYPE_STORE); #endif // VMIME_HAVE_TLS_SUPPORT #endif #if VMIME_BUILTIN_MESSAGING_PROTO_SMTP #include "vmime/net/smtp/SMTPTransport.hpp" REGISTER_SERVICE(smtp::SMTPTransport, smtp, TYPE_TRANSPORT); #if VMIME_HAVE_TLS_SUPPORT #include "vmime/net/smtp/SMTPSTransport.hpp" REGISTER_SERVICE(smtp::SMTPSTransport, smtps, TYPE_TRANSPORT); #endif // VMIME_HAVE_TLS_SUPPORT #endif #if VMIME_BUILTIN_MESSAGING_PROTO_IMAP #include "vmime/net/imap/IMAPStore.hpp" REGISTER_SERVICE(imap::IMAPStore, imap, TYPE_STORE); #if VMIME_HAVE_TLS_SUPPORT #include "vmime/net/imap/IMAPSStore.hpp" REGISTER_SERVICE(imap::IMAPSStore, imaps, TYPE_STORE); #endif // VMIME_HAVE_TLS_SUPPORT #endif #if VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR #include "vmime/net/maildir/maildirStore.hpp" REGISTER_SERVICE(maildir::maildirStore, maildir, TYPE_STORE); #endif #if VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL #include "vmime/net/sendmail/sendmailTransport.hpp" REGISTER_SERVICE(sendmail::sendmailTransport, sendmail, TYPE_TRANSPORT); #endif #endif // VMIME_BUILDING_DOC libvmime-0.9.1/src/net/imap/0000755000175000017500000000000011607302336016133 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/imap/IMAPSStore.cpp0000644000175000017500000000312511250723263020526 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPSStore.hpp" namespace vmime { namespace net { namespace imap { IMAPSStore::IMAPSStore(ref sess, ref auth) : IMAPStore(sess, auth, true) { } IMAPSStore::~IMAPSStore() { } const string IMAPSStore::getProtocolName() const { return "imaps"; } // Service infos IMAPServiceInfos IMAPSStore::sm_infos(true); const serviceInfos& IMAPSStore::getInfosInstance() { return sm_infos; } const serviceInfos& IMAPSStore::getInfos() const { return sm_infos; } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPFolder.cpp0000644000175000017500000013005011314151075020515 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPFolder.hpp" #include "vmime/net/imap/IMAPStore.hpp" #include "vmime/net/imap/IMAPParser.hpp" #include "vmime/net/imap/IMAPMessage.hpp" #include "vmime/net/imap/IMAPUtils.hpp" #include "vmime/net/imap/IMAPConnection.hpp" #include "vmime/message.hpp" #include "vmime/exception.hpp" #include "vmime/utility/smartPtr.hpp" #include #include namespace vmime { namespace net { namespace imap { IMAPFolder::IMAPFolder(const folder::path& path, ref store, const int type, const int flags) : m_store(store), m_connection(store->connection()), m_path(path), m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1), m_open(false), m_type(type), m_flags(flags), m_messageCount(0), m_uidValidity(0) { store->registerFolder(this); } IMAPFolder::~IMAPFolder() { ref store = m_store.acquire(); if (store) { if (m_open) close(false); store->unregisterFolder(this); } else if (m_open) { m_connection = NULL; onClose(); } } int IMAPFolder::getMode() const { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); return (m_mode); } int IMAPFolder::getType() { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); // Root folder if (m_path.isEmpty()) { return (TYPE_CONTAINS_FOLDERS); } else { if (m_type == TYPE_UNDEFINED) testExistAndGetType(); return (m_type); } } int IMAPFolder::getFlags() { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); // Root folder if (m_path.isEmpty()) { return (FLAG_CHILDREN | FLAG_NO_OPEN); } else { if (m_flags == FLAG_UNDEFINED) testExistAndGetType(); return (m_flags); } } const folder::path::component IMAPFolder::getName() const { return (m_name); } const folder::path IMAPFolder::getFullPath() const { return (m_path); } void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); // Open a connection for this folder ref connection = vmime::create (store, store->getAuthenticator()); try { connection->connect(); // Emit the "SELECT" command // // Example: C: A142 SELECT INBOX // S: * 172 EXISTS // S: * 1 RECENT // S: * OK [UNSEEN 12] Message 12 is first unseen // S: * OK [UIDVALIDITY 3857529045] UIDs valid // S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) // S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited // S: A142 OK [READ-WRITE] SELECT completed std::ostringstream oss; if (mode == MODE_READ_ONLY) oss << "EXAMINE "; else oss << "SELECT "; oss << IMAPUtils::quoteString(IMAPUtils::pathToString (connection->hierarchySeparator(), getFullPath())); connection->send(true, oss.str(), true); // Read the response utility::auto_ptr resp(connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("SELECT", connection->getParser()->lastLine(), "bad response"); } const std::vector & respDataList = resp->continue_req_or_response_data(); for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) { throw exceptions::command_error("SELECT", connection->getParser()->lastLine(), "invalid response"); } const IMAPParser::response_data* responseData = (*it)->response_data(); // OK Untagged responses: UNSEEN, PERMANENTFLAGS, UIDVALIDITY (optional) if (responseData->resp_cond_state()) { const IMAPParser::resp_text_code* code = responseData->resp_cond_state()->resp_text()->resp_text_code(); if (code != NULL) { switch (code->type()) { case IMAPParser::resp_text_code::UIDVALIDITY: m_uidValidity = code->nz_number()->value(); break; default: break; } } } // Untagged responses: FLAGS, EXISTS, RECENT (required) else if (responseData->mailbox_data()) { switch (responseData->mailbox_data()->type()) { default: break; case IMAPParser::mailbox_data::FLAGS: { m_type = IMAPUtils::folderTypeFromFlags (responseData->mailbox_data()->mailbox_flag_list()); m_flags = IMAPUtils::folderFlagsFromFlags (responseData->mailbox_data()->mailbox_flag_list()); break; } case IMAPParser::mailbox_data::EXISTS: { m_messageCount = responseData->mailbox_data()->number()->value(); break; } case IMAPParser::mailbox_data::RECENT: { // TODO break; } } } } // Check for access mode (read-only or read-write) const IMAPParser::resp_text_code* respTextCode = resp->response_done()-> response_tagged()->resp_cond_state()->resp_text()->resp_text_code(); if (respTextCode) { const int openMode = (respTextCode->type() == IMAPParser::resp_text_code::READ_WRITE) ? MODE_READ_WRITE : MODE_READ_ONLY; if (failIfModeIsNotAvailable && mode == MODE_READ_WRITE && openMode == MODE_READ_ONLY) { throw exceptions::operation_not_supported(); } } m_connection = connection; m_open = true; m_mode = mode; } catch (std::exception&) { throw; } } void IMAPFolder::close(const bool expunge) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (!isOpen()) throw exceptions::illegal_state("Folder not open"); ref oldConnection = m_connection; // Emit the "CLOSE" command to expunge messages marked // as deleted (this is fastest than "EXPUNGE") if (expunge) { if (m_mode == MODE_READ_ONLY) throw exceptions::operation_not_supported(); oldConnection->send(true, "CLOSE", true); } // Close this folder connection oldConnection->disconnect(); // Now use default store connection m_connection = m_store.acquire()->connection(); m_open = false; m_mode = -1; m_uidValidity = 0; onClose(); } void IMAPFolder::onClose() { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { (*it)->onFolderClosed(); } m_messages.clear(); } void IMAPFolder::create(const int type) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (isOpen()) throw exceptions::illegal_state("Folder is open"); else if (exists()) throw exceptions::illegal_state("Folder already exists"); else if (!store->isValidFolderName(m_name)) throw exceptions::invalid_folder_name(); // Emit the "CREATE" command // // Example: C: A003 CREATE owatagusiam/ // S: A003 OK CREATE completed // C: A004 CREATE owatagusiam/blurdybloop // S: A004 OK CREATE completed string mailbox = IMAPUtils::pathToString (m_connection->hierarchySeparator(), getFullPath()); if (type & TYPE_CONTAINS_FOLDERS) mailbox += m_connection->hierarchySeparator(); std::ostringstream oss; oss << "CREATE " << IMAPUtils::quoteString(mailbox); m_connection->send(true, oss.str(), true); utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("CREATE", m_connection->getParser()->lastLine(), "bad response"); } // Notify folder created events::folderEvent event (thisRef().dynamicCast (), events::folderEvent::TYPE_CREATED, m_path, m_path); notifyFolder(event); } void IMAPFolder::destroy() { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (isOpen()) throw exceptions::illegal_state("Folder is open"); const string mailbox = IMAPUtils::pathToString (m_connection->hierarchySeparator(), getFullPath()); std::ostringstream oss; oss << "DELETE " << IMAPUtils::quoteString(mailbox); m_connection->send(true, oss.str(), true); utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("DELETE", m_connection->getParser()->lastLine(), "bad response"); } // Notify folder deleted events::folderEvent event (thisRef().dynamicCast (), events::folderEvent::TYPE_DELETED, m_path, m_path); notifyFolder(event); } bool IMAPFolder::exists() { ref store = m_store.acquire(); if (!isOpen() && !store) throw exceptions::illegal_state("Store disconnected"); return (testExistAndGetType() != TYPE_UNDEFINED); } int IMAPFolder::testExistAndGetType() { m_type = TYPE_UNDEFINED; // To test whether a folder exists, we simple list it using // the "LIST" command, and there should be one unique mailbox // with this name... // // Eg. Test whether '/foo/bar' exists // // C: a005 list "" foo/bar // S: * LIST (\NoSelect) "/" foo/bar // S: a005 OK LIST completed // // ==> OK, exists // // Test whether '/foo/bar/zap' exists // // C: a005 list "" foo/bar/zap // S: a005 OK LIST completed // // ==> NO, does not exist std::ostringstream oss; oss << "LIST \"\" "; oss << IMAPUtils::quoteString(IMAPUtils::pathToString (m_connection->hierarchySeparator(), getFullPath())); m_connection->send(true, oss.str(), true); utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("LIST", m_connection->getParser()->lastLine(), "bad response"); } // Check whether the result mailbox list contains this folder const std::vector & respDataList = resp->continue_req_or_response_data(); for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) { throw exceptions::command_error("LIST", m_connection->getParser()->lastLine(), "invalid response"); } const IMAPParser::mailbox_data* mailboxData = (*it)->response_data()->mailbox_data(); // We are only interested in responses of type "LIST" if (mailboxData != NULL && mailboxData->type() == IMAPParser::mailbox_data::LIST) { // Get the folder type/flags at the same time m_type = IMAPUtils::folderTypeFromFlags (mailboxData->mailbox_list()->mailbox_flag_list()); m_flags = IMAPUtils::folderFlagsFromFlags (mailboxData->mailbox_list()->mailbox_flag_list()); } } return (m_type); } bool IMAPFolder::isOpen() const { return (m_open); } ref IMAPFolder::getMessage(const int num) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); if (num < 1 || num > m_messageCount) throw exceptions::message_not_found(); return vmime::create (thisRef().dynamicCast (), num); } std::vector > IMAPFolder::getMessages(const int from, const int to) { const int messageCount = getMessageCount(); const int to2 = (to == -1 ? messageCount : to); if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (to2 < from || from < 1 || to2 < 1 || from > messageCount || to2 > messageCount) throw exceptions::message_not_found(); std::vector > v; ref thisFolder = thisRef().dynamicCast (); for (int i = from ; i <= to2 ; ++i) v.push_back(vmime::create (thisFolder, i)); return (v); } std::vector > IMAPFolder::getMessages(const std::vector & nums) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); std::vector > v; ref thisFolder = thisRef().dynamicCast (); for (std::vector ::const_iterator it = nums.begin() ; it != nums.end() ; ++it) v.push_back(vmime::create (thisFolder, *it)); return (v); } int IMAPFolder::getMessageCount() { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); return (m_messageCount); } ref IMAPFolder::getFolder(const folder::path::component& name) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); return vmime::create (m_path / name, store); } std::vector > IMAPFolder::getFolders(const bool recursive) { ref store = m_store.acquire(); if (!isOpen() && !store) throw exceptions::illegal_state("Store disconnected"); // Eg. List folders in '/foo/bar' // // C: a005 list "foo/bar" * // S: * LIST (\NoSelect) "/" foo/bar // S: * LIST (\NoInferiors) "/" foo/bar/zap // S: a005 OK LIST completed std::ostringstream oss; oss << "LIST "; const string pathString = IMAPUtils::pathToString (m_connection->hierarchySeparator(), getFullPath()); if (recursive) { oss << IMAPUtils::quoteString(pathString); oss << " *"; } else { if (pathString.empty()) // don't add sep for root folder oss << "\"\""; else oss << IMAPUtils::quoteString(pathString + m_connection->hierarchySeparator()); oss << " %"; } m_connection->send(true, oss.str(), true); utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("LIST", m_connection->getParser()->lastLine(), "bad response"); } const std::vector & respDataList = resp->continue_req_or_response_data(); std::vector > v; for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) { throw exceptions::command_error("LIST", m_connection->getParser()->lastLine(), "invalid response"); } const IMAPParser::mailbox_data* mailboxData = (*it)->response_data()->mailbox_data(); if (mailboxData == NULL || mailboxData->type() != IMAPParser::mailbox_data::LIST) continue; // Get folder path const class IMAPParser::mailbox* mailbox = mailboxData->mailbox_list()->mailbox(); folder::path path = IMAPUtils::stringToPath (mailboxData->mailbox_list()->quoted_char(), mailbox->name()); if (recursive || m_path.isDirectParentOf(path)) { // Append folder to list const class IMAPParser::mailbox_flag_list* mailbox_flag_list = mailboxData->mailbox_list()->mailbox_flag_list(); v.push_back(vmime::create (path, store, IMAPUtils::folderTypeFromFlags(mailbox_flag_list), IMAPUtils::folderFlagsFromFlags(mailbox_flag_list))); } } return (v); } void IMAPFolder::fetchMessages(std::vector >& msg, const int options, utility::progressListener* progress) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); // Build message numbers list std::vector list; list.reserve(msg.size()); std::map > numberToMsg; for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { list.push_back((*it)->getNumber()); numberToMsg[(*it)->getNumber()] = (*it).dynamicCast (); } // Send the request const string command = IMAPUtils::buildFetchRequest(list, options); m_connection->send(true, command, true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("FETCH", m_connection->getParser()->lastLine(), "bad response"); } const std::vector & respDataList = resp->continue_req_or_response_data(); const int total = msg.size(); int current = 0; if (progress) progress->start(total); try { for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) { throw exceptions::command_error("FETCH", m_connection->getParser()->lastLine(), "invalid response"); } const IMAPParser::message_data* messageData = (*it)->response_data()->message_data(); // We are only interested in responses of type "FETCH" if (messageData == NULL || messageData->type() != IMAPParser::message_data::FETCH) continue; // Process fetch response for this message const int num = static_cast (messageData->number()); std::map >::iterator msg = numberToMsg.find(num); if (msg != numberToMsg.end()) { (*msg).second->processFetchResponse(options, messageData->msg_att()); if (progress) progress->progress(++current, total); } } } catch (...) { if (progress) progress->stop(total); throw; } if (progress) progress->stop(total); } void IMAPFolder::fetchMessage(ref msg, const int options) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); msg.dynamicCast ()->fetch(thisRef().dynamicCast (), options); } int IMAPFolder::getFetchCapabilities() const { return (FETCH_ENVELOPE | FETCH_CONTENT_INFO | FETCH_STRUCTURE | FETCH_FLAGS | FETCH_SIZE | FETCH_FULL_HEADER | FETCH_UID | FETCH_IMPORTANCE); } ref IMAPFolder::getParent() { if (m_path.isEmpty()) return NULL; else return vmime::create (m_path.getParent(), m_store.acquire()); } ref IMAPFolder::getStore() const { return m_store.acquire(); } ref IMAPFolder::getStore() { return m_store.acquire(); } void IMAPFolder::registerMessage(IMAPMessage* msg) { m_messages.push_back(msg); } void IMAPFolder::unregisterMessage(IMAPMessage* msg) { std::vector ::iterator it = std::find(m_messages.begin(), m_messages.end(), msg); if (it != m_messages.end()) m_messages.erase(it); } void IMAPFolder::onStoreDisconnected() { m_store = NULL; } void IMAPFolder::deleteMessage(const int num) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "STORE " << num << " +FLAGS.SILENT (\\Deleted)"; // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("STORE", m_connection->getParser()->lastLine(), "bad response"); } // Update local flags for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() == num && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags |= message::FLAG_DELETED; } } // Notify message flags changed std::vector nums; nums.push_back(num); events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); } void IMAPFolder::deleteMessages(const int from, const int to) { ref store = m_store.acquire(); if (from < 1 || (to < from && to != -1)) throw exceptions::invalid_argument(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "STORE " << from << ":"; if (to == -1) command << m_messageCount; else command << to; command << " +FLAGS.SILENT (\\Deleted)"; // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("STORE", m_connection->getParser()->lastLine(), "bad response"); } // Update local flags const int to2 = (to == -1) ? m_messageCount : to; const int count = to - from + 1; for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() >= from && (*it)->getNumber() <= to2 && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags |= message::FLAG_DELETED; } } // Notify message flags changed std::vector nums; nums.resize(count); for (int i = from, j = 0 ; i <= to2 ; ++i, ++j) nums[j] = i; events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); } void IMAPFolder::deleteMessages(const std::vector & nums) { ref store = m_store.acquire(); if (nums.empty()) throw exceptions::invalid_argument(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Sort the list of message numbers std::vector list; list.resize(nums.size()); std::copy(nums.begin(), nums.end(), list.begin()); std::sort(list.begin(), list.end()); // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "STORE "; command << IMAPUtils::listToSet(list, m_messageCount, true); command << " +FLAGS.SILENT (\\Deleted)"; // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("STORE", m_connection->getParser()->lastLine(), "bad response"); } // Update local flags for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(list.begin(), list.end(), (*it)->getNumber())) { if ((*it)->m_flags != message::FLAG_UNDEFINED) (*it)->m_flags |= message::FLAG_DELETED; } } // Notify message flags changed events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, list); notifyMessageChanged(event); } void IMAPFolder::setMessageFlags(const int from, const int to, const int flags, const int mode) { ref store = m_store.acquire(); if (from < 1 || (to < from && to != -1)) throw exceptions::invalid_argument(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); std::ostringstream oss; oss.imbue(std::locale::classic()); if (to == -1) oss << from << ":*"; else oss << from << ":" << to; setMessageFlags(oss.str(), flags, mode); // Update local flags const int to2 = (to == -1) ? m_messageCount : to; const int count = to - from + 1; switch (mode) { case message::FLAG_MODE_ADD: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() >= from && (*it)->getNumber() <= to2 && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags |= flags; } } break; } case message::FLAG_MODE_REMOVE: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() >= from && (*it)->getNumber() <= to2 && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags &= ~flags; } } break; } default: case message::FLAG_MODE_SET: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() >= from && (*it)->getNumber() <= to2 && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags = flags; } } break; } } // Notify message flags changed std::vector nums; nums.resize(count); for (int i = from, j = 0 ; i <= to2 ; ++i, ++j) nums[j] = i; events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); } void IMAPFolder::setMessageFlags(const std::vector & nums, const int flags, const int mode) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Sort the list of message numbers std::vector list; list.resize(nums.size()); std::copy(nums.begin(), nums.end(), list.begin()); std::sort(list.begin(), list.end()); // Delegates call setMessageFlags(IMAPUtils::listToSet(list, m_messageCount, true), flags, mode); // Update local flags switch (mode) { case message::FLAG_MODE_ADD: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(list.begin(), list.end(), (*it)->getNumber()) && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags |= flags; } } break; } case message::FLAG_MODE_REMOVE: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(list.begin(), list.end(), (*it)->getNumber()) && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags &= ~flags; } } break; } default: case message::FLAG_MODE_SET: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(list.begin(), list.end(), (*it)->getNumber()) && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags = flags; } } break; } } // Notify message flags changed events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); } void IMAPFolder::setMessageFlags(const string& set, const int flags, const int mode) { // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "STORE " << set; switch (mode) { case message::FLAG_MODE_ADD: command << " +FLAGS.SILENT "; break; case message::FLAG_MODE_REMOVE: command << " -FLAGS.SILENT "; break; default: case message::FLAG_MODE_SET: command << " FLAGS.SILENT "; break; } const string flagList = IMAPUtils::messageFlagList(flags); if (!flagList.empty()) { command << flagList; // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("STORE", m_connection->getParser()->lastLine(), "bad response"); } } } void IMAPFolder::addMessage(ref msg, const int flags, vmime::datetime* date, utility::progressListener* progress) { std::ostringstream oss; utility::outputStreamAdapter ossAdapter(oss); msg->generate(ossAdapter); const std::string& str = oss.str(); utility::inputStreamStringAdapter strAdapter(str); addMessage(strAdapter, str.length(), flags, date, progress); } void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int flags, vmime::datetime* date, utility::progressListener* progress) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "APPEND " << IMAPUtils::quoteString(IMAPUtils::pathToString (m_connection->hierarchySeparator(), getFullPath())) << ' '; const string flagList = IMAPUtils::messageFlagList(flags); if (flags != message::FLAG_UNDEFINED && !flagList.empty()) { command << flagList; command << ' '; } if (date != NULL) { command << IMAPUtils::dateTime(*date); command << ' '; } command << '{' << size << '}'; // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); bool ok = false; const std::vector & respList = resp->continue_req_or_response_data(); for (std::vector ::const_iterator it = respList.begin() ; !ok && (it != respList.end()) ; ++it) { if ((*it)->continue_req()) ok = true; } if (!ok) { throw exceptions::command_error("APPEND", m_connection->getParser()->lastLine(), "bad response"); } // Send message data const int total = size; int current = 0; if (progress) progress->start(total); const socket::size_type blockSize = std::min(is.getBlockSize(), static_cast (m_connection->getSocket()->getBlockSize())); std::vector vbuffer(blockSize); char* buffer = &vbuffer.front(); while (!is.eof()) { // Read some data from the input stream const int read = is.read(buffer, sizeof(buffer)); current += read; // Put read data into socket output stream m_connection->sendRaw(buffer, read); // Notify progress if (progress) progress->progress(current, total); } m_connection->send(false, "", true); if (progress) progress->stop(total); // Get the response utility::auto_ptr finalResp(m_connection->readResponse()); if (finalResp->isBad() || finalResp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("APPEND", m_connection->getParser()->lastLine(), "bad response"); } // Notify message added std::vector nums; nums.push_back(m_messageCount + 1); events::messageCountEvent event (thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); m_messageCount++; notifyMessageCount(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == m_path) { events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->m_messageCount++; (*it)->notifyMessageCount(event); } } } void IMAPFolder::expunge() { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Send the request m_connection->send(true, "EXPUNGE", true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("EXPUNGE", m_connection->getParser()->lastLine(), "bad response"); } // Update the numbering of the messages const std::vector & respDataList = resp->continue_req_or_response_data(); std::vector nums; for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) { throw exceptions::command_error("EXPUNGE", m_connection->getParser()->lastLine(), "invalid response"); } const IMAPParser::message_data* messageData = (*it)->response_data()->message_data(); // We are only interested in responses of type "EXPUNGE" if (messageData == NULL || messageData->type() != IMAPParser::message_data::EXPUNGE) { continue; } const int number = messageData->number(); nums.push_back(number); for (std::vector ::iterator jt = m_messages.begin() ; jt != m_messages.end() ; ++jt) { if ((*jt)->m_num == number) (*jt)->m_expunged = true; else if ((*jt)->m_num > number) (*jt)->m_num--; } } m_messageCount -= nums.size(); // Notify message expunged events::messageCountEvent event (thisRef().dynamicCast (), events::messageCountEvent::TYPE_REMOVED, nums); notifyMessageCount(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == m_path) { (*it)->m_messageCount = m_messageCount; events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_REMOVED, nums); (*it)->notifyMessageCount(event); } } } void IMAPFolder::rename(const folder::path& newPath) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (m_path.isEmpty() || newPath.isEmpty()) throw exceptions::illegal_operation("Cannot rename root folder"); else if (m_path.getSize() == 1 && m_name.getBuffer() == "INBOX") throw exceptions::illegal_operation("Cannot rename 'INBOX' folder"); else if (!store->isValidFolderName(newPath.getLastComponent())) throw exceptions::invalid_folder_name(); // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "RENAME "; command << IMAPUtils::quoteString(IMAPUtils::pathToString (m_connection->hierarchySeparator(), getFullPath())) << " "; command << IMAPUtils::quoteString(IMAPUtils::pathToString (m_connection->hierarchySeparator(), newPath)); // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("RENAME", m_connection->getParser()->lastLine(), "bad response"); } // Notify folder renamed folder::path oldPath(m_path); m_path = newPath; m_name = newPath.getLastComponent(); events::folderEvent event (thisRef().dynamicCast (), events::folderEvent::TYPE_RENAMED, oldPath, newPath); notifyFolder(event); // Notify folders with the same path and sub-folders for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == oldPath) { (*it)->m_path = newPath; (*it)->m_name = newPath.getLastComponent(); events::folderEvent event ((*it)->thisRef().dynamicCast (), events::folderEvent::TYPE_RENAMED, oldPath, newPath); (*it)->notifyFolder(event); } else if ((*it) != this && oldPath.isParentOf((*it)->getFullPath())) { folder::path oldPath((*it)->m_path); (*it)->m_path.renameParent(oldPath, newPath); events::folderEvent event ((*it)->thisRef().dynamicCast (), events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path); (*it)->notifyFolder(event); } } } void IMAPFolder::copyMessage(const folder::path& dest, const int num) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); // Construct set std::ostringstream set; set.imbue(std::locale::classic()); set << num; // Delegate message copy copyMessages(set.str(), dest); // Notify message count changed std::vector nums; nums.push_back(num); for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it)->getFullPath() == dest) { events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->m_messageCount++; (*it)->notifyMessageCount(event); } } } void IMAPFolder::copyMessages(const folder::path& dest, const int from, const int to) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (from < 1 || (to < from && to != -1)) throw exceptions::invalid_argument(); // Construct set std::ostringstream set; set.imbue(std::locale::classic()); if (to == -1) set << from << ":*"; else set << from << ":" << to; // Delegate message copy copyMessages(set.str(), dest); // Notify message count changed const int to2 = (to == -1) ? m_messageCount : to; const int count = to - from + 1; std::vector nums; nums.resize(count); for (int i = from, j = 0 ; i <= to2 ; ++i, ++j) nums[j] = i; for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it)->getFullPath() == dest) { events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->m_messageCount += count; (*it)->notifyMessageCount(event); } } } void IMAPFolder::copyMessages(const folder::path& dest, const std::vector & nums) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); // Delegate message copy copyMessages(IMAPUtils::listToSet(nums, m_messageCount), dest); // Notify message count changed const int count = nums.size(); for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it)->getFullPath() == dest) { events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->m_messageCount += count; (*it)->notifyMessageCount(event); } } } void IMAPFolder::copyMessages(const string& set, const folder::path& dest) { // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "COPY " << set << " "; command << IMAPUtils::quoteString(IMAPUtils::pathToString (m_connection->hierarchySeparator(), dest)); // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("COPY", m_connection->getParser()->lastLine(), "bad response"); } } void IMAPFolder::status(int& count, int& unseen) { ref store = m_store.acquire(); count = 0; unseen = 0; // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "STATUS "; command << IMAPUtils::quoteString(IMAPUtils::pathToString (m_connection->hierarchySeparator(), getFullPath())); command << " (MESSAGES UNSEEN)"; // Send the request m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("STATUS", m_connection->getParser()->lastLine(), "bad response"); } const std::vector & respDataList = resp->continue_req_or_response_data(); for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) { throw exceptions::command_error("STATUS", m_connection->getParser()->lastLine(), "invalid response"); } const IMAPParser::response_data* responseData = (*it)->response_data(); if (responseData->mailbox_data() && responseData->mailbox_data()->type() == IMAPParser::mailbox_data::STATUS) { const std::vector & statusList = responseData->mailbox_data()->status_info_list(); for (std::vector ::const_iterator jt = statusList.begin() ; jt != statusList.end() ; ++jt) { switch ((*jt)->status_att()->type()) { case IMAPParser::status_att::MESSAGES: count = (*jt)->number()->value(); break; case IMAPParser::status_att::UNSEEN: unseen = (*jt)->number()->value(); break; default: break; } } } } // Notify message count changed (new messages) if (m_messageCount != count) { const int oldCount = m_messageCount; m_messageCount = count; if (count > oldCount) { std::vector nums; nums.reserve(count - oldCount); for (int i = oldCount + 1, j = 0 ; i <= count ; ++i, ++j) nums[j] = i; events::messageCountEvent event (thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == m_path) { (*it)->m_messageCount = count; events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); } } } } } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPConnection.cpp0000644000175000017500000003731511421613100021402 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPTag.hpp" #include "vmime/net/imap/IMAPConnection.hpp" #include "vmime/net/imap/IMAPUtils.hpp" #include "vmime/net/imap/IMAPStore.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" #include "vmime/net/defaultConnectionInfos.hpp" #if VMIME_HAVE_SASL_SUPPORT #include "vmime/security/sasl/SASLContext.hpp" #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT #include "vmime/net/tls/TLSSession.hpp" #include "vmime/net/tls/TLSSecuredConnectionInfos.hpp" #endif // VMIME_HAVE_TLS_SUPPORT #include // Helpers for service properties #define GET_PROPERTY(type, prop) \ (m_store.acquire()->getInfos().getPropertyValue (getSession(), \ dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ (m_store.acquire()->getInfos().hasProperty(getSession(), \ dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) namespace vmime { namespace net { namespace imap { IMAPConnection::IMAPConnection(ref store, ref auth) : m_store(store), m_auth(auth), m_socket(NULL), m_parser(NULL), m_tag(NULL), m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(NULL), m_secured(false) { } IMAPConnection::~IMAPConnection() { try { if (isConnected()) disconnect(); else if (m_socket) internalDisconnect(); } catch (vmime::exception&) { // Ignore } } void IMAPConnection::connect() { if (isConnected()) throw exceptions::already_connected(); m_state = STATE_NONE; m_hierarchySeparator = '\0'; const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS); const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT); ref store = m_store.acquire(); // Create the time-out handler if (store->getTimeoutHandlerFactory()) m_timeoutHandler = store->getTimeoutHandlerFactory()->create(); // Create and connect the socket m_socket = store->getSocketFactory()->create(m_timeoutHandler); #if VMIME_HAVE_TLS_SUPPORT if (store->isIMAPS()) // dedicated port/IMAPS { ref tlsSession = vmime::create (store->getCertificateVerifier()); ref tlsSocket = tlsSession->getSocket(m_socket); m_socket = tlsSocket; m_secured = true; m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); } else #endif // VMIME_HAVE_TLS_SUPPORT { m_cntInfos = vmime::create (address, port); } m_socket->connect(address, port); m_tag = vmime::create (); m_parser = vmime::create (m_tag, m_socket, m_timeoutHandler); setState(STATE_NON_AUTHENTICATED); // Connection greeting // // eg: C: // --- S: * OK mydomain.org IMAP4rev1 v12.256 server ready utility::auto_ptr greet(m_parser->readGreeting()); bool needAuth = false; if (greet->resp_cond_bye()) { internalDisconnect(); throw exceptions::connection_greeting_error(m_parser->lastLine()); } else if (greet->resp_cond_auth()->condition() != IMAPParser::resp_cond_auth::PREAUTH) { needAuth = true; } #if VMIME_HAVE_TLS_SUPPORT // Setup secured connection, if requested const bool tls = HAS_PROPERTY(PROPERTY_CONNECTION_TLS) && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS); const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED) && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED); if (!store->isIMAPS() && tls) // only if not IMAPS { try { startTLS(); } // Non-fatal error catch (exceptions::command_error&) { if (tlsRequired) { m_state = STATE_NONE; throw; } else { // TLS is not required, so don't bother } } // Fatal error catch (...) { m_state = STATE_NONE; throw; } } #endif // VMIME_HAVE_TLS_SUPPORT // Authentication if (needAuth) { try { authenticate(); } catch (...) { m_state = STATE_NONE; throw; } } // Get the hierarchy separator character initHierarchySeparator(); // Switch to state "Authenticated" setState(STATE_AUTHENTICATED); } void IMAPConnection::authenticate() { getAuthenticator()->setService(m_store.acquire()); #if VMIME_HAVE_SASL_SUPPORT // First, try SASL authentication if (GET_PROPERTY(bool, PROPERTY_OPTIONS_SASL)) { try { authenticateSASL(); return; } catch (exceptions::authentication_error& e) { if (!GET_PROPERTY(bool, PROPERTY_OPTIONS_SASL_FALLBACK)) { // Can't fallback on normal authentication internalDisconnect(); throw e; } else { // Ignore, will try normal authentication } } catch (exception& e) { internalDisconnect(); throw e; } } #endif // VMIME_HAVE_SASL_SUPPORT // Normal authentication const string username = getAuthenticator()->getUsername(); const string password = getAuthenticator()->getPassword(); send(true, "LOGIN " + IMAPUtils::quoteString(username) + " " + IMAPUtils::quoteString(password), true); utility::auto_ptr resp(m_parser->readResponse()); if (resp->isBad()) { internalDisconnect(); throw exceptions::command_error("LOGIN", m_parser->lastLine()); } else if (resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { internalDisconnect(); throw exceptions::authentication_error(m_parser->lastLine()); } } #if VMIME_HAVE_SASL_SUPPORT void IMAPConnection::authenticateSASL() { if (!getAuthenticator().dynamicCast ()) throw exceptions::authentication_error("No SASL authenticator available."); const std::vector capa = getCapabilities(); std::vector saslMechs; for (unsigned int i = 0 ; i < capa.size() ; ++i) { const string& x = capa[i]; if (x.length() > 5 && (x[0] == 'A' || x[0] == 'a') && (x[1] == 'U' || x[1] == 'u') && (x[2] == 'T' || x[2] == 't') && (x[3] == 'H' || x[3] == 'h') && x[4] == '=') { saslMechs.push_back(string(x.begin() + 5, x.end())); } } if (saslMechs.empty()) throw exceptions::authentication_error("No SASL mechanism available."); std::vector > mechList; ref saslContext = vmime::create (); for (unsigned int i = 0 ; i < saslMechs.size() ; ++i) { try { mechList.push_back (saslContext->createMechanism(saslMechs[i])); } catch (exceptions::no_such_mechanism&) { // Ignore mechanism } } if (mechList.empty()) throw exceptions::authentication_error("No SASL mechanism available."); // Try to suggest a mechanism among all those supported ref suggestedMech = saslContext->suggestMechanism(mechList); if (!suggestedMech) throw exceptions::authentication_error("Unable to suggest SASL mechanism."); // Allow application to choose which mechanisms to use mechList = getAuthenticator().dynamicCast ()-> getAcceptableMechanisms(mechList, suggestedMech); if (mechList.empty()) throw exceptions::authentication_error("No SASL mechanism available."); // Try each mechanism in the list in turn for (unsigned int i = 0 ; i < mechList.size() ; ++i) { ref mech = mechList[i]; ref saslSession = saslContext->createSession("imap", getAuthenticator(), mech); saslSession->init(); send(true, "AUTHENTICATE " + mech->getName(), true); for (bool cont = true ; cont ; ) { utility::auto_ptr resp(m_parser->readResponse()); if (resp->response_done() && resp->response_done()->response_tagged() && resp->response_done()->response_tagged()->resp_cond_state()-> status() == IMAPParser::resp_cond_state::OK) { m_socket = saslSession->getSecuredSocket(m_socket); return; } else { std::vector respDataList = resp->continue_req_or_response_data(); string response; bool hasResponse = false; for (unsigned int i = 0 ; i < respDataList.size() ; ++i) { if (respDataList[i]->continue_req()) { response = respDataList[i]->continue_req()->resp_text()->text(); hasResponse = true; break; } } if (!hasResponse) { cont = false; continue; } byte_t* challenge = 0; int challengeLen = 0; byte_t* resp = 0; int respLen = 0; try { // Extract challenge saslContext->decodeB64(response, &challenge, &challengeLen); // Prepare response saslSession->evaluateChallenge (challenge, challengeLen, &resp, &respLen); // Send response send(false, saslContext->encodeB64(resp, respLen), true); } catch (exceptions::sasl_exception& e) { if (challenge) { delete [] challenge; challenge = NULL; } if (resp) { delete [] resp; resp = NULL; } // Cancel SASL exchange send(false, "*", true); } catch (...) { if (challenge) delete [] challenge; if (resp) delete [] resp; throw; } if (challenge) delete [] challenge; if (resp) delete [] resp; } } } throw exceptions::authentication_error ("Could not authenticate using SASL: all mechanisms failed."); } #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT void IMAPConnection::startTLS() { try { send(true, "STARTTLS", true); utility::auto_ptr resp(m_parser->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error ("STARTTLS", m_parser->lastLine(), "bad response"); } ref tlsSession = vmime::create (m_store.acquire()->getCertificateVerifier()); ref tlsSocket = tlsSession->getSocket(m_socket); tlsSocket->handshake(m_timeoutHandler); m_socket = tlsSocket; m_parser->setSocket(m_socket); m_secured = true; m_cntInfos = vmime::create (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); } catch (exceptions::command_error&) { // Non-fatal error throw; } catch (exception&) { // Fatal error internalDisconnect(); throw; } } #endif // VMIME_HAVE_TLS_SUPPORT const std::vector IMAPConnection::getCapabilities() { send(true, "CAPABILITY", true); utility::auto_ptr resp(m_parser->readResponse()); std::vector res; if (resp->response_done()->response_tagged()-> resp_cond_state()->status() == IMAPParser::resp_cond_state::OK) { const std::vector & respDataList = resp->continue_req_or_response_data(); for (unsigned int i = 0 ; i < respDataList.size() ; ++i) { if (respDataList[i]->response_data() == NULL) continue; const IMAPParser::capability_data* capaData = respDataList[i]->response_data()->capability_data(); if (capaData == NULL) continue; std::vector caps = capaData->capabilities(); for (unsigned int j = 0 ; j < caps.size() ; ++j) { if (caps[j]->auth_type()) res.push_back("AUTH=" + caps[j]->auth_type()->name()); else res.push_back(caps[j]->atom()->value()); } } } return res; } ref IMAPConnection::getAuthenticator() { return m_auth; } bool IMAPConnection::isConnected() const { return (m_socket && m_socket->isConnected() && (m_state == STATE_AUTHENTICATED || m_state == STATE_SELECTED)); } bool IMAPConnection::isSecuredConnection() const { return m_secured; } ref IMAPConnection::getConnectionInfos() const { return m_cntInfos; } void IMAPConnection::disconnect() { if (!isConnected()) throw exceptions::not_connected(); internalDisconnect(); } void IMAPConnection::internalDisconnect() { if (isConnected()) { send(true, "LOGOUT", true); m_socket->disconnect(); m_socket = NULL; } m_timeoutHandler = NULL; m_state = STATE_LOGOUT; m_secured = false; m_cntInfos = NULL; } void IMAPConnection::initHierarchySeparator() { send(true, "LIST \"\" \"\"", true); vmime::utility::auto_ptr resp(m_parser->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { internalDisconnect(); throw exceptions::command_error("LIST", m_parser->lastLine(), "bad response"); } const std::vector & respDataList = resp->continue_req_or_response_data(); bool found = false; for (unsigned int i = 0 ; !found && i < respDataList.size() ; ++i) { if (respDataList[i]->response_data() == NULL) continue; const IMAPParser::mailbox_data* mailboxData = static_cast (respDataList[i]->response_data())->mailbox_data(); if (mailboxData == NULL || mailboxData->type() != IMAPParser::mailbox_data::LIST) continue; if (mailboxData->mailbox_list()->quoted_char() != '\0') { m_hierarchySeparator = mailboxData->mailbox_list()->quoted_char(); found = true; } } if (!found) // default m_hierarchySeparator = '/'; } void IMAPConnection::send(bool tag, const string& what, bool end) { #if VMIME_DEBUG std::ostringstream oss; if (tag) { ++(*m_tag); oss << string(*m_tag); oss << " "; } oss << what; if (end) oss << "\r\n"; m_socket->send(oss.str()); #else if (tag) { ++(*m_tag); m_socket->send(*m_tag); m_socket->send(" "); } m_socket->send(what); if (end) { m_socket->send("\r\n"); } #endif } void IMAPConnection::sendRaw(const char* buffer, const int count) { m_socket->sendRaw(buffer, count); } IMAPParser::response* IMAPConnection::readResponse(IMAPParser::literalHandler* lh) { return (m_parser->readResponse(lh)); } IMAPConnection::ProtocolStates IMAPConnection::state() const { return (m_state); } void IMAPConnection::setState(const ProtocolStates state) { m_state = state; } char IMAPConnection::hierarchySeparator() const { return (m_hierarchySeparator); } ref IMAPConnection::getTag() const { return (m_tag); } ref IMAPConnection::getParser() const { return (m_parser); } ref IMAPConnection::getStore() const { return m_store.acquire(); } ref IMAPConnection::getStore() { return m_store.acquire(); } ref IMAPConnection::getSession() { return m_store.acquire()->getSession(); } ref IMAPConnection::getSocket() const { return m_socket; } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPServiceInfos.cpp0000644000175000017500000000742311250723263021713 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPServiceInfos.hpp" namespace vmime { namespace net { namespace imap { IMAPServiceInfos::IMAPServiceInfos(const bool imaps) : m_imaps(imaps) { } const string IMAPServiceInfos::getPropertyPrefix() const { if (m_imaps) return "store.imaps."; else return "store.imap."; } const IMAPServiceInfos::props& IMAPServiceInfos::getProperties() const { static props imapProps = { // IMAP-specific options #if VMIME_HAVE_SASL_SUPPORT property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"), property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "true"), #endif // VMIME_HAVE_SASL_SUPPORT // Common properties property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED), #if VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::CONNECTION_TLS), property(serviceInfos::property::CONNECTION_TLS_REQUIRED), #endif // VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::SERVER_PORT, "143"), }; static props imapsProps = { // IMAP-specific options #if VMIME_HAVE_SASL_SUPPORT property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"), property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "true"), #endif // VMIME_HAVE_SASL_SUPPORT // Common properties property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED), #if VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::CONNECTION_TLS), property(serviceInfos::property::CONNECTION_TLS_REQUIRED), #endif // VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::SERVER_PORT, "993"), }; return m_imaps ? imapsProps : imapProps; } const std::vector IMAPServiceInfos::getAvailableProperties() const { std::vector list; const props& p = getProperties(); // IMAP-specific options #if VMIME_HAVE_SASL_SUPPORT list.push_back(p.PROPERTY_OPTIONS_SASL); list.push_back(p.PROPERTY_OPTIONS_SASL_FALLBACK); #endif // VMIME_HAVE_SASL_SUPPORT // Common properties list.push_back(p.PROPERTY_AUTH_USERNAME); list.push_back(p.PROPERTY_AUTH_PASSWORD); #if VMIME_HAVE_TLS_SUPPORT if (!m_imaps) { list.push_back(p.PROPERTY_CONNECTION_TLS); list.push_back(p.PROPERTY_CONNECTION_TLS_REQUIRED); } #endif // VMIME_HAVE_TLS_SUPPORT list.push_back(p.PROPERTY_SERVER_ADDRESS); list.push_back(p.PROPERTY_SERVER_PORT); return list; } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPMessagePartContentHandler.cpp0000644000175000017500000001171111376250564024363 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPMessagePartContentHandler.hpp" namespace vmime { namespace net { namespace imap { IMAPMessagePartContentHandler::IMAPMessagePartContentHandler (ref msg, ref part, const vmime::encoding& encoding) : m_message(msg), m_part(part), m_encoding(encoding) { } ref IMAPMessagePartContentHandler::clone() const { return create (m_message.acquire().constCast (), m_part.acquire().constCast (), m_encoding); } void IMAPMessagePartContentHandler::generate (utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const { ref msg = m_message.acquire().constCast (); ref part = m_part.acquire().constCast (); // Data is already encoded if (isEncoded()) { // The data is already encoded but the encoding specified for // the generation is different from the current one. We need // to re-encode data: decode from input buffer to temporary // buffer, and then re-encode to output stream... if (m_encoding != enc) { // Extract part contents to temporary buffer std::ostringstream oss; utility::outputStreamAdapter tmp(oss); msg->extractPart(part, tmp, NULL); // Decode to another temporary buffer utility::inputStreamStringProxyAdapter in(oss.str()); std::ostringstream oss2; utility::outputStreamAdapter tmp2(oss2); ref theDecoder = m_encoding.getEncoder(); theDecoder->decode(in, tmp2); // Reencode to output stream string str = oss2.str(); utility::inputStreamStringAdapter tempIn(str); ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->encode(tempIn, os); } // No encoding to perform else { msg->extractPart(part, os); } } // Need to encode data before else { // Extract part contents to temporary buffer std::ostringstream oss; utility::outputStreamAdapter tmp(oss); msg->extractPart(part, tmp, NULL); // Encode temporary buffer to output stream ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; utility::inputStreamStringAdapter is(oss.str()); theEncoder->encode(is, os); } } void IMAPMessagePartContentHandler::extract (utility::outputStream& os, utility::progressListener* progress) const { ref msg = m_message.acquire().constCast (); ref part = m_part.acquire().constCast (); // No decoding to perform if (!isEncoded()) { msg->extractPart(part, os, progress); } // Need to decode data else { // Extract part contents to temporary buffer std::ostringstream oss; utility::outputStreamAdapter tmp(oss); msg->extractPart(part, tmp, NULL); // Encode temporary buffer to output stream utility::inputStreamStringAdapter is(oss.str()); utility::progressListenerSizeAdapter plsa(progress, getLength()); ref theDecoder = m_encoding.getEncoder(); theDecoder->decode(is, os, &plsa); } } void IMAPMessagePartContentHandler::extractRaw (utility::outputStream& os, utility::progressListener* progress) const { ref msg = m_message.acquire().constCast (); ref part = m_part.acquire().constCast (); msg->extractPart(part, os, progress); } string::size_type IMAPMessagePartContentHandler::getLength() const { return m_part.acquire()->getSize(); } bool IMAPMessagePartContentHandler::isEncoded() const { return m_encoding != NO_ENCODING; } const vmime::encoding& IMAPMessagePartContentHandler::getEncoding() const { return m_encoding; } bool IMAPMessagePartContentHandler::isEmpty() const { return getLength() == 0; } bool IMAPMessagePartContentHandler::isBuffered() const { return true; } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPStore.cpp0000644000175000017500000001142711250723263020407 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPStore.hpp" #include "vmime/net/imap/IMAPFolder.hpp" #include "vmime/net/imap/IMAPConnection.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" #include namespace vmime { namespace net { namespace imap { IMAPStore::IMAPStore(ref sess, ref auth, const bool secured) : store(sess, getInfosInstance(), auth), m_connection(NULL), m_isIMAPS(secured) { } IMAPStore::~IMAPStore() { try { if (isConnected()) disconnect(); } catch (vmime::exception&) { // Ignore } } const string IMAPStore::getProtocolName() const { return "imap"; } ref IMAPStore::getRootFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (folder::path(), thisRef().dynamicCast ()); } ref IMAPStore::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (folder::path::component("INBOX"), thisRef().dynamicCast ()); } ref IMAPStore::getFolder(const folder::path& path) { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (path, thisRef().dynamicCast ()); } bool IMAPStore::isValidFolderName(const folder::path::component& /* name */) const { return true; } void IMAPStore::connect() { if (isConnected()) throw exceptions::already_connected(); m_connection = vmime::create (thisRef().dynamicCast (), getAuthenticator()); try { m_connection->connect(); } catch (std::exception&) { m_connection = NULL; throw; } } bool IMAPStore::isConnected() const { return (m_connection && m_connection->isConnected()); } bool IMAPStore::isIMAPS() const { return m_isIMAPS; } bool IMAPStore::isSecuredConnection() const { if (m_connection == NULL) return false; return m_connection->isSecuredConnection(); } ref IMAPStore::getConnectionInfos() const { if (m_connection == NULL) return NULL; return m_connection->getConnectionInfos(); } void IMAPStore::disconnect() { if (!isConnected()) throw exceptions::not_connected(); for (std::list ::iterator it = m_folders.begin() ; it != m_folders.end() ; ++it) { (*it)->onStoreDisconnected(); } m_folders.clear(); m_connection->disconnect(); m_connection = NULL; } void IMAPStore::noop() { if (!isConnected()) throw exceptions::not_connected(); m_connection->send(true, "NOOP", true); utility::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("NOOP", m_connection->getParser()->lastLine()); } } ref IMAPStore::connection() { return (m_connection); } void IMAPStore::registerFolder(IMAPFolder* folder) { m_folders.push_back(folder); } void IMAPStore::unregisterFolder(IMAPFolder* folder) { std::list ::iterator it = std::find(m_folders.begin(), m_folders.end(), folder); if (it != m_folders.end()) m_folders.erase(it); } int IMAPStore::getCapabilities() const { return (CAPABILITY_CREATE_FOLDER | CAPABILITY_RENAME_FOLDER | CAPABILITY_ADD_MESSAGE | CAPABILITY_COPY_MESSAGE | CAPABILITY_DELETE_MESSAGE | CAPABILITY_PARTIAL_FETCH | CAPABILITY_MESSAGE_FLAGS | CAPABILITY_EXTRACT_PART); } // Service infos IMAPServiceInfos IMAPStore::sm_infos(false); const serviceInfos& IMAPStore::getInfosInstance() { return sm_infos; } const serviceInfos& IMAPStore::getInfos() const { return sm_infos; } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPStructure.cpp0000644000175000017500000000405111374206636021315 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPStructure.hpp" #include "vmime/net/imap/IMAPPart.hpp" namespace vmime { namespace net { namespace imap { IMAPStructure::IMAPStructure() { } IMAPStructure::IMAPStructure(const IMAPParser::body* body) { m_parts.push_back(IMAPPart::create(NULL, 0, body)); } IMAPStructure::IMAPStructure(ref parent, const std::vector & list) { int number = 0; for (std::vector ::const_iterator it = list.begin() ; it != list.end() ; ++it, ++number) { m_parts.push_back(IMAPPart::create(parent, number, *it)); } } ref IMAPStructure::getPartAt(const int x) const { return m_parts[x]; } ref IMAPStructure::getPartAt(const int x) { return m_parts[x]; } int IMAPStructure::getPartCount() const { return m_parts.size(); } // static ref IMAPStructure::emptyStructure() { static ref emptyStructure = vmime::create (); return emptyStructure; } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPUtils.cpp0000644000175000017500000003512711457315137020424 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPUtils.hpp" #include "vmime/net/message.hpp" #include "vmime/net/folder.hpp" #include #include #include namespace vmime { namespace net { namespace imap { // static const string IMAPUtils::quoteString(const string& text) { // // ATOM_CHAR ::= // // atom_specials ::= "(" / ")" / "{" / SPACE / CTL / // list_wildcards / quoted_specials // // list_wildcards ::= "%" / "*" // // quoted_specials ::= <"> / "\" // // CHAR ::= // // CTL ::= // bool needQuoting = text.empty(); for (string::const_iterator it = text.begin() ; !needQuoting && it != text.end() ; ++it) { const unsigned char c = *it; switch (c) { case '(': case ')': case '{': case 0x20: // SPACE case '%': case '*': case '"': case '\\': needQuoting = true; break; default: if (c <= 0x1f || c >= 0x7f) needQuoting = true; } } if (needQuoting) { string quoted; quoted.reserve((text.length() * 3) / 2 + 2); quoted += '"'; for (string::const_iterator it = text.begin() ; it != text.end() ; ++it) { const unsigned char c = *it; if (c == '\\' || c == '"') quoted += '\\'; quoted += c; } quoted += '"'; return (quoted); } else { return (text); } } const string IMAPUtils::pathToString (const char hierarchySeparator, const folder::path& path) { string result; for (int i = 0 ; i < path.getSize() ; ++i) { if (i > 0) result += hierarchySeparator; result += toModifiedUTF7(hierarchySeparator, path[i]); } return (result); } const folder::path IMAPUtils::stringToPath (const char hierarchySeparator, const string& str) { folder::path result; string::const_iterator begin = str.begin(); for (string::const_iterator it = str.begin() ; it != str.end() ; ++it) { if (*it == hierarchySeparator) { result /= fromModifiedUTF7(string(begin, it)); begin = it + 1; } } if (begin != str.end()) { result /= fromModifiedUTF7(string(begin, str.end())); } return (result); } const string IMAPUtils::toModifiedUTF7 (const char hierarchySeparator, const folder::path::component& text) { // We will replace the hierarchy separator with an equivalent // UTF-7 sequence, so we compute it here... const char base64alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,="; const unsigned int hs = static_cast (static_cast (hierarchySeparator)); string hsUTF7; hsUTF7.resize(3); hsUTF7[0] = base64alphabet[0]; hsUTF7[1] = base64alphabet[(hs & 0xF0) >> 4]; hsUTF7[2] = base64alphabet[(hs & 0x0F) << 2]; // iconv() is buggy with UTF-8 to UTF-7 conversion, so we do it "by hand". // This code is largely inspired from "imap/utf7.c", in mutt 1.4. // Copyright (C) 2000 Edmund Grimley Evans // WARNING: This may throw "exceptions::charset_conv_error" const string cvt = text.getConvertedText(charset(charsets::UTF_8)); // In the worst case we convert 2 chars to 7 chars. // For example: "\x10&\x10&..." -> "&ABA-&-&ABA-&-...". string out; out.reserve((cvt.length() / 2) * 7 + 6); int b = 0, k = 0; bool base64 = false; string::size_type remaining = cvt.length(); for (string::size_type i = 0, len = cvt.length() ; i < len ; ) { const unsigned char c = cvt[i]; // Replace hierarchy separator with an equivalent UTF-7 Base64 sequence if (!base64 && c == hierarchySeparator) { out += "&" + hsUTF7 + "-"; ++i; --remaining; continue; } string::size_type n = 0; int ch = 0; if (c < 0x80) ch = c, n = 0; else if (c < 0xc2) return ""; else if (c < 0xe0) ch = c & 0x1f, n = 1; else if (c < 0xf0) ch = c & 0x0f, n = 2; else if (c < 0xf8) ch = c & 0x07, n = 3; else if (c < 0xfc) ch = c & 0x03, n = 4; else if (c < 0xfe) ch = c & 0x01, n = 5; else return ""; if (n > remaining) return ""; // error ++i; --remaining; for (string::size_type j = 0 ; j < n ; j++) { if ((cvt[i + j] & 0xc0) != 0x80) return ""; // error ch = (ch << 6) | (cvt[i + j] & 0x3f); } if (n > 1 && !(ch >> (n * 5 + 1))) return ""; // error i += n; remaining -= n; if (ch < 0x20 || ch >= 0x7f) { if (!base64) { out += '&'; base64 = true; b = 0; k = 10; } if (ch & ~0xffff) ch = 0xfffe; out += base64alphabet[b | ch >> k]; k -= 6; for ( ; k >= 0 ; k -= 6) out += base64alphabet[(ch >> k) & 0x3f]; b = (ch << (-k)) & 0x3f; k += 16; } else { if (base64) { if (k > 10) out += base64alphabet[b]; out += '-'; base64 = false; } out += static_cast (ch); if (ch == '&') out += '-'; } } if (base64) { if (k > 10) out += base64alphabet[b]; out += '-'; } return (out); } const folder::path::component IMAPUtils::fromModifiedUTF7(const string& text) { // Transcode from modified UTF-7 (RFC-2060). string out; out.reserve(text.length()); bool inB64sequence = false; unsigned char prev = 0; for (string::const_iterator it = text.begin() ; it != text.end() ; ++it) { const unsigned char c = *it; switch (c) { // Start of Base64 sequence case '&': { if (!inB64sequence) { inB64sequence = true; out += '+'; } else { out += '&'; } break; } // End of Base64 sequence (or "&-" --> "&") case '-': { if (inB64sequence && prev == '&') out += '&'; else out += '-'; inB64sequence = false; break; } // ',' is used instead of '/' in modified Base64 case ',': { out += (inB64sequence ? '/' : ','); break; } default: { out += c; break; } } prev = c; } // Store it as UTF-8 by default string cvt; charset::convert(out, cvt, charset(charsets::UTF_7), charset(charsets::UTF_8)); return (folder::path::component(cvt, charset(charsets::UTF_8))); } int IMAPUtils::folderTypeFromFlags(const IMAPParser::mailbox_flag_list* list) { // Get folder type int type = folder::TYPE_CONTAINS_MESSAGES | folder::TYPE_CONTAINS_FOLDERS; const std::vector & flags = list->flags(); for (std::vector ::const_iterator it = flags.begin() ; it != flags.end() ; ++it) { if ((*it)->type() == IMAPParser::mailbox_flag::NOSELECT) type &= ~folder::TYPE_CONTAINS_MESSAGES; } if (type & folder::TYPE_CONTAINS_MESSAGES) type &= ~folder::TYPE_CONTAINS_FOLDERS; return (type); } int IMAPUtils::folderFlagsFromFlags(const IMAPParser::mailbox_flag_list* list) { // Get folder flags int folderFlags = folder::FLAG_CHILDREN; const std::vector & flags = list->flags(); for (std::vector ::const_iterator it = flags.begin() ; it != flags.end() ; ++it) { if ((*it)->type() == IMAPParser::mailbox_flag::NOSELECT) folderFlags |= folder::FLAG_NO_OPEN; else if ((*it)->type() == IMAPParser::mailbox_flag::NOINFERIORS) folderFlags &= ~folder::FLAG_CHILDREN; } return (folderFlags); } int IMAPUtils::messageFlagsFromFlags(const IMAPParser::flag_list* list) { const std::vector & flagList = list->flags(); int flags = 0; for (std::vector ::const_iterator it = flagList.begin() ; it != flagList.end() ; ++it) { switch ((*it)->type()) { case IMAPParser::flag::ANSWERED: flags |= message::FLAG_REPLIED; break; case IMAPParser::flag::FLAGGED: flags |= message::FLAG_MARKED; break; case IMAPParser::flag::DELETED: flags |= message::FLAG_DELETED; break; case IMAPParser::flag::SEEN: flags |= message::FLAG_SEEN; break; case IMAPParser::flag::DRAFT: flags |= message::FLAG_DRAFT; break; default: //case IMAPParser::flag::UNKNOWN: break; } } return (flags); } const string IMAPUtils::messageFlagList(const int flags) { std::vector flagList; if (flags & message::FLAG_REPLIED) flagList.push_back("\\Answered"); if (flags & message::FLAG_MARKED) flagList.push_back("\\Flagged"); if (flags & message::FLAG_DELETED) flagList.push_back("\\Deleted"); if (flags & message::FLAG_SEEN) flagList.push_back("\\Seen"); if (flags & message::FLAG_DRAFT) flagList.push_back("\\Draft"); if (!flagList.empty()) { std::ostringstream res; res.imbue(std::locale::classic()); res << "("; if (flagList.size() >= 2) { std::copy(flagList.begin(), flagList.end() - 1, std::ostream_iterator (res, " ")); } res << *(flagList.end() - 1) << ")"; return (res.str()); } return ""; } // static const string IMAPUtils::listToSet(const std::vector & list, const int max, const bool alreadySorted) { // Sort a copy of the list (if not already sorted) std::vector temp; if (!alreadySorted) { temp.resize(list.size()); std::copy(list.begin(), list.end(), temp.begin()); std::sort(temp.begin(), temp.end()); } const std::vector & theList = (alreadySorted ? list : temp); // Build the set std::ostringstream res; res.imbue(std::locale::classic()); int previous = -1, setBegin = -1; for (std::vector ::const_iterator it = theList.begin() ; it != theList.end() ; ++it) { const int current = *it; if (previous == -1) { res << current; previous = current; setBegin = current; } else { if (current == previous + 1) { previous = current; } else { if (setBegin != previous) { res << ":" << previous << "," << current; previous = current; setBegin = current; } else { if (setBegin != current) // skip duplicates res << "," << current; previous = current; setBegin = current; } } } } if (previous != setBegin) { if (previous == max) res << ":*"; else res << ":" << previous; } return (res.str()); } // static const string IMAPUtils::dateTime(const vmime::datetime& date) { std::ostringstream res; res.imbue(std::locale::classic()); // date_time ::= <"> date_day_fixed "-" date_month "-" date_year // SPACE time SPACE zone <"> // // time ::= 2digit ":" 2digit ":" 2digit // ;; Hours minutes seconds // zone ::= ("+" / "-") 4digit // ;; Signed four-digit value of hhmm representing // ;; hours and minutes west of Greenwich res << '"'; // Date if (date.getDay() < 10) res << ' '; res << date.getDay(); res << '-'; static const char* monthNames[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; res << monthNames[std::min(std::max(date.getMonth() - 1, 0), 11)]; res << '-'; if (date.getYear() < 10) res << '0'; if (date.getYear() < 100) res << '0'; if (date.getYear() < 1000) res << '0'; res << date.getYear(); res << ' '; // Time if (date.getHour() < 10) res << '0'; res << date.getHour() << ':'; if (date.getMinute() < 10) res << '0'; res << date.getMinute() << ':'; if (date.getSecond() < 10) res << '0'; res << date.getSecond(); res << ' '; // Zone const int zs = (date.getZone() < 0 ? -1 : 1); const int zh = (date.getZone() * zs) / 60; const int zm = (date.getZone() * zs) % 60; res << (zs < 0 ? '-' : '+'); if (zh < 10) res << '0'; res << zh; if (zm < 10) res << '0'; res << zm; res << '"'; return (res.str()); } // static const string IMAPUtils::buildFetchRequest(const std::vector & list, const int options) { // Example: // C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) // S: * 2 FETCH .... // S: * 3 FETCH .... // S: * 4 FETCH .... // S: A654 OK FETCH completed std::vector items; if (options & folder::FETCH_SIZE) items.push_back("RFC822.SIZE"); if (options & folder::FETCH_FLAGS) items.push_back("FLAGS"); if (options & folder::FETCH_STRUCTURE) items.push_back("BODYSTRUCTURE"); if (options & folder::FETCH_UID) items.push_back("UID"); if (options & folder::FETCH_FULL_HEADER) items.push_back("RFC822.HEADER"); else { if (options & folder::FETCH_ENVELOPE) items.push_back("ENVELOPE"); std::vector headerFields; if (options & folder::FETCH_CONTENT_INFO) headerFields.push_back("CONTENT_TYPE"); if (options & folder::FETCH_IMPORTANCE) { headerFields.push_back("IMPORTANCE"); headerFields.push_back("X-PRIORITY"); } if (!headerFields.empty()) { string list; for (std::vector ::iterator it = headerFields.begin() ; it != headerFields.end() ; ++it) { if (it != headerFields.begin()) list += " "; list += *it; } items.push_back("BODY[HEADER.FIELDS (" + list + ")]"); } } // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "FETCH " << listToSet(list, -1, false) << " ("; for (std::vector ::const_iterator it = items.begin() ; it != items.end() ; ++it) { if (it != items.begin()) command << " "; command << *it; } command << ")"; return command.str(); } // static void IMAPUtils::convertAddressList (const IMAPParser::address_list& src, mailboxList& dest) { for (std::vector ::const_iterator it = src.addresses().begin() ; it != src.addresses().end() ; ++it) { const IMAPParser::address& addr = **it; text name; text::decodeAndUnfold(addr.addr_name()->value(), &name); string email = addr.addr_mailbox()->value() + "@" + addr.addr_host()->value(); dest.appendMailbox(vmime::create (name, email)); } } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPPart.cpp0000644000175000017500000000704011374206611020215 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPPart.hpp" #include "vmime/net/imap/IMAPStructure.hpp" namespace vmime { namespace net { namespace imap { IMAPPart::IMAPPart(ref parent, const int number, const IMAPParser::body_type_mpart* mpart) : m_parent(parent), m_header(NULL), m_number(number), m_size(0) { m_mediaType = vmime::mediaType ("multipart", mpart->media_subtype()->value()); } IMAPPart::IMAPPart(ref parent, const int number, const IMAPParser::body_type_1part* part) : m_parent(parent), m_header(NULL), m_number(number), m_size(0) { if (part->body_type_text()) { m_mediaType = vmime::mediaType ("text", part->body_type_text()-> media_text()->media_subtype()->value()); m_size = part->body_type_text()->body_fields()->body_fld_octets()->value(); } else if (part->body_type_msg()) { m_mediaType = vmime::mediaType ("message", part->body_type_msg()-> media_message()->media_subtype()->value()); } else { m_mediaType = vmime::mediaType (part->body_type_basic()->media_basic()->media_type()->value(), part->body_type_basic()->media_basic()->media_subtype()->value()); m_size = part->body_type_basic()->body_fields()->body_fld_octets()->value(); } m_structure = NULL; } ref IMAPPart::getStructure() const { if (m_structure != NULL) return m_structure; else return IMAPStructure::emptyStructure(); } ref IMAPPart::getStructure() { if (m_structure != NULL) return m_structure; else return IMAPStructure::emptyStructure(); } ref IMAPPart::getParent() const { return m_parent.acquire(); } const mediaType& IMAPPart::getType() const { return m_mediaType; } int IMAPPart::getSize() const { return m_size; } int IMAPPart::getNumber() const { return m_number; } ref IMAPPart::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); else return m_header; } // static ref IMAPPart::create (ref parent, const int number, const IMAPParser::body* body) { if (body->body_type_mpart()) { ref part = vmime::create (parent, number, body->body_type_mpart()); part->m_structure = vmime::create (part, body->body_type_mpart()->list()); return part; } else { return vmime::create (parent, number, body->body_type_1part()); } } header& IMAPPart::getOrCreateHeader() { if (m_header != NULL) return *m_header; else return *(m_header = vmime::create
()); } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPMessage.cpp0000644000175000017500000004202211457315347020703 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPParser.hpp" #include "vmime/net/imap/IMAPMessage.hpp" #include "vmime/net/imap/IMAPFolder.hpp" #include "vmime/net/imap/IMAPStore.hpp" #include "vmime/net/imap/IMAPConnection.hpp" #include "vmime/net/imap/IMAPUtils.hpp" #include "vmime/net/imap/IMAPStructure.hpp" #include "vmime/net/imap/IMAPPart.hpp" #include "vmime/net/imap/IMAPMessagePartContentHandler.hpp" #include #include #include namespace vmime { namespace net { namespace imap { #ifndef VMIME_BUILDING_DOC // // IMAPMessage_literalHandler // class IMAPMessage_literalHandler : public IMAPParser::literalHandler { public: IMAPMessage_literalHandler(utility::outputStream& os, utility::progressListener* progress) : m_os(os), m_progress(progress) { } target* targetFor(const IMAPParser::component& comp, const int /* data */) { if (typeid(comp) == typeid(IMAPParser::msg_att_item)) { const int type = static_cast (comp).type(); if (type == IMAPParser::msg_att_item::BODY_SECTION || type == IMAPParser::msg_att_item::RFC822_TEXT) { return new targetStream(m_progress, m_os); } } return (NULL); } private: utility::outputStream& m_os; utility::progressListener* m_progress; }; #endif // VMIME_BUILDING_DOC // // IMAPMessage // IMAPMessage::IMAPMessage(ref folder, const int num) : m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED), m_expunged(false), m_structure(NULL) { folder->registerMessage(this); } IMAPMessage::~IMAPMessage() { ref folder = m_folder.acquire(); if (folder) folder->unregisterMessage(this); } void IMAPMessage::onFolderClosed() { m_folder = NULL; } int IMAPMessage::getNumber() const { return (m_num); } const message::uid IMAPMessage::getUniqueId() const { return (m_uid); } int IMAPMessage::getSize() const { if (m_size == -1) throw exceptions::unfetched_object(); return (m_size); } bool IMAPMessage::isExpunged() const { return (m_expunged); } int IMAPMessage::getFlags() const { if (m_flags == FLAG_UNDEFINED) throw exceptions::unfetched_object(); return (m_flags); } ref IMAPMessage::getStructure() const { if (m_structure == NULL) throw exceptions::unfetched_object(); return m_structure; } ref IMAPMessage::getStructure() { if (m_structure == NULL) throw exceptions::unfetched_object(); return m_structure; } ref IMAPMessage::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); return (m_header); } void IMAPMessage::extract(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { ref folder = m_folder.acquire(); if (!folder) throw exceptions::folder_not_found(); extract(NULL, os, progress, start, length, false, peek); } void IMAPMessage::extractPart (ref p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { ref folder = m_folder.acquire(); if (!folder) throw exceptions::folder_not_found(); extract(p, os, progress, start, length, false, peek); } void IMAPMessage::fetchPartHeader(ref p) { ref folder = m_folder.acquire(); if (!folder) throw exceptions::folder_not_found(); std::ostringstream oss; utility::outputStreamAdapter ossAdapter(oss); extract(p, ossAdapter, NULL, 0, -1, true, true); p.dynamicCast ()->getOrCreateHeader().parse(oss.str()); } void IMAPMessage::fetchPartHeaderForStructure(ref str) { for (int i = 0, n = str->getPartCount() ; i < n ; ++i) { ref part = str->getPartAt(i); // Fetch header of current part fetchPartHeader(part); // Fetch header of sub-parts fetchPartHeaderForStructure(part->getStructure()); } } void IMAPMessage::extract(ref p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool headerOnly, const bool peek) const { ref folder = m_folder.acquire(); IMAPMessage_literalHandler literalHandler(os, progress); // Construct section identifier std::ostringstream section; section.imbue(std::locale::classic()); if (p != NULL) { ref currentPart = p.dynamicCast (); std::vector numbers; numbers.push_back(currentPart->getNumber()); currentPart = currentPart->getParent(); while (currentPart != NULL) { numbers.push_back(currentPart->getNumber()); currentPart = currentPart->getParent(); } numbers.erase(numbers.end() - 1); for (std::vector ::reverse_iterator it = numbers.rbegin() ; it != numbers.rend() ; ++it) { if (it != numbers.rbegin()) section << "."; section << (*it + 1); } } // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "FETCH " << m_num << " BODY"; if (peek) command << ".PEEK"; command << "["; if (section.str().empty()) { if (headerOnly) command << "HEADER"; else command << "TEXT"; } else { command << section.str(); if (headerOnly) command << ".MIME"; // "MIME" not "HEADER" for parts } command << "]"; if (start != 0 || length != -1) command << "<" << start << "." << length << ">"; // Send the request folder.constCast ()->m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp (folder.constCast ()->m_connection->readResponse(&literalHandler)); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("FETCH", folder.constCast ()->m_connection->getParser()->lastLine(), "bad response"); } if (!headerOnly) { // TODO: update the flags (eg. flag "\Seen" may have been set) } } void IMAPMessage::fetch(ref msgFolder, const int options) { ref folder = m_folder.acquire(); if (folder != msgFolder) throw exceptions::folder_not_found(); // Send the request std::vector list; list.push_back(m_num); const string command = IMAPUtils::buildFetchRequest(list, options); folder->m_connection->send(true, command, true); // Get the response utility::auto_ptr resp(folder->m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("FETCH", folder->m_connection->getParser()->lastLine(), "bad response"); } const std::vector & respDataList = resp->continue_req_or_response_data(); for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) { throw exceptions::command_error("FETCH", folder->m_connection->getParser()->lastLine(), "invalid response"); } const IMAPParser::message_data* messageData = (*it)->response_data()->message_data(); // We are only interested in responses of type "FETCH" if (messageData == NULL || messageData->type() != IMAPParser::message_data::FETCH) continue; if (static_cast (messageData->number()) != m_num) continue; // Process fetch response for this message processFetchResponse(options, messageData->msg_att()); } } void IMAPMessage::processFetchResponse (const int options, const IMAPParser::msg_att* msgAtt) { ref folder = m_folder.acquire(); // Get message attributes const std::vector atts = msgAtt->items(); int flags = 0; for (std::vector ::const_iterator it = atts.begin() ; it != atts.end() ; ++it) { switch ((*it)->type()) { case IMAPParser::msg_att_item::FLAGS: { flags |= IMAPUtils::messageFlagsFromFlags((*it)->flag_list()); break; } case IMAPParser::msg_att_item::UID: { std::ostringstream oss; oss.imbue(std::locale::classic()); oss << folder->m_uidValidity << ":" << (*it)->unique_id()->value(); m_uid = oss.str(); break; } case IMAPParser::msg_att_item::ENVELOPE: { if (!(options & folder::FETCH_FULL_HEADER)) { const IMAPParser::envelope* env = (*it)->envelope(); ref hdr = getOrCreateHeader(); // Date hdr->Date()->setValue(env->env_date()->value()); // Subject text subject; text::decodeAndUnfold(env->env_subject()->value(), &subject); hdr->Subject()->setValue(subject); // From mailboxList from; IMAPUtils::convertAddressList(*(env->env_from()), from); if (!from.isEmpty()) hdr->From()->setValue(*(from.getMailboxAt(0))); // To mailboxList to; IMAPUtils::convertAddressList(*(env->env_to()), to); hdr->To()->setValue(to); // Sender mailboxList sender; IMAPUtils::convertAddressList(*(env->env_sender()), sender); if (!sender.isEmpty()) hdr->Sender()->setValue(*(sender.getMailboxAt(0))); // Reply-to mailboxList replyTo; IMAPUtils::convertAddressList(*(env->env_reply_to()), replyTo); if (!replyTo.isEmpty()) hdr->ReplyTo()->setValue(*(replyTo.getMailboxAt(0))); // Cc mailboxList cc; IMAPUtils::convertAddressList(*(env->env_cc()), cc); if (!cc.isEmpty()) hdr->Cc()->setValue(cc); // Bcc mailboxList bcc; IMAPUtils::convertAddressList(*(env->env_bcc()), bcc); if (!bcc.isEmpty()) hdr->Bcc()->setValue(bcc); } break; } case IMAPParser::msg_att_item::BODY_STRUCTURE: { m_structure = vmime::create ((*it)->body()); break; } case IMAPParser::msg_att_item::RFC822_HEADER: { getOrCreateHeader()->parse((*it)->nstring()->value()); break; } case IMAPParser::msg_att_item::RFC822_SIZE: { m_size = (*it)->number()->value(); break; } case IMAPParser::msg_att_item::BODY_SECTION: { if (!(options & folder::FETCH_FULL_HEADER)) { if ((*it)->section()->section_text1() && (*it)->section()->section_text1()->type() == IMAPParser::section_text::HEADER_FIELDS) { header tempHeader; tempHeader.parse((*it)->nstring()->value()); vmime::header& hdr = *getOrCreateHeader(); std::vector > fields = tempHeader.getFieldList(); for (std::vector >::const_iterator jt = fields.begin() ; jt != fields.end() ; ++jt) { hdr.appendField((*jt)->clone().dynamicCast ()); } } } break; } case IMAPParser::msg_att_item::INTERNALDATE: case IMAPParser::msg_att_item::RFC822: case IMAPParser::msg_att_item::RFC822_TEXT: case IMAPParser::msg_att_item::BODY: { break; } } } if (options & folder::FETCH_FLAGS) m_flags = flags; } ref
IMAPMessage::getOrCreateHeader() { if (m_header != NULL) return (m_header); else return (m_header = vmime::create
()); } void IMAPMessage::setFlags(const int flags, const int mode) { ref folder = m_folder.acquire(); if (!folder) throw exceptions::folder_not_found(); else if (folder->m_mode == folder::MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Build the request text std::ostringstream command; command.imbue(std::locale::classic()); command << "STORE " << m_num; switch (mode) { case FLAG_MODE_ADD: command << " +FLAGS"; break; case FLAG_MODE_REMOVE: command << " -FLAGS"; break; default: case FLAG_MODE_SET: command << " FLAGS"; break; } if (m_flags == FLAG_UNDEFINED) // Update local flags only if they command << ".SILENT "; // have been fetched previously else command << " "; std::vector flagList; if (flags & FLAG_REPLIED) flagList.push_back("\\Answered"); if (flags & FLAG_MARKED) flagList.push_back("\\Flagged"); if (flags & FLAG_DELETED) flagList.push_back("\\Deleted"); if (flags & FLAG_SEEN) flagList.push_back("\\Seen"); if (flags & FLAG_DRAFT) flagList.push_back("\\Draft"); if (!flagList.empty()) { command << "("; if (flagList.size() >= 2) { std::copy(flagList.begin(), flagList.end() - 1, std::ostream_iterator (command, " ")); } command << *(flagList.end() - 1) << ")"; // Send the request folder->m_connection->send(true, command.str(), true); // Get the response utility::auto_ptr resp(folder->m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) { throw exceptions::command_error("STORE", folder->m_connection->getParser()->lastLine(), "bad response"); } // Update the local flags for this message if (m_flags != FLAG_UNDEFINED) { const std::vector & respDataList = resp->continue_req_or_response_data(); int newFlags = 0; for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) { if ((*it)->response_data() == NULL) continue; const IMAPParser::message_data* messageData = (*it)->response_data()->message_data(); // We are only interested in responses of type "FETCH" if (messageData == NULL || messageData->type() != IMAPParser::message_data::FETCH) continue; // Get message attributes const std::vector atts = messageData->msg_att()->items(); for (std::vector ::const_iterator it = atts.begin() ; it != atts.end() ; ++it) { if ((*it)->type() == IMAPParser::msg_att_item::FLAGS) newFlags |= IMAPUtils::messageFlagsFromFlags((*it)->flag_list()); } } m_flags = newFlags; } // Notify message flags changed std::vector nums; nums.push_back(m_num); events::messageChangedEvent event (folder, events::messageChangedEvent::TYPE_FLAGS, nums); for (std::list ::iterator it = folder->m_store.acquire()->m_folders.begin() ; it != folder->m_store.acquire()->m_folders.end() ; ++it) { if ((*it)->getFullPath() == folder->m_path) (*it)->notifyMessageChanged(event); } } } void IMAPMessage::constructParsedMessage(ref parentPart, ref str, int level) { if (level == 0) { ref part = str->getPartAt(0); // Copy header ref hdr = part->getHeader(); parentPart->getHeader()->copyFrom(*hdr); // Initialize body parentPart->getBody()->setContents (vmime::create (thisRef().dynamicCast (), part, parentPart->getBody()->getEncoding())); constructParsedMessage(parentPart, part->getStructure(), 1); } else { for (int i = 0, n = str->getPartCount() ; i < n ; ++i) { ref part = str->getPartAt(i); ref childPart = vmime::create (); // Copy header ref hdr = part->getHeader(); childPart->getHeader()->copyFrom(*hdr); // Initialize body childPart->getBody()->setContents (vmime::create (thisRef().dynamicCast (), part, childPart->getBody()->getEncoding())); // Add child part parentPart->getBody()->appendPart(childPart); // Construct sub parts constructParsedMessage(childPart, part->getStructure(), ++level); } } } ref IMAPMessage::getParsedMessage() { // Fetch structure ref structure = NULL; try { structure = getStructure(); } catch (exceptions::unfetched_object&) { fetch(m_folder.acquire(), IMAPFolder::FETCH_STRUCTURE); structure = getStructure(); } // Fetch header for each part fetchPartHeaderForStructure(structure); // Construct message from structure ref msg = vmime::create (); constructParsedMessage(msg, structure); return msg; } } // imap } // net } // vmime libvmime-0.9.1/src/net/imap/IMAPTag.cpp0000644000175000017500000000415311250723263020024 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/imap/IMAPTag.hpp" namespace vmime { namespace net { namespace imap { const int IMAPTag::sm_maxNumber = 52 * 10 * 10 * 10; IMAPTag::IMAPTag(const int number) : m_number(number) { m_tag.resize(4); } IMAPTag::IMAPTag(const IMAPTag& tag) : object(), m_number(tag.m_number) { m_tag.resize(4); } IMAPTag::IMAPTag() : m_number(0) { m_tag.resize(4); } IMAPTag& IMAPTag::operator++() { ++m_number; if (m_number >= sm_maxNumber) m_number = 1; generate(); return (*this); } const IMAPTag IMAPTag::operator++(int) { IMAPTag old(*this); operator++(); return (old); } int IMAPTag::number() const { return (m_number); } IMAPTag::operator string() const { return (m_tag); } void IMAPTag::generate() { static const char prefixChars[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; m_tag[0] = prefixChars[m_number / 1000]; m_tag[1] = static_cast ('0' + (m_number % 1000) / 100); m_tag[2] = static_cast ('0' + (m_number % 100) / 10); m_tag[3] = static_cast ('0' + m_number % 10); } } // imap } // net } // vmime libvmime-0.9.1/src/net/pop3/0000755000175000017500000000000011607302336016066 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/pop3/POP3ServiceInfos.cpp0000644000175000017500000001023611250723263021635 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/pop3/POP3ServiceInfos.hpp" namespace vmime { namespace net { namespace pop3 { POP3ServiceInfos::POP3ServiceInfos(const bool pop3s) : m_pop3s(pop3s) { } const string POP3ServiceInfos::getPropertyPrefix() const { if (m_pop3s) return "store.pop3s."; else return "store.pop3."; } const POP3ServiceInfos::props& POP3ServiceInfos::getProperties() const { static props pop3Props = { // POP3-specific options property("options.apop", serviceInfos::property::TYPE_BOOL, "true"), property("options.apop.fallback", serviceInfos::property::TYPE_BOOL, "true"), #if VMIME_HAVE_SASL_SUPPORT property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"), property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "true"), #endif // VMIME_HAVE_SASL_SUPPORT // Common properties property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED), #if VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::CONNECTION_TLS), property(serviceInfos::property::CONNECTION_TLS_REQUIRED), #endif // VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::SERVER_PORT, "110"), }; static props pop3sProps = { // POP3-specific options property("options.apop", serviceInfos::property::TYPE_BOOL, "true"), property("options.apop.fallback", serviceInfos::property::TYPE_BOOL, "true"), #if VMIME_HAVE_SASL_SUPPORT property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"), property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "true"), #endif // VMIME_HAVE_SASL_SUPPORT // Common properties property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED), #if VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::CONNECTION_TLS), property(serviceInfos::property::CONNECTION_TLS_REQUIRED), #endif // VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::SERVER_PORT, "995"), }; return m_pop3s ? pop3sProps : pop3Props; } const std::vector POP3ServiceInfos::getAvailableProperties() const { std::vector list; const props& p = getProperties(); // POP3-specific options list.push_back(p.PROPERTY_OPTIONS_APOP); list.push_back(p.PROPERTY_OPTIONS_APOP_FALLBACK); #if VMIME_HAVE_SASL_SUPPORT list.push_back(p.PROPERTY_OPTIONS_SASL); list.push_back(p.PROPERTY_OPTIONS_SASL_FALLBACK); #endif // VMIME_HAVE_SASL_SUPPORT // Common properties list.push_back(p.PROPERTY_AUTH_USERNAME); list.push_back(p.PROPERTY_AUTH_PASSWORD); #if VMIME_HAVE_TLS_SUPPORT if (!m_pop3s) { list.push_back(p.PROPERTY_CONNECTION_TLS); list.push_back(p.PROPERTY_CONNECTION_TLS_REQUIRED); } #endif // VMIME_HAVE_TLS_SUPPORT list.push_back(p.PROPERTY_SERVER_ADDRESS); list.push_back(p.PROPERTY_SERVER_PORT); return list; } } // pop3 } // net } // vmime libvmime-0.9.1/src/net/pop3/POP3SStore.cpp0000644000175000017500000000312611250723263020455 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/pop3/POP3SStore.hpp" namespace vmime { namespace net { namespace pop3 { POP3SStore::POP3SStore(ref sess, ref auth) : POP3Store(sess, auth, true) { } POP3SStore::~POP3SStore() { } const string POP3SStore::getProtocolName() const { return "pop3s"; } // Service infos POP3ServiceInfos POP3SStore::sm_infos(true); const serviceInfos& POP3SStore::getInfosInstance() { return sm_infos; } const serviceInfos& POP3SStore::getInfos() const { return sm_infos; } } // pop3 } // net } // vmime libvmime-0.9.1/src/net/pop3/POP3Folder.cpp0000644000175000017500000004473711250723263020466 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/pop3/POP3Folder.hpp" #include "vmime/net/pop3/POP3Store.hpp" #include "vmime/net/pop3/POP3Message.hpp" #include "vmime/net/pop3/POP3Utils.hpp" #include "vmime/exception.hpp" namespace vmime { namespace net { namespace pop3 { POP3Folder::POP3Folder(const folder::path& path, ref store) : m_store(store), m_path(path), m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1), m_open(false) { store->registerFolder(this); } POP3Folder::~POP3Folder() { ref store = m_store.acquire(); if (store) { if (m_open) close(false); store->unregisterFolder(this); } else if (m_open) { onClose(); } } int POP3Folder::getMode() const { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); return (m_mode); } int POP3Folder::getType() { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); if (m_path.isEmpty()) return (TYPE_CONTAINS_FOLDERS); else if (m_path.getSize() == 1 && m_path[0].getBuffer() == "INBOX") return (TYPE_CONTAINS_MESSAGES); else throw exceptions::folder_not_found(); } int POP3Folder::getFlags() { return (0); } const folder::path::component POP3Folder::getName() const { return (m_name); } const folder::path POP3Folder::getFullPath() const { return (m_path); } void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (m_path.isEmpty()) { if (mode != MODE_READ_ONLY && failIfModeIsNotAvailable) throw exceptions::operation_not_supported(); m_open = true; m_mode = mode; m_messageCount = 0; } else if (m_path.getSize() == 1 && m_path[0].getBuffer() == "INBOX") { store->sendRequest("STAT"); string response; store->readResponse(response, false); if (!store->isSuccessResponse(response)) throw exceptions::command_error("STAT", response); store->stripResponseCode(response, response); std::istringstream iss(response); iss >> m_messageCount; if (iss.fail()) throw exceptions::invalid_response("STAT", response); m_open = true; m_mode = mode; } else { throw exceptions::folder_not_found(); } } void POP3Folder::close(const bool expunge) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (!isOpen()) throw exceptions::illegal_state("Folder not open"); if (!expunge) { store->sendRequest("RSET"); string response; store->readResponse(response, false); } m_open = false; m_mode = -1; onClose(); } void POP3Folder::onClose() { for (MessageMap::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) (*it).first->onFolderClosed(); m_messages.clear(); } void POP3Folder::create(const int /* type */) { throw exceptions::operation_not_supported(); } void POP3Folder::destroy() { throw exceptions::operation_not_supported(); } bool POP3Folder::exists() { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); return (m_path.isEmpty() || (m_path.getSize() == 1 && m_path[0].getBuffer() == "INBOX")); } bool POP3Folder::isOpen() const { return (m_open); } ref POP3Folder::getMessage(const int num) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (num < 1 || num > m_messageCount) throw exceptions::message_not_found(); return vmime::create (thisRef().dynamicCast (), num); } std::vector > POP3Folder::getMessages(const int from, const int to) { ref store = m_store.acquire(); const int to2 = (to == -1 ? m_messageCount : to); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (to2 < from || from < 1 || to2 < 1 || from > m_messageCount || to2 > m_messageCount) throw exceptions::message_not_found(); std::vector > v; ref thisFolder = thisRef().dynamicCast (); for (int i = from ; i <= to2 ; ++i) v.push_back(vmime::create (thisFolder, i)); return (v); } std::vector > POP3Folder::getMessages(const std::vector & nums) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); std::vector > v; ref thisFolder = thisRef().dynamicCast (); for (std::vector ::const_iterator it = nums.begin() ; it != nums.end() ; ++it) { if (*it < 1|| *it > m_messageCount) throw exceptions::message_not_found(); v.push_back(vmime::create (thisFolder, *it)); } return (v); } int POP3Folder::getMessageCount() { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); return (m_messageCount); } ref POP3Folder::getFolder(const folder::path::component& name) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); return vmime::create (m_path / name, store); } std::vector > POP3Folder::getFolders(const bool /* recursive */) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (m_path.isEmpty()) { std::vector > v; v.push_back(vmime::create (folder::path::component("INBOX"), store)); return (v); } else { std::vector > v; return (v); } } void POP3Folder::fetchMessages(std::vector >& msg, const int options, utility::progressListener* progress) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); const int total = msg.size(); int current = 0; if (progress) progress->start(total); for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { (*it).dynamicCast ()->fetch (thisRef().dynamicCast (), options); if (progress) progress->progress(++current, total); } if (options & FETCH_SIZE) { // Send the "LIST" command std::ostringstream command; command << "LIST"; store->sendRequest(command.str()); // Get the response string response; store->readResponse(response, true, NULL); if (store->isSuccessResponse(response)) { store->stripFirstLine(response, response, NULL); // C: LIST // S: +OK // S: 1 47548 // S: 2 12653 // S: . std::map result; POP3Utils::parseMultiListOrUidlResponse(response, result); for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { ref m = (*it).dynamicCast (); std::map ::const_iterator x = result.find(m->m_num); if (x != result.end()) { int size = 0; std::istringstream iss((*x).second); iss >> size; m->m_size = size; } } } } if (options & FETCH_UID) { // Send the "UIDL" command std::ostringstream command; command << "UIDL"; store->sendRequest(command.str()); // Get the response string response; store->readResponse(response, true, NULL); if (store->isSuccessResponse(response)) { store->stripFirstLine(response, response, NULL); // C: UIDL // S: +OK // S: 1 whqtswO00WBw418f9t5JxYwZ // S: 2 QhdPYR:00WBw1Ph7x7 // S: . std::map result; POP3Utils::parseMultiListOrUidlResponse(response, result); for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { ref m = (*it).dynamicCast (); std::map ::const_iterator x = result.find(m->m_num); if (x != result.end()) m->m_uid = (*x).second; } } } if (progress) progress->stop(total); } void POP3Folder::fetchMessage(ref msg, const int options) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); msg.dynamicCast ()->fetch (thisRef().dynamicCast (), options); if (options & FETCH_SIZE) { // Send the "LIST" command std::ostringstream command; command.imbue(std::locale::classic()); command << "LIST " << msg->getNumber(); store->sendRequest(command.str()); // Get the response string response; store->readResponse(response, false, NULL); if (store->isSuccessResponse(response)) { store->stripResponseCode(response, response); // C: LIST 2 // S: +OK 2 4242 string::iterator it = response.begin(); while (it != response.end() && (*it == ' ' || *it == '\t')) ++it; while (it != response.end() && !(*it == ' ' || *it == '\t')) ++it; while (it != response.end() && (*it == ' ' || *it == '\t')) ++it; if (it != response.end()) { int size = 0; std::istringstream iss(string(it, response.end())); iss >> size; msg.dynamicCast ()->m_size = size; } } } if (options & FETCH_UID) { // Send the "UIDL" command std::ostringstream command; command.imbue(std::locale::classic()); command << "UIDL " << msg->getNumber(); store->sendRequest(command.str()); // Get the response string response; store->readResponse(response, false, NULL); if (store->isSuccessResponse(response)) { store->stripResponseCode(response, response); // C: UIDL 2 // S: +OK 2 QhdPYR:00WBw1Ph7x7 string::iterator it = response.begin(); while (it != response.end() && (*it == ' ' || *it == '\t')) ++it; while (it != response.end() && !(*it == ' ' || *it == '\t')) ++it; while (it != response.end() && (*it == ' ' || *it == '\t')) ++it; if (it != response.end()) { msg.dynamicCast ()->m_uid = string(it, response.end()); } } } } int POP3Folder::getFetchCapabilities() const { return (FETCH_ENVELOPE | FETCH_CONTENT_INFO | FETCH_SIZE | FETCH_FULL_HEADER | FETCH_UID | FETCH_IMPORTANCE); } ref POP3Folder::getParent() { if (m_path.isEmpty()) return NULL; else return vmime::create (m_path.getParent(), m_store.acquire()); } ref POP3Folder::getStore() const { return m_store.acquire(); } ref POP3Folder::getStore() { return m_store.acquire(); } void POP3Folder::registerMessage(POP3Message* msg) { m_messages.insert(MessageMap::value_type(msg, msg->getNumber())); } void POP3Folder::unregisterMessage(POP3Message* msg) { m_messages.erase(msg); } void POP3Folder::onStoreDisconnected() { m_store = NULL; } void POP3Folder::deleteMessage(const int num) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); std::ostringstream command; command.imbue(std::locale::classic()); command << "DELE " << num; store->sendRequest(command.str()); string response; store->readResponse(response, false); if (!store->isSuccessResponse(response)) throw exceptions::command_error("DELE", response); // Update local flags for (std::map ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { POP3Message* msg = (*it).first; if (msg->getNumber() == num) msg->m_deleted = true; } // Notify message flags changed std::vector nums; nums.push_back(num); events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); } void POP3Folder::deleteMessages(const int from, const int to) { ref store = m_store.acquire(); if (from < 1 || (to < from && to != -1)) throw exceptions::invalid_argument(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); const int to2 = (to == -1 ? m_messageCount : to); for (int i = from ; i <= to2 ; ++i) { std::ostringstream command; command.imbue(std::locale::classic()); command << "DELE " << i; store->sendRequest(command.str()); string response; store->readResponse(response, false); if (!store->isSuccessResponse(response)) throw exceptions::command_error("DELE", response); } // Update local flags for (std::map ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { POP3Message* msg = (*it).first; if (msg->getNumber() >= from && msg->getNumber() <= to2) msg->m_deleted = true; } // Notify message flags changed std::vector nums; for (int i = from ; i <= to2 ; ++i) nums.push_back(i); events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); } void POP3Folder::deleteMessages(const std::vector & nums) { ref store = m_store.acquire(); if (nums.empty()) throw exceptions::invalid_argument(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); for (std::vector ::const_iterator it = nums.begin() ; it != nums.end() ; ++it) { std::ostringstream command; command.imbue(std::locale::classic()); command << "DELE " << (*it); store->sendRequest(command.str()); string response; store->readResponse(response, false); if (!store->isSuccessResponse(response)) throw exceptions::command_error("DELE", response); } // Sort message list std::vector list; list.resize(nums.size()); std::copy(nums.begin(), nums.end(), list.begin()); std::sort(list.begin(), list.end()); // Update local flags for (std::map ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { POP3Message* msg = (*it).first; if (std::binary_search(list.begin(), list.end(), msg->getNumber())) msg->m_deleted = true; } // Notify message flags changed events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, list); notifyMessageChanged(event); } void POP3Folder::setMessageFlags(const int /* from */, const int /* to */, const int /* flags */, const int /* mode */) { throw exceptions::operation_not_supported(); } void POP3Folder::setMessageFlags(const std::vector & /* nums */, const int /* flags */, const int /* mode */) { throw exceptions::operation_not_supported(); } void POP3Folder::rename(const folder::path& /* newPath */) { throw exceptions::operation_not_supported(); } void POP3Folder::addMessage(ref /* msg */, const int /* flags */, vmime::datetime* /* date */, utility::progressListener* /* progress */) { throw exceptions::operation_not_supported(); } void POP3Folder::addMessage(utility::inputStream& /* is */, const int /* size */, const int /* flags */, vmime::datetime* /* date */, utility::progressListener* /* progress */) { throw exceptions::operation_not_supported(); } void POP3Folder::copyMessage(const folder::path& /* dest */, const int /* num */) { throw exceptions::operation_not_supported(); } void POP3Folder::copyMessages(const folder::path& /* dest */, const int /* from */, const int /* to */) { throw exceptions::operation_not_supported(); } void POP3Folder::copyMessages(const folder::path& /* dest */, const std::vector & /* nums */) { throw exceptions::operation_not_supported(); } void POP3Folder::status(int& count, int& unseen) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); store->sendRequest("STAT"); string response; store->readResponse(response, false); if (!store->isSuccessResponse(response)) throw exceptions::command_error("STAT", response); store->stripResponseCode(response, response); std::istringstream iss(response); iss >> count; unseen = count; // Update local message count if (m_messageCount != count) { const int oldCount = m_messageCount; m_messageCount = count; if (count > oldCount) { std::vector nums; nums.reserve(count - oldCount); for (int i = oldCount + 1, j = 0 ; i <= count ; ++i, ++j) nums[j] = i; // Notify message count changed events::messageCountEvent event (thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == m_path) { (*it)->m_messageCount = count; events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); } } } } } void POP3Folder::expunge() { // Not supported by POP3 protocol (deleted messages are automatically // expunged at the end of the session...). } } // pop3 } // net } // vmime libvmime-0.9.1/src/net/pop3/POP3Message.cpp0000644000175000017500000001242111374321372020622 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/pop3/POP3Message.hpp" #include "vmime/net/pop3/POP3Folder.hpp" #include "vmime/net/pop3/POP3Store.hpp" #include namespace vmime { namespace net { namespace pop3 { POP3Message::POP3Message(ref folder, const int num) : m_folder(folder), m_num(num), m_size(-1), m_deleted(false) { folder->registerMessage(this); } POP3Message::~POP3Message() { ref folder = m_folder.acquire(); if (folder) folder->unregisterMessage(this); } void POP3Message::onFolderClosed() { m_folder = NULL; } int POP3Message::getNumber() const { return (m_num); } const message::uid POP3Message::getUniqueId() const { return (m_uid); } int POP3Message::getSize() const { if (m_size == -1) throw exceptions::unfetched_object(); return (m_size); } bool POP3Message::isExpunged() const { return (false); } int POP3Message::getFlags() const { int flags = FLAG_RECENT; if (m_deleted) flags |= FLAG_DELETED; return (flags); } ref POP3Message::getStructure() const { throw exceptions::operation_not_supported(); } ref POP3Message::getStructure() { throw exceptions::operation_not_supported(); } ref POP3Message::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); return (m_header); } void POP3Message::extract(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool /* peek */) const { ref folder = m_folder.acquire(); if (!folder) throw exceptions::illegal_state("Folder closed"); else if (!folder->getStore()) throw exceptions::illegal_state("Store disconnected"); if (start != 0 && length != -1) throw exceptions::partial_fetch_not_supported(); // Emit the "RETR" command std::ostringstream oss; oss << "RETR " << m_num; folder.constCast ()->m_store.acquire()->sendRequest(oss.str()); try { POP3Folder::MessageMap::const_iterator it = folder->m_messages.find(const_cast (this)); const int totalSize = (it != folder.constCast ()->m_messages.end()) ? (*it).second : 0; folder.constCast ()->m_store.acquire()-> readResponse(os, progress, totalSize); } catch (exceptions::command_error& e) { throw exceptions::command_error("RETR", e.response()); } } void POP3Message::extractPart (ref /* p */, utility::outputStream& /* os */, utility::progressListener* /* progress */, const int /* start */, const int /* length */, const bool /* peek */) const { throw exceptions::operation_not_supported(); } void POP3Message::fetchPartHeader(ref /* p */) { throw exceptions::operation_not_supported(); } void POP3Message::fetch(ref msgFolder, const int options) { ref folder = m_folder.acquire(); if (folder != msgFolder) throw exceptions::folder_not_found(); // FETCH_STRUCTURE and FETCH_FLAGS are not supported by POP3. if (options & (folder::FETCH_STRUCTURE | folder::FETCH_FLAGS)) throw exceptions::operation_not_supported(); // Check for the real need to fetch the full header static const int optionsRequiringHeader = folder::FETCH_ENVELOPE | folder::FETCH_CONTENT_INFO | folder::FETCH_FULL_HEADER | folder::FETCH_IMPORTANCE; if (!(options & optionsRequiringHeader)) return; // No need to differenciate between FETCH_ENVELOPE, // FETCH_CONTENT_INFO, ... since POP3 only permits to // retrieve the whole header and not fields in particular. // Emit the "TOP" command std::ostringstream oss; oss << "TOP " << m_num << " 0"; folder->m_store.acquire()->sendRequest(oss.str()); try { string buffer; folder->m_store.acquire()->readResponse(buffer, true); m_header = vmime::create
(); m_header->parse(buffer); } catch (exceptions::command_error& e) { throw exceptions::command_error("TOP", e.response()); } } void POP3Message::setFlags(const int /* flags */, const int /* mode */) { throw exceptions::operation_not_supported(); } ref POP3Message::getParsedMessage() { std::ostringstream oss; utility::outputStreamAdapter os(oss); extract(os); vmime::ref msg = vmime::create (); msg->parse(oss.str()); return msg; } } // pop3 } // net } // vmime libvmime-0.9.1/src/net/pop3/POP3Store.cpp0000644000175000017500000005312611421613140020327 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/pop3/POP3Store.hpp" #include "vmime/net/pop3/POP3Folder.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" #include "vmime/messageId.hpp" #include "vmime/security/digest/messageDigestFactory.hpp" #include "vmime/utility/filteredStream.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/net/defaultConnectionInfos.hpp" #if VMIME_HAVE_SASL_SUPPORT #include "vmime/security/sasl/SASLContext.hpp" #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT #include "vmime/net/tls/TLSSession.hpp" #include "vmime/net/tls/TLSSecuredConnectionInfos.hpp" #endif // VMIME_HAVE_TLS_SUPPORT #include // Helpers for service properties #define GET_PROPERTY(type, prop) \ (getInfos().getPropertyValue (getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ (getInfos().hasProperty(getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) namespace vmime { namespace net { namespace pop3 { POP3Store::POP3Store(ref sess, ref auth, const bool secured) : store(sess, getInfosInstance(), auth), m_socket(NULL), m_authentified(false), m_timeoutHandler(NULL), m_isPOP3S(secured), m_secured(false) { } POP3Store::~POP3Store() { try { if (isConnected()) disconnect(); else if (m_socket) internalDisconnect(); } catch (vmime::exception&) { // Ignore } } const string POP3Store::getProtocolName() const { return "pop3"; } ref POP3Store::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (folder::path(folder::path::component("INBOX")), thisRef().dynamicCast ()); } ref POP3Store::getRootFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (folder::path(), thisRef().dynamicCast ()); } ref POP3Store::getFolder(const folder::path& path) { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (path, thisRef().dynamicCast ()); } bool POP3Store::isValidFolderName(const folder::path::component& /* name */) const { return true; } void POP3Store::connect() { if (isConnected()) throw exceptions::already_connected(); const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS); const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT); // Create the time-out handler if (getTimeoutHandlerFactory()) m_timeoutHandler = getTimeoutHandlerFactory()->create(); // Create and connect the socket m_socket = getSocketFactory()->create(m_timeoutHandler); #if VMIME_HAVE_TLS_SUPPORT if (m_isPOP3S) // dedicated port/POP3S { ref tlsSession = vmime::create (getCertificateVerifier()); ref tlsSocket = tlsSession->getSocket(m_socket); m_socket = tlsSocket; m_secured = true; m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); } else #endif // VMIME_HAVE_TLS_SUPPORT { m_cntInfos = vmime::create (address, port); } m_socket->connect(address, port); // Connection // // eg: C: // --- S: +OK MailSite POP3 Server 5.3.4.0 Ready <36938848.1056800841.634@somewhere.com> string response; readResponse(response, false); if (!isSuccessResponse(response)) { internalDisconnect(); throw exceptions::connection_greeting_error(response); } #if VMIME_HAVE_TLS_SUPPORT // Setup secured connection, if requested const bool tls = HAS_PROPERTY(PROPERTY_CONNECTION_TLS) && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS); const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED) && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED); if (!m_isPOP3S && tls) // only if not POP3S { try { startTLS(); } // Non-fatal error catch (exceptions::command_error&) { if (tlsRequired) { throw; } else { // TLS is not required, so don't bother } } // Fatal error catch (...) { throw; } } #endif // VMIME_HAVE_TLS_SUPPORT // Start authentication process authenticate(messageId(response)); } void POP3Store::authenticate(const messageId& randomMID) { getAuthenticator()->setService(thisRef().dynamicCast ()); #if VMIME_HAVE_SASL_SUPPORT // First, try SASL authentication if (GET_PROPERTY(bool, PROPERTY_OPTIONS_SASL)) { try { authenticateSASL(); m_authentified = true; return; } catch (exceptions::authentication_error& e) { if (!GET_PROPERTY(bool, PROPERTY_OPTIONS_SASL_FALLBACK)) { // Can't fallback on APOP/normal authentication internalDisconnect(); throw e; } else { // Ignore, will try APOP/normal authentication } } catch (exception& e) { internalDisconnect(); throw e; } } #endif // VMIME_HAVE_SASL_SUPPORT // Secured authentication with APOP (if requested and if available) // // eg: C: APOP vincent // --- S: +OK vincent is a valid mailbox const string username = getAuthenticator()->getUsername(); const string password = getAuthenticator()->getPassword(); string response; if (GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP)) { if (randomMID.getLeft().length() != 0 && randomMID.getRight().length() != 0) { // is the result of MD5 applied to "password" ref md5 = security::digest::messageDigestFactory::getInstance()->create("md5"); md5->update(randomMID.generate() + password); md5->finalize(); sendRequest("APOP " + username + " " + md5->getHexDigest()); readResponse(response, false); if (isSuccessResponse(response)) { m_authentified = true; return; } else { // Some servers close the connection after an unsuccessful APOP // command, so the fallback may not always work... // // S: +OK Qpopper (version 4.0.5) at xxx starting. <30396.1126730747@xxx> // C: APOP plop c5e0a87d088ec71d60e32692d4c5bdf4 // S: -ERR [AUTH] Password supplied for "plop" is incorrect. // S: +OK Pop server at xxx signing off. // [Connection closed by foreign host.] if (!GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP_FALLBACK)) { // Can't fallback on basic authentication internalDisconnect(); throw exceptions::authentication_error(response); } // Ensure connection is valid (cf. note above) try { string response2; sendRequest("NOOP"); readResponse(response2, false); } catch (exceptions::socket_exception&) { internalDisconnect(); throw exceptions::authentication_error(response); } } } else { // APOP not supported if (!GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP_FALLBACK)) { // Can't fallback on basic authentication internalDisconnect(); throw exceptions::authentication_error("APOP not supported"); } } } // Basic authentication // // eg: C: USER vincent // --- S: +OK vincent is a valid mailbox // // C: PASS couic // S: +OK vincent's maildrop has 2 messages (320 octets) sendRequest("USER " + username); readResponse(response, false); if (!isSuccessResponse(response)) { internalDisconnect(); throw exceptions::authentication_error(response); } sendRequest("PASS " + password); readResponse(response, false); if (!isSuccessResponse(response)) { internalDisconnect(); throw exceptions::authentication_error(response); } m_authentified = true; } #if VMIME_HAVE_SASL_SUPPORT void POP3Store::authenticateSASL() { if (!getAuthenticator().dynamicCast ()) throw exceptions::authentication_error("No SASL authenticator available."); std::vector capa = getCapabilities(); std::vector saslMechs; for (unsigned int i = 0 ; i < capa.size() ; ++i) { const string& x = capa[i]; // C: CAPA // S: +OK List of capabilities follows // S: LOGIN-DELAY 0 // S: PIPELINING // S: UIDL // S: ... // S: SASL DIGEST-MD5 CRAM-MD5 <----- // S: EXPIRE NEVER // S: ... if (x.length() > 5 && (x[0] == 'S' || x[0] == 's') && (x[1] == 'A' || x[1] == 'a') && (x[2] == 'S' || x[2] == 's') && (x[3] == 'L' || x[3] == 'l') && (x[4] == ' ' || x[4] == '\t')) { const string list(x.begin() + 5, x.end()); std::istringstream iss(list); string mech; while (iss >> mech) saslMechs.push_back(mech); } } if (saslMechs.empty()) throw exceptions::authentication_error("No SASL mechanism available."); std::vector > mechList; ref saslContext = vmime::create (); for (unsigned int i = 0 ; i < saslMechs.size() ; ++i) { try { mechList.push_back (saslContext->createMechanism(saslMechs[i])); } catch (exceptions::no_such_mechanism&) { // Ignore mechanism } } if (mechList.empty()) throw exceptions::authentication_error("No SASL mechanism available."); // Try to suggest a mechanism among all those supported ref suggestedMech = saslContext->suggestMechanism(mechList); if (!suggestedMech) throw exceptions::authentication_error("Unable to suggest SASL mechanism."); // Allow application to choose which mechanisms to use mechList = getAuthenticator().dynamicCast ()-> getAcceptableMechanisms(mechList, suggestedMech); if (mechList.empty()) throw exceptions::authentication_error("No SASL mechanism available."); // Try each mechanism in the list in turn for (unsigned int i = 0 ; i < mechList.size() ; ++i) { ref mech = mechList[i]; ref saslSession = saslContext->createSession("pop3", getAuthenticator(), mech); saslSession->init(); sendRequest("AUTH " + mech->getName()); for (bool cont = true ; cont ; ) { string response; readResponse(response, false); switch (getResponseCode(response)) { case RESPONSE_OK: { m_socket = saslSession->getSecuredSocket(m_socket); return; } case RESPONSE_READY: { byte_t* challenge = 0; int challengeLen = 0; byte_t* resp = 0; int respLen = 0; try { // Extract challenge stripResponseCode(response, response); saslContext->decodeB64(response, &challenge, &challengeLen); // Prepare response saslSession->evaluateChallenge (challenge, challengeLen, &resp, &respLen); // Send response sendRequest(saslContext->encodeB64(resp, respLen)); } catch (exceptions::sasl_exception& e) { if (challenge) { delete [] challenge; challenge = NULL; } if (resp) { delete [] resp; resp = NULL; } // Cancel SASL exchange sendRequest("*"); } catch (...) { if (challenge) delete [] challenge; if (resp) delete [] resp; throw; } if (challenge) delete [] challenge; if (resp) delete [] resp; break; } default: cont = false; break; } } } throw exceptions::authentication_error ("Could not authenticate using SASL: all mechanisms failed."); } #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT void POP3Store::startTLS() { try { sendRequest("STLS"); string response; readResponse(response, false); if (getResponseCode(response) != RESPONSE_OK) throw exceptions::command_error("STLS", response); ref tlsSession = vmime::create (getCertificateVerifier()); ref tlsSocket = tlsSession->getSocket(m_socket); tlsSocket->handshake(m_timeoutHandler); m_socket = tlsSocket; m_secured = true; m_cntInfos = vmime::create (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); } catch (exceptions::command_error&) { // Non-fatal error throw; } catch (exception&) { // Fatal error internalDisconnect(); throw; } } #endif // VMIME_HAVE_TLS_SUPPORT bool POP3Store::isConnected() const { return (m_socket && m_socket->isConnected() && m_authentified); } bool POP3Store::isSecuredConnection() const { return m_secured; } ref POP3Store::getConnectionInfos() const { return m_cntInfos; } void POP3Store::disconnect() { if (!isConnected()) throw exceptions::not_connected(); internalDisconnect(); } void POP3Store::internalDisconnect() { for (std::list ::iterator it = m_folders.begin() ; it != m_folders.end() ; ++it) { (*it)->onStoreDisconnected(); } m_folders.clear(); try { sendRequest("QUIT"); } catch (exception&) { // Not important } m_socket->disconnect(); m_socket = NULL; m_timeoutHandler = NULL; m_authentified = false; m_secured = false; m_cntInfos = NULL; } void POP3Store::noop() { sendRequest("NOOP"); string response; readResponse(response, false); if (!isSuccessResponse(response)) throw exceptions::command_error("NOOP", response); } const std::vector POP3Store::getCapabilities() { sendRequest("CAPA"); string response; readResponse(response, true); std::vector res; if (isSuccessResponse(response)) { stripFirstLine(response, response); std::istringstream iss(response); string line; while (std::getline(iss, line, '\n')) res.push_back(utility::stringUtils::trim(line)); } return res; } bool POP3Store::isSuccessResponse(const string& buffer) { return getResponseCode(buffer) == RESPONSE_OK; } bool POP3Store::stripFirstLine(const string& buffer, string& result, string* firstLine) { const string::size_type end = buffer.find('\n'); if (end != string::npos) { if (firstLine) *firstLine = buffer.substr(0, end); result = buffer.substr(end + 1); return (true); } else { result = buffer; return (false); } } int POP3Store::getResponseCode(const string& buffer) { if (buffer.length() >= 2) { // +[space] if (buffer[0] == '+' && (buffer[1] == ' ' || buffer[1] == '\t')) { return RESPONSE_READY; } // +OK if (buffer.length() >= 3) { if (buffer[0] == '+' && (buffer[1] == 'O' || buffer[1] == 'o') && (buffer[2] == 'K' || buffer[1] == 'k')) { return RESPONSE_OK; } } } // -ERR or whatever return RESPONSE_ERR; } void POP3Store::stripResponseCode(const string& buffer, string& result) { const string::size_type pos = buffer.find_first_of(" \t"); if (pos != string::npos) result = buffer.substr(pos + 1); else result = buffer; } void POP3Store::sendRequest(const string& buffer, const bool end) { if (end) m_socket->send(buffer + "\r\n"); else m_socket->send(buffer); } void POP3Store::readResponse(string& buffer, const bool multiLine, utility::progressListener* progress) { bool foundTerminator = false; int current = 0, total = 0; if (progress) progress->start(total); if (m_timeoutHandler) m_timeoutHandler->resetTimeOut(); buffer.clear(); string::value_type last1 = '\0', last2 = '\0'; for ( ; !foundTerminator ; ) { #if 0 // not supported // Check for possible cancellation if (progress && progress->cancel()) throw exceptions::operation_cancelled(); #endif // Check whether the time-out delay is elapsed if (m_timeoutHandler && m_timeoutHandler->isTimeOut()) { if (!m_timeoutHandler->handleTimeOut()) throw exceptions::operation_timed_out(); m_timeoutHandler->resetTimeOut(); } // Receive data from the socket string receiveBuffer; m_socket->receive(receiveBuffer); if (receiveBuffer.empty()) // buffer is empty { platform::getHandler()->wait(); continue; } // We have received data: reset the time-out counter if (m_timeoutHandler) m_timeoutHandler->resetTimeOut(); // Check for transparent characters: '\n..' becomes '\n.' const string::value_type first = receiveBuffer[0]; if (first == '.' && last2 == '\n' && last1 == '.') { receiveBuffer.erase(receiveBuffer.begin()); } else if (receiveBuffer.length() >= 2 && first == '.' && receiveBuffer[1] == '.' && last1 == '\n') { receiveBuffer.erase(receiveBuffer.begin()); } for (string::size_type trans ; string::npos != (trans = receiveBuffer.find("\n..")) ; ) { receiveBuffer.replace(trans, 3, "\n."); } last1 = receiveBuffer[receiveBuffer.length() - 1]; last2 = static_cast ((receiveBuffer.length() >= 2) ? receiveBuffer[receiveBuffer.length() - 2] : 0); // Append the data to the response buffer buffer += receiveBuffer; current += receiveBuffer.length(); // Check for terminator string (and strip it if present) foundTerminator = checkTerminator(buffer, multiLine); // Notify progress if (progress) { total = std::max(total, current); progress->progress(current, total); } // If there is an error (-ERR) when executing a command that // requires a multi-line response, the error response will // include only one line, so we stop waiting for a multi-line // terminator and check for a "normal" one. if (multiLine && !foundTerminator && buffer.length() >= 4 && buffer[0] == '-') { foundTerminator = checkTerminator(buffer, false); } } if (progress) progress->stop(total); } void POP3Store::readResponse(utility::outputStream& os, utility::progressListener* progress, const int predictedSize) { int current = 0, total = predictedSize; string temp; bool codeDone = false; if (progress) progress->start(total); if (m_timeoutHandler) m_timeoutHandler->resetTimeOut(); utility::inputStreamSocketAdapter sis(*m_socket); utility::stopSequenceFilteredInputStream <5> sfis1(sis, "\r\n.\r\n"); utility::stopSequenceFilteredInputStream <3> sfis2(sfis1, "\n.\n"); utility::dotFilteredInputStream dfis(sfis2); // "\n.." --> "\n." utility::inputStream& is = dfis; while (!is.eof()) { #if 0 // not supported // Check for possible cancellation if (progress && progress->cancel()) throw exceptions::operation_cancelled(); #endif // Check whether the time-out delay is elapsed if (m_timeoutHandler && m_timeoutHandler->isTimeOut()) { if (!m_timeoutHandler->handleTimeOut()) throw exceptions::operation_timed_out(); } // Receive data from the socket utility::stream::value_type buffer[65536]; const utility::stream::size_type read = is.read(buffer, sizeof(buffer)); if (read == 0) // buffer is empty { platform::getHandler()->wait(); continue; } // We have received data: reset the time-out counter if (m_timeoutHandler) m_timeoutHandler->resetTimeOut(); // If we don't have extracted the response code yet if (!codeDone) { temp += string(buffer, read); string firstLine; if (stripFirstLine(temp, temp, &firstLine) == true) { if (!isSuccessResponse(firstLine)) throw exceptions::command_error("?", firstLine); codeDone = true; os.write(temp.data(), temp.length()); temp.clear(); continue; } } else { // Inject the data into the output stream os.write(buffer, read); current += read; // Notify progress if (progress) { total = std::max(total, current); progress->progress(current, total); } } } if (progress) progress->stop(total); } bool POP3Store::checkTerminator(string& buffer, const bool multiLine) { // Multi-line response if (multiLine) { static const string term1("\r\n.\r\n"); static const string term2("\n.\n"); return (checkOneTerminator(buffer, term1) || checkOneTerminator(buffer, term2)); } // Normal response else { static const string term1("\r\n"); static const string term2("\n"); return (checkOneTerminator(buffer, term1) || checkOneTerminator(buffer, term2)); } return (false); } bool POP3Store::checkOneTerminator(string& buffer, const string& term) { if (buffer.length() >= term.length() && std::equal(buffer.end() - term.length(), buffer.end(), term.begin())) { buffer.erase(buffer.end() - term.length(), buffer.end()); return (true); } return (false); } void POP3Store::registerFolder(POP3Folder* folder) { m_folders.push_back(folder); } void POP3Store::unregisterFolder(POP3Folder* folder) { std::list ::iterator it = std::find(m_folders.begin(), m_folders.end(), folder); if (it != m_folders.end()) m_folders.erase(it); } int POP3Store::getCapabilities() const { return (CAPABILITY_DELETE_MESSAGE); } // Service infos POP3ServiceInfos POP3Store::sm_infos(false); const serviceInfos& POP3Store::getInfosInstance() { return sm_infos; } const serviceInfos& POP3Store::getInfos() const { return sm_infos; } } // pop3 } // net } // vmime libvmime-0.9.1/src/net/pop3/POP3Utils.cpp0000644000175000017500000000367111250723263020343 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/pop3/POP3Utils.hpp" #include namespace vmime { namespace net { namespace pop3 { // static void POP3Utils::parseMultiListOrUidlResponse(const string& response, std::map & result) { std::istringstream iss(response); std::map ids; string line; while (std::getline(iss, line)) { string::iterator it = line.begin(); while (it != line.end() && (*it == ' ' || *it == '\t')) ++it; if (it != line.end()) { int number = 0; while (it != line.end() && (*it >= '0' && *it <= '9')) { number = (number * 10) + (*it - '0'); ++it; } while (it != line.end() && !(*it == ' ' || *it == '\t')) ++it; while (it != line.end() && (*it == ' ' || *it == '\t')) ++it; if (it != line.end()) { result.insert(std::map ::value_type(number, string(it, line.end()))); } } } } } // pop3 } // net } // vmime libvmime-0.9.1/src/net/smtp/0000755000175000017500000000000011607302336016170 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/smtp/SMTPTransport.cpp0000644000175000017500000003414511457534022021405 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/smtp/SMTPTransport.hpp" #include "vmime/net/smtp/SMTPResponse.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" #include "vmime/mailboxList.hpp" #include "vmime/utility/filteredStream.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/net/defaultConnectionInfos.hpp" #if VMIME_HAVE_SASL_SUPPORT #include "vmime/security/sasl/SASLContext.hpp" #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT #include "vmime/net/tls/TLSSession.hpp" #include "vmime/net/tls/TLSSecuredConnectionInfos.hpp" #endif // VMIME_HAVE_TLS_SUPPORT // Helpers for service properties #define GET_PROPERTY(type, prop) \ (getInfos().getPropertyValue (getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ (getInfos().hasProperty(getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) namespace vmime { namespace net { namespace smtp { SMTPTransport::SMTPTransport(ref sess, ref auth, const bool secured) : transport(sess, getInfosInstance(), auth), m_socket(NULL), m_authentified(false), m_extendedSMTP(false), m_timeoutHandler(NULL), m_isSMTPS(secured), m_secured(false) { } SMTPTransport::~SMTPTransport() { try { if (isConnected()) disconnect(); else if (m_socket) internalDisconnect(); } catch (vmime::exception&) { // Ignore } } const string SMTPTransport::getProtocolName() const { return "smtp"; } void SMTPTransport::connect() { if (isConnected()) throw exceptions::already_connected(); const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS); const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT); // Create the time-out handler if (getTimeoutHandlerFactory()) m_timeoutHandler = getTimeoutHandlerFactory()->create(); // Create and connect the socket m_socket = getSocketFactory()->create(m_timeoutHandler); #if VMIME_HAVE_TLS_SUPPORT if (m_isSMTPS) // dedicated port/SMTPS { ref tlsSession = vmime::create (getCertificateVerifier()); ref tlsSocket = tlsSession->getSocket(m_socket); m_socket = tlsSocket; m_secured = true; m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); } else #endif // VMIME_HAVE_TLS_SUPPORT { m_cntInfos = vmime::create (address, port); } m_socket->connect(address, port); // Connection // // eg: C: // --- S: 220 smtp.domain.com Service ready ref resp; if ((resp = readResponse())->getCode() != 220) { internalDisconnect(); throw exceptions::connection_greeting_error(resp->getText()); } // Identification helo(); #if VMIME_HAVE_TLS_SUPPORT // Setup secured connection, if requested const bool tls = HAS_PROPERTY(PROPERTY_CONNECTION_TLS) && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS); const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED) && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED); if (!m_isSMTPS && tls) // only if not SMTPS { try { startTLS(); } // Non-fatal error catch (exceptions::command_error&) { if (tlsRequired) { throw; } else { // TLS is not required, so don't bother } } // Fatal error catch (...) { throw; } // Must reissue a EHLO command [RFC-2487, 5.2] helo(); } #endif // VMIME_HAVE_TLS_SUPPORT // Authentication if (GET_PROPERTY(bool, PROPERTY_OPTIONS_NEEDAUTH)) authenticate(); else m_authentified = true; } void SMTPTransport::helo() { // First, try Extended SMTP (ESMTP) // // eg: C: EHLO thismachine.ourdomain.com // S: 250-smtp.theserver.com // S: 250-AUTH CRAM-MD5 DIGEST-MD5 // S: 250-PIPELINING // S: 250 SIZE 2555555555 sendRequest("EHLO " + platform::getHandler()->getHostName()); ref resp; if ((resp = readResponse())->getCode() != 250) { // Next, try "Basic" SMTP // // eg: C: HELO thismachine.ourdomain.com // S: 250 OK sendRequest("HELO " + platform::getHandler()->getHostName()); if ((resp = readResponse())->getCode() != 250) { internalDisconnect(); throw exceptions::connection_greeting_error(resp->getLastLine().getText()); } m_extendedSMTP = false; m_extensions.clear(); } else { m_extendedSMTP = true; m_extensions.clear(); // Get supported extensions from SMTP response // One extension per line, format is: EXT PARAM1 PARAM2... for (int i = 1, n = resp->getLineCount() ; i < n ; ++i) { const string line = resp->getLineAt(i).getText(); std::istringstream iss(line); string ext; iss >> ext; std::vector params; string param; // Special case: some servers send "AUTH=MECH [MECH MECH...]" if (ext.length() >= 5 && utility::stringUtils::toUpper(ext.substr(0, 5)) == "AUTH=") { params.push_back(utility::stringUtils::toUpper(ext.substr(5))); ext = "AUTH"; } while (iss >> param) params.push_back(utility::stringUtils::toUpper(param)); m_extensions[ext] = params; } } } void SMTPTransport::authenticate() { if (!m_extendedSMTP) { internalDisconnect(); throw exceptions::command_error("AUTH", "ESMTP not supported."); } getAuthenticator()->setService(thisRef().dynamicCast ()); #if VMIME_HAVE_SASL_SUPPORT // First, try SASL authentication if (GET_PROPERTY(bool, PROPERTY_OPTIONS_SASL)) { try { authenticateSASL(); m_authentified = true; return; } catch (exceptions::authentication_error& e) { if (!GET_PROPERTY(bool, PROPERTY_OPTIONS_SASL_FALLBACK)) { // Can't fallback on normal authentication internalDisconnect(); throw e; } else { // Ignore, will try normal authentication } } catch (exception& e) { internalDisconnect(); throw e; } } #endif // VMIME_HAVE_SASL_SUPPORT // No other authentication method is possible throw exceptions::authentication_error("All authentication methods failed"); } #if VMIME_HAVE_SASL_SUPPORT void SMTPTransport::authenticateSASL() { if (!getAuthenticator().dynamicCast ()) throw exceptions::authentication_error("No SASL authenticator available."); // Obtain SASL mechanisms supported by server from ESMTP extensions const std::vector saslMechs = (m_extensions.find("AUTH") != m_extensions.end()) ? m_extensions["AUTH"] : std::vector (); if (saslMechs.empty()) throw exceptions::authentication_error("No SASL mechanism available."); std::vector > mechList; ref saslContext = vmime::create (); for (unsigned int i = 0 ; i < saslMechs.size() ; ++i) { try { mechList.push_back (saslContext->createMechanism(saslMechs[i])); } catch (exceptions::no_such_mechanism&) { // Ignore mechanism } } if (mechList.empty()) throw exceptions::authentication_error("No SASL mechanism available."); // Try to suggest a mechanism among all those supported ref suggestedMech = saslContext->suggestMechanism(mechList); if (!suggestedMech) throw exceptions::authentication_error("Unable to suggest SASL mechanism."); // Allow application to choose which mechanisms to use mechList = getAuthenticator().dynamicCast ()-> getAcceptableMechanisms(mechList, suggestedMech); if (mechList.empty()) throw exceptions::authentication_error("No SASL mechanism available."); // Try each mechanism in the list in turn for (unsigned int i = 0 ; i < mechList.size() ; ++i) { ref mech = mechList[i]; ref saslSession = saslContext->createSession("smtp", getAuthenticator(), mech); saslSession->init(); sendRequest("AUTH " + mech->getName()); for (bool cont = true ; cont ; ) { ref response = readResponse(); switch (response->getCode()) { case 235: { m_socket = saslSession->getSecuredSocket(m_socket); return; } case 334: { byte_t* challenge = 0; int challengeLen = 0; byte_t* resp = 0; int respLen = 0; try { // Extract challenge saslContext->decodeB64(response->getText(), &challenge, &challengeLen); // Prepare response saslSession->evaluateChallenge (challenge, challengeLen, &resp, &respLen); // Send response sendRequest(saslContext->encodeB64(resp, respLen)); } catch (exceptions::sasl_exception& e) { if (challenge) { delete [] challenge; challenge = NULL; } if (resp) { delete [] resp; resp = NULL; } // Cancel SASL exchange sendRequest("*"); } catch (...) { if (challenge) delete [] challenge; if (resp) delete [] resp; throw; } if (challenge) delete [] challenge; if (resp) delete [] resp; break; } default: cont = false; break; } } } throw exceptions::authentication_error ("Could not authenticate using SASL: all mechanisms failed."); } #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT void SMTPTransport::startTLS() { try { sendRequest("STARTTLS"); ref resp = readResponse(); if (resp->getCode() != 220) throw exceptions::command_error("STARTTLS", resp->getText()); ref tlsSession = vmime::create (getCertificateVerifier()); ref tlsSocket = tlsSession->getSocket(m_socket); tlsSocket->handshake(m_timeoutHandler); m_socket = tlsSocket; m_secured = true; m_cntInfos = vmime::create (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); } catch (exceptions::command_error&) { // Non-fatal error throw; } catch (exception&) { // Fatal error internalDisconnect(); throw; } } #endif // VMIME_HAVE_TLS_SUPPORT bool SMTPTransport::isConnected() const { return (m_socket && m_socket->isConnected() && m_authentified); } bool SMTPTransport::isSecuredConnection() const { return m_secured; } ref SMTPTransport::getConnectionInfos() const { return m_cntInfos; } void SMTPTransport::disconnect() { if (!isConnected()) throw exceptions::not_connected(); internalDisconnect(); } void SMTPTransport::internalDisconnect() { try { sendRequest("QUIT"); } catch (exception&) { // Not important } m_socket->disconnect(); m_socket = NULL; m_timeoutHandler = NULL; m_authentified = false; m_extendedSMTP = false; m_secured = false; m_cntInfos = NULL; } void SMTPTransport::noop() { if (!isConnected()) throw exceptions::not_connected(); sendRequest("NOOP"); ref resp = readResponse(); if (resp->getCode() != 250) throw exceptions::command_error("NOOP", resp->getText()); } void SMTPTransport::send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress) { if (!isConnected()) throw exceptions::not_connected(); // If no recipient/expeditor was found, throw an exception if (recipients.isEmpty()) throw exceptions::no_recipient(); else if (expeditor.isEmpty()) throw exceptions::no_expeditor(); // Emit the "MAIL" command ref resp; sendRequest("MAIL FROM: <" + expeditor.getEmail() + ">"); if ((resp = readResponse())->getCode() != 250) { internalDisconnect(); throw exceptions::command_error("MAIL", resp->getText()); } // Emit a "RCPT TO" command for each recipient for (int i = 0 ; i < recipients.getMailboxCount() ; ++i) { const mailbox& mbox = *recipients.getMailboxAt(i); sendRequest("RCPT TO: <" + mbox.getEmail() + ">"); if ((resp = readResponse())->getCode() != 250) { internalDisconnect(); throw exceptions::command_error("RCPT TO", resp->getText(), mbox.getEmail()); } } // Send the message data sendRequest("DATA"); if ((resp = readResponse())->getCode() != 354) { internalDisconnect(); throw exceptions::command_error("DATA", resp->getText()); } // Stream copy with "\n." to "\n.." transformation utility::outputStreamSocketAdapter sos(*m_socket); utility::dotFilteredOutputStream fos(sos); utility::bufferedStreamCopy(is, fos, size, progress); fos.flush(); // Send end-of-data delimiter m_socket->sendRaw("\r\n.\r\n", 5); if ((resp = readResponse())->getCode() != 250) { internalDisconnect(); throw exceptions::command_error("DATA", resp->getText()); } } void SMTPTransport::sendRequest(const string& buffer, const bool end) { if (end) m_socket->send(buffer + "\r\n"); else m_socket->send(buffer); } ref SMTPTransport::readResponse() { return SMTPResponse::readResponse(m_socket, m_timeoutHandler); } // Service infos SMTPServiceInfos SMTPTransport::sm_infos(false); const serviceInfos& SMTPTransport::getInfosInstance() { return sm_infos; } const serviceInfos& SMTPTransport::getInfos() const { return sm_infos; } } // smtp } // net } // vmime libvmime-0.9.1/src/net/smtp/SMTPServiceInfos.cpp0000644000175000017500000000777011250723263022012 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/smtp/SMTPServiceInfos.hpp" namespace vmime { namespace net { namespace smtp { SMTPServiceInfos::SMTPServiceInfos(const bool smtps) : m_smtps(smtps) { } const string SMTPServiceInfos::getPropertyPrefix() const { if (m_smtps) return "transport.smtps."; else return "transport.smtp."; } const SMTPServiceInfos::props& SMTPServiceInfos::getProperties() const { static props smtpProps = { // SMTP-specific options property("options.need-authentication", serviceInfos::property::TYPE_BOOL, "false"), #if VMIME_HAVE_SASL_SUPPORT property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"), property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "false"), #endif // VMIME_HAVE_SASL_SUPPORT // Common properties property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED), #if VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::CONNECTION_TLS), property(serviceInfos::property::CONNECTION_TLS_REQUIRED), #endif // VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::SERVER_PORT, "25"), }; static props smtpsProps = { // SMTP-specific options property("options.need-authentication", serviceInfos::property::TYPE_BOOL, "false"), #if VMIME_HAVE_SASL_SUPPORT property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"), property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "false"), #endif // VMIME_HAVE_SASL_SUPPORT // Common properties property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED), #if VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::CONNECTION_TLS), property(serviceInfos::property::CONNECTION_TLS_REQUIRED), #endif // VMIME_HAVE_TLS_SUPPORT property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED), property(serviceInfos::property::SERVER_PORT, "465"), }; return m_smtps ? smtpsProps : smtpProps; } const std::vector SMTPServiceInfos::getAvailableProperties() const { std::vector list; const props& p = getProperties(); // SMTP-specific options list.push_back(p.PROPERTY_OPTIONS_NEEDAUTH); #if VMIME_HAVE_SASL_SUPPORT list.push_back(p.PROPERTY_OPTIONS_SASL); list.push_back(p.PROPERTY_OPTIONS_SASL_FALLBACK); #endif // VMIME_HAVE_SASL_SUPPORT // Common properties list.push_back(p.PROPERTY_AUTH_USERNAME); list.push_back(p.PROPERTY_AUTH_PASSWORD); #if VMIME_HAVE_TLS_SUPPORT if (!m_smtps) { list.push_back(p.PROPERTY_CONNECTION_TLS); list.push_back(p.PROPERTY_CONNECTION_TLS_REQUIRED); } #endif // VMIME_HAVE_TLS_SUPPORT list.push_back(p.PROPERTY_SERVER_ADDRESS); list.push_back(p.PROPERTY_SERVER_PORT); return list; } } // smtp } // net } // vmime libvmime-0.9.1/src/net/smtp/SMTPResponse.cpp0000644000175000017500000001215511250723263021202 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/smtp/SMTPResponse.hpp" #include "vmime/platform.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" namespace vmime { namespace net { namespace smtp { SMTPResponse::SMTPResponse(ref sok, ref toh) : m_socket(sok), m_timeoutHandler(toh), m_responseContinues(false) { } SMTPResponse::SMTPResponse(const SMTPResponse&) : vmime::object() { // Not used } int SMTPResponse::getCode() const { const int firstCode = m_lines[0].getCode(); for (unsigned int i = 1 ; i < m_lines.size() ; ++i) { // All response codes returned must be equal // or else this in an error... if (m_lines[i].getCode() != firstCode) return 0; } return firstCode; } const string SMTPResponse::getText() const { string text = m_lines[0].getText(); for (unsigned int i = 1 ; i < m_lines.size() ; ++i) { text += '\n'; text += m_lines[i].getText(); } return text; } // static ref SMTPResponse::readResponse (ref sok, ref toh) { ref resp = vmime::create (sok, toh); resp->readResponse(); return resp; } void SMTPResponse::readResponse() { responseLine line = getNextResponse(); m_lines.push_back(line); while (m_responseContinues) { line = getNextResponse(); m_lines.push_back(line); } } const string SMTPResponse::readResponseLine() { string currentBuffer = m_responseBuffer; if (m_timeoutHandler) m_timeoutHandler->resetTimeOut(); while (true) { // Get a line from the response buffer const string::size_type lineEnd = currentBuffer.find_first_of('\n'); if (lineEnd != string::npos) { string::size_type actualLineEnd = lineEnd; if (actualLineEnd != 0 && currentBuffer[actualLineEnd - 1] == '\r') // CRLF case actualLineEnd--; const string line(currentBuffer.begin(), currentBuffer.begin() + actualLineEnd); currentBuffer.erase(currentBuffer.begin(), currentBuffer.begin() + lineEnd + 1); m_responseBuffer = currentBuffer; return line; } // Check whether the time-out delay is elapsed if (m_timeoutHandler && m_timeoutHandler->isTimeOut()) { if (!m_timeoutHandler->handleTimeOut()) throw exceptions::operation_timed_out(); m_timeoutHandler->resetTimeOut(); } // Receive data from the socket string receiveBuffer; m_socket->receive(receiveBuffer); if (receiveBuffer.empty()) // buffer is empty { platform::getHandler()->wait(); continue; } currentBuffer += receiveBuffer; } } const SMTPResponse::responseLine SMTPResponse::getNextResponse() { string line = readResponseLine(); const int code = extractResponseCode(line); string text; // Special case where CRLF occurs after response code // in "Positive Intermediate replies" (3yz reply) if (line.length() < 4 && (code / 100) == 3) line = line + '\n' + readResponseLine(); m_responseContinues = (line.length() >= 4 && line[3] == '-'); if (line.length() > 4) text = utility::stringUtils::trim(line.substr(4)); else text = ""; return responseLine(code, text); } // static int SMTPResponse::extractResponseCode(const string& response) { int code = 0; if (response.length() >= 3) { code = (response[0] - '0') * 100 + (response[1] - '0') * 10 + (response[2] - '0'); } return code; } const SMTPResponse::responseLine SMTPResponse::getLineAt(const unsigned int pos) const { return m_lines[pos]; } unsigned int SMTPResponse::getLineCount() const { return m_lines.size(); } const SMTPResponse::responseLine SMTPResponse::getLastLine() const { return m_lines[m_lines.size() - 1]; } // SMTPResponse::responseLine SMTPResponse::responseLine::responseLine(const int code, const string& text) : m_code(code), m_text(text) { } void SMTPResponse::responseLine::setCode(const int code) { m_code = code; } int SMTPResponse::responseLine::getCode() const { return m_code; } void SMTPResponse::responseLine::setText(const string& text) { m_text = text; } const string SMTPResponse::responseLine::getText() const { return m_text; } } // smtp } // net } // vmime libvmime-0.9.1/src/net/smtp/SMTPSTransport.cpp0000644000175000017500000000317611250723263021526 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/smtp/SMTPSTransport.hpp" namespace vmime { namespace net { namespace smtp { SMTPSTransport::SMTPSTransport(ref sess, ref auth) : SMTPTransport(sess, auth, true) { } SMTPSTransport::~SMTPSTransport() { } const string SMTPSTransport::getProtocolName() const { return "smtps"; } // Service infos SMTPServiceInfos SMTPSTransport::sm_infos(true); const serviceInfos& SMTPSTransport::getInfosInstance() { return sm_infos; } const serviceInfos& SMTPSTransport::getInfos() const { return sm_infos; } } // smtp } // net } // vmime libvmime-0.9.1/src/net/message.cpp0000644000175000017500000000261111250723263017335 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/message.hpp" namespace vmime { namespace net { ref part::getPartAt(const int pos) const { return getStructure()->getPartAt(pos); } ref part::getPartAt(const int pos) { return getStructure()->getPartAt(pos); } int part::getPartCount() const { return getStructure()->getPartCount(); } } // net } // vmime libvmime-0.9.1/src/net/transport.cpp0000644000175000017500000000664211250723263017755 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/transport.hpp" #include "vmime/utility/stream.hpp" #include "vmime/mailboxList.hpp" #include "vmime/message.hpp" namespace vmime { namespace net { transport::transport(ref sess, const serviceInfos& infos, ref auth) : service(sess, infos, auth) { } static void extractMailboxes (mailboxList& recipients, const addressList& list) { for (int i = 0 ; i < list.getAddressCount() ; ++i) { ref mbox = list.getAddressAt(i)->clone().dynamicCast (); if (mbox != NULL) recipients.appendMailbox(mbox); } } void transport::send(ref msg, utility::progressListener* progress) { // Extract expeditor mailbox expeditor; try { const mailbox& mbox = *msg->getHeader()->findField(fields::FROM)-> getValue().dynamicCast (); expeditor = mbox; } catch (exceptions::no_such_field&) { throw exceptions::no_expeditor(); } // Extract recipients mailboxList recipients; try { const addressList& to = *msg->getHeader()->findField(fields::TO)-> getValue().dynamicCast (); extractMailboxes(recipients, to); } catch (exceptions::no_such_field&) { } try { const addressList& cc = *msg->getHeader()->findField(fields::CC)-> getValue().dynamicCast (); extractMailboxes(recipients, cc); } catch (exceptions::no_such_field&) { } try { const addressList& bcc = *msg->getHeader()->findField(fields::BCC)-> getValue().dynamicCast (); extractMailboxes(recipients, bcc); } catch (exceptions::no_such_field&) { } // Remove BCC headers from the message we're about to send, as required by the RFC. // Some SMTP server automatically strip this header (Postfix, qmail), and others // have an option for this (Exim). try { ref bcc = msg->getHeader()->findField(fields::BCC); msg->getHeader()->removeField(bcc); } catch (exceptions::no_such_field&) { } // Generate the message, "stream" it and delegate the sending // to the generic send() function. std::ostringstream oss; utility::outputStreamAdapter ossAdapter(oss); msg->generate(ossAdapter); const string& str(oss.str()); utility::inputStreamStringAdapter isAdapter(str); send(expeditor, recipients, isAdapter, str.length(), progress); } transport::Type transport::getType() const { return (TYPE_TRANSPORT); } } // net } // vmime libvmime-0.9.1/src/net/serviceRegistration.inl0000644000175000017500000000437211250723263021752 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/serviceFactory.hpp" #ifndef VMIME_BUILDING_DOC namespace vmime { namespace net { template class registeredServiceImpl : public serviceFactory::registeredService { public: registeredServiceImpl(const string& name, const int type) : m_type(type), m_name(name), m_servInfos(S::getInfosInstance()) { } ref create (ref sess, ref auth) const { return vmime::create (sess, auth); } const serviceInfos& getInfos() const { return (m_servInfos); } const string& getName() const { return (m_name); } int getType() const { return (m_type); } private: const int m_type; const string m_name; const serviceInfos& m_servInfos; }; // Basic service registerer template class serviceRegisterer { public: serviceRegisterer(const string& protocol, const service::Type type) { serviceFactory::getInstance()->registerService (vmime::create >(protocol, type)); } }; } // net } // vmime #define REGISTER_SERVICE(p_class, p_name, p_type) \ vmime::net::serviceRegisterer \ p_name(#p_name, vmime::net::service::p_type) #endif // VMIME_BUILDING_DOC libvmime-0.9.1/src/net/serviceFactory.cpp0000644000175000017500000000713311250723263020705 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/serviceFactory.hpp" #include "vmime/net/service.hpp" #include "vmime/exception.hpp" #include "vmime/config.hpp" #include "src/net/builtinServices.inl" namespace vmime { namespace net { serviceFactory::serviceFactory() { } serviceFactory::~serviceFactory() { } serviceFactory* serviceFactory::getInstance() { static serviceFactory instance; return (&instance); } ref serviceFactory::create (ref sess, const string& protocol, ref auth) { return (getServiceByProtocol(protocol)->create(sess, auth)); } ref serviceFactory::create (ref sess, const utility::url& u, ref auth) { ref serv = create(sess, u.getProtocol(), auth); sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.address"] = u.getHost(); if (u.getPort() != utility::url::UNSPECIFIED_PORT) sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.port"] = u.getPort(); // Path portion of the URL is used to point a specific folder (empty = root). // In maildir, this is used to point to the root of the message repository. if (!u.getPath().empty()) sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.rootpath"] = u.getPath(); if (!u.getUsername().empty()) { sess->getProperties()[serv->getInfos().getPropertyPrefix() + "auth.username"] = u.getUsername(); sess->getProperties()[serv->getInfos().getPropertyPrefix() + "auth.password"] = u.getPassword(); } return (serv); } ref serviceFactory::getServiceByProtocol(const string& protocol) const { const string name(utility::stringUtils::toLower(protocol)); for (std::vector >::const_iterator it = m_services.begin() ; it != m_services.end() ; ++it) { if ((*it)->getName() == name) return (*it); } throw exceptions::no_service_available(name); } int serviceFactory::getServiceCount() const { return (m_services.size()); } ref serviceFactory::getServiceAt(const int pos) const { return (m_services[pos]); } const std::vector > serviceFactory::getServiceList() const { std::vector > res; for (std::vector >::const_iterator it = m_services.begin() ; it != m_services.end() ; ++it) { res.push_back(*it); } return (res); } void serviceFactory::registerService(ref reg) { m_services.push_back(reg); } } // net } // vmime libvmime-0.9.1/src/net/maildir/0000755000175000017500000000000011607302336016626 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/maildir/maildirServiceInfos.cpp0000644000175000017500000000341711250723263023300 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/maildirServiceInfos.hpp" namespace vmime { namespace net { namespace maildir { maildirServiceInfos::maildirServiceInfos() { } const string maildirServiceInfos::getPropertyPrefix() const { return "store.maildir."; } const maildirServiceInfos::props& maildirServiceInfos::getProperties() const { static props maildirProps = { property(serviceInfos::property::SERVER_ROOTPATH, serviceInfos::property::FLAG_REQUIRED) }; return maildirProps; } const std::vector maildirServiceInfos::getAvailableProperties() const { std::vector list; const props& p = getProperties(); list.push_back(p.PROPERTY_SERVER_ROOTPATH); return list; } } // maildir } // net } // vmime libvmime-0.9.1/src/net/maildir/maildirStore.cpp0000644000175000017500000001312311314151075021765 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/net/maildir/maildirFolder.hpp" #include "vmime/net/maildir/maildirFormat.hpp" #include "vmime/utility/smartPtr.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" #include "vmime/net/defaultConnectionInfos.hpp" // Helpers for service properties #define GET_PROPERTY(type, prop) \ (getInfos().getPropertyValue (getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ (getInfos().hasProperty(getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) namespace vmime { namespace net { namespace maildir { maildirStore::maildirStore(ref sess, ref auth) : store(sess, getInfosInstance(), auth), m_connected(false) { } maildirStore::~maildirStore() { try { if (isConnected()) disconnect(); } catch (vmime::exception&) { // Ignore } } const string maildirStore::getProtocolName() const { return "maildir"; } ref maildirStore::getRootFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (folder::path(), thisRef().dynamicCast ()); } ref maildirStore::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (folder::path::component("inbox"), thisRef().dynamicCast ()); } ref maildirStore::getFolder(const folder::path& path) { if (!isConnected()) throw exceptions::illegal_state("Not connected"); return vmime::create (path, thisRef().dynamicCast ()); } bool maildirStore::isValidFolderName(const folder::path::component& name) const { if (!platform::getHandler()->getFileSystemFactory()->isValidPathComponent(name)) return false; const string& buf = name.getBuffer(); // Name cannot start/end with spaces if (utility::stringUtils::trim(buf) != buf) return false; // Name cannot start with '.' const int length = buf.length(); int pos = 0; while ((pos < length) && (buf[pos] == '.')) ++pos; return (pos == 0); } void maildirStore::connect() { if (isConnected()) throw exceptions::already_connected(); // Get root directory ref fsf = platform::getHandler()->getFileSystemFactory(); m_fsPath = fsf->stringToPath(GET_PROPERTY(string, PROPERTY_SERVER_ROOTPATH)); ref rootDir = fsf->create(m_fsPath); // Try to create the root directory if it does not exist if (!(rootDir->exists() && rootDir->isDirectory())) { try { rootDir->createDirectory(); } catch (exceptions::filesystem_exception& e) { throw exceptions::connection_error("Cannot create root directory.", e); } } m_format = maildirFormat::detect(thisRef().dynamicCast ()); m_connected = true; } bool maildirStore::isConnected() const { return (m_connected); } bool maildirStore::isSecuredConnection() const { return false; } ref maildirStore::getConnectionInfos() const { return vmime::create ("localhost", static_cast (0)); } void maildirStore::disconnect() { for (std::list ::iterator it = m_folders.begin() ; it != m_folders.end() ; ++it) { (*it)->onStoreDisconnected(); } m_folders.clear(); m_connected = false; } void maildirStore::noop() { // Nothing to do. } ref maildirStore::getFormat() { return m_format; } ref maildirStore::getFormat() const { return m_format; } void maildirStore::registerFolder(maildirFolder* folder) { m_folders.push_back(folder); } void maildirStore::unregisterFolder(maildirFolder* folder) { std::list ::iterator it = std::find(m_folders.begin(), m_folders.end(), folder); if (it != m_folders.end()) m_folders.erase(it); } const utility::path& maildirStore::getFileSystemPath() const { return (m_fsPath); } int maildirStore::getCapabilities() const { return (CAPABILITY_CREATE_FOLDER | CAPABILITY_RENAME_FOLDER | CAPABILITY_ADD_MESSAGE | CAPABILITY_COPY_MESSAGE | CAPABILITY_DELETE_MESSAGE | CAPABILITY_PARTIAL_FETCH | CAPABILITY_MESSAGE_FLAGS | CAPABILITY_EXTRACT_PART); } // Service infos maildirServiceInfos maildirStore::sm_infos; const serviceInfos& maildirStore::getInfosInstance() { return sm_infos; } const serviceInfos& maildirStore::getInfos() const { return sm_infos; } } // maildir } // net } // vmime libvmime-0.9.1/src/net/maildir/format/0000755000175000017500000000000011607302336020116 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/maildir/format/kmailMaildirFormat.cpp0000644000175000017500000001711511314151075024374 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/format/kmailMaildirFormat.hpp" #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/net/maildir/maildirUtils.hpp" #include "vmime/platform.hpp" namespace vmime { namespace net { namespace maildir { namespace format { kmailMaildirFormat::kmailMaildirFormat(ref ctx) : maildirFormat(ctx) { } const string kmailMaildirFormat::getName() const { return "kmail"; } void kmailMaildirFormat::createFolder(const folder::path& path) { ref fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); ref rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); ref newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); ref tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); ref curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); rootDir->createDirectory(true); newDir->createDirectory(false); tmpDir->createDirectory(false); curDir->createDirectory(false); } void kmailMaildirFormat::destroyFolder(const folder::path& path) { // Delete 'folder' and '.folder.directory' directories ref fsf = platform::getHandler()->getFileSystemFactory(); maildirUtils::recursiveFSDelete(fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY))); // root maildirUtils::recursiveFSDelete(fsf->create (folderPathToFileSystemPath(path, CONTAINER_DIRECTORY))); // container } bool kmailMaildirFormat::folderExists(const folder::path& path) const { ref fsf = platform::getHandler()->getFileSystemFactory(); ref rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); ref newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); ref tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); ref curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); return rootDir->exists() && rootDir->isDirectory() && newDir->exists() && newDir->isDirectory() && tmpDir->exists() && tmpDir->isDirectory() && curDir->exists() && curDir->isDirectory(); } const utility::file::path kmailMaildirFormat::folderPathToFileSystemPath (const folder::path& path, const DirectoryType type) const { // Root path utility::file::path fsPath = getContext()->getStore()->getFileSystemPath(); const int count = (type == CONTAINER_DIRECTORY ? path.getSize() : path.getSize() - 1); // Parent folders for (int i = 0 ; i < count ; ++i) { utility::file::path::component comp(path[i]); // TODO: may not work with all encodings... comp.setBuffer("." + comp.getBuffer() + ".directory"); fsPath /= comp; } // Last component if (path.getSize() != 0 && type != CONTAINER_DIRECTORY) { fsPath /= path.getLastComponent(); switch (type) { case ROOT_DIRECTORY: // Nothing to add break; case NEW_DIRECTORY: fsPath /= NEW_DIR; break; case CUR_DIRECTORY: fsPath /= CUR_DIR; break; case TMP_DIRECTORY: fsPath /= TMP_DIR; break; case CONTAINER_DIRECTORY: // Can't happen... break; } } return fsPath; } const std::vector kmailMaildirFormat::listFolders (const folder::path& root, const bool recursive) const { std::vector list; listFoldersImpl(list, root, recursive); return list; } void kmailMaildirFormat::listFoldersImpl (std::vector & list, const folder::path& root, const bool recursive) const { ref fsf = platform::getHandler()->getFileSystemFactory(); ref rootDir = fsf->create(folderPathToFileSystemPath(root, root.isEmpty() ? ROOT_DIRECTORY : CONTAINER_DIRECTORY)); if (rootDir->exists()) { ref it = rootDir->getFiles(); while (it->hasMoreElements()) { ref file = it->nextElement(); if (isSubfolderDirectory(*file)) { const utility::path subPath = root / file->getFullPath().getLastComponent(); list.push_back(subPath); if (recursive) listFoldersImpl(list, subPath, true); } } } else { // No sub-folder } } // static bool kmailMaildirFormat::isSubfolderDirectory(const utility::file& file) { // A directory which name does not start with '.' is listed as a sub-folder if (file.isDirectory() && file.getFullPath().getLastComponent().getBuffer().length() >= 1 && file.getFullPath().getLastComponent().getBuffer()[0] != '.') { return true; } return false; } void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder::path& newPath) { ref fsf = platform::getHandler()->getFileSystemFactory(); ref rootDir = fsf->create (folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY)); ref contDir = fsf->create (folderPathToFileSystemPath(oldPath, CONTAINER_DIRECTORY)); try { const utility::file::path newRootPath = folderPathToFileSystemPath(newPath, ROOT_DIRECTORY); const utility::file::path newContPath = folderPathToFileSystemPath(newPath, CONTAINER_DIRECTORY); rootDir->rename(newRootPath); // Container directory may not exist, so ignore error when trying to rename it try { contDir->rename(newContPath); } catch (exceptions::filesystem_exception& e) { // Ignore } } catch (exceptions::filesystem_exception& e) { // Revert to old location const utility::file::path rootPath = folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY); const utility::file::path contPath = folderPathToFileSystemPath(oldPath, CONTAINER_DIRECTORY); try { rootDir->rename(rootPath); contDir->rename(contPath); } catch (exceptions::filesystem_exception& e) { // Ignore (not recoverable) } throw; } } bool kmailMaildirFormat::folderHasSubfolders(const folder::path& path) const { ref fsf = platform::getHandler()->getFileSystemFactory(); ref rootDir = fsf->create (folderPathToFileSystemPath(path, CONTAINER_DIRECTORY)); ref it = rootDir->getFiles(); while (it->hasMoreElements()) { ref file = it->nextElement(); if (isSubfolderDirectory(*file)) return true; } return false; } bool kmailMaildirFormat::supports() const { // This is the default return true; } } // format } // maildir } // net } // vmime libvmime-0.9.1/src/net/maildir/format/courierMaildirFormat.cpp0000644000175000017500000003144111314151075024745 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/format/courierMaildirFormat.hpp" #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/net/maildir/maildirUtils.hpp" #include "vmime/platform.hpp" namespace vmime { namespace net { namespace maildir { namespace format { courierMaildirFormat::courierMaildirFormat(ref ctx) : maildirFormat(ctx) { } const string courierMaildirFormat::getName() const { return "courier"; } void courierMaildirFormat::createFolder(const folder::path& path) { ref fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); ref rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); ref newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); ref tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); ref curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); rootDir->createDirectory(true); newDir->createDirectory(false); tmpDir->createDirectory(false); curDir->createDirectory(false); ref maildirFile = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY) / utility::file::path::component("maildirfolder")); maildirFile->createFile(); } void courierMaildirFormat::destroyFolder(const folder::path& path) { ref fsf = platform::getHandler()->getFileSystemFactory(); // Recursively delete directories of subfolders const std::vector folders = listFolders(path, true); for (unsigned int i = 0, n = folders.size() ; i < n ; ++i) { maildirUtils::recursiveFSDelete(fsf->create (folderPathToFileSystemPath(folders[i], ROOT_DIRECTORY))); } // Recursively delete the directory of this folder maildirUtils::recursiveFSDelete(fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY))); } void courierMaildirFormat::renameFolder (const folder::path& oldPath, const folder::path& newPath) { const std::vector folders = listFolders(oldPath, true); for (unsigned int i = 0, n = folders.size() ; i < n ; ++i) { const folder::path folderOldPath = folders[i]; folder::path folderNewPath = folderOldPath; folderNewPath.renameParent(oldPath, newPath); renameFolderImpl(folderOldPath, folderNewPath); } renameFolderImpl(oldPath, newPath); } void courierMaildirFormat::renameFolderImpl (const folder::path& oldPath, const folder::path& newPath) { ref fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path oldFSPath = folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY); const utility::file::path newFSPath = folderPathToFileSystemPath(newPath, ROOT_DIRECTORY); ref rootDir = fsf->create(oldFSPath); rootDir->rename(newFSPath); } bool courierMaildirFormat::folderExists(const folder::path& path) const { ref fsf = platform::getHandler()->getFileSystemFactory(); ref rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); ref newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); ref tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); ref curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); ref maildirFile = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY) / utility::file::path::component("maildirfolder")); bool exists = rootDir->exists() && rootDir->isDirectory() && newDir->exists() && newDir->isDirectory() && tmpDir->exists() && tmpDir->isDirectory() && curDir->exists() && curDir->isDirectory(); // If this is not the root folder, then a file named "maildirfolder" // must also be present in the directory if (!path.isRoot()) exists = exists && maildirFile->exists() && maildirFile->isFile(); return exists; } bool courierMaildirFormat::folderHasSubfolders(const folder::path& path) const { std::vector dirs; return listDirectories(path, dirs, true); } const utility::file::path courierMaildirFormat::folderPathToFileSystemPath (const folder::path& path, const DirectoryType type) const { // Virtual folder "/MyFolder/SubFolder" corresponds to physical // directory "[store root]/.MyFolder.SubFolder" utility::file::path fsPath = getContext()->getStore()->getFileSystemPath(); if (!path.isRoot()) { string folderComp; for (int i = 0, n = path.getSize() ; i < n ; ++i) folderComp += "." + toModifiedUTF7(path[i]); fsPath /= utility::file::path::component(folderComp); } // Last component switch (type) { case ROOT_DIRECTORY: // Nothing to add break; case NEW_DIRECTORY: fsPath /= NEW_DIR; break; case CUR_DIRECTORY: fsPath /= CUR_DIR; break; case TMP_DIRECTORY: fsPath /= TMP_DIR; break; case CONTAINER_DIRECTORY: // Not used break; } return fsPath; } const std::vector courierMaildirFormat::listFolders (const folder::path& root, const bool recursive) const { // First, list directories std::vector dirs; listDirectories(root, dirs, false); // Then, map directories to folders std::vector folders; for (unsigned int i = 0, n = dirs.size() ; i < n ; ++i) { const string dir = dirs[i].substr(1) + "."; folder::path path; for (string::size_type pos = dir.find("."), prev = 0 ; pos != string::npos ; prev = pos + 1, pos = dir.find(".", pos + 1)) { const string comp = dir.substr(prev, pos - prev); path /= fromModifiedUTF7(comp); } if (recursive || path.getSize() == root.getSize() + 1) folders.push_back(path); } return folders; } bool courierMaildirFormat::listDirectories(const folder::path& root, std::vector & dirs, const bool onlyTestForExistence) const { ref fsf = platform::getHandler()->getFileSystemFactory(); ref rootDir = fsf->create (getContext()->getStore()->getFileSystemPath()); if (rootDir->exists()) { // To speed up things, and if we are not searching in root folder, // search for directories with a common prefix string base; if (!root.isRoot()) { for (int i = 0, n = root.getSize() ; i < n ; ++i) base += "." + toModifiedUTF7(root[i]); } // Enumerate directories ref it = rootDir->getFiles(); while (it->hasMoreElements()) { ref file = it->nextElement(); if (isSubfolderDirectory(*file)) { const string dir = file->getFullPath().getLastComponent().getBuffer(); if (base.empty() || (dir.length() > base.length() && dir.substr(0, base.length()) == base)) { dirs.push_back(dir); if (onlyTestForExistence) return true; } } } } else { // No sub-folder } std::sort(dirs.begin(), dirs.end()); return !dirs.empty(); } // static bool courierMaildirFormat::isSubfolderDirectory(const utility::file& file) { // A directory which names starts with '.' may be a subfolder if (file.isDirectory() && file.getFullPath().getLastComponent().getBuffer().length() >= 1 && file.getFullPath().getLastComponent().getBuffer()[0] == '.') { return true; } return false; } // static const string courierMaildirFormat::toModifiedUTF7(const folder::path::component& text) { // From http://www.courier-mta.org/?maildir.html: // // Folder names can contain any Unicode character, except for control // characters. US-ASCII characters, U+0x0020 - U+0x007F, except for the // period, forward-slash, and ampersand characters (U+0x002E, U+0x002F, // and U+0x0026) represent themselves. The ampersand is represented by // the two character sequence "&-". The period, forward slash, and non // US-ASCII Unicode characters are represented using the UTF-7 character // set, and encoded with a modified form of base64-encoding. // // The "&" character starts the modified base64-encoded sequence; the // sequence is terminated by the "-" character. The sequence of 16-bit // Unicode characters is written in big-endian order, and encoded using // the base64-encoding method described in section 5.2 of RFC 1521, with // the following modifications: // // * The "=" padding character is omitted. When decoding, an incomplete // 16-bit character is discarded. // // * The comma character, "," is used in place of the "/" character in // the base64 alphabet. // // For example, the word "Resume" with both "e"s being the e-acute // character, U+0x00e9, is encoded as "R&AOk-sum&AOk-" (so a folder of // that name would be a maildir subdirectory called ".R&AOk-sum&AOk-"). // // Transcode path component to UTF-7 charset. // WARNING: This may throw "exceptions::charset_conv_error" const string cvt = text.getConvertedText(charset(charsets::UTF_7)); // Transcode to modified UTF-7 (RFC-2060). string out; out.reserve((cvt.length() * 3) / 2); bool inB64sequence = false; for (string::const_iterator it = cvt.begin() ; it != cvt.end() ; ++it) { const unsigned char c = *it; switch (c) { // Beginning of Base64 sequence: replace '+' with '&' case '+': { if (!inB64sequence) { inB64sequence = true; out += '&'; } else { out += '+'; } break; } // End of Base64 sequence case '-': { inB64sequence = false; out += '-'; break; } // ',' is used instead of '/' in modified Base64, // and simply UTF7-encoded out of a Base64 sequence case '/': { if (inB64sequence) out += ','; else out += "&Lw-"; break; } // Encode period (should not happen in a Base64 sequence) case '.': { out += "&Lg-"; break; } // '&' (0x26) is represented by the two-octet sequence "&-" case '&': { if (!inB64sequence) out += "&-"; else out += '&'; break; } default: { out += c; break; } } } return out; } // static const folder::path::component courierMaildirFormat::fromModifiedUTF7(const string& text) { // Transcode from modified UTF-7 string out; out.reserve(text.length()); bool inB64sequence = false; unsigned char prev = 0; for (string::const_iterator it = text.begin() ; it != text.end() ; ++it) { const unsigned char c = *it; switch (c) { // Start of Base64 sequence case '&': { if (!inB64sequence) { inB64sequence = true; out += '+'; } else { out += '&'; } break; } // End of Base64 sequence (or "&-" --> "&") case '-': { if (inB64sequence && prev == '&') out += '&'; else out += '-'; inB64sequence = false; break; } // ',' is used instead of '/' in modified Base64 case ',': { out += (inB64sequence ? '/' : ','); break; } default: { out += c; break; } } prev = c; } // Store it as UTF-8 by default string cvt; charset::convert(out, cvt, charset(charsets::UTF_7), charset(charsets::UTF_8)); return (folder::path::component(cvt, charset(charsets::UTF_8))); } bool courierMaildirFormat::supports() const { ref fsf = platform::getHandler()->getFileSystemFactory(); ref rootDir = fsf->create (getContext()->getStore()->getFileSystemPath()); if (rootDir->exists()) { // Try to find a file named "maildirfolder", which indicates // the Maildir is in Courier format ref it = rootDir->getFiles(); while (it->hasMoreElements()) { ref file = it->nextElement(); if (isSubfolderDirectory(*file)) { ref folderFile = fsf->create (file->getFullPath() / utility::file::path::component("maildirfolder")); if (folderFile->exists() && folderFile->isFile()) return true; } } } return false; } } // format } // maildir } // net } // vmime libvmime-0.9.1/src/net/maildir/maildirFormat.cpp0000644000175000017500000000503111333330451022116 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/maildirFormat.hpp" #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/net/maildir/format/kmailMaildirFormat.hpp" #include "vmime/net/maildir/format/courierMaildirFormat.hpp" #include "vmime/utility/file.hpp" namespace vmime { namespace net { namespace maildir { const utility::file::path::component maildirFormat::TMP_DIR("tmp", vmime::charset(vmime::charsets::US_ASCII)); const utility::file::path::component maildirFormat::CUR_DIR("cur", vmime::charset(vmime::charsets::US_ASCII)); const utility::file::path::component maildirFormat::NEW_DIR("new", vmime::charset(vmime::charsets::US_ASCII)); // // maildirFormat::context // maildirFormat::context::context(ref store) : m_store(store) { } ref maildirFormat::context::getStore() const { return m_store.acquire().constCast (); } // // maildirFormat // maildirFormat::maildirFormat(ref ctx) : m_context(ctx) { } ref maildirFormat::getContext() { return m_context; } ref maildirFormat::getContext() const { return m_context; } // static ref maildirFormat::detect(ref store) { ref ctx = create (store); // Try Courier format ref fmt = create (ctx); if (fmt->supports()) return fmt; // Default is KMail format return create (ctx); } } // maildir } // net } // vmime libvmime-0.9.1/src/net/maildir/maildirFolder.cpp0000644000175000017500000010240611314151075022107 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/maildirFolder.hpp" #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/net/maildir/maildirMessage.hpp" #include "vmime/net/maildir/maildirUtils.hpp" #include "vmime/net/maildir/maildirFormat.hpp" #include "vmime/utility/smartPtr.hpp" #include "vmime/message.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" namespace vmime { namespace net { namespace maildir { maildirFolder::maildirFolder(const folder::path& path, ref store) : m_store(store), m_path(path), m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1), m_open(false), m_unreadMessageCount(0), m_messageCount(0) { store->registerFolder(this); } maildirFolder::~maildirFolder() { ref store = m_store.acquire(); if (store) { if (m_open) close(false); store->unregisterFolder(this); } else if (m_open) { close(false); } } void maildirFolder::onStoreDisconnected() { m_store = NULL; } int maildirFolder::getMode() const { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); return (m_mode); } int maildirFolder::getType() { if (m_path.isEmpty()) return (TYPE_CONTAINS_FOLDERS); else return (TYPE_CONTAINS_FOLDERS | TYPE_CONTAINS_MESSAGES); } int maildirFolder::getFlags() { int flags = 0; if (m_store.acquire()->getFormat()->folderHasSubfolders(m_path)) flags |= FLAG_CHILDREN; // Contains at least one sub-folder return (flags); } const folder::path::component maildirFolder::getName() const { return (m_name); } const folder::path maildirFolder::getFullPath() const { return (m_path); } void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (isOpen()) throw exceptions::illegal_state("Folder is already open"); else if (!exists()) throw exceptions::illegal_state("Folder does not exist"); scanFolder(); m_open = true; m_mode = mode; } void maildirFolder::close(const bool expunge) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (!isOpen()) throw exceptions::illegal_state("Folder not open"); if (expunge) this->expunge(); m_open = false; m_mode = -1; onClose(); } void maildirFolder::onClose() { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { (*it)->onFolderClosed(); } m_messages.clear(); } void maildirFolder::registerMessage(maildirMessage* msg) { m_messages.push_back(msg); } void maildirFolder::unregisterMessage(maildirMessage* msg) { std::vector ::iterator it = std::find(m_messages.begin(), m_messages.end(), msg); if (it != m_messages.end()) m_messages.erase(it); } void maildirFolder::create(const int /* type */) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (isOpen()) throw exceptions::illegal_state("Folder is open"); else if (exists()) throw exceptions::illegal_state("Folder already exists"); else if (!store->isValidFolderName(m_name)) throw exceptions::invalid_folder_name(); // Create directory on file system try { store->getFormat()->createFolder(m_path); } catch (exceptions::filesystem_exception& e) { throw exceptions::command_error("CREATE", "", "File system exception", e); } // Notify folder created events::folderEvent event (thisRef().dynamicCast (), events::folderEvent::TYPE_CREATED, m_path, m_path); notifyFolder(event); } void maildirFolder::destroy() { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (isOpen()) throw exceptions::illegal_state("Folder is open"); // Delete folder try { store->getFormat()->destroyFolder(m_path); } catch (std::exception&) { // Ignore exception: anyway, we can't recover from this... } // Notify folder deleted events::folderEvent event (thisRef().dynamicCast (), events::folderEvent::TYPE_DELETED, m_path, m_path); notifyFolder(event); } bool maildirFolder::exists() { ref store = m_store.acquire(); return store->getFormat()->folderExists(m_path); } bool maildirFolder::isOpen() const { return (m_open); } void maildirFolder::scanFolder() { ref store = m_store.acquire(); try { m_messageCount = 0; m_unreadMessageCount = 0; ref fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path newDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::NEW_DIRECTORY); ref newDir = fsf->create(newDirPath); utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::CUR_DIRECTORY); ref curDir = fsf->create(curDirPath); // New received messages (new/) ref nit = newDir->getFiles(); std::vector newMessageFilenames; while (nit->hasMoreElements()) { ref file = nit->nextElement(); if (maildirUtils::isMessageFile(*file)) newMessageFilenames.push_back(file->getFullPath().getLastComponent()); } // Current messages (cur/) ref cit = curDir->getFiles(); std::vector curMessageFilenames; while (cit->hasMoreElements()) { ref file = cit->nextElement(); if (maildirUtils::isMessageFile(*file)) curMessageFilenames.push_back(file->getFullPath().getLastComponent()); } // Update/delete existing messages (found in previous scan) for (unsigned int i = 0 ; i < m_messageInfos.size() ; ++i) { messageInfos& msgInfos = m_messageInfos[i]; // NOTE: the flags may have changed (eg. moving from 'new' to 'cur' // may imply the 'S' flag) and so the filename. That's why we use // "maildirUtils::messageIdComparator" to compare only the 'unique' // portion of the filename... if (msgInfos.type == messageInfos::TYPE_CUR) { const std::vector ::iterator pos = std::find_if(curMessageFilenames.begin(), curMessageFilenames.end(), maildirUtils::messageIdComparator(msgInfos.path)); // If we cannot find this message in the 'cur' directory, // it means it has been deleted (and expunged). if (pos == curMessageFilenames.end()) { msgInfos.type = messageInfos::TYPE_DELETED; } // Otherwise, update its information. else { msgInfos.path = *pos; curMessageFilenames.erase(pos); } } } m_messageInfos.reserve(m_messageInfos.size() + newMessageFilenames.size() + curMessageFilenames.size()); // Add new messages from 'new': we are responsible to move the files // from the 'new' directory to the 'cur' directory, and append them // to our message list. for (std::vector ::const_iterator it = newMessageFilenames.begin() ; it != newMessageFilenames.end() ; ++it) { const utility::file::path::component newFilename = maildirUtils::buildFilename(maildirUtils::extractId(*it), 0); // Move messages from 'new' to 'cur' ref file = fsf->create(newDirPath / *it); file->rename(curDirPath / newFilename); // Append to message list messageInfos msgInfos; msgInfos.path = newFilename; if (maildirUtils::extractFlags(msgInfos.path) & message::FLAG_DELETED) msgInfos.type = messageInfos::TYPE_DELETED; else msgInfos.type = messageInfos::TYPE_CUR; m_messageInfos.push_back(msgInfos); } // Add new messages from 'cur': the files have already been moved // from 'new' to 'cur'. Just append them to our message list. for (std::vector ::const_iterator it = curMessageFilenames.begin() ; it != curMessageFilenames.end() ; ++it) { // Append to message list messageInfos msgInfos; msgInfos.path = *it; if (maildirUtils::extractFlags(msgInfos.path) & message::FLAG_DELETED) msgInfos.type = messageInfos::TYPE_DELETED; else msgInfos.type = messageInfos::TYPE_CUR; m_messageInfos.push_back(msgInfos); } // Update message count int unreadMessageCount = 0; for (std::vector ::const_iterator it = m_messageInfos.begin() ; it != m_messageInfos.end() ; ++it) { if ((maildirUtils::extractFlags((*it).path) & message::FLAG_SEEN) == 0) ++unreadMessageCount; } m_unreadMessageCount = unreadMessageCount; m_messageCount = m_messageInfos.size(); } catch (exceptions::filesystem_exception&) { // Should not happen... } } ref maildirFolder::getMessage(const int num) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); if (num < 1 || num > m_messageCount) throw exceptions::message_not_found(); return vmime::create (thisRef().dynamicCast (), num); } std::vector > maildirFolder::getMessages(const int from, const int to) { const int to2 = (to == -1 ? m_messageCount : to); if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (to2 < from || from < 1 || to2 < 1 || from > m_messageCount || to2 > m_messageCount) throw exceptions::message_not_found(); std::vector > v; ref thisFolder = thisRef().dynamicCast (); for (int i = from ; i <= to2 ; ++i) v.push_back(vmime::create (thisFolder, i)); return (v); } std::vector > maildirFolder::getMessages(const std::vector & nums) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); std::vector > v; ref thisFolder = thisRef().dynamicCast (); for (std::vector ::const_iterator it = nums.begin() ; it != nums.end() ; ++it) v.push_back(vmime::create (thisFolder, *it)); return (v); } int maildirFolder::getMessageCount() { return (m_messageCount); } ref maildirFolder::getFolder(const folder::path::component& name) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); return vmime::create (m_path / name, store); } std::vector > maildirFolder::getFolders(const bool recursive) { ref store = m_store.acquire(); if (!isOpen() && !store) throw exceptions::illegal_state("Store disconnected"); std::vector > list; listFolders(list, recursive); return (list); } void maildirFolder::listFolders(std::vector >& list, const bool recursive) { ref store = m_store.acquire(); try { std::vector pathList = store->getFormat()->listFolders(m_path, recursive); list.reserve(pathList.size()); for (unsigned int i = 0, n = pathList.size() ; i < n ; ++i) { ref subFolder = vmime::create (pathList[i], store); list.push_back(subFolder); } } catch (exceptions::filesystem_exception& e) { throw exceptions::command_error("LIST", "", "", e); } } void maildirFolder::rename(const folder::path& newPath) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (m_path.isEmpty() || newPath.isEmpty()) throw exceptions::illegal_operation("Cannot rename root folder"); else if (!store->isValidFolderName(newPath.getLastComponent())) throw exceptions::invalid_folder_name(); // Rename the directory on the file system try { store->getFormat()->renameFolder(m_path, newPath); } catch (vmime::exception& e) { throw exceptions::command_error("RENAME", "", "", e); } // Notify folder renamed folder::path oldPath(m_path); m_path = newPath; m_name = newPath.getLastComponent(); events::folderEvent event (thisRef().dynamicCast (), events::folderEvent::TYPE_RENAMED, oldPath, newPath); notifyFolder(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == oldPath) { (*it)->m_path = newPath; (*it)->m_name = newPath.getLastComponent(); events::folderEvent event ((*it)->thisRef().dynamicCast (), events::folderEvent::TYPE_RENAMED, oldPath, newPath); (*it)->notifyFolder(event); } else if ((*it) != this && oldPath.isParentOf((*it)->getFullPath())) { folder::path oldPath((*it)->m_path); (*it)->m_path.renameParent(oldPath, newPath); events::folderEvent event ((*it)->thisRef().dynamicCast (), events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path); (*it)->notifyFolder(event); } } } void maildirFolder::deleteMessage(const int num) { // Mark messages as deleted setMessageFlags(num, num, message::FLAG_DELETED, message::FLAG_MODE_ADD); } void maildirFolder::deleteMessages(const int from, const int to) { // Mark messages as deleted setMessageFlags(from, to, message::FLAG_DELETED, message::FLAG_MODE_ADD); } void maildirFolder::deleteMessages(const std::vector & nums) { // Mark messages as deleted setMessageFlags(nums, message::FLAG_DELETED, message::FLAG_MODE_ADD); } void maildirFolder::setMessageFlags (const int from, const int to, const int flags, const int mode) { ref store = m_store.acquire(); if (from < 1 || (to < from && to != -1)) throw exceptions::invalid_argument(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Construct the list of message numbers const int to2 = (to == -1) ? m_messageCount : to; const int count = to - from + 1; std::vector nums; nums.resize(count); for (int i = from, j = 0 ; i <= to2 ; ++i, ++j) nums[j] = i; // Change message flags setMessageFlagsImpl(nums, flags, mode); // Update local flags switch (mode) { case message::FLAG_MODE_ADD: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() >= from && (*it)->getNumber() <= to2 && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags |= flags; } } break; } case message::FLAG_MODE_REMOVE: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() >= from && (*it)->getNumber() <= to2 && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags &= ~flags; } } break; } default: case message::FLAG_MODE_SET: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->getNumber() >= from && (*it)->getNumber() <= to2 && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags = flags; } } break; } } // Notify message flags changed events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); // TODO: notify other folders with the same path } void maildirFolder::setMessageFlags (const std::vector & nums, const int flags, const int mode) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); // Sort the list of message numbers std::vector list; list.resize(nums.size()); std::copy(nums.begin(), nums.end(), list.begin()); std::sort(list.begin(), list.end()); // Change message flags setMessageFlagsImpl(list, flags, mode); // Update local flags switch (mode) { case message::FLAG_MODE_ADD: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(list.begin(), list.end(), (*it)->getNumber()) && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags |= flags; } } break; } case message::FLAG_MODE_REMOVE: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(list.begin(), list.end(), (*it)->getNumber()) && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags &= ~flags; } } break; } default: case message::FLAG_MODE_SET: { for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(list.begin(), list.end(), (*it)->getNumber()) && (*it)->m_flags != message::FLAG_UNDEFINED) { (*it)->m_flags = flags; } } break; } } // Notify message flags changed events::messageChangedEvent event (thisRef().dynamicCast (), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); // TODO: notify other folders with the same path } void maildirFolder::setMessageFlagsImpl (const std::vector & nums, const int flags, const int mode) { ref store = m_store.acquire(); ref fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); for (std::vector ::const_iterator it = nums.begin() ; it != nums.end() ; ++it) { const int num = *it - 1; try { const utility::file::path::component path = m_messageInfos[num].path; ref file = fsf->create(curDirPath / path); int newFlags = maildirUtils::extractFlags(path); switch (mode) { case message::FLAG_MODE_ADD: newFlags |= flags; break; case message::FLAG_MODE_REMOVE: newFlags &= ~flags; break; default: case message::FLAG_MODE_SET: newFlags = flags; break; } const utility::file::path::component newPath = maildirUtils::buildFilename (maildirUtils::extractId(path), newFlags); file->rename(curDirPath / newPath); if (flags & message::FLAG_DELETED) m_messageInfos[num].type = messageInfos::TYPE_DELETED; else m_messageInfos[num].type = messageInfos::TYPE_CUR; m_messageInfos[num].path = newPath; } catch (exceptions::filesystem_exception& e) { // Ignore (not important) } } } void maildirFolder::addMessage(ref msg, const int flags, vmime::datetime* date, utility::progressListener* progress) { std::ostringstream oss; utility::outputStreamAdapter ossAdapter(oss); msg->generate(ossAdapter); const std::string& str = oss.str(); utility::inputStreamStringAdapter strAdapter(str); addMessage(strAdapter, str.length(), flags, date, progress); } void maildirFolder::addMessage(utility::inputStream& is, const int size, const int flags, vmime::datetime* /* date */, utility::progressListener* progress) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); ref fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path tmpDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY); utility::file::path dstDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path, flags == message::FLAG_RECENT ? maildirFormat::NEW_DIRECTORY : maildirFormat::CUR_DIRECTORY); const utility::file::path::component filename = maildirUtils::buildFilename(maildirUtils::generateId(), ((flags == message::FLAG_UNDEFINED) ? 0 : flags)); try { ref tmpDir = fsf->create(tmpDirPath); tmpDir->createDirectory(true); } catch (exceptions::filesystem_exception&) { // Don't throw now, it will fail later... } try { ref curDir = fsf->create(dstDirPath); curDir->createDirectory(true); } catch (exceptions::filesystem_exception&) { // Don't throw now, it will fail later... } // Actually add the message copyMessageImpl(tmpDirPath, dstDirPath, filename, is, size, progress); // Append the message to the cache list messageInfos msgInfos; msgInfos.path = filename; msgInfos.type = messageInfos::TYPE_CUR; m_messageInfos.push_back(msgInfos); m_messageCount++; if ((flags == message::FLAG_UNDEFINED) || !(flags & message::FLAG_SEEN)) m_unreadMessageCount++; // Notification std::vector nums; nums.push_back(m_messageCount); events::messageCountEvent event (thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == m_path) { (*it)->m_messageCount = m_messageCount; (*it)->m_unreadMessageCount = m_unreadMessageCount; (*it)->m_messageInfos.resize(m_messageInfos.size()); std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin()); events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); } } } void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, const utility::file::path& dstDirPath, const utility::file::path::component& filename, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress) { ref fsf = platform::getHandler()->getFileSystemFactory(); ref file = fsf->create(tmpDirPath / filename); if (progress) progress->start(size); // First, write the message into 'tmp'... try { file->createFile(); ref fw = file->getFileWriter(); ref os = fw->getOutputStream(); utility::stream::value_type buffer[65536]; utility::stream::size_type total = 0; while (!is.eof()) { const utility::stream::size_type read = is.read(buffer, sizeof(buffer)); if (read != 0) { os->write(buffer, read); total += read; } if (progress) progress->progress(total, size); } os->flush(); } catch (exception& e) { if (progress) progress->stop(size); // Delete temporary file try { ref file = fsf->create(tmpDirPath / filename); file->remove(); } catch (exceptions::filesystem_exception&) { // Ignore } throw exceptions::command_error("ADD", "", "", e); } // ...then, move it to 'cur' try { file->rename(dstDirPath / filename); } catch (exception& e) { if (progress) progress->stop(size); // Delete temporary file try { file->remove(); ref file = fsf->create(dstDirPath / filename); file->remove(); } catch (exceptions::filesystem_exception&) { // Ignore } throw exceptions::command_error("ADD", "", "", e); } if (progress) progress->stop(size); } void maildirFolder::copyMessage(const folder::path& dest, const int num) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); copyMessages(dest, num, num); } void maildirFolder::copyMessages(const folder::path& dest, const int from, const int to) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (from < 1 || (to < from && to != -1)) throw exceptions::invalid_argument(); // Construct the list of message numbers const int to2 = (to == -1) ? m_messageCount : to; const int count = to - from + 1; std::vector nums; nums.resize(count); for (int i = from, j = 0 ; i <= to2 ; ++i, ++j) nums[j] = i; // Copy messages copyMessagesImpl(dest, nums); } void maildirFolder::copyMessages(const folder::path& dest, const std::vector & nums) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); // Copy messages copyMessagesImpl(dest, nums); } void maildirFolder::copyMessagesImpl(const folder::path& dest, const std::vector & nums) { ref store = m_store.acquire(); ref fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::CUR_DIRECTORY); utility::file::path destCurDirPath = store->getFormat()-> folderPathToFileSystemPath(dest, maildirFormat::CUR_DIRECTORY); utility::file::path destTmpDirPath = store->getFormat()-> folderPathToFileSystemPath(dest, maildirFormat::TMP_DIRECTORY); // Create destination directories try { ref destTmpDir = fsf->create(destTmpDirPath); destTmpDir->createDirectory(true); } catch (exceptions::filesystem_exception&) { // Don't throw now, it will fail later... } try { ref destCurDir = fsf->create(destCurDirPath); destCurDir->createDirectory(true); } catch (exceptions::filesystem_exception&) { // Don't throw now, it will fail later... } // Copy messages try { for (std::vector ::const_iterator it = nums.begin() ; it != nums.end() ; ++it) { const int num = *it; const messageInfos& msg = m_messageInfos[num - 1]; const int flags = maildirUtils::extractFlags(msg.path); const utility::file::path::component filename = maildirUtils::buildFilename(maildirUtils::generateId(), flags); ref file = fsf->create(curDirPath / msg.path); ref fr = file->getFileReader(); ref is = fr->getInputStream(); copyMessageImpl(destTmpDirPath, destCurDirPath, filename, *is, file->getLength(), NULL); } } catch (exception& e) { notifyMessagesCopied(dest); throw exceptions::command_error("COPY", "", "", e); } notifyMessagesCopied(dest); } void maildirFolder::notifyMessagesCopied(const folder::path& dest) { ref store = m_store.acquire(); for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == dest) { // We only need to update the first folder we found as calling // status() will notify all the folders with the same path. int count, unseen; (*it)->status(count, unseen); return; } } } void maildirFolder::status(int& count, int& unseen) { ref store = m_store.acquire(); const int oldCount = m_messageCount; scanFolder(); count = m_messageCount; unseen = m_unreadMessageCount; // Notify message count changed (new messages) if (count > oldCount) { std::vector nums; nums.reserve(count - oldCount); for (int i = oldCount + 1, j = 0 ; i <= count ; ++i, ++j) nums[j] = i; events::messageCountEvent event (thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == m_path) { (*it)->m_messageCount = m_messageCount; (*it)->m_unreadMessageCount = m_unreadMessageCount; (*it)->m_messageInfos.resize(m_messageInfos.size()); std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin()); events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); } } } } void maildirFolder::expunge() { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); ref fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); std::vector nums; int unreadCount = 0; for (int num = 1 ; num <= m_messageCount ; ++num) { messageInfos& infos = m_messageInfos[num - 1]; if (infos.type == messageInfos::TYPE_DELETED) { nums.push_back(num); for (std::vector ::iterator it = m_messages.begin() ; it != m_messages.end() ; ++it) { if ((*it)->m_num == num) (*it)->m_expunged = true; else if ((*it)->m_num > num) (*it)->m_num--; } if (maildirUtils::extractFlags(infos.path) & message::FLAG_SEEN) ++unreadCount; // Delete file from file system try { ref file = fsf->create(curDirPath / infos.path); file->remove(); } catch (exceptions::filesystem_exception& e) { // Ignore (not important) } } } if (!nums.empty()) { for (int i = nums.size() - 1 ; i >= 0 ; --i) m_messageInfos.erase(m_messageInfos.begin() + i); } m_messageCount -= nums.size(); m_unreadMessageCount -= unreadCount; // Notify message expunged events::messageCountEvent event (thisRef().dynamicCast (), events::messageCountEvent::TYPE_REMOVED, nums); notifyMessageCount(event); // Notify folders with the same path for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) { if ((*it) != this && (*it)->getFullPath() == m_path) { (*it)->m_messageCount = m_messageCount; (*it)->m_unreadMessageCount = m_unreadMessageCount; (*it)->m_messageInfos.resize(m_messageInfos.size()); std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin()); events::messageCountEvent event ((*it)->thisRef().dynamicCast (), events::messageCountEvent::TYPE_REMOVED, nums); (*it)->notifyMessageCount(event); } } } ref maildirFolder::getParent() { if (m_path.isEmpty()) return NULL; else return vmime::create (m_path.getParent(), m_store.acquire()); } ref maildirFolder::getStore() const { return m_store.acquire(); } ref maildirFolder::getStore() { return m_store.acquire(); } void maildirFolder::fetchMessages(std::vector >& msg, const int options, utility::progressListener* progress) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); const int total = msg.size(); int current = 0; if (progress) progress->start(total); ref thisFolder = thisRef().dynamicCast (); for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { (*it).dynamicCast ()->fetch(thisFolder, options); if (progress) progress->progress(++current, total); } if (progress) progress->stop(total); } void maildirFolder::fetchMessage(ref msg, const int options) { ref store = m_store.acquire(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); msg.dynamicCast ()->fetch (thisRef().dynamicCast (), options); } int maildirFolder::getFetchCapabilities() const { return (FETCH_ENVELOPE | FETCH_STRUCTURE | FETCH_CONTENT_INFO | FETCH_FLAGS | FETCH_SIZE | FETCH_FULL_HEADER | FETCH_UID | FETCH_IMPORTANCE); } const utility::file::path maildirFolder::getMessageFSPath(const int number) const { utility::file::path curDirPath = m_store.acquire()->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); return (curDirPath / m_messageInfos[number - 1].path); } } // maildir } // net } // vmime libvmime-0.9.1/src/net/maildir/maildirUtils.cpp0000644000175000017500000001340411457315061022000 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/maildirUtils.hpp" #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/utility/random.hpp" #include "vmime/platform.hpp" #include "vmime/exception.hpp" namespace vmime { namespace net { namespace maildir { bool maildirUtils::isMessageFile(const utility::file& file) { // Ignore files which name begins with '.' if (file.isFile() && file.getFullPath().getLastComponent().getBuffer().length() >= 1 && file.getFullPath().getLastComponent().getBuffer()[0] != '.') { return (true); } return (false); } // NOTE ABOUT ID/FLAGS SEPARATOR // ----------------------------- // In the maildir specification, the character ':' is used to separate // the unique identifier and the message flags. // // On Windows (and particularly FAT file systems), ':' is not allowed // in a filename, so we use a dash ('-') instead. This is the solution // used by Mutt/Win32, so we also use it here. // // To be compatible between implementations, we check for both // characters when reading file names. const utility::file::path::component maildirUtils::extractId (const utility::file::path::component& filename) { string::size_type sep = filename.getBuffer().rfind(':'); // try colon if (sep == string::npos) { sep = filename.getBuffer().rfind('-'); // try dash (Windows) if (sep == string::npos) return (filename); } return (utility::path::component (string(filename.getBuffer().begin(), filename.getBuffer().begin() + sep))); } int maildirUtils::extractFlags(const utility::file::path::component& comp) { string::size_type sep = comp.getBuffer().rfind(':'); // try colon if (sep == string::npos) { sep = comp.getBuffer().rfind('-'); // try dash (Windows) if (sep == string::npos) return 0; } const string flagsString(comp.getBuffer().begin() + sep + 1, comp.getBuffer().end()); const string::size_type count = flagsString.length(); int flags = 0; for (string::size_type i = 0 ; i < count ; ++i) { switch (flagsString[i]) { case 'R': case 'r': flags |= message::FLAG_REPLIED; break; case 'S': case 's': flags |= message::FLAG_SEEN; break; case 'T': case 't': flags |= message::FLAG_DELETED; break; case 'F': case 'f': flags |= message::FLAG_MARKED; break; case 'P': case 'p': flags |= message::FLAG_PASSED; break; case 'D': case 'd': flags |= message::FLAG_DRAFT; break; } } return (flags); } const utility::file::path::component maildirUtils::buildFlags(const int flags) { string str; str.reserve(8); str += "2,"; if (flags & message::FLAG_MARKED) str += "F"; if (flags & message::FLAG_PASSED) str += "P"; if (flags & message::FLAG_REPLIED) str += "R"; if (flags & message::FLAG_SEEN) str += "S"; if (flags & message::FLAG_DELETED) str += "T"; if (flags & message::FLAG_DRAFT) str += "D"; return (utility::file::path::component(str)); } const utility::file::path::component maildirUtils::buildFilename (const utility::file::path::component& id, const int flags) { if (flags == message::FLAG_RECENT) return id; else return (buildFilename(id, buildFlags(flags))); } const utility::file::path::component maildirUtils::buildFilename (const utility::file::path::component& id, const utility::file::path::component& flags) { #if VMIME_BUILTIN_PLATFORM_WINDOWS static const char DELIMITER[] = "-"; #else static const char DELIMITER[] = ":"; #endif return utility::path::component(id.getBuffer() + DELIMITER + flags.getBuffer()); } const utility::file::path::component maildirUtils::generateId() { std::ostringstream oss; oss.imbue(std::locale::classic()); oss << utility::random::getTime(); oss << "."; oss << utility::random::getProcess(); oss << "."; oss << utility::random::getString(6); oss << "."; oss << platform::getHandler()->getHostName(); return (utility::file::path::component(oss.str())); } void maildirUtils::recursiveFSDelete(ref dir) { ref files = dir->getFiles(); // First, delete files and subdirectories in this directory while (files->hasMoreElements()) { ref file = files->nextElement(); if (file->isDirectory()) { maildirUtils::recursiveFSDelete(file); } else { try { file->remove(); } catch (exceptions::filesystem_exception&) { // Ignore } } } // Then, delete this (empty) directory try { dir->remove(); } catch (exceptions::filesystem_exception&) { // Ignore } } // // messageIdComparator // maildirUtils::messageIdComparator::messageIdComparator (const utility::file::path::component& comp) : m_comp(maildirUtils::extractId(comp)) { } bool maildirUtils::messageIdComparator::operator() (const utility::file::path::component& other) const { return (m_comp == maildirUtils::extractId(other)); } } // maildir } // net } // vmime libvmime-0.9.1/src/net/maildir/maildirMessage.cpp0000644000175000017500000002760411374321410022264 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/maildir/maildirMessage.hpp" #include "vmime/net/maildir/maildirFolder.hpp" #include "vmime/net/maildir/maildirUtils.hpp" #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/message.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" namespace vmime { namespace net { namespace maildir { // // maildirPart // class maildirStructure; class maildirPart : public part { public: maildirPart(ref parent, const int number, const bodyPart& part); ~maildirPart(); ref getStructure() const; ref getStructure(); weak_ref getParent() const { return (m_parent); } const mediaType& getType() const { return (m_mediaType); } int getSize() const { return (m_size); } int getNumber() const { return (m_number); } ref getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); else return m_header; } header& getOrCreateHeader() { if (m_header != NULL) return (*m_header); else return (*(m_header = vmime::create
())); } int getHeaderParsedOffset() const { return (m_headerParsedOffset); } int getHeaderParsedLength() const { return (m_headerParsedLength); } int getBodyParsedOffset() const { return (m_bodyParsedOffset); } int getBodyParsedLength() const { return (m_bodyParsedLength); } void initStructure(const bodyPart& part); private: ref m_structure; weak_ref m_parent; ref
m_header; int m_number; int m_size; mediaType m_mediaType; int m_headerParsedOffset; int m_headerParsedLength; int m_bodyParsedOffset; int m_bodyParsedLength; }; // // maildirStructure // class maildirStructure : public structure { public: maildirStructure() { } maildirStructure(ref parent, const bodyPart& part) { vmime::ref mpart = vmime::create (parent, 0, part); mpart->initStructure(part); m_parts.push_back(mpart); } maildirStructure(ref parent, const std::vector >& list) { for (unsigned int i = 0 ; i < list.size() ; ++i) { vmime::ref mpart = vmime::create (parent, i, *list[i]); mpart->initStructure(*list[i]); m_parts.push_back(mpart); } } ref getPartAt(const int x) const { return m_parts[x]; } ref getPartAt(const int x) { return m_parts[x]; } int getPartCount() const { return m_parts.size(); } static ref emptyStructure() { return m_emptyStructure; } private: static ref m_emptyStructure; std::vector > m_parts; }; ref maildirStructure::m_emptyStructure = vmime::create (); maildirPart::maildirPart(ref parent, const int number, const bodyPart& part) : m_parent(parent), m_header(NULL), m_number(number) { m_headerParsedOffset = part.getHeader()->getParsedOffset(); m_headerParsedLength = part.getHeader()->getParsedLength(); m_bodyParsedOffset = part.getBody()->getParsedOffset(); m_bodyParsedLength = part.getBody()->getParsedLength(); m_size = part.getBody()->getContents()->getLength(); m_mediaType = part.getBody()->getContentType(); } maildirPart::~maildirPart() { } void maildirPart::initStructure(const bodyPart& part) { if (part.getBody()->getPartList().size() == 0) m_structure = NULL; else { m_structure = vmime::create (thisRef().dynamicCast (), part.getBody()->getPartList()); } } ref maildirPart::getStructure() const { if (m_structure != NULL) return m_structure; else return maildirStructure::emptyStructure(); } ref maildirPart::getStructure() { if (m_structure != NULL) return m_structure; else return maildirStructure::emptyStructure(); } // // maildirMessage // maildirMessage::maildirMessage(ref folder, const int num) : m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED), m_expunged(false), m_structure(NULL) { folder->registerMessage(this); } maildirMessage::~maildirMessage() { ref folder = m_folder.acquire(); if (folder) folder->unregisterMessage(this); } void maildirMessage::onFolderClosed() { m_folder = NULL; } int maildirMessage::getNumber() const { return (m_num); } const message::uid maildirMessage::getUniqueId() const { return (m_uid); } int maildirMessage::getSize() const { if (m_size == -1) throw exceptions::unfetched_object(); return (m_size); } bool maildirMessage::isExpunged() const { return (m_expunged); } ref maildirMessage::getStructure() const { if (m_structure == NULL) throw exceptions::unfetched_object(); return m_structure; } ref maildirMessage::getStructure() { if (m_structure == NULL) throw exceptions::unfetched_object(); return m_structure; } ref maildirMessage::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); return (m_header); } int maildirMessage::getFlags() const { if (m_flags == FLAG_UNDEFINED) throw exceptions::unfetched_object(); return (m_flags); } void maildirMessage::setFlags(const int flags, const int mode) { ref folder = m_folder.acquire(); if (!folder) throw exceptions::folder_not_found(); folder->setMessageFlags(m_num, m_num, flags, mode); } void maildirMessage::extract(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { extractImpl(os, progress, 0, m_size, start, length, peek); } void maildirMessage::extractPart(ref p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { ref mp = p.dynamicCast (); extractImpl(os, progress, mp->getBodyParsedOffset(), mp->getBodyParsedLength(), start, length, peek); } void maildirMessage::extractImpl(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const int partialStart, const int partialLength, const bool /* peek */) const { ref folder = m_folder.acquire(); ref fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); ref file = fsf->create(path); ref reader = file->getFileReader(); ref is = reader->getInputStream(); is->skip(start + partialStart); utility::stream::value_type buffer[8192]; utility::stream::size_type remaining = (partialLength == -1 ? length : std::min(partialLength, length)); const int total = remaining; int current = 0; if (progress) progress->start(total); while (!is->eof() && remaining > 0) { const utility::stream::size_type read = is->read(buffer, std::min(remaining, sizeof(buffer))); remaining -= read; current += read; os.write(buffer, read); if (progress) progress->progress(current, total); } if (progress) progress->stop(total); // TODO: mark as read unless 'peek' is set } void maildirMessage::fetchPartHeader(ref p) { ref folder = m_folder.acquire(); ref mp = p.dynamicCast (); ref fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); ref file = fsf->create(path); ref reader = file->getFileReader(); ref is = reader->getInputStream(); is->skip(mp->getHeaderParsedOffset()); utility::stream::value_type buffer[1024]; utility::stream::size_type remaining = mp->getHeaderParsedLength(); string contents; contents.reserve(remaining); while (!is->eof() && remaining > 0) { const utility::stream::size_type read = is->read(buffer, std::min(remaining, sizeof(buffer))); remaining -= read; contents.append(buffer, read); } mp->getOrCreateHeader().parse(contents); } void maildirMessage::fetch(ref msgFolder, const int options) { ref folder = m_folder.acquire(); if (folder != msgFolder) throw exceptions::folder_not_found(); ref fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); ref file = fsf->create(path); if (options & folder::FETCH_FLAGS) m_flags = maildirUtils::extractFlags(path.getLastComponent()); if (options & folder::FETCH_SIZE) m_size = file->getLength(); if (options & folder::FETCH_UID) m_uid = maildirUtils::extractId(path.getLastComponent()).getBuffer(); if (options & (folder::FETCH_ENVELOPE | folder::FETCH_CONTENT_INFO | folder::FETCH_FULL_HEADER | folder::FETCH_STRUCTURE | folder::FETCH_IMPORTANCE)) { string contents; ref reader = file->getFileReader(); ref is = reader->getInputStream(); // Need whole message contents for structure if (options & folder::FETCH_STRUCTURE) { utility::stream::value_type buffer[16384]; contents.reserve(file->getLength()); while (!is->eof()) { const utility::stream::size_type read = is->read(buffer, sizeof(buffer)); contents.append(buffer, read); } } // Need only header else { utility::stream::value_type buffer[1024]; contents.reserve(4096); while (!is->eof()) { const utility::stream::size_type read = is->read(buffer, sizeof(buffer)); contents.append(buffer, read); const string::size_type sep1 = contents.rfind("\r\n\r\n"); const string::size_type sep2 = contents.rfind("\n\n"); if (sep1 != string::npos) { contents.erase(contents.begin() + sep1 + 4, contents.end()); break; } else if (sep2 != string::npos) { contents.erase(contents.begin() + sep2 + 2, contents.end()); break; } } } vmime::message msg; msg.parse(contents); // Extract structure if (options & folder::FETCH_STRUCTURE) { m_structure = vmime::create (null, msg); } // Extract some header fields or whole header if (options & (folder::FETCH_ENVELOPE | folder::FETCH_CONTENT_INFO | folder::FETCH_FULL_HEADER | folder::FETCH_IMPORTANCE)) { getOrCreateHeader()->copyFrom(*(msg.getHeader())); } } } ref
maildirMessage::getOrCreateHeader() { if (m_header != NULL) return (m_header); else return (m_header = vmime::create
()); } ref maildirMessage::getParsedMessage() { std::ostringstream oss; utility::outputStreamAdapter os(oss); extract(os); vmime::ref msg = vmime::create (); msg->parse(oss.str()); return msg; } } // maildir } // net } // vmime libvmime-0.9.1/src/net/defaultConnectionInfos.cpp0000644000175000017500000000263311250723263022360 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/defaultConnectionInfos.hpp" namespace vmime { namespace net { defaultConnectionInfos::defaultConnectionInfos(const string& host, const port_t port) : m_host(host), m_port(port) { } const string defaultConnectionInfos::getHost() const { return m_host; } port_t defaultConnectionInfos::getPort() const { return m_port; } } // net } // vmime libvmime-0.9.1/src/net/folder.cpp0000644000175000017500000000523011250723263017164 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/folder.hpp" #include namespace vmime { namespace net { void folder::addMessageChangedListener(events::messageChangedListener* l) { m_messageChangedListeners.push_back(l); } void folder::removeMessageChangedListener(events::messageChangedListener* l) { std::remove(m_messageChangedListeners.begin(), m_messageChangedListeners.end(), l); } void folder::notifyMessageChanged(const events::messageChangedEvent& event) { for (std::list ::iterator it = m_messageChangedListeners.begin() ; it != m_messageChangedListeners.end() ; ++it) { event.dispatch(*it); } } void folder::addMessageCountListener(events::messageCountListener* l) { m_messageCountListeners.push_back(l); } void folder::removeMessageCountListener(events::messageCountListener* l) { std::remove(m_messageCountListeners.begin(), m_messageCountListeners.end(), l); } void folder::notifyMessageCount(const events::messageCountEvent& event) { for (std::list ::iterator it = m_messageCountListeners.begin() ; it != m_messageCountListeners.end() ; ++it) { event.dispatch(*it); } } void folder::addFolderListener(events::folderListener* l) { m_folderListeners.push_back(l); } void folder::removeFolderListener(events::folderListener* l) { std::remove(m_folderListeners.begin(), m_folderListeners.end(), l); } void folder::notifyFolder(const events::folderEvent& event) { for (std::list ::iterator it = m_folderListeners.begin() ; it != m_folderListeners.end() ; ++it) { event.dispatch(*it); } } } // net } // vmime libvmime-0.9.1/src/net/sendmail/0000755000175000017500000000000011607302336017001 5ustar mnordstrmnordstrlibvmime-0.9.1/src/net/sendmail/sendmailTransport.cpp0000644000175000017500000001212611250723263023220 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/sendmail/sendmailTransport.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" #include "vmime/message.hpp" #include "vmime/mailboxList.hpp" #include "vmime/utility/filteredStream.hpp" #include "vmime/utility/childProcess.hpp" #include "vmime/utility/smartPtr.hpp" #include "vmime/net/defaultConnectionInfos.hpp" #include "vmime/config.hpp" // Helpers for service properties #define GET_PROPERTY(type, prop) \ (getInfos().getPropertyValue (getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ (getInfos().hasProperty(getSession(), \ dynamic_cast (getInfos()).getProperties().prop)) #if VMIME_BUILTIN_PLATFORM_POSIX namespace vmime { namespace net { namespace sendmail { sendmailTransport::sendmailTransport(ref sess, ref auth) : transport(sess, getInfosInstance(), auth), m_connected(false) { } sendmailTransport::~sendmailTransport() { try { if (isConnected()) disconnect(); } catch (vmime::exception&) { // Ignore } } const string sendmailTransport::getProtocolName() const { return "sendmail"; } void sendmailTransport::connect() { if (isConnected()) throw exceptions::already_connected(); // Use the specified path for 'sendmail' or a default one if no path is specified m_sendmailPath = GET_PROPERTY(string, PROPERTY_BINPATH); m_connected = true; } bool sendmailTransport::isConnected() const { return (m_connected); } bool sendmailTransport::isSecuredConnection() const { return false; } ref sendmailTransport::getConnectionInfos() const { return vmime::create ("localhost", static_cast (0)); } void sendmailTransport::disconnect() { if (!isConnected()) throw exceptions::not_connected(); internalDisconnect(); } void sendmailTransport::internalDisconnect() { m_connected = false; } void sendmailTransport::noop() { // Do nothing } void sendmailTransport::send (const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress) { // If no recipient/expeditor was found, throw an exception if (recipients.isEmpty()) throw exceptions::no_recipient(); else if (expeditor.isEmpty()) throw exceptions::no_expeditor(); // Construct the argument list std::vector args; args.push_back("-i"); args.push_back("-f"); args.push_back(expeditor.getEmail()); args.push_back("--"); for (int i = 0 ; i < recipients.getMailboxCount() ; ++i) args.push_back(recipients.getMailboxAt(i)->getEmail()); // Call sendmail try { internalSend(args, is, size, progress); } catch (vmime::exception& e) { throw exceptions::command_error("SEND", "", "sendmail failed", e); } } void sendmailTransport::internalSend (const std::vector args, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress) { const utility::file::path path = vmime::platform::getHandler()-> getFileSystemFactory()->stringToPath(m_sendmailPath); ref proc = vmime::platform::getHandler()-> getChildProcessFactory()->create(path); proc->start(args, utility::childProcess::FLAG_REDIRECT_STDIN); // Copy message data from input stream to output pipe utility::outputStream& os = *(proc->getStdIn()); // Workaround for lame sendmail implementations that // can't handle CRLF eoln sequences: we transform CRLF // sequences into LF characters. utility::CRLFToLFFilteredOutputStream fos(os); // TODO: remove 'Bcc:' field from message header utility::bufferedStreamCopy(is, fos, size, progress); // Wait for sendmail to exit proc->waitForFinish(); } // Service infos sendmailServiceInfos sendmailTransport::sm_infos; const serviceInfos& sendmailTransport::getInfosInstance() { return sm_infos; } const serviceInfos& sendmailTransport::getInfos() const { return sm_infos; } } // sendmail } // net } // vmime #endif // VMIME_BUILTIN_PLATFORM_POSIX libvmime-0.9.1/src/net/sendmail/sendmailServiceInfos.cpp0000644000175000017500000000361211250723263023623 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/sendmail/sendmailServiceInfos.hpp" #if VMIME_BUILTIN_PLATFORM_POSIX namespace vmime { namespace net { namespace sendmail { sendmailServiceInfos::sendmailServiceInfos() { } const string sendmailServiceInfos::getPropertyPrefix() const { return "transport.sendmail."; } const sendmailServiceInfos::props& sendmailServiceInfos::getProperties() const { static props sendmailProps = { // Path to sendmail (override default) property("binpath", serviceInfos::property::TYPE_STRING, string(VMIME_SENDMAIL_PATH)) }; return sendmailProps; } const std::vector sendmailServiceInfos::getAvailableProperties() const { std::vector list; const props& p = getProperties(); list.push_back(p.PROPERTY_BINPATH); return list; } } // sendmail } // net } // vmime #endif // VMIME_BUILTIN_PLATFORM_POSIX libvmime-0.9.1/src/net/session.cpp0000644000175000017500000000636411250723263017405 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/session.hpp" #include "vmime/net/serviceFactory.hpp" #include "vmime/net/store.hpp" #include "vmime/net/transport.hpp" namespace vmime { namespace net { session::session() { } session::session(const session& sess) : object(), m_props(sess.m_props) { } session::session(const propertySet& props) : m_props(props) { } session::~session() { } ref session::getTransport(ref auth) { return (getTransport(m_props["transport.protocol"], auth)); } ref session::getTransport (const string& protocol, ref auth) { ref sess = thisRef().dynamicCast (); ref sv = serviceFactory::getInstance()->create(sess, protocol, auth); if (sv->getType() != service::TYPE_TRANSPORT) throw exceptions::no_service_available(); return sv.staticCast (); } ref session::getTransport (const utility::url& url, ref auth) { ref sess = thisRef().dynamicCast (); ref sv = serviceFactory::getInstance()->create(sess, url, auth); if (sv->getType() != service::TYPE_TRANSPORT) throw exceptions::no_service_available(); return sv.staticCast (); } ref session::getStore(ref auth) { return (getStore(m_props["store.protocol"], auth)); } ref session::getStore (const string& protocol, ref auth) { ref sess = thisRef().dynamicCast (); ref sv = serviceFactory::getInstance()->create(sess, protocol, auth); if (sv->getType() != service::TYPE_STORE) throw exceptions::no_service_available(); return sv.staticCast (); } ref session::getStore (const utility::url& url, ref auth) { ref sess = thisRef().dynamicCast (); ref sv = serviceFactory::getInstance()->create(sess, url, auth); if (sv->getType() != service::TYPE_STORE) throw exceptions::no_service_available(); return sv.staticCast (); } const propertySet& session::getProperties() const { return (m_props); } propertySet& session::getProperties() { return (m_props); } } // net } // vmime libvmime-0.9.1/src/net/service.cpp0000644000175000017500000000615611250723263017361 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/config.hpp" #include "vmime/net/service.hpp" #include "vmime/platform.hpp" #if VMIME_HAVE_SASL_SUPPORT #include "vmime/security/sasl/defaultSASLAuthenticator.hpp" #else #include "vmime/security/defaultAuthenticator.hpp" #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT #include "vmime/security/cert/defaultCertificateVerifier.hpp" #endif // VMIME_HAVE_TLS_SUPPORT namespace vmime { namespace net { service::service(ref sess, const serviceInfos& /* infos */, ref auth) : m_session(sess), m_auth(auth) { if (!auth) { #if VMIME_HAVE_SASL_SUPPORT m_auth = vmime::create (); #else m_auth = vmime::create (); #endif // VMIME_HAVE_SASL_SUPPORT } #if VMIME_HAVE_TLS_SUPPORT m_certVerifier = vmime::create (); #endif // VMIME_HAVE_TLS_SUPPORT m_socketFactory = platform::getHandler()->getSocketFactory(); } service::~service() { } ref service::getSession() const { return (m_session); } ref service::getSession() { return (m_session); } ref service::getAuthenticator() const { return (m_auth); } ref service::getAuthenticator() { return (m_auth); } void service::setAuthenticator(ref auth) { m_auth = auth; } #if VMIME_HAVE_TLS_SUPPORT void service::setCertificateVerifier(ref cv) { m_certVerifier = cv; } ref service::getCertificateVerifier() { return m_certVerifier; } #endif // VMIME_HAVE_TLS_SUPPORT void service::setSocketFactory(ref sf) { m_socketFactory = sf; } ref service::getSocketFactory() { return m_socketFactory; } void service::setTimeoutHandlerFactory(ref thf) { m_toHandlerFactory = thf; } ref service::getTimeoutHandlerFactory() { return m_toHandlerFactory; } } // net } // vmime libvmime-0.9.1/src/net/serviceInfos.cpp0000644000175000017500000000732111250723263020353 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/serviceInfos.hpp" namespace vmime { namespace net { // Common properties const serviceInfos::property serviceInfos::property::SERVER_ADDRESS ("server.address", serviceInfos::property::TYPE_STRING); const serviceInfos::property serviceInfos::property::SERVER_PORT ("server.port", serviceInfos::property::TYPE_INTEGER); const serviceInfos::property serviceInfos::property::SERVER_ROOTPATH ("server.rootpath", serviceInfos::property::TYPE_STRING); const serviceInfos::property serviceInfos::property::AUTH_USERNAME ("auth.username", serviceInfos::property::TYPE_STRING); const serviceInfos::property serviceInfos::property::AUTH_PASSWORD ("auth.password", serviceInfos::property::TYPE_STRING); #if VMIME_HAVE_TLS_SUPPORT const serviceInfos::property serviceInfos::property::CONNECTION_TLS ("connection.tls", serviceInfos::property::TYPE_BOOL, "false"); const serviceInfos::property serviceInfos::property::CONNECTION_TLS_REQUIRED ("connection.tls.required", serviceInfos::property::TYPE_BOOL, "false"); #endif // VMIME_HAVE_TLS_SUPPORT // serviceInfos serviceInfos::serviceInfos() { } serviceInfos::serviceInfos(const serviceInfos&) { } serviceInfos& serviceInfos::operator=(const serviceInfos&) { return (*this); } serviceInfos::~serviceInfos() { } bool serviceInfos::hasProperty(ref s, const property& p) const { return s->getProperties().hasProperty(getPropertyPrefix() + p.getName()); } // serviceInfos::property serviceInfos::property::property (const string& name, const Types type, const string& defaultValue, const int flags) : m_name(name), m_defaultValue(defaultValue), m_type(type), m_flags(flags) { } serviceInfos::property::property (const property& p, const int addFlags, const int removeFlags) { m_name = p.m_name; m_type = p.m_type; m_defaultValue = p.m_defaultValue; m_flags = (p.m_flags | addFlags) & ~removeFlags; } serviceInfos::property::property (const property& p, const string& newDefaultValue, const int addFlags, const int removeFlags) { m_name = p.m_name; m_type = p.m_type; m_defaultValue = newDefaultValue; m_flags = (p.m_flags | addFlags) & ~removeFlags; } serviceInfos::property& serviceInfos::property::operator=(const property& p) { m_name = p.m_name; m_type = p.m_type; m_defaultValue = p.m_defaultValue; m_flags = p.m_flags; return (*this); } const string& serviceInfos::property::getName() const { return (m_name); } const string& serviceInfos::property::getDefaultValue() const { return (m_defaultValue); } serviceInfos::property::Types serviceInfos::property::getType() const { return (m_type); } int serviceInfos::property::getFlags() const { return (m_flags); } } // net } // vmime libvmime-0.9.1/src/net/events.cpp0000644000175000017500000000615411250723263017223 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/net/events.hpp" #include "vmime/net/folder.hpp" #include namespace vmime { namespace net { namespace events { // // messageCountEvent // messageCountEvent::messageCountEvent (ref folder, const Types type, const std::vector & nums) : m_folder(folder), m_type(type) { m_nums.resize(nums.size()); std::copy(nums.begin(), nums.end(), m_nums.begin()); } ref messageCountEvent::getFolder() const { return (m_folder); } messageCountEvent::Types messageCountEvent::getType() const { return (m_type); } const std::vector & messageCountEvent::getNumbers() const { return (m_nums); } void messageCountEvent::dispatch(messageCountListener* listener) const { if (m_type == TYPE_ADDED) listener->messagesAdded(*this); else listener->messagesRemoved(*this); } // // messageChangedEvent // messageChangedEvent::messageChangedEvent (ref folder, const Types type, const std::vector & nums) : m_folder(folder), m_type(type) { m_nums.resize(nums.size()); std::copy(nums.begin(), nums.end(), m_nums.begin()); } ref messageChangedEvent::getFolder() const { return (m_folder); } messageChangedEvent::Types messageChangedEvent::getType() const { return (m_type); } const std::vector & messageChangedEvent::getNumbers() const { return (m_nums); } void messageChangedEvent::dispatch(messageChangedListener* listener) const { listener->messageChanged(*this); } // // folderEvent // folderEvent::folderEvent (ref folder, const Types type, const utility::path& oldPath, const utility::path& newPath) : m_folder(folder), m_type(type), m_oldPath(oldPath), m_newPath(newPath) { } ref folderEvent::getFolder() const { return (m_folder); } folderEvent::Types folderEvent::getType() const { return (m_type); } void folderEvent::dispatch(folderListener* listener) const { switch (m_type) { case TYPE_CREATED: listener->folderCreated(*this); break; case TYPE_RENAMED: listener->folderRenamed(*this); break; case TYPE_DELETED: listener->folderDeleted(*this); break; } } } // events } // net } // vmime libvmime-0.9.1/src/misc/0000755000175000017500000000000011607302336015352 5ustar mnordstrmnordstrlibvmime-0.9.1/src/misc/importanceHelper.cpp0000644000175000017500000000765211250723263021371 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/misc/importanceHelper.hpp" #include "vmime/exception.hpp" #include "vmime/text.hpp" namespace vmime { namespace misc { void importanceHelper::resetImportance(ref msg) { resetImportanceHeader(msg->getHeader()); } void importanceHelper::resetImportanceHeader(ref
hdr) { try { ref fld = hdr->findField("X-Priority"); hdr->removeField(fld); } catch (exceptions::no_such_field) { // Ignore } try { ref fld = hdr->findField("Importance"); hdr->removeField(fld); } catch (exceptions::no_such_field) { // Ignore } } importanceHelper::Importance importanceHelper::getImportance(ref msg) { return getImportanceHeader(msg->getHeader()); } importanceHelper::Importance importanceHelper::getImportanceHeader(ref hdr) { // Try "X-Priority" field try { const ref fld = hdr->findField("X-Priority"); const string value = fld->getValue().dynamicCast ()->getWholeBuffer(); int n = IMPORTANCE_NORMAL; std::istringstream iss(value); iss >> n; Importance i = IMPORTANCE_NORMAL; switch (n) { case 1: i = IMPORTANCE_HIGHEST; break; case 2: i = IMPORTANCE_HIGH; break; case 3: i = IMPORTANCE_NORMAL; break; case 4: i = IMPORTANCE_LOW; break; case 5: i = IMPORTANCE_LOWEST; break; } return (i); } catch (exceptions::no_such_field) { // Try "Importance" field try { const ref fld = hdr->findField("Importance"); const string value = utility::stringUtils::toLower(utility::stringUtils::trim (fld->getValue().dynamicCast ()->getWholeBuffer())); if (value == "low") return (IMPORTANCE_LOWEST); else if (value == "high") return (IMPORTANCE_HIGHEST); else return (IMPORTANCE_NORMAL); } catch (exceptions::no_such_field) { // Default return (IMPORTANCE_NORMAL); } } // Should not go here... return (IMPORTANCE_NORMAL); } void importanceHelper::setImportance(ref msg, const Importance i) { setImportanceHeader(msg->getHeader(), i); } void importanceHelper::setImportanceHeader(ref
hdr, const Importance i) { // "X-Priority:" Field ref fld = hdr->getField("X-Priority"); switch (i) { case IMPORTANCE_HIGHEST: fld->setValue("1 (Highest)"); break; case IMPORTANCE_HIGH: fld->setValue("2 (High)"); break; default: case IMPORTANCE_NORMAL: fld->setValue("3 (Normal)"); break; case IMPORTANCE_LOW: fld->setValue("4 (Low)"); break; case IMPORTANCE_LOWEST: fld->setValue("5 (Lowest)"); break; } // "Importance:" Field fld = hdr->getField("Importance"); switch (i) { case IMPORTANCE_HIGHEST: case IMPORTANCE_HIGH: fld->setValue("high"); break; default: case IMPORTANCE_NORMAL: fld->setValue("normal"); break; case IMPORTANCE_LOWEST: case IMPORTANCE_LOW: fld->setValue("low"); break; } } } // misc } // vmime libvmime-0.9.1/src/messageIdSequence.cpp0000644000175000017500000001226511250723263020523 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/messageIdSequence.hpp" #include "vmime/exception.hpp" #include namespace vmime { messageIdSequence::messageIdSequence() { } messageIdSequence::~messageIdSequence() { removeAllMessageIds(); } messageIdSequence::messageIdSequence(const messageIdSequence& midSeq) : headerFieldValue() { copyFrom(midSeq); } ref messageIdSequence::clone() const { return vmime::create (*this); } void messageIdSequence::copyFrom(const component& other) { const messageIdSequence& midSeq = dynamic_cast (other); removeAllMessageIds(); for (unsigned int i = 0 ; i < midSeq.m_list.size() ; ++i) m_list.push_back(midSeq.m_list[i]->clone().dynamicCast ()); } messageIdSequence& messageIdSequence::operator=(const messageIdSequence& other) { copyFrom(other); return (*this); } const std::vector > messageIdSequence::getChildComponents() const { std::vector > res; copy_vector(m_list, res); return (res); } void messageIdSequence::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { removeAllMessageIds(); string::size_type pos = position; while (pos < end) { ref parsedMid = messageId::parseNext(buffer, pos, end, &pos); if (parsedMid != NULL) m_list.push_back(parsedMid); } setParsedBounds(position, end); if (newPosition) *newPosition = end; } void messageIdSequence::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { string::size_type pos = curLinePos; if (!m_list.empty()) { for (std::vector >::const_iterator it = m_list.begin() ; ; ) { (*it)->generate(os, maxLineLength - 2, pos, &pos); if (++it == m_list.end()) break; os << " "; pos++; } } if (newLinePos) *newLinePos = pos; } void messageIdSequence::appendMessageId(ref mid) { m_list.push_back(mid); } void messageIdSequence::insertMessageIdBefore(ref beforeMid, ref mid) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), beforeMid); if (it == m_list.end()) throw exceptions::no_such_message_id(); m_list.insert(it, mid); } void messageIdSequence::insertMessageIdBefore(const int pos, ref mid) { m_list.insert(m_list.begin() + pos, mid); } void messageIdSequence::insertMessageIdAfter(ref afterMid, ref mid) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), afterMid); if (it == m_list.end()) throw exceptions::no_such_message_id(); m_list.insert(it + 1, mid); } void messageIdSequence::insertMessageIdAfter(const int pos, ref mid) { m_list.insert(m_list.begin() + pos + 1, mid); } void messageIdSequence::removeMessageId(ref mid) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), mid); if (it == m_list.end()) throw exceptions::no_such_message_id(); m_list.erase(it); } void messageIdSequence::removeMessageId(const int pos) { const std::vector >::iterator it = m_list.begin() + pos; m_list.erase(it); } void messageIdSequence::removeAllMessageIds() { m_list.clear(); } int messageIdSequence::getMessageIdCount() const { return (m_list.size()); } bool messageIdSequence::isEmpty() const { return (m_list.empty()); } const ref messageIdSequence::getMessageIdAt(const int pos) { return (m_list[pos]); } const ref messageIdSequence::getMessageIdAt(const int pos) const { return (m_list[pos]); } const std::vector > messageIdSequence::getMessageIdList() const { std::vector > list; list.reserve(m_list.size()); for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { list.push_back(*it); } return (list); } const std::vector > messageIdSequence::getMessageIdList() { return (m_list); } } // vmime libvmime-0.9.1/src/wordEncoder.cpp0000644000175000017500000001720311455065024017402 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/wordEncoder.hpp" #include "vmime/exception.hpp" #include "vmime/charsetConverter.hpp" #include "vmime/encoding.hpp" #include "vmime/utility/encoder/b64Encoder.hpp" #include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/utility/stringUtils.hpp" namespace vmime { wordEncoder::wordEncoder(const string& buffer, const charset& charset, const Encoding encoding) : m_buffer(buffer), m_pos(0), m_length(buffer.length()), m_charset(charset), m_encoding(encoding) { try { string utf8Buffer; vmime::charset::convert (buffer, utf8Buffer, charset, vmime::charset(charsets::UTF_8)); m_buffer = utf8Buffer; m_length = utf8Buffer.length(); m_simple = false; } catch (exceptions::charset_conv_error&) { // Ignore exception. // We will fall back on simple encoding. m_simple = true; } if (m_encoding == ENCODING_AUTO) m_encoding = guessBestEncoding(buffer, charset); if (m_encoding == ENCODING_B64) { m_encoder = vmime::create (); } else // ENCODING_QP { m_encoder = vmime::create (); m_encoder->getProperties()["rfc2047"] = true; } } static string::size_type getUTF8CharLength (const string& buffer, const string::size_type pos, const string::size_type length) { // Gives the number of extra bytes in a UTF8 char, given the leading char static const unsigned char UTF8_EXTRA_BYTES[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; const unsigned char c = buffer[pos]; const unsigned char n = UTF8_EXTRA_BYTES[c]; if (n < length - pos) return n + 1; else return 1; } const string wordEncoder::getNextChunk(const string::size_type maxLength) { const string::size_type remaining = m_length - m_pos; if (remaining == 0) return string(); vmime::string chunk; vmime::utility::outputStreamStringAdapter chunkStream(chunk); // Simple encoding if (m_simple) { // WARNING! Simple encoding can encode a non-integral number of // characters and then may generate incorrectly-formed words! if (m_encoding == ENCODING_B64) { // Here, we have a formula to compute the maximum number of source // bytes to encode knowing the maximum number of encoded chars. In // Base64 encoding, 3 bytes of input provide 4 bytes of output. const string::size_type inputCount = std::min(remaining, (maxLength > 1) ? ((maxLength - 1) * 3) / 4 : 1); // Encode chunk utility::inputStreamStringAdapter in(m_buffer, m_pos, m_pos + inputCount); m_encoder->encode(in, chunkStream); m_pos += inputCount; } else // ENCODING_QP { // Compute exactly how much input bytes are needed to have an output // string length of less than 'maxLength' bytes. In Quoted-Printable // encoding, encoded bytes take 3 bytes. string::size_type inputCount = 0; string::size_type outputCount = 0; while ((inputCount == 0 || outputCount < maxLength) && (inputCount < remaining)) { const unsigned char c = m_buffer[m_pos + inputCount]; inputCount++; outputCount += utility::encoder::qpEncoder::RFC2047_getEncodedLength(c); } // Encode chunk utility::inputStreamStringAdapter in(m_buffer, m_pos, m_pos + inputCount); m_encoder->encode(in, chunkStream); m_pos += inputCount; } } // Fully RFC-compliant encoding else { charsetConverter conv(charsets::UTF_8, m_charset); string::size_type inputCount = 0; string::size_type outputCount = 0; string encodeBuffer; while ((inputCount == 0 || outputCount < maxLength) && (inputCount < remaining)) { // Get the next UTF8 character const string::size_type inputCharLength = getUTF8CharLength(m_buffer, m_pos + inputCount, m_length); const string inputChar(m_buffer.begin() + m_pos + inputCount, m_buffer.begin() + m_pos + inputCount + inputCharLength); // Convert back to original encoding string encodeBytes; conv.convert(inputChar, encodeBytes); encodeBuffer += encodeBytes; // Compute number of output bytes if (m_encoding == ENCODING_B64) { outputCount = std::max(static_cast (4), (encodeBuffer.length() * 4) / 3); } else // ENCODING_QP { for (string::size_type i = 0, n = encodeBytes.length() ; i < n ; ++i) { const unsigned char c = encodeBytes[i]; outputCount += utility::encoder::qpEncoder::RFC2047_getEncodedLength(c); } } inputCount += inputCharLength; } // Encode chunk utility::inputStreamStringAdapter in(encodeBuffer); m_encoder->encode(in, chunkStream); m_pos += inputCount; } return chunk; } wordEncoder::Encoding wordEncoder::getEncoding() const { return m_encoding; } // static bool wordEncoder::isEncodingNeeded(const string& buffer, const charset& charset) { // Charset-specific encoding encoding recEncoding; if (charset.getRecommendedEncoding(recEncoding)) return true; // No encoding is needed if the buffer only contains ASCII chars if (utility::stringUtils::findFirstNonASCIIchar(buffer.begin(), buffer.end()) != string::npos) return true; // Force encoding when there are only ASCII chars, but there is // also at least one of '\n' or '\r' (header fields) if (buffer.find_first_of("\n\r") != string::npos) return true; return false; } // static wordEncoder::Encoding wordEncoder::guessBestEncoding (const string& buffer, const charset& charset) { // Charset-specific encoding encoding recEncoding; if (charset.getRecommendedEncoding(recEncoding)) { if (recEncoding == encoding(encodingTypes::QUOTED_PRINTABLE)) return ENCODING_QP; else return ENCODING_B64; } // Use Base64 if more than 40% non-ASCII, or Quoted-Printable else (default) const string::size_type asciiCount = utility::stringUtils::countASCIIchars(buffer.begin(), buffer.end()); const string::size_type asciiPercent = (buffer.length() == 0 ? 100 : (100 * asciiCount) / buffer.length()); if (asciiPercent < 60) return ENCODING_B64; else return ENCODING_QP; } } // vmime libvmime-0.9.1/src/messageParser.cpp0000644000175000017500000001624211250723263017731 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/messageParser.hpp" #include "vmime/attachmentHelper.hpp" #include "vmime/defaultAttachment.hpp" #include "vmime/textPartFactory.hpp" #include "vmime/relay.hpp" #include "vmime/contentTypeField.hpp" #include "vmime/contentDispositionField.hpp" namespace vmime { messageParser::messageParser(const string& buffer) { ref msg = vmime::create (); msg->parse(buffer); parse(msg); } messageParser::messageParser(ref msg) { parse(msg); } messageParser::~messageParser() { } void messageParser::parse(ref msg) { // Header fields (if field is present, copy its value, else do nothing) #ifndef VMIME_BUILDING_DOC #define TRY_FIELD(var, type, name) \ try { var = *msg->getHeader()->findField(name)->getValue().dynamicCast (); } \ catch (exceptions::no_such_field) { } TRY_FIELD(m_from, mailbox, fields::FROM); TRY_FIELD(m_to, addressList, fields::TO); TRY_FIELD(m_cc, addressList, fields::CC); TRY_FIELD(m_bcc, addressList, fields::BCC); TRY_FIELD(m_subject, text, fields::SUBJECT); #undef TRY_FIELD #endif // VMIME_BUILDING_DOC // Date try { const headerField& recv = *msg->getHeader()->findField(fields::RECEIVED); m_date = recv.getValue().dynamicCast ()->getDate(); } catch (vmime::exceptions::no_such_field&) { try { const headerField& date = *msg->getHeader()->findField(fields::DATE); m_date = *date.getValue().dynamicCast (); } catch (vmime::exceptions::no_such_field&) { m_date = datetime::now(); } } // Attachments findAttachments(msg); // Text parts findTextParts(msg, msg); } void messageParser::findAttachments(ref msg) { m_attach = attachmentHelper::findAttachmentsInMessage(msg); } void messageParser::findTextParts(ref msg, ref part) { // Handle the case in which the message is not multipart: if the body part is // "text/*", take this part. if (part->getBody()->getPartCount() == 0) { mediaType type(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN); bool accept = false; try { const contentTypeField& ctf = dynamic_cast (*msg->getHeader()->findField(fields::CONTENT_TYPE)); const mediaType ctfType = *ctf.getValue().dynamicCast (); if (ctfType.getType() == mediaTypes::TEXT) { type = ctfType; accept = true; } } catch (exceptions::no_such_field&) { // No "Content-type" field: assume "text/plain". accept = true; } if (accept) { ref txtPart = textPartFactory::getInstance()->create(type); txtPart->parse(msg, msg, msg); m_textParts.push_back(txtPart); } } // Multipart message else { findSubTextParts(msg, part); } } bool messageParser::findSubTextParts(ref msg, ref part) { // In general, all the text parts are contained in parallel in the same // parent part (or message). // So, wherever the text parts are, all we have to do is to find the first // MIME part which is a text part. std::vector > textParts; for (int i = 0 ; i < part->getBody()->getPartCount() ; ++i) { const ref p = part->getBody()->getPartAt(i); try { const contentTypeField& ctf = dynamic_cast (*(p->getHeader()->findField(fields::CONTENT_TYPE))); const mediaType type = *ctf.getValue().dynamicCast (); contentDisposition disp; // default should be inline if (type.getType() == mediaTypes::TEXT) { try { ref cdf = p->getHeader()-> findField(fields::CONTENT_DISPOSITION).dynamicCast (); disp = *cdf->getValue().dynamicCast (); } catch (exceptions::no_such_field&) { // No "Content-Disposition" field, assume default } if (disp.getName() == contentDispositionTypes::INLINE) textParts.push_back(p); } } catch (exceptions::no_such_field&) { // No "Content-type" field. } } if (textParts.size()) { // Okay. So we have found at least one text part for (std::vector >::const_iterator p = textParts.begin() ; p != textParts.end() ; ++p) { const contentTypeField& ctf = dynamic_cast (*((*p)->getHeader()->findField(fields::CONTENT_TYPE))); const mediaType type = *ctf.getValue().dynamicCast (); try { ref txtPart = textPartFactory::getInstance()->create(type); txtPart->parse(msg, part, *p); m_textParts.push_back(txtPart); } catch (exceptions::no_factory_available& e) { // Content-type not recognized. } } } bool found = false; for (int i = 0 ; !found && (i < part->getBody()->getPartCount()) ; ++i) { found = findSubTextParts(msg, part->getBody()->getPartAt(i)); } return found; } const mailbox& messageParser::getExpeditor() const { return (m_from); } const addressList& messageParser::getRecipients() const { return (m_to); } const addressList& messageParser::getCopyRecipients() const { return (m_cc); } const addressList& messageParser::getBlindCopyRecipients() const { return (m_bcc); } const text& messageParser::getSubject() const { return (m_subject); } const datetime& messageParser::getDate() const { return (m_date); } const std::vector > messageParser::getAttachmentList() const { return m_attach; } int messageParser::getAttachmentCount() const { return (m_attach.size()); } const ref messageParser::getAttachmentAt(const int pos) const { return (m_attach[pos]); } const std::vector > messageParser::getTextPartList() const { std::vector > res; res.reserve(m_textParts.size()); for (std::vector >::const_iterator it = m_textParts.begin() ; it != m_textParts.end() ; ++it) { res.push_back(*it); } return (res); } int messageParser::getTextPartCount() const { return (m_textParts.size()); } const ref messageParser::getTextPartAt(const int pos) const { return (m_textParts[pos]); } } // vmime libvmime-0.9.1/src/contentHandler.cpp0000644000175000017500000000237211250723263020077 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/contentHandler.hpp" namespace vmime { // No encoding = "binary" encoding const encoding contentHandler::NO_ENCODING(encodingTypes::BINARY); contentHandler::~contentHandler() { } } // vmime libvmime-0.9.1/src/plainTextPart.cpp0000644000175000017500000000544411376250433017734 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/plainTextPart.hpp" #include "vmime/header.hpp" #include "vmime/exception.hpp" #include "vmime/contentTypeField.hpp" #include "vmime/emptyContentHandler.hpp" namespace vmime { plainTextPart::plainTextPart() : m_text(vmime::create ()) { } plainTextPart::~plainTextPart() { } const mediaType plainTextPart::getType() const { return (mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN)); } int plainTextPart::getPartCount() const { return (1); } void plainTextPart::generateIn(ref /* message */, ref parent) const { // Create a new part ref part = vmime::create (); parent->getBody()->appendPart(part); // Set contents part->getBody()->setContents(m_text, mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN), m_charset, encoding::decide(m_text, m_charset, encoding::USAGE_TEXT)); } void plainTextPart::parse(ref /* message */, ref /* parent */, ref textPart) { m_text = textPart->getBody()->getContents()->clone().dynamicCast (); try { const contentTypeField& ctf = dynamic_cast (*textPart->getHeader()->findField(fields::CONTENT_TYPE)); m_charset = ctf.getCharset(); } catch (exceptions::no_such_field&) { // No "Content-type" field. } catch (exceptions::no_such_parameter&) { // No "charset" parameter. } } const charset& plainTextPart::getCharset() const { return (m_charset); } void plainTextPart::setCharset(const charset& ch) { m_charset = ch; } const ref plainTextPart::getText() const { return (m_text); } void plainTextPart::setText(ref text) { m_text = text->clone().dynamicCast (); } } // vmime libvmime-0.9.1/src/mailboxGroup.cpp0000644000175000017500000001627011250723263017601 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mailboxGroup.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/exception.hpp" namespace vmime { mailboxGroup::mailboxGroup() { } mailboxGroup::mailboxGroup(const mailboxGroup& mboxGroup) : address() { copyFrom(mboxGroup); } mailboxGroup::mailboxGroup(const text& name) : m_name(name) { } mailboxGroup::~mailboxGroup() { removeAllMailboxes(); } void mailboxGroup::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { const string::value_type* const pend = buffer.data() + end; const string::value_type* const pstart = buffer.data() + position; const string::value_type* p = pstart; while (p < pend && parserHelpers::isSpace(*p)) ++p; string name; while (p < pend && *p != ':') { name += *p; ++p; } if (p < pend && *p == ':') ++p; string::size_type pos = position + (p - pstart); while (pos < end) { ref
parsedAddress = address::parseNext(buffer, pos, end, &pos); if (parsedAddress) { if (parsedAddress->isGroup()) { ref group = parsedAddress.staticCast (); // Sub-groups are not allowed in mailbox groups: so, we add all // the contents of the sub-group into this group... for (int i = 0 ; i < group->getMailboxCount() ; ++i) { m_list.push_back(group->getMailboxAt(i)->clone().staticCast ()); } } else { m_list.push_back(parsedAddress.staticCast ()); } } } text::decodeAndUnfold(name, &m_name); setParsedBounds(position, end); if (newPosition) *newPosition = end; } void mailboxGroup::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { // We have to encode the name: // - if it contains characters in a charset different from "US-ASCII", // - and/or if it contains one or more of these special chars: // SPACE TAB " ; , < > ( ) @ / ? . = : // Check whether there are words that are not "US-ASCII" // and/or contain the special chars. bool forceEncode = false; for (int w = 0 ; !forceEncode && w < m_name.getWordCount() ; ++w) { if (m_name.getWordAt(w)->getCharset() == charset(charsets::US_ASCII)) { const string& buffer = m_name.getWordAt(w)->getBuffer(); for (string::const_iterator c = buffer.begin() ; !forceEncode && c != buffer.end() ; ++c) { switch (*c) { case ' ': case '\t': case ';': case ',': case '<': case '>': case '(': case ')': case '@': case '/': case '?': case '.': case '=': case ':': forceEncode = true; break; } } } } string::size_type pos = curLinePos; m_name.encodeAndFold(os, maxLineLength - 2, pos, &pos, forceEncode ? text::FORCE_ENCODING : 0); os << ":"; ++pos; for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { if (it != m_list.begin()) { os << ", "; pos += 2; } else { os << " "; ++pos; } (*it)->generate(os, maxLineLength - 2, pos, &pos); } os << ";"; pos++; if (newLinePos) *newLinePos = pos; } void mailboxGroup::copyFrom(const component& other) { const mailboxGroup& source = dynamic_cast (other); m_name = source.m_name; removeAllMailboxes(); for (std::vector >::const_iterator it = source.m_list.begin() ; it != source.m_list.end() ; ++it) { m_list.push_back((*it)->clone().staticCast ()); } } ref mailboxGroup::clone() const { return vmime::create (*this); } mailboxGroup& mailboxGroup::operator=(const component& other) { copyFrom(other); return (*this); } const text& mailboxGroup::getName() const { return (m_name); } void mailboxGroup::setName(const text& name) { m_name = name; } bool mailboxGroup::isGroup() const { return (true); } bool mailboxGroup::isEmpty() const { return (m_list.empty()); } void mailboxGroup::appendMailbox(ref mbox) { m_list.push_back(mbox); } void mailboxGroup::insertMailboxBefore(ref beforeMailbox, ref mbox) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), beforeMailbox); if (it == m_list.end()) throw exceptions::no_such_mailbox(); m_list.insert(it, mbox); } void mailboxGroup::insertMailboxBefore(const int pos, ref mbox) { m_list.insert(m_list.begin() + pos, mbox); } void mailboxGroup::insertMailboxAfter(ref afterMailbox, ref mbox) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), afterMailbox); if (it == m_list.end()) throw exceptions::no_such_mailbox(); m_list.insert(it + 1, mbox); } void mailboxGroup::insertMailboxAfter(const int pos, ref mbox) { m_list.insert(m_list.begin() + pos + 1, mbox); } void mailboxGroup::removeMailbox(ref mbox) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), mbox); if (it == m_list.end()) throw exceptions::no_such_mailbox(); m_list.erase(it); } void mailboxGroup::removeMailbox(const int pos) { const std::vector >::iterator it = m_list.begin() + pos; m_list.erase(it); } void mailboxGroup::removeAllMailboxes() { m_list.clear(); } int mailboxGroup::getMailboxCount() const { return (m_list.size()); } ref mailboxGroup::getMailboxAt(const int pos) { return (m_list[pos]); } const ref mailboxGroup::getMailboxAt(const int pos) const { return (m_list[pos]); } const std::vector > mailboxGroup::getMailboxList() const { std::vector > list; list.reserve(m_list.size()); for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { list.push_back(*it); } return (list); } const std::vector > mailboxGroup::getMailboxList() { return (m_list); } const std::vector > mailboxGroup::getChildComponents() const { std::vector > list; copy_vector(m_list, list); return (list); } } // vmime libvmime-0.9.1/src/options.cpp0000644000175000017500000000343611250723263016624 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/options.hpp" namespace vmime { options* options::getInstance() { static options instance; return (&instance); } options::multipartOptions::multipartOptions() : m_prologText("This is a multi-part message in MIME format. Your mail reader " \ "does not understand MIME message format."), m_epilogText("") { } const string& options::multipartOptions::getPrologText() const { return (m_prologText); } void options::multipartOptions::setPrologText(const string& prologText) { m_prologText = prologText; } const string& options::multipartOptions::getEpilogText() const { return (m_epilogText); } void options::multipartOptions::setEpilogText(const string& epilogText) { m_epilogText = epilogText; } } // vmime libvmime-0.9.1/src/headerFieldFactory.cpp0000644000175000017500000001106311250723263020650 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/headerFieldFactory.hpp" #include "vmime/exception.hpp" #include "vmime/mailboxList.hpp" #include "vmime/dateTime.hpp" #include "vmime/text.hpp" #include "vmime/path.hpp" #include "vmime/relay.hpp" #include "vmime/encoding.hpp" #include "vmime/disposition.hpp" #include "vmime/messageIdSequence.hpp" #include "vmime/contentTypeField.hpp" #include "vmime/contentDispositionField.hpp" #include "vmime/mailboxField.hpp" namespace vmime { headerFieldFactory::headerFieldFactory() { // Register parameterized fields registerField (vmime::fields::CONTENT_TYPE); registerField (vmime::fields::CONTENT_TRANSFER_ENCODING); registerField (vmime::fields::CONTENT_DISPOSITION); registerField (vmime::fields::FROM); registerField (vmime::fields::SENDER); registerField (vmime::fields::REPLY_TO); registerField (vmime::fields::DELIVERED_TO); // Register standard field values registerFieldValue (vmime::fields::FROM); registerFieldValue (vmime::fields::TO); registerFieldValue (vmime::fields::CC); registerFieldValue (vmime::fields::BCC); registerFieldValue (vmime::fields::SENDER); registerFieldValue (vmime::fields::DATE); registerFieldValue (vmime::fields::RECEIVED); registerFieldValue (vmime::fields::SUBJECT); registerFieldValue (vmime::fields::REPLY_TO); registerFieldValue (vmime::fields::DELIVERED_TO); registerFieldValue (vmime::fields::ORGANIZATION); registerFieldValue (vmime::fields::USER_AGENT); registerFieldValue (vmime::fields::RETURN_PATH); registerFieldValue (vmime::fields::CONTENT_TYPE); registerFieldValue (vmime::fields::CONTENT_TRANSFER_ENCODING); registerFieldValue (vmime::fields::CONTENT_DESCRIPTION); registerFieldValue (vmime::fields::MIME_VERSION); registerFieldValue (vmime::fields::CONTENT_DISPOSITION); registerFieldValue (vmime::fields::CONTENT_ID); registerFieldValue (vmime::fields::MESSAGE_ID); registerFieldValue (vmime::fields::CONTENT_LOCATION); registerFieldValue (vmime::fields::IN_REPLY_TO); registerFieldValue (vmime::fields::REFERENCES); registerFieldValue (vmime::fields::ORIGINAL_MESSAGE_ID); registerFieldValue (vmime::fields::DISPOSITION); registerFieldValue (vmime::fields::DISPOSITION_NOTIFICATION_TO); } headerFieldFactory::~headerFieldFactory() { } headerFieldFactory* headerFieldFactory::getInstance() { static headerFieldFactory instance; return (&instance); } ref headerFieldFactory::create (const string& name, const string& body) { NameMap::const_iterator pos = m_nameMap.find(utility::stringUtils::toLower(name)); ref field = NULL; if (pos != m_nameMap.end()) field = ((*pos).second)(); else field = registerer ::creator(); field->setName(name); field->setValue(createValue(name)); if (body != NULL_STRING) field->parse(body); return field; } ref headerFieldFactory::createValue(const string& fieldName) { ValueMap::const_iterator pos = m_valueMap.find (utility::stringUtils::toLower(fieldName)); ref value = NULL; if (pos != m_valueMap.end()) value = ((*pos).second)(); else value = registerer ::creator(); return value; } } // vmime libvmime-0.9.1/src/charsetConverter.cpp0000644000175000017500000002351611333330451020446 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/charsetConverter.hpp" #include "vmime/exception.hpp" extern "C" { #ifndef VMIME_BUILDING_DOC #include #include // HACK: prototypes may differ depending on the compiler and/or system (the // second parameter may or may not be 'const'). This relies on the compiler // for choosing the right type. class ICONV_HACK { public: ICONV_HACK(const char** ptr) : m_ptr(ptr) { } operator const char**() { return m_ptr; } operator char**() { return const_cast (m_ptr); } private: const char** m_ptr; }; #endif // VMIME_BUILDING_DOC } // Output replacement char when an invalid sequence is encountered template void outputInvalidChar(OUTPUT_CLASS& out, ICONV_DESC cd) { const char* invalidCharIn = "?"; size_t invalidCharInLen = 1; char invalidCharOutBuffer[16]; char* invalidCharOutPtr = invalidCharOutBuffer; size_t invalidCharOutLen = 16; if (iconv(cd, ICONV_HACK(&invalidCharIn), &invalidCharInLen, &invalidCharOutPtr, &invalidCharOutLen) != static_cast (-1)) { out.write(invalidCharOutBuffer, 16 - invalidCharOutLen); } } namespace vmime { charsetConverter::charsetConverter(const charset& source, const charset& dest) : m_desc(NULL), m_source(source), m_dest(dest) { // Get an iconv descriptor const iconv_t cd = iconv_open(dest.getName().c_str(), source.getName().c_str()); if (cd != reinterpret_cast (-1)) { iconv_t* p = new iconv_t; *p= cd; m_desc = p; } } charsetConverter::~charsetConverter() { if (m_desc != NULL) { // Close iconv handle iconv_close(*static_cast (m_desc)); delete static_cast (m_desc); m_desc = NULL; } } void charsetConverter::convert(utility::inputStream& in, utility::outputStream& out) { if (m_desc == NULL) throw exceptions::charset_conv_error("Cannot initialize converter."); const iconv_t cd = *static_cast (m_desc); char inBuffer[32768]; char outBuffer[32768]; size_t inPos = 0; bool prevIsInvalid = false; while (true) { // Fullfill the buffer size_t inLength = static_cast (in.read(inBuffer + inPos, sizeof(inBuffer) - inPos) + inPos); size_t outLength = sizeof(outBuffer); const char* inPtr = inBuffer; char* outPtr = outBuffer; // Convert input bytes if (iconv(cd, ICONV_HACK(&inPtr), &inLength, &outPtr, &outLength) == static_cast (-1)) { // Illegal input sequence or input sequence has no equivalent // sequence in the destination charset. if (prevIsInvalid) { // Write successfully converted bytes out.write(outBuffer, sizeof(outBuffer) - outLength); // Output a special character to indicate we don't known how to // convert the sequence at this position outputInvalidChar(out, cd); // Skip a byte and leave unconverted bytes in the input buffer std::copy(const_cast (inPtr + 1), inBuffer + sizeof(inBuffer), inBuffer); inPos = inLength - 1; } else { // Write successfully converted bytes out.write(outBuffer, sizeof(outBuffer) - outLength); // Leave unconverted bytes in the input buffer std::copy(const_cast (inPtr), inBuffer + sizeof(inBuffer), inBuffer); inPos = inLength; if (errno != E2BIG) prevIsInvalid = true; } } else { // Write successfully converted bytes out.write(outBuffer, sizeof(outBuffer) - outLength); inPos = 0; prevIsInvalid = false; } // Check for end of data if (in.eof() && inPos == 0) break; } } void charsetConverter::convert(const string& in, string& out) { out.clear(); utility::inputStreamStringAdapter is(in); utility::outputStreamStringAdapter os(out); convert(is, os); os.flush(); } // charsetFilteredOutputStream namespace utility { charsetFilteredOutputStream::charsetFilteredOutputStream (const charset& source, const charset& dest, outputStream& os) : m_desc(NULL), m_sourceCharset(source), m_destCharset(dest), m_stream(os), m_unconvCount(0) { // Get an iconv descriptor const iconv_t cd = iconv_open(dest.getName().c_str(), source.getName().c_str()); if (cd != reinterpret_cast (-1)) { iconv_t* p = new iconv_t; *p= cd; m_desc = p; } } charsetFilteredOutputStream::~charsetFilteredOutputStream() { if (m_desc != NULL) { // Close iconv handle iconv_close(*static_cast (m_desc)); delete static_cast (m_desc); m_desc = NULL; } } outputStream& charsetFilteredOutputStream::getNextOutputStream() { return m_stream; } void charsetFilteredOutputStream::write (const value_type* const data, const size_type count) { if (m_desc == NULL) throw exceptions::charset_conv_error("Cannot initialize converter."); const iconv_t cd = *static_cast (m_desc); const value_type* curData = data; size_type curDataLen = count; // If there is some unconverted bytes left, add more data from this // chunk to see if it can now be converted. while (m_unconvCount != 0 || curDataLen != 0) { if (m_unconvCount != 0) { // Check if an incomplete input sequence is larger than the // input buffer size: should not happen except if something // in the input sequence is invalid. If so, output a special // character and skip one byte in the invalid sequence. if (m_unconvCount >= sizeof(m_unconvBuffer)) { outputInvalidChar(m_stream, cd); std::copy(m_unconvBuffer + 1, m_unconvBuffer + m_unconvCount, m_unconvBuffer); m_unconvCount--; } // Get more data const size_type remaining = std::min(curDataLen, sizeof(m_unconvBuffer) - m_unconvCount); std::copy(curData, curData + remaining, m_unconvBuffer + m_unconvCount); m_unconvCount += remaining; curDataLen -= remaining; curData += remaining; if (remaining == 0) return; // no more data // Try a conversion const char* inPtr = m_unconvBuffer; size_t inLength = m_unconvCount; char* outPtr = m_outputBuffer; size_t outLength = sizeof(m_outputBuffer); const size_t inLength0 = inLength; if (iconv(cd, ICONV_HACK(&inPtr), &inLength, &outPtr, &outLength) == static_cast (-1)) { const size_t inputConverted = inLength0 - inLength; // Write successfully converted bytes m_stream.write(m_outputBuffer, sizeof(m_outputBuffer) - outLength); // Shift unconverted bytes std::copy(m_unconvBuffer + inputConverted, m_unconvBuffer + m_unconvCount, m_unconvBuffer); m_unconvCount -= inputConverted; continue; } // Write successfully converted bytes m_stream.write(m_outputBuffer, sizeof(m_outputBuffer) - outLength); // Empty the unconverted buffer m_unconvCount = 0; } if (curDataLen == 0) return; // no more data // Now, convert the current data buffer const char* inPtr = curData; size_t inLength = std::min(curDataLen, sizeof(m_outputBuffer) / MAX_CHARACTER_WIDTH); char* outPtr = m_outputBuffer; size_t outLength = sizeof(m_outputBuffer); const size_t inLength0 = inLength; if (iconv(cd, ICONV_HACK(&inPtr), &inLength, &outPtr, &outLength) == static_cast (-1)) { // Write successfully converted bytes m_stream.write(m_outputBuffer, sizeof(m_outputBuffer) - outLength); const size_t inputConverted = inLength0 - inLength; curData += inputConverted; curDataLen -= inputConverted; // Put one byte byte into the unconverted buffer so // that the next iteration fill it if (curDataLen != 0) { m_unconvCount = 1; m_unconvBuffer[0] = *curData; curData++; curDataLen--; } } else { // Write successfully converted bytes m_stream.write(m_outputBuffer, sizeof(m_outputBuffer) - outLength); curData += inLength0; curDataLen -= inLength0; } } } void charsetFilteredOutputStream::flush() { if (m_desc == NULL) throw exceptions::charset_conv_error("Cannot initialize converter."); const iconv_t cd = *static_cast (m_desc); size_t offset = 0; // Process unconverted bytes while (m_unconvCount != 0) { // Try a conversion const char* inPtr = m_unconvBuffer + offset; size_t inLength = m_unconvCount; char* outPtr = m_outputBuffer; size_t outLength = sizeof(m_outputBuffer); const size_t inLength0 = inLength; if (iconv(cd, ICONV_HACK(&inPtr), &inLength, &outPtr, &outLength) == static_cast (-1)) { const size_t inputConverted = inLength0 - inLength; // Skip a "blocking" character if (inputConverted == 0) { outputInvalidChar(m_stream, cd); offset++; m_unconvCount--; } else { // Write successfully converted bytes m_stream.write(m_outputBuffer, sizeof(m_outputBuffer) - outLength); offset += inputConverted; m_unconvCount -= inputConverted; } } else { // Write successfully converted bytes m_stream.write(m_outputBuffer, sizeof(m_outputBuffer) - outLength); m_unconvCount = 0; } } m_stream.flush(); } } // utility } // vmime libvmime-0.9.1/src/parsedMessageAttachment.cpp0000644000175000017500000000522311250723263021721 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/parsedMessageAttachment.hpp" #include "vmime/stringContentHandler.hpp" #include "vmime/contentDisposition.hpp" namespace vmime { parsedMessageAttachment::parsedMessageAttachment(ref msg) : m_msg(msg) { } const mediaType parsedMessageAttachment::getType() const { return mediaType(mediaTypes::MESSAGE, mediaTypes::MESSAGE_RFC822); } const text parsedMessageAttachment::getDescription() const { return text(); } const word parsedMessageAttachment::getName() const { return word(); } const ref parsedMessageAttachment::getData() const { if (m_data == NULL) { std::ostringstream oss; utility::outputStreamAdapter os(oss); m_msg->generate(os); m_data = vmime::create (oss.str()); } return m_data; } const encoding parsedMessageAttachment::getEncoding() const { return encoding(encodingTypes::EIGHT_BIT); // not important } ref parsedMessageAttachment::getPart() const { return NULL; } ref parsedMessageAttachment::getHeader() const { return NULL; } ref parsedMessageAttachment::getMessage() const { return m_msg; } void parsedMessageAttachment::generateIn(ref parent) const { // Create and append a new part for this attachment ref part = vmime::create (); parent->getBody()->appendPart(part); // Set header fields part->getHeader()->ContentType()->setValue(getType()); part->getHeader()->ContentDisposition()->setValue(contentDisposition(contentDispositionTypes::ATTACHMENT)); // Set contents part->getBody()->setContents(getData()); } } // vmime libvmime-0.9.1/src/contentTypeField.cpp0000644000175000017500000000401611250723263020404 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/contentTypeField.hpp" #include "vmime/exception.hpp" namespace vmime { contentTypeField::contentTypeField() { } contentTypeField::contentTypeField(contentTypeField&) : headerField(), parameterizedHeaderField() { } const string contentTypeField::getBoundary() const { return findParameter("boundary")->getValue().getBuffer(); } void contentTypeField::setBoundary(const string& boundary) { getParameter("boundary")->setValue(word(boundary, vmime::charsets::US_ASCII)); } const charset contentTypeField::getCharset() const { return findParameter("charset")->getValueAs (); } void contentTypeField::setCharset(const charset& ch) { getParameter("charset")->setValue(ch); } const string contentTypeField::getReportType() const { return findParameter("report-type")->getValue().getBuffer(); } void contentTypeField::setReportType(const string& reportType) { getParameter("report-type")->setValue(word(reportType, vmime::charsets::US_ASCII)); } } // vmime libvmime-0.9.1/src/platform.cpp0000644000175000017500000000227711250723263016757 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/platform.hpp" namespace vmime { ref platform::sm_handler = NULL; platform::handler::~handler() { } } // vmime libvmime-0.9.1/src/message.cpp0000644000175000017500000000373511250723263016557 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/message.hpp" #include "vmime/options.hpp" #include namespace vmime { message::message() { } void message::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { // We override this function to change the default value for the // "maxLineLength" parameter. So, the user will just have to call // message::generate() without any argument to use the maximum line // length specified in vmime::options... bodyPart::generate(os, maxLineLength, curLinePos, newLinePos); } const string message::generate(const string::size_type maxLineLength, const string::size_type curLinePos) const { std::ostringstream oss; utility::outputStreamAdapter adapter(oss); generate(adapter, maxLineLength, curLinePos, NULL); return (oss.str()); } void message::parse(const string& buffer) { bodyPart::parse(buffer); } } // vmime libvmime-0.9.1/src/platforms/0000755000175000017500000000000011607302336016426 5ustar mnordstrmnordstrlibvmime-0.9.1/src/platforms/posix/0000755000175000017500000000000011607302336017570 5ustar mnordstrmnordstrlibvmime-0.9.1/src/platforms/posix/posixChildProcess.cpp0000644000175000017500000001756511250723263023757 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/platforms/posix/posixChildProcess.hpp" #include "vmime/platforms/posix/posixFile.hpp" #include "vmime/exception.hpp" #include "vmime/utility/smartPtr.hpp" #include #include #include #include #include #include namespace vmime { namespace platforms { namespace posix { // posixChildProcessFactory ref posixChildProcessFactory::create(const utility::file::path& path) const { return vmime::create (path); } #ifndef VMIME_BUILDING_DOC // getPosixSignalMessage // Returns the name of a POSIX signal. static const string getPosixSignalMessage(const int num) { switch (num) { case SIGHUP: return "SIGHUP"; case SIGINT: return "SIGINT"; case SIGQUIT: return "SIGQUIT"; case SIGILL: return "SIGILL"; case SIGABRT: return "SIGABRT"; case SIGFPE: return "SIGFPE"; case SIGKILL: return "SIGKILL"; case SIGSEGV: return "SIGSEGV"; case SIGPIPE: return "SIGPIPE"; case SIGALRM: return "SIGALRM"; case SIGTERM: return "SIGTERM"; case SIGUSR1: return "SIGUSR1"; case SIGUSR2: return "SIGUSR2"; case SIGCHLD: return "SIGCHLD"; case SIGCONT: return "SIGCONT"; case SIGSTOP: return "SIGSTOP"; case SIGTSTP: return "SIGTSTP"; case SIGTTIN: return "SIGTTIN"; case SIGTTOU: return "SIGTTOU"; } return "(unknown)"; } // getPosixErrorMessage // Returns a message corresponding to an error code. static const string getPosixErrorMessage(const int num) { #ifdef strerror_r char res[256]; res[0] = '\0'; strerror_r(num, res, sizeof(res)); return string(res); #else return string(strerror(num)); #endif } // Output stream adapter for POSIX pipe class outputStreamPosixPipeAdapter : public utility::outputStream { public: outputStreamPosixPipeAdapter(const int desc) : m_desc(desc) { } void write(const value_type* const data, const size_type count) { if (::write(m_desc, data, count) == -1) { const string errorMsg = getPosixErrorMessage(errno); throw exceptions::system_error(errorMsg); } } void flush() { ::fsync(m_desc); } private: const int m_desc; }; // Input stream adapter for POSIX pipe class inputStreamPosixPipeAdapter : public utility::inputStream { public: inputStreamPosixPipeAdapter(const int desc) : m_desc(desc) { } bool eof() const { return (m_eof); } void reset() { // Do nothing: unsupported } size_type skip(const size_type count) { // TODO: not tested value_type buffer[4096]; int bytesSkipped = 0; int bytesRead = 0; while ((bytesRead = ::read(m_desc, buffer, std::min(sizeof(buffer), count - bytesSkipped))) != 0) { if (bytesRead == -1) { const string errorMsg = getPosixErrorMessage(errno); throw exceptions::system_error(errorMsg); } bytesSkipped += bytesRead; } return static_cast (bytesSkipped); } size_type read(value_type* const data, const size_type count) { int bytesRead = 0; if ((bytesRead = ::read(m_desc, data, count)) == -1) { const string errorMsg = getPosixErrorMessage(errno); throw exceptions::system_error(errorMsg); } m_eof = (bytesRead == 0); return static_cast (bytesRead); } private: const int m_desc; bool m_eof; }; #endif // VMIME_BUILDING_DOC // posixChildProcess posixChildProcess::posixChildProcess(const utility::file::path& path) : m_processPath(path), m_started(false), m_stdIn(NULL), m_stdOut(NULL), m_pid(0), m_argArray(NULL) { m_pipe[0] = 0; m_pipe[1] = 0; sigemptyset(&m_oldProcMask); } posixChildProcess::~posixChildProcess() { if (m_started) sigprocmask(SIG_SETMASK, &m_oldProcMask, NULL); if (m_pipe[0] != 0) close(m_pipe[0]); if (m_pipe[1] != 0) close(m_pipe[1]); delete [] (m_argArray); } // The following code is highly inspired and adapted from the 'sendmail' // provider module in Evolution data server code. // // Original authors: Dan Winship // Copyright 2000 Ximian, Inc. (www.ximian.com) void posixChildProcess::start(const std::vector args, const int flags) { if (m_started) return; // Construct C-style argument array const char** argv = new const char*[args.size() + 2]; m_argVector = args; // for c_str() pointer to remain valid m_argArray = argv; // to free later argv[0] = m_processPath.getLastComponent().getBuffer().c_str(); argv[args.size() + 1] = NULL; for (unsigned int i = 0 ; i < m_argVector.size() ; ++i) argv[i + 1] = m_argVector[i].c_str(); // Create a pipe to communicate with the child process int fd[2]; if (pipe(fd) == -1) { throw exceptions::system_error(getPosixErrorMessage(errno)); } m_pipe[0] = fd[0]; m_pipe[1] = fd[1]; // Block SIGCHLD so the calling application doesn't notice // process exiting before we do sigset_t mask; sigemptyset(&mask); sigaddset(&mask, SIGCHLD); sigprocmask(SIG_BLOCK, &mask, &m_oldProcMask); // Spawn process const pid_t pid = fork(); if (pid == -1) // error { const string errorMsg = getPosixErrorMessage(errno); sigprocmask(SIG_SETMASK, &m_oldProcMask, NULL); close(fd[0]); close(fd[1]); throw exceptions::system_error(errorMsg); } else if (pid == 0) // child process { if (flags & FLAG_REDIRECT_STDIN) dup2(fd[0], STDIN_FILENO); else close(fd[0]); if (flags & FLAG_REDIRECT_STDOUT) dup2(fd[1], STDOUT_FILENO); else close(fd[1]); posixFileSystemFactory* pfsf = new posixFileSystemFactory(); const string path = pfsf->pathToString(m_processPath); delete (pfsf); execv(path.c_str(), const_cast (argv)); _exit(255); } if (flags & FLAG_REDIRECT_STDIN) { m_stdIn = vmime::create (m_pipe[1]); } else { close(m_pipe[1]); m_pipe[1] = 0; } if (flags & FLAG_REDIRECT_STDOUT) { m_stdOut = vmime::create (m_pipe[0]); } else { close(m_pipe[0]); m_pipe[0] = 0; } m_pid = pid; m_started = true; } ref posixChildProcess::getStdIn() { return (m_stdIn); } ref posixChildProcess::getStdOut() { return (m_stdOut); } void posixChildProcess::waitForFinish() { // Close stdin pipe if (m_pipe[1] != 0) { close(m_pipe[1]); m_pipe[1] = 0; } int wstat; while (waitpid(m_pid, &wstat, 0) == -1 && errno == EINTR) ; if (!WIFEXITED(wstat)) { throw exceptions::system_error("Process exited with signal " + getPosixSignalMessage(WTERMSIG(wstat))); } else if (WEXITSTATUS(wstat) != 0) { if (WEXITSTATUS(wstat) == 255) { vmime::utility::auto_ptr pfsf = new posixFileSystemFactory(); throw exceptions::system_error("Could not execute '" + pfsf->pathToString(m_processPath) + "'"); } else { std::ostringstream oss; oss.imbue(std::locale::classic()); oss << "Process exited with status " << WEXITSTATUS(wstat); throw exceptions::system_error(oss.str()); } } } } // posix } // platforms } // vmime libvmime-0.9.1/src/platforms/posix/posixHandler.cpp0000644000175000017500000001252111314151074022731 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/platforms/posix/posixHandler.hpp" #include #include #include #include #include #include #include #include #include #include #if VMIME_HAVE_PTHREAD # include #endif // VMIME_HAVE_PTHREAD /* #ifdef _POSIX_PRIORITY_SCHEDULING #include #endif // _POSIX_PRIORITY_SCHEDULING */ #if VMIME_HAVE_PTHREAD namespace { // This construction ensures mutex will be initialized in compile-time // and will be available any time in the runtime. pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; // Helper lock, to be exception safe all the time. class PLockHelper { public: PLockHelper() { if (pthread_mutex_lock(&g_mutex) != 0) assert(!"unable to lock mutex - thread safety's void"); } ~PLockHelper() { if (pthread_mutex_unlock(&g_mutex) != 0) assert(!"unable to unlock mutex - application's dead..."); } private: // Object cannot be copied PLockHelper(const PLockHelper&); const PLockHelper& operator=(const PLockHelper&); }; } // unnamed namespace #endif // VMIME_HAVE_PTHREAD namespace vmime { namespace platforms { namespace posix { posixHandler::posixHandler() { #if VMIME_HAVE_MESSAGING_FEATURES m_socketFactory = vmime::create (); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES m_fileSysFactory = vmime::create (); m_childProcFactory = vmime::create (); #endif } posixHandler::~posixHandler() { } unsigned int posixHandler::getUnixTime() const { return ::time(NULL); } const vmime::datetime posixHandler::getCurrentLocalTime() const { const time_t t(::time(NULL)); // Get the local time #ifdef _REENTRANT tm local; ::localtime_r(&t, &local); #else tm local = *::localtime(&t); // WARNING: this is not thread-safe! #endif // Get the UTC time #ifdef _REENTRANT tm gmt; ::gmtime_r(&t, &gmt); #else tm gmt = *::gmtime(&t); // WARNING: this is not thread-safe! #endif // "A negative value for tm_isdst causes mktime() to attempt // to determine whether Daylight Saving Time is in effect // for the specified time." local.tm_isdst = -1; gmt.tm_isdst = -1; // Calculate the difference (in seconds) const int diff = ::mktime(&local) - ::mktime(&gmt); // Return the date return vmime::datetime(local.tm_year + 1900, local.tm_mon + 1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec, diff / 60); // minutes needed } const vmime::charset posixHandler::getLocaleCharset() const { const PLockHelper lock; const char* prevLocale = ::setlocale(LC_ALL, ""); vmime::charset ch(::nl_langinfo(CODESET)); ::setlocale(LC_ALL, prevLocale); return (ch); } const vmime::string posixHandler::getHostName() const { std::vector hostnames; char buffer[256]; // Try with 'gethostname' ::gethostname(buffer, sizeof(buffer)); buffer[sizeof(buffer) - 1] = '\0'; if (::strlen(buffer) == 0) ::strcpy(buffer, "localhost"); hostnames.push_back(buffer); // And with 'gethostbyname' struct hostent* he = ::gethostbyname(buffer); if (he != NULL) { if (::strlen(he->h_name) != 0) hostnames.push_back(he->h_name); char** alias = he->h_aliases; while (alias && *alias) { if (::strlen(*alias) != 0) hostnames.push_back(*alias); ++alias; } } // Find a Fully-Qualified Domain Name (FQDN) for (unsigned int i = 0 ; i < hostnames.size() ; ++i) { if (hostnames[i].find_first_of(".") != vmime::string::npos) return (hostnames[i]); } return (hostnames[0]); } unsigned int posixHandler::getProcessId() const { return (::getpid()); } #if VMIME_HAVE_MESSAGING_FEATURES ref posixHandler::getSocketFactory() { return m_socketFactory; } #endif #if VMIME_HAVE_FILESYSTEM_FEATURES ref posixHandler::getFileSystemFactory() { return m_fileSysFactory; } ref posixHandler::getChildProcessFactory() { return m_childProcFactory; } #endif void posixHandler::wait() const { /* #ifdef _POSIX_PRIORITY_SCHEDULING ::sched_yield(); #else ::sleep(1); #endif // _POSIX_PRIORITY_SCHEDULING */ struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 500000; // 500 microseconds nanosleep(&ts, NULL); } } // posix } // platforms } // vmime libvmime-0.9.1/src/platforms/posix/posixFile.cpp0000644000175000017500000003071111374031010022225 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/platforms/posix/posixFile.hpp" #include #include #include #include #include #include #include #include #include "vmime/exception.hpp" #if VMIME_HAVE_FILESYSTEM_FEATURES namespace vmime { namespace platforms { namespace posix { // // posixFileIterator // posixFileIterator::posixFileIterator(const vmime::utility::file::path& path, const vmime::string& nativePath) : m_path(path), m_nativePath(nativePath), m_dir(NULL), m_dirEntry(NULL) { if ((m_dir = ::opendir(m_nativePath.c_str())) == NULL) posixFileSystemFactory::reportError(path, errno); getNextElement(); } posixFileIterator::~posixFileIterator() { if (m_dir != NULL) { if (::closedir(m_dir) == -1) posixFileSystemFactory::reportError(m_path, errno); } } bool posixFileIterator::hasMoreElements() const { return (m_dirEntry != NULL); } ref posixFileIterator::nextElement() { ref file = vmime::create (m_path / vmime::utility::file::path::component(m_dirEntry->d_name)); getNextElement(); return (file); } void posixFileIterator::getNextElement() { errno = 0; while ((m_dirEntry = ::readdir(m_dir)) != NULL) { const char* name = m_dirEntry->d_name; const int len = ::strlen(name); if (!(len == 1 && name[0] == '.') && !(len == 2 && name[0] == '.' && name[1] == '.')) { break; } } if (errno) posixFileSystemFactory::reportError(m_path, errno); } // // posixFileWriterOutputStream // posixFileWriterOutputStream::posixFileWriterOutputStream(const vmime::utility::file::path& path, const int fd) : m_path(path), m_fd(fd) { } posixFileWriterOutputStream::~posixFileWriterOutputStream() { ::close(m_fd); } void posixFileWriterOutputStream::write(const value_type* const data, const size_type count) { const value_type* array = data; size_t size = count; while (1) { ssize_t ret = ::write(m_fd, array, size); if (ret == -1) { if (errno == EINTR) continue; posixFileSystemFactory::reportError(m_path, errno); break; } else if (size_t(ret) < size) { array += ret; size -= ret; } break; } } void posixFileWriterOutputStream::flush() { if (::fsync(m_fd) == -1) posixFileSystemFactory::reportError(m_path, errno); } // // posixFileReaderInputStream // posixFileReaderInputStream::posixFileReaderInputStream(const vmime::utility::file::path& path, const int fd) : m_path(path), m_fd(fd), m_eof(false) { } posixFileReaderInputStream::~posixFileReaderInputStream() { if (::close(m_fd) == -1) posixFileSystemFactory::reportError(m_path, errno); } bool posixFileReaderInputStream::eof() const { return (m_eof); } void posixFileReaderInputStream::reset() { if (::lseek(m_fd, 0, SEEK_SET) == off_t(-1)) posixFileSystemFactory::reportError(m_path, errno); m_eof = false; } vmime::utility::stream::size_type posixFileReaderInputStream::read (value_type* const data, const size_type count) { ssize_t c = 0; if ((c = ::read(m_fd, data, count)) == -1) posixFileSystemFactory::reportError(m_path, errno); if (c == 0 && count != 0) m_eof = true; return static_cast (c); } vmime::utility::stream::size_type posixFileReaderInputStream::skip(const size_type count) { const off_t curPos = ::lseek(m_fd, 0, SEEK_CUR); if (curPos == off_t(-1)) posixFileSystemFactory::reportError(m_path, errno); const off_t newPos = ::lseek(m_fd, count, SEEK_CUR); if (newPos == off_t(-1)) posixFileSystemFactory::reportError(m_path, errno); return static_cast (newPos - curPos); } // // posixFileWriter // posixFileWriter::posixFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath) : m_path(path), m_nativePath(nativePath) { } ref posixFileWriter::getOutputStream() { int fd = 0; if ((fd = ::open(m_nativePath.c_str(), O_WRONLY, 0660)) == -1) posixFileSystemFactory::reportError(m_path, errno); return vmime::create (m_path, fd); } // // posixFileReader // posixFileReader::posixFileReader(const vmime::utility::file::path& path, const vmime::string& nativePath) : m_path(path), m_nativePath(nativePath) { } ref posixFileReader::getInputStream() { int fd = 0; if ((fd = ::open(m_nativePath.c_str(), O_RDONLY, 0640)) == -1) posixFileSystemFactory::reportError(m_path, errno); return vmime::create (m_path, fd); } // // posixFile // posixFile::posixFile(const vmime::utility::file::path& path) : m_path(path), m_nativePath(posixFileSystemFactory::pathToStringImpl(path)) { } void posixFile::createFile() { int fd = 0; if ((fd = ::open(m_nativePath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660)) == -1) posixFileSystemFactory::reportError(m_path, errno); if (::fsync(fd) == -1) posixFileSystemFactory::reportError(m_path, errno); if (::close(fd) == -1) posixFileSystemFactory::reportError(m_path, errno); } void posixFile::createDirectory(const bool createAll) { createDirectoryImpl(m_path, m_path, createAll); } bool posixFile::isFile() const { struct stat buf; if (::stat(m_nativePath.c_str(), &buf) == -1) { if (errno == ENOENT) return false; posixFileSystemFactory::reportError(m_path, errno); return false; } return S_ISREG(buf.st_mode); } bool posixFile::isDirectory() const { struct stat buf; if (::stat(m_nativePath.c_str(), &buf) == -1) { if (errno == ENOENT) return false; posixFileSystemFactory::reportError(m_path, errno); return false; } return S_ISDIR(buf.st_mode); } bool posixFile::canRead() const { struct stat buf; if (::stat(m_nativePath.c_str(), &buf) == -1) { if (errno == ENOENT) return false; posixFileSystemFactory::reportError(m_path, errno); return false; } return S_ISREG(buf.st_mode) && ::access(m_nativePath.c_str(), R_OK | F_OK) == 0; } bool posixFile::canWrite() const { struct stat buf; if (::stat(m_nativePath.c_str(), &buf) == -1) { if (errno == ENOENT) return false; posixFileSystemFactory::reportError(m_path, errno); return false; } return S_ISREG(buf.st_mode) && ::access(m_nativePath.c_str(), W_OK | F_OK) == 0; } posixFile::length_type posixFile::getLength() { struct stat buf; if (::stat(m_nativePath.c_str(), &buf) == -1) posixFileSystemFactory::reportError(m_path, errno); return static_cast (buf.st_size); } const posixFile::path& posixFile::getFullPath() const { return (m_path); } bool posixFile::exists() const { struct stat buf; return (::stat(m_nativePath.c_str(), &buf) == 0); } ref posixFile::getParent() const { if (m_path.isEmpty()) return NULL; else return vmime::create (m_path.getParent()); } void posixFile::rename(const path& newName) { const vmime::string newNativePath = posixFileSystemFactory::pathToStringImpl(newName); posixFile dest(newName); if (isDirectory()) dest.createDirectory(); else dest.createFile(); if (::rename(m_nativePath.c_str(), newNativePath.c_str()) == -1) posixFileSystemFactory::reportError(m_path, errno); m_path = newName; m_nativePath = newNativePath; } void posixFile::remove() { struct stat buf; if (::stat(m_nativePath.c_str(), &buf) == -1) posixFileSystemFactory::reportError(m_path, errno); if (S_ISDIR(buf.st_mode)) { if (::rmdir(m_nativePath.c_str()) == -1) posixFileSystemFactory::reportError(m_path, errno); } else if (S_ISREG(buf.st_mode)) { if (::unlink(m_nativePath.c_str()) == -1) posixFileSystemFactory::reportError(m_path, errno); } } ref posixFile::getFileWriter() { return vmime::create (m_path, m_nativePath); } ref posixFile::getFileReader() { return vmime::create (m_path, m_nativePath); } ref posixFile::getFiles() const { if (!isDirectory()) throw vmime::exceptions::not_a_directory(m_path); return vmime::create (m_path, m_nativePath); } void posixFile::createDirectoryImpl(const vmime::utility::file::path& fullPath, const vmime::utility::file::path& path, const bool recursive) { const vmime::string nativePath = posixFileSystemFactory::pathToStringImpl(path); struct stat buf; if (::stat(nativePath.c_str(), &buf) == 0 && S_ISDIR(buf.st_mode)) return; if (!path.isEmpty() && recursive) createDirectoryImpl(fullPath, path.getParent(), true); if (::mkdir(nativePath.c_str(), 0750) == -1) posixFileSystemFactory::reportError(fullPath, errno); } // // posixFileSystemFactory // ref posixFileSystemFactory::create(const vmime::utility::file::path& path) const { return vmime::create (path); } const vmime::utility::file::path posixFileSystemFactory::stringToPath(const vmime::string& str) const { return (stringToPathImpl(str)); } const vmime::string posixFileSystemFactory::pathToString(const vmime::utility::file::path& path) const { return (pathToStringImpl(path)); } const vmime::utility::file::path posixFileSystemFactory::stringToPathImpl(const vmime::string& str) { vmime::string::size_type offset = 0; vmime::string::size_type prev = 0; vmime::utility::file::path path; while ((offset = str.find_first_of("/", offset)) != vmime::string::npos) { if (offset != prev) path.appendComponent(vmime::string(str.begin() + prev, str.begin() + offset)); prev = offset + 1; offset++; } if (prev < str.length()) path.appendComponent(vmime::string(str.begin() + prev, str.end())); return (path); } const vmime::string posixFileSystemFactory::pathToStringImpl(const vmime::utility::file::path& path) { vmime::string native = "/"; for (int i = 0 ; i < path.getSize() ; ++i) { if (i > 0) native += "/"; native += path[i].getBuffer(); } return (native); } bool posixFileSystemFactory::isValidPathComponent(const vmime::utility::file::path::component& comp) const { return (comp.getBuffer().find_first_of("/*") == vmime::string::npos); } bool posixFileSystemFactory::isValidPath(const vmime::utility::file::path& path) const { for (int i = 0 ; i < path.getSize() ; ++i) { if (!isValidPathComponent(path[i])) return false; } return true; } void posixFileSystemFactory::reportError(const vmime::utility::path& path, const int err) { vmime::string desc; switch (err) { case EEXIST: desc = "EEXIST: file already exists."; break; case EISDIR: desc = "EISDIR: path refers to a directory."; break; case EACCES: desc = "EACCES: permission denied"; break; case ENAMETOOLONG: desc = "ENAMETOOLONG: path too long."; break; case ENOENT: desc = "ENOENT: a directory in the path does not exist."; break; case ENOTDIR: desc = "ENOTDIR: path is not a directory."; break; case EROFS: desc = "EROFS: read-only filesystem."; break; case ELOOP: desc = "ELOOP: too many symbolic links."; break; case ENOSPC: desc = "ENOSPC: no space left on device."; break; case ENOMEM: desc = "ENOMEM: insufficient kernel memory."; break; case EMFILE: desc = "ENFILE: limit on number of files open by the process has been reached."; break; case ENFILE: desc = "ENFILE: limit on number of files open on the system has been reached."; break; #ifndef AIX case ENOTEMPTY: desc = "ENOTEMPTY: directory is not empty."; break; #endif default: std::ostringstream oss; oss << ::strerror(err) << "."; desc = oss.str(); break; } throw vmime::exceptions::filesystem_exception(desc, path); } } // posix } // platforms } // vmime #endif // VMIME_HAVE_FILESYSTEM_FEATURES libvmime-0.9.1/src/platforms/posix/posixSocket.cpp0000644000175000017500000002206211426504624022614 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/platforms/posix/posixSocket.hpp" #include "vmime/platforms/posix/posixHandler.hpp" #include #include #include #include #include #include #include #include #include #include "vmime/exception.hpp" #if VMIME_HAVE_MESSAGING_FEATURES namespace vmime { namespace platforms { namespace posix { // // posixSocket // posixSocket::posixSocket(ref th) : m_timeoutHandler(th), m_desc(-1) { } posixSocket::~posixSocket() { if (m_desc != -1) ::close(m_desc); } void posixSocket::connect(const vmime::string& address, const vmime::port_t port) { // Close current connection, if any if (m_desc != -1) { ::close(m_desc); m_desc = -1; } #if VMIME_HAVE_GETADDRINFO // use thread-safe and IPv6-aware getaddrinfo() if available // Resolve address, if needed struct ::addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; std::ostringstream portStr; portStr.imbue(std::locale::classic()); portStr << port; struct ::addrinfo* res0; if (::getaddrinfo(address.c_str(), portStr.str().c_str(), &hints, &res0) != 0) { // Error: cannot resolve address throw vmime::exceptions::connection_error("Cannot resolve address."); } // Connect to host int sock = -1; struct ::addrinfo* res = res0; for ( ; sock == -1 && res != NULL ; res = res->ai_next) { sock = ::socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (sock < 0) continue; // try next if (m_timeoutHandler != NULL) { ::fcntl(sock, F_SETFL, ::fcntl(sock, F_GETFL) | O_NONBLOCK); if (::connect(sock, res->ai_addr, res->ai_addrlen) < 0) { switch (errno) { case 0: case EINPROGRESS: case EINTR: #if defined(EAGAIN) case EAGAIN: #endif // EAGAIN #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN)) case EWOULDBLOCK: #endif // EWOULDBLOCK // Connection in progress break; default: ::close(sock); sock = -1; continue; // try next } // Wait for socket to be connected. // We will check for time out every second. fd_set fds; FD_ZERO(&fds); FD_SET(sock, &fds); fd_set fdsError; FD_ZERO(&fdsError); FD_SET(sock, &fdsError); struct timeval tm; tm.tv_sec = 1; tm.tv_usec = 0; m_timeoutHandler->resetTimeOut(); bool connected = false; do { const int ret = select(sock + 1, NULL, &fds, &fdsError, &tm); // Success if (ret > 0) { connected = true; break; } // Error else if (ret < -1) { if (errno != EINTR) { // Cancel connection break; } } // 1-second timeout else if (ret == 0) { if (m_timeoutHandler->isTimeOut()) { if (!m_timeoutHandler->handleTimeOut()) { // Cancel connection break; } else { // Reset timeout and keep waiting for connection m_timeoutHandler->resetTimeOut(); } } else { // Keep waiting for connection } } ::sched_yield(); } while (true); if (!connected) { ::close(sock); sock = -1; continue; // try next } break; } } else { if (::connect(sock, res->ai_addr, res->ai_addrlen) < 0) { ::close(sock); sock = -1; continue; // try next } } } ::freeaddrinfo(res0); if (sock == -1) { try { throwSocketError(errno); } catch (exceptions::socket_exception& e) { throw vmime::exceptions::connection_error ("Error while connecting socket.", e); } } m_desc = sock; #else // !VMIME_HAVE_GETADDRINFO // Resolve address ::sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(static_cast (port)); addr.sin_addr.s_addr = ::inet_addr(address.c_str()); if (addr.sin_addr.s_addr == static_cast (-1)) { ::hostent* hostInfo = ::gethostbyname(address.c_str()); if (hostInfo == NULL) { // Error: cannot resolve address throw vmime::exceptions::connection_error("Cannot resolve address."); } ::memcpy(reinterpret_cast (&addr.sin_addr), hostInfo->h_addr, hostInfo->h_length); } // Get a new socket m_desc = ::socket(AF_INET, SOCK_STREAM, 0); if (m_desc == -1) { try { throwSocketError(errno); } catch (exceptions::socket_exception& e) { throw vmime::exceptions::connection_error ("Error while creating socket.", e); } } // Start connection if (::connect(m_desc, reinterpret_cast (&addr), sizeof(addr)) == -1) { try { throwSocketError(errno); } catch (exceptions::socket_exception& e) { ::close(m_desc); m_desc = -1; // Error throw vmime::exceptions::connection_error ("Error while connecting socket.", e); } } #endif // VMIME_HAVE_GETADDRINFO ::fcntl(m_desc, F_SETFL, ::fcntl(m_desc, F_GETFL) | O_NONBLOCK); } bool posixSocket::isConnected() const { if (m_desc == -1) return false; char buff; return ::recv(m_desc, &buff, 1, MSG_PEEK) != 0; } void posixSocket::disconnect() { if (m_desc != -1) { ::shutdown(m_desc, SHUT_RDWR); ::close(m_desc); m_desc = -1; } } posixSocket::size_type posixSocket::getBlockSize() const { return 16384; // 16 KB } void posixSocket::receive(vmime::string& buffer) { const int size = receiveRaw(m_buffer, sizeof(m_buffer)); buffer = vmime::string(m_buffer, size); } posixSocket::size_type posixSocket::receiveRaw(char* buffer, const size_type count) { const int ret = ::recv(m_desc, buffer, count, 0); if (ret < 0) { if (errno != EAGAIN) throwSocketError(errno); // No data available at this time return 0; } else if (ret == 0) { // Host shutdown throwSocketError(ENOTCONN); } return ret; } void posixSocket::send(const vmime::string& buffer) { sendRaw(buffer.data(), buffer.length()); } void posixSocket::sendRaw(const char* buffer, const size_type count) { size_type size = count; while (size > 0) { const int ret = ::send(m_desc, buffer, size, 0); if (ret < 0) { if (errno != EAGAIN) throwSocketError(errno); platform::getHandler()->wait(); } else { buffer += ret; size -= ret; } } } void posixSocket::throwSocketError(const int err) { string msg; switch (err) { case EACCES: msg = "EACCES: permission denied"; break; case EAFNOSUPPORT: msg = "EAFNOSUPPORT: address family not supported"; break; case EMFILE: msg = "EMFILE: process file table overflow"; break; case ENFILE: msg = "ENFILE: system limit reached"; break; case EPROTONOSUPPORT: msg = "EPROTONOSUPPORT: protocol not supported"; break; case EAGAIN: msg = "EGAIN: blocking operation"; break; case EBADF: msg = "EBADF: invalid descriptor"; break; case ECONNRESET: msg = "ECONNRESET: connection reset by peer"; break; case EFAULT: msg = "EFAULT: bad user space address"; break; case EINTR: msg = "EINTR: signal occured before transmission"; break; case EINVAL: msg = "EINVAL: invalid argument"; break; case EMSGSIZE: msg = "EMSGSIZE: message cannot be sent atomically"; break; case ENOBUFS: msg = "ENOBUFS: output queue is full"; break; case ENOMEM: msg = "ENOMEM: out of memory"; break; case EPIPE: case ENOTCONN: msg = "ENOTCONN: not connected"; break; case ECONNREFUSED: msg = "ECONNREFUSED: connection refused"; break; default: std::ostringstream oss; oss << ::strerror(err); msg = oss.str(); break; } throw exceptions::socket_exception(msg); } // // posixSocketFactory // ref posixSocketFactory::create() { ref th = NULL; return vmime::create (th); } ref posixSocketFactory::create(ref th) { return vmime::create (th); } } // posix } // platforms } // vmime #endif // VMIME_HAVE_MESSAGING_FEATURES libvmime-0.9.1/src/platforms/windows/0000755000175000017500000000000011607302336020120 5ustar mnordstrmnordstrlibvmime-0.9.1/src/platforms/windows/windowsFile.cpp0000644000175000017500000003046411333330451023120 0ustar mnordstrmnordstr// // VMime library (http://vmime.sourceforge.net) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/platforms/windows/windowsFile.hpp" #include #include #include "vmime/exception.hpp" #include "vmime/utility/stringUtils.hpp" #if VMIME_HAVE_FILESYSTEM_FEATURES namespace vmime { namespace platforms { namespace windows { ref windowsFileSystemFactory::create(const vmime::utility::file::path& path) const { return vmime::create (path); } const vmime::utility::file::path windowsFileSystemFactory::stringToPath(const vmime::string& str) const { return (stringToPathImpl(str)); } const vmime::string windowsFileSystemFactory::pathToString(const vmime::utility::file::path& path) const { return (pathToStringImpl(path)); } const vmime::utility::file::path windowsFileSystemFactory::stringToPathImpl(const vmime::string& str) { vmime::string::size_type offset = 0; vmime::string::size_type prev = 0; vmime::utility::file::path path; while ((offset = str.find_first_of("\\", offset)) != vmime::string::npos) { if (offset != prev) path.appendComponent(vmime::string(str.begin() + prev, str.begin() + offset)); prev = offset + 1; offset++; } if (prev < str.length()) path.appendComponent(vmime::string(str.begin() + prev, str.end())); return (path); } const vmime::string windowsFileSystemFactory::pathToStringImpl(const vmime::utility::file::path& path) { vmime::string native = ""; for (int i = 0 ; i < path.getSize() ; ++i) { if (i > 0) native += "\\"; native += path[i].getBuffer(); } return (native); } bool windowsFileSystemFactory::isValidPathComponent(const vmime::utility::file::path::component& comp) const { return isValidPathComponent(comp, false); } bool windowsFileSystemFactory::isValidPathComponent( const vmime::utility::file::path::component& comp, bool firstComponent) const { const string& buffer = comp.getBuffer(); // If first component, check if component is a drive if (firstComponent && (buffer.length() == 2) && (buffer[1] == ':')) { char drive = tolower(buffer[0]); if ((drive >= 'a') && (drive <= 'z')) return true; } // Check for invalid characters for (string::size_type i = 0 ; i < buffer.length() ; ++i) { const unsigned char c = buffer[i]; switch (c) { // Reserved characters case '<': case '>': case ':': case '"': case '/': case '\\': case '|': case '$': case '*': return false; default: if (c <= 31) return false; } } string upperBuffer = vmime::utility::stringUtils::toUpper(buffer); // Check for reserved names if (upperBuffer.length() == 3) { if (upperBuffer == "CON" || buffer == "PRN" || buffer == "AUX" || buffer == "NUL") return false; } else if (upperBuffer.length() == 4) { if ((upperBuffer.substr(0, 3) == "COM") && // COM0 to COM9 (upperBuffer[3] >= '0') && (upperBuffer[3] <= '9')) { return false; } else if ((upperBuffer.substr(0, 3) == "LPT") && // LPT0 to LPT9 (upperBuffer[3] >= '0') && (upperBuffer[3] <= '9')) { return false; } } return true; } bool windowsFileSystemFactory::isValidPath(const vmime::utility::file::path& path) const { for (int i = 0 ; i < path.getSize() ; ++i) { if (!isValidPathComponent(path[i], (i==0))) return false; } return true; } void windowsFileSystemFactory::reportError(const vmime::utility::path& path, const int err) { vmime::string desc; LPVOID lpMsgBuf; if (FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL )) { desc = (char*)lpMsgBuf; LocalFree( lpMsgBuf ); } throw vmime::exceptions::filesystem_exception(desc, path); } windowsFile::windowsFile(const vmime::utility::file::path& path) : m_path(path), m_nativePath(windowsFileSystemFactory::pathToStringImpl(path)) { } void windowsFile::createFile() { HANDLE hFile = CreateFile( m_nativePath.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) windowsFileSystemFactory::reportError(m_path, GetLastError()); CloseHandle(hFile); } void windowsFile::createDirectory(const bool createAll) { createDirectoryImpl(m_path, m_path, createAll); } bool windowsFile::isFile() const { DWORD dwFileAttribute = GetFileAttributes(m_nativePath.c_str()); if (dwFileAttribute == INVALID_FILE_ATTRIBUTES) return false; return (dwFileAttribute & FILE_ATTRIBUTE_DIRECTORY) == 0; } bool windowsFile::isDirectory() const { DWORD dwFileAttribute = GetFileAttributes(m_nativePath.c_str()); if (dwFileAttribute == INVALID_FILE_ATTRIBUTES) return false; return (dwFileAttribute & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY; } bool windowsFile::canRead() const { HANDLE hFile = CreateFile( m_nativePath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return false; CloseHandle(hFile); return true; } bool windowsFile::canWrite() const { HANDLE hFile = CreateFile( m_nativePath.c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return false; CloseHandle(hFile); return true; } windowsFile::length_type windowsFile::getLength() { HANDLE hFile = CreateFile( m_nativePath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) windowsFileSystemFactory::reportError(m_path, GetLastError()); DWORD dwSize = GetFileSize(hFile, NULL); CloseHandle(hFile); return dwSize; } const vmime::utility::path& windowsFile::getFullPath() const { return m_path; } bool windowsFile::exists() const { WIN32_FIND_DATA findData; HANDLE hFind = FindFirstFile(m_nativePath.c_str(), &findData); if (hFind != INVALID_HANDLE_VALUE) { FindClose(hFind); return true; } return false; } ref windowsFile::getParent() const { if (m_path.isEmpty()) return NULL; else return vmime::create (m_path.getParent()); } void windowsFile::rename(const path& newName) { const vmime::string newNativeName = windowsFileSystemFactory::pathToStringImpl(newName); if (MoveFile(m_nativePath.c_str(), newNativeName.c_str())) { m_path = newName; m_nativePath = newNativeName; } else windowsFileSystemFactory::reportError(m_path, GetLastError()); } void windowsFile::remove() { if (!DeleteFile(m_nativePath.c_str())) windowsFileSystemFactory::reportError(m_path, GetLastError()); } ref windowsFile::getFileWriter() { return vmime::create (m_path, m_nativePath); } ref windowsFile::getFileReader() { return vmime::create (m_path, m_nativePath); } ref windowsFile::getFiles() const { return vmime::create (m_path, m_nativePath); } void windowsFile::createDirectoryImpl(const vmime::utility::file::path& fullPath, const vmime::utility::file::path& path, const bool recursive) { const vmime::string nativePath = windowsFileSystemFactory::pathToStringImpl(path); windowsFile tmp(fullPath); if (tmp.isDirectory()) return; if (!path.isEmpty() && recursive) createDirectoryImpl(fullPath, path.getParent(), true); if (!CreateDirectory(nativePath.c_str(), NULL)) windowsFileSystemFactory::reportError(fullPath, GetLastError()); } windowsFileIterator::windowsFileIterator(const vmime::utility::file::path& path, const vmime::string& nativePath) : m_path(path), m_nativePath(nativePath), m_moreElements(false), m_hFind(INVALID_HANDLE_VALUE) { findFirst(); } windowsFileIterator::~windowsFileIterator() { if (m_hFind != INVALID_HANDLE_VALUE) FindClose(m_hFind); } bool windowsFileIterator::hasMoreElements() const { return m_moreElements; } ref windowsFileIterator::nextElement() { ref pFile = vmime::create (m_path / vmime::utility::file::path::component(m_findData.cFileName)); findNext(); return pFile; } void windowsFileIterator::findFirst() { m_hFind = FindFirstFile(m_nativePath.c_str(), &m_findData); if (m_hFind == INVALID_HANDLE_VALUE) { m_moreElements = false; return; } m_moreElements = true; if (isCurrentOrParentDir()) findNext(); } void windowsFileIterator::findNext() { do { if (!FindNextFile(m_hFind, &m_findData)) { m_moreElements = false; return; } } while (isCurrentOrParentDir()); } bool windowsFileIterator::isCurrentOrParentDir() const { vmime::string s(m_findData.cFileName); if ((s == ".") || (s == "..")) return true; return false; } windowsFileReader::windowsFileReader(const vmime::utility::file::path& path, const vmime::string& nativePath) : m_path(path), m_nativePath(nativePath) { } ref windowsFileReader::getInputStream() { HANDLE hFile = CreateFile( m_nativePath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); if (hFile == INVALID_HANDLE_VALUE) windowsFileSystemFactory::reportError(m_path, GetLastError()); return vmime::create (m_path, hFile); } windowsFileReaderInputStream::windowsFileReaderInputStream(const vmime::utility::file::path& path, HANDLE hFile) : m_path(path), m_hFile(hFile) { } windowsFileReaderInputStream::~windowsFileReaderInputStream() { CloseHandle(m_hFile); } bool windowsFileReaderInputStream::eof() const { DWORD dwSize = GetFileSize(m_hFile, NULL); DWORD dwPosition = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT); return (dwSize == dwPosition); } void windowsFileReaderInputStream::reset() { SetFilePointer(m_hFile, 0, NULL, FILE_BEGIN); } vmime::utility::stream::size_type windowsFileReaderInputStream::read(value_type* const data, const size_type count) { DWORD dwBytesRead; if (!ReadFile(m_hFile, (LPVOID)data, (DWORD)count, &dwBytesRead, NULL)) windowsFileSystemFactory::reportError(m_path, GetLastError()); return dwBytesRead; } vmime::utility::stream::size_type windowsFileReaderInputStream::skip(const size_type count) { DWORD dwCurPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT); DWORD dwNewPos = SetFilePointer(m_hFile, (LONG)count, NULL, FILE_CURRENT); return (dwNewPos - dwCurPos); } windowsFileWriter::windowsFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath) : m_path(path), m_nativePath(nativePath) { } ref windowsFileWriter::getOutputStream() { HANDLE hFile = CreateFile( m_nativePath.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) windowsFileSystemFactory::reportError(m_path, GetLastError()); return vmime::create (m_path, hFile); } windowsFileWriterOutputStream::windowsFileWriterOutputStream(const vmime::utility::file::path& path, HANDLE hFile) : m_path(path), m_hFile(hFile) { } windowsFileWriterOutputStream::~windowsFileWriterOutputStream() { CloseHandle(m_hFile); } void windowsFileWriterOutputStream::write(const value_type* const data, const size_type count) { DWORD dwBytesWritten; if (!WriteFile(m_hFile, data, (DWORD)count, &dwBytesWritten, NULL)) windowsFileSystemFactory::reportError(m_path, GetLastError()); } void windowsFileWriterOutputStream::flush() { // TODO } } // windows } // platforms } // vmime #endif // VMIME_HAVE_FILESYSTEM_FEATURES libvmime-0.9.1/src/platforms/windows/windowsSocket.cpp0000644000175000017500000001002611432210306023455 0ustar mnordstrmnordstr// // VMime library (http://vmime.sourceforge.net) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #pragma warning(disable: 4267) #include "vmime/platforms/windows/windowsSocket.hpp" #include "vmime/exception.hpp" #if VMIME_HAVE_MESSAGING_FEATURES namespace vmime { namespace platforms { namespace windows { // // posixSocket // windowsSocket::windowsSocket(ref th) : m_timeoutHandler(th), m_desc(-1) { WSAData wsaData; WSAStartup(MAKEWORD(1, 1), &wsaData); } windowsSocket::~windowsSocket() { if (m_desc != -1) ::closesocket(m_desc); WSACleanup(); } void windowsSocket::connect(const vmime::string& address, const vmime::port_t port) { // Close current connection, if any if (m_desc != -1) { ::closesocket(m_desc); m_desc = -1; } // Resolve address ::sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(static_cast (port)); addr.sin_addr.s_addr = ::inet_addr(address.c_str()); if (addr.sin_addr.s_addr == static_cast (-1)) { ::hostent* hostInfo = ::gethostbyname(address.c_str()); if (hostInfo == NULL) { // Error: cannot resolve address throw vmime::exceptions::connection_error("Cannot resolve address."); } memcpy(reinterpret_cast (&addr.sin_addr), hostInfo->h_addr, hostInfo->h_length); } // Get a new socket m_desc = ::socket(AF_INET, SOCK_STREAM, 0); if (m_desc == -1) throw vmime::exceptions::connection_error("Error while creating socket."); // Start connection if (::connect(m_desc, reinterpret_cast (&addr), sizeof(addr)) == -1) { ::closesocket(m_desc); m_desc = -1; // Error throw vmime::exceptions::connection_error("Error while connecting socket."); } } bool windowsSocket::isConnected() const { return (m_desc != -1); } void windowsSocket::disconnect() { if (m_desc != -1) { ::shutdown(m_desc, SD_BOTH); ::closesocket(m_desc); m_desc = -1; } } windowsSocket::size_type windowsSocket::getBlockSize() const { return 16384; // 16 KB } void windowsSocket::receive(vmime::string& buffer) { int ret = ::recv(m_desc, m_buffer, sizeof(m_buffer), 0); if (ret == -1) { // Error or no data return; } else if (ret > 0) { buffer = vmime::string(m_buffer, ret); } } windowsSocket::size_type windowsSocket::receiveRaw(char* buffer, const size_type count) { int ret = ::recv(m_desc, buffer, count, 0); if (ret == -1) { // Error or no data return (0); } else { return (ret); } } void windowsSocket::send(const vmime::string& buffer) { ::send(m_desc, buffer.data(), buffer.length(), 0); } void windowsSocket::sendRaw(const char* buffer, const size_type count) { ::send(m_desc, buffer, count, 0); } // // posixSocketFactory // ref windowsSocketFactory::create() { ref th = NULL; return vmime::create (th); } ref windowsSocketFactory::create(ref th) { return vmime::create (th); } } // posix } // platforms } // vmime #endif // VMIME_HAVE_MESSAGING_FEATURES libvmime-0.9.1/src/platforms/windows/windowsHandler.cpp0000644000175000017500000001565311314151074023622 0ustar mnordstrmnordstr// // VMime library (http://vmime.sourceforge.net) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/platforms/windows/windowsHandler.hpp" #include "vmime/config.hpp" #include #include #include #include // for winnls.h #include // for WSAStartup() #ifdef VMIME_HAVE_MLANG_H # include #endif namespace vmime { namespace platforms { namespace windows { windowsHandler::windowsHandler() { WSAData wsaData; WSAStartup(MAKEWORD(1, 1), &wsaData); #if VMIME_HAVE_MESSAGING_FEATURES m_socketFactory = vmime::create (); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES m_fileSysFactory = vmime::create (); #endif } windowsHandler::~windowsHandler() { WSACleanup(); } unsigned int windowsHandler::getUnixTime() const { return static_cast (::time(NULL)); } const vmime::datetime windowsHandler::getCurrentLocalTime() const { const time_t t(::time(NULL)); // Get the local time #if defined(_REENTRANT) && defined(localtime_r) tm local; ::localtime_r(&t, &local); #else tm local = *::localtime(&t); // WARNING: this is not thread-safe! #endif // Get the UTC time #if defined(_REENTRANT) && defined(gmtime_r) tm gmt; ::gmtime_r(&t, &gmt); #else tm gmt = *::gmtime(&t); // WARNING: this is not thread-safe! #endif // "A negative value for tm_isdst causes mktime() to attempt // to determine whether Daylight Saving Time is in effect // for the specified time." local.tm_isdst = -1; gmt.tm_isdst = -1; // Calculate the difference (in seconds) const int diff = (const int)(::mktime(&local) - ::mktime(&gmt)); // Return the date return vmime::datetime(local.tm_year + 1900, local.tm_mon + 1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec, diff / 60); // minutes needed } const vmime::charset windowsHandler::getLocaleCharset() const { #ifdef VMIME_HAVE_MLANG_H char szCharset[256]; CoInitialize(NULL); { IMultiLanguage* pMultiLanguage; CoCreateInstance( CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER, IID_IMultiLanguage, (void**)&pMultiLanguage); UINT codePage = GetACP(); MIMECPINFO cpInfo; pMultiLanguage->GetCodePageInfo(codePage, &cpInfo); int nLengthW = lstrlenW(cpInfo.wszBodyCharset) + 1; WideCharToMultiByte(codePage, 0, cpInfo.wszBodyCharset, nLengthW, szCharset, sizeof(szCharset), NULL, NULL ); pMultiLanguage->Release(); } CoUninitialize(); return vmime::charset(szCharset); #else // VMIME_HAVE_MLANG_H vmime::string ch = vmime::charsets::ISO8859_1; // default switch (GetACP()) { case 437: ch = vmime::charsets::CP_437; break; case 737: ch = vmime::charsets::CP_737; break; case 775: ch = vmime::charsets::CP_775; break; case 850: ch = vmime::charsets::CP_850; break; case 852: ch = vmime::charsets::CP_852; break; case 853: ch = vmime::charsets::CP_853; break; case 855: ch = vmime::charsets::CP_855; break; case 857: ch = vmime::charsets::CP_857; break; case 858: ch = vmime::charsets::CP_858; break; case 860: ch = vmime::charsets::CP_860; break; case 861: ch = vmime::charsets::CP_861; break; case 862: ch = vmime::charsets::CP_862; break; case 863: ch = vmime::charsets::CP_863; break; case 864: ch = vmime::charsets::CP_864; break; case 865: ch = vmime::charsets::CP_865; break; case 866: ch = vmime::charsets::CP_866; break; case 869: ch = vmime::charsets::CP_869; break; case 874: ch = vmime::charsets::CP_874; break; case 1125: ch = vmime::charsets::CP_1125; break; case 1250: ch = vmime::charsets::CP_1250; break; case 1251: ch = vmime::charsets::CP_1251; break; case 1252: ch = vmime::charsets::CP_1252; break; case 1253: ch = vmime::charsets::CP_1253; break; case 1254: ch = vmime::charsets::CP_1254; break; case 1255: ch = vmime::charsets::CP_1255; break; case 1256: ch = vmime::charsets::CP_1256; break; case 1257: ch = vmime::charsets::CP_1257; break; case 28591: ch = vmime::charsets::ISO8859_1; break; case 28592: ch = vmime::charsets::ISO8859_2; break; case 28593: ch = vmime::charsets::ISO8859_3; break; case 28594: ch = vmime::charsets::ISO8859_4; break; case 28595: ch = vmime::charsets::ISO8859_5; break; case 28596: ch = vmime::charsets::ISO8859_6; break; case 28597: ch = vmime::charsets::ISO8859_7; break; case 28598: ch = vmime::charsets::ISO8859_8; break; case 28599: ch = vmime::charsets::ISO8859_9; break; case 28605: ch = vmime::charsets::ISO8859_15; break; case 65000: ch = vmime::charsets::UTF_7; break; case 65001: ch = vmime::charsets::UTF_8; break; } return (vmime::charset(ch)); #endif } const vmime::string windowsHandler::getHostName() const { std::vector hostnames; char buffer[256]; // Try with 'gethostname' ::gethostname(buffer, sizeof(buffer)); buffer[sizeof(buffer) - 1] = '\0'; if (::strlen(buffer) == 0) ::strcpy(buffer, "localhost"); hostnames.push_back(buffer); // And with 'gethostbyname' struct hostent* he = ::gethostbyname(buffer); if (he != NULL) { if (::strlen(he->h_name) != 0) hostnames.push_back(he->h_name); char** alias = he->h_aliases; while (alias && *alias) { if (::strlen(*alias) != 0) hostnames.push_back(*alias); ++alias; } } // Find a Fully-Qualified Domain Name (FQDN) for (unsigned int i = 0 ; i < hostnames.size() ; ++i) { if (hostnames[i].find_first_of(".") != vmime::string::npos) return (hostnames[i]); } return (hostnames[0]); } unsigned int windowsHandler::getProcessId() const { return (static_cast (::GetCurrentProcessId())); } #if VMIME_HAVE_MESSAGING_FEATURES ref windowsHandler::getSocketFactory() { return m_socketFactory; } #endif #if VMIME_HAVE_FILESYSTEM_FEATURES ref windowsHandler::getFileSystemFactory() { return m_fileSysFactory; } ref windowsHandler::getChildProcessFactory() { // TODO: Not implemented return (NULL); } #endif void windowsHandler::wait() const { ::Sleep(1000); } } // posix } // platforms } // vmime libvmime-0.9.1/src/disposition.cpp0000644000175000017500000001553711250723263017502 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/disposition.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/utility/stringUtils.hpp" namespace vmime { disposition::disposition() { } disposition::disposition(const string& actionMode, const string& sendingMode, const string& type, const string& modifier) : m_actionMode(actionMode), m_sendingMode(sendingMode), m_type(type) { m_modifiers.push_back(modifier); } ref disposition::clone() const { ref disp = vmime::create (); disp->m_actionMode = m_actionMode; disp->m_sendingMode = m_sendingMode; disp->m_type = m_type; disp->m_modifiers.resize(m_modifiers.size()); std::copy(m_modifiers.begin(), m_modifiers.end(), disp->m_modifiers.begin()); return (disp); } void disposition::copyFrom(const component& other) { const disposition& disp = dynamic_cast (other); m_actionMode = disp.m_actionMode; m_sendingMode = disp.m_sendingMode; m_type = disp.m_type; m_modifiers.resize(disp.m_modifiers.size()); std::copy(disp.m_modifiers.begin(), disp.m_modifiers.end(), m_modifiers.begin()); } disposition& disposition::operator=(const disposition& other) { copyFrom(other); return (*this); } const std::vector > disposition::getChildComponents() const { return std::vector >(); } void disposition::setActionMode(const string& mode) { m_actionMode = mode; } const string& disposition::getActionMode() const { return (m_actionMode); } void disposition::setSendingMode(const string& mode) { m_sendingMode = mode; } const string& disposition::getSendingMode() const { return (m_sendingMode); } void disposition::setType(const string& type) { m_type = type; } const string& disposition::getType() const { return (m_type); } void disposition::addModifier(const string& modifier) { if (!hasModifier(modifier)) m_modifiers.push_back(utility::stringUtils::toLower(modifier)); } void disposition::removeModifier(const string& modifier) { const string modifierLC = utility::stringUtils::toLower(modifier); for (std::vector ::iterator it = m_modifiers.begin() ; it != m_modifiers.end() ; ++it) { if (*it == modifierLC) { m_modifiers.erase(it); break; } } } void disposition::removeAllModifiers() { m_modifiers.clear(); } bool disposition::hasModifier(const string& modifier) const { const string modifierLC = utility::stringUtils::toLower(modifier); for (std::vector ::const_iterator it = m_modifiers.begin() ; it != m_modifiers.end() ; ++it) { if (*it == modifierLC) return (true); } return (false); } const std::vector disposition::getModifierList() const { return (m_modifiers); } void disposition::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { // disposition-mode ";" disposition-type // [ "/" disposition-modifier *( "," disposition-modifier ) ] // // disposition-mode = action-mode "/" sending-mode string::size_type pos = position; while (pos < end && parserHelpers::isSpace(buffer[pos])) ++pos; // -- disposition-mode const string::size_type modeStart = pos; string::size_type modeEnd = pos; while (pos < end && buffer[pos] != ';') { ++modeEnd; ++pos; } while (modeEnd > modeStart && parserHelpers::isSpace(buffer[modeEnd - 1])) --modeEnd; const string mode = string(buffer.begin() + modeStart, buffer.begin() + modeEnd); const string::size_type slash = mode.find('/'); if (slash != string::npos) { m_actionMode = string(mode.begin(), mode.begin() + slash); m_sendingMode = string(mode.begin() + slash + 1, mode.end()); } else { m_actionMode = mode; m_sendingMode.clear(); } if (pos < end) { // Skip ';' ++pos; } while (pos < end && parserHelpers::isSpace(buffer[pos])) ++pos; // -- disposition-type const string::size_type typeStart = pos; string::size_type typeEnd = pos; while (pos < end && buffer[pos] != '/') { ++typeEnd; ++pos; } while (typeEnd > typeStart && parserHelpers::isSpace(buffer[typeEnd - 1])) --typeEnd; m_type = string(buffer.begin() + typeStart, buffer.begin() + typeEnd); m_modifiers.clear(); if (pos < end) // modifiers follow { // Skip '/' ++pos; while (pos < end) { while (pos < end && parserHelpers::isSpace(buffer[pos])) ++pos; const string::size_type modifierStart = pos; string::size_type modifierEnd = pos; while (pos < end && buffer[pos] != ',') { ++modifierEnd; ++pos; } while (modifierEnd > modifierStart && parserHelpers::isSpace(buffer[modifierEnd - 1])) --modifierEnd; if (modifierEnd > modifierStart) { m_modifiers.push_back(string(buffer.begin() + modifierStart, buffer.begin() + modifierEnd)); } // Skip ',' if (pos < end) ++pos; } } if (newPosition) *newPosition = pos; } void disposition::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { string::size_type pos = curLinePos; const string actionMode = (m_actionMode.empty() ? "automatic-action" : m_actionMode); const string sendingMode = (m_sendingMode.empty() ? "MDN-sent-automatically" : m_sendingMode); os << actionMode << "/" << sendingMode << ";"; pos += actionMode.length() + 1 + sendingMode.length() + 1; if (pos > maxLineLength) { os << NEW_LINE_SEQUENCE; pos = NEW_LINE_SEQUENCE_LENGTH; } const string type = (m_type.empty() ? "displayed" : m_type); os << type; pos += type.length(); if (m_modifiers.size() >= 1) { os << "/" << m_modifiers[0]; pos += 1 + m_modifiers[0].length(); for (std::vector ::size_type i = 1 ; i < m_modifiers.size() ; ++i) { os << "," << m_modifiers[i]; pos += 1 + m_modifiers[i].length(); } } if (newLinePos) *newLinePos = pos; } } libvmime-0.9.1/src/exception.cpp0000644000175000017500000005637511250723263017141 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/exception.hpp" namespace vmime { // // exception // const exception exception::NO_EXCEPTION; exception::exception() : m_what(""), m_other(NULL) { } exception::exception(const string& what, const exception& other) : m_what(what), m_other(&other != &NO_EXCEPTION ? other.clone() : NULL) { } exception::exception(const exception& e) : std::exception(), m_what(e.what()), m_other(e.m_other == NULL ? NULL : e.m_other->clone()) { } exception::~exception() throw() { delete (m_other); } const char* exception::what() const throw() { return (m_what.c_str()); } const char* exception::what() throw() { return (m_what.c_str()); } const exception* exception::other() const throw() { return (m_other); } const char* exception::name() const throw() { return "exception"; } exception* exception::clone() const { return new exception(*this); } namespace exceptions { // // bad_field_type // bad_field_type::~bad_field_type() throw() {} bad_field_type::bad_field_type(const exception& other) : exception("Bad field type.", other) {} exception* bad_field_type::clone() const { return new bad_field_type(*this); } const char* bad_field_type::name() const throw() { return "bad_field_type"; } // // charset_conv_error // charset_conv_error::~charset_conv_error() throw() {} charset_conv_error::charset_conv_error(const string& what, const exception& other) : exception(what.empty() ? "Charset conversion error." : what, other) {} exception* charset_conv_error::clone() const { return new charset_conv_error(*this); } const char* charset_conv_error::name() const throw() { return "charset_conv_error"; } // // no_encoder_available // no_encoder_available::~no_encoder_available() throw() {} no_encoder_available::no_encoder_available(const string& name, const exception& other) : exception("No encoder available: '" + name + "'.", other) {} exception* no_encoder_available::clone() const { return new no_encoder_available(*this); } const char* no_encoder_available::name() const throw() { return "no_encoder_available"; } // // no_digest_algorithm_available // no_digest_algorithm_available::~no_digest_algorithm_available() throw() {} no_digest_algorithm_available::no_digest_algorithm_available(const string& name, const exception& other) : exception("No algorithm available: '" + name + "'.", other) {} exception* no_digest_algorithm_available::clone() const { return new no_digest_algorithm_available(*this); } const char* no_digest_algorithm_available::name() const throw() { return "no_digest_algorithm_available"; } // // no_such_parameter // no_such_parameter::~no_such_parameter() throw() {} no_such_parameter::no_such_parameter(const string& name, const exception& other) : exception(string("Parameter not found: '") + name + string("'."), other) {} exception* no_such_parameter::clone() const { return new no_such_parameter(*this); } const char* no_such_parameter::name() const throw() { return "no_such_parameter"; } // // no_such_field // no_such_field::~no_such_field() throw() {} no_such_field::no_such_field(const exception& other) : exception("Field not found.", other) {} exception* no_such_field::clone() const { return new no_such_field(*this); } const char* no_such_field::name() const throw() { return "no_such_field"; } // // no_such_part // no_such_part::~no_such_part() throw() {} no_such_part::no_such_part(const exception& other) : exception("Part not found.", other) {} exception* no_such_part::clone() const { return new no_such_part(*this); } const char* no_such_part::name() const throw() { return "no_such_part"; } // // no_such_mailbox // no_such_mailbox::~no_such_mailbox() throw() {} no_such_mailbox::no_such_mailbox(const exception& other) : exception("Mailbox not found.", other) {} exception* no_such_mailbox::clone() const { return new no_such_mailbox(*this); } const char* no_such_mailbox::name() const throw() { return "no_such_mailbox"; } // // no_such_message_id // no_such_message_id::~no_such_message_id() throw() {} no_such_message_id::no_such_message_id(const exception& other) : exception("Message-Id not found.", other) {} exception* no_such_message_id::clone() const { return new no_such_message_id(*this); } const char* no_such_message_id::name() const throw() { return "no_such_message_id"; } // // no_such_address // no_such_address::~no_such_address() throw() {} no_such_address::no_such_address(const exception& other) : exception("Address not found.", other) {} exception* no_such_address::clone() const { return new no_such_address(*this); } const char* no_such_address::name() const throw() { return "no_such_address"; } // // open_file_error // open_file_error::~open_file_error() throw() {} open_file_error::open_file_error(const exception& other) : exception("Error opening file.", other) {} exception* open_file_error::clone() const { return new open_file_error(*this); } const char* open_file_error::name() const throw() { return "open_file_error"; } // // no_factory_available // no_factory_available::~no_factory_available() throw() {} no_factory_available::no_factory_available(const exception& other) : exception("No factory available.", other) {} exception* no_factory_available::clone() const { return new no_factory_available(*this); } const char* no_factory_available::name() const throw() { return "no_factory_available"; } // // no_platform_handler // no_platform_handler::~no_platform_handler() throw() {} no_platform_handler::no_platform_handler(const exception& other) : exception("No platform handler installed.", other) {} exception* no_platform_handler::clone() const { return new no_platform_handler(*this); } const char* no_platform_handler::name() const throw() { return "no_platform_handler"; } // // no_expeditor // no_expeditor::~no_expeditor() throw() {} no_expeditor::no_expeditor(const exception& other) : exception("No expeditor specified.", other) {} exception* no_expeditor::clone() const { return new no_expeditor(*this); } const char* no_expeditor::name() const throw() { return "no_expeditor"; } // // no_recipient // no_recipient::~no_recipient() throw() {} no_recipient::no_recipient(const exception& other) : exception("No recipient specified.", other) {} exception* no_recipient::clone() const { return new no_recipient(*this); } const char* no_recipient::name() const throw() { return "no_recipient"; } // // no_object_found // no_object_found::~no_object_found() throw() {} no_object_found::no_object_found(const exception& other) : exception("No object found.", other) {} exception* no_object_found::clone() const { return new no_object_found(*this); } const char* no_object_found::name() const throw() { return "no_object_found"; } // // no_such_property // no_such_property::~no_such_property() throw() {} no_such_property::no_such_property(const string& name, const exception& other) : exception(std::string("No such property: '") + name + string("'."), other) { } exception* no_such_property::clone() const { return new no_such_property(*this); } const char* no_such_property::name() const throw() { return "no_such_property"; } // // invalid_property_type // invalid_property_type::~invalid_property_type() throw() {} invalid_property_type::invalid_property_type(const exception& other) : exception("Invalid property type.", other) {} exception* invalid_property_type::clone() const { return new invalid_property_type(*this); } const char* invalid_property_type::name() const throw() { return "invalid_property_type"; } // // invalid_argument // invalid_argument::~invalid_argument() throw() {} invalid_argument::invalid_argument(const exception& other) : exception("Invalid argument.", other) {} exception* invalid_argument::clone() const { return new invalid_argument(*this); } const char* invalid_argument::name() const throw() { return "invalid_argument"; } // // system_error // system_error::~system_error() throw() { } system_error::system_error(const string& what, const exception& other) : exception(what, other) {} exception* system_error::clone() const { return new system_error(*this); } const char* system_error::name() const throw() { return "system_error"; } #if VMIME_HAVE_MESSAGING_FEATURES // // net_exception // net_exception::~net_exception() throw() {} net_exception::net_exception(const string& what, const exception& other) : exception(what, other) {} exception* net_exception::clone() const { return new net_exception(*this); } const char* net_exception::name() const throw() { return "net_exception"; } // // socket_exception // socket_exception::~socket_exception() throw() {} socket_exception::socket_exception(const string& what, const exception& other) : net_exception(what.empty() ? "Socket error." : what, other) {} exception* socket_exception::clone() const { return new socket_exception(*this); } const char* socket_exception::name() const throw() { return "socket_exception"; } // // connection_error // connection_error::~connection_error() throw() {} connection_error::connection_error(const string& what, const exception& other) : socket_exception(what.empty() ? "Connection error." : what, other) {} exception* connection_error::clone() const { return new connection_error(*this); } const char* connection_error::name() const throw() { return "connection_error"; } // // connection_greeting_error // connection_greeting_error::~connection_greeting_error() throw() {} connection_greeting_error::connection_greeting_error(const string& response, const exception& other) : net_exception("Greeting error.", other), m_response(response) {} const string& connection_greeting_error::response() const { return (m_response); } exception* connection_greeting_error::clone() const { return new connection_greeting_error(*this); } const char* connection_greeting_error::name() const throw() { return "connection_greeting_error"; } // // authentication_error // authentication_error::~authentication_error() throw() {} authentication_error::authentication_error(const string& response, const exception& other) : net_exception("Authentication error.", other), m_response(response) {} const string& authentication_error::response() const { return (m_response); } exception* authentication_error::clone() const { return new authentication_error(*this); } const char* authentication_error::name() const throw() { return "authentication_error"; } // // unsupported_option // unsupported_option::~unsupported_option() throw() {} unsupported_option::unsupported_option(const exception& other) : net_exception("Unsupported option.", other) {} exception* unsupported_option::clone() const { return new unsupported_option(*this); } const char* unsupported_option::name() const throw() { return "unsupported_option"; } // // no_service_available // no_service_available::~no_service_available() throw() {} no_service_available::no_service_available(const string& proto, const exception& other) : net_exception(proto.empty() ? "No service available for this protocol." : "No service available for this protocol: '" + proto + "'.", other) {} exception* no_service_available::clone() const { return new no_service_available(*this); } const char* no_service_available::name() const throw() { return "no_service_available"; } // // illegal_state // illegal_state::~illegal_state() throw() {} illegal_state::illegal_state(const string& state, const exception& other) : net_exception("Illegal state to accomplish the operation: '" + state + "'.", other) {} exception* illegal_state::clone() const { return new illegal_state(*this); } const char* illegal_state::name() const throw() { return "illegal_state"; } // // folder_not_found // folder_not_found::~folder_not_found() throw() {} folder_not_found::folder_not_found(const exception& other) : net_exception("Folder not found.", other) {} exception* folder_not_found::clone() const { return new folder_not_found(*this); } const char* folder_not_found::name() const throw() { return "folder_not_found"; } // // message_not_found // message_not_found::~message_not_found() throw() {} message_not_found::message_not_found(const exception& other) : net_exception("Message not found.", other) {} exception* message_not_found::clone() const { return new message_not_found(*this); } const char* message_not_found::name() const throw() { return "message_not_found"; } // // operation_not_supported // operation_not_supported::~operation_not_supported() throw() {} operation_not_supported::operation_not_supported(const exception& other) : net_exception("Operation not supported.", other) {} exception* operation_not_supported::clone() const { return new operation_not_supported(*this); } const char* operation_not_supported::name() const throw() { return "operation_not_supported"; } // // operation_timed_out // operation_timed_out::~operation_timed_out() throw() {} operation_timed_out::operation_timed_out(const exception& other) : net_exception("Operation timed out.", other) {} exception* operation_timed_out::clone() const { return new operation_timed_out(*this); } const char* operation_timed_out::name() const throw() { return "operation_timed_out"; } // // operation_cancelled // operation_cancelled::~operation_cancelled() throw() {} operation_cancelled::operation_cancelled(const exception& other) : net_exception("Operation cancelled by the user.", other) {} exception* operation_cancelled::clone() const { return new operation_cancelled(*this); } const char* operation_cancelled::name() const throw() { return "operation_cancelled"; } // // unfetched_object // unfetched_object::~unfetched_object() throw() {} unfetched_object::unfetched_object(const exception& other) : net_exception("Object not fetched.", other) {} exception* unfetched_object::clone() const { return new unfetched_object(*this); } const char* unfetched_object::name() const throw() { return "unfetched_object"; } // // not_connected // not_connected::~not_connected() throw() {} not_connected::not_connected(const exception& other) : net_exception("Not connected to a service.", other) {} exception* not_connected::clone() const { return new not_connected(*this); } const char* not_connected::name() const throw() { return "not_connected"; } // // already_connected // already_connected::~already_connected() throw() {} already_connected::already_connected(const exception& other) : net_exception("Already connected to a service. Disconnect and retry.", other) {} exception* already_connected::clone() const { return new already_connected(*this); } const char* already_connected::name() const throw() { return "already_connected"; } // // illegal_operation // illegal_operation::~illegal_operation() throw() {} illegal_operation::illegal_operation(const string& msg, const exception& other) : net_exception(msg.empty() ? "Illegal operation." : "Illegal operation: " + msg + ".", other ) {} exception* illegal_operation::clone() const { return new illegal_operation(*this); } const char* illegal_operation::name() const throw() { return "illegal_operation"; } // // command_error // command_error::~command_error() throw() {} command_error::command_error(const string& command, const string& response, const string& desc, const exception& other) : net_exception(desc.empty() ? "Error while executing command '" + command + "'." : "Error while executing command '" + command + "': " + desc + ".", other ), m_command(command), m_response(response) {} const string& command_error::command() const { return (m_command); } const string& command_error::response() const { return (m_response); } exception* command_error::clone() const { return new command_error(*this); } const char* command_error::name() const throw() { return "command_error"; } // // invalid_response // invalid_response::~invalid_response() throw() {} invalid_response::invalid_response(const string& command, const string& response, const exception& other) : net_exception(command.empty() ? "Received invalid response." : "Received invalid response for command '" + command + "'.", other ), m_command(command), m_response(response) {} const string& invalid_response::command() const { return (m_command); } const string& invalid_response::response() const { return (m_response); } exception* invalid_response::clone() const { return new invalid_response(*this); } const char* invalid_response::name() const throw() { return "invalid_response"; } // // partial_fetch_not_supported // partial_fetch_not_supported::~partial_fetch_not_supported() throw() {} partial_fetch_not_supported::partial_fetch_not_supported(const exception& other) : net_exception("Partial fetch not supported.", other) {} exception* partial_fetch_not_supported::clone() const { return new partial_fetch_not_supported(*this); } const char* partial_fetch_not_supported::name() const throw() { return "partial_fetch_not_supported"; } // // malformed_url // malformed_url::~malformed_url() throw() {} malformed_url::malformed_url(const string& error, const exception& other) : net_exception("Malformed URL: " + error + ".", other) {} exception* malformed_url::clone() const { return new malformed_url(*this); } const char* malformed_url::name() const throw() { return "malformed_url"; } // // invalid_folder_name // invalid_folder_name::~invalid_folder_name() throw() {} invalid_folder_name::invalid_folder_name(const string& error, const exception& other) : net_exception(error.empty() ? "Invalid folder name: " + error + "." : "Invalid folder name.", other) {} exception* invalid_folder_name::clone() const { return new invalid_folder_name(*this); } const char* invalid_folder_name::name() const throw() { return "invalid_folder_name"; } #endif // VMIME_HAVE_MESSAGING_FEATURES #if VMIME_HAVE_FILESYSTEM_FEATURES // // filesystem_exception // filesystem_exception::~filesystem_exception() throw() {} filesystem_exception::filesystem_exception(const string& what, const utility::path& path, const exception& other) : exception(what, other), m_path(path) {} const utility::path& filesystem_exception::path() const { return (m_path); } exception* filesystem_exception::clone() const { return new filesystem_exception(*this); } const char* filesystem_exception::name() const throw() { return "filesystem_exception"; } // // not_a_directory // not_a_directory::~not_a_directory() throw() {} not_a_directory::not_a_directory(const utility::path& path, const exception& other) : filesystem_exception("Operation failed: this is not a directory.", path, other) {} exception* not_a_directory::clone() const { return new not_a_directory(*this); } const char* not_a_directory::name() const throw() { return "not_a_directory"; } // // file_not_found // file_not_found::~file_not_found() throw() {} file_not_found::file_not_found(const utility::path& path, const exception& other) : filesystem_exception("File not found.", path, other) {} exception* file_not_found::clone() const { return new file_not_found(*this); } const char* file_not_found::name() const throw() { return "file_not_found"; } #endif // VMIME_HAVE_FILESYSTEM_FEATURES // // authentication_exception // authentication_exception::~authentication_exception() throw() {} authentication_exception::authentication_exception(const string& what, const exception& other) : exception(what, other) {} exception* authentication_exception::clone() const { return new authentication_exception(*this); } const char* authentication_exception::name() const throw() { return "authentication_exception"; } // // no_auth_information // no_auth_information::~no_auth_information() throw() {} no_auth_information::no_auth_information(const exception& other) : authentication_exception("Information cannot be provided.", other) {} exception* no_auth_information::clone() const { return new no_auth_information(*this); } const char* no_auth_information::name() const throw() { return "no_auth_information"; } #if VMIME_HAVE_SASL_SUPPORT // // sasl_exception // sasl_exception::~sasl_exception() throw() {} sasl_exception::sasl_exception(const string& what, const exception& other) : authentication_exception(what, other) {} exception* sasl_exception::clone() const { return new sasl_exception(*this); } const char* sasl_exception::name() const throw() { return "sasl_exception"; } // // no_such_mechanism // no_such_mechanism::~no_such_mechanism() throw() {} no_such_mechanism::no_such_mechanism(const string& name, const exception& other) : sasl_exception("No such SASL mechanism: '" + name + "'.", other) {} exception* no_such_mechanism::clone() const { return new no_such_mechanism(*this); } const char* no_such_mechanism::name() const throw() { return "no_such_mechanism"; } #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT // // tls_exception // tls_exception::~tls_exception() throw() {} tls_exception::tls_exception(const string& what, const exception& other) : exception(what, other) {} exception* tls_exception::clone() const { return new tls_exception(*this); } const char* tls_exception::name() const throw() { return "tls_exception"; } // // certificate_exception // certificate_exception::~certificate_exception() throw() {} certificate_exception::certificate_exception(const string& what, const exception& other) : tls_exception(what, other) {} exception* certificate_exception::clone() const { return new certificate_exception(*this); } const char* certificate_exception::name() const throw() { return "certificate_exception"; } // // certificate_verification_exception // certificate_verification_exception::~certificate_verification_exception() throw() {} certificate_verification_exception::certificate_verification_exception(const string& what, const exception& other) : certificate_exception(what, other) {} exception* certificate_verification_exception::clone() const { return new certificate_verification_exception(*this); } const char* certificate_verification_exception::name() const throw() { return "certificate_verification_exception"; } // // unsupported_certificate_type // unsupported_certificate_type::~unsupported_certificate_type() throw() {} unsupported_certificate_type::unsupported_certificate_type(const string& type, const exception& other) : certificate_exception("Unsupported certificate type: '" + type + "'", other) {} exception* unsupported_certificate_type::clone() const { return new unsupported_certificate_type(*this); } const char* unsupported_certificate_type::name() const throw() { return "unsupported_certificate_type"; } #endif // VMIME_HAVE_TLS_SUPPORT } // exceptions } // vmime libvmime-0.9.1/src/charset.cpp0000644000175000017500000001062211376177267016575 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/charset.hpp" #include "vmime/exception.hpp" #include "vmime/platform.hpp" #include "vmime/encoding.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/charsetConverter.hpp" namespace vmime { charset::charset() : m_name(charsets::US_ASCII) { } charset::charset(const string& name) : m_name(name) { } charset::charset(const char* name) : m_name(name) { } void charset::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { m_name = utility::stringUtils::trim (string(buffer.begin() + position, buffer.begin() + end)); setParsedBounds(position, end); if (newPosition) *newPosition = end; } void charset::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, const string::size_type curLinePos, string::size_type* newLinePos) const { os << m_name; if (newLinePos) *newLinePos = curLinePos + m_name.length(); } void charset::convert(utility::inputStream& in, utility::outputStream& out, const charset& source, const charset& dest) { charsetConverter conv(source, dest); conv.convert(in, out); } void charset::convert(const string& in, string& out, const charset& source, const charset& dest) { charsetConverter conv(source, dest); conv.convert(in, out); } const charset charset::getLocaleCharset() { return (platform::getHandler()->getLocaleCharset()); } charset& charset::operator=(const charset& other) { copyFrom(other); return (*this); } bool charset::operator==(const charset& value) const { return (utility::stringUtils::isStringEqualNoCase(m_name, value.m_name)); } bool charset::operator!=(const charset& value) const { return !(*this == value); } ref charset::clone() const { return vmime::create (m_name); } const string& charset::getName() const { return (m_name); } void charset::copyFrom(const component& other) { m_name = dynamic_cast (other).m_name; } const std::vector > charset::getChildComponents() const { return std::vector >(); } // Explicitly force encoding for some charsets struct CharsetEncodingEntry { CharsetEncodingEntry(const string& charset_, const string& encoding_) : charset(charset_), encoding(encoding_) { } const string charset; const string encoding; }; CharsetEncodingEntry g_charsetEncodingMap[] = { // Use QP encoding for ISO-8859-x charsets CharsetEncodingEntry("iso-8859", encodingTypes::QUOTED_PRINTABLE), CharsetEncodingEntry("iso8859", encodingTypes::QUOTED_PRINTABLE), // RFC-1468 states: // " ISO-2022-JP may also be used in MIME Part 2 headers. The "B" // encoding should be used with ISO-2022-JP text. " // Use Base64 encoding for all ISO-2022 charsets. CharsetEncodingEntry("iso-2022", encodingTypes::BASE64), CharsetEncodingEntry("iso2022", encodingTypes::BASE64), // Last entry is not used CharsetEncodingEntry("", "") }; bool charset::getRecommendedEncoding(encoding& enc) const { // Special treatment for some charsets const string cset = utility::stringUtils::toLower(getName()); for (unsigned int i = 0 ; i < (sizeof(g_charsetEncodingMap) / sizeof(g_charsetEncodingMap[0])) - 1 ; ++i) { if (cset.find(g_charsetEncodingMap[i].charset) != string::npos) { enc = g_charsetEncodingMap[i].encoding; return true; } } return false; } } // vmime libvmime-0.9.1/src/defaultAttachment.cpp0000644000175000017500000000714011250723263020562 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/defaultAttachment.hpp" #include "vmime/contentDisposition.hpp" #include "vmime/contentDispositionField.hpp" #include "vmime/encoding.hpp" namespace vmime { defaultAttachment::defaultAttachment() { } defaultAttachment::defaultAttachment(ref data, const encoding& enc, const mediaType& type, const text& desc, const word& name) : m_type(type), m_desc(desc), m_data(data), m_encoding(enc), m_name(name) { } defaultAttachment::defaultAttachment(ref data, const mediaType& type, const text& desc, const word& name) : m_type(type), m_desc(desc), m_data(data), m_encoding(encoding::decide(data)), m_name(name) { } defaultAttachment::defaultAttachment(const defaultAttachment& attach) : attachment(), m_type(attach.m_type), m_desc(attach.m_desc), m_data(attach.m_data->clone().dynamicCast ()), m_encoding(attach.m_encoding), m_name(attach.m_name) { } defaultAttachment::~defaultAttachment() { } defaultAttachment& defaultAttachment::operator=(const defaultAttachment& attach) { m_type = attach.m_type; m_desc = attach.m_desc; m_name = attach.m_name; m_data = attach.m_data->clone().dynamicCast (); m_encoding = attach.m_encoding; return (*this); } void defaultAttachment::generateIn(ref parent) const { // Create and append a new part for this attachment ref part = vmime::create (); parent->getBody()->appendPart(part); generatePart(part); } void defaultAttachment::generatePart(ref part) const { // Set header fields part->getHeader()->ContentType()->setValue(m_type); if (!m_desc.isEmpty()) part->getHeader()->ContentDescription()->setValue(m_desc); part->getHeader()->ContentTransferEncoding()->setValue(m_encoding); part->getHeader()->ContentDisposition()->setValue(contentDisposition(contentDispositionTypes::ATTACHMENT)); part->getHeader()->ContentDisposition().dynamicCast ()->setFilename(m_name); // Set contents part->getBody()->setContents(m_data); } const mediaType defaultAttachment::getType() const { return m_type; } const text defaultAttachment::getDescription() const { return m_desc; } const word defaultAttachment::getName() const { return m_name; } const ref defaultAttachment::getData() const { return m_data; } const encoding defaultAttachment::getEncoding() const { return m_encoding; } ref defaultAttachment::getPart() const { return NULL; } ref defaultAttachment::getHeader() const { return NULL; } } // vmime libvmime-0.9.1/src/messageId.cpp0000644000175000017500000001364111250723263017031 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/messageId.hpp" #include "vmime/utility/random.hpp" #include "vmime/platform.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { messageId::messageId() { } messageId::messageId(const string& id) { parse(id); } messageId::messageId(const messageId& mid) : headerFieldValue(), m_left(mid.m_left), m_right(mid.m_right) { } messageId::messageId(const string& left, const string& right) : m_left(left), m_right(right) { } /* RFC-2822: 3.6.4. Identification fields msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] */ void messageId::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { const string::value_type* const pend = buffer.data() + end; const string::value_type* const pstart = buffer.data() + position; const string::value_type* p = pstart; m_left.clear(); m_right.clear(); unsigned int commentLevel = 0; bool escape = false; bool stop = false; for ( ; !stop && p < pend ; ++p) { if (escape) { // Ignore this character } else { switch (*p) { case '(': ++commentLevel; break; case ')': --commentLevel; break; case '\\': escape = true; break; case '<': { if (commentLevel == 0) { stop = true; break; } } } } } // Fix for message ids without angle brackets (invalid) bool hasBrackets = true; if (p == pend) // no opening angle bracket found { hasBrackets = false; p = pstart; while (p < pend && parserHelpers::isSpace(*p)) ++p; } if (p < pend) { // Extract left part const string::size_type leftStart = position + (p - pstart); while (p < pend && *p != '@' && *p != '>') ++p; m_left = string(buffer.begin() + leftStart, buffer.begin() + position + (p - pstart)); if (p < pend) { // Skip '@' ++p; // Extract right part const string::size_type rightStart = position + (p - pstart); while (p < pend && *p != '>' && (hasBrackets || !parserHelpers::isSpace(*p))) ++p; m_right = string(buffer.begin() + rightStart, buffer.begin() + position + (p - pstart)); } } setParsedBounds(position, end); if (newPosition) *newPosition = end; } ref messageId::parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { string::size_type pos = position; while (pos < end && parserHelpers::isSpace(buffer[pos])) ++pos; if (pos != end) { const string::size_type begin = pos; while (pos < end && !parserHelpers::isSpace(buffer[pos])) ++pos; ref mid = vmime::create (); mid->parse(buffer, begin, pos, NULL); if (newPosition != NULL) *newPosition = pos; return (mid); } if (newPosition != NULL) *newPosition = end; return (NULL); } const string messageId::getId() const { if (m_right.empty()) return m_left; return (m_left + '@' + m_right); } void messageId::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { string::size_type pos = curLinePos; if (curLinePos + m_left.length() + m_right.length() + 3 > maxLineLength) { os << NEW_LINE_SEQUENCE; pos = NEW_LINE_SEQUENCE_LENGTH; } os << '<' << m_left; if (m_right != "") os << '@' << m_right; os << '>'; if (newLinePos) *newLinePos = pos + m_left.length() + m_right.length() + 3; } messageId& messageId::operator=(const string& id) { parse(id); return (*this); } messageId messageId::generateId() { std::ostringstream left; left.imbue(std::locale::classic()); left << "vmime"; left << '.'; left << std::hex << utility::random::getTime(); left << '.'; left << std::hex << utility::random::getProcess(); left << '.'; left << std::hex << utility::random::getNext(); left << std::hex << utility::random::getNext(); return (messageId(left.str(), platform::getHandler()->getHostName())); } bool messageId::operator==(const messageId& mid) const { return (m_left == mid.m_left && m_right == mid.m_right); } bool messageId::operator!=(const messageId& mid) const { return !(*this == mid); } ref messageId::clone() const { return vmime::create (*this); } void messageId::copyFrom(const component& other) { const messageId& mid = dynamic_cast (other); m_left = mid.m_left; m_right = mid.m_right; } messageId& messageId::operator=(const messageId& other) { copyFrom(other); return (*this); } const string& messageId::getLeft() const { return (m_left); } void messageId::setLeft(const string& left) { m_left = left; } const string& messageId::getRight() const { return (m_right); } void messageId::setRight(const string& right) { m_right = right; } const std::vector > messageId::getChildComponents() const { return std::vector >(); } } // vmime libvmime-0.9.1/src/mailboxList.cpp0000644000175000017500000001120711250723263017413 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mailboxList.hpp" #include "vmime/exception.hpp" namespace vmime { mailboxList::mailboxList() { } mailboxList::mailboxList(const mailboxList& mboxList) : headerFieldValue(), m_list(mboxList.m_list) { } void mailboxList::appendMailbox(ref mbox) { m_list.appendAddress(mbox); } void mailboxList::insertMailboxBefore(ref beforeMailbox, ref mbox) { try { m_list.insertAddressBefore(beforeMailbox, mbox); } catch (exceptions::no_such_address&) { throw exceptions::no_such_mailbox(); } } void mailboxList::insertMailboxBefore(const int pos, ref mbox) { m_list.insertAddressBefore(pos, mbox); } void mailboxList::insertMailboxAfter(ref afterMailbox, ref mbox) { try { m_list.insertAddressAfter(afterMailbox, mbox); } catch (exceptions::no_such_address&) { throw exceptions::no_such_mailbox(); } } void mailboxList::insertMailboxAfter(const int pos, ref mbox) { m_list.insertAddressAfter(pos, mbox); } void mailboxList::removeMailbox(ref mbox) { try { m_list.removeAddress(mbox); } catch (exceptions::no_such_address&) { throw exceptions::no_such_mailbox(); } } void mailboxList::removeMailbox(const int pos) { m_list.removeAddress(pos); } void mailboxList::removeAllMailboxes() { m_list.removeAllAddresses(); } int mailboxList::getMailboxCount() const { return (m_list.getAddressCount()); } bool mailboxList::isEmpty() const { return (m_list.isEmpty()); } ref mailboxList::getMailboxAt(const int pos) { return m_list.getAddressAt(pos).staticCast (); } const ref mailboxList::getMailboxAt(const int pos) const { return m_list.getAddressAt(pos).staticCast (); } const std::vector > mailboxList::getMailboxList() const { const std::vector > addrList = m_list.getAddressList(); std::vector > res; for (std::vector >::const_iterator it = addrList.begin() ; it != addrList.end() ; ++it) { const ref mbox = (*it).dynamicCast (); if (mbox != NULL) res.push_back(mbox); } return (res); } const std::vector > mailboxList::getMailboxList() { const std::vector > addrList = m_list.getAddressList(); std::vector > res; for (std::vector >::const_iterator it = addrList.begin() ; it != addrList.end() ; ++it) { const ref mbox = (*it).dynamicCast (); if (mbox != NULL) res.push_back(mbox); } return (res); } ref mailboxList::clone() const { return vmime::create (*this); } void mailboxList::copyFrom(const component& other) { const mailboxList& mboxList = dynamic_cast (other); m_list = mboxList.m_list; } mailboxList& mailboxList::operator=(const mailboxList& other) { copyFrom(other); return (*this); } const std::vector > mailboxList::getChildComponents() const { return (m_list.getChildComponents()); } void mailboxList::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { m_list.parse(buffer, position, end, newPosition); } void mailboxList::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { m_list.generate(os, maxLineLength, curLinePos, newLinePos); } ref mailboxList::toAddressList() const { return m_list.clone().dynamicCast (); } } // vmime libvmime-0.9.1/src/textPartFactory.cpp0000644000175000017500000000352711250723263020275 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/textPartFactory.hpp" #include "vmime/exception.hpp" #include "vmime/plainTextPart.hpp" #include "vmime/htmlTextPart.hpp" namespace vmime { textPartFactory::textPartFactory() { // Register some default names registerType (mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN)); registerType (mediaType(mediaTypes::TEXT, mediaTypes::TEXT_HTML)); } textPartFactory::~textPartFactory() { } textPartFactory* textPartFactory::getInstance() { static textPartFactory instance; return (&instance); } ref textPartFactory::create(const mediaType& type) { for (MapType::const_iterator it = m_map.begin() ; it != m_map.end() ; ++it) { if ((*it).first == type) return ((*it).second)(); } throw exceptions::no_factory_available(); } } // vmime libvmime-0.9.1/src/parameter.cpp0000644000175000017500000003017211441366024017106 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/parameter.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/text.hpp" #include "vmime/encoding.hpp" namespace vmime { parameter::parameter(const string& name) : m_name(name) { } parameter::parameter(const string& name, const word& value) : m_name(name), m_value(value) { } parameter::parameter(const string& name, const string& value) : m_name(name), m_value(value) { } parameter::parameter(const parameter&) : component() { } ref parameter::clone() const { ref p = vmime::create (m_name); p->copyFrom(*this); return (p); } void parameter::copyFrom(const component& other) { const parameter& param = dynamic_cast (other); m_name = param.m_name; m_value.copyFrom(param.m_value); } parameter& parameter::operator=(const parameter& other) { copyFrom(other); return (*this); } const string& parameter::getName() const { return m_name; } const word& parameter::getValue() const { return m_value; } void parameter::setValue(const component& value) { std::ostringstream oss; utility::outputStreamAdapter vos(oss); value.generate(vos); setValue(word(oss.str(), vmime::charsets::US_ASCII)); } void parameter::setValue(const word& value) { m_value = value; } void parameter::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { m_value.setBuffer(string(buffer.begin() + position, buffer.begin() + end)); m_value.setCharset(charset(charsets::US_ASCII)); if (newPosition) *newPosition = end; } void parameter::parse(const std::vector & chunks) { bool foundCharsetChunk = false; charset ch(charsets::US_ASCII); std::ostringstream value; value.imbue(std::locale::classic()); for (std::vector ::size_type i = 0 ; i < chunks.size() ; ++i) { const valueChunk& chunk = chunks[i]; // Decode following data if (chunk.encoded) { const string::size_type len = chunk.data.length(); string::size_type pos = 0; // If this is the first encoded chunk, extract charset // and language information if (!foundCharsetChunk) { // Eg. "us-ascii'en'This%20is%20even%20more%20" string::size_type q = chunk.data.find_first_of('\''); if (q != string::npos) { const string chs = chunk.data.substr(0, q); if (!chs.empty()) ch = charset(chs); ++q; pos = q; } q = chunk.data.find_first_of('\'', pos); if (q != string::npos) { // Ignore language ++q; pos = q; } foundCharsetChunk = true; } for (string::size_type i = pos ; i < len ; ++i) { const string::value_type c = chunk.data[i]; if (c == '%' && i + 2 < len) { unsigned int v = 0; // First char switch (chunk.data[i + 1]) { case 'a': case 'A': v += 10; break; case 'b': case 'B': v += 11; break; case 'c': case 'C': v += 12; break; case 'd': case 'D': v += 13; break; case 'e': case 'E': v += 14; break; case 'f': case 'F': v += 15; break; default: // assume 0-9 v += (chunk.data[i + 1] - '0'); break; } v *= 16; // Second char switch (chunk.data[i + 2]) { case 'a': case 'A': v += 10; break; case 'b': case 'B': v += 11; break; case 'c': case 'C': v += 12; break; case 'd': case 'D': v += 13; break; case 'e': case 'E': v += 14; break; case 'f': case 'F': v += 15; break; default: // assume 0-9 v += (chunk.data[i + 2] - '0'); break; } value << static_cast (v); i += 2; // skip next 2 chars } else { value << c; } } } // Simply copy data, as it is not encoded else { // This syntax is non-standard (expressly prohibited // by RFC-2047), but is used by Mozilla: // // Content-Type: image/png; // name="=?us-ascii?Q?Logo_VMime=2Epng?=" // Using 'vmime::text' to parse the data is safe even // if the data is not encoded, because it can recover // from parsing errors. vmime::text t; t.parse(chunk.data); if (t.getWordCount() != 0) { value << t.getWholeBuffer(); if (!foundCharsetChunk) ch = t.getWordAt(0)->getCharset(); } } } m_value.setBuffer(value.str()); m_value.setCharset(ch); } void parameter::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { const string& name = m_name; const string& value = m_value.getBuffer(); // For compatibility with implementations that do not understand RFC-2231, // also generate a normal "7bit/us-ascii" parameter // [By Eugene A. Shatokhin] // Note that if both the normal "7bit/us-ascii" value and the extended // value are present, the latter can be ignored by mail processing systems. // This may lead to annoying problems, for example, with strange names of // attachments with all but 7-bit ascii characters removed, etc. To avoid // this, I would suggest not to create "7bit/us-ascii" value if the extended // value is to be generated. // A stream for a temporary storage std::ostringstream sevenBitBuffer; string::size_type pos = curLinePos; if (pos + name.length() + 10 + value.length() > maxLineLength) { sevenBitBuffer << NEW_LINE_SEQUENCE; pos = NEW_LINE_SEQUENCE_LENGTH; } bool needQuoting = false; string::size_type valueLength = 0; for (string::size_type i = 0 ; (i < value.length()) && (pos + valueLength < maxLineLength - 4) ; ++i, ++valueLength) { switch (value[i]) { // Characters that need to be quoted _and_ escaped case '"': case '\\': // Other characters that need quoting case ' ': case '\t': case '(': case ')': case '<': case '>': case '@': case ',': case ';': case ':': case '/': case '[': case ']': case '?': case '=': needQuoting = true; break; } } const bool cutValue = (valueLength != value.length()); // has the value been cut? if (needQuoting) { sevenBitBuffer << name << "=\""; pos += name.length() + 2; } else { sevenBitBuffer << name << "="; pos += name.length() + 1; } // Check whether there is a recommended encoding for this charset. // If so, the whole buffer will be encoded. Else, the number of // 7-bit (ASCII) bytes in the input will be used to determine if // we need to encode the whole buffer. encoding recommendedEnc; const bool alwaysEncode = m_value.getCharset().getRecommendedEncoding(recommendedEnc); bool extended = alwaysEncode; for (string::size_type i = 0 ; (i < value.length()) && (pos < maxLineLength - 4) ; ++i) { const char_t c = value[i]; if (/* needQuoting && */ (c == '"' || c == '\\')) // 'needQuoting' is implicit { sevenBitBuffer << '\\' << value[i]; // escape 'x' with '\x' pos += 2; } else if (parserHelpers::isAscii(c)) { sevenBitBuffer << value[i]; ++pos; } else { extended = true; } } if (needQuoting) { sevenBitBuffer << '"'; ++pos; } #if VMIME_ALWAYS_GENERATE_7BIT_PARAMETER os << sevenBitBuffer; #endif // !VMIME_ALWAYS_GENERATE_7BIT_PARAMETER // Also generate an extended parameter if the value contains 8-bit characters // or is too long for a single line if (extended || cutValue) { #if VMIME_ALWAYS_GENERATE_7BIT_PARAMETER os << ';'; ++pos; #else // !VMIME_ALWAYS_GENERATE_7BIT_PARAMETER // The data output to 'sevenBitBuffer' will be discarded in this case pos = curLinePos; #endif // VMIME_ALWAYS_GENERATE_7BIT_PARAMETER /* RFC-2231 * ======== * * Content-Type: message/external-body; access-type=URL; * URL*0="ftp://"; * URL*1="cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" * * Content-Type: application/x-stuff; * title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A * * Content-Type: application/x-stuff; * title*0*=us-ascii'en'This%20is%20even%20more%20 * title*1*=%2A%2A%2Afun%2A%2A%2A%20 * title*2="isn't it!" */ // Check whether there is enough space for the first section: // parameter name, section identifier, charset and separators // + at least 5 characters for the value const string::size_type firstSectionLength = name.length() + 4 /* *0*= */ + 2 /* '' */ + m_value.getCharset().getName().length(); if (pos + firstSectionLength + 5 >= maxLineLength) { os << NEW_LINE_SEQUENCE; pos = NEW_LINE_SEQUENCE_LENGTH; } // Split text into multiple sections that fit on one line int sectionCount = 0; std::vector sectionText; string currentSection; string::size_type currentSectionLength = firstSectionLength; for (string::size_type i = 0 ; i < value.length() ; ++i) { // Check whether we should start a new line (taking into // account the next character will be encoded = worst case) if (currentSectionLength + 3 >= maxLineLength) { sectionText.push_back(currentSection); sectionCount++; currentSection.clear(); currentSectionLength = NEW_LINE_SEQUENCE_LENGTH + name.length() + 6; } // Output next character const char_t c = value[i]; bool encode = false; switch (c) { // special characters case ' ': case '\t': case '\r': case '\n': case '%': case '"': case ';': case ',': case '(': case ')': case '<': case '>': case '@': case ':': case '/': case '[': case ']': case '?': case '=': encode = true; break; default: encode = (!parserHelpers::isPrint(c) || !parserHelpers::isAscii(c) || alwaysEncode); break; } if (encode) // need encoding { const int h1 = static_cast (c) / 16; const int h2 = static_cast (c) % 16; currentSection += '%'; currentSection += "0123456789ABCDEF"[h1]; currentSection += "0123456789ABCDEF"[h2]; pos += 3; currentSectionLength += 3; } else { currentSection += value[i]; ++pos; ++currentSectionLength; } } if (!currentSection.empty()) { sectionText.push_back(currentSection); sectionCount++; } // Output sections for (int sectionNumber = 0 ; sectionNumber < sectionCount ; ++sectionNumber) { os << name; if (sectionCount != 1) // no section specifier when only a single one { os << '*'; os << sectionNumber; } os << "*="; if (sectionNumber == 0) { os << m_value.getCharset().getName(); os << '\'' << /* No language */ '\''; } os << sectionText[sectionNumber]; if (sectionNumber + 1 < sectionCount) { os << ';'; os << NEW_LINE_SEQUENCE; pos = NEW_LINE_SEQUENCE_LENGTH; } } } #if !VMIME_ALWAYS_GENERATE_7BIT_PARAMETER else { // The value does not contain 8-bit characters and // is short enough for a single line. // "7bit/us-ascii" will suffice in this case. // Output what has been stored in temporary buffer so far os << sevenBitBuffer.str(); } #endif // !VMIME_ALWAYS_GENERATE_7BIT_PARAMETER if (newLinePos) *newLinePos = pos; } const std::vector > parameter::getChildComponents() const { std::vector > list; list.push_back(ref ::fromPtr(&m_value)); return list; } } // vmime libvmime-0.9.1/src/bodyPartAttachment.cpp0000644000175000017500000000667611250723263020737 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/bodyPartAttachment.hpp" namespace vmime { bodyPartAttachment::bodyPartAttachment(ref part) : m_part(part) { } const mediaType bodyPartAttachment::getType() const { mediaType type; try { type = *getContentType()->getValue().dynamicCast (); } catch (exceptions::no_such_field&) { // No "Content-type" field: assume "application/octet-stream". type = mediaType(mediaTypes::APPLICATION, mediaTypes::APPLICATION_OCTET_STREAM); } return type; } const word bodyPartAttachment::getName() const { word name; // Try the 'filename' parameter of 'Content-Disposition' field try { name = getContentDisposition()->getFilename(); } catch (exceptions::no_such_field&) { // No 'Content-Disposition' field } catch (exceptions::no_such_parameter&) { // No 'filename' parameter } // Try the 'name' parameter of 'Content-Type' field if (name.getBuffer().empty()) { try { ref prm = getContentType()->findParameter("name"); if (prm != NULL) name = prm->getValue(); } catch (exceptions::no_such_field&) { // No 'Content-Type' field } catch (exceptions::no_such_parameter&) { // No attachment name available } } return name; } const text bodyPartAttachment::getDescription() const { text description; try { ref cd = getHeader()->findField(fields::CONTENT_DESCRIPTION); description = *cd->getValue().dynamicCast (); } catch (exceptions::no_such_field&) { // No description available. } return description; } const encoding bodyPartAttachment::getEncoding() const { return m_part->getBody()->getEncoding(); } const ref bodyPartAttachment::getData() const { return m_part->getBody()->getContents(); } ref bodyPartAttachment::getPart() const { return m_part; } ref bodyPartAttachment::getHeader() const { return m_part->getHeader(); } ref bodyPartAttachment::getContentDisposition() const { return getHeader()->findField(fields::CONTENT_DISPOSITION). dynamicCast (); } ref bodyPartAttachment::getContentType() const { return getHeader()->findField(fields::CONTENT_TYPE). dynamicCast (); } void bodyPartAttachment::generateIn(ref /* parent */) const { // Not used } } // vmime libvmime-0.9.1/src/encoding.cpp0000644000175000017500000001231111376252030016705 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/encoding.hpp" #include "vmime/contentHandler.hpp" #include "vmime/utility/encoder/encoderFactory.hpp" #include namespace vmime { encoding::encoding() : m_name(encodingTypes::SEVEN_BIT) { } encoding::encoding(const string& name) : m_name(utility::stringUtils::toLower(name)) { } encoding::encoding(const encoding& enc) : headerFieldValue(), m_name(enc.m_name) { } void encoding::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { m_name = utility::stringUtils::toLower(utility::stringUtils::trim (utility::stringUtils::unquote(utility::stringUtils::trim (string(buffer.begin() + position, buffer.begin() + end))))); if (m_name.empty()) m_name = encodingTypes::SEVEN_BIT; // assume default "7-bit" setParsedBounds(position, end); if (newPosition) *newPosition = end; } void encoding::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, const string::size_type curLinePos, string::size_type* newLinePos) const { os << m_name; if (newLinePos) *newLinePos = curLinePos + m_name.length(); } ref encoding::getEncoder() const { return (utility::encoder::encoderFactory::getInstance()->create(generate())); } encoding& encoding::operator=(const encoding& other) { copyFrom(other); return (*this); } encoding& encoding::operator=(const string& name) { m_name = utility::stringUtils::toLower(name); return (*this); } bool encoding::operator==(const encoding& value) const { return (utility::stringUtils::toLower(m_name) == value.m_name); } bool encoding::operator!=(const encoding& value) const { return !(*this == value); } const encoding encoding::decideImpl (const string::const_iterator begin, const string::const_iterator end) { const string::difference_type length = end - begin; const string::difference_type count = std::count_if (begin, end, std::bind2nd(std::less(), 127)); // All is in 7-bit US-ASCII --> 7-bit (or Quoted-Printable...) if (length == count) { // Now, we check if there is any line with more than // "lineLengthLimits::convenient" characters (7-bit requires that) string::const_iterator p = begin; const string::size_type maxLen = lineLengthLimits::convenient; string::size_type len = 0; for ( ; p != end && len <= maxLen ; ) { if (*p == '\n') { len = 0; ++p; // May or may not need to be encoded, we don't take // any risk (avoid problems with SMTP) if (p != end && *p == '.') len = maxLen + 1; } else { ++len; ++p; } } if (len > maxLen) return (encoding(encodingTypes::QUOTED_PRINTABLE)); else return (encoding(encodingTypes::SEVEN_BIT)); } // Less than 20% non US-ASCII --> Quoted-Printable else if ((length - count) <= length / 5) { return (encoding(encodingTypes::QUOTED_PRINTABLE)); } // Otherwise --> Base64 else { return (encoding(encodingTypes::BASE64)); } } const encoding encoding::decide (ref data, const EncodingUsage usage) { if (usage == USAGE_TEXT && data->isBuffered() && data->getLength() > 0 && data->getLength() < 32768) { // Extract data into temporary buffer string buffer; utility::outputStreamStringAdapter os(buffer); data->extract(os); os.flush(); return decideImpl(buffer.begin(), buffer.end()); } else { return encoding(encodingTypes::BASE64); } } const encoding encoding::decide(ref data, const charset& chset, const EncodingUsage usage) { if (usage == USAGE_TEXT) { encoding recEncoding; if (chset.getRecommendedEncoding(recEncoding)) return recEncoding; } return decide(data, usage); } ref encoding::clone() const { return vmime::create (*this); } void encoding::copyFrom(const component& other) { const encoding& e = dynamic_cast (other); m_name = e.m_name; } const string& encoding::getName() const { return (m_name); } void encoding::setName(const string& name) { m_name = name; } const std::vector > encoding::getChildComponents() const { return std::vector >(); } } // vmime libvmime-0.9.1/src/path.cpp0000644000175000017500000000757411250723263016074 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/path.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { path::path() { } path::path(const string& localPart, const string& domain) : m_localPart(localPart), m_domain(domain) { } path::path(const path& p) : headerFieldValue(), m_localPart(p.m_localPart), m_domain(p.m_domain) { } const string& path::getLocalPart() const { return (m_localPart); } void path::setLocalPart(const string& localPart) { m_localPart = localPart; } const string& path::getDomain() const { return (m_domain); } void path::setDomain(const string& domain) { m_domain = domain; } bool path::operator==(const path& p) const { return (m_localPart == p.m_localPart && m_domain == p.m_domain); } bool path::operator!=(const path& p) const { return (m_localPart != p.m_localPart || m_domain != p.m_domain); } void path::copyFrom(const component& other) { const path& p = dynamic_cast (other); m_localPart = p.m_localPart; m_domain = p.m_domain; } ref path::clone() const { return vmime::create (*this); } path& path::operator=(const path& other) { copyFrom(other); return (*this); } const std::vector > path::getChildComponents() const { return std::vector >(); } void path::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { string::size_type pos = position; while (pos < end && parserHelpers::isSpace(buffer[pos])) ++pos; string addrSpec; if (pos < end && buffer[pos] == '<') { // Skip '<' ++pos; while (pos < end && parserHelpers::isSpace(buffer[pos])) ++pos; const string::size_type addrStart = pos; while (pos < end && buffer[pos] != '>') ++pos; string::size_type addrEnd = pos; while (addrEnd > addrStart && parserHelpers::isSpace(buffer[addrEnd - 1])) addrEnd--; addrSpec = string(buffer.begin() + addrStart, buffer.begin() + addrEnd); } else { addrSpec = string(buffer.begin() + position, buffer.begin() + end); } const string::size_type at = addrSpec.find_first_of('@'); if (at != string::npos) { m_localPart = string(addrSpec.begin(), addrSpec.begin() + at); m_domain = string(addrSpec.begin() + at + 1, addrSpec.end()); } else { m_localPart.clear(); m_domain = addrSpec; } if (newPosition != NULL) *newPosition = end; } void path::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, const string::size_type curLinePos, string::size_type* newLinePos) const { if (m_localPart.empty() && m_domain.empty()) { os << "<>"; if (newLinePos) *newLinePos = curLinePos + 2; } else { os << "<" << m_localPart << "@" << m_domain << ">"; if (newLinePos) *newLinePos = curLinePos + m_localPart.length() + m_domain.length() + 3; } } } // vmime libvmime-0.9.1/src/emptyContentHandler.cpp0000644000175000017500000000432611376250245021123 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/emptyContentHandler.hpp" namespace vmime { emptyContentHandler::emptyContentHandler() { } ref emptyContentHandler::clone() const { return vmime::create (); } void emptyContentHandler::generate(utility::outputStream& /* os */, const vmime::encoding& /* enc */, const string::size_type /* maxLineLength */) const { // Nothing to do. } void emptyContentHandler::extract(utility::outputStream& /* os */, utility::progressListener* progress) const { if (progress) progress->start(0); // Nothing to do. if (progress) progress->stop(0); } void emptyContentHandler::extractRaw(utility::outputStream& /* os */, utility::progressListener* progress) const { if (progress) progress->start(0); // Nothing to do. if (progress) progress->stop(0); } string::size_type emptyContentHandler::getLength() const { return (0); } bool emptyContentHandler::isEmpty() const { return (true); } bool emptyContentHandler::isEncoded() const { return (false); } const vmime::encoding& emptyContentHandler::getEncoding() const { return (NO_ENCODING); } bool emptyContentHandler::isBuffered() const { return true; } } // vmime libvmime-0.9.1/src/mailbox.cpp0000644000175000017500000002265311374031010016553 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mailbox.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { mailbox::mailbox() { } mailbox::mailbox(const mailbox& mbox) : address(), m_name(mbox.m_name), m_email(mbox.m_email) { } mailbox::mailbox(const string& email) : m_email(email) { } mailbox::mailbox(const text& name, const string& email) : m_name(name), m_email(email) { } /* RFC #2822: 3.4. ADDRESS SPECIFICATION mailbox = name-addr / addr-spec name-addr = [display-name] angle-addr angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr */ void mailbox::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { const string::value_type* const pend = buffer.data() + end; const string::value_type* const pstart = buffer.data() + position; const string::value_type* p = pstart; // Ignore blank spaces at the beginning while (p < pend && parserHelpers::isSpace(*p)) ++p; // Current state for parsing machine enum States { State_None, State_Name, State_Address }; States state = State_Name; // let's start with name, we will see later (*) // Temporary buffers for extracted name and address string name; string address; while (p < pend) { if (state == State_Name) { if (*p == '<') { state = State_Address; continue; } if (*p == '"') // Quoted string { ++p; bool escaped = false; while (p < pend) { if (escaped) { name += *p; escaped = false; } else if (*p == '\\') { escaped = true; } else { if (*p == '"') { ++p; break; } else { name += *p; } } ++p; } } else { bool escaped = false; int comment = 0; while (p < pend) { if (escaped) { if (!comment) name += *p; escaped = false; } else if (comment) { if (*p == '\\') escaped = true; else if (*p == '(') ++comment; else if (*p == ')') --comment; } else if (*p == '\\') { escaped = true; } else if (*p == '(') { ++comment; } else if (*p == '<') { // Erase any space between display name and
string::iterator q = name.end(); while (q != name.begin() && parserHelpers::isSpace(*(q - 1))) --q; name.erase(q, name.end()); break; } else if (/* parserHelpers::isSpace(*p) || */ *p == '@') { break; } else { name += *p; } ++p; } } if (p < pend && *p == '@') { // (*) Actually, we were parsing the local-part of an address // and not a display name... address = name; name.clear(); bool escaped = false; int comment = 0; while (p < pend) { if (escaped) { if (!comment) address += *p; escaped = false; } else if (comment) { if (*p == '\\') escaped = true; else if (*p == '(') ++comment; else if (*p == ')') --comment; } else if (*p == '\\') { escaped = true; } else if (*p == '(') { ++comment; } else if (parserHelpers::isSpace(*p)) { break; } else { address += *p; } ++p; } break; } else { while (p < pend && parserHelpers::isSpace(*p)) ++p; state = State_None; } } else if (state == State_Address) { // Skip '<' character if (*p == '<') ++p; bool escaped = false; int comment = 0; while (p < pend) { if (escaped) { if (!comment) address += *p; escaped = false; } else if (comment) { if (*p == '\\') escaped = true; else if (*p == '(') ++comment; else if (*p == ')') --comment; } else if (*p == '(') { ++comment; } else if (*p == '\\') { escaped = true; } else if (*p == '<') { // If we found a '<' here, it means that the address // starts _only_ here...and the stuff we have parsed // before belongs actually to the display name! name += address; address.clear(); } else if (*p == '>') { break; } else if (!parserHelpers::isSpace(*p)) { address += *p; } ++p; } break; } else { while (p < pend && parserHelpers::isSpace(*p)) ++p; if (p < pend) { //if (*p == '<') state = State_Address; } } } // Swap name and address when no address was found // (email address is mandatory, whereas name is optional). if (address.empty() && !name.empty()) { m_email.clear(); m_email.reserve(name.size()); m_name.removeAllWords(); for (string::size_type i = 0 ; i < name.size() ; ++i) { if (!parserHelpers::isSpace(name[i])) m_email += name[i]; } } else { text::decodeAndUnfold(name, &m_name); m_email.clear(); m_email.reserve(address.size()); for (string::size_type i = 0 ; i < address.size() ; ++i) { if (!parserHelpers::isSpace(address[i])) m_email += address[i]; } } setParsedBounds(position, position + (p - pstart)); if (newPosition) *newPosition = position + (p - pstart); } void mailbox::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { if (m_name.isEmpty()) { bool newLine = false; // No display name is specified, only email address. if (curLinePos /* + 2 */ + m_email.length() > maxLineLength) { os << NEW_LINE_SEQUENCE; newLine = true; } //os << "<" << m_email << ">"; os << m_email; if (newLinePos) { *newLinePos = curLinePos + m_email.length() /* + 2 */; if (newLine) *newLinePos += 1; } } else { // We have to encode the name: // - if it contains characters in a charset different from "US-ASCII", // - and/or if it contains one or more of these special chars: // CR LF TAB " ; , < > ( ) @ / ? . = : // Check whether there are words that are not "US-ASCII" // and/or contain the special chars. bool forceEncode = false; for (int w = 0 ; !forceEncode && w != m_name.getWordCount() ; ++w) { if (m_name.getWordAt(w)->getCharset() == charset(charsets::US_ASCII)) { const string& buffer = m_name.getWordAt(w)->getBuffer(); for (string::const_iterator c = buffer.begin() ; !forceEncode && c != buffer.end() ; ++c) { switch (*c) { case '\r': case '\n': case '\t': case ';': case ',': case '<': case '>': case '(': case ')': case '@': case '/': case '?': case '.': case '=': case ':': case '"': forceEncode = true; break; } } } else { forceEncode = true; } } string::size_type pos = curLinePos; bool newLine = true; m_name.encodeAndFold(os, maxLineLength, pos, &pos, text::QUOTE_IF_POSSIBLE | (forceEncode ? text::FORCE_ENCODING : 0)); if (pos + m_email.length() + 3 > maxLineLength) { os << NEW_LINE_SEQUENCE; newLine = true; } os << " <" << m_email << ">"; if (newLinePos) { *newLinePos = pos + m_email.length() + 3; if (newLine) *newLinePos += NEW_LINE_SEQUENCE.length(); } } } bool mailbox::operator==(const class mailbox& mailbox) const { return (m_name == mailbox.m_name && m_email == mailbox.m_email); } bool mailbox::operator!=(const class mailbox& mailbox) const { return !(*this == mailbox); } void mailbox::copyFrom(const component& other) { const mailbox& source = dynamic_cast (other); m_name = source.m_name; m_email = source.m_email; } mailbox& mailbox::operator=(const mailbox& other) { copyFrom(other); return (*this); } ref mailbox::clone() const { return vmime::create (*this); } bool mailbox::isEmpty() const { return (m_email.empty()); } void mailbox::clear() { m_name.removeAllWords(); m_email.clear(); } bool mailbox::isGroup() const { return (false); } const text& mailbox::getName() const { return (m_name); } void mailbox::setName(const text& name) { m_name = name; } const string& mailbox::getEmail() const { return (m_email); } void mailbox::setEmail(const string& email) { m_email = email; } const std::vector > mailbox::getChildComponents() const { return std::vector >(); } } // vmime libvmime-0.9.1/src/text.cpp0000644000175000017500000002032211455137112016105 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/text.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/encoding.hpp" namespace vmime { text::text() { } text::text(const text& t) : headerFieldValue() { copyFrom(t); } text::text(const string& t, const charset& ch) { createFromString(t, ch); } text::text(const string& t) { createFromString(t, charset::getLocaleCharset()); } text::text(const word& w) { appendWord(vmime::create (w)); } text::~text() { removeAllWords(); } void text::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { removeAllWords(); string::size_type newPos; const std::vector > words = word::parseMultiple(buffer, position, end, &newPos); copy_vector(words, m_words); setParsedBounds(position, newPos); if (newPosition) *newPosition = newPos; } void text::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { encodeAndFold(os, maxLineLength, curLinePos, newLinePos, 0); } void text::copyFrom(const component& other) { const text& t = dynamic_cast (other); removeAllWords(); for (std::vector >::const_iterator i = t.m_words.begin() ; i != t.m_words.end() ; ++i) m_words.push_back(vmime::create (**i)); } text& text::operator=(const component& other) { copyFrom(other); return (*this); } text& text::operator=(const text& other) { copyFrom(other); return (*this); } bool text::operator==(const text& t) const { if (getWordCount() == t.getWordCount()) { bool equal = true; std::vector >::const_iterator i = m_words.begin(); std::vector >::const_iterator j = t.m_words.begin(); for ( ; equal && i != m_words.end() ; ++i, ++j) equal = (**i == **j); return (equal); } return (false); } bool text::operator!=(const text& t) const { return !(*this == t); } const string text::getConvertedText(const charset& dest) const { string out; for (std::vector >::const_iterator i = m_words.begin() ; i != m_words.end() ; ++i) out += (*i)->getConvertedText(dest); return (out); } void text::appendWord(ref w) { m_words.push_back(w); } void text::insertWordBefore(const int pos, ref w) { m_words.insert(m_words.begin() + pos, w); } void text::insertWordAfter(const int pos, ref w) { m_words.insert(m_words.begin() + pos + 1, w); } void text::removeWord(const int pos) { const std::vector >::iterator it = m_words.begin() + pos; m_words.erase(it); } void text::removeAllWords() { m_words.clear(); } int text::getWordCount() const { return (m_words.size()); } bool text::isEmpty() const { return (m_words.empty()); } const ref text::getWordAt(const int pos) { return (m_words[pos]); } const ref text::getWordAt(const int pos) const { return (m_words[pos]); } const std::vector > text::getWordList() const { std::vector > list; list.reserve(m_words.size()); for (std::vector >::const_iterator it = m_words.begin() ; it != m_words.end() ; ++it) { list.push_back(*it); } return (list); } const std::vector > text::getWordList() { return (m_words); } ref text::clone() const { return vmime::create (*this); } ref text::newFromString(const string& in, const charset& ch) { ref t = vmime::create (); t->createFromString(in, ch); return t; } void text::createFromString(const string& in, const charset& ch) { string::size_type asciiCount = 0; string::size_type asciiPercent = 0; removeAllWords(); // Check whether there is a recommended encoding for this charset. // If so, the whole buffer will be encoded. Else, the number of // 7-bit (ASCII) bytes in the input will be used to determine if // we need to encode the whole buffer. encoding recommendedEnc; const bool alwaysEncode = ch.getRecommendedEncoding(recommendedEnc); if (!alwaysEncode) { asciiCount = utility::stringUtils::countASCIIchars(in.begin(), in.end()); asciiPercent = (in.length() == 0 ? 100 : (100 * asciiCount) / in.length()); } // If there are "too much" non-ASCII chars, encode everything if (alwaysEncode || asciiPercent < 60) // less than 60% ASCII chars { appendWord(vmime::create (in, ch)); } // Else, only encode words which need it else { bool is8bit = false; // is the current word 8-bit? bool prevIs8bit = false; // is previous word 8-bit? unsigned int count = 0; // total number of words for (string::size_type end = in.size(), pos = 0, start = 0 ; ; ) { if (pos == end || parserHelpers::isSpace(in[pos])) { const string chunk(in.begin() + start, in.begin() + pos); if (pos != end) ++pos; if (is8bit) { if (count && prevIs8bit) { // No need to create a new encoded word, just append // the current word to the previous one. ref w = getWordAt(getWordCount() - 1); w->getBuffer() += " " + chunk; } else { if (count) { ref w = getWordAt(getWordCount() - 1); w->getBuffer() += ' '; } appendWord(vmime::create (chunk, ch)); prevIs8bit = true; ++count; } } else { if (count && !prevIs8bit) { ref w = getWordAt(getWordCount() - 1); w->getBuffer() += " " + chunk; } else { if (count) { ref w = getWordAt(getWordCount() - 1); w->getBuffer() += ' '; } appendWord(vmime::create (chunk, charset(charsets::US_ASCII))); prevIs8bit = false; ++count; } } if (pos == end) break; is8bit = false; start = pos; } else if (!parserHelpers::isAscii(in[pos])) { is8bit = true; ++pos; } else { ++pos; } } } } void text::encodeAndFold(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type firstLineOffset, string::size_type* lastLineLength, const int flags) const { string::size_type curLineLength = firstLineOffset; word::generatorState state; for (int wi = 0 ; wi < getWordCount() ; ++wi) { getWordAt(wi)->generate(os, maxLineLength, curLineLength, &curLineLength, flags, &state); } if (lastLineLength) *lastLineLength = curLineLength; } ref text::decodeAndUnfold(const string& in) { ref t = vmime::create (); decodeAndUnfold(in, t.get()); return t; } text* text::decodeAndUnfold(const string& in, text* generateInExisting) { text* out = (generateInExisting != NULL) ? generateInExisting : new text(); out->removeAllWords(); const std::vector > words = word::parseMultiple(in, 0, in.length(), NULL); copy_vector(words, out->m_words); return (out); } const std::vector > text::getChildComponents() const { std::vector > list; copy_vector(m_words, list); return (list); } const string text::getWholeBuffer() const { string res; for (std::vector >::const_iterator it = m_words.begin() ; it != m_words.end() ; ++it) { res += (*it)->getBuffer(); } return res; } } // vmime libvmime-0.9.1/src/object.cpp0000644000175000017500000000401611250723263016372 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/types.hpp" #include "vmime/object.hpp" #ifndef VMIME_BUILDING_DOC namespace vmime { object::object() : m_refMgr(utility::refManager::create(this)) { } object::object(const object&) : m_refMgr(utility::refManager::create(this)) { } object& object::operator=(const object&) { // Do _NOT_ copy 'm_refMgr' return *this; } object::~object() { delete m_refMgr; m_refMgr = 0; } ref object::thisRef() { m_refMgr->addStrong(); return ref ::fromPtr(this); } ref object::thisRef() const { m_refMgr->addStrong(); return ref ::fromPtr(this); } weak_ref object::thisWeakRef() { return weak_ref (thisRef()); } weak_ref object::thisWeakRef() const { return weak_ref (thisRef()); } void object::setRefManager(utility::refManager* mgr) { m_refMgr = mgr; } utility::refManager* object::getRefManager() const { return m_refMgr; } } // vmime #endif // VMIME_BUILDING_DOC libvmime-0.9.1/src/mailboxField.cpp0000644000175000017500000000441711250723263017530 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mailboxField.hpp" #include "vmime/mailboxGroup.hpp" #ifndef VMIME_BUILDING_DOC namespace vmime { mailboxField::mailboxField() { } mailboxField::mailboxField(const mailboxField&) : headerField() { } void mailboxField::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { ref mbox = vmime::create (); // Here, we cannot simply call "m_mailbox.parse()" because it // may have more than one address specified (even if this field // should contain only one). We are never too much careful... ref
parsedAddress = address::parseNext(buffer, position, end, newPosition); if (parsedAddress) { if (parsedAddress->isGroup()) { // If it is a group of mailboxes, take the first // mailbox of the group ref group = parsedAddress.staticCast (); if (!group->isEmpty()) mbox = group->getMailboxAt(0); } else { // Parse only if it is a mailbox mbox = parsedAddress.staticCast (); } } mbox->setParsedBounds(position, end); setValue(mbox); setParsedBounds(position, end); if (newPosition) *newPosition = end; } } // vmime #endif // VMIME_BUILDING_DOC libvmime-0.9.1/src/component.cpp0000644000175000017500000000457111250723263017134 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/component.hpp" #include "vmime/base.hpp" #include namespace vmime { component::component() : m_parsedOffset(0), m_parsedLength(0) { } component::~component() { } void component::parse(const string& buffer) { parse(buffer, 0, buffer.length(), NULL); } const string component::generate(const string::size_type maxLineLength, const string::size_type curLinePos) const { std::ostringstream oss; utility::outputStreamAdapter adapter(oss); generate(adapter, maxLineLength, curLinePos, NULL); return (oss.str()); } string::size_type component::getParsedOffset() const { return (m_parsedOffset); } string::size_type component::getParsedLength() const { return (m_parsedLength); } void component::setParsedBounds(const string::size_type start, const string::size_type end) { m_parsedOffset = start; m_parsedLength = end - start; } const std::vector > component::getChildComponents() { const std::vector > constList = const_cast (this)->getChildComponents(); std::vector > list; const std::vector >::size_type count = constList.size(); list.resize(count); for (std::vector >::size_type i = 0 ; i < count ; ++i) list[i] = constList[i].constCast (); return (list); } } libvmime-0.9.1/src/Makefile.am0000644000175000017500000002670311470477531016473 0ustar mnordstrmnordstr # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! AUTOMAKE_OPTIONS = no-dependencies foreign INTERNALS = INCLUDES = -I$(prefix)/include -I$(top_srcdir) @PKGCONFIG_CFLAGS@ @EXTRA_CFLAGS@ lib_LTLIBRARIES = libvmime.la libvmime_la_LDFLAGS = -export-dynamic -version-info @LIBRARY_VERSION@ @PKGCONFIG_LIBS@ @EXTRA_LIBS@ libvmime_la_SOURCES = address.cpp \ addressList.cpp \ attachmentHelper.cpp \ base.cpp \ body.cpp \ bodyPart.cpp \ bodyPartAttachment.cpp \ charset.cpp \ charsetConverter.cpp \ component.cpp \ constants.cpp \ contentDisposition.cpp \ contentDispositionField.cpp \ contentHandler.cpp \ contentTypeField.cpp \ dateTime.cpp \ defaultAttachment.cpp \ disposition.cpp \ emptyContentHandler.cpp \ encoding.cpp \ exception.cpp \ fileAttachment.cpp \ generatedMessageAttachment.cpp \ header.cpp \ headerFieldFactory.cpp \ headerField.cpp \ htmlTextPart.cpp \ mailbox.cpp \ mailboxField.cpp \ mailboxGroup.cpp \ mailboxList.cpp \ mediaType.cpp \ messageBuilder.cpp \ message.cpp \ messageId.cpp \ messageIdSequence.cpp \ messageParser.cpp \ object.cpp \ options.cpp \ path.cpp \ parameter.cpp \ parameterizedHeaderField.cpp \ parsedMessageAttachment.cpp \ plainTextPart.cpp \ platform.cpp \ propertySet.cpp \ relay.cpp \ stringContentHandler.cpp \ streamContentHandler.cpp \ text.cpp \ textPartFactory.cpp \ word.cpp \ wordEncoder.cpp \ utility_datetimeUtils.cpp \ utility_filteredStream.cpp \ utility_path.cpp \ utility_progressListener.cpp \ utility_random.cpp \ utility_smartPtr.cpp \ utility_smartPtrInt.cpp \ utility_stream.cpp \ utility_stringProxy.cpp \ utility_stringUtils.cpp \ utility_url.cpp \ utility_urlUtils.cpp \ utility_encoder_encoder.cpp \ utility_encoder_sevenBitEncoder.cpp \ utility_encoder_eightBitEncoder.cpp \ utility_encoder_b64Encoder.cpp \ utility_encoder_binaryEncoder.cpp \ utility_encoder_defaultEncoder.cpp \ utility_encoder_encoderFactory.cpp \ utility_encoder_qpEncoder.cpp \ utility_encoder_uuEncoder.cpp \ mdn_MDNHelper.cpp \ mdn_MDNInfos.cpp \ mdn_receivedMDNInfos.cpp \ mdn_sendableMDNInfos.cpp \ misc_importanceHelper.cpp \ security_defaultAuthenticator.cpp \ security_digest_messageDigest.cpp \ security_digest_messageDigestFactory.cpp \ security_digest_md5_md5MessageDigest.cpp \ security_digest_sha1_sha1MessageDigest.cpp if VMIME_HAVE_MESSAGING_FEATURES libvmime_la_SOURCES += net_builtinServices.inl \ net_defaultConnectionInfos.cpp \ net_events.cpp \ net_folder.cpp \ net_message.cpp \ net_service.cpp \ net_serviceFactory.cpp \ net_serviceInfos.cpp \ net_serviceRegistration.inl \ net_session.cpp \ net_transport.cpp endif if VMIME_BUILTIN_MESSAGING_PROTO_POP3 libvmime_la_SOURCES += net_pop3_POP3ServiceInfos.cpp \ net_pop3_POP3Store.cpp \ net_pop3_POP3SStore.cpp \ net_pop3_POP3Folder.cpp \ net_pop3_POP3Message.cpp \ net_pop3_POP3Utils.cpp endif if VMIME_BUILTIN_MESSAGING_PROTO_SMTP libvmime_la_SOURCES += net_smtp_SMTPResponse.cpp \ net_smtp_SMTPServiceInfos.cpp \ net_smtp_SMTPTransport.cpp \ net_smtp_SMTPSTransport.cpp endif if VMIME_BUILTIN_MESSAGING_PROTO_IMAP libvmime_la_SOURCES += net_imap_IMAPServiceInfos.cpp \ net_imap_IMAPConnection.cpp \ net_imap_IMAPStore.cpp \ net_imap_IMAPSStore.cpp \ net_imap_IMAPFolder.cpp \ net_imap_IMAPMessage.cpp \ net_imap_IMAPTag.cpp \ net_imap_IMAPUtils.cpp \ net_imap_IMAPMessagePartContentHandler.cpp \ net_imap_IMAPStructure.cpp \ net_imap_IMAPPart.cpp endif if VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR libvmime_la_SOURCES += net_maildir_maildirServiceInfos.cpp \ net_maildir_maildirStore.cpp \ net_maildir_maildirFolder.cpp \ net_maildir_maildirMessage.cpp \ net_maildir_maildirUtils.cpp \ net_maildir_maildirFormat.cpp \ net_maildir_format_kmailMaildirFormat.cpp \ net_maildir_format_courierMaildirFormat.cpp endif if VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL libvmime_la_SOURCES += net_sendmail_sendmailServiceInfos.cpp \ net_sendmail_sendmailTransport.cpp endif if VMIME_HAVE_SASL_SUPPORT libvmime_la_SOURCES += security_sasl_SASLContext.cpp \ security_sasl_SASLSession.cpp \ security_sasl_SASLMechanismFactory.cpp \ security_sasl_SASLSocket.cpp \ security_sasl_defaultSASLAuthenticator.cpp \ security_sasl_builtinSASLMechanism.cpp endif if VMIME_HAVE_TLS_SUPPORT libvmime_la_SOURCES += net_tls_TLSSession.cpp \ net_tls_TLSSocket.cpp \ net_tls_TLSSecuredConnectionInfos.cpp \ security_cert_certificateChain.cpp \ security_cert_defaultCertificateVerifier.cpp \ security_cert_X509Certificate.cpp endif if VMIME_BUILTIN_PLATFORM_WINDOWS libvmime_la_SOURCES += platforms_windows_windowsFile.cpp \ platforms_windows_windowsHandler.cpp \ platforms_windows_windowsSocket.cpp endif if VMIME_BUILTIN_PLATFORM_POSIX libvmime_la_SOURCES += platforms_posix_posixChildProcess.cpp \ platforms_posix_posixFile.cpp \ platforms_posix_posixHandler.cpp \ platforms_posix_posixSocket.cpp endif noinst_HEADERS = $(INTERNALS) utility_datetimeUtils.cpp: utility/datetimeUtils.cpp ln -sf $< $@ utility_filteredStream.cpp: utility/filteredStream.cpp ln -sf $< $@ utility_path.cpp: utility/path.cpp ln -sf $< $@ utility_progressListener.cpp: utility/progressListener.cpp ln -sf $< $@ utility_random.cpp: utility/random.cpp ln -sf $< $@ utility_smartPtr.cpp: utility/smartPtr.cpp ln -sf $< $@ utility_smartPtrInt.cpp: utility/smartPtrInt.cpp ln -sf $< $@ utility_stream.cpp: utility/stream.cpp ln -sf $< $@ utility_stringProxy.cpp: utility/stringProxy.cpp ln -sf $< $@ utility_stringUtils.cpp: utility/stringUtils.cpp ln -sf $< $@ utility_url.cpp: utility/url.cpp ln -sf $< $@ utility_urlUtils.cpp: utility/urlUtils.cpp ln -sf $< $@ utility_encoder_encoder.cpp: utility/encoder/encoder.cpp ln -sf $< $@ utility_encoder_sevenBitEncoder.cpp: utility/encoder/sevenBitEncoder.cpp ln -sf $< $@ utility_encoder_eightBitEncoder.cpp: utility/encoder/eightBitEncoder.cpp ln -sf $< $@ utility_encoder_b64Encoder.cpp: utility/encoder/b64Encoder.cpp ln -sf $< $@ utility_encoder_binaryEncoder.cpp: utility/encoder/binaryEncoder.cpp ln -sf $< $@ utility_encoder_defaultEncoder.cpp: utility/encoder/defaultEncoder.cpp ln -sf $< $@ utility_encoder_encoderFactory.cpp: utility/encoder/encoderFactory.cpp ln -sf $< $@ utility_encoder_qpEncoder.cpp: utility/encoder/qpEncoder.cpp ln -sf $< $@ utility_encoder_uuEncoder.cpp: utility/encoder/uuEncoder.cpp ln -sf $< $@ mdn_MDNHelper.cpp: mdn/MDNHelper.cpp ln -sf $< $@ mdn_MDNInfos.cpp: mdn/MDNInfos.cpp ln -sf $< $@ mdn_receivedMDNInfos.cpp: mdn/receivedMDNInfos.cpp ln -sf $< $@ mdn_sendableMDNInfos.cpp: mdn/sendableMDNInfos.cpp ln -sf $< $@ misc_importanceHelper.cpp: misc/importanceHelper.cpp ln -sf $< $@ security_defaultAuthenticator.cpp: security/defaultAuthenticator.cpp ln -sf $< $@ security_digest_messageDigest.cpp: security/digest/messageDigest.cpp ln -sf $< $@ security_digest_messageDigestFactory.cpp: security/digest/messageDigestFactory.cpp ln -sf $< $@ security_digest_md5_md5MessageDigest.cpp: security/digest/md5/md5MessageDigest.cpp ln -sf $< $@ security_digest_sha1_sha1MessageDigest.cpp: security/digest/sha1/sha1MessageDigest.cpp ln -sf $< $@ net_builtinServices.inl: net/builtinServices.inl ln -sf $< $@ net_defaultConnectionInfos.cpp: net/defaultConnectionInfos.cpp ln -sf $< $@ net_events.cpp: net/events.cpp ln -sf $< $@ net_folder.cpp: net/folder.cpp ln -sf $< $@ net_message.cpp: net/message.cpp ln -sf $< $@ net_service.cpp: net/service.cpp ln -sf $< $@ net_serviceFactory.cpp: net/serviceFactory.cpp ln -sf $< $@ net_serviceInfos.cpp: net/serviceInfos.cpp ln -sf $< $@ net_serviceRegistration.inl: net/serviceRegistration.inl ln -sf $< $@ net_session.cpp: net/session.cpp ln -sf $< $@ net_transport.cpp: net/transport.cpp ln -sf $< $@ net_pop3_POP3ServiceInfos.cpp: net/pop3/POP3ServiceInfos.cpp ln -sf $< $@ net_pop3_POP3Store.cpp: net/pop3/POP3Store.cpp ln -sf $< $@ net_pop3_POP3SStore.cpp: net/pop3/POP3SStore.cpp ln -sf $< $@ net_pop3_POP3Folder.cpp: net/pop3/POP3Folder.cpp ln -sf $< $@ net_pop3_POP3Message.cpp: net/pop3/POP3Message.cpp ln -sf $< $@ net_pop3_POP3Utils.cpp: net/pop3/POP3Utils.cpp ln -sf $< $@ net_smtp_SMTPResponse.cpp: net/smtp/SMTPResponse.cpp ln -sf $< $@ net_smtp_SMTPServiceInfos.cpp: net/smtp/SMTPServiceInfos.cpp ln -sf $< $@ net_smtp_SMTPTransport.cpp: net/smtp/SMTPTransport.cpp ln -sf $< $@ net_smtp_SMTPSTransport.cpp: net/smtp/SMTPSTransport.cpp ln -sf $< $@ net_imap_IMAPServiceInfos.cpp: net/imap/IMAPServiceInfos.cpp ln -sf $< $@ net_imap_IMAPConnection.cpp: net/imap/IMAPConnection.cpp ln -sf $< $@ net_imap_IMAPStore.cpp: net/imap/IMAPStore.cpp ln -sf $< $@ net_imap_IMAPSStore.cpp: net/imap/IMAPSStore.cpp ln -sf $< $@ net_imap_IMAPFolder.cpp: net/imap/IMAPFolder.cpp ln -sf $< $@ net_imap_IMAPMessage.cpp: net/imap/IMAPMessage.cpp ln -sf $< $@ net_imap_IMAPTag.cpp: net/imap/IMAPTag.cpp ln -sf $< $@ net_imap_IMAPUtils.cpp: net/imap/IMAPUtils.cpp ln -sf $< $@ net_imap_IMAPMessagePartContentHandler.cpp: net/imap/IMAPMessagePartContentHandler.cpp ln -sf $< $@ net_imap_IMAPStructure.cpp: net/imap/IMAPStructure.cpp ln -sf $< $@ net_imap_IMAPPart.cpp: net/imap/IMAPPart.cpp ln -sf $< $@ net_maildir_maildirServiceInfos.cpp: net/maildir/maildirServiceInfos.cpp ln -sf $< $@ net_maildir_maildirStore.cpp: net/maildir/maildirStore.cpp ln -sf $< $@ net_maildir_maildirFolder.cpp: net/maildir/maildirFolder.cpp ln -sf $< $@ net_maildir_maildirMessage.cpp: net/maildir/maildirMessage.cpp ln -sf $< $@ net_maildir_maildirUtils.cpp: net/maildir/maildirUtils.cpp ln -sf $< $@ net_maildir_maildirFormat.cpp: net/maildir/maildirFormat.cpp ln -sf $< $@ net_maildir_format_kmailMaildirFormat.cpp: net/maildir/format/kmailMaildirFormat.cpp ln -sf $< $@ net_maildir_format_courierMaildirFormat.cpp: net/maildir/format/courierMaildirFormat.cpp ln -sf $< $@ net_sendmail_sendmailServiceInfos.cpp: net/sendmail/sendmailServiceInfos.cpp ln -sf $< $@ net_sendmail_sendmailTransport.cpp: net/sendmail/sendmailTransport.cpp ln -sf $< $@ security_sasl_SASLContext.cpp: security/sasl/SASLContext.cpp ln -sf $< $@ security_sasl_SASLSession.cpp: security/sasl/SASLSession.cpp ln -sf $< $@ security_sasl_SASLMechanismFactory.cpp: security/sasl/SASLMechanismFactory.cpp ln -sf $< $@ security_sasl_SASLSocket.cpp: security/sasl/SASLSocket.cpp ln -sf $< $@ security_sasl_defaultSASLAuthenticator.cpp: security/sasl/defaultSASLAuthenticator.cpp ln -sf $< $@ security_sasl_builtinSASLMechanism.cpp: security/sasl/builtinSASLMechanism.cpp ln -sf $< $@ net_tls_TLSSession.cpp: net/tls/TLSSession.cpp ln -sf $< $@ net_tls_TLSSocket.cpp: net/tls/TLSSocket.cpp ln -sf $< $@ net_tls_TLSSecuredConnectionInfos.cpp: net/tls/TLSSecuredConnectionInfos.cpp ln -sf $< $@ security_cert_certificateChain.cpp: security/cert/certificateChain.cpp ln -sf $< $@ security_cert_defaultCertificateVerifier.cpp: security/cert/defaultCertificateVerifier.cpp ln -sf $< $@ security_cert_X509Certificate.cpp: security/cert/X509Certificate.cpp ln -sf $< $@ platforms_windows_windowsFile.cpp: platforms/windows/windowsFile.cpp ln -sf $< $@ platforms_windows_windowsHandler.cpp: platforms/windows/windowsHandler.cpp ln -sf $< $@ platforms_windows_windowsSocket.cpp: platforms/windows/windowsSocket.cpp ln -sf $< $@ platforms_posix_posixChildProcess.cpp: platforms/posix/posixChildProcess.cpp ln -sf $< $@ platforms_posix_posixFile.cpp: platforms/posix/posixFile.cpp ln -sf $< $@ platforms_posix_posixHandler.cpp: platforms/posix/posixHandler.cpp ln -sf $< $@ platforms_posix_posixSocket.cpp: platforms/posix/posixSocket.cpp ln -sf $< $@ libvmime-0.9.1/src/Makefile.in0000644000175000017500000011636211470477543016510 0ustar mnordstrmnordstr# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@am__append_1 = net_builtinServices.inl \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_defaultConnectionInfos.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_events.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_folder.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_message.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_service.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_serviceFactory.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_serviceInfos.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_serviceRegistration.inl \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_session.cpp \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_transport.cpp @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@am__append_2 = net_pop3_POP3ServiceInfos.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Store.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3SStore.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Folder.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Message.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Utils.cpp @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@am__append_3 = net_smtp_SMTPResponse.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@ net_smtp_SMTPServiceInfos.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@ net_smtp_SMTPTransport.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@ net_smtp_SMTPSTransport.cpp @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@am__append_4 = net_imap_IMAPServiceInfos.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPConnection.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPStore.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPSStore.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPFolder.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPMessage.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPTag.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPUtils.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPMessagePartContentHandler.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPStructure.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPPart.cpp @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@am__append_5 = net_maildir_maildirServiceInfos.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirStore.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirFolder.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirMessage.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirUtils.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirFormat.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_format_kmailMaildirFormat.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_format_courierMaildirFormat.cpp @VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE@am__append_6 = net_sendmail_sendmailServiceInfos.cpp \ @VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE@ net_sendmail_sendmailTransport.cpp @VMIME_HAVE_SASL_SUPPORT_TRUE@am__append_7 = security_sasl_SASLContext.cpp \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_SASLSession.cpp \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_SASLMechanismFactory.cpp \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_SASLSocket.cpp \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_defaultSASLAuthenticator.cpp \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_builtinSASLMechanism.cpp @VMIME_HAVE_TLS_SUPPORT_TRUE@am__append_8 = net_tls_TLSSession.cpp \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ net_tls_TLSSocket.cpp \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ net_tls_TLSSecuredConnectionInfos.cpp \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ security_cert_certificateChain.cpp \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ security_cert_defaultCertificateVerifier.cpp \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ security_cert_X509Certificate.cpp @VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE@am__append_9 = platforms_windows_windowsFile.cpp \ @VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE@ platforms_windows_windowsHandler.cpp \ @VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE@ platforms_windows_windowsSocket.cpp @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@am__append_10 = platforms_posix_posixChildProcess.cpp \ @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@ platforms_posix_posixFile.cpp \ @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@ platforms_posix_posixHandler.cpp \ @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@ platforms_posix_posixSocket.cpp subdir = src DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ $(top_srcdir)/m4/ost_posix.m4 $(top_srcdir)/m4/ost_prog.m4 \ $(top_srcdir)/m4/ost_pthread.m4 \ $(top_srcdir)/m4/ost_systime.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libvmime_la_LIBADD = am__libvmime_la_SOURCES_DIST = address.cpp addressList.cpp \ attachmentHelper.cpp base.cpp body.cpp bodyPart.cpp \ bodyPartAttachment.cpp charset.cpp charsetConverter.cpp \ component.cpp constants.cpp contentDisposition.cpp \ contentDispositionField.cpp contentHandler.cpp \ contentTypeField.cpp dateTime.cpp defaultAttachment.cpp \ disposition.cpp emptyContentHandler.cpp encoding.cpp \ exception.cpp fileAttachment.cpp \ generatedMessageAttachment.cpp header.cpp \ headerFieldFactory.cpp headerField.cpp htmlTextPart.cpp \ mailbox.cpp mailboxField.cpp mailboxGroup.cpp mailboxList.cpp \ mediaType.cpp messageBuilder.cpp message.cpp messageId.cpp \ messageIdSequence.cpp messageParser.cpp object.cpp options.cpp \ path.cpp parameter.cpp parameterizedHeaderField.cpp \ parsedMessageAttachment.cpp plainTextPart.cpp platform.cpp \ propertySet.cpp relay.cpp stringContentHandler.cpp \ streamContentHandler.cpp text.cpp textPartFactory.cpp word.cpp \ wordEncoder.cpp utility_datetimeUtils.cpp \ utility_filteredStream.cpp utility_path.cpp \ utility_progressListener.cpp utility_random.cpp \ utility_smartPtr.cpp utility_smartPtrInt.cpp \ utility_stream.cpp utility_stringProxy.cpp \ utility_stringUtils.cpp utility_url.cpp utility_urlUtils.cpp \ utility_encoder_encoder.cpp \ utility_encoder_sevenBitEncoder.cpp \ utility_encoder_eightBitEncoder.cpp \ utility_encoder_b64Encoder.cpp \ utility_encoder_binaryEncoder.cpp \ utility_encoder_defaultEncoder.cpp \ utility_encoder_encoderFactory.cpp \ utility_encoder_qpEncoder.cpp utility_encoder_uuEncoder.cpp \ mdn_MDNHelper.cpp mdn_MDNInfos.cpp mdn_receivedMDNInfos.cpp \ mdn_sendableMDNInfos.cpp misc_importanceHelper.cpp \ security_defaultAuthenticator.cpp \ security_digest_messageDigest.cpp \ security_digest_messageDigestFactory.cpp \ security_digest_md5_md5MessageDigest.cpp \ security_digest_sha1_sha1MessageDigest.cpp \ net_builtinServices.inl net_defaultConnectionInfos.cpp \ net_events.cpp net_folder.cpp net_message.cpp net_service.cpp \ net_serviceFactory.cpp net_serviceInfos.cpp \ net_serviceRegistration.inl net_session.cpp net_transport.cpp \ net_pop3_POP3ServiceInfos.cpp net_pop3_POP3Store.cpp \ net_pop3_POP3SStore.cpp net_pop3_POP3Folder.cpp \ net_pop3_POP3Message.cpp net_pop3_POP3Utils.cpp \ net_smtp_SMTPResponse.cpp net_smtp_SMTPServiceInfos.cpp \ net_smtp_SMTPTransport.cpp net_smtp_SMTPSTransport.cpp \ net_imap_IMAPServiceInfos.cpp net_imap_IMAPConnection.cpp \ net_imap_IMAPStore.cpp net_imap_IMAPSStore.cpp \ net_imap_IMAPFolder.cpp net_imap_IMAPMessage.cpp \ net_imap_IMAPTag.cpp net_imap_IMAPUtils.cpp \ net_imap_IMAPMessagePartContentHandler.cpp \ net_imap_IMAPStructure.cpp net_imap_IMAPPart.cpp \ net_maildir_maildirServiceInfos.cpp \ net_maildir_maildirStore.cpp net_maildir_maildirFolder.cpp \ net_maildir_maildirMessage.cpp net_maildir_maildirUtils.cpp \ net_maildir_maildirFormat.cpp \ net_maildir_format_kmailMaildirFormat.cpp \ net_maildir_format_courierMaildirFormat.cpp \ net_sendmail_sendmailServiceInfos.cpp \ net_sendmail_sendmailTransport.cpp \ security_sasl_SASLContext.cpp security_sasl_SASLSession.cpp \ security_sasl_SASLMechanismFactory.cpp \ security_sasl_SASLSocket.cpp \ security_sasl_defaultSASLAuthenticator.cpp \ security_sasl_builtinSASLMechanism.cpp net_tls_TLSSession.cpp \ net_tls_TLSSocket.cpp net_tls_TLSSecuredConnectionInfos.cpp \ security_cert_certificateChain.cpp \ security_cert_defaultCertificateVerifier.cpp \ security_cert_X509Certificate.cpp \ platforms_windows_windowsFile.cpp \ platforms_windows_windowsHandler.cpp \ platforms_windows_windowsSocket.cpp \ platforms_posix_posixChildProcess.cpp \ platforms_posix_posixFile.cpp platforms_posix_posixHandler.cpp \ platforms_posix_posixSocket.cpp @VMIME_HAVE_MESSAGING_FEATURES_TRUE@am__objects_1 = net_defaultConnectionInfos.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_events.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_folder.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_message.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_service.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_serviceFactory.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_serviceInfos.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_session.lo \ @VMIME_HAVE_MESSAGING_FEATURES_TRUE@ net_transport.lo @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@am__objects_2 = net_pop3_POP3ServiceInfos.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Store.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3SStore.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Folder.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Message.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE@ net_pop3_POP3Utils.lo @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@am__objects_3 = net_smtp_SMTPResponse.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@ net_smtp_SMTPServiceInfos.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@ net_smtp_SMTPTransport.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE@ net_smtp_SMTPSTransport.lo @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@am__objects_4 = net_imap_IMAPServiceInfos.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPConnection.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPStore.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPSStore.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPFolder.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPMessage.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPTag.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPUtils.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPMessagePartContentHandler.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPStructure.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE@ net_imap_IMAPPart.lo @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@am__objects_5 = net_maildir_maildirServiceInfos.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirStore.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirFolder.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirMessage.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirUtils.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_maildirFormat.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_format_kmailMaildirFormat.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE@ net_maildir_format_courierMaildirFormat.lo @VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE@am__objects_6 = net_sendmail_sendmailServiceInfos.lo \ @VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE@ net_sendmail_sendmailTransport.lo @VMIME_HAVE_SASL_SUPPORT_TRUE@am__objects_7 = \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_SASLContext.lo \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_SASLSession.lo \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_SASLMechanismFactory.lo \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_SASLSocket.lo \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_defaultSASLAuthenticator.lo \ @VMIME_HAVE_SASL_SUPPORT_TRUE@ security_sasl_builtinSASLMechanism.lo @VMIME_HAVE_TLS_SUPPORT_TRUE@am__objects_8 = net_tls_TLSSession.lo \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ net_tls_TLSSocket.lo \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ net_tls_TLSSecuredConnectionInfos.lo \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ security_cert_certificateChain.lo \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ security_cert_defaultCertificateVerifier.lo \ @VMIME_HAVE_TLS_SUPPORT_TRUE@ security_cert_X509Certificate.lo @VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE@am__objects_9 = platforms_windows_windowsFile.lo \ @VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE@ platforms_windows_windowsHandler.lo \ @VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE@ platforms_windows_windowsSocket.lo @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@am__objects_10 = platforms_posix_posixChildProcess.lo \ @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@ platforms_posix_posixFile.lo \ @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@ platforms_posix_posixHandler.lo \ @VMIME_BUILTIN_PLATFORM_POSIX_TRUE@ platforms_posix_posixSocket.lo am_libvmime_la_OBJECTS = address.lo addressList.lo attachmentHelper.lo \ base.lo body.lo bodyPart.lo bodyPartAttachment.lo charset.lo \ charsetConverter.lo component.lo constants.lo \ contentDisposition.lo contentDispositionField.lo \ contentHandler.lo contentTypeField.lo dateTime.lo \ defaultAttachment.lo disposition.lo emptyContentHandler.lo \ encoding.lo exception.lo fileAttachment.lo \ generatedMessageAttachment.lo header.lo headerFieldFactory.lo \ headerField.lo htmlTextPart.lo mailbox.lo mailboxField.lo \ mailboxGroup.lo mailboxList.lo mediaType.lo messageBuilder.lo \ message.lo messageId.lo messageIdSequence.lo messageParser.lo \ object.lo options.lo path.lo parameter.lo \ parameterizedHeaderField.lo parsedMessageAttachment.lo \ plainTextPart.lo platform.lo propertySet.lo relay.lo \ stringContentHandler.lo streamContentHandler.lo text.lo \ textPartFactory.lo word.lo wordEncoder.lo \ utility_datetimeUtils.lo utility_filteredStream.lo \ utility_path.lo utility_progressListener.lo utility_random.lo \ utility_smartPtr.lo utility_smartPtrInt.lo utility_stream.lo \ utility_stringProxy.lo utility_stringUtils.lo utility_url.lo \ utility_urlUtils.lo utility_encoder_encoder.lo \ utility_encoder_sevenBitEncoder.lo \ utility_encoder_eightBitEncoder.lo \ utility_encoder_b64Encoder.lo utility_encoder_binaryEncoder.lo \ utility_encoder_defaultEncoder.lo \ utility_encoder_encoderFactory.lo utility_encoder_qpEncoder.lo \ utility_encoder_uuEncoder.lo mdn_MDNHelper.lo mdn_MDNInfos.lo \ mdn_receivedMDNInfos.lo mdn_sendableMDNInfos.lo \ misc_importanceHelper.lo security_defaultAuthenticator.lo \ security_digest_messageDigest.lo \ security_digest_messageDigestFactory.lo \ security_digest_md5_md5MessageDigest.lo \ security_digest_sha1_sha1MessageDigest.lo $(am__objects_1) \ $(am__objects_2) $(am__objects_3) $(am__objects_4) \ $(am__objects_5) $(am__objects_6) $(am__objects_7) \ $(am__objects_8) $(am__objects_9) $(am__objects_10) libvmime_la_OBJECTS = $(am_libvmime_la_OBJECTS) libvmime_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(libvmime_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libvmime_la_SOURCES) DIST_SOURCES = $(am__libvmime_la_SOURCES_DIST) HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ EXTRA_LIBS = @EXTRA_LIBS@ FGREP = @FGREP@ GENERIC_LIBRARY_NAME = @GENERIC_LIBRARY_NAME@ GENERIC_VERSIONED_LIBRARY_NAME = @GENERIC_VERSIONED_LIBRARY_NAME@ GREP = @GREP@ GSASL_AVAIL_LIBS = @GSASL_AVAIL_LIBS@ GSASL_AVAIL_REQUIRED = @GSASL_AVAIL_REQUIRED@ GSASL_LIBS = @GSASL_LIBS@ GSASL_REQUIRED = @GSASL_REQUIRED@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBRARY_LD_FLAGS = @LIBRARY_LD_FLAGS@ LIBRARY_NAME = @LIBRARY_NAME@ LIBRARY_RELEASE = @LIBRARY_RELEASE@ LIBRARY_VERSION = @LIBRARY_VERSION@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKGCONFIG_CFLAGS = @PKGCONFIG_CFLAGS@ PKGCONFIG_LIBS = @PKGCONFIG_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SENDMAIL = @SENDMAIL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ THREAD_FLAGS = @THREAD_FLAGS@ THREAD_LIBS = @THREAD_LIBS@ VERSION = @VERSION@ VMIME_ADDITIONAL_PC_LIBS = @VMIME_ADDITIONAL_PC_LIBS@ VMIME_PKGCONFIGDIR = @VMIME_PKGCONFIGDIR@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ thrprefix = @thrprefix@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = no-dependencies foreign INTERNALS = INCLUDES = -I$(prefix)/include -I$(top_srcdir) @PKGCONFIG_CFLAGS@ @EXTRA_CFLAGS@ lib_LTLIBRARIES = libvmime.la libvmime_la_LDFLAGS = -export-dynamic -version-info @LIBRARY_VERSION@ @PKGCONFIG_LIBS@ @EXTRA_LIBS@ libvmime_la_SOURCES = address.cpp addressList.cpp attachmentHelper.cpp \ base.cpp body.cpp bodyPart.cpp bodyPartAttachment.cpp \ charset.cpp charsetConverter.cpp component.cpp constants.cpp \ contentDisposition.cpp contentDispositionField.cpp \ contentHandler.cpp contentTypeField.cpp dateTime.cpp \ defaultAttachment.cpp disposition.cpp emptyContentHandler.cpp \ encoding.cpp exception.cpp fileAttachment.cpp \ generatedMessageAttachment.cpp header.cpp \ headerFieldFactory.cpp headerField.cpp htmlTextPart.cpp \ mailbox.cpp mailboxField.cpp mailboxGroup.cpp mailboxList.cpp \ mediaType.cpp messageBuilder.cpp message.cpp messageId.cpp \ messageIdSequence.cpp messageParser.cpp object.cpp options.cpp \ path.cpp parameter.cpp parameterizedHeaderField.cpp \ parsedMessageAttachment.cpp plainTextPart.cpp platform.cpp \ propertySet.cpp relay.cpp stringContentHandler.cpp \ streamContentHandler.cpp text.cpp textPartFactory.cpp word.cpp \ wordEncoder.cpp utility_datetimeUtils.cpp \ utility_filteredStream.cpp utility_path.cpp \ utility_progressListener.cpp utility_random.cpp \ utility_smartPtr.cpp utility_smartPtrInt.cpp \ utility_stream.cpp utility_stringProxy.cpp \ utility_stringUtils.cpp utility_url.cpp utility_urlUtils.cpp \ utility_encoder_encoder.cpp \ utility_encoder_sevenBitEncoder.cpp \ utility_encoder_eightBitEncoder.cpp \ utility_encoder_b64Encoder.cpp \ utility_encoder_binaryEncoder.cpp \ utility_encoder_defaultEncoder.cpp \ utility_encoder_encoderFactory.cpp \ utility_encoder_qpEncoder.cpp utility_encoder_uuEncoder.cpp \ mdn_MDNHelper.cpp mdn_MDNInfos.cpp mdn_receivedMDNInfos.cpp \ mdn_sendableMDNInfos.cpp misc_importanceHelper.cpp \ security_defaultAuthenticator.cpp \ security_digest_messageDigest.cpp \ security_digest_messageDigestFactory.cpp \ security_digest_md5_md5MessageDigest.cpp \ security_digest_sha1_sha1MessageDigest.cpp $(am__append_1) \ $(am__append_2) $(am__append_3) $(am__append_4) \ $(am__append_5) $(am__append_6) $(am__append_7) \ $(am__append_8) $(am__append_9) $(am__append_10) noinst_HEADERS = $(INTERNALS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libvmime.la: $(libvmime_la_OBJECTS) $(libvmime_la_DEPENDENCIES) $(libvmime_la_LINK) -rpath $(libdir) $(libvmime_la_OBJECTS) $(libvmime_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES utility_datetimeUtils.cpp: utility/datetimeUtils.cpp ln -sf $< $@ utility_filteredStream.cpp: utility/filteredStream.cpp ln -sf $< $@ utility_path.cpp: utility/path.cpp ln -sf $< $@ utility_progressListener.cpp: utility/progressListener.cpp ln -sf $< $@ utility_random.cpp: utility/random.cpp ln -sf $< $@ utility_smartPtr.cpp: utility/smartPtr.cpp ln -sf $< $@ utility_smartPtrInt.cpp: utility/smartPtrInt.cpp ln -sf $< $@ utility_stream.cpp: utility/stream.cpp ln -sf $< $@ utility_stringProxy.cpp: utility/stringProxy.cpp ln -sf $< $@ utility_stringUtils.cpp: utility/stringUtils.cpp ln -sf $< $@ utility_url.cpp: utility/url.cpp ln -sf $< $@ utility_urlUtils.cpp: utility/urlUtils.cpp ln -sf $< $@ utility_encoder_encoder.cpp: utility/encoder/encoder.cpp ln -sf $< $@ utility_encoder_sevenBitEncoder.cpp: utility/encoder/sevenBitEncoder.cpp ln -sf $< $@ utility_encoder_eightBitEncoder.cpp: utility/encoder/eightBitEncoder.cpp ln -sf $< $@ utility_encoder_b64Encoder.cpp: utility/encoder/b64Encoder.cpp ln -sf $< $@ utility_encoder_binaryEncoder.cpp: utility/encoder/binaryEncoder.cpp ln -sf $< $@ utility_encoder_defaultEncoder.cpp: utility/encoder/defaultEncoder.cpp ln -sf $< $@ utility_encoder_encoderFactory.cpp: utility/encoder/encoderFactory.cpp ln -sf $< $@ utility_encoder_qpEncoder.cpp: utility/encoder/qpEncoder.cpp ln -sf $< $@ utility_encoder_uuEncoder.cpp: utility/encoder/uuEncoder.cpp ln -sf $< $@ mdn_MDNHelper.cpp: mdn/MDNHelper.cpp ln -sf $< $@ mdn_MDNInfos.cpp: mdn/MDNInfos.cpp ln -sf $< $@ mdn_receivedMDNInfos.cpp: mdn/receivedMDNInfos.cpp ln -sf $< $@ mdn_sendableMDNInfos.cpp: mdn/sendableMDNInfos.cpp ln -sf $< $@ misc_importanceHelper.cpp: misc/importanceHelper.cpp ln -sf $< $@ security_defaultAuthenticator.cpp: security/defaultAuthenticator.cpp ln -sf $< $@ security_digest_messageDigest.cpp: security/digest/messageDigest.cpp ln -sf $< $@ security_digest_messageDigestFactory.cpp: security/digest/messageDigestFactory.cpp ln -sf $< $@ security_digest_md5_md5MessageDigest.cpp: security/digest/md5/md5MessageDigest.cpp ln -sf $< $@ security_digest_sha1_sha1MessageDigest.cpp: security/digest/sha1/sha1MessageDigest.cpp ln -sf $< $@ net_builtinServices.inl: net/builtinServices.inl ln -sf $< $@ net_defaultConnectionInfos.cpp: net/defaultConnectionInfos.cpp ln -sf $< $@ net_events.cpp: net/events.cpp ln -sf $< $@ net_folder.cpp: net/folder.cpp ln -sf $< $@ net_message.cpp: net/message.cpp ln -sf $< $@ net_service.cpp: net/service.cpp ln -sf $< $@ net_serviceFactory.cpp: net/serviceFactory.cpp ln -sf $< $@ net_serviceInfos.cpp: net/serviceInfos.cpp ln -sf $< $@ net_serviceRegistration.inl: net/serviceRegistration.inl ln -sf $< $@ net_session.cpp: net/session.cpp ln -sf $< $@ net_transport.cpp: net/transport.cpp ln -sf $< $@ net_pop3_POP3ServiceInfos.cpp: net/pop3/POP3ServiceInfos.cpp ln -sf $< $@ net_pop3_POP3Store.cpp: net/pop3/POP3Store.cpp ln -sf $< $@ net_pop3_POP3SStore.cpp: net/pop3/POP3SStore.cpp ln -sf $< $@ net_pop3_POP3Folder.cpp: net/pop3/POP3Folder.cpp ln -sf $< $@ net_pop3_POP3Message.cpp: net/pop3/POP3Message.cpp ln -sf $< $@ net_pop3_POP3Utils.cpp: net/pop3/POP3Utils.cpp ln -sf $< $@ net_smtp_SMTPResponse.cpp: net/smtp/SMTPResponse.cpp ln -sf $< $@ net_smtp_SMTPServiceInfos.cpp: net/smtp/SMTPServiceInfos.cpp ln -sf $< $@ net_smtp_SMTPTransport.cpp: net/smtp/SMTPTransport.cpp ln -sf $< $@ net_smtp_SMTPSTransport.cpp: net/smtp/SMTPSTransport.cpp ln -sf $< $@ net_imap_IMAPServiceInfos.cpp: net/imap/IMAPServiceInfos.cpp ln -sf $< $@ net_imap_IMAPConnection.cpp: net/imap/IMAPConnection.cpp ln -sf $< $@ net_imap_IMAPStore.cpp: net/imap/IMAPStore.cpp ln -sf $< $@ net_imap_IMAPSStore.cpp: net/imap/IMAPSStore.cpp ln -sf $< $@ net_imap_IMAPFolder.cpp: net/imap/IMAPFolder.cpp ln -sf $< $@ net_imap_IMAPMessage.cpp: net/imap/IMAPMessage.cpp ln -sf $< $@ net_imap_IMAPTag.cpp: net/imap/IMAPTag.cpp ln -sf $< $@ net_imap_IMAPUtils.cpp: net/imap/IMAPUtils.cpp ln -sf $< $@ net_imap_IMAPMessagePartContentHandler.cpp: net/imap/IMAPMessagePartContentHandler.cpp ln -sf $< $@ net_imap_IMAPStructure.cpp: net/imap/IMAPStructure.cpp ln -sf $< $@ net_imap_IMAPPart.cpp: net/imap/IMAPPart.cpp ln -sf $< $@ net_maildir_maildirServiceInfos.cpp: net/maildir/maildirServiceInfos.cpp ln -sf $< $@ net_maildir_maildirStore.cpp: net/maildir/maildirStore.cpp ln -sf $< $@ net_maildir_maildirFolder.cpp: net/maildir/maildirFolder.cpp ln -sf $< $@ net_maildir_maildirMessage.cpp: net/maildir/maildirMessage.cpp ln -sf $< $@ net_maildir_maildirUtils.cpp: net/maildir/maildirUtils.cpp ln -sf $< $@ net_maildir_maildirFormat.cpp: net/maildir/maildirFormat.cpp ln -sf $< $@ net_maildir_format_kmailMaildirFormat.cpp: net/maildir/format/kmailMaildirFormat.cpp ln -sf $< $@ net_maildir_format_courierMaildirFormat.cpp: net/maildir/format/courierMaildirFormat.cpp ln -sf $< $@ net_sendmail_sendmailServiceInfos.cpp: net/sendmail/sendmailServiceInfos.cpp ln -sf $< $@ net_sendmail_sendmailTransport.cpp: net/sendmail/sendmailTransport.cpp ln -sf $< $@ security_sasl_SASLContext.cpp: security/sasl/SASLContext.cpp ln -sf $< $@ security_sasl_SASLSession.cpp: security/sasl/SASLSession.cpp ln -sf $< $@ security_sasl_SASLMechanismFactory.cpp: security/sasl/SASLMechanismFactory.cpp ln -sf $< $@ security_sasl_SASLSocket.cpp: security/sasl/SASLSocket.cpp ln -sf $< $@ security_sasl_defaultSASLAuthenticator.cpp: security/sasl/defaultSASLAuthenticator.cpp ln -sf $< $@ security_sasl_builtinSASLMechanism.cpp: security/sasl/builtinSASLMechanism.cpp ln -sf $< $@ net_tls_TLSSession.cpp: net/tls/TLSSession.cpp ln -sf $< $@ net_tls_TLSSocket.cpp: net/tls/TLSSocket.cpp ln -sf $< $@ net_tls_TLSSecuredConnectionInfos.cpp: net/tls/TLSSecuredConnectionInfos.cpp ln -sf $< $@ security_cert_certificateChain.cpp: security/cert/certificateChain.cpp ln -sf $< $@ security_cert_defaultCertificateVerifier.cpp: security/cert/defaultCertificateVerifier.cpp ln -sf $< $@ security_cert_X509Certificate.cpp: security/cert/X509Certificate.cpp ln -sf $< $@ platforms_windows_windowsFile.cpp: platforms/windows/windowsFile.cpp ln -sf $< $@ platforms_windows_windowsHandler.cpp: platforms/windows/windowsHandler.cpp ln -sf $< $@ platforms_windows_windowsSocket.cpp: platforms/windows/windowsSocket.cpp ln -sf $< $@ platforms_posix_posixChildProcess.cpp: platforms/posix/posixChildProcess.cpp ln -sf $< $@ platforms_posix_posixFile.cpp: platforms/posix/posixFile.cpp ln -sf $< $@ platforms_posix_posixHandler.cpp: platforms/posix/posixHandler.cpp ln -sf $< $@ platforms_posix_posixSocket.cpp: platforms/posix/posixSocket.cpp ln -sf $< $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libvmime-0.9.1/src/relay.cpp0000644000175000017500000001646411250723263016252 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/relay.hpp" #include "vmime/text.hpp" #include "vmime/parserHelpers.hpp" #include namespace vmime { relay::relay() { } relay::relay(const relay& r) : headerFieldValue() { copyFrom(r); } /* RFC #2822: received = "Received" ":" ; one per relay ["from" domain] ; sending host ["by" domain] ; receiving host ["via" atom] ; physical path *("with" atom) ; link/mail protocol ["id" msg-id] ; receiver msg id ["for" addr-spec] ; initial form */ void relay::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { const string::value_type* const pend = buffer.data() + end; const string::value_type* const pstart = buffer.data() + position; const string::value_type* p = pend - 1; // Find the beginning of the date part while (p >= pstart && *p != ';') --p; if (p >= pstart) { // Parse the date/time part m_date.parse(buffer, position + (p - pstart) + 1, end); // Parse the components std::istringstream iss(string (buffer.begin() + position, buffer.begin() + position + (p - pstart))); string word; std::vector previous; enum Parts { Part_None, Part_From, // The "from" part Part_By, // The "by" part Part_Via, // The "via" part Part_With, // One "with" part Part_Id, // The "id" part Part_For, // The "for" part Part_End }; Parts part = Part_None; bool cont = true; bool inComment = false; while (cont) { Parts newPart = Part_None; if ((cont = ((iss >> word) != 0))) { // A little hack for handling comments if (inComment) { string::size_type par = word.find(')'); if (par != string::npos) { previous.push_back(string(word.begin(), word.begin() + par + 1)); word.erase(word.begin(), word.begin() + par + 1); inComment = false; } } bool keyword = false; if (!inComment) { if (utility::stringUtils::isStringEqualNoCase(word, "from", 4)) { newPart = Part_From; keyword = true; } else if (utility::stringUtils::isStringEqualNoCase(word, "by", 2)) { newPart = Part_By; keyword = true; } else if (utility::stringUtils::isStringEqualNoCase(word, "via", 2)) { newPart = Part_Via; keyword = true; } else if (utility::stringUtils::isStringEqualNoCase(word, "with", 2)) { newPart = Part_With; keyword = true; } else if (utility::stringUtils::isStringEqualNoCase(word, "id", 2)) { newPart = Part_Id; keyword = true; } else if (utility::stringUtils::isStringEqualNoCase(word, "for", 2)) { newPart = Part_For; keyword = true; } } if (!keyword) { if (word.find('(') != string::npos) inComment = true; previous.push_back(word); } } if (!cont || newPart != Part_None) { if (part != Part_None) { std::ostringstream value; for (std::vector ::const_iterator it = previous.begin() ; it != previous.end() ; ++it) { if (it != previous.begin()) value << " "; value << *it; } switch (part) { case Part_From: m_from = value.str(); break; case Part_By: m_by = value.str(); break; case Part_Via: m_via = value.str(); break; case Part_With: m_with.push_back(value.str()); break; case Part_Id: m_id = value.str(); break; case Part_For: m_for = value.str(); break; default: break; // Should never happen... } } previous.clear(); part = newPart; } } } setParsedBounds(position, end); if (newPosition) *newPosition = end; } void relay::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { std::ostringstream oss; int count = 0; if (m_from.length()) oss << (count++ > 0 ? " " : "") << "from " << m_from; if (m_by.length()) oss << (count++ > 0 ? " " : "") << "by " << m_by; if (m_via.length()) oss << (count++ > 0 ? " " : "") << "via " << m_via; for (std::vector ::const_iterator it = m_with.begin() ; it != m_with.end() ; ++it) { oss << (count++ > 0 ? " " : "") << "with " << *it; } if (m_id.length()) oss << (count++ > 0 ? " " : "") << "id " << m_id; if (m_for.length()) oss << (count++ > 0 ? " " : "") << "for " << m_for; oss << "; " << m_date.generate(); text(oss.str()).encodeAndFold(os, maxLineLength, curLinePos, newLinePos, text::FORCE_NO_ENCODING); } void relay::copyFrom(const component& other) { const relay& r = dynamic_cast (other); m_from = r.m_from; m_via = r.m_via; m_by = r.m_by; m_id = r.m_id; m_for = r.m_for; m_with.resize(r.m_with.size()); std::copy(r.m_with.begin(), r.m_with.end(), m_with.begin()); m_date = r.m_date; } relay& relay::operator=(const relay& other) { copyFrom(other); return (*this); } ref relay::clone() const { return vmime::create (*this); } const string& relay::getFrom() const { return (m_from); } void relay::setFrom(const string& from) { m_from = from; } const string& relay::getVia() const { return (m_via); } void relay::setVia(const string& via) { m_via = via; } const string& relay::getBy() const { return (m_by); } void relay::setBy(const string& by) { m_by = by; } const string& relay::getId() const { return (m_id); } void relay::setId(const string& id) { m_id = id; } const string& relay::getFor() const { return (m_for); } void relay::setFor(const string& for_) { m_for = for_; } const datetime& relay::getDate() const { return (m_date); } void relay::setDate(const datetime& date) { m_date = date; } const std::vector & relay::getWithList() const { return (m_with); } std::vector & relay::getWithList() { return (m_with); } const std::vector > relay::getChildComponents() const { // TODO: should fields inherit from 'component'? (using typeAdapter) return std::vector >(); } } // vmime libvmime-0.9.1/src/messageBuilder.cpp0000644000175000017500000001665711314151075020072 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/messageBuilder.hpp" #include "vmime/dateTime.hpp" #include "vmime/textPartFactory.hpp" namespace vmime { messageBuilder::messageBuilder() { // By default there is one text part of type "text/plain" constructTextPart(mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN)); } messageBuilder::~messageBuilder() { } ref messageBuilder::construct() const { // Create a new message ref msg = vmime::create (); // Generate the header fields msg->getHeader()->Subject()->setValue(m_subject); if (m_from.isEmpty()) throw exceptions::no_expeditor(); if ((m_to.isEmpty() || m_to.getAddressAt(0)->isEmpty()) && (m_cc.isEmpty() || m_cc.getAddressAt(0)->isEmpty()) && (m_bcc.isEmpty() || m_bcc.getAddressAt(0)->isEmpty())) { throw exceptions::no_recipient(); } msg->getHeader()->From()->setValue(m_from); if (!m_to.isEmpty()) msg->getHeader()->To()->setValue(m_to); if (!m_cc.isEmpty()) msg->getHeader()->Cc()->setValue(m_cc); if (!m_bcc.isEmpty()) msg->getHeader()->Bcc()->setValue(m_bcc); // Add a "Date" field msg->getHeader()->Date()->setValue(datetime::now()); // Add a "Mime-Version" header field msg->getHeader()->MimeVersion()->setValue(string(SUPPORTED_MIME_VERSION)); // If there is one or more attachments (or other parts that are // not "text/...") and if there is more than one parts for the // text part, we generate these text parts into a sub-part: // // [message] // | // +-- multipart/mixed // | // +-- multipart/alternative // | | // | +-- text part #1 (eg. plain text "text/plain") // | +-- text part #2 (eg. HTML "text/html") // | +-- ... // | // +-- application/octet-stream (attachment #1) // | // +-- ... (other attachments/parts) // if (!m_attach.empty() && m_textPart->getPartCount() > 1) { // Set parent part (message) to "multipart/mixed" msg->getHeader()->ContentType()->setValue (mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED)); // Create a sub-part "multipart/alternative" for text parts ref subPart = vmime::create (); msg->getBody()->appendPart(subPart); subPart->getHeader()->ContentType()->setValue (mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_ALTERNATIVE)); // Generate the text parts into this sub-part (normally, this // sub-part will have the "multipart/alternative" content-type...) m_textPart->generateIn(msg, subPart); } else { // Generate the text part(s) directly into the message m_textPart->generateIn(msg, msg); // If any attachment, set message content-type to "multipart/mixed" if (!m_attach.empty()) { msg->getHeader()->ContentType()->setValue (mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED)); } // Else, set it to "multipart/alternative" if there are more than one text part. else if (m_textPart->getPartCount() > 1) { msg->getHeader()->ContentType()->setValue (mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_ALTERNATIVE)); } } // Generate the attachments if (!m_attach.empty()) { for (std::vector >::const_iterator a = m_attach.begin() ; a != m_attach.end() ; ++a) { (*a)->generateIn(msg); } } // If there is only one part in the message, move it into the message // (hence, the message will not be multipart...) if (msg->getBody()->getPartCount() == 1) { const bodyPart& part = *msg->getBody()->getPartAt(0); // Make a full copy of the body, otherwise the copyFrom() will delete the body we're copying ref bodyCopy = part.getBody()->clone().dynamicCast (); // First, copy (and replace) the header fields const std::vector > fields = part.getHeader()->getFieldList(); for (std::vector >::const_iterator it = fields.begin() ; it != fields.end() ; ++it) { *(msg->getHeader()->getField((*it)->getName())) = **it; } // Second, copy the body contents and sub-parts (this also remove // the body part we are copying...) msg->getBody()->copyFrom(*bodyCopy); } return (msg); } void messageBuilder::attach(ref attach) { appendAttachment(attach); } void messageBuilder::appendAttachment(ref attach) { m_attach.push_back(attach); } void messageBuilder::constructTextPart(const mediaType& type) { ref part = NULL; try { part = textPartFactory::getInstance()->create(type); } catch (exceptions::no_factory_available& e) { throw; } m_textPart = part; } ref messageBuilder::getTextPart() { return (m_textPart); } const mailbox& messageBuilder::getExpeditor() const { return (m_from); } void messageBuilder::setExpeditor(const mailbox& expeditor) { m_from = expeditor; } const addressList& messageBuilder::getRecipients() const { return (m_to); } addressList& messageBuilder::getRecipients() { return (m_to); } void messageBuilder::setRecipients(const addressList& recipients) { m_to = recipients; } const addressList& messageBuilder::getCopyRecipients() const { return (m_cc); } addressList& messageBuilder::getCopyRecipients() { return (m_cc); } void messageBuilder::setCopyRecipients(const addressList& cc) { m_cc = cc; } const addressList& messageBuilder::getBlindCopyRecipients() const { return (m_bcc); } addressList& messageBuilder::getBlindCopyRecipients() { return (m_bcc); } void messageBuilder::setBlindCopyRecipients(const addressList& bcc) { m_bcc = bcc; } const text& messageBuilder::getSubject() const { return (m_subject); } void messageBuilder::setSubject(const text& subject) { m_subject = subject; } void messageBuilder::removeAttachment(const int pos) { m_attach.erase(m_attach.begin() + pos); } const ref messageBuilder::getAttachmentAt(const int pos) const { return (m_attach[pos]); } ref messageBuilder::getAttachmentAt(const int pos) { return (m_attach[pos]); } int messageBuilder::getAttachmentCount() const { return (m_attach.size()); } const std::vector > messageBuilder::getAttachmentList() const { std::vector > res; res.reserve(m_attach.size()); for (std::vector >::const_iterator it = m_attach.begin() ; it != m_attach.end() ; ++it) { res.push_back(*it); } return (res); } const std::vector > messageBuilder::getAttachmentList() { return (m_attach); } } // vmime libvmime-0.9.1/src/security/0000755000175000017500000000000011607302336016266 5ustar mnordstrmnordstrlibvmime-0.9.1/src/security/cert/0000755000175000017500000000000011607302336017223 5ustar mnordstrmnordstrlibvmime-0.9.1/src/security/cert/X509Certificate.cpp0000644000175000017500000001261011250723263022537 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include #include "vmime/security/cert/X509Certificate.hpp" namespace vmime { namespace security { namespace cert { #ifndef VMIME_BUILDING_DOC struct X509CertificateInternalData { X509CertificateInternalData() { gnutls_x509_crt_init(&cert); } ~X509CertificateInternalData() { gnutls_x509_crt_deinit(cert); } gnutls_x509_crt cert; }; #endif // VMIME_BUILDING_DOC X509Certificate::X509Certificate() : m_data(new X509CertificateInternalData) { } X509Certificate::X509Certificate(const X509Certificate&) : certificate(), m_data(NULL) { // Not used } X509Certificate::~X509Certificate() { delete m_data; } // static ref X509Certificate::import(utility::inputStream& is) { byteArray bytes; utility::stream::value_type chunk[4096]; while (!is.eof()) { const int len = is.read(chunk, sizeof(chunk)); bytes.insert(bytes.end(), chunk, chunk + len); } return import(&bytes[0], bytes.size()); } // static ref X509Certificate::import (const byte_t* data, const unsigned int length) { gnutls_datum buffer; buffer.data = const_cast (data); buffer.size = length; // Try DER format ref derCert = vmime::create (); if (gnutls_x509_crt_import(derCert->m_data->cert, &buffer, GNUTLS_X509_FMT_DER) >= 0) return derCert; // Try PEM format ref pemCert = vmime::create (); if (gnutls_x509_crt_import(pemCert->m_data->cert, &buffer, GNUTLS_X509_FMT_PEM) >= 0) return pemCert; return NULL; } void X509Certificate::write (utility::outputStream& os, const Format format) const { size_t dataSize = 0; gnutls_x509_crt_fmt fmt = GNUTLS_X509_FMT_DER; switch (format) { case FORMAT_DER: fmt = GNUTLS_X509_FMT_DER; break; case FORMAT_PEM: fmt = GNUTLS_X509_FMT_PEM; break; } gnutls_x509_crt_export(m_data->cert, fmt, NULL, &dataSize); std::vector data(dataSize); gnutls_x509_crt_export(m_data->cert, fmt, &data[0], &dataSize); os.write(reinterpret_cast (&data[0]), dataSize); } const byteArray X509Certificate::getSerialNumber() const { char serial[64]; size_t serialSize = sizeof(serial); gnutls_x509_crt_get_serial(m_data->cert, serial, &serialSize); return byteArray(serial, serial + serialSize); } bool X509Certificate::checkIssuer(ref issuer) const { return (gnutls_x509_crt_check_issuer (m_data->cert, issuer->m_data->cert) >= 1); } bool X509Certificate::verify(ref caCert) const { unsigned int verify = 0; const int res = gnutls_x509_crt_verify (m_data->cert, &(caCert->m_data->cert), 1, GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT, &verify); return (res == 0 && verify == 0); } const datetime X509Certificate::getActivationDate() const { const time_t t = gnutls_x509_crt_get_activation_time(m_data->cert); return datetime(t); } const datetime X509Certificate::getExpirationDate() const { const time_t t = gnutls_x509_crt_get_expiration_time(m_data->cert); return datetime(t); } const byteArray X509Certificate::getFingerprint(const DigestAlgorithm algo) const { gnutls_digest_algorithm galgo; switch (algo) { case DIGEST_MD5: galgo = GNUTLS_DIG_MD5; break; default: case DIGEST_SHA1: galgo = GNUTLS_DIG_SHA; break; } size_t bufferSize = 0; gnutls_x509_crt_get_fingerprint (m_data->cert, galgo, NULL, &bufferSize); std::vector buffer(bufferSize); if (gnutls_x509_crt_get_fingerprint (m_data->cert, galgo, &buffer[0], &bufferSize) == 0) { byteArray res; res.insert(res.end(), &buffer[0], &buffer[0] + bufferSize); return res; } return byteArray(); } const byteArray X509Certificate::getEncoded() const { byteArray bytes; utility::outputStreamByteArrayAdapter os(bytes); write(os, FORMAT_DER); return bytes; } const string X509Certificate::getType() const { return "X.509"; } int X509Certificate::getVersion() const { return gnutls_x509_crt_get_version(m_data->cert); } bool X509Certificate::equals(ref other) const { ref otherX509 = other.dynamicCast (); if (!otherX509) return false; const byteArray fp1 = getFingerprint(DIGEST_MD5); const byteArray fp2 = otherX509->getFingerprint(DIGEST_MD5); return fp1 == fp2; } } // cert } // security } // vmime libvmime-0.9.1/src/security/cert/defaultCertificateVerifier.cpp0000644000175000017500000001034711250723263025217 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/security/cert/defaultCertificateVerifier.hpp" #include "vmime/security/cert/X509Certificate.hpp" #include "vmime/exception.hpp" namespace vmime { namespace security { namespace cert { defaultCertificateVerifier::defaultCertificateVerifier() { } defaultCertificateVerifier::~defaultCertificateVerifier() { } defaultCertificateVerifier::defaultCertificateVerifier(const defaultCertificateVerifier&) : certificateVerifier() { // Not used } void defaultCertificateVerifier::verify(ref chain) { if (chain->getCount() == 0) return; const string type = chain->getAt(0)->getType(); if (type == "X.509") verifyX509(chain); else throw exceptions::unsupported_certificate_type(type); } void defaultCertificateVerifier::verifyX509(ref chain) { // For every certificate in the chain, verify that the certificate // has been issued by the next certificate in the chain if (chain->getCount() >= 2) { for (unsigned int i = 0 ; i < chain->getCount() - 1 ; ++i) { ref cert = chain->getAt(i).dynamicCast (); ref next = chain->getAt(i + 1).dynamicCast (); if (!cert->checkIssuer(next)) { throw exceptions::certificate_verification_exception ("Subject/issuer verification failed."); } } } // For every certificate in the chain, verify that the certificate // is valid at the current time const datetime now = datetime::now(); for (unsigned int i = 0 ; i < chain->getCount() ; ++i) { ref cert = chain->getAt(i).dynamicCast (); const datetime begin = cert->getActivationDate(); const datetime end = cert->getExpirationDate(); if (now < begin || now > end) { throw exceptions::certificate_verification_exception ("Validity date check failed."); } } // Check whether the certificate can be trusted // -- First, verify that the the last certificate in the chain was // -- issued by a third-party that we trust ref lastCert = chain->getAt(chain->getCount() - 1).dynamicCast (); bool trusted = false; for (unsigned int i = 0 ; !trusted && i < m_x509RootCAs.size() ; ++i) { ref rootCa = m_x509RootCAs[i]; if (lastCert->verify(rootCa)) trusted = true; } // -- Next, if the issuer certificate cannot be verified against // -- root CAs, compare the subject's certificate against the // -- trusted certificates ref firstCert = chain->getAt(0).dynamicCast (); for (unsigned int i = 0 ; !trusted && i < m_x509TrustedCerts.size() ; ++i) { ref cert = m_x509TrustedCerts[i]; if (firstCert->equals(cert)) trusted = true; } if (!trusted) { throw exceptions::certificate_verification_exception ("Cannot verify certificate against trusted certificates."); } } void defaultCertificateVerifier::setX509RootCAs (const std::vector >& caCerts) { m_x509RootCAs = caCerts; } void defaultCertificateVerifier::setX509TrustedCerts (const std::vector >& trustedCerts) { m_x509TrustedCerts = trustedCerts; } } // cert } // security } // vmime libvmime-0.9.1/src/security/cert/certificateChain.cpp0000644000175000017500000000275711250723263023167 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/security/cert/certificateChain.hpp" namespace vmime { namespace security { namespace cert { certificateChain::certificateChain(const std::vector >& certs) : m_certs(certs) { } unsigned int certificateChain::getCount() const { return static_cast (m_certs.size()); } ref certificateChain::getAt(const unsigned int index) { return m_certs[index]; } } // cert } // security } // vmime libvmime-0.9.1/src/security/sasl/0000755000175000017500000000000011607302336017230 5ustar mnordstrmnordstrlibvmime-0.9.1/src/security/sasl/SASLMechanismFactory.cpp0000644000175000017500000000614011250723263023654 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include #include "vmime/security/sasl/SASLMechanismFactory.hpp" #include "vmime/security/sasl/builtinSASLMechanism.hpp" #include "vmime/security/sasl/SASLContext.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/base.hpp" #include "vmime/exception.hpp" namespace vmime { namespace security { namespace sasl { SASLMechanismFactory::SASLMechanismFactory() { if (gsasl_init(&m_gsaslContext) != GSASL_OK) throw std::bad_alloc(); } SASLMechanismFactory::~SASLMechanismFactory() { gsasl_done(m_gsaslContext); } // static SASLMechanismFactory* SASLMechanismFactory::getInstance() { static SASLMechanismFactory instance; return &instance; } ref SASLMechanismFactory::create (ref ctx, const string& name_) { const string name(utility::stringUtils::toUpper(name_)); // Check for built-in mechanisms if (isMechanismSupported(name)) { return vmime::create (ctx, name); } // Check for registered mechanisms else { MapType::iterator it = m_mechs.find(name); if (it != m_mechs.end()) return (*it).second->create(ctx, name); } throw exceptions::no_such_mechanism(name); return 0; } const std::vector SASLMechanismFactory::getSupportedMechanisms() const { std::vector list; // Registered mechanisms for (MapType::const_iterator it = m_mechs.begin() ; it != m_mechs.end() ; ++it) { list.push_back((*it).first); } // Built-in mechanisms char* out = 0; if (gsasl_client_mechlist(m_gsaslContext, &out) == GSASL_OK) { // 'out' contains SASL mechanism names, separated by spaces for (char *start = out, *p = out ; ; ++p) { if (*p == ' ' || !*p) { list.push_back(string(start, p)); start = p + 1; // End of string if (!*p) break; } } gsasl_free(out); } return list; } bool SASLMechanismFactory::isMechanismSupported(const string& name) const { return (gsasl_client_support_p(m_gsaslContext, name.c_str()) != 0 || m_mechs.find(name) != m_mechs.end()); } } // sasl } // security } // vmime libvmime-0.9.1/src/security/sasl/SASLSession.cpp0000644000175000017500000000763511250723263022055 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include "vmime/security/sasl/SASLSession.hpp" #include "vmime/security/sasl/SASLContext.hpp" #include "vmime/security/sasl/SASLSocket.hpp" #include "vmime/security/sasl/SASLAuthenticator.hpp" namespace vmime { namespace security { namespace sasl { SASLSession::SASLSession(const string& serviceName, ref ctx, ref auth, ref mech) : m_serviceName(serviceName), m_context(ctx), m_auth(auth), m_mech(mech), m_gsaslContext(0), m_gsaslSession(0) { if (gsasl_init(&m_gsaslContext) != GSASL_OK) throw std::bad_alloc(); gsasl_client_start(m_gsaslContext, mech->getName().c_str(), &m_gsaslSession); gsasl_callback_set(m_gsaslContext, gsaslCallback); gsasl_callback_hook_set(m_gsaslContext, this); } SASLSession::~SASLSession() { gsasl_finish(m_gsaslSession); m_gsaslSession = 0; gsasl_done(m_gsaslContext); m_gsaslContext = 0; } void SASLSession::init() { ref saslAuth = m_auth.dynamicCast (); if (saslAuth) { saslAuth->setSASLMechanism(m_mech); saslAuth->setSASLSession(thisRef().dynamicCast ()); } } ref SASLSession::getAuthenticator() { return m_auth; } ref SASLSession::getMechanism() { return m_mech; } ref SASLSession::getContext() { return m_context; } bool SASLSession::evaluateChallenge (const byte_t* challenge, const int challengeLen, byte_t** response, int* responseLen) { return m_mech->step(thisRef().dynamicCast (), challenge, challengeLen, response, responseLen); } ref SASLSession::getSecuredSocket(ref sok) { return vmime::create (thisRef().dynamicCast (), sok); } const string SASLSession::getServiceName() const { return m_serviceName; } // static int SASLSession::gsaslCallback (Gsasl* ctx, Gsasl_session* sctx, Gsasl_property prop) { SASLSession* sess = reinterpret_cast (gsasl_callback_hook_get(ctx)); if (!sess) return GSASL_AUTHENTICATION_ERROR; ref auth = sess->getAuthenticator(); try { string res; switch (prop) { case GSASL_AUTHID: res = auth->getUsername(); break; case GSASL_PASSWORD: res = auth->getPassword(); break; case GSASL_ANONYMOUS_TOKEN: res = auth->getAnonymousToken(); break; case GSASL_HOSTNAME: res = auth->getHostname(); break; case GSASL_SERVICE: res = auth->getServiceName(); break; case GSASL_AUTHZID: case GSASL_GSSAPI_DISPLAY_NAME: case GSASL_PASSCODE: case GSASL_SUGGESTED_PIN: case GSASL_PIN: case GSASL_REALM: default: return GSASL_NO_CALLBACK; } gsasl_property_set(sctx, prop, res.c_str()); return GSASL_OK; } //catch (exceptions::no_auth_information&) catch (...) { return GSASL_NO_CALLBACK; } } } // sasl } // security } // vmime libvmime-0.9.1/src/security/sasl/SASLContext.cpp0000644000175000017500000001121411250723263022042 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include "vmime/security/sasl/SASLContext.hpp" #include "vmime/security/sasl/SASLMechanism.hpp" #include "vmime/base.hpp" #include "vmime/utility/encoder/encoderFactory.hpp" #include "vmime/utility/stream.hpp" namespace vmime { namespace security { namespace sasl { SASLContext::SASLContext() { if (gsasl_init(&m_gsaslContext) != GSASL_OK) throw std::bad_alloc(); } SASLContext::~SASLContext() { gsasl_done(m_gsaslContext); } ref SASLContext::createSession (const string& serviceName, ref auth, ref mech) { return vmime::create (serviceName, thisRef().dynamicCast (), auth, mech); } ref SASLContext::createMechanism(const string& name) { return SASLMechanismFactory::getInstance()->create (thisRef().dynamicCast (), name); } ref SASLContext::suggestMechanism (const std::vector >& mechs) { if (mechs.empty()) return 0; std::ostringstream oss; for (unsigned int i = 0 ; i < mechs.size() ; ++i) oss << mechs[i]->getName() << " "; const string mechList = oss.str(); const char* suggested = gsasl_client_suggest_mechanism (m_gsaslContext, mechList.c_str()); if (suggested) { for (unsigned int i = 0 ; i < mechs.size() ; ++i) { if (mechs[i]->getName() == suggested) return mechs[i]; } } return 0; } void SASLContext::decodeB64(const string& input, byte_t** output, int* outputLen) { string res; utility::inputStreamStringAdapter is(input); utility::outputStreamStringAdapter os(res); ref dec = utility::encoder::encoderFactory::getInstance()->create("base64"); dec->decode(is, os); byte_t* out = new byte_t[res.length()]; std::copy(res.begin(), res.end(), out); *output = out; *outputLen = res.length(); } const string SASLContext::encodeB64(const byte_t* input, const int inputLen) { string res; utility::inputStreamByteBufferAdapter is(input, inputLen); utility::outputStreamStringAdapter os(res); ref enc = utility::encoder::encoderFactory::getInstance()->create("base64"); enc->encode(is, os); return res; } const string SASLContext::getErrorMessage(const string& fname, const int code) { string msg = fname + "() returned "; #define ERROR(x) \ case x: msg += #x; break; switch (code) { ERROR(GSASL_NEEDS_MORE) ERROR(GSASL_UNKNOWN_MECHANISM) ERROR(GSASL_MECHANISM_CALLED_TOO_MANY_TIMES) ERROR(GSASL_MALLOC_ERROR) ERROR(GSASL_BASE64_ERROR) ERROR(GSASL_CRYPTO_ERROR) ERROR(GSASL_SASLPREP_ERROR) ERROR(GSASL_MECHANISM_PARSE_ERROR) ERROR(GSASL_AUTHENTICATION_ERROR) ERROR(GSASL_INTEGRITY_ERROR) ERROR(GSASL_NO_CLIENT_CODE) ERROR(GSASL_NO_SERVER_CODE) ERROR(GSASL_NO_CALLBACK) ERROR(GSASL_NO_ANONYMOUS_TOKEN) ERROR(GSASL_NO_AUTHID) ERROR(GSASL_NO_AUTHZID) ERROR(GSASL_NO_PASSWORD) ERROR(GSASL_NO_PASSCODE) ERROR(GSASL_NO_PIN) ERROR(GSASL_NO_SERVICE) ERROR(GSASL_NO_HOSTNAME) ERROR(GSASL_GSSAPI_RELEASE_BUFFER_ERROR) ERROR(GSASL_GSSAPI_IMPORT_NAME_ERROR) ERROR(GSASL_GSSAPI_INIT_SEC_CONTEXT_ERROR) ERROR(GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERROR) ERROR(GSASL_GSSAPI_UNWRAP_ERROR) ERROR(GSASL_GSSAPI_WRAP_ERROR) ERROR(GSASL_GSSAPI_ACQUIRE_CRED_ERROR) ERROR(GSASL_GSSAPI_DISPLAY_NAME_ERROR) ERROR(GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERROR) ERROR(GSASL_KERBEROS_V5_INIT_ERROR) ERROR(GSASL_KERBEROS_V5_INTERNAL_ERROR) ERROR(GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE) ERROR(GSASL_SECURID_SERVER_NEED_NEW_PIN) default: msg += "unknown error"; break; } #undef ERROR return msg; } } // sasl } // security } // vmime libvmime-0.9.1/src/security/sasl/defaultSASLAuthenticator.cpp0000644000175000017500000000606111374031010024566 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/security/sasl/defaultSASLAuthenticator.hpp" #include "vmime/security/sasl/SASLMechanism.hpp" #include "vmime/security/sasl/SASLSession.hpp" #include "vmime/net/service.hpp" namespace vmime { namespace security { namespace sasl { defaultSASLAuthenticator::defaultSASLAuthenticator() { } defaultSASLAuthenticator::~defaultSASLAuthenticator() { } const std::vector > defaultSASLAuthenticator::getAcceptableMechanisms (const std::vector >& available, ref suggested) const { if (suggested) { std::vector > res; res.push_back(suggested); for (unsigned int i = 0 ; i < available.size() ; ++i) { if (available[i]->getName() != suggested->getName()) res.push_back(available[i]); } return res; } else { return available; } } const string defaultSASLAuthenticator::getUsername() const { return m_default.getUsername(); } const string defaultSASLAuthenticator::getPassword() const { return m_default.getPassword(); } const string defaultSASLAuthenticator::getHostname() const { return m_default.getHostname(); } const string defaultSASLAuthenticator::getAnonymousToken() const { return m_default.getAnonymousToken(); } const string defaultSASLAuthenticator::getServiceName() const { return m_saslSession.acquire()->getServiceName(); } void defaultSASLAuthenticator::setService(ref serv) { m_service = serv; m_default.setService(serv); } weak_ref defaultSASLAuthenticator::getService() const { return m_service; } void defaultSASLAuthenticator::setSASLSession(ref sess) { m_saslSession = sess; } ref defaultSASLAuthenticator::getSASLSession() const { return m_saslSession.acquire().constCast (); } void defaultSASLAuthenticator::setSASLMechanism(ref mech) { m_saslMech = mech; } ref defaultSASLAuthenticator::getSASLMechanism() const { return m_saslMech; } } // sasl } // security } // vmime libvmime-0.9.1/src/security/sasl/SASLSocket.cpp0000644000175000017500000000717411314151075021655 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/security/sasl/SASLSocket.hpp" #include "vmime/security/sasl/SASLSession.hpp" #include "vmime/exception.hpp" #include #include namespace vmime { namespace security { namespace sasl { SASLSocket::SASLSocket(ref sess, ref wrapped) : m_session(sess), m_wrapped(wrapped), m_pendingBuffer(0), m_pendingPos(0), m_pendingLen(0) { } SASLSocket::~SASLSocket() { if (m_pendingBuffer) delete [] m_pendingBuffer; } void SASLSocket::connect(const string& address, const port_t port) { m_wrapped->connect(address, port); } void SASLSocket::disconnect() { m_wrapped->disconnect(); } bool SASLSocket::isConnected() const { return m_wrapped->isConnected(); } SASLSocket::size_type SASLSocket::getBlockSize() const { return m_wrapped->getBlockSize(); } void SASLSocket::receive(string& buffer) { const int n = receiveRaw(m_recvBuffer, sizeof(m_recvBuffer)); buffer = string(m_recvBuffer, n); } SASLSocket::size_type SASLSocket::receiveRaw(char* buffer, const size_type count) { if (m_pendingLen != 0) { const int copyLen = (count >= m_pendingLen ? m_pendingLen : count); std::copy(m_pendingBuffer + m_pendingPos, m_pendingBuffer + m_pendingPos + copyLen, buffer); m_pendingLen -= copyLen; m_pendingPos += copyLen; if (m_pendingLen == 0) { delete [] m_pendingBuffer; m_pendingBuffer = 0; m_pendingPos = 0; m_pendingLen = 0; } return copyLen; } const int n = m_wrapped->receiveRaw(buffer, count); byte_t* output = 0; int outputLen = 0; m_session->getMechanism()->decode (m_session, reinterpret_cast (buffer), n, &output, &outputLen); // If we can not copy all decoded data into the output buffer, put // remaining data into a pending buffer for next calls to receive() if (outputLen > count) { std::copy(output, output + count, buffer); m_pendingBuffer = output; m_pendingLen = outputLen; m_pendingPos = count; return count; } else { std::copy(output, output + outputLen, buffer); delete [] output; return outputLen; } } void SASLSocket::send(const string& buffer) { sendRaw(buffer.data(), buffer.length()); } void SASLSocket::sendRaw(const char* buffer, const size_type count) { byte_t* output = 0; int outputLen = 0; m_session->getMechanism()->encode (m_session, reinterpret_cast (buffer), count, &output, &outputLen); try { m_wrapped->sendRaw (reinterpret_cast (output), outputLen); } catch (...) { delete [] output; throw; } delete [] output; } } // sasl } // security } // vmime libvmime-0.9.1/src/security/sasl/builtinSASLMechanism.cpp0000644000175000017500000000765411250723263023726 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include "vmime/security/sasl/builtinSASLMechanism.hpp" #include "vmime/security/sasl/SASLContext.hpp" #include "vmime/security/sasl/SASLSession.hpp" #include "vmime/exception.hpp" #include #include namespace vmime { namespace security { namespace sasl { builtinSASLMechanism::builtinSASLMechanism(ref ctx, const string& name) : m_context(ctx), m_name(name), m_complete(false) { } builtinSASLMechanism::~builtinSASLMechanism() { } const string builtinSASLMechanism::getName() const { return m_name; } bool builtinSASLMechanism::step (ref sess, const byte_t* challenge, const int challengeLen, byte_t** response, int* responseLen) { char* output = 0; size_t outputLen = 0; const int result = gsasl_step(sess->m_gsaslSession, reinterpret_cast (challenge), challengeLen, &output, &outputLen); if (result == GSASL_OK || result == GSASL_NEEDS_MORE) { byte_t* res = new byte_t[outputLen]; for (size_t i = 0 ; i < outputLen ; ++i) res[i] = output[i]; *response = res; *responseLen = outputLen; gsasl_free(output); } else { *response = 0; *responseLen = 0; } if (result == GSASL_OK) { // Authentication process completed m_complete = true; return true; } else if (result == GSASL_NEEDS_MORE) { // Continue authentication process return false; } else if (result == GSASL_MALLOC_ERROR) { throw std::bad_alloc(); } else { throw exceptions::sasl_exception("Error when processing challenge: " + SASLContext::getErrorMessage("gsasl_step", result)); } } bool builtinSASLMechanism::isComplete() const { return m_complete; } void builtinSASLMechanism::encode (ref sess, const byte_t* input, const int inputLen, byte_t** output, int* outputLen) { char* coutput = 0; size_t coutputLen = 0; if (gsasl_encode(sess->m_gsaslSession, reinterpret_cast (input), inputLen, &coutput, &coutputLen) != GSASL_OK) { throw exceptions::sasl_exception("Encoding error."); } try { byte_t* res = new byte_t[coutputLen]; std::copy(coutput, coutput + coutputLen, res); *output = res; *outputLen = static_cast (coutputLen); } catch (...) { gsasl_free(coutput); throw; } gsasl_free(coutput); } void builtinSASLMechanism::decode (ref sess, const byte_t* input, const int inputLen, byte_t** output, int* outputLen) { char* coutput = 0; size_t coutputLen = 0; try { if (gsasl_decode(sess->m_gsaslSession, reinterpret_cast (input), inputLen, &coutput, &coutputLen) != GSASL_OK) { throw exceptions::sasl_exception("Decoding error."); } byte_t* res = new byte_t[coutputLen]; std::copy(coutput, coutput + coutputLen, res); *output = res; *outputLen = static_cast (coutputLen); } catch (...) { gsasl_free(coutput); throw; } gsasl_free(coutput); } } // sasl } // security } // vmime libvmime-0.9.1/src/security/digest/0000755000175000017500000000000011607302336017545 5ustar mnordstrmnordstrlibvmime-0.9.1/src/security/digest/md5/0000755000175000017500000000000011607302336020232 5ustar mnordstrmnordstrlibvmime-0.9.1/src/security/digest/md5/md5MessageDigest.cpp0000644000175000017500000002234311250723263024074 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // Derived from cryptoapi implementation, originally based on the // public domain implementation written by Colin Plumb in 1993. // // Copyright (C) Cryptoapi developers. // // Algorithm Copyright: // // Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All // rights reserved. // // License to copy and use this software is granted provided that it // is identified as the "RSA Data Security, Inc. MD5 Message-Digest // Algorithm" in all material mentioning or referencing this software // or this function. // // License is also granted to make and use derivative works provided // that such works are identified as "derived from the RSA Data // Security, Inc. MD5 Message-Digest Algorithm" in all material // mentioning or referencing the derived work. // // RSA Data Security, Inc. makes no representations concerning either // the merchantability of this software or the suitability of this // software forany particular purpose. It is provided "as is" // without express or implied warranty of any kind. // These notices must be retained in any copies of any part of this // documentation and/or software. #include "vmime/security/digest/md5/md5MessageDigest.hpp" #include namespace vmime { namespace security { namespace digest { namespace md5 { md5MessageDigest::md5MessageDigest() { init(); } void md5MessageDigest::reset() { init(); } void md5MessageDigest::init() { m_hash[0] = 0x67452301; m_hash[1] = 0xefcdab89; m_hash[2] = 0x98badcfe; m_hash[3] = 0x10325476; m_byteCount = 0; m_finalized = false; } static void copyUint8Array(vmime_uint8* dest, const vmime_uint8* src, unsigned long count) { for ( ; count >= 4 ; count -= 4, dest += 4, src += 4) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; dest[3] = src[3]; } for ( ; count ; --count, ++dest, ++src) dest[0] = src[0]; } static inline vmime_uint32 swapUint32(const vmime_uint32 D) { return ((D << 24) | ((D << 8) & 0x00FF0000) | ((D >> 8) & 0x0000FF00) | (D >> 24)); } static inline void swapUint32Array(vmime_uint32* buf, unsigned long words) { for ( ; words >= 4 ; words -= 4, buf += 4) { buf[0] = swapUint32(buf[0]); buf[1] = swapUint32(buf[1]); buf[2] = swapUint32(buf[2]); buf[3] = swapUint32(buf[3]); } for ( ; words ; --words, ++buf) buf[0] = swapUint32(buf[0]); } void md5MessageDigest::update(const byte_t b) { update(&b, 1); } void md5MessageDigest::update(const string& s) { update(reinterpret_cast (s.data()), s.length()); } void md5MessageDigest::update(const byte_t* data, const unsigned long offset, const unsigned long len) { update(data + offset, len); } void md5MessageDigest::update(const byte_t* data, const unsigned long length) { const unsigned long avail = 64 - (m_byteCount & 0x3f); unsigned long len = length; m_byteCount += len; if (avail > len) { copyUint8Array(m_block + (64 - avail), data, len); return; } copyUint8Array(m_block + (64 - avail), data, avail); transformHelper(); data += avail; len -= avail; while (len >= 64) { copyUint8Array(m_block, data, 64); transformHelper(); data += 64; len -= 64; } copyUint8Array(m_block, data, len); } void md5MessageDigest::finalize(const string& s) { update(s); finalize(); } void md5MessageDigest::finalize(const byte_t* buffer, const unsigned long len) { update(buffer, len); finalize(); } void md5MessageDigest::finalize(const byte_t* buffer, const unsigned long offset, const unsigned long len) { update(buffer, offset, len); finalize(); } void md5MessageDigest::finalize() { const long offset = m_byteCount & 0x3f; vmime_uint8* p = m_block + offset; long padding = 56 - (offset + 1); *p++ = 0x80; if (padding < 0) { memset(p, 0x00, padding + 8); transformHelper(); p = m_block; padding = 56; } memset(p, 0, padding); reinterpret_cast (m_block)[14] = (m_byteCount << 3); reinterpret_cast (m_block)[15] = (m_byteCount >> 29); #if VMIME_BYTE_ORDER_BIG_ENDIAN swapUint32Array((vmime_uint32*) m_block, (64 - 8) / 4); #endif transform(); #if VMIME_BYTE_ORDER_BIG_ENDIAN swapUint32Array((vmime_uint32*) m_hash, 4); #endif m_finalized = true; } void md5MessageDigest::transformHelper() { #if VMIME_BYTE_ORDER_BIG_ENDIAN swapUint32Array((vmime_uint32*) m_block, 64 / 4); #endif transform(); } void md5MessageDigest::transform() { const vmime_uint32* const in = reinterpret_cast (m_block); vmime_uint32 a = m_hash[0]; vmime_uint32 b = m_hash[1]; vmime_uint32 c = m_hash[2]; vmime_uint32 d = m_hash[3]; #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) #define MD5STEP(f, w, x, y, z, in, s) \ (w += f(x, y, z) + in, w = (w<>(32-s)) + x) MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); m_hash[0] += a; m_hash[1] += b; m_hash[2] += c; m_hash[3] += d; } int md5MessageDigest::getDigestLength() const { return 16; } const byte_t* md5MessageDigest::getDigest() const { return reinterpret_cast (m_hash); } } // md5 } // digest } // security } // vmime libvmime-0.9.1/src/security/digest/sha1/0000755000175000017500000000000011607302336020401 5ustar mnordstrmnordstrlibvmime-0.9.1/src/security/digest/sha1/sha1MessageDigest.cpp0000644000175000017500000001572011375203276024420 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // This is an implementation by Steve Reid // 100% public domain. #include "vmime/security/digest/sha1/sha1MessageDigest.hpp" #include #include namespace vmime { namespace security { namespace digest { namespace sha1 { #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) // blk0() and blk() perform the initial expand. // I got the idea of expanding during the round function from SSLeay #if VMIME_BYTE_ORDER_LITTLE_ENDIAN #define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) \ | (rol(block->l[i], 8) & 0x00FF00FF)) #else #define blk0(i) block->l[i] #endif #define blk(i) (block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ block->l[(i + 8) & 15] \ ^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1)) // (R0+R1), R2, R3, R4 are the different operations used in SHA1 #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); sha1MessageDigest::sha1MessageDigest() { init(); } void sha1MessageDigest::reset() { init(); } void sha1MessageDigest::init() { m_state[0] = 0x67452301; m_state[1] = 0xefcdab89; m_state[2] = 0x98badcfe; m_state[3] = 0x10325476; m_state[4] = 0xc3d2e1f0; m_count[0] = 0; m_count[1] = 0; } void sha1MessageDigest::update(const byte_t b) { update(&b, 1); } void sha1MessageDigest::update(const string& s) { update(reinterpret_cast (s.data()), s.length()); } void sha1MessageDigest::update(const byte_t* buffer, const unsigned long offset, const unsigned long len) { update(buffer + offset, len); } void sha1MessageDigest::update(const byte_t* buffer, const unsigned long len) { unsigned int i, j; j = (m_count[0] >> 3) & 63; if ((m_count[0] += len << 3) < (len << 3)) m_count[1]++; m_count[1] += (len >> 29); if ((j + len) > 63) { memcpy(&m_buffer[j], buffer, (i = 64 - j)); transform(m_state, m_buffer); for ( ; i + 63 < len ; i += 64) transform(m_state, &buffer[i]); j = 0; } else { i = 0; } std::memcpy(&m_buffer[j], &buffer[i], len - i); } void sha1MessageDigest::finalize() { unsigned int i, j; unsigned char finalcount[8]; for (i = 0 ; i < 8 ; i++) { finalcount[i] = static_cast ((m_count[(i >= 4 ? 0 : 1)] >> ((3-(i & 3)) * 8) ) & 255); // Endian independent } update(reinterpret_cast ("\200"), 1); while ((m_count[0] & 504) != 448) update(reinterpret_cast ("\0"), 1); update(finalcount, 8); // Should cause a transform() for (i = 0 ; i < 20 ; i++) { m_digest[i] = static_cast ((m_state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); } // Wipe variables i = j = 0; std::memset(m_buffer, 0, 64); std::memset(m_state, 0, 5 * sizeof(unsigned int)); std::memset(m_count, 0, 2 * sizeof(unsigned int)); std::memset(&finalcount, 0, 8); } void sha1MessageDigest::finalize(const string& s) { finalize(reinterpret_cast (s.data()), s.length()); } void sha1MessageDigest::finalize(const byte_t* buffer, const unsigned long len) { update(buffer, len); finalize(); } void sha1MessageDigest::finalize(const byte_t* buffer, const unsigned long offset, const unsigned long len) { finalize(buffer + offset, len); } /** Hash a single 512-bit block. * This is the core of the algorithm. */ void sha1MessageDigest::transform (unsigned int state[5], const unsigned char buffer[64]) { unsigned int a, b, c, d, e; typedef union { unsigned char c[64]; unsigned int l[16]; } CHAR64LONG16; assert(sizeof(unsigned int) == 4); CHAR64LONG16* block; static unsigned char workspace[64]; block = reinterpret_cast (workspace); memcpy(block, buffer, 64); // Copy context->state[] to working vars a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; // 4 rounds of 20 operations each. Loop unrolled. R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); // Add the working vars back into context.state[] state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; // Wipe variables a = b = c = d = e = 0; } int sha1MessageDigest::getDigestLength() const { return 20; } const byte_t* sha1MessageDigest::getDigest() const { return m_digest; } } // sha1 } // digest } // security } // vmime libvmime-0.9.1/src/security/digest/messageDigestFactory.cpp0000644000175000017500000000427211250723263024372 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/security/digest/messageDigestFactory.hpp" #include "vmime/exception.hpp" #include "vmime/security/digest/md5/md5MessageDigest.hpp" #include "vmime/security/digest/sha1/sha1MessageDigest.hpp" namespace vmime { namespace security { namespace digest { messageDigestFactory::messageDigestFactory() { registerAlgorithm ("md5"); registerAlgorithm ("sha1"); } messageDigestFactory::~messageDigestFactory() { } messageDigestFactory* messageDigestFactory::getInstance() { static messageDigestFactory instance; return (&instance); } ref messageDigestFactory::create(const string& name) { const MapType::const_iterator it = m_algos.find (utility::stringUtils::toLower(name)); if (it != m_algos.end()) return (*it).second->create(); throw exceptions::no_digest_algorithm_available(name); } const std::vector messageDigestFactory::getSupportedAlgorithms() const { std::vector res; for (MapType::const_iterator it = m_algos.begin() ; it != m_algos.end() ; ++it) { res.push_back((*it).first); } return res; } } // digest } // security } // vmime libvmime-0.9.1/src/security/digest/messageDigest.cpp0000644000175000017500000000310611250723263023035 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/security/digest/messageDigest.hpp" #include namespace vmime { namespace security { namespace digest { const string messageDigest::getHexDigest() const { const byte_t* hash = getDigest(); const int len = getDigestLength(); static const unsigned char hex[] = "0123456789abcdef"; std::ostringstream oss; oss.imbue(std::locale::classic()); for (int i = 0 ; i < len ; ++i) { oss << hex[(hash[i] & 0xf0) >> 4]; oss << hex[(hash[i] & 0x0f)]; } return oss.str(); } } // digest } // security } // vmime libvmime-0.9.1/src/security/defaultAuthenticator.cpp0000644000175000017500000000541311250723263023154 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/security/defaultAuthenticator.hpp" #include "vmime/net/service.hpp" #include "vmime/platform.hpp" namespace vmime { namespace security { defaultAuthenticator::defaultAuthenticator() { } defaultAuthenticator::~defaultAuthenticator() { } const string defaultAuthenticator::getUsername() const { ref service = m_service.acquire(); const string prefix = service->getInfos().getPropertyPrefix(); const propertySet& props = service->getSession()->getProperties(); if (props.hasProperty(prefix + net::serviceInfos::property::AUTH_USERNAME.getName())) return props[prefix + net::serviceInfos::property::AUTH_USERNAME.getName()]; throw exceptions::no_auth_information(); } const string defaultAuthenticator::getPassword() const { ref service = m_service.acquire(); const string prefix = service->getInfos().getPropertyPrefix(); const propertySet& props = service->getSession()->getProperties(); if (props.hasProperty(prefix + net::serviceInfos::property::AUTH_PASSWORD.getName())) return props[prefix + net::serviceInfos::property::AUTH_PASSWORD.getName()]; throw exceptions::no_auth_information(); } const string defaultAuthenticator::getHostname() const { return platform::getHandler()->getHostName(); } const string defaultAuthenticator::getAnonymousToken() const { return "anonymous@" + platform::getHandler()->getHostName(); } const string defaultAuthenticator::getServiceName() const { // Information cannot be provided throw exceptions::no_auth_information(); } void defaultAuthenticator::setService(ref serv) { m_service = serv; } weak_ref defaultAuthenticator::getService() const { return m_service; } } // security } // vmime libvmime-0.9.1/src/constants.cpp0000644000175000017500000002301011250723263017133 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/constants.hpp" namespace vmime { // Media Types namespace mediaTypes { // Types const string::value_type* const TEXT = "text"; const string::value_type* const MULTIPART = "multipart"; const string::value_type* const MESSAGE = "message"; const string::value_type* const APPLICATION = "application"; const string::value_type* const IMAGE = "image"; const string::value_type* const AUDIO = "audio"; const string::value_type* const VIDEO = "video"; // Sub-types const string::value_type* const TEXT_PLAIN = "plain"; const string::value_type* const TEXT_HTML = "html"; const string::value_type* const TEXT_RICHTEXT = "richtext"; const string::value_type* const TEXT_ENRICHED = "enriched"; const string::value_type* const TEXT_RFC822_HEADERS = "rfc822-headers"; // RFC-1892 const string::value_type* const TEXT_DIRECTORY = "directory"; // RFC-2426 const string::value_type* const MULTIPART_MIXED = "mixed"; const string::value_type* const MULTIPART_RELATED = "related"; const string::value_type* const MULTIPART_ALTERNATIVE = "alternative"; const string::value_type* const MULTIPART_PARALLEL = "parallel"; const string::value_type* const MULTIPART_DIGEST = "digest"; const string::value_type* const MULTIPART_REPORT = "report"; // RFC-1892 const string::value_type* const MESSAGE_RFC822 = "rfc822"; const string::value_type* const MESSAGE_PARTIAL = "partial"; const string::value_type* const MESSAGE_EXTERNAL_BODY = "external-body"; const string::value_type* const MESSAGE_DISPOSITION_NOTIFICATION = "disposition-notification"; const string::value_type* const APPLICATION_OCTET_STREAM = "octet-stream"; const string::value_type* const IMAGE_JPEG = "jpeg"; const string::value_type* const IMAGE_GIF = "gif"; const string::value_type* const AUDIO_BASIC = "basic"; const string::value_type* const VIDEO_MPEG = "mpeg"; } // Encoding types namespace encodingTypes { const string::value_type* const SEVEN_BIT = "7bit"; const string::value_type* const EIGHT_BIT = "8bit"; const string::value_type* const BASE64 = "base64"; const string::value_type* const QUOTED_PRINTABLE = "quoted-printable"; const string::value_type* const BINARY = "binary"; const string::value_type* const UUENCODE = "uuencode"; } // Content disposition types namespace contentDispositionTypes { const string::value_type* const INLINE = "inline"; const string::value_type* const ATTACHMENT = "attachment"; } // Charsets namespace charsets { const string::value_type* const ISO8859_1 = "iso-8859-1"; const string::value_type* const ISO8859_2 = "iso-8859-2"; const string::value_type* const ISO8859_3 = "iso-8859-3"; const string::value_type* const ISO8859_4 = "iso-8859-4"; const string::value_type* const ISO8859_5 = "iso-8859-5"; const string::value_type* const ISO8859_6 = "iso-8859-6"; const string::value_type* const ISO8859_7 = "iso-8859-7"; const string::value_type* const ISO8859_8 = "iso-8859-8"; const string::value_type* const ISO8859_9 = "iso-8859-9"; const string::value_type* const ISO8859_10 = "iso-8859-10"; const string::value_type* const ISO8859_13 = "iso-8859-13"; const string::value_type* const ISO8859_14 = "iso-8859-14"; const string::value_type* const ISO8859_15 = "iso-8859-15"; const string::value_type* const ISO8859_16 = "iso-8859-16"; const string::value_type* const CP_437 = "cp437"; const string::value_type* const CP_737 = "cp737"; const string::value_type* const CP_775 = "cp775"; const string::value_type* const CP_850 = "cp850"; const string::value_type* const CP_852 = "cp852"; const string::value_type* const CP_853 = "cp853"; const string::value_type* const CP_855 = "cp855"; const string::value_type* const CP_857 = "cp857"; const string::value_type* const CP_858 = "cp858"; const string::value_type* const CP_860 = "cp860"; const string::value_type* const CP_861 = "cp861"; const string::value_type* const CP_862 = "cp862"; const string::value_type* const CP_863 = "cp863"; const string::value_type* const CP_864 = "cp864"; const string::value_type* const CP_865 = "cp865"; const string::value_type* const CP_866 = "cp866"; const string::value_type* const CP_869 = "cp869"; const string::value_type* const CP_874 = "cp874"; const string::value_type* const CP_1125 = "cp1125"; const string::value_type* const CP_1250 = "cp1250"; const string::value_type* const CP_1251 = "cp1251"; const string::value_type* const CP_1252 = "cp1252"; const string::value_type* const CP_1253 = "cp1253"; const string::value_type* const CP_1254 = "cp1254"; const string::value_type* const CP_1255 = "cp1255"; const string::value_type* const CP_1256 = "cp1256"; const string::value_type* const CP_1257 = "cp1257"; const string::value_type* const US_ASCII = "us-ascii"; const string::value_type* const UTF_7 = "utf-7"; const string::value_type* const UTF_8 = "utf-8"; const string::value_type* const UTF_16 = "utf-16"; const string::value_type* const UTF_32 = "utf-32"; const string::value_type* const WINDOWS_1250 = "windows-1250"; const string::value_type* const WINDOWS_1251 = "windows-1251"; const string::value_type* const WINDOWS_1252 = "windows-1252"; const string::value_type* const WINDOWS_1253 = "windows-1253"; const string::value_type* const WINDOWS_1254 = "windows-1254"; const string::value_type* const WINDOWS_1255 = "windows-1255"; const string::value_type* const WINDOWS_1256 = "windows-1256"; const string::value_type* const WINDOWS_1257 = "windows-1257"; const string::value_type* const WINDOWS_1258 = "windows-1258"; } // Fields namespace fields { const string::value_type* const RECEIVED = "Received"; const string::value_type* const FROM = "From"; const string::value_type* const SENDER = "Sender"; const string::value_type* const REPLY_TO = "Reply-To"; const string::value_type* const TO = "To"; const string::value_type* const CC = "Cc"; const string::value_type* const BCC = "Bcc"; const string::value_type* const DATE = "Date"; const string::value_type* const SUBJECT = "Subject"; const string::value_type* const ORGANIZATION = "Organization"; const string::value_type* const USER_AGENT = "User-Agent"; const string::value_type* const DELIVERED_TO = "Delivered-To"; const string::value_type* const RETURN_PATH = "Return-Path"; const string::value_type* const MIME_VERSION = "Mime-Version"; const string::value_type* const MESSAGE_ID = "Message-Id"; const string::value_type* const CONTENT_TYPE = "Content-Type"; const string::value_type* const CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; const string::value_type* const CONTENT_DESCRIPTION = "Content-Description"; const string::value_type* const CONTENT_DISPOSITION = "Content-Disposition"; const string::value_type* const CONTENT_ID = "Content-Id"; const string::value_type* const CONTENT_LOCATION = "Content-Location"; const string::value_type* const IN_REPLY_TO = "In-Reply-To"; const string::value_type* const REFERENCES = "References"; const string::value_type* const X_MAILER = "X-Mailer"; const string::value_type* const X_PRIORITY = "X-Priority"; // RFC-3798: Message Disposition const string::value_type* const ORIGINAL_MESSAGE_ID = "Original-Message-ID"; const string::value_type* const DISPOSITION_NOTIFICATION_TO = "Disposition-Notification-To"; const string::value_type* const DISPOSITION_NOTIFICATION_OPTIONS = "Disposition-Notification-Options"; const string::value_type* const DISPOSITION = "Disposition"; const string::value_type* const FAILURE = "Failure"; const string::value_type* const ERROR = "Error"; const string::value_type* const WARNING = "Warning"; const string::value_type* const ORIGINAL_RECIPIENT = "Original-Recipient"; const string::value_type* const FINAL_RECIPIENT = "Final-Recipient"; const string::value_type* const REPORTING_UA = "Reporting-UA"; const string::value_type* const MDN_GATEWAY = "MDN-Gateway"; } // Constants for disposition action modes (RFC-3978). namespace dispositionActionModes { const string::value_type* const MANUAL = "manual"; const string::value_type* const AUTOMATIC = "automatic"; } // Constants for disposition sending modes (RFC-3798). namespace dispositionSendingModes { const string::value_type* const SENT_MANUALLY = "MDN-sent-manually"; const string::value_type* const SENT_AUTOMATICALLY ="MDN-sent-automatically"; } // Constants for disposition types (RFC-3798). namespace dispositionTypes { const string::value_type* const DISPLAYED = "displayed"; const string::value_type* const DELETED = "deleted"; } // Constants for disposition modifiers (RFC-3798). namespace dispositionModifiers { const string::value_type* const ERROR = "error"; } } // vmime libvmime-0.9.1/src/fileAttachment.cpp0000644000175000017500000001430211314151075020050 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include "vmime/fileAttachment.hpp" #include "vmime/exception.hpp" #include "vmime/streamContentHandler.hpp" #include "vmime/contentDispositionField.hpp" #include "vmime/platform.hpp" #include "vmime/utility/file.hpp" namespace vmime { fileAttachment::fileAttachment(const string& filepath, const mediaType& type) { m_type = type; setData(filepath); m_encoding = encoding::decide(m_data); } fileAttachment::fileAttachment(const string& filepath, const mediaType& type, const text& desc) { m_type = type; m_desc = desc; setData(filepath); m_encoding = encoding::decide(m_data); } fileAttachment::fileAttachment(const string& filepath, const mediaType& type, const text& desc, const encoding& enc) { m_type = type; m_desc = desc; setData(filepath); m_encoding = enc; } fileAttachment::fileAttachment(ref is, const word& filename, const mediaType& type) { if (!filename.isEmpty()) m_fileInfo.setFilename(filename); m_type = type; setData(is); m_encoding = encoding::decide(m_data); } fileAttachment::fileAttachment(ref is, const word& filename, const mediaType& type, const text& desc) { if (!filename.isEmpty()) m_fileInfo.setFilename(filename); m_type = type; m_desc = desc; setData(is); m_encoding = encoding::decide(m_data); } fileAttachment::fileAttachment(ref is, const word& filename, const mediaType& type, const text& desc, const encoding& enc) { if (!filename.isEmpty()) m_fileInfo.setFilename(filename); m_type = type; m_desc = desc; m_encoding = enc; setData(is); } void fileAttachment::setData(const string& filepath) { std::ifstream* file = new std::ifstream(); file->open(filepath.c_str(), std::ios::in | std::ios::binary); if (!*file) { delete file; throw exceptions::open_file_error(); } ref is = vmime::create (file, true); setData(is); utility::file::path path = platform::getHandler()->getFileSystemFactory()->stringToPath(filepath); m_fileInfo.setFilename(path.getLastComponent()); } void fileAttachment::setData(ref is) { m_data = vmime::create (is, 0); } void fileAttachment::generatePart(ref part) const { defaultAttachment::generatePart(part); ref cdf = part->getHeader()->ContentDisposition(). dynamicCast (); if (m_fileInfo.hasSize()) cdf->setSize(utility::stringUtils::toString(m_fileInfo.getSize())); if (m_fileInfo.hasFilename() && !m_fileInfo.getFilename().isEmpty()) cdf->setFilename(m_fileInfo.getFilename()); if (m_fileInfo.hasCreationDate()) cdf->setCreationDate(m_fileInfo.getCreationDate()); if (m_fileInfo.hasModificationDate()) cdf->setModificationDate(m_fileInfo.getModificationDate()); if (m_fileInfo.hasReadDate()) cdf->setReadDate(m_fileInfo.getReadDate()); } const fileAttachment::fileInfo& fileAttachment::getFileInfo() const { return m_fileInfo; } fileAttachment::fileInfo& fileAttachment::getFileInfo() { return m_fileInfo; } // // fileAttachment::fileInfo // fileAttachment::fileInfo::fileInfo() : m_filename(NULL), m_size(NULL), m_creationDate(NULL), m_modifDate(NULL), m_readDate(NULL) { } fileAttachment::fileInfo::~fileInfo() { delete (m_filename); delete (m_size); delete (m_creationDate); delete (m_modifDate); delete (m_readDate); } bool fileAttachment::fileInfo::hasFilename() const { return (m_filename != NULL); } const word& fileAttachment::fileInfo::getFilename() const { return (*m_filename); } void fileAttachment::fileInfo::setFilename(const string& name) { if (m_filename) { *m_filename = name; } else { m_filename = new word(name); } } void fileAttachment::fileInfo::setFilename(const word& name) { if (m_filename) { *m_filename = name; } else { m_filename = new word(name); } } bool fileAttachment::fileInfo::hasCreationDate() const { return (m_creationDate != NULL); } const datetime& fileAttachment::fileInfo::getCreationDate() const { return (*m_creationDate); } void fileAttachment::fileInfo::setCreationDate(const datetime& date) { if (m_creationDate) { *m_creationDate = date; } else { m_creationDate = new datetime(date); } } bool fileAttachment::fileInfo::hasModificationDate() const { return (m_modifDate != NULL); } const datetime& fileAttachment::fileInfo::getModificationDate() const { return (*m_modifDate); } void fileAttachment::fileInfo::setModificationDate(const datetime& date) { if (m_modifDate) { *m_modifDate = date; } else { m_modifDate = new datetime(date); } } bool fileAttachment::fileInfo::hasReadDate() const { return (m_readDate != NULL); } const datetime& fileAttachment::fileInfo::getReadDate() const { return (*m_readDate); } void fileAttachment::fileInfo::setReadDate(const datetime& date) { if (m_readDate) { *m_readDate = date; } else { m_readDate = new datetime(date); } } bool fileAttachment::fileInfo::hasSize() const { return (m_size != NULL); } unsigned int fileAttachment::fileInfo::getSize() const { return (*m_size); } void fileAttachment::fileInfo::setSize(const unsigned int& size) { if (m_size) { *m_size = size; } else { m_size = new unsigned int(size); } } } // vmime libvmime-0.9.1/src/word.cpp0000644000175000017500000004314011455551064016105 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/word.hpp" #include "vmime/text.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/utility/smartPtr.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/utility/encoder/encoder.hpp" #include "vmime/utility/encoder/b64Encoder.hpp" #include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/wordEncoder.hpp" namespace vmime { word::word() : m_charset(charset::getLocaleCharset()) { } word::word(const word& w) : headerFieldValue(), m_buffer(w.m_buffer), m_charset(w.m_charset) { } word::word(const string& buffer) // Defaults to locale charset : m_buffer(buffer), m_charset(charset::getLocaleCharset()) { } word::word(const string& buffer, const charset& charset) : m_buffer(buffer), m_charset(charset) { } ref word::parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition, bool prevIsEncoded, bool* isEncoded, bool isFirst) { string::size_type pos = position; // Ignore white-spaces: // - before the first word // - between two encoded words // - after the last word string whiteSpaces; while (pos < end && parserHelpers::isSpace(buffer[pos])) { whiteSpaces += buffer[pos]; ++pos; } string::size_type startPos = pos; string unencoded; while (pos < end) { // End of line: does not occur in the middle of an encoded word. This is // used to remove folding white-spaces from unencoded text. if (buffer[pos] == '\n') { string::size_type endPos = pos; if (pos > position && buffer[pos - 1] == '\r') { ++pos; --endPos; } while (pos != end && parserHelpers::isSpace(buffer[pos])) ++pos; unencoded += buffer.substr(startPos, endPos - startPos); unencoded += ' '; startPos = pos; continue; } // Start of an encoded word else if (pos + 8 < end && // 8 = "=?(.+)?(.+)?(.*)?=" buffer[pos] == '=' && buffer[pos + 1] == '?') { // Check whether there is some unencoded text before unencoded += buffer.substr(startPos, pos - startPos); if (!unencoded.empty()) { if (prevIsEncoded) unencoded = whiteSpaces + unencoded; ref w = vmime::create (unencoded, charset(charsets::US_ASCII)); w->setParsedBounds(position, pos); if (newPosition) *newPosition = pos; if (isEncoded) *isEncoded = false; return (w); } // ...else find the finish sequence '?=' and return an encoded word const string::size_type wordStart = pos; pos += 2; while (pos < end && buffer[pos] != '?') ++pos; if (pos < end) { ++pos; // skip '?' between charset and encoding while (pos < end && buffer[pos] != '?') ++pos; if (pos < end) { ++pos; // skip '?' between encoding and encoded data } } while (pos < end) { if (buffer[pos] == '\n') { // End of line not allowed in the middle of an encoded word: // treat this text as unencoded text (see *). break; } else if (buffer[pos] == '?' && pos + 1 < end && buffer[pos + 1] == '=') { // Found the finish sequence break; } ++pos; } if (pos == end) // not a valid word (no finish sequence) continue; else if (buffer[pos] == '\n') // (*) continue; pos += 2; // ?= ref w = vmime::create (); w->parse(buffer, wordStart, pos, NULL); if (newPosition) *newPosition = pos; if (isEncoded) *isEncoded = true; return (w); } ++pos; } // Treat unencoded text at the end of the buffer if (end != startPos) { if (startPos != pos && !isFirst && prevIsEncoded) unencoded += whiteSpaces; unencoded += buffer.substr(startPos, end - startPos); ref w = vmime::create (unencoded, charset(charsets::US_ASCII)); w->setParsedBounds(position, end); if (newPosition) *newPosition = end; if (isEncoded) *isEncoded = false; return (w); } return (null); } const std::vector > word::parseMultiple(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { std::vector > res; ref w; string::size_type pos = position; bool prevIsEncoded = false; while ((w = word::parseNext(buffer, pos, end, &pos, prevIsEncoded, &prevIsEncoded, (w == NULL))) != NULL) res.push_back(w); if (newPosition) *newPosition = pos; return (res); } void word::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { if (position + 6 < end && // 6 = "=?(.+)?(.*)?=" buffer[position] == '=' && buffer[position + 1] == '?') { string::const_iterator p = buffer.begin() + position + 2; const string::const_iterator pend = buffer.begin() + end; const string::const_iterator charsetPos = p; for ( ; p != pend && *p != '?' ; ++p) {} if (p != pend) // a charset is specified { const string::const_iterator charsetEnd = p; const string::const_iterator encPos = ++p; // skip '?' for ( ; p != pend && *p != '?' ; ++p) {} if (p != pend) // an encoding is specified { //const string::const_iterator encEnd = p; const string::const_iterator dataPos = ++p; // skip '?' for ( ; p != pend && !(*p == '?' && *(p + 1) == '=') ; ++p) {} if (p != pend) // some data is specified { const string::const_iterator dataEnd = p; p += 2; // skip '?=' utility::encoder::encoder* theEncoder = NULL; // Base-64 encoding if (*encPos == 'B' || *encPos == 'b') { theEncoder = new utility::encoder::b64Encoder(); } // Quoted-Printable encoding else if (*encPos == 'Q' || *encPos == 'q') { theEncoder = new utility::encoder::qpEncoder(); theEncoder->getProperties()["rfc2047"] = true; } if (theEncoder) { // Decode text string decodedBuffer; utility::inputStreamStringAdapter ein(string(dataPos, dataEnd)); utility::outputStreamStringAdapter eout(decodedBuffer); theEncoder->decode(ein, eout); delete (theEncoder); m_buffer = decodedBuffer; m_charset = charset(string(charsetPos, charsetEnd)); setParsedBounds(position, p - buffer.begin()); if (newPosition) *newPosition = (p - buffer.begin()); return; } } } } } // Unknown encoding or malformed encoded word: treat the buffer as ordinary text (RFC-2047, Page 9). m_buffer = string(buffer.begin() + position, buffer.begin() + end); m_charset = charsets::US_ASCII; setParsedBounds(position, end); if (newPosition) *newPosition = end; } void word::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { generate(os, maxLineLength, curLinePos, newLinePos, 0, NULL); } void word::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos, const int flags, generatorState* state) const { string::size_type curLineLength = curLinePos; generatorState defaultGeneratorState; if (state == NULL) state = &defaultGeneratorState; // Find out if encoding is forced or required by contents + charset bool encodingNeeded = (flags & text::FORCE_ENCODING) != 0; if (encodingNeeded == false) encodingNeeded = wordEncoder::isEncodingNeeded(m_buffer, m_charset); else if ((flags & text::FORCE_NO_ENCODING) != 0) encodingNeeded = false; // If possible and requested (with flag), quote the buffer (no folding is performed). // Quoting is possible if and only if: // - the buffer does not need to be encoded // - the buffer does not contain quoting character (") // - there is enough remaining space on the current line to hold the whole buffer if (!encodingNeeded && (flags & text::QUOTE_IF_POSSIBLE) && m_buffer.find('"') == string::npos && (curLineLength + 2 /* 2 x " */ + m_buffer.length()) < maxLineLength) { os << '"' << m_buffer << '"'; curLineLength += 2 + m_buffer.length(); } // We will fold lines without encoding them. else if (!encodingNeeded) { // Here, we could have the following conditions: // // * a maximum line length of N bytes // * a buffer containing N+1 bytes, with no whitespace // // Look in the buffer for any run (ie. whitespace-separated sequence) which // is longer than the maximum line length. If there is one, then force encoding, // so that no generated line is longer than the maximum line length. string::size_type maxRunLength = 0; string::size_type curRunLength = 0; for (string::const_iterator p = m_buffer.begin(), end = m_buffer.end() ; p != end ; ++p) { if (parserHelpers::isSpace(*p)) { maxRunLength = std::max(maxRunLength, curRunLength); curRunLength = 0; } else { curRunLength++; } } maxRunLength = std::max(maxRunLength, curRunLength); if (maxRunLength >= maxLineLength - 3) { // Generate with encoding forced generate(os, maxLineLength, curLinePos, newLinePos, flags | text::FORCE_ENCODING, state); return; } // Output runs, and fold line when a whitespace is encountered string::const_iterator lastWSpos = m_buffer.end(); // last white-space position string::const_iterator curLineStart = m_buffer.begin(); // current line start string::const_iterator p = m_buffer.begin(); const string::const_iterator end = m_buffer.end(); bool finished = false; bool newLine = false; while (!finished) { for ( ; p != end ; ++p, ++curLineLength) { // Exceeded maximum line length, but we have found a white-space // where we can cut the line... if (curLineLength >= maxLineLength && lastWSpos != end) break; if (*p == ' ' || *p == '\t') { // Remember the position of this white-space character lastWSpos = p; } } if (p != end) ++curLineLength; if (p == end || lastWSpos == end) { // If we are here, it means that we have found no whitespace // before the first "maxLineLength" characters. In this case, // we write the full line no matter of the max line length... if (!newLine && p != end && lastWSpos == end && !state->isFirstWord && curLineStart == m_buffer.begin()) { // Here, we are continuing on the line of previous encoded // word, but there is not even enough space to put the // first word of this line, so we start a new line. if (flags & text::NO_NEW_LINE_SEQUENCE) { os << CRLF; curLineLength = 0; state->lastCharIsSpace = true; } else { os << NEW_LINE_SEQUENCE; curLineLength = NEW_LINE_SEQUENCE_LENGTH; state->lastCharIsSpace = true; } p = curLineStart; lastWSpos = end; newLine = true; } else { if (!state->isFirstWord && state->prevWordIsEncoded && !state->lastCharIsSpace && !parserHelpers::isSpace(*curLineStart)) os << " "; // Separate from previous word os << string(curLineStart, p); if (parserHelpers::isSpace(*(p - 1))) state->lastCharIsSpace = true; else state->lastCharIsSpace = false; if (p == end) { finished = true; } else { if (flags & text::NO_NEW_LINE_SEQUENCE) { os << CRLF; curLineLength = 0; } else { os << NEW_LINE_SEQUENCE; curLineLength = NEW_LINE_SEQUENCE_LENGTH; } curLineStart = p; lastWSpos = end; newLine = true; } } } else { // In this case, there will not be enough space on the line for all the // characters _after_ the last white-space; so we cut the line at this // last white-space. #if 1 if (curLineLength != NEW_LINE_SEQUENCE_LENGTH && !state->isFirstWord && state->prevWordIsEncoded) os << " "; // Separate from previous word #endif os << string(curLineStart, lastWSpos); if (lastWSpos > curLineStart && parserHelpers::isSpace(*(lastWSpos - 1))) state->lastCharIsSpace = true; else state->lastCharIsSpace = false; if (flags & text::NO_NEW_LINE_SEQUENCE) { os << CRLF; curLineLength = 0; state->lastCharIsSpace = true; } else { os << NEW_LINE_SEQUENCE; curLineLength = NEW_LINE_SEQUENCE_LENGTH; state->lastCharIsSpace = true; } curLineStart = lastWSpos + 1; p = lastWSpos + 1; lastWSpos = end; newLine = true; } } } /* RFC #2047: 4. Encodings Initially, the legal values for "encoding" are "Q" and "B". These encodings are described below. The "Q" encoding is recommended for use when most of the characters to be encoded are in the ASCII character set; otherwise, the "B" encoding should be used. Nevertheless, a mail reader which claims to recognize 'encoded-word's MUST be able to accept either encoding for any character set which it supports. */ else { // We will encode _AND_ fold lines /* RFC #2047: 2. Syntax of encoded-words " While there is no limit to the length of a multiple-line header field, each line of a header field that contains one or more 'encoded-word's is limited to 76 characters. " */ const string::size_type maxLineLength3 = (maxLineLength == lineLengthLimits::infinite) ? maxLineLength : std::min(maxLineLength, static_cast (76)); wordEncoder wordEnc(m_buffer, m_charset); const string wordStart("=?" + m_charset.getName() + "?" + (wordEnc.getEncoding() == wordEncoder::ENCODING_B64 ? 'B' : 'Q') + "?"); const string wordEnd("?="); const string::size_type minWordLength = wordStart.length() + wordEnd.length(); const string::size_type maxLineLength2 = (maxLineLength3 < minWordLength + 1) ? maxLineLength3 + minWordLength + 1 : maxLineLength3; // Checks whether remaining space on this line is usable. If too few // characters can be encoded, start a new line. bool startNewLine = true; if (curLineLength + 2 < maxLineLength2) { const string::size_type remainingSpaceOnLine = maxLineLength2 - curLineLength - 2; if (remainingSpaceOnLine < minWordLength + 10) { // Space for no more than 10 encoded chars! // It is not worth while to continue on this line... startNewLine = true; } else { // OK, there is enough usable space on the current line. startNewLine = false; } } if (startNewLine) { os << NEW_LINE_SEQUENCE; curLineLength = NEW_LINE_SEQUENCE_LENGTH; state->lastCharIsSpace = true; } // Encode and fold input buffer if (!startNewLine && !state->isFirstWord && !state->lastCharIsSpace) { os << " "; // Separate from previous word ++curLineLength; state->lastCharIsSpace = true; } for (unsigned int i = 0 ; ; ++i) { // Compute the number of encoded chars that will fit on this line const string::size_type fit = maxLineLength2 - minWordLength - (i == 0 ? curLineLength : NEW_LINE_SEQUENCE_LENGTH); // Get the next encoded chunk const string chunk = wordEnc.getNextChunk(fit); if (chunk.empty()) break; // Start a new encoded word if (i != 0) { os << NEW_LINE_SEQUENCE; curLineLength = NEW_LINE_SEQUENCE_LENGTH; } os << wordStart; curLineLength += minWordLength; os << chunk; curLineLength += chunk.length(); // End of the encoded word os << wordEnd; state->prevWordIsEncoded = true; state->lastCharIsSpace = false; } } if (newLinePos) *newLinePos = curLineLength; state->isFirstWord = false; } word& word::operator=(const word& w) { m_buffer = w.m_buffer; m_charset = w.m_charset; return (*this); } word& word::operator=(const string& s) { m_buffer = s; return (*this); } void word::copyFrom(const component& other) { const word& w = dynamic_cast (other); m_buffer = w.m_buffer; m_charset = w.m_charset; } bool word::operator==(const word& w) const { return (m_charset == w.m_charset && m_buffer == w.m_buffer); } bool word::operator!=(const word& w) const { return (m_charset != w.m_charset || m_buffer != w.m_buffer); } const string word::getConvertedText(const charset& dest) const { string out; charset::convert(m_buffer, out, m_charset, dest); return (out); } ref word::clone() const { return vmime::create (m_buffer, m_charset); } const charset& word::getCharset() const { return (m_charset); } void word::setCharset(const charset& ch) { m_charset = ch; } const string& word::getBuffer() const { return (m_buffer); } string& word::getBuffer() { return (m_buffer); } bool word::isEmpty() const { return m_buffer.empty(); } void word::setBuffer(const string& buffer) { m_buffer = buffer; } const std::vector > word::getChildComponents() const { return std::vector >(); } } // vmime libvmime-0.9.1/src/parameterizedHeaderField.cpp0000644000175000017500000003301011374031010022016 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/parameterizedHeaderField.hpp" #include "vmime/text.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { parameterizedHeaderField::parameterizedHeaderField() { } parameterizedHeaderField::~parameterizedHeaderField() { removeAllParameters(); } /* This class handles field contents of the following form: Field: VALUE; PARAM1="VALUE1"; PARAM2="VALUE2"... eg. RFC-1521 content := "Content-Type" ":" type "/" subtype *(";" parameter) parameter := attribute "=" value attribute := token ; case-insensitive value := token / quoted-string token := 1* tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> / "/" / "[" / "]" / "?" / "=" ; Must be in quoted-string, ; to use within parameter values */ #ifndef VMIME_BUILDING_DOC struct paramInfo { bool extended; std::vector value; string::size_type start; string::size_type end; }; #endif // VMIME_BUILDING_DOC void parameterizedHeaderField::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { const string::value_type* const pend = buffer.data() + end; const string::value_type* const pstart = buffer.data() + position; const string::value_type* p = pstart; // Skip non-significant whitespaces string::size_type valueStart = position; while (p < pend && parserHelpers::isSpace(*p)) { ++p; ++valueStart; } // Advance up to ';', if any string::size_type valueLength = 0; while (p < pend && *p != ';') // FIXME: support ";" inside quoted or RFC-2047-encoded text { ++p; ++valueLength; } // Trim whitespaces at the end of the value while (valueLength > 0 && parserHelpers::isSpace(buffer[valueStart + valueLength - 1])) --valueLength; // Parse value getValue()->parse(buffer, valueStart, valueStart + valueLength); // Reset parameters removeAllParameters(); // If there is one or more parameters following... if (p < pend) { std::map params; while (*p == ';') { // Skip ';' ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; const string::size_type attrStart = position + (p - pstart); while (p < pend && !(*p == ';' || *p == '=')) ++p; if (p >= pend || *p == ';') { // Hmmmm... we didn't found an '=' sign. // This parameter may not be valid so try to advance // to the next one, if there is one. while (p < pend && *p != ';') ++p; } else { // Extract the attribute name string::size_type attrEnd = position + (p - pstart); while (attrEnd != attrStart && parserHelpers::isSpace(buffer[attrEnd - 1])) --attrEnd; // Skip '=' ++p; // Skip white-spaces between '=' and the value while (p < pend && parserHelpers::isSpace(*p)) ++p; // Extract the value string value; // -- this is a quoted-string if (*p == '"') { // Skip '"' ++p; // Extract quoted-string bool escape = false; bool stop = false; std::ostringstream ss; string::size_type start = position + (p - pstart); for ( ; p < pend && !stop ; ++p) { if (escape) { escape = false; start = position + (p - pstart); } else { switch (*p) { case '"': { ss << string(buffer.begin() + start, buffer.begin() + position + (p - pstart)); stop = true; break; } case '\\': { ss << string(buffer.begin() + start, buffer.begin() + position + (p - pstart)); escape = true; break; } } } } if (!stop) { ss << string(buffer.begin() + start, buffer.begin() + position + (p - pstart)); } value = ss.str(); } // -- the value is a simple token else { const string::size_type valStart = position + (p - pstart); while (p < pend && *p != ';') ++p; string::size_type valEnd = position + (p - pstart); while (valEnd != valStart && parserHelpers::isSpace(buffer[valEnd - 1])) --valEnd; value = string(buffer.begin() + valStart, buffer.begin() + valEnd); } // Don't allow ill-formed parameters if (attrStart != attrEnd && value.length()) { string name(buffer.begin() + attrStart, buffer.begin() + attrEnd); // Check for RFC-2231 extended parameters bool extended = false; bool encoded = false; if (name[name.length() - 1] == '*') { name.erase(name.end() - 1, name.end()); extended = true; encoded = true; } // Check for RFC-2231 multi-section parameters const string::size_type star = name.find_last_of('*'); if (star != string::npos) { bool allDigits = true; for (string::size_type i = star + 1 ; allDigits && (i < name.length()) ; ++i) allDigits = parserHelpers::isDigit(name[i]); if (allDigits) { name.erase(name.begin() + star, name.end()); extended = true; } // NOTE: we ignore section number, and we suppose that // the sequence is correct (ie. the sections appear // in order: param*0, param*1...) } // Add/replace/modify the parameter const std::map ::iterator it = params.find(name); if (it != params.end()) { paramInfo& info = (*it).second; // An extended parameter replaces a normal one if (!info.extended) { info.extended = extended; info.value.clear(); info.start = attrStart; } // Append a new section for a multi-section parameter parameter::valueChunk chunk; chunk.encoded = encoded; chunk.data = value; info.value.push_back(chunk); info.end = position + (p - pstart); } else { parameter::valueChunk chunk; chunk.encoded = encoded; chunk.data = value; paramInfo info; info.extended = extended; info.value.push_back(chunk); info.start = attrStart; info.end = position + (p - pstart); // Insert a new parameter params.insert(std::map ::value_type(name, info)); } } // Skip white-spaces after this parameter while (p < pend && parserHelpers::isSpace(*p)) ++p; } } for (std::map ::const_iterator it = params.begin() ; it != params.end() ; ++it) { const paramInfo& info = (*it).second; // Append this parameter to the list ref param = vmime::create ((*it).first); param->parse(info.value); param->setParsedBounds(info.start, info.end); appendParameter(param); } } if (newPosition) *newPosition = end; } void parameterizedHeaderField::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { string::size_type pos = curLinePos; // Parent header field headerField::generate(os, maxLineLength, pos, &pos); // Parameters for (std::vector >::const_iterator it = m_params.begin() ; it != m_params.end() ; ++it) { os << "; "; pos += 2; (*it)->generate(os, maxLineLength, pos, &pos); } if (newLinePos) *newLinePos = pos; } void parameterizedHeaderField::copyFrom(const component& other) { headerField::copyFrom(other); const parameterizedHeaderField& source = dynamic_cast(other); removeAllParameters(); for (std::vector >::const_iterator i = source.m_params.begin() ; i != source.m_params.end() ; ++i) { appendParameter((*i)->clone().dynamicCast ()); } } parameterizedHeaderField& parameterizedHeaderField::operator=(const parameterizedHeaderField& other) { copyFrom(other); return (*this); } bool parameterizedHeaderField::hasParameter(const string& paramName) const { const string name = utility::stringUtils::toLower(paramName); std::vector >::const_iterator pos = m_params.begin(); const std::vector >::const_iterator end = m_params.end(); for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {} return (pos != end); } ref parameterizedHeaderField::findParameter(const string& paramName) const { const string name = utility::stringUtils::toLower(paramName); // Find the first parameter that matches the specified name std::vector >::const_iterator pos = m_params.begin(); const std::vector >::const_iterator end = m_params.end(); for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {} // No parameter with this name can be found if (pos == end) { throw exceptions::no_such_parameter(paramName); } // Else, return a reference to the existing parameter else { return (*pos); } } ref parameterizedHeaderField::getParameter(const string& paramName) { const string name = utility::stringUtils::toLower(paramName); // Find the first parameter that matches the specified name std::vector >::const_iterator pos = m_params.begin(); const std::vector >::const_iterator end = m_params.end(); for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {} // If no parameter with this name can be found, create a new one if (pos == end) { ref param = vmime::create (paramName); appendParameter(param); // Return a reference to the new parameter return (param); } // Else, return a reference to the existing parameter else { return (*pos); } } void parameterizedHeaderField::appendParameter(ref param) { m_params.push_back(param); } void parameterizedHeaderField::insertParameterBefore(ref beforeParam, ref param) { const std::vector >::iterator it = std::find (m_params.begin(), m_params.end(), beforeParam); if (it == m_params.end()) throw exceptions::no_such_parameter(beforeParam->getName()); m_params.insert(it, param); } void parameterizedHeaderField::insertParameterBefore(const int pos, ref param) { m_params.insert(m_params.begin() + pos, param); } void parameterizedHeaderField::insertParameterAfter(ref afterParam, ref param) { const std::vector >::iterator it = std::find (m_params.begin(), m_params.end(), afterParam); if (it == m_params.end()) throw exceptions::no_such_parameter(afterParam->getName()); m_params.insert(it + 1, param); } void parameterizedHeaderField::insertParameterAfter(const int pos, ref param) { m_params.insert(m_params.begin() + pos + 1, param); } void parameterizedHeaderField::removeParameter(ref param) { const std::vector >::iterator it = std::find (m_params.begin(), m_params.end(), param); if (it == m_params.end()) throw exceptions::no_such_parameter(param->getName()); m_params.erase(it); } void parameterizedHeaderField::removeParameter(const int pos) { const std::vector >::iterator it = m_params.begin() + pos; m_params.erase(it); } void parameterizedHeaderField::removeAllParameters() { m_params.clear(); } int parameterizedHeaderField::getParameterCount() const { return (m_params.size()); } bool parameterizedHeaderField::isEmpty() const { return (m_params.empty()); } const ref parameterizedHeaderField::getParameterAt(const int pos) { return (m_params[pos]); } const ref parameterizedHeaderField::getParameterAt(const int pos) const { return (m_params[pos]); } const std::vector > parameterizedHeaderField::getParameterList() const { std::vector > list; list.reserve(m_params.size()); for (std::vector >::const_iterator it = m_params.begin() ; it != m_params.end() ; ++it) { list.push_back(*it); } return (list); } const std::vector > parameterizedHeaderField::getParameterList() { return (m_params); } const std::vector > parameterizedHeaderField::getChildComponents() const { std::vector > list = headerField::getChildComponents(); for (std::vector >::const_iterator it = m_params.begin() ; it != m_params.end() ; ++it) { list.push_back(*it); } return (list); } } // vmime libvmime-0.9.1/src/address.cpp0000644000175000017500000000751211250723263016555 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/address.hpp" #include "vmime/mailbox.hpp" #include "vmime/mailboxGroup.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { address::address() { } /* RFC #2822: 3.4. ADDRESS SPECIFICATION Addresses occur in several message header fields to indicate senders and recipients of messages. An address may either be an individual mailbox, or a group of mailboxes. address = mailbox / group mailbox = name-addr / addr-spec name-addr = [display-name] angle-addr angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr group = display-name ":" [mailbox-list / CFWS] ";" [CFWS] display-name = phrase mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list address-list = (address *("," address)) / obs-addr-list */ ref
address::parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { bool escaped = false; bool quoted = false; bool quotedRFC2047 = false; bool inRouteAddr = false; bool isGroup = false; bool stop = false; string::size_type pos = position; while (pos < end && parserHelpers::isSpace(buffer[pos])) ++pos; const string::size_type start = pos; while (!stop && pos < end) { if (escaped) { escaped = false; } else { switch (buffer[pos]) { case '\\': escaped = true; break; case '"': quoted = !quoted; break; case '<': inRouteAddr = true; break; case '>': inRouteAddr = false; break; case '=': if (!quoted && !quotedRFC2047 && pos + 1 < end && buffer[pos + 1] == '?') { ++pos; quotedRFC2047 = true; } break; case '?': if (quotedRFC2047 && pos + 1 < end && buffer[pos + 1] == '=') { ++pos; quotedRFC2047 = false; } break; default: { if (!quoted && !quotedRFC2047 && !inRouteAddr) { switch (buffer[pos]) { case ';': if (isGroup) { if (pos + 1 < end && buffer[pos + 1] == ',') ++pos; } stop = true; break; case ':': isGroup = true; break; case ',': if (!isGroup) stop = true; break; } } break; } } } if (!stop) ++pos; } if (newPosition) { if (pos == end) *newPosition = end; else *newPosition = pos + 1; // ',' or ';' } // Parse extracted address (mailbox or group) if (pos != start) { ref
parsedAddress = isGroup ? create ().dynamicCast
() : create ().dynamicCast
(); parsedAddress->parse(buffer, start, pos, NULL); parsedAddress->setParsedBounds(start, pos); return (parsedAddress); } return (NULL); } } // vmime libvmime-0.9.1/src/contentDispositionField.cpp0000644000175000017500000000513111250723263021766 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/contentDispositionField.hpp" #include "vmime/exception.hpp" namespace vmime { contentDispositionField::contentDispositionField() { } contentDispositionField::contentDispositionField(contentDispositionField&) : headerField(), parameterizedHeaderField() { } const datetime contentDispositionField::getCreationDate() const { return findParameter("creation-date")->getValueAs (); } void contentDispositionField::setCreationDate(const datetime& creationDate) { getParameter("creation-date")->setValue(creationDate); } const datetime contentDispositionField::getModificationDate() const { return findParameter("modification-date")->getValueAs (); } void contentDispositionField::setModificationDate(const datetime& modificationDate) { getParameter("modification-date")->setValue(modificationDate); } const datetime contentDispositionField::getReadDate() const { return findParameter("read-date")->getValueAs (); } void contentDispositionField::setReadDate(const datetime& readDate) { getParameter("read-date")->setValue(readDate); } const word contentDispositionField::getFilename() const { return findParameter("filename")->getValue(); } void contentDispositionField::setFilename(const word& filename) { getParameter("filename")->setValue(filename); } const string contentDispositionField::getSize() const { return findParameter("size")->getValue().getBuffer(); } void contentDispositionField::setSize(const string& size) { getParameter("size")->setValue(word(size, vmime::charsets::US_ASCII)); } } // vmime libvmime-0.9.1/src/dateTime.cpp0000644000175000017500000005072411250723263016667 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include "vmime/dateTime.hpp" #include "vmime/platform.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/utility/datetimeUtils.hpp" namespace vmime { /* RFC #822: 5. DATE AND TIME SPECIFICATION date-time = [ day "," ] date time ; dd mm yy ; hh:mm:ss zzz day = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun" date = 1*2DIGIT month 2DIGIT ; day month year ; e.g. 20 Jun 82 month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" time = hour zone ; ANSI and Military hour = 2DIGIT ":" 2DIGIT [":" 2DIGIT] ; 00:00:00 - 23:59:59 zone = "UT" / "GMT" ; Universal Time ; North American : UT / "EST" / "EDT" ; Eastern: - 5/ - 4 / "CST" / "CDT" ; Central: - 6/ - 5 / "MST" / "MDT" ; Mountain: - 7/ - 6 / "PST" / "PDT" ; Pacific: - 8/ - 7 / 1ALPHA ; Military: Z = UT; ; A:-1; (J not used) ; M:-12; N:+1; Y:+12 / ( ("+" / "-") 4DIGIT ) ; Local differential ; hours+min. (HHMM) */ void datetime::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { const string::value_type* const pend = buffer.data() + end; const string::value_type* p = buffer.data() + position; // Parse the date and time value while (p < pend && parserHelpers::isSpace(*p)) ++p; if (p < pend) { if (parserHelpers::isAlpha(*p)) { // Ignore week day while (p < pend && parserHelpers::isAlpha(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; if (p < pend && *p == ',') ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } bool dayParsed = false; if (parserHelpers::isAlpha(*p)) { // Ill-formed date/time, this may be the month, // so we skip day parsing (will be done later) } else { while (p < pend && !parserHelpers::isDigit(*p)) ++p; if (p < pend && parserHelpers::isDigit(*p)) { // Month day int day = 0; do { day = day * 10 + (*p - '0'); ++p; } while (p < pend && parserHelpers::isDigit(*p)); m_day = (day >= 1 && day <= 31) ? day : 1; while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } else { m_day = 1; // Skip everything to the next field while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } dayParsed = true; } if (p < pend && parserHelpers::isAlpha(*p)) { // Month char_t month[4] = { 0 }; int monthLength = 0; do { month[monthLength++] = *p; ++p; } while (monthLength < 3 && p < pend && parserHelpers::isAlpha(*p)); while (p < pend && parserHelpers::isAlpha(*p)) ++p; switch (month[0]) { case 'a': case 'A': { if (month[1] == 'u' || month[1] == 'U') m_month = AUGUST; else m_month = APRIL; // by default break; } case 'd': case 'D': { m_month = DECEMBER; break; } case 'f': case 'F': { m_month = FEBRUARY; break; } case 'j': case 'J': { if (month[1] == 'u' || month[1] == 'U') { if (month[2] == 'l' || month[2] == 'L') m_month = JULY; else // if (month[2] == 'n' || month[2] == 'N') m_month = JUNE; } else { m_month = JANUARY; // by default } break; } case 'm': case 'M': { if ((month[1] == 'a' || month[1] == 'A') && (month[2] == 'y' || month[2] == 'Y')) { m_month = MAY; } else { m_month = MARCH; // by default } break; } case 'n': case 'N': { m_month = NOVEMBER; break; } case 'o': case 'O': { m_month = OCTOBER; break; } case 's': case 'S': { m_month = SEPTEMBER; break; } default: { m_month = JANUARY; // by default break; } } while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } else { m_month = JANUARY; if (parserHelpers::isDigit(*p)) { // Here, we expected a month, but it maybe // a ill-formed date, so try to parse a year // (we don't skip anything). } else { // Skip everything to the next field while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } } if (!dayParsed && p < pend && parserHelpers::isDigit(*p)) { // Month day int day = 0; do { day = day * 10 + (*p - '0'); ++p; } while (p < pend && parserHelpers::isDigit(*p)); m_day = (day >= 1 && day <= 31) ? day : 1; while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } if (p < pend && parserHelpers::isDigit(*p)) { // Check for ill-formed date/time and try to recover if (p + 2 < pend && *(p + 2) == ':') { // Skip year (default to current), and advance // to time parsing m_year = now().getYear(); } else { // Year int year = 0; do { year = year * 10 + (*p - '0'); ++p; } while (p < pend && parserHelpers::isDigit(*p)); if (year < 70) m_year = year + 2000; else if (year < 1000) m_year = year + 1900; else m_year = year; while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } } else { m_year = 1970; // Skip everything to the next field while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } if (p < pend && parserHelpers::isDigit(*p)) { // Hour int hour = 0; do { hour = hour * 10 + (*p - '0'); ++p; } while (p < pend && parserHelpers::isDigit(*p)); m_hour = (hour >= 0 && hour <= 23) ? hour : 0; while (p < pend && parserHelpers::isSpace(*p)) ++p; if (p < pend && *p == ':') { ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; if (p < pend && parserHelpers::isDigit(*p)) { // Minute int minute = 0; do { minute = minute * 10 + (*p - '0'); ++p; } while (p < pend && parserHelpers::isDigit(*p)); m_minute = (minute >= 0 && minute <= 59) ? minute : 0; while (p < pend && parserHelpers::isSpace(*p)) ++p; if (p < pend && *p == ':') { ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; if (p < pend && parserHelpers::isDigit(*p)) { // Second int second = 0; do { second = second * 10 + (*p - '0'); ++p; } while (p < pend && parserHelpers::isDigit(*p)); m_second = (second >= 0 && second <= 59) ? second : 0; while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } else { m_second = 0; } } else { m_second = 0; } } else { m_minute = 0; } } else { m_minute = 0; } } else { m_hour = 0; // Skip everything to the next field while (p < pend && !parserHelpers::isSpace(*p)) ++p; while (p < pend && parserHelpers::isSpace(*p)) ++p; } if (p + 1 < pend && (*p == '+' || *p == '-') && parserHelpers::isDigit(*(p + 1))) { const char_t sign = *p; ++p; // Zone offset (in hour/minutes) int offset = 0; do { offset = offset * 10 + (*p - '0'); ++p; } while (p < pend && parserHelpers::isDigit(*p)); const int hourOff = offset / 100; const int minOff = offset % 100; if (sign == '+') m_zone = hourOff * 60 + minOff; else m_zone = -(hourOff * 60 + minOff); } else if (p < pend && isalpha(*p)) { bool done = false; // Zone offset (Time zone name) char_t zone[4] = { 0 }; int zoneLength = 0; do { zone[zoneLength++] = *p; ++p; } while (zoneLength < 3 && p < pend); switch (zone[0]) { case 'c': case 'C': { if (zoneLength >= 2) { if (zone[1] == 's' || zone[1] == 'S') m_zone = CST; else m_zone = CDT; done = true; } break; } case 'e': case 'E': { if (zoneLength >= 2) { if (zone[1] == 's' || zone[1] == 'S') m_zone = EST; else m_zone = EDT; done = true; } break; } case 'm': case 'M': { if (zoneLength >= 2) { if (zone[1] == 's' || zone[1] == 'S') m_zone = MST; else m_zone = MDT; done = true; } break; } case 'p': case 'P': { if (zoneLength >= 2) { if (zone[1] == 's' || zone[1] == 'S') m_zone = PST; else m_zone = PDT; done = true; } break; } case 'g': case 'G': case 'u': case 'U': { if (zoneLength >= 2) { m_zone = GMT; // = UTC done = true; } break; } } if (!done) { const char_t z = zone[0]; // Military time zone if (z != 'j' && z != 'J') { typedef std::map Map; static const Map::value_type offsetMapInit[] = { Map::value_type('a', -60), Map::value_type('b', -120), Map::value_type('c', -180), Map::value_type('d', -240), Map::value_type('e', -300), Map::value_type('f', -360), Map::value_type('g', -420), Map::value_type('h', -480), Map::value_type('i', -540), Map::value_type('k', -600), Map::value_type('l', -660), Map::value_type('m', -720), Map::value_type('n', 60), Map::value_type('o', 120), Map::value_type('p', 180), Map::value_type('q', 240), Map::value_type('r', 300), Map::value_type('s', 360), Map::value_type('t', 420), Map::value_type('u', 480), Map::value_type('v', 540), Map::value_type('w', 600), Map::value_type('x', 660), Map::value_type('y', 720), Map::value_type('z', 0), }; static const Map offsetMap (::vmime::begin(offsetMapInit), ::vmime::end(offsetMapInit)); Map::const_iterator pos = offsetMap.find(parserHelpers::toLower(z)); if (pos != offsetMap.end()) m_zone = (*pos).second; else m_zone = GMT; } else { m_zone = GMT; } } } else { m_zone = 0; } } else { m_year = 1970; m_month = JANUARY; m_day = 1; m_hour = 0; m_minute = 0; m_second = 0; m_zone = 0; } setParsedBounds(position, end); if (newPosition) *newPosition = end; } void datetime::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, const string::size_type curLinePos, string::size_type* newLinePos) const { static const string::value_type* dayNames[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const string::value_type* monthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; const int z = ((m_zone < 0) ? -m_zone : m_zone); const int zh = z / 60; const int zm = z % 60; std::ostringstream oss; oss.imbue(std::locale::classic()); oss << dayNames[getWeekDay()] << ", " << m_day << " " << monthNames[m_month - 1] << " " << m_year << " " << std::setfill('0') << std::setw(2) << m_hour << ":" << std::setfill('0') << std::setw(2) << m_minute << ":" << std::setfill('0') << std::setw(2) << m_second << " " << ((m_zone < 0) ? '-' : '+') << std::setfill('0') << std::setw(2) << zh << std::setfill('0') << std::setw(2) << zm; const string& str = oss.str(); os << str; if (newLinePos) *newLinePos = curLinePos + str.length(); } datetime::datetime() : m_year(1970), m_month(1), m_day(1), m_hour(0), m_minute(0), m_second(0), m_zone(0) { } datetime::datetime(const int year, const int month, const int day) : m_year(year), m_month(month), m_day(day), m_hour(0), m_minute(0), m_second(0), m_zone(0) { } datetime::datetime(const int year, const int month, const int day, const int hour, const int minute, const int second, const int zone) : m_year(year), m_month(month), m_day(day), m_hour(hour), m_minute(minute), m_second(second), m_zone(zone) { } datetime::datetime(const datetime& d) : headerFieldValue(), m_year(d.m_year), m_month(d.m_month), m_day(d.m_day), m_hour(d.m_hour), m_minute(d.m_minute), m_second(d.m_second), m_zone(d.m_zone) { } datetime::datetime(const time_t t, const int zone) { #if defined(_MSC_VER) || defined(__MINGW32__) // These functions are reentrant in MS C runtime library struct tm* gtm = gmtime(&t); struct tm* ltm = localtime(&t); struct tm tms; if (gtm) tms = *gtm; else if (ltm) tms = *ltm; #elif defined(_REENTRANT) struct tm tms; if (!gmtime_r(&t, &tms)) localtime_r(&t, &tms); #else struct tm* gtm = gmtime(&t); struct tm* ltm = localtime(&t); struct tm tms; if (gtm) tms = *gtm; else if (ltm) tms = *ltm; #endif // _REENTRANT m_year = tms.tm_year + 1900; m_month = tms.tm_mon + 1; m_day = tms.tm_mday; m_hour = tms.tm_hour; m_minute = tms.tm_min; m_second = tms.tm_sec; m_zone = zone; } datetime::datetime(const string& date) { parse(date); } datetime::~datetime() { } void datetime::copyFrom(const component& other) { const datetime& d = dynamic_cast (other); m_year = d.m_year; m_month = d.m_month; m_day = d.m_day; m_hour = d.m_hour; m_minute = d.m_minute; m_second = d.m_second; m_zone = d.m_zone; } datetime& datetime::operator=(const datetime& other) { copyFrom(other); return (*this); } datetime& datetime::operator=(const string& s) { parse(s); return (*this); } void datetime::getTime(int& hour, int& minute, int& second, int& zone) const { hour = m_hour; minute = m_minute; second = m_second; zone = m_zone; } void datetime::getTime(int& hour, int& minute, int& second) const { hour = m_hour; minute = m_minute; second = m_second; } void datetime::getDate(int& year, int& month, int& day) const { year = m_year; month = m_month; day = m_day; } void datetime::setTime(const int hour, const int minute, const int second, const int zone) { m_hour = hour; m_minute = minute; m_second = second; m_zone = zone; } void datetime::setDate(const int year, const int month, const int day) { m_year = year; m_month = month; m_day = day; } const datetime datetime::now() { return (platform::getHandler()->getCurrentLocalTime()); } ref datetime::clone() const { return vmime::create (*this); } const std::vector > datetime::getChildComponents() const { return std::vector >(); } int datetime::getYear() const { return (m_year); } int datetime::getMonth() const { return (m_month); } int datetime::getDay() const { return (m_day); } int datetime::getHour() const { return (m_hour); } int datetime::getMinute() const { return (m_minute); } int datetime::getSecond() const { return (m_second); } int datetime::getZone() const { return (m_zone); } int datetime::getWeekDay() const { return (utility::datetimeUtils::getDayOfWeek(m_year, m_month, m_day)); } int datetime::getWeek() const { return utility::datetimeUtils::getWeekOfYear(m_year, m_month, m_day); } void datetime::setYear(const int year) { m_year = year; } void datetime::setMonth(const int month) { m_month = std::min(std::max(month, 1), 12); } void datetime::setDay(const int day) { m_day = day; } void datetime::setHour(const int hour) { m_hour = hour; } void datetime::setMinute(const int minute) { m_minute = minute; } void datetime::setSecond(const int second) { m_second = second; } void datetime::setZone(const int zone) { m_zone = zone; } bool datetime::operator==(const datetime& other) const { const datetime ut1 = utility::datetimeUtils::toUniversalTime(*this); const datetime ut2 = utility::datetimeUtils::toUniversalTime(other); return (ut1.m_year == ut2.m_year && ut1.m_month == ut2.m_month && ut1.m_day == ut2.m_day && ut1.m_hour == ut2.m_hour && ut1.m_minute == ut2.m_minute && ut1.m_second == ut2.m_second); } bool datetime::operator!=(const datetime& other) const { const datetime ut1 = utility::datetimeUtils::toUniversalTime(*this); const datetime ut2 = utility::datetimeUtils::toUniversalTime(other); return (ut1.m_year != ut2.m_year || ut1.m_month != ut2.m_month || ut1.m_day != ut2.m_day || ut1.m_hour != ut2.m_hour || ut1.m_minute != ut2.m_minute || ut1.m_second != ut2.m_second); } bool datetime::operator<(const datetime& other) const { const datetime ut1 = utility::datetimeUtils::toUniversalTime(*this); const datetime ut2 = utility::datetimeUtils::toUniversalTime(other); return ((ut1.m_year < ut2.m_year) || ((ut1.m_year == ut2.m_year) && ((ut1.m_month < ut2.m_month) || ((ut1.m_month == ut2.m_month) && ((ut1.m_day < ut2.m_day) || ((ut1.m_day == ut2.m_day) && ((ut1.m_hour < ut2.m_hour) || ((ut1.m_hour == ut2.m_hour) && ((ut1.m_minute < ut2.m_minute) || ((ut1.m_minute == ut2.m_minute) && ((ut1.m_second < ut2.m_second)))))))))))); } bool datetime::operator<=(const datetime& other) const { const datetime ut1 = utility::datetimeUtils::toUniversalTime(*this); const datetime ut2 = utility::datetimeUtils::toUniversalTime(other); return ((ut1.m_year < ut2.m_year) || ((ut1.m_year == ut2.m_year) && ((ut1.m_month < ut2.m_month) || ((ut1.m_month == ut2.m_month) && ((ut1.m_day < ut2.m_day) || ((ut1.m_day == ut2.m_day) && ((ut1.m_hour < ut2.m_hour) || ((ut1.m_hour == ut2.m_hour) && ((ut1.m_minute < ut2.m_minute) || ((ut1.m_minute == ut2.m_minute) && ((ut1.m_second <= ut2.m_second)))))))))))); } bool datetime::operator>(const datetime& other) const { const datetime ut1 = utility::datetimeUtils::toUniversalTime(*this); const datetime ut2 = utility::datetimeUtils::toUniversalTime(other); return ((ut1.m_year > ut2.m_year) || ((ut1.m_year == ut2.m_year) && ((ut1.m_month > ut2.m_month) || ((ut1.m_month == ut2.m_month) && ((ut1.m_day > ut2.m_day) || ((ut1.m_day == ut2.m_day) && ((ut1.m_hour > ut2.m_hour) || ((ut1.m_hour == ut2.m_hour) && ((ut1.m_minute > ut2.m_minute) || ((ut1.m_minute == ut2.m_minute) && (ut1.m_second > ut2.m_second))))))))))); } bool datetime::operator>=(const datetime& other) const { const datetime ut1 = utility::datetimeUtils::toUniversalTime(*this); const datetime ut2 = utility::datetimeUtils::toUniversalTime(other); return ((ut1.m_year > ut2.m_year) || ((ut1.m_year == ut2.m_year) && ((ut1.m_month > ut2.m_month) || ((ut1.m_month == ut2.m_month) && ((ut1.m_day > ut2.m_day) || ((ut1.m_day == ut2.m_day) && ((ut1.m_hour > ut2.m_hour) || ((ut1.m_hour == ut2.m_hour) && ((ut1.m_minute > ut2.m_minute) || ((ut1.m_minute == ut2.m_minute) && (ut1.m_second >= ut2.m_second))))))))))); } } // vmime libvmime-0.9.1/src/bodyPart.cpp0000644000175000017500000000637711374045024016723 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/bodyPart.hpp" namespace vmime { bodyPart::bodyPart() : m_header(vmime::create
()), m_body(vmime::create ()), m_parent(NULL) { m_body->setParentPart(thisRef().dynamicCast ()); } bodyPart::bodyPart(weak_ref parentPart) : m_header(vmime::create
()), m_body(vmime::create ()), m_parent(parentPart) { m_body->setParentPart(thisRef().dynamicCast ()); } void bodyPart::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { // Parse the headers string::size_type pos = position; m_header->parse(buffer, pos, end, &pos); // Parse the body contents m_body->parse(buffer, pos, end, NULL); setParsedBounds(position, end); if (newPosition) *newPosition = end; } void bodyPart::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type /* curLinePos */, string::size_type* newLinePos) const { m_header->generate(os, maxLineLength); os << CRLF; m_body->generate(os, maxLineLength); if (newLinePos) *newLinePos = 0; } ref bodyPart::clone() const { ref p = vmime::create (); p->m_parent = null; p->m_header->copyFrom(*m_header); p->m_body->copyFrom(*m_body); return (p); } void bodyPart::copyFrom(const component& other) { const bodyPart& bp = dynamic_cast (other); m_header->copyFrom(*(bp.m_header)); m_body->copyFrom(*(bp.m_body)); } bodyPart& bodyPart::operator=(const bodyPart& other) { copyFrom(other); return (*this); } const ref bodyPart::getHeader() const { return (m_header); } ref
bodyPart::getHeader() { return (m_header); } const ref bodyPart::getBody() const { return (m_body); } ref bodyPart::getBody() { return (m_body); } ref bodyPart::getParentPart() { return m_parent.acquire(); } ref bodyPart::getParentPart() const { return m_parent.acquire(); } const std::vector > bodyPart::getChildComponents() const { std::vector > list; list.push_back(m_header); list.push_back(m_body); return (list); } } // vmime libvmime-0.9.1/src/headerField.cpp0000644000175000017500000001701411374231602017320 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/headerField.hpp" #include "vmime/headerFieldFactory.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { headerField::headerField() : m_name("X-Undefined") { } headerField::headerField(const string& fieldName) : m_name(fieldName) { } headerField::~headerField() { } ref headerField::clone() const { ref field = headerFieldFactory::getInstance()->create(m_name); field->copyFrom(*this); return (field); } void headerField::copyFrom(const component& other) { const headerField& hf = dynamic_cast (other); m_value->copyFrom(*hf.m_value); } headerField& headerField::operator=(const headerField& other) { copyFrom(other); return (*this); } ref headerField::parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { string::size_type pos = position; while (pos < end) { char_t c = buffer[pos]; // Check for end of headers (empty line): although RFC-822 recommends // to use CRLF for header/body separator (see 4.1 SYNTAX), here, we // also check for LF for compatibility with broken implementations... if (c == '\n') { if (newPosition) *newPosition = pos + 1; // LF: illegal return (NULL); } else if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n') { if (newPosition) *newPosition = pos + 2; // CR+LF return (NULL); } // This line may be a field description if (!parserHelpers::isSpace(c)) { const string::size_type nameStart = pos; // remember the start position of the line while (pos < end && (buffer[pos] != ':' && !parserHelpers::isSpace(buffer[pos]))) ++pos; const string::size_type nameEnd = pos; while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t')) ++pos; if (buffer[pos] != ':') { // Humm...does not seem to be a valid header line. // Skip this error and advance to the next line pos = nameStart; while (pos < end && buffer[pos] != '\n') ++pos; if (pos < end && buffer[pos] == '\n') ++pos; } else { // Extract the field name const string name(buffer.begin() + nameStart, buffer.begin() + nameEnd); // Skip ':' character ++pos; // Skip spaces between ':' and the field contents while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t')) ++pos; const string::size_type contentsStart = pos; string::size_type contentsEnd = 0; // Extract the field value while (pos < end) { c = buffer[pos]; // Check for folded line if (c == '\r' && pos + 2 < end && buffer[pos + 1] == '\n' && (buffer[pos + 2] == ' ' || buffer[pos + 2] == '\t')) { pos += 3; } // Check for end of contents if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n') { contentsEnd = pos; pos += 2; break; } else if (c == '\n') { contentsEnd = pos; ++pos; break; } while (pos < end) { c = buffer[pos]; // Check for end of line if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n') { contentsEnd = pos; pos += 2; break; } else if (c == '\n') { contentsEnd = pos; ++pos; break; } ++pos; } // Handle the case of folded lines if (buffer[pos] == ' ' || buffer[pos] == '\t') { // This is a folding white-space: we keep it as is and // we continue with contents parsing... // If the line contains only space characters, we assume it is // the end of the headers. This is not strictly standard-compliant // but, hey, we can't fail when parsing some malformed mails... while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t')) ++pos; if ((pos < end && buffer[pos] == '\n') || (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] == '\n')) { break; } } else { // End of this field break; } } // Return a new field ref field = headerFieldFactory::getInstance()->create(name); field->parse(buffer, contentsStart, contentsEnd, NULL); field->setParsedBounds(nameStart, pos); if (newPosition) *newPosition = pos; return (field); } } else { // If the line contains only space characters, we assume it is // the end of the headers. while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t')) ++pos; if (pos < end && buffer[pos] == '\n') { if (newPosition) *newPosition = pos + 1; // LF: illegal return NULL; } else if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] == '\n') { if (newPosition) *newPosition = pos + 2; // CR+LF return NULL; } // Skip this error and advance to the next line while (pos < end && buffer[pos] != '\n') ++pos; if (buffer[pos] == '\n') ++pos; } } if (newPosition) *newPosition = pos; return (NULL); } void headerField::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { m_value->parse(buffer, position, end, newPosition); } void headerField::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { os << m_name + ": "; m_value->generate(os, maxLineLength, curLinePos + m_name.length() + 2, newLinePos); } const string headerField::getName() const { return m_name; } void headerField::setName(const string& name) { m_name = name; } bool headerField::isCustom() const { return (m_name.length() > 2 && m_name[0] == 'X' && m_name[1] == '-'); } const std::vector > headerField::getChildComponents() const { std::vector > list; if (m_value) list.push_back(m_value); return (list); } ref headerField::getValue() const { return m_value; } ref headerField::getValue() { return m_value; } void headerField::setValue(ref value) { if (value != NULL) m_value = value; } void headerField::setValueConst(ref value) { m_value = value->clone().dynamicCast (); } void headerField::setValue(const headerFieldValue& value) { m_value = value.clone().dynamicCast (); } void headerField::setValue(const string& value) { parse(value); } } // vmime libvmime-0.9.1/src/utility/0000755000175000017500000000000011607302335016121 5ustar mnordstrmnordstrlibvmime-0.9.1/src/utility/random.cpp0000644000175000017500000000377311250723262020117 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/random.hpp" #include "vmime/platform.hpp" #include namespace vmime { namespace utility { unsigned int random::m_next(static_cast(::std::time(NULL))); unsigned int random::getNext() { // Park and Miller's minimal standard generator: // xn+1 = (a * xn + b) mod c // xn+1 = (16807 * xn) mod (2^31 - 1) m_next = static_cast((16807 * m_next) % 2147483647ul); return (m_next); } unsigned int random::getTime() { return (platform::getHandler()->getUnixTime()); } unsigned int random::getProcess() { return (platform::getHandler()->getProcessId()); } const string random::getString(const int length, const string& randomChars) { string res; res.resize(length); const unsigned int x = randomChars.length(); int c = 0; while (c < length) { for (unsigned int n = random::getNext() ; n != 0 && c < length ; n /= x) { res[c++] = randomChars[n % x]; } } return (res); } } // utility } // vmime libvmime-0.9.1/src/utility/smartPtr.cpp0000644000175000017500000000240411250723262020441 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/object.hpp" #include "vmime/utility/smartPtr.hpp" namespace vmime { namespace utility { void refManager::deleteObjectImpl(object* obj) { obj->setRefManager(0); delete obj; } } // utility } // vmime libvmime-0.9.1/src/utility/datetimeUtils.cpp0000644000175000017500000001570011314151074021442 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/datetimeUtils.hpp" #include namespace vmime { namespace utility { #ifndef VMIME_BUILDING_DOC static inline void nextMonth(datetime& d) { if (d.getMonth() >= 12) { d.setMonth(1); d.setYear(d.getYear() + 1); } else { d.setMonth(d.getMonth() + 1); } } static inline void prevMonth(datetime& d) { if (d.getMonth() <= 1) { d.setYear(d.getYear() - 1); d.setMonth(12); } else { d.setMonth(d.getMonth() - 1); } } static inline void nextDay(datetime& d) { if (d.getDay() >= datetimeUtils::getDaysInMonth(d.getYear(), d.getMonth())) { d.setDay(1); nextMonth(d); } else { d.setDay(d.getDay() + 1); } } static inline void prevDay(datetime& d) { if (d.getDay() <= 1) { prevMonth(d); d.setDay(datetimeUtils::getDaysInMonth(d.getYear(), d.getMonth())); } else { d.setDay(d.getDay() - 1); } } static inline void nextHour(datetime& d) { if (d.getHour() >= 23) { d.setHour(0); nextDay(d); } else { d.setHour(d.getHour() + 1); } } static inline void prevHour(datetime& d) { if (d.getHour() <= 0) { d.setHour(23); prevDay(d); } else { d.setHour(d.getHour() - 1); } } static inline void addHoursAndMinutes(datetime& d, const int h, const int m) { d.setMinute(d.getMinute() + m); if (d.getMinute() >= 60) { d.setMinute(d.getMinute() - 60); nextHour(d); } d.setHour(d.getHour() + h); if (d.getHour() >= 24) { d.setHour(d.getHour() - 24); nextDay(d); } } static inline void substractHoursAndMinutes(datetime& d, const int h, const int m) { if (m > d.getMinute()) { d.setMinute(60 - (m - d.getMinute())); prevHour(d); } else { d.setMinute(d.getMinute() - m); } if (h > d.getHour()) { d.setHour(24 - (h - d.getHour())); prevDay(d); } else { d.setHour(d.getHour() - h); } } #endif // VMIME_BUILDING_DOC const datetime datetimeUtils::toUniversalTime(const datetime& date) { if (date.getZone() == datetime::GMT) return date; // no conversion needed datetime nd(date); nd.setZone(datetime::GMT); const int z = date.getZone(); const int h = (z < 0) ? (-z / 60) : (z / 60); const int m = (z < 0) ? (-z - h * 60) : (z - h * 60); if (z < 0) // GMT-hhmm: add hours and minutes to date addHoursAndMinutes(nd, h, m); else // GMT+hhmm: substract hours and minutes from date substractHoursAndMinutes(nd, h, m); return (nd); } const datetime datetimeUtils::toLocalTime(const datetime& date, const int zone) { datetime utcDate(date); if (utcDate.getZone() != datetime::GMT) utcDate = toUniversalTime(date); // convert to UT before datetime nd(utcDate); nd.setZone(zone); const int h = (zone < 0) ? (-zone / 60) : (zone / 60); const int m = (zone < 0) ? (-zone - h * 60) : (zone - h * 60); if (zone < 0) // GMT+hhmm: substract hours and minutes from date substractHoursAndMinutes(nd, h, m); else // GMT-hhmm: add hours and minutes to date addHoursAndMinutes(nd, h, m); return (nd); } bool datetimeUtils::isLeapYear(const int year) { // From RFC 3339 - Appendix C. Leap Years: return ((year % 4) == 0 && (year % 100 != 0 || year % 400 == 0)); } int datetimeUtils::getDaysInMonth(const int year, const int month) { static const int daysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static const int daysInMonthLeapYear[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (month < 1 || month > 12) throw std::out_of_range("Invalid month number"); return (isLeapYear(year) ? daysInMonthLeapYear[month - 1] : daysInMonth[month - 1]); } int datetimeUtils::getDayOfWeek(const int year, const int month, const int day) { int y = year; int m = month; if (month < 1 || month > 12) throw std::out_of_range("Invalid month number"); else if (day < 1 || day > getDaysInMonth(year, month)) throw std::out_of_range("Invalid day number"); // From RFC-3339 - Appendix B. Day of the Week // Adjust months so February is the last one m -= 2; if (m < 1) { m += 12; --y; } // Split by century const int cent = y / 100; y %= 100; return (((26 * m - 2) / 10 + day + y + (y >> 2) + (cent >> 2) + 5 * cent) % 7); } int datetimeUtils::getWeekOfYear(const int year, const int month, const int day, const bool iso) { // Algorithm from http://personal.ecu.edu/mccartyr/ISOwdALG.txt const bool leapYear = ((year % 4) == 0 && (year % 100) != 0) || (year % 400) == 0; const bool leapYear_1 = (((year - 1) % 4) == 0 && ((year - 1) % 100) != 0) || ((year - 1) % 400) == 0; // 4. Find the DayOfYearNumber for Y M D static const int DAY_OF_YEAR_NUMBER_MAP[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; int DayOfYearNumber = day + DAY_OF_YEAR_NUMBER_MAP[month - 1]; if (leapYear && month > 2) DayOfYearNumber += 1; // 5. Find the Jan1Weekday for Y (Monday=1, Sunday=7) const int YY = (year - 1) % 100; const int C = (year - 1) - YY; const int G = YY + YY / 4; const int Jan1Weekday = 1 + (((((C / 100) % 4) * 5) + G) % 7); // 6. Find the Weekday for Y M D const int H = DayOfYearNumber + (Jan1Weekday - 1); const int Weekday = 1 + ((H - 1) % 7); // 7. Find if Y M D falls in YearNumber Y-1, WeekNumber 52 or 53 int YearNumber = 0, WeekNumber = 0; if (DayOfYearNumber <= (8 - Jan1Weekday) && Jan1Weekday > 4) { YearNumber = year - 1; if (Jan1Weekday == 5 || (Jan1Weekday == 6 && leapYear_1)) WeekNumber = 53; else WeekNumber = 52; } else { YearNumber = year; } // 8. Find if Y M D falls in YearNumber Y+1, WeekNumber 1 if (YearNumber == year) { const int I = (leapYear ? 366 : 365); if ((I - DayOfYearNumber) < (4 - Weekday)) { YearNumber = year + 1; WeekNumber = 1; } } // 9. Find if Y M D falls in YearNumber Y, WeekNumber 1 through 53 if (YearNumber == year) { const int J = DayOfYearNumber + (7 - Weekday) + (Jan1Weekday - 1); WeekNumber = J / 7; if (Jan1Weekday > 4) WeekNumber -= 1; } if (!iso && (WeekNumber == 1 && month == 12)) WeekNumber = 53; return WeekNumber; } } // utility } // vmime libvmime-0.9.1/src/utility/encoder/0000755000175000017500000000000011607302336017541 5ustar mnordstrmnordstrlibvmime-0.9.1/src/utility/encoder/encoderFactory.cpp0000644000175000017500000000620511374031010023204 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/encoderFactory.hpp" #include "vmime/exception.hpp" #include "vmime/utility/encoder/b64Encoder.hpp" #include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/utility/encoder/uuEncoder.hpp" #include "vmime/utility/encoder/binaryEncoder.hpp" #include "vmime/utility/encoder/sevenBitEncoder.hpp" #include "vmime/utility/encoder/eightBitEncoder.hpp" namespace vmime { namespace utility { namespace encoder { encoderFactory::encoderFactory() { // Register some default encoders registerName ("base64"); registerName ("quoted-printable"); registerName ("uuencode"); registerName ("7bit"); registerName ("8bit"); registerName ("binary"); // Also register some non-standard encoding names registerName ("7-bit"); registerName ("8-bit"); } encoderFactory::~encoderFactory() { } encoderFactory* encoderFactory::getInstance() { static encoderFactory instance; return (&instance); } ref encoderFactory::create(const string& name) { return (getEncoderByName(name)->create()); } const ref encoderFactory::getEncoderByName(const string& name) const { const string lcName(utility::stringUtils::toLower(name)); for (std::vector >::const_iterator it = m_encoders.begin() ; it != m_encoders.end() ; ++it) { if ((*it)->getName() == lcName) return (*it); } throw exceptions::no_encoder_available(name); } int encoderFactory::getEncoderCount() const { return (m_encoders.size()); } const ref encoderFactory::getEncoderAt(const int pos) const { return (m_encoders[pos]); } const std::vector > encoderFactory::getEncoderList() const { std::vector > res; for (std::vector >::const_iterator it = m_encoders.begin() ; it != m_encoders.end() ; ++it) { res.push_back(*it); } return (res); } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/qpEncoder.cpp0000644000175000017500000003366011455065364022205 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { namespace utility { namespace encoder { qpEncoder::qpEncoder() { } const std::vector qpEncoder::getAvailableProperties() const { std::vector list(encoder::getAvailableProperties()); list.push_back("maxlinelength"); list.push_back("text"); // if set, '\r' and '\n' are not hex-encoded. // WARNING! You should not use this for binary data! list.push_back("rfc2047"); // for header fields encoding (RFC #2047) return (list); } // Hex-encoding table const unsigned char qpEncoder::sm_hexDigits[] = "0123456789ABCDEF"; // RFC-2047 encoding table: we always encode RFC-2047 using the restricted // charset, that is the one used for 'phrase' in From/To/Cc/... headers. // // " The set of characters that may be used in a "Q"-encoded 'encoded-word' // is restricted to: . " // // Two special cases: // - encode space (32) as underscore (95) // - encode underscore as hex (=5F) // // This is a quick lookup table: // '1' means "encode", '0' means "no encoding" // const unsigned char qpEncoder::sm_RFC2047EncodeTable[] = { /* 0 NUL */ 1, /* 1 SOH */ 1, /* 2 STX */ 1, /* 3 ETX */ 1, /* 4 EOT */ 1, /* 5 ENQ */ 1, /* 6 ACK */ 1, /* 7 BEL */ 1, /* 8 BS */ 1, /* 9 TAB */ 1, /* 10 LF */ 1, /* 11 VT */ 1, /* 12 FF */ 1, /* 13 CR */ 1, /* 14 SO */ 1, /* 15 SI */ 1, /* 16 DLE */ 1, /* 17 DC1 */ 1, /* 18 DC2 */ 1, /* 19 DC3 */ 1, /* 20 DC4 */ 1, /* 21 NAK */ 1, /* 22 SYN */ 1, /* 23 ETB */ 1, /* 24 CAN */ 1, /* 25 EM */ 1, /* 26 SUB */ 1, /* 27 ESC */ 1, /* 28 FS */ 1, /* 29 GS */ 1, /* 30 RS */ 1, /* 31 US */ 1, /* 32 SPACE*/ 1, /* 33 ! */ 0, /* 34 " */ 1, /* 35 # */ 1, /* 36 $ */ 1, /* 37 % */ 1, /* 38 & */ 1, /* 39 ' */ 1, /* 40 ( */ 1, /* 41 ) */ 1, /* 42 * */ 0, /* 43 + */ 0, /* 44 , */ 1, /* 45 - */ 0, /* 46 . */ 1, /* 47 / */ 0, /* 48 0 */ 0, /* 49 1 */ 0, /* 50 2 */ 0, /* 51 3 */ 0, /* 52 4 */ 0, /* 53 5 */ 0, /* 54 6 */ 0, /* 55 7 */ 0, /* 56 8 */ 0, /* 57 9 */ 0, /* 58 : */ 1, /* 59 ; */ 1, /* 60 < */ 1, /* 61 = */ 1, /* 62 > */ 1, /* 63 ? */ 1, /* 64 @ */ 1, /* 65 A */ 0, /* 66 B */ 0, /* 67 C */ 0, /* 68 D */ 0, /* 69 E */ 0, /* 70 F */ 0, /* 71 G */ 0, /* 72 H */ 0, /* 73 I */ 0, /* 74 J */ 0, /* 75 K */ 0, /* 76 L */ 0, /* 77 M */ 0, /* 78 N */ 0, /* 79 O */ 0, /* 80 P */ 0, /* 81 Q */ 0, /* 82 R */ 0, /* 83 S */ 0, /* 84 T */ 0, /* 85 U */ 0, /* 86 V */ 0, /* 87 W */ 0, /* 88 X */ 0, /* 89 Y */ 0, /* 90 Z */ 0, /* 91 [ */ 1, /* 92 " */ 1, /* 93 ] */ 1, /* 94 ^ */ 1, /* 95 _ */ 1, /* 96 ` */ 1, /* 97 a */ 0, /* 98 b */ 0, /* 99 c */ 0, /* 100 d */ 0, /* 101 e */ 0, /* 102 f */ 0, /* 103 g */ 0, /* 104 h */ 0, /* 105 i */ 0, /* 106 j */ 0, /* 107 k */ 0, /* 108 l */ 0, /* 109 m */ 0, /* 110 n */ 0, /* 111 o */ 0, /* 112 p */ 0, /* 113 q */ 0, /* 114 r */ 0, /* 115 s */ 0, /* 116 t */ 0, /* 117 u */ 0, /* 118 v */ 0, /* 119 w */ 0, /* 120 x */ 0, /* 121 y */ 0, /* 122 z */ 0, /* 123 { */ 1, /* 124 | */ 1, /* 125 } */ 1, /* 126 ~ */ 1, /* 127 DEL */ 1 }; // Hex-decoding table const unsigned char qpEncoder::sm_hexDecodeTable[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // static bool qpEncoder::RFC2047_isEncodingNeededForChar(const unsigned char c) { return (c >= 128 || sm_RFC2047EncodeTable[c] != 0); } // static int qpEncoder::RFC2047_getEncodedLength(const unsigned char c) { if (c >= 128 || sm_RFC2047EncodeTable[c] != 0) { if (c == 32) // space { // Encoded as "_" return 1; } else { // Hex encoding return 3; } } else { return 1; // no encoding } } #ifndef VMIME_BUILDING_DOC #define QP_ENCODE_HEX(x) \ outBuffer[outBufferPos] = '='; \ outBuffer[outBufferPos + 1] = sm_hexDigits[x >> 4]; \ outBuffer[outBufferPos + 2] = sm_hexDigits[x & 0xF]; \ outBufferPos += 3; \ curCol += 3 #define QP_WRITE(s, x, l) s.write(reinterpret_cast (x), l) #endif // VMIME_BUILDING_DOC utility::stream::size_type qpEncoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... const string::size_type propMaxLineLength = getProperties().getProperty ("maxlinelength", static_cast (-1)); const bool rfc2047 = getProperties().getProperty ("rfc2047", false); const bool text = getProperties().getProperty ("text", false); // binary mode by default const bool cutLines = (propMaxLineLength != static_cast (-1)); const string::size_type maxLineLength = std::min(propMaxLineLength, static_cast (74)); // Process the data char buffer[16384]; int bufferLength = 0; int bufferPos = 0; string::size_type curCol = 0; unsigned char outBuffer[16384]; int outBufferPos = 0; utility::stream::size_type total = 0; utility::stream::size_type inTotal = 0; if (progress) progress->start(0); while (bufferPos < bufferLength || !in.eof()) { // Flush current output buffer if (outBufferPos + 6 >= static_cast (sizeof(outBuffer))) { QP_WRITE(out, outBuffer, outBufferPos); total += outBufferPos; outBufferPos = 0; } // Need to get more data? if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; // No more data if (bufferLength == 0) break; } // Get the next char and encode it const unsigned char c = static_cast (buffer[bufferPos++]); if (rfc2047) { if (c >= 128 || sm_RFC2047EncodeTable[c] != 0) { if (c == 32) // space { // RFC-2047, Page 5, 4.2. The "Q" encoding: // << The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be // represented as "_" (underscore, ASCII 95.). >> outBuffer[outBufferPos++] = '_'; ++curCol; } else { // Other characters: '=' + hexadecimal encoding QP_ENCODE_HEX(c); } } else { // No encoding outBuffer[outBufferPos++] = c; ++curCol; } } else { switch (c) { case 46: // . { if (curCol == 0) { // If a '.' appears at the beginning of a line, we encode it to // to avoid problems with SMTP servers... ("\r\n.\r\n" means the // end of data transmission). QP_ENCODE_HEX('.'); continue; } outBuffer[outBufferPos++] = '.'; ++curCol; break; } case 32: // space { // Need to get more data? if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; } // Spaces cannot appear at the end of a line. So, encode the space. if (bufferPos >= bufferLength || (buffer[bufferPos] == '\r' || buffer[bufferPos] == '\n')) { QP_ENCODE_HEX(' '); } else { outBuffer[outBufferPos++] = ' '; ++curCol; } break; } case 9: // TAB { QP_ENCODE_HEX(c); break; } case 13: // CR case 10: // LF { // Text mode (where using CRLF or LF or ... does not // care for a new line...) if (text) { outBuffer[outBufferPos++] = c; ++curCol; } // Binary mode (where CR and LF bytes are important!) else { QP_ENCODE_HEX(c); } break; } case 61: // = { QP_ENCODE_HEX('='); break; } /* Rule #2: (Literal representation) Octets with decimal values of 33 through 60 inclusive, and 62 through 126, inclusive, MAY be represented as the ASCII characters which correspond to those octets (EXCLAMATION POINT through LESS THAN, and GREATER THAN through TILDE, respectively). */ default: //if ((c >= 33 && c <= 60) || (c >= 62 && c <= 126)) if (c >= 33 && c <= 126 && c != 61 && c != 63) { outBuffer[outBufferPos++] = c; ++curCol; } // Other characters: '=' + hexadecimal encoding else { QP_ENCODE_HEX(c); } break; } // switch (c) // Soft line break : "=\r\n" if (cutLines && curCol >= maxLineLength - 1) { outBuffer[outBufferPos] = '='; outBuffer[outBufferPos + 1] = '\r'; outBuffer[outBufferPos + 2] = '\n'; outBufferPos += 3; curCol = 0; } } // !rfc2047 ++inTotal; if (progress) progress->progress(inTotal, inTotal); } // Flush remaining output buffer if (outBufferPos != 0) { QP_WRITE(out, outBuffer, outBufferPos); total += outBufferPos; } if (progress) progress->stop(inTotal); return (total); } utility::stream::size_type qpEncoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... // Process the data const bool rfc2047 = getProperties().getProperty ("rfc2047", false); char buffer[16384]; int bufferLength = 0; int bufferPos = 0; unsigned char outBuffer[16384]; int outBufferPos = 0; utility::stream::size_type total = 0; utility::stream::size_type inTotal = 0; while (bufferPos < bufferLength || !in.eof()) { // Flush current output buffer if (outBufferPos >= static_cast (sizeof(outBuffer))) { QP_WRITE(out, outBuffer, outBufferPos); total += outBufferPos; outBufferPos = 0; } // Need to get more data? if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; // No more data if (bufferLength == 0) break; } // Decode the next sequence (hex-encoded byte or printable character) unsigned char c = static_cast (buffer[bufferPos++]); ++inTotal; switch (c) { case '=': { if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; } if (bufferPos < bufferLength) { c = static_cast (buffer[bufferPos++]); ++inTotal; switch (c) { // Ignore soft line break ("=\r\n" or "=\n") case '\r': // Read one byte more if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; } if (bufferPos < bufferLength) { ++bufferPos; ++inTotal; } break; case '\n': break; // Hex-encoded char default: { // We need another byte... if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; } if (bufferPos < bufferLength) { const unsigned char next = static_cast (buffer[bufferPos++]); ++inTotal; const unsigned char value = static_cast (sm_hexDecodeTable[c] * 16 + sm_hexDecodeTable[next]); outBuffer[outBufferPos++] = value; } else { // Premature end-of-data } break; } } } else { // Premature end-of-data } break; } case '_': { if (rfc2047) { // RFC-2047, Page 5, 4.2. The "Q" encoding: // << Note that the "_" always represents hexadecimal 20, even if the SPACE // character occupies a different code position in the character set in use. >> outBuffer[outBufferPos++] = 0x20; break; } // no break here... } default: { outBuffer[outBufferPos++] = c; } } if (progress) progress->progress(inTotal, inTotal); } // Flush remaining output buffer if (outBufferPos != 0) { QP_WRITE(out, outBuffer, outBufferPos); total += outBufferPos; } if (progress) progress->stop(inTotal); return (total); } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/encoder.cpp0000644000175000017500000000321611250723262021665 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/encoder.hpp" #include "vmime/exception.hpp" namespace vmime { namespace utility { namespace encoder { encoder::encoder() { } encoder::~encoder() { } const propertySet& encoder::getProperties() const { return (m_props); } propertySet& encoder::getProperties() { return (m_props); } const propertySet& encoder::getResults() const { return (m_results); } propertySet& encoder::getResults() { return (m_results); } const std::vector encoder::getAvailableProperties() const { std::vector list; return (list); } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/eightBitEncoder.cpp0000644000175000017500000000234611250723262023310 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/eightBitEncoder.hpp" namespace vmime { namespace utility { namespace encoder { eightBitEncoder::eightBitEncoder() { } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/uuEncoder.cpp0000644000175000017500000001747311250723262022211 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/uuEncoder.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { namespace utility { namespace encoder { uuEncoder::uuEncoder() { getProperties()["mode"] = 644; getProperties()["filename"] = "no_name"; getProperties()["maxlinelength"] = 46; } const std::vector uuEncoder::getAvailableProperties() const { std::vector list(encoder::getAvailableProperties()); list.push_back("maxlinelength"); list.push_back("mode"); list.push_back("filename"); return (list); } // This is the character encoding function to make a character printable static inline unsigned char UUENCODE(const unsigned char c) { return ((c & 077) + ' '); } // Single character decoding static inline unsigned char UUDECODE(const unsigned char c) { return ((c - ' ') & 077); } utility::stream::size_type uuEncoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... const string propFilename = getProperties().getProperty ("filename", ""); const string propMode = getProperties().getProperty ("mode", "644"); const string::size_type maxLineLength = std::min(getProperties().getProperty ("maxlinelength", 46), static_cast (46)); utility::stream::size_type total = 0; utility::stream::size_type inTotal = 0; // Output the prelude text ("begin [mode] [filename]") out << "begin"; if (!propFilename.empty()) { out << " " << propMode << " " << propFilename; total += 2 + propMode.length() + propFilename.length(); } out << "\r\n"; total += 7; // Process the data utility::stream::value_type inBuffer[64]; utility::stream::value_type outBuffer[64]; if (progress) progress->start(0); while (!in.eof()) { // Process up to 45 characters per line std::fill(inBuffer, inBuffer + sizeof(inBuffer), 0); const utility::stream::size_type inLength = in.read(inBuffer, maxLineLength - 1); outBuffer[0] = UUENCODE(inLength); // Line length utility::stream::size_type j = 1; for (utility::stream::size_type i = 0 ; i < inLength ; i += 3, j += 4) { const unsigned char c1 = static_cast (inBuffer[i]); const unsigned char c2 = static_cast (inBuffer[i + 1]); const unsigned char c3 = static_cast (inBuffer[i + 2]); outBuffer[j] = UUENCODE(c1 >> 2); outBuffer[j + 1] = UUENCODE((c1 << 4) & 060 | (c2 >> 4) & 017); outBuffer[j + 2] = UUENCODE((c2 << 2) & 074 | (c3 >> 6) & 03); outBuffer[j + 3] = UUENCODE(c3 & 077); } outBuffer[j] = '\r'; outBuffer[j + 1] = '\n'; out.write(outBuffer, j + 2); total += j + 2; inTotal += inLength; if (progress) progress->progress(inTotal, inTotal); } out << "end\r\n"; total += 5; if (progress) progress->stop(inTotal); return (total); } utility::stream::size_type uuEncoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... // Process the data utility::stream::value_type inBuffer[64]; utility::stream::value_type outBuffer[64]; utility::stream::size_type total = 0; utility::stream::size_type inTotal = 0; bool stop = false; std::fill(inBuffer, inBuffer + sizeof(inBuffer), 0); if (progress) progress->start(0); while (!stop && !in.eof()) { // Get the line length utility::stream::value_type lengthChar; if (in.read(&lengthChar, 1) == 0) break; const utility::stream::size_type outLength = UUDECODE(lengthChar); const utility::stream::size_type inLength = std::min((outLength * 4) / 3, static_cast (64)); utility::stream::value_type inPos = 0; switch (lengthChar) { case ' ': case '\t': case '\r': case '\n': { // Ignore continue; } case 'b': { // Read 5 characters more to check for begin ("begin ...\r\n" or "begin ...\n") inPos = in.read(inBuffer, 5); if (inPos == 5 && inBuffer[0] == 'e' && inBuffer[1] == 'g' && inBuffer[2] == 'i' && inBuffer[3] == 'n' && parserHelpers::isSpace(inBuffer[4])) { inTotal += 5; utility::stream::value_type c = 0; utility::stream::size_type count = 0; utility::stream::value_type buffer[512]; while (count < sizeof(buffer) - 1 && in.read(&c, 1) == 1) { if (c == '\n') break; buffer[count++] = c; } inTotal += count; if (c != '\n') { // OOPS! Weird line. Don't try to decode more... if (progress) progress->stop(inTotal); return (total); } // Parse filename and mode if (count > 0) { buffer[count] = '\0'; utility::stream::value_type* p = buffer; while (*p && parserHelpers::isSpace(*p)) ++p; utility::stream::value_type* modeStart = buffer; while (*p && !parserHelpers::isSpace(*p)) ++p; getResults()["mode"] = string(modeStart, p); while (*p && parserHelpers::isSpace(*p)) ++p; utility::stream::value_type* filenameStart = buffer; while (*p && !(*p == '\r' || *p == '\n')) ++p; getResults()["filename"] = string(filenameStart, p); } // No filename or mode specified else { getResults()["filename"] = "untitled"; getResults()["mode"] = 644; } continue; } break; } case 'e': { // Read 3 characters more to check for end ("end\r\n" or "end\n") inPos = in.read(inBuffer, 3); if (inPos == 3 && inBuffer[0] == 'n' && inBuffer[1] == 'd' && (inBuffer[2] == '\r' || inBuffer[2] == '\n')) { stop = true; inTotal += 3; continue; } break; } } // Read encoded data if (in.read(inBuffer + inPos, inLength - inPos) != inLength - inPos) { // Premature end of data break; } inTotal += (inLength - inPos); // Decode data for (utility::stream::size_type i = 0, j = 0 ; i < inLength ; i += 4, j += 3) { const unsigned char c1 = static_cast (inBuffer[i]); const unsigned char c2 = static_cast (inBuffer[i + 1]); const unsigned char c3 = static_cast (inBuffer[i + 2]); const unsigned char c4 = static_cast (inBuffer[i + 3]); const utility::stream::size_type n = std::min(inLength - i, static_cast (3)); switch (n) { default: case 3: outBuffer[j + 2] = UUDECODE(c3) << 6 | UUDECODE(c4); case 2: outBuffer[j + 1] = UUDECODE(c2) << 4 | UUDECODE(c3) >> 2; case 1: outBuffer[j] = UUDECODE(c1) << 2 | UUDECODE(c2) >> 4; case 0: break; } total += n; } out.write(outBuffer, outLength); std::fill(inBuffer, inBuffer + sizeof(inBuffer), 0); if (progress) progress->progress(inTotal, inTotal); } if (progress) progress->stop(inTotal); return (total); } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/b64Encoder.cpp0000644000175000017500000002000311250723262022132 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/b64Encoder.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { namespace utility { namespace encoder { b64Encoder::b64Encoder() { } const std::vector b64Encoder::getAvailableProperties() const { std::vector list(encoder::getAvailableProperties()); list.push_back("maxlinelength"); return (list); } // 7-bits alphabet used to encode binary data const unsigned char b64Encoder::sm_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; const unsigned char b64Encoder::sm_decodeMap[256] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0x00 - 0x0f 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0x10 - 0x1f 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3e,0xff,0xff,0xff,0x3f, // 0x20 - 0x2f 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0xff,0xff,0xff,0x3d,0xff,0xff, // 0x30 - 0x3f 0xff,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e, // 0x40 - 0x4f 0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0xff,0xff,0xff,0xff,0xff, // 0x50 - 0x5f 0xff,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28, // 0x60 - 0x6f 0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0xff,0xff,0xff,0xff, // 0x70 - 0x7f 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0x80 - 0x8f 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0x90 - 0x9f 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0xa0 - 0xaf 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0xb0 - 0xbf 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0xc0 - 0xcf 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0xd0 - 0xdf 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0xe0 - 0xef 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0xf0 - 0xff }; #ifndef VMIME_BUILDING_DOC #define B64_WRITE(s, x, l) s.write(reinterpret_cast (x), l) #endif // VMIME_BUILDING_DOC utility::stream::size_type b64Encoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... const int propMaxLineLength = getProperties().getProperty ("maxlinelength", -1); const bool cutLines = (propMaxLineLength != -1); const int maxLineLength = std::min(propMaxLineLength, 76); // Process data utility::stream::value_type buffer[65536]; utility::stream::size_type bufferLength = 0; utility::stream::size_type bufferPos = 0; unsigned char bytes[3]; unsigned char output[4]; utility::stream::size_type total = 0; utility::stream::size_type inTotal = 0; int curCol = 0; if (progress) progress->start(0); while (bufferPos < bufferLength || !in.eof()) { if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; if (bufferLength == 0) break; } // Get 3 bytes of data int count = 0; while (count < 3 && bufferPos < bufferLength) bytes[count++] = buffer[bufferPos++]; while (count < 3) { // There may be more data in the next chunk... if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; if (bufferLength == 0) break; } while (count < 3 && bufferPos < bufferLength) bytes[count++] = buffer[bufferPos++]; } // Encode data switch (count) { case 1: output[0] = sm_alphabet[(bytes[0] & 0xFC) >> 2]; output[1] = sm_alphabet[(bytes[0] & 0x03) << 4]; output[2] = sm_alphabet[64]; // padding output[3] = sm_alphabet[64]; // padding break; case 2: output[0] = sm_alphabet[(bytes[0] & 0xFC) >> 2]; output[1] = sm_alphabet[((bytes[0] & 0x03) << 4) | ((bytes[1] & 0xF0) >> 4)]; output[2] = sm_alphabet[(bytes[1] & 0x0F) << 2]; output[3] = sm_alphabet[64]; // padding break; default: case 3: output[0] = sm_alphabet[(bytes[0] & 0xFC) >> 2]; output[1] = sm_alphabet[((bytes[0] & 0x03) << 4) | ((bytes[1] & 0xF0) >> 4)]; output[2] = sm_alphabet[((bytes[1] & 0x0F) << 2) | ((bytes[2] & 0xC0) >> 6)]; output[3] = sm_alphabet[(bytes[2] & 0x3F)]; break; } // Write encoded data to output stream B64_WRITE(out, output, 4); inTotal += count; total += 4; curCol += 4; if (cutLines && curCol >= maxLineLength - 2 /* \r\n */ - 4 /* next bytes */) { out.write("\r\n", 2); curCol = 0; } if (progress) progress->progress(inTotal, inTotal); } if (progress) progress->stop(inTotal); return (total); } utility::stream::size_type b64Encoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... // Process the data char buffer[16384]; int bufferLength = 0; int bufferPos = 0; utility::stream::size_type total = 0; utility::stream::size_type inTotal = 0; unsigned char bytes[4]; unsigned char output[3]; if (progress) progress->start(0); while (bufferPos < bufferLength || !in.eof()) { bytes[0] = '='; bytes[1] = '='; bytes[2] = '='; bytes[3] = '='; // Need to get more data? if (bufferPos >= bufferLength) { bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; // No more data if (bufferLength == 0) break; } // 4 bytes of input provide 3 bytes of output, so // get the next 4 bytes from the input stream. int count = 0; while (count < 4 && bufferPos < bufferLength) { const unsigned char c = buffer[bufferPos++]; if (!parserHelpers::isSpace(c)) bytes[count++] = c; } if (count != 4) { while (count < 4 && !in.eof()) { // Data continues on the next chunk bufferLength = in.read(buffer, sizeof(buffer)); bufferPos = 0; while (count < 4 && bufferPos < bufferLength) { const unsigned char c = buffer[bufferPos++]; if (!parserHelpers::isSpace(c)) bytes[count++] = c; } } } // Decode the bytes unsigned char c1 = bytes[0]; unsigned char c2 = bytes[1]; if (c1 == '=' || c2 == '=') // end break; output[0] = static_cast ((sm_decodeMap[c1] << 2) | ((sm_decodeMap[c2] & 0x30) >> 4)); c1 = bytes[2]; if (c1 == '=') // end { B64_WRITE(out, output, 1); total += 1; break; } output[1] = static_cast (((sm_decodeMap[c2] & 0xf) << 4) | ((sm_decodeMap[c1] & 0x3c) >> 2)); c2 = bytes[3]; if (c2 == '=') // end { B64_WRITE(out, output, 2); total += 2; break; } output[2] = static_cast (((sm_decodeMap[c1] & 0x03) << 6) | sm_decodeMap[c2]); B64_WRITE(out, output, 3); total += 3; inTotal += count; if (progress) progress->progress(inTotal, inTotal); } if (progress) progress->stop(inTotal); return (total); } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/binaryEncoder.cpp0000644000175000017500000000234011250723262023027 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/binaryEncoder.hpp" namespace vmime { namespace utility { namespace encoder { binaryEncoder::binaryEncoder() { } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/defaultEncoder.cpp0000644000175000017500000000374711250723262023203 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/defaultEncoder.hpp" namespace vmime { namespace utility { namespace encoder { defaultEncoder::defaultEncoder() { } utility::stream::size_type defaultEncoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... // No encoding performed utility::stream::size_type res = 0; if (progress) res = utility::bufferedStreamCopy(in, out, 0, progress); else res = utility::bufferedStreamCopy(in, out); return res; } utility::stream::size_type defaultEncoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... // No decoding performed utility::stream::size_type res = 0; if (progress) res = utility::bufferedStreamCopy(in, out, 0, progress); else res = utility::bufferedStreamCopy(in, out); return res; } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/encoder/sevenBitEncoder.cpp0000644000175000017500000000234611250723262023330 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/encoder/sevenBitEncoder.hpp" namespace vmime { namespace utility { namespace encoder { sevenBitEncoder::sevenBitEncoder() { } } // encoder } // utility } // vmime libvmime-0.9.1/src/utility/filteredStream.cpp0000644000175000017500000001332511333330451021577 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/filteredStream.hpp" #include namespace vmime { namespace utility { // filteredInputStream stream::size_type filteredInputStream::getBlockSize() { return std::min(inputStream::getBlockSize(), getPreviousInputStream().getBlockSize()); } // filteredOutputStream stream::size_type filteredOutputStream::getBlockSize() { return std::min(outputStream::getBlockSize(), getNextOutputStream().getBlockSize()); } // dotFilteredInputStream dotFilteredInputStream::dotFilteredInputStream(inputStream& is) : m_stream(is), m_previousChar2('\0'), m_previousChar1('\0') { } inputStream& dotFilteredInputStream::getPreviousInputStream() { return (m_stream); } bool dotFilteredInputStream::eof() const { return (m_stream.eof()); } void dotFilteredInputStream::reset() { m_previousChar2 = '\0'; m_previousChar1 = '\0'; m_stream.reset(); } stream::size_type dotFilteredInputStream::read(value_type* const data, const size_type count) { const stream::size_type read = m_stream.read(data, count); const value_type* readPtr = data; value_type* writePtr = data; const value_type* end = data + read; stream::size_type written = 0; // Replace "\n.." with "\n." while (readPtr < end) { if (*readPtr == '.') { const value_type prevChar2 = (readPtr == data + 1 ? m_previousChar1 : readPtr == data ? m_previousChar2 : *(readPtr - 2)); const value_type prevChar1 = (readPtr == data ? m_previousChar1 : *(readPtr - 1)); if (prevChar2 == '\n' && prevChar1 == '.') { // Ignore last dot } else { *writePtr = *readPtr; ++writePtr; ++written; } } else { *writePtr = *readPtr; ++writePtr; ++written; } ++readPtr; } m_previousChar2 = (read >= 2 ? data[read - 2] : m_previousChar1); m_previousChar1 = (read >= 1 ? data[read - 1] : '\0'); return (written); } stream::size_type dotFilteredInputStream::skip(const size_type /* count */) { // Skipping bytes is not supported return 0; } // dotFilteredOutputStream dotFilteredOutputStream::dotFilteredOutputStream(outputStream& os) : m_stream(os), m_previousChar('\0') { } outputStream& dotFilteredOutputStream::getNextOutputStream() { return (m_stream); } void dotFilteredOutputStream::write (const value_type* const data, const size_type count) { if (count == 0) return; const value_type* pos = data; const value_type* end = data + count; const value_type* start = data; // Replace "\n." with "\n.." while ((pos = std::find(pos, end, '.')) != end) { const value_type previousChar = (pos == data ? m_previousChar : *(pos - 1)); if (previousChar == '\n') { m_stream.write(start, pos - start); m_stream.write("..", 2); start = pos + 1; } ++pos; } m_stream.write(start, end - start); m_previousChar = data[count - 1]; } void dotFilteredOutputStream::flush() { // Do nothing m_stream.flush(); } // CRLFToLFFilteredOutputStream CRLFToLFFilteredOutputStream::CRLFToLFFilteredOutputStream(outputStream& os) : m_stream(os), m_previousChar('\0') { } outputStream& CRLFToLFFilteredOutputStream::getNextOutputStream() { return (m_stream); } void CRLFToLFFilteredOutputStream::write (const value_type* const data, const size_type count) { if (count == 0) return; const value_type* pos = data; const value_type* end = data + count; const value_type* start = data; // Warning: if the whole buffer finishes with '\r', this // last character will not be written back if flush() is // not called if (m_previousChar == '\r') { if (*pos != '\n') { m_stream.write("\r", 1); // write back \r m_previousChar = *pos; } } // Replace "\r\n" (CRLF) with "\n" (LF) while ((pos = std::find(pos, end, '\n')) != end) { const value_type previousChar = (pos == data ? m_previousChar : *(pos - 1)); if (previousChar == '\r') { if (pos != start) m_stream.write(start, pos - 1 - start); // do not write \r m_stream.write("\n", 1); start = pos + 1; } ++pos; } if (data[count - 1] == '\r') { m_stream.write(start, end - start - 1); m_previousChar = '\r'; } else { m_stream.write(start, end - start); m_previousChar = data[count - 1]; } } void CRLFToLFFilteredOutputStream::flush() { m_stream.flush(); // TODO } // stopSequenceFilteredInputStream <1> template <> stream::size_type stopSequenceFilteredInputStream <1>::read (value_type* const data, const size_type count) { if (eof() || m_stream.eof()) { m_eof = true; return 0; } const size_type read = m_stream.read(data, count); value_type* end = data + read; value_type* pos = std::find(data, end, m_sequence[0]); if (pos == end) { return (read); } else { m_found = 1; return (pos - data); } } } // utility } // vmime libvmime-0.9.1/src/utility/smartPtrInt.cpp0000644000175000017500000001100311250723262021107 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/smartPtrInt.hpp" #include "vmime/object.hpp" #if defined(_WIN32) # include #elif defined(VMIME_HAVE_PTHREAD) # include #endif namespace vmime { namespace utility { // static refManager* refManager::create(object* obj) { return new refManagerImpl(obj); } // // refManager // refManagerImpl::refManagerImpl(object* obj) : m_object(obj), m_strongCount(1), m_weakCount(1) { } refManagerImpl::~refManagerImpl() { } bool refManagerImpl::addStrong() { if (m_strongCount <= 0) return false; m_strongCount.increment(); m_weakCount.increment(); return true; } void refManagerImpl::releaseStrong() { if (m_strongCount.decrement() <= 0) deleteObject(); releaseWeak(); } void refManagerImpl::addWeak() { m_weakCount.increment(); } void refManagerImpl::releaseWeak() { if (m_weakCount.decrement() <= 0) deleteManager(); } object* refManagerImpl::getObject() { return m_object; } void refManagerImpl::deleteManager() { delete this; } void refManagerImpl::deleteObject() { try { deleteObjectImpl(m_object); } catch (...) { // Exception in destructor } m_object = 0; } long refManagerImpl::getStrongRefCount() const { return m_strongCount; } long refManagerImpl::getWeakRefCount() const { return m_weakCount; } // // refCounter // #ifdef _WIN32 refCounter::refCounter(const long initialValue) : m_value(initialValue) { } refCounter::~refCounter() { } long refCounter::increment() { return InterlockedIncrement(&m_value); } long refCounter::decrement() { return InterlockedDecrement(&m_value); } refCounter::operator long() const { return m_value; } #elif defined(__GNUC__) && (defined(__GLIBCPP__) || defined(__GLIBCXX__)) refCounter::refCounter(const long initialValue) : m_value(static_cast (initialValue)) { } refCounter::~refCounter() { } long refCounter::increment() { #if __GNUC_MINOR__ < 4 && __GNUC__ < 4 return __exchange_and_add(&m_value, 1) + 1; #else return __gnu_cxx::__exchange_and_add(&m_value, 1) + 1; #endif } long refCounter::decrement() { #if __GNUC_MINOR__ < 4 && __GNUC__ < 4 return __exchange_and_add(&m_value, -1) - 1; #else return __gnu_cxx::__exchange_and_add(&m_value, -1) - 1; #endif } refCounter::operator long() const { #if __GNUC_MINOR__ < 4 && __GNUC__ < 4 return static_cast (__exchange_and_add(&m_value, 0)); #else return static_cast (__gnu_cxx::__exchange_and_add(&m_value, 0)); #endif } #elif defined(VMIME_HAVE_PTHREAD) refCounter::refCounter(const long initialValue) : m_value(initialValue) { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); pthread_mutex_init(&m_mutex, &attr); pthread_mutexattr_destroy(&attr); } refCounter::~refCounter() { pthread_mutex_destroy(&m_mutex); } long refCounter::increment() { long value; pthread_mutex_lock(&m_mutex); value = ++m_value; pthread_mutex_unlock(&m_mutex); return value; } long refCounter::decrement() { long value; pthread_mutex_lock(&m_mutex); value = --m_value; pthread_mutex_unlock(&m_mutex); return value; } refCounter::operator long() const { return m_value; } #else // not thread-safe implementation refCounter::refCounter(const long initialValue) : m_value(initialValue) { } refCounter::~refCounter() { } long refCounter::increment() { return ++m_value; } long refCounter::decrement() { return --m_value; } refCounter::operator long() const { return m_value; } #endif } // utility } // vmime libvmime-0.9.1/src/utility/path.cpp0000644000175000017500000001114711250723262017565 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/path.hpp" #include namespace vmime { namespace utility { path::path() { } path::path(const component& c) { m_list.push_back(c); } path::path(const path& p) : object() { m_list.resize(p.m_list.size()); std::copy(p.m_list.begin(), p.m_list.end(), m_list.begin()); } path::path(const string& s) { m_list.push_back(component(s)); } path path::operator/(const path& p) const { path pr(*this); pr /= p; return (pr); } path path::operator/(const component& c) const { path pr(*this); pr /= c; return (pr); } path& path::operator/=(const path& p) { const list::size_type size = m_list.size(); m_list.resize(size + p.m_list.size()); std::copy(p.m_list.begin(), p.m_list.end(), m_list.begin() + size); return (*this); } path& path::operator/=(const component& c) { m_list.push_back(c); return (*this); } path path::getParent() const { path p; if (!isEmpty()) { p.m_list.resize(m_list.size() - 1); std::copy(m_list.begin(), m_list.end() - 1, p.m_list.begin()); } return (p); } path& path::operator=(const path& p) { m_list.resize(p.m_list.size()); std::copy(p.m_list.begin(), p.m_list.end(), m_list.begin()); return (*this); } path& path::operator=(const component& c) { m_list.resize(1); m_list[0] = c; return (*this); } bool path::operator==(const path& p) const { if (m_list.size() != p.m_list.size()) return (false); list::const_iterator i = m_list.begin(); list::const_iterator j = p.m_list.begin(); bool equal = true; for ( ; equal && i != m_list.end() ; ++i, ++j) //equal = (*i == *j); equal = ((*i).getBuffer() == (*j).getBuffer()); return (equal); } bool path::operator!=(const path& p) const { return (!(*this == p)); } bool path::isEmpty() const { return (m_list.empty()); } bool path::isRoot() const { return (m_list.empty()); } const path::component path::getLastComponent() const { return (m_list[m_list.size() - 1]); } path::component& path::getLastComponent() { return (m_list[m_list.size() - 1]); } int path::getSize() const { return (m_list.size()); } const path::component& path::operator[](const int x) const { return (m_list[x]); } path::component& path::operator[](const int x) { return (m_list[x]); } bool path::isDirectParentOf(const path& p) const { if (p.getSize() != getSize() + 1) return (false); bool equal = true; for (list::size_type i = 0 ; equal && i < m_list.size() ; ++i) equal = (m_list[i] == p.m_list[i]); return (equal); } bool path::isParentOf(const path& p) const { if (p.getSize() < getSize() + 1) return (false); bool equal = true; for (list::size_type i = 0 ; equal && i < m_list.size() ; ++i) equal = (m_list[i] == p.m_list[i]); return (equal); } void path::renameParent(const path& oldPath, const path& newPath) { if (isEmpty() || oldPath.getSize() > getSize()) return; bool equal = true; list::size_type i; for (i = 0 ; equal && i < oldPath.m_list.size() ; ++i) equal = (m_list[i] == oldPath.m_list[i]); if (i != oldPath.m_list.size()) return; list newList; for (list::size_type j = 0 ; j < newPath.m_list.size() ; ++j) newList.push_back(newPath.m_list[j]); for (list::size_type j = i ; j < m_list.size() ; ++j) newList.push_back(m_list[j]); m_list.resize(newList.size()); std::copy(newList.begin(), newList.end(), m_list.begin()); } void path::appendComponent(const path::component& c) { m_list.push_back(c); } const path::component& path::getComponentAt(const int pos) const { return (m_list[pos]); } path::component& path::getComponentAt(const int pos) { return (m_list[pos]); } } // utility } // vmime libvmime-0.9.1/src/utility/urlUtils.cpp0000644000175000017500000000605311250723262020454 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/urlUtils.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { namespace utility { const string urlUtils::encode(const string& s) { static const string RESERVED_CHARS = /* reserved */ "$&+,/:;=?@" /* unsafe */ "<>#%{}[]|\\^\"~`"; string result; result.reserve(s.length()); for (string::const_iterator it = s.begin() ; it != s.end() ; ++it) { const string::value_type c = *it; if (parserHelpers::isPrint(c) && !parserHelpers::isSpace(c) && static_cast (c) <= 127 && RESERVED_CHARS.find(c) == string::npos) { result += c; } else { char hex[4]; const unsigned char k = static_cast (c); hex[0] = '%'; hex[1] = "0123456789ABCDEF"[k / 16]; hex[2] = "0123456789ABCDEF"[k % 16]; hex[3] = 0; result += hex; } } return (result); } const string urlUtils::decode(const string& s) { string result; result.reserve(s.length()); for (string::const_iterator it = s.begin() ; it != s.end() ; ) { const string::value_type c = *it; switch (c) { case '%': { ++it; // skip '%' const char_t p = (it != s.end() ? *(it++) : 0); const char_t q = (it != s.end() ? *(it++) : 0); unsigned int r = 0; switch (p) { case 0: r = '%'; break; case 'a': case 'A': r = 10; break; case 'b': case 'B': r = 11; break; case 'c': case 'C': r = 12; break; case 'd': case 'D': r = 13; break; case 'e': case 'E': r = 14; break; case 'f': case 'F': r = 15; break; default: r = p - '0'; break; } if (q != 0) { r *= 16; switch (q) { case 'a': case 'A': r += 10; break; case 'b': case 'B': r += 11; break; case 'c': case 'C': r += 12; break; case 'd': case 'D': r += 13; break; case 'e': case 'E': r += 14; break; case 'f': case 'F': r += 15; break; default: r += q - '0'; break; } } result += static_cast (r); break; } default: result += c; ++it; break; } } return (result); } } // utility } // vmime libvmime-0.9.1/src/utility/stringUtils.cpp0000644000175000017500000001161211375253010021152 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/stringUtils.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { namespace utility { bool stringUtils::isStringEqualNoCase (const string& s1, const char* s2, const string::size_type n) { // 'n' is the number of characters to compare // 's2' must be in lowercase letters only if (s1.length() < n) return (false); const std::ctype & fac = std::use_facet >(std::locale::classic()); bool equal = true; for (string::size_type i = 0 ; equal && i < n ; ++i) equal = (fac.tolower(static_cast (s1[i])) == s2[i]); return (equal); } bool stringUtils::isStringEqualNoCase(const string& s1, const string& s2) { if (s1.length() != s2.length()) return (false); const std::ctype & fac = std::use_facet >(std::locale::classic()); bool equal = true; const string::const_iterator end = s1.end(); for (string::const_iterator i = s1.begin(), j = s2.begin(); i != end ; ++i, ++j) equal = (fac.tolower(static_cast (*i)) == fac.tolower(static_cast (*j))); return (equal); } bool stringUtils::isStringEqualNoCase (const string::const_iterator begin, const string::const_iterator end, const char* s, const string::size_type n) { if (static_cast (end - begin) < n) return (false); const std::ctype & fac = std::use_facet >(std::locale::classic()); bool equal = true; char* c = const_cast(s); string::size_type r = n; for (string::const_iterator i = begin ; equal && r && *c ; ++i, ++c, --r) equal = (fac.tolower(static_cast (*i)) == static_cast (*c)); return (r == 0 && equal); } const string stringUtils::toLower(const string& str) { const std::ctype & fac = std::use_facet >(std::locale::classic()); string out; out.resize(str.size()); for (string::size_type i = 0, len = str.length() ; i < len ; ++i) out[i] = fac.tolower(static_cast (str[i])); return out; } const string stringUtils::toUpper(const string& str) { const std::ctype & fac = std::use_facet >(std::locale::classic()); string out; out.resize(str.size()); for (string::size_type i = 0, len = str.length() ; i < len ; ++i) out[i] = fac.toupper(static_cast (str[i])); return out; } const string stringUtils::trim(const string& str) { string::const_iterator b = str.begin(); string::const_iterator e = str.end(); if (b != e) { for ( ; b != e && parserHelpers::isSpace(*b) ; ++b) {} for ( ; e != b && parserHelpers::isSpace(*(e - 1)) ; --e) {} } return (string(b, e)); } string::size_type stringUtils::countASCIIchars (const string::const_iterator begin, const string::const_iterator end) { string::size_type count = 0; for (string::const_iterator i = begin ; i != end ; ++i) { if (parserHelpers::isAscii(*i)) { if (*i != '=' || ((i + 1) != end && *(i + 1) != '?')) // To avoid bad behaviour... ++count; } } return (count); } string::size_type stringUtils::findFirstNonASCIIchar (const string::const_iterator begin, const string::const_iterator end) { string::size_type pos = string::npos; for (string::const_iterator i = begin ; i != end ; ++i) { if (!parserHelpers::isAscii(*i)) { pos = i - begin; break; } } return pos; } const string stringUtils::unquote(const string& str) { if (str.length() < 2) return str; if (str[0] != '"' || str[str.length() - 1] != '"') return str; string res; res.reserve(str.length()); bool escaped = false; for (string::const_iterator it = str.begin() + 1, end = str.end() - 1 ; it != end ; ++it) { const string::value_type c = *it; if (escaped) { res += c; escaped = false; } else if (!escaped && c == '\\') { escaped = true; } else { res += c; } } return res; } } // utility } // vmime libvmime-0.9.1/src/utility/stringProxy.cpp0000644000175000017500000000601711250723262021201 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/stringProxy.hpp" #include #include namespace vmime { namespace utility { stringProxy::stringProxy() : m_start(0), m_end(0) { } stringProxy::stringProxy(const stringProxy& s) : m_buffer(s.m_buffer), m_start(s.m_start), m_end(s.m_end) { } stringProxy::stringProxy(const string_type& s, const size_type start, const size_type end) : m_buffer(s), m_start(start), m_end(end == std::numeric_limits ::max() ? s.length() : end) { } void stringProxy::set(const string_type& s, const size_type start, const size_type end) { m_buffer = s; m_start = start; if (end == std::numeric_limits ::max()) m_end = s.length(); else m_end = end; } void stringProxy::detach() { m_buffer.clear(); m_start = m_end = 0; } stringProxy& stringProxy::operator=(const stringProxy& s) { m_buffer = s.m_buffer; m_start = s.m_start; m_end = s.m_end; return (*this); } stringProxy& stringProxy::operator=(const string_type& s) { m_buffer = s; m_start = 0; m_end = s.length(); return (*this); } void stringProxy::extract(outputStream& os, const size_type start, const size_type end, utility::progressListener* progress) const { size_type len = 0; if (end == std::numeric_limits ::max()) len = m_end - start - m_start; else if (end > start) len = end - start; if (progress) progress->start(len); os.write(m_buffer.data() + m_start + start, len); if (progress) { progress->progress(len, len); progress->stop(len); } } stringProxy::size_type stringProxy::length() const { return (m_end - m_start); } stringProxy::size_type stringProxy::start() const { return (m_start); } stringProxy::size_type stringProxy::end() const { return (m_end); } std::ostream& operator<<(std::ostream& os, const stringProxy& s) { outputStreamAdapter adapter(os); s.extract(adapter); return (os); } outputStream& operator<<(outputStream& os, const stringProxy& s) { s.extract(os); return (os); } } // utility } // vmime libvmime-0.9.1/src/utility/stream.cpp0000644000175000017500000002257011314151074020123 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/stream.hpp" #include "vmime/utility/stringProxy.hpp" #include // for std::copy #include // for std::back_inserter #if VMIME_HAVE_MESSAGING_FEATURES #include "vmime/net/socket.hpp" #endif namespace vmime { namespace utility { // stream stream::size_type stream::getBlockSize() { return 32768; // 32 KB } // Helpers outputStream& operator<<(outputStream& os, const stream::value_type c) { os.write(&c, 1); return (os); } outputStream& operator<<(outputStream& os, const string& str) { os.write(str.data(), str.length()); return (os); } stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os) { return bufferedStreamCopy(is, os, 0, NULL); } stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os, const stream::size_type length, progressListener* progress) { const stream::size_type blockSize = std::min(is.getBlockSize(), os.getBlockSize()); std::vector vbuffer(blockSize); stream::value_type* buffer = &vbuffer.front(); stream::size_type total = 0; if (progress != NULL) progress->start(length); while (!is.eof()) { const stream::size_type read = is.read(buffer, blockSize); if (read != 0) { os.write(buffer, read); total += read; if (progress != NULL) progress->progress(total, std::max(total, length)); } } if (progress != NULL) progress->stop(total); return (total); } // outputStreamAdapter outputStreamAdapter::outputStreamAdapter(std::ostream& os) : m_stream(os) { } void outputStreamAdapter::write (const value_type* const data, const size_type count) { m_stream.exceptions(std::ios_base::badbit); m_stream.write(data, count); } void outputStreamAdapter::flush() { m_stream.exceptions(std::ios_base::badbit); m_stream.flush(); } // outputStreamStringAdapter outputStreamStringAdapter::outputStreamStringAdapter(string& buffer) : m_buffer(buffer) { } void outputStreamStringAdapter::write(const value_type* const data, const size_type count) { m_buffer.append(data, count); } void outputStreamStringAdapter::flush() { // Do nothing } // outputStreamByteArrayAdapter outputStreamByteArrayAdapter::outputStreamByteArrayAdapter(byteArray& array) : m_array(array) { } void outputStreamByteArrayAdapter::write(const value_type* const data, const size_type count) { m_array.insert(m_array.end(), data, data + count); } void outputStreamByteArrayAdapter::flush() { // Do nothing } // inputStreamAdapter inputStreamAdapter::inputStreamAdapter(std::istream& is) : m_stream(is) { } bool inputStreamAdapter::eof() const { return (m_stream.eof()); } void inputStreamAdapter::reset() { m_stream.exceptions(std::ios_base::badbit); m_stream.seekg(0, std::ios::beg); m_stream.clear(); } stream::size_type inputStreamAdapter::read (value_type* const data, const size_type count) { m_stream.exceptions(std::ios_base::badbit); m_stream.read(data, count); return (m_stream.gcount()); } stream::size_type inputStreamAdapter::skip(const size_type count) { m_stream.exceptions(std::ios_base::badbit); m_stream.ignore(count); return (m_stream.gcount()); } // inputStreamStringAdapter inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer) : m_buffer(buffer), m_begin(0), m_end(buffer.length()), m_pos(0) { } inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer, const string::size_type begin, const string::size_type end) : m_buffer(buffer), m_begin(begin), m_end(end), m_pos(begin) { } bool inputStreamStringAdapter::eof() const { return (m_pos >= m_end); } void inputStreamStringAdapter::reset() { m_pos = m_begin; } stream::size_type inputStreamStringAdapter::read (value_type* const data, const size_type count) { if (m_pos + count >= m_end) { const size_type remaining = m_end - m_pos; std::copy(m_buffer.begin() + m_pos, m_buffer.end(), data); m_pos = m_end; return (remaining); } else { std::copy(m_buffer.begin() + m_pos, m_buffer.begin() + m_pos + count, data); m_pos += count; return (count); } } stream::size_type inputStreamStringAdapter::skip(const size_type count) { if (m_pos + count >= m_end) { const size_type remaining = m_end - m_pos; m_pos = m_end; return (remaining); } else { m_pos += count; return (count); } } // inputStreamStringProxyAdapter inputStreamStringProxyAdapter::inputStreamStringProxyAdapter(const stringProxy& buffer) : m_buffer(buffer), m_pos(0) { } bool inputStreamStringProxyAdapter::eof() const { return (m_pos >= m_buffer.length()); } void inputStreamStringProxyAdapter::reset() { m_pos = 0; } stream::size_type inputStreamStringProxyAdapter::read (value_type* const data, const size_type count) { const size_type remaining = m_buffer.length() - m_pos; if (count > remaining) { std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_end(), data); m_pos = m_buffer.length(); return (remaining); } else { std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_begin() + m_pos + count, data); m_pos += count; return (count); } } stream::size_type inputStreamStringProxyAdapter::skip(const size_type count) { const size_type remaining = m_buffer.length() - m_pos; if (count > remaining) { m_pos = m_buffer.length(); return (remaining); } else { m_pos += count; return (count); } } // inputStreamPointerAdapter inputStreamPointerAdapter::inputStreamPointerAdapter(std::istream* is, const bool own) : m_stream(is), m_own(own) { } inputStreamPointerAdapter::inputStreamPointerAdapter(const inputStreamPointerAdapter&) : inputStream(), m_stream(NULL), m_own(false) { // Not copiable } inputStreamPointerAdapter::~inputStreamPointerAdapter() { if (m_own) delete (m_stream); } bool inputStreamPointerAdapter::eof() const { return (m_stream->eof()); } void inputStreamPointerAdapter::reset() { m_stream->exceptions(std::ios_base::badbit); m_stream->seekg(0, std::ios::beg); m_stream->clear(); } stream::size_type inputStreamPointerAdapter::read (value_type* const data, const size_type count) { m_stream->exceptions(std::ios_base::badbit); m_stream->read(data, count); return (m_stream->gcount()); } stream::size_type inputStreamPointerAdapter::skip(const size_type count) { m_stream->exceptions(std::ios_base::badbit); m_stream->ignore(count); return (m_stream->gcount()); } // inputStreamByteBufferAdapter inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte_t* buffer, const size_type length) : m_buffer(buffer), m_length(length), m_pos(0) { } bool inputStreamByteBufferAdapter::eof() const { return m_pos >= m_length; } void inputStreamByteBufferAdapter::reset() { m_pos = 0; } stream::size_type inputStreamByteBufferAdapter::read (value_type* const data, const size_type count) { const size_type remaining = m_length - m_pos; if (remaining < count) { std::copy(m_buffer + m_pos, m_buffer + m_pos + remaining, data); m_pos += remaining; return remaining; } else { std::copy(m_buffer + m_pos, m_buffer + m_pos + count, data); m_pos += count; return count; } } stream::size_type inputStreamByteBufferAdapter::skip(const size_type count) { const size_type remaining = m_length - m_pos; if (remaining < count) { m_pos += remaining; return remaining; } else { m_pos += count; return count; } } #ifdef VMIME_HAVE_MESSAGING_FEATURES // outputStreamSocketAdapter outputStreamSocketAdapter::outputStreamSocketAdapter(net::socket& sok) : m_socket(sok) { } void outputStreamSocketAdapter::write (const value_type* const data, const size_type count) { m_socket.sendRaw(data, count); } void outputStreamSocketAdapter::flush() { // Do nothing } stream::size_type outputStreamSocketAdapter::getBlockSize() { return m_socket.getBlockSize(); } // inputStreamSocketAdapter inputStreamSocketAdapter::inputStreamSocketAdapter(net::socket& sok) : m_socket(sok) { } bool inputStreamSocketAdapter::eof() const { // Can't know... return false; } void inputStreamSocketAdapter::reset() { // Not supported } stream::size_type inputStreamSocketAdapter::read (value_type* const data, const size_type count) { return m_socket.receiveRaw(data, count); } stream::size_type inputStreamSocketAdapter::skip (const size_type /* count */) { // Not supported return 0; } stream::size_type inputStreamSocketAdapter::getBlockSize() { return m_socket.getBlockSize(); } #endif // VMIME_HAVE_MESSAGING_FEATURES } // utility } // vmime libvmime-0.9.1/src/utility/url.cpp0000644000175000017500000001717511250723262017442 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/url.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/utility/urlUtils.hpp" #include "vmime/exception.hpp" #include namespace vmime { namespace utility { // Unspecified port const port_t url::UNSPECIFIED_PORT = static_cast (-1); // Known protocols const string url::PROTOCOL_FILE = "file"; const string url::PROTOCOL_HTTP = "http"; const string url::PROTOCOL_FTP = "ftp"; url::url(const string& s) { parse(s); } url::url(const url& u) { operator=(u); } url::url(const string& protocol, const string& host, const port_t port, const string& path, const string& username, const string& password) : m_protocol(protocol), m_username(username), m_password(password), m_host(host), m_port(port), m_path(path) { } url& url::operator=(const url& u) { m_protocol = u.m_protocol; m_username = u.m_username; m_password = u.m_password; m_host = u.m_host; m_port = u.m_port; m_path = u.m_path; m_params = u.m_params; return (*this); } url& url::operator=(const string& s) { parse(s); return (*this); } url::operator string() const { return build(); } const string url::build() const { std::ostringstream oss; oss.imbue(std::locale::classic()); oss << m_protocol << "://"; if (!m_username.empty()) { oss << urlUtils::encode(m_username); if (!m_password.empty()) { oss << ":"; oss << urlUtils::encode(m_password); } oss << "@"; } oss << urlUtils::encode(m_host); if (m_port != UNSPECIFIED_PORT) { oss << ":"; oss << m_port; } if (!m_path.empty()) { oss << "/"; oss << urlUtils::encode(m_path); } const std::vector > params = m_params.getPropertyList(); if (!params.empty()) { if (m_path.empty()) oss << "/"; oss << "?"; for (unsigned int i = 0 ; i < params.size() ; ++i) { const ref prop = params[i]; if (i != 0) oss << "&"; oss << urlUtils::encode(prop->getName()); oss << "="; oss << urlUtils::encode(prop->getValue()); } } return (oss.str()); } void url::parse(const string& str) { // Protocol const string::size_type protoEnd = str.find("://"); if (protoEnd == string::npos) throw exceptions::malformed_url("No protocol separator"); const string proto = utility::stringUtils::toLower(string(str.begin(), str.begin() + protoEnd)); // Username/password string::size_type slashPos = str.find('/', protoEnd + 3); if (slashPos == string::npos) slashPos = str.length(); string::size_type atPos = str.rfind('@', slashPos); string hostPart; string username; string password; if (proto == PROTOCOL_FILE) { // No user name, password and host part. slashPos = protoEnd + 3; } else { if (atPos != string::npos && atPos < slashPos) { const string userPart(str.begin() + protoEnd + 3, str.begin() + atPos); const string::size_type colonPos = userPart.find(':'); if (colonPos == string::npos) { username = userPart; } else { username = string(userPart.begin(), userPart.begin() + colonPos); password = string(userPart.begin() + colonPos + 1, userPart.end()); } hostPart = string(str.begin() + atPos + 1, str.begin() + slashPos); } else { hostPart = string(str.begin() + protoEnd + 3, str.begin() + slashPos); } } // Host/port const string::size_type colonPos = hostPart.find(':'); string host; string port; if (colonPos == string::npos) { host = utility::stringUtils::trim(hostPart); } else { host = utility::stringUtils::trim(string(hostPart.begin(), hostPart.begin() + colonPos)); port = utility::stringUtils::trim(string(hostPart.begin() + colonPos + 1, hostPart.end())); } // Path string path = utility::stringUtils::trim(string(str.begin() + slashPos, str.end())); string params; string::size_type paramSep = path.find_first_of('?'); if (paramSep != string::npos) { params = string(path.begin() + paramSep + 1, path.end()); path.erase(path.begin() + paramSep, path.end()); } if (path == "/") path.clear(); // Some sanity check if (proto.empty()) throw exceptions::malformed_url("No protocol specified"); else if (host.empty()) { // Accept empty host (eg. "file:///home/vincent/mydoc") if (proto != PROTOCOL_FILE) throw exceptions::malformed_url("No host specified"); } bool onlyDigit = true; for (string::const_iterator it = port.begin() ; onlyDigit && it != port.end() ; ++it) { onlyDigit = parserHelpers::isDigit(*it); } if (!onlyDigit) throw exceptions::malformed_url("Port can only contain digits"); std::istringstream iss(port); port_t portNum = 0; iss >> portNum; if (portNum == 0) portNum = UNSPECIFIED_PORT; // Extract parameters m_params.removeAllProperties(); if (!params.empty()) { string::size_type pos = 0; do { const string::size_type start = pos; pos = params.find_first_of('&', pos); const string::size_type equal = params.find_first_of('=', start); const string::size_type end = (pos == string::npos ? params.length() : pos); string name; string value; if (equal == string::npos || equal > pos) // no value { name = string(params.begin() + start, params.begin() + end); value = name; } else { name = string(params.begin() + start, params.begin() + equal); value = string(params.begin() + equal + 1, params.begin() + end); } name = urlUtils::decode(name); value = urlUtils::decode(value); m_params.setProperty(name, value); if (pos != string::npos) ++pos; } while (pos != string::npos); } // Now, save URL parts m_protocol = proto; m_username = urlUtils::decode(username); m_password = urlUtils::decode(password); m_host = urlUtils::decode(host); m_port = portNum; m_path = urlUtils::decode(path); } const string& url::getProtocol() const { return (m_protocol); } void url::setProtocol(const string& protocol) { m_protocol = protocol; } const string& url::getUsername() const { return (m_username); } void url::setUsername(const string& username) { m_username = username; } const string& url::getPassword() const { return (m_password); } void url::setPassword(const string& password) { m_password = password; } const string& url::getHost() const { return (m_host); } void url::setHost(const string& host) { m_host = host; } port_t url::getPort() const { return (m_port); } void url::setPort(const port_t port) { m_port = port; } const string& url::getPath() const { return (m_path); } void url::setPath(const string& path) { m_path = path; } const propertySet& url::getParams() const { return (m_params); } propertySet& url::getParams() { return (m_params); } } // utility } // vmime libvmime-0.9.1/src/utility/progressListener.cpp0000644000175000017500000000363211250723262022203 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/utility/progressListener.hpp" namespace vmime { namespace utility { // progressListenerSizeAdapter progressListenerSizeAdapter::progressListenerSizeAdapter (progressListener* list, const int total) : m_wrapped(list), m_total(total) { } bool progressListenerSizeAdapter::cancel() const { return (m_wrapped ? m_wrapped->cancel() : false); } void progressListenerSizeAdapter::start(const int predictedTotal) { if (m_wrapped) m_wrapped->start(predictedTotal); } void progressListenerSizeAdapter::progress(const int current, const int currentTotal) { if (m_wrapped) { if (currentTotal > m_total) m_total = currentTotal; m_wrapped->progress(current, m_total); } } void progressListenerSizeAdapter::stop(const int total) { if (m_wrapped) { if (total > m_total) m_total = total; m_wrapped->stop(m_total); } } } // utility } // vmime libvmime-0.9.1/src/mediaType.cpp0000644000175000017500000001001711250723263017043 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/mediaType.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { mediaType::mediaType() : m_type(mediaTypes::APPLICATION), m_subType(mediaTypes::APPLICATION_OCTET_STREAM) { } mediaType::mediaType(const string& type) { parse(type); } mediaType::mediaType(const string& type, const string& subType) : m_type(utility::stringUtils::toLower(type)), m_subType(utility::stringUtils::toLower(subType)) { } void mediaType::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { const string::value_type* const pend = buffer.data() + end; const string::value_type* const pstart = buffer.data() + position; const string::value_type* p = pstart; // Extract the type const string::size_type typeStart = position; while (p < pend && *p != '/') ++p; m_type = utility::stringUtils::trim(utility::stringUtils::toLower( string(buffer.begin() + typeStart, buffer.begin() + position + (p - pstart)))); if (p < pend) { // Skip '/' character ++p; // Extract the sub-type m_subType = utility::stringUtils::trim(utility::stringUtils::toLower( string(buffer.begin() + position + (p - pstart), buffer.begin() + end))); } setParsedBounds(position, end); if (newPosition) *newPosition = end; } void mediaType::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { const string value = m_type + "/" + m_subType; if (curLinePos + value.length() > maxLineLength) { os << NEW_LINE_SEQUENCE; os << value; if (newLinePos) *newLinePos = NEW_LINE_SEQUENCE_LENGTH + value.length(); } else { os << value; if (newLinePos) *newLinePos = curLinePos + value.length(); } } bool mediaType::operator==(const mediaType& type) const { return (m_type == type.m_type && m_subType == type.m_subType); } bool mediaType::operator!=(const mediaType& type) const { return !(*this == type); } mediaType& mediaType::operator=(const string& type) { parse(type); return (*this); } ref mediaType::clone() const { return vmime::create (m_type, m_subType); } void mediaType::copyFrom(const component& other) { const mediaType& mt = dynamic_cast (other); m_type = mt.m_type; m_subType = mt.m_subType; } mediaType& mediaType::operator=(const mediaType& other) { copyFrom(other); return (*this); } const string& mediaType::getType() const { return (m_type); } void mediaType::setType(const string& type) { m_type = utility::stringUtils::toLower(type); } const string& mediaType::getSubType() const { return (m_subType); } void mediaType::setSubType(const string& subType) { m_subType = utility::stringUtils::toLower(subType); } void mediaType::setFromString(const string& type) { parse(type); } const std::vector > mediaType::getChildComponents() const { return std::vector >(); } } // vmime libvmime-0.9.1/src/generatedMessageAttachment.cpp0000644000175000017500000000461011250723263022400 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/generatedMessageAttachment.hpp" namespace vmime { generatedMessageAttachment::generatedMessageAttachment(ref part) : m_bpa(vmime::create (part)) { } const mediaType generatedMessageAttachment::getType() const { return mediaType(mediaTypes::MESSAGE, mediaTypes::MESSAGE_RFC822); } const text generatedMessageAttachment::getDescription() const { return m_bpa->getDescription(); } const word generatedMessageAttachment::getName() const { return m_bpa->getName(); } const ref generatedMessageAttachment::getData() const { return m_bpa->getData(); } const encoding generatedMessageAttachment::getEncoding() const { return m_bpa->getEncoding(); } ref generatedMessageAttachment::getPart() const { return m_bpa->getPart(); } ref generatedMessageAttachment::getHeader() const { return m_bpa->getHeader(); } ref generatedMessageAttachment::getMessage() const { if (m_msg == NULL) { // Extract data std::ostringstream oss; utility::outputStreamAdapter os(oss); getData()->extract(os); // Parse message m_msg = vmime::create (); m_msg->parse(oss.str()); } return m_msg; } void generatedMessageAttachment::generateIn(ref /* parent */) const { // Not used (see 'parsedMessageAttachment') } } // vmime libvmime-0.9.1/src/body.cpp0000644000175000017500000004304711376242310016066 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/bodyPart.hpp" #include "vmime/body.hpp" #include "vmime/options.hpp" #include "vmime/contentTypeField.hpp" #include "vmime/text.hpp" #include "vmime/utility/random.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/emptyContentHandler.hpp" #include "vmime/stringContentHandler.hpp" namespace vmime { body::body() : m_contents(create ()), m_part(NULL), m_header(NULL) { } body::~body() { } void body::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { removeAllParts(); // Check whether the body is a MIME-multipart bool isMultipart = false; string boundary; try { const ref ctf = m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); const mediaType type = *ctf->getValue().dynamicCast (); if (type.getType() == mediaTypes::MULTIPART) { isMultipart = true; try { boundary = ctf->getBoundary(); } catch (exceptions::no_such_parameter&) { // No "boundary" parameter specified: we can try to // guess it by scanning the body contents... string::size_type pos = buffer.find("\n--", position); if ((pos != string::npos) && (pos < end)) { pos += 3; const string::size_type start = pos; char_t c = buffer[pos]; string::size_type length = 0; // We have to stop after a reasonnably long boundary length (100) // not to take the whole body contents for a boundary... while (pos < end && length < 100 && !(c == '\r' || c == '\n')) { ++length; c = buffer[pos++]; } if (pos < end && length < 100) { // RFC #1521, Page 31: // "...the boundary parameter, which consists of 1 to 70 // characters from a set of characters known to be very // robust through email gateways, and NOT ending with // white space..." while (pos != start && parserHelpers::isSpace(buffer[pos - 1])) --pos; boundary = string(buffer.begin() + start, buffer.begin() + pos); } } } } } catch (exceptions::no_such_field&) { // No "Content-Type" field... } // This is a multi-part body if (isMultipart && !boundary.empty()) { const string boundarySep("--" + boundary); string::size_type partStart = position; string::size_type pos = buffer.find(boundarySep, position); bool lastPart = false; if (pos != string::npos && pos < end) { m_prologText = string(buffer.begin() + position, buffer.begin() + pos); } for (int index = 0 ; !lastPart && (pos != string::npos) && (pos < end) ; ++index) { string::size_type partEnd = pos; // Get rid of the [CR]LF just before the boundary string if (pos >= (position + 1) && buffer[pos - 1] == '\n') --partEnd; if (pos >= (position + 2) && buffer[pos - 2] == '\r') --partEnd; // Check whether it is the last part (boundary terminated by "--") pos += boundarySep.length(); if (pos + 1 < end && buffer[pos] == '-' && buffer[pos + 1] == '-') { lastPart = true; pos += 2; } // RFC #1521, Page 31: // "...(If a boundary appears to end with white space, the // white space must be presumed to have been added by a // gateway, and must be deleted.)..." while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t')) ++pos; // End of boundary line if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] =='\n') { pos += 2; } else if (pos < end && buffer[pos] == '\n') { ++pos; } if (index > 0) { ref part = vmime::create (); part->parse(buffer, partStart, partEnd, NULL); part->m_parent = m_part; m_parts.push_back(part); } partStart = pos; pos = buffer.find(boundarySep, partStart); } m_contents = vmime::create (); // Last part was not found: recover from missing boundary if (!lastPart && pos == string::npos) { ref part = vmime::create (); try { part->parse(buffer, partStart, end); } catch (std::exception&) { throw; } part->m_parent = m_part; m_parts.push_back(part); } // Treat remaining text as epilog else if (partStart < end) { m_epilogText = string(buffer.begin() + partStart, buffer.begin() + end); } } // Treat the contents as 'simple' data else { encoding enc; try { const ref cef = m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING); enc = *cef->getValue().dynamicCast (); } catch (exceptions::no_such_field&) { // Defaults to "7bit" (RFC-1521) enc = vmime::encoding(encodingTypes::SEVEN_BIT); // Set header field m_header.acquire()->ContentTransferEncoding()->setValue(enc); } // Extract the (encoded) contents m_contents = vmime::create (buffer, position, end, enc); } setParsedBounds(position, end); if (newPosition) *newPosition = end; } void body::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type /* curLinePos */, string::size_type* newLinePos) const { // MIME-Multipart if (getPartCount() != 0) { string boundary; if (m_header.acquire() == NULL) { boundary = generateRandomBoundaryString(); } else { try { ref ctf = m_header.acquire()->findField(fields::CONTENT_TYPE) .dynamicCast (); boundary = ctf->getBoundary(); } catch (exceptions::no_such_field&) { // Warning: no content-type and no boundary string specified! boundary = generateRandomBoundaryString(); } catch (exceptions::no_such_parameter&) { // Warning: no boundary string specified! boundary = generateRandomBoundaryString(); } } const string& prologText = m_prologText.empty() ? (isRootPart() ? options::getInstance()->multipart.getPrologText() : NULL_STRING ) : m_prologText; const string& epilogText = m_epilogText.empty() ? (isRootPart() ? options::getInstance()->multipart.getEpilogText() : NULL_STRING ) : m_epilogText; if (!prologText.empty()) { text prolog(word(prologText, getCharset())); prolog.encodeAndFold(os, maxLineLength, 0, NULL, text::FORCE_NO_ENCODING | text::NO_NEW_LINE_SEQUENCE); os << CRLF; } os << "--" << boundary; for (int p = 0 ; p < getPartCount() ; ++p) { os << CRLF; getPartAt(p)->generate(os, maxLineLength, 0); os << CRLF << "--" << boundary; } os << "--" << CRLF; if (!epilogText.empty()) { text epilog(word(epilogText, getCharset())); epilog.encodeAndFold(os, maxLineLength, 0, NULL, text::FORCE_NO_ENCODING | text::NO_NEW_LINE_SEQUENCE); os << CRLF; } if (newLinePos) *newLinePos = 0; } // Simple body else { // Generate the contents m_contents->generate(os, getEncoding(), maxLineLength); } } /* RFC #1521, Page 32: 7.2.1. Multipart: The common syntax "...Encapsulation boundaries must not appear within the encapsulations, and must be no longer than 70 characters..." boundary := 0*69 bcharsnospace bchars := bcharsnospace / " " bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" /"_" / "," / "-" / "." / "/" / ":" / "=" / "?" */ const string body::generateRandomBoundaryString() { // 64 characters that can be _safely_ used in a boundary string static const char bchars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-+"; /* RFC #1521, Page 19: Since the hyphen character ("-") is represented as itself in the Quoted-Printable encoding, care must be taken, when encapsulating a quoted-printable encoded body in a multipart entity, to ensure that the encapsulation boundary does not appear anywhere in the encoded body. (A good strategy is to choose a boundary that includes a character sequence such as "=_" which can never appear in a quoted- printable body. See the definition of multipart messages later in this document.) */ string::value_type boundary[2 + 48 + 1] = { 0 }; boundary[0] = '='; boundary[1] = '_'; // Generate a string of random characters unsigned int r = utility::random::getTime(); unsigned int m = sizeof(unsigned int); for (size_t i = 2 ; i < (sizeof(boundary) / sizeof(boundary[0]) - 1) ; ++i) { boundary[i] = bchars[r & 63]; r >>= 6; if (--m == 0) { r = utility::random::getNext(); m = sizeof(unsigned int); } } return (string(boundary)); } bool body::isValidBoundary(const string& boundary) { static const string validChars("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'()+_,-./:=?"); const string::const_iterator end = boundary.end(); bool valid = false; if (boundary.length() > 0 && boundary.length() < 70) { const string::value_type last = *(end - 1); if (!(last == ' ' || last == '\t' || last == '\n')) { valid = true; for (string::const_iterator i = boundary.begin() ; valid && i != end ; ++i) valid = (validChars.find_first_of(*i) != string::npos); } } return (valid); } // // Quick-access functions // void body::setContentType(const mediaType& type, const charset& chset) { ref ctf = m_header.acquire()->ContentType().dynamicCast (); ctf->setValue(type); ctf->setCharset(chset); } void body::setContentType(const mediaType& type) { m_header.acquire()->ContentType()->setValue(type); } const mediaType body::getContentType() const { try { ref ctf = m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); return (*ctf->getValue().dynamicCast ()); } catch (exceptions::no_such_field&) { // Defaults to "text/plain" (RFC-1521) return (mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN)); } } void body::setCharset(const charset& chset) { // If a Content-Type field exists, set charset try { ref ctf = m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); ctf->setCharset(chset); } // Else, create a new Content-Type field of default type "text/plain" // and set charset on it catch (exceptions::no_such_field&) { setContentType(mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN), chset); } } const charset body::getCharset() const { try { const ref ctf = m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); return (ctf->getCharset()); } catch (exceptions::no_such_parameter&) { // Defaults to "us-ascii" (RFC-1521) return (vmime::charset(charsets::US_ASCII)); } catch (exceptions::no_such_field&) { // Defaults to "us-ascii" (RFC-1521) return (vmime::charset(charsets::US_ASCII)); } } void body::setEncoding(const encoding& enc) { m_header.acquire()->ContentTransferEncoding()->setValue(enc); } const encoding body::getEncoding() const { try { const ref cef = m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING); return (*cef->getValue().dynamicCast ()); } catch (exceptions::no_such_field&) { if (m_contents->isEncoded()) { return m_contents->getEncoding(); } else { // Defaults to "7bit" (RFC-1521) return vmime::encoding(encodingTypes::SEVEN_BIT); } } } void body::setParentPart(ref parent) { m_part = parent; m_header = (parent != NULL ? parent->getHeader() : NULL); } bool body::isRootPart() const { ref part = m_part.acquire(); return (part == NULL || part->getParentPart() == NULL); } ref body::clone() const { ref bdy = vmime::create (); bdy->copyFrom(*this); return (bdy); } void body::copyFrom(const component& other) { const body& bdy = dynamic_cast (other); m_prologText = bdy.m_prologText; m_epilogText = bdy.m_epilogText; m_contents = bdy.m_contents; removeAllParts(); for (int p = 0 ; p < bdy.getPartCount() ; ++p) { ref part = bdy.getPartAt(p)->clone().dynamicCast (); part->m_parent = m_part; m_parts.push_back(part); } } body& body::operator=(const body& other) { copyFrom(other); return (*this); } const string& body::getPrologText() const { return (m_prologText); } void body::setPrologText(const string& prologText) { m_prologText = prologText; } const string& body::getEpilogText() const { return (m_epilogText); } void body::setEpilogText(const string& epilogText) { m_epilogText = epilogText; } const ref body::getContents() const { return (m_contents); } void body::setContents(ref contents) { m_contents = contents; } void body::setContents(ref contents, const mediaType& type) { m_contents = contents; setContentType(type); } void body::setContents(ref contents, const mediaType& type, const charset& chset) { m_contents = contents; setContentType(type, chset); } void body::setContents(ref contents, const mediaType& type, const charset& chset, const encoding& enc) { m_contents = contents; setContentType(type, chset); setEncoding(enc); } void body::initNewPart(ref part) { part->m_parent = m_part; ref
hdr = m_header.acquire(); if (hdr != NULL) { // Check whether we have a boundary string try { ref ctf = hdr->findField(fields::CONTENT_TYPE).dynamicCast (); try { const string boundary = ctf->getBoundary(); if (boundary.empty() || !isValidBoundary(boundary)) ctf->setBoundary(generateRandomBoundaryString()); } catch (exceptions::no_such_parameter&) { // No "boundary" parameter: generate a random one. ctf->setBoundary(generateRandomBoundaryString()); } if (ctf->getValue().dynamicCast ()->getType() != mediaTypes::MULTIPART) { // Warning: multi-part body but the Content-Type is // not specified as "multipart/..." } } catch (exceptions::no_such_field&) { // No "Content-Type" field: create a new one and generate // a random boundary string. ref ctf = hdr->getField(fields::CONTENT_TYPE).dynamicCast (); ctf->setValue(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED)); ctf->setBoundary(generateRandomBoundaryString()); } } } void body::appendPart(ref part) { initNewPart(part); m_parts.push_back(part); } void body::insertPartBefore(ref beforePart, ref part) { initNewPart(part); const std::vector >::iterator it = std::find (m_parts.begin(), m_parts.end(), beforePart); if (it == m_parts.end()) throw exceptions::no_such_part(); m_parts.insert(it, part); } void body::insertPartBefore(const int pos, ref part) { initNewPart(part); m_parts.insert(m_parts.begin() + pos, part); } void body::insertPartAfter(ref afterPart, ref part) { initNewPart(part); const std::vector >::iterator it = std::find (m_parts.begin(), m_parts.end(), afterPart); if (it == m_parts.end()) throw exceptions::no_such_part(); m_parts.insert(it + 1, part); } void body::insertPartAfter(const int pos, ref part) { initNewPart(part); m_parts.insert(m_parts.begin() + pos + 1, part); } void body::removePart(ref part) { const std::vector >::iterator it = std::find (m_parts.begin(), m_parts.end(), part); if (it == m_parts.end()) throw exceptions::no_such_part(); m_parts.erase(it); } void body::removePart(const int pos) { m_parts.erase(m_parts.begin() + pos); } void body::removeAllParts() { m_parts.clear(); } int body::getPartCount() const { return (m_parts.size()); } bool body::isEmpty() const { return (m_parts.size() == 0); } ref body::getPartAt(const int pos) { return (m_parts[pos]); } const ref body::getPartAt(const int pos) const { return (m_parts[pos]); } const std::vector > body::getPartList() const { std::vector > list; list.reserve(m_parts.size()); for (std::vector >::const_iterator it = m_parts.begin() ; it != m_parts.end() ; ++it) { list.push_back(*it); } return (list); } const std::vector > body::getPartList() { return (m_parts); } const std::vector > body::getChildComponents() const { std::vector > list; copy_vector(m_parts, list); return (list); } } // vmime libvmime-0.9.1/src/contentDisposition.cpp0000644000175000017500000000620411250723263021024 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/contentDisposition.hpp" #include "vmime/utility/stringUtils.hpp" namespace vmime { contentDisposition::contentDisposition() : m_name(contentDispositionTypes::INLINE) { } contentDisposition::contentDisposition(const string& name) : m_name(utility::stringUtils::toLower(name)) { } contentDisposition::contentDisposition(const contentDisposition& type) : headerFieldValue(), m_name(type.m_name) { } void contentDisposition::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { m_name = utility::stringUtils::trim(utility::stringUtils::toLower (string(buffer.begin() + position, buffer.begin() + end))); setParsedBounds(position, end); if (newPosition) *newPosition = end; } void contentDisposition::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, const string::size_type curLinePos, string::size_type* newLinePos) const { os << m_name; if (newLinePos) *newLinePos = curLinePos + m_name.length(); } contentDisposition& contentDisposition::operator=(const string& name) { m_name = utility::stringUtils::toLower(name); return (*this); } bool contentDisposition::operator==(const contentDisposition& value) const { return (utility::stringUtils::toLower(m_name) == value.m_name); } bool contentDisposition::operator!=(const contentDisposition& value) const { return !(*this == value); } ref contentDisposition::clone() const { return vmime::create (*this); } void contentDisposition::copyFrom(const component& other) { const contentDisposition& d = dynamic_cast (other); m_name = d.m_name; } contentDisposition& contentDisposition::operator=(const contentDisposition& other) { copyFrom(other); return (*this); } const string& contentDisposition::getName() const { return (m_name); } void contentDisposition::setName(const string& name) { m_name = name; } const std::vector > contentDisposition::getChildComponents() const { return std::vector >(); } } // vmime libvmime-0.9.1/src/stringContentHandler.cpp0000644000175000017500000001174711376250135021276 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/stringContentHandler.hpp" namespace vmime { stringContentHandler::stringContentHandler(const string& buffer, const vmime::encoding& enc) : m_encoding(enc), m_string(buffer) { } stringContentHandler::stringContentHandler(const stringContentHandler& cts) : contentHandler(), m_encoding(cts.m_encoding), m_string(cts.m_string) { } stringContentHandler::stringContentHandler(const utility::stringProxy& str, const vmime::encoding& enc) : m_encoding(enc), m_string(str) { } stringContentHandler::stringContentHandler(const string& buffer, const string::size_type start, const string::size_type end, const vmime::encoding& enc) : m_encoding(enc), m_string(buffer, start, end) { } stringContentHandler::~stringContentHandler() { } ref stringContentHandler::clone() const { return vmime::create (*this); } stringContentHandler& stringContentHandler::operator=(const stringContentHandler& cts) { m_encoding = cts.m_encoding; m_string = cts.m_string; return (*this); } void stringContentHandler::setData(const utility::stringProxy& str, const vmime::encoding& enc) { m_encoding = enc; m_string = str; } void stringContentHandler::setData(const string& buffer, const vmime::encoding& enc) { m_encoding = enc; m_string.set(buffer); } void stringContentHandler::setData(const string& buffer, const string::size_type start, const string::size_type end, const vmime::encoding& enc) { m_encoding = enc; m_string.set(buffer, start, end); } stringContentHandler& stringContentHandler::operator=(const string& buffer) { setData(buffer, NO_ENCODING); return (*this); } void stringContentHandler::generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const { // Managed data is already encoded if (isEncoded()) { // The data is already encoded but the encoding specified for // the generation is different from the current one. We need // to re-encode data: decode from input buffer to temporary // buffer, and then re-encode to output stream... if (m_encoding != enc) { ref theDecoder = m_encoding.getEncoder(); ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; utility::inputStreamStringProxyAdapter in(m_string); std::ostringstream oss; utility::outputStreamAdapter tempOut(oss); theDecoder->decode(in, tempOut); string str = oss.str(); utility::inputStreamStringAdapter tempIn(str); theEncoder->encode(tempIn, os); } // No encoding to perform else { m_string.extract(os); } } // Need to encode data before else { ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; utility::inputStreamStringProxyAdapter in(m_string); theEncoder->encode(in, os); } } void stringContentHandler::extract(utility::outputStream& os, utility::progressListener* progress) const { // No decoding to perform if (!isEncoded()) { m_string.extract(os, 0, m_string.length(), progress); } // Need to decode data else { ref theDecoder = m_encoding.getEncoder(); utility::inputStreamStringProxyAdapter in(m_string); utility::progressListenerSizeAdapter plsa(progress, getLength()); theDecoder->decode(in, os, &plsa); } } void stringContentHandler::extractRaw(utility::outputStream& os, utility::progressListener* progress) const { m_string.extract(os, 0, m_string.length(), progress); } string::size_type stringContentHandler::getLength() const { return (m_string.length()); } bool stringContentHandler::isEmpty() const { return (m_string.length() == 0); } bool stringContentHandler::isEncoded() const { return (m_encoding != NO_ENCODING); } const vmime::encoding& stringContentHandler::getEncoding() const { return (m_encoding); } bool stringContentHandler::isBuffered() const { return true; } } // vmime libvmime-0.9.1/src/attachmentHelper.cpp0000644000175000017500000002011011441371576020415 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/attachmentHelper.hpp" #include "vmime/bodyPartAttachment.hpp" #include "vmime/parsedMessageAttachment.hpp" #include "vmime/generatedMessageAttachment.hpp" #include "vmime/disposition.hpp" #include "vmime/emptyContentHandler.hpp" namespace vmime { // static bool attachmentHelper::isBodyPartAnAttachment (ref part, const unsigned int options) { try { const contentDispositionField& cdf = dynamic_cast (*part->getHeader()->findField(fields::CONTENT_DISPOSITION)); const contentDisposition disp = *cdf.getValue() .dynamicCast (); if (disp.getName() != contentDispositionTypes::INLINE) return true; if ((options & INLINE_OBJECTS) == 0) { // If the Content-Disposition is 'inline' and there is no // Content-Id or Content-Location field, it may be an attachment if (!part->getHeader()->hasField(vmime::fields::CONTENT_ID) && !part->getHeader()->hasField(vmime::fields::CONTENT_LOCATION)) { // If this is the root part, it might not be an attachment if (part->getParentPart() == NULL) return false; return true; } return false; } } catch (exceptions::no_such_field&) { // Will try using Content-Type } // Assume "attachment" if type is not "text/..." or "multipart/...". mediaType type; try { const contentTypeField& ctf = dynamic_cast (*part->getHeader()->findField(fields::CONTENT_TYPE)); type = *ctf.getValue().dynamicCast (); } catch (exceptions::no_such_field&) { // If this is the root part and no Content-Type field is present, // then this may not be a MIME message, so do not assume it is // an attachment if (part->getParentPart() == NULL) return false; // No "Content-type" field: assume "application/octet-stream". type = mediaType(mediaTypes::APPLICATION, mediaTypes::APPLICATION_OCTET_STREAM); } if (type.getType() != mediaTypes::TEXT && type.getType() != mediaTypes::MULTIPART) { if ((options & INLINE_OBJECTS) == 0) { // If a "Content-Id" field is present, it might be an // embedded object (MHTML messages) if (part->getHeader()->hasField(vmime::fields::CONTENT_ID)) return false; } return true; } return false; } // static ref attachmentHelper::getBodyPartAttachment (ref part, const unsigned int options) { if (!isBodyPartAnAttachment(part, options)) return NULL; mediaType type; try { const contentTypeField& ctf = dynamic_cast (*part->getHeader()->findField(fields::CONTENT_TYPE)); type = *ctf.getValue().dynamicCast (); } catch (exceptions::no_such_field&) { // No "Content-type" field: assume "application/octet-stream". type = mediaType(mediaTypes::APPLICATION, mediaTypes::APPLICATION_OCTET_STREAM); } if (type.getType() == mediaTypes::MESSAGE && type.getSubType() == mediaTypes::MESSAGE_RFC822) { return vmime::create (part); } else { return vmime::create (part); } } // static const std::vector > attachmentHelper::findAttachmentsInMessage (ref msg, const unsigned int options) { return findAttachmentsInBodyPart(msg, options); } // static const std::vector > attachmentHelper::findAttachmentsInBodyPart (ref part, const unsigned int options) { std::vector > atts; // Test this part if (isBodyPartAnAttachment(part, options)) { atts.push_back(getBodyPartAttachment(part, options)); } // Find in sub-parts else { ref bdy = part->getBody(); for (int i = 0 ; i < bdy->getPartCount() ; ++i) { std::vector > partAtts = findAttachmentsInBodyPart(bdy->getPartAt(i), options); std::copy(partAtts.begin(), partAtts.end(), std::back_inserter(atts)); } } return atts; } // static void attachmentHelper::addAttachment(ref msg, ref att) { // We simply search for a "multipart/mixed" part. If no one exists, // create it in the root part. This (very simple) algorithm should // work in the most cases. vmime::mediaType mpMixed(vmime::mediaTypes::MULTIPART, vmime::mediaTypes::MULTIPART_MIXED); ref part = findBodyPart(msg, mpMixed); if (part == NULL) // create it { if (msg->getBody()->getPartCount() != 0) { // Create a new container part for the parts that were in // the root part of the message ref container = vmime::create (); try { if (msg->getHeader()->hasField(fields::CONTENT_TYPE)) { container->getHeader()->ContentType()->setValue (msg->getHeader()->ContentType()->getValue()); } if (msg->getHeader()->hasField(fields::CONTENT_TRANSFER_ENCODING)) { container->getHeader()->ContentTransferEncoding()->setValue (msg->getHeader()->ContentTransferEncoding()->getValue()); } } catch (exceptions::no_such_field&) { // Ignore } // Move parts from the root part to this new part const std::vector > partList = msg->getBody()->getPartList(); msg->getBody()->removeAllParts(); for (unsigned int i = 0 ; i < partList.size() ; ++i) container->getBody()->appendPart(partList[i]); msg->getBody()->appendPart(container); } else { // The message is a simple (RFC-822) message, and do not // contains any MIME part. Move the contents from the // root to a new child part. ref child = vmime::create (); if (msg->getHeader()->hasField(fields::CONTENT_TYPE)) { child->getHeader()->ContentType()->setValue (msg->getHeader()->ContentType()->getValue()); } if (msg->getHeader()->hasField(fields::CONTENT_TRANSFER_ENCODING)) { child->getHeader()->ContentTransferEncoding()->setValue (msg->getHeader()->ContentTransferEncoding()->getValue()); } child->getBody()->setContents(msg->getBody()->getContents()); msg->getBody()->setContents(vmime::create ()); msg->getBody()->appendPart(child); } // Set the root part to 'multipart/mixed' msg->getHeader()->ContentType()->setValue(mpMixed); msg->getHeader()->removeAllFields(vmime::fields::CONTENT_DISPOSITION); msg->getHeader()->removeAllFields(vmime::fields::CONTENT_TRANSFER_ENCODING); part = msg; } // Generate the attachment part att->generateIn(part); } // static ref attachmentHelper::findBodyPart (ref part, const mediaType& type) { if (part->getBody()->getContentType() == type) return part; // Try in sub-parts ref bdy = part->getBody(); for (int i = 0 ; i < bdy->getPartCount() ; ++i) { ref found = findBodyPart(bdy->getPartAt(i), type); if (found != NULL) return found; } return NULL; } // static void attachmentHelper::addAttachment(ref msg, ref amsg) { ref att = vmime::create (amsg); addAttachment(msg, att); } } // vmime libvmime-0.9.1/src/propertySet.cpp0000644000175000017500000001620711250723263017471 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/propertySet.hpp" #include "vmime/parserHelpers.hpp" namespace vmime { propertySet::propertySet() { } propertySet::propertySet(const string& props) { parse(props); } propertySet::propertySet(const propertySet& set) : object() { for (std::list >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it) m_props.push_back(vmime::create (**it)); } propertySet::~propertySet() { removeAllProperties(); } propertySet& propertySet::operator=(const propertySet& set) { removeAllProperties(); for (std::list >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it) m_props.push_back(vmime::create (**it)); return (*this); } void propertySet::setFromString(const string& props) { parse(props); } void propertySet::removeAllProperties() { m_props.clear(); } void propertySet::removeProperty(const string& name) { std::list >::iterator it = std::find_if (m_props.begin(), m_props.end(), propFinder(name)); if (it != m_props.end()) m_props.erase(it); } void propertySet::parse(const string& props) { const string::const_iterator end = props.end(); string::const_iterator pos = props.begin(); for ( ; pos != end ; ) { // Skip white-spaces for ( ; pos != end && parserHelpers::isSpace(*pos) ; ++pos) {} if (pos != end) { if (*pos == ';') { ++pos; continue; } // Extract the property name const string::const_iterator optStart = pos; for ( ; pos != end && *pos != '=' ; ++pos) {} string::const_iterator optEnd = pos; for ( ; optEnd != optStart && parserHelpers::isSpace(*(optEnd - 1)) ; --optEnd) {} const string option(optStart, optEnd); string value = "1"; if (pos != end) { ++pos; // skip '=' // Extract the value for ( ; pos != end && parserHelpers::isSpace(*pos) ; ++pos) {} if (pos != end) { // A quoted-string if (*pos == '"' || *pos == '\'') { value.reserve(50); const std::string::value_type quoteChar = *pos; bool theEnd = false; bool escape = false; for ( ; (pos != end) && !theEnd ; ++pos) { if (escape) { value += *pos; escape = false; } else { if (*pos == '\\') escape = true; else if (*pos == quoteChar) theEnd = true; else value += *pos; } } if (pos != end) ++pos; } // Simple value else { const string::const_iterator valStart = pos; for ( ; pos != end && !parserHelpers::isSpace(*pos) ; ++pos) {} value = string(valStart, pos); } // Advance to the next ';' for ( ; pos != end && (*pos != ';') ; ++pos) {} if (pos != end) ++pos; // skip ';' } } m_props.push_back(vmime::create (option, value)); } } } ref propertySet::find(const string& name) const { std::list >::const_iterator it = std::find_if (m_props.begin(), m_props.end(), propFinder(name)); return (it != m_props.end() ? *it : NULL); } ref propertySet::findOrCreate(const string& name) { std::list >::const_iterator it = std::find_if (m_props.begin(), m_props.end(), propFinder(name)); if (it != m_props.end()) { return (*it); } else { ref prop = vmime::create (name, ""); m_props.push_back(prop); return (prop); } } propertySet::propertyProxy propertySet::operator[](const string& name) { return (propertyProxy(name, this)); } const propertySet::constPropertyProxy propertySet::operator[](const string& name) const { return (constPropertyProxy(name, this)); } bool propertySet::hasProperty(const string& name) const { return (find(name) != NULL); } const std::vector > propertySet::getPropertyList() const { std::vector > res; for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it) res.push_back(*it); return (res); } const std::vector > propertySet::getPropertyList() { std::vector > res; for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it) res.push_back(*it); return (res); } // // propertySet::property // propertySet::property::property(const string& name, const string& value) : m_name(name), m_value(value) { } propertySet::property::property(const string& name) : m_name(name) { } propertySet::property::property(const property& prop) : object(), m_name(prop.m_name), m_value(prop.m_value) { } const string& propertySet::property::getName() const { return (m_name); } const string& propertySet::property::getValue() const { return (m_value); } void propertySet::property::setValue(const string& value) { m_value = value; } #ifndef VMIME_INLINE_TEMPLATE_SPECIALIZATION template <> void propertySet::property::setValue(const string& value) { m_value = value; } template <> void propertySet::property::setValue(const bool& value) { m_value = value ? "true" : "false"; } template <> string propertySet::property::getValue() const { return (m_value); } template <> bool propertySet::property::getValue() const { if (utility::stringUtils::toLower(m_value) == "true") return true; else { int val = 0; std::istringstream iss(m_value); iss.imbue(std::locale::classic()); // no formatting iss >> val; return (!iss.fail() && val != 0); } } template <> string propertySet::valueFromString(const string& value) { return value; } template <> string propertySet::valueToString(const string& value) { return value; } template <> bool propertySet::valueFromString(const string& value) { if (utility::stringUtils::toLower(value) == "true") return true; else { int val = 0; std::istringstream iss(value); iss.imbue(std::locale::classic()); // no formatting iss >> val; return (!iss.fail() && val != 0); } } template <> string propertySet::valueToString(const bool& value) { return (value ? "true" : "false"); } #endif // VMIME_INLINE_TEMPLATE_SPECIALIZATION } // vmime libvmime-0.9.1/src/streamContentHandler.cpp0000644000175000017500000001150311376250173021253 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/streamContentHandler.hpp" namespace vmime { streamContentHandler::streamContentHandler() : m_encoding(NO_ENCODING), m_stream(null) { } streamContentHandler::streamContentHandler(ref is, const utility::stream::size_type length, const vmime::encoding& enc) { setData(is, length, enc); } streamContentHandler::~streamContentHandler() { } streamContentHandler::streamContentHandler(const streamContentHandler& cts) : contentHandler(), m_encoding(cts.m_encoding), m_stream(cts.m_stream), m_length(cts.m_length) { } ref streamContentHandler::clone() const { return vmime::create (*this); } streamContentHandler& streamContentHandler::operator=(const streamContentHandler& cts) { m_encoding = cts.m_encoding; m_stream = cts.m_stream; m_length = cts.m_length; return (*this); } void streamContentHandler::setData(ref is, const utility::stream::size_type length, const vmime::encoding& enc) { m_encoding = enc; m_length = length; m_stream = is; } void streamContentHandler::generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const { if (!m_stream) return; // Managed data is already encoded if (isEncoded()) { // The data is already encoded but the encoding specified for // the generation is different from the current one. We need // to re-encode data: decode from input buffer to temporary // buffer, and then re-encode to output stream... if (m_encoding != enc) { ref theDecoder = m_encoding.getEncoder(); ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; m_stream->reset(); // may not work... std::ostringstream oss; utility::outputStreamAdapter tempOut(oss); theDecoder->decode(*m_stream, tempOut); string str = oss.str(); utility::inputStreamStringAdapter tempIn(str); theEncoder->encode(tempIn, os); } // No encoding to perform else { m_stream->reset(); // may not work... utility::bufferedStreamCopy(*m_stream, os); } } // Need to encode data before else { ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; m_stream->reset(); // may not work... theEncoder->encode(*m_stream, os); } } void streamContentHandler::extract(utility::outputStream& os, utility::progressListener* progress) const { if (!m_stream) return; // No decoding to perform if (!isEncoded()) { m_stream->reset(); // may not work... if (progress) utility::bufferedStreamCopy(*m_stream, os, getLength(), progress); else utility::bufferedStreamCopy(*m_stream, os); } // Need to decode data else { ref theDecoder = m_encoding.getEncoder(); m_stream->reset(); // may not work... utility::progressListenerSizeAdapter plsa(progress, getLength()); theDecoder->decode(*m_stream, os, &plsa); } } void streamContentHandler::extractRaw(utility::outputStream& os, utility::progressListener* progress) const { if (!m_stream) return; m_stream->reset(); // may not work... if (progress) utility::bufferedStreamCopy(*m_stream, os, getLength(), progress); else utility::bufferedStreamCopy(*m_stream, os); } string::size_type streamContentHandler::getLength() const { return (m_length); } bool streamContentHandler::isEmpty() const { return (m_length == 0 || !m_stream); } bool streamContentHandler::isEncoded() const { return (m_encoding != NO_ENCODING); } const vmime::encoding& streamContentHandler::getEncoding() const { return (m_encoding); } bool streamContentHandler::isBuffered() const { // FIXME: some streams can be resetted return false; } } // vmime libvmime-0.9.1/src/header.cpp0000644000175000017500000002023711250723263016357 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/header.hpp" #include "vmime/parserHelpers.hpp" #include namespace vmime { header::header() { } header::~header() { removeAllFields(); } /* RFC #822: 3.2. HEADER FIELD DEFINITIONS field = field-name ":" [ field-body ] CRLF field-name = 1* field-body = field-body-contents [CRLF LWSP-char field-body] field-body-contents = */ void header::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { string::size_type pos = position; removeAllFields(); while (pos < end) { ref field = headerField::parseNext(buffer, pos, end, &pos); if (field == NULL) break; m_fields.push_back(field); } setParsedBounds(position, pos); if (newPosition) *newPosition = pos; } void header::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type /* curLinePos */, string::size_type* newLinePos) const { // Generate the fields for (std::vector >::const_iterator it = m_fields.begin() ; it != m_fields.end() ; ++it) { (*it)->generate(os, maxLineLength); os << CRLF; } if (newLinePos) *newLinePos = 0; } ref header::clone() const { ref
hdr = vmime::create
(); hdr->m_fields.reserve(m_fields.size()); for (std::vector >::const_iterator it = m_fields.begin() ; it != m_fields.end() ; ++it) { hdr->m_fields.push_back((*it)->clone().dynamicCast ()); } return (hdr); } void header::copyFrom(const component& other) { const header& h = dynamic_cast (other); std::vector > fields; fields.reserve(h.m_fields.size()); for (std::vector >::const_iterator it = h.m_fields.begin() ; it != h.m_fields.end() ; ++it) { fields.push_back((*it)->clone().dynamicCast ()); } m_fields.clear(); m_fields.resize(fields.size()); std::copy(fields.begin(), fields.end(), m_fields.begin()); } header& header::operator=(const header& other) { copyFrom(other); return (*this); } bool header::hasField(const string& fieldName) const { std::vector >::const_iterator pos = std::find_if(m_fields.begin(), m_fields.end(), fieldHasName(utility::stringUtils::toLower(fieldName))); return (pos != m_fields.end()); } ref header::findField(const string& fieldName) const { // Find the first field that matches the specified name std::vector >::const_iterator pos = std::find_if(m_fields.begin(), m_fields.end(), fieldHasName(utility::stringUtils::toLower(fieldName))); // No field with this name can be found if (pos == m_fields.end()) { throw exceptions::no_such_field(); } // Else, return a reference to the existing field else { return (*pos); } } std::vector > header::findAllFields(const string& fieldName) { std::vector > result; std::back_insert_iterator > > back(result); std::remove_copy_if(m_fields.begin(), m_fields.end(), back, fieldHasNotName(utility::stringUtils::toLower(fieldName))); return result; } ref header::getField(const string& fieldName) { const string name = utility::stringUtils::toLower(fieldName); // Find the first field that matches the specified name std::vector >::const_iterator pos = m_fields.begin(); const std::vector >::const_iterator end = m_fields.end(); while (pos != end && utility::stringUtils::toLower((*pos)->getName()) != name) ++pos; // If no field with this name can be found, create a new one if (pos == end) { ref field = headerFieldFactory::getInstance()->create(fieldName); appendField(field); // Return a reference to the new field return (field); } // Else, return a reference to the existing field else { return (*pos); } } void header::appendField(ref field) { m_fields.push_back(field); } void header::insertFieldBefore(ref beforeField, ref field) { const std::vector >::iterator it = std::find (m_fields.begin(), m_fields.end(), beforeField); if (it == m_fields.end()) throw exceptions::no_such_field(); m_fields.insert(it, field); } void header::insertFieldBefore(const int pos, ref field) { m_fields.insert(m_fields.begin() + pos, field); } void header::insertFieldAfter(ref afterField, ref field) { const std::vector >::iterator it = std::find (m_fields.begin(), m_fields.end(), afterField); if (it == m_fields.end()) throw exceptions::no_such_field(); m_fields.insert(it + 1, field); } void header::insertFieldAfter(const int pos, ref field) { m_fields.insert(m_fields.begin() + pos + 1, field); } void header::removeField(ref field) { const std::vector >::iterator it = std::find (m_fields.begin(), m_fields.end(), field); if (it == m_fields.end()) throw exceptions::no_such_field(); m_fields.erase(it); } void header::removeField(const int pos) { const std::vector >::iterator it = m_fields.begin() + pos; m_fields.erase(it); } void header::removeAllFields() { m_fields.clear(); } void header::removeAllFields(const string& fieldName) { std::vector > fields = findAllFields(fieldName); for (unsigned int i = 0 ; i < fields.size() ; ++i) removeField(fields[i]); } int header::getFieldCount() const { return (m_fields.size()); } bool header::isEmpty() const { return (m_fields.empty()); } const ref header::getFieldAt(const int pos) { return (m_fields[pos]); } const ref header::getFieldAt(const int pos) const { return (m_fields[pos]); } const std::vector > header::getFieldList() const { std::vector > list; list.reserve(m_fields.size()); for (std::vector >::const_iterator it = m_fields.begin() ; it != m_fields.end() ; ++it) { list.push_back(*it); } return (list); } const std::vector > header::getFieldList() { return (m_fields); } const std::vector > header::getChildComponents() const { std::vector > list; copy_vector(m_fields, list); return (list); } // Field search header::fieldHasName::fieldHasName(const string& name) : m_name(name) { } bool header::fieldHasName::operator() (const ref & field) { return utility::stringUtils::toLower(field->getName()) == m_name; } header::fieldHasNotName::fieldHasNotName(const string& name) : m_name(name) { } bool header::fieldHasNotName::operator() (const ref & field) { return utility::stringUtils::toLower(field->getName()) != m_name; } } // vmime libvmime-0.9.1/src/addressList.cpp0000644000175000017500000001375411250723263017416 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/addressList.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/exception.hpp" #include "vmime/mailboxList.hpp" #include "vmime/mailboxGroup.hpp" namespace vmime { addressList::addressList() { } addressList::addressList(const addressList& addrList) : headerFieldValue() { copyFrom(addrList); } addressList::~addressList() { removeAllAddresses(); } void addressList::parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { removeAllAddresses(); string::size_type pos = position; while (pos < end) { ref
parsedAddress = address::parseNext(buffer, pos, end, &pos); if (parsedAddress != NULL) m_list.push_back(parsedAddress); } setParsedBounds(position, end); if (newPosition) *newPosition = end; } void addressList::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { string::size_type pos = curLinePos; if (!m_list.empty()) { for (std::vector >::const_iterator i = m_list.begin() ; ; ) { (*i)->generate(os, maxLineLength - 2, pos, &pos); if (++i == m_list.end()) break; os << ", "; pos += 2; } } if (newLinePos) *newLinePos = pos; } void addressList::copyFrom(const component& other) { const addressList& addrList = dynamic_cast (other); removeAllAddresses(); for (std::vector >::const_iterator it = addrList.m_list.begin() ; it != addrList.m_list.end() ; ++it) { m_list.push_back((*it)->clone().dynamicCast
()); } } addressList& addressList::operator=(const addressList& other) { copyFrom(other); return (*this); } addressList& addressList::operator=(const mailboxList& other) { removeAllAddresses(); for (int i = 0 ; i < other.getMailboxCount() ; ++i) m_list.push_back(other.getMailboxAt(i)->clone().dynamicCast
()); return (*this); } ref addressList::clone() const { return vmime::create (*this); } void addressList::appendAddress(ref
addr) { m_list.push_back(addr); } void addressList::insertAddressBefore(ref
beforeAddress, ref
addr) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), beforeAddress); if (it == m_list.end()) throw exceptions::no_such_address(); m_list.insert(it, addr); } void addressList::insertAddressBefore(const int pos, ref
addr) { m_list.insert(m_list.begin() + pos, addr); } void addressList::insertAddressAfter(ref
afterAddress, ref
addr) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), afterAddress); if (it == m_list.end()) throw exceptions::no_such_address(); m_list.insert(it + 1, addr); } void addressList::insertAddressAfter(const int pos, ref
addr) { m_list.insert(m_list.begin() + pos + 1, addr); } void addressList::removeAddress(ref
addr) { const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), addr); if (it == m_list.end()) throw exceptions::no_such_address(); m_list.erase(it); } void addressList::removeAddress(const int pos) { const std::vector >::iterator it = m_list.begin() + pos; m_list.erase(it); } void addressList::removeAllAddresses() { m_list.clear(); } int addressList::getAddressCount() const { return (m_list.size()); } bool addressList::isEmpty() const { return (m_list.empty()); } ref
addressList::getAddressAt(const int pos) { return (m_list[pos]); } const ref addressList::getAddressAt(const int pos) const { return (m_list[pos]); } const std::vector > addressList::getAddressList() const { std::vector > list; list.reserve(m_list.size()); for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { list.push_back(*it); } return (list); } const std::vector > addressList::getAddressList() { return (m_list); } const std::vector > addressList::getChildComponents() const { std::vector > list; copy_vector(m_list, list); return (list); } ref addressList::toMailboxList() const { ref res = vmime::create (); for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { ref addr = *it; if (addr->isGroup()) { const std::vector > mailboxes = addr.dynamicCast ()->getMailboxList(); for (std::vector >::const_iterator jt = mailboxes.begin() ; jt != mailboxes.end() ; ++jt) { res->appendMailbox(vmime::clone(*jt)); } } else { res->appendMailbox(addr->clone().dynamicCast ()); } } return res; } } // vmime libvmime-0.9.1/src/base.cpp0000644000175000017500000000725411333330451016040 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/config.hpp" #include "vmime/charset.hpp" #include "vmime/base.hpp" #include "vmime/utility/encoder/encoder.hpp" #include "vmime/utility/encoder/b64Encoder.hpp" #include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/text.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/utility/stringUtils.hpp" // For initializing #include "vmime/utility/encoder/encoderFactory.hpp" #include "vmime/headerFieldFactory.hpp" #include "vmime/textPartFactory.hpp" #include "vmime/options.hpp" #if VMIME_HAVE_MESSAGING_FEATURES #include "vmime/net/serviceFactory.hpp" #endif namespace vmime { /** "Null" (empty) string. */ const string NULL_STRING; /** "Null" (empty) text. */ const text NULL_TEXT; /** "Null" (empty) word. */ const word NULL_WORD("", vmime::charset(vmime::charsets::US_ASCII)); /** Return the library name (eg: "libvmime"). * * @return library name */ const string libname() { return (VMIME_PACKAGE); } /** Return the library version (eg: "0.5.2"). * * @return library version */ const string libversion() { return (VMIME_VERSION " (" __DATE__ " " __TIME__ ")"); } /** Return the library API version (eg: "6:1:6"). * * @return library API version */ const string libapi() { return (VMIME_API); } // New line sequence to be used when folding header fields. const string NEW_LINE_SEQUENCE = "\r\n "; const string::size_type NEW_LINE_SEQUENCE_LENGTH = 1; // space /** The CR-LF sequence. */ const string CRLF = "\r\n"; /** The current MIME version supported by VMime. */ const string SUPPORTED_MIME_VERSION = "1.0"; /** Null reference. */ const null_ref null = null_ref(); // Line length limits namespace lineLengthLimits { const string::size_type infinite = std::numeric_limits ::max(); } #ifndef VMIME_BUILDING_DOC // // V-Mime Initializer // ==================== // // Force instanciation of singletons. This is to prevent problems that might // happen in multithreaded applications... // // WARNING: we put the initializer at the end of this compilation unit. This // ensures this object is initialized _after_ all other global variables in // the same compilation unit (in particular "lineLengthLimits::infinite", // which is used by the generate() function (called from "textPartFactory" // constructor, for example). // class initializer { public: initializer() { options::getInstance(); utility::encoder::encoderFactory::getInstance(); headerFieldFactory::getInstance(); textPartFactory::getInstance(); #if VMIME_HAVE_MESSAGING_FEATURES net::serviceFactory::getInstance(); #endif } }; initializer theInitializer; #endif // VMIME_BUILDING_DOC } // vmime libvmime-0.9.1/src/htmlTextPart.cpp0000644000175000017500000003033411376245106017572 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "vmime/htmlTextPart.hpp" #include "vmime/exception.hpp" #include "vmime/contentTypeField.hpp" #include "vmime/contentDisposition.hpp" #include "vmime/text.hpp" #include "vmime/emptyContentHandler.hpp" #include "vmime/stringContentHandler.hpp" namespace vmime { htmlTextPart::htmlTextPart() : m_plainText(vmime::create ()), m_text(vmime::create ()) { } htmlTextPart::~htmlTextPart() { } const mediaType htmlTextPart::getType() const { return mediaType(mediaTypes::TEXT, mediaTypes::TEXT_HTML); } int htmlTextPart::getPartCount() const { return (m_plainText->isEmpty() ? 1 : 2); } void htmlTextPart::generateIn(ref /* message */, ref parent) const { // Plain text if (!m_plainText->isEmpty()) { // -- Create a new part ref part = vmime::create (); parent->getBody()->appendPart(part); // -- Set contents part->getBody()->setContents(m_plainText, mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN), m_charset, encoding::decide(m_plainText, m_charset, encoding::USAGE_TEXT)); } // HTML text // -- Create a new part ref htmlPart = vmime::create (); // -- Set contents htmlPart->getBody()->setContents(m_text, mediaType(mediaTypes::TEXT, mediaTypes::TEXT_HTML), m_charset, encoding::decide(m_text, m_charset, encoding::USAGE_TEXT)); // Handle the case we have embedded objects if (!m_objects.empty()) { // Create a "multipart/related" body part ref relPart = vmime::create (); parent->getBody()->appendPart(relPart); relPart->getHeader()->ContentType()-> setValue(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_RELATED)); // Add the HTML part into this part relPart->getBody()->appendPart(htmlPart); // Also add objects into this part for (std::vector >::const_iterator it = m_objects.begin() ; it != m_objects.end() ; ++it) { ref objPart = vmime::create (); relPart->getBody()->appendPart(objPart); string id = (*it)->getId(); if (id.substr(0, 4) == "CID:") id = id.substr(4); objPart->getHeader()->ContentType()->setValue((*it)->getType()); objPart->getHeader()->ContentId()->setValue(messageId("<" + id + ">")); objPart->getHeader()->ContentDisposition()->setValue(contentDisposition(contentDispositionTypes::INLINE)); objPart->getHeader()->ContentTransferEncoding()->setValue((*it)->getEncoding()); //encoding(encodingTypes::BASE64); objPart->getBody()->setContents((*it)->getData()->clone()); } } else { // Add the HTML part into the parent part parent->getBody()->appendPart(htmlPart); } } void htmlTextPart::findEmbeddedParts(const bodyPart& part, std::vector >& cidParts, std::vector >& locParts) { for (int i = 0 ; i < part.getBody()->getPartCount() ; ++i) { ref p = part.getBody()->getPartAt(i); // For a part to be an embedded object, it must have a // Content-Id field or a Content-Location field. try { p->getHeader()->findField(fields::CONTENT_ID); cidParts.push_back(p); } catch (exceptions::no_such_field) { // No "Content-id" field. } try { p->getHeader()->findField(fields::CONTENT_LOCATION); locParts.push_back(p); } catch (exceptions::no_such_field) { // No "Content-Location" field. } findEmbeddedParts(*p, cidParts, locParts); } } void htmlTextPart::addEmbeddedObject(const bodyPart& part, const string& id) { // The object may already exists. This can happen if an object is // identified by both a Content-Id and a Content-Location. In this // case, there will be two embedded objects with two different IDs // but referencing the same content. mediaType type; try { const ref ctf = part.getHeader()->ContentType(); type = *ctf->getValue().dynamicCast (); } catch (exceptions::no_such_field) { // No "Content-type" field: assume "application/octet-stream". } m_objects.push_back(vmime::create (part.getBody()->getContents()->clone().dynamicCast (), part.getBody()->getEncoding(), id, type)); } void htmlTextPart::parse(ref message, ref parent, ref textPart) { // Search for possible embedded objects in the _whole_ message. std::vector > cidParts; std::vector > locParts; findEmbeddedParts(*message, cidParts, locParts); // Extract HTML text std::ostringstream oss; utility::outputStreamAdapter adapter(oss); textPart->getBody()->getContents()->extract(adapter); const string data = oss.str(); m_text = textPart->getBody()->getContents()->clone(); try { const ref ctf = textPart->getHeader()->findField(fields::CONTENT_TYPE).dynamicCast (); m_charset = ctf->getCharset(); } catch (exceptions::no_such_field) { // No "Content-type" field. } catch (exceptions::no_such_parameter) { // No "charset" parameter. } // Extract embedded objects. The algorithm is quite simple: for each previously // found inline part, we check if its CID/Location is contained in the HTML text. for (std::vector >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p) { const ref midField = (*p)->getHeader()->findField(fields::CONTENT_ID); const messageId mid = *midField->getValue().dynamicCast (); if (data.find("CID:" + mid.getId()) != string::npos || data.find("cid:" + mid.getId()) != string::npos) { // This part is referenced in the HTML text. // Add it to the embedded object list. addEmbeddedObject(**p, mid.getId()); } } for (std::vector >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p) { const ref locField = (*p)->getHeader()->findField(fields::CONTENT_LOCATION); const text loc = *locField->getValue().dynamicCast (); const string locStr = loc.getWholeBuffer(); if (data.find(locStr) != string::npos) { // This part is referenced in the HTML text. // Add it to the embedded object list. addEmbeddedObject(**p, locStr); } } // Extract plain text, if any. if (!findPlainTextPart(*message, *parent, *textPart)) { m_plainText = vmime::create (); } } bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& parent, const bodyPart& textPart) { // We search for the nearest "multipart/alternative" part. try { const ref ctf = part.getHeader()->findField(fields::CONTENT_TYPE); const mediaType type = *ctf->getValue().dynamicCast (); if (type.getType() == mediaTypes::MULTIPART && type.getSubType() == mediaTypes::MULTIPART_ALTERNATIVE) { ref foundPart = NULL; for (int i = 0 ; i < part.getBody()->getPartCount() ; ++i) { const ref p = part.getBody()->getPartAt(i); if (p == &parent || // if "text/html" is in "multipart/related" p == &textPart) // if not... { foundPart = p; } } if (foundPart) { bool found = false; // Now, search for the alternative plain text part for (int i = 0 ; !found && i < part.getBody()->getPartCount() ; ++i) { const ref p = part.getBody()->getPartAt(i); try { const ref ctf = p->getHeader()->findField(fields::CONTENT_TYPE); const mediaType type = *ctf->getValue().dynamicCast (); if (type.getType() == mediaTypes::TEXT && type.getSubType() == mediaTypes::TEXT_PLAIN) { m_plainText = p->getBody()->getContents()->clone(); found = true; } } catch (exceptions::no_such_field) { // No "Content-type" field. } } // If we don't have found the plain text part here, it means that // it does not exists (the MUA which built this message probably // did not include it...). return found; } } } catch (exceptions::no_such_field) { // No "Content-type" field. } bool found = false; for (int i = 0 ; !found && i < part.getBody()->getPartCount() ; ++i) { found = findPlainTextPart(*part.getBody()->getPartAt(i), parent, textPart); } return found; } const charset& htmlTextPart::getCharset() const { return m_charset; } void htmlTextPart::setCharset(const charset& ch) { m_charset = ch; } const ref htmlTextPart::getPlainText() const { return m_plainText; } void htmlTextPart::setPlainText(ref plainText) { m_plainText = plainText->clone(); } const ref htmlTextPart::getText() const { return m_text; } void htmlTextPart::setText(ref text) { m_text = text->clone(); } int htmlTextPart::getObjectCount() const { return m_objects.size(); } const ref htmlTextPart::getObjectAt(const int pos) const { return m_objects[pos]; } const ref htmlTextPart::findObject(const string& id_) const { const string id = cleanId(id_); for (std::vector >::const_iterator o = m_objects.begin() ; o != m_objects.end() ; ++o) { if ((*o)->getId() == id) return *o; } throw exceptions::no_object_found(); } bool htmlTextPart::hasObject(const string& id_) const { const string id = cleanId(id_); for (std::vector >::const_iterator o = m_objects.begin() ; o != m_objects.end() ; ++o) { if ((*o)->getId() == id) return true; } return false; } const string htmlTextPart::addObject(ref data, const vmime::encoding& enc, const mediaType& type) { const messageId mid(messageId::generateId()); const string id = mid.getId(); m_objects.push_back(vmime::create (data, enc, id, type)); return "CID:" + id; } const string htmlTextPart::addObject(ref data, const mediaType& type) { return addObject(data, encoding::decide(data), type); } const string htmlTextPart::addObject(const string& data, const mediaType& type) { ref cts = vmime::create (data); return addObject(cts, encoding::decide(cts), type); } // static const string htmlTextPart::cleanId(const string& id) { if (id.length() >= 4 && (id[0] == 'c' || id[0] == 'C') && (id[1] == 'i' || id[1] == 'I') && (id[2] == 'd' || id[2] == 'D') && id[3] == ':') { return id.substr(4); } else { return id; } } // // htmlTextPart::embeddedObject // htmlTextPart::embeddedObject::embeddedObject (ref data, const encoding& enc, const string& id, const mediaType& type) : m_data(data->clone().dynamicCast ()), m_encoding(enc), m_id(id), m_type(type) { } const ref htmlTextPart::embeddedObject::getData() const { return m_data; } const vmime::encoding& htmlTextPart::embeddedObject::getEncoding() const { return m_encoding; } const string& htmlTextPart::embeddedObject::getId() const { return m_id; } const mediaType& htmlTextPart::embeddedObject::getType() const { return m_type; } } // vmime libvmime-0.9.1/NEWS0000644000175000017500000000000011250723264014316 0ustar mnordstrmnordstrlibvmime-0.9.1/vmime.pc.in0000644000175000017500000000070411470477531015707 0ustar mnordstrmnordstr# File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: @GENERIC_LIBRARY_NAME@ Description: VMime C++ Mail Library (http://www.vmime.org) Version: @VERSION@ Requires: @GSASL_REQUIRED@ Libs: -L${libdir} -l@GENERIC_VERSIONED_LIBRARY_NAME@ @GSASL_LIBS@ @LIBGNUTLS_LIBS@ @VMIME_ADDITIONAL_PC_LIBS@ Cflags: -I${includedir}/ @LIBGNUTLS_CFLAGS@ libvmime-0.9.1/SConstruct0000644000175000017500000020441411375200714015666 0ustar mnordstrmnordstr# # SConstruct # libvmime build script # # Process this file with 'scons' to build the project. # For more information, please visit: http://www.scons.org/ . # # Usage: # # . scons build the library # . scons -h see available configuration options # . scons opt=value set a configuration option # . scons install install library and include files (as root) # . scons dist build a source package (.tar.bz2) # . scons doc build documentation for the project (Doxygen) # import commands import os import sys import re import string ############# # Version # ############# # Package version number packageVersionMajor = 0 packageVersionMinor = 9 packageVersionMicro = 1 # API version number (libtool) # # Increment this number only immediately before a public release. # This is independent from package version number. # # See: http://www.gnu.org/software/libtool/manual.html#Libtool-versioning # # . Implementation changed (eg. bug/security fix): REVISION++ # . Interfaces added/removed/changed: CURRENT++, REVISION=0 # . Interfaces added (upward-compatible changes): AGE++ # . Interfaces removed: AGE=0 # packageAPICurrent = 0 packageAPIRevision = 0 packageAPIAge = 0 # Package information packageName = 'libvmime' packageGenericName = 'vmime' packageRealName = 'VMime Library' packageDescription = 'VMime C++ Mail Library (http://www.vmime.org)' packageMaintainer = 'vincent@vincent-richard.net' packageVersion = '%d.%d.%d' % (packageVersionMajor, packageVersionMinor, packageVersionMicro) packageAPI = '%d:%d:%d' % (packageAPICurrent, packageAPIRevision, packageAPIAge) #if packageVersionMajor >= 2: # packageVersionedGenericName = packageGenericName + ('%d' % packageVersionMajor) # packageVersionedName = packageName + ('%d' % packageVersionMajor) #else: # packageVersionedGenericName = packageGenericName # packageVersionedName = packageName packageVersionedGenericName = packageGenericName packageVersionedName = packageName ################## # Source files # ################## libvmime_sources = [ # ============================== Parser ============================== 'address.cpp', 'address.hpp', 'addressList.cpp', 'addressList.hpp', 'attachment.hpp', 'attachmentHelper.cpp', 'attachmentHelper.hpp', 'base.cpp', 'base.hpp', 'body.cpp', 'body.hpp', 'bodyPart.cpp', 'bodyPart.hpp', 'bodyPartAttachment.cpp', 'bodyPartAttachment.hpp', 'charset.cpp', 'charset.hpp', 'charsetConverter.cpp', 'charsetConverter.hpp', 'component.cpp', 'component.hpp', 'constants.cpp', 'constants.hpp', 'contentDisposition.cpp', 'contentDisposition.hpp', 'contentDispositionField.cpp', 'contentDispositionField.hpp', 'contentHandler.cpp', 'contentHandler.hpp', 'contentTypeField.cpp', 'contentTypeField.hpp', 'dateTime.cpp', 'dateTime.hpp', 'defaultAttachment.cpp', 'defaultAttachment.hpp', 'disposition.cpp', 'disposition.hpp', 'emptyContentHandler.cpp', 'emptyContentHandler.hpp', 'encoding.cpp', 'encoding.hpp', 'exception.cpp', 'exception.hpp', 'fileAttachment.cpp', 'fileAttachment.hpp', 'generatedMessageAttachment.hpp', 'generatedMessageAttachment.cpp', 'header.cpp', 'header.hpp', 'headerFieldFactory.cpp', 'headerFieldFactory.hpp', 'headerField.cpp', 'headerField.hpp', 'headerFieldValue.hpp', 'htmlTextPart.cpp', 'htmlTextPart.hpp', 'mailbox.cpp', 'mailbox.hpp', 'mailboxField.cpp', 'mailboxField.hpp', 'mailboxGroup.cpp', 'mailboxGroup.hpp', 'mailboxList.cpp', 'mailboxList.hpp', 'mediaType.cpp', 'mediaType.hpp', 'messageAttachment.hpp', 'messageBuilder.cpp', 'messageBuilder.hpp', 'message.cpp', 'message.hpp', 'messageId.cpp', 'messageId.hpp', 'messageIdSequence.cpp', 'messageIdSequence.hpp', 'messageParser.cpp', 'messageParser.hpp', 'object.cpp', 'object.hpp', 'options.cpp', 'options.hpp', 'path.cpp', 'path.hpp', 'parameter.cpp', 'parameter.hpp', 'parameterizedHeaderField.cpp', 'parameterizedHeaderField.hpp', 'parsedMessageAttachment.cpp', 'parsedMessageAttachment.hpp', 'parserHelpers.hpp', 'plainTextPart.cpp', 'plainTextPart.hpp', 'platform.cpp', 'platform.hpp', 'propertySet.cpp', 'propertySet.hpp', 'relay.cpp', 'relay.hpp', 'stringContentHandler.cpp', 'stringContentHandler.hpp', 'streamContentHandler.cpp', 'streamContentHandler.hpp', 'text.cpp', 'text.hpp', 'textPartFactory.cpp', 'textPartFactory.hpp', 'textPart.hpp', 'types.hpp', 'word.cpp', 'word.hpp', 'wordEncoder.cpp', 'wordEncoder.hpp', 'vmime.hpp', # ============================== Utility ============================= 'utility/childProcess.hpp', 'utility/file.hpp', 'utility/datetimeUtils.cpp', 'utility/datetimeUtils.hpp', 'utility/filteredStream.cpp', 'utility/filteredStream.hpp', 'utility/path.cpp', 'utility/path.hpp', 'utility/progressListener.cpp', 'utility/progressListener.hpp', 'utility/random.cpp', 'utility/random.hpp', 'utility/smartPtr.cpp', 'utility/smartPtr.hpp', 'utility/smartPtrInt.cpp', 'utility/smartPtrInt.hpp', 'utility/stream.cpp', 'utility/stream.hpp', 'utility/stringProxy.cpp', 'utility/stringProxy.hpp', 'utility/stringUtils.cpp', 'utility/stringUtils.hpp', 'utility/url.cpp', 'utility/url.hpp', 'utility/urlUtils.cpp', 'utility/urlUtils.hpp', # -- encoder 'utility/encoder/encoder.cpp', 'utility/encoder/encoder.hpp', 'utility/encoder/sevenBitEncoder.cpp', 'utility/encoder/sevenBitEncoder.hpp', 'utility/encoder/eightBitEncoder.cpp', 'utility/encoder/eightBitEncoder.hpp', 'utility/encoder/b64Encoder.cpp', 'utility/encoder/b64Encoder.hpp', 'utility/encoder/binaryEncoder.cpp', 'utility/encoder/binaryEncoder.hpp', 'utility/encoder/defaultEncoder.cpp', 'utility/encoder/defaultEncoder.hpp', 'utility/encoder/encoderFactory.cpp', 'utility/encoder/encoderFactory.hpp', 'utility/encoder/qpEncoder.cpp', 'utility/encoder/qpEncoder.hpp', 'utility/encoder/uuEncoder.cpp', 'utility/encoder/uuEncoder.hpp', # =============================== MDN ================================ 'mdn/MDNHelper.cpp', 'mdn/MDNHelper.hpp', 'mdn/MDNInfos.cpp', 'mdn/MDNInfos.hpp', 'mdn/receivedMDNInfos.cpp', 'mdn/receivedMDNInfos.hpp', 'mdn/sendableMDNInfos.cpp', 'mdn/sendableMDNInfos.hpp', # =============================== Misc =============================== 'misc/importanceHelper.cpp', 'misc/importanceHelper.hpp', # ============================= Security ============================= 'security/authenticator.hpp', 'security/defaultAuthenticator.cpp', 'security/defaultAuthenticator.hpp', # -- digest 'security/digest/messageDigest.cpp', 'security/digest/messageDigest.hpp', 'security/digest/messageDigestFactory.cpp', 'security/digest/messageDigestFactory.hpp', 'security/digest/md5/md5MessageDigest.cpp', 'security/digest/md5/md5MessageDigest.hpp', 'security/digest/sha1/sha1MessageDigest.cpp', 'security/digest/sha1/sha1MessageDigest.hpp' ] libvmime_security_sasl_sources = [ 'security/sasl/SASLContext.cpp', 'security/sasl/SASLContext.hpp', 'security/sasl/SASLSession.cpp', 'security/sasl/SASLSession.hpp', 'security/sasl/SASLMechanism.hpp', 'security/sasl/SASLMechanismFactory.cpp', 'security/sasl/SASLMechanismFactory.hpp', 'security/sasl/SASLSocket.cpp', 'security/sasl/SASLSocket.hpp', 'security/sasl/SASLAuthenticator.hpp', 'security/sasl/defaultSASLAuthenticator.cpp', 'security/sasl/defaultSASLAuthenticator.hpp', 'security/sasl/builtinSASLMechanism.cpp', 'security/sasl/builtinSASLMechanism.hpp' ] libvmime_examples_sources = [ 'examples/README', # 'examples/Makefile.am', # not generated # 'examples/Makefile.in', 'examples/example1.cpp', 'examples/example2.cpp', 'examples/example3.cpp', 'examples/example4.cpp', 'examples/example5.cpp', 'examples/example6.cpp', 'examples/example7.cpp' ] libvmime_messaging_sources = [ 'net/builtinServices.inl', 'net/connectionInfos.hpp', 'net/defaultConnectionInfos.cpp', 'net/defaultConnectionInfos.hpp', 'net/events.cpp', 'net/events.hpp', 'net/folder.cpp', 'net/folder.hpp', 'net/message.cpp', 'net/message.hpp', 'net/securedConnectionInfos.hpp', 'net/service.cpp', 'net/service.hpp', 'net/serviceFactory.cpp', 'net/serviceFactory.hpp', 'net/serviceInfos.cpp', 'net/serviceInfos.hpp', 'net/serviceRegistration.inl', 'net/session.cpp', 'net/session.hpp', 'net/socket.hpp', 'net/store.hpp', 'net/timeoutHandler.hpp', 'net/transport.cpp', 'net/transport.hpp' ] libvmime_net_tls_sources = [ 'net/tls/TLSSession.cpp', 'net/tls/TLSSession.hpp', 'net/tls/TLSSocket.cpp', 'net/tls/TLSSocket.hpp', 'net/tls/TLSSecuredConnectionInfos.cpp', 'net/tls/TLSSecuredConnectionInfos.hpp', 'security/cert/certificateChain.cpp', 'security/cert/certificateChain.hpp', 'security/cert/certificateVerifier.hpp', 'security/cert/defaultCertificateVerifier.cpp', 'security/cert/defaultCertificateVerifier.hpp', 'security/cert/certificate.hpp', 'security/cert/X509Certificate.cpp', 'security/cert/X509Certificate.hpp' ] libvmime_messaging_proto_sources = [ [ 'pop3', [ 'net/pop3/POP3ServiceInfos.cpp', 'net/pop3/POP3ServiceInfos.hpp', 'net/pop3/POP3Store.cpp', 'net/pop3/POP3Store.hpp', 'net/pop3/POP3SStore.cpp', 'net/pop3/POP3SStore.hpp', 'net/pop3/POP3Folder.cpp', 'net/pop3/POP3Folder.hpp', 'net/pop3/POP3Message.cpp', 'net/pop3/POP3Message.hpp', 'net/pop3/POP3Utils.cpp', 'net/pop3/POP3Utils.hpp' ] ], [ 'smtp', [ 'net/smtp/SMTPResponse.cpp', 'net/smtp/SMTPResponse.hpp', 'net/smtp/SMTPServiceInfos.cpp', 'net/smtp/SMTPServiceInfos.hpp', 'net/smtp/SMTPTransport.cpp', 'net/smtp/SMTPTransport.hpp', 'net/smtp/SMTPSTransport.cpp', 'net/smtp/SMTPSTransport.hpp' ] ], [ 'imap', [ 'net/imap/IMAPServiceInfos.cpp', 'net/imap/IMAPServiceInfos.hpp', 'net/imap/IMAPConnection.cpp', 'net/imap/IMAPConnection.hpp', 'net/imap/IMAPStore.cpp', 'net/imap/IMAPStore.hpp', 'net/imap/IMAPSStore.cpp', 'net/imap/IMAPSStore.hpp', 'net/imap/IMAPFolder.cpp', 'net/imap/IMAPFolder.hpp', 'net/imap/IMAPMessage.cpp', 'net/imap/IMAPMessage.hpp', 'net/imap/IMAPTag.cpp', 'net/imap/IMAPTag.hpp', 'net/imap/IMAPUtils.cpp', 'net/imap/IMAPUtils.hpp', 'net/imap/IMAPMessagePartContentHandler.cpp', 'net/imap/IMAPMessagePartContentHandler.hpp', 'net/imap/IMAPStructure.cpp', 'net/imap/IMAPStructure.hpp', 'net/imap/IMAPPart.cpp', 'net/imap/IMAPPart.hpp', 'net/imap/IMAPParser.hpp', ] ], [ 'maildir', [ 'net/maildir/maildirServiceInfos.cpp', 'net/maildir/maildirServiceInfos.hpp', 'net/maildir/maildirStore.cpp', 'net/maildir/maildirStore.hpp', 'net/maildir/maildirFolder.cpp', 'net/maildir/maildirFolder.hpp', 'net/maildir/maildirMessage.cpp', 'net/maildir/maildirMessage.hpp', 'net/maildir/maildirUtils.cpp', 'net/maildir/maildirUtils.hpp', 'net/maildir/maildirFormat.cpp', 'net/maildir/maildirFormat.hpp', 'net/maildir/format/kmailMaildirFormat.cpp', 'net/maildir/format/kmailMaildirFormat.hpp', 'net/maildir/format/courierMaildirFormat.cpp', 'net/maildir/format/courierMaildirFormat.hpp' ] ], [ 'sendmail', [ 'net/sendmail/sendmailServiceInfos.cpp', 'net/sendmail/sendmailServiceInfos.hpp', 'net/sendmail/sendmailTransport.cpp', 'net/sendmail/sendmailTransport.hpp' ] ] ] libvmime_platforms_sources = { 'posix': [ 'platforms/posix/posixChildProcess.cpp', 'platforms/posix/posixChildProcess.hpp', 'platforms/posix/posixFile.cpp', 'platforms/posix/posixFile.hpp', 'platforms/posix/posixHandler.cpp', 'platforms/posix/posixHandler.hpp', 'platforms/posix/posixSocket.cpp', 'platforms/posix/posixSocket.hpp' ], 'windows': [ 'platforms/windows/windowsFile.cpp', 'platforms/windows/windowsFile.hpp', 'platforms/windows/windowsHandler.cpp', 'platforms/windows/windowsHandler.hpp', 'platforms/windows/windowsSocket.cpp', 'platforms/windows/windowsSocket.hpp' ] } libvmime_extra = [ 'AUTHORS', 'ChangeLog', 'COPYING', 'HACKING', 'INSTALL', 'NEWS', 'README', 'README.msvc', 'README.refcounting', 'SConstruct', 'vmime.doxygen' ] libvmime_tests = [ # 'tests/Makefile.am', # not generated # 'tests/Makefile.in', # parser # 'tests/parser/Makefile.am', # not generated # 'tests/parser/Makefile.in', # charset # 'tests/charset/Makefile.am', # not generated # 'tests/charset/Makefile.in', 'tests/charset/main.cpp', 'tests/charset/run-test.sh', 'tests/charset/test-suites/gnu.in.utf-8', 'tests/charset/test-suites/gnu.out.iso-8859-1', ] libvmimetest_common = [ 'tests/testUtils.hpp' ] libvmimetest_sources = [ 'tests/testRunner.cpp', 'tests/testUtils.cpp', # ============================== Parser ============================== 'tests/parser/attachmentHelperTest.cpp', 'tests/parser/bodyPartTest.cpp', 'tests/parser/charsetTest.cpp', 'tests/parser/datetimeTest.cpp', 'tests/parser/dispositionTest.cpp', 'tests/parser/headerTest.cpp', 'tests/parser/htmlTextPartTest.cpp', 'tests/parser/mailboxTest.cpp', 'tests/parser/mediaTypeTest.cpp', 'tests/parser/messageIdTest.cpp', 'tests/parser/messageIdSequenceTest.cpp', 'tests/parser/pathTest.cpp', 'tests/parser/parameterTest.cpp', 'tests/parser/textTest.cpp', # ============================== Utility ============================= 'tests/utility/datetimeUtilsTest.cpp', 'tests/utility/filteredStreamTest.cpp', 'tests/utility/stringProxyTest.cpp', 'tests/utility/stringUtilsTest.cpp', 'tests/utility/pathTest.cpp', 'tests/utility/urlTest.cpp', 'tests/utility/smartPtrTest.cpp', 'tests/utility/encoderTest.cpp', # =============================== Misc =============================== 'tests/misc/importanceHelperTest.cpp', # ============================= Security ============================= 'tests/security/digest/md5Test.cpp', 'tests/security/digest/sha1Test.cpp', # =============================== Net ================================ 'tests/net/smtp/SMTPTransportTest.cpp', 'tests/net/smtp/SMTPResponseTest.cpp', 'tests/net/maildir/maildirStoreTest.cpp' ] libvmime_autotools = [ 'm4/acx_pthread.m4', 'm4/iconv.m4', 'm4/lib-ld.m4', 'm4/lib-link.m4', 'm4/lib-prefix.m4', 'm4/libgnutls.m4', 'autotools/install-sh', # 'autotools/mkinstalldirs', 'autotools/missing', 'autotools/config.guess', 'autotools/config.sub', 'autotools/ltmain.sh', # 'autotools/depcomp', 'bootstrap', # not generated 'configure', 'configure.in', 'config.h.in', 'Makefile.am', 'Makefile.in', 'src/Makefile.am', 'src/Makefile.in', 'vmime/Makefile.am', 'vmime/Makefile.in' ] libvmime_all_sources = [] + libvmime_sources + libvmime_messaging_sources + libvmime_security_sasl_sources + libvmime_net_tls_sources for i in range(len(libvmime_all_sources)): f = libvmime_all_sources[i] if f[-4:] == '.hpp': libvmime_all_sources[i] = 'vmime/' + f else: libvmime_all_sources[i] = 'src/' + f for p in libvmime_messaging_proto_sources: for f in p[1]: if f[-4:] == '.hpp': libvmime_all_sources.append('vmime/' + f) else: libvmime_all_sources.append('src/' + f) for p in libvmime_platforms_sources: for f in libvmime_platforms_sources[p]: if f[-4:] == '.hpp': libvmime_all_sources.append('vmime/' + f) else: libvmime_all_sources.append('src/' + f) libvmime_dist_files = libvmime_all_sources + libvmime_extra + libvmime_examples_sources libvmime_dist_files += libvmime_tests libvmime_dist_files += libvmimetest_sources libvmime_dist_files += libvmimetest_common libvmime_dist_files += libvmime_autotools ################# # Set options # ################# EnsureSConsVersion(0, 98, 1) SetOption('implicit_cache', 1) try: Decider('MD5-timestamp') except: SourceSignatures('MD5') TargetSignatures('build') ############# # Options # ############# # Try to guess some default values defaultSendmailPath = WhereIs("sendmail") if defaultSendmailPath == None: defaultSendmailPath = '' # Command line options opts = Variables('options.cache') opts.AddVariables( ( 'prefix', 'Installation prefix directory', '/usr' ), EnumVariable( 'debug', 'Debug version (useful for developers only)', 'no', allowed_values = ('yes', 'no'), map = { }, ignorecase = 1 ), EnumVariable( 'with_messaging', 'Messaging support (connection to mail store/transport servers)', 'yes', allowed_values = ('yes', 'no'), map = { }, ignorecase = 1 ), EnumVariable( 'with_filesystem', 'Enable file-system support (this is needed for "maildir" messaging support)', 'yes', allowed_values = ('yes', 'no'), map = { }, ignorecase = 1 ), ( 'with_messaging_protocols', 'Specifies which protocols to build into the library.\n' + 'This option has no effect if "with_messaging" is not activated.\n' + 'Separate protocols with spaces; string must be quoted with ".\n' + 'Currently available protocols: pop3, smtp, imap, maildir, sendmail.', '"pop3 smtp imap maildir sendmail"' ), ( 'with_platforms', 'Specifies which default platform handlers to build.\n' + 'This provides support for each platform selected.\n' + 'If no platform handler is available for your platform, you will have\n' + 'to write your own...\n' + 'Separate platforms with spaces; string must be quoted with ".\n' + 'Currently available platform handlers: posix.', '"posix"' ), EnumVariable( 'with_sasl', 'Enable SASL support (requires GNU SASL library)', 'yes', allowed_values = ('yes', 'no'), map = { }, ignorecase = 1 ), EnumVariable( 'with_tls', 'Enable TLS support (requires GNU TLS library)', 'yes', allowed_values = ('yes', 'no'), map = { }, ignorecase = 1 ), ( 'sendmail_path', 'Specifies the path to sendmail.', defaultSendmailPath ), EnumVariable( 'byte_order', 'Byte order (Big Endian or Little Endian)', sys.byteorder, allowed_values = ('big', 'little'), map = { }, ignorecase = 1 ), EnumVariable( 'pf_8bit_type', 'The C-language 8-bit type for your platform', 'char', allowed_values = ('char', 'short', 'int', 'long'), map = { }, ignorecase = 1 ), EnumVariable( 'pf_16bit_type', 'The C-language 16-bit type for your platform', 'short', allowed_values = ('char', 'short', 'int', 'long'), map = { }, ignorecase = 1 ), EnumVariable( 'pf_32bit_type', 'The C-language 32-bit type for your platform', 'int', allowed_values = ('char', 'short', 'int', 'long'), map = { }, ignorecase = 1 ), EnumVariable( 'build_tests', 'Build unit tests (run with "scons run-tests")', 'no', allowed_values = ('yes', 'no'), map = { }, ignorecase = 1 ) ) ############################### # Configuration Environment # ############################### try: env = Environment(variables = opts) except TypeError: env = Environment(options = opts) env.Append(ENV = os.environ) env.Append(ENV = {'PATH' : os.environ['PATH']}) env.Append(CPPPATH = [ '.' ]) env.Append(CPPDEFINES = ['_REENTRANT=1']) env.Append(CXXFLAGS = ['-W']) env.Append(CXXFLAGS = ['-Wall']) env.Append(CXXFLAGS = ['-ansi']) env.Append(CXXFLAGS = ['-pedantic']) env.Append(CXXFLAGS = ['-Wpointer-arith']) env.Append(CXXFLAGS = ['-Wold-style-cast']) env.Append(CXXFLAGS = ['-Wconversion']) env.Append(CXXFLAGS = ['-Wcast-align']) #env.Append(CXXFLAGS = ['-Wshadow']) env.Append(TARFLAGS = ['-c']) env.Append(TARFLAGS = ['--bzip2']) if env['debug'] == 'yes': env.Append(CXXFLAGS = ['-g']) env.Append(CXXFLAGS = ['-O0']) else: env.Append(CXXFLAGS = ['-O2']) #-fomit-frame-pointer -fmove-all-movables -fstrict-aliasing #env.Append(LIBS = ['additional-lib-here']) if env['with_sasl'] == 'yes': libgsasl_pc = string.strip(os.popen("pkg-config --list-all | grep '^libgsasl[ ]' | cut -f 1 -d ' '").read()) if len(libgsasl_pc) == 0: print "ERROR: GNU SASL development package is not installed\n" Exit(1) env.ParseConfig('pkg-config --cflags --libs ' + libgsasl_pc) if env['with_tls'] == 'yes': libgnutls_pc = string.strip(os.popen("pkg-config --list-all | grep '^libgnutls[ ]' | cut -f 1 -d ' '").read()) if len(libgnutls_pc) == 0: libgnutls_pc = string.strip(os.popen("pkg-config --list-all | grep '^gnutls[ ]' | cut -f 1 -d ' '").read()) if len(libgnutls_pc) == 0: print "ERROR: GNU TLS development package is not installed\n" Exit(1) env.ParseConfig('pkg-config --cflags --libs ' + libgnutls_pc) env.Append(CXXFLAGS = ['-pthread']) # Generate help text for command line options Help(opts.GenerateHelpText(env)) # Cache current options opts.Save('options.cache', env) # Documentation generation system doxygenBuilder = Builder(action = 'doxygen $SOURCE') env.Append(BUILDERS = { 'DoxygenDoc' : doxygenBuilder }) ########################## # Some initializations # ########################## # Messaging protocols messaging_protocols = [ ] for proto in re.split('\W+', string.replace(env['with_messaging_protocols'], '"', '')): proto = string.strip(proto) if len(proto) >= 1: messaging_protocols.append(proto) # Platforms platforms = [ ] for platform in re.split('\W+', string.replace(env['with_platforms'], '"', '')): platform = string.strip(platform) if len(platform) >= 1: platforms.append(platform) ######################## # Some sanity checks # ######################## def IsProtocolSupported(protoList, proto): for supportedProto in protoList: if string.upper(supportedProto) == string.upper(proto): return 1 return 0 # File-system support must be activated when 'maildir' protocol is selected if env['with_messaging'] == 'yes': if IsProtocolSupported(messaging_protocols, 'maildir'): if env['with_filesystem'] != 'yes': print "ERROR: 'maildir' protocol requires file-system support!\n" Exit(1) # Sendmail transport is only available on POSIX platforms if os.name != 'posix': if IsProtocolSupported(messaging_protocols, 'sendmail'): print "WARNING: ignoring 'sendmail' support (only available on POSIX platforms)\n" newProtoList = [ ] for p in messaging_protocols: if string.upper(p) != "SENDMAIL": newProtoList.append(p) messaging_protocols = newProtoList # Check sendmail path if IsProtocolSupported(messaging_protocols, 'sendmail'): if env['sendmail_path'] == '': print "ERROR: no path specified for 'sendmail'" Exit(1) ########################### # Configuration summary # ########################### print "" print "+=================+" print "| CONFIGURATION |" print "+=================+" print "" print "Installation prefix : " + env['prefix'] print "Debugging mode : " + env['debug'] print "Messaging support : " + env['with_messaging'] if env['with_messaging'] == 'yes': print " * protocols : " + env['with_messaging_protocols'] print "File-system support : " + env['with_filesystem'] print "Platform handlers : " + env['with_platforms'] print "SASL support : " + env['with_sasl'] print "TLS/SSL support : " + env['with_tls'] if IsProtocolSupported(messaging_protocols, 'sendmail'): print "Sendmail path : " + env['sendmail_path'] print "" ######################### # Generate config.hpp # ######################### config_hpp = open('vmime/config.hpp', 'w') config_hpp.write(""" // // This file was automatically generated by configuration script. // #ifndef VMIME_CONFIG_HPP_INCLUDED #define VMIME_CONFIG_HPP_INCLUDED """) config_hpp.write('// Name of package\n') config_hpp.write('#define VMIME_PACKAGE "' + packageName + '"\n') config_hpp.write('\n') config_hpp.write('// Version number of package\n') config_hpp.write('#define VMIME_VERSION "' + packageVersion + '"\n') config_hpp.write('#define VMIME_API "' + packageAPI + '"\n') config_hpp.write('\n') config_hpp.write('// Target OS and architecture\n') if os.name == 'posix': config_hpp.write('#define VMIME_TARGET_ARCH "' + commands.getoutput('uname -m') + '"\n') config_hpp.write('#define VMIME_TARGET_OS "' + commands.getoutput('uname -s') + '"\n') else: config_hpp.write('#define VMIME_TARGET_ARCH "" // Unknown\n') config_hpp.write('#define VMIME_TARGET_OS "' + sys.platform + '/' + os.name + '"\n') config_hpp.write('\n') config_hpp.write('// Set to 1 if debugging should be activated\n') if env['debug'] == 'yes': config_hpp.write('#define VMIME_DEBUG 1\n') else: config_hpp.write('#define VMIME_DEBUG 0\n') config_hpp.write('\n') config_hpp.write('// Byte order (set one or the other, but not both!)\n') if env['byte_order'] == 'big': config_hpp.write('#define VMIME_BYTE_ORDER_BIG_ENDIAN 1\n') config_hpp.write('#define VMIME_BYTE_ORDER_LITTLE_ENDIAN 0\n') else: config_hpp.write('#define VMIME_BYTE_ORDER_BIG_ENDIAN 0\n') config_hpp.write('#define VMIME_BYTE_ORDER_LITTLE_ENDIAN 1\n') config_hpp.write('\n') config_hpp.write('// Generic types\n') config_hpp.write('// -- 8-bit\n') config_hpp.write('typedef signed ' + env['pf_8bit_type'] + ' vmime_int8;\n') config_hpp.write('typedef unsigned ' + env['pf_8bit_type'] + ' vmime_uint8;\n') config_hpp.write('// -- 16-bit\n') config_hpp.write('typedef signed ' + env['pf_16bit_type'] + ' vmime_int16;\n') config_hpp.write('typedef unsigned ' + env['pf_16bit_type'] + ' vmime_uint16;\n') config_hpp.write('// -- 32-bit\n') config_hpp.write('typedef signed ' + env['pf_32bit_type'] + ' vmime_int32;\n') config_hpp.write('typedef unsigned ' + env['pf_32bit_type'] + ' vmime_uint32;\n') config_hpp.write('\n') config_hpp.write('// Options\n') config_hpp.write('// -- File-system support\n') if env['with_filesystem'] == 'yes': config_hpp.write('#define VMIME_HAVE_FILESYSTEM_FEATURES 1\n') else: config_hpp.write('#define VMIME_HAVE_FILESYSTEM_FEATURES 0\n') config_hpp.write('// -- SASL support\n') if env['with_sasl'] == 'yes': config_hpp.write('#define VMIME_HAVE_SASL_SUPPORT 1\n') else: config_hpp.write('#define VMIME_HAVE_SASL_SUPPORT 0\n') config_hpp.write('// -- TLS/SSL support\n') if env['with_tls'] == 'yes': config_hpp.write('#define VMIME_HAVE_TLS_SUPPORT 1\n') else: config_hpp.write('#define VMIME_HAVE_TLS_SUPPORT 0\n') config_hpp.write('// -- Messaging support\n') if env['with_messaging'] == 'yes': config_hpp.write('#define VMIME_HAVE_MESSAGING_FEATURES 1\n') config_hpp.write('// -- Built-in messaging protocols\n') config_hpp.write('#define VMIME_BUILTIN_MESSAGING_PROTOS "' + string.replace(env['with_messaging_protocols'], '"', '') + '"\n') for proto in messaging_protocols: config_hpp.write('#define VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(proto) + ' 1\n') for p in libvmime_messaging_proto_sources: proto = p[0] if not proto in messaging_protocols: config_hpp.write('#define VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(proto) + ' 0\n') else: config_hpp.write('#define VMIME_HAVE_MESSAGING_FEATURES 0\n') config_hpp.write('// -- Built-in platform handlers\n') config_hpp.write('#define VMIME_BUILTIN_PLATFORMS "' + string.replace(env['with_platforms'], '"', '') + '"\n') for platform in platforms: config_hpp.write('#define VMIME_BUILTIN_PLATFORM_' + string.upper(platform) + ' 1\n') for platform in libvmime_platforms_sources: if not platform in platforms: config_hpp.write('#define VMIME_BUILTIN_PLATFORM_' + string.upper(platform) + ' 0\n') config_hpp.write('\n') config_hpp.write('// Miscellaneous flags\n') if IsProtocolSupported(messaging_protocols, 'sendmail'): config_hpp.write('#define VMIME_SENDMAIL_PATH "' + env['sendmail_path'] + '"\n') config_hpp.write(""" // Additional defines #define VMIME_HAVE_GETADDRINFO 1 #define VMIME_HAVE_PTHREAD 1 #endif // VMIME_CONFIG_HPP_INCLUDED """) config_hpp.close() ################# # Build rules # ################# # Build directory if env['debug'] == 'yes': BuildDir("#build/debug", 'src', duplicate = 0) buildDirectory = 'build/debug/' else: BuildDir("#build/release", 'src', duplicate = 0) buildDirectory = 'build/release/' # Create effective source files list # -- main library libvmime_sel_sources = [] + libvmime_sources # -- messaging module if env['with_messaging'] == 'yes': # -- Add common files for messaging support for file in libvmime_messaging_sources: libvmime_sel_sources.append(file) # -- Add protocol specific source files for proto in messaging_protocols: for protosrc in libvmime_messaging_proto_sources: if protosrc[0] == proto: for file in protosrc[1]: libvmime_sel_sources.append(file) # -- SASL support if env['with_sasl'] == 'yes': for file in libvmime_security_sasl_sources: libvmime_sel_sources.append(file) # -- TLS support if env['with_tls'] == 'yes': for file in libvmime_net_tls_sources: libvmime_sel_sources.append(file) # -- platform handlers for platform in platforms: files = libvmime_platforms_sources[platform] for file in files: libvmime_sel_sources.append(file) # Split source files list into two lists: .CPP and .HPP libvmime_sources_CPP = [ ] libvmime_sources_HPP = [ ] libvmime_install_includes = [ ] for file in libvmime_sel_sources: slash = string.rfind(file, '/') dir = '' if slash != -1: dir = file[0:slash] + '/' if file[-4:] == '.hpp': libvmime_sources_HPP.append(buildDirectory + file) libvmime_install_includes.append([dir, 'vmime/' + file, file]) else: if file[-4:] == '.cpp': libvmime_sources_CPP.append(buildDirectory + file) # HACK: SCons does not allow '.' in target name, so we have to # detect the suffix for library name and add it ourself #libFoo = env.StaticLibrary(target = 'FOO', source = []) #libNameSuffix = ''; # #if str(libFoo[0]).rfind('.') != -1: # libNameSuffix = str(libFoo[0])[str(libFoo[0]).rfind('.'):] # Static library build if env['debug'] == 'yes': libVmime = env.StaticLibrary( target = packageVersionedGenericName + '-debug', source = libvmime_sources_CPP ) else: libVmime = env.StaticLibrary( target = packageVersionedGenericName, source = libvmime_sources_CPP ) Default(libVmime) # Tests if env['build_tests'] == 'yes': if env['debug'] == 'yes': env = env.Clone() env.Append(LIBS = ['cppunit', 'dl', packageVersionedGenericName + '-debug', 'pthread']) env.Append(LIBPATH=['.']) if sys.platform == "mac" or sys.platform == "darwin": env.Append(LIBS = ['iconv', 'gcrypt']) Default( env.Program( target = 'run-tests', source = libvmimetest_sources ) ) else: print 'Debug mode must be enabled to build tests!' Exit(1) ######################## # Installation rules # ######################## libDir = "%s/lib" % env['prefix'] #includeDir = "%s/include/%s/vmime" % (env['prefix'], packageVersionedGenericName) includeDir = "%s/include/vmime" % env['prefix'] installPaths = [libDir, includeDir] # Library env.Install(libDir, libVmime) # Header files for i in range(len(libvmime_install_includes)): env.Install(includeDir + '/' + libvmime_install_includes[i][0], libvmime_install_includes[i][1]) # Configuration header file env.Install(includeDir, 'vmime/config.hpp') # Pkg-config support vmime_pc = open(packageVersionedGenericName + ".pc", 'w') vmime_pc_requires = '' vmime_pc_libs = '' if env['with_sasl'] == 'yes': vmime_pc_requires = vmime_pc_requires + "libgsasl " vmime_pc_libs = vmime_pc_libs + "-lgsasl " vmime_pc.write("prefix=" + env['prefix'] + "\n") vmime_pc.write("exec_prefix=" + env['prefix'] + "\n") vmime_pc.write("libdir=" + env['prefix'] + "/lib\n") vmime_pc.write("includedir=" + env['prefix'] + "/include\n") vmime_pc.write("\n") vmime_pc.write("Name: " + packageRealName + "\n") vmime_pc.write("Description: " + packageDescription + "\n") vmime_pc.write("Version: " + packageVersion + "\n") vmime_pc.write("Requires: " + vmime_pc_requires + "\n") vmime_pc.write("Libs: -L${libdir} -l" + packageVersionedGenericName + " " + vmime_pc_libs + "\n") #vmime_pc.write("Cflags: -I${includedir}/" + packageVersionedGenericName + "\n") vmime_pc.write("Cflags: -I${includedir}/" + "\n") vmime_pc.close() env.Install(libDir + "/pkgconfig", packageVersionedGenericName + ".pc") # Provide "install" target (ie. 'scons install') env.Alias('install', installPaths) ################################ # Generate autotools scripts # ################################ # Return the path of the specified filename. # Example: getPath("a/b/c/myfile") will return "a/b/c" def getPath(s): x = s.rfind('/') if x != -1: return s[0:x] else: return "" def getParentPath(s): return getPath(s) def getLastDir(s): x = s.rfind('/') if x != -1: return s[x + 1:len(s)] else: return s def buildMakefileFileList(l, replaceSlash): s = '' for i in range(len(l)): if i != 0: s += ' \\\n\t' f = l[i] if replaceSlash: f = string.replace(f, "/", "_") s += f return s def selectFilesFromSuffixNot(l, ext): r = [] n = len(ext) for f in l: if f[-n:] != ext: r.append(f) return r def generateAutotools(target, source, env): # Generate pkg-config file for shared and static library vmime_pc_in = open(packageVersionedGenericName + ".pc.in", 'w') vmime_pc_in.write("# File automatically generated by SConstruct ('scons autotools')\n") vmime_pc_in.write("# DO NOT EDIT!\n") vmime_pc_in.write("\n") vmime_pc_in.write("prefix=@prefix@\n") vmime_pc_in.write("exec_prefix=@exec_prefix@\n") vmime_pc_in.write("libdir=@libdir@\n") vmime_pc_in.write("includedir=@includedir@\n") vmime_pc_in.write("\n") vmime_pc_in.write("Name: @GENERIC_LIBRARY_NAME@\n") vmime_pc_in.write("Description: " + packageDescription + "\n") vmime_pc_in.write("Version: @VERSION@\n") vmime_pc_in.write("Requires: @GSASL_REQUIRED@\n") vmime_pc_in.write("Libs: -L${libdir} -l@GENERIC_VERSIONED_LIBRARY_NAME@ @GSASL_LIBS@ @LIBGNUTLS_LIBS@ @VMIME_ADDITIONAL_PC_LIBS@\n") #vmime_pc_in.write("Cflags: -I${includedir}/@GENERIC_VERSIONED_LIBRARY_NAME@\n") vmime_pc_in.write("Cflags: -I${includedir}/ @LIBGNUTLS_CFLAGS@\n") vmime_pc_in.close() # Generate 'Makefile.am' Makefile_am = open("Makefile.am", 'w') Makefile_am.write(""" # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! BINDING = INCLUDE = vmime #examples tests SUBDIRS = src $(INCLUDE) $(BINDING) DIST_SUBDIRS = $(SUBDIRS) autotools #AUTOMAKE_OPTIONS = dist-bzip2 AUTOMAKE_OPTIONS = no-dist pkgconfigdir = $(VMIME_PKGCONFIGDIR) pkgconfig_DATA = $(GENERIC_VERSIONED_LIBRARY_NAME).pc EXTRA_DIST=SConstruct bootstrap dist: @ echo "" @ echo "Please use 'scons dist' to generate distribution tarball." @ echo "" doc_DATA = AUTHORS ChangeLog COPYING INSTALL NEWS README docdir = $(datadir)/doc/$(GENERIC_LIBRARY_NAME) """) Makefile_am.close() # Generate Makefile for header files Makefile_am = open("vmime/Makefile.am", 'w') Makefile_am.write(""" # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! """) #Makefile_am.write(packageVersionedName + "includedir = $(prefix)/include/@GENERIC_VERSIONED_LIBRARY_NAME@/@GENERIC_LIBRARY_NAME@\n") Makefile_am.write(packageVersionedName + "includedir = $(prefix)/include/@GENERIC_LIBRARY_NAME@\n") Makefile_am.write("nobase_" + packageVersionedName + "include_HEADERS = ") x = [] for file in libvmime_all_sources: if file[-4:] == '.hpp': x.append(file[len("vmime/"):]) # remove 'vmime/' prefix x.append("config.hpp") Makefile_am.write(buildMakefileFileList(x, 0)) Makefile_am.close() # Generate 'src/Makefile.am' (Makefile for source files) Makefile_am = open("src/Makefile.am", 'w') Makefile_am.write(""" # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! AUTOMAKE_OPTIONS = no-dependencies foreign INTERNALS = INCLUDES = -I$(prefix)/include -I$(top_srcdir) @PKGCONFIG_CFLAGS@ @EXTRA_CFLAGS@ """) Makefile_am.write('lib_LTLIBRARIES = ' + packageVersionedName + '.la\n') Makefile_am.write(packageVersionedName + '_la_LDFLAGS = -export-dynamic -version-info ' # + '@LIBRARY_VERSION@ -release @LIBRARY_RELEASE@ @PKGCONFIG_LIBS@ @EXTRA_LIBS@\n') + '@LIBRARY_VERSION@ @PKGCONFIG_LIBS@ @EXTRA_LIBS@\n') sourceFiles = [] # for conversion: subpath/file.cpp --> subpath_file.cpp # used to avoid collision when two files have the same name if different dirs # -- base library x = selectFilesFromSuffixNot(libvmime_sources, '.hpp') sourceFiles += x Makefile_am.write(packageVersionedName + "_la_SOURCES = " + buildMakefileFileList(x, 1) + "\n") # -- messaging module x = selectFilesFromSuffixNot(libvmime_messaging_sources, '.hpp') sourceFiles += x Makefile_am.write("\n") Makefile_am.write("if VMIME_HAVE_MESSAGING_FEATURES\n") Makefile_am.write(packageVersionedName + "_la_SOURCES += " + buildMakefileFileList(x, 1) + "\n") Makefile_am.write("endif\n") # -- messaging protocols for proto in libvmime_messaging_proto_sources: Makefile_am.write("\n") Makefile_am.write("if VMIME_BUILTIN_MESSAGING_PROTO_" + string.upper(proto[0]) + "\n") x = selectFilesFromSuffixNot(proto[1], '.hpp') sourceFiles += x Makefile_am.write(packageVersionedName + "_la_SOURCES += " + buildMakefileFileList(x, 1) + "\n") Makefile_am.write("endif\n") # -- SASL support x = selectFilesFromSuffixNot(libvmime_security_sasl_sources, '.hpp') sourceFiles += x Makefile_am.write("\n") Makefile_am.write("if VMIME_HAVE_SASL_SUPPORT\n") Makefile_am.write(packageVersionedName + "_la_SOURCES += " + buildMakefileFileList(x, 1) + "\n") Makefile_am.write("endif\n") # -- TLS support x = selectFilesFromSuffixNot(libvmime_net_tls_sources, '.hpp') sourceFiles += x Makefile_am.write("\n") Makefile_am.write("if VMIME_HAVE_TLS_SUPPORT\n") Makefile_am.write(packageVersionedName + "_la_SOURCES += " + buildMakefileFileList(x, 1) + "\n") Makefile_am.write("endif\n") # -- platform handlers for platform in libvmime_platforms_sources: Makefile_am.write("\n") Makefile_am.write("if VMIME_BUILTIN_PLATFORM_" + string.upper(platform) + "\n") x = selectFilesFromSuffixNot(libvmime_platforms_sources[platform], '.hpp') sourceFiles += x Makefile_am.write(packageVersionedName + "_la_SOURCES += " + buildMakefileFileList(x, 1) + "\n") Makefile_am.write("endif\n") Makefile_am.write(""" noinst_HEADERS = $(INTERNALS) """) for f in sourceFiles: # symbolic links to avoid filename collision a = f b = string.replace(f, "/", "_") if a != b: Makefile_am.write(b + ": " + a + "\n\tln -sf $< $@\n\n") Makefile_am.close() # Generate 'configure.in' configure_in = open("configure.in", 'w') configure_in.write(""" # configure.in # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! # Init """) configure_in.write("AC_INIT([" + packageRealName + "], [" + packageVersion + "], [" + packageMaintainer + "], [" + packageGenericName + "])") configure_in.write(""" AC_PREREQ([2.53]) AC_CONFIG_AUX_DIR(autotools) # Library name GENERIC_LIBRARY_NAME=""" + '"' + packageGenericName + '"' + """ AC_SUBST(GENERIC_LIBRARY_NAME) GENERIC_VERSIONED_LIBRARY_NAME=""" + '"' + packageVersionedGenericName + '"' + """ AC_SUBST(GENERIC_VERSIONED_LIBRARY_NAME) LIBRARY_NAME=""" + '"' + packageName + '"' + """ AC_SUBST(LIBRARY_NAME) """) configure_in.write('# Library version\n') configure_in.write('LIBRARY_VERSION="' + str(packageAPICurrent) + ':' + str(packageAPIRevision) + ':' + str(packageAPIAge) + '"\n') configure_in.write('AC_SUBST(LIBRARY_VERSION)\n') configure_in.write('\n') configure_in.write('LIBRARY_RELEASE="' + str(packageVersionMajor) + '"\n') configure_in.write('AC_SUBST(LIBRARY_RELEASE)\n') configure_in.write(""" # # Miscellaneous init stuff # AC_CANONICAL_HOST AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(""" + packageGenericName + """, """ + packageVersion + """) AC_CONFIG_SRCDIR([src/base.cpp]) AM_CONFIG_HEADER([config.h]) AM_MAINTAINER_MODE VMIME_ADDITIONAL_DEFINES="" VMIME_ADDITIONAL_PC_LIBS="" # # Check compilers, processors, etc # AC_PROG_CC AC_PROG_CXX AC_PROG_CPP AC_C_CONST AC_C_INLINE AC_HEADER_STDC AC_HEADER_STDBOOL AC_HEADER_DIRENT AC_HEADER_TIME AC_C_CONST AC_LANG(C++) AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_LN_S AC_PROG_LIBTOOL OST_LIB_PTHREAD # from GNU Commons C++ AM_SANITY_CHECK AM_PROG_LIBTOOL AM_PROG_CC_C_O AM_ICONV # # Some checks # # -- iconv AC_MSG_CHECKING([if an usable version of iconv exists (required)]) if test "x$am_cv_func_iconv" = "xyes"; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_ERROR(no usable version of iconv has been found) fi # -- global constructors (stolen from 'configure.in' in libsigc++) AC_MSG_CHECKING([if linker supports global constructors]) cat > mylib.$ac_ext < struct A { A() { printf(\"PASS\\n\"); } }; A a; int foo() { return 1; } EOF cat > mytest.$ac_ext < extern int foo(); int main(int, char**) { int i = foo(); if(i != 1) printf(\"FAIL\\n\"); return 0; } EOF sh libtool --mode=compile $CXX -c mylib.$ac_ext >&5 sh libtool --mode=link $CXX -o libtest.la -rpath / -version-info 0 mylib.lo >&5 $CXX -c $CFLAGS $CPPFLAGS mytest.$ac_ext >&5 sh libtool --mode=link $CXX -o mytest mytest.o libtest.la >&5 2>/dev/null if test -x mytest -a "$cross_compiling" != yes; then myresult=`./mytest` if test "X$myresult" = "XPASS"; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_ERROR([ =================================================================== ERROR: This platform lacks support of construction of global objects in shared libraries. See ftp://rtfm.mit.edu/pub/usenet/news.answers/g++-FAQ/plain for details about this problem. Also for possible solutions http://www.informatik.uni-frankfurt.de/~fp/Tcl/tcl-c++/tcl-c++.html ===================================================================]) fi else AC_MSG_RESULT(unknown) fi rm -f mylib.* mytest.* libtest.la .libs/libtest* mytest .libs/mytest .libs/lt-mytest .libs/mylib.* >&5 rmdir .libs >&5 # -- const_cast AC_MSG_CHECKING([if C++ compiler supports const_cast<> (required)]) AC_TRY_COMPILE( [ class foo; ],[ const foo *c=0; foo *c1=const_cast(c); ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler const_cast<> does not work) ]) # -- dynamic_cast AC_MSG_CHECKING([if C++ compiler supports dynamic_cast<> (required)]) AC_TRY_COMPILE( [ class foo { public: virtual ~foo() { } }; class bar : public foo { public: virtual ~bar() { } }; ],[ foo *c=0; bar *c1=dynamic_cast(c); ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler dynamic_cast<> does not work) ]) # -- mutable AC_MSG_CHECKING(if C++ compiler supports mutable (required)) AC_TRY_COMPILE( [ class k { mutable char *c; public: void foo() const { c=0; } }; ],[ ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler does not support 'mutable') ]) # -- namespace AC_MSG_CHECKING(if C++ compiler supports name spaces (required)) AC_TRY_COMPILE( [ namespace Check { int i; } ],[ Check::i=1; ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler does not support 'namespace') ]) # # Target OS and architecture # VMIME_TARGET_ARCH=${target_cpu} VMIME_TARGET_OS=${target_os} # # Byte Order # AC_C_BIGENDIAN if test "x$ac_cv_c_bigendian" = "xyes"; then VMIME_BYTE_ORDER_BIG_ENDIAN=1 VMIME_BYTE_ORDER_LITTLE_ENDIAN=0 else VMIME_BYTE_ORDER_BIG_ENDIAN=0 VMIME_BYTE_ORDER_LITTLE_ENDIAN=1 fi # # Generic Type Size # AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) case 1 in $ac_cv_sizeof_char) VMIME_TYPE_INT8=char ;; *) AC_MSG_ERROR([no 8-bit type available]) esac case 2 in $ac_cv_sizeof_short) VMIME_TYPE_INT16=short ;; $ac_cv_sizeof_int) VMIME_TYPE_INT16=int ;; *) AC_MSG_ERROR([no 16-bit type available]) esac case 4 in $ac_cv_sizeof_int) VMIME_TYPE_INT32=int ;; $ac_cv_sizeof_long) VMIME_TYPE_INT32=long ;; *) AC_MSG_ERROR([no 32-bit type available]) esac # # Options # # ** debug AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Turn on debugging, default: disabled]), [case "${enableval}" in yes) conf_debug=yes ;; no) conf_debug=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; esac], [conf_debug=no]) if test "x$conf_debug" = "xyes"; then AM_CONDITIONAL(VMIME_DEBUG, true) VMIME_DEBUG=1 else AM_CONDITIONAL(VMIME_DEBUG, false) VMIME_DEBUG=0 fi # ** messaging AC_ARG_ENABLE(messaging, AC_HELP_STRING([--enable-messaging], [Enable messaging support and connection to mail servers, default: enabled]), [case "${enableval}" in yes) conf_messaging=yes ;; no) conf_messaging=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-messaging) ;; esac], [conf_messaging=yes]) if test "x$conf_messaging" = "xyes"; then AM_CONDITIONAL(VMIME_HAVE_MESSAGING_FEATURES, true) VMIME_HAVE_MESSAGING_FEATURES=1 else AM_CONDITIONAL(VMIME_HAVE_MESSAGING_FEATURES, false) VMIME_HAVE_MESSAGING_FEATURES=0 fi # ** SASL AC_ARG_ENABLE(sasl, AC_HELP_STRING([--enable-sasl], [Enable SASL support with GNU SASL, default: enabled]), [case "${enableval}" in yes) conf_sasl=yes ;; no) conf_sasl=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-sasl) ;; esac], [conf_sasl=yes]) if test "x$conf_sasl" = "xyes"; then # -- GNU SASL Library (http://www.gnu.org/software/gsasl/) AC_CHECK_HEADER(gsasl.h, AC_CHECK_LIB(gsasl, gsasl_check_version, [have_gsasl=yes AC_SUBST(GSASL_AVAIL_LIBS, -lgsasl) AC_SUBST(GSASL_AVAIL_REQUIRED, libgsasl)], have_gsasl=no), have_gsasl=no) if test "x$have_gsasl" = "xyes"; then AM_CONDITIONAL(VMIME_HAVE_SASL_SUPPORT, true) VMIME_HAVE_SASL_SUPPORT=1 GSASL_REQUIRED=${GSASL_AVAIL_REQUIRED} GSASL_LIBS=${GSASL_AVAIL_LIBS} else AC_MSG_ERROR(can't find an usable version of GNU SASL library) fi else AM_CONDITIONAL(VMIME_HAVE_SASL_SUPPORT, false) VMIME_HAVE_SASL_SUPPORT=0 GSASL_REQUIRED= GSASL_LIBS= fi AC_SUBST(GSASL_REQUIRED) AC_SUBST(GSASL_LIBS) # ** TLS AC_ARG_ENABLE(tls, AC_HELP_STRING([--enable-tls], [Enable TLS/SSL support with GNU TLS, default: enabled]), [case "${enableval}" in yes) conf_tls=yes ;; no) conf_tls=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-tls) ;; esac], [conf_tls=yes]) if test "x$conf_tls" = "xyes"; then # -- GNU TLS Library (http://www.gnu.org/software/gnutls/) PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 1.2.0], have_gnutls=yes, have_gnutls=no) if test "x$have_gnutls" = "xyes"; then AM_CONDITIONAL(VMIME_HAVE_TLS_SUPPORT, true) VMIME_HAVE_TLS_SUPPORT=1 else AC_MSG_ERROR(can't find an usable version of GNU TLS library) fi else AM_CONDITIONAL(VMIME_HAVE_TLS_SUPPORT, false) VMIME_HAVE_TLS_SUPPORT=0 fi # ** platform handlers VMIME_BUILTIN_PLATFORMS='' VMIME_DETECT_PLATFORM='' case "x${target_os}" in xwin* | xmingw* | xcygwin*) VMIME_DETECT_PLATFORM='windows' ;; x*) # Default is POSIX VMIME_DETECT_PLATFORM='posix' ;; esac # ** messaging protocols VMIME_BUILTIN_MESSAGING_PROTOS='' """) for proto in libvmime_messaging_proto_sources: p = proto[0] configure_in.write("AC_ARG_ENABLE(messaging-proto-" + p + ",\n") configure_in.write(" AC_HELP_STRING([--enable-messaging-proto-" + p + "], [Enable built-in support for protocol '" + p + "'" + ", default: enabled]),\n") configure_in.write(' [case "${enableval}" in\n') configure_in.write(' yes) conf_messaging_proto_' + p + '=yes ;;\n') configure_in.write(' no) conf_messaging_proto_' + p + '=no ;;\n') configure_in.write(' *) AC_MSG_ERROR(bad value ${enableval} for ' + '--enable-messaging-proto-' + p + ') ;;\n') configure_in.write(' esac],\n') configure_in.write(' [conf_messaging_proto_' + p + '=yes])\n') configure_in.write('if test "x$conf_messaging_proto_' + p + '" = "xyes"; then\n') if p == 'sendmail': # sendmail only on POSIX platforms configure_in.write('if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then\n') configure_in.write(' AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(p) + ', true)\n') configure_in.write(' VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(p) + '=1\n') configure_in.write(' VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS ' + p + '"\n') if p == 'sendmail': # sendmail only on POSIX platforms configure_in.write('else\n'); configure_in.write(' AC_MSG_WARN(' + p +' is only available on POSIX platforms)\n'); configure_in.write(' AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(p) + ', false)\n') configure_in.write(' VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(p) + '=0\n') configure_in.write('fi\n'); configure_in.write('else\n') configure_in.write(' AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(p) + ', false)\n') configure_in.write(' VMIME_BUILTIN_MESSAGING_PROTO_' + string.upper(p) + '=0\n') configure_in.write('fi\n\n') configure_in.write(""" # # System mail # AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, /usr/sbin:/usr/lib) # # Detect some platform-specific stuff # # -- MLang (Windows) if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then AC_CHECK_HEADER(mlang.h, [VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_MLANG_H"]) fi # -- Link with Winsock (Windows) if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then VMIME_ADDITIONAL_PC_LIBS="$VMIME_ADDITIONAL_PC_LIBS -lwsock32" fi # -- getaddrinfo (POSIX) if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then AC_CHECK_HEADERS(netdb.h sys/types.h sys/socket.h,) AC_CHECK_FUNC(getaddrinfo, [VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_GETADDRINFO"]) fi # -- pthreads (POSIX) ACX_PTHREAD([VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_PTHREAD"]) """) for p in libvmime_platforms_sources: configure_in.write('if test "x$VMIME_DETECT_PLATFORM" = "x' + p + '"; then\n') configure_in.write(' conf_platform_' + p + '=yes\n') configure_in.write('else\n') configure_in.write(' conf_platform_' + p + '=no\n') configure_in.write('fi\n\n') configure_in.write("AC_ARG_ENABLE(platform-" + p + ",\n") configure_in.write(" AC_HELP_STRING([--enable-platform-" + p + "], [Compile built-in platform handler for '" + p + "' " + ", default: disabled, except if default for your platform]),\n") configure_in.write(' [case "${enableval}" in\n') configure_in.write(' yes) conf_platform_' + p + '=yes ;;\n') configure_in.write(' no) conf_platform_' + p + '=no ;;\n') configure_in.write(' *) AC_MSG_ERROR(bad value ${enableval} for ' + '--enable-platform-' + p + ') ;;\n') configure_in.write(' esac],\n') #configure_in.write(' [conf_platform_' + p + '=yes])\n') configure_in.write(' [])\n') configure_in.write('if test "x$conf_platform_' + p + '" = "xyes"; then\n') configure_in.write(' AM_CONDITIONAL(VMIME_BUILTIN_PLATFORM_' + string.upper(p) + ', true)\n') configure_in.write(' VMIME_BUILTIN_PLATFORM_' + string.upper(p) + '=1\n') configure_in.write(' VMIME_BUILTIN_PLATFORMS="$VMIME_BUILTIN_PLATFORMS ' + p + '"\n') configure_in.write('else\n') configure_in.write(' AM_CONDITIONAL(VMIME_BUILTIN_PLATFORM_' + string.upper(p) + ', false)\n') configure_in.write(' VMIME_BUILTIN_PLATFORM_' + string.upper(p) + '=0\n') configure_in.write('fi\n\n') configure_in.write(""" # # Workarounds for some platforms # # -- pkgconfigdir case "x${target_os}" in xfreebsd*) VMIME_PKGCONFIGDIR='$(prefix)/libdata/pkgconfig' ;; x*) VMIME_PKGCONFIGDIR='$(libdir)/pkgconfig' ;; esac AC_SUBST(VMIME_PKGCONFIGDIR) # -- libtool 'CXX' tag case "x${target_os}" in xfreebsd*) # FIXME: temporary hack until I find a better solution # to make libtool use the C++ tag... LIBTOOL="$LIBTOOL --tag=CXX" ;; esac # # Flags # LIBRARY_LD_FLAGS="\$(top_builddir)/src/\$(LIBRARY_NAME).la" AC_SUBST(LIBRARY_LD_FLAGS) PKGCONFIG_CFLAGS="" PKGCONFIG_LIBS="" AC_SUBST(PKGCONFIG_CFLAGS) AC_SUBST(PKGCONFIG_LIBS) EXTRA_CFLAGS="$EXTRA_CFLAGS -D_REENTRANT=1 -D_THREAD_SAFE=1 $LIBGNUTLS_CFLAGS" EXTRA_LIBS="$GSASL_LIBS $LIBGNUTLS_LIBS" CFLAGS="" CXXFLAGS="" # -- Debug if test x$VMIME_DEBUG = x1 ; then # -g OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -g" AC_MSG_CHECKING(whether cc accepts -g) AC_TRY_COMPILE(,,echo yes,echo no; CXXFLAGS="$OLD_CXXFLAGS") else # -O2 OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -O2" AC_MSG_CHECKING(whether cc accepts -O2) AC_TRY_COMPILE(,,echo yes,echo no; CXXFLAGS="$OLD_CXXFLAGS") fi # -- HACK: add -fPIC or -fpic on static library object files EXTRA_CFLAGS="$EXTRA_CFLAGS $lt_prog_compiler_pic" # # Check to see if the compiler can handle some flags # """) compilerFlags = [ '-ansi', '-pedantic', '-W', '-Wall', '-Wpointer-arith', '-Wold-style-cast', '-Wconversion' ] for f in compilerFlags: configure_in.write('# ' + f + '\n') configure_in.write('OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS"\n') configure_in.write('EXTRA_CFLAGS="$EXTRA_CFLAGS ' + f + '"\n') configure_in.write('AC_MSG_CHECKING(whether cc accepts ' + f + ')\n') configure_in.write('AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS")\n\n') configure_in.write(""" #EXTRA_CFLAGS=`echo $EXTRA_CFLAGS | sed -e 's| |\\n|g' | sort | uniq | tr '\\n' ' '` EXTRA_CFLAGS=`echo $EXTRA_CFLAGS | tr '\\n' ' ' | sort | uniq | tr '\\n' ' '` EXTRA_LIBS=`echo $EXTRA_LIBS | sed -e 's|^ ||g' | sed -e 's| | |g'` AC_SUBST(CFLAGS) AC_SUBST(CXXFLAGS) AC_SUBST(EXTRA_CFLAGS) AC_SUBST(EXTRA_LIBS) AC_SUBST(VMIME_ADDITIONAL_PC_LIBS) LIBS=`echo $LIBS | sed -e 's|^ ||g' | sed -e 's| | |g'` AC_CONFIG_FILES([ """) libvmime_dist_files.append(packageVersionedGenericName + ".pc.in") configure_in.write(packageVersionedGenericName + ".pc\n") for f in libvmime_dist_files: if f[-11:] == 'Makefile.in': configure_in.write("\t" + f[0:len(f) - 3] + "\n") configure_in.write("\t])") configure_in.write(""" AC_OUTPUT # # Generate vmime/config.hpp # echo " // // This file was automatically generated by configuration script. // #ifndef VMIME_CONFIG_HPP_INCLUDED #define VMIME_CONFIG_HPP_INCLUDED // Name of package #define VMIME_PACKAGE """ + '\\"' + packageName + '\\"' + """ // Version number of package #define VMIME_VERSION """ + '\\"' + packageVersion + '\\"' + """ #define VMIME_API """ + '\\"' + packageAPI + '\\"' + """ // Target OS and architecture #define VMIME_TARGET_ARCH \\"${VMIME_TARGET_ARCH}\\" #define VMIME_TARGET_OS \\"${VMIME_TARGET_OS}\\" // Set to 1 if debugging should be activated #define VMIME_DEBUG ${VMIME_DEBUG} // Byte order (set one or the other, but not both!) #define VMIME_BYTE_ORDER_BIG_ENDIAN ${VMIME_BYTE_ORDER_BIG_ENDIAN} #define VMIME_BYTE_ORDER_LITTLE_ENDIAN ${VMIME_BYTE_ORDER_LITTLE_ENDIAN} // Generic types // -- 8-bit typedef signed ${VMIME_TYPE_INT8} vmime_int8; typedef unsigned ${VMIME_TYPE_INT8} vmime_uint8; // -- 16-bit typedef signed ${VMIME_TYPE_INT16} vmime_int16; typedef unsigned ${VMIME_TYPE_INT16} vmime_uint16; // -- 32-bit typedef signed ${VMIME_TYPE_INT32} vmime_int32; typedef unsigned ${VMIME_TYPE_INT32} vmime_uint32; // Options // -- File-system support #define VMIME_HAVE_FILESYSTEM_FEATURES 1 // -- SASL support #define VMIME_HAVE_SASL_SUPPORT ${VMIME_HAVE_SASL_SUPPORT} // -- TLS support #define VMIME_HAVE_TLS_SUPPORT ${VMIME_HAVE_TLS_SUPPORT} // -- Messaging support #define VMIME_HAVE_MESSAGING_FEATURES ${VMIME_HAVE_MESSAGING_FEATURES} """) # Messaging protocols configure_in.write('// -- Built-in messaging protocols\n') configure_in.write('#define VMIME_BUILTIN_MESSAGING_PROTOS \\"$VMIME_BUILTIN_MESSAGING_PROTOS\\"\n') for p in libvmime_messaging_proto_sources: p = string.upper(p[0]) configure_in.write("#define VMIME_BUILTIN_MESSAGING_PROTO_" + p + " $VMIME_BUILTIN_MESSAGING_PROTO_" + p + "\n") # Platform handlers configure_in.write('// -- Built-in platform handlers\n') configure_in.write('#define VMIME_BUILTIN_PLATFORMS \\"$VMIME_BUILTIN_PLATFORMS\\"\n') for p in libvmime_platforms_sources: p = string.upper(p) configure_in.write('#define VMIME_BUILTIN_PLATFORM_' + p + " $VMIME_BUILTIN_PLATFORM_" + p + " \n") configure_in.write(""" " > vmime/config.hpp # Miscellaneous flags echo "// Miscellaneous flags" >> vmime/config.hpp echo "#define VMIME_SENDMAIL_PATH \\"$SENDMAIL\\"" >> vmime/config.hpp echo "" >> vmime/config.hpp # Additional defines echo "// Additional defines" >> vmime/config.hpp for d in $VMIME_ADDITIONAL_DEFINES ; do echo "#define VMIME_$d 1" >> vmime/config.hpp done echo "" >> vmime/config.hpp echo "#endif // VMIME_CONFIG_HPP_INCLUDED" >> vmime/config.hpp AC_MSG_RESULT([ +=================+ | CONFIGURATION | +=================+ Installation prefix : $prefix Debugging mode : $conf_debug Messaging support : $conf_messaging * protocols :$VMIME_BUILTIN_MESSAGING_PROTOS File-system support : yes Platform handlers :$VMIME_BUILTIN_PLATFORMS SASL support : $conf_sasl TLS/SSL support : $conf_tls Please check 'vmime/config.hpp' to ensure the configuration is correct. ]) """) configure_in.close() os.system('bash bootstrap') return None # Custom builder for generating autotools scripts autotoolsBuilder = Builder(action = generateAutotools) env.Append(BUILDERS = { 'GenerateAutoTools' : autotoolsBuilder }) env.Alias('autotools', env.GenerateAutoTools('foo_autotools', 'SConstruct')) ################################ # Generate MSVC project files # ################################ MSVC_filesDone = [] MSVC_dupCounter = 1 # counter for duplicate file names def generateMSVC(target, source, env): # vmime.sln vmime_sln = open("vmime.sln", 'w') vmime_sln.write("""Microsoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmime", "vmime.vcproj", "{B2B47E11-DB57-49E1-8895-F03BDF78A221}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Debug.ActiveCfg = Debug|Win32 {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Debug.Build.0 = Debug|Win32 {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Release.ActiveCfg = Release|Win32 {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal """) vmime_sln.close(); # vmime.vcproj vmime_vcproj = open("vmime.vcproj", 'w') vmime_vcproj.write(""" """) # Source files all_sources = libvmime_sel_sources # -- Remove all platform files and re-add files for "windows" only for i in range(len(all_sources)): if string.find(all_sources[i], 'platforms/') != -1: all_sources[i] = '' for f in libvmime_platforms_sources['windows']: all_sources.append(f) # -- Prepend with 'src' (for source files) or 'vmime' (for includes) for i in range(len(all_sources)): f = all_sources[i] if f[-4:] == '.cpp': all_sources[i] = 'src/' + f else: all_sources[i] = 'vmime/' + f # -- Replace '/' with '\' for i in range(len(all_sources)): all_sources[i] = string.replace(all_sources[i], '/', '\\') all_sources.sort() # -- Sort by directory filesInDir = {} for f in all_sources: if len(f) != 0: comps = re.split('\\\\', f) l = len(comps) - 1 tmp = filesInDir for i in range(len(comps) - 1): d = '*' + comps[i] if not tmp.has_key(d): tmp[d] = {} tmp = tmp[d] tmp['file%i' % len(tmp)] = f # -- Output files in filters vmime_vcproj.write(""" """) def MSVC_OutputFiles(filesInDir): global MSVC_filesDone, MSVC_dupCounter for k in filesInDir.keys(): f = filesInDir[k] # Directory if k[0] == '*': vmime_vcproj.write('\n') MSVC_OutputFiles(f) vmime_vcproj.write('\n') # File else: fn = f[string.rfind(f, '\\') + 1:] if len(fn) != 0: if fn in MSVC_filesDone: # File (duplicate filename) vmime_vcproj.write('\n') vmime_vcproj.write(""" """) vmime_vcproj.write('') MSVC_dupCounter = MSVC_dupCounter + 1 else: # File vmime_vcproj.write('\n') MSVC_filesDone.append(fn) MSVC_OutputFiles(filesInDir) vmime_vcproj.write(""" """) vmime_vcproj.close(); # config.hpp.msvc config_hpp_msvc = open("config.hpp.msvc", 'w') config_hpp_msvc.write(""" // // This file was automatically generated by configuration script. // #ifndef VMIME_CONFIG_HPP_INCLUDED #define VMIME_CONFIG_HPP_INCLUDED // Name of package #define VMIME_PACKAGE """ + '"' + packageName + '"' + """ // Version number of package #define VMIME_VERSION """ + '"' + packageVersion + '"' + """ #define VMIME_API """ + '"' + packageAPI + '"' + """ // Target OS and architecture #define VMIME_TARGET_ARCH "i686" #define VMIME_TARGET_OS "windows" // Set to 1 if debugging should be activated #ifdef _DEBUG # define VMIME_DEBUG 1 #else # define VMIME_DEBUG 0 #endif // Byte order (set one or the other, but not both!) #define VMIME_BYTE_ORDER_BIG_ENDIAN 0 #define VMIME_BYTE_ORDER_LITTLE_ENDIAN 1 // Generic types // -- 8-bit typedef signed char vmime_int8; typedef unsigned char vmime_uint8; // -- 16-bit typedef signed short vmime_int16; typedef unsigned short vmime_uint16; // -- 32-bit typedef signed int vmime_int32; typedef unsigned int vmime_uint32; // Options // -- File-system support #define VMIME_HAVE_FILESYSTEM_FEATURES 1 // -- SASL support #define VMIME_HAVE_SASL_SUPPORT 1 // -- TLS/SSL support #define VMIME_HAVE_TLS_SUPPORT 1 // -- Messaging support #define VMIME_HAVE_MESSAGING_FEATURES 1 // -- Built-in messaging protocols #define VMIME_BUILTIN_MESSAGING_PROTOS "pop3 smtp imap maildir" #define VMIME_BUILTIN_MESSAGING_PROTO_POP3 1 #define VMIME_BUILTIN_MESSAGING_PROTO_SMTP 1 #define VMIME_BUILTIN_MESSAGING_PROTO_IMAP 1 #define VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR 1 // -- Built-in platform handlers #define VMIME_BUILTIN_PLATFORMS "windows" #define VMIME_BUILTIN_PLATFORM_WINDOWS 1 // Miscellaneous #define VMIME_INLINE_TEMPLATE_SPECIALIZATION 1 #define VMIME_NO_MULTIPLE_INHERITANCE 1 """) for p in libvmime_platforms_sources: if not (p == 'windows'): p = string.upper(p) config_hpp_msvc.write('#define VMIME_BUILTIN_PLATFORM_' + p + ' 0\n') config_hpp_msvc.write(""" #endif // VMIME_CONFIG_HPP_INCLUDED """) config_hpp_msvc.close() libvmime_dist_files.append("vmime.sln") libvmime_dist_files.append("vmime.vcproj") libvmime_dist_files.append("config.hpp.msvc") return None # Custom builder for generating MSVC project files msvcBuilder = Builder(action = generateMSVC) env.Append(BUILDERS = { 'GenerateMSVC' : msvcBuilder }) env.Alias('msvc', env.GenerateMSVC('foo_msvc', 'SConstruct')) ##################### # Packaging rules # ##################### def appendAdditionalDistFiles(): # Generate autotools-related files generateAutotools([], [], env) # Generate MSVC-related files generateMSVC([], [], env) # 'tar' is not available under Windows... if not (os.name == 'win32' or os.name == 'nt'): def createPackage(target, source, env): packageFullName = packageName + '-' + packageVersion packageFile = packageFullName + '.tar.bz2' appendAdditionalDistFiles() distFiles = [] distFilesStr = '' for f in libvmime_dist_files: distFiles.append(packageFullName + '/' + f) distFilesStr = distFilesStr + packageFullName + '/' + f + ' ' print f os.system('ln -s . ' + packageFullName) os.system('tar jcf ' + packageFile + ' ' + distFilesStr) os.system('rm -f ' + packageFullName) return None # Custom builder for creating package createPackageBuilder = Builder(action = createPackage) env.Append(BUILDERS = { 'CreatePackage' : createPackageBuilder }) env.Alias('dist', env.CreatePackage('foo_tar', 'SConstruct')) ################### # Documentation # ################### doxygenDocPath = '(doxygen-generated-files)' env.DoxygenDoc(doxygenDocPath, 'vmime.doxygen') env.Alias('doc', doxygenDocPath) ################ # Unit tests # ################ def runTests(target, source, env): os.system("./run-tests") return None runTestsBuilder = Builder(action = runTests) env.Append(BUILDERS = { 'RunTests' : runTestsBuilder }) env.Alias('run-tests', env.RunTests('foo', 'SConstruct')) libvmime-0.9.1/config.hpp.msvc0000644000175000017500000000330511470477543016571 0ustar mnordstrmnordstr // // This file was automatically generated by configuration script. // #ifndef VMIME_CONFIG_HPP_INCLUDED #define VMIME_CONFIG_HPP_INCLUDED // Name of package #define VMIME_PACKAGE "libvmime" // Version number of package #define VMIME_VERSION "0.9.1" #define VMIME_API "0:0:0" // Target OS and architecture #define VMIME_TARGET_ARCH "i686" #define VMIME_TARGET_OS "windows" // Set to 1 if debugging should be activated #ifdef _DEBUG # define VMIME_DEBUG 1 #else # define VMIME_DEBUG 0 #endif // Byte order (set one or the other, but not both!) #define VMIME_BYTE_ORDER_BIG_ENDIAN 0 #define VMIME_BYTE_ORDER_LITTLE_ENDIAN 1 // Generic types // -- 8-bit typedef signed char vmime_int8; typedef unsigned char vmime_uint8; // -- 16-bit typedef signed short vmime_int16; typedef unsigned short vmime_uint16; // -- 32-bit typedef signed int vmime_int32; typedef unsigned int vmime_uint32; // Options // -- File-system support #define VMIME_HAVE_FILESYSTEM_FEATURES 1 // -- SASL support #define VMIME_HAVE_SASL_SUPPORT 1 // -- TLS/SSL support #define VMIME_HAVE_TLS_SUPPORT 1 // -- Messaging support #define VMIME_HAVE_MESSAGING_FEATURES 1 // -- Built-in messaging protocols #define VMIME_BUILTIN_MESSAGING_PROTOS "pop3 smtp imap maildir" #define VMIME_BUILTIN_MESSAGING_PROTO_POP3 1 #define VMIME_BUILTIN_MESSAGING_PROTO_SMTP 1 #define VMIME_BUILTIN_MESSAGING_PROTO_IMAP 1 #define VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR 1 // -- Built-in platform handlers #define VMIME_BUILTIN_PLATFORMS "windows" #define VMIME_BUILTIN_PLATFORM_WINDOWS 1 // Miscellaneous #define VMIME_INLINE_TEMPLATE_SPECIALIZATION 1 #define VMIME_NO_MULTIPLE_INHERITANCE 1 #define VMIME_BUILTIN_PLATFORM_POSIX 0 #endif // VMIME_CONFIG_HPP_INCLUDED libvmime-0.9.1/tests/0000755000175000017500000000000011607302336014772 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/net/0000755000175000017500000000000011607302336015560 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/net/smtp/0000755000175000017500000000000011607302336016543 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/net/smtp/SMTPTransportTest.cpp0000644000175000017500000001352211250723263022612 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE SMTPTransportTest #define VMIME_TEST_SUITE_MODULE "Net/SMTP" class greetingErrorSMTPTestSocket; class MAILandRCPTSMTPTestSocket; VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testGreetingError) VMIME_TEST(testMAILandRCPT) VMIME_TEST_LIST_END void testGreetingError() { vmime::ref session = vmime::create (); vmime::ref tr = session->getTransport (vmime::utility::url("smtp://localhost")); tr->setSocketFactory(vmime::create >()); tr->setTimeoutHandlerFactory(vmime::create ()); VASSERT_THROW("Connection", tr->connect(), vmime::exceptions::connection_greeting_error); } void testMAILandRCPT() { vmime::ref session = vmime::create (); vmime::ref tr = session->getTransport (vmime::utility::url("smtp://localhost")); tr->setSocketFactory(vmime::create >()); tr->setTimeoutHandlerFactory(vmime::create ()); VASSERT_NO_THROW("Connection", tr->connect()); vmime::mailbox exp("expeditor@test.vmime.org"); vmime::mailboxList recips; recips.appendMailbox(vmime::create ("recipient1@test.vmime.org")); recips.appendMailbox(vmime::create ("recipient2@test.vmime.org")); recips.appendMailbox(vmime::create ("recipient3@test.vmime.org")); vmime::string data("Message data"); vmime::utility::inputStreamStringAdapter is(data); tr->send(exp, recips, is, 0); } VMIME_TEST_SUITE_END /** Accepts connection and fails on greeting. */ class greetingErrorSMTPTestSocket : public lineBasedTestSocket { public: void onConnected() { localSend("421 test.vmime.org Service not available, closing transmission channel\r\n"); disconnect(); } void processCommand() { if (!haveMoreLines()) return; getNextLine(); localSend("502 Command not implemented\r\n"); processCommand(); } }; /** SMTP test server 1. * * Test send(). * Ensure MAIL and RCPT commands are sent correctly. */ class MAILandRCPTSMTPTestSocket : public lineBasedTestSocket { public: MAILandRCPTSMTPTestSocket() { m_recipients.insert("recipient1@test.vmime.org"); m_recipients.insert("recipient2@test.vmime.org"); m_recipients.insert("recipient3@test.vmime.org"); m_state = STATE_NOT_CONNECTED; } void onConnected() { localSend("220 test.vmime.org Service ready\r\n"); processCommand(); m_state = STATE_COMMAND; } void processCommand() { if (!haveMoreLines()) return; vmime::string line = getNextLine(); std::istringstream iss(line); switch (m_state) { case STATE_NOT_CONNECTED: localSend("451 Requested action aborted: invalid state\r\n"); break; case STATE_COMMAND: { std::string cmd; iss >> cmd; if (cmd.empty()) { localSend("500 Syntax error, command unrecognized\r\n"); } else if (cmd == "HELO") { localSend("250 OK\r\n"); } else if (cmd == "MAIL") { VASSERT_EQ("MAIL", std::string("MAIL FROM: "), line); localSend("250 OK\r\n"); } else if (cmd == "RCPT") { const vmime::string::size_type lt = line.find('<'); const vmime::string::size_type gt = line.find('>'); VASSERT("RCPT <", lt != vmime::string::npos); VASSERT("RCPT >", gt != vmime::string::npos); VASSERT("RCPT ><", gt >= lt); const vmime::string recip = vmime::string (line.begin() + lt + 1, line.begin() + gt); std::set ::iterator it = m_recipients.find(recip); VASSERT(std::string("Recipient not found: '") + recip + "'", it != m_recipients.end()); m_recipients.erase(it); localSend("250 OK, recipient accepted\r\n"); } else if (cmd == "DATA") { VASSERT("All recipients", m_recipients.empty()); localSend("354 Ready to accept data; end with .\r\n"); m_state = STATE_DATA; m_msgData.clear(); } else if (cmd == "NOOP") { localSend("250 Completed\r\n"); } else if (cmd == "QUIT") { localSend("221 test.vmime.org Service closing transmission channel\r\n"); } else { localSend("502 Command not implemented\r\n"); } break; } case STATE_DATA: { if (line == ".") { VASSERT_EQ("Data", "Message data\r\n", m_msgData); localSend("250 Message accepted for delivery\r\n"); m_state = STATE_COMMAND; } else { m_msgData += line + "\r\n"; } break; } } processCommand(); } private: enum State { STATE_NOT_CONNECTED, STATE_COMMAND, STATE_DATA }; int m_state; std::set m_recipients; std::string m_msgData; }; libvmime-0.9.1/tests/net/smtp/SMTPResponseTest.cpp0000644000175000017500000001275411250723263022422 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/net/smtp/SMTPResponse.hpp" #define VMIME_TEST_SUITE SMTPResponseTest #define VMIME_TEST_SUITE_MODULE "Net/SMTP" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testSingleLineResponse) VMIME_TEST(testSingleLineResponseLF) VMIME_TEST(testMultiLineResponse) VMIME_TEST(testMultiLineResponseDifferentCode) VMIME_TEST(testIncompleteMultiLineResponse) VMIME_TEST(testIntermediateResponse) VMIME_TEST(testNoResponseText) VMIME_TEST_LIST_END void testSingleLineResponse() { vmime::ref socket = vmime::create (); vmime::ref toh = vmime::create (); socket->localSend("123 Response Text\r\n"); vmime::ref resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh); VASSERT_EQ("Code", 123, resp->getCode()); VASSERT_EQ("Lines", 1, resp->getLineCount()); VASSERT_EQ("Text", "Response Text", resp->getText()); } void testSingleLineResponseLF() { vmime::ref socket = vmime::create (); vmime::ref toh = vmime::create (); socket->localSend("123 Response Text\n"); vmime::ref resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh); VASSERT_EQ("Code", 123, resp->getCode()); VASSERT_EQ("Lines", 1, resp->getLineCount()); VASSERT_EQ("Text", "Response Text", resp->getText()); } void testMultiLineResponse() { vmime::ref socket = vmime::create (); vmime::ref toh = vmime::create (); socket->localSend ( "123-Response\r\n" "123 Text\r\n" ); vmime::ref resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh); VASSERT_EQ("Code", 123, resp->getCode()); VASSERT_EQ("Lines", 2, resp->getLineCount()); VASSERT_EQ("Text", "Response\nText", resp->getText()); VASSERT_EQ("Code", 123, resp->getLineAt(0).getCode()); VASSERT_EQ("Text", "Response", resp->getLineAt(0).getText()); VASSERT_EQ("Code", 123, resp->getLineAt(1).getCode()); VASSERT_EQ("Text", "Text", resp->getLineAt(1).getText()); } void testMultiLineResponseDifferentCode() { vmime::ref socket = vmime::create (); vmime::ref toh = vmime::create (); socket->localSend ( "123-Response\r\n" "456 Text\r\n" ); vmime::ref resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh); VASSERT_EQ("Code", 0, resp->getCode()); VASSERT_EQ("Lines", 2, resp->getLineCount()); VASSERT_EQ("Text", "Response\nText", resp->getText()); VASSERT_EQ("Code", 123, resp->getLineAt(0).getCode()); VASSERT_EQ("Text", "Response", resp->getLineAt(0).getText()); VASSERT_EQ("Code", 456, resp->getLineAt(1).getCode()); VASSERT_EQ("Text", "Text", resp->getLineAt(1).getText()); } void testIncompleteMultiLineResponse() { vmime::ref socket = vmime::create (); vmime::ref toh = vmime::create (1); socket->localSend ( "123-Response\r\n" "123-Text\r\n" // Missing data ); VASSERT_THROW("Incomplete response", vmime::net::smtp::SMTPResponse::readResponse(socket, toh), vmime::exceptions::operation_timed_out); } void testIntermediateResponse() { vmime::ref socket = vmime::create (); vmime::ref toh = vmime::create (1); socket->localSend ( "334\r\n" "More information\r\n" ); vmime::ref resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh); VASSERT_EQ("Code", 334, resp->getCode()); VASSERT_EQ("Lines", 1, resp->getLineCount()); VASSERT_EQ("Text", "More information", resp->getText()); } void testNoResponseText() { vmime::ref socket = vmime::create (); vmime::ref toh = vmime::create (1); socket->localSend ( "250\r\n" ); vmime::ref resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh); VASSERT_EQ("Code", 250, resp->getCode()); VASSERT_EQ("Lines", 1, resp->getLineCount()); VASSERT_EQ("Text", "", resp->getText()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/net/maildir/0000755000175000017500000000000011607302336017201 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/net/maildir/maildirStoreTest.cpp0000644000175000017500000004051611314151075023206 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/platform.hpp" #include "vmime/net/maildir/maildirStore.hpp" #include "vmime/net/maildir/maildirFormat.hpp" #define VMIME_TEST_SUITE maildirStoreTest #define VMIME_TEST_SUITE_MODULE "Net/Maildir" // Shortcuts and helpers typedef vmime::utility::file::path fspath; typedef vmime::utility::file::path::component fspathc; typedef vmime::net::folder::path fpath; typedef vmime::net::folder::path::component fpathc; const fpath operator/(const fpath& path, const std::string& c) { return path / fpathc(c); } /** Test messages */ static const vmime::string TEST_MESSAGE_1 = "From: \r\n" "Subject: VMime Test\r\n" "Date: Thu, 01 Mar 2007 09:49:35 +0100\r\n" "\r\n" "Hello, world!"; /** Maildir trees used in tests. * Structure: * * . * |-- Folder * | `-- SubFolder * | |-- SubSubFolder1 * | `-- SubSubFolder2 * `-- Folder2 * */ // KMail format static const vmime::string TEST_MAILDIR_KMAIL[] = // directories to create { "/Folder", "/Folder/new", "/Folder/tmp", "/Folder/cur", "/.Folder.directory", "/.Folder.directory/SubFolder", "/.Folder.directory/SubFolder/new", "/.Folder.directory/SubFolder/tmp", "/.Folder.directory/SubFolder/cur", "/.Folder.directory/.SubFolder.directory", "/.Folder.directory/.SubFolder.directory/SubSubFolder1", "/.Folder.directory/.SubFolder.directory/SubSubFolder1/new", "/.Folder.directory/.SubFolder.directory/SubSubFolder1/tmp", "/.Folder.directory/.SubFolder.directory/SubSubFolder1/cur", "/.Folder.directory/.SubFolder.directory/SubSubFolder2", "/.Folder.directory/.SubFolder.directory/SubSubFolder2/new", "/.Folder.directory/.SubFolder.directory/SubSubFolder2/tmp", "/.Folder.directory/.SubFolder.directory/SubSubFolder2/cur", "/Folder2", "/Folder2/new", "/Folder2/tmp", "/Folder2/cur", "*" // end }; static const vmime::string TEST_MAILDIRFILES_KMAIL[] = // files to create and their contents { "/.Folder.directory/.SubFolder.directory/SubSubFolder2/cur/1043236113.351.EmqD:S", TEST_MESSAGE_1, "*" // end }; // Courier format static const vmime::string TEST_MAILDIR_COURIER[] = // directories to create { "/.Folder", "/.Folder/new", "/.Folder/tmp", "/.Folder/cur", "/.Folder.SubFolder", "/.Folder.SubFolder", "/.Folder.SubFolder/new", "/.Folder.SubFolder/tmp", "/.Folder.SubFolder/cur", "/.Folder.SubFolder.SubSubFolder1", "/.Folder.SubFolder.SubSubFolder1/new", "/.Folder.SubFolder.SubSubFolder1/tmp", "/.Folder.SubFolder.SubSubFolder1/cur", "/.Folder.SubFolder.SubSubFolder2", "/.Folder.SubFolder.SubSubFolder2/new", "/.Folder.SubFolder.SubSubFolder2/tmp", "/.Folder.SubFolder.SubSubFolder2/cur", "/.Folder2", "/.Folder2/new", "/.Folder2/tmp", "/.Folder2/cur", "*" // end }; static const vmime::string TEST_MAILDIRFILES_COURIER[] = // files to create and their contents { "/.Folder/maildirfolder", "", "/.Folder.SubFolder/maildirfolder", "", "/.Folder.SubFolder.SubSubFolder1/maildirfolder", "", "/.Folder.SubFolder.SubSubFolder2/maildirfolder", "", "/.Folder.SubFolder.SubSubFolder2/cur/1043236113.351.EmqD:S", TEST_MESSAGE_1, "/.Folder2/maildirfolder", "", "*" // end }; VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testDetectFormat_KMail) VMIME_TEST(testDetectFormat_Courier) VMIME_TEST(testListRootFolders_KMail) VMIME_TEST(testListAllFolders_KMail) VMIME_TEST(testListRootFolders_Courier) VMIME_TEST(testListAllFolders_Courier) VMIME_TEST(testListMessages_KMail) VMIME_TEST(testListMessages_Courier) VMIME_TEST(testRenameFolder_KMail) VMIME_TEST(testRenameFolder_Courier) VMIME_TEST(testDestroyFolder_KMail) VMIME_TEST(testDestroyFolder_Courier) VMIME_TEST(testFolderExists_KMail) VMIME_TEST(testFolderExists_Courier) VMIME_TEST(testCreateFolder_KMail) VMIME_TEST(testCreateFolder_Courier) VMIME_TEST_LIST_END public: maildirStoreTest() { // Temporary directory m_tempPath = fspath() / fspathc("tmp") // Use /tmp / fspathc("vmime" + vmime::utility::stringUtils::toString(std::time(NULL)) + vmime::utility::stringUtils::toString(std::rand())); } void tearDown() { // In case of an uncaught exception destroyMaildir(); } void testDetectFormat_KMail() { createMaildir(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); vmime::ref store = vmime::dynamicCast (createAndConnectStore()); VASSERT_EQ("*", "kmail", store->getFormat()->getName()); destroyMaildir(); } void testDetectFormat_Courier() { createMaildir(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); vmime::ref store = vmime::dynamicCast (createAndConnectStore()); VASSERT_EQ("*", "courier", store->getFormat()->getName()); destroyMaildir(); } void testListRootFolders_KMail() { testListRootFoldersImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); } void testListRootFolders_Courier() { testListRootFoldersImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); } void testListRootFoldersImpl(const vmime::string* const dirs, const vmime::string* const files) { createMaildir(dirs, files); // Connect to store vmime::ref store = createAndConnectStore(); vmime::ref rootFolder = store->getRootFolder(); // Get root folders, not recursive const std::vector > rootFolders = rootFolder->getFolders(false); VASSERT_EQ("1", 2, rootFolders.size()); VASSERT("2", findFolder(rootFolders, fpath() / "Folder") != NULL); VASSERT("3", findFolder(rootFolders, fpath() / "Folder2") != NULL); destroyMaildir(); } void testListAllFolders_KMail() { testListAllFoldersImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); } void testListAllFolders_Courier() { testListAllFoldersImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); } void testListAllFoldersImpl(const vmime::string* const dirs, const vmime::string* const files) { createMaildir(dirs, files); // Connect to store vmime::ref store = createAndConnectStore(); vmime::ref rootFolder = store->getRootFolder(); // Get all folders, recursive const std::vector > allFolders = rootFolder->getFolders(true); VASSERT_EQ("1", 5, allFolders.size()); VASSERT("2", findFolder(allFolders, fpath() / "Folder") != NULL); VASSERT("3", findFolder(allFolders, fpath() / "Folder" / "SubFolder") != NULL); VASSERT("4", findFolder(allFolders, fpath() / "Folder" / "SubFolder" / "SubSubFolder1") != NULL); VASSERT("5", findFolder(allFolders, fpath() / "Folder" / "SubFolder" / "SubSubFolder2") != NULL); VASSERT("6", findFolder(allFolders, fpath() / "Folder2") != NULL); destroyMaildir(); } void testListMessages_KMail() { testListMessagesImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); } void testListMessages_Courier() { testListMessagesImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); } void testListMessagesImpl(const vmime::string* const dirs, const vmime::string* const files) { createMaildir(dirs, files); vmime::ref store = createAndConnectStore(); vmime::ref rootFolder = store->getRootFolder(); vmime::ref folder = store->getFolder (fpath() / "Folder" / "SubFolder" / "SubSubFolder2"); int count, unseen; folder->status(count, unseen); VASSERT_EQ("Message count", 1, count); folder->open(vmime::net::folder::MODE_READ_ONLY); vmime::ref msg = folder->getMessage(1); folder->fetchMessage(msg, vmime::net::folder::FETCH_SIZE); VASSERT_EQ("Message size", TEST_MESSAGE_1.length(), msg->getSize()); std::ostringstream oss; vmime::utility::outputStreamAdapter os(oss); msg->extract(os); VASSERT_EQ("Message contents", TEST_MESSAGE_1, oss.str()); folder->close(false); destroyMaildir(); } void testRenameFolder_KMail() { try { testRenameFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); } catch (vmime::exception& e) { std::cerr << e; throw e; } } void testRenameFolder_Courier() { try { testRenameFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); } catch (vmime::exception& e) { std::cerr << e; throw e; } } void testRenameFolderImpl(const vmime::string* const dirs, const vmime::string* const files) { createMaildir(dirs, files); vmime::ref store = createAndConnectStore(); vmime::ref rootFolder = store->getRootFolder(); // Rename "Folder/SubFolder" to "Folder/foo" vmime::ref folder = store->getFolder (fpath() / "Folder" / "SubFolder"); folder->rename(fpath() / "Folder" / "foo"); // Ensure folder and its subfolders have been renamed const std::vector > allFolders = rootFolder->getFolders(true); VASSERT_EQ("1", 5, allFolders.size()); VASSERT("2", findFolder(allFolders, fpath() / "Folder") != NULL); VASSERT("3", findFolder(allFolders, fpath() / "Folder" / "SubFolder") == NULL); VASSERT("4", findFolder(allFolders, fpath() / "Folder" / "SubFolder" / "SubSubFolder1") == NULL); VASSERT("5", findFolder(allFolders, fpath() / "Folder" / "SubFolder" / "SubSubFolder2") == NULL); VASSERT("6", findFolder(allFolders, fpath() / "Folder2") != NULL); VASSERT("7", findFolder(allFolders, fpath() / "Folder" / "foo") != NULL); VASSERT("8", findFolder(allFolders, fpath() / "Folder" / "foo" / "SubSubFolder1") != NULL); VASSERT("9", findFolder(allFolders, fpath() / "Folder" / "foo" / "SubSubFolder2") != NULL); destroyMaildir(); } void testDestroyFolder_KMail() { testDestroyFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); } void testDestroyFolder_Courier() { testDestroyFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); } void testDestroyFolderImpl(const vmime::string* const dirs, const vmime::string* const files) { createMaildir(dirs, files); vmime::ref store = createAndConnectStore(); vmime::ref rootFolder = store->getRootFolder(); // Destroy "Folder/SubFolder" (total: 3 folders) vmime::ref folder = store->getFolder (fpath() / "Folder" / "SubFolder"); folder->destroy(); // Ensure folder and its subfolders have been deleted and other folders still exist const std::vector > allFolders = rootFolder->getFolders(true); VASSERT_EQ("1", 2, allFolders.size()); VASSERT("2", findFolder(allFolders, fpath() / "Folder") != NULL); VASSERT("3", findFolder(allFolders, fpath() / "Folder" / "SubFolder") == NULL); VASSERT("4", findFolder(allFolders, fpath() / "Folder" / "SubFolder" / "SubSubFolder1") == NULL); VASSERT("5", findFolder(allFolders, fpath() / "Folder" / "SubFolder" / "SubSubFolder2") == NULL); VASSERT("6", findFolder(allFolders, fpath() / "Folder2") != NULL); destroyMaildir(); } void testFolderExists_KMail() { testFolderExistsImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); } void testFolderExists_Courier() { testFolderExistsImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); } void testFolderExistsImpl(const vmime::string* const dirs, const vmime::string* const files) { createMaildir(dirs, files); vmime::ref store = createAndConnectStore(); vmime::ref rootFolder = store->getRootFolder(); VASSERT("1", store->getFolder(fpath() / "Folder" / "SubFolder")->exists()); VASSERT("2", !store->getFolder(fpath() / "Folder" / "SubSubFolder1")->exists()); VASSERT("3", store->getFolder(fpath() / "Folder2")->exists()); VASSERT("4", store->getFolder(fpath() / "Folder" / "SubFolder" / "SubSubFolder2")->exists()); destroyMaildir(); } void testCreateFolder_KMail() { testCreateFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); } void testCreateFolder_Courier() { testCreateFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); } void testCreateFolderImpl(const vmime::string* const dirs, const vmime::string* const files) { createMaildir(dirs, files); vmime::ref store = createAndConnectStore(); vmime::ref rootFolder = store->getRootFolder(); VASSERT("Before", !store->getFolder(fpath() / "Folder" / "NewFolder")->exists()); VASSERT_NO_THROW("Creation", store->getFolder(fpath() / "Folder" / "NewFolder")-> create(vmime::net::folder::TYPE_CONTAINS_MESSAGES)); VASSERT("After", store->getFolder(fpath() / "Folder" / "NewFolder")->exists()); destroyMaildir(); } private: vmime::utility::file::path m_tempPath; vmime::ref createAndConnectStore() { vmime::ref session = vmime::create (); vmime::ref store = session->getStore(getStoreURL()); store->connect(); return store; } const vmime::ref findFolder (const std::vector >& folders, const vmime::net::folder::path& path) { for (unsigned int i = 0, n = folders.size() ; i < n ; ++i) { if (folders[i]->getFullPath() == path) return folders[i]; } return NULL; } const vmime::utility::url getStoreURL() { vmime::ref fsf = vmime::platform::getHandler()->getFileSystemFactory(); vmime::utility::url url(std::string("maildir://localhost") + fsf->pathToString(m_tempPath)); return url; } void createMaildir(const vmime::string* const dirs, const vmime::string* const files) { vmime::ref fsf = vmime::platform::getHandler()->getFileSystemFactory(); vmime::ref rootDir = fsf->create(m_tempPath); rootDir->createDirectory(false); for (vmime::string const* dir = dirs ; *dir != "*" ; ++dir) { vmime::ref fdir = fsf->create(m_tempPath / fsf->stringToPath(*dir)); fdir->createDirectory(false); } for (vmime::string const* file = files ; *file != "*" ; file += 2) { const vmime::string& contents = *(file + 1); vmime::ref ffile = fsf->create(m_tempPath / fsf->stringToPath(*file)); ffile->createFile(); vmime::ref fileWriter = ffile->getFileWriter(); vmime::ref os = fileWriter->getOutputStream(); os->write(contents.data(), contents.length()); os->flush(); fileWriter = NULL; } } void destroyMaildir() { vmime::ref fsf = vmime::platform::getHandler()->getFileSystemFactory(); recursiveDelete(fsf->create(m_tempPath)); } void recursiveDelete(vmime::ref dir) { if (!dir->exists() || !dir->isDirectory()) return; vmime::ref files = dir->getFiles(); // First, delete files and subdirectories in this directory while (files->hasMoreElements()) { vmime::ref file = files->nextElement(); if (file->isDirectory()) { recursiveDelete(file); } else { try { file->remove(); } catch (vmime::exceptions::filesystem_exception&) { // Ignore } } } // Then, delete this (empty) directory try { dir->remove(); } catch (vmime::exceptions::filesystem_exception&) { // Ignore } } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/misc/0000755000175000017500000000000011607302336015725 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/misc/importanceHelperTest.cpp0000644000175000017500000001174211250723263022577 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/misc/importanceHelper.hpp" #define VMIME_TEST_SUITE importanceHelperTest #define VMIME_TEST_SUITE_MODULE "Misc" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testResetImportance) VMIME_TEST(testSetImportance1) VMIME_TEST(testSetImportance2) VMIME_TEST(testSetImportance3) VMIME_TEST(testSetImportance4) VMIME_TEST(testSetImportance5) VMIME_TEST(testGetImportance1) VMIME_TEST(testGetImportance2) VMIME_TEST(testGetImportance3) VMIME_TEST(testGetImportance4) VMIME_TEST(testGetImportance5) VMIME_TEST_LIST_END // resetImportance void testResetImportance() { vmime::ref hdr = vmime::create (); hdr->getField("Importance")->setValue("xxx"); hdr->getField("X-Priority")->setValue("yyy"); VASSERT_NO_THROW("1", hdr->findField("Importance")); VASSERT_NO_THROW("2", hdr->findField("X-Priority")); vmime::misc::importanceHelper::resetImportanceHeader(hdr); VASSERT_THROW("3", hdr->findField("Importance"), vmime::exceptions::no_such_field); VASSERT_THROW("4", hdr->findField("X-Priority"), vmime::exceptions::no_such_field); } // setImportance void testSetImportanceImpl(const vmime::misc::importanceHelper::Importance i, const std::string& ImportanceValue, const std::string& XPriorityValue) { vmime::ref hdr = vmime::create (); vmime::misc::importanceHelper::setImportanceHeader(hdr, i); VASSERT_NO_THROW("1", hdr->findField("Importance")); VASSERT_EQ("2", ImportanceValue, hdr->findField("Importance")->getValue()->generate()); VASSERT_NO_THROW("3", hdr->findField("X-Priority")); VASSERT_EQ("4", XPriorityValue, hdr->findField("X-Priority")->getValue()->generate()); } void testSetImportance1() { testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, "high", "1 (Highest)"); } void testSetImportance2() { testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGH, "high", "2 (High)"); } void testSetImportance3() { testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL, "normal", "3 (Normal)"); } void testSetImportance4() { testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOW, "low", "4 (Low)"); } void testSetImportance5() { testSetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST, "low", "5 (Lowest)"); } // getImportance void testGetImportanceImpl(const vmime::misc::importanceHelper::Importance i1, const vmime::misc::importanceHelper::Importance i2, const std::string& ImportanceValue, const std::string& XPriorityValue) { vmime::ref hdr1 = vmime::create (); hdr1->getField("Importance")->setValue(ImportanceValue); VASSERT_EQ("1", i1, vmime::misc::importanceHelper::getImportanceHeader(hdr1)); vmime::ref hdr2 = vmime::create (); hdr2->getField("X-Priority")->setValue(XPriorityValue); VASSERT_EQ("2", i2, vmime::misc::importanceHelper::getImportanceHeader(hdr2)); } void testGetImportance1() { testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, "high", "1 (Highest)"); } void testGetImportance2() { testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_HIGHEST, vmime::misc::importanceHelper::IMPORTANCE_HIGH, "high", "2 (High)"); } void testGetImportance3() { testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_NORMAL, vmime::misc::importanceHelper::IMPORTANCE_NORMAL, "normal", "3 (Normal)"); } void testGetImportance4() { testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST, vmime::misc::importanceHelper::IMPORTANCE_LOW, "low", "4 (Low)"); } void testGetImportance5() { testGetImportanceImpl(vmime::misc::importanceHelper::IMPORTANCE_LOWEST, vmime::misc::importanceHelper::IMPORTANCE_LOWEST, "low", "5 (Lowest)"); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/testUtils.cpp0000644000175000017500000001257411314151075017504 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2005 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "testUtils.hpp" // testSocket void testSocket::connect(const vmime::string& address, const vmime::port_t port) { m_address = address; m_port = port; m_connected = true; onConnected(); } void testSocket::disconnect() { m_address.clear(); m_port = 0; m_connected = false; } bool testSocket::isConnected() const { return m_connected; } testSocket::size_type testSocket::getBlockSize() const { return 16384; } void testSocket::receive(vmime::string& buffer) { buffer = m_inBuffer; m_inBuffer.clear(); } void testSocket::send(const vmime::string& buffer) { m_outBuffer += buffer; onDataReceived(); } int testSocket::receiveRaw(char* buffer, const int count) { const int n = std::min(count, static_cast (m_inBuffer.size())); std::copy(m_inBuffer.begin(), m_inBuffer.begin() + n, buffer); m_inBuffer.erase(m_inBuffer.begin(), m_inBuffer.begin() + n); return n; } void testSocket::sendRaw(const char* buffer, const int count) { send(vmime::string(buffer, count)); } void testSocket::localSend(const vmime::string& buffer) { m_inBuffer += buffer; } void testSocket::localReceive(vmime::string& buffer) { buffer = m_outBuffer; m_outBuffer.clear(); } void testSocket::onDataReceived() { // Override } void testSocket::onConnected() { // Override } // lineBasedTestSocket void lineBasedTestSocket::onDataReceived() { vmime::string chunk; localReceive(chunk); m_buffer += chunk; vmime::string::size_type eol; while ((eol = m_buffer.find('\n')) != vmime::string::npos) { vmime::string line(std::string(m_buffer.begin(), m_buffer.begin() + eol)); if (!line.empty() && line[line.length() - 1] == '\r') line.erase(line.end() - 1, line.end()); m_lines.push_back(line); m_buffer.erase(m_buffer.begin(), m_buffer.begin() + eol + 1); } while (!m_lines.empty()) processCommand(); } const vmime::string lineBasedTestSocket::getNextLine() { const vmime::string line = m_lines.front(); m_lines.erase(m_lines.begin(), m_lines.begin() + 1); return line; } bool lineBasedTestSocket::haveMoreLines() const { return !m_lines.empty(); } // testTimeoutHandler testTimeoutHandler::testTimeoutHandler(const unsigned int delay) : m_delay(delay), m_start(0) { } bool testTimeoutHandler::isTimeOut() { return (vmime::platform::getHandler()->getUnixTime() - m_start) >= m_delay; } void testTimeoutHandler::resetTimeOut() { m_start = vmime::platform::getHandler()->getUnixTime(); } bool testTimeoutHandler::handleTimeOut() { return false; } // testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory vmime::ref testTimeoutHandlerFactory::create() { return vmime::create (); } // Exception helper std::ostream& operator<<(std::ostream& os, const vmime::exception& e) { os << "* vmime::exceptions::" << e.name() << std::endl; os << " what = " << e.what() << std::endl; // More information for special exceptions if (dynamic_cast (&e)) { const vmime::exceptions::command_error& cee = dynamic_cast (e); os << " command = " << cee.command() << std::endl; os << " response = " << cee.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::invalid_response& ir = dynamic_cast (e); os << " response = " << ir.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::connection_greeting_error& cgee = dynamic_cast (e); os << " response = " << cgee.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::authentication_error& aee = dynamic_cast (e); os << " response = " << aee.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::filesystem_exception& fse = dynamic_cast (e); os << " path = " << vmime::platform::getHandler()-> getFileSystemFactory()->pathToString(fse.path()) << std::endl; } if (e.other() != NULL) os << *e.other(); return os; } libvmime-0.9.1/tests/testUtils.hpp0000644000175000017500000001576111421620265017513 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2005 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include #include #include // VMime #include "vmime/vmime.hpp" // CppUnit #include #include #define VASSERT(msg, cond) \ CPPUNIT_ASSERT_MESSAGE(std::string(msg), cond) #define VASSERT_TRUE(msg, cond) \ VASSERT(msg, cond) #define VASSERT_FALSE(msg, cond) \ VASSERT(!(msg, cond)) #define VASSERT_EQ(msg, expected, actual) \ CPPUNIT_ASSERT_EQUAL_MESSAGE(std::string(msg), expected, actual) #define VASSERT_THROW(msg, expression, exceptionType) \ CPPUNIT_ASSERT_THROW(expression, exceptionType) #define VASSERT_NO_THROW(msg, expression) \ CPPUNIT_ASSERT_NO_THROW(expression) #define VMIME_TEST_SUITE_BEGIN \ class VMIME_TEST_SUITE : public CppUnit::TestFixture { public: #define VMIME_TEST_SUITE_END \ }; \ \ static CppUnit::AutoRegisterSuite (autoRegisterRegistry1); \ static CppUnit::AutoRegisterSuite (autoRegisterRegistry2)(VMIME_TEST_SUITE_MODULE); \ extern void registerTestModule(const char* name); \ template \ struct AutoRegisterModule { \ AutoRegisterModule() { \ registerTestModule(VMIME_TEST_SUITE_MODULE); \ } \ }; \ static AutoRegisterModule autoRegisterModule; #define VMIME_TEST_LIST_BEGIN CPPUNIT_TEST_SUITE(VMIME_TEST_SUITE); #define VMIME_TEST_LIST_END CPPUNIT_TEST_SUITE_END(); #define VMIME_TEST(name) CPPUNIT_TEST(name); namespace CppUnit { // Work-around for comparing 'std::string' against 'char*' inline void assertEquals(const char* expected, const std::string actual, SourceLine sourceLine, const std::string &message) { assertEquals(std::string(expected), actual, sourceLine, message); } template void assertEquals(const X expected, const Y actual, SourceLine sourceLine, const std::string &message) { assertEquals(static_cast (expected), actual, sourceLine, message); } } namespace std { inline std::ostream& operator<<(std::ostream& os, const vmime::charset& ch) { os << "[charset: " << ch.getName() << "]"; return (os); } inline std::ostream& operator<<(std::ostream& os, const vmime::text& txt) { os << "[text: ["; for (int i = 0 ; i < txt.getWordCount() ; ++i) { const vmime::word& w = *txt.getWordAt(i); if (i != 0) os << ","; os << "[word: charset=" << w.getCharset().getName() << ", buffer=" << w.getBuffer() << "]"; } os << "]]"; return (os); } inline std::ostream& operator<<(std::ostream& os, const vmime::mailbox& mbox) { os << "[mailbox: name=" << mbox.getName() << ", email=" << mbox.getEmail() << "]"; return (os); } inline std::ostream& operator<<(std::ostream& os, const vmime::mailboxGroup& group) { os << "[mailbox-group: name=" << group.getName() << ", list=["; for (int i = 0 ; i < group.getMailboxCount() ; ++i) { if (i != 0) os << ","; os << *group.getMailboxAt(i); } os << "]]"; return (os); } inline std::ostream& operator<<(std::ostream& os, const vmime::addressList& list) { os << "[address-list: ["; for (int i = 0 ; i < list.getAddressCount() ; ++i) { const vmime::address& addr = *list.getAddressAt(i); if (i != 0) os << ","; if (addr.isGroup()) { const vmime::mailboxGroup& group = dynamic_cast (addr); os << group; } else { const vmime::mailbox& mbox = dynamic_cast (addr); os << mbox; } } os << "]]"; return (os); } inline std::ostream& operator<<(std::ostream& os, const vmime::datetime& d) { os << "[datetime: " << d.getYear() << "/" << d.getMonth() << "/" << d.getDay(); os << " " << d.getHour() << ":" << d.getMinute() << ":" << d.getSecond(); os << " #" << d.getZone() << "]"; return (os); } } // Used to test network features. // // This works like a local pipe: client reads and writes data using receive() // and send(). Server reads incoming data with localReceive() and sends data // to client with localSend(). class testSocket : public vmime::net::socket { public: void connect(const vmime::string& address, const vmime::port_t port); void disconnect(); bool isConnected() const; void receive(vmime::string& buffer); void send(const vmime::string& buffer); int receiveRaw(char* buffer, const int count); void sendRaw(const char* buffer, const int count); size_type getBlockSize() const; /** Send data to client. * * @buffer data to send */ void localSend(const vmime::string& buffer); /** Receive data from client. * * @buffer buffer in which to store received data */ void localReceive(vmime::string& buffer); protected: /** Called when the client has sent some data. */ virtual void onDataReceived(); /** Called when the client has connected. */ virtual void onConnected(); private: vmime::string m_address; vmime::port_t m_port; bool m_connected; vmime::string m_inBuffer; vmime::string m_outBuffer; }; template class testSocketFactory : public vmime::net::socketFactory { public: vmime::ref create() { return vmime::create (); } vmime::ref create(vmime::ref /* th */) { return vmime::create (); } }; class lineBasedTestSocket : public testSocket { public: void onDataReceived(); const vmime::string getNextLine(); bool haveMoreLines() const; virtual void processCommand() = 0; private: std::vector m_lines; std::string m_buffer; }; class testTimeoutHandler : public vmime::net::timeoutHandler { public: testTimeoutHandler(const unsigned int delay = 3); bool isTimeOut(); void resetTimeOut(); bool handleTimeOut(); private: unsigned int m_delay; unsigned int m_start; }; class testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory { public: vmime::ref create(); }; // Exception helper std::ostream& operator<<(std::ostream& os, const vmime::exception& e); libvmime-0.9.1/tests/security/0000755000175000017500000000000011607302336016641 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/security/digest/0000755000175000017500000000000011607302336020120 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/security/digest/md5Test.cpp0000644000175000017500000001233211250723263022152 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/security/digest/messageDigestFactory.hpp" #define VMIME_TEST_SUITE md5Test #define VMIME_TEST_SUITE_MODULE "Security/Digest" #define INIT_DIGEST(var, algo) \ vmime::ref var = \ vmime::security::digest::messageDigestFactory::getInstance()->create(algo) VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testRFC1321_1) VMIME_TEST(testRFC1321_2) VMIME_TEST(testRFC1321_3) VMIME_TEST(testRFC1321_4) VMIME_TEST(testRFC1321_5) VMIME_TEST(testRFC1321_6) VMIME_TEST(testRFC1321_7) VMIME_TEST(testUpdate1) VMIME_TEST(testUpdate2) VMIME_TEST(testUpdate3) VMIME_TEST(testUpdate4) VMIME_TEST(testUpdate5) VMIME_TEST(testUpdate6) VMIME_TEST(testUpdate7) VMIME_TEST_LIST_END // Test suites from RFC #1321 void testRFC1321_1() { INIT_DIGEST(algo, "md5"); algo->update(""); algo->finalize(); VASSERT_EQ("*", "d41d8cd98f00b204e9800998ecf8427e", algo->getHexDigest()); } void testRFC1321_2() { INIT_DIGEST(algo, "md5"); algo->update("a"); algo->finalize(); VASSERT_EQ("*", "0cc175b9c0f1b6a831c399e269772661", algo->getHexDigest()); } void testRFC1321_3() { INIT_DIGEST(algo, "md5"); algo->update("abc"); algo->finalize(); VASSERT_EQ("*", "900150983cd24fb0d6963f7d28e17f72", algo->getHexDigest()); } void testRFC1321_4() { INIT_DIGEST(algo, "md5"); algo->update("message digest"); algo->finalize(); VASSERT_EQ("*", "f96b697d7cb7938d525a2f31aaf161d0", algo->getHexDigest()); } void testRFC1321_5() { INIT_DIGEST(algo, "md5"); algo->update("abcdefghijklmnopqrstuvwxyz"); algo->finalize(); VASSERT_EQ("*", "c3fcd3d76192e4007dfb496cca67e13b", algo->getHexDigest()); } void testRFC1321_6() { INIT_DIGEST(algo, "md5"); algo->update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); algo->finalize(); VASSERT_EQ("*", "d174ab98d277d9f5a5611c2c9f419d9f", algo->getHexDigest()); } void testRFC1321_7() { INIT_DIGEST(algo, "md5"); algo->update("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); algo->finalize(); VASSERT_EQ("*", "57edf4a22be3c955ac49da2e2107b67a", algo->getHexDigest()); } void testReset() { INIT_DIGEST(algo, "md5"); algo->update("foo"); algo->update("bar"); algo->finalize(); algo->reset(); algo->finalize(); VASSERT_EQ("*", "d41d8cd98f00b204e9800998ecf8427e", algo->getHexDigest()); // empty string } void testUpdate1() { INIT_DIGEST(algo, "md5"); algo->update(""); algo->finalize(); VASSERT_EQ("*", "d41d8cd98f00b204e9800998ecf8427e", algo->getHexDigest()); } void testUpdate2() { INIT_DIGEST(algo, "md5"); algo->update("a"); algo->update(""); algo->finalize(); VASSERT_EQ("2", "0cc175b9c0f1b6a831c399e269772661", algo->getHexDigest()); } void testUpdate3() { INIT_DIGEST(algo, "md5"); algo->update("ab"); algo->update("c"); algo->finalize(); VASSERT_EQ("3", "900150983cd24fb0d6963f7d28e17f72", algo->getHexDigest()); } void testUpdate4() { INIT_DIGEST(algo, "md5"); algo->update(""); algo->update("message"); algo->update(" "); algo->update("digest"); algo->finalize(); VASSERT_EQ("4", "f96b697d7cb7938d525a2f31aaf161d0", algo->getHexDigest()); } void testUpdate5() { INIT_DIGEST(algo, "md5"); algo->update("abcd"); algo->update(""); algo->update("efghijklmnop"); algo->update("qrstuvwx"); algo->update("yz"); algo->finalize(); VASSERT_EQ("5", "c3fcd3d76192e4007dfb496cca67e13b", algo->getHexDigest()); } void testUpdate6() { INIT_DIGEST(algo, "md5"); algo->update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012"); algo->update("345"); algo->update("6"); algo->update("7"); algo->update("89"); algo->finalize(); VASSERT_EQ("6", "d174ab98d277d9f5a5611c2c9f419d9f", algo->getHexDigest()); } void testUpdate7() { INIT_DIGEST(algo, "md5"); algo->update("12345678901234567890123456789"); algo->update("01234567890123456789012345678901"); algo->update("234567890123456789"); algo->update(""); algo->update("0"); algo->finalize(); VASSERT_EQ("7", "57edf4a22be3c955ac49da2e2107b67a", algo->getHexDigest()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/security/digest/sha1Test.cpp0000644000175000017500000000612111250723263022320 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/security/digest/messageDigestFactory.hpp" #define VMIME_TEST_SUITE sha1Test #define VMIME_TEST_SUITE_MODULE "Security/Digest" #define INIT_DIGEST(var, algo) \ vmime::ref var = \ vmime::security::digest::messageDigestFactory::getInstance()->create(algo) VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testFIPS180_1) VMIME_TEST(testFIPS180_2) VMIME_TEST(testFIPS180_3) VMIME_TEST(testReset) VMIME_TEST(testUpdate) VMIME_TEST_LIST_END // Test suites from FIPS PUB 180-1 // http://www.itl.nist.gov/fipspubs/fip180-1.htm void testFIPS180_1() { INIT_DIGEST(algo, "sha1"); algo->update("abc"); algo->finalize(); VASSERT_EQ("*", "a9993e364706816aba3e25717850c26c9cd0d89d", algo->getHexDigest()); } void testFIPS180_2() { INIT_DIGEST(algo, "sha1"); algo->update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"); algo->finalize(); VASSERT_EQ("*", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", algo->getHexDigest()); } void testFIPS180_3() { INIT_DIGEST(algo, "sha1"); vmime::byte_t* buffer = new vmime::byte_t[1000000]; for (int i = 0 ; i < 1000000 ; ++i) buffer[i] = 'a'; algo->update(buffer, 1000000); algo->finalize(); delete [] buffer; VASSERT_EQ("*", "34aa973cd4c4daa4f61eeb2bdbad27316534016f", algo->getHexDigest()); } void testReset() { INIT_DIGEST(algo, "sha1"); algo->update("ab"); algo->update("c"); algo->finalize(); algo->reset(); algo->finalize(); VASSERT_EQ("*", "da39a3ee5e6b4b0d3255bfef95601890afd80709", algo->getHexDigest()); // empty string } void testUpdate() { INIT_DIGEST(algo, "sha1"); algo->update("a"); algo->update(""); algo->update("bcdbcdecdefd"); algo->update("efgef"); algo->update("ghfghighijhijkijkljklmklmnlmnomnopnop"); algo->update(""); algo->update("q"); algo->update(""); algo->update(""); algo->finalize(); VASSERT_EQ("*", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", algo->getHexDigest()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/0000755000175000017500000000000011607302336016266 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/parser/mediaTypeTest.cpp0000644000175000017500000000527511250723263021564 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE mediaTypeTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testConstructors) VMIME_TEST(testCopy) VMIME_TEST(testSetFromString) VMIME_TEST(testParse) VMIME_TEST(testGenerate) VMIME_TEST_LIST_END void testConstructors() { vmime::mediaType t1; VASSERT_EQ("1.1", vmime::mediaTypes::APPLICATION, t1.getType()); VASSERT_EQ("1.2", vmime::mediaTypes::APPLICATION_OCTET_STREAM, t1.getSubType()); vmime::mediaType t2("type", "sub"); VASSERT_EQ("2.1", "type", t2.getType()); VASSERT_EQ("2.2", "sub", t2.getSubType()); vmime::mediaType t3("type/sub"); VASSERT_EQ("3.1", "type", t3.getType()); VASSERT_EQ("3.2", "sub", t3.getSubType()); } void testCopy() { vmime::mediaType t1("type/sub"); VASSERT_EQ("eq1", "type", t1.getType()); VASSERT_EQ("eq2", "sub", t1.getSubType()); VASSERT("operator==", t1 == t1); VASSERT("clone", t1 == *vmime::clone(t1)); VASSERT_EQ("eq3", "type", vmime::clone(t1)->getType()); VASSERT_EQ("eq4", "sub", vmime::clone(t1)->getSubType()); vmime::mediaType t2; t2.copyFrom(t1); VASSERT("copyFrom", t1 == t2); } void testSetFromString() { vmime::mediaType t1; t1.setFromString("type/sub"); VASSERT_EQ("1.1", "type", t1.getType()); VASSERT_EQ("1.2", "sub", t1.getSubType()); } void testParse() { vmime::mediaType t1; t1.parse("type/sub"); VASSERT_EQ("1.1", "type", t1.getType()); VASSERT_EQ("1.2", "sub", t1.getSubType()); } void testGenerate() { vmime::mediaType t1("type", "sub"); VASSERT_EQ("1", "type/sub", t1.generate()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/headerTest.cpp0000644000175000017500000002422211250723263021064 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE headerTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testHas1) VMIME_TEST(testHas2) VMIME_TEST(testAppend1) VMIME_TEST(testAppend2) VMIME_TEST(testInsertFieldBefore1) VMIME_TEST(testInsertFieldBefore2) VMIME_TEST(testInsertFieldAfter1) VMIME_TEST(testInsertFieldAfter2) VMIME_TEST(testRemoveField1) VMIME_TEST(testRemoveField2) VMIME_TEST(testRemoveAllFields) VMIME_TEST(testgetFieldCount) VMIME_TEST(testIsEmpty1) VMIME_TEST(testIsEmpty2) VMIME_TEST(testGetFieldAt) VMIME_TEST(testGetFieldList1) VMIME_TEST(testGetFieldList2) VMIME_TEST(testFind1) VMIME_TEST(testFindAllFields1) VMIME_TEST(testFindAllFields2) VMIME_TEST(testFindAllFields3) VMIME_TEST_LIST_END static const std::string getFieldValue(const vmime::headerField& field) { std::ostringstream oss; vmime::utility::outputStreamAdapter voss(oss); field.generate(voss); return (oss.str()); } // has function tests void testHas1() { vmime::header hdr; hdr.parse("From: x\r\nTo: y\r\nTo: z\r\n"); bool res = hdr.hasField("Z"); VASSERT_EQ("Value", false, res); } void testHas2() { vmime::header hdr; hdr.parse("X: x\r\nTo: y\r\nTo: z\r\n"); bool res = hdr.hasField("To"); VASSERT_EQ("Value", true, res); } // appendField function tests void testAppend1() { vmime::header hdr; hdr.parse(""); vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("A", "a"); hdr.appendField(hf); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (1), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); } void testAppend2() { vmime::header hdr; hdr.parse("A: a\r\n"); vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.appendField(hf); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (2), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); } // insertFieldBefore void testInsertFieldBefore1() { vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldBefore(hdr.getField("C"), hf); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); } void testInsertFieldBefore2() { vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldBefore(1, hf); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); } // insertFieldAfter void testInsertFieldAfter1() { vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldAfter(hdr.getField("A"), hf); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); } void testInsertFieldAfter2() { vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldAfter(0, hf); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); } // removeField void testRemoveField1() { vmime::header hdr1, hdr2; hdr1.parse("A: a\r\nB: b\r\nC: c\r\n"); hdr2.parse("A: a\r\nB: b\r\nC: c\r\n"); hdr1.removeField(hdr1.getField("B")); hdr2.removeField(1); std::vector > res1 = hdr1.getFieldList(); VASSERT_EQ("Count", static_cast (2), res1.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res1[0])); VASSERT_EQ("Second value", "C: c", headerTest::getFieldValue(*res1[1])); std::vector > res2 = hdr2.getFieldList(); VASSERT_EQ("Count", static_cast (2), res2.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res2[0])); VASSERT_EQ("Second value", "C: c", headerTest::getFieldValue(*res2[1])); } void testRemoveField2() { vmime::header hdr1, hdr2; hdr1.parse("A: a\r\n"); hdr2.parse("A: a\r\n"); hdr1.removeField(hdr1.getField("A")); hdr2.removeField(0); std::vector > res1 = hdr1.getFieldList(); VASSERT_EQ("Count", static_cast (0), res1.size()); std::vector > res2 = hdr2.getFieldList(); VASSERT_EQ("Count", static_cast (0), res2.size()); } // removeAllFields void testRemoveAllFields() { vmime::header hdr1, hdr2; hdr1.parse("A: a\r\n"); hdr2.parse("A: a\r\nB: b\r\n"); hdr1.removeAllFields(); hdr2.removeAllFields(); std::vector > res1 = hdr1.getFieldList(); VASSERT_EQ("Count", static_cast (0), res1.size()); std::vector > res2 = hdr2.getFieldList(); VASSERT_EQ("Count", static_cast (0), res2.size()); } // getFieldCount void testgetFieldCount() { vmime::header hdr; hdr.parse("A: a\r\nB: b\r\nC: c\r\nD: d\r\n"); VASSERT_EQ("Value", 4, hdr.getFieldCount()); } // isEmpty void testIsEmpty1() { vmime::header hdr; hdr.parse("A: a\r\nB: b\r\nC: c\r\n"); VASSERT_EQ("Value", false, hdr.isEmpty()); } void testIsEmpty2() { vmime::header hdr; hdr.parse("\r\n"); VASSERT_EQ("Value", true, hdr.isEmpty()); } // getFieldAt void testGetFieldAt() { vmime::header hdr; hdr.parse("B: b\r\nA: a\r\nC: c\r\n"); vmime::ref res = hdr.getFieldAt(2); VASSERT_EQ("Value", "C: c", getFieldValue(*res)); } // getFieldList void testGetFieldList1() { vmime::header hdr; hdr.parse("A: a\r\nB: b1\r\nC: c\r\nB: b2\r\n"); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (4), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "B: b1", headerTest::getFieldValue(*res[1])); VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); VASSERT_EQ("Thourth value", "B: b2", headerTest::getFieldValue(*res[3])); } void testGetFieldList2() { vmime::header hdr; hdr.parse("\r\n"); std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (0), res.size()); } // find function tests void testFind1() { vmime::header hdr; hdr.parse("A: a\r\nB: b\r\nC: c\r\nB: d\r\n"); vmime::ref res = hdr.findField("B"); VASSERT_EQ("Value", "B: b", getFieldValue(*res)); } // getAllByName function tests void testFindAllFields1() { vmime::header hdr; hdr.parse("A: a1\nC: c1\n"); std::vector > res = hdr.findAllFields("B"); VASSERT_EQ("Count", static_cast (0), res.size()); } void testFindAllFields2() { vmime::header hdr; hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\n"); std::vector > res = hdr.findAllFields("B"); VASSERT_EQ("Count", static_cast (2), res.size()); VASSERT_EQ("First value", "B: b1", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "B: b2", headerTest::getFieldValue(*res[1])); } void testFindAllFields3() { vmime::header hdr; hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\nC: c3\nC: c2\n"); std::vector > res = hdr.findAllFields("C"); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "C: c1", headerTest::getFieldValue(*res[0])); VASSERT_EQ("Second value", "C: c3", headerTest::getFieldValue(*res[1])); VASSERT_EQ("Second value", "C: c2", headerTest::getFieldValue(*res[2])); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/dispositionTest.cpp0000644000175000017500000001164211250723263022202 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE dispositionTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testGenerate) VMIME_TEST(testModifiers) VMIME_TEST_LIST_END void testParse() { // disposition-mode ";" disposition-type // [ "/" disposition-modifier *( "," disposition-modifier ) ] // // disposition-mode = action-mode "/" sending-mode vmime::disposition disp1; disp1.parse("mode"); VASSERT_EQ("1.1", "mode", disp1.getActionMode()); VASSERT_EQ("1.2", "", disp1.getSendingMode()); VASSERT_EQ("1.3", "", disp1.getType()); VASSERT_EQ("1.4", 0, static_cast (disp1.getModifierList().size())); vmime::disposition disp2; disp2.parse("amode/smode"); VASSERT_EQ("2.1", "amode", disp2.getActionMode()); VASSERT_EQ("2.2", "smode", disp2.getSendingMode()); VASSERT_EQ("2.3", "", disp2.getType()); VASSERT_EQ("2.4", 0, static_cast (disp2.getModifierList().size())); vmime::disposition disp3; disp3.parse("amode/smode;type"); VASSERT_EQ("3.1", "amode", disp3.getActionMode()); VASSERT_EQ("3.2", "smode", disp3.getSendingMode()); VASSERT_EQ("3.3", "type", disp3.getType()); VASSERT_EQ("3.4", 0, static_cast (disp3.getModifierList().size())); vmime::disposition disp4; disp4.parse("amode/smode;type/modif"); VASSERT_EQ("4.1", "amode", disp4.getActionMode()); VASSERT_EQ("4.2", "smode", disp4.getSendingMode()); VASSERT_EQ("4.3", "type", disp4.getType()); VASSERT_EQ("4.4", 1, static_cast (disp4.getModifierList().size())); VASSERT_EQ("4.5", "modif", disp4.getModifierList()[0]); vmime::disposition disp5; disp5.parse("amode/smode;type/modif1,modif2"); VASSERT_EQ("5.1", "amode", disp5.getActionMode()); VASSERT_EQ("5.2", "smode", disp5.getSendingMode()); VASSERT_EQ("5.3", "type", disp5.getType()); VASSERT_EQ("5.4", 2, static_cast (disp5.getModifierList().size())); VASSERT_EQ("5.5", "modif1", disp5.getModifierList()[0]); VASSERT_EQ("5.6", "modif2", disp5.getModifierList()[1]); } void testGenerate() { vmime::disposition disp; VASSERT_EQ("1", "automatic-action/MDN-sent-automatically;displayed", disp.generate()); disp.setActionMode("amode"); VASSERT_EQ("2", "amode/MDN-sent-automatically;displayed", disp.generate()); disp.setActionMode("amode"); disp.setSendingMode("smode"); VASSERT_EQ("3", "amode/smode;displayed", disp.generate()); disp.setType("type"); VASSERT_EQ("4", "amode/smode;type", disp.generate()); disp.addModifier("modif1"); VASSERT_EQ("5", "amode/smode;type/modif1", disp.generate()); disp.addModifier("modif2"); VASSERT_EQ("6", "amode/smode;type/modif1,modif2", disp.generate()); } void testModifiers() { vmime::disposition disp1; VASSERT_EQ("1", false, disp1.hasModifier("foo")); VASSERT_EQ("2", 0, static_cast (disp1.getModifierList().size())); disp1.addModifier("bar"); VASSERT_EQ("3", false, disp1.hasModifier("foo")); VASSERT_EQ("4", true, disp1.hasModifier("bar")); VASSERT_EQ("5", 1, static_cast (disp1.getModifierList().size())); disp1.addModifier("plop"); VASSERT_EQ("6", false, disp1.hasModifier("foo")); VASSERT_EQ("7", true, disp1.hasModifier("bar")); VASSERT_EQ("8", true, disp1.hasModifier("plop")); VASSERT_EQ("9", 2, static_cast (disp1.getModifierList().size())); disp1.removeModifier("bar"); VASSERT_EQ("10", false, disp1.hasModifier("foo")); VASSERT_EQ("11", false, disp1.hasModifier("bar")); VASSERT_EQ("12", true, disp1.hasModifier("plop")); VASSERT_EQ("13", 1, static_cast (disp1.getModifierList().size())); disp1.removeModifier("PlOp"); VASSERT_EQ("14", false, disp1.hasModifier("foo")); VASSERT_EQ("15", false, disp1.hasModifier("bar")); VASSERT_EQ("16", false, disp1.hasModifier("plop")); VASSERT_EQ("17", 0, static_cast (disp1.getModifierList().size())); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/bodyPartTest.cpp0000644000175000017500000000647111250723263021426 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE bodyPartTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testGenerate) VMIME_TEST(testParseMissingLastBoundary) VMIME_TEST_LIST_END static const vmime::string extractComponentString (const vmime::string& buffer, const vmime::component& c) { return vmime::string(buffer.begin() + c.getParsedOffset(), buffer.begin() + c.getParsedOffset() + c.getParsedLength()); } static const vmime::string extractContents(const vmime::ref cts) { std::ostringstream oss; vmime::utility::outputStreamAdapter os(oss); cts->extract(os); return oss.str(); } void testParse() { vmime::string str1 = "HEADER\r\n\r\nBODY"; vmime::bodyPart p1; p1.parse(str1); VASSERT_EQ("1", "HEADER\r\n\r\n", extractComponentString(str1, *p1.getHeader())); VASSERT_EQ("2", "BODY", extractComponentString(str1, *p1.getBody())); vmime::string str2 = "HEADER\n\nBODY"; vmime::bodyPart p2; p2.parse(str2); VASSERT_EQ("3", "HEADER\n\n", extractComponentString(str2, *p2.getHeader())); VASSERT_EQ("4", "BODY", extractComponentString(str2, *p2.getBody())); vmime::string str3 = "HEADER\r\n\nBODY"; vmime::bodyPart p3; p3.parse(str3); VASSERT_EQ("5", "HEADER\r\n\n", extractComponentString(str3, *p3.getHeader())); VASSERT_EQ("6", "BODY", extractComponentString(str3, *p3.getBody())); } void testParseMissingLastBoundary() { vmime::string str = "Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\"" "\r\n\r\n" "--MY-BOUNDARY\r\nHEADER1\r\n\r\nBODY1" "--MY-BOUNDARY\r\nHEADER2\r\n\r\nBODY2"; vmime::bodyPart p; p.parse(str); VASSERT_EQ("count", 2, p.getBody()->getPartCount()); VASSERT_EQ("part1-body", "BODY1", extractContents(p.getBody()->getPartAt(0)->getBody()->getContents())); VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents())); } void testGenerate() { vmime::bodyPart p1; p1.getHeader()->getField("Foo")->setValue(vmime::string("bar")); p1.getBody()->setContents(vmime::create ("Baz")); VASSERT_EQ("1", "Foo: bar\r\n\r\nBaz", p1.generate()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/datetimeTest.cpp0000644000175000017500000000757511250723263021444 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE datetimeTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testGenerate) VMIME_TEST(testCompare) VMIME_TEST_LIST_END void testParse() { struct datetimePair { vmime::string parseBuffer; vmime::datetime result; }; // Here, we can't test all the possible structures for date/time, // so we test some cases. Don't forget to add a new test case // each time you encounter a bug in date/time parsing (after // you have fixed it). datetimePair pairs[] = { { /* 1 */ "Mon, 8 Nov 2004 13:42:56 +0000 (GMT)", vmime::datetime(2004, 11, 8, 13, 42, 56, vmime::datetime::GMT) }, { /* 2 */ "Sun, 7 Nov 2004 00:43:22 -0500 (EST)", vmime::datetime(2004, 11, 7, 0, 43, 22, vmime::datetime::GMT_5) }, { /* 3 */ "Thu Nov 18 12:11:16 2004", vmime::datetime(vmime::datetime::now().getYear(), 11, 18, 12, 11, 16, vmime::datetime::GMT) }, { /* 4 */ "Sat, 18, 2004 22:36:32 -0400", vmime::datetime(2004, 1, 18, 22, 36, 32, vmime::datetime::GMT_4) }, { /* 5 */ "Mon Dec 13 21:57:18 2004", vmime::datetime(vmime::datetime::now().getYear(), 12, 13, 21, 57, 18, vmime::datetime::GMT) }, { /* 6 */ "18 Nov 2004 21:44:54 +0300", vmime::datetime(2004, 11, 18, 21, 44, 54, vmime::datetime::GMT3) } }; for (unsigned int i = 0 ; i < sizeof(pairs) / sizeof(pairs[0]) ; ++i) { vmime::datetime d; d.parse(pairs[i].parseBuffer); std::ostringstream oss; oss << (i + 1); VASSERT_EQ(oss.str(), pairs[i].result, d); } } void testGenerate() { vmime::datetime d1(2005, 7, 8, 4, 5, 6, 1 * 60 + 23); VASSERT_EQ("1", "Fri, 8 Jul 2005 04:05:06 +0123", d1.generate()); } void testCompare() { // Date1 = Date2 vmime::datetime d1(2005, 4, 22, 14, 6, 0, vmime::datetime::GMT2); vmime::datetime d2(2005, 4, 22, 10, 6, 0, vmime::datetime::GMT_2); VASSERT_EQ("1.1", true, d1 == d2); VASSERT_EQ("1.2", false, d1 != d2); VASSERT_EQ("1.3", true, d1 <= d2); VASSERT_EQ("1.4", false, d1 < d2); VASSERT_EQ("1.5", true, d1 >= d2); VASSERT_EQ("1.6", false, d1 > d2); // Date1 < Date2 vmime::datetime d3(2005, 4, 22, 14, 6, 0); vmime::datetime d4(2005, 4, 22, 15, 6, 0); VASSERT_EQ("2.1", false, d3 == d4); VASSERT_EQ("2.2", true, d3 != d4); VASSERT_EQ("2.3", true, d3 <= d4); VASSERT_EQ("2.4", true, d3 < d4); VASSERT_EQ("2.5", false, d3 >= d4); VASSERT_EQ("2.6", false, d3 > d4); // Date1 > Date2 vmime::datetime d5(2005, 4, 22, 15, 6, 0); vmime::datetime d6(2005, 4, 22, 14, 6, 0); VASSERT_EQ("3.1", false, d5 == d6); VASSERT_EQ("3.2", true, d5 != d6); VASSERT_EQ("3.3", false, d5 <= d6); VASSERT_EQ("3.4", false, d5 < d6); VASSERT_EQ("3.5", true, d5 >= d6); VASSERT_EQ("3.6", true, d5 > d6); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/parameterTest.cpp0000644000175000017500000003307011432601325021611 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE parameterTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testParseRFC2231) VMIME_TEST(testGenerate) VMIME_TEST(testGenerateRFC2231) VMIME_TEST(testNonStandardEncodedParam) VMIME_TEST(testParseNonSignificantWS) VMIME_TEST(testEncodeTSpecials) VMIME_TEST(testEncodeTSpecialsInRFC2231) VMIME_TEST_LIST_END // HACK: parameterizedHeaderField constructor is private class parameterizedHeaderField : public vmime::parameterizedHeaderField { public: parameterizedHeaderField() : headerField("F") { setValue(vmime::headerFieldFactory::getInstance()->createValue(getName())); setValue(vmime::word("X")); } }; #define FIELD_VALUE(f) (f.getValue()->generate()) #define PARAM_VALUE(p, n) (p.getParameterAt(n)->getValue().generate()) #define PARAM_NAME(p, n) (p.getParameterAt(n)->getName()) #define PARAM_CHARSET(p, n) \ (p.getParameterAt(n)->getValue().getCharset().generate()) #define PARAM_BUFFER(p, n) \ (p.getParameterAt(n)->getValue().getBuffer()) void testParse() { // Simple parameter parameterizedHeaderField p1; p1.parse("X; param1=value1;\r\n"); VASSERT_EQ("1.1", 1, p1.getParameterCount()); VASSERT_EQ("1.2", "param1", PARAM_NAME(p1, 0)); VASSERT_EQ("1.3", "value1", PARAM_VALUE(p1, 0)); // Multi-section parameters (1/2) parameterizedHeaderField p2a; p2a.parse("X; param1=value1;\r\n" " param2*0=\"val\";\r\n" " param2*1=\"ue2\";"); VASSERT_EQ("2a.1", 2, p2a.getParameterCount()); VASSERT_EQ("2a.2", "param1", PARAM_NAME(p2a, 0)); VASSERT_EQ("2a.3", "value1", PARAM_VALUE(p2a, 0)); VASSERT_EQ("2a.4", "param2", PARAM_NAME(p2a, 1)); VASSERT_EQ("2a.5", "value2", PARAM_VALUE(p2a, 1)); // Multi-section parameters (2/2) parameterizedHeaderField p2b; p2b.parse("X; param1=value1;\r\n" " param2=\"should be ignored\";\r\n" " param2*0=\"val\";\r\n" " param2*1=\"ue2\";"); VASSERT_EQ("2b.1", 2, p2b.getParameterCount()); VASSERT_EQ("2b.2", "param1", PARAM_NAME(p2b, 0)); VASSERT_EQ("2b.3", "value1", PARAM_VALUE(p2b, 0)); VASSERT_EQ("2b.4", "param2", PARAM_NAME(p2b, 1)); VASSERT_EQ("2b.5", "value2", PARAM_VALUE(p2b, 1)); // Extended parameter (charset and language information) parameterizedHeaderField p3; p3.parse("X; param1*=charset'language'value1;\r\n"); VASSERT_EQ("3.1", 1, p3.getParameterCount()); VASSERT_EQ("3.2", "param1", PARAM_NAME(p3, 0)); VASSERT_EQ("3.3", "charset", PARAM_CHARSET(p3, 0)); VASSERT_EQ("3.4", "value1", PARAM_BUFFER(p3, 0)); // Encoded characters in extended parameter values parameterizedHeaderField p4; p4.parse("X; param1*=a%20value%20with%20multiple%20word%73"); // 0x73 = 's' VASSERT_EQ("4.1", 1, p4.getParameterCount()); VASSERT_EQ("4.2", "param1", PARAM_NAME(p4, 0)); VASSERT_EQ("4.3", "a value with multiple words", PARAM_VALUE(p4, 0)); // Invalid encoded character parameterizedHeaderField p5; p5.parse("X; param1*=test%20value%"); VASSERT_EQ("5.1", 1, p5.getParameterCount()); VASSERT_EQ("5.2", "param1", PARAM_NAME(p5, 0)); VASSERT_EQ("5.3", "test value%", PARAM_VALUE(p5, 0)); // Spaces before and after '=' parameterizedHeaderField p6; p6.parse("X; param1\t= \"value1\""); VASSERT_EQ("6.1", 1, p6.getParameterCount()); VASSERT_EQ("6.2", "param1", PARAM_NAME(p6, 0)); VASSERT_EQ("6.3", "value1", PARAM_VALUE(p6, 0)); // Quoted strings and escaped chars parameterizedHeaderField p7; p7.parse("X; param1=\"this is a slash: \\\"\\\\\\\"\""); // \"\\\" VASSERT_EQ("7.1", 1, p7.getParameterCount()); VASSERT_EQ("7.2", "param1", PARAM_NAME(p7, 0)); VASSERT_EQ("7.3", "this is a slash: \"\\\"", PARAM_VALUE(p7, 0)); } void testParseRFC2231() { // Extended parameter with charset specified in more than one // section (this is forbidden by RFC, but is should not fail) parameterizedHeaderField p1; p1.parse("X; param1*0*=charset1'language1'value1;\r\n" " param1*1*=charset2'language2'value2;"); VASSERT_EQ("1.1", 1, p1.getParameterCount()); VASSERT_EQ("1.2", "param1", PARAM_NAME(p1, 0)); VASSERT_EQ("1.3", "charset1", PARAM_CHARSET(p1, 0)); VASSERT_EQ("1.4", "value1charset2'language2'value2", PARAM_BUFFER(p1, 0)); // Charset not specified in the first section (that is not encoded), // but specified in the second one (legal) parameterizedHeaderField p2; p2.parse("X; param1*0=value1;\r\n" " param1*1*=charset'language'value2;"); VASSERT_EQ("2.1", 1, p2.getParameterCount()); VASSERT_EQ("2.2", "param1", PARAM_NAME(p2, 0)); VASSERT_EQ("2.3", "charset", PARAM_CHARSET(p2, 0)); VASSERT_EQ("2.4", "value1value2", PARAM_BUFFER(p2, 0)); // Characters prefixed with '%' in a simple (not extended) section // should not be decoded parameterizedHeaderField p3; p3.parse("X; param1=val%20ue1"); VASSERT_EQ("3.1", 1, p3.getParameterCount()); VASSERT_EQ("3.2", "param1", PARAM_NAME(p3, 0)); VASSERT_EQ("3.3", "val%20ue1", PARAM_VALUE(p3, 0)); // Multiple sections + charset specified and encoding parameterizedHeaderField p4; p4.parse("X; param1*0*=charset'language'value1a%20;" " param1*1*=value1b%20;" " param1*2=value1c"); VASSERT_EQ("4.1", 1, p4.getParameterCount()); VASSERT_EQ("4.2", "param1", PARAM_NAME(p4, 0)); VASSERT_EQ("4.3", "charset", PARAM_CHARSET(p4, 0)); VASSERT_EQ("4.4", "value1a value1b value1c", PARAM_BUFFER(p4, 0)); // No charset specified: defaults to US-ASCII parameterizedHeaderField p5; p5.parse("X; param1*='language'value1"); VASSERT_EQ("5.1", 1, p5.getParameterCount()); VASSERT_EQ("5.2", "param1", PARAM_NAME(p5, 0)); VASSERT_EQ("5.3", "us-ascii", PARAM_CHARSET(p5, 0)); VASSERT_EQ("5.4", "value1", PARAM_BUFFER(p5, 0)); } void testGenerate() { // Simple parameter/value parameterizedHeaderField p1; p1.appendParameter(vmime::create ("param1", "value1")); VASSERT_EQ("1", "F: X; param1=value1", p1.generate()); // Value that needs quoting (1/2) parameterizedHeaderField p2a; p2a.appendParameter(vmime::create ("param1", "value1a;value1b")); VASSERT_EQ("2a", "F: X; param1=\"value1a;value1b\"", p2a.generate()); // Value that needs quoting (2/2) parameterizedHeaderField p2b; p2b.appendParameter(vmime::create ("param1", "va\\lue\"1")); VASSERT_EQ("2b", "F: X; param1=\"va\\\\lue\\\"1\"", p2b.generate()); } void testGenerateRFC2231() { // Extended parameter with charset specifier parameterizedHeaderField p1; p1.appendParameter(vmime::create ("param1", vmime::word("value 1\xe9", vmime::charset("charset")))); #if VMIME_ALWAYS_GENERATE_7BIT_PARAMETER VASSERT_EQ("1", "F: X; param1=\"value 1\";param1*=charset''value%201%E9", p1.generate()); #else VASSERT_EQ("1", "F: X; param1*=charset''value%201%E9", p1.generate()); #endif // Value that spans on multiple lines parameterizedHeaderField p2; p2.appendParameter(vmime::create ("param1", vmime::word("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", vmime::charset("charset")))); #if VMIME_ALWAYS_GENERATE_7BIT_PARAMETER VASSERT_EQ("2", "F: X; \r\n " "param1=abcdefghijklm;\r\n " "param1*0*=charset''abc;\r\n " "param1*1*=defghijkl;\r\n " "param1*2*=mnopqrstu;\r\n " "param1*3*=vwxyzABCD;\r\n " "param1*4*=EFGHIJKLM;\r\n " "param1*5*=NOPQRSTUV;\r\n " "param1*6*=WXYZ", p2.generate(25)); // max line length = 25 #else VASSERT_EQ("2", "F: X; \r\n " "param1*0*=charset''abc;\r\n " "param1*1*=defghijkl;\r\n " "param1*2*=mnopqrstu;\r\n " "param1*3*=vwxyzABCD;\r\n " "param1*4*=EFGHIJKLM;\r\n " "param1*5*=NOPQRSTUV;\r\n " "param1*6*=WXYZ", p2.generate(25)); // max line length = 25 #endif // Non-ASCII parameter value parameterizedHeaderField p3; p3.appendParameter(vmime::create ("param1", vmime::word("δσσσσσσσσσσσσσσσσσσσσδσδα δσαδσδσαδσαδασδασ δσαδασδσα δσαδασδσα δασδασδασ δασαχφδδσα 2008.doc", vmime::charset("utf-8")))); #if VMIME_ALWAYS_GENERATE_7BIT_PARAMETER VASSERT_EQ("3", "F: X; \r\n " "param1=\" 2008.doc\";param1*0*=utf-8''%CE%B4%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83;\r\n " "param1*1*=%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83;\r\n " "param1*2*=%CE%B4%CF%83%CE%B4%CE%B1%20%CE%B4%CF%83%CE%B1%CE%B4%CF%83%CE%B4%CF;\r\n " "param1*3*=%83%CE%B1%CE%B4%CF%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CE%B1%CF%83%20;\r\n " "param1*4*=%CE%B4%CF%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CF%83%CE%B1%20%CE%B4%CF;\r\n " "param1*5*=%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CF%83%CE%B1%20%CE%B4%CE%B1%CF%83;\r\n " "param1*6*=%CE%B4%CE%B1%CF%83%CE%B4%CE%B1%CF%83%20%CE%B4%CE%B1%CF%83%CE%B1%CF;\r\n " "param1*7*=%87%CF%86%CE%B4%CE%B4%CF%83%CE%B1%202008.doc", p3.generate(80)); #else VASSERT_EQ("3", "F: X; param1*0*=utf-8''%CE%B4%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83;\r\n " "param1*1*=%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83%CF%83;\r\n " "param1*2*=%CE%B4%CF%83%CE%B4%CE%B1%20%CE%B4%CF%83%CE%B1%CE%B4%CF%83%CE%B4%CF;\r\n " "param1*3*=%83%CE%B1%CE%B4%CF%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CE%B1%CF%83%20;\r\n " "param1*4*=%CE%B4%CF%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CF%83%CE%B1%20%CE%B4%CF;\r\n " "param1*5*=%83%CE%B1%CE%B4%CE%B1%CF%83%CE%B4%CF%83%CE%B1%20%CE%B4%CE%B1%CF%83;\r\n " "param1*6*=%CE%B4%CE%B1%CF%83%CE%B4%CE%B1%CF%83%20%CE%B4%CE%B1%CF%83%CE%B1%CF;\r\n " "param1*7*=%87%CF%86%CE%B4%CE%B4%CF%83%CE%B1%202008.doc", p3.generate(80)); #endif } void testNonStandardEncodedParam() { // This syntax is non-standard (expressly prohibited // by RFC-2047), but is used by Mozilla: // // Content-Type: image/png; // name="=?us-ascii?Q?Logo_VMime=2Epng?=" parameterizedHeaderField p1; p1.parse("image/png; name=\"=?us-ascii?Q?Logo_VMime=2Epng?=\""); VASSERT_EQ("1.1", 1, p1.getParameterCount()); VASSERT_EQ("1.2", "name", PARAM_NAME(p1, 0)); VASSERT_EQ("1.3", "Logo VMime.png", PARAM_VALUE(p1, 0)); parameterizedHeaderField p2; p2.parse("image/png; name=\"Logo =?us-ascii?Q?VMime=2Epng?=\""); VASSERT_EQ("2.1", 1, p2.getParameterCount()); VASSERT_EQ("2.2", "name", PARAM_NAME(p2, 0)); VASSERT_EQ("2.3", "Logo VMime.png", PARAM_VALUE(p2, 0)); } // Parse parameters with non-significant whitespaces void testParseNonSignificantWS() { parameterizedHeaderField p1; p1.parse(" \t X \r\n"); VASSERT_EQ("1.1", "X", FIELD_VALUE(p1)); parameterizedHeaderField p2; p2.parse(" X ; param1 = value1 \r\n"); VASSERT_EQ("2.1", 1, p2.getParameterCount()); VASSERT_EQ("2.2", "X", FIELD_VALUE(p2)); VASSERT_EQ("2.3", "param1", PARAM_NAME(p2, 0)); VASSERT_EQ("2.4", "value1", PARAM_VALUE(p2, 0)); } // Encode "tspecials" void testEncodeTSpecials() { VASSERT_EQ(" 1", "p=\"val(ue\"", vmime::create ("p", "val(ue")->generate()); VASSERT_EQ(" 2", "p=\"val)ue\"", vmime::create ("p", "val)ue")->generate()); VASSERT_EQ(" 3", "p=\"val("p", "valgenerate()); VASSERT_EQ(" 4", "p=\"val>ue\"", vmime::create ("p", "val>ue")->generate()); VASSERT_EQ(" 5", "p=\"val@ue\"", vmime::create ("p", "val@ue")->generate()); VASSERT_EQ(" 6", "p=\"val,ue\"", vmime::create ("p", "val,ue")->generate()); VASSERT_EQ(" 7", "p=\"val;ue\"", vmime::create ("p", "val;ue")->generate()); VASSERT_EQ(" 8", "p=\"val:ue\"", vmime::create ("p", "val:ue")->generate()); VASSERT_EQ(" 9", "p=\"val/ue\"", vmime::create ("p", "val/ue")->generate()); VASSERT_EQ("10", "p=\"val[ue\"", vmime::create ("p", "val[ue")->generate()); VASSERT_EQ("11", "p=\"val]ue\"", vmime::create ("p", "val]ue")->generate()); VASSERT_EQ("12", "p=\"val?ue\"", vmime::create ("p", "val?ue")->generate()); VASSERT_EQ("13", "p=\"val=ue\"", vmime::create ("p", "val=ue")->generate()); VASSERT_EQ("14", "p=\"val ue\"", vmime::create ("p", "val ue")->generate()); VASSERT_EQ("15", "p=\"val\tue\"", vmime::create ("p", "val\tue")->generate()); } // http://sourceforge.net/projects/vmime/forums/forum/237356/topic/3812278 void testEncodeTSpecialsInRFC2231() { VASSERT_EQ("1", "filename*=UTF-8''my_file_name_%C3%B6%C3%A4%C3%BC_%281%29.txt", vmime::create ("filename", "my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt")->generate()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/mailboxTest.cpp0000644000175000017500000001022011250723263021260 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE mailboxTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST_LIST_END void testParse() { static const vmime::string testSuitesParse[] = { // Test 1 "My (this is a comment)name ", "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=My name]]], email=me@somewhere.com]]]", // Test 2 "mailbox1 ,;,,, ,, ,,;group1:mailbox1@group1, mailbox2@group2,,\"mailbox #3\" ;, ,,,,,,,,=?iso-8859-1?q?mailbox_number_3?= , =?abc?Q?mailbox?= =?def?Q?_number_4?= ", "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=mailbox1]]], email=mailbox@one],[mailbox-group: name=[text: [[word: charset=us-ascii, buffer=group1]]], list=[[mailbox: name=[text: []], email=mailbox1@group1],[mailbox: name=[text: []], email=mailbox2@group2],[mailbox: name=[text: [[word: charset=us-ascii, buffer=mailbox #3]]], email=mailbox3@group2]]],[mailbox: name=[text: []], email=mailbox@two],[mailbox: name=[text: [[word: charset=iso-8859-1, buffer=mailbox number 3]]], email=mailbox@three],[mailbox: name=[text: [[word: charset=abc, buffer=mailbox],[word: charset=def, buffer= number 4]]], email=mailbox@four]]]", // Test 3 "John Doe ", "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John Doe]]], email=john.doe@acme.com]]]", // Test 4 "john.doe@acme.com (John Doe)", "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", // Test 5 "John.Doe (ignore) @acme.com (John Doe)", "[address-list: [[mailbox: name=[text: []], email=John.Doe@acme.com]]]", // Test 6 "", "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", // Test 7 "john.doe@acme.com", "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", // Test 8 "\"John Doe\" ", "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John Doe]]], email=john.doe@acme.com]]]", // Test 9 "=?us-ascii?q?John?=", "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]", // Test 10 "\"John\"", "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]", // Test 11 "John", "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]" }; for (unsigned int i = 0 ; i < sizeof(testSuitesParse) / sizeof(testSuitesParse[0]) / 2 ; ++i) { vmime::string in = testSuitesParse[i * 2]; vmime::string out = testSuitesParse[i * 2 + 1]; std::ostringstream oss; oss << "Test " << (i + 1); vmime::addressList addrList; addrList.parse(in); std::ostringstream cmp; cmp << addrList; VASSERT_EQ(oss.str(), out, cmp.str()); } } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/pathTest.cpp0000644000175000017500000000511611250723263020571 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE pathTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testParse2) VMIME_TEST(testGenerate) VMIME_TEST_LIST_END void testParse() { vmime::path p1; p1.parse("<>"); VASSERT_EQ("1.1", "", p1.getLocalPart()); VASSERT_EQ("1.2", "", p1.getDomain()); vmime::path p2; p2.parse(""); VASSERT_EQ("2.1", "", p2.getLocalPart()); VASSERT_EQ("2.2", "domain", p2.getDomain()); vmime::path p3; p3.parse(""); VASSERT_EQ("3.1", "local", p3.getLocalPart()); VASSERT_EQ("3.2", "domain", p3.getDomain()); } void testParse2() { // Test some invalid paths (no '<>') vmime::path p1; p1.parse(""); VASSERT_EQ("1.1", "", p1.getLocalPart()); VASSERT_EQ("1.2", "", p1.getDomain()); vmime::path p2; p2.parse("domain"); VASSERT_EQ("2.1", "", p2.getLocalPart()); VASSERT_EQ("2.2", "domain", p2.getDomain()); vmime::path p3; p3.parse("local@domain"); VASSERT_EQ("3.1", "local", p3.getLocalPart()); VASSERT_EQ("3.2", "domain", p3.getDomain()); } void testGenerate() { vmime::path p1; VASSERT_EQ("1", "<>", p1.generate()); vmime::path p2; p2.setLocalPart("local"); VASSERT_EQ("2", "", p2.generate()); vmime::path p3; p3.setDomain("domain"); VASSERT_EQ("3", "<@domain>", p3.generate()); vmime::path p4; p4.setLocalPart("local"); p4.setDomain("domain"); VASSERT_EQ("4", "", p4.generate()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/messageIdSequenceTest.cpp0000644000175000017500000000472211250723263023231 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE messageIdSequenceTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testGenerate) VMIME_TEST_LIST_END void testParse() { vmime::messageIdSequence s1; s1.parse(""); VASSERT_EQ("1", 0, s1.getMessageIdCount()); vmime::messageIdSequence s2; s2.parse(" \t "); VASSERT_EQ("2", 0, s2.getMessageIdCount()); vmime::messageIdSequence s3; s3.parse(""); VASSERT_EQ("3.1", 1, s3.getMessageIdCount()); VASSERT_EQ("3.2", "a", s3.getMessageIdAt(0)->getLeft()); VASSERT_EQ("3.3", "b", s3.getMessageIdAt(0)->getRight()); vmime::messageIdSequence s4; s4.parse(" \r\n\t"); VASSERT_EQ("4.1", 2, s4.getMessageIdCount()); VASSERT_EQ("4.2", "a", s4.getMessageIdAt(0)->getLeft()); VASSERT_EQ("4.3", "b", s4.getMessageIdAt(0)->getRight()); VASSERT_EQ("4.4", "c", s4.getMessageIdAt(1)->getLeft()); VASSERT_EQ("4.5", "d", s4.getMessageIdAt(1)->getRight()); } void testGenerate() { vmime::messageIdSequence s1; s1.appendMessageId(vmime::create ("a", "b")); VASSERT_EQ("1", "", s1.generate()); vmime::messageIdSequence s2; s2.appendMessageId(vmime::create ("a", "b")); s2.appendMessageId(vmime::create ("c", "d")); VASSERT_EQ("2", " ", s2.generate()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/attachmentHelperTest.cpp0000644000175000017500000002330411250723263023124 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE attachmentHelperTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testAddAttachment1) VMIME_TEST(testAddAttachment2) VMIME_TEST(testAddAttachment3) VMIME_TEST(testIsBodyPartAnAttachment1) VMIME_TEST(testIsBodyPartAnAttachment2) VMIME_TEST(testIsBodyPartAnAttachment3) VMIME_TEST(testGetBodyPartAttachment) VMIME_TEST(testAddAttachmentMessage1) VMIME_TEST(testGetBodyPartAttachmentMessage) VMIME_TEST_LIST_END static const vmime::string getStructure(vmime::ref part) { vmime::ref bdy = part->getBody(); vmime::string res = part->getBody()->getContentType().generate(); if (bdy->getPartCount() == 0) return res; res += "["; for (int i = 0 ; i < bdy->getPartCount() ; ++i) { vmime::ref subPart = bdy->getPartAt(i); if (i != 0) res += ","; res += getStructure(subPart); } return res + "]"; } static const vmime::string extractBodyContents(vmime::ref part) { vmime::ref cth = part->getBody()->getContents(); vmime::string data; vmime::utility::outputStreamStringAdapter os(data); cth->extract(os); return data; } void testAddAttachment1() { vmime::string data = "Content-Type: text/plain\r\n" "\r\n" "The text\r\n" ""; vmime::ref msg = vmime::create (); msg->parse(data); vmime::ref att = vmime::create (vmime::create ("test"), vmime::mediaType("image/jpeg")); vmime::attachmentHelper::addAttachment(msg, att); VASSERT_EQ("1", "multipart/mixed[text/plain,image/jpeg]", getStructure(msg)); VASSERT_EQ("2", "The text\r\n", extractBodyContents(msg->getBody()->getPartAt(0))); } void testAddAttachment2() { vmime::string data = "Content-Type: multipart/mixed; boundary=\"foo\"\r\n" "\r\n" "--foo\r\n" "Content-Type: text/plain\r\n" "\r\n" "The text\r\n" "--foo\r\n" "Content-Type: application/octet-stream\r\n" "\r\n" "Blah\r\n" "--foo--\r\n" ""; vmime::ref msg = vmime::create (); msg->parse(data); vmime::ref att = vmime::create (vmime::create ("test"), vmime::mediaType("image/jpeg")); vmime::attachmentHelper::addAttachment(msg, att); VASSERT_EQ("1", "multipart/mixed[text/plain,application/octet-stream,image/jpeg]", getStructure(msg)); VASSERT_EQ("2", "The text", extractBodyContents(msg->getBody()->getPartAt(0))); VASSERT_EQ("3", "Blah", extractBodyContents(msg->getBody()->getPartAt(1))); VASSERT_EQ("4", "test", extractBodyContents(msg->getBody()->getPartAt(2))); } // Initial part is encoded void testAddAttachment3() { vmime::string data = "Content-Type: text/plain\r\n" "Content-Transfer-Encoding: base64\r\n" "\r\n" "TWVzc2FnZSBib2R5"; vmime::ref msg = vmime::create (); msg->parse(data); vmime::ref att = vmime::create (vmime::create ("test"), vmime::mediaType("image/jpeg")); vmime::attachmentHelper::addAttachment(msg, att); VASSERT_EQ("1", "multipart/mixed[text/plain,image/jpeg]", getStructure(msg)); VASSERT_EQ("2", "Message body", extractBodyContents(msg->getBody()->getPartAt(0))); } // Content-Disposition: attachment // No other field void testIsBodyPartAnAttachment1() { vmime::string data = "Content-Disposition: attachment\r\n\r\nFoo\r\n"; vmime::ref p = vmime::create (); p->parse(data); VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p)); } // No Content-Disposition field // Content-Type: multipart/* or text/* void testIsBodyPartAnAttachment2() { vmime::string data = "Content-Type: multipart/*\r\n\r\nFoo\r\n"; vmime::ref p = vmime::create (); p->parse(data); VASSERT_EQ("1", false, vmime::attachmentHelper::isBodyPartAnAttachment(p)); data = "Content-Type: text/*\r\n\r\nFoo\r\n"; p->parse(data); VASSERT_EQ("2", false, vmime::attachmentHelper::isBodyPartAnAttachment(p)); } // No Content-Disposition field void testIsBodyPartAnAttachment3() { vmime::string data = "Content-Type: application/octet-stream\r\n\r\nFoo\r\n"; vmime::ref p = vmime::create (); p->parse(data); VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p)); } // Content-Disposition: attachment // Content-Id field present void testIsBodyPartAnAttachment4() { vmime::string data = "Content-Disposition: attachment\r\n" "Content-Type: application/octet-stream\r\n" "Content-Id: bar\r\n" "\r\nFoo\r\n"; vmime::ref p = vmime::create (); p->parse(data); VASSERT_EQ("1", false, vmime::attachmentHelper::isBodyPartAnAttachment(p)); } void testGetBodyPartAttachment() { vmime::string data = "Content-Type: image/jpeg\r\n" "Content-Description: foobar\r\n" "Content-Transfer-Encoding: x-baz\r\n" "Content-Disposition: attachment; filename=\"foobar.baz\"\r\n" "\r\n" "Foo bar baz"; vmime::ref part = vmime::create (); part->parse(data); vmime::ref att = vmime::attachmentHelper::getBodyPartAttachment(part); VASSERT_EQ("1", "image/jpeg", att->getType().generate()); VASSERT_EQ("2", "foobar", att->getDescription().generate()); VASSERT_EQ("3", "x-baz", att->getEncoding().generate()); VASSERT_EQ("4", "foobar.baz", att->getName().generate()); vmime::string attData; vmime::utility::outputStreamStringAdapter out(attData); att->getData()->extractRaw(out); // 'x-baz' encoding not supported VASSERT_EQ("5", "Foo bar baz", attData); //VASSERT_EQ("6", part, att->getPart()); VASSERT_EQ("6", part->generate(), att->getPart().dynamicCast ()->generate()); //VASSERT_EQ("7", part->getHeader(), att->getHeader()); VASSERT_EQ("7", part->getHeader()->generate(), att->getHeader()->generate()); } void testAddAttachmentMessage1() { const vmime::string data = "Subject: Test message\r\n" "Content-Type: text/plain\r\n" "\r\n" "Message body"; vmime::ref msg = vmime::create (); msg->parse(data); const vmime::string attData = "Subject: Attached message\r\n" "Content-Type: text/plain\r\n" "Content-Transfer-Encoding: base64\r\n" "\r\n" "QXR0YWNoZWQgbWVzc2FnZSBib2R5"; vmime::ref amsg = vmime::create (); amsg->parse(attData); vmime::attachmentHelper::addAttachment(msg, amsg); VASSERT_EQ("1", "multipart/mixed[text/plain,message/rfc822]", getStructure(msg)); VASSERT_EQ("2", "Message body", extractBodyContents(msg->getBody()->getPartAt(0))); // Ensure message has been encoded properly vmime::ref attPart = msg->getBody()->getPartAt(1); vmime::ref attCth = attPart->getBody()->getContents(); vmime::string attDataOut; vmime::utility::outputStreamStringAdapter attDataOutOs(attDataOut); attCth->extract(attDataOutOs); vmime::ref amsgOut = vmime::create (); amsgOut->parse(attDataOut); vmime::ref hdr = amsgOut->getHeader(); VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast ()->generate()); VASSERT_EQ("4", "Attached message body", extractBodyContents(amsgOut)); } void testGetBodyPartAttachmentMessage() { const vmime::string data = "Subject: Test message\r\n" "Content-Type: multipart/mixed; boundary=\"foo\"\r\n" "\r\n" "--foo\r\n" "Content-Type: message/rfc822\r\n" "\r\n" "Subject: Attached message\r\n" "\r\n" "Attached message body\r\n" "--foo\r\n" "Content-Type: text/plain\r\n" "\r\n" "FooBar\r\n" "--foo--\r\n"; vmime::ref msg = vmime::create (); msg->parse(data); VASSERT_EQ("0", 2, msg->getBody()->getPartCount()); vmime::ref att = vmime::attachmentHelper:: getBodyPartAttachment(msg->getBody()->getPartAt(0)); VASSERT("1", att != NULL); vmime::ref msgAtt = att.dynamicCast (); VASSERT("2", msgAtt != NULL); vmime::ref amsg = msgAtt->getMessage(); vmime::ref hdr = amsg->getHeader(); VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast ()->generate()); VASSERT_EQ("4", "Attached message body", extractBodyContents(amsg)); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/htmlTextPartTest.cpp0000644000175000017500000001660611250723263022303 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/htmlTextPart.hpp" #define VMIME_TEST_SUITE htmlTextPartTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParseText) VMIME_TEST(testParseEmbeddedObjectsCID) VMIME_TEST(testParseEmbeddedObjectsLocation) VMIME_TEST_LIST_END static const vmime::string extractContent (vmime::ref cth) { std::ostringstream oss; vmime::utility::outputStreamAdapter osa(oss); cth->extract(osa); return oss.str(); } void testParseText() { const vmime::string msgString = "" "MIME-Version: 1.0\r\n" "Content-Type: multipart/alternative; boundary=\"LEVEL1\"\r\n" "\r\n" "--LEVEL1\r\n" "Content-Type: text/plain; charset=\"x-ch1\"\r\n" "\r\n" "Plain text part\r\n" "--LEVEL1\r\n" "Content-Type: multipart/related; boundary=\"LEVEL2\"\r\n" "\r\n" "--LEVEL2\r\n" "Content-Type: text/html; charset=\"x-ch2\"\r\n" "\r\n" "\r\n" "--LEVEL2\r\n" "Content-Type: image/png; name=\"image.png\"\r\n" "Content-Disposition: inline; filename=\"image.png\"\r\n" "Content-ID: \r\n" "\r\n" "Image\r\n" "--LEVEL2--\r\n" "\r\n" "--LEVEL1--\r\n" ""; vmime::ref msg = vmime::create (); msg->parse(msgString); // Sanity checks VASSERT_EQ("part-count1", 2, msg->getBody()->getPartCount()); VASSERT_EQ("part-count2", 2, msg->getBody()->getPartAt(1)->getBody()->getPartCount()); vmime::htmlTextPart htmlPart; htmlPart.parse(msg, msg->getBody()->getPartAt(1), msg->getBody()->getPartAt(1)->getBody()->getPartAt(0)); VASSERT_EQ("plain", "Plain text part", extractContent(htmlPart.getPlainText())); VASSERT_EQ("html", "", extractContent(htmlPart.getText())); // Should return the charset of the HTML part VASSERT_EQ("charset", "x-ch2", htmlPart.getCharset().generate()); } /** Test parsing of embedded objects by CID (Content-Id). */ void testParseEmbeddedObjectsCID() { const vmime::string msgString = "" "MIME-Version: 1.0\r\n" "Content-Type: multipart/alternative; boundary=\"LEVEL1\"\r\n" "\r\n" "--LEVEL1\r\n" "Content-Type: text/plain; charset=\"x-ch1\"\r\n" "\r\n" "Plain text part\r\n" "--LEVEL1\r\n" "Content-Type: multipart/related; boundary=\"LEVEL2\"\r\n" "\r\n" "--LEVEL2\r\n" // one embedded object before... "Content-Type: image/png; name=\"image1.png\"\r\n" "Content-Disposition: inline; filename=\"image1.png\"\r\n" "Content-ID: \r\n" "\r\n" "Image1\r\n" "--LEVEL2\r\n" // ...the actual text part... "Content-Type: text/html; charset=\"x-ch2\"\r\n" "\r\n" "\r\n" "\r\n" "--LEVEL2\r\n" // ...and one after "Content-Type: image/jpeg; name=\"image2.jpg\"\r\n" "Content-Disposition: inline; filename=\"image2.jpg\"\r\n" "Content-ID: \r\n" "\r\n" "Image2\r\n" "--LEVEL2--\r\n" "\r\n" "--LEVEL1--\r\n" ""; vmime::ref msg = vmime::create (); msg->parse(msgString); // Sanity checks VASSERT_EQ("part-count1", 2, msg->getBody()->getPartCount()); VASSERT_EQ("part-count2", 3, msg->getBody()->getPartAt(1)->getBody()->getPartCount()); vmime::htmlTextPart htmlPart; htmlPart.parse(msg, msg->getBody()->getPartAt(1), msg->getBody()->getPartAt(1)->getBody()->getPartAt(1)); // Two embedded objects should be found. // BUGFIX: "CID:" prefix is not case-sensitive. VASSERT_EQ("count", 2, htmlPart.getObjectCount()); // Ensure the right objects have been found. VASSERT_EQ("has-obj1", true, htmlPart.hasObject("image1@test")); VASSERT_EQ("has-obj2", true, htmlPart.hasObject("image2@test")); // hasObject() should also work with prefixes VASSERT_EQ("has-obj1-pre", true, htmlPart.hasObject("CID:image1@test")); VASSERT_EQ("has-obj2-pre", true, htmlPart.hasObject("cid:image2@test")); // Check data in objects vmime::ref obj; obj = htmlPart.findObject("image1@test"); VASSERT_EQ("id-obj1", "image1@test", obj->getId()); VASSERT_EQ("data-obj1", "Image1", extractContent(obj->getData())); VASSERT_EQ("type-obj1", "image/png", obj->getType().generate()); obj = htmlPart.findObject("image2@test"); VASSERT_EQ("id-obj2", "image2@test", obj->getId()); VASSERT_EQ("data-obj2", "Image2", extractContent(obj->getData())); VASSERT_EQ("type-obj2", "image/jpeg", obj->getType().generate()); } /** Test parsing of embedded objects by location. */ void testParseEmbeddedObjectsLocation() { const vmime::string msgString = "" "MIME-Version: 1.0\r\n" "Content-Type: multipart/alternative; boundary=\"LEVEL1\"\r\n" "\r\n" "--LEVEL1\r\n" "Content-Type: text/plain; charset=\"x-ch1\"\r\n" "\r\n" "Plain text part\r\n" "--LEVEL1\r\n" "Content-Type: multipart/related; boundary=\"LEVEL2\"\r\n" "\r\n" "--LEVEL2\r\n" "Content-Type: image/png; name=\"image1.png\"\r\n" "Content-Location: http://www.vmime.org/test/image1.png\r\n" "Content-Disposition: inline; filename=\"image1.png\"\r\n" "Content-Id: \r\n" "\r\n" "Image1\r\n" "--LEVEL2\r\n" "Content-Type: text/html; charset=\"x-ch2\"\r\n" "\r\n" "\r\n" "--LEVEL2--\r\n" "\r\n" "--LEVEL1--\r\n" ""; vmime::ref msg = vmime::create (); msg->parse(msgString); // Sanity checks VASSERT_EQ("part-count1", 2, msg->getBody()->getPartCount()); VASSERT_EQ("part-count2", 2, msg->getBody()->getPartAt(1)->getBody()->getPartCount()); vmime::htmlTextPart htmlPart; htmlPart.parse(msg, msg->getBody()->getPartAt(1), msg->getBody()->getPartAt(1)->getBody()->getPartAt(1)); // Only one embedded object VASSERT_EQ("count", 1, htmlPart.getObjectCount()); // Should work only with Content-Location as the Content-Id is // not referenced in the HTML contents VASSERT_EQ("has-obj-loc", true, htmlPart.hasObject("http://www.vmime.org/test/image1.png")); VASSERT_EQ("has-obj-cid", false, htmlPart.hasObject("image1@test")); // Check data vmime::ref obj; obj = htmlPart.findObject("http://www.vmime.org/test/image1.png"); VASSERT_EQ("id-obj", "http://www.vmime.org/test/image1.png", obj->getId()); VASSERT_EQ("data-obj", "Image1", extractContent(obj->getData())); VASSERT_EQ("type-obj", "image/png", obj->getType().generate()); } // TODO: test generation of text parts VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/charsetTest.cpp0000644000175000017500000002174511250723263021274 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE charsetTest #define VMIME_TEST_SUITE_MODULE "Parser" // Excerpt from http://www.gnu.org/ static const vmime::charset inputCharset("gb2312"); static const char inputBytes[] = "\xbb\xb6\xd3\xad\xc0\xb4\xb5\xbd\x20\x47\x4e\x55\x20\xb9\xa4\xb3" "\xcc\xb5\xc4\xcd\xf8\xd2\xb3\xcb\xc5\xb7\xfe\xd6\xf7\xbb\xfa\x20" "\x77\x77\x77\x2e\x67\x6e\x75\x2e\x6f\x72\x67\x20\xa1\xa3\x20\x47" "\x4e\x55\x20\xb9\xa4\xb3\xcc\x20\xbf\xaa\xca\xbc\xec\xb6\xd2\xbb" "\xbe\xc5\xb0\xcb\xcb\xc4\xc4\xea\xa3\xac\xd6\xbc\xd4\xda\xb7\xa2" "\xd5\xb9\xd2\xbb\xb8\xf6\xc0\xe0\xcb\xc6\x20\x55\x6e\x69\x78\x20" "\xa3\xac\xc7\xd2\xce\xaa\x20\xd7\xd4\xd3\xc9\xc8\xed\xbc\xfe\x20" "\xb5\xc4\xcd\xea\xd5\xfb\xb2\xd9\xd7\xf7\xcf\xb5\xcd\xb3\xa3\xba" "\x20\x47\x4e\x55\x20\xcf\xb5\xcd\xb3\xa1\xa3\xa3\xa8\x47\x4e\x55" "\x20\xca\xc7\xd3\xc9\xa1\xb0\x47\x4e\x55\x27\x73\x20\x4e\x6f\x74" "\x20\x55\x6e\x69\x78\xa1\xb1\xcb\xf9\xb5\xdd\xbb\xd8\xb6\xa8\xd2" "\xe5\xb3\xf6\xb5\xc4\xca\xd7\xd7\xd6\xc4\xb8\xcb\xf5\xd0\xb4\xd3" "\xef\xa3\xbb\xcb\xfc\xb5\xc4\xb7\xa2\xd2\xf4\xce\xaa\xa1\xb0\x67" "\x75\x68\x2d\x4e\x45\x57\xa1\xb1\xa3\xa9\xa1\xa3\xb8\xf7\xd6\xd6" "\xca\xb9\xd3\xc3\x20\x4c\x69\x6e\x75\x78\x20\xd7\xf7\xce\xaa\xc4" "\xda\xba\xcb\xb5\xc4\x20\x47\x4e\x55\x20\xb2\xd9\xd7\xf7\xcf\xb5" "\xcd\xb3\xd5\xfd\xb1\xbb\xb9\xe3\xb7\xba\xb5\xd8\xca\xb9\xd3\xc3" "\xd6\xf8\xa3\xbb\xcb\xe4\xc8\xbb\xd5\xe2\xd0\xa9\xcf\xb5\xcd\xb3" "\xcd\xa8\xb3\xa3\xb1\xbb\xb3\xc6\xd7\xf7\xce\xaa\xa1\xb0\x4c\x69" "\x6e\x75\x78\xa1\xb1\xa3\xac\xb5\xab\xca\xc7\xcb\xfc\xc3\xc7\xd3" "\xa6\xb8\xc3\xb8\xfc\xbe\xab\xc8\xb7\xb5\xd8\xb1\xbb\xb3\xc6\xce" "\xaa\x20\x47\x4e\x55\x2f\x4c\x69\x6e\x75\x78\x20\xcf\xb5\xcd\xb3" "\x20\xa1\xa3\x0a"; static const vmime::charset outputCharset("utf-8"); static const char outputBytes[] = "\xe6\xac\xa2\xe8\xbf\x8e\xe6\x9d\xa5\xe5\x88\xb0\x20\x47\x4e\x55" "\x20\xe5\xb7\xa5\xe7\xa8\x8b\xe7\x9a\x84\xe7\xbd\x91\xe9\xa1\xb5" "\xe4\xbc\xba\xe6\x9c\x8d\xe4\xb8\xbb\xe6\x9c\xba\x20\x77\x77\x77" "\x2e\x67\x6e\x75\x2e\x6f\x72\x67\x20\xe3\x80\x82\x20\x47\x4e\x55" "\x20\xe5\xb7\xa5\xe7\xa8\x8b\x20\xe5\xbc\x80\xe5\xa7\x8b\xe6\x96" "\xbc\xe4\xb8\x80\xe4\xb9\x9d\xe5\x85\xab\xe5\x9b\x9b\xe5\xb9\xb4" "\xef\xbc\x8c\xe6\x97\xa8\xe5\x9c\xa8\xe5\x8f\x91\xe5\xb1\x95\xe4" "\xb8\x80\xe4\xb8\xaa\xe7\xb1\xbb\xe4\xbc\xbc\x20\x55\x6e\x69\x78" "\x20\xef\xbc\x8c\xe4\xb8\x94\xe4\xb8\xba\x20\xe8\x87\xaa\xe7\x94" "\xb1\xe8\xbd\xaf\xe4\xbb\xb6\x20\xe7\x9a\x84\xe5\xae\x8c\xe6\x95" "\xb4\xe6\x93\x8d\xe4\xbd\x9c\xe7\xb3\xbb\xe7\xbb\x9f\xef\xbc\x9a" "\x20\x47\x4e\x55\x20\xe7\xb3\xbb\xe7\xbb\x9f\xe3\x80\x82\xef\xbc" "\x88\x47\x4e\x55\x20\xe6\x98\xaf\xe7\x94\xb1\xe2\x80\x9c\x47\x4e" "\x55\x27\x73\x20\x4e\x6f\x74\x20\x55\x6e\x69\x78\xe2\x80\x9d\xe6" "\x89\x80\xe9\x80\x92\xe5\x9b\x9e\xe5\xae\x9a\xe4\xb9\x89\xe5\x87" "\xba\xe7\x9a\x84\xe9\xa6\x96\xe5\xad\x97\xe6\xaf\x8d\xe7\xbc\xa9" "\xe5\x86\x99\xe8\xaf\xad\xef\xbc\x9b\xe5\xae\x83\xe7\x9a\x84\xe5" "\x8f\x91\xe9\x9f\xb3\xe4\xb8\xba\xe2\x80\x9c\x67\x75\x68\x2d\x4e" "\x45\x57\xe2\x80\x9d\xef\xbc\x89\xe3\x80\x82\xe5\x90\x84\xe7\xa7" "\x8d\xe4\xbd\xbf\xe7\x94\xa8\x20\x4c\x69\x6e\x75\x78\x20\xe4\xbd" "\x9c\xe4\xb8\xba\xe5\x86\x85\xe6\xa0\xb8\xe7\x9a\x84\x20\x47\x4e" "\x55\x20\xe6\x93\x8d\xe4\xbd\x9c\xe7\xb3\xbb\xe7\xbb\x9f\xe6\xad" "\xa3\xe8\xa2\xab\xe5\xb9\xbf\xe6\xb3\x9b\xe5\x9c\xb0\xe4\xbd\xbf" "\xe7\x94\xa8\xe8\x91\x97\xef\xbc\x9b\xe8\x99\xbd\xe7\x84\xb6\xe8" "\xbf\x99\xe4\xba\x9b\xe7\xb3\xbb\xe7\xbb\x9f\xe9\x80\x9a\xe5\xb8" "\xb8\xe8\xa2\xab\xe7\xa7\xb0\xe4\xbd\x9c\xe4\xb8\xba\xe2\x80\x9c" "\x4c\x69\x6e\x75\x78\xe2\x80\x9d\xef\xbc\x8c\xe4\xbd\x86\xe6\x98" "\xaf\xe5\xae\x83\xe4\xbb\xac\xe5\xba\x94\xe8\xaf\xa5\xe6\x9b\xb4" "\xe7\xb2\xbe\xe7\xa1\xae\xe5\x9c\xb0\xe8\xa2\xab\xe7\xa7\xb0\xe4" "\xb8\xba\x20\x47\x4e\x55\x2f\x4c\x69\x6e\x75\x78\x20\xe7\xb3\xbb" "\xe7\xbb\x9f\x20\xe3\x80\x82\x0a"; VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN // Test valid input VMIME_TEST(testConvertStringValid) VMIME_TEST(testConvertStreamValid) VMIME_TEST(testFilterValid1) VMIME_TEST(testFilterValid2) VMIME_TEST(testFilterValid3) // Test invalid input VMIME_TEST(testFilterInvalid1) // TODO: more tests VMIME_TEST_LIST_END void testConvertStringValid() { vmime::string in(inputBytes, sizeof(inputBytes) - 1); vmime::string expectedOut(outputBytes, sizeof(outputBytes) - 1); vmime::string actualOut; vmime::charset::convert (in, actualOut, inputCharset, outputCharset); VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } void testConvertStreamValid() { vmime::string in(inputBytes, sizeof(inputBytes) - 1); vmime::string expectedOut(outputBytes, sizeof(outputBytes) - 1); vmime::string actualOut; vmime::utility::outputStreamStringAdapter os(actualOut); vmime::utility::inputStreamStringAdapter is(in); vmime::charset::convert (is, os, inputCharset, outputCharset); os.flush(); VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } // Using 'bufferedStreamCopy' void testFilterValid1() { vmime::string in(inputBytes, sizeof(inputBytes) - 1); vmime::string expectedOut(outputBytes, sizeof(outputBytes) - 1); vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); vmime::utility::charsetFilteredOutputStream os (inputCharset, outputCharset, osa); vmime::utility::inputStreamStringAdapter is(in); vmime::utility::bufferedStreamCopy(is, os); os.flush(); VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } // One byte at a time void testFilterValid2() { vmime::string in(inputBytes, sizeof(inputBytes) - 1); vmime::string expectedOut(outputBytes, sizeof(outputBytes) - 1); vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); vmime::utility::charsetFilteredOutputStream os (inputCharset, outputCharset, osa); vmime::utility::inputStreamStringAdapter is(in); vmime::utility::stream::value_type buffer[16]; for (int i = 0 ; !is.eof() ; ++i) os.write(buffer, is.read(buffer, 1)); os.flush(); VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } // Variable chunks void testFilterValid3() { vmime::string in(inputBytes, sizeof(inputBytes) - 1); vmime::string expectedOut(outputBytes, sizeof(outputBytes) - 1); vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); vmime::utility::charsetFilteredOutputStream os (inputCharset, outputCharset, osa); vmime::utility::inputStreamStringAdapter is(in); vmime::utility::stream::value_type buffer[16]; for (int i = 0 ; !is.eof() ; ++i) os.write(buffer, is.read(buffer, (i % 5) + 1)); os.flush(); VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } void testFilterInvalid1() { vmime::string in("foo\xab\xcd\xef bar"); vmime::string expectedOut("foo??? bar"); vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); vmime::utility::charsetFilteredOutputStream os (vmime::charset("utf-8"), vmime::charset("iso-8859-1"), osa); vmime::utility::inputStreamStringAdapter is(in); vmime::utility::stream::value_type buffer[16]; for (int i = 0 ; !is.eof() ; ++i) os.write(buffer, is.read(buffer, 1)); os.flush(); VASSERT_EQ("1", toHex(expectedOut), toHex(actualOut)); } // Conversion to hexadecimal for easier debugging static const vmime::string toHex(const vmime::string str) { static const char hexChars[] = "0123456789abcdef"; vmime::string res = "\n"; for (unsigned int i = 0 ; i < str.length() ; i += 16) { unsigned int r = std::min (static_cast (16), str.length() - i); vmime::string hex; vmime::string chr; for (unsigned int j = 0 ; j < r ; ++j) { const unsigned char c = str[i + j]; hex += hexChars[c / 16]; hex += hexChars[c % 16]; hex += " "; if (c >= 32 && c <= 127) chr += c; else chr += '.'; } for (unsigned int j = r ; j < 16 ; ++j) hex += " "; res += hex + " " + chr + "\n"; } return res; } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/messageIdTest.cpp0000644000175000017500000000377511250723263021547 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE messageIdTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse) VMIME_TEST(testParseInvalid) VMIME_TEST(testGenerate) VMIME_TEST_LIST_END void testParse() { vmime::messageId m1; m1.parse(""); VASSERT_EQ("1.1", "a", m1.getLeft()); VASSERT_EQ("1.2", "b", m1.getRight()); } void testParseInvalid() { vmime::messageId m1; m1.parse("foo@bar"); VASSERT_EQ("1.1", "foo", m1.getLeft()); VASSERT_EQ("1.2", "bar", m1.getRight()); } void testGenerate() { vmime::messageId m1; VASSERT_EQ("1", "<>", m1.generate()); vmime::messageId m2; m2.setLeft("a"); VASSERT_EQ("2", "", m2.generate()); vmime::messageId m3; m3.setRight("b"); VASSERT_EQ("3", "<@b>", m3.generate()); vmime::messageId m4; m4.setLeft("a"); m4.setRight("b"); VASSERT_EQ("4", "", m4.generate()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/parser/textTest.cpp0000644000175000017500000003660111457316027020631 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE textTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testConstructors) VMIME_TEST(testCopy) VMIME_TEST(testNewFromString) VMIME_TEST(testDisplayForm) VMIME_TEST(testParse) VMIME_TEST(testGenerate) VMIME_TEST(testWordConstructors) VMIME_TEST(testWordParse) VMIME_TEST(testWordGenerate) VMIME_TEST(testWordGenerateSpace) VMIME_TEST(testWordGenerateSpace2) VMIME_TEST(testWordGenerateMultiBytes) VMIME_TEST(testWordGenerateQuote) VMIME_TEST(testWordGenerateSpecialCharsets) VMIME_TEST(testWordGenerateSpecials) VMIME_TEST(testWhitespace) VMIME_TEST(testWhitespaceMBox) VMIME_TEST(testFoldingAscii) VMIME_TEST_LIST_END static const vmime::string getDisplayText(const vmime::text& t) { return t.getWholeBuffer(); } static const vmime::string cleanGeneratedWords(const std::string& str) { std::istringstream iss(str); std::string res; std::string x; while (std::getline(iss, x)) res += vmime::utility::stringUtils::trim(x); return res; } void testConstructors() { vmime::text t1; VASSERT_EQ("1.1", 0, t1.getWordCount()); vmime::text t2("Test\xa9\xc3"); VASSERT_EQ("2.1", 1, t2.getWordCount()); VASSERT_EQ("2.2", "Test\xa9\xc3", t2.getWordAt(0)->getBuffer()); VASSERT_EQ("2.3", vmime::charset::getLocaleCharset(), t2.getWordAt(0)->getCharset()); vmime::text t3("Test\xa9\xc3", vmime::charset(vmime::charsets::ISO8859_13)); VASSERT_EQ("3.1", 1, t3.getWordCount()); VASSERT_EQ("3.2", "Test\xa9\xc3", t3.getWordAt(0)->getBuffer()); VASSERT_EQ("3.3", vmime::charset(vmime::charsets::ISO8859_13), t3.getWordAt(0)->getCharset()); vmime::word w1("Test", vmime::charset(vmime::charsets::UTF_8)); vmime::text t4(w1); VASSERT_EQ("4.1", 1, t4.getWordCount()); VASSERT_EQ("4.2", w1.getBuffer(), t4.getWordAt(0)->getBuffer()); VASSERT_EQ("4.3", w1.getCharset(), t4.getWordAt(0)->getCharset()); vmime::word w2("Other", vmime::charset(vmime::charsets::US_ASCII)); t4.appendWord(vmime::create (w2)); vmime::text t5(t4); VASSERT_EQ("5.1", 2, t5.getWordCount()); VASSERT_EQ("5.2", w1.getBuffer(), t5.getWordAt(0)->getBuffer()); VASSERT_EQ("5.3", w1.getCharset(), t5.getWordAt(0)->getCharset()); VASSERT_EQ("5.4", w2.getBuffer(), t5.getWordAt(1)->getBuffer()); VASSERT_EQ("5.5", w2.getCharset(), t5.getWordAt(1)->getCharset()); } void testCopy() { vmime::text t1("Test: \xa9\xc3"); VASSERT("operator==", t1 == t1); VASSERT("clone", *vmime::clone(t1) == t1); vmime::text t2; t2.copyFrom(t1); VASSERT("copyFrom", t1 == t2); } void testNewFromString() { vmime::string s1 = "only ASCII characters"; vmime::charset c1("test"); vmime::text t1; t1.createFromString(s1, c1); VASSERT_EQ("1.1", 1, t1.getWordCount()); VASSERT_EQ("1.2", s1, t1.getWordAt(0)->getBuffer()); VASSERT_EQ("1.3", vmime::charset(vmime::charsets::US_ASCII), t1.getWordAt(0)->getCharset()); vmime::string s2_1 = "some ASCII characters and special chars: "; vmime::string s2_2 = "\xf1\xf2\xf3\xf4 "; vmime::string s2_3 = "and then more ASCII chars."; vmime::string s2 = s2_1 + s2_2 + s2_3; vmime::charset c2("test"); vmime::text t2; t2.createFromString(s2, c2); VASSERT_EQ("2.1", 3, t2.getWordCount()); VASSERT_EQ("2.2", "some ASCII characters and special chars: ", t2.getWordAt(0)->getBuffer()); VASSERT_EQ("2.3", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(0)->getCharset()); VASSERT_EQ("2.4", "\xf1\xf2\xf3\xf4 ", t2.getWordAt(1)->getBuffer()); VASSERT_EQ("2.5", c2, t2.getWordAt(1)->getCharset()); VASSERT_EQ("2.6", "and then more ASCII chars.", t2.getWordAt(2)->getBuffer()); VASSERT_EQ("2.7", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(2)->getCharset()); } static const vmime::string parseText(const vmime::string& buffer) { vmime::text t; t.parse(buffer); std::ostringstream oss; oss << t; return (oss.str()); } void testParse() { // From RFC-2047 VASSERT_EQ("1", "[text: [[word: charset=US-ASCII, buffer=Keith Moore]]]", parseText("=?US-ASCII?Q?Keith_Moore?=")); VASSERT_EQ("2", "[text: [[word: charset=ISO-8859-1, buffer=Keld J\xf8rn Simonsen]]]", parseText("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?=")); VASSERT_EQ("3", "[text: [[word: charset=ISO-8859-1, buffer=Andr\xe9]," \ "[word: charset=us-ascii, buffer= Pirard]]]", parseText("=?ISO-8859-1?Q?Andr=E9?= Pirard")); VASSERT_EQ("4", "[text: [[word: charset=ISO-8859-1, buffer=If you can read this yo]," \ "[word: charset=ISO-8859-2, buffer=u understand the example.]]]", parseText("=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\r\n " \ "=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=")); // Bugfix: in "=?charset?q?=XX=YY?=", the "?=" finish // sequence was not correctly found (should be the one // after '=YY' and not the one after '?q'). VASSERT_EQ("5", "[text: [[word: charset=abc, buffer=\xe9\xe9]]]", parseText("=?abc?q?=E9=E9?=")); // Question marks (?) in the middle of the string VASSERT_EQ("6", "[text: [[word: charset=iso-8859-1, buffer=Know wh\xe4t? It works!]]]", parseText("=?iso-8859-1?Q?Know_wh=E4t?_It_works!?=")); // TODO: add more } void testGenerate() { // TODO } void testDisplayForm() { #define DISPLAY_FORM(x) getDisplayText(*vmime::text::decodeAndUnfold(x)) // From RFC-2047 VASSERT_EQ("1", "a", DISPLAY_FORM("=?ISO-8859-1?Q?a?=")); VASSERT_EQ("2", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a?= b")); VASSERT_EQ("3", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=")); VASSERT_EQ("4", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= \t =?ISO-8859-1?Q?b?=")); VASSERT_EQ("5", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= \r\n \t =?ISO-8859-1?Q?b?=")); VASSERT_EQ("6", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a_b?=")); VASSERT_EQ("7", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=")); // Some more tests... VASSERT_EQ("8", "a b", DISPLAY_FORM(" a =?ISO-8859-1?Q?b?= ")); VASSERT_EQ("9", "a b ", DISPLAY_FORM(" \t =?ISO-8859-1?Q?a?= b ")); VASSERT_EQ("10", "a b", DISPLAY_FORM(" a\r\n\t b")); VASSERT_EQ("11", "a b c", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c")); VASSERT_EQ("12", "a b c ", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c ")); VASSERT_EQ("13", "a b c ", DISPLAY_FORM(" a =?ISO-8859-1?Q?b?= c ")); VASSERT_EQ("14", "a b c d", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c =?ISO-8859-1?Q?d?= ")); VASSERT_EQ("15", "a b c d e", DISPLAY_FORM("a =?ISO-8859-1?Q?b?= c =?ISO-8859-1?Q?d?= e")); // Whitespaces and multiline VASSERT_EQ("16", "a b c d e", DISPLAY_FORM("=?ISO-8859-1?Q?a_b_?=c\n\t=?ISO-8859-1?Q?d_?=e")); #undef DISPLAY_FORM } void testWordConstructors() { VASSERT_EQ("1.1", vmime::charset::getLocaleCharset(), vmime::word().getCharset()); VASSERT_EQ("1.2", "", vmime::word().getBuffer()); VASSERT_EQ("2.1", vmime::charset::getLocaleCharset(), vmime::word("foo").getCharset()); VASSERT_EQ("2.2", "foo", vmime::word("foo").getBuffer()); VASSERT_EQ("3.1", "bar", vmime::word("foo", vmime::charset("bar")).getCharset().getName()); VASSERT_EQ("3.2", "foo", vmime::word("foo", vmime::charset("bar")).getBuffer()); } void testWordParse() { // Simple encoded word vmime::word w1; w1.parse("=?foo?q?bar=E9 baz?="); VASSERT_EQ("1.1", "foo", w1.getCharset().getName()); VASSERT_EQ("1.2", "bar\xe9 baz", w1.getBuffer()); // Unencoded text vmime::word w2; w2.parse(" foo bar \tbaz..."); VASSERT_EQ("2.1", vmime::charset(vmime::charsets::US_ASCII), w2.getCharset()); VASSERT_EQ("2.2", " foo bar \tbaz...", w2.getBuffer()); // Malformed word vmime::word w3; w3.parse("=?foo bar"); VASSERT_EQ("3.1", vmime::charset(vmime::charsets::US_ASCII), w3.getCharset()); VASSERT_EQ("3.2", "=?foo bar", w3.getBuffer()); // Unknown encoding vmime::word w4; w4.parse("=?whatever?not_q_or_b?whatever?="); VASSERT_EQ("4.1", vmime::charset(vmime::charsets::US_ASCII), w4.getCharset()); VASSERT_EQ("4.2", "=?whatever?not_q_or_b?whatever?=", w4.getBuffer()); } void testWordGenerate() { VASSERT_EQ("1", "=?foo?Q?bar=E9_baz?=", vmime::word("bar\xe9 baz", vmime::charset("foo")).generate()); VASSERT_EQ("2", "=?foo?B?8fLz9PU=?=", vmime::word("\xf1\xf2\xf3\xf4\xf5", vmime::charset("foo")).generate()); } void testWordGenerateSpace() { // No white-space between an unencoded word and a encoded one VASSERT_EQ("1", "Bonjour =?utf-8?Q?Fran=C3=A7ois?=", vmime::text::newFromString("Bonjour Fran\xc3\xa7ois", vmime::charset("utf-8"))->generate()); // White-space between two encoded words vmime::text txt; txt.appendWord(vmime::create ("\xc3\x89t\xc3\xa9", "utf-8")); txt.appendWord(vmime::create ("Fran\xc3\xa7ois", "utf-8")); const vmime::string decoded = "\xc3\x89t\xc3\xa9""Fran\xc3\xa7ois"; const vmime::string encoded = "=?utf-8?B?w4l0w6k=?= =?utf-8?Q?Fran=C3=A7ois?="; // -- test encoding VASSERT_EQ("2", encoded, txt.generate()); // -- ensure no space is added when decoding vmime::text txt2; txt2.parse(encoded, 0, encoded.length()); VASSERT_EQ("3", decoded, txt2.getWholeBuffer()); // -- test rencoding VASSERT_EQ("4", encoded, txt2.generate()); } void testWordGenerateSpace2() { // White-space between two encoded words (#2) vmime::text txt; txt.appendWord(vmime::create ("Facture ", "utf-8")); txt.appendWord(vmime::create ("\xc3\xa0", "utf-8")); txt.appendWord(vmime::create (" envoyer ", "utf-8")); txt.appendWord(vmime::create ("\xc3\xa0", "utf-8")); txt.appendWord(vmime::create (" Martine", "utf-8")); const vmime::string decoded = "Facture ""\xc3\xa0"" envoyer ""\xc3\xa0"" Martine"; const vmime::string encoded = "Facture =?utf-8?B?w6A=?= envoyer =?utf-8?B?w6A=?= Martine"; // -- test encoding VASSERT_EQ("1", encoded, txt.generate()); // -- ensure no space is added when decoding vmime::text txt2; txt2.parse(encoded, 0, encoded.length()); VASSERT_EQ("2", decoded, txt2.getWholeBuffer()); // -- test rencoding VASSERT_EQ("3", encoded, txt2.generate()); } void testWordGenerateMultiBytes() { // Ensure we don't encode a non-integral number of characters VASSERT_EQ("1", "=?utf-8?Q?aaa?==?utf-8?Q?=C3=A9?==?utf-8?Q?zzz?=", cleanGeneratedWords(vmime::word("aaa\xc3\xa9zzz", vmime::charset("utf-8")).generate(16))); VASSERT_EQ("2", "=?utf-8?Q?aaa=C3=A9?==?utf-8?Q?zzz?=", cleanGeneratedWords(vmime::word("aaa\xc3\xa9zzz", vmime::charset("utf-8")).generate(17))); } void testWordGenerateQuote() { std::string str; vmime::utility::outputStreamStringAdapter os(str); // ASCII-only text is quotable str.clear(); vmime::word("Quoted text").generate(os, 1000, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL); VASSERT_EQ("1", "\"Quoted text\"", cleanGeneratedWords(str)); // Text with CR/LF is not quotable str.clear(); vmime::word("Non-quotable\ntext", "us-ascii").generate(os, 1000, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL); VASSERT_EQ("2", "=?us-ascii?Q?Non-quotable=0Atext?=", cleanGeneratedWords(str)); // Text with non-ASCII chars is not quotable str.clear(); vmime::word("Non-quotable text \xc3\xa9").generate(os, 1000, 0, NULL, vmime::text::QUOTE_IF_POSSIBLE, NULL); VASSERT_EQ("3", "=?UTF-8?Q?Non-quotable_text_=C3=A9?=", cleanGeneratedWords(str)); } void testWordGenerateSpecialCharsets() { // ISO-2022-JP only uses 7-bit chars but should be encoded in Base64 VASSERT_EQ("1", "=?iso-2022-jp?B?XlskQiVRITwlPSVKJWshJiU9JVUlSCUmJSclIl5bKEI=?=", cleanGeneratedWords(vmime::word("^[$B%Q!<%=%J%k!&%=%U%H%&%'%\"^[(B", vmime::charset("iso-2022-jp")).generate(100))); } void testWordGenerateSpecials() { // In RFC-2047, quotation marks (ASCII 22h) should be encoded VASSERT_EQ("1", "=?UTF-8?Q?=22=C3=9Cml=C3=A4ute=22?=", vmime::word("\x22\xC3\x9Cml\xC3\xA4ute\x22", vmime::charset("UTF-8")).generate()); } void testWhitespace() { // Create vmime::text text; text.createFromString("Achim Br\xc3\xa4ndt", vmime::charsets::UTF_8); VASSERT_EQ("1", 2, text.getWordCount()); VASSERT_EQ("2", "Achim ", text.getWordAt(0)->getBuffer()); VASSERT_EQ("3", "us-ascii", text.getWordAt(0)->getCharset()); VASSERT_EQ("4", "Br\xc3\xa4ndt", text.getWordAt(1)->getBuffer()); VASSERT_EQ("5", "utf-8", text.getWordAt(1)->getCharset()); // Generate VASSERT_EQ("6", "Achim =?utf-8?Q?Br=C3=A4ndt?=", text.generate()); // Parse text.parse("=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?="); VASSERT_EQ("7", 2, text.getWordCount()); VASSERT_EQ("8", "Achim ", text.getWordAt(0)->getBuffer()); VASSERT_EQ("9", "us-ascii", text.getWordAt(0)->getCharset()); VASSERT_EQ("10", "Br\xc3\xa4ndt", text.getWordAt(1)->getBuffer()); VASSERT_EQ("11", "utf-8", text.getWordAt(1)->getCharset()); } void testWhitespaceMBox() { // Space MUST be encoded inside a word vmime::mailbox mbox(vmime::text("Achim Br\xc3\xa4ndt", vmime::charsets::UTF_8), "me@vmime.org"); VASSERT_EQ("generate1", "=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?= ", mbox.generate()); vmime::text txt; txt.appendWord(vmime::create ("Achim ", "us-ascii")); txt.appendWord(vmime::create ("Br\xc3\xa4ndt", "utf-8")); mbox = vmime::mailbox(txt, "me@vmime.org"); VASSERT_EQ("generate2", "=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?= ", mbox.generate()); mbox.parse("=?us-ascii?Q?Achim?= =?utf-8?Q?Br=C3=A4ndt?= "); VASSERT_EQ("parse.name.count", 2, mbox.getName().getWordCount()); VASSERT_EQ("parse.name.word1.buffer", "Achim", mbox.getName().getWordAt(0)->getBuffer()); VASSERT_EQ("parse.name.word1.charset", "us-ascii", mbox.getName().getWordAt(0)->getCharset()); VASSERT_EQ("parse.name.word2.buffer", "Br\xc3\xa4ndt", mbox.getName().getWordAt(1)->getBuffer()); VASSERT_EQ("parse.name.word2.charset", "utf-8", mbox.getName().getWordAt(1)->getCharset()); VASSERT_EQ("parse.email", "me@vmime.org", mbox.getEmail()); } void testFoldingAscii() { // In this test, no encoding is needed, but line should be folded anyway vmime::word w("01234567890123456789012345678901234567890123456789" "01234567890123456789012345678901234567890123456789", vmime::charset("us-ascii")); VASSERT_EQ("fold.ascii", "=?us-ascii?Q?01234567890123456789012345678901234?=\r\n" " =?us-ascii?Q?5678901234567890123456789012345678?=\r\n" " =?us-ascii?Q?9012345678901234567890123456789?=", w.generate(50)); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/testRunner.cpp0000644000175000017500000001350611250723263017654 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" class Clock { public: void reset() { struct timezone tz; gettimeofday(&m_start, &tz); } double getDuration() const { struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); return static_cast (tv.tv_sec - m_start.tv_sec) + static_cast (tv.tv_usec - m_start.tv_usec) / 1000000.0; } private: struct timeval m_start; }; class XmlTestListener : public CppUnit::TestListener { public: XmlTestListener() : m_doc("utf-8"), m_testElt(NULL) { m_doc.setRootElement(new CppUnit::XmlElement("TestRun")); } void startTest(CppUnit::Test* test) { m_testElt = new CppUnit::XmlElement("Test"); m_suiteElt.back()->addElement(m_testElt); m_testElt->addElement(new CppUnit::XmlElement("Name", test->getName())); m_chrono.reset(); } void addFailure(const CppUnit::TestFailure& failure) { CppUnit::XmlElement* failElt = new CppUnit::XmlElement("Failure"); m_testElt->addElement(failElt); failElt->addElement(new CppUnit::XmlElement("FailureType", failure.isError() ? "Error" : "Assertion")); if (failure.sourceLine().isValid()) { CppUnit::XmlElement* locElt = new CppUnit::XmlElement("Location"); failElt->addElement(locElt); locElt->addElement(new CppUnit::XmlElement("File", failure.sourceLine().fileName())); locElt->addElement(new CppUnit::XmlElement("Line", failure.sourceLine().lineNumber())); } CppUnit::XmlElement* exElt = new CppUnit::XmlElement("Exception"); failElt->addElement(exElt); exElt->addElement(new CppUnit::XmlElement("Message", failure.thrownException()->what())); } void endTest(CppUnit::Test* /* test */) { std::ostringstream ossTime; ossTime << (m_chrono.getDuration() * 1000.0); m_testElt->addElement(new CppUnit::XmlElement("Time", ossTime.str())); m_testElt = NULL; } void startSuite(CppUnit::Test* suite) { if (suite->getName() == "All Tests") return; CppUnit::XmlElement* suiteElt = new CppUnit::XmlElement("Suite"); if (m_suiteElt.size() == 0) m_doc.rootElement().addElement(suiteElt); else m_suiteElt.back()->addElement(suiteElt); m_suiteElt.push_back(suiteElt); suiteElt->addElement(new CppUnit::XmlElement("Name", suite->getName())); } void endSuite(CppUnit::Test* /* suite */) { if (m_suiteElt.size()) m_suiteElt.pop_back(); } void startTestRun(CppUnit::Test* /* test */, CppUnit::TestResult* /* eventManager */) { } void endTestRun(CppUnit::Test* /* test */, CppUnit::TestResult* /* eventManager */) { } void output(std::ostream& os) { os << m_doc.toString(); } private: Clock m_chrono; CppUnit::XmlDocument m_doc; std::vector m_suiteElt; CppUnit::XmlElement* m_testElt; }; // see testUtils.hpp std::vector & getTestModules() { static std::vector allModules; return allModules; } void registerTestModule(const char* name_) { std::vector & testModules = getTestModules(); std::string name(name_); if (std::find(testModules.begin(), testModules.end(), name) == testModules.end()) testModules.push_back(name); } int main(int argc, char* argv[]) { // VMime initialization vmime::platform::setHandler(); // Parse arguments bool xmlOutput = false; for (int c = 1 ; c < argc ; ++c) { const std::string arg = argv[c]; if (arg == "--xml") xmlOutput = true; } // Run the tests if (xmlOutput) { // Get the test suites from the registry and add them to the list of tests to run CppUnit::TestRunner runner; for (unsigned int i = 0 ; i < getTestModules().size() ; ++i) { runner.addTest(CppUnit::TestFactoryRegistry:: getRegistry(getTestModules()[i]).makeTest()); } std::auto_ptr xmlListener(new XmlTestListener); CppUnit::TestResult controller; controller.addListener(xmlListener.get()); CppUnit::TestResultCollector result; controller.addListener(&result); runner.run(controller); xmlListener->output(std::cout); // Return error code 1 if a test failed return result.wasSuccessful() ? 0 : 1; } else { // Get the top level suite from the registry CppUnit::TextUi::TestRunner runner; runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); return runner.run() ? 0 : 1; } } libvmime-0.9.1/tests/utility/0000755000175000017500000000000011607302336016475 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/utility/stringProxyTest.cpp0000644000175000017500000001244111250723263022413 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE stringProxyTest #define VMIME_TEST_SUITE_MODULE "Utility" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testConstruct) VMIME_TEST(testConstruct2) VMIME_TEST(testDetach) VMIME_TEST(testSet) VMIME_TEST(testExtract) VMIME_TEST(testOperatorLTLT1) VMIME_TEST(testOperatorLTLT2) VMIME_TEST_LIST_END void testConstruct() { vmime::utility::stringProxy s; VASSERT_EQ("1", static_cast (0), s.length()); VASSERT_EQ("2", static_cast (0), s.start()); VASSERT_EQ("3", static_cast (0), s.end()); } void testConstruct2() { vmime::string str("This is a test string."); vmime::utility::stringProxy s1(str); VASSERT_EQ("1", str.length(), s1.length()); VASSERT_EQ("2", static_cast (0), s1.start()); VASSERT_EQ("3", str.length(), s1.end()); vmime::utility::stringProxy s2(str, 10); VASSERT_EQ("4", str.length() - 10, s2.length()); VASSERT_EQ("5", static_cast (10), s2.start()); VASSERT_EQ("6", str.length(), s2.end()); vmime::utility::stringProxy s3(str, 10, 14); VASSERT_EQ("7", static_cast (4), s3.length()); VASSERT_EQ("8", static_cast (10), s3.start()); VASSERT_EQ("9", static_cast (14), s3.end()); VASSERT_EQ("10", 't', *s3.it_begin()); VASSERT_EQ("11", 'e', *(s3.it_begin() + 1)); VASSERT_EQ("12", 's', *(s3.it_begin() + 2)); VASSERT_EQ("13", 't', *(s3.it_begin() + 3)); } void testDetach() { vmime::utility::stringProxy s; s = "foo"; s.detach(); VASSERT_EQ("1", static_cast (0), s.length()); VASSERT_EQ("2", static_cast (0), s.start()); VASSERT_EQ("3", static_cast (0), s.end()); } void testSet() { vmime::string str("This is a test string."); vmime::utility::stringProxy s1; s1.set(str); VASSERT_EQ("1", str.length(), s1.length()); VASSERT_EQ("2", static_cast (0), s1.start()); VASSERT_EQ("3", str.length(), s1.end()); vmime::utility::stringProxy s2; s2.set(str, 10); VASSERT_EQ("4", str.length() - 10, s2.length()); VASSERT_EQ("5", static_cast (10), s2.start()); VASSERT_EQ("6", str.length(), s2.end()); vmime::utility::stringProxy s3; s3.set(str, 10, 14); VASSERT_EQ("7", static_cast (4), s3.length()); VASSERT_EQ("8", static_cast (10), s3.start()); VASSERT_EQ("9", static_cast (14), s3.end()); VASSERT_EQ("10", 't', *s3.it_begin()); VASSERT_EQ("11", 'e', *(s3.it_begin() + 1)); VASSERT_EQ("12", 's', *(s3.it_begin() + 2)); VASSERT_EQ("13", 't', *(s3.it_begin() + 3)); } void testExtract() { vmime::string str("This is a test string."); vmime::utility::stringProxy s1(str, 10, 14); std::ostringstream oss1; vmime::utility::outputStreamAdapter osa1(oss1); s1.extract(osa1); VASSERT_EQ("1", "test", oss1.str()); vmime::utility::stringProxy s2(str); std::ostringstream oss2; vmime::utility::outputStreamAdapter osa2(oss2); s2.extract(osa2); VASSERT_EQ("2", str, oss2.str()); } void testOperatorLTLT1() { vmime::string str("This is a test string."); vmime::utility::stringProxy s1(str, 10, 14); std::ostringstream oss1; oss1 << s1; VASSERT_EQ("1", "test", oss1.str()); vmime::utility::stringProxy s2(str); std::ostringstream oss2; oss2 << s2; VASSERT_EQ("2", str, oss2.str()); } void testOperatorLTLT2() { vmime::string str("This is a test string."); vmime::utility::stringProxy s1(str, 10, 14); std::ostringstream oss1; vmime::utility::outputStreamAdapter osa1(oss1); osa1 << s1; VASSERT_EQ("1", "test", oss1.str()); vmime::utility::stringProxy s2(str); std::ostringstream oss2; vmime::utility::outputStreamAdapter osa2(oss2); osa2 << s2; VASSERT_EQ("2", str, oss2.str()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/utility/urlTest.cpp0000644000175000017500000002451111250723263020646 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/utility/url.hpp" #include "vmime/utility/urlUtils.hpp" #define VMIME_TEST_SUITE urlTest #define VMIME_TEST_SUITE_MODULE "Utility" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testParse1) VMIME_TEST(testParse2) VMIME_TEST(testParse3) VMIME_TEST(testParse4) VMIME_TEST(testParse5) VMIME_TEST(testGenerate) VMIME_TEST(testUtilsEncode) VMIME_TEST(testUtilsDecode) VMIME_TEST(testUtilsDecodeSpecialCases) VMIME_TEST(testUtilsEncodeReservedChars) VMIME_TEST(testUtilsEncodeUnsafeChars) VMIME_TEST_LIST_END static bool parseHelper(vmime::utility::url& u, const vmime::string& str) { try { u = vmime::utility::url(str); } catch (vmime::exceptions::malformed_url) { return false; } return true; } void testParse1() { // Test some valid constructions vmime::utility::url u1("", ""); VASSERT_EQ("1.1", true, parseHelper(u1, "protocol://user:password@host:12345/path/")); VASSERT_EQ("1.2", "protocol", u1.getProtocol()); VASSERT_EQ("1.3", "user", u1.getUsername()); VASSERT_EQ("1.4", "password", u1.getPassword()); VASSERT_EQ("1.5", "host", u1.getHost()); VASSERT_EQ("1.6", 12345, u1.getPort()); VASSERT_EQ("1.7", "/path/", u1.getPath()); vmime::utility::url u2("", ""); VASSERT_EQ("2.1", true, parseHelper(u2, "protocol://user@host:12345/path/")); VASSERT_EQ("2.2", "protocol", u2.getProtocol()); VASSERT_EQ("2.3", "user", u2.getUsername()); VASSERT_EQ("2.4", "", u2.getPassword()); VASSERT_EQ("2.5", "host", u2.getHost()); VASSERT_EQ("2.6", 12345, u2.getPort()); VASSERT_EQ("2.7", "/path/", u2.getPath()); vmime::utility::url u3("", ""); VASSERT_EQ("3.1", true, parseHelper(u3, "protocol://host:12345/path/")); VASSERT_EQ("3.2", "protocol", u3.getProtocol()); VASSERT_EQ("3.3", "", u3.getUsername()); VASSERT_EQ("3.4", "", u3.getPassword()); VASSERT_EQ("3.5", "host", u3.getHost()); VASSERT_EQ("3.6", 12345, u3.getPort()); VASSERT_EQ("3.7", "/path/", u3.getPath()); vmime::utility::url u4("", ""); VASSERT_EQ("4.1", true, parseHelper(u4, "protocol://host/path/")); VASSERT_EQ("4.2", "protocol", u4.getProtocol()); VASSERT_EQ("4.3", "", u4.getUsername()); VASSERT_EQ("4.4", "", u4.getPassword()); VASSERT_EQ("4.5", "host", u4.getHost()); VASSERT_EQ("4.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); VASSERT_EQ("4.7", "/path/", u4.getPath()); vmime::utility::url u5("", ""); VASSERT_EQ("5.1", true, parseHelper(u5, "protocol://host/")); VASSERT_EQ("5.2", "protocol", u5.getProtocol()); VASSERT_EQ("5.3", "", u5.getUsername()); VASSERT_EQ("5.4", "", u5.getPassword()); VASSERT_EQ("5.5", "host", u5.getHost()); VASSERT_EQ("5.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); VASSERT_EQ("5.7", "", u5.getPath()); vmime::utility::url u6("", ""); VASSERT_EQ("6.1", true, parseHelper(u4, "protocol://host/path/file")); VASSERT_EQ("6.2", "protocol", u4.getProtocol()); VASSERT_EQ("6.3", "", u4.getUsername()); VASSERT_EQ("6.4", "", u4.getPassword()); VASSERT_EQ("6.5", "host", u4.getHost()); VASSERT_EQ("6.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); VASSERT_EQ("6.7", "/path/file", u4.getPath()); } void testParse2() { // Now, test some ill-formed URLs // -- missing protocol vmime::utility::url u1("", ""); VASSERT_EQ("1", false, parseHelper(u1, "://host")); // -- port can contain only digits vmime::utility::url u2("", ""); VASSERT_EQ("2", false, parseHelper(u2, "proto://host:abc123")); // -- no host specified vmime::utility::url u3("", ""); VASSERT_EQ("3", false, parseHelper(u3, "proto:///path")); // -- no protocol separator (://) vmime::utility::url u4("", ""); VASSERT_EQ("4", false, parseHelper(u4, "protohost/path")); } void testParse3() { // Test decoding vmime::utility::url u1("", ""); VASSERT_EQ("1.1", true, parseHelper(u1, "pro%12to://user%34:pass%56word@ho%78st:12345/pa%abth/")); VASSERT_EQ("1.2", "pro%12to", u1.getProtocol()); // protocol should not be decoded VASSERT_EQ("1.3", "user\x34", u1.getUsername()); VASSERT_EQ("1.4", "pass\x56word", u1.getPassword()); VASSERT_EQ("1.5", "ho\x78st", u1.getHost()); VASSERT_EQ("1.6", 12345, u1.getPort()); VASSERT_EQ("1.7", "/pa\xabth/", u1.getPath()); } void testParse4() { // Test parameters vmime::utility::url u1("", ""); VASSERT_EQ("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2")); VASSERT_EQ("1.2", "v1", u1.getParams().getProperty ("p1")); VASSERT_EQ("1.3", "v2", u1.getParams().getProperty ("p2")); VASSERT_EQ("1.4", "/path", u1.getPath()); vmime::utility::url u2("", ""); VASSERT_EQ("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2")); VASSERT_EQ("2.2", "v1", u2.getParams().getProperty ("p1")); VASSERT_EQ("2.3", "p2", u2.getParams().getProperty ("p2")); VASSERT_EQ("2.4", "/path", u2.getPath()); vmime::utility::url u3("", ""); VASSERT_EQ("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2")); VASSERT_EQ("3.2", "v1", u3.getParams().getProperty ("p1")); VASSERT_EQ("3.3", "v2", u3.getParams().getProperty ("p2")); VASSERT_EQ("3.4", "", u3.getPath()); vmime::utility::url u4("", ""); VASSERT_EQ("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2")); VASSERT_EQ("4.2", "=", u4.getParams().getProperty ("p1")); VASSERT_EQ("4.3", "v2", u4.getParams().getProperty ("=")); VASSERT_EQ("4.4", "/path", u4.getPath()); } // '@' symbol in the username part void testParse5() { vmime::utility::url u1("", ""); VASSERT_EQ("1", true, parseHelper(u1, "imap://account@myserver.com:password@myserver.com")); VASSERT_EQ("2", "account@myserver.com", u1.getUsername()); VASSERT_EQ("3", "password", u1.getPassword()); VASSERT_EQ("4", "myserver.com", u1.getHost()); } void testGenerate() { vmime::utility::url u1("proto", "host", 12345, "path", "user", "password"); VASSERT_EQ("1", "proto://user:password@host:12345/path", static_cast (u1)); vmime::utility::url u2("proto", "host"); VASSERT_EQ("2", "proto://host", static_cast (u2)); vmime::utility::url u3("proto", "host"); u3.getParams().setProperty("p1", "v1"); VASSERT_EQ("3.1", "proto://host/?p1=v1", static_cast (u3)); u3.getParams().setProperty("p2", "v2"); VASSERT_EQ("3.2", "proto://host/?p1=v1&p2=v2", static_cast (u3)); u3.getParams().setProperty("&", "="); VASSERT_EQ("3.3", "proto://host/?p1=v1&p2=v2&%26=%3D", static_cast (u3)); } void testUtilsEncode() { VASSERT_EQ("1", "%01", vmime::utility::urlUtils::encode("\x01")); VASSERT_EQ("2", "%20", vmime::utility::urlUtils::encode(" ")); VASSERT_EQ("3", "%FF", vmime::utility::urlUtils::encode("\xff")); VASSERT_EQ("4", "a", vmime::utility::urlUtils::encode("a")); } void testUtilsDecode() { for (int i = 0 ; i < 255 ; ++i) { std::ostringstream ossTest; ossTest << "%" << "0123456789ABCDEF"[i / 16] << "0123456789ABCDEF"[i % 16]; std::ostringstream ossNum; ossNum << i; vmime::string res; res += static_cast (i); VASSERT_EQ(ossNum.str(), res, vmime::utility::urlUtils::decode(ossTest.str())); } } void testUtilsDecodeSpecialCases() { // Bug #1656547: segfault with '%' at the end of the string VASSERT_EQ("1.1", "sadfsda%", vmime::utility::urlUtils::decode("sadfsda%")); VASSERT_EQ("1.2", "sadfsda\x05", vmime::utility::urlUtils::decode("sadfsda%5")); VASSERT_EQ("1.3", "sadfsda\x42", vmime::utility::urlUtils::decode("sadfsda%42")); } void testUtilsEncodeReservedChars() { VASSERT_EQ("1", "%24", vmime::utility::urlUtils::encode("$")); VASSERT_EQ("2", "%26", vmime::utility::urlUtils::encode("&")); VASSERT_EQ("3", "%2B", vmime::utility::urlUtils::encode("+")); VASSERT_EQ("4", "%2C", vmime::utility::urlUtils::encode(",")); VASSERT_EQ("5", "%2F", vmime::utility::urlUtils::encode("/")); VASSERT_EQ("6", "%3A", vmime::utility::urlUtils::encode(":")); VASSERT_EQ("7", "%3B", vmime::utility::urlUtils::encode(";")); VASSERT_EQ("8", "%3D", vmime::utility::urlUtils::encode("=")); VASSERT_EQ("9", "%3F", vmime::utility::urlUtils::encode("?")); VASSERT_EQ("10", "%40", vmime::utility::urlUtils::encode("@")); } void testUtilsEncodeUnsafeChars() { VASSERT_EQ("1", "%20", vmime::utility::urlUtils::encode(" ")); VASSERT_EQ("2", "%22", vmime::utility::urlUtils::encode("\"")); VASSERT_EQ("3", "%3C", vmime::utility::urlUtils::encode("<")); VASSERT_EQ("4", "%3E", vmime::utility::urlUtils::encode(">")); VASSERT_EQ("5", "%23", vmime::utility::urlUtils::encode("#")); VASSERT_EQ("6", "%25", vmime::utility::urlUtils::encode("%")); VASSERT_EQ("7", "%7B", vmime::utility::urlUtils::encode("{")); VASSERT_EQ("8", "%7D", vmime::utility::urlUtils::encode("}")); VASSERT_EQ("9", "%7C", vmime::utility::urlUtils::encode("|")); VASSERT_EQ("10", "%5C", vmime::utility::urlUtils::encode("\\")); VASSERT_EQ("11", "%5E", vmime::utility::urlUtils::encode("^")); VASSERT_EQ("12", "%7E", vmime::utility::urlUtils::encode("~")); VASSERT_EQ("13", "%5B", vmime::utility::urlUtils::encode("[")); VASSERT_EQ("14", "%5D", vmime::utility::urlUtils::encode("]")); VASSERT_EQ("15", "%60", vmime::utility::urlUtils::encode("`")); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/utility/smartPtrTest.cpp0000644000175000017500000001327111250723263021661 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/utility/smartPtr.hpp" #define VMIME_TEST_SUITE smartPtrTest #define VMIME_TEST_SUITE_MODULE "Utility" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testNull) VMIME_TEST(testRefCounting) VMIME_TEST(testWeakRef) VMIME_TEST(testCast) VMIME_TEST(testContainer) VMIME_TEST(testCompare) VMIME_TEST_LIST_END struct A : public vmime::object { int strongCount() const { return getRefManager()->getStrongRefCount(); } int weakCount() const { return getRefManager()->getWeakRefCount(); } }; struct B : public virtual A { }; struct C : public virtual A { }; struct D : public B, public C { }; class R : public A { public: R(bool* aliveFlag) : m_aliveFlag(aliveFlag) { *m_aliveFlag = true; } ~R() { *m_aliveFlag = false; } private: bool* m_aliveFlag; }; void testNull() { vmime::ref r1; VASSERT("1", r1 == NULL); VASSERT("2", r1 == 0); VASSERT("3", NULL == r1); VASSERT("4", 0 == r1); VASSERT("5", !r1); VASSERT("6", r1 == vmime::null); VASSERT("7", vmime::null == r1); VASSERT_EQ("8", static_cast (0), r1.get()); } void testRefCounting() { bool o1_alive; vmime::ref r1 = vmime::create (&o1_alive); VASSERT("1", r1.get() != 0); VASSERT("2", o1_alive); VASSERT_EQ("3", 1, r1->strongCount()); VASSERT_EQ("4", 1, r1->weakCount()); vmime::ref r2 = r1; VASSERT("5", o1_alive); VASSERT_EQ("6", 2, r1->strongCount()); VASSERT_EQ("7", 2, r1->weakCount()); bool o2_alive; vmime::ref r3 = vmime::create (&o2_alive); r2 = r3; VASSERT("8", o1_alive); VASSERT("9", o2_alive); VASSERT_EQ("10", 1, r1->strongCount()); VASSERT_EQ("11", 2, r2->strongCount()); VASSERT_EQ("12", 2, r3->strongCount()); { vmime::ref r4; r4 = r1; VASSERT("13", o1_alive); VASSERT("14", o2_alive); VASSERT_EQ("15", 2, r4->strongCount()); VASSERT_EQ("16", 2, r1->strongCount()); r1 = NULL; VASSERT("17", o1_alive); VASSERT("18", o2_alive); VASSERT_EQ("19", 1, r4->strongCount()); // Here, object1 will be deleted } VASSERT("20", !o1_alive); VASSERT("21", o2_alive); { vmime::weak_ref w1 = r3; VASSERT_EQ("22", 3, r3->weakCount()); } VASSERT("23", o2_alive); VASSERT_EQ("24", 2, r3->strongCount()); VASSERT_EQ("25", 2, r3->weakCount()); } void testWeakRef() { vmime::ref r1 = vmime::create (); vmime::weak_ref w1 = r1; VASSERT("1", r1.get() != 0); VASSERT("2", r1.get() == w1.acquire().get()); { vmime::ref r2 = r1; VASSERT("3", r1.get() == r2.get()); VASSERT("4", r1.get() == w1.acquire().get()); } VASSERT("5", r1.get() != 0); VASSERT("6", r1.get() == w1.acquire().get()); r1 = 0; VASSERT("7", w1.acquire().get() == 0); } void testCast() { // Explicit upcast vmime::ref r1 = vmime::create (); vmime::ref r2 = r1.dynamicCast (); VASSERT("1", r2.get() == dynamic_cast (r1.get())); VASSERT("2", 0 == r1.dynamicCast ().get()); // Implicit downcast vmime::ref r3 = vmime::create (); vmime::ref r4 = r3; VASSERT("3", r4.get() == dynamic_cast (r3.get())); } void testContainer() { bool o1_alive; vmime::ref r1 = vmime::create (&o1_alive); bool o2_alive; vmime::ref r2 = vmime::create (&o2_alive); std::vector > v1; v1.push_back(r1); v1.push_back(r2); VASSERT("1", o1_alive); VASSERT_EQ("2", 2, r1->strongCount()); VASSERT("3", o2_alive); VASSERT_EQ("4", 2, r2->strongCount()); { std::vector > v2 = v1; VASSERT("5", o1_alive); VASSERT_EQ("6", 3, r1->strongCount()); VASSERT("7", o2_alive); VASSERT_EQ("8", 3, r2->strongCount()); v2[1] = NULL; VASSERT("9", o1_alive); VASSERT_EQ("10", 3, r1->strongCount()); VASSERT("11", o2_alive); VASSERT_EQ("12", 2, r2->strongCount()); } VASSERT("13", o1_alive); VASSERT_EQ("14", 2, r1->strongCount()); VASSERT("15", o2_alive); VASSERT_EQ("16", 2, r2->strongCount()); } void testCompare() { vmime::ref r1 = vmime::create (); vmime::ref r2 = vmime::create (); vmime::ref r3 = vmime::create (); vmime::ref r4 = r1; VASSERT("1", r1 != r2); VASSERT("2", r1.get() == r1); VASSERT("3", r1 == r1.get()); VASSERT("4", r2 != r1.get()); VASSERT("5", r1.get() != r2); VASSERT("6", r1 == r4); VASSERT("7", r1.get() == r4); std::vector > v; v.push_back(r1); v.push_back(r2); VASSERT("8", std::find(v.begin(), v.end(), r1) == v.begin()); VASSERT("9", std::find(v.begin(), v.end(), r2) == v.begin() + 1); VASSERT("10", std::find(v.begin(), v.end(), r3) == v.end()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/utility/encoderTest.cpp0000644000175000017500000002654711455025734021503 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #define VMIME_TEST_SUITE encoderTest #define VMIME_TEST_SUITE_MODULE "Parser" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testBase64) VMIME_TEST(testQuotedPrintable) VMIME_TEST(testQuotedPrintable_RFC2047) VMIME_TEST_LIST_END // Encoding helper function static const vmime::string encode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet()) { vmime::ref enc = vmime::utility::encoder::encoderFactory::getInstance()->create(name); enc->getProperties() = props; if (maxLineLength != 0) enc->getProperties()["maxlinelength"] = maxLineLength; vmime::utility::inputStreamStringAdapter vin(in); std::ostringstream out; vmime::utility::outputStreamAdapter vout(out); enc->encode(vin, vout); return (out.str()); } // Decoding helper function static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) { vmime::ref enc = vmime::utility::encoder::encoderFactory::getInstance()->create(name); if (maxLineLength != 0) enc->getProperties()["maxlinelength"] = maxLineLength; vmime::utility::inputStreamStringAdapter vin(in); std::ostringstream out; vmime::utility::outputStreamAdapter vout(out); enc->decode(vin, vout); return (out.str()); } void testBase64() { static const vmime::string testSuites[] = { // Test 1 "", "", // Test 2 "A", "QQ==", // Test 3 "AB", "QUI=", // Test 4 "ABC", "QUJD", // Test 5 "foo", "Zm9v", // Test 6 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAx" "MjM0NTY3ODk=", // Test 7 vmime::string( "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", 256), "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1" "Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWpr" "bG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6Ch" "oqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX" "2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" }; for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) { const vmime::string decoded = testSuites[i * 2]; const vmime::string encoded = testSuites[i * 2 + 1]; std::ostringstream oss; oss << "[Base64] Test " << (i + 1) << ": "; // Encoding VASSERT_EQ(oss.str() + "encoding", encoded, encode("base64", decoded)); // Decoding VASSERT_EQ(oss.str() + "decoding", decoded, decode("base64", encoded)); // Multiple and successive encoding/decoding VASSERT_EQ(oss.str() + "multiple1", decoded, decode("base64", encode("base64", decoded))); VASSERT_EQ(oss.str() + "multiple2", decoded, decode("base64", decode("base64", encode("base64", encode("base64", decoded))))); VASSERT_EQ(oss.str() + "multiple3", decoded, decode("base64", decode("base64", decode("base64", encode("base64", encode("base64", encode("base64", decoded))))))); VASSERT_EQ(oss.str() + "multiple4", decoded, decode("base64", decode("base64", decode("base64", decode("base64", encode("base64", encode("base64", encode("base64", encode("base64", decoded))))))))); } } void testQuotedPrintable() { static const vmime::string testSuites[] = { // Test 1 "", "", // Test 2 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", // Test 3 "0123456789012345678901234567890123456789012345678901234567890123456789012" "3456789012345678901234567890123456789012345678901234567890123456789012345" "6789", "0123456789012345678901234567890123456789012345678901234567890123456789012=\r\n" "3456789012345678901234567890123456789012345678901234567890123456789012345=\r\n" "6789", // Test 4 vmime::string( "\x89\xe8\x24\x04\x2f\xe8\xff\xfb\xeb\xff\x90\xd7\x74\x8d\x00\x26\x89\x55" "\x83\xe5\x08\xec\x04\xc7\xa0\x24\x05\xa2\xe8\x08\x43\xee\x00\x00\xc0\x85" "\x0a\x74\xec\x89\xc3\x5d\xb6\x8d\x00\x00\x00\x00\x04\xc7\xa8\x24\x05\xa2" "\xe8\x08\x43\xd4\x00\x00\xe8\xeb\xf6\x89\x89\x55\x81\xe5\xa8\xec\x00\x00" "\x89\x00\xfc\x75\x75\x8b\x89\x08\xf8\x5d\xb9\xe8\xff\xff\x83\xff\x14\xfe" "\x47\x74\xc0\x31\x9d\x8d\xff\x68\xff\xff\x85\x89\xff\x68\xff\xff\x85\x8d" "\xff\x6c\xff\xff\x04\x89\xe8\x24\xfa\x50\xff\xff\x45\xc7\x00\xec\x00\x00" "\x31\x00\x89\xc0\x24\x44\x89\x08\x24\x5c\x89\x04\x24\x34\x87\xe8\xff\xf6" "\x89\xff\x24\x34\x2f\xe8\xff\xf9\x8b\xff\xf8\x5d\x75\x8b\x89\xfc\x5d\xec" "\xbe\xc3\x00\x13\x00\x00\xe7\xeb\xb6\x8d\x00\x00\x00\x00\x89\x55\x57\xe5" "\x53\x56\xec\x81\x01\xdc\x00\x00\x45\xbb\x05\x5c\x8b\x08\x0c\x55\xe4\x83" "\x8b\xf0\x89\x02\x24\x5c\xc7\x04\x24\x04\x00\x06\x00\x00\xec\xa3\x05\xa9" "\xe8\x08\xf7\x2a\xff\xff\x04\xc7\x46\x24\x05\x5c\xb9\x08\x5c\x50\x08\x05" "\x4c\x89\x04\x24\xf5\xe8\xff\xf7\xc7\xff\x24\x04\x5c\x46\x08\x05\xe9\xe8" "\xff\xf8\xc7\xff\x24\x04\x1d\x70\x08\x05\x55\xe8\x00\xbb\xb8\x00\x00\x01" "\x00\x00\xd2\x31\x08\xa3\x05\xa7\xb8\x08\x00\x01\x00\x00\x0c\xa3\x05\xa7", 18 * 16), "=89=E8$=04/=E8=FF=FB=EB=FF=90=D7t=8D=00&=89U=83=E5=08=EC=04=C7=A0$=05=A2=E8=\r\n" "=08C=EE=00=00=C0=85=0At=EC=89=C3]=B6=8D=00=00=00=00=04=C7=A8$=05=A2=E8=08=\r\n" "C=D4=00=00=E8=EB=F6=89=89U=81=E5=A8=EC=00=00=89=00=FCuu=8B=89=08=F8]=B9=E8=\r\n" "=FF=FF=83=FF=14=FEGt=C01=9D=8D=FFh=FF=FF=85=89=FFh=FF=FF=85=8D=FFl=FF=FF=04=\r\n" "=89=E8$=FAP=FF=FFE=C7=00=EC=00=001=00=89=C0$D=89=08$\\=89=04$4=87=E8=FF=F6=\r\n" "=89=FF$4/=E8=FF=F9=8B=FF=F8]u=8B=89=FC]=EC=BE=C3=00=13=00=00=E7=EB=B6=8D=00=\r\n" "=00=00=00=89UW=E5SV=EC=81=01=DC=00=00E=BB=05\\=8B=08=0CU=E4=83=8B=F0=89=02=\r\n" "$\\=C7=04$=04=00=06=00=00=EC=A3=05=A9=E8=08=F7*=FF=FF=04=C7F$=05\\=B9=08\\P=08=\r\n" "=05L=89=04$=F5=E8=FF=F7=C7=FF$=04\\F=08=05=E9=E8=FF=F8=C7=FF$=04=1Dp=08=05=\r\n" "U=E8=00=BB=B8=00=00=01=00=00=D21=08=A3=05=A7=B8=08=00=01=00=00=0C=A3=05=A7=\r\n" }; for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) { const vmime::string decoded = testSuites[i * 2]; const vmime::string encoded = testSuites[i * 2 + 1]; std::ostringstream oss; oss << "[QP] Test " << (i + 1) << ": "; // Encoding VASSERT_EQ(oss.str() + "encoding", encoded, encode("quoted-printable", decoded, 74)); // Decoding VASSERT_EQ(oss.str() + "decoding", decoded, decode("quoted-printable", encoded, 74)); // Multiple and successive encoding/decoding VASSERT_EQ(oss.str() + "multiple1", decoded, decode("quoted-printable", encode("quoted-printable", decoded))); VASSERT_EQ(oss.str() + "multiple2", decoded, decode("quoted-printable", decode("quoted-printable", encode("quoted-printable", encode("quoted-printable", decoded))))); VASSERT_EQ(oss.str() + "multiple3", decoded, decode("quoted-printable", decode("quoted-printable", decode("quoted-printable", encode("quoted-printable", encode("quoted-printable", encode("quoted-printable", decoded))))))); VASSERT_EQ(oss.str() + "multiple4", decoded, decode("quoted-printable", decode("quoted-printable", decode("quoted-printable", decode("quoted-printable", encode("quoted-printable", encode("quoted-printable", encode("quoted-printable", encode("quoted-printable", decoded))))))))); } } void testQuotedPrintable_RFC2047() { /* * The RFC (http://tools.ietf.org/html/rfc2047#section-5) says: * * In this case the set of characters that may be used in a "Q"-encoded * 'encoded-word' is restricted to: . An 'encoded-word' that appears within a * 'phrase' MUST be separated from any adjacent 'word', 'text' or * 'special' by 'linear-white-space'. */ vmime::propertySet encProps; encProps["rfc2047"] = true; // Ensure 'especials' are encoded VASSERT_EQ("especials.1", "=2C", encode("quoted-printable", ",", 10, encProps)); VASSERT_EQ("especials.2", "=3B", encode("quoted-printable", ";", 10, encProps)); VASSERT_EQ("especials.3", "=3A", encode("quoted-printable", ":", 10, encProps)); VASSERT_EQ("especials.4", "=5F", encode("quoted-printable", "_", 10, encProps)); VASSERT_EQ("especials.5", "=40", encode("quoted-printable", "@", 10, encProps)); VASSERT_EQ("especials.6", "=28", encode("quoted-printable", "(", 10, encProps)); VASSERT_EQ("especials.7", "=29", encode("quoted-printable", ")", 10, encProps)); VASSERT_EQ("especials.8", "=3C", encode("quoted-printable", "<", 10, encProps)); VASSERT_EQ("especials.9", "=3E", encode("quoted-printable", ">", 10, encProps)); VASSERT_EQ("especials.10", "=5B", encode("quoted-printable", "[", 10, encProps)); VASSERT_EQ("especials.11", "=5D", encode("quoted-printable", "]", 10, encProps)); VASSERT_EQ("especials.12", "=22", encode("quoted-printable", "\"", 10, encProps)); } // TODO: UUEncode VMIME_TEST_SUITE_END libvmime-0.9.1/tests/utility/datetimeUtilsTest.cpp0000644000175000017500000001513611314151075022661 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/dateTime.hpp" #include "vmime/utility/datetimeUtils.hpp" #define VMIME_TEST_SUITE datetimeUtilsTest #define VMIME_TEST_SUITE_MODULE "Utility" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testIsLeapYear) VMIME_TEST(testGetDaysInMonth) VMIME_TEST(testGetDaysInMonthLeapYear) VMIME_TEST(testToUniversalTime) VMIME_TEST(testToLocalTime) VMIME_TEST(testGetDayOfWeek) VMIME_TEST(testGetWeekOfYear) VMIME_TEST_LIST_END typedef vmime::utility::datetimeUtils datetimeUtils; void testIsLeapYear() { VASSERT_EQ("1", false, datetimeUtils::isLeapYear(1999)); VASSERT_EQ("2", false, datetimeUtils::isLeapYear(1800)); VASSERT_EQ("3", false, datetimeUtils::isLeapYear(1900)); VASSERT_EQ("4", false, datetimeUtils::isLeapYear(2100)); VASSERT_EQ("5", false, datetimeUtils::isLeapYear(2200)); VASSERT_EQ("6", true, datetimeUtils::isLeapYear(1996)); VASSERT_EQ("7", true, datetimeUtils::isLeapYear(2000)); } void testGetDaysInMonth() { VASSERT_EQ("1", 31, datetimeUtils::getDaysInMonth(2006, 1)); VASSERT_EQ("2", 28, datetimeUtils::getDaysInMonth(2006, 2)); VASSERT_EQ("3", 31, datetimeUtils::getDaysInMonth(2006, 3)); VASSERT_EQ("4", 30, datetimeUtils::getDaysInMonth(2006, 4)); VASSERT_EQ("5", 31, datetimeUtils::getDaysInMonth(2006, 5)); VASSERT_EQ("6", 30, datetimeUtils::getDaysInMonth(2006, 6)); VASSERT_EQ("7", 31, datetimeUtils::getDaysInMonth(2006, 7)); VASSERT_EQ("8", 31, datetimeUtils::getDaysInMonth(2006, 8)); VASSERT_EQ("9", 30, datetimeUtils::getDaysInMonth(2006, 9)); VASSERT_EQ("10", 31, datetimeUtils::getDaysInMonth(2006, 10)); VASSERT_EQ("11", 30, datetimeUtils::getDaysInMonth(2006, 11)); VASSERT_EQ("12", 31, datetimeUtils::getDaysInMonth(2006, 12)); } void testGetDaysInMonthLeapYear() { VASSERT_EQ("1", 31, datetimeUtils::getDaysInMonth(2004, 1)); VASSERT_EQ("2", 29, datetimeUtils::getDaysInMonth(2004, 2)); VASSERT_EQ("3", 31, datetimeUtils::getDaysInMonth(2004, 3)); VASSERT_EQ("4", 30, datetimeUtils::getDaysInMonth(2004, 4)); VASSERT_EQ("5", 31, datetimeUtils::getDaysInMonth(2004, 5)); VASSERT_EQ("6", 30, datetimeUtils::getDaysInMonth(2004, 6)); VASSERT_EQ("7", 31, datetimeUtils::getDaysInMonth(2004, 7)); VASSERT_EQ("8", 31, datetimeUtils::getDaysInMonth(2004, 8)); VASSERT_EQ("9", 30, datetimeUtils::getDaysInMonth(2004, 9)); VASSERT_EQ("10", 31, datetimeUtils::getDaysInMonth(2004, 10)); VASSERT_EQ("11", 30, datetimeUtils::getDaysInMonth(2004, 11)); VASSERT_EQ("12", 31, datetimeUtils::getDaysInMonth(2004, 12)); } void testToUniversalTime() { const vmime::datetime local (2005, 12, 2, 12, 34, 56, -789); const vmime::datetime gmt = datetimeUtils::toUniversalTime(local); // 789 is 13 hours, 9 minutes later VASSERT_EQ("1", 2005, gmt.getYear()); VASSERT_EQ("2", 12, gmt.getMonth()); VASSERT_EQ("3", 3, gmt.getDay()); VASSERT_EQ("4", 1, gmt.getHour()); VASSERT_EQ("5", 43, gmt.getMinute()); VASSERT_EQ("6", 56, gmt.getSecond()); VASSERT_EQ("7", 0, gmt.getZone()); } void testToLocalTime() { const vmime::datetime date (2005, 12, 2, 12, 34, 56, -120); // GMT-2 const vmime::datetime local = datetimeUtils::toLocalTime(date, 120); // GMT+2 VASSERT_EQ("1", 2005, local.getYear()); VASSERT_EQ("2", 12, local.getMonth()); VASSERT_EQ("3", 2, local.getDay()); VASSERT_EQ("4", 16, local.getHour()); VASSERT_EQ("5", 34, local.getMinute()); VASSERT_EQ("6", 56, local.getSecond()); VASSERT_EQ("7", 120, local.getZone()); } void testGetDayOfWeek() { VASSERT_EQ("1", vmime::datetime::WEDNESDAY, datetimeUtils::getDayOfWeek(1969, 12, 31)); VASSERT_EQ("2", vmime::datetime::FRIDAY, datetimeUtils::getDayOfWeek(1976, 4, 9)); VASSERT_EQ("3", vmime::datetime::TUESDAY, datetimeUtils::getDayOfWeek(1987, 6, 23)); VASSERT_EQ("4", vmime::datetime::SATURDAY, datetimeUtils::getDayOfWeek(1990, 1, 13)); VASSERT_EQ("5", vmime::datetime::MONDAY, datetimeUtils::getDayOfWeek(1999, 9, 20)); VASSERT_EQ("6", vmime::datetime::THURSDAY, datetimeUtils::getDayOfWeek(2003, 2, 27)); VASSERT_EQ("7", vmime::datetime::SATURDAY, datetimeUtils::getDayOfWeek(2005, 11, 19)); VASSERT_EQ("8", vmime::datetime::WEDNESDAY, datetimeUtils::getDayOfWeek(2012, 5, 16)); VASSERT_EQ("9", vmime::datetime::FRIDAY, datetimeUtils::getDayOfWeek(2027, 3, 12)); } void testGetWeekOfYear() { VASSERT_EQ("1.1", 52, datetimeUtils::getWeekOfYear(2003, 12, 27)); VASSERT_EQ("1.2", 52, datetimeUtils::getWeekOfYear(2003, 12, 28)); VASSERT_EQ("1.3", 1, datetimeUtils::getWeekOfYear(2003, 12, 29, true)); VASSERT_EQ("1.4", 53, datetimeUtils::getWeekOfYear(2003, 12, 29, false)); VASSERT_EQ("1.5", 1, datetimeUtils::getWeekOfYear(2004, 1, 4)); VASSERT_EQ("1.6", 2, datetimeUtils::getWeekOfYear(2004, 1, 5)); VASSERT_EQ("1.7", 2, datetimeUtils::getWeekOfYear(2004, 1, 11)); VASSERT_EQ("2.1", 52, datetimeUtils::getWeekOfYear(2004, 12, 26)); VASSERT_EQ("2.2", 53, datetimeUtils::getWeekOfYear(2004, 12, 27)); VASSERT_EQ("2.3", 53, datetimeUtils::getWeekOfYear(2005, 1, 2)); VASSERT_EQ("2.4", 1, datetimeUtils::getWeekOfYear(2005, 1, 3)); VASSERT_EQ("2.5", 1, datetimeUtils::getWeekOfYear(2005, 1, 4)); VASSERT_EQ("2.6", 2, datetimeUtils::getWeekOfYear(2005, 1, 11)); VASSERT_EQ("3.1", 9, datetimeUtils::getWeekOfYear(2027, 3, 7)); VASSERT_EQ("3.2", 10, datetimeUtils::getWeekOfYear(2027, 3, 8)); VASSERT_EQ("3.3", 10, datetimeUtils::getWeekOfYear(2027, 3, 14)); VASSERT_EQ("3.4", 11, datetimeUtils::getWeekOfYear(2027, 3, 15)); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/utility/stringUtilsTest.cpp0000644000175000017500000001137711250723263022401 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/utility/stringUtils.hpp" #define VMIME_TEST_SUITE stringUtilsTest #define VMIME_TEST_SUITE_MODULE "Utility" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testIsStringEqualNoCase1) VMIME_TEST(testIsStringEqualNoCase2) VMIME_TEST(testIsStringEqualNoCase3) VMIME_TEST(testToLower) VMIME_TEST(testTrim) VMIME_TEST(testCountASCIIChars) VMIME_TEST(testUnquote) VMIME_TEST_LIST_END typedef vmime::utility::stringUtils stringUtils; void testIsStringEqualNoCase1() { VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3)); VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), "foo", 3)); VASSERT_EQ("3", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "FOo", 3)); VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "bar", 3)); } void testIsStringEqualNoCase2() { VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo"))); VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo"))); VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo"))); } void testIsStringEqualNoCase3() { vmime::string str1("FooBar"); VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "foobar", 6)); VASSERT_EQ("2", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "FooBar", 6)); VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "fooBar", 3)); VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "fooBar", 6)); } void testToLower() { VASSERT_EQ("1", "foo", stringUtils::toLower("FOO")); VASSERT_EQ("2", "foo", stringUtils::toLower("foO")); VASSERT_EQ("3", "foo", stringUtils::toLower("foo")); } void testTrim() { VASSERT_EQ("1", "foo", stringUtils::trim(" foo")); VASSERT_EQ("2", "foo", stringUtils::trim("\t\tfoo")); VASSERT_EQ("3", "foo", stringUtils::trim(" \t \tfoo")); VASSERT_EQ("4", "foo", stringUtils::trim(" \r\n\tfoo")); VASSERT_EQ("5", "foo", stringUtils::trim("foo ")); VASSERT_EQ("6", "foo", stringUtils::trim("foo\t\t")); VASSERT_EQ("7", "foo", stringUtils::trim("foo \t \t")); VASSERT_EQ("8", "foo", stringUtils::trim("foo \r\n\t")); VASSERT_EQ( "9", "foo", stringUtils::trim("foo ")); VASSERT_EQ("10", "foo", stringUtils::trim(" foo ")); VASSERT_EQ("11", "foo", stringUtils::trim(" foo\t\t")); VASSERT_EQ("12", "foo", stringUtils::trim("\tfoo \r \t")); VASSERT_EQ("13", "foo", stringUtils::trim("\r \tfoo \n\t")); } void testCountASCIIChars() { vmime::string str1("foo"); VASSERT_EQ("1", static_cast (3), stringUtils::countASCIIchars(str1.begin(), str1.end())); vmime::string str2("f=?oo"); VASSERT_EQ("2", static_cast (3 + 1), stringUtils::countASCIIchars(str2.begin(), str2.end())); vmime::string str3("foo\x7f"); VASSERT_EQ("3", static_cast (4), stringUtils::countASCIIchars(str3.begin(), str3.end())); vmime::string str4("foo\x80"); VASSERT_EQ("4", static_cast (3), stringUtils::countASCIIchars(str4.begin(), str4.end())); } void testUnquote() { VASSERT_EQ("1", "quoted", stringUtils::unquote("\"quoted\"")); // "quoted" VASSERT_EQ("2", "\"not quoted", stringUtils::unquote("\"not quoted")); // "not quoted VASSERT_EQ("3", "not quoted\"", stringUtils::unquote("not quoted\"")); // not quoted" VASSERT_EQ("4", "quoted with \"escape\"", stringUtils::unquote("\"quoted with \\\"escape\\\"\"")); // "quoted with \"escape\"" } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/utility/pathTest.cpp0000644000175000017500000001672211250723263021005 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/utility/path.hpp" #define VMIME_TEST_SUITE pathTest #define VMIME_TEST_SUITE_MODULE "Utility" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testConstruct1) VMIME_TEST(testConstruct2) VMIME_TEST(testConstruct3) VMIME_TEST(testConstruct4) VMIME_TEST(testAppendComponent) VMIME_TEST(testOperatorDiv1) VMIME_TEST(testOperatorDiv2) VMIME_TEST(testOperatorDivEqual1) VMIME_TEST(testOperatorDivEqual2) VMIME_TEST(testGetParent) VMIME_TEST(testComparison) VMIME_TEST(testGetLastComponent) VMIME_TEST(testIsDirectParentOf) VMIME_TEST(testIsParentOf) VMIME_TEST(testRenameParent) VMIME_TEST_LIST_END typedef vmime::utility::path path; typedef vmime::utility::path::component comp; void testConstruct1() { VASSERT_EQ("1", true, path().isEmpty()); VASSERT_EQ("2", 0, path().getSize()); } void testConstruct2() { path p(comp("foo")); VASSERT_EQ("1", false, p.isEmpty()); VASSERT_EQ("2", 1, p.getSize()); VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer()); } void testAppendComponent() { path p; VASSERT_EQ("1", 0, p.getSize()); comp c("foo"); p.appendComponent(c); VASSERT_EQ("2", 1, p.getSize()); VASSERT_EQ("3", c.getBuffer(), p.getComponentAt(0).getBuffer()); } void testConstruct3() { path p1; p1.appendComponent(comp("foo")); p1.appendComponent(comp("bar")); path p2(p1); VASSERT_EQ("1", 2, p2.getSize()); VASSERT_EQ("2", "foo", p2.getComponentAt(0).getBuffer()); VASSERT_EQ("3", "bar", p2.getComponentAt(1).getBuffer()); } void testConstruct4() { // Same as path::path(const component&) path p("foo"); VASSERT_EQ("1", false, p.isEmpty()); VASSERT_EQ("2", 1, p.getSize()); VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer()); } void testOperatorDiv1() { path p1; p1.appendComponent(comp("foo")); p1.appendComponent(comp("bar")); path p2; p2.appendComponent(comp("baz")); path p3 = p1 / p2; VASSERT_EQ("1", 3, p3.getSize()); VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p3.getComponentAt(0).getBuffer()); VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p3.getComponentAt(1).getBuffer()); VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer()); } void testOperatorDiv2() { path p1; p1.appendComponent(comp("foo")); p1.appendComponent(comp("bar")); comp c("baz"); path p2 = p1 / c; VASSERT_EQ("1", 3, p2.getSize()); VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p2.getComponentAt(0).getBuffer()); VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p2.getComponentAt(1).getBuffer()); VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer()); } void testOperatorDivEqual1() { path p1; p1.appendComponent(comp("foo")); p1.appendComponent(comp("bar")); path p2; p2.appendComponent(comp("baz")); path p3(p1); p3 /= p2; VASSERT_EQ("1", 3, p3.getSize()); VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p3.getComponentAt(0).getBuffer()); VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p3.getComponentAt(1).getBuffer()); VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer()); } void testOperatorDivEqual2() { path p1; p1.appendComponent(comp("foo")); p1.appendComponent(comp("bar")); comp c("baz"); path p2(p1); p2 /= c; VASSERT_EQ("1", 3, p2.getSize()); VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p2.getComponentAt(0).getBuffer()); VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p2.getComponentAt(1).getBuffer()); VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer()); } void testGetParent() { path p1; path p1p = p1.getParent(); VASSERT_EQ("1", true, p1p.isEmpty()); path p2; p2.appendComponent(comp("foo")); p2.appendComponent(comp("bar")); path p2p = p2.getParent(); VASSERT_EQ("2", 1, p2p.getSize()); VASSERT_EQ("3", p2.getComponentAt(0).getBuffer(), p2p.getComponentAt(0).getBuffer()); } void testComparison() { path p1; p1.appendComponent(comp("foo")); p1.appendComponent(comp("bar")); path p2; p2.appendComponent(comp("foo")); p2.appendComponent(comp("bar")); path p3; p3.appendComponent(comp("foo")); p3.appendComponent(comp("bar")); p3.appendComponent(comp("baz")); VASSERT_EQ("1", true, p1 == p2); VASSERT_EQ("2", false, p1 == p3); VASSERT_EQ("3", false, p1 != p2); VASSERT_EQ("4", true, p1 != p3); VASSERT_EQ("5", true, p3.getParent() == p1); } void testGetLastComponent() { path p1; p1.appendComponent(comp("foo")); p1.appendComponent(comp("bar")); p1.appendComponent(comp("baz")); VASSERT_EQ("1", "baz", p1.getLastComponent().getBuffer()); VASSERT_EQ("2", "bar", p1.getParent().getLastComponent().getBuffer()); VASSERT_EQ("3", "foo", p1.getParent().getParent().getLastComponent().getBuffer()); } void testIsDirectParentOf() { path p1; p1.appendComponent(comp("foo")); path p2; p2.appendComponent(comp("foo")); p2.appendComponent(comp("bar")); path p3; p3.appendComponent(comp("foo")); p3.appendComponent(comp("bar")); p3.appendComponent(comp("baz")); VASSERT_EQ("1", true, p1.isDirectParentOf(p2)); VASSERT_EQ("2", true, p2.isDirectParentOf(p3)); VASSERT_EQ("3", false, p1.isDirectParentOf(p3)); VASSERT_EQ("4", false, p2.isDirectParentOf(p1)); } void testIsParentOf() { path p1; p1.appendComponent(comp("foo")); path p2; p2.appendComponent(comp("foo")); p2.appendComponent(comp("bar")); path p3; p3.appendComponent(comp("foo")); p3.appendComponent(comp("bar")); p3.appendComponent(comp("baz")); VASSERT_EQ("1", true, p1.isParentOf(p2)); VASSERT_EQ("2", true, p2.isParentOf(p3)); VASSERT_EQ("3", true, p1.isParentOf(p3)); VASSERT_EQ("4", false, p2.isParentOf(p1)); } void testRenameParent() { path p1; p1.appendComponent(comp("a")); p1.appendComponent(comp("b")); p1.appendComponent(comp("c")); p1.appendComponent(comp("d")); path p2; p2.appendComponent(comp("a")); p2.appendComponent(comp("b")); path p3; p3.appendComponent(comp("x")); p3.appendComponent(comp("y")); p3.appendComponent(comp("z")); path p(p1); p.renameParent(p2, p3); VASSERT_EQ("1", 5, p.getSize()); VASSERT_EQ("2", "x", p.getComponentAt(0).getBuffer()); VASSERT_EQ("3", "y", p.getComponentAt(1).getBuffer()); VASSERT_EQ("4", "z", p.getComponentAt(2).getBuffer()); VASSERT_EQ("5", "c", p.getComponentAt(3).getBuffer()); VASSERT_EQ("6", "d", p.getComponentAt(4).getBuffer()); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/utility/filteredStreamTest.cpp0000644000175000017500000002367611333330451023024 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include "tests/testUtils.hpp" #include "vmime/utility/filteredStream.hpp" #define VMIME_TEST_SUITE filteredStreamTest #define VMIME_TEST_SUITE_MODULE "Utility" VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testDotFilteredInputStream) VMIME_TEST(testDotFilteredOutputStream) VMIME_TEST(testCRLFToLFFilteredOutputStream) VMIME_TEST(testStopSequenceFilteredInputStream1) VMIME_TEST(testStopSequenceFilteredInputStreamN_2) VMIME_TEST(testStopSequenceFilteredInputStreamN_3) VMIME_TEST_LIST_END class chunkInputStream : public vmime::utility::inputStream { private: std::vector m_chunks; std::vector ::size_type m_index; public: chunkInputStream() : m_index(0) { } void addChunk(const std::string& chunk) { m_chunks.push_back(chunk); } bool eof() const { return (m_index >= m_chunks.size()); } void reset() { m_index = 0; } size_type read(value_type* const data, const size_type /* count */) { if (eof()) return 0; const std::string chunk = m_chunks[m_index]; // Warning: 'count' should be larger than chunk length. // This is OK for our tests. std::copy(chunk.begin(), chunk.end(), data); ++m_index; return chunk.length(); } size_type skip(const size_type /* count */) { // Not supported return 0; } }; const std::string readWhole(vmime::utility::inputStream& is) { vmime::utility::stream::value_type buffer[256]; std::string whole; while (!is.eof()) { const vmime::utility::stream::size_type read = is.read(buffer, sizeof(buffer)); whole += std::string(buffer, read); } return (whole); } // dotFilteredInputStream void testDotFilteredInputStreamHelper (const std::string& number, const std::string& expected, const std::string& c1, const std::string& c2 = "", const std::string& c3 = "", const std::string& c4 = "") { chunkInputStream cis; cis.addChunk(c1); if (!c2.empty()) cis.addChunk(c2); if (!c3.empty()) cis.addChunk(c3); if (!c4.empty()) cis.addChunk(c4); vmime::utility::dotFilteredInputStream is(cis); std::ostringstream oss; vmime::utility::outputStreamAdapter os(oss); vmime::utility::bufferedStreamCopy(is, os); VASSERT_EQ(number, expected, oss.str()); } void testDotFilteredInputStream() { testDotFilteredInputStreamHelper("1", "foo\n.bar", "foo\n..bar"); testDotFilteredInputStreamHelper("2", "foo\n.bar", "foo\n", "..bar"); testDotFilteredInputStreamHelper("3", "foo\n.bar", "foo\n.", ".bar"); testDotFilteredInputStreamHelper("4", "foo\n.bar", "foo\n..", "bar"); testDotFilteredInputStreamHelper("5", "foo\n.bar", "foo\n", ".", ".bar"); testDotFilteredInputStreamHelper("6", "foo\n.bar", "foo\n", ".", ".", "bar"); } // dotFilteredOutputStream // CRLFToLFFilteredOutputStream template void testFilteredOutputStreamHelper (const std::string& number, const std::string& expected, const std::string& c1, const std::string& c2 = "", const std::string& c3 = "", const std::string& c4 = "") { std::ostringstream oss; vmime::utility::outputStreamAdapter os(oss); FILTER fos(os); fos.write(c1.data(), c1.length()); if (!c2.empty()) fos.write(c2.data(), c2.length()); if (!c3.empty()) fos.write(c3.data(), c3.length()); if (!c4.empty()) fos.write(c4.data(), c4.length()); VASSERT_EQ(number, expected, oss.str()); } void testDotFilteredOutputStream() { typedef vmime::utility::dotFilteredOutputStream FILTER; testFilteredOutputStreamHelper("1", "foo\n..bar", "foo\n.bar"); testFilteredOutputStreamHelper("2", "foo\n..bar", "foo\n", ".bar"); testFilteredOutputStreamHelper("3", "foo\n..bar", "foo", "\n.bar"); testFilteredOutputStreamHelper("4", "foo\n..bar", "foo", "\n", ".bar"); testFilteredOutputStreamHelper("5", "foo\n..bar", "foo", "\n", ".", "bar"); } void testCRLFToLFFilteredOutputStream() { typedef vmime::utility::CRLFToLFFilteredOutputStream FILTER; testFilteredOutputStreamHelper("1", "foo\nbar", "foo\r\nbar"); testFilteredOutputStreamHelper("2", "foo\nbar", "foo\r\n", "bar"); testFilteredOutputStreamHelper("3", "foo\nbar", "foo\r", "\nbar"); testFilteredOutputStreamHelper("4", "foo\nbar", "foo", "\r\nbar"); testFilteredOutputStreamHelper("5", "foo\nbar", "foo", "\r", "\nbar"); testFilteredOutputStreamHelper("6", "foo\nbar", "foo", "\r", "\n", "bar"); testFilteredOutputStreamHelper("7", "foo\nba\nr", "foo\r", "\nba\r\nr"); } // stopSequenceFilteredInputStream template void testStopSequenceFISHelper (const std::string& number, const std::string& sequence, const std::string& expected, const std::string& c1, const std::string& c2 = "", const std::string& c3 = "", const std::string& c4 = "", const std::string& c5 = "") { chunkInputStream cis; cis.addChunk(c1); if (!c2.empty()) cis.addChunk(c2); if (!c3.empty()) cis.addChunk(c3); if (!c4.empty()) cis.addChunk(c4); if (!c5.empty()) cis.addChunk(c5); vmime::utility::stopSequenceFilteredInputStream is(cis, sequence.data()); VASSERT_EQ(number, expected, readWhole(is)); } void testStopSequenceFilteredInputStream1() { testStopSequenceFISHelper <1>("1", "x", "foo", "fooxbar"); testStopSequenceFISHelper <1>("2", "x", "foo", "foox", "bar"); testStopSequenceFISHelper <1>("3", "x", "foo", "foo", "x", "bar"); testStopSequenceFISHelper <1>("4", "x", "foo", "fo", "o", "x", "bar"); testStopSequenceFISHelper <1>("5", "x", "foo", "fo", "o", "x", "b", "ar"); testStopSequenceFISHelper <1>("6", "x", "foobar", "fo", "o", "b", "ar"); testStopSequenceFISHelper <1>("7", "x", "foobar", "foo", "bar"); testStopSequenceFISHelper <1>("8", "x", "foobar", "foo", "b", "ar"); testStopSequenceFISHelper <1>("9", "x", "foobar", "foobar"); testStopSequenceFISHelper <1>("10", "x", "foobar", "foobarx"); testStopSequenceFISHelper <1>("11", "x", "", ""); testStopSequenceFISHelper <1>("12", "x", "", "x"); testStopSequenceFISHelper <1>("13", "x", "", "", "x"); } void testStopSequenceFilteredInputStreamN_2() { testStopSequenceFISHelper <2>("1", "xy", "foo", "fooxybar"); testStopSequenceFISHelper <2>("2", "xy", "foo", "foox", "ybar"); testStopSequenceFISHelper <2>("3", "xy", "foo", "foox", "y", "bar"); testStopSequenceFISHelper <2>("4", "xy", "foo", "foo", "x", "ybar"); testStopSequenceFISHelper <2>("5", "xy", "foo", "foo", "xy", "bar"); testStopSequenceFISHelper <2>("6", "xy", "foo", "foo", "x", "y", "bar"); testStopSequenceFISHelper <2>("7", "xy", "fooxbar", "foox", "bar"); testStopSequenceFISHelper <2>("8", "xy", "fooxbar", "foo", "xbar"); testStopSequenceFISHelper <2>("9", "xy", "fooxbar", "foo", "x", "bar"); testStopSequenceFISHelper <2>("10", "xy", "foobarx", "foo", "barx"); testStopSequenceFISHelper <2>("11", "xy", "foobar", "foobarxy"); testStopSequenceFISHelper <2>("12", "xy", "foobar", "foo", "barxy"); testStopSequenceFISHelper <2>("13", "xy", "foobar", "foo", "bar", "xy"); testStopSequenceFISHelper <2>("14", "xy", "", ""); testStopSequenceFISHelper <2>("15", "xy", "x", "x"); testStopSequenceFISHelper <2>("16", "xy", "", "xy"); testStopSequenceFISHelper <2>("17", "xy", "", "x", "y"); } void testStopSequenceFilteredInputStreamN_3() { testStopSequenceFISHelper <3>("1", "xyz", "foo", "fooxyzbar"); testStopSequenceFISHelper <3>("2", "xyz", "foo", "foox", "yzbar"); testStopSequenceFISHelper <3>("3", "xyz", "foo", "foox", "y", "zbar"); testStopSequenceFISHelper <3>("4", "xyz", "foo", "foox", "yz", "bar"); testStopSequenceFISHelper <3>("5", "xyz", "foo", "foo", "xyz", "bar"); testStopSequenceFISHelper <3>("6", "xyz", "foo", "foo", "xy", "zbar"); testStopSequenceFISHelper <3>("7", "xyz", "foo", "foo", "x", "y", "zbar"); testStopSequenceFISHelper <3>("8", "xyz", "foo", "foo", "x", "y", "z", "bar"); testStopSequenceFISHelper <3>("9", "xyz", "foo", "fooxy", "z", "bar"); testStopSequenceFISHelper <3>("10", "xyz", "fooxybar", "foox", "y", "bar"); testStopSequenceFISHelper <3>("11", "xyz", "fooxybar", "fooxy", "bar"); testStopSequenceFISHelper <3>("12", "xyz", "fooxybar", "fo", "ox", "y", "bar"); testStopSequenceFISHelper <3>("13", "xyz", "fooxybar", "fo", "o", "x", "y", "bar"); testStopSequenceFISHelper <3>("14", "xyz", "fooxybar", "foo", "x", "ybar"); testStopSequenceFISHelper <3>("15", "xyz", "fooxybar", "foo", "xybar"); testStopSequenceFISHelper <3>("16", "xyz", "xfoxoxybxar", "xfoxo", "xybxar"); testStopSequenceFISHelper <3>("17", "xyz", "xfoxoxybxarx", "xfoxo", "xybxarx"); testStopSequenceFISHelper <3>("18", "xyz", "xfoxoxybxarxy", "xfoxo", "xybxarxy"); testStopSequenceFISHelper <3>("19", "xyz", "", ""); testStopSequenceFISHelper <3>("20", "xyz", "x", "x"); testStopSequenceFISHelper <3>("21", "xyz", "xy", "xy"); testStopSequenceFISHelper <3>("22", "xyz", "", "xyz"); testStopSequenceFISHelper <3>("23", "xyz", "", "x", "yz"); testStopSequenceFISHelper <3>("24", "xyz", "", "x", "y", "z"); } VMIME_TEST_SUITE_END libvmime-0.9.1/tests/charset/0000755000175000017500000000000011607302336016423 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/charset/run-test.sh0000755000175000017500000000211011250723263020535 0ustar mnordstrmnordstr#!/bin/sh TEST_DIR="./test-suites" TEMP_DIR="/tmp" PROGRAM="./main" testFiles=`cd $TEST_DIR ; find . -maxdepth 1 -regex '\./[^\.]*\.in\..*' -type f` echo echo Testing charset conversions echo ===================================================================== for testFile in $testFiles ; do testName=`echo $testFile | sed 's/^\.\/\([^\.]*\).*/\1/'` sourceCharset=`echo $testFile | sed 's/^\.\/[^\.]*\.[^\.]*\.\(.*\)/\1/'` testOutFiles=`cd $TEST_DIR ; find . -maxdepth 1 -regex "\./$testName\.out\..*" -type f` for testOutFile in $testOutFiles ; do destCharset=`echo $testOutFile | sed 's/^\.\/[^\.]*\.[^\.]*\.\(.*\)/\1/'` printf %20s "$testName " printf %30s "$sourceCharset --> $destCharset : " $PROGRAM $sourceCharset $destCharset < $TEST_DIR/$testFile > $TEMP_DIR/vmime_result diff="diff $TEMP_DIR/vmime_result $TEST_DIR/$testOutFile" res=`$diff` if [ "$res" = "" ] then echo "[OK]" else diffFile=$TEMP_DIR/vmime.charset.$testName.$sourceCharset.$destCharset.diff echo "[NO: diff file is $diffFile]" $diff > $diffFile fi done done echo libvmime-0.9.1/tests/charset/main.cpp0000644000175000017500000000277711250723263020070 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" int main(int argc, char* argv[]) { // VMime initialization vmime::platform::setHandler(); const vmime::string from(argv[1]); const vmime::string to(argv[2]); vmime::utility::inputStreamAdapter in(std::cin); vmime::utility::outputStreamAdapter out(std::cout); vmime::charset::convert(in, out, from, to); } libvmime-0.9.1/tests/charset/test-suites/0000755000175000017500000000000011607302336020714 5ustar mnordstrmnordstrlibvmime-0.9.1/tests/charset/test-suites/gnu.in.utf-80000644000175000017500000000551311250723263023003 0ustar mnordstrmnordstrKorean Part. GNU 프로ì íŠ¸ì˜ ì›¹ì„œë²„ì¸ www.gnu.orgì— ì˜¤ì‹  ê²ƒì„ í™˜ì˜í•©ë‹ˆë‹¤. GNU 프로ì íŠ¸ëŠ” GNU 시스템ì´ë¼ê³  불리는 유닉스 í˜•íƒœì˜ ì™„ë²½í•œ ìžìœ  소프트웨어 ìš´ì˜ì²´ì œë¥¼ 개발하기 위해서 1984년부터 시작ë˜ì—ˆìŠµë‹ˆë‹¤. (GNUë¼ëŠ” 단어는 ``GNU's Not Unix''를 ì˜ë¯¸í•˜ëŠ” ìž¬ê·€ì  ì•½ì–´ì´ë©° ``ê·¸-뉴"ë¼ê³  ë°œìŒí•©ë‹ˆë‹¤.) GNU 시스템으로부터 연유한 다양한 ì¢…ë¥˜ì˜ ìš´ì˜ì²´ì œë“¤ì´ 현재 ``리눅스''ë¼ëŠ” ì´ë¦„으로 사용ë˜ê³  있지만, 시스템 커ë„로 리눅스를 탑재한 ìš´ì˜ì²´ì œì˜ 보다 정확한 ì´ë¦„ì€ GNU/리눅스 시스템입니다. Japanese Part GNU プロジェクトã®ã‚¦ã‚§ãƒ–サーãƒã€www.gnu.org ã¸ã‚ˆã†ã“ã。1984 å¹´ã®ãƒ—ロジェクト 開始以æ¥ã€GNU プロジェクトã§ã¯ã€Unix ã«ä¼¼ãŸ フリーソフトウェアã®å®Œå…¨ãªã‚ªãƒšãƒ¬ãƒ¼ ティングシステムã€GNU システムを開発ã—ã¦æ¥ã¾ã—ãŸ(GNU ã¨ã¯ã€ŒGNU's Not Unix(GNU 㯠Unix ã§ã¯ãªã„)ã€ã®å†å¸°é ­å­—語ã§ã‚りã€ã€Œã‚°ãƒ‹ãƒ¥ãƒ¼ã€ã¨ç™ºéŸ³ã•れã¾ã™)。ç¾åœ¨ã€ã‚«ãƒ¼ãƒ ルã¨ã—㦠Linux を用ã„㟠GNU システムã®ã•ã¾ã–ã¾ãªå¤‰ç¨®ãŒåºƒã使ã‚れã¦ã„ã¾ã™ã€‚ã“れ らã®ã‚·ã‚¹ãƒ†ãƒ ã¯ã€ŒLinuxã€ã¨å‘¼ã°ã‚Œã‚‹ã“ã¨ãŒå¤šã„ã®ã§ã™ãŒã€ã‚ˆã‚Šæ­£ç¢ºã«ã¯ GNU/Linux システム ã¨å‘¼ã°ã‚Œã‚‹ã‚‚ã®ãªã®ã§ã™ã€‚ Chinese Part. 歡迎來到GNU 專案的伺æœä¸»æ©Ÿï¼Œwww.gnu.org。 GNU 專案 é–‹å§‹æ–¼1984年,旨在發展一 個 Unix-like 且為 自由軟體 的作業系統: GNU 系統。(GNU 是由``GNU's Not Unix''所éžè¿´å®šç¾©å‡ºçš„頭字語);它的發音為"guh-NEW"。å„種使用 Linux 作為核心的 GNU 作業系統正被廣泛的使用著;雖然這些系統通常被稱作 ``Linux'',但是它們應該更精 確地被稱為 GNU/Linux 系統。 English Part. Welcome to the GNU Project web server, www.gnu.org. The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system. (GNU is a recursive acronym for ``GNU's Not Unix''; it is pronounced "guh-NEW".) Variants of the GNU operating system, which use the kernel Linux, are now widely used; though these systems are often referred to as ``Linux'', they are more accurately called GNU/Linux systems. French Part. Bienvenue sur le serveur web du projet GNU, www.gnu.org. Le projet GNU a été lancé en 1984 afin de développer un système d'exploitation complet, semblable à Unix et qui soit un logiciel libre: le système GNU. (« GNU » est l'acronyme récursif the « GNU's Not Unix »; on le prononce « gnou » avec un G audible) Des variantes du système d'exploitation GNU, basées sur le noyau « Linux », sont utilisées largement à présent; bien que ces systèmes soient communément appelés par le terme « Linux », ils le seraient plus exactement par « GNU/Linux ». libvmime-0.9.1/tests/charset/test-suites/gnu.out.iso-8859-10000644000175000017500000000545711250723263023613 0ustar mnordstrmnordstrKorean Part. GNU ??????????????? ???????????? www.gnu.org??? ?????? ?????? ???????????????. GNU ??????????????? GNU ?????????????????? ????????? ????????? ????????? ????????? ?????? ??????????????? ??????????????? ???????????? ????????? 1984????????? ?????????????????????. (GNU?????? ????????? ``GNU's Not Unix''??? ???????????? ????????? ???????????? ``???-???"?????? ???????????????.) GNU ????????????????????? ????????? ????????? ????????? ?????????????????? ?????? ``?????????''?????? ???????????? ???????????? ?????????, ????????? ????????? ???????????? ????????? ??????????????? ?????? ????????? ????????? GNU/????????? ??????????????????. Japanese Part GNU ??????????????????????????????????????????www.gnu.org ??????????????????1984 ???????????????????????? ???????????????GNU ???????????????????????????Unix ????????? ??????????????????????????????????????????????????? ???????????????????????????GNU ???????????????????????????????????????(GNU ?????????GNU's Not Unix(GNU ??? Unix ????????????)????????????????????????????????????????????????????????????????????????)????????????????????? ???????????? Linux ???????????? GNU ??????????????????????????????????????????????????????????????????????????? ????????????????????????Linux?????????????????????????????????????????????????????????????????? GNU/Linux ???????????? ???????????????????????????????????? Chinese Part. ????????????GNU ????????????????????????www.gnu.org??? GNU ?????? ?????????1984????????????????????? ??? Unix-like ?????? ???????????? ?????????????????? GNU ????????????GNU ??????``GNU's Not Unix''???????????????????????????????????????????????????"guh-NEW"??????????????? Linux ??????????????? GNU ???????????????????????????????????????????????????????????????????????? ``Linux''??????????????????????????? ??????????????? GNU/Linux ????????? English Part. Welcome to the GNU Project web server, www.gnu.org. The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system. (GNU is a recursive acronym for ``GNU's Not Unix''; it is pronounced "guh-NEW".) Variants of the GNU operating system, which use the kernel Linux, are now widely used; though these systems are often referred to as ``Linux'', they are more accurately called GNU/Linux systems. French Part. Bienvenue sur le serveur web du projet GNU, www.gnu.org. Le projet GNU a été lancé en 1984 afin de développer un système d'exploitation complet, semblable à Unix et qui soit un logiciel libre: le système GNU. (« GNU » est l'acronyme récursif the « GNU's Not Unix »; on le prononce « gnou » avec un G audible) Des variantes du système d'exploitation GNU, basées sur le noyau « Linux », sont utilisées largement à présent; bien que ces systèmes soient communément appelés par le terme « Linux », ils le seraient plus exactement par « GNU/Linux ». libvmime-0.9.1/vmime/0000755000175000017500000000000011607302336014745 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/mdn/0000755000175000017500000000000011607302336015523 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/mdn/MDNHelper.hpp0000644000175000017500000001151011250723264020011 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MDN_MDNHELPER_HPP_INCLUDED #define VMIME_MDN_MDNHELPER_HPP_INCLUDED #include "vmime/mdn/receivedMDNInfos.hpp" #include "vmime/mdn/sendableMDNInfos.hpp" #include "vmime/mailboxList.hpp" namespace vmime { namespace mdn { /** Helper for creating or extracting Message Disposition * Notifications (MDN), as defined in RFC-3798. */ class MDNHelper { public: /** Attach a MDN request to the specified message. * * @param msg message in which to add a MDN request * @param mailboxes list of mailboxes to which the MDN will be sent */ static void attachMDNRequest(ref msg, const mailboxList& mailboxes); /** Attach a MDN request to the specified message. * * @param msg message in which to add a MDN request * @param mbox mailbox to which the MDN will be sent */ static void attachMDNRequest(ref msg, const mailbox& mbox); /** Return a list of possible MDNs that can be generated * for the specified message. * * @param msg message for which to send a MDN * @return list of possible MDNs */ static const std::vector getPossibleMDNs(const ref msg); /** Test whether the specified message is a MDN. * * @param msg message * @return true if the message is a MDN, false otherwise */ static bool isMDN(const ref msg); /** If the specified message is a MDN, return information * about it. * * @param msg message * @throw exceptions::invalid_argument if the message is not a MDN * @return information about the MDN */ static receivedMDNInfos getReceivedMDN(const ref msg); /** Check whether we need user confirmation for sending a MDN even * if he/she explicitely allowed automatic send of MDNs. This can * happen in some situations, described in RFC-3798. * * @param msg message for which to send a MDN * @return true if user confirmation should be asked, false otherwise */ static bool needConfirmation(const ref msg); /** Build a new MDN for the message. The resulting MDN can then be * sent over SMTP transport service. * * @param mdnInfos information about the MDN to construct * @param text human readable message. The purpose of this message is * to provide an easily-understood description of the * condition(s) that caused the report to be generated. * @param ch charset of the text * @param expeditor expeditor of the MDN * @param dispo disposition information * @param reportingUA name of reporting user-agent (optional) * @param reportingUAProducts list of products in the reporting user-agent (optional) * @return a new message object containing the MDN */ static ref buildMDN(const sendableMDNInfos& mdnInfos, const string& text, const charset& ch, const mailbox& expeditor, const disposition& dispo, const string& reportingUA = NULL_STRING, const std::vector & reportingUAProducts = std::vector ()); private: static ref createFirstMDNPart(const sendableMDNInfos& mdnInfos, const string& text, const charset& ch); static ref createSecondMDNPart(const sendableMDNInfos& mdnInfos, const disposition& dispo, const string& reportingUA, const std::vector & reportingUAProducts); static ref createThirdMDNPart(const sendableMDNInfos& mdnInfos); }; } // mdn } // vmime #endif // VMIME_MDN_MDNHELPER_HPP_INCLUDED libvmime-0.9.1/vmime/mdn/sendableMDNInfos.hpp0000644000175000017500000000373511250723264021360 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MDN_SENDABLEMDNINFOS_HPP_INCLUDED #define VMIME_MDN_SENDABLEMDNINFOS_HPP_INCLUDED #include "vmime/mdn/MDNInfos.hpp" #include "vmime/mailbox.hpp" namespace vmime { namespace mdn { /** Holds information about a Message Disposition Notifications (MDN) * that is to be sent. */ class sendableMDNInfos : public MDNInfos { public: sendableMDNInfos(const ref msg, const mailbox& mbox); sendableMDNInfos(const sendableMDNInfos& other); sendableMDNInfos& operator=(const sendableMDNInfos& other); const ref getMessage() const; /** Return the recipient of the MDN (the mailbox that will receive * the notification message). * * @return recipient of the MDN */ const mailbox& getRecipient() const; private: void copyFrom(const sendableMDNInfos& other); ref m_msg; mailbox m_mailbox; }; } // mdn } // vmime #endif // VMIME_MDN_SENDABLEMDNINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/mdn/MDNInfos.hpp0000644000175000017500000000306711250723264017660 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MDN_MDNINFOS_HPP_INCLUDED #define VMIME_MDN_MDNINFOS_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/message.hpp" namespace vmime { namespace mdn { /** Holds information about Message Disposition Notifications (MDN). */ class MDNInfos : public object { public: virtual ~MDNInfos(); /** Return the message related to this MDN. * * @return related message */ virtual const ref getMessage() const = 0; }; } // mdn } // vmime #endif // VMIME_MDN_MDNINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/mdn/receivedMDNInfos.hpp0000644000175000017500000000427011250723264021364 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MDN_RECEIVEDMDNINFOS_HPP_INCLUDED #define VMIME_MDN_RECEIVEDMDNINFOS_HPP_INCLUDED #include "vmime/mdn/MDNInfos.hpp" #include "vmime/disposition.hpp" #include "vmime/messageId.hpp" #include "vmime/mailbox.hpp" namespace vmime { namespace mdn { /** Holds information about a Message Disposition Notification (MDN) * that has been received. */ class receivedMDNInfos : public MDNInfos { public: receivedMDNInfos(const ref msg); receivedMDNInfos(const receivedMDNInfos& other); receivedMDNInfos& operator=(const receivedMDNInfos& other); const ref getMessage() const; /** Return the identifier of the message for which this MDN * has been generated. * * @return original message-id */ const messageId getOriginalMessageId() const; /** Return information about the disposition. * * @return disposition information */ const disposition getDisposition() const; private: void copyFrom(const receivedMDNInfos& other); void extract(); ref m_msg; disposition m_disp; messageId m_omid; }; } // mdn } // vmime #endif // VMIME_MDN_RECEIVEDMDNINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/0000755000175000017500000000000011607302336015533 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/tls/0000755000175000017500000000000011607302336016335 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/tls/TLSSecuredConnectionInfos.hpp0000644000175000017500000000405011250723264024042 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_TLSSECUREDCONNECTIONINFOS_HPP_INCLUDED #define VMIME_NET_TLSSECUREDCONNECTIONINFOS_HPP_INCLUDED #include "vmime/net/securedConnectionInfos.hpp" #include "vmime/security/cert/certificateChain.hpp" namespace vmime { namespace net { namespace tls { class TLSSession; class TLSSocket; /** Information about a TLS-secured connection used by a service. */ class TLSSecuredConnectionInfos : public securedConnectionInfos { public: TLSSecuredConnectionInfos(const string& host, const port_t port, ref tlsSession, ref tlsSocket); const string getHost() const; port_t getPort() const; /** Return the peer's certificate (chain) as sent by the peer. * * @return server certificate chain */ ref getPeerCertificates() const; private: string m_host; port_t m_port; ref m_tlsSession; ref m_tlsSocket; }; } // tls } // net } // vmime #endif // VMIME_NET_TLSSECUREDCONNECTIONINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/tls/TLSSocket.hpp0000644000175000017500000000634311314151075020664 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_TLS_TLSSOCKET_HPP_INCLUDED #define VMIME_NET_TLS_TLSSOCKET_HPP_INCLUDED #include "vmime/exception.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" #include "vmime/security/cert/certificateChain.hpp" namespace vmime { namespace net { namespace tls { class TLSSession; /** Add a TLS security layer to an existing socket. */ class TLSSocket : public socket { friend class vmime::creator; protected: /** Create a new socket object that adds a security layer * around an existing socket. * * @param session TLS session * @param sok socket to wrap */ TLSSocket(ref session, ref sok); public: ~TLSSocket(); /** Starts a TLS handshake on this connection. * * @throw exceptions::tls_exception if a fatal error occurs * during the negociation process, exceptions::operation_timed_out * if a time-out occurs */ void handshake(ref toHandler = NULL); /** Return the peer's certificate (chain) as sent by the peer. * * @return server certificate chain, or NULL if the handshake * has not been performed yet */ ref getPeerCertificates() const; // Implementation of 'socket' void connect(const string& address, const port_t port); void disconnect(); bool isConnected() const; void receive(string& buffer); size_type receiveRaw(char* buffer, const size_type count); void send(const string& buffer); void sendRaw(const char* buffer, const size_type count); size_type getBlockSize() const; private: void internalThrow(); #ifdef LIBGNUTLS_VERSION static ssize_t gnutlsPushFunc(gnutls_transport_ptr trspt, const void* data, size_t len); static ssize_t gnutlsPullFunc(gnutls_transport_ptr trspt, void* data, size_t len); #else static int gnutlsPushFunc(void* trspt, const void* data, size_t len); static int gnutlsPullFunc(void* trspt, void* data, size_t len); #endif // LIBGNUTLS_VERSION ref m_session; ref m_wrapped; bool m_connected; char m_buffer[65536]; bool m_handshaking; ref m_toHandler; exception* m_ex; }; } // tls } // net } // vmime #endif // VMIME_NET_TLS_TLSSOCKET_HPP_INCLUDED libvmime-0.9.1/vmime/net/tls/TLSSession.hpp0000644000175000017500000000475111250723264021064 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_TLS_TLSSESSION_HPP_INCLUDED #define VMIME_NET_TLS_TLSSESSION_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/net/tls/TLSSocket.hpp" #include "vmime/security/cert/certificateVerifier.hpp" namespace vmime { namespace net { namespace tls { /** Describe a TLS connection between a client and a server. */ class TLSSession : public object { friend class TLSSocket; public: ~TLSSession(); /** Create and initialize a new TLS session. * * @param cv object responsible for verifying certificates * sent by the server * @return a new TLS session */ TLSSession(ref cv); /** Create a new socket that adds a TLS security layer around * an existing socket. You should create only one socket * per session. * * @param sok socket to wrap * @return TLS socket wrapper */ ref getSocket(ref sok); /** Get the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ ref getCertificateVerifier(); private: TLSSession(const TLSSession&); static void throwTLSException(const string& fname, const int code); #ifdef LIBGNUTLS_VERSION gnutls_session* m_gnutlsSession; #else void* m_gnutlsSession; #endif // LIBGNUTLS_VERSION ref m_certVerifier; }; } // tls } // net } // vmime #endif // VMIME_NET_TLS_TLSSESSION_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/0000755000175000017500000000000011607302336016461 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/imap/IMAPSStore.hpp0000644000175000017500000000321411250723264021061 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPSSTORE_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPSSTORE_HPP_INCLUDED #include "vmime/net/imap/IMAPStore.hpp" namespace vmime { namespace net { namespace imap { /** IMAPS store service. */ class IMAPSStore : public IMAPStore { public: IMAPSStore(ref sess, ref auth); ~IMAPSStore(); const string getProtocolName() const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; private: static IMAPServiceInfos sm_infos; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPSSTORE_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPFolder.hpp0000644000175000017500000001056511250723264021064 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPFOLDER_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPFOLDER_HPP_INCLUDED #include #include #include "vmime/types.hpp" #include "vmime/net/folder.hpp" namespace vmime { namespace net { namespace imap { class IMAPStore; class IMAPMessage; class IMAPConnection; /** IMAP folder implementation. */ class IMAPFolder : public folder { private: friend class IMAPStore; friend class IMAPMessage; friend class vmime::creator; // vmime::create IMAPFolder(const folder::path& path, ref store, const int type = TYPE_UNDEFINED, const int flags = FLAG_UNDEFINED); IMAPFolder(const IMAPFolder&) : folder() { } ~IMAPFolder(); public: int getMode() const; int getType(); int getFlags(); const folder::path::component getName() const; const folder::path getFullPath() const; void open(const int mode, bool failIfModeIsNotAvailable = false); void close(const bool expunge); void create(const int type); bool exists(); void destroy(); bool isOpen() const; ref getMessage(const int num); std::vector > getMessages(const int from = 1, const int to = -1); std::vector > getMessages(const std::vector & nums); int getMessageCount(); ref getFolder(const folder::path::component& name); std::vector > getFolders(const bool recursive = false); void rename(const folder::path& newPath); void deleteMessage(const int num); void deleteMessages(const int from = 1, const int to = -1); void deleteMessages(const std::vector & nums); void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector & nums, const int flags, const int mode = message::FLAG_MODE_SET); void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); void copyMessages(const folder::path& dest, const int from = 1, const int to = -1); void copyMessages(const folder::path& dest, const std::vector & nums); void status(int& count, int& unseen); void expunge(); ref getParent(); ref getStore() const; ref getStore(); void fetchMessages(std::vector >& msg, const int options, utility::progressListener* progress = NULL); void fetchMessage(ref msg, const int options); int getFetchCapabilities() const; private: void registerMessage(IMAPMessage* msg); void unregisterMessage(IMAPMessage* msg); void onStoreDisconnected(); void onClose(); int testExistAndGetType(); void setMessageFlags(const string& set, const int flags, const int mode); void copyMessages(const string& set, const folder::path& dest); weak_ref m_store; ref m_connection; folder::path m_path; folder::path::component m_name; int m_mode; bool m_open; int m_type; int m_flags; int m_messageCount; int m_uidValidity; std::vector m_messages; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPFOLDER_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPConnection.hpp0000644000175000017500000000621211314151075021736 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPCONNECTION_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPCONNECTION_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" #include "vmime/net/session.hpp" #include "vmime/net/connectionInfos.hpp" #include "vmime/net/imap/IMAPParser.hpp" #include "vmime/security/authenticator.hpp" namespace vmime { namespace net { namespace imap { class IMAPTag; class IMAPStore; class IMAPConnection : public object { public: IMAPConnection(ref store, ref auth); ~IMAPConnection(); void connect(); bool isConnected() const; void disconnect(); enum ProtocolStates { STATE_NONE, STATE_NON_AUTHENTICATED, STATE_AUTHENTICATED, STATE_SELECTED, STATE_LOGOUT }; ProtocolStates state() const; void setState(const ProtocolStates state); char hierarchySeparator() const; void send(bool tag, const string& what, bool end); void sendRaw(const char* buffer, const int count); IMAPParser::response* readResponse(IMAPParser::literalHandler* lh = NULL); ref getTag() const; ref getParser() const; ref getStore() const; ref getStore(); ref getSession(); const std::vector getCapabilities(); ref getAuthenticator(); bool isSecuredConnection() const; ref getConnectionInfos() const; ref getSocket() const; private: void authenticate(); #if VMIME_HAVE_SASL_SUPPORT void authenticateSASL(); #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT void startTLS(); #endif // VMIME_HAVE_TLS_SUPPORT weak_ref m_store; ref m_auth; ref m_socket; ref m_parser; ref m_tag; char m_hierarchySeparator; ProtocolStates m_state; ref m_timeoutHandler; bool m_secured; ref m_cntInfos; void internalDisconnect(); void initHierarchySeparator(); }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPCONNECTION_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPServiceInfos.hpp0000644000175000017500000000441011250723264022240 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPSERVICEINFOS_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPSERVICEINFOS_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/serviceInfos.hpp" namespace vmime { namespace net { namespace imap { /** Information about IMAP service. */ class IMAPServiceInfos : public serviceInfos { public: IMAPServiceInfos(const bool imaps); struct props { // IMAP-specific options #if VMIME_HAVE_SASL_SUPPORT serviceInfos::property PROPERTY_OPTIONS_SASL; serviceInfos::property PROPERTY_OPTIONS_SASL_FALLBACK; #endif // VMIME_HAVE_SASL_SUPPORT // Common properties serviceInfos::property PROPERTY_AUTH_USERNAME; serviceInfos::property PROPERTY_AUTH_PASSWORD; #if VMIME_HAVE_TLS_SUPPORT serviceInfos::property PROPERTY_CONNECTION_TLS; serviceInfos::property PROPERTY_CONNECTION_TLS_REQUIRED; #endif // VMIME_HAVE_TLS_SUPPORT serviceInfos::property PROPERTY_SERVER_ADDRESS; serviceInfos::property PROPERTY_SERVER_PORT; }; const props& getProperties() const; const string getPropertyPrefix() const; const std::vector getAvailableProperties() const; private: const bool m_imaps; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPSERVICEINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPMessagePartContentHandler.hpp0000644000175000017500000000431311376250531024710 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPMESSAGEPARTCONTENTHANDLER_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPMESSAGEPARTCONTENTHANDLER_HPP_INCLUDED #include "vmime/contentHandler.hpp" #include "vmime/net/imap/IMAPMessage.hpp" namespace vmime { namespace net { namespace imap { class IMAPMessagePartContentHandler : public contentHandler { public: IMAPMessagePartContentHandler(ref msg, ref part, const vmime::encoding& encoding); ref clone() const; void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; string::size_type getLength() const; bool isEncoded() const; const vmime::encoding& getEncoding() const; bool isEmpty() const; bool isBuffered() const; private: weak_ref m_message; weak_ref m_part; vmime::encoding m_encoding; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPMESSAGEPARTCONTENTHANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPStore.hpp0000644000175000017500000000515711250723264020746 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPSTORE_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPSTORE_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/store.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/folder.hpp" #include "vmime/net/imap/IMAPServiceInfos.hpp" #include "vmime/net/imap/IMAPConnection.hpp" namespace vmime { namespace net { namespace imap { class IMAPParser; class IMAPTag; class IMAPFolder; /** IMAP store service. */ class IMAPStore : public store { friend class IMAPFolder; friend class IMAPMessage; friend class IMAPConnection; public: IMAPStore(ref sess, ref auth, const bool secured = false); ~IMAPStore(); const string getProtocolName() const; ref getDefaultFolder(); ref getRootFolder(); ref getFolder(const folder::path& path); bool isValidFolderName(const folder::path::component& name) const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; void connect(); bool isConnected() const; void disconnect(); void noop(); int getCapabilities() const; bool isIMAPS() const; bool isSecuredConnection() const; ref getConnectionInfos() const; protected: // Connection ref m_connection; ref connection(); void registerFolder(IMAPFolder* folder); void unregisterFolder(IMAPFolder* folder); std::list m_folders; const bool m_isIMAPS; // Use IMAPS static IMAPServiceInfos sm_infos; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPSTORE_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPStructure.hpp0000644000175000017500000000342111374205751021645 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED #include "vmime/net/message.hpp" #include "vmime/net/imap/IMAPParser.hpp" namespace vmime { namespace net { namespace imap { class IMAPPart; class IMAPStructure : public structure { public: IMAPStructure(); IMAPStructure(const IMAPParser::body* body); IMAPStructure(ref parent, const std::vector & list); ref getPartAt(const int x) const; ref getPartAt(const int x); int getPartCount() const; static ref emptyStructure(); private: std::vector > m_parts; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPParser.hpp0000644000175000017500000033455111250723264021111 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPPARSER_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPPARSER_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/dateTime.hpp" #include "vmime/charset.hpp" #include "vmime/exception.hpp" #include "vmime/utility/smartPtr.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/utility/progressListener.hpp" #include "vmime/utility/encoder/b64Encoder.hpp" #include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/platform.hpp" #include "vmime/net/timeoutHandler.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/imap/IMAPTag.hpp" #include #include //#define DEBUG_RESPONSE 1 #if DEBUG_RESPONSE # include #endif namespace vmime { namespace net { namespace imap { #if DEBUG_RESPONSE static int IMAPParserDebugResponse_level = 0; static std::vector IMAPParserDebugResponse_stack; class IMAPParserDebugResponse { public: IMAPParserDebugResponse(const string& name, string& line, const string::size_type currentPos) : m_name(name), m_line(line), m_pos(currentPos) { ++IMAPParserDebugResponse_level; IMAPParserDebugResponse_stack.push_back(name); for (int i = 0 ; i < IMAPParserDebugResponse_level ; ++i) std::cout << " "; std::cout << "ENTER(" << m_name << "), pos=" << m_pos; std::cout << std::endl; for (std::vector ::iterator it = IMAPParserDebugResponse_stack.begin() ; it != IMAPParserDebugResponse_stack.end() ; ++it) { std::cout << "> " << *it << " "; } std::cout << std::endl; std::cout << string(m_line.begin() + (m_pos < 30 ? 0U : m_pos - 30), m_line.begin() + std::min(m_line.length(), m_pos + 30)) << std::endl; for (string::size_type i = (m_pos < 30 ? m_pos : (m_pos - (m_pos - 30))) ; i != 0 ; --i) std::cout << " "; std::cout << "^" << std::endl; } ~IMAPParserDebugResponse() { for (int i = 0 ; i < IMAPParserDebugResponse_level ; ++i) std::cout << " "; std::cout << "LEAVE(" << m_name << "), result="; std::cout << (std::uncaught_exception() ? "FALSE" : "TRUE") << ", pos=" << m_pos; std::cout << std::endl; --IMAPParserDebugResponse_level; IMAPParserDebugResponse_stack.pop_back(); } private: const string& m_name; string& m_line; string::size_type m_pos; }; #define DEBUG_ENTER_COMPONENT(x) \ IMAPParserDebugResponse dbg(x, line, *currentPos) #define DEBUG_FOUND(x, y) \ std::cout << "FOUND: " << x << ": " << y << std::endl; #else #define DEBUG_ENTER_COMPONENT(x) #define DEBUG_FOUND(x, y) #endif class IMAPParser : public object { public: IMAPParser(weak_ref tag, weak_ref sok, weak_ref _timeoutHandler) : m_tag(tag), m_socket(sok), m_progress(NULL), m_strict(false), m_literalHandler(NULL), m_timeoutHandler(_timeoutHandler) { } ref getTag() const { return m_tag.acquire(); } void setSocket(ref sok) { m_socket = sok; } /** Set whether we operate in strict mode (this may not work * with some servers which are not fully standard-compliant). * * @param strict true to operate in strict mode, or false * to operate in default, relaxed mode */ void setStrict(const bool strict) { m_strict = strict; } /** Return true if the parser operates in strict mode, or * false otherwise. * * @return true if we are in strict mode, false otherwise */ bool isStrict() const { return m_strict; } const string lastLine() const { // Remove blanks and new lines at the end of the line. string line(m_lastLine); string::const_iterator it = line.end(); int count = 0; while (it != line.begin()) { const unsigned char c = *(it - 1); if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) break; ++count; --it; } line.resize(line.length() - count); return (line); } // // literalHandler : literal content handler // class component; class literalHandler { public: virtual ~literalHandler() { } // Abstract target class class target { protected: target(utility::progressListener* progress) : m_progress(progress) {} target(const target&) {} public: virtual ~target() { } utility::progressListener* progressListener() { return (m_progress); } virtual void putData(const string& chunk) = 0; private: utility::progressListener* m_progress; }; // Target: put in a string class targetString : public target { public: targetString(utility::progressListener* progress, vmime::string& str) : target(progress), m_string(str) { } const vmime::string& string() const { return (m_string); } vmime::string& string() { return (m_string); } void putData(const vmime::string& chunk) { m_string += chunk; } private: vmime::string& m_string; }; // Target: redirect to an output stream class targetStream : public target { public: targetStream(utility::progressListener* progress, utility::outputStream& stream) : target(progress), m_stream(stream) { } const utility::outputStream& stream() const { return (m_stream); } utility::outputStream& stream() { return (m_stream); } void putData(const string& chunk) { m_stream.write(chunk.data(), chunk.length()); } private: utility::outputStream& m_stream; }; // Called when the parser needs to know what to do with a literal // . comp: the component in which we are at this moment // . data: data specific to the component (may not be used) // // Returns : // . == NULL to put the literal into the response // . != NULL to redirect the literal to the specified target virtual target* targetFor(const component& comp, const int data) = 0; }; // // Base class for a terminal or a non-terminal // class component { public: component() { } virtual ~component() { } virtual void go(IMAPParser& parser, string& line, string::size_type* currentPos) = 0; const string makeResponseLine(const string& comp, const string& line, const string::size_type pos) { #if DEBUG_RESPONSE if (pos > line.length()) std::cout << "WARNING: component::makeResponseLine(): pos > line.length()" << std::endl; #endif string result(line.substr(0, pos)); result += "[^]"; // indicates current parser position result += line.substr(pos, line.length()); if (!comp.empty()) result += " [" + comp + "]"; return (result); } }; #define COMPONENT_ALIAS(parent, name) \ class name : public parent \ { \ void go(IMAPParser& parser, string& line, string::size_type* currentPos) \ { \ DEBUG_ENTER_COMPONENT(#name); \ parent::go(parser, line, currentPos); \ } \ } // // Parse one character // template class one_char : public component { public: void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT(string("one_char <") + C + ">: current='" + ((*currentPos < line.length() ? line[*currentPos] : '?')) + "'"); const string::size_type pos = *currentPos; if (pos < line.length() && line[pos] == C) *currentPos = pos + 1; else throw exceptions::invalid_response("", makeResponseLine("", line, pos)); } }; // // SPACE ::= // class SPACE : public component { public: void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("SPACE"); string::size_type pos = *currentPos; while (pos < line.length() && (line[pos] == ' ' || line[pos] == '\t')) ++pos; if (pos > *currentPos) *currentPos = pos; else throw exceptions::invalid_response("", makeResponseLine("SPACE", line, pos)); } }; // // CR ::= // LF ::= // CRLF ::= CR LF // class CRLF : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("CRLF"); string::size_type pos = *currentPos; parser.check (line, &pos, true); if (pos + 1 < line.length() && line[pos] == 0x0d && line[pos + 1] == 0x0a) { *currentPos = pos + 2; } else { throw exceptions::invalid_response("", makeResponseLine("CRLF", line, pos)); } } }; // // SPACE ::= // CTL ::= // CHAR ::= // ATOM_CHAR ::= // atom_specials ::= "(" / ")" / "{" / SPACE / CTL / list_wildcards / quoted_specials // list_wildcards ::= "%" / "*" // quoted_specials ::= <"> / "\" // // tag ::= 1* (named "xtag") // class xtag : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("tag"); string::size_type pos = *currentPos; bool end = false; string tagString; tagString.reserve(10); while (!end && pos < line.length()) { const unsigned char c = line[pos]; switch (c) { case '+': case '(': case ')': case '{': case 0x20: // SPACE case '%': // list_wildcards case '*': // list_wildcards case '"': // quoted_specials case '\\': // quoted_specials end = true; break; default: if (c <= 0x1f || c >= 0x7f) end = true; else { tagString += c; ++pos; } break; } } if (tagString == string(*parser.getTag())) { *currentPos = pos; } else { // Invalid tag throw exceptions::invalid_response("", makeResponseLine("tag", line, pos)); } } }; // // digit ::= "0" / digit_nz // digit_nz ::= "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" // // number ::= 1*digit // ;; Unsigned 32-bit integer // ;; (0 <= n < 4,294,967,296) // class number : public component { public: number(const bool nonZero = false) : m_nonZero(nonZero), m_value(0) { } void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("number"); string::size_type pos = *currentPos; bool valid = true; unsigned int val = 0; while (valid && pos < line.length()) { const char c = line[pos]; if (c >= '0' && c <= '9') { val = (val * 10) + (c - '0'); ++pos; } else { valid = false; } } // Check for non-null length (and for non-zero number) if (!(m_nonZero && val == 0) && pos != *currentPos) { m_value = val; *currentPos = pos; } else { throw exceptions::invalid_response("", makeResponseLine("number", line, pos)); } } private: const bool m_nonZero; unsigned int m_value; public: unsigned int value() const { return (m_value); } }; // nz_number ::= digit_nz *digit // ;; Non-zero unsigned 32-bit integer // ;; (0 < n < 4,294,967,296) // class nz_number : public number { public: nz_number() : number(true) { } }; // // text ::= 1*TEXT_CHAR // // CHAR ::= // TEXT_CHAR ::= // class text : public component { public: text(bool allow8bits = false, const char except = 0) : m_allow8bits(allow8bits), m_except(except) { } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("text"); string::size_type pos = *currentPos; string::size_type len = 0; if (m_allow8bits || !parser.isStrict()) { const unsigned char except = m_except; for (bool end = false ; !end && pos < line.length() ; ) { const unsigned char c = line[pos]; if (c == 0x00 || c == 0x0d || c == 0x0a || c == except) { end = true; } else { ++pos; ++len; } } } else { const unsigned char except = m_except; for (bool end = false ; !end && pos < line.length() ; ) { const unsigned char c = line[pos]; if (c < 0x01 || c > 0x7f || c == 0x0d || c == 0x0a || c == except) { end = true; } else { ++pos; ++len; } } } if (len != 0) { m_value.resize(len); std::copy(line.begin() + *currentPos, line.begin() + pos, m_value.begin()); *currentPos = pos; } else { throw exceptions::invalid_response("", makeResponseLine("text", line, pos)); } } private: string m_value; const bool m_allow8bits; const char m_except; public: const string& value() const { return (m_value); } }; class text8 : public text { public: text8() : text(true) { } }; template class text_except : public text { public: text_except() : text(false, C) { } }; template class text8_except : public text { public: text8_except() : text(true, C) { } }; // // QUOTED_CHAR ::= / "\" quoted_specials // quoted_specials ::= <"> / "\" // TEXT_CHAR ::= // CHAR ::= // class QUOTED_CHAR : public component { public: void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("quoted_char"); string::size_type pos = *currentPos; const unsigned char c = static_cast (pos < line.length() ? line[pos] : 0); if (c >= 0x01 && c <= 0x7f && // 0x01 - 0x7f c != '"' && c != '\\' && // quoted_specials c != '\r' && c != '\n') // CR and LF { m_value = c; *currentPos = pos + 1; } else if (c == '\\' && pos + 1 < line.length() && (line[pos + 1] == '"' || line[pos + 1] == '\\')) { m_value = line[pos + 1]; *currentPos = pos + 2; } else { throw exceptions::invalid_response("", makeResponseLine("QUOTED_CHAR", line, pos)); } } private: char m_value; public: char value() const { return (m_value); } }; // // quoted ::= <"> *QUOTED_CHAR <"> // QUOTED_CHAR ::= / "\" quoted_specials // quoted_specials ::= <"> / "\" // TEXT_CHAR ::= // CHAR ::= // class quoted_text : public component { public: void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("quoted_text"); string::size_type pos = *currentPos; string::size_type len = 0; bool valid = false; m_value.reserve(line.length() - pos); for (bool end = false, quoted = false ; !end && pos < line.length() ; ) { const unsigned char c = line[pos]; if (quoted) { if (c == '"' || c == '\\') m_value += c; else { m_value += '\\'; m_value += c; } quoted = false; ++pos; ++len; } else { if (c == '\\') { quoted = true; ++pos; ++len; } else if (c == '"') { valid = true; end = true; } else if (c >= 0x01 && c <= 0x7f && // CHAR c != 0x0a && c != 0x0d) // CR and LF { m_value += c; ++pos; ++len; } else { valid = false; end = true; } } } if (valid) { *currentPos = pos; } else { throw exceptions::invalid_response("", makeResponseLine("quoted_text", line, pos)); } } private: string m_value; public: const string& value() const { return (m_value); } }; // // nil ::= "NIL" // class NIL : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("NIL"); string::size_type pos = *currentPos; parser.checkWithArg (line, &pos, "nil"); *currentPos = pos; } }; // // string ::= quoted / literal ----> named 'xstring' // // nil ::= "NIL" // quoted ::= <"> *QUOTED_CHAR <"> // QUOTED_CHAR ::= / "\" quoted_specials // quoted_specials ::= <"> / "\" // TEXT_CHAR ::= // CHAR ::= // literal ::= "{" number "}" CRLF *CHAR8 // ;; Number represents the number of CHAR8 octets // CHAR8 ::= // class xstring : public component { public: xstring(const bool canBeNIL = false, component* comp = NULL, const int data = 0) : m_canBeNIL(canBeNIL), m_component(comp), m_data(data) { } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("string"); string::size_type pos = *currentPos; if (m_canBeNIL && parser.checkWithArg (line, &pos, "nil", true)) { // NIL } else { pos = *currentPos; // quoted ::= <"> *QUOTED_CHAR <"> if (parser.check >(line, &pos, true)) { utility::auto_ptr text(parser.get (line, &pos)); parser.check >(line, &pos); if (parser.m_literalHandler != NULL) { literalHandler::target* target = parser.m_literalHandler->targetFor(*m_component, m_data); if (target != NULL) { m_value = "[literal-handler]"; const string::size_type length = text->value().length(); utility::progressListener* progress = target->progressListener(); if (progress) { progress->start(length); } target->putData(text->value()); if (progress) { progress->progress(length, length); progress->stop(length); } delete (target); } else { m_value = text->value(); } } else { m_value = text->value(); } DEBUG_FOUND("string[quoted]", ""); } // literal ::= "{" number "}" CRLF *CHAR8 else { parser.check >(line, &pos); number* num = parser.get (line, &pos); const string::size_type length = num->value(); delete (num); parser.check >(line, &pos); parser.check (line, &pos); if (parser.m_literalHandler != NULL) { literalHandler::target* target = parser.m_literalHandler->targetFor(*m_component, m_data); if (target != NULL) { m_value = "[literal-handler]"; parser.m_progress = target->progressListener(); parser.readLiteral(*target, length); parser.m_progress = NULL; delete (target); } else { literalHandler::targetString target(NULL, m_value); parser.readLiteral(target, length); } } else { literalHandler::targetString target(NULL, m_value); parser.readLiteral(target, length); } line += parser.readLine(); DEBUG_FOUND("string[literal]", ""); } } *currentPos = pos; } private: bool m_canBeNIL; string m_value; component* m_component; const int m_data; public: const string& value() const { return (m_value); } }; // // nstring ::= string / nil // class nstring : public xstring { public: nstring(component* comp = NULL, const int data = 0) : xstring(true, comp, data) { } }; // // astring ::= atom / string // class astring : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("astring"); string::size_type pos = *currentPos; xstring* str = NULL; if ((str = parser.get (line, &pos, true))) { m_value = str->value(); delete (str); } else { atom* at = parser.get (line, &pos); m_value = at->value(); delete (at); } *currentPos = pos; } private: string m_value; public: const string& value() const { return (m_value); } }; // // atom ::= 1*ATOM_CHAR // // ATOM_CHAR ::= // atom_specials ::= "(" / ")" / "{" / SPACE / CTL / list_wildcards / quoted_specials // CHAR ::= // CTL ::= // list_wildcards ::= "%" / "*" // quoted_specials ::= <"> / "\" // SPACE ::= // class atom : public component { public: void go(IMAPParser& /* parser */, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("atom"); string::size_type pos = *currentPos; string::size_type len = 0; for (bool end = false ; !end && pos < line.length() ; ) { const unsigned char c = line[pos]; switch (c) { case '(': case ')': case '{': case 0x20: // SPACE case '%': // list_wildcards case '*': // list_wildcards case '"': // quoted_specials case '\\': // quoted_specials case '[': case ']': // for "special_atom" end = true; break; default: if (c <= 0x1f || c >= 0x7f) end = true; else { ++pos; ++len; } } } if (len != 0) { m_value.resize(len); std::copy(line.begin() + *currentPos, line.begin() + pos, m_value.begin()); *currentPos = pos; } else { throw exceptions::invalid_response("", makeResponseLine("atom", line, pos)); } } private: string m_value; public: const string& value() const { return (m_value); } }; // // special atom (eg. "CAPABILITY", "FLAGS", "STATUS"...) // // " Except as noted otherwise, all alphabetic characters are case- // insensitive. The use of upper or lower case characters to define // token strings is for editorial clarity only. Implementations MUST // accept these strings in a case-insensitive fashion. " // class special_atom : public atom { public: special_atom(const char* str) : m_string(str) // 'string' must be in lower-case { } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT(string("special_atom(") + m_string + ")"); string::size_type pos = *currentPos; atom::go(parser, line, &pos); const char* cmp = value().c_str(); const char* with = m_string; bool ok = true; while (ok && *cmp && *with) { ok = (std::tolower(*cmp, std::locale()) == *with); ++cmp; ++with; } if (!ok || *cmp || *with) { throw exceptions::invalid_response("", makeResponseLine(string("special_atom <") + m_string + ">", line, pos)); } else { *currentPos = pos; } } private: const char* m_string; }; // // text_mime2 ::= "=?" "?" "?" "?=" // ;; Syntax defined in [MIME-HDRS] // class text_mime2 : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("text_mime2"); string::size_type pos = *currentPos; atom* theCharset = NULL, *theEncoding = NULL; text* theText = NULL; try { parser.check >(line, &pos); theCharset = parser.get (line, &pos); parser.check >(line, &pos); theEncoding = parser.get (line, &pos); parser.check >(line, &pos); theText = parser.get >(line, &pos); parser.check >(line, &pos); parser.check value()[0] == 'Q') { // Quoted-printable theEncoder = new utility::encoder::qpEncoder(); theEncoder->getProperties()["rfc2047"] = true; } else if (theEncoding->value()[0] == 'b' || theEncoding->value()[0] == 'B') { // Base64 theEncoder = new utility::encoder::b64Encoder(); } if (theEncoder) { utility::inputStreamStringAdapter in(theText->value()); utility::outputStreamStringAdapter out(m_value); theEncoder->decode(in, out); delete (theEncoder); } // No decoder available else { m_value = theText->value(); } delete (theEncoding); delete (theText); *currentPos = pos; } private: vmime::charset m_charset; string m_value; public: const vmime::charset& charset() const { return (m_charset); } const string& value() const { return (m_value); } }; // // flag ::= "\Answered" / "\Flagged" / "\Deleted" / // "\Seen" / "\Draft" / flag_keyword / flag_extension // // flag_extension ::= "\" atom // ;; Future expansion. Client implementations // ;; MUST accept flag_extension flags. Server // ;; implementations MUST NOT generate // ;; flag_extension flags except as defined by // ;; future standard or standards-track // ;; revisions of this specification. // // flag_keyword ::= atom // class flag : public component { public: flag() : m_type(UNKNOWN), m_flag_keyword(NULL) { } ~flag() { delete (m_flag_keyword); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("flag_keyword"); string::size_type pos = *currentPos; if (parser.check >(line, &pos, true)) { if (parser.check >(line, &pos, true)) { m_type = STAR; } else { atom* at = parser.get (line, &pos); const string name = utility::stringUtils::toLower(at->value()); delete (at); if (name == "answered") m_type = ANSWERED; else if (name == "flagged") m_type = FLAGGED; else if (name == "deleted") m_type = DELETED; else if (name == "seen") m_type = SEEN; else if (name == "draft") m_type = DRAFT; else { m_type = UNKNOWN; m_name = name; } } } else { m_type = KEYWORD_OR_EXTENSION; m_flag_keyword = parser.get (line, &pos); } *currentPos = pos; } enum Type { UNKNOWN, ANSWERED, FLAGGED, DELETED, SEEN, DRAFT, KEYWORD_OR_EXTENSION, STAR // * = custom flags allowed }; private: Type m_type; string m_name; IMAPParser::atom* m_flag_keyword; public: Type type() const { return (m_type); } const string& name() const { return (m_name); } const IMAPParser::atom* flag_keyword() const { return (m_flag_keyword); } }; // // flag_list ::= "(" #flag ")" // class flag_list : public component { public: ~flag_list() { for (std::vector ::iterator it = m_flags.begin() ; it != m_flags.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("flag_list"); string::size_type pos = *currentPos; parser.check >(line, &pos); while (!parser.check >(line, &pos, true)) { m_flags.push_back(parser.get (line, &pos)); parser.check (line, &pos, true); } *currentPos = pos; } private: std::vector m_flags; public: const std::vector & flags() const { return (m_flags); } }; // // mailbox ::= "INBOX" / astring // ;; INBOX is case-insensitive. All case variants of // ;; INBOX (e.g. "iNbOx") MUST be interpreted as INBOX // ;; not as an astring. Refer to section 5.1 for // ;; further semantic details of mailbox names. // class mailbox : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("mailbox"); string::size_type pos = *currentPos; if (parser.checkWithArg (line, &pos, "inbox", true)) { m_type = INBOX; m_name = "INBOX"; } else { m_type = OTHER; astring* astr = parser.get (line, &pos); m_name = astr->value(); delete (astr); } *currentPos = pos; } enum Type { INBOX, OTHER }; private: Type m_type; string m_name; public: Type type() const { return (m_type); } const string& name() const { return (m_name); } }; // // mailbox_flag := "\Marked" / "\Noinferiors" / // "\Noselect" / "\Unmarked" / flag_extension // class mailbox_flag : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_flag"); string::size_type pos = *currentPos; if (parser.check >(line, &pos, true)) { atom* at = parser.get (line, &pos); const string name = utility::stringUtils::toLower(at->value()); delete (at); if (name == "marked") m_type = MARKED; else if (name == "noinferiors") m_type = NOINFERIORS; else if (name == "noselect") m_type = NOSELECT; else if (name == "unmarked") m_type = UNMARKED; else { m_type = UNKNOWN; m_name = "\\" + name; } } else { atom* at = parser.get (line, &pos); const string name = utility::stringUtils::toLower(at->value()); delete (at); m_type = UNKNOWN; m_name = name; } *currentPos = pos; } enum Type { UNKNOWN, MARKED, NOINFERIORS, NOSELECT, UNMARKED }; private: Type m_type; string m_name; public: Type type() const { return (m_type); } const string& name() const { return (m_name); } }; // // mailbox_flag_list ::= "(" #(mailbox_flag) ")" // class mailbox_flag_list : public component { public: ~mailbox_flag_list() { for (std::vector ::iterator it = m_flags.begin() ; it != m_flags.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_flag_list"); string::size_type pos = *currentPos; parser.check >(line, &pos); while (!parser.check >(line, &pos, true)) { m_flags.push_back(parser.get (line, &pos)); parser.check (line, &pos, true); } *currentPos = pos; } private: std::vector m_flags; public: const std::vector & flags() const { return (m_flags); } }; // // mailbox_list ::= mailbox_flag_list SPACE // (<"> QUOTED_CHAR <"> / nil) SPACE mailbox // class mailbox_list : public component { public: mailbox_list() : m_mailbox_flag_list(NULL), m_mailbox(NULL), m_quoted_char('\0') { } ~mailbox_list() { delete (m_mailbox_flag_list); delete (m_mailbox); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_list"); string::size_type pos = *currentPos; m_mailbox_flag_list = parser.get (line, &pos); parser.check (line, &pos); if (!parser.check (line, &pos, true)) { parser.check >(line, &pos); QUOTED_CHAR* qc = parser.get (line, &pos); m_quoted_char = qc->value(); delete (qc); parser.check >(line, &pos); } parser.check (line, &pos); m_mailbox = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::mailbox_flag_list* m_mailbox_flag_list; IMAPParser::mailbox* m_mailbox; char m_quoted_char; public: const IMAPParser::mailbox_flag_list* mailbox_flag_list() const { return (m_mailbox_flag_list); } const IMAPParser::mailbox* mailbox() const { return (m_mailbox); } char quoted_char() const { return (m_quoted_char); } }; // // resp_text_code ::= "ALERT" / "PARSE" / // "PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" / // "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / // "UIDVALIDITY" SPACE nz_number / // "UNSEEN" SPACE nz_number / // atom [SPACE 1*] class resp_text_code : public component { public: resp_text_code() : m_nz_number(NULL), m_atom(NULL), m_flag_list(NULL), m_text(NULL) { } ~resp_text_code() { delete (m_nz_number); delete (m_atom); delete (m_flag_list); delete (m_text); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("resp_text_code"); string::size_type pos = *currentPos; // "ALERT" if (parser.checkWithArg (line, &pos, "alert", true)) { m_type = ALERT; } // "PARSE" else if (parser.checkWithArg (line, &pos, "parse", true)) { m_type = PARSE; } // "PERMANENTFLAGS" SPACE flag_list else if (parser.checkWithArg (line, &pos, "permanentflags", true)) { m_type = PERMANENTFLAGS; parser.check (line, &pos); m_flag_list = parser.get (line, &pos); } // "READ-ONLY" else if (parser.checkWithArg (line, &pos, "read-only", true)) { m_type = READ_ONLY; } // "READ-WRITE" else if (parser.checkWithArg (line, &pos, "read-write", true)) { m_type = READ_WRITE; } // "TRYCREATE" else if (parser.checkWithArg (line, &pos, "trycreate", true)) { m_type = TRYCREATE; } // "UIDVALIDITY" SPACE nz_number else if (parser.checkWithArg (line, &pos, "uidvalidity", true)) { m_type = UIDVALIDITY; parser.check (line, &pos); m_nz_number = parser.get (line, &pos); } // "UNSEEN" SPACE nz_number else if (parser.checkWithArg (line, &pos, "unseen", true)) { m_type = UNSEEN; parser.check (line, &pos); m_nz_number = parser.get (line, &pos); } // atom [SPACE 1*] else { m_type = OTHER; m_atom = parser.get (line, &pos); if (parser.check (line, &pos, true)) m_text = parser.get >(line, &pos); } *currentPos = pos; } enum Type { ALERT, PARSE, PERMANENTFLAGS, READ_ONLY, READ_WRITE, TRYCREATE, UIDVALIDITY, UNSEEN, OTHER }; private: Type m_type; IMAPParser::nz_number* m_nz_number; IMAPParser::atom* m_atom; IMAPParser::flag_list* m_flag_list; IMAPParser::text* m_text; public: Type type() const { return (m_type); } const IMAPParser::nz_number* nz_number() const { return (m_nz_number); } const IMAPParser::atom* atom() const { return (m_atom); } const IMAPParser::flag_list* flag_list() const { return (m_flag_list); } const IMAPParser::text* text() const { return (m_text); } }; // // resp_text ::= ["[" resp_text_code "]" SPACE] (text_mime2 / text) // ;; text SHOULD NOT begin with "[" or "=" class resp_text : public component { public: resp_text() : m_resp_text_code(NULL) { } ~resp_text() { delete (m_resp_text_code); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("resp_text"); string::size_type pos = *currentPos; if (parser.check >(line, &pos, true)) { m_resp_text_code = parser.get (line, &pos); parser.check >(line, &pos); parser.check (line, &pos, true); } text_mime2* text1 = parser.get (line, &pos, true); if (text1 != NULL) { m_text = text1->value(); delete (text1); } else { IMAPParser::text* text2 = parser.get (line, &pos, true); if (text2 != NULL) { m_text = text2->value(); delete (text2); } else { // Empty response text } } *currentPos = pos; } private: IMAPParser::resp_text_code* m_resp_text_code; string m_text; public: const IMAPParser::resp_text_code* resp_text_code() const { return (m_resp_text_code); } const string& text() const { return (m_text); } }; // // continue_req ::= "+" SPACE (resp_text / base64) // class continue_req : public component { public: continue_req() : m_resp_text(NULL) { } ~continue_req() { delete (m_resp_text); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("continue_req"); string::size_type pos = *currentPos; parser.check >(line, &pos); parser.check (line, &pos); m_resp_text = parser.get (line, &pos); parser.check (line, &pos); *currentPos = pos; } private: IMAPParser::resp_text* m_resp_text; public: const IMAPParser::resp_text* resp_text() const { return (m_resp_text); } }; // // auth_type ::= atom // ;; Defined by [IMAP-AUTH] // class auth_type : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("auth_type"); atom* at = parser.get (line, currentPos); m_name = utility::stringUtils::toLower(at->value()); delete (at); if (m_name == "kerberos_v4") m_type = KERBEROS_V4; else if (m_name == "gssapi") m_type = GSSAPI; else if (m_name == "skey") m_type = SKEY; else m_type = UNKNOWN; } enum Type { UNKNOWN, // RFC 1731 - IMAP4 Authentication Mechanisms KERBEROS_V4, GSSAPI, SKEY }; private: Type m_type; string m_name; public: Type type() const { return (m_type); } const string name() const { return (m_name); } }; // // status_att ::= "MESSAGES" / "RECENT" / "UIDNEXT" / // "UIDVALIDITY" / "UNSEEN" // class status_att : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("status_att"); string::size_type pos = *currentPos; if (parser.checkWithArg (line, &pos, "messages", true)) { m_type = MESSAGES; } else if (parser.checkWithArg (line, &pos, "recent", true)) { m_type = RECENT; } else if (parser.checkWithArg (line, &pos, "uidnext", true)) { m_type = UIDNEXT; } else if (parser.checkWithArg (line, &pos, "uidvalidity", true)) { m_type = UIDVALIDITY; } else { parser.checkWithArg (line, &pos, "unseen"); m_type = UNSEEN; } *currentPos = pos; } enum Type { MESSAGES, RECENT, UIDNEXT, UIDVALIDITY, UNSEEN }; private: Type m_type; public: Type type() const { return (m_type); } }; // // capability ::= "AUTH=" auth_type / atom // ;; New capabilities MUST begin with "X" or be // ;; registered with IANA as standard or standards-track // class capability : public component { public: capability() : m_auth_type(NULL), m_atom(NULL) { } ~capability() { delete (m_auth_type); delete (m_atom); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("capability"); string::size_type pos = *currentPos; class atom* at = parser.get (line, &pos); string value = at->value(); const char* str = value.c_str(); if ((str[0] == 'a' || str[0] == 'A') && (str[1] == 'u' || str[1] == 'U') && (str[2] == 't' || str[2] == 'T') && (str[3] == 'h' || str[3] == 'H') && (str[4] == '=')) { string::size_type pos = 5; m_auth_type = parser.get (value, &pos); delete (at); } else { m_atom = at; } *currentPos = pos; } private: IMAPParser::auth_type* m_auth_type; IMAPParser::atom* m_atom; public: const IMAPParser::auth_type* auth_type() const { return (m_auth_type); } const IMAPParser::atom* atom() const { return (m_atom); } }; // // capability_data ::= "CAPABILITY" SPACE [1#capability SPACE] "IMAP4rev1" // [SPACE 1#capability] // ;; IMAP4rev1 servers which offer RFC 1730 // ;; compatibility MUST list "IMAP4" as the first // ;; capability. // class capability_data : public component { public: ~capability_data() { for (std::vector ::iterator it = m_capabilities.begin() ; it != m_capabilities.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("capability_data"); string::size_type pos = *currentPos; parser.checkWithArg (line, &pos, "capability"); while (parser.check (line, &pos, true)) { capability* cap = parser.get (line, &pos); if (cap == NULL) break; m_capabilities.push_back(cap); } *currentPos = pos; } private: std::vector m_capabilities; public: const std::vector & capabilities() const { return (m_capabilities); } }; // // date_day_fixed ::= (SPACE digit) / 2digit // ;; Fixed-format version of date_day // // date_month ::= "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / // "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" // // date_year ::= 4digit // // time ::= 2digit ":" 2digit ":" 2digit // ;; Hours minutes seconds // // zone ::= ("+" / "-") 4digit // ;; Signed four-digit value of hhmm representing // ;; hours and minutes west of Greenwich (that is, // ;; (the amount that the given time differs from // ;; Universal Time). Subtracting the timezone // ;; from the given time will give the UT form. // ;; The Universal Time zone is "+0000". // // date_time ::= <"> date_day_fixed "-" date_month "-" date_year // SPACE time SPACE zone <"> // class date_time : public component { public: void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("date_time"); string::size_type pos = *currentPos; // <"> date_day_fixed "-" date_month "-" date_year parser.check >(line, &pos); parser.check (line, &pos, true); utility::auto_ptr nd(parser.get (line, &pos)); parser.check >(line, &pos); utility::auto_ptr amo(parser.get (line, &pos)); parser.check >(line, &pos); utility::auto_ptr ny(parser.get (line, &pos)); parser.check (line, &pos, true); // 2digit ":" 2digit ":" 2digit utility::auto_ptr nh(parser.get (line, &pos)); parser.check >(line, &pos); utility::auto_ptr nmi(parser.get (line, &pos)); parser.check >(line, &pos); utility::auto_ptr ns(parser.get (line, &pos)); parser.check (line, &pos, true); // ("+" / "-") 4digit int sign = 1; if (!(parser.check >(line, &pos, true))) parser.check >(line, &pos); utility::auto_ptr nz(parser.get (line, &pos)); parser.check >(line, &pos); m_datetime.setHour(std::min(std::max(nh->value(), 0u), 23u)); m_datetime.setMinute(std::min(std::max(nmi->value(), 0u), 59u)); m_datetime.setSecond(std::min(std::max(ns->value(), 0u), 59u)); const int zone = static_cast (nz->value()); const int zh = zone / 100; // hour offset const int zm = zone % 100; // minute offset m_datetime.setZone(((zh * 60) + zm) * sign); m_datetime.setDay(std::min(std::max(nd->value(), 1u), 31u)); m_datetime.setYear(ny->value()); const string month(utility::stringUtils::toLower(amo->value())); int mon = vmime::datetime::JANUARY; if (month.length() >= 3) { switch (month[0]) { case 'j': { switch (month[1]) { case 'a': mon = vmime::datetime::JANUARY; break; case 'u': { switch (month[2]) { case 'n': mon = vmime::datetime::JUNE; break; default: mon = vmime::datetime::JULY; break; } break; } } break; } case 'f': mon = vmime::datetime::FEBRUARY; break; case 'm': { switch (month[2]) { case 'r': mon = vmime::datetime::MARCH; break; default: mon = vmime::datetime::MAY; break; } break; } case 'a': { switch (month[1]) { case 'p': mon = vmime::datetime::APRIL; break; default: mon = vmime::datetime::AUGUST; break; } break; } case 's': mon = vmime::datetime::SEPTEMBER; break; case 'o': mon = vmime::datetime::OCTOBER; break; case 'n': mon = vmime::datetime::NOVEMBER; break; case 'd': mon = vmime::datetime::DECEMBER; break; } } m_datetime.setMonth(mon); *currentPos = pos; } private: vmime::datetime m_datetime; }; // // header_fld_name ::= astring // typedef astring header_fld_name; // // header_list ::= "(" 1#header_fld_name ")" // class header_list : public component { public: ~header_list() { for (std::vector ::iterator it = m_fld_names.begin() ; it != m_fld_names.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("header_list"); string::size_type pos = *currentPos; parser.check >(line, &pos); while (!parser.check >(line, &pos, true)) { m_fld_names.push_back(parser.get (line, &pos)); parser.check (line, &pos, true); } *currentPos = pos; } private: std::vector m_fld_names; public: const std::vector & fld_names() const { return (m_fld_names); } }; // // body_extension ::= nstring / number / "(" 1#body_extension ")" // ;; Future expansion. Client implementations // ;; MUST accept body_extension fields. Server // ;; implementations MUST NOT generate // ;; body_extension fields except as defined by // ;; future standard or standards-track // ;; revisions of this specification. // class body_extension : public component { public: body_extension() : m_nstring(NULL), m_number(NULL) { } ~body_extension() { delete (m_nstring); delete (m_number); for (std::vector ::iterator it = m_body_extensions.begin() ; it != m_body_extensions.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { string::size_type pos = *currentPos; if (parser.check >(line, &pos, true)) { m_body_extensions.push_back (parser.get (line, &pos)); while (!parser.check >(line, &pos, true)) { m_body_extensions.push_back(parser.get (line, &pos)); parser.check (line, &pos, true); } } else { if (!(m_nstring = parser.get (line, &pos, true))) m_number = parser.get (line, &pos); } *currentPos = pos; } private: IMAPParser::nstring* m_nstring; IMAPParser::number* m_number; std::vector m_body_extensions; public: IMAPParser::nstring* nstring() const { return (m_nstring); } IMAPParser::number* number() const { return (m_number); } const std::vector & body_extensions() const { return (m_body_extensions); } }; // // section_text ::= "HEADER" / "HEADER.FIELDS" [".NOT"] // SPACE header_list / "TEXT" / "MIME" // class section_text : public component { public: section_text() : m_header_list(NULL) { } ~section_text() { delete (m_header_list); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("section_text"); string::size_type pos = *currentPos; // "HEADER.FIELDS" [".NOT"] SPACE header_list const bool b1 = parser.checkWithArg (line, &pos, "header.fields.not", true); const bool b2 = (b1 ? false : parser.checkWithArg (line, &pos, "header.fields", true)); if (b1 || b2) { m_type = b1 ? HEADER_FIELDS_NOT : HEADER_FIELDS; parser.check (line, &pos); m_header_list = parser.get (line, &pos); } // "HEADER" else if (parser.checkWithArg (line, &pos, "header", true)) { m_type = HEADER; } // "MIME" else if (parser.checkWithArg (line, &pos, "mime", true)) { m_type = MIME; } // "TEXT" else { m_type = TEXT; parser.checkWithArg (line, &pos, "text"); } *currentPos = pos; } enum Type { HEADER, HEADER_FIELDS, HEADER_FIELDS_NOT, MIME, TEXT }; private: Type m_type; IMAPParser::header_list* m_header_list; public: Type type() const { return (m_type); } const IMAPParser::header_list* header_list() const { return (m_header_list); } }; // // section ::= "[" [section_text / (nz_number *["." nz_number] // ["." (section_text / "MIME")])] "]" // class section : public component { public: section() : m_section_text1(NULL), m_section_text2(NULL) { } ~section() { delete (m_section_text1); delete (m_section_text2); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("section"); string::size_type pos = *currentPos; parser.check >(line, &pos); if (!parser.check >(line, &pos, true)) { if (!(m_section_text1 = parser.get (line, &pos, true))) { nz_number* num = parser.get (line, &pos); m_nz_numbers.push_back(num->value()); delete (num); while (parser.check >(line, &pos, true)) { if ((num = parser.get (line, &pos, true))) { m_nz_numbers.push_back(num->value()); delete (num); } else { m_section_text2 = parser.get (line, &pos); break; } } } parser.check >(line, &pos); } *currentPos = pos; } private: section_text* m_section_text1; section_text* m_section_text2; std::vector m_nz_numbers; public: const section_text* section_text1() const { return (m_section_text1); } const section_text* section_text2() const { return (m_section_text2); } const std::vector & nz_numbers() const { return (m_nz_numbers); } }; // // addr_adl ::= nstring // ;; Holds route from [RFC-822] route-addr if // ;; non-NIL // // addr_host ::= nstring // ;; NIL indicates [RFC-822] group syntax. // ;; Otherwise, holds [RFC-822] domain name // // addr_mailbox ::= nstring // ;; NIL indicates end of [RFC-822] group; if // ;; non-NIL and addr_host is NIL, holds // ;; [RFC-822] group name. // ;; Otherwise, holds [RFC-822] local-part // // addr_name ::= nstring // ;; Holds phrase from [RFC-822] mailbox if // ;; non-NIL // // address ::= "(" addr_name SPACE addr_adl SPACE addr_mailbox // SPACE addr_host ")" // class address : public component { public: address() : m_addr_name(NULL), m_addr_adl(NULL), m_addr_mailbox(NULL), m_addr_host(NULL) { } ~address() { delete (m_addr_name); delete (m_addr_adl); delete (m_addr_mailbox); delete (m_addr_host); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("address"); string::size_type pos = *currentPos; parser.check >(line, &pos); m_addr_name = parser.get (line, &pos); parser.check (line, &pos); m_addr_adl = parser.get (line, &pos); parser.check (line, &pos); m_addr_mailbox = parser.get (line, &pos); parser.check (line, &pos); m_addr_host = parser.get (line, &pos); parser.check >(line, &pos); *currentPos = pos; } private: nstring* m_addr_name; nstring* m_addr_adl; nstring* m_addr_mailbox; nstring* m_addr_host; public: nstring* addr_name() const { return (m_addr_name); } nstring* addr_adl() const { return (m_addr_adl); } nstring* addr_mailbox() const { return (m_addr_mailbox); } nstring* addr_host() const { return (m_addr_host); } }; // // address_list ::= "(" 1*address ")" / nil // class address_list : public component { public: ~address_list() { for (std::vector ::iterator it = m_addresses.begin() ; it != m_addresses.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("address_list"); string::size_type pos = *currentPos; if (!parser.check (line, &pos, true)) { parser.check >(line, &pos); while (!parser.check >(line, &pos, true)) { m_addresses.push_back(parser.get
(line, &pos)); parser.check (line, &pos, true); } } *currentPos = pos; } private: std::vector m_addresses; public: const std::vector & addresses() const { return (m_addresses); } }; // // env_bcc ::= "(" 1*address ")" / nil // COMPONENT_ALIAS(address_list, env_bcc); // // env_cc ::= "(" 1*address ")" / nil // COMPONENT_ALIAS(address_list, env_cc); // // env_date ::= nstring // COMPONENT_ALIAS(nstring, env_date); // // env_from ::= "(" 1*address ")" / nil // COMPONENT_ALIAS(address_list, env_from); // // env_in_reply_to ::= nstring // COMPONENT_ALIAS(nstring, env_in_reply_to); // // env_message_id ::= nstring // COMPONENT_ALIAS(nstring, env_message_id); // // env_reply_to ::= "(" 1*address ")" / nil // COMPONENT_ALIAS(address_list, env_reply_to); // // env_sender ::= "(" 1*address ")" / nil // COMPONENT_ALIAS(address_list, env_sender); // // env_subject ::= nstring // COMPONENT_ALIAS(nstring, env_subject); // // env_to ::= "(" 1*address ")" / nil // COMPONENT_ALIAS(address_list, env_to); // // envelope ::= "(" env_date SPACE env_subject SPACE env_from // SPACE env_sender SPACE env_reply_to SPACE env_to // SPACE env_cc SPACE env_bcc SPACE env_in_reply_to // SPACE env_message_id ")" // class envelope : public component { public: envelope() : m_env_date(NULL), m_env_subject(NULL), m_env_from(NULL), m_env_sender(NULL), m_env_reply_to(NULL), m_env_to(NULL), m_env_cc(NULL), m_env_bcc(NULL), m_env_in_reply_to(NULL), m_env_message_id(NULL) { } ~envelope() { delete (m_env_date); delete (m_env_subject); delete (m_env_from); delete (m_env_sender); delete (m_env_reply_to); delete (m_env_to); delete (m_env_cc); delete (m_env_bcc); delete (m_env_in_reply_to); delete (m_env_message_id); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("envelope"); string::size_type pos = *currentPos; parser.check >(line, &pos); m_env_date = parser.get (line, &pos); parser.check (line, &pos); m_env_subject = parser.get (line, &pos); parser.check (line, &pos); m_env_from = parser.get (line, &pos); parser.check (line, &pos); m_env_sender = parser.get (line, &pos); parser.check (line, &pos); m_env_reply_to = parser.get (line, &pos); parser.check (line, &pos); m_env_to = parser.get (line, &pos); parser.check (line, &pos); m_env_cc = parser.get (line, &pos); parser.check (line, &pos); m_env_bcc = parser.get (line, &pos); parser.check (line, &pos); m_env_in_reply_to = parser.get (line, &pos); parser.check (line, &pos); m_env_message_id = parser.get (line, &pos); parser.check >(line, &pos); *currentPos = pos; } private: IMAPParser::env_date* m_env_date; IMAPParser::env_subject* m_env_subject; IMAPParser::env_from* m_env_from; IMAPParser::env_sender* m_env_sender; IMAPParser::env_reply_to* m_env_reply_to; IMAPParser::env_to* m_env_to; IMAPParser::env_cc* m_env_cc; IMAPParser::env_bcc* m_env_bcc; IMAPParser::env_in_reply_to* m_env_in_reply_to; IMAPParser::env_message_id* m_env_message_id; public: const IMAPParser::env_date* env_date() const { return (m_env_date); } const IMAPParser::env_subject* env_subject() const { return (m_env_subject); } const IMAPParser::env_from* env_from() const { return (m_env_from); } const IMAPParser::env_sender* env_sender() const { return (m_env_sender); } const IMAPParser::env_reply_to* env_reply_to() const { return (m_env_reply_to); } const IMAPParser::env_to* env_to() const { return (m_env_to); } const IMAPParser::env_cc* env_cc() const { return (m_env_cc); } const IMAPParser::env_bcc* env_bcc() const { return (m_env_bcc); } const IMAPParser::env_in_reply_to* env_in_reply_to() const { return (m_env_in_reply_to); } const IMAPParser::env_message_id* env_message_id() const { return (m_env_message_id); } }; // // body_fld_desc ::= nstring // typedef nstring body_fld_desc; // // body_fld_id ::= nstring // typedef nstring body_fld_id; // // body_fld_md5 ::= nstring // typedef nstring body_fld_md5; // // body_fld_octets ::= number // typedef number body_fld_octets; // // body_fld_lines ::= number // typedef number body_fld_lines; // // body_fld_enc ::= (<"> ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ // "QUOTED-PRINTABLE") <">) / string // typedef xstring body_fld_enc; // // body_fld_param_item ::= string SPACE string // class body_fld_param_item : public component { public: body_fld_param_item() : m_string1(NULL), m_string2(NULL) { } ~body_fld_param_item() { delete (m_string1); delete (m_string2); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_param_item"); string::size_type pos = *currentPos; m_string1 = parser.get (line, &pos); parser.check (line, &pos); m_string2 = parser.get (line, &pos); DEBUG_FOUND("body_fld_param_item", "<" << m_string1->value() << ", " << m_string2->value() << ">"); *currentPos = pos; } private: xstring* m_string1; xstring* m_string2; public: const xstring* string1() const { return (m_string1); } const xstring* string2() const { return (m_string2); } }; // // body_fld_param ::= "(" 1#(body_fld_param_item) ")" / nil // class body_fld_param : public component { public: ~body_fld_param() { for (std::vector ::iterator it = m_items.begin() ; it != m_items.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_param"); string::size_type pos = *currentPos; if (parser.check >(line, &pos, true)) { m_items.push_back(parser.get (line, &pos)); while (!parser.check >(line, &pos, true)) { parser.check (line, &pos); m_items.push_back(parser.get (line, &pos)); } } else { parser.check (line, &pos); } *currentPos = pos; } private: std::vector m_items; public: const std::vector & items() const { return (m_items); } }; // // body_fld_dsp ::= "(" string SPACE body_fld_param ")" / nil // class body_fld_dsp : public component { public: body_fld_dsp() : m_string(NULL), m_body_fld_param(NULL) { } ~body_fld_dsp() { delete (m_string); delete (m_body_fld_param); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_dsp"); string::size_type pos = *currentPos; if (parser.check >(line, &pos, true)) { m_string = parser.get (line, &pos); parser.check (line, &pos); m_body_fld_param = parser.get (line, &pos); parser.check >(line, &pos); } else { parser.check (line, &pos); } *currentPos = pos; } private: class xstring* m_string; class body_fld_param* m_body_fld_param; public: const class xstring* str() const { return (m_string); } const class body_fld_param* body_fld_param() const { return (m_body_fld_param); } }; // // body_fld_lang ::= nstring / "(" 1#string ")" // class body_fld_lang : public component { public: ~body_fld_lang() { for (std::vector ::iterator it = m_strings.begin() ; it != m_strings.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_fld_lang"); string::size_type pos = *currentPos; if (parser.check >(line, &pos, true)) { m_strings.push_back(parser.get (line, &pos)); while (!parser.check >(line, &pos, true)) { parser.check (line, &pos); m_strings.push_back(parser.get (line, &pos)); } } else { m_strings.push_back(parser.get (line, &pos)); } *currentPos = pos; } private: std::vector m_strings; public: const std::vector & strings() const { return (m_strings); } }; // // body_fields ::= body_fld_param SPACE body_fld_id SPACE // body_fld_desc SPACE body_fld_enc SPACE // body_fld_octets // class body_fields : public component { public: body_fields() : m_body_fld_param(NULL), m_body_fld_id(NULL), m_body_fld_desc(NULL), m_body_fld_enc(NULL), m_body_fld_octets(NULL) { } ~body_fields() { delete (m_body_fld_param); delete (m_body_fld_id); delete (m_body_fld_desc); delete (m_body_fld_enc); delete (m_body_fld_octets); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_fields"); string::size_type pos = *currentPos; m_body_fld_param = parser.get (line, &pos); parser.check (line, &pos); m_body_fld_id = parser.get (line, &pos); parser.check (line, &pos); m_body_fld_desc = parser.get (line, &pos); parser.check (line, &pos); m_body_fld_enc = parser.get (line, &pos); parser.check (line, &pos); m_body_fld_octets = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::body_fld_param* m_body_fld_param; IMAPParser::body_fld_id* m_body_fld_id; IMAPParser::body_fld_desc* m_body_fld_desc; IMAPParser::body_fld_enc* m_body_fld_enc; IMAPParser::body_fld_octets* m_body_fld_octets; public: const IMAPParser::body_fld_param* body_fld_param() const { return (m_body_fld_param); } const IMAPParser::body_fld_id* body_fld_id() const { return (m_body_fld_id); } const IMAPParser::body_fld_desc* body_fld_desc() const { return (m_body_fld_desc); } const IMAPParser::body_fld_enc* body_fld_enc() const { return (m_body_fld_enc); } const IMAPParser::body_fld_octets* body_fld_octets() const { return (m_body_fld_octets); } }; // // media_subtype ::= string // ;; Defined in [MIME-IMT] // typedef xstring media_subtype; // // media_text ::= <"> "TEXT" <"> SPACE media_subtype // ;; Defined in [MIME-IMT] // class media_text : public component { public: media_text() : m_media_subtype(NULL) { } ~media_text() { delete (m_media_subtype); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("media_text"); string::size_type pos = *currentPos; parser.check >(line, &pos); parser.checkWithArg (line, &pos, "text"); parser.check >(line, &pos); parser.check (line, &pos); m_media_subtype = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::media_subtype* m_media_subtype; public: const IMAPParser::media_subtype* media_subtype() const { return (m_media_subtype); } }; // // media_message ::= <"> "MESSAGE" <"> SPACE <"> "RFC822" <"> // ;; Defined in [MIME-IMT] // class media_message : public component { public: media_message() : m_media_subtype(NULL) { } ~media_message() { delete m_media_subtype; } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("media_message"); string::size_type pos = *currentPos; parser.check >(line, &pos); parser.checkWithArg (line, &pos, "message"); parser.check >(line, &pos); parser.check (line, &pos); //parser.check >(line, &pos); //parser.checkWithArg (line, &pos, "rfc822"); //parser.check >(line, &pos); m_media_subtype = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::media_subtype* m_media_subtype; public: const IMAPParser::media_subtype* media_subtype() const { return (m_media_subtype); } }; // // media_basic ::= (<"> ("APPLICATION" / "AUDIO" / "IMAGE" / // "MESSAGE" / "VIDEO") <">) / string) // SPACE media_subtype // ;; Defined in [MIME-IMT] class media_basic : public component { public: media_basic() : m_media_type(NULL), m_media_subtype(NULL) { } ~media_basic() { delete (m_media_type); delete (m_media_subtype); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("media_basic"); string::size_type pos = *currentPos; m_media_type = parser.get (line, &pos); parser.check (line, &pos); m_media_subtype = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::xstring* m_media_type; IMAPParser::media_subtype* m_media_subtype; public: const IMAPParser::xstring* media_type() const { return (m_media_type); } const IMAPParser::media_subtype* media_subtype() const { return (m_media_subtype); } }; // // body_ext_1part ::= body_fld_md5 [SPACE body_fld_dsp // [SPACE body_fld_lang // [SPACE 1#body_extension]]] // ;; MUST NOT be returned on non-extensible // ;; "BODY" fetch // class body_ext_1part : public component { public: body_ext_1part() : m_body_fld_md5(NULL), m_body_fld_dsp(NULL), m_body_fld_lang(NULL) { } ~body_ext_1part() { delete (m_body_fld_md5); delete (m_body_fld_dsp); delete (m_body_fld_lang); for (std::vector ::iterator it = m_body_extensions.begin() ; it != m_body_extensions.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_ext_1part"); string::size_type pos = *currentPos; m_body_fld_md5 = parser.get (line, &pos); // [SPACE body_fld_dsp if (parser.check (line, &pos, true)) { m_body_fld_dsp = parser.get (line, &pos); // [SPACE body_fld_lang if (parser.check (line, &pos, true)) { m_body_fld_lang = parser.get (line, &pos); // [SPACE 1#body_extension] if (parser.check (line, &pos, true)) { m_body_extensions.push_back (parser.get (line, &pos)); parser.check (line, &pos, true); body_extension* ext = NULL; while ((ext = parser.get (line, &pos, true)) != NULL) { m_body_extensions.push_back(ext); parser.check (line, &pos, true); } } } } *currentPos = pos; } private: IMAPParser::body_fld_md5* m_body_fld_md5; IMAPParser::body_fld_dsp* m_body_fld_dsp; IMAPParser::body_fld_lang* m_body_fld_lang; std::vector m_body_extensions; public: const IMAPParser::body_fld_md5* body_fld_md5() const { return (m_body_fld_md5); } const IMAPParser::body_fld_dsp* body_fld_dsp() const { return (m_body_fld_dsp); } const IMAPParser::body_fld_lang* body_fld_lang() const { return (m_body_fld_lang); } const std::vector body_extensions() const { return (m_body_extensions); } }; // // body_ext_mpart ::= body_fld_param // [SPACE body_fld_dsp SPACE body_fld_lang // [SPACE 1#body_extension]] // ;; MUST NOT be returned on non-extensible // ;; "BODY" fetch class body_ext_mpart : public component { public: body_ext_mpart() : m_body_fld_param(NULL), m_body_fld_dsp(NULL), m_body_fld_lang(NULL) { } ~body_ext_mpart() { delete (m_body_fld_param); delete (m_body_fld_dsp); delete (m_body_fld_lang); for (std::vector ::iterator it = m_body_extensions.begin() ; it != m_body_extensions.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_ext_mpart"); string::size_type pos = *currentPos; m_body_fld_param = parser.get (line, &pos); // [SPACE body_fld_dsp SPACE body_fld_lang [SPACE 1#body_extension]] if (parser.check (line, &pos, true)) { m_body_fld_dsp = parser.get (line, &pos); parser.check (line, &pos); m_body_fld_lang = parser.get (line, &pos); // [SPACE 1#body_extension] if (parser.check (line, &pos, true)) { m_body_extensions.push_back (parser.get (line, &pos)); parser.check (line, &pos, true); body_extension* ext = NULL; while ((ext = parser.get (line, &pos, true)) != NULL) { m_body_extensions.push_back(ext); parser.check (line, &pos, true); } } } *currentPos = pos; } private: IMAPParser::body_fld_param* m_body_fld_param; IMAPParser::body_fld_dsp* m_body_fld_dsp; IMAPParser::body_fld_lang* m_body_fld_lang; std::vector m_body_extensions; public: const IMAPParser::body_fld_param* body_fld_param() const { return (m_body_fld_param); } const IMAPParser::body_fld_dsp* body_fld_dsp() const { return (m_body_fld_dsp); } const IMAPParser::body_fld_lang* body_fld_lang() const { return (m_body_fld_lang); } const std::vector body_extensions() const { return (m_body_extensions); } }; // // body_type_basic ::= media_basic SPACE body_fields // ;; MESSAGE subtype MUST NOT be "RFC822" // class body_type_basic : public component { public: body_type_basic() : m_media_basic(NULL), m_body_fields(NULL) { } ~body_type_basic() { delete (m_media_basic); delete (m_body_fields); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_type_basic"); string::size_type pos = *currentPos; m_media_basic = parser.get (line, &pos); parser.check (line, &pos); m_body_fields = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::media_basic* m_media_basic; IMAPParser::body_fields* m_body_fields; public: const IMAPParser::media_basic* media_basic() const { return (m_media_basic); } const IMAPParser::body_fields* body_fields() const { return (m_body_fields); } }; // // body_type_msg ::= media_message SPACE body_fields SPACE envelope // SPACE body SPACE body_fld_lines // class xbody; typedef xbody body; class body_type_msg : public component { public: body_type_msg() : m_media_message(NULL), m_body_fields(NULL), m_envelope(NULL), m_body(NULL), m_body_fld_lines(NULL) { } ~body_type_msg() { delete (m_media_message); delete (m_body_fields); delete (m_envelope); delete (m_body); delete (m_body_fld_lines); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_type_msg"); string::size_type pos = *currentPos; m_media_message = parser.get (line, &pos); parser.check (line, &pos); m_body_fields = parser.get (line, &pos); parser.check (line, &pos); // BUGFIX: made SPACE optional. This is not standard, but some servers // seem to return responses like that... m_envelope = parser.get (line, &pos); parser.check (line, &pos, true); m_body = parser.get (line, &pos); parser.check (line, &pos, true); m_body_fld_lines = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::media_message* m_media_message; IMAPParser::body_fields* m_body_fields; IMAPParser::envelope* m_envelope; IMAPParser::xbody* m_body; IMAPParser::body_fld_lines* m_body_fld_lines; public: const IMAPParser::media_message* media_message() const { return (m_media_message); } const IMAPParser::body_fields* body_fields() const { return (m_body_fields); } const IMAPParser::envelope* envelope() const { return (m_envelope); } const IMAPParser::xbody* body() const { return (m_body); } const IMAPParser::body_fld_lines* body_fld_lines() const { return (m_body_fld_lines); } }; // // body_type_text ::= media_text SPACE body_fields SPACE body_fld_lines // class body_type_text : public component { public: body_type_text() : m_media_text(NULL), m_body_fields(NULL), m_body_fld_lines(NULL) { } ~body_type_text() { delete (m_media_text); delete (m_body_fields); delete (m_body_fld_lines); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_type_text"); string::size_type pos = *currentPos; m_media_text = parser.get (line, &pos); parser.check (line, &pos); m_body_fields = parser.get (line, &pos); parser.check (line, &pos); m_body_fld_lines = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::media_text* m_media_text; IMAPParser::body_fields* m_body_fields; IMAPParser::body_fld_lines* m_body_fld_lines; public: const IMAPParser::media_text* media_text() const { return (m_media_text); } const IMAPParser::body_fields* body_fields() const { return (m_body_fields); } const IMAPParser::body_fld_lines* body_fld_lines() const { return (m_body_fld_lines); } }; // // body_type_1part ::= (body_type_basic / body_type_msg / body_type_text) // [SPACE body_ext_1part] // class body_type_1part : public component { public: body_type_1part() : m_body_type_basic(NULL), m_body_type_msg(NULL), m_body_type_text(NULL), m_body_ext_1part(NULL) { } ~body_type_1part() { delete (m_body_type_basic); delete (m_body_type_msg); delete (m_body_type_text); delete (m_body_ext_1part); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_type_1part"); string::size_type pos = *currentPos; if (!(m_body_type_text = parser.get (line, &pos, true))) if (!(m_body_type_msg = parser.get (line, &pos, true))) m_body_type_basic = parser.get (line, &pos); if (parser.check (line, &pos, true)) { m_body_ext_1part = parser.get (line, &pos, true); if (!m_body_ext_1part) --pos; } *currentPos = pos; } private: IMAPParser::body_type_basic* m_body_type_basic; IMAPParser::body_type_msg* m_body_type_msg; IMAPParser::body_type_text* m_body_type_text; IMAPParser::body_ext_1part* m_body_ext_1part; public: const IMAPParser::body_type_basic* body_type_basic() const { return (m_body_type_basic); } const IMAPParser::body_type_msg* body_type_msg() const { return (m_body_type_msg); } const IMAPParser::body_type_text* body_type_text() const { return (m_body_type_text); } const IMAPParser::body_ext_1part* body_ext_1part() const { return (m_body_ext_1part); } }; // // body_type_mpart ::= 1*body SPACE media_subtype // [SPACE body_ext_mpart] // class body_type_mpart : public component { public: body_type_mpart() : m_media_subtype(NULL), m_body_ext_mpart(NULL) { } ~body_type_mpart() { delete (m_media_subtype); delete (m_body_ext_mpart); for (std::vector ::iterator it = m_list.begin() ; it != m_list.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body_type_mpart"); string::size_type pos = *currentPos; m_list.push_back(parser.get (line, &pos)); for (xbody* b ; (b = parser.get (line, &pos, true)) ; ) m_list.push_back(b); parser.check (line, &pos); m_media_subtype = parser.get (line, &pos); if (parser.check (line, &pos, true)) m_body_ext_mpart = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::media_subtype* m_media_subtype; IMAPParser::body_ext_mpart* m_body_ext_mpart; std::vector m_list; public: const std::vector & list() const { return (m_list); } const IMAPParser::media_subtype* media_subtype() const { return (m_media_subtype); } const IMAPParser::body_ext_mpart* body_ext_mpart() const { return (m_body_ext_mpart); } }; // // xbody ::= "(" body_type_1part / body_type_mpart ")" // class xbody : public component { public: xbody() : m_body_type_1part(NULL), m_body_type_mpart(NULL) { } ~xbody() { delete (m_body_type_1part); delete (m_body_type_mpart); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("body"); string::size_type pos = *currentPos; parser.check >(line, &pos); if (!(m_body_type_mpart = parser.get (line, &pos, true))) m_body_type_1part = parser.get (line, &pos); parser.check >(line, &pos); *currentPos = pos; } private: IMAPParser::body_type_1part* m_body_type_1part; IMAPParser::body_type_mpart* m_body_type_mpart; public: const IMAPParser::body_type_1part* body_type_1part() const { return (m_body_type_1part); } const IMAPParser::body_type_mpart* body_type_mpart() const { return (m_body_type_mpart); } }; // // uniqueid ::= nz_number // ;; Strictly ascending // // msg_att_item ::= "ENVELOPE" SPACE envelope / // "FLAGS" SPACE "(" #(flag / "\Recent") ")" / // "INTERNALDATE" SPACE date_time / // "RFC822" [".HEADER" / ".TEXT"] SPACE nstring / // "RFC822.SIZE" SPACE number / // "BODY" ["STRUCTURE"] SPACE body / // "BODY" section ["<" number ">"] SPACE nstring / // "UID" SPACE uniqueid // class msg_att_item : public component { public: msg_att_item() : m_date_time(NULL), m_number(NULL), m_envelope(NULL), m_uniqueid(NULL), m_nstring(NULL), m_body(NULL), m_flag_list(NULL) { } ~msg_att_item() { delete (m_date_time); delete (m_number); delete (m_envelope); delete (m_uniqueid); delete (m_nstring); delete (m_body); delete (m_flag_list); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("msg_att_item"); string::size_type pos = *currentPos; // "ENVELOPE" SPACE envelope if (parser.checkWithArg (line, &pos, "envelope", true)) { m_type = ENVELOPE; parser.check (line, &pos); m_envelope = parser.get (line, &pos); } // "FLAGS" SPACE "(" #(flag / "\Recent") ")" else if (parser.checkWithArg (line, &pos, "flags", true)) { m_type = FLAGS; parser.check (line, &pos); m_flag_list = parser.get (line, &pos); } // "INTERNALDATE" SPACE date_time else if (parser.checkWithArg (line, &pos, "internaldate", true)) { m_type = INTERNALDATE; parser.check (line, &pos); m_date_time = parser.get (line, &pos); } // "RFC822" ".HEADER" SPACE nstring else if (parser.checkWithArg (line, &pos, "rfc822.header", true)) { m_type = RFC822_HEADER; parser.check (line, &pos); m_nstring = parser.get (line, &pos); } // "RFC822" ".TEXT" SPACE nstring else if (parser.checkWithArg (line, &pos, "rfc822.text", true)) { m_type = RFC822_TEXT; parser.check (line, &pos); m_nstring = parser.getWithArgs (line, &pos, this, RFC822_TEXT); } // "RFC822.SIZE" SPACE number else if (parser.checkWithArg (line, &pos, "rfc822.size", true)) { m_type = RFC822_SIZE; parser.check (line, &pos); m_number = parser.get (line, &pos); } // "RFC822" SPACE nstring else if (parser.checkWithArg (line, &pos, "rfc822", true)) { m_type = RFC822; parser.check (line, &pos); m_nstring = parser.get (line, &pos); } // "BODY" "STRUCTURE" SPACE body else if (parser.checkWithArg (line, &pos, "bodystructure", true)) { m_type = BODY_STRUCTURE; parser.check (line, &pos); m_body = parser.get (line, &pos); } // "BODY" section ["<" number ">"] SPACE nstring // "BODY" SPACE body else if (parser.checkWithArg (line, &pos, "body", true)) { m_section = parser.get (line, &pos, true); // "BODY" section ["<" number ">"] SPACE nstring if (m_section != NULL) { m_type = BODY_SECTION; if (parser.check >(line, &pos, true)) { m_number = parser.get (line, &pos); parser.check '> >(line, &pos); } parser.check (line, &pos); m_nstring = parser.getWithArgs (line, &pos, this, BODY_SECTION); } // "BODY" SPACE body else { m_type = BODY; parser.check (line, &pos); m_body = parser.get (line, &pos); } } // "UID" SPACE uniqueid else { m_type = UID; parser.checkWithArg (line, &pos, "uid"); parser.check (line, &pos); m_uniqueid = parser.get (line, &pos); } *currentPos = pos; } enum Type { ENVELOPE, FLAGS, INTERNALDATE, RFC822, RFC822_SIZE, RFC822_HEADER, RFC822_TEXT, BODY, BODY_SECTION, BODY_STRUCTURE, UID }; private: Type m_type; IMAPParser::date_time* m_date_time; IMAPParser::number* m_number; IMAPParser::envelope* m_envelope; IMAPParser::nz_number* m_uniqueid; IMAPParser::nstring* m_nstring; IMAPParser::xbody* m_body; IMAPParser::flag_list* m_flag_list; IMAPParser::section* m_section; public: Type type() const { return (m_type); } const IMAPParser::date_time* date_time() const { return (m_date_time); } const IMAPParser::number* number() const { return (m_number); } const IMAPParser::envelope* envelope() const { return (m_envelope); } const IMAPParser::nz_number* unique_id() const { return (m_uniqueid); } const IMAPParser::nstring* nstring() const { return (m_nstring); } const IMAPParser::xbody* body() const { return (m_body); } const IMAPParser::flag_list* flag_list() const { return (m_flag_list); } const IMAPParser::section* section() const { return (m_section); } }; // // msg_att ::= "(" 1#(msg_att_item) ")" // class msg_att : public component { public: ~msg_att() { for (std::vector ::iterator it = m_items.begin() ; it != m_items.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("msg_att"); string::size_type pos = *currentPos; parser.check >(line, &pos); m_items.push_back(parser.get (line, &pos)); while (!parser.check >(line, &pos, true)) { parser.check (line, &pos); m_items.push_back(parser.get (line, &pos)); } *currentPos = pos; } private: std::vector m_items; public: const std::vector & items() const { return (m_items); } }; // // message_data ::= nz_number SPACE ("EXPUNGE" / // ("FETCH" SPACE msg_att)) // class message_data : public component { public: message_data() : m_number(0), m_msg_att(NULL) { } ~message_data() { delete (m_msg_att); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("message_data"); string::size_type pos = *currentPos; nz_number* num = parser.get (line, &pos); m_number = num->value(); delete (num); parser.check (line, &pos); if (parser.checkWithArg (line, &pos, "expunge", true)) { m_type = EXPUNGE; } else { parser.checkWithArg (line, &pos, "fetch"); parser.check (line, &pos); m_type = FETCH; m_msg_att = parser.get (line, &pos); } *currentPos = pos; } enum Type { EXPUNGE, FETCH }; private: Type m_type; unsigned int m_number; IMAPParser::msg_att* m_msg_att; public: Type type() const { return (m_type); } unsigned int number() const { return (m_number); } const IMAPParser::msg_att* msg_att() const { return (m_msg_att); } }; // // resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text // ;; Status condition // class resp_cond_state : public component { public: resp_cond_state() : m_resp_text(NULL), m_status(BAD) { } ~resp_cond_state() { delete (m_resp_text); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("resp_cond_state"); string::size_type pos = *currentPos; if (parser.checkWithArg (line, &pos, "ok", true)) { m_status = OK; } else if (parser.checkWithArg (line, &pos, "no", true)) { m_status = NO; } else { parser.checkWithArg (line, &pos, "bad"); m_status = BAD; } parser.check (line, &pos); m_resp_text = parser.get (line, &pos); *currentPos = pos; } enum Status { OK, NO, BAD }; private: IMAPParser::resp_text* m_resp_text; Status m_status; public: const IMAPParser::resp_text* resp_text() const { return (m_resp_text); } Status status() const { return (m_status); } }; // // resp_cond_bye ::= "BYE" SPACE resp_text // class resp_cond_bye : public component { public: resp_cond_bye() : m_resp_text(NULL) { } ~resp_cond_bye() { delete (m_resp_text); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("resp_cond_bye"); string::size_type pos = *currentPos; parser.checkWithArg (line, &pos, "bye"); parser.check (line, &pos); m_resp_text = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::resp_text* m_resp_text; public: const IMAPParser::resp_text* resp_text() const { return (m_resp_text); } }; // // resp_cond_auth ::= ("OK" / "PREAUTH") SPACE resp_text // ;; Authentication condition // class resp_cond_auth : public component { public: resp_cond_auth() : m_resp_text(NULL) { } ~resp_cond_auth() { delete (m_resp_text); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("resp_cond_auth"); string::size_type pos = *currentPos; if (parser.checkWithArg (line, &pos, "ok", true)) { m_cond = OK; } else { parser.checkWithArg (line, &pos, "preauth"); m_cond = PREAUTH; } parser.check (line, &pos); m_resp_text = parser.get (line, &pos); *currentPos = pos; } enum Condition { OK, PREAUTH }; private: Condition m_cond; IMAPParser::resp_text* m_resp_text; public: Condition condition() const { return (m_cond); } const IMAPParser::resp_text* resp_text() const { return (m_resp_text); } }; // // status_info ::= status_att SPACE number // class status_info : public component { public: status_info() : m_status_att(NULL), m_number(NULL) { } ~status_info() { delete (m_status_att); delete (m_number); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("status_info"); string::size_type pos = *currentPos; m_status_att = parser.get (line, &pos); parser.check (line, &pos); m_number = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::status_att* m_status_att; IMAPParser::number* m_number; public: const IMAPParser::status_att* status_att() const { return (m_status_att); } const IMAPParser::number* number() const { return (m_number); } }; // // mailbox_data ::= "FLAGS" SPACE mailbox_flag_list / // "LIST" SPACE mailbox_list / // "LSUB" SPACE mailbox_list / // "MAILBOX" SPACE text / // "SEARCH" [SPACE 1#nz_number] / // "STATUS" SPACE mailbox SPACE // "(" #::iterator it = m_search_nz_number_list.begin() ; it != m_search_nz_number_list.end() ; ++it) { delete (*it); } for (std::vector ::iterator it = m_status_info_list.begin() ; it != m_status_info_list.end() ; ++it) { delete (*it); } } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("mailbox_data"); string::size_type pos = *currentPos; m_number = parser.get (line, &pos, true); if (m_number) { parser.check (line, &pos); if (parser.checkWithArg (line, &pos, "exists", true)) { m_type = EXISTS; } else { parser.checkWithArg (line, &pos, "recent"); m_type = RECENT; } } else { // "FLAGS" SPACE mailbox_flag_list if (parser.checkWithArg (line, &pos, "flags", true)) { parser.check (line, &pos); m_mailbox_flag_list = parser.get (line, &pos); m_type = FLAGS; } // "LIST" SPACE mailbox_list else if (parser.checkWithArg (line, &pos, "list", true)) { parser.check (line, &pos); m_mailbox_list = parser.get (line, &pos); m_type = LIST; } // "LSUB" SPACE mailbox_list else if (parser.checkWithArg (line, &pos, "lsub", true)) { parser.check (line, &pos); m_mailbox_list = parser.get (line, &pos); m_type = LSUB; } // "MAILBOX" SPACE text else if (parser.checkWithArg (line, &pos, "mailbox", true)) { parser.check (line, &pos); m_text = parser.get (line, &pos); m_type = MAILBOX; } // "SEARCH" [SPACE 1#nz_number] else if (parser.checkWithArg (line, &pos, "search", true)) { if (parser.check (line, &pos, true)) { m_search_nz_number_list.push_back (parser.get (line, &pos)); while (parser.check (line, &pos, true)) { m_search_nz_number_list.push_back (parser.get (line, &pos)); } } m_type = SEARCH; } // "STATUS" SPACE mailbox SPACE // "(" #(line, &pos, "status"); parser.check (line, &pos); m_mailbox = parser.get (line, &pos); parser.check (line, &pos); parser.check >(line, &pos); m_status_info_list.push_back(parser.get (line, &pos)); while (!parser.check >(line, &pos, true)) { parser.check (line, &pos); m_status_info_list.push_back(parser.get (line, &pos)); } m_type = STATUS; } } *currentPos = pos; } enum Type { FLAGS, LIST, LSUB, MAILBOX, SEARCH, STATUS, EXISTS, RECENT }; private: Type m_type; IMAPParser::number* m_number; IMAPParser::mailbox_flag_list* m_mailbox_flag_list; IMAPParser::mailbox_list* m_mailbox_list; IMAPParser::mailbox* m_mailbox; IMAPParser::text* m_text; std::vector m_search_nz_number_list; std::vector m_status_info_list; public: Type type() const { return (m_type); } const IMAPParser::number* number() const { return (m_number); } const IMAPParser::mailbox_flag_list* mailbox_flag_list() const { return (m_mailbox_flag_list); } const IMAPParser::mailbox_list* mailbox_list() const { return (m_mailbox_list); } const IMAPParser::mailbox* mailbox() const { return (m_mailbox); } const IMAPParser::text* text() const { return (m_text); } const std::vector & search_nz_number_list() const { return (m_search_nz_number_list); } const std::vector & status_info_list() const { return (m_status_info_list); } }; // // response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye / // mailbox_data / message_data / capability_data) CRLF // class response_data : public component { public: response_data() : m_resp_cond_state(NULL), m_resp_cond_bye(NULL), m_mailbox_data(NULL), m_message_data(NULL), m_capability_data(NULL) { } ~response_data() { delete (m_resp_cond_state); delete (m_resp_cond_bye); delete (m_mailbox_data); delete (m_message_data); delete (m_capability_data); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("response_data"); string::size_type pos = *currentPos; parser.check >(line, &pos); parser.check (line, &pos); if (!(m_resp_cond_state = parser.get (line, &pos, true))) if (!(m_resp_cond_bye = parser.get (line, &pos, true))) if (!(m_mailbox_data = parser.get (line, &pos, true))) if (!(m_message_data = parser.get (line, &pos, true))) m_capability_data = parser.get (line, &pos); parser.check (line, &pos); *currentPos = pos; } private: IMAPParser::resp_cond_state* m_resp_cond_state; IMAPParser::resp_cond_bye* m_resp_cond_bye; IMAPParser::mailbox_data* m_mailbox_data; IMAPParser::message_data* m_message_data; IMAPParser::capability_data* m_capability_data; public: const IMAPParser::resp_cond_state* resp_cond_state() const { return (m_resp_cond_state); } const IMAPParser::resp_cond_bye* resp_cond_bye() const { return (m_resp_cond_bye); } const IMAPParser::mailbox_data* mailbox_data() const { return (m_mailbox_data); } const IMAPParser::message_data* message_data() const { return (m_message_data); } const IMAPParser::capability_data* capability_data() const { return (m_capability_data); } }; class continue_req_or_response_data : public component { public: continue_req_or_response_data() : m_continue_req(NULL), m_response_data(NULL) { } ~continue_req_or_response_data() { delete (m_continue_req); delete (m_response_data); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("continue_req_or_response_data"); string::size_type pos = *currentPos; if (!(m_continue_req = parser.get (line, &pos, true))) m_response_data = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::continue_req* m_continue_req; IMAPParser::response_data* m_response_data; public: const IMAPParser::continue_req* continue_req() const { return (m_continue_req); } const IMAPParser::response_data* response_data() const { return (m_response_data); } }; // // response_fatal ::= "*" SPACE resp_cond_bye CRLF // ;; Server closes connection immediately // class response_fatal : public component { public: response_fatal() : m_resp_cond_bye(NULL) { } ~response_fatal() { delete (m_resp_cond_bye); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("response_fatal"); string::size_type pos = *currentPos; parser.check >(line, &pos); parser.check (line, &pos); m_resp_cond_bye = parser.get (line, &pos); parser.check (line, &pos); *currentPos = pos; } private: IMAPParser::resp_cond_bye* m_resp_cond_bye; public: const IMAPParser::resp_cond_bye* resp_cond_bye() const { return (m_resp_cond_bye); } }; // // response_tagged ::= tag SPACE resp_cond_state CRLF // class response_tagged : public component { public: response_tagged() : m_resp_cond_state(NULL) { } ~response_tagged() { delete (m_resp_cond_state); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("response_tagged"); string::size_type pos = *currentPos; parser.check (line, &pos); parser.check (line, &pos); m_resp_cond_state = parser.get (line, &pos); parser.check (line, &pos); *currentPos = pos; } private: IMAPParser::resp_cond_state* m_resp_cond_state; public: const IMAPParser::resp_cond_state* resp_cond_state() const { return (m_resp_cond_state); } }; // // response_done ::= response_tagged / response_fatal // class response_done : public component { public: response_done() : m_response_tagged(NULL), m_response_fatal(NULL) { } ~response_done() { delete (m_response_tagged); delete (m_response_fatal); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("response_done"); string::size_type pos = *currentPos; if (!(m_response_tagged = parser.get (line, &pos, true))) m_response_fatal = parser.get (line, &pos); *currentPos = pos; } private: IMAPParser::response_tagged* m_response_tagged; IMAPParser::response_fatal* m_response_fatal; public: const IMAPParser::response_tagged* response_tagged() const { return (m_response_tagged); } const IMAPParser::response_fatal* response_fatal() const { return (m_response_fatal); } }; // // response ::= *(continue_req / response_data) response_done // class response : public component { public: response() : m_response_done(NULL) { } ~response() { for (std::vector ::iterator it = m_continue_req_or_response_data.begin() ; it != m_continue_req_or_response_data.end() ; ++it) { delete (*it); } delete (m_response_done); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("response"); string::size_type pos = *currentPos; string curLine = line; bool partial = false; // partial response IMAPParser::continue_req_or_response_data* resp = NULL; while ((resp = parser.get (curLine, &pos, true)) != NULL) { m_continue_req_or_response_data.push_back(resp); // Partial response (continue_req) if (resp->continue_req()) { partial = true; break; } // We have read a CRLF, read another line curLine = parser.readLine(); pos = 0; } if (!partial) m_response_done = parser.get (curLine, &pos); *currentPos = pos; } bool isBad() const { if (!response_done()) // incomplete (partial) response return (true); if (response_done()->response_fatal()) return (true); if (response_done()->response_tagged()->resp_cond_state()-> status() == IMAPParser::resp_cond_state::BAD) { return (true); } return (false); } private: std::vector m_continue_req_or_response_data; IMAPParser::response_done* m_response_done; public: const std::vector & continue_req_or_response_data() const { return (m_continue_req_or_response_data); } const IMAPParser::response_done* response_done() const { return (m_response_done); } }; // // greeting ::= "*" SPACE (resp_cond_auth / resp_cond_bye) CRLF // class greeting : public component { public: greeting() : m_resp_cond_auth(NULL), m_resp_cond_bye(NULL) { } ~greeting() { delete (m_resp_cond_auth); delete (m_resp_cond_bye); } void go(IMAPParser& parser, string& line, string::size_type* currentPos) { DEBUG_ENTER_COMPONENT("greeting"); string::size_type pos = *currentPos; parser.check >(line, &pos); parser.check (line, &pos); if (!(m_resp_cond_auth = parser.get (line, &pos, true))) m_resp_cond_bye = parser.get (line, &pos); parser.check (line, &pos); *currentPos = pos; } private: IMAPParser::resp_cond_auth* m_resp_cond_auth; IMAPParser::resp_cond_bye* m_resp_cond_bye; public: const IMAPParser::resp_cond_auth* resp_cond_auth() const { return (m_resp_cond_auth); } const IMAPParser::resp_cond_bye* resp_cond_bye() const { return (m_resp_cond_bye); } }; // // The main functions used to parse a response // response* readResponse(literalHandler* lh = NULL) { string::size_type pos = 0; string line = readLine(); m_literalHandler = lh; response* resp = get (line, &pos); m_literalHandler = NULL; return (resp); } greeting* readGreeting() { string::size_type pos = 0; string line = readLine(); return get (line, &pos); } // // Get a token and advance // template TYPE* get(string& line, string::size_type* currentPos, const bool noThrow = false) { component* resp = new TYPE; return internalGet (resp, line, currentPos, noThrow); } template TYPE* getWithArgs(string& line, string::size_type* currentPos, ARG1_TYPE arg1, ARG2_TYPE arg2, const bool noThrow = false) { component* resp = new TYPE(arg1, arg2); return internalGet (resp, line, currentPos, noThrow); } private: template TYPE* internalGet(component* resp, string& line, string::size_type* currentPos, const bool noThrow = false) { const string::size_type oldPos = *currentPos; try { resp->go(*this, line, currentPos); } catch (...) { *currentPos = oldPos; delete (resp); if (!noThrow) throw; return (NULL); } return static_cast (resp); } public: // // Check a token and advance // template bool check(string& line, string::size_type* currentPos, const bool noThrow = false) { const string::size_type oldPos = *currentPos; try { TYPE term; term.go(*this, line, currentPos); } catch (...) { *currentPos = oldPos; if (!noThrow) throw; return false; } return true; } template bool checkWithArg(string& line, string::size_type* currentPos, const ARG_TYPE arg, const bool noThrow = false) { const string::size_type oldPos = *currentPos; try { TYPE term(arg); term.go(*this, line, currentPos); } catch (...) { *currentPos = oldPos; if (!noThrow) throw; return false; } return true; } private: weak_ref m_tag; weak_ref m_socket; utility::progressListener* m_progress; bool m_strict; literalHandler* m_literalHandler; weak_ref m_timeoutHandler; string m_buffer; int m_pos; string m_lastLine; public: // // Read one line // const string readLine() { string::size_type pos; while ((pos = m_buffer.find('\n')) == string::npos) { read(); } string line; line.resize(pos + 1); std::copy(m_buffer.begin(), m_buffer.begin() + pos + 1, line.begin()); m_buffer.erase(m_buffer.begin(), m_buffer.begin() + pos + 1); m_lastLine = line; #if DEBUG_RESPONSE std::cout << std::endl << "Read line:" << std::endl << line << std::endl; #endif return (line); } // // Read available data from socket stream // void read() { string receiveBuffer; ref toh = m_timeoutHandler.acquire(); ref sok = m_socket.acquire(); if (toh) toh->resetTimeOut(); while (receiveBuffer.empty()) { // Check whether the time-out delay is elapsed if (toh && toh->isTimeOut()) { if (!toh->handleTimeOut()) throw exceptions::operation_timed_out(); } // We have received data: reset the time-out counter sok->receive(receiveBuffer); if (receiveBuffer.empty()) // buffer is empty { platform::getHandler()->wait(); continue; } // We have received data ... if (toh) toh->resetTimeOut(); } m_buffer += receiveBuffer; } void readLiteral(literalHandler::target& buffer, string::size_type count) { string::size_type len = 0; string receiveBuffer; ref toh = m_timeoutHandler.acquire(); ref sok = m_socket.acquire(); if (m_progress) m_progress->start(count); if (toh) toh->resetTimeOut(); if (!m_buffer.empty()) { if (m_buffer.length() > count) { buffer.putData(string(m_buffer.begin(), m_buffer.begin() + count)); m_buffer.erase(m_buffer.begin(), m_buffer.begin() + count); len = count; } else { len += m_buffer.length(); buffer.putData(m_buffer); m_buffer.clear(); } } while (len < count) { // Check whether the time-out delay is elapsed if (toh && toh->isTimeOut()) { if (!toh->handleTimeOut()) throw exceptions::operation_timed_out(); toh->resetTimeOut(); } // Receive data from the socket sok->receive(receiveBuffer); if (receiveBuffer.empty()) // buffer is empty { platform::getHandler()->wait(); continue; } // We have received data: reset the time-out counter if (toh) toh->resetTimeOut(); if (len + receiveBuffer.length() > count) { const string::size_type remaining = count - len; // Get the needed amount of data buffer.putData(string(receiveBuffer.begin(), receiveBuffer.begin() + remaining)); // Put the remaining data into the internal response buffer receiveBuffer.erase(receiveBuffer.begin(), receiveBuffer.begin() + remaining); m_buffer += receiveBuffer; len = count; } else { buffer.putData(receiveBuffer); len += receiveBuffer.length(); } // Notify progress if (m_progress) m_progress->progress(len, count); } if (m_progress) m_progress->stop(count); } }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPPARSER_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPUtils.hpp0000644000175000017500000000716611250723264020754 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPUTILS_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPUTILS_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/dateTime.hpp" #include "vmime/net/folder.hpp" #include "vmime/net/imap/IMAPParser.hpp" #include "vmime/mailboxList.hpp" #include namespace vmime { namespace net { namespace imap { class IMAPUtils { public: static const string pathToString(const char hierarchySeparator, const folder::path& path); static const folder::path stringToPath(const char hierarchySeparator, const string& str); static const string toModifiedUTF7(const char hierarchySeparator, const folder::path::component& text); static const folder::path::component fromModifiedUTF7(const string& text); /** Quote string if it contains IMAP-special characters. * * @param text string to quote * @return quoted string */ static const string quoteString(const string& text); static int folderTypeFromFlags(const IMAPParser::mailbox_flag_list* list); static int folderFlagsFromFlags(const IMAPParser::mailbox_flag_list* list); static int messageFlagsFromFlags(const IMAPParser::flag_list* list); static const string messageFlagList(const int flags); /** Build an "IMAP set" given a list. The function tries to group * consecutive message numbers to reduce the list. * * Example: * IN = "1,2,3,4,5,7,8,13,15,16,17" * OUT = "1:5,7:8,13,15:*" for a mailbox with a total of 17 messages (max = 17) * * @param list list of message numbers * @param max number of messages in the mailbox (or -1 if not known) * @param alreadySorted set to true if the list of message numbers is * already sorted in ascending order * @return a set corresponding to the message list */ static const string listToSet(const std::vector & list, const int max = -1, const bool alreadySorted = false); /** Format a date/time to IMAP date/time format. * * @param date date/time to format * @return IMAP-formatted date/time */ static const string dateTime(const vmime::datetime& date); /** Construct a fetch request for the specified messages. * * @param list list of message numbers * @param options fetch options * @return fetch request */ static const string buildFetchRequest(const std::vector & list, const int options); /** Convert a parser-style address list to a mailbox list. * * @param src input address list * @param dest output mailbox list */ static void convertAddressList(const IMAPParser::address_list& src, mailboxList& dest); }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPUTILS_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPPart.hpp0000644000175000017500000000422211374206162020550 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED #include "vmime/net/message.hpp" #include "vmime/net/imap/IMAPParser.hpp" namespace vmime { namespace net { namespace imap { class IMAPStructure; class IMAPPart : public part { private: friend class vmime::creator; IMAPPart(ref parent, const int number, const IMAPParser::body_type_mpart* mpart); IMAPPart(ref parent, const int number, const IMAPParser::body_type_1part* part); public: ref getStructure() const; ref getStructure(); ref getParent() const; const mediaType& getType() const; int getSize() const; int getNumber() const; ref getHeader() const; static ref create (ref parent, const int number, const IMAPParser::body* body); header& getOrCreateHeader(); private: ref m_structure; weak_ref m_parent; ref
m_header; int m_number; int m_size; mediaType m_mediaType; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPMessage.hpp0000644000175000017500000000677411374513427021251 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPMESSAGE_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPMESSAGE_HPP_INCLUDED #include "vmime/net/message.hpp" #include "vmime/net/folder.hpp" #include "vmime/net/imap/IMAPParser.hpp" namespace vmime { namespace net { namespace imap { class IMAPFolder; /** IMAP message implementation. */ class IMAPMessage : public message { private: friend class IMAPFolder; friend class vmime::creator; // vmime::create IMAPMessage(ref folder, const int num); IMAPMessage(const IMAPMessage&) : message() { } ~IMAPMessage(); public: int getNumber() const; const uid getUniqueId() const; int getSize() const; bool isExpunged() const; ref getStructure() const; ref getStructure(); ref getHeader() const; int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; void extractPart(ref p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; void fetchPartHeader(ref p); ref getParsedMessage(); private: void fetch(ref folder, const int options); void processFetchResponse(const int options, const IMAPParser::msg_att* msgAtt); /** Recursively fetch part header for all parts in the structure. * * @param str structure for which to fetch parts headers */ void fetchPartHeaderForStructure(ref str); /** Recursively contruct parsed message from structure. * Called by getParsedMessage(). * * @param parentPart root body part (the message) * @param str structure for which to construct part * @param level current nesting level (0 is root) */ void constructParsedMessage(ref parentPart, ref str, int level = 0); void extract(ref p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool headerOnly, const bool peek) const; ref
getOrCreateHeader(); void onFolderClosed(); weak_ref m_folder; int m_num; int m_size; int m_flags; bool m_expunged; uid m_uid; ref
m_header; ref m_structure; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPMESSAGE_HPP_INCLUDED libvmime-0.9.1/vmime/net/imap/IMAPTag.hpp0000644000175000017500000000321311250723264020354 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_IMAP_IMAPTAG_HPP_INCLUDED #define VMIME_NET_IMAP_IMAPTAG_HPP_INCLUDED #include "vmime/types.hpp" namespace vmime { namespace net { namespace imap { class IMAPTag : public object { private: IMAPTag(const int number); IMAPTag(const IMAPTag& tag); public: IMAPTag(); IMAPTag& operator++(); // ++IMAPTag const IMAPTag operator++(int); // IMAPTag++ int number() const; operator string() const; private: void generate(); static const int sm_maxNumber; int m_number; string m_tag; }; } // imap } // net } // vmime #endif // VMIME_NET_IMAP_IMAPTAG_HPP_INCLUDED libvmime-0.9.1/vmime/net/pop3/0000755000175000017500000000000011607302336016414 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/pop3/POP3ServiceInfos.hpp0000644000175000017500000000456111250723264022175 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_POP3_POP3SERVICEINFOS_HPP_INCLUDED #define VMIME_NET_POP3_POP3SERVICEINFOS_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/serviceInfos.hpp" namespace vmime { namespace net { namespace pop3 { /** Information about POP3 service. */ class POP3ServiceInfos : public serviceInfos { public: POP3ServiceInfos(const bool pop3s); struct props { // POP3-specific options serviceInfos::property PROPERTY_OPTIONS_APOP; serviceInfos::property PROPERTY_OPTIONS_APOP_FALLBACK; #if VMIME_HAVE_SASL_SUPPORT serviceInfos::property PROPERTY_OPTIONS_SASL; serviceInfos::property PROPERTY_OPTIONS_SASL_FALLBACK; #endif // VMIME_HAVE_SASL_SUPPORT // Common properties serviceInfos::property PROPERTY_AUTH_USERNAME; serviceInfos::property PROPERTY_AUTH_PASSWORD; #if VMIME_HAVE_TLS_SUPPORT serviceInfos::property PROPERTY_CONNECTION_TLS; serviceInfos::property PROPERTY_CONNECTION_TLS_REQUIRED; #endif // VMIME_HAVE_TLS_SUPPORT serviceInfos::property PROPERTY_SERVER_ADDRESS; serviceInfos::property PROPERTY_SERVER_PORT; }; const props& getProperties() const; const string getPropertyPrefix() const; const std::vector getAvailableProperties() const; private: const bool m_pop3s; }; } // pop3 } // net } // vmime #endif // VMIME_NET_POP3_POP3SERVICEINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/pop3/POP3SStore.hpp0000644000175000017500000000321411250723264021007 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_POP3_POP3SSTORE_HPP_INCLUDED #define VMIME_NET_POP3_POP3SSTORE_HPP_INCLUDED #include "vmime/net/pop3/POP3Store.hpp" namespace vmime { namespace net { namespace pop3 { /** POP3S store service. */ class POP3SStore : public POP3Store { public: POP3SStore(ref sess, ref auth); ~POP3SStore(); const string getProtocolName() const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; private: static POP3ServiceInfos sm_infos; }; } // pop3 } // net } // vmime #endif // VMIME_NET_POP3_POP3SSTORE_HPP_INCLUDED libvmime-0.9.1/vmime/net/pop3/POP3Folder.hpp0000644000175000017500000001013111250723264020777 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_POP3_POP3FOLDER_HPP_INCLUDED #define VMIME_NET_POP3_POP3FOLDER_HPP_INCLUDED #include #include #include "vmime/config.hpp" #include "vmime/types.hpp" #include "vmime/net/folder.hpp" namespace vmime { namespace net { namespace pop3 { class POP3Store; class POP3Message; /** POP3 folder implementation. */ class POP3Folder : public folder { private: friend class POP3Store; friend class POP3Message; friend class vmime::creator; // vmime::create POP3Folder(const folder::path& path, ref store); POP3Folder(const POP3Folder&) : folder() { } ~POP3Folder(); public: int getMode() const; int getType(); int getFlags(); const folder::path::component getName() const; const folder::path getFullPath() const; void open(const int mode, bool failIfModeIsNotAvailable = false); void close(const bool expunge); void create(const int type); bool exists(); void destroy(); bool isOpen() const; ref getMessage(const int num); std::vector > getMessages(const int from = 1, const int to = -1); std::vector > getMessages(const std::vector & nums); int getMessageCount(); ref getFolder(const folder::path::component& name); std::vector > getFolders(const bool recursive = false); void rename(const folder::path& newPath); void deleteMessage(const int num); void deleteMessages(const int from = 1, const int to = -1); void deleteMessages(const std::vector & nums); void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector & nums, const int flags, const int mode = message::FLAG_MODE_SET); void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); void copyMessages(const folder::path& dest, const int from = 1, const int to = -1); void copyMessages(const folder::path& dest, const std::vector & nums); void status(int& count, int& unseen); void expunge(); ref getParent(); ref getStore() const; ref getStore(); void fetchMessages(std::vector >& msg, const int options, utility::progressListener* progress = NULL); void fetchMessage(ref msg, const int options); int getFetchCapabilities() const; private: void registerMessage(POP3Message* msg); void unregisterMessage(POP3Message* msg); void onStoreDisconnected(); void onClose(); weak_ref m_store; folder::path m_path; folder::path::component m_name; int m_mode; bool m_open; int m_messageCount; typedef std::map MessageMap; MessageMap m_messages; }; } // pop3 } // net } // vmime #endif // VMIME_NET_POP3_POP3FOLDER_HPP_INCLUDED libvmime-0.9.1/vmime/net/pop3/POP3Message.hpp0000644000175000017500000000515711314460735021166 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_POP3_POP3MESSAGE_HPP_INCLUDED #define VMIME_NET_POP3_POP3MESSAGE_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/message.hpp" #include "vmime/net/folder.hpp" namespace vmime { namespace net { namespace pop3 { class POP3Folder; /** POP3 message implementation. */ class POP3Message : public message { private: friend class POP3Folder; friend class vmime::creator; // vmime::create POP3Message(ref folder, const int num); POP3Message(const POP3Message&) : message() { } ~POP3Message(); public: int getNumber() const; const uid getUniqueId() const; int getSize() const; bool isExpunged() const; ref getStructure() const; ref getStructure(); ref getHeader() const; int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; void extractPart(ref p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; void fetchPartHeader(ref p); ref getParsedMessage(); private: void fetch(ref folder, const int options); void onFolderClosed(); weak_ref m_folder; int m_num; uid m_uid; int m_size; bool m_deleted; ref
m_header; }; } // pop3 } // net } // vmime #endif // VMIME_NET_POP3_POP3MESSAGE_HPP_INCLUDED libvmime-0.9.1/vmime/net/pop3/POP3Store.hpp0000644000175000017500000000722611250723264020673 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_POP3_POP3STORE_HPP_INCLUDED #define VMIME_NET_POP3_POP3STORE_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/messageId.hpp" #include "vmime/net/store.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" #include "vmime/net/pop3/POP3ServiceInfos.hpp" #include "vmime/utility/stream.hpp" namespace vmime { namespace net { namespace pop3 { class POP3Folder; /** POP3 store service. */ class POP3Store : public store { friend class POP3Folder; friend class POP3Message; public: POP3Store(ref sess, ref auth, const bool secured = false); ~POP3Store(); const string getProtocolName() const; ref getDefaultFolder(); ref getRootFolder(); ref getFolder(const folder::path& path); bool isValidFolderName(const folder::path::component& name) const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; void connect(); bool isConnected() const; void disconnect(); void noop(); int getCapabilities() const; bool isSecuredConnection() const; ref getConnectionInfos() const; private: enum ResponseCode { RESPONSE_OK = 0, RESPONSE_READY, RESPONSE_ERR }; void authenticate(const messageId& randomMID); #if VMIME_HAVE_SASL_SUPPORT void authenticateSASL(); #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT void startTLS(); #endif // VMIME_HAVE_TLS_SUPPORT const std::vector getCapabilities(); static bool isSuccessResponse(const string& buffer); static bool stripFirstLine(const string& buffer, string& result, string* firstLine = NULL); static void stripResponseCode(const string& buffer, string& result); static int getResponseCode(const string& buffer); void sendRequest(const string& buffer, const bool end = true); void readResponse(string& buffer, const bool multiLine, utility::progressListener* progress = NULL); void readResponse(utility::outputStream& os, utility::progressListener* progress = NULL, const int predictedSize = 0); static bool checkTerminator(string& buffer, const bool multiLine); static bool checkOneTerminator(string& buffer, const string& term); void internalDisconnect(); void registerFolder(POP3Folder* folder); void unregisterFolder(POP3Folder* folder); std::list m_folders; ref m_socket; bool m_authentified; ref m_timeoutHandler; const bool m_isPOP3S; bool m_secured; ref m_cntInfos; // Service infos static POP3ServiceInfos sm_infos; }; } // pop3 } // net } // vmime #endif // VMIME_NET_POP3_POP3STORE_HPP_INCLUDED libvmime-0.9.1/vmime/net/pop3/POP3Utils.hpp0000644000175000017500000000354411250723264020676 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_POP3_POP3UTILS_HPP_INCLUDED #define VMIME_NET_POP3_POP3UTILS_HPP_INCLUDED #include #include "vmime/config.hpp" #include "vmime/types.hpp" namespace vmime { namespace net { namespace pop3 { class POP3Utils { public: /** Parse a response of type ([integer] [string] \n)*. * This is used in LIST or UIDL commands: * * C: UIDL * S: +OK * S: 1 whqtswO00WBw418f9t5JxYwZ * S: 2 QhdPYR:00WBw1Ph7x7 * S: . * * @param response raw response string as returned by the server * @return an associative array which map a message number to its * data (either UID or size) */ static void parseMultiListOrUidlResponse (const string& response, std::map & result); }; } // pop3 } // net } // vmime #endif // VMIME_NET_POP3_POP3UTILS_HPP_INCLUDED libvmime-0.9.1/vmime/net/smtp/0000755000175000017500000000000011607302336016516 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/smtp/SMTPTransport.hpp0000644000175000017500000000542111250723264021732 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SMTP_SMTPTRANSPORT_HPP_INCLUDED #define VMIME_NET_SMTP_SMTPTRANSPORT_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/transport.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" #include "vmime/net/smtp/SMTPServiceInfos.hpp" namespace vmime { namespace net { namespace smtp { class SMTPResponse; /** SMTP transport service. */ class SMTPTransport : public transport { public: SMTPTransport(ref sess, ref auth, const bool secured = false); ~SMTPTransport(); const string getProtocolName() const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; void connect(); bool isConnected() const; void disconnect(); void noop(); void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL); bool isSecuredConnection() const; ref getConnectionInfos() const; private: void sendRequest(const string& buffer, const bool end = true); ref readResponse(); void internalDisconnect(); void helo(); void authenticate(); #if VMIME_HAVE_SASL_SUPPORT void authenticateSASL(); #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT void startTLS(); #endif // VMIME_HAVE_TLS_SUPPORT ref m_socket; bool m_authentified; bool m_extendedSMTP; std::map > m_extensions; ref m_timeoutHandler; const bool m_isSMTPS; bool m_secured; ref m_cntInfos; // Service infos static SMTPServiceInfos sm_infos; }; } // smtp } // net } // vmime #endif // VMIME_NET_SMTP_SMTPTRANSPORT_HPP_INCLUDED libvmime-0.9.1/vmime/net/smtp/SMTPServiceInfos.hpp0000644000175000017500000000447411250723264022344 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SMTP_SMTPSERVICEINFOS_HPP_INCLUDED #define VMIME_NET_SMTP_SMTPSERVICEINFOS_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/serviceInfos.hpp" namespace vmime { namespace net { namespace smtp { /** Information about SMTP service. */ class SMTPServiceInfos : public serviceInfos { public: SMTPServiceInfos(const bool smtps); struct props { // SMTP-specific options serviceInfos::property PROPERTY_OPTIONS_NEEDAUTH; #if VMIME_HAVE_SASL_SUPPORT serviceInfos::property PROPERTY_OPTIONS_SASL; serviceInfos::property PROPERTY_OPTIONS_SASL_FALLBACK; #endif // VMIME_HAVE_SASL_SUPPORT // Common properties serviceInfos::property PROPERTY_AUTH_USERNAME; serviceInfos::property PROPERTY_AUTH_PASSWORD; #if VMIME_HAVE_TLS_SUPPORT serviceInfos::property PROPERTY_CONNECTION_TLS; serviceInfos::property PROPERTY_CONNECTION_TLS_REQUIRED; #endif // VMIME_HAVE_TLS_SUPPORT serviceInfos::property PROPERTY_SERVER_ADDRESS; serviceInfos::property PROPERTY_SERVER_PORT; }; const props& getProperties() const; const string getPropertyPrefix() const; const std::vector getAvailableProperties() const; private: const bool m_smtps; }; } // smtp } // net } // vmime #endif // VMIME_NET_SMTP_SMTPSERVICEINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/smtp/SMTPResponse.hpp0000644000175000017500000000640411250723264021536 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SMTP_SMTPRESPONSE_HPP_INCLUDED #define VMIME_NET_SMTP_SMTPRESPONSE_HPP_INCLUDED #include "vmime/object.hpp" #include "vmime/base.hpp" namespace vmime { namespace net { class socket; class timeoutHandler; namespace smtp { /** A SMTP response, as sent by the server. */ class SMTPResponse : public object { friend class vmime::creator; public: /** An element of a SMTP response. */ class responseLine { public: responseLine(const int code, const string& text); void setCode(const int code); int getCode() const; void setText(const string& text); const string getText() const; private: int m_code; string m_text; }; /** Receive and parse a new SMTP response from the * specified socket. * * @param sok socket from which to read * @param toh time-out handler * @return SMTP response * @throws exceptions::operation_timed_out if no data * has been received within the granted time */ static ref readResponse(ref sok, ref toh); /** Return the SMTP response code. * * @return response code */ int getCode() const; /** Return the SMTP response text. * The text of each line is concatenated. * * @return response text */ const string getText() const; /** Return the response line at the specified position. * * @param pos line index * @return line at the specified index */ const responseLine getLineAt(const unsigned int pos) const; /** Return the number of lines in the response. * * @return number of lines in the response */ unsigned int getLineCount() const; /** Return the last line in the response. * * @return last response line */ const responseLine getLastLine() const; private: SMTPResponse(ref sok, ref toh); SMTPResponse(const SMTPResponse&); void readResponse(); const string readResponseLine(); const responseLine getNextResponse(); static int extractResponseCode(const string& response); std::vector m_lines; ref m_socket; ref m_timeoutHandler; string m_responseBuffer; bool m_responseContinues; }; } // smtp } // net } // vmime #endif // VMIME_NET_SMTP_SMTPRESPONSE_HPP_INCLUDED libvmime-0.9.1/vmime/net/smtp/SMTPSTransport.hpp0000644000175000017500000000324411250723264022056 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SMTP_SMTPSSTORE_HPP_INCLUDED #define VMIME_NET_SMTP_SMTPSSTORE_HPP_INCLUDED #include "vmime/net/smtp/SMTPTransport.hpp" namespace vmime { namespace net { namespace smtp { /** SMTPS transport service. */ class SMTPSTransport : public SMTPTransport { public: SMTPSTransport(ref sess, ref auth); ~SMTPSTransport(); const string getProtocolName() const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; private: static SMTPServiceInfos sm_infos; }; } // smtp } // net } // vmime #endif // VMIME_NET_SMTP_SMTPSSTORE_HPP_INCLUDED libvmime-0.9.1/vmime/net/message.hpp0000644000175000017500000002120711457315206017675 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MESSAGE_HPP_INCLUDED #define VMIME_NET_MESSAGE_HPP_INCLUDED #include "vmime/header.hpp" #include "vmime/mediaType.hpp" #include "vmime/utility/progressListener.hpp" #include "vmime/utility/stream.hpp" #include "vmime/message.hpp" namespace vmime { namespace net { class structure; /** A MIME part in a message. */ class part : public object { protected: part() { } part(const part&) : object() { } virtual ~part() { } public: /** Return the structure of this part. * * @return structure of the part */ virtual ref getStructure() const = 0; /** Return the structure of this part. * * @return structure of the part */ virtual ref getStructure() = 0; /** Return the header section for this part (you must fetch header * before using this function: see message::fetchPartHeader). * * @return header section */ virtual ref getHeader() const = 0; /** Return the media-type of the content in this part. * * @return content media type */ virtual const mediaType& getType() const = 0; /** Return the size of this part. * * @return size of the part (in bytes) */ virtual int getSize() const = 0; /** Return the part sequence number (index). * The first part is at index zero. * * @return part number */ virtual int getNumber() const = 0; /** Return the sub-part at the specified position (zero is the * first part). * * @param pos index of the sub-part * @return sub-part at position 'pos' */ ref getPartAt(const int pos) const; /** Return the sub-part at the specified position (zero is the * first part). * * @param pos index of the sub-part * @return sub-part at position 'pos' */ ref getPartAt(const int pos); /** Return the number of sub-parts in this part. * * @return number of sub-parts */ int getPartCount() const; }; /** Structure of a MIME part/message. */ class structure : public object { protected: structure() { } structure(const structure&) : object() { } public: virtual ~structure() { } /** Return the part at the specified position (first * part is at position 0). * * @param pos position * @return part at position 'pos' */ virtual ref getPartAt(const int pos) const = 0; /** Return the part at the specified position (first * part is at position 0). * * @param pos position * @return part at position 'pos' */ virtual ref getPartAt(const int pos) = 0; /** Return the number of parts in this part. * * @return number of parts */ virtual int getPartCount() const = 0; }; /** Abstract representation of a message in a store/transport service. */ class message : public object { protected: message() { } message(const message&) : object() { } public: virtual ~message() { } /** The type for an unique message identifier. */ typedef string uid; /** Return the MIME structure of the message (must fetch before). * * @return MIME structure of the message */ virtual ref getStructure() const = 0; /** Return the MIME structure of the message (must fetch before). * * @return MIME structure of the message */ virtual ref getStructure() = 0; /** Return a reference to the header fields of the message (must fetch before). * * @return header section of the message */ virtual ref getHeader() const = 0; /** Return the sequence number of this message. This number is * used to reference the message in the folder. * * @return sequence number of the message */ virtual int getNumber() const = 0; /** Return the unique identified of this message (must fetch before). * * @return UID of the message */ virtual const uid getUniqueId() const = 0; /** Return the size of the message (must fetch before). * * @return size of the message (in bytes) */ virtual int getSize() const = 0; /** Check whether this message has been expunged * (ie: definitively deleted). * * @return true if the message is expunged, false otherwise */ virtual bool isExpunged() const = 0; /** Possible flags for a message. */ enum Flags { FLAG_SEEN = (1 << 0), /**< Message has been seen. */ FLAG_RECENT = (1 << 1), /**< Message has been recently received. */ FLAG_DELETED = (1 << 2), /**< Message is marked for deletion. */ FLAG_REPLIED = (1 << 3), /**< User replied to this message. */ FLAG_MARKED = (1 << 4), /**< Used-defined flag. */ FLAG_PASSED = (1 << 5), /**< Message has been resent/forwarded/bounced. */ FLAG_DRAFT = (1 << 6), /**< Message is marked as a 'draft'. */ FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned by the flags() function). */ }; /** Methods for setting the flags. */ enum FlagsModes { FLAG_MODE_SET, /**< Set (replace) the flags. */ FLAG_MODE_ADD, /**< Add the flags. */ FLAG_MODE_REMOVE /**< Remove the flags. */ }; /** Return the flags of this message. * * @return flags of the message */ virtual int getFlags() const = 0; /** Set the flags of this message. * * @param flags set of flags (see Flags) * @param mode indicate how to treat old and new flags (see FlagsModes) */ virtual void setFlags(const int flags, const int mode = FLAG_MODE_SET) = 0; /** Extract the whole message data (header + contents). * * \warning Partial fetch might not be supported by the underlying protocol. * * @param os output stream in which to write message data * @param progress progress listener, or NULL if not used * @param start index of the first byte to retrieve (used for partial fetch) * @param length number of bytes to retrieve (used for partial fetch) * @param peek if true, try not to mark the message as read. This may not * be supported by the protocol (IMAP supports this), but it will NOT throw * an exception if not supported. */ virtual void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const = 0; /** Extract the specified MIME part of the message (header + contents). * * \warning Partial fetch might not be supported by the underlying protocol. * * @param p part to extract * @param os output stream in which to write part data * @param progress progress listener, or NULL if not used * @param start index of the first byte to retrieve (used for partial fetch) * @param length number of bytes to retrieve (used for partial fetch) * @param peek if true, try not to mark the message as read. This may not * be supported by the protocol (IMAP supports this), but it will NOT throw * an exception if not supported. */ virtual void extractPart(ref p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const = 0; /** Fetch the MIME header for the specified part. * * @param p the part for which to fetch the header */ virtual void fetchPartHeader(ref p) = 0; /** Get the RFC-822 message for this abstract message. * Warning: This may require getting some data (ie: structure and headers) from * the server, which is done automatically. Actual message contents (ie: body) * will not be fetched if possible (IMAP allows it, whereas POP3 will require * to fetch the whole message). * * @return a RFC-822-parsed message */ virtual ref getParsedMessage() = 0; }; } // net } // vmime #endif // VMIME_NET_MESSAGE_HPP_INCLUDED libvmime-0.9.1/vmime/net/transport.hpp0000644000175000017500000000456111250723264020307 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_TRANSPORT_HPP_INCLUDED #define VMIME_NET_TRANSPORT_HPP_INCLUDED #include "vmime/net/service.hpp" #include "vmime/utility/stream.hpp" #include "vmime/mailboxList.hpp" namespace vmime { class message; class mailbox; class mailboxList; namespace net { /** A transport service. * Encapsulate protocols that can send messages. */ class transport : public service { protected: transport(ref sess, const serviceInfos& infos, ref auth); public: /** Send a message over this transport service. * * @param msg message to send * @param progress progress listener, or NULL if not used */ virtual void send(ref msg, utility::progressListener* progress = NULL); /** Send a message over this transport service. * * @param expeditor expeditor mailbox * @param recipients list of recipient mailboxes * @param is input stream provding message data (header + body) * @param size size of the message data * @param progress progress listener, or NULL if not used */ virtual void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL) = 0; Type getType() const; }; } // net } // vmime #endif // VMIME_NET_TRANSPORT_HPP_INCLUDED libvmime-0.9.1/vmime/net/connectionInfos.hpp0000644000175000017500000000323311250723264021404 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_CONNECTIONINFOS_HPP_INCLUDED #define VMIME_NET_CONNECTIONINFOS_HPP_INCLUDED #include "vmime/object.hpp" namespace vmime { namespace net { /** Information about the connection used by a service. */ class connectionInfos : public object { public: /** Return the host to which the service is connected. * * @return server host name or address */ virtual const string getHost() const = 0; /** Return the port to which the service is connected. * * @return server port */ virtual port_t getPort() const = 0; }; } // net } // vmime #endif // VMIME_NET_CONNECTIONINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/serviceFactory.hpp0000644000175000017500000001051711250723264021241 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SERVICEFACTORY_HPP_INCLUDED #define VMIME_NET_SERVICEFACTORY_HPP_INCLUDED #include #include "vmime/types.hpp" #include "vmime/base.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/utility/url.hpp" #include "vmime/net/service.hpp" #include "vmime/net/serviceInfos.hpp" #include "vmime/net/timeoutHandler.hpp" #include "vmime/security/authenticator.hpp" #include "vmime/utility/progressListener.hpp" namespace vmime { namespace net { class session; /** A factory to create 'service' objects for a specified protocol. */ class serviceFactory { private: serviceFactory(); ~serviceFactory(); public: static serviceFactory* getInstance(); /** Information about a registered service. */ class registeredService : public object { friend class serviceFactory; protected: virtual ~registeredService() { } public: virtual ref create (ref sess, ref auth) const = 0; virtual int getType() const = 0; virtual const string& getName() const = 0; virtual const serviceInfos& getInfos() const = 0; }; /** Register a new service by its protocol name. * * @param reg service registration infos */ void registerService(ref reg); /** Create a new service instance from a protocol name. * * @param sess session * @param protocol protocol name (eg. "pop3") * @param auth authenticator used to provide credentials (can be NULL if not used) * @return a new service instance for the specified protocol * @throw exceptions::no_service_available if no service is registered * for this protocol */ ref create (ref sess, const string& protocol, ref auth = NULL); /** Create a new service instance from a URL. * * @param sess session * @param u full URL with at least protocol and server (you can also specify * port, username and password) * @param auth authenticator used to provide credentials (can be NULL if not used) * @return a new service instance for the specified protocol * @throw exceptions::no_service_available if no service is registered * for this protocol */ ref create (ref sess, const utility::url& u, ref auth = NULL); /** Return information about a registered protocol. * * @param protocol protocol name * @return information about this protocol * @throw exceptions::no_service_available if no service is registered * for this protocol */ ref getServiceByProtocol(const string& protocol) const; /** Return the number of registered services. * * @return number of registered services */ int getServiceCount() const; /** Return the registered service at the specified position. * * @param pos position of the registered service to return * @return registered service at the specified position */ ref getServiceAt(const int pos) const; /** Return a list of all registered services. * * @return list of registered services */ const std::vector > getServiceList() const; private: std::vector > m_services; }; } // net } // vmime #endif // VMIME_NET_SERVICEFACTORY_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/0000755000175000017500000000000011607302336017154 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/maildir/maildirServiceInfos.hpp0000644000175000017500000000334411250723264023633 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_MAILDIRSERVICEINFOS_HPP_INCLUDED #define VMIME_NET_MAILDIR_MAILDIRSERVICEINFOS_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/serviceInfos.hpp" namespace vmime { namespace net { namespace maildir { /** Information about maildir service. */ class maildirServiceInfos : public serviceInfos { public: maildirServiceInfos(); struct props { serviceInfos::property PROPERTY_SERVER_ROOTPATH; }; const props& getProperties() const; const string getPropertyPrefix() const; const std::vector getAvailableProperties() const; }; } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_MAILDIRSERVICEINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/maildirStore.hpp0000644000175000017500000000526611250723264022335 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_MAILDIRSTORE_HPP_INCLUDED #define VMIME_NET_MAILDIR_MAILDIRSTORE_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/store.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/folder.hpp" #include "vmime/net/maildir/maildirFormat.hpp" #include "vmime/net/maildir/maildirServiceInfos.hpp" #include "vmime/utility/file.hpp" #include namespace vmime { namespace net { namespace maildir { class maildirFolder; /** maildir store service. */ class maildirStore : public store { friend class maildirFolder; public: maildirStore(ref sess, ref auth); ~maildirStore(); const string getProtocolName() const; ref getDefaultFolder(); ref getRootFolder(); ref getFolder(const folder::path& path); bool isValidFolderName(const folder::path::component& name) const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; void connect(); bool isConnected() const; void disconnect(); void noop(); const utility::path& getFileSystemPath() const; int getCapabilities() const; bool isSecuredConnection() const; ref getConnectionInfos() const; ref getFormat(); ref getFormat() const; private: void registerFolder(maildirFolder* folder); void unregisterFolder(maildirFolder* folder); std::list m_folders; ref m_format; bool m_connected; utility::path m_fsPath; // Service infos static maildirServiceInfos sm_infos; }; } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_MAILDIRSTORE_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/format/0000755000175000017500000000000011607302336020444 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/maildir/format/kmailMaildirFormat.hpp0000644000175000017500000000565511250723264024741 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_FORMAT_KMAILMAILDIRFORMAT_HPP_INCLUDED #define VMIME_NET_MAILDIR_FORMAT_KMAILMAILDIRFORMAT_HPP_INCLUDED #include "vmime/net/maildir/maildirFormat.hpp" namespace vmime { namespace net { namespace maildir { namespace format { /** Reads KMail Maildir format. */ class kmailMaildirFormat : public maildirFormat { public: kmailMaildirFormat(ref ctx); /* Folder types: * * - ROOT_DIRECTORY: ~/Mail/MyFolder * - NEW_DIRECTORY: ~/Mail/MyFolder/new * - CUR_DIRECTORY: ~/Mail/MyFolder/cur * - TMP_DIRECTORY: ~/Mail/MyFolder/tmp * - CONTAINER_DIRECTORY: ~/Mail/.MyFolder.directory */ const string getName() const; void createFolder(const folder::path& path); void destroyFolder(const folder::path& path); void renameFolder(const folder::path& oldPath, const folder::path& newPath); bool folderExists(const folder::path& path) const; bool folderHasSubfolders(const folder::path& path) const; const utility::file::path folderPathToFileSystemPath (const folder::path& path, const DirectoryType type) const; const std::vector listFolders (const folder::path& root, const bool recursive) const; protected: bool supports() const; /** Recursive implementation of listFolders(). */ void listFoldersImpl(std::vector & list, const folder::path& root, const bool recursive) const; /** Test whether the specified file system directory corresponds to * a maildir subfolder. The name of the directory should not start * with '.' to be listed as a subfolder. * * @param file reference to a file system directory * @return true if the specified directory is a maildir subfolder, * false otherwise */ static bool isSubfolderDirectory(const utility::file& file); }; } // format } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_FORMAT_KMAILMAILDIRFORMAT_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/format/courierMaildirFormat.hpp0000644000175000017500000000677511250723264025320 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_FORMAT_COURIERMAILDIRFORMAT_HPP_INCLUDED #define VMIME_NET_MAILDIR_FORMAT_COURIERMAILDIRFORMAT_HPP_INCLUDED #include "vmime/net/maildir/maildirFormat.hpp" namespace vmime { namespace net { namespace maildir { namespace format { /** Reads Courier/QMail Maildir format. */ class courierMaildirFormat : public maildirFormat { public: courierMaildirFormat(ref ctx); /* Folder types: * * - ROOT_DIRECTORY: ~/Mail/.MyFolder * - NEW_DIRECTORY: ~/Mail/.MyFolder/new * - CUR_DIRECTORY: ~/Mail/.MyFolder/cur * - TMP_DIRECTORY: ~/Mail/.MyFolder/tmp * - CONTAINER_DIRECTORY: not used */ const string getName() const; void createFolder(const folder::path& path); void destroyFolder(const folder::path& path); void renameFolder(const folder::path& oldPath, const folder::path& newPath); bool folderExists(const folder::path& path) const; bool folderHasSubfolders(const folder::path& path) const; const utility::file::path folderPathToFileSystemPath (const folder::path& path, const DirectoryType type) const; const std::vector listFolders (const folder::path& root, const bool recursive) const; protected: bool supports() const; static const string toModifiedUTF7(const folder::path::component& text); static const folder::path::component fromModifiedUTF7(const string& text); void renameFolderImpl(const folder::path& oldPath, const folder::path& newPath); /** Test whether the specified file system directory corresponds to * a maildir subfolder. The name of the directory should start * with a '.' to be listed as a subfolder. * * @param file reference to a file system directory * @return true if the specified directory is a maildir subfolder, * false otherwise */ static bool isSubfolderDirectory(const utility::file& file); /** List directories corresponding to folders which are (direct or * indirect) children of specified folder. * * @param root root folder * @param dirs list in which found directories will be added * @param onlyTestForExistence if true, the function returns as soon * as the first directory is found * @return true if at least one directory has been found, * false otherwise */ bool listDirectories(const folder::path& root, std::vector & dirs, const bool onlyTestForExistence) const; }; } // format } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_FORMAT_COURIERMAILDIRFORMAT_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/maildirFormat.hpp0000644000175000017500000001241611333330451022456 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_FORMAT_MAILDIRFORMAT_HPP_INCLUDED #define VMIME_NET_MAILDIR_FORMAT_MAILDIRFORMAT_HPP_INCLUDED #include "vmime/net/folder.hpp" #include "vmime/utility/file.hpp" #include "vmime/utility/path.hpp" namespace vmime { namespace net { namespace maildir { class maildirStore; /** Interface for an object capable of reading a specific Maildir format. */ class maildirFormat : public object { public: class context : public object { public: context(ref store); ref getStore() const; private: weak_ref m_store; }; /** Physical directory types. */ enum DirectoryType { ROOT_DIRECTORY, /**< Root directory. */ NEW_DIRECTORY, /**< Directory containing unread messages. */ CUR_DIRECTORY, /**< Directory containing messages that have been seen. */ TMP_DIRECTORY, /**< Temporary directory used for reliable delivery. */ CONTAINER_DIRECTORY /**< Container for subfolders. */ }; /** Return the name of this Maildir format. * * @return format name */ virtual const string getName() const = 0; /** Create the specified folder. * * @param path virtual path of the folder * @throw filesystem_exception, invalid_folder_name */ virtual void createFolder(const folder::path& path) = 0; /** Destroy the specified folder. * * @param path virtual path of the folder * @throw filesystem_exception */ virtual void destroyFolder(const folder::path& path) = 0; /** Rename the specified folder. * * @param oldPath old virtual path of the folder * @param newPath new virtual path of the folder * @throw filesystem_exception */ virtual void renameFolder(const folder::path& oldPath, const folder::path& newPath) = 0; /** Test whether the specified folder exists. * * @param path virtual path of the folder * @return true if the folder exists, false otherwise */ virtual bool folderExists(const folder::path& path) const = 0; /** Test whether the specified folder has subfolders. * * @param path virtual path of the folder * @return true if the folder has at least one subfolder, * false otherwise */ virtual bool folderHasSubfolders(const folder::path& path) const = 0; /** Returns the directory which represents the specified * folder on the file system. * * @param path virtual path of the folder * @param type type of directory to return * @return corresponding directory on the file system */ virtual const utility::file::path folderPathToFileSystemPath (const folder::path& path, const DirectoryType type) const = 0; /** List subfolders in the specified folder. * * @param root root folder in which to start the search * @param recursive if set to true, all the descendant are * returned; if set to false, only direct children are returned. * @return list of subfolders */ virtual const std::vector listFolders (const folder::path& root, const bool recursive) const = 0; /** Try to detect the format of the specified Maildir store. * If the format cannot be detected, a compatible implementation * will be returned. * * @param store of which to detect format * @return a Maildir format implementation for the specified store */ static ref detect(ref store); protected: static const utility::file::path::component TMP_DIR; /**< Ensure reliable delivery (not to be listed). */ static const utility::file::path::component CUR_DIR; /**< No longer new messages. */ static const utility::file::path::component NEW_DIR; /**< Unread messages. */ maildirFormat(ref ctx); /** Returns the current context. * * @return current context */ ref getContext(); /** Returns the current context (const version). * * @return current context */ ref getContext() const; /** Quick checks whether this implementation can read the Maildir * format in the specified directory. * * @return true if the implementation supports the specified * Maildir, or false otherwise */ virtual bool supports() const = 0; private: ref m_context; }; } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_FORMAT_MAILDIRFORMAT_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/maildirFolder.hpp0000644000175000017500000001224211250723264022444 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_MAILDIRFOLDER_HPP_INCLUDED #define VMIME_NET_MAILDIR_MAILDIRFOLDER_HPP_INCLUDED #include #include #include "vmime/types.hpp" #include "vmime/net/folder.hpp" #include "vmime/utility/file.hpp" namespace vmime { namespace net { namespace maildir { class maildirStore; class maildirMessage; /** maildir folder implementation. */ class maildirFolder : public folder { private: friend class maildirStore; friend class maildirMessage; friend class vmime::creator; // vmime::create maildirFolder(const folder::path& path, ref store); maildirFolder(const maildirFolder&) : folder() { } ~maildirFolder(); public: int getMode() const; int getType(); int getFlags(); const folder::path::component getName() const; const folder::path getFullPath() const; void open(const int mode, bool failIfModeIsNotAvailable = false); void close(const bool expunge); void create(const int type); bool exists(); void destroy(); bool isOpen() const; ref getMessage(const int num); std::vector > getMessages(const int from = 1, const int to = -1); std::vector > getMessages(const std::vector & nums); int getMessageCount(); ref getFolder(const folder::path::component& name); std::vector > getFolders(const bool recursive = false); void rename(const folder::path& newPath); void deleteMessage(const int num); void deleteMessages(const int from = 1, const int to = -1); void deleteMessages(const std::vector & nums); void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector & nums, const int flags, const int mode = message::FLAG_MODE_SET); void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); void copyMessages(const folder::path& dest, const int from = 1, const int to = -1); void copyMessages(const folder::path& dest, const std::vector & nums); void status(int& count, int& unseen); void expunge(); ref getParent(); ref getStore() const; ref getStore(); void fetchMessages(std::vector >& msg, const int options, utility::progressListener* progress = NULL); void fetchMessage(ref msg, const int options); int getFetchCapabilities() const; private: void scanFolder(); void listFolders(std::vector >& list, const bool recursive); void registerMessage(maildirMessage* msg); void unregisterMessage(maildirMessage* msg); const utility::file::path getMessageFSPath(const int number) const; void onStoreDisconnected(); void onClose(); void deleteMessagesImpl(const std::vector & nums); void setMessageFlagsImpl(const std::vector & nums, const int flags, const int mode); void copyMessagesImpl(const folder::path& dest, const std::vector & nums); void copyMessageImpl(const utility::file::path& tmpDirPath, const utility::file::path& curDirPath, const utility::file::path::component& filename, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress); void notifyMessagesCopied(const folder::path& dest); weak_ref m_store; folder::path m_path; folder::path::component m_name; int m_mode; bool m_open; int m_unreadMessageCount; int m_messageCount; // Store information about scanned messages struct messageInfos { enum Type { TYPE_CUR, TYPE_DELETED }; utility::file::path::component path; // filename Type type; // current location }; std::vector m_messageInfos; // Instanciated message objects std::vector m_messages; }; } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_MAILDIRFOLDER_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/maildirUtils.hpp0000644000175000017500000001006111250723264022326 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_MAILDIRUTILS_HPP_INCLUDED #define VMIME_NET_MAILDIR_MAILDIRUTILS_HPP_INCLUDED #include "vmime/utility/file.hpp" #include "vmime/utility/path.hpp" namespace vmime { namespace net { namespace maildir { class maildirStore; /** Miscellaneous helpers functions for maildir messaging system. */ class maildirUtils { public: /** Comparator for message filenames, based only on the * unique identifier part of the filename. */ class messageIdComparator { public: messageIdComparator(const utility::file::path::component& comp); bool operator()(const utility::file::path::component& other) const; private: const utility::file::path::component m_comp; }; /** Test whether the specified file-system object is a message. * * @param file reference to a file-system object * @return true if the specified object is a message file, * false otherwise */ static bool isMessageFile(const utility::file& file); /** Extract the unique identifier part of the message filename. * Eg: for the filename "1071577232.28549.m03s:2,RS", it will * return "1071577232.28549.m03s". * * @param filename filename part * @return part of the filename that corresponds to the unique * identifier of the message */ static const utility::file::path::component extractId(const utility::file::path::component& filename); /** Extract message flags from the specified message filename. * Eg: for the filename "1071577232.28549.m03s:2,RS", it will * return (message::FLAG_SEEN | message::FLAG_REPLIED). * * @param comp filename part * @return message flags extracted from the specified filename */ static int extractFlags(const utility::file::path::component& comp); /** Return a string representing the specified message flags. * Eg: for (message::FLAG_SEEN | message::FLAG_REPLIED), it will * return "RS". * * @param flags set of flags * @return message flags in a string representation */ static const utility::file::path::component buildFlags(const int flags); /** Build a filename with the specified id and flags. * * @param id id part of the filename * @param flags flags part of the filename * @return message filename */ static const utility::file::path::component buildFilename(const utility::file::path::component& id, const utility::file::path::component& flags); /** Build a filename with the specified id and flags. * * @param id id part of the filename * @param flags set of flags * @return message filename */ static const utility::file::path::component buildFilename(const utility::file::path::component& id, const int flags); /** Generate a new unique message identifier. * * @return unique message id */ static const utility::file::path::component generateId(); /** Recursively delete a directory on the file system. * * @param dir directory to delete */ static void recursiveFSDelete(ref dir); }; } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_MAILDIRUTILS_HPP_INCLUDED libvmime-0.9.1/vmime/net/maildir/maildirMessage.hpp0000644000175000017500000000563711314461664022633 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_MAILDIR_MAILDIRMESSAGE_HPP_INCLUDED #define VMIME_NET_MAILDIR_MAILDIRMESSAGE_HPP_INCLUDED #include "vmime/net/message.hpp" #include "vmime/net/folder.hpp" namespace vmime { namespace net { namespace maildir { class maildirFolder; /** maildir message implementation. */ class maildirMessage : public message { friend class maildirFolder; friend class vmime::creator; // vmime::create private: maildirMessage(ref folder, const int num); maildirMessage(const maildirMessage&) : message() { } ~maildirMessage(); public: int getNumber() const; const uid getUniqueId() const; int getSize() const; bool isExpunged() const; ref getStructure() const; ref getStructure(); ref getHeader() const; int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; void extractPart(ref p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; void fetchPartHeader(ref p); ref getParsedMessage(); private: void fetch(ref folder, const int options); void onFolderClosed(); ref
getOrCreateHeader(); void extractImpl(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const int partialStart, const int partialLength, const bool peek) const; weak_ref m_folder; int m_num; int m_size; int m_flags; bool m_expunged; uid m_uid; ref
m_header; ref m_structure; }; } // maildir } // net } // vmime #endif // VMIME_NET_MAILDIR_MAILDIRMESSAGE_HPP_INCLUDED libvmime-0.9.1/vmime/net/defaultConnectionInfos.hpp0000644000175000017500000000313011250723264022705 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_DEFAULTCONNECTIONINFOS_HPP_INCLUDED #define VMIME_NET_DEFAULTCONNECTIONINFOS_HPP_INCLUDED #include "vmime/net/connectionInfos.hpp" namespace vmime { namespace net { /** Information about the connection used by a service. */ class defaultConnectionInfos : public connectionInfos { public: defaultConnectionInfos(const string& host, const port_t port); const string getHost() const; port_t getPort() const; private: string m_host; port_t m_port; }; } // net } // vmime #endif // VMIME_NET_DEFAULTCONNECTIONINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/securedConnectionInfos.hpp0000644000175000017500000000266311250723264022725 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SECUREDCONNECTIONINFOS_HPP_INCLUDED #define VMIME_NET_SECUREDCONNECTIONINFOS_HPP_INCLUDED #include "vmime/net/connectionInfos.hpp" namespace vmime { namespace net { /** Information about the secured connection used by a service. */ class securedConnectionInfos : public connectionInfos { }; } // net } // vmime #endif // VMIME_NET_SECUREDCONNECTIONINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/socket.hpp0000644000175000017500000000664711421612630017544 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SOCKET_HPP_INCLUDED #define VMIME_NET_SOCKET_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/net/timeoutHandler.hpp" namespace vmime { namespace net { /** Interface for connecting to servers. */ class socket : public object { public: virtual ~socket() { } /** Type used for lengths in streams. */ typedef int size_type; /** Connect to the specified address and port. * * @param address server address (this can be a full qualified domain name * or an IP address, doesn't matter) * @param port server port */ virtual void connect(const string& address, const port_t port) = 0; /** Disconnect from the server. */ virtual void disconnect() = 0; /** Test whether this socket is connected. * * @return true if the socket is connected, false otherwise */ virtual bool isConnected() const = 0; /** Receive (text) data from the socket. * * @param buffer buffer in which to write received data */ virtual void receive(string& buffer) = 0; /** Receive (raw) data from the socket. * * @param buffer buffer in which to write received data * @param count maximum number of bytes to receive (size of buffer) * @return number of bytes received/written into output buffer */ virtual int receiveRaw(char* buffer, const size_type count) = 0; /** Send (text) data to the socket. * * @param buffer data to send */ virtual void send(const string& buffer) = 0; /** Send (raw) data to the socket. * * @param buffer data to send * @param count number of bytes to send (size of buffer) */ virtual void sendRaw(const char* buffer, const size_type count) = 0; /** Return the preferred maximum block size when reading * from or writing to this stream. * * @return block size, in bytes */ virtual size_type getBlockSize() const = 0; protected: socket() { } private: socket(const socket&) : object() { } }; /** A class to create 'socket' objects. */ class socketFactory : public object { public: virtual ~socketFactory() { } /** Creates a socket without timeout handler. * * @return a new socket */ virtual ref create() = 0; /** Creates a socket with the specified timeout handler. * * @param th timeout handler * @return a new socket */ virtual ref create(ref th) = 0; }; } // net } // vmime #endif // VMIME_NET_SOCKET_HPP_INCLUDED libvmime-0.9.1/vmime/net/folder.hpp0000644000175000017500000003277111250723264017532 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_FOLDER_HPP_INCLUDED #define VMIME_NET_FOLDER_HPP_INCLUDED #include #include "vmime/types.hpp" #include "vmime/dateTime.hpp" #include "vmime/message.hpp" #include "vmime/net/message.hpp" #include "vmime/net/events.hpp" #include "vmime/utility/path.hpp" #include "vmime/utility/stream.hpp" #include "vmime/utility/progressListener.hpp" namespace vmime { namespace net { class store; /** Abstract representation of a folder in a message store. */ class folder : public object { protected: folder(const folder&) : object() { } folder() { } public: virtual ~folder() { } /** Type used for fully qualified path name of a folder. */ typedef vmime::utility::path path; /** Open mode. */ enum Modes { MODE_READ_ONLY, /**< Read-only mode (no modification to folder or messages is possible). */ MODE_READ_WRITE /**< Full access mode (read and write). */ }; /** Folder types. */ enum Types { TYPE_CONTAINS_FOLDERS = (1 << 0), /**< Folder can contain folders. */ TYPE_CONTAINS_MESSAGES = (1 << 1), /**< Folder can contain messages. */ TYPE_UNDEFINED = 9999 /**< Used internally (this should not be returned by the type() function). */ }; /** Folder flags. */ enum Flags { FLAG_CHILDREN = (1 << 0), /**< Folder contains subfolders. */ FLAG_NO_OPEN = (1 << 1), /**< Folder cannot be open. */ FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned by the type() function). */ }; /** Return the type of this folder. * * @return folder type (see folder::Types) */ virtual int getType() = 0; /** Return the flags of this folder. * * @return folder flags (see folder::Flags) */ virtual int getFlags() = 0; /** Return the mode in which the folder has been open. * * @return folder opening mode (see folder::Modes) */ virtual int getMode() const = 0; /** Return the name of this folder. * * @return folder name */ virtual const folder::path::component getName() const = 0; /** Return the fully qualified path name of this folder. * * @return absolute path of the folder */ virtual const folder::path getFullPath() const = 0; /** Open this folder. * * @param mode open mode (see folder::Modes) * @param failIfModeIsNotAvailable if set to false and if the requested mode * is not available, a more restricted mode will be selected automatically. * If set to true and if the requested mode is not available, the opening * will fail. * @throw net_exception if an error occurs */ virtual void open(const int mode, bool failIfModeIsNotAvailable = false) = 0; /** Close this folder. * * @param expunge if set to true, deleted messages are expunged * @throw net_exception if an error occurs */ virtual void close(const bool expunge) = 0; /** Create this folder. * * @param type folder type (see folder::Types) * @throw net_exception if an error occurs */ virtual void create(const int type) = 0; /** Test whether this folder exists. * * @return true if the folder exists, false otherwise */ virtual bool exists() = 0; /** Delete this folder. * The folder should be closed before attempting to delete it. * * @throw net_exception if an error occurs */ virtual void destroy() = 0; /** Test whether this folder is open. * * @return true if the folder is open, false otherwise */ virtual bool isOpen() const = 0; /** Get a new reference to a message in this folder. * * @param num message sequence number * @return a new object referencing the specified message * @throw net_exception if an error occurs */ virtual ref getMessage(const int num) = 0; /** Get new references to messages in this folder. * * @param from sequence number of the first message to get * @param to sequence number of the last message to get * @return new objects referencing the specified messages * @throw net_exception if an error occurs */ virtual std::vector > getMessages(const int from = 1, const int to = -1) = 0; /** Get new references to messages in this folder. * * @param nums sequence numbers of the messages to delete * @return new objects referencing the specified messages * @throw net_exception if an error occurs */ virtual std::vector > getMessages(const std::vector & nums) = 0; /** Return the number of messages in this folder. * * @return number of messages in the folder */ virtual int getMessageCount() = 0; /** Get a new reference to a sub-folder in this folder. * * @param name sub-folder name * @return a new object referencing the specified folder * @throw net_exception if an error occurs */ virtual ref getFolder(const folder::path::component& name) = 0; /** Get the list of all sub-folders in this folder. * * @param recursive if set to true, all the descendant are returned. * If set to false, only the direct children are returned. * @return list of sub-folders * @throw net_exception if an error occurs */ virtual std::vector > getFolders(const bool recursive = false) = 0; /** Rename (move) this folder to another location. * * @param newPath new path of the folder * @throw net_exception if an error occurs */ virtual void rename(const folder::path& newPath) = 0; /** Remove a message in this folder. * * @param num sequence number of the message to delete * @throw net_exception if an error occurs */ virtual void deleteMessage(const int num) = 0; /** Remove one or more messages from this folder. * * @param from sequence number of the first message to delete * @param to sequence number of the last message to delete * @throw net_exception if an error occurs */ virtual void deleteMessages(const int from = 1, const int to = -1) = 0; /** Remove one or more messages from this folder. * * @param nums sequence numbers of the messages to delete * @throw net_exception if an error occurs */ virtual void deleteMessages(const std::vector & nums) = 0; /** Change the flags for one or more messages in this folder. * * @param from sequence number of the first message to modify * @param to sequence number of the last message to modify * @param flags set of flags (see message::Flags) * @param mode indicate how to treat old and new flags (see message::FlagsModes) * @throw net_exception if an error occurs */ virtual void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET) = 0; /** Change the flags for one or more messages in this folder. * * @param nums sequence numbers of the messages to modify * @param flags set of flags (see message::Flags) * @param mode indicate how to treat old and new flags (see message::FlagsModes) * @throw net_exception if an error occurs */ virtual void setMessageFlags(const std::vector & nums, const int flags, const int mode = message::FLAG_MODE_SET) = 0; /** Add a message to this folder. * * @param msg message to add (data: header + body) * @param flags flags for the new message * @param date date/time for the new message (if NULL, the current time is used) * @param progress progress listener, or NULL if not used * @throw net_exception if an error occurs */ virtual void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; /** Add a message to this folder. * * @param is message to add (data: header + body) * @param size size of the message to add (in bytes) * @param flags flags for the new message * @param date date/time for the new message (if NULL, the current time is used) * @param progress progress listener, or NULL if not used * @throw net_exception if an error occurs */ virtual void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; /** Copy a message from this folder to another folder. * * @param dest destination folder path * @param num sequence number of the message to copy * @throw net_exception if an error occurs */ virtual void copyMessage(const folder::path& dest, const int num) = 0; /** Copy messages from this folder to another folder. * * @param dest destination folder path * @param from sequence number of the first message to copy * @param to sequence number of the last message to copy * @throw net_exception if an error occurs */ virtual void copyMessages(const folder::path& dest, const int from = 1, const int to = -1) = 0; /** Copy messages from this folder to another folder. * * @param dest destination folder path * @param nums sequence numbers of the messages to copy * @throw net_exception if an error occurs */ virtual void copyMessages(const folder::path& dest, const std::vector & nums) = 0; /** Request folder status without opening it. * * @param count will receive the number of messages in the folder * @param unseen will receive the number of unseen messages in the folder * @throw net_exception if an error occurs */ virtual void status(int& count, int& unseen) = 0; /** Expunge deleted messages. * * @throw net_exception if an error occurs */ virtual void expunge() = 0; /** Return a new folder object referencing the parent folder of this folder. * * @return parent folder object */ virtual ref getParent() = 0; /** Return a reference to the store to which this folder belongs. * * @return the store object to which this folder is attached */ virtual ref getStore() const = 0; /** Return a reference to the store to which this folder belongs. * * @return the store object to which this folder is attached */ virtual ref getStore() = 0; /** Fetchable objects. */ enum FetchOptions { FETCH_ENVELOPE = (1 << 0), /**< Fetch sender, recipients, date, subject. */ FETCH_STRUCTURE = (1 << 1), /**< Fetch structure (body parts). */ FETCH_CONTENT_INFO = (1 << 2), /**< Fetch top-level content type. */ FETCH_FLAGS = (1 << 3), /**< Fetch message flags. */ FETCH_SIZE = (1 << 4), /**< Fetch message size (exact or estimated). */ FETCH_FULL_HEADER = (1 << 5), /**< Fetch full RFC-[2]822 header. */ FETCH_UID = (1 << 6), /**< Fetch unique identifier (protocol specific). */ FETCH_IMPORTANCE = (1 << 7), /**< Fetch header fields suitable for use with misc::importanceHelper. */ FETCH_CUSTOM = (1 << 16) /**< Reserved for future use. */ }; /** Fetch objects for the specified messages. * * @param msg list of message sequence numbers * @param options objects to fetch (combination of folder::FetchOptions flags) * @param progress progress listener, or NULL if not used * @throw net_exception if an error occurs */ virtual void fetchMessages(std::vector >& msg, const int options, utility::progressListener* progress = NULL) = 0; /** Fetch objects for the specified message. * * @param msg the message * @param options objects to fetch (combination of folder::FetchOptions flags) * @throw net_exception if an error occurs */ virtual void fetchMessage(ref msg, const int options) = 0; /** Return the list of fetchable objects supported by * the underlying protocol (see folder::FetchOptions). * * @return list of supported fetchable objects */ virtual int getFetchCapabilities() const = 0; // Event listeners void addMessageChangedListener(events::messageChangedListener* l); void removeMessageChangedListener(events::messageChangedListener* l); void addMessageCountListener(events::messageCountListener* l); void removeMessageCountListener(events::messageCountListener* l); void addFolderListener(events::folderListener* l); void removeFolderListener(events::folderListener* l); protected: void notifyMessageChanged(const events::messageChangedEvent& event); void notifyMessageCount(const events::messageCountEvent& event); void notifyFolder(const events::folderEvent& event); private: std::list m_messageChangedListeners; std::list m_messageCountListeners; std::list m_folderListeners; }; } // net } // vmime #endif // VMIME_NET_FOLDER_HPP_INCLUDED libvmime-0.9.1/vmime/net/sendmail/0000755000175000017500000000000011607302336017327 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/net/sendmail/sendmailTransport.hpp0000644000175000017500000000502411250723264023553 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SENDMAIL_SENDMAILTRANSPORT_HPP_INCLUDED #define VMIME_NET_SENDMAIL_SENDMAILTRANSPORT_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/transport.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" #include "vmime/net/sendmail/sendmailServiceInfos.hpp" #if VMIME_BUILTIN_PLATFORM_POSIX namespace vmime { namespace net { namespace sendmail { /** Sendmail local transport service. */ class sendmailTransport : public transport { public: sendmailTransport(ref sess, ref auth); ~sendmailTransport(); const string getProtocolName() const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; void connect(); bool isConnected() const; void disconnect(); void noop(); void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL); bool isSecuredConnection() const; ref getConnectionInfos() const; private: void internalDisconnect(); void internalSend(const std::vector args, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress); string m_sendmailPath; bool m_connected; // Service infos static sendmailServiceInfos sm_infos; }; } // sendmail } // net } // vmime #endif // VMIME_BUILTIN_PLATFORM_POSIX #endif // VMIME_NET_SENDMAIL_SENDMAILTRANSPORT_HPP_INCLUDED libvmime-0.9.1/vmime/net/sendmail/sendmailServiceInfos.hpp0000644000175000017500000000346311250723264024163 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SENDMAIL_SENDMAILSERVICEINFOS_HPP_INCLUDED #define VMIME_NET_SENDMAIL_SENDMAILSERVICEINFOS_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/net/serviceInfos.hpp" #if VMIME_BUILTIN_PLATFORM_POSIX namespace vmime { namespace net { namespace sendmail { /** Information about sendmail service. */ class sendmailServiceInfos : public serviceInfos { public: sendmailServiceInfos(); struct props { serviceInfos::property PROPERTY_BINPATH; }; const props& getProperties() const; const string getPropertyPrefix() const; const std::vector getAvailableProperties() const; }; } // sendmail } // net } // vmime #endif // VMIME_BUILTIN_PLATFORM_POSIX #endif // VMIME_NET_SENDMAIL_SENDMAILSERVICEINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/session.hpp0000644000175000017500000001170111250723264017730 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SESSION_HPP_INCLUDED #define VMIME_NET_SESSION_HPP_INCLUDED #include "vmime/security/authenticator.hpp" #include "vmime/utility/url.hpp" #include "vmime/propertySet.hpp" namespace vmime { namespace net { class store; class transport; /** An object that contains all the information needed * for connection to a service. */ class session : public object { public: session(); session(const session& sess); session(const propertySet& props); virtual ~session(); /** Return a transport service instance for the protocol specified * in the session properties. * * The property "transport.protocol" specify the protocol to use. * * @param auth authenticator object to use for the new transport service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ ref getTransport (ref auth = NULL); /** Return a transport service instance for the specified protocol. * * @param protocol transport protocol to use (eg. "smtp") * @param auth authenticator object to use for the new transport service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ ref getTransport (const string& protocol, ref auth = NULL); /** Return a transport service instance for the specified URL. * * @param url full URL with at least the protocol to use (eg: "smtp://myserver.com/") * @param auth authenticator object to use for the new transport service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ ref getTransport (const utility::url& url, ref auth = NULL); /** Return a transport service instance for the protocol specified * in the session properties. * * The property "store.protocol" specify the protocol to use. * * @param auth authenticator object to use for the new store service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ ref getStore(ref auth = NULL); /** Return a store service instance for the specified protocol. * * @param protocol store protocol to use (eg. "imap") * @param auth authenticator object to use for the new store service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ ref getStore (const string& protocol, ref auth = NULL); /** Return a store service instance for the specified URL. * * @param url full URL with at least the protocol to use (eg: "imap://username:password@myserver.com/") * @param auth authenticator object to use for the new store service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ ref getStore (const utility::url& url, ref auth = NULL); /** Properties for the session and for the services. */ const propertySet& getProperties() const; /** Properties for the session and for the services. */ propertySet& getProperties(); private: propertySet m_props; }; } // net } // vmime #endif // VMIME_NET_SESSION_HPP_INCLUDED libvmime-0.9.1/vmime/net/timeoutHandler.hpp0000644000175000017500000000406511421615154021234 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_TIMEOUTHANDLER_HPP_INCLUDED #define VMIME_NET_TIMEOUTHANDLER_HPP_INCLUDED #include "vmime/types.hpp" namespace vmime { namespace net { /** A class to manage time-out in messaging services. */ class timeoutHandler : public object { public: virtual ~timeoutHandler() { } /** Called to test if the time limit has been reached. * * @return true if the time-out delay is elapsed */ virtual bool isTimeOut() = 0; /** Called to reset the time-out counter. */ virtual void resetTimeOut() = 0; /** Called when the time limit has been reached (when * isTimeOut() returned true). * * @return true to continue (and reset the time-out) * or false to cancel the current operation */ virtual bool handleTimeOut() = 0; }; /** A class to create 'timeoutHandler' objects. */ class timeoutHandlerFactory : public object { public: virtual ~timeoutHandlerFactory() { } virtual ref create() = 0; }; } // net } // vmime #endif // VMIME_NET_TIMEOUTHANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/net/service.hpp0000644000175000017500000001362511250723264017714 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SERVICE_HPP_INCLUDED #define VMIME_NET_SERVICE_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/types.hpp" #include "vmime/net/session.hpp" #include "vmime/net/serviceInfos.hpp" #include "vmime/net/connectionInfos.hpp" #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" #if VMIME_HAVE_TLS_SUPPORT #include "vmime/security/cert/certificateVerifier.hpp" #endif // VMIME_HAVE_TLS_SUPPORT #include "vmime/utility/progressListener.hpp" namespace vmime { namespace net { /** Base class for messaging services. */ class service : public object { protected: service(ref sess, const serviceInfos& infos, ref auth); public: virtual ~service(); /** Possible service types. */ enum Type { TYPE_STORE = 0, /**< The service is a message store. */ TYPE_TRANSPORT /**< The service sends messages. */ }; /** Return the type of service. * * @return type of service */ virtual Type getType() const = 0; /** Return the protocol name of this service. * * @return protocol name */ virtual const string getProtocolName() const = 0; /** Return the session object associated with this service instance. * * @return session object */ ref getSession() const; /** Return the session object associated with this service instance. * * @return session object */ ref getSession(); /** Return information about this service. * * @return information about the service */ virtual const serviceInfos& getInfos() const = 0; /** Connect to service. */ virtual void connect() = 0; /** Disconnect from service. */ virtual void disconnect() = 0; /** Test whether this service is connected. * * @return true if the service is connected, false otherwise */ virtual bool isConnected() const = 0; /** Do nothing but ensure the server do not disconnect (for * example, this can reset the auto-logout timer on the * server, if one exists). */ virtual void noop() = 0; /** Return the authenticator object used with this service instance. * * @return authenticator object */ ref getAuthenticator() const; /** Return the authenticator object used with this service instance. * * @return authenticator object */ ref getAuthenticator(); /** Set the authenticator object used with this service instance. * * @param auth authenticator object */ void setAuthenticator(ref auth); #if VMIME_HAVE_TLS_SUPPORT /** Set the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ void setCertificateVerifier(ref cv); /** Get the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ ref getCertificateVerifier(); #endif // VMIME_HAVE_TLS_SUPPORT /** Set the factory used to create socket objects for this * service. * * @param sf socket factory */ void setSocketFactory(ref sf); /** Return the factory used to create socket objects for this * service. * * @return socket factory */ ref getSocketFactory(); /** Set the factory used to create timeoutHandler objects for * this service. By default, no timeout handler is used. Not all * services support timeout handling. * * @param thf timeoutHandler factory */ void setTimeoutHandlerFactory(ref thf); /** Return the factory used to create timeoutHandler objects for * this service. * * @return timeoutHandler factory */ ref getTimeoutHandlerFactory(); /** Set a property for this service (service prefix is added automatically). * * WARNING: this sets the property on the session object, so all service * instances created with the session object will inherit the property. * * @param name property name * @param value property value */ template void setProperty(const string& name, const TYPE& value) { m_session->getProperties()[getInfos().getPropertyPrefix() + name] = value; } /** Check whether the connection is secured. * * @return true if the connection is secured, false otherwise */ virtual bool isSecuredConnection() const = 0; /** Get information about the connection. * * @return information about the connection */ virtual ref getConnectionInfos() const = 0; private: ref m_session; ref m_auth; #if VMIME_HAVE_TLS_SUPPORT ref m_certVerifier; #endif // VMIME_HAVE_TLS_SUPPORT ref m_socketFactory; ref m_toHandlerFactory; }; } // net } // vmime #endif // VMIME_NET_SERVICE_HPP_INCLUDED libvmime-0.9.1/vmime/net/store.hpp0000644000175000017500000000643211250723264017406 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_STORE_HPP_INCLUDED #define VMIME_NET_STORE_HPP_INCLUDED #include "vmime/net/service.hpp" #include "vmime/net/folder.hpp" namespace vmime { namespace net { /** A store service. * Encapsulate protocols that provide access to user's mail drop. */ class store : public service { protected: store(ref sess, const serviceInfos& infos, ref auth) : service(sess, infos, auth) { } public: /** Return the default folder. This is protocol dependent * and usually is the INBOX folder. * * @return default folder */ virtual ref getDefaultFolder() = 0; /** Return the root folder. This is protocol dependent * and usually is the user's mail drop root folder. * * @return root folder */ virtual ref getRootFolder() = 0; /** Return the folder specified by the path. * * @param path absolute folder path * @return folder at the specified path */ virtual ref getFolder(const folder::path& path) = 0; /** Test whether the specified folder name is a syntactically * a valid name. * * @return true if the specified folder name is valid, false otherwise */ virtual bool isValidFolderName(const folder::path::component& name) const = 0; /** Store capabilities. */ enum Capabilities { CAPABILITY_CREATE_FOLDER = (1 << 0), /**< Can create folders. */ CAPABILITY_RENAME_FOLDER = (1 << 1), /**< Can rename folders. */ CAPABILITY_ADD_MESSAGE = (1 << 2), /**< Can append message to folders. */ CAPABILITY_COPY_MESSAGE = (1 << 3), /**< Can copy messages from a folder to another one. */ CAPABILITY_DELETE_MESSAGE = (1 << 4), /**< Can delete messages. */ CAPABILITY_PARTIAL_FETCH = (1 << 5), /**< Is partial fetch supported? */ CAPABILITY_MESSAGE_FLAGS = (1 << 6), /**< Can set flags on messages. */ CAPABILITY_EXTRACT_PART = (1 << 7) /**< Can extract a specific part of the message. */ }; /** Return the features supported by this service. This is * a combination of store::CAPABILITY_xxx flags. * * @return features supported by this service */ virtual int getCapabilities() const = 0; Type getType() const { return (TYPE_STORE); } }; } // net } // vmime #endif // VMIME_NET_STORE_HPP_INCLUDED libvmime-0.9.1/vmime/net/serviceInfos.hpp0000644000175000017500000001472511250723264020715 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_SERVICEINFOS_HPP_INCLUDED #define VMIME_NET_SERVICEINFOS_HPP_INCLUDED #include #include "vmime/types.hpp" #include "vmime/net/session.hpp" namespace vmime { namespace net { /** Stores information about a messaging service. */ class serviceInfos { friend class serviceFactory; protected: serviceInfos(); serviceInfos(const serviceInfos&); private: serviceInfos& operator=(const serviceInfos&); public: virtual ~serviceInfos(); /** A service property. */ class property { public: /** The common property 'server.address' which is * the host name or the IP address of the server. */ static const property SERVER_ADDRESS; /** The common property 'server.port' which is * the port used to connect to the server. */ static const property SERVER_PORT; /** The common property 'server.rootpath' which is * the full path of the folder on the server (for * maildir, this is the local filesystem directory). */ static const property SERVER_ROOTPATH; /** The common property 'auth.username' which is the * username used to authenticate with the server. */ static const property AUTH_USERNAME; /** The common property 'auth.password' which is the * password used to authenticate with the server. */ static const property AUTH_PASSWORD; #if VMIME_HAVE_TLS_SUPPORT /** The common property 'connection.tls': this is used to * start a secured connection if it is supported by the * server (STARTTLS extension). */ static const property CONNECTION_TLS; /** The common property 'connection.tls.required' should be * set to 'true' to make the connection process fail if the * server can't start a secured connection (no effect if * 'connection.tls' is not set to 'true'). */ static const property CONNECTION_TLS_REQUIRED; #endif // VMIME_HAVE_TLS_SUPPORT /** Value types. */ enum Types { TYPE_INTEGER, /*< Integer number. */ TYPE_STRING, /*< Character string. */ TYPE_BOOL, /*< Boolean (true or false). */ TYPE_DEFAULT = TYPE_STRING }; /** Property flags. */ enum Flags { FLAG_NONE = 0, /*< No flags. */ FLAG_REQUIRED = (1 << 0), /*< The property must be valued. */ FLAG_HIDDEN = (1 << 1), /*< The property should not be shown to the user but can be modified. */ FLAG_DEFAULT = FLAG_NONE /*< Default flags. */ }; /** Construct a new property. * * @param name property name * @param type value type * @param defaultValue default value * @param flags property attributes */ property(const string& name, const Types type, const string& defaultValue = "", const int flags = FLAG_DEFAULT); /** Construct a new property from an existing property. * * @param p source property * @param addFlags flags to add * @param removeFlags flags to remove */ property(const property& p, const int addFlags = FLAG_NONE, const int removeFlags = FLAG_NONE); /** Construct a new property from an existing property. * * @param p source property * @param newDefaultValue new default value * @param addFlags flags to add * @param removeFlags flags to remove */ property(const property& p, const string& newDefaultValue, const int addFlags = FLAG_NONE, const int removeFlags = FLAG_NONE); property& operator=(const property& p); /** Return the name of the property. * * @return property name */ const string& getName() const; /** Return the default value of the property or * an empty string if there is no default value. * * @return default value for the property */ const string& getDefaultValue() const; /** Return the value type of the property. * * @return property value type */ Types getType() const; /** Return the attributes of the property (see * serviceInfos::property::Types constants). * * @return property attributes */ int getFlags() const; private: string m_name; string m_defaultValue; Types m_type; int m_flags; }; /** Return the property prefix used by this service. * Use this to set/get properties in the session object. * * @return property prefix */ virtual const string getPropertyPrefix() const = 0; /** Return a list of available properties for this service. * * @return list of properties */ virtual const std::vector getAvailableProperties() const = 0; /** Helper function to retrieve the value of a property. * * @param s session object * @param p property to retrieve * @throw exceptions::no_such_property if the property does not exist * and has the flag property::FLAG_REQUIRED * @return value of the property */ template const TYPE getPropertyValue(ref s, const property& p) const { if (p.getFlags() & property::FLAG_REQUIRED) return s->getProperties()[getPropertyPrefix() + p.getName()].template getValue (); return s->getProperties().template getProperty (getPropertyPrefix() + p.getName(), propertySet::valueFromString (p.getDefaultValue())); } /** Helper function to test if the specified property is set in * the session object. * * @param s session object * @param p property to test * @return true if the property is set, false otherwise */ bool hasProperty(ref s, const property& p) const; }; } // net } // vmime #endif // VMIME_NET_SERVICEINFOS_HPP_INCLUDED libvmime-0.9.1/vmime/net/events.hpp0000644000175000017500000001155011250723264017553 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_NET_EVENTS_HPP_INCLUDED #define VMIME_NET_EVENTS_HPP_INCLUDED #include #include "vmime/utility/path.hpp" namespace vmime { namespace net { class folder; namespace events { /** Event about the message count in a folder. */ class messageCountEvent { public: enum Types { TYPE_ADDED, /**< New messages have been added. */ TYPE_REMOVED /**< Messages have been expunged (renumbering). */ }; messageCountEvent(ref folder, const Types type, const std::vector & nums); /** Return the folder in which messages have been added/removed. * * @return folder in which message count changed */ ref getFolder() const; /** Return the event type. * * @return event type (see messageCountEvent::Types) */ Types getType() const; /** Return the numbers of the messages that have been added/removed. * * @return a list of message numbers */ const std::vector & getNumbers() const; /** Dispatch the event to the specified listener. * * @param listener listener to notify */ void dispatch(class messageCountListener* listener) const; private: ref m_folder; const Types m_type; std::vector m_nums; }; /** Listener for events about the message count in a folder. */ class messageCountListener { protected: virtual ~messageCountListener() { } public: virtual void messagesAdded(const messageCountEvent& event) = 0; virtual void messagesRemoved(const messageCountEvent& event) = 0; }; /** Event occuring on a message. */ class messageChangedEvent { public: enum Types { TYPE_FLAGS // flags changed }; messageChangedEvent(ref folder, const Types type, const std::vector & nums); /** Return the folder in which messages have changed. * * @return folder in which message count changed */ ref getFolder() const; /** Return the event type. * * @return event type (see messageChangedEvent::Types) */ Types getType() const; /** Return the numbers of the messages that have changed. * * @return a list of message numbers */ const std::vector & getNumbers() const; /** Dispatch the event to the specified listener. * * @param listener listener to notify */ void dispatch(class messageChangedListener* listener) const; private: ref m_folder; const Types m_type; std::vector m_nums; }; /** Listener for events occuring on a message. */ class messageChangedListener { protected: virtual ~messageChangedListener() { } public: virtual void messageChanged(const messageChangedEvent& event) = 0; }; /** Event occuring on a folder. */ class folderEvent { public: enum Types { TYPE_CREATED, /**< A folder was created. */ TYPE_DELETED, /**< A folder was deleted. */ TYPE_RENAMED /**< A folder was renamed. */ }; folderEvent(ref folder, const Types type, const utility::path& oldPath, const utility::path& newPath); /** Return the folder on which the event occured. * * @return folder on which the event occured */ ref getFolder() const; /** Return the event type. * * @return event type (see folderEvent::Types) */ Types getType() const; /** Dispatch the event to the specified listener. * * @param listener listener to notify */ void dispatch(class folderListener* listener) const; private: ref m_folder; const Types m_type; const utility::path m_oldPath; const utility::path m_newPath; }; /** Listener for events occuring on a folder. */ class folderListener { protected: virtual ~folderListener() { } public: virtual void folderCreated(const folderEvent& event) = 0; virtual void folderRenamed(const folderEvent& event) = 0; virtual void folderDeleted(const folderEvent& event) = 0; }; } // events } // net } // vmime #endif // VMIME_NET_EVENTS_HPP_INCLUDED libvmime-0.9.1/vmime/misc/0000755000175000017500000000000011607302336015700 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/misc/importanceHelper.hpp0000644000175000017500000000615511250723263021721 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MISC_IMPORTANCEHELPER_HPP_INCLUDED #define VMIME_MISC_IMPORTANCEHELPER_HPP_INCLUDED #include "vmime/message.hpp" namespace vmime { namespace misc { /** Deals with setting and retrieving message importance (also * known as priority). * * Basically, it wraps the use of the 'X-Priority' (non standard) * and 'Importance' (RFC-1327, RFC-1911) fields. */ class importanceHelper { public: /** Different levels of importance. */ enum Importance { IMPORTANCE_HIGHEST, IMPORTANCE_HIGH, IMPORTANCE_NORMAL, IMPORTANCE_LOW, IMPORTANCE_LOWEST }; /** Reset the importance of the message to the default importance. * * @param msg message on which to reset importance */ static void resetImportance(ref msg); /** Reset the importance of a message to the default importance. * * @param hdr message header on which to reset importance */ static void resetImportanceHeader(ref
hdr); /** Return the importance of the specified message. * * @param msg message from which to retrieve importance * @return importance of the message, or default importance is no * information about importance is given in the message */ static Importance getImportance(ref msg); /** Return the importance of a message, given its header. * * @param hdr message header from which to retrieve importance * @return importance of the message, or default importance is no * information about importance is given in the message */ static Importance getImportanceHeader(ref hdr); /** Set the importance of the specified message. * * @param msg message on which to set importance * @param i new message importance */ static void setImportance(ref msg, const Importance i); /** Set the importance of a message, given its header. * * @param hdr message header on which to set importance * @param i new message importance */ static void setImportanceHeader(ref
hdr, const Importance i); }; } // misc } // vmime #endif // VMIME_MISC_IMPORTANCEHELPER_HPP_INCLUDED libvmime-0.9.1/vmime/messageIdSequence.hpp0000644000175000017500000001152611250723264021056 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MESSAGEIDSEQUENCE_HPP_INCLUDED #define VMIME_MESSAGEIDSEQUENCE_HPP_INCLUDED #include "vmime/messageId.hpp" namespace vmime { /** A list of message identifiers (basic type). */ class messageIdSequence : public headerFieldValue { public: messageIdSequence(); messageIdSequence(const messageIdSequence& midSeq); ~messageIdSequence(); ref clone() const; void copyFrom(const component& other); messageIdSequence& operator=(const messageIdSequence& other); const std::vector > getChildComponents() const; /** Add a message-id at the end of the list. * * @param mid message-id to append */ void appendMessageId(ref mid); /** Insert a new message-id before the specified message-id. * * @param beforeMid message-id before which the new message-id will be inserted * @param mid message-id to insert * @throw exceptions::no_such_messageid if the message-id is not in the list */ void insertMessageIdBefore(ref beforeMid, ref mid); /** Insert a new message-id before the specified position. * * @param pos position at which to insert the new message-id (0 to insert at * the beginning of the list) * @param mid message-id to insert */ void insertMessageIdBefore(const int pos, ref mid); /** Insert a new message-id after the specified message-id. * * @param afterMid message-id after which the new message-id will be inserted * @param mid message-id to insert * @throw exceptions::no_such_message_id if the message-id is not in the list */ void insertMessageIdAfter(ref afterMid, ref mid); /** Insert a new message-id after the specified position. * * @param pos position of the message-id before the new message-id * @param mid message-id to insert */ void insertMessageIdAfter(const int pos, ref mid); /** Remove the specified message-id from the list. * * @param mid message-id to remove * @throw exceptions::no_such_message_id if the message-id is not in the list */ void removeMessageId(ref mid); /** Remove the message-id at the specified position. * * @param pos position of the message-id to remove */ void removeMessageId(const int pos); /** Remove all message-ids from the list. */ void removeAllMessageIds(); /** Return the number of message-ides in the list. * * @return number of message-ides */ int getMessageIdCount() const; /** Tests whether the list of message-ides is empty. * * @return true if there is no message-id, false otherwise */ bool isEmpty() const; /** Return the message-id at the specified position. * * @param pos position * @return message-id at position 'pos' */ const ref getMessageIdAt(const int pos); /** Return the message-id at the specified position. * * @param pos position * @return message-id at position 'pos' */ const ref getMessageIdAt(const int pos) const; /** Return the message-id list. * * @return list of message-ids */ const std::vector > getMessageIdList() const; /** Return the message-id list. * * @return list of message-ids */ const std::vector > getMessageIdList(); private: std::vector > m_list; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_MESSAGEIDSEQUENCE_HPP_INCLUDED libvmime-0.9.1/vmime/wordEncoder.hpp0000644000175000017500000000520211375174021017730 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_WORDENCODER_HPP_INCLUDED #define VMIME_WORDENCODER_HPP_INCLUDED #include "vmime/charset.hpp" namespace vmime { namespace utility { namespace encoder { class encoder; } // encoder } // utility /** Encodes words following RFC-2047. */ class wordEncoder { public: /** Available encodings for RFC-2047. */ enum Encoding { ENCODING_AUTO, ENCODING_QP, ENCODING_B64 }; wordEncoder(const string& buffer, const charset& charset, const Encoding encoding = ENCODING_AUTO); /** Return the next chunk in the word. * * @param maxLength maximal length of the chunk * @return next chunk, of maximal length 'maxLength' if possible */ const string getNextChunk(const string::size_type maxLength); /** Return the encoding used. * * @return encoding */ Encoding getEncoding() const; /** Test whether RFC-2047 encoding is needed. * * @param buffer buffer to analyze * @param charset charset of the buffer * @return true if encoding is needed, false otherwise. */ static bool isEncodingNeeded(const string& buffer, const charset& charset); /** Guess the best RFC-2047 encoding to use for the specified buffer. * * @param buffer buffer to analyze * @param charset charset of the buffer * @return RFC-2047 encoding */ static Encoding guessBestEncoding(const string& buffer, const charset& charset); private: string m_buffer; string::size_type m_pos; string::size_type m_length; bool m_simple; charset m_charset; Encoding m_encoding; ref m_encoder; }; } // vmime #endif // VMIME_WORDENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/messageParser.hpp0000644000175000017500000000760511250723264020270 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MESSAGEPARSER_HPP_INCLUDED #define VMIME_MESSAGEPARSER_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/message.hpp" #include "vmime/attachment.hpp" #include "vmime/mailbox.hpp" #include "vmime/addressList.hpp" #include "vmime/dateTime.hpp" #include "vmime/textPart.hpp" namespace vmime { /** A helper for parsing MIME messages. */ class messageParser { public: messageParser(const string& buffer); messageParser(ref msg); ~messageParser(); public: /** Return the expeditor of the message (From:). * * @return expeditor of the message */ const mailbox& getExpeditor() const; /** Return the recipients of the message (To:). * * return recipients of the message */ const addressList& getRecipients() const; /** Return the copy recipients of the message (Cc:). * * @return copy recipients of the message */ const addressList& getCopyRecipients() const; /** Return the blind-copy recipients of the message (Bcc:). * * @return blind-copy recipients of the message */ const addressList& getBlindCopyRecipients() const; /** Return the subject of the message. * * @return subject of the message */ const text& getSubject() const; /** Return the date of the message. * * @return date of the message */ const datetime& getDate() const; /** Return the number of attachments in the message. * * @return number of attachments */ int getAttachmentCount() const; /** Return the attachment at the specified position. * * @param pos position of the attachment * @return attachment at position 'pos' */ const ref getAttachmentAt(const int pos) const; /** Return the attachments of the message. * * @return list of attachments in the message */ const std::vector > getAttachmentList() const; /** Return the text parts of the message. * * @return list of text parts in the message */ const std::vector > getTextPartList() const; /** Return the number of text parts in the message. * * @return number of text parts */ int getTextPartCount() const; /** Return the text part at the specified position. * * @param pos position of the text part * @return text part at position 'pos' */ const ref getTextPartAt(const int pos) const; private: mailbox m_from; addressList m_to; addressList m_cc; addressList m_bcc; text m_subject; datetime m_date; std::vector > m_attach; std::vector > m_textParts; void parse(ref msg); void findAttachments(ref msg); void findTextParts(ref msg, ref part); bool findSubTextParts(ref msg, ref part); }; } // vmime #endif // VMIME_MESSAGEPARSER_HPP_INCLUDED libvmime-0.9.1/vmime/contentHandler.hpp0000644000175000017500000001016511376250103020426 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_CONTENTHANDLER_HPP_INCLUDED #define VMIME_CONTENTHANDLER_HPP_INCLUDED #include #include "vmime/base.hpp" #include "vmime/utility/stringProxy.hpp" #include "vmime/utility/smartPtr.hpp" #include "vmime/utility/progressListener.hpp" #include "vmime/encoding.hpp" namespace vmime { class contentHandler : public object { public: /** Used to specify that enclosed data is not encoded. */ static const vmime::encoding NO_ENCODING; virtual ~contentHandler(); /** Return a copy of this object. * * @return copy of this object */ virtual ref clone() const = 0; /** Output the contents into the specified stream. Data will be * encoded before being written into the stream. This is used internally * by the body object to generate the message, you may not need to use * this (see contentHandler::extract() if you want to get the contents). * * @param os output stream * @param enc encoding for output * @param maxLineLength maximum line length for output */ virtual void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const = 0; /** Extract the contents into the specified stream. If needed, data * will be decoded before being written into the stream. * * @throw exceptions::no_encoder_available if the encoding is * not supported * @param os output stream * @param progress progress listener, or NULL if you do not * want to receive progress notifications */ virtual void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const = 0; /** Extract the contents into the specified stream, without * decoding it. It may be useful in case the encoding is not * supported and you want to extract raw data. * * @param os output stream * @param progress progress listener, or NULL if you do not * want to receive progress notifications */ virtual void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const = 0; /** Returns the actual length of data. WARNING: this can return 0 if no * length was specified when setting data of this object, or if the * length is not known). * * @return length of data */ virtual string::size_type getLength() const = 0; /** Returns 'true' if data managed by this object is encoded. * * @return true if data is encoded, false otherwise */ virtual bool isEncoded() const = 0; /** Returns the encoding used for data (or "binary" if not encoded). * * @return encoding used for data */ virtual const vmime::encoding& getEncoding() const = 0; /** Returns 'true' if there is no data set. * * @return true if no data is managed by this object, false otherwise */ virtual bool isEmpty() const = 0; /** Indicates whether the extract() method can be called multiple times. * * @return true if the data can be extracted multiple times, or false * if not (ie. streamed data from socket) */ virtual bool isBuffered() const = 0; }; } // vmime #endif // VMIME_CONTENTHANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/plainTextPart.hpp0000644000175000017500000000347511250723264020267 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLAINTEXTPART_HPP_INCLUDED #define VMIME_PLAINTEXTPART_HPP_INCLUDED #include "vmime/textPart.hpp" namespace vmime { /** Text part of type 'text/plain'. */ class plainTextPart : public textPart { public: plainTextPart(); ~plainTextPart(); const mediaType getType() const; const charset& getCharset() const; void setCharset(const charset& ch); const ref getText() const; void setText(ref text); int getPartCount() const; void generateIn(ref message, ref parent) const; void parse(ref message, ref parent, ref textPart); private: ref m_text; charset m_charset; }; } // vmime #endif // VMIME_PLAINTEXTPART_HPP_INCLUDED libvmime-0.9.1/vmime/mailboxGroup.hpp0000644000175000017500000001170011250723264020126 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MAILBOXGROUP_HPP_INCLUDED #define VMIME_MAILBOXGROUP_HPP_INCLUDED #include "vmime/address.hpp" #include "vmime/mailbox.hpp" #include "vmime/text.hpp" namespace vmime { /** A group of mailboxes (basic type). */ class mailboxGroup : public address { public: mailboxGroup(); mailboxGroup(const mailboxGroup& mboxGroup); mailboxGroup(const text& name); ~mailboxGroup(); void copyFrom(const component& other); ref clone() const; mailboxGroup& operator=(const component& other); const std::vector > getChildComponents() const; /** Return the name of the group. * * @return group name */ const text& getName() const; /** Set the name of the group. * * @param name group name */ void setName(const text& name); /** Add a mailbox at the end of the list. * * @param mbox mailbox to append */ void appendMailbox(ref mbox); /** Insert a new mailbox before the specified mailbox. * * @param beforeMailbox mailbox before which the new mailbox will be inserted * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ void insertMailboxBefore(ref beforeMailbox, ref mbox); /** Insert a new mailbox before the specified position. * * @param pos position at which to insert the new mailbox (0 to insert at * the beginning of the list) * @param mbox mailbox to insert */ void insertMailboxBefore(const int pos, ref mbox); /** Insert a new mailbox after the specified mailbox. * * @param afterMailbox mailbox after which the new mailbox will be inserted * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ void insertMailboxAfter(ref afterMailbox, ref mbox); /** Insert a new mailbox after the specified position. * * @param pos position of the mailbox before the new mailbox * @param mbox mailbox to insert */ void insertMailboxAfter(const int pos, ref mbox); /** Remove the specified mailbox from the list. * * @param mbox mailbox to remove * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ void removeMailbox(ref mbox); /** Remove the mailbox at the specified position. * * @param pos position of the mailbox to remove */ void removeMailbox(const int pos); /** Remove all mailboxes from the list. */ void removeAllMailboxes(); /** Return the number of mailboxes in the list. * * @return number of mailboxes */ int getMailboxCount() const; /** Tests whether the list of mailboxes is empty. * * @return true if there is no mailbox, false otherwise */ bool isEmpty() const; /** Return the mailbox at the specified position. * * @param pos position * @return mailbox at position 'pos' */ ref getMailboxAt(const int pos); /** Return the mailbox at the specified position. * * @param pos position * @return mailbox at position 'pos' */ const ref getMailboxAt(const int pos) const; /** Return the mailbox list. * * @return list of mailboxes */ const std::vector > getMailboxList() const; /** Return the mailbox list. * * @return list of mailboxes */ const std::vector > getMailboxList(); bool isGroup() const; private: text m_name; std::vector > m_list; public: using address::parse; using address::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_MAILBOXGROUP_HPP_INCLUDED libvmime-0.9.1/vmime/options.hpp0000644000175000017500000000414511250723264017156 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_OPTIONS_HPP_INCLUDED #define VMIME_OPTIONS_HPP_INCLUDED #include "vmime/base.hpp" namespace vmime { /** A class to set global options for VMime. */ class options { protected: /** Message-related options. */ class messageOptions { protected: friend class options; messageOptions() : m_maxLineLength(lineLengthLimits::convenient) { } string::size_type m_maxLineLength; public: const string::size_type& maxLineLength() const { return (m_maxLineLength); } string::size_type& maxLineLength() { return (m_maxLineLength); } }; /** Multipart-related options. */ class multipartOptions { private: friend class options; multipartOptions(); string m_prologText; string m_epilogText; public: const string& getPrologText() const; void setPrologText(const string& prologText); const string& getEpilogText() const; void setEpilogText(const string& epilogText); }; public: static options* getInstance(); multipartOptions multipart; messageOptions message; }; } // vmime #endif // VMIME_OPTIONS_HPP_INCLUDED libvmime-0.9.1/vmime/headerFieldFactory.hpp0000644000175000017500000000641511250723264021211 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_HEADERFIELDFACTORY_HPP_INCLUDED #define VMIME_HEADERFIELDFACTORY_HPP_INCLUDED #include "vmime/headerField.hpp" #include "vmime/utility/stringUtils.hpp" namespace vmime { /** Creates header field and header field value objects. */ class headerFieldFactory { protected: headerFieldFactory(); ~headerFieldFactory(); typedef ref (*AllocFunc)(void); typedef std::map NameMap; NameMap m_nameMap; typedef ref (*ValueAllocFunc)(void); typedef std::map ValueMap; ValueMap m_valueMap; public: static headerFieldFactory* getInstance(); #ifndef VMIME_BUILDING_DOC // TYPE must inherit from BASE_TYPE template class registerer { public: static ref creator() { // Allocate a new object return vmime::create (); } }; #endif // VMIME_BUILDING_DOC /** Register a field type. * * @param T field class (must inherit from 'headerField') * @param name field name (eg. "X-MyField") */ template void registerField(const string& name) { m_nameMap.insert(NameMap::value_type (utility::stringUtils::toLower(name), ®isterer ::creator)); } /** Register a field value type. * * @param T value class (must inherit from 'headerFieldValue') * @param name field name */ template void registerFieldValue(const string& name) { m_valueMap.insert(ValueMap::value_type (utility::stringUtils::toLower(name), ®isterer ::creator)); } /** Create a new field object for the specified field name. * If the field name has not been registered, a default type * is used. * * @param name field name * @param body string that will be parsed to initialize * the value of the field * @return a new field object */ ref create(const string& name, const string& body = NULL_STRING); /** Create a new field value for the specified field. * * @param fieldName name of the field for which to create value * @return a new value object for the field */ ref createValue(const string& fieldName); }; } // vmime #endif // VMIME_HEADERFIELDFACTORY_HPP_INCLUDED libvmime-0.9.1/vmime/charsetConverter.hpp0000644000175000017500000000754411250723264021012 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_CHARSETCONVERTER_HPP_INCLUDED #define VMIME_CHARSETCONVERTER_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" #include "vmime/charset.hpp" #include "vmime/utility/filteredStream.hpp" namespace vmime { /** Convert between charsets. */ class charsetConverter : public object { public: /** Construct and initialize a charset converter. * * @param source input charset * @param dest output charset */ charsetConverter(const charset& source, const charset& dest); ~charsetConverter(); /** Convert a string buffer from one charset to another * charset (in-memory conversion) * * \deprecated Use the new convert() method, which takes * an outputStream parameter. * * @param in input buffer * @param out output buffer * @throws exceptions::charset_conv_error if an error occured during * the conversion */ void convert(const string& in, string& out); /** Convert the contents of an input stream in a specified charset * to another charset and write the result to an output stream. * * @param in input stream to read data from * @param out output stream to write the converted data * @throws exceptions::charset_conv_error if an error occured during * the conversion */ void convert(utility::inputStream& in, utility::outputStream& out); private: void* m_desc; charset m_source; charset m_dest; }; namespace utility { /** A filtered output stream which applies a charset conversion * to input bytes. * * May throw a exceptions::charset_conv_error if an error * occured when initializing convert, or during charset conversion. */ class charsetFilteredOutputStream : public filteredOutputStream { public: /** Construct a new filter for the specified output stream. * * @param source input charset * @param dest output charset * @param os stream into which write filtered data */ charsetFilteredOutputStream (const charset& source, const charset& dest, outputStream& os); ~charsetFilteredOutputStream(); outputStream& getNextOutputStream(); void write(const value_type* const data, const size_type count); void flush(); private: // Maximum character width in any charset enum { MAX_CHARACTER_WIDTH = 128 }; void* m_desc; const charset m_sourceCharset; const charset m_destCharset; outputStream& m_stream; // Buffer in which unconverted bytes are left until they can // be converted (when more data arrives). The length should be // large enough to contain any character in any charset. value_type m_unconvBuffer[MAX_CHARACTER_WIDTH]; size_type m_unconvCount; // Buffer used for conversion. Avoids declaring it in write(). // Should be at least MAX_CHARACTER_WIDTH * MAX_CHARACTER_WIDTH. value_type m_outputBuffer[32768]; }; } // utility } // vmime #endif // VMIME_CHARSETCONVERTER_HPP_INCLUDED libvmime-0.9.1/vmime/parsedMessageAttachment.hpp0000644000175000017500000000372111250723264022256 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PARSEDMESSAGEATTACHMENT_HPP_INCLUDED #define VMIME_PARSEDMESSAGEATTACHMENT_HPP_INCLUDED #ifndef VMIME_BUILDING_DOC // implementation detail #include "vmime/messageAttachment.hpp" namespace vmime { /** A message attachment that can be generated into a message. */ class parsedMessageAttachment : public messageAttachment { public: parsedMessageAttachment(ref msg); const mediaType getType() const; const text getDescription() const; const word getName() const; const ref getData() const; const encoding getEncoding() const; ref getPart() const; ref getHeader() const; ref getMessage() const; protected: void generateIn(ref parent) const; private: ref m_msg; mutable ref m_data; }; } // vmime #endif // !VMIME_BUILDING_DOC #endif // VMIME_PARSEDMESSAGEATTACHMENT_HPP_INCLUDED libvmime-0.9.1/vmime/contentTypeField.hpp0000644000175000017500000000575511250723264020753 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_CONTENTTYPEFIELD_HPP_INCLUDED #define VMIME_CONTENTTYPEFIELD_HPP_INCLUDED #include "vmime/parameterizedHeaderField.hpp" #include "vmime/mediaType.hpp" #include "vmime/charset.hpp" namespace vmime { class contentTypeField : public parameterizedHeaderField { friend class vmime::creator; // create ref protected: contentTypeField(); contentTypeField(contentTypeField&); public: /** Return the value of the "boundary" parameter. Boundary is a * random string used to separate body parts. * * @return value of the "boundary" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const string getBoundary() const; /** Set the value of the "boundary" parameter. Boundary is a * random string used to separate body parts. Normally, the * boundary is generated automatically by VMime, you should * not need to call this. * * @param boundary new value for the "boundary" parameter */ void setBoundary(const string& boundary); /** Return the value of the "charset" parameter. It specifies the * charset used in the body part contents. * * @return value of the "charset" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const charset getCharset() const; /** Set the value of the "charset" parameter. It specifies the * charset used in the body part contents. * * @param ch new value for the "charset" parameter */ void setCharset(const charset& ch); /** Return the value of the "report-type" parameter (RFC-1892). * * @return value of the "report-type" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const string getReportType() const; /** Set the value of the "report-type" parameter (RFC-1892). * * @param reportType new value for the "report-type" parameter */ void setReportType(const string& reportType); }; } // vmime #endif // VMIME_CONTENTTYPEFIELD_HPP_INCLUDED libvmime-0.9.1/vmime/platform.hpp0000644000175000017500000001010111314151075017270 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORM_HPP_INCLUDED #define VMIME_PLATFORM_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/dateTime.hpp" #include "vmime/exception.hpp" #include "vmime/charset.hpp" #if VMIME_HAVE_MESSAGING_FEATURES #include "vmime/net/socket.hpp" #include "vmime/net/timeoutHandler.hpp" #endif #if VMIME_HAVE_FILESYSTEM_FEATURES #include "vmime/utility/file.hpp" #include "vmime/utility/childProcess.hpp" #endif namespace vmime { /** Allow setting or getting the current platform handler. */ class platform { public: /** Handles all platform-dependent operations. It offers an interface to * access platform-dependent objects: sockets, date/time, file system, etc. */ class handler : public object { public: virtual ~handler(); /** Return the current UNIX time (Epoch time): the number of * seconds elapsed since Jan, 1st 1970 00:00. * * @return UNIX Epoch time */ virtual unsigned int getUnixTime() const = 0; /** Return the current date and time, in the local time zone. * * @return current date and time */ virtual const datetime getCurrentLocalTime() const = 0; /** Return the host name of the system. * Used when generating message ids. * * @return host name */ virtual const string getHostName() const = 0; /** Return the current process identifier. * Used when generating random strings (part boundaries or message ids). * * @return current process id */ virtual unsigned int getProcessId() const = 0; /** Return the charset used on the system. * * @return locale charset */ virtual const charset getLocaleCharset() const = 0; /** This function is called when VMime library is waiting for * something (for example, it is called when there is no data * available in a socket). On POSIX-compliant systems, a * simple call to sched_yield() should suffice. */ virtual void wait() const = 0; #if VMIME_HAVE_MESSAGING_FEATURES /** Return a pointer to the default socket factory for * this platform. * * @return socket factory */ virtual ref getSocketFactory() = 0; #endif #if VMIME_HAVE_FILESYSTEM_FEATURES /** Return a pointer to a factory that creates file-system objects. * * @return file-system factory */ virtual ref getFileSystemFactory() = 0; /** Return a pointer to a factory that creates child process objects, * which are used to spawn processes (run executable files). * * @return child process factory */ virtual ref getChildProcessFactory() = 0; #endif }; template static void setHandler() { sm_handler = vmime::create (); } static ref getHandler() { if (!sm_handler) throw exceptions::no_platform_handler(); return (sm_handler); } private: static ref sm_handler; }; /** Compatibility with older versions of VMime (before 0.8.1). */ typedef platform platformDependant; } // vmime #endif // VMIME_PLATFORM_HPP_INCLUDED libvmime-0.9.1/vmime/message.hpp0000644000175000017500000000341011250723264017101 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MESSAGE_HPP_INCLUDED #define VMIME_MESSAGE_HPP_INCLUDED #include "vmime/bodyPart.hpp" #include "vmime/options.hpp" namespace vmime { /** A MIME message. */ class message : public bodyPart { public: message(); // Component parsing & assembling void generate(utility::outputStream& os, const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(), const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; const string generate(const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(), const string::size_type curLinePos = 0) const; void parse(const string& buffer); }; } // vmime #endif // VMIME_MESSAGE_HPP_INCLUDED libvmime-0.9.1/vmime/platforms/0000755000175000017500000000000011607302336016754 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/platforms/posix/0000755000175000017500000000000011607302336020116 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/platforms/posix/posixChildProcess.hpp0000644000175000017500000000420211250723264024273 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORMS_POSIX_POSIXCHILDPROCESS_HPP_INCLUDED #define VMIME_PLATFORMS_POSIX_POSIXCHILDPROCESS_HPP_INCLUDED #include "vmime/utility/childProcess.hpp" #include #include namespace vmime { namespace platforms { namespace posix { class posixChildProcess : public utility::childProcess { public: posixChildProcess(const utility::file::path& path); ~posixChildProcess(); void start(const std::vector args, const int flags = 0); ref getStdIn(); ref getStdOut(); void waitForFinish(); private: utility::file::path m_processPath; bool m_started; ref m_stdIn; ref m_stdOut; sigset_t m_oldProcMask; pid_t m_pid; int m_pipe[2]; std::vector m_argVector; const char** m_argArray; }; class posixChildProcessFactory : public utility::childProcessFactory { public: ref create(const utility::file::path& path) const; }; } // posix } // platforms } // vmime #endif // VMIME_PLATFORMS_POSIX_POSIXCHILDPROCESS_HPP_INCLUDED libvmime-0.9.1/vmime/platforms/posix/posixHandler.hpp0000644000175000017500000000465611314151075023277 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORMS_POSIX_HANDLER_HPP_INCLUDED #define VMIME_PLATFORMS_POSIX_HANDLER_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/platform.hpp" #if VMIME_HAVE_MESSAGING_FEATURES #include "vmime/platforms/posix/posixSocket.hpp" #endif #if VMIME_HAVE_FILESYSTEM_FEATURES #include "vmime/platforms/posix/posixFile.hpp" #include "vmime/platforms/posix/posixChildProcess.hpp" #endif namespace vmime { namespace platforms { namespace posix { class posixHandler : public vmime::platform::handler { public: posixHandler(); ~posixHandler(); unsigned int getUnixTime() const; const vmime::datetime getCurrentLocalTime() const; const vmime::charset getLocaleCharset() const; const vmime::string getHostName() const; unsigned int getProcessId() const; #if VMIME_HAVE_MESSAGING_FEATURES ref getSocketFactory(); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES ref getFileSystemFactory(); ref getChildProcessFactory(); #endif void wait() const; private: #if VMIME_HAVE_MESSAGING_FEATURES ref m_socketFactory; #endif #if VMIME_HAVE_FILESYSTEM_FEATURES ref m_fileSysFactory; ref m_childProcFactory; #endif }; } // posix } // platforms } // vmime #endif // VMIME_PLATFORMS_POSIX_HANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/platforms/posix/posixFile.hpp0000644000175000017500000001134311250723264022574 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORMS_POSIX_FILE_HPP_INCLUDED #define VMIME_PLATFORMS_POSIX_FILE_HPP_INCLUDED #include "vmime/utility/file.hpp" #if VMIME_HAVE_FILESYSTEM_FEATURES #include namespace vmime { namespace platforms { namespace posix { class posixFileWriterOutputStream : public vmime::utility::outputStream { public: posixFileWriterOutputStream(const vmime::utility::file::path& path, const int fd); ~posixFileWriterOutputStream(); void write(const value_type* const data, const size_type count); void flush(); private: const vmime::utility::file::path m_path; const int m_fd; }; class posixFileReaderInputStream : public vmime::utility::inputStream { public: posixFileReaderInputStream(const vmime::utility::file::path& path, const int fd); ~posixFileReaderInputStream(); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: const vmime::utility::file::path m_path; const int m_fd; bool m_eof; }; class posixFileWriter : public vmime::utility::fileWriter { public: posixFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath); ref getOutputStream(); private: vmime::utility::file::path m_path; vmime::string m_nativePath; }; class posixFileReader : public vmime::utility::fileReader { public: posixFileReader(const vmime::utility::file::path& path, const vmime::string& nativePath); ref getInputStream(); private: vmime::utility::file::path m_path; vmime::string m_nativePath; }; class posixFileIterator : public vmime::utility::fileIterator { public: posixFileIterator(const vmime::utility::file::path& path, const vmime::string& nativePath); ~posixFileIterator(); bool hasMoreElements() const; ref nextElement(); private: void getNextElement(); vmime::utility::file::path m_path; vmime::string m_nativePath; DIR* m_dir; struct dirent* m_dirEntry; }; class posixFile : public vmime::utility::file { public: posixFile(const vmime::utility::file::path& path); void createFile(); void createDirectory(const bool createAll = false); bool isFile() const; bool isDirectory() const; bool canRead() const; bool canWrite() const; length_type getLength(); const path& getFullPath() const; bool exists() const; ref getParent() const; void rename(const path& newName); void remove(); ref getFileWriter(); ref getFileReader(); ref getFiles() const; private: static void createDirectoryImpl(const vmime::utility::file::path& fullPath, const vmime::utility::file::path& path, const bool recursive = false); private: vmime::utility::file::path m_path; vmime::string m_nativePath; }; class posixFileSystemFactory : public vmime::utility::fileSystemFactory { public: ref create(const vmime::utility::file::path& path) const; const vmime::utility::file::path stringToPath(const vmime::string& str) const; const vmime::string pathToString(const vmime::utility::file::path& path) const; static const vmime::utility::file::path stringToPathImpl(const vmime::string& str); static const vmime::string pathToStringImpl(const vmime::utility::file::path& path); bool isValidPathComponent(const vmime::utility::file::path::component& comp) const; bool isValidPath(const vmime::utility::file::path& path) const; static void reportError(const vmime::utility::path& path, const int err); }; } // posix } // platforms } // vmime #endif // VMIME_HAVE_FILESYSTEM_FEATURES #endif // VMIME_PLATFORMS_POSIX_FILE_HPP_INCLUDED libvmime-0.9.1/vmime/platforms/posix/posixSocket.hpp0000644000175000017500000000431211421613423023136 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORMS_POSIX_SOCKET_HPP_INCLUDED #define VMIME_PLATFORMS_POSIX_SOCKET_HPP_INCLUDED #include "vmime/net/socket.hpp" #if VMIME_HAVE_MESSAGING_FEATURES namespace vmime { namespace platforms { namespace posix { class posixSocket : public vmime::net::socket { public: posixSocket(ref th); ~posixSocket(); void connect(const vmime::string& address, const vmime::port_t port); bool isConnected() const; void disconnect(); void receive(vmime::string& buffer); size_type receiveRaw(char* buffer, const size_type count); void send(const vmime::string& buffer); void sendRaw(const char* buffer, const size_type count); size_type getBlockSize() const; protected: static void throwSocketError(const int err); private: ref m_timeoutHandler; char m_buffer[65536]; int m_desc; }; class posixSocketFactory : public vmime::net::socketFactory { public: ref create(); ref create(ref th); }; } // posix } // platforms } // vmime #endif // VMIME_HAVE_MESSAGING_FEATURES #endif // VMIME_PLATFORMS_POSIX_SOCKET_HPP_INCLUDED libvmime-0.9.1/vmime/platforms/windows/0000755000175000017500000000000011607302336020446 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/platforms/windows/windowsFile.hpp0000644000175000017500000001176711314151075023462 0ustar mnordstrmnordstr// // VMime library (http://vmime.sourceforge.net) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORMS_WINDOWS_FILE_HPP_INCLUDED #define VMIME_PLATFORMS_WINDOWS_FILE_HPP_INCLUDED #include "vmime/utility/file.hpp" #include #if VMIME_HAVE_FILESYSTEM_FEATURES namespace vmime { namespace platforms { namespace windows { class windowsFileSystemFactory : public vmime::utility::fileSystemFactory { public: ref create(const vmime::utility::file::path& path) const; const vmime::utility::file::path stringToPath(const vmime::string& str) const; const vmime::string pathToString(const vmime::utility::file::path& path) const; static const vmime::utility::file::path stringToPathImpl(const vmime::string& str); static const vmime::string pathToStringImpl(const vmime::utility::file::path& path); bool isValidPathComponent(const vmime::utility::file::path::component& comp) const; bool isValidPathComponent(const vmime::utility::file::path::component& comp, bool firstComponent) const; bool isValidPath(const vmime::utility::file::path& path) const; static void reportError(const vmime::utility::path& path, const int err); }; class windowsFile : public vmime::utility::file { public: windowsFile(const vmime::utility::file::path& path); void createFile(); void createDirectory(const bool createAll = false); bool isFile() const; bool isDirectory() const; bool canRead() const; bool canWrite() const; length_type getLength(); const path& getFullPath() const; bool exists() const; ref getParent() const; void rename(const path& newName); void remove(); ref getFileWriter(); ref getFileReader(); ref getFiles() const; private: static void createDirectoryImpl(const vmime::utility::file::path& fullPath, const vmime::utility::file::path& path, const bool recursive = false); private: vmime::utility::file::path m_path; vmime::string m_nativePath; }; class windowsFileIterator : public vmime::utility::fileIterator { public: windowsFileIterator(const vmime::utility::file::path& path, const vmime::string& nativePath); ~windowsFileIterator(); bool hasMoreElements() const; vmime::ref nextElement(); private: void findFirst(); void findNext(); bool isCurrentOrParentDir() const; private: vmime::utility::file::path m_path; vmime::string m_nativePath; WIN32_FIND_DATA m_findData; bool m_moreElements; HANDLE m_hFind; }; class windowsFileReader : public vmime::utility::fileReader { public: windowsFileReader(const vmime::utility::file::path& path, const vmime::string& nativePath); public: ref getInputStream(); private: vmime::utility::file::path m_path; vmime::string m_nativePath; }; class windowsFileReaderInputStream : public vmime::utility::inputStream { public: windowsFileReaderInputStream(const vmime::utility::file::path& path, HANDLE hFile); ~windowsFileReaderInputStream(); public: bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: const vmime::utility::file::path m_path; HANDLE m_hFile; }; class windowsFileWriter : public vmime::utility::fileWriter { public: windowsFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath); public: ref getOutputStream(); private: vmime::utility::file::path m_path; vmime::string m_nativePath; }; class windowsFileWriterOutputStream : public vmime::utility::outputStream { public: windowsFileWriterOutputStream(const vmime::utility::file::path& path, HANDLE hFile); ~windowsFileWriterOutputStream(); public: void write(const value_type* const data, const size_type count); void flush(); private: const vmime::utility::file::path m_path; HANDLE m_hFile; }; } // windows } // platforms } // vmime #endif // VMIME_HAVE_FILESYSTEM_FEATURES #endif // VMIME_PLATFORMS_WINDOWS_FILE_HPP_INCLUDED libvmime-0.9.1/vmime/platforms/windows/windowsSocket.hpp0000644000175000017500000000433411432210306024015 0ustar mnordstrmnordstr// // VMime library (http://vmime.sourceforge.net) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORMS_WINDOWS_SOCKET_HPP_INCLUDED #define VMIME_PLATFORMS_WINDOWS_SOCKET_HPP_INCLUDED #include #include "vmime/net/socket.hpp" #if VMIME_HAVE_MESSAGING_FEATURES namespace vmime { namespace platforms { namespace windows { class windowsSocket : public vmime::net::socket { public: windowsSocket(); windowsSocket(ref th); ~windowsSocket(); public: void connect(const vmime::string& address, const vmime::port_t port); bool isConnected() const; void disconnect(); void receive(vmime::string& buffer); size_type receiveRaw(char* buffer, const size_type count); void send(const vmime::string& buffer); void sendRaw(const char* buffer, const size_type count); size_type getBlockSize() const; private: ref m_timeoutHandler; char m_buffer[65536]; SOCKET m_desc; }; class windowsSocketFactory : public vmime::net::socketFactory { public: ref create(); ref create(ref th); }; } // windows } // platforms } // vmime #endif // VMIME_HAVE_MESSAGING_FEATURES #endif // VMIME_PLATFORMS_WINDOWS_SOCKET_HPP_INCLUDED libvmime-0.9.1/vmime/platforms/windows/windowsHandler.hpp0000644000175000017500000000453711314151075024155 0ustar mnordstrmnordstr// // VMime library (http://vmime.sourceforge.net) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PLATFORMS_WINDOWS_HANDLER_HPP_INCLUDED #define VMIME_PLATFORMS_WINDOWS_HANDLER_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/platform.hpp" #if VMIME_HAVE_MESSAGING_FEATURES #include "vmime/platforms/windows/windowsSocket.hpp" #endif #if VMIME_HAVE_FILESYSTEM_FEATURES #include "vmime/platforms/windows/windowsFile.hpp" #endif namespace vmime { namespace platforms { namespace windows { class windowsHandler : public vmime::platform::handler { public: windowsHandler(); ~windowsHandler(); unsigned int getUnixTime() const; const vmime::datetime getCurrentLocalTime() const; const vmime::charset getLocaleCharset() const; const vmime::string getHostName() const; unsigned int getProcessId() const; #if VMIME_HAVE_MESSAGING_FEATURES ref getSocketFactory(); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES ref getFileSystemFactory(); ref getChildProcessFactory(); #endif void wait() const; private: #if VMIME_HAVE_MESSAGING_FEATURES ref m_socketFactory; #endif #if VMIME_HAVE_FILESYSTEM_FEATURES ref m_fileSysFactory; #endif }; } // windows } // platforms } // vmime #endif // VMIME_PLATFORMS_WINDOWS_HANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/disposition.hpp0000644000175000017500000001012311250723264020020 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_DISPOSITION_HPP_INCLUDED #define VMIME_DISPOSITION_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" #include namespace vmime { /** Disposition - from RFC-3798 (basic type). */ class disposition : public headerFieldValue { public: disposition(); disposition(const string& actionMode, const string& sendingMode, const string& type, const string& modifier); ref clone() const; void copyFrom(const component& other); disposition& operator=(const disposition& other); const std::vector > getChildComponents() const; /** Set the disposition action mode. * See the constants in vmime::dispositionActionModes. * * @param mode disposition action mode */ void setActionMode(const string& mode); /** Return the disposition action mode. * See the constants in vmime::dispositionActionModes. * * @return disposition action mode */ const string& getActionMode() const; /** Set the disposition sending mode. * See the constants in vmime::dispositionSendingModes. * * @param mode disposition sending mode */ void setSendingMode(const string& mode); /** Return the disposition sending mode. * See the constants in vmime::dispositionSendingModes. * * @return disposition sending mode */ const string& getSendingMode() const; /** Set the disposition type. * See the constants in vmime::dispositionTypes. * * @param type disposition type */ void setType(const string& type); /** Return the disposition type. * See the constants in vmime::dispositionTypes. * * @return disposition type */ const string& getType() const; /** Add a disposition modifier if it does not exist. * See the constants in vmime::dispositionModifiers. * * @param modifier modifier to add */ void addModifier(const string& modifier); /** Remove the specified disposition modifier. * See the constants in vmime::dispositionModifiers. * * @param modifier modifier to remove */ void removeModifier(const string& modifier); /** Remove all disposition modifiers. */ void removeAllModifiers(); /** Test whether a disposition modifier is set. * * @param modifier modifier to test * @return true if the specified modifier is set, false otherwise */ bool hasModifier(const string& modifier) const; /** Return the list of modifiers. * * @return list of modifiers */ const std::vector getModifierList() const; private: string m_actionMode; string m_sendingMode; string m_type; std::vector m_modifiers; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_DISPOSITION_HPP_INCLUDED libvmime-0.9.1/vmime/exception.hpp0000644000175000017500000004433211376177061017472 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_EXCEPTION_HPP_INCLUDED #define VMIME_EXCEPTION_HPP_INCLUDED #include #include "vmime/config.hpp" #include "vmime/base.hpp" #include "vmime/utility/path.hpp" namespace vmime { /** Base class for VMime exceptions. */ class exception : public std::exception { private: string m_what; exception* m_other; exception(); public: exception(const string& what, const exception& other = NO_EXCEPTION); exception(const exception& e); virtual ~exception() throw(); /** Return a description of the error. * * @return error message */ const char* what() const throw(); /** Return a description of the error. * * @return error message */ const char* what() throw(); /** Return the next exception in the chain (encapsulated exception). * * @return next exception in the chain */ const exception* other() const throw(); /** Return a name identifying the exception. * * @return exception name */ virtual const char* name() const throw(); /** Clone this object. * * @return a new copy of this object */ virtual exception* clone() const; protected: static const exception NO_EXCEPTION; }; /** List of all VMime exceptions. */ namespace exceptions { class bad_field_type : public vmime::exception { public: bad_field_type(const exception& other = NO_EXCEPTION); ~bad_field_type() throw(); exception* clone() const; const char* name() const throw(); }; class charset_conv_error : public vmime::exception { public: charset_conv_error(const string& what = "", const exception& other = NO_EXCEPTION); ~charset_conv_error() throw(); exception* clone() const; const char* name() const throw(); }; /** No encoder has been found for the specified encoding name. */ class no_encoder_available : public vmime::exception { public: no_encoder_available(const string& name, const exception& other = NO_EXCEPTION); ~no_encoder_available() throw(); exception* clone() const; const char* name() const throw(); }; /** No algorithm has been found for the specified name. */ class no_digest_algorithm_available : public vmime::exception { public: no_digest_algorithm_available(const string& name, const exception& other = NO_EXCEPTION); ~no_digest_algorithm_available() throw(); exception* clone() const; const char* name() const throw(); }; class no_such_parameter : public vmime::exception { public: no_such_parameter(const string& name, const exception& other = NO_EXCEPTION); ~no_such_parameter() throw(); exception* clone() const; const char* name() const throw(); }; class no_such_field : public vmime::exception { public: no_such_field(const exception& other = NO_EXCEPTION); ~no_such_field() throw(); exception* clone() const; const char* name() const throw(); }; class no_such_part : public vmime::exception { public: no_such_part(const exception& other = NO_EXCEPTION); ~no_such_part() throw(); exception* clone() const; const char* name() const throw(); }; class no_such_mailbox : public vmime::exception { public: no_such_mailbox(const exception& other = NO_EXCEPTION); ~no_such_mailbox() throw(); exception* clone() const; const char* name() const throw(); }; class no_such_message_id : public vmime::exception { public: no_such_message_id(const exception& other = NO_EXCEPTION); ~no_such_message_id() throw(); exception* clone() const; const char* name() const throw(); }; class no_such_address : public vmime::exception { public: no_such_address(const exception& other = NO_EXCEPTION); ~no_such_address() throw(); exception* clone() const; const char* name() const throw(); }; class open_file_error : public vmime::exception { public: open_file_error(const exception& other = NO_EXCEPTION); ~open_file_error() throw(); exception* clone() const; const char* name() const throw(); }; class no_factory_available : public vmime::exception { public: no_factory_available(const exception& other = NO_EXCEPTION); ~no_factory_available() throw(); exception* clone() const; const char* name() const throw(); }; class no_platform_handler : public vmime::exception { public: no_platform_handler(const exception& other = NO_EXCEPTION); ~no_platform_handler() throw(); exception* clone() const; const char* name() const throw(); }; /** No expeditor specified. */ class no_expeditor : public vmime::exception { public: no_expeditor(const exception& other = NO_EXCEPTION); ~no_expeditor() throw(); exception* clone() const; const char* name() const throw(); }; /** No recipient specified. */ class no_recipient : public vmime::exception { public: no_recipient(const exception& other = NO_EXCEPTION); ~no_recipient() throw(); exception* clone() const; const char* name() const throw(); }; class no_object_found : public vmime::exception { public: no_object_found(const exception& other = NO_EXCEPTION); ~no_object_found() throw(); exception* clone() const; const char* name() const throw(); }; /** There is no property with that name in the set. */ class no_such_property : public vmime::exception { public: no_such_property(const string& name, const exception& other = NO_EXCEPTION); ~no_such_property() throw(); exception* clone() const; const char* name() const throw(); }; /** Bad type specified when reading property. */ class invalid_property_type : public vmime::exception { public: invalid_property_type(const exception& other = NO_EXCEPTION); ~invalid_property_type() throw(); exception* clone() const; const char* name() const throw(); }; /** Bad argument was passed to the function. */ class invalid_argument : public vmime::exception { public: invalid_argument(const exception& other = NO_EXCEPTION); ~invalid_argument() throw(); exception* clone() const; const char* name() const throw(); }; /** Underlying operating system error. */ class system_error : public vmime::exception { public: system_error(const string& what, const exception& other = NO_EXCEPTION); ~system_error() throw(); exception* clone() const; const char* name() const throw(); }; #if VMIME_HAVE_MESSAGING_FEATURES /** Base class for exceptions thrown by the networking module. */ class net_exception : public vmime::exception { public: net_exception(const string& what, const exception& other = NO_EXCEPTION); ~net_exception() throw(); exception* clone() const; const char* name() const throw(); }; /** Alias for 'net_exception' (compatibility with version <= 0.7.1); * this is deprecated. */ typedef net_exception messaging_exception; /** Socket error. */ class socket_exception : public net_exception { public: socket_exception(const string& what = "", const exception& other = NO_EXCEPTION); ~socket_exception() throw(); exception* clone() const; const char* name() const throw(); }; /** Error while connecting to the server: this may be a DNS resolution error * or a connection error (for example, time-out while connecting). */ class connection_error : public socket_exception { public: connection_error(const string& what = "", const exception& other = NO_EXCEPTION); ~connection_error() throw(); exception* clone() const; const char* name() const throw(); }; /** Server did not initiated the connection correctly. */ class connection_greeting_error : public net_exception { public: connection_greeting_error(const string& response, const exception& other = NO_EXCEPTION); ~connection_greeting_error() throw(); const string& response() const; exception* clone() const; const char* name() const throw(); private: string m_response; }; /** Error while giving credentials to the server (wrong username * or password, or wrong authentication method). */ class authentication_error : public net_exception { public: authentication_error(const string& response, const exception& other = NO_EXCEPTION); ~authentication_error() throw(); const string& response() const; exception* clone() const; const char* name() const throw(); private: string m_response; }; /** Option not supported. */ class unsupported_option : public net_exception { public: unsupported_option(const exception& other = NO_EXCEPTION); ~unsupported_option() throw(); exception* clone() const; const char* name() const throw(); }; /** No service available for this protocol. */ class no_service_available : public net_exception { public: no_service_available(const string& proto = "", const exception& other = NO_EXCEPTION); ~no_service_available() throw(); exception* clone() const; const char* name() const throw(); }; /** The current state of the object does not permit to execute the * operation (for example, you try to close a folder which is not open). */ class illegal_state : public net_exception { public: illegal_state(const string& state, const exception& other = NO_EXCEPTION); ~illegal_state() throw(); exception* clone() const; const char* name() const throw(); }; /** Folder not found (does not exist). */ class folder_not_found : public net_exception { public: folder_not_found(const exception& other = NO_EXCEPTION); ~folder_not_found() throw(); exception* clone() const; const char* name() const throw(); }; /** Message not found (does not exist). */ class message_not_found : public net_exception { public: message_not_found(const exception& other = NO_EXCEPTION); ~message_not_found() throw(); exception* clone() const; const char* name() const throw(); }; /** Operation not supported by the underlying protocol. */ class operation_not_supported : public net_exception { public: operation_not_supported(const exception& other = NO_EXCEPTION); ~operation_not_supported() throw(); exception* clone() const; const char* name() const throw(); }; /** The operation timed out (time-out delay is elapsed). */ class operation_timed_out : public net_exception { public: operation_timed_out(const exception& other = NO_EXCEPTION); ~operation_timed_out() throw(); exception* clone() const; const char* name() const throw(); }; /** The operation has been cancelled. */ class operation_cancelled : public net_exception { public: operation_cancelled(const exception& other = NO_EXCEPTION); ~operation_cancelled() throw(); exception* clone() const; const char* name() const throw(); }; /** Must call fetchMessage() or fetchHeader() before accessing * the requested object. */ class unfetched_object : public net_exception { public: unfetched_object(const exception& other = NO_EXCEPTION); ~unfetched_object() throw(); exception* clone() const; const char* name() const throw(); }; /** The service is not currently connected. */ class not_connected : public net_exception { public: not_connected(const exception& other = NO_EXCEPTION); ~not_connected() throw(); exception* clone() const; const char* name() const throw(); }; /** The service is already connected (must disconnect before). */ class already_connected : public net_exception { public: already_connected(const exception& other = NO_EXCEPTION); ~already_connected() throw(); exception* clone() const; const char* name() const throw(); }; /** Illegal operation: cannot run this operation on the object. */ class illegal_operation : public net_exception { public: illegal_operation(const string& msg = "", const exception& other = NO_EXCEPTION); ~illegal_operation() throw(); exception* clone() const; const char* name() const throw(); }; /** Command error: operation failed (this is specific to the underlying protocol). */ class command_error : public net_exception { public: command_error(const string& command, const string& response, const string& desc = "", const exception& other = NO_EXCEPTION); ~command_error() throw(); /** Return the name of the command which have thrown the exception. * This is protocol-dependent. * * @return command name (protocol-dependent) */ const string& command() const; /** Return the invalid response line. * The meaning is protocol-dependent. * * @return response line (protocol-dependent) */ const string& response() const; exception* clone() const; const char* name() const throw(); private: string m_command; string m_response; }; /** The server returned an invalid response. */ class invalid_response : public net_exception { public: invalid_response(const string& command, const string& response, const exception& other = NO_EXCEPTION); ~invalid_response() throw(); /** Return the name of the command which have thrown the exception. * This is protocol-dependent. * * @return command name (protocol-dependent) */ const string& command() const; /** Return the invalid response line. * The meaning is protocol-dependent. * * @return response line (protocol-dependent) */ const string& response() const; exception* clone() const; const char* name() const throw(); private: string m_command; string m_response; }; /** Partial fetch is not supported by the underlying protocol. */ class partial_fetch_not_supported : public net_exception { public: partial_fetch_not_supported(const exception& other = NO_EXCEPTION); ~partial_fetch_not_supported() throw(); exception* clone() const; const char* name() const throw(); }; /** The URL is malformed. */ class malformed_url : public net_exception { public: malformed_url(const string& error, const exception& other = NO_EXCEPTION); ~malformed_url() throw(); exception* clone() const; const char* name() const throw(); }; /** Folder name is invalid. */ class invalid_folder_name : public net_exception { public: invalid_folder_name(const string& error = "", const exception& other = NO_EXCEPTION); ~invalid_folder_name() throw(); exception* clone() const; const char* name() const throw(); }; #endif // VMIME_HAVE_MESSAGING_FEATURES #if VMIME_HAVE_FILESYSTEM_FEATURES /** Base class for exceptions thrown by the filesystem features. */ class filesystem_exception : public vmime::exception { public: filesystem_exception(const string& what, const utility::path& path, const exception& other = NO_EXCEPTION); ~filesystem_exception() throw(); /** Return the full path of the file have thrown the exception. * * @return full path of the file/directory */ const utility::path& path() const; exception* clone() const; const char* name() const throw(); private: const utility::path m_path; }; /** File is not a directory. */ class not_a_directory : public filesystem_exception { public: not_a_directory(const utility::path& path, const exception& other = NO_EXCEPTION); ~not_a_directory() throw(); exception* clone() const; const char* name() const throw(); }; /** File not found. */ class file_not_found : public filesystem_exception { public: file_not_found(const utility::path& path, const exception& other = NO_EXCEPTION); ~file_not_found() throw(); exception* clone() const; const char* name() const throw(); }; #endif // VMIME_HAVE_FILESYSTEM_FEATURES /** Authentication exception. */ class authentication_exception : public vmime::exception { public: authentication_exception(const string& what, const exception& other = NO_EXCEPTION); ~authentication_exception() throw(); exception* clone() const; const char* name() const throw(); }; /** The requested information cannot be provided. */ class no_auth_information : public authentication_exception { public: no_auth_information(const exception& other = NO_EXCEPTION); ~no_auth_information() throw(); exception* clone() const; const char* name() const throw(); }; #if VMIME_HAVE_SASL_SUPPORT /** Base class for exceptions thrown by SASL module. */ class sasl_exception : public authentication_exception { public: sasl_exception(const string& what, const exception& other = NO_EXCEPTION); ~sasl_exception() throw(); exception* clone() const; const char* name() const throw(); }; /** No mechanism is registered with the specified name. */ class no_such_mechanism : public sasl_exception { public: no_such_mechanism(const string& name, const exception& other = NO_EXCEPTION); ~no_such_mechanism() throw(); exception* clone() const; const char* name() const throw(); }; #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT /** Base class for exceptions thrown by TLS module. */ class tls_exception : public vmime::exception { public: tls_exception(const string& what, const exception& other = NO_EXCEPTION); ~tls_exception() throw(); exception* clone() const; const char* name() const throw(); }; class certificate_exception : public tls_exception { public: certificate_exception(const string& what, const exception& other = NO_EXCEPTION); ~certificate_exception() throw(); exception* clone() const; const char* name() const throw(); }; class certificate_verification_exception : public certificate_exception { public: certificate_verification_exception(const string& what, const exception& other = NO_EXCEPTION); ~certificate_verification_exception() throw (); exception* clone() const; const char* name() const throw (); }; class unsupported_certificate_type : public certificate_exception { public: unsupported_certificate_type(const string& type, const exception& other = NO_EXCEPTION); ~unsupported_certificate_type() throw (); exception* clone() const; const char* name() const throw (); }; #endif // VMIME_HAVE_TLS_SUPPORT } // exceptions } // vmime #endif // VMIME_EXCEPTION_HPP_INCLUDED libvmime-0.9.1/vmime/charset.hpp0000644000175000017500000000777011376177204017131 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_CHARSET_HPP_INCLUDED #define VMIME_CHARSET_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" namespace vmime { class encoding; // forward reference /** Charset description (basic type). */ class charset : public component { public: charset(); charset(const string& name); charset(const char* name); // to allow creation from vmime::charsets constants public: /** Return the ISO name of the charset. * * @return charset name */ const string& getName() const; charset& operator=(const charset& other); bool operator==(const charset& value) const; bool operator!=(const charset& value) const; const std::vector > getChildComponents() const; /** Gets the recommended encoding for this charset. * Note: there may be no recommended encoding. * * @param enc output parameter that will hold recommended encoding * @return true if an encoding is recommended (the encoding is stored * in the enc parameter), false otherwise (in this case, the enc * parameter is not modified) */ bool getRecommendedEncoding(encoding& enc) const; /** Returns the default charset used on the system. * * This function simply calls platformHandler::getLocaleCharset() * and is provided for convenience. * * @return system default charset */ static const charset getLocaleCharset(); /** Convert a string buffer from one charset to another * charset (in-memory conversion) * * \deprecated Use the new convert() method, which takes * an outputStream parameter. * * @param in input buffer * @param out output buffer * @param source input charset * @param dest output charset * @throws exceptions::charset_conv_error if an error occured during * the conversion */ static void convert(const string& in, string& out, const charset& source, const charset& dest); /** Convert the contents of an input stream in a specified charset * to another charset and write the result to an output stream. * * @param in input stream to read data from * @param out output stream to write the converted data * @param source input charset * @param dest output charset * @throws exceptions::charset_conv_error if an error occured during * the conversion */ static void convert(utility::inputStream& in, utility::outputStream& out, const charset& source, const charset& dest); ref clone() const; void copyFrom(const component& other); private: string m_name; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_CHARSET_HPP_INCLUDED libvmime-0.9.1/vmime/messageAttachment.hpp0000644000175000017500000000301711250723264021115 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MESSAGEATTACHMENT_HPP_INCLUDED #define VMIME_MESSAGEATTACHMENT_HPP_INCLUDED #include "vmime/attachment.hpp" #include "vmime/message.hpp" namespace vmime { /** Attachment of type message/rfc822. */ class messageAttachment : public attachment { public: /** Return the message encapsulated in this attachment. * * @return encapsulated message */ virtual ref getMessage() const = 0; }; } // vmime #endif // VMIME_MESSAGEATTACHMENT_HPP_INCLUDED libvmime-0.9.1/vmime/defaultAttachment.hpp0000644000175000017500000000534311250723264021121 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_DEFAULTATTACHMENT_HPP_INCLUDED #define VMIME_DEFAULTATTACHMENT_HPP_INCLUDED #include "vmime/attachment.hpp" #include "vmime/encoding.hpp" namespace vmime { /** Default implementation for attachments. */ class defaultAttachment : public attachment { protected: // For use in derived classes. defaultAttachment(); public: defaultAttachment(ref data, const encoding& enc, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD); defaultAttachment(ref data, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD); defaultAttachment(const defaultAttachment& attach); ~defaultAttachment(); defaultAttachment& operator=(const defaultAttachment& attach); const mediaType getType() const; const text getDescription() const; const word getName() const; const ref getData() const; const encoding getEncoding() const; ref getPart() const; ref getHeader() const; protected: mediaType m_type; /**< Media type (eg. "application/octet-stream") */ text m_desc; /**< Description (eg. "The image you requested") */ ref m_data; /**< Attachment data (eg. the file contents) */ encoding m_encoding; /**< Encoding */ word m_name; /**< Name/filename (eg. "sunset.jpg") */ private: // No need to override "generateIn", use "generatePart" instead (see below). void generateIn(ref parent) const; protected: virtual void generatePart(ref part) const; }; } // vmime #endif // VMIME_DEFAULTATTACHMENT_HPP_INCLUDED libvmime-0.9.1/vmime/messageId.hpp0000644000175000017500000000734511250723264017371 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MESSAGEID_HPP_INCLUDED #define VMIME_MESSAGEID_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" namespace vmime { /** Message identifier (basic type). */ class messageId : public headerFieldValue { friend class messageIdSequence; public: messageId(); messageId(const string& id); messageId(const messageId& mid); messageId(const string& left, const string& right); public: /** Return the left part of the message identifier. * * @return left part of message identifier */ const string& getLeft() const; /** Set the left part of the message identifier. * * @param left left part of message identifier */ void setLeft(const string& left); /** Return the right part of the message identifier. * * @return right part of message identifier */ const string& getRight() const; /** Set the right part of the message identifier. * * @param right right part of message identifier */ void setRight(const string& right); messageId& operator=(const string& id); bool operator==(const messageId& mid) const; bool operator!=(const messageId& mid) const; /** Generate a random message identifier. * * @return randomly created message identifier */ static messageId generateId(); /** Return the message identifier constructed by using * the right part and the left part, separated by * a '@' character. * * @return full message identifier */ const string getId() const; ref clone() const; void copyFrom(const component& other); messageId& operator=(const messageId& other); const std::vector > getChildComponents() const; private: string m_left; string m_right; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; protected: /** Parse a message-id from an input buffer. * * @param buffer input buffer * @param position position in the input buffer * @param end end position in the input buffer * @param newPosition will receive the new position in the input buffer * @return a new message-id object, or null if no more message-id can be parsed from the input buffer */ static ref parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition); }; } // vmime #endif // VMIME_MESSAGEID_HPP_INCLUDED libvmime-0.9.1/vmime/mailboxList.hpp0000644000175000017500000001157611250723264017760 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MAILBOXLIST_HPP_INCLUDED #define VMIME_MAILBOXLIST_HPP_INCLUDED #include "vmime/addressList.hpp" #include "vmime/mailbox.hpp" namespace vmime { /** A list of mailboxes (basic type). * * This class works exactly like 'addressList' except it prevents user * from inserting mailbox groups where it is not allowed by the RFC. */ class mailboxList : public headerFieldValue { public: mailboxList(); mailboxList(const mailboxList& mboxList); ref clone() const; void copyFrom(const component& other); mailboxList& operator=(const mailboxList& other); const std::vector > getChildComponents() const; /** Add a mailbox at the end of the list. * * @param mbox mailbox to append */ void appendMailbox(ref mbox); /** Insert a new mailbox before the specified mailbox. * * @param beforeMailbox mailbox before which the new mailbox will be inserted * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ void insertMailboxBefore(ref beforeMailbox, ref mbox); /** Insert a new mailbox before the specified position. * * @param pos position at which to insert the new mailbox (0 to insert at * the beginning of the list) * @param mbox mailbox to insert */ void insertMailboxBefore(const int pos, ref mbox); /** Insert a new mailbox after the specified mailbox. * * @param afterMailbox mailbox after which the new mailbox will be inserted * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ void insertMailboxAfter(ref afterMailbox, ref mbox); /** Insert a new mailbox after the specified position. * * @param pos position of the mailbox before the new mailbox * @param mbox mailbox to insert */ void insertMailboxAfter(const int pos, ref mbox); /** Remove the specified mailbox from the list. * * @param mbox mailbox to remove * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ void removeMailbox(ref mbox); /** Remove the mailbox at the specified position. * * @param pos position of the mailbox to remove */ void removeMailbox(const int pos); /** Remove all mailboxes from the list. */ void removeAllMailboxes(); /** Return the number of mailboxes in the list. * * @return number of mailboxes */ int getMailboxCount() const; /** Tests whether the list of mailboxes is empty. * * @return true if there is no mailbox, false otherwise */ bool isEmpty() const; /** Return the mailbox at the specified position. * * @param pos position * @return mailbox at position 'pos' */ ref getMailboxAt(const int pos); /** Return the mailbox at the specified position. * * @param pos position * @return mailbox at position 'pos' */ const ref getMailboxAt(const int pos) const; /** Return the mailbox list. * * @return list of mailboxes */ const std::vector > getMailboxList() const; /** Return the mailbox list. * * @return list of mailboxes */ const std::vector > getMailboxList(); /** Return a list of addresses. * * @return list of addresses */ ref toAddressList() const; private: addressList m_list; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_MAILBOXLIST_HPP_INCLUDED libvmime-0.9.1/vmime/vmime.hpp0000644000175000017500000000773711250723264016612 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should.have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_INCLUDED #define VMIME_INCLUDED // Configuration #include "vmime/config.hpp" // Base definitions #include "vmime/base.hpp" #include "vmime/exception.hpp" #include "vmime/options.hpp" #include "vmime/platform.hpp" // Base components #include "vmime/dateTime.hpp" #include "vmime/message.hpp" #include "vmime/bodyPart.hpp" #include "vmime/charset.hpp" #include "vmime/text.hpp" #include "vmime/encoding.hpp" #include "vmime/contentDisposition.hpp" #include "vmime/mailbox.hpp" #include "vmime/mailboxGroup.hpp" #include "vmime/mailboxList.hpp" #include "vmime/addressList.hpp" #include "vmime/mediaType.hpp" #include "vmime/messageId.hpp" #include "vmime/messageIdSequence.hpp" #include "vmime/relay.hpp" #include "vmime/disposition.hpp" #include "vmime/path.hpp" #include "vmime/emptyContentHandler.hpp" #include "vmime/stringContentHandler.hpp" #include "vmime/streamContentHandler.hpp" // Message components #include "vmime/message.hpp" // Header fields #include "vmime/headerFieldFactory.hpp" #include "vmime/mailboxField.hpp" #include "vmime/parameterizedHeaderField.hpp" // Encoders #include "vmime/utility/encoder/encoderFactory.hpp" // Message builder/parser #include "vmime/messageBuilder.hpp" #include "vmime/messageParser.hpp" #include "vmime/fileAttachment.hpp" #include "vmime/defaultAttachment.hpp" #include "vmime/messageAttachment.hpp" #include "vmime/plainTextPart.hpp" #include "vmime/htmlTextPart.hpp" #include "vmime/attachmentHelper.hpp" // MDN #include "vmime/mdn/MDNHelper.hpp" // Misc #include "vmime/misc/importanceHelper.hpp" // Property set #include "vmime/propertySet.hpp" // Utilities #include "vmime/utility/datetimeUtils.hpp" #include "vmime/utility/filteredStream.hpp" #include "vmime/charsetConverter.hpp" // Security #include "vmime/security/authenticator.hpp" #include "vmime/security/defaultAuthenticator.hpp" // Security/digest #include "vmime/security/digest/messageDigestFactory.hpp" // Security/SASL #if VMIME_HAVE_SASL_SUPPORT #include "vmime/security/sasl/SASLAuthenticator.hpp" #include "vmime/security/sasl/defaultSASLAuthenticator.hpp" #include "vmime/security/sasl/SASLContext.hpp" #include "vmime/security/sasl/SASLSession.hpp" #endif // VMIME_HAVE_SASL_SUPPORT // Messaging features #if VMIME_HAVE_MESSAGING_FEATURES #include "vmime/net/socket.hpp" #include "vmime/net/serviceFactory.hpp" #include "vmime/net/store.hpp" #include "vmime/net/transport.hpp" #include "vmime/net/session.hpp" #include "vmime/net/folder.hpp" #include "vmime/net/message.hpp" #endif // VMIME_HAVE_MESSAGING_FEATURES // Net/TLS #if VMIME_HAVE_TLS_SUPPORT #include "vmime/security/cert/certificate.hpp" #include "vmime/security/cert/certificateChain.hpp" #include "vmime/security/cert/certificateVerifier.hpp" #include "vmime/security/cert/X509Certificate.hpp" #include "vmime/security/cert/defaultCertificateVerifier.hpp" #include "vmime/net/tls/TLSSession.hpp" #endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_INCLUDED libvmime-0.9.1/vmime/textPartFactory.hpp0000644000175000017500000000364511250723264020632 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_TEXTPARTFACTORY_HPP_INCLUDED #define VMIME_TEXTPARTFACTORY_HPP_INCLUDED #include "vmime/textPart.hpp" #include "vmime/mediaType.hpp" namespace vmime { class textPartFactory { protected: textPartFactory(); ~textPartFactory(); typedef ref (*AllocFunc)(void); typedef std::vector > MapType; MapType m_map; #ifndef VMIME_BUILDING_DOC template class registerer { public: static ref creator() { // Allocate a new object return vmime::create (); } }; #endif // VMIME_BUILDING_DOC public: static textPartFactory* getInstance(); template void registerType(const mediaType& type) { m_map.push_back(MapType::value_type(type, ®isterer::creator)); } ref create(const mediaType& type); }; } // vmime #endif // VMIME_TEXTPARTFACTORY_HPP_INCLUDED libvmime-0.9.1/vmime/types.hpp0000644000175000017500000000344711333330451016625 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_TYPES_HPP_INCLUDED #define VMIME_TYPES_HPP_INCLUDED #include #include #include #include "vmime/config.hpp" #include "vmime/utility/smartPtr.hpp" namespace vmime { typedef std::string string; typedef unsigned short port_t; typedef int char_t; typedef vmime_uint8 byte_t; typedef std::vector byteArray; // Some aliases namespace utils = utility; using vmime::utility::ref; using vmime::utility::weak_ref; using vmime::utility::null_ref; extern const null_ref null; // For compatibility with versions <= 0.7.1 (deprecated) namespace net { } namespace messaging = net; } // This is here because 'vmime::ref' need to be declared... #include "vmime/object.hpp" #endif // VMIME_TYPES_HPP_INCLUDED libvmime-0.9.1/vmime/parameter.hpp0000644000175000017500000000676411250723264017454 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PARAMETER_HPP_INCLUDED #define VMIME_PARAMETER_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" #include "vmime/word.hpp" namespace vmime { class parameter : public component { friend class parameterizedHeaderField; private: parameter(const parameter&); public: parameter(const string& name); parameter(const string& name, const word& value); parameter(const string& name, const string& value); #ifndef VMIME_BUILDING_DOC /** A single section of a multi-section parameter, * as defined in RFC-2231/3. This is used when * calling parse() on the parameter. */ struct valueChunk { bool encoded; string data; }; #endif // VMIME_BUILDING_DOC ref clone() const; void copyFrom(const component& other); parameter& operator=(const parameter& other); const std::vector > getChildComponents() const; /** Return the name of this parameter. * * @return name of this parameter */ const string& getName() const; /** Return the raw value of this parameter. * * @return read-only value */ const word& getValue() const; /** Return the value of this object in the specified type. * For example, the following code: * *
	  *    getParameter("creation-date")->getValueAs ()
	  * 
* * is equivalent to: * *
	  *    ref  rawValue = getParameter("creation-date");
	  *
	  *    vmime::dateTime theDate;
	  *    theDate.parse(rawValue->getBuffer());
	  * 
* * @param T type to which convert the value * @return value */ template const T getValueAs() const { T ret; ret.parse(m_value.getBuffer()); return ret; } /** Set the value of this parameter. * * @param value new value */ void setValue(const component& value); /** Set the raw value of this parameter. * * @param value new value */ void setValue(const word& value); using component::parse; using component::generate; void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; private: void parse(const std::vector & chunks); string m_name; word m_value; }; } // vmime #endif // VMIME_PARAMETER_HPP_INCLUDED libvmime-0.9.1/vmime/bodyPartAttachment.hpp0000644000175000017500000000410611250723264021255 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_BODYPARTATTACHMENT_HPP_INCLUDED #define VMIME_BODYPARTATTACHMENT_HPP_INCLUDED #ifndef VMIME_BUILDING_DOC // implementation detail #include "vmime/attachment.hpp" #include "vmime/contentDispositionField.hpp" #include "vmime/contentTypeField.hpp" namespace vmime { /** An attachment related to a local body part. */ class bodyPartAttachment : public attachment { friend class creator; protected: bodyPartAttachment(ref part); public: const mediaType getType() const; const word getName() const; const text getDescription() const; const encoding getEncoding() const; const ref getData() const; ref getPart() const; ref getHeader() const; private: void generateIn(ref parent) const; ref getContentDisposition() const; ref getContentType() const; ref m_part; }; } // vmime #endif // VMIME_BUILDING_DOC #endif // VMIME_BODYPARTATTACHMENT_HPP_INCLUDED libvmime-0.9.1/vmime/encoding.hpp0000644000175000017500000001035411376244502017252 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_ENCODING_HPP_INCLUDED #define VMIME_ENCODING_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" #include "vmime/utility/encoder/encoder.hpp" namespace vmime { class contentHandler; /** Content encoding (basic type). */ class encoding : public headerFieldValue { public: enum EncodingUsage { USAGE_TEXT, /**< Use for body text. */ USAGE_BINARY_DATA /**< Use for attachment, image... */ }; encoding(); explicit encoding(const string& name); encoding(const encoding& enc); public: /** Return the name of the encoding. * See the constants in vmime::encodingTypes. * * @return name of the encoding (eg. "quoted-printable") */ const string& getName() const; /** Set the name of the encoding. * See the constants in vmime::encodingTypes. * * @param name name of the encoding */ void setName(const string& name); encoding& operator=(const encoding& other); encoding& operator=(const string& name); bool operator==(const encoding& value) const; bool operator!=(const encoding& value) const; const std::vector > getChildComponents() const; /** Decide which encoding to use based on the specified data. * * @param data data used to determine encoding * @param usage context of use of data * @return suitable encoding for specified data */ static const encoding decide(ref data, const EncodingUsage usage = USAGE_BINARY_DATA); /** Decide which encoding to use based on the specified data and charset. * * @param data data used to determine encoding * @param charset charset of data * @param usage context of use of data * @return suitable encoding for specified data and charset */ static const encoding decide(ref data, const charset& chset, const EncodingUsage usage = USAGE_BINARY_DATA); ref clone() const; void copyFrom(const component& other); /** Use encoderFactory to obtain an encoder/decoder object * for the current encoding type. * * @throw exceptions::no_encoder_available if no encoder * is registered for the encoding * @return a new encoder object for the encoding type */ ref getEncoder() const; private: string m_name; /** Decide which encoding to use based on the specified data. * * Please note: this will read the whole buffer, so it should be used only * for small amount of data (eg. text), and not large binary attachments. * * @param begin start iterator in buffer * @param end end iterator in buffer * @return suitable encoding for specified data */ static const encoding decideImpl(const string::const_iterator begin, const string::const_iterator end); public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_ENCODING_HPP_INCLUDED libvmime-0.9.1/vmime/path.hpp0000644000175000017500000000524011250723264016414 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PATH_HPP_INCLUDED #define VMIME_PATH_HPP_INCLUDED #include "vmime/headerFieldValue.hpp" namespace vmime { /** A path: a local part + '@' + a domain. */ class path : public headerFieldValue { public: path(); path(const string& localPart, const string& domain); path(const path& p); /** Return the local part of the address. * * @return local part of the address */ const string& getLocalPart() const; /** Set the local part of the address. * * @param localPart local part of the address */ void setLocalPart(const string& localPart); /** Return the domain of the address. * * @return domain of the address */ const string& getDomain() const; /** Set the domain of the address. * * @param domain domain of the address */ void setDomain(const string& domain); // Comparison bool operator==(const path& p) const; bool operator!=(const path& p) const; // Assignment void copyFrom(const component& other); ref clone() const; path& operator=(const path& other); const std::vector > getChildComponents() const; protected: string m_localPart; string m_domain; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_PATH_HPP_INCLUDED libvmime-0.9.1/vmime/emptyContentHandler.hpp0000644000175000017500000000355511376250224021456 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_EMPTYCONTENTHANDLER_HPP_INCLUDED #define VMIME_EMPTYCONTENTHANDLER_HPP_INCLUDED #include "vmime/contentHandler.hpp" namespace vmime { class emptyContentHandler : public contentHandler { public: emptyContentHandler(); ref clone() const; void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; string::size_type getLength() const; bool isEncoded() const; const vmime::encoding& getEncoding() const; bool isEmpty() const; bool isBuffered() const; }; } // vmime #endif // VMIME_EMPTYCONTENTHANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/mailbox.hpp0000644000175000017500000000554511250723264017123 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MAILBOX_HPP_INCLUDED #define VMIME_MAILBOX_HPP_INCLUDED #include "vmime/address.hpp" #include "vmime/text.hpp" namespace vmime { /** A mailbox: full name + email (basic type). */ class mailbox : public address { friend class mailboxGroup; friend class mailboxField; public: mailbox(); mailbox(const mailbox& mbox); mailbox(const string& email); mailbox(const text& name, const string& email); /** Return the full name of the mailbox (empty if not specified). * * @return full name of the mailbox */ const text& getName() const; /** Set the full name of the mailbox. * * @param name full name of the mailbox */ void setName(const text& name); /** Return the email of the mailbox. * * @return email of the mailbox */ const string& getEmail() const; /** Set the email of the mailbox. * * @param email email of the mailbox */ void setEmail(const string& email); // Comparison bool operator==(const class mailbox& mailbox) const; bool operator!=(const class mailbox& mailbox) const; // Assignment void copyFrom(const component& other); ref clone() const; mailbox& operator=(const mailbox& other); bool isEmpty() const; void clear(); const std::vector > getChildComponents() const; bool isGroup() const; protected: text m_name; string m_email; public: using address::parse; using address::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_MAILBOX_HPP_INCLUDED libvmime-0.9.1/vmime/text.hpp0000644000175000017500000001703111375176272016456 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_TEXT_HPP_INCLUDED #define VMIME_TEXT_HPP_INCLUDED #include "vmime/headerFieldValue.hpp" #include "vmime/base.hpp" #include "vmime/word.hpp" namespace vmime { /** List of encoded-words, as defined in RFC-2047 (basic type). */ class text : public headerFieldValue { public: text(); text(const text& t); text(const string& t, const charset& ch); explicit text(const string& t); explicit text(const word& w); ~text(); public: bool operator==(const text& t) const; bool operator!=(const text& t) const; ref clone() const; void copyFrom(const component& other); text& operator=(const component& other); text& operator=(const text& other); const std::vector > getChildComponents() const; /** Add a word at the end of the list. * * @param w word to append */ void appendWord(ref w); /** Insert a new word before the specified position. * * @param pos position at which to insert the new word (0 to insert at * the beginning of the list) * @param w word to insert */ void insertWordBefore(const int pos, ref w); /** Insert a new word after the specified position. * * @param pos position of the word before the new word * @param w word to insert */ void insertWordAfter(const int pos, ref w); /** Remove the word at the specified position. * * @param pos position of the word to remove */ void removeWord(const int pos); /** Remove all words from the list. */ void removeAllWords(); /** Return the number of words in the list. * * @return number of words */ int getWordCount() const; /** Tests whether the list of words is empty. * * @return true if there is no word, false otherwise */ bool isEmpty() const; /** Return the word at the specified position. * * @param pos position * @return word at position 'pos' */ const ref getWordAt(const int pos); /** Return the word at the specified position. * * @param pos position * @return word at position 'pos' */ const ref getWordAt(const int pos) const; /** Return the word list. * * @return list of words */ const std::vector > getWordList() const; /** Return the word list. * * @return list of words */ const std::vector > getWordList(); /** Return the text converted into the specified charset. * The encoded-words are decoded and then converted in the * specified destination charset. * * @param dest output charset * @return text decoded in the specified charset */ const string getConvertedText(const charset& dest) const; /** Return the unconverted (raw) data of all words. This is the * concatenation of the results returned by getBuffer() on * the contained words. * * @return raw data */ const string getWholeBuffer() const; /** This function can be used to make several encoded words from a text. * All the characters in the text must be in the same specified charset. * *

Eg: giving:

*
   <iso-8859-1> "Linux dans un t'el'ephone mobile"
	  *    ("=?iso-8859-1?Q?Linux_dans_un_t=E9l=E9phone_mobile?=")
	  * 

it will return:

*
   <us-ascii>   "Linux dans un "
	  *    <iso-8859-1> "t'el'ephone "
	  *    <us-ascii>   "mobile"
	  *    ("Linux dans un =?iso-8859-1?Q?t=E9l=E9phone_?= mobile")
	  * 
* * @param in input string * @param ch input charset * @return new text object */ static ref newFromString(const string& in, const charset& ch); /** This function can be used to make several encoded words from a text. * All the characters in the text must be in the same specified charset. * *

Eg: giving:

*
   <iso-8859-1> "Linux dans un t'el'ephone mobile"
	  *    ("=?iso-8859-1?Q?Linux_dans_un_t=E9l=E9phone_mobile?=")
	  * 

it will return:

*
   <us-ascii>   "Linux dans un "
	  *    <iso-8859-1> "t'el'ephone "
	  *    <us-ascii>   "mobile"
	  *    ("Linux dans un =?iso-8859-1?Q?t=E9l=E9phone_?= mobile")
	  * 
* * @param in input string * @param ch input charset */ void createFromString(const string& in, const charset& ch); /** Flags used by "encodeAndFold" function. */ enum EncodeAndFoldFlags { // NOTE: If both "FORCE_NO_ENCODING" and "FORCE_ENCODING" are // specified, "FORCE_NO_ENCODING" is used by default. FORCE_NO_ENCODING = (1 << 0), /**< Just fold lines, don't encode them. */ FORCE_ENCODING = (1 << 1), /**< Encode lines even if they are plain ASCII text. */ NO_NEW_LINE_SEQUENCE = (1 << 2), /**< Use CRLF instead of new-line sequence (CRLF + TAB). */ QUOTE_IF_POSSIBLE = (1 << 3) /**< Use quoting instead of encoding when possible (even if FORCE_ENCODING is specified). */ }; /** Encode and fold text in respect to RFC-2047. * * @param os output stream * @param maxLineLength maximum line length for output * @param firstLineOffset the first line length (may be useful if the current output line is not empty) * @param lastLineLength will receive the length of the last line written * @param flags encoding flags (see EncodeAndFoldFlags) */ void encodeAndFold(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type firstLineOffset, string::size_type* lastLineLength, const int flags) const; /** Decode and unfold text (RFC-2047). * * @param in input string * @return new text object */ static ref decodeAndUnfold(const string& in); /** Decode and unfold text (RFC-2047). * * @param in input string * @param generateInExisting if not NULL, the resulting text will be generated * in the specified object instead of a new created object (in this case, the * function returns the same pointer). Can be used to avoid copying the * resulting object into an existing object. * @return new text object or existing object if generateInExisting != NULL */ static text* decodeAndUnfold(const string& in, text* generateInExisting); using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; private: std::vector > m_words; }; } // vmime #endif // VMIME_TEXT_HPP_INCLUDED libvmime-0.9.1/vmime/object.hpp0000644000175000017500000000445711250723264016737 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_OBJECT_HPP_INCLUDED #define VMIME_OBJECT_HPP_INCLUDED #include "vmime/types.hpp" #include namespace vmime { /** Base object for all objects in the library. This implements * reference counting and auto-deletion. */ class object { template friend class utility::ref; template friend class utility::weak_ref; friend class utility::refManager; protected: object(); object(const object&); object& operator=(const object&); virtual ~object(); #ifndef VMIME_BUILDING_DOC /** Return a reference to this object. * * @return reference to self */ ref thisRef(); /** Return a reference to this object (const version). * * @return reference to self */ ref thisRef() const; /** Return a weak reference to this object. * * @return weak reference to self */ weak_ref thisWeakRef(); /** Return a weak reference to this object (const version). * * @return weak reference to self */ weak_ref thisWeakRef() const; void setRefManager(utility::refManager* mgr); utility::refManager* getRefManager() const; #endif // VMIME_BUILDING_DOC private: mutable utility::refManager* m_refMgr; }; } // vmime #endif // VMIME_OBJECT_HPP_INCLUDED libvmime-0.9.1/vmime/mailboxField.hpp0000644000175000017500000000341311250723264020057 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MAILBOXFIELD_HPP_INCLUDED #define VMIME_MAILBOXFIELD_HPP_INCLUDED #include "vmime/headerField.hpp" #include "vmime/mailbox.hpp" // Hide implementation details from user #ifndef VMIME_BUILDING_DOC namespace vmime { /** Work-around for malformed header fields that are of type 'mailbox' * and contains multiple addresses. */ class mailboxField : public headerField { friend class vmime::creator; // create ref protected: mailboxField(); mailboxField(const mailboxField&); public: void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); }; #endif // VMIME_BUILDING_DOC } // vmime #endif // VMIME_MAILBOXFIELD_HPP_INCLUDED libvmime-0.9.1/vmime/component.hpp0000644000175000017500000001053711375451460017473 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_COMPONENT_HPP_INCLUDED #define VMIME_COMPONENT_HPP_INCLUDED #include "vmime/base.hpp" namespace vmime { /** This abstract class is the base class for all the components of a message. * It defines methods for parsing and generating a component. */ class component : public object { public: component(); virtual ~component(); /** Parse RFC-822/MIME data for this component. * * @param buffer input buffer */ void parse(const string& buffer); /** Parse RFC-822/MIME data for this component. * * @param buffer input buffer * @param position current position in the input buffer * @param end end position in the input buffer * @param newPosition will receive the new position in the input buffer */ virtual void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL) = 0; /** Generate RFC-2822/MIME data for this component. * * \deprecated Use the new generate() method, which takes an outputStream parameter. * * @param maxLineLength maximum line length for output * @param curLinePos length of the current line in the output buffer * @return generated data */ const string generate(const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0) const; /** Generate RFC-2822/MIME data for this component. * * @param os output stream * @param maxLineLength maximum line length for output * @param curLinePos length of the current line in the output buffer * @param newLinePos will receive the new line position (length of the last line written) */ virtual void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const = 0; /** Clone this component. * * @return a copy of this component */ virtual ref clone() const = 0; /** Replace data in this component by data in other component. * Both components must be of the same type. * * @throw std::bad_cast_exception if the components are not * of the same (dynamic) type * @param other other component to copy data from */ virtual void copyFrom(const component& other) = 0; /** Return the start position of this component in the * parsed message contents. * * @return start position in parsed buffer * or 0 if this component has not been parsed */ string::size_type getParsedOffset() const; /** Return the length of this component in the * parsed message contents. * * @return length of the component in parsed buffer * or 0 if this component has not been parsed */ string::size_type getParsedLength() const; /** Return the list of children of this component. * * @return list of child components */ const std::vector > getChildComponents(); /** Return the list of children of this component (const version). * * @return list of child components */ virtual const std::vector > getChildComponents() const = 0; protected: void setParsedBounds(const string::size_type start, const string::size_type end); private: string::size_type m_parsedOffset; string::size_type m_parsedLength; }; } // vmime #endif // VMIME_COMPONENT_HPP_INCLUDED libvmime-0.9.1/vmime/Makefile.am0000644000175000017500000001076511470477531017022 0ustar mnordstrmnordstr # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! libvmimeincludedir = $(prefix)/include/@GENERIC_LIBRARY_NAME@ nobase_libvmimeinclude_HEADERS = address.hpp \ addressList.hpp \ attachment.hpp \ attachmentHelper.hpp \ base.hpp \ body.hpp \ bodyPart.hpp \ bodyPartAttachment.hpp \ charset.hpp \ charsetConverter.hpp \ component.hpp \ constants.hpp \ contentDisposition.hpp \ contentDispositionField.hpp \ contentHandler.hpp \ contentTypeField.hpp \ dateTime.hpp \ defaultAttachment.hpp \ disposition.hpp \ emptyContentHandler.hpp \ encoding.hpp \ exception.hpp \ fileAttachment.hpp \ generatedMessageAttachment.hpp \ header.hpp \ headerFieldFactory.hpp \ headerField.hpp \ headerFieldValue.hpp \ htmlTextPart.hpp \ mailbox.hpp \ mailboxField.hpp \ mailboxGroup.hpp \ mailboxList.hpp \ mediaType.hpp \ messageAttachment.hpp \ messageBuilder.hpp \ message.hpp \ messageId.hpp \ messageIdSequence.hpp \ messageParser.hpp \ object.hpp \ options.hpp \ path.hpp \ parameter.hpp \ parameterizedHeaderField.hpp \ parsedMessageAttachment.hpp \ parserHelpers.hpp \ plainTextPart.hpp \ platform.hpp \ propertySet.hpp \ relay.hpp \ stringContentHandler.hpp \ streamContentHandler.hpp \ text.hpp \ textPartFactory.hpp \ textPart.hpp \ types.hpp \ word.hpp \ wordEncoder.hpp \ vmime.hpp \ utility/childProcess.hpp \ utility/file.hpp \ utility/datetimeUtils.hpp \ utility/filteredStream.hpp \ utility/path.hpp \ utility/progressListener.hpp \ utility/random.hpp \ utility/smartPtr.hpp \ utility/smartPtrInt.hpp \ utility/stream.hpp \ utility/stringProxy.hpp \ utility/stringUtils.hpp \ utility/url.hpp \ utility/urlUtils.hpp \ utility/encoder/encoder.hpp \ utility/encoder/sevenBitEncoder.hpp \ utility/encoder/eightBitEncoder.hpp \ utility/encoder/b64Encoder.hpp \ utility/encoder/binaryEncoder.hpp \ utility/encoder/defaultEncoder.hpp \ utility/encoder/encoderFactory.hpp \ utility/encoder/qpEncoder.hpp \ utility/encoder/uuEncoder.hpp \ mdn/MDNHelper.hpp \ mdn/MDNInfos.hpp \ mdn/receivedMDNInfos.hpp \ mdn/sendableMDNInfos.hpp \ misc/importanceHelper.hpp \ security/authenticator.hpp \ security/defaultAuthenticator.hpp \ security/digest/messageDigest.hpp \ security/digest/messageDigestFactory.hpp \ security/digest/md5/md5MessageDigest.hpp \ security/digest/sha1/sha1MessageDigest.hpp \ net/connectionInfos.hpp \ net/defaultConnectionInfos.hpp \ net/events.hpp \ net/folder.hpp \ net/message.hpp \ net/securedConnectionInfos.hpp \ net/service.hpp \ net/serviceFactory.hpp \ net/serviceInfos.hpp \ net/session.hpp \ net/socket.hpp \ net/store.hpp \ net/timeoutHandler.hpp \ net/transport.hpp \ security/sasl/SASLContext.hpp \ security/sasl/SASLSession.hpp \ security/sasl/SASLMechanism.hpp \ security/sasl/SASLMechanismFactory.hpp \ security/sasl/SASLSocket.hpp \ security/sasl/SASLAuthenticator.hpp \ security/sasl/defaultSASLAuthenticator.hpp \ security/sasl/builtinSASLMechanism.hpp \ net/tls/TLSSession.hpp \ net/tls/TLSSocket.hpp \ net/tls/TLSSecuredConnectionInfos.hpp \ security/cert/certificateChain.hpp \ security/cert/certificateVerifier.hpp \ security/cert/defaultCertificateVerifier.hpp \ security/cert/certificate.hpp \ security/cert/X509Certificate.hpp \ net/pop3/POP3ServiceInfos.hpp \ net/pop3/POP3Store.hpp \ net/pop3/POP3SStore.hpp \ net/pop3/POP3Folder.hpp \ net/pop3/POP3Message.hpp \ net/pop3/POP3Utils.hpp \ net/smtp/SMTPResponse.hpp \ net/smtp/SMTPServiceInfos.hpp \ net/smtp/SMTPTransport.hpp \ net/smtp/SMTPSTransport.hpp \ net/imap/IMAPServiceInfos.hpp \ net/imap/IMAPConnection.hpp \ net/imap/IMAPStore.hpp \ net/imap/IMAPSStore.hpp \ net/imap/IMAPFolder.hpp \ net/imap/IMAPMessage.hpp \ net/imap/IMAPTag.hpp \ net/imap/IMAPUtils.hpp \ net/imap/IMAPMessagePartContentHandler.hpp \ net/imap/IMAPStructure.hpp \ net/imap/IMAPPart.hpp \ net/imap/IMAPParser.hpp \ net/maildir/maildirServiceInfos.hpp \ net/maildir/maildirStore.hpp \ net/maildir/maildirFolder.hpp \ net/maildir/maildirMessage.hpp \ net/maildir/maildirUtils.hpp \ net/maildir/maildirFormat.hpp \ net/maildir/format/kmailMaildirFormat.hpp \ net/maildir/format/courierMaildirFormat.hpp \ net/sendmail/sendmailServiceInfos.hpp \ net/sendmail/sendmailTransport.hpp \ platforms/windows/windowsFile.hpp \ platforms/windows/windowsHandler.hpp \ platforms/windows/windowsSocket.hpp \ platforms/posix/posixChildProcess.hpp \ platforms/posix/posixFile.hpp \ platforms/posix/posixHandler.hpp \ platforms/posix/posixSocket.hpp \ config.hpplibvmime-0.9.1/vmime/Makefile.in0000644000175000017500000004663211470477543017040 0ustar mnordstrmnordstr# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = vmime DIST_COMMON = $(nobase_libvmimeinclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ $(top_srcdir)/m4/ost_posix.m4 $(top_srcdir)/m4/ost_prog.m4 \ $(top_srcdir)/m4/ost_pthread.m4 \ $(top_srcdir)/m4/ost_systime.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libvmimeincludedir)" HEADERS = $(nobase_libvmimeinclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ EXTRA_LIBS = @EXTRA_LIBS@ FGREP = @FGREP@ GENERIC_LIBRARY_NAME = @GENERIC_LIBRARY_NAME@ GENERIC_VERSIONED_LIBRARY_NAME = @GENERIC_VERSIONED_LIBRARY_NAME@ GREP = @GREP@ GSASL_AVAIL_LIBS = @GSASL_AVAIL_LIBS@ GSASL_AVAIL_REQUIRED = @GSASL_AVAIL_REQUIRED@ GSASL_LIBS = @GSASL_LIBS@ GSASL_REQUIRED = @GSASL_REQUIRED@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBRARY_LD_FLAGS = @LIBRARY_LD_FLAGS@ LIBRARY_NAME = @LIBRARY_NAME@ LIBRARY_RELEASE = @LIBRARY_RELEASE@ LIBRARY_VERSION = @LIBRARY_VERSION@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKGCONFIG_CFLAGS = @PKGCONFIG_CFLAGS@ PKGCONFIG_LIBS = @PKGCONFIG_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SENDMAIL = @SENDMAIL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ THREAD_FLAGS = @THREAD_FLAGS@ THREAD_LIBS = @THREAD_LIBS@ VERSION = @VERSION@ VMIME_ADDITIONAL_PC_LIBS = @VMIME_ADDITIONAL_PC_LIBS@ VMIME_PKGCONFIGDIR = @VMIME_PKGCONFIGDIR@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ thrprefix = @thrprefix@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! libvmimeincludedir = $(prefix)/include/@GENERIC_LIBRARY_NAME@ nobase_libvmimeinclude_HEADERS = address.hpp \ addressList.hpp \ attachment.hpp \ attachmentHelper.hpp \ base.hpp \ body.hpp \ bodyPart.hpp \ bodyPartAttachment.hpp \ charset.hpp \ charsetConverter.hpp \ component.hpp \ constants.hpp \ contentDisposition.hpp \ contentDispositionField.hpp \ contentHandler.hpp \ contentTypeField.hpp \ dateTime.hpp \ defaultAttachment.hpp \ disposition.hpp \ emptyContentHandler.hpp \ encoding.hpp \ exception.hpp \ fileAttachment.hpp \ generatedMessageAttachment.hpp \ header.hpp \ headerFieldFactory.hpp \ headerField.hpp \ headerFieldValue.hpp \ htmlTextPart.hpp \ mailbox.hpp \ mailboxField.hpp \ mailboxGroup.hpp \ mailboxList.hpp \ mediaType.hpp \ messageAttachment.hpp \ messageBuilder.hpp \ message.hpp \ messageId.hpp \ messageIdSequence.hpp \ messageParser.hpp \ object.hpp \ options.hpp \ path.hpp \ parameter.hpp \ parameterizedHeaderField.hpp \ parsedMessageAttachment.hpp \ parserHelpers.hpp \ plainTextPart.hpp \ platform.hpp \ propertySet.hpp \ relay.hpp \ stringContentHandler.hpp \ streamContentHandler.hpp \ text.hpp \ textPartFactory.hpp \ textPart.hpp \ types.hpp \ word.hpp \ wordEncoder.hpp \ vmime.hpp \ utility/childProcess.hpp \ utility/file.hpp \ utility/datetimeUtils.hpp \ utility/filteredStream.hpp \ utility/path.hpp \ utility/progressListener.hpp \ utility/random.hpp \ utility/smartPtr.hpp \ utility/smartPtrInt.hpp \ utility/stream.hpp \ utility/stringProxy.hpp \ utility/stringUtils.hpp \ utility/url.hpp \ utility/urlUtils.hpp \ utility/encoder/encoder.hpp \ utility/encoder/sevenBitEncoder.hpp \ utility/encoder/eightBitEncoder.hpp \ utility/encoder/b64Encoder.hpp \ utility/encoder/binaryEncoder.hpp \ utility/encoder/defaultEncoder.hpp \ utility/encoder/encoderFactory.hpp \ utility/encoder/qpEncoder.hpp \ utility/encoder/uuEncoder.hpp \ mdn/MDNHelper.hpp \ mdn/MDNInfos.hpp \ mdn/receivedMDNInfos.hpp \ mdn/sendableMDNInfos.hpp \ misc/importanceHelper.hpp \ security/authenticator.hpp \ security/defaultAuthenticator.hpp \ security/digest/messageDigest.hpp \ security/digest/messageDigestFactory.hpp \ security/digest/md5/md5MessageDigest.hpp \ security/digest/sha1/sha1MessageDigest.hpp \ net/connectionInfos.hpp \ net/defaultConnectionInfos.hpp \ net/events.hpp \ net/folder.hpp \ net/message.hpp \ net/securedConnectionInfos.hpp \ net/service.hpp \ net/serviceFactory.hpp \ net/serviceInfos.hpp \ net/session.hpp \ net/socket.hpp \ net/store.hpp \ net/timeoutHandler.hpp \ net/transport.hpp \ security/sasl/SASLContext.hpp \ security/sasl/SASLSession.hpp \ security/sasl/SASLMechanism.hpp \ security/sasl/SASLMechanismFactory.hpp \ security/sasl/SASLSocket.hpp \ security/sasl/SASLAuthenticator.hpp \ security/sasl/defaultSASLAuthenticator.hpp \ security/sasl/builtinSASLMechanism.hpp \ net/tls/TLSSession.hpp \ net/tls/TLSSocket.hpp \ net/tls/TLSSecuredConnectionInfos.hpp \ security/cert/certificateChain.hpp \ security/cert/certificateVerifier.hpp \ security/cert/defaultCertificateVerifier.hpp \ security/cert/certificate.hpp \ security/cert/X509Certificate.hpp \ net/pop3/POP3ServiceInfos.hpp \ net/pop3/POP3Store.hpp \ net/pop3/POP3SStore.hpp \ net/pop3/POP3Folder.hpp \ net/pop3/POP3Message.hpp \ net/pop3/POP3Utils.hpp \ net/smtp/SMTPResponse.hpp \ net/smtp/SMTPServiceInfos.hpp \ net/smtp/SMTPTransport.hpp \ net/smtp/SMTPSTransport.hpp \ net/imap/IMAPServiceInfos.hpp \ net/imap/IMAPConnection.hpp \ net/imap/IMAPStore.hpp \ net/imap/IMAPSStore.hpp \ net/imap/IMAPFolder.hpp \ net/imap/IMAPMessage.hpp \ net/imap/IMAPTag.hpp \ net/imap/IMAPUtils.hpp \ net/imap/IMAPMessagePartContentHandler.hpp \ net/imap/IMAPStructure.hpp \ net/imap/IMAPPart.hpp \ net/imap/IMAPParser.hpp \ net/maildir/maildirServiceInfos.hpp \ net/maildir/maildirStore.hpp \ net/maildir/maildirFolder.hpp \ net/maildir/maildirMessage.hpp \ net/maildir/maildirUtils.hpp \ net/maildir/maildirFormat.hpp \ net/maildir/format/kmailMaildirFormat.hpp \ net/maildir/format/courierMaildirFormat.hpp \ net/sendmail/sendmailServiceInfos.hpp \ net/sendmail/sendmailTransport.hpp \ platforms/windows/windowsFile.hpp \ platforms/windows/windowsHandler.hpp \ platforms/windows/windowsSocket.hpp \ platforms/posix/posixChildProcess.hpp \ platforms/posix/posixFile.hpp \ platforms/posix/posixHandler.hpp \ platforms/posix/posixSocket.hpp \ config.hpp all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu vmime/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu vmime/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-nobase_libvmimeincludeHEADERS: $(nobase_libvmimeinclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(libvmimeincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libvmimeincludedir)" @list='$(nobase_libvmimeinclude_HEADERS)'; test -n "$(libvmimeincludedir)" || list=; \ $(am__nobase_list) | while read dir files; do \ xfiles=; for file in $$files; do \ if test -f "$$file"; then xfiles="$$xfiles $$file"; \ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ test -z "$$xfiles" || { \ test "x$$dir" = x. || { \ echo "$(MKDIR_P) '$(DESTDIR)$(libvmimeincludedir)/$$dir'"; \ $(MKDIR_P) "$(DESTDIR)$(libvmimeincludedir)/$$dir"; }; \ echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(libvmimeincludedir)/$$dir'"; \ $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(libvmimeincludedir)/$$dir" || exit $$?; }; \ done uninstall-nobase_libvmimeincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(nobase_libvmimeinclude_HEADERS)'; test -n "$(libvmimeincludedir)" || list=; \ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(libvmimeincludedir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(libvmimeincludedir)" && rm -f $$files ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libvmimeincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-nobase_libvmimeincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-nobase_libvmimeincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool ctags distclean distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man \ install-nobase_libvmimeincludeHEADERS install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-nobase_libvmimeincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libvmime-0.9.1/vmime/relay.hpp0000644000175000017500000000512611250723264016577 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_RELAY_HPP_INCLUDED #define VMIME_RELAY_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" #include "vmime/dateTime.hpp" namespace vmime { /** Trace information about a relay (basic type). */ class relay : public headerFieldValue { public: relay(); relay(const relay& r); public: ref clone() const; void copyFrom(const component& other); relay& operator=(const relay& other); const std::vector > getChildComponents() const; const string& getFrom() const; void setFrom(const string& from); const string& getVia() const; void setVia(const string& via); const string& getBy() const; void setBy(const string& by); const string& getId() const; void setId(const string& id); const string& getFor() const; void setFor(const string& for_); const datetime& getDate() const; void setDate(const datetime& date); const std::vector & getWithList() const; std::vector & getWithList(); private: string m_from; string m_via; string m_by; string m_id; string m_for; std::vector m_with; datetime m_date; public: using component::parse; using component::generate; void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_RELAY_HPP_INCLUDED libvmime-0.9.1/vmime/messageBuilder.hpp0000644000175000017500000001262311250723264020416 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MESSAGEBUILDER_HPP_INCLUDED #define VMIME_MESSAGEBUILDER_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/mailbox.hpp" #include "vmime/addressList.hpp" #include "vmime/text.hpp" #include "vmime/message.hpp" #include "vmime/mediaType.hpp" #include "vmime/attachment.hpp" #include "vmime/textPart.hpp" #include "vmime/bodyPart.hpp" namespace vmime { /** A helper for building MIME messages. */ class messageBuilder { public: messageBuilder(); ~messageBuilder(); public: /** Return the expeditor of the message (From:). * * @return expeditor of the message */ const mailbox& getExpeditor() const; /** Set the expeditor of the message (From:). * * @param expeditor expeditor of the message */ void setExpeditor(const mailbox& expeditor); /** Return the recipients of the message (To:). * * return recipients of the message */ const addressList& getRecipients() const; /** Return the recipients of the message (To:). * * return recipients of the message */ addressList& getRecipients(); /** Set the recipients of the message (To:). * * @param recipients list of recipients */ void setRecipients(const addressList& recipients); /** Return the copy recipients of the message (Cc:). * * @return copy recipients of the message */ const addressList& getCopyRecipients() const; /** Return the copy recipients of the message (Cc:). * * @return copy recipients of the message */ addressList& getCopyRecipients(); /** Set the copy recipients of the message (Cc:). * * @param cc list of copy recipients */ void setCopyRecipients(const addressList& cc); /** Return the blind-copy recipients of the message (Bcc:). * * @return blind-copy recipients of the message */ const addressList& getBlindCopyRecipients() const; /** Return the blind-copy recipients of the message (Bcc:). * * @return blind-copy recipients of the message */ addressList& getBlindCopyRecipients(); /** Set the blind-copy recipients of the message (Bcc:). * * @param bcc list of blind-copy recipients */ void setBlindCopyRecipients(const addressList& bcc); /** Return the subject of the message. * * @return subject of the message */ const text& getSubject() const; /** Set the subject of the message. * * @param subject message subject */ void setSubject(const text& subject); /** Attach a new object to the message. * \deprecated Use messageBuilder::appendAttachment() instead. * * @param attach new attachment */ void attach(ref attach); /** Attach a new object to the message. * * @param attach new attachment */ void appendAttachment(ref attach); /** Remove the attachment at the specified position. * * @param pos position of the attachment to remove */ void removeAttachment(const int pos); /** Return the attachment at the specified position. * * @param pos position of the attachment * @return attachment at the specified position */ const ref getAttachmentAt(const int pos) const; /** Return the attachment at the specified position. * * @param pos position of the attachment * @return attachment at the specified position */ ref getAttachmentAt(const int pos); /** Return the number of attachments in the message. * * @return number of attachments */ int getAttachmentCount() const; /** Return the list of attachments. * * @return list of attachments */ const std::vector > getAttachmentList() const; /** Return the list of attachments. * * @return list of attachments */ const std::vector > getAttachmentList(); /** Change the type of the text part and construct a new part. * * @param type media type of the text part */ void constructTextPart(const mediaType& type); /** Return the text part of the message. * * @return text part of the message */ ref getTextPart(); /** Construct a new message based on the information specified * in this object. * * @return a new message */ ref construct() const; private: mailbox m_from; addressList m_to; addressList m_cc; addressList m_bcc; text m_subject; ref m_textPart; std::vector > m_attach; }; } // vmime #endif // VMIME_MESSAGEBUILDER_HPP_INCLUDED libvmime-0.9.1/vmime/security/0000755000175000017500000000000011607302336016614 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/security/cert/0000755000175000017500000000000011607302336017551 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/security/cert/certificate.hpp0000644000175000017500000000421411250723263022545 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED #define VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED #include "vmime/types.hpp" namespace vmime { namespace security { namespace cert { /** Identity certificate for a peer. */ class certificate : public object { public: /** Returns the encoded form of this certificate (for example, * X.509 certificates are encoded as ASN.1 DER). * * @return the encoded form of this certificate */ virtual const byteArray getEncoded() const = 0; /** Return the type of this certificate. * * @return the type of this certificate */ virtual const string getType() const = 0; /** Return the version of this certificate. * * @return the version of this certificate */ virtual int getVersion() const = 0; /** Checks if two certificates are the same. * * @param other certificate to compare with * @return true if the two certificates are the same, * false otherwise */ virtual bool equals(ref other) const = 0; }; } // cert } // security } // vmime #endif // VMIME_SECURITY_CERT_CERTIFICATE_HPP_INCLUDED libvmime-0.9.1/vmime/security/cert/X509Certificate.hpp0000644000175000017500000001100211250723263023064 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED #define VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED #include "vmime/security/cert/certificate.hpp" #include "vmime/utility/stream.hpp" #include "vmime/base.hpp" #include "vmime/dateTime.hpp" namespace vmime { namespace security { namespace cert { /** Identity certificate based on X.509 standard. */ class X509Certificate : public certificate { friend class vmime::creator; protected: X509Certificate(); X509Certificate(const X509Certificate&); public: ~X509Certificate(); /** Supported encodings for X.509 certificates. */ enum Format { FORMAT_DER, /**< DER encoding */ FORMAT_PEM /**< PEM encoding */ }; /** Supported digest algorithms (used for fingerprint). */ enum DigestAlgorithm { DIGEST_MD5, /**< MD5 digest */ DIGEST_SHA1 /**< SHA1 digest */ }; /** Imports a DER or PEM encoded X.509 certificate. * * @param is input stream to read data from * @return a X.509 certificate, or NULL if the given data does not * represent a valid certificate */ static ref import(utility::inputStream& is); /** Imports a DER or PEM encoded X.509 certificate. * * @param data points to raw data * @param length size of data * @return a X.509 certificate, or NULL if the given data does not * represent a valid certificate */ static ref import(const byte_t* data, const unsigned int length); /** Exports this X.509 certificate to the specified format. * * @param os output stream into which write data * @param format output format */ void write(utility::outputStream& os, const Format format) const; /** Returns the X.509 certificate's serial number. This is obtained * by the X.509 Certificate 'serialNumber' field. Serial is not * always a 32 or 64bit number. Some CAs use large serial numbers, * thus it may be wise to handle it as something opaque. * * @return serial number of this certificate */ const byteArray getSerialNumber() const; /** Checks if this certificate has the given issuer. * * @param issuer certificate of a possible issuer * @return true if this certificate was issued by the given issuer, * false otherwise */ bool checkIssuer(ref issuer) const; /** Verifies this certificate against a given trusted one. * * @param caCert a certificate that is considered to be trusted one * @return true if the verification succeeded, false otherwise */ bool verify(ref caCert) const; /** Gets the expiration date of this certificate. This is the date * at which this certificate will not be valid anymore. * * @return expiration date of this certificate */ const datetime getExpirationDate() const; /** Gets the activation date of this certificate. This is the date * at which this certificate will be valid. * * @return activation date of this certificate */ const datetime getActivationDate() const; /** Returns the fingerprint of this certificate. * * @return the fingerprint of this certificate */ const byteArray getFingerprint(const DigestAlgorithm algo) const; // Implementation of 'certificate' const byteArray getEncoded() const; const string getType() const; int getVersion() const; bool equals(ref other) const; private: class X509CertificateInternalData* m_data; }; } // cert } // security } // vmime #endif // VMIME_SECURITY_CERT_X509CERTIFICATE_HPP_INCLUDED libvmime-0.9.1/vmime/security/cert/defaultCertificateVerifier.hpp0000644000175000017500000000466211250723263025555 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED #define VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED #include "vmime/security/cert/certificateVerifier.hpp" namespace vmime { namespace security { namespace cert { class X509Certificate; /** Default implementation for certificate verification. */ class defaultCertificateVerifier : public certificateVerifier { private: defaultCertificateVerifier(const defaultCertificateVerifier&); public: defaultCertificateVerifier(); ~defaultCertificateVerifier(); /** Sets a list of X.509 certificates that are trusted. * * @param trustedCerts list of trusted certificates */ void setX509TrustedCerts(const std::vector >& trustedCerts); /** Sets the X.509 root CAs used for certificate verification. * * @param caCerts list of root CAs */ void setX509RootCAs(const std::vector >& caCerts); // Implementation of 'certificateVerifier' void verify(ref chain); private: /** Verify a chain of X.509 certificates. * * @param chain list of X.509 certificates */ void verifyX509(ref chain); std::vector > m_x509RootCAs; std::vector > m_x509TrustedCerts; }; } // cert } // security } // vmime #endif // VMIME_SECURITY_CERT_DEFAULTCERTIFICATEVERIFIER_HPP_INCLUDED libvmime-0.9.1/vmime/security/cert/certificateChain.hpp0000644000175000017500000000440511250723263023512 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED #define VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/security/cert/certificate.hpp" namespace vmime { namespace security { namespace cert { /** An ordered list of certificates, from the subject certificate to * the issuer certificate. */ class certificateChain : public object { public: /** Construct a new certificateChain object given an ordered list * of certificates. * * @param certs chain of certificates */ certificateChain(const std::vector >& certs); /** Return the number of certificates in the chain. * * @return number of certificates in the chain */ unsigned int getCount() const; /** Return the certificate at the specified position. 0 is the * subject certificate, 1 is the issuer's certificate, 2 is * the issuer's issuer, etc. * * @param index position at which to retrieve certificate * @return certificate at the specified position */ ref getAt(const unsigned int index); protected: std::vector > m_certs; }; } // cert } // security } // vmime #endif // VMIME_SECURITY_CERT_CERTIFICATECHAIN_HPP_INCLUDED libvmime-0.9.1/vmime/security/cert/certificateVerifier.hpp0000644000175000017500000000345211250723263024244 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED #define VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/security/cert/certificateChain.hpp" namespace vmime { namespace security { namespace cert { /** Verify that a certificate path issued by a server can be trusted. */ class certificateVerifier : public object { public: /** Verify that the specified certificate chain is trusted. * * @param chain certificate chain * @throw exceptions::certificate_verification_exception if one * or more certificates can not be trusted */ virtual void verify(ref chain) = 0; }; } // cert } // security } // vmime #endif // VMIME_SECURITY_CERT_CERTIFICATEVERIFIER_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/0000755000175000017500000000000011607302336017556 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/security/sasl/SASLMechanismFactory.hpp0000644000175000017500000000660111250723263024211 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_SASLMECHANISMFACTORY_HPP_INCLUDED #define VMIME_SECURITY_SASL_SASLMECHANISMFACTORY_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/base.hpp" #include "vmime/security/sasl/SASLMechanism.hpp" #include namespace vmime { namespace security { namespace sasl { class SASLContext; /** Constructs SASL mechanism objects. */ class SASLMechanismFactory : public object { private: SASLMechanismFactory(); ~SASLMechanismFactory(); class registeredMechanism : public object { public: virtual ref create (ref ctx, const string& name) = 0; }; template class registeredMechanismImpl : public registeredMechanism { public: ref create(ref ctx, const string& name) { return vmime::create (ctx, name); } }; typedef std::map > MapType; MapType m_mechs; public: static SASLMechanismFactory* getInstance(); /** Register a mechanism into this factory, so that subsequent * calls to create return a valid object for this mechanism. * * @param name mechanism name */ template void registerMechanism(const string& name) { m_mechs.insert(MapType::value_type(name, vmime::create >())); } /** Create a mechanism object given its name. * * @param ctx SASL context * @param name mechanism name * @return a new mechanism object * @throw exceptions::no_such_mechanism if no mechanism is * registered for the specified name */ ref create(ref ctx, const string& name); /** Return a list of supported mechanisms. This includes mechanisms * registered using registerMechanism() as well as the ones that * are built-in. * * @return list of supported mechanisms */ const std::vector getSupportedMechanisms() const; /** Test whether an authentication mechanism is supported. * * @param name mechanism name * @return true if the specified mechanism is supported, * false otherwise */ bool isMechanismSupported(const string& name) const; private: #ifdef GSASL_VERSION Gsasl* m_gsaslContext; #else void* m_gsaslContext; #endif // GSASL_VERSION }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_SASLMECHANISMFACTORY_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/SASLSession.hpp0000644000175000017500000001060011250723263022372 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_SASLSESSION_HPP_INCLUDED #define VMIME_SECURITY_SASL_SASLSESSION_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/security/sasl/SASLAuthenticator.hpp" #include "vmime/security/sasl/SASLMechanism.hpp" #include "vmime/security/sasl/SASLSocket.hpp" namespace vmime { namespace security { namespace sasl { class SASLContext; /** An SASL client session. */ class SASLSession : public object { friend class builtinSASLMechanism; friend class SASLSocket; public: ~SASLSession(); /** Construct a new SASL session. * * @param serviceName name of the service using this session * @param ctx SASL context * @param auth authenticator to use for this session * @param mech SASL mechanism */ SASLSession(const string& serviceName, ref ctx, ref auth, ref mech); /** Initialize this SASL session. This must be called before * calling any other method on this object (except accessors). */ void init(); /** Return the authenticator used for this session. This is the * authenticator which has been previously set with a call to * setAuthenticator(). * * @return authenticator object */ ref getAuthenticator(); /** Return the mechanism used for this session. * * @return SASL mechanism */ ref getMechanism(); /** Return the SASL context. * * @return SASL context */ ref getContext(); /** Perform one step of SASL authentication. Accept data from the * server (challenge), process it and return data to be returned * in response to the server. * * @param challenge challenge sent from the server * @param challengeLen length of challenge * @param response response to send to the server (allocated by * this function, free with delete[]) * @param responseLen length of response buffer * @return true if authentication terminated successfully, or * false if the authentication process should continue * @throw exceptions::sasl_exception if an error occured during * authentication (in this case, the values in 'response' and * 'responseLen' are undetermined) */ bool evaluateChallenge (const byte_t* challenge, const int challengeLen, byte_t** response, int* responseLen); /** Return a socket in which transmitted data is integrity * and/or privacy protected, depending on the QOP (Quality of * Protection) negotiated during the SASL authentication. * * @param sok socket to wrap * @return secured socket */ ref getSecuredSocket(ref sok); /** Return the name of the service which is using this * SASL session (eg. "imap"). This value should be returned * by the authenticator when INFO_SERVICE is requested. * * @return service name */ const string getServiceName() const; private: const string m_serviceName; ref m_context; ref m_auth; ref m_mech; #ifdef GSASL_VERSION Gsasl* m_gsaslContext; Gsasl_session* m_gsaslSession; static int gsaslCallback(Gsasl* ctx, Gsasl_session* sctx, Gsasl_property prop); #else void* m_gsaslContext; void* m_gsaslSession; static int gsaslCallback(void* ctx, void* sctx, int prop); #endif // GSASL_VERSION }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_SASLSESSION_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/SASLContext.hpp0000644000175000017500000000651211250723263022402 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_SASLCONTEXT_HPP_INCLUDED #define VMIME_SECURITY_SASL_SASLCONTEXT_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/security/sasl/SASLSession.hpp" #include "vmime/security/sasl/SASLMechanismFactory.hpp" namespace vmime { namespace security { namespace sasl { /** An SASL client context. */ class SASLContext : public object { friend class SASLSession; friend class builtinSASLMechanism; public: ~SASLContext(); /** Construct and initialize a new SASL context. */ SASLContext(); /** Create and initialize a new SASL session. * * @param serviceName name of the service which will use the session * @param auth authenticator object to use during the session * @param mech SASL mechanism * @return a new SASL session */ ref createSession (const string& serviceName, ref auth, ref mech); /** Create an instance of an SASL mechanism. * * @param name mechanism name * @return a new instance of the specified SASL mechanism * @throw exceptions::no_such_mechanism if no mechanism is * registered for the specified name */ ref createMechanism(const string& name); /** Suggests an SASL mechanism among a set of mechanisms * supported by the server. * * @param mechs list of mechanisms * @return suggested mechanism (usually the safest mechanism * supported by both the client and the server) */ ref suggestMechanism (const std::vector >& mechs); /** Helper function for decoding Base64-encoded challenge. * * @param input input buffer * @param output output buffer * @param outputLen length of output buffer */ void decodeB64(const string& input, byte_t** output, int* outputLen); /** Helper function for encoding challenge in Base64. * * @param input input buffer * @param inputLen length of input buffer * @return Base64-encoded challenge */ const string encodeB64(const byte_t* input, const int inputLen); private: static const string getErrorMessage(const string& fname, const int code); #ifdef GSASL_VERSION Gsasl* m_gsaslContext; #else void* m_gsaslContext; #endif // GSASL_VERSION }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_SASLCONTEXT_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/defaultSASLAuthenticator.hpp0000644000175000017500000000472511374031010025126 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_DEFAULTSASLAUTHENTICATOR_HPP_INCLUDED #define VMIME_SECURITY_SASL_DEFAULTSASLAUTHENTICATOR_HPP_INCLUDED #include "vmime/security/sasl/SASLAuthenticator.hpp" #include "vmime/security/defaultAuthenticator.hpp" namespace vmime { namespace security { namespace sasl { /** An authenticator that is capable of providing information * for simple authentication mechanisms (username and password). */ class defaultSASLAuthenticator : public SASLAuthenticator { public: defaultSASLAuthenticator(); ~defaultSASLAuthenticator(); const std::vector > getAcceptableMechanisms (const std::vector >& available, ref suggested) const; const string getUsername() const; const string getPassword() const; const string getHostname() const; const string getAnonymousToken() const; const string getServiceName() const; void setService(ref serv); weak_ref getService() const; void setSASLSession(ref sess); ref getSASLSession() const; void setSASLMechanism(ref mech); ref getSASLMechanism() const; private: defaultAuthenticator m_default; weak_ref m_service; weak_ref m_saslSession; ref m_saslMech; }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_DEFAULTSASLAUTHENTICATOR_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/SASLSocket.hpp0000644000175000017500000000406211314151075022201 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_SASLSOCKET_HPP_INCLUDED #define VMIME_SECURITY_SASL_SASLSOCKET_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/net/socket.hpp" namespace vmime { namespace security { namespace sasl { class SASLSession; /** A socket which provides data integrity and/or privacy protection. */ class SASLSocket : public net::socket { public: SASLSocket(ref sess, ref wrapped); ~SASLSocket(); void connect(const string& address, const port_t port); void disconnect(); bool isConnected() const; void receive(string& buffer); size_type receiveRaw(char* buffer, const size_type count); void send(const string& buffer); void sendRaw(const char* buffer, const size_type count); size_type getBlockSize() const; private: ref m_session; ref m_wrapped; byte_t* m_pendingBuffer; int m_pendingPos; int m_pendingLen; char m_recvBuffer[65536]; }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_SASLSOCKET_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/SASLAuthenticator.hpp0000644000175000017500000000534711250723263023575 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_SASLAUTHENTICATOR_HPP_INCLUDED #define VMIME_SECURITY_SASL_SASLAUTHENTICATOR_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/security/authenticator.hpp" namespace vmime { namespace security { namespace sasl { class SASLMechanism; class SASLSession; /** SASL-aware authenticator. * * Usually, you should not inherit from this class, but instead from the * more convenient defaultSASLAuthenticator class. */ class SASLAuthenticator : public authenticator { public: /** This method is called to allow the client to choose the * authentication mechanisms that will be used. By default, * the most secure mechanisms are chosen. * * @param available available mechanisms * @param suggested suggested mechanism (or NULL if the system * could not suggest a mechanism) * @return ordered list of mechanism to use among the available * mechanisms (from the first to try to the last) */ virtual const std::vector > getAcceptableMechanisms (const std::vector >& available, ref suggested) const = 0; /** Set the SASL session which is using this authenticator. * * @param sess SASL session */ virtual void setSASLSession(ref sess) = 0; /** Set the SASL mechanism which has been selected for the * SASL authentication process. This may be called several times * if the multiple mechanisms are tried by the service which * use this authentication. * * @param mech SASL mechanism */ virtual void setSASLMechanism(ref mech) = 0; }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_SASLAUTHENTICATOR_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/builtinSASLMechanism.hpp0000644000175000017500000000431411250723263024247 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_BUILTINSASLMECHANISM_HPP_INCLUDED #define VMIME_SECURITY_SASL_BUILTINSASLMECHANISM_HPP_INCLUDED #include "vmime/security/sasl/SASLMechanism.hpp" namespace vmime { namespace security { namespace sasl { class SASLContext; /** A built-in authentication mechanism that relies on * the GNU SASL library. */ class builtinSASLMechanism : public SASLMechanism { public: builtinSASLMechanism(ref ctx, const string& name); ~builtinSASLMechanism(); const string getName() const; bool step(ref sess, const byte_t* challenge, const int challengeLen, byte_t** response, int* responseLen); bool isComplete() const; void encode(ref sess, const byte_t* input, const int inputLen, byte_t** output, int* outputLen); void decode(ref sess, const byte_t* input, const int inputLen, byte_t** output, int* outputLen); private: /** SASL context */ ref m_context; /** Mechanism name */ const string m_name; /** Authentication process status. */ bool m_complete; }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_BUILTINSASLMECHANISM_HPP_INCLUDED libvmime-0.9.1/vmime/security/sasl/SASLMechanism.hpp0000644000175000017500000000777411250723263022675 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_SASL_SASLMECHANISM_HPP_INCLUDED #define VMIME_SECURITY_SASL_SASLMECHANISM_HPP_INCLUDED #include "vmime/types.hpp" namespace vmime { namespace security { namespace sasl { class SASLSession; /** An SASL mechanism. */ class SASLMechanism : public object { public: /** Return the name of this mechanism. * * @return mechanism name */ virtual const string getName() const = 0; /** Perform one step of SASL authentication. Accept data from the * server (challenge), process it and return data to be returned * in response to the server. * * @param sess SASL session * @param challenge challenge sent from the server * @param challengeLen length of challenge * @param response response to send to the server (allocated by * this function, free with delete[]) * @param responseLen length of response buffer * @return true if authentication terminated successfully, or * false if the authentication process should continue * @throw exceptions::sasl_exception if an error occured during * authentication (in this case, the values in 'response' and * 'responseLen' are undetermined) */ virtual bool step (ref sess, const byte_t* challenge, const int challengeLen, byte_t** response, int* responseLen) = 0; /** Check whether authentication has completed. If false, more * calls to evaluateChallenge() are needed to complete the * authentication process). * * @return true if the authentication has finished, or false * otherwise */ virtual bool isComplete() const = 0; /** Encode data according to negotiated SASL mechanism. This * might mean that data is integrity or privacy protected. * * @param sess SASL session * @param input input buffer * @param inputLen length of input buffer * @param output output buffer (allocated bu the function, * free with delete[]) * @param outputLen length of output buffer * @throw exceptions::sasl_exception if an error occured during * the encoding of data (in this case, the values in 'output' and * 'outputLen' are undetermined) */ virtual void encode(ref sess, const byte_t* input, const int inputLen, byte_t** output, int* outputLen) = 0; /** Decode data according to negotiated SASL mechanism. This * might mean that data is integrity or privacy protected. * * @param sess SASL session * @param input input buffer * @param inputLen length of input buffer * @param output output buffer (allocated bu the function, * free with delete[]) * @param outputLen length of output buffer * @throw exceptions::sasl_exception if an error occured during * the encoding of data (in this case, the values in 'output' and * 'outputLen' are undetermined) */ virtual void decode(ref sess, const byte_t* input, const int inputLen, byte_t** output, int* outputLen) = 0; }; } // sasl } // security } // vmime #endif // VMIME_SECURITY_SASL_SASLMECHANISM_HPP_INCLUDED libvmime-0.9.1/vmime/security/authenticator.hpp0000644000175000017500000000702111250723263022177 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_AUTHENTICATOR_HPP_INCLUDED #define VMIME_SECURITY_AUTHENTICATOR_HPP_INCLUDED #include "vmime/types.hpp" // Forward declarations namespace vmime { namespace net { class service; } // net } // vmime namespace vmime { namespace security { /** Provides required information for user authentication. The same * information can be requested multiple time (eg. in IMAP, there is a * new connection started each time a folder is open), so the object is * responsible for caching the information to avoid useless interactions * with the user. * * Usually, you should not inherit from this class, but instead from the * more convenient defaultAuthenticator class. * * WARNING: an authenticator should be used with one and ONLY ONE messaging * service at a time. */ class authenticator : public object { public: /** Return the authentication identity (usually, this * is the username). * * @return username * @throw exceptions::no_auth_information if the information * could not be provided */ virtual const string getUsername() const = 0; /** Return the password of the authentication identity. * * @return password * @throw exceptions::no_auth_information if the information * could not be provided */ virtual const string getPassword() const = 0; /** Return the local host name of the machine. * * @return hostname * @throw exceptions::no_auth_information if the information * could not be provided */ virtual const string getHostname() const = 0; /** Return the anonymous token (usually, this is the user's * email address). * * @return anonymous token * @throw exceptions::no_auth_information if the information * could not be provided */ virtual const string getAnonymousToken() const = 0; /** Return the registered service name of the application * service (eg: "imap"). This can be used by GSSAPI or DIGEST-MD5 * mechanisms with SASL. * * @return service name * @throw exceptions::no_auth_information if the information * could not be provided */ virtual const string getServiceName() const = 0; /** Called by the messaging service to allow this authenticator to * know which service is currently using it. This is called just * before the service starts the authentication process. * * @param serv messaging service instance */ virtual void setService(ref serv) = 0; }; } // security } // vmime #endif // VMIME_SECURITY_AUTHENTICATOR_HPP_INCLUDED libvmime-0.9.1/vmime/security/digest/0000755000175000017500000000000011607302336020073 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/security/digest/md5/0000755000175000017500000000000011607302336020560 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/security/digest/md5/md5MessageDigest.hpp0000644000175000017500000000421511250723263024425 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_DIGEST_MD5_MD5MESSAGEDIGEST_HPP_INCLUDED #define VMIME_SECURITY_DIGEST_MD5_MD5MESSAGEDIGEST_HPP_INCLUDED #include "vmime/security/digest/messageDigest.hpp" namespace vmime { namespace security { namespace digest { namespace md5 { class md5MessageDigest : public messageDigest { public: md5MessageDigest(); void update(const byte_t b); void update(const string& s); void update(const byte_t* buffer, const unsigned long len); void update(const byte_t* buffer, const unsigned long offset, const unsigned long len); void finalize(); void finalize(const string& s); void finalize(const byte_t* buffer, const unsigned long len); void finalize(const byte_t* buffer, const unsigned long offset, const unsigned long len); int getDigestLength() const; const byte_t* getDigest() const; void reset(); protected: void init(); void transformHelper(); void transform(); vmime_uint32 m_hash[4]; unsigned long m_byteCount; vmime_uint8 m_block[64]; bool m_finalized; }; } // md5 } // digest } // security } // vmime #endif // VMIME_SECURITY_DIGEST_MD5_MD5MESSAGEDIGEST_HPP_INCLUDED libvmime-0.9.1/vmime/security/digest/sha1/0000755000175000017500000000000011607302336020727 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/security/digest/sha1/sha1MessageDigest.hpp0000644000175000017500000000426111375203172024744 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_DIGEST_SHA1_SHA1MESSAGEDIGEST_HPP_INCLUDED #define VMIME_SECURITY_DIGEST_SHA1_SHA1MESSAGEDIGEST_HPP_INCLUDED #include "vmime/security/digest/messageDigest.hpp" namespace vmime { namespace security { namespace digest { namespace sha1 { class sha1MessageDigest : public messageDigest { public: sha1MessageDigest(); void update(const byte_t b); void update(const string& s); void update(const byte_t* buffer, const unsigned long len); void update(const byte_t* buffer, const unsigned long offset, const unsigned long len); void finalize(); void finalize(const string& s); void finalize(const byte_t* buffer, const unsigned long len); void finalize(const byte_t* buffer, const unsigned long offset, const unsigned long len); int getDigestLength() const; const byte_t* getDigest() const; void reset(); protected: void init(); static void transform(unsigned int state[5], const byte_t buffer[64]); unsigned int m_state[5]; unsigned int m_count[2]; byte_t m_buffer[64]; byte_t m_digest[20]; }; } // sha1 } // digest } // security } // vmime #endif // VMIME_SECURITY_DIGEST_SHA1_SHA1MESSAGEDIGEST_HPP_INCLUDED libvmime-0.9.1/vmime/security/digest/messageDigestFactory.hpp0000644000175000017500000000547711250723263024735 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_DIGEST_MESSAGEDIGESTFACTORY_HPP_INCLUDED #define VMIME_SECURITY_DIGEST_MESSAGEDIGESTFACTORY_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/security/digest/messageDigest.hpp" #include "vmime/utility/stringUtils.hpp" namespace vmime { namespace security { namespace digest { /** Creates instances of message digest algorithms. */ class messageDigestFactory { private: messageDigestFactory(); ~messageDigestFactory(); public: static messageDigestFactory* getInstance(); private: class digestAlgorithmFactory : public object { public: virtual ref create() const = 0; }; template class digestAlgorithmFactoryImpl : public digestAlgorithmFactory { public: ref create() const { return vmime::create (); } }; typedef std::map > MapType; MapType m_algos; public: /** Register a new digest algorithm by its name. * * @param name algorithm name */ template void registerAlgorithm(const string& name) { m_algos.insert(MapType::value_type(utility::stringUtils::toLower(name), vmime::create >())); } /** Create a new algorithm instance from its name. * * @param name algorithm name (eg. "md5") * @return a new algorithm instance for the specified name * @throw exceptions::no_digest_algorithm_available if no algorithm is * registered with this name */ ref create(const string& name); /** Return a list of supported digest algorithms. * * @return list of supported digest algorithms */ const std::vector getSupportedAlgorithms() const; }; } // digest } // security } // vmime #endif // VMIME_SECURITY_DIGEST_MESSAGEDIGESTFACTORY_HPP_INCLUDED libvmime-0.9.1/vmime/security/digest/messageDigest.hpp0000644000175000017500000001027411250723263023374 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_DIGEST_MESSAGEDIGEST_HPP_INCLUDED #define VMIME_SECURITY_DIGEST_MESSAGEDIGEST_HPP_INCLUDED #include "vmime/object.hpp" #include "vmime/types.hpp" namespace vmime { namespace security { namespace digest { /** Computes message digests using standard algorithms, * such as MD5 or SHA. */ class messageDigest : public object { public: /** Updates the digest using the specified string. * * @param s the string with which to update the digest. */ virtual void update(const string& s) = 0; /** Updates the digest using the specified byte. * * @param b the byte with which to update the digest. */ virtual void update(const byte_t b) = 0; /** Updates the digest using the specified array of bytes. * * @param buffer array of bytes * @param len number of bytes to use in the buffer */ virtual void update(const byte_t* buffer, const unsigned long len) = 0; /** Updates the digest using the specified array of bytes, * starting at the specified offset. * * @param buffer array of bytes * @param offset offset to start from in the array of bytes * @param len number of bytes to use, starting at offset */ virtual void update(const byte_t* buffer, const unsigned long offset, const unsigned long len) = 0; /** Completes the hash computation by performing final operations * such as padding. */ virtual void finalize() = 0; /** Completes the hash computation by performing final operations * such as padding. This is equivalent to calling update() and * then finalize(). */ virtual void finalize(const string& s) = 0; /** Completes the hash computation by performing final operations * such as padding. This is equivalent to calling update() and * then finalize(). */ virtual void finalize(const byte_t* buffer, const unsigned long len) = 0; /** Completes the hash computation by performing final operations * such as padding. This is equivalent to calling update() and * then finalize(). */ virtual void finalize(const byte_t* buffer, const unsigned long offset, const unsigned long len) = 0; /** Returns the length of the hash. * This is the length of the array returned by getDigest(). * * @return length of computed hash */ virtual int getDigestLength() const = 0; /** Returns the hash, as computed by the algorithm. * You must call finalize() before using this function, or the * hash will not be correct. * To get the size of the returned array, call getDigestLength(). * * @return computed hash */ virtual const byte_t* getDigest() const = 0; /** Returns the hash as an hexadecimal string. * You must call finalize() before using this function, or the * hash will not be correct. * * @return computed hash, in hexadecimal format */ virtual const string getHexDigest() const; /** Resets the algorithm to its initial state, so that you can * compute a new hash using the same object. */ virtual void reset() = 0; }; } // digest } // security } // vmime #endif // VMIME_SECURITY_DIGEST_MESSAGEDIGEST_HPP_INCLUDED libvmime-0.9.1/vmime/security/defaultAuthenticator.hpp0000644000175000017500000000356311250723263023513 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_SECURITY_DEFAULTAUTHENTICATOR_HPP_INCLUDED #define VMIME_SECURITY_DEFAULTAUTHENTICATOR_HPP_INCLUDED #include "vmime/security/authenticator.hpp" namespace vmime { namespace security { /** An authenticator that can provide some basic information by * reading in the messaging session properties. */ class defaultAuthenticator : public authenticator { public: defaultAuthenticator(); ~defaultAuthenticator(); const string getUsername() const; const string getPassword() const; const string getHostname() const; const string getAnonymousToken() const; const string getServiceName() const; void setService(ref serv); weak_ref getService() const; private: weak_ref m_service; }; } // security } // vmime #endif // VMIME_SECURITY_DEFAULTAUTHENTICATOR_HPP_INCLUDED libvmime-0.9.1/vmime/constants.hpp0000644000175000017500000002326411250723264017502 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free SOFTWARE; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software FOUNDATION; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // along with this PROGRAM; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_CONSTANTS_HPP_INCLUDED #define VMIME_CONSTANTS_HPP_INCLUDED #include #include "vmime/types.hpp" // Remove Windows defines of ERROR and WARNING #ifdef WIN32 #undef ERROR #undef WARNING #endif namespace vmime { /** Constants for media types. */ namespace mediaTypes { // Types extern const string::value_type* const TEXT; extern const string::value_type* const MULTIPART; extern const string::value_type* const MESSAGE; extern const string::value_type* const APPLICATION; extern const string::value_type* const IMAGE; extern const string::value_type* const AUDIO; extern const string::value_type* const VIDEO; // Sub-types extern const string::value_type* const TEXT_PLAIN; extern const string::value_type* const TEXT_HTML; extern const string::value_type* const TEXT_RICHTEXT; extern const string::value_type* const TEXT_ENRICHED; extern const string::value_type* const TEXT_RFC822_HEADERS; // RFC-1892 extern const string::value_type* const TEXT_DIRECTORY; // RFC-2426 extern const string::value_type* const MULTIPART_MIXED; extern const string::value_type* const MULTIPART_RELATED; extern const string::value_type* const MULTIPART_ALTERNATIVE; extern const string::value_type* const MULTIPART_PARALLEL; extern const string::value_type* const MULTIPART_DIGEST; extern const string::value_type* const MULTIPART_REPORT; // RFC-1892 extern const string::value_type* const MESSAGE_RFC822; extern const string::value_type* const MESSAGE_PARTIAL; extern const string::value_type* const MESSAGE_EXTERNAL_BODY; extern const string::value_type* const MESSAGE_DISPOSITION_NOTIFICATION; extern const string::value_type* const APPLICATION_OCTET_STREAM; extern const string::value_type* const IMAGE_JPEG; extern const string::value_type* const IMAGE_GIF; extern const string::value_type* const AUDIO_BASIC; extern const string::value_type* const VIDEO_MPEG; } /** Constants for encoding types. */ namespace encodingTypes { extern const string::value_type* const SEVEN_BIT; extern const string::value_type* const EIGHT_BIT; extern const string::value_type* const BASE64; extern const string::value_type* const QUOTED_PRINTABLE; extern const string::value_type* const BINARY; extern const string::value_type* const UUENCODE; } /** Constants for content disposition types (RFC-2183). */ namespace contentDispositionTypes { extern const string::value_type* const INLINE; extern const string::value_type* const ATTACHMENT; } /** Constants for charsets. */ namespace charsets { extern const string::value_type* const ISO8859_1; extern const string::value_type* const ISO8859_2; extern const string::value_type* const ISO8859_3; extern const string::value_type* const ISO8859_4; extern const string::value_type* const ISO8859_5; extern const string::value_type* const ISO8859_6; extern const string::value_type* const ISO8859_7; extern const string::value_type* const ISO8859_8; extern const string::value_type* const ISO8859_9; extern const string::value_type* const ISO8859_10; extern const string::value_type* const ISO8859_13; extern const string::value_type* const ISO8859_14; extern const string::value_type* const ISO8859_15; extern const string::value_type* const ISO8859_16; extern const string::value_type* const CP_437; extern const string::value_type* const CP_737; extern const string::value_type* const CP_775; extern const string::value_type* const CP_850; extern const string::value_type* const CP_852; extern const string::value_type* const CP_853; extern const string::value_type* const CP_855; extern const string::value_type* const CP_857; extern const string::value_type* const CP_858; extern const string::value_type* const CP_860; extern const string::value_type* const CP_861; extern const string::value_type* const CP_862; extern const string::value_type* const CP_863; extern const string::value_type* const CP_864; extern const string::value_type* const CP_865; extern const string::value_type* const CP_866; extern const string::value_type* const CP_869; extern const string::value_type* const CP_874; extern const string::value_type* const CP_1125; extern const string::value_type* const CP_1250; extern const string::value_type* const CP_1251; extern const string::value_type* const CP_1252; extern const string::value_type* const CP_1253; extern const string::value_type* const CP_1254; extern const string::value_type* const CP_1255; extern const string::value_type* const CP_1256; extern const string::value_type* const CP_1257; extern const string::value_type* const US_ASCII; extern const string::value_type* const UTF_7; extern const string::value_type* const UTF_8; extern const string::value_type* const UTF_16; extern const string::value_type* const UTF_32; extern const string::value_type* const WINDOWS_1250; extern const string::value_type* const WINDOWS_1251; extern const string::value_type* const WINDOWS_1252; extern const string::value_type* const WINDOWS_1253; extern const string::value_type* const WINDOWS_1254; extern const string::value_type* const WINDOWS_1255; extern const string::value_type* const WINDOWS_1256; extern const string::value_type* const WINDOWS_1257; extern const string::value_type* const WINDOWS_1258; } /** Constants for standard field names. */ namespace fields { extern const string::value_type* const RECEIVED; extern const string::value_type* const FROM; extern const string::value_type* const SENDER; extern const string::value_type* const REPLY_TO; extern const string::value_type* const TO; extern const string::value_type* const CC; extern const string::value_type* const BCC; extern const string::value_type* const DATE; extern const string::value_type* const SUBJECT; extern const string::value_type* const ORGANIZATION; extern const string::value_type* const USER_AGENT; extern const string::value_type* const DELIVERED_TO; extern const string::value_type* const RETURN_PATH; extern const string::value_type* const MIME_VERSION; extern const string::value_type* const MESSAGE_ID; extern const string::value_type* const CONTENT_TYPE; extern const string::value_type* const CONTENT_TRANSFER_ENCODING; extern const string::value_type* const CONTENT_DESCRIPTION; extern const string::value_type* const CONTENT_DISPOSITION; extern const string::value_type* const CONTENT_ID; extern const string::value_type* const CONTENT_LOCATION; extern const string::value_type* const IN_REPLY_TO; extern const string::value_type* const REFERENCES; extern const string::value_type* const X_MAILER; extern const string::value_type* const X_PRIORITY; // RFC-3798: Message Disposition Notification extern const string::value_type* const ORIGINAL_MESSAGE_ID; extern const string::value_type* const DISPOSITION_NOTIFICATION_TO; extern const string::value_type* const DISPOSITION_NOTIFICATION_OPTIONS; extern const string::value_type* const DISPOSITION; extern const string::value_type* const FAILURE; extern const string::value_type* const ERROR; extern const string::value_type* const WARNING; extern const string::value_type* const ORIGINAL_RECIPIENT; extern const string::value_type* const FINAL_RECIPIENT; extern const string::value_type* const REPORTING_UA; extern const string::value_type* const MDN_GATEWAY; } /** Constants for disposition action modes (RFC-3978). */ namespace dispositionActionModes { /** User implicitely displayed or deleted the message (filter or * any other automatic action). */ extern const string::value_type* const MANUAL; /** User explicitely displayed or deleted the message (manual action). */ extern const string::value_type* const AUTOMATIC; } /** Constants for disposition sending modes (RFC-3798). */ namespace dispositionSendingModes { /** The MDN was sent because the MUA had previously been configured * to do so automatically. */ extern const string::value_type* const SENT_MANUALLY; /** User explicitly gave permission for this particular MDN to be sent. */ extern const string::value_type* const SENT_AUTOMATICALLY; } /** Constants for disposition types (RFC-3798). */ namespace dispositionTypes { /** Message has been displayed to the user. */ extern const string::value_type* const DISPLAYED; /** Message has been deleted without being displayed. */ extern const string::value_type* const DELETED; /** Message has been denied. */ extern const string::value_type* const DENIED; } /** Constants for disposition modifiers (RFC-3798). */ namespace dispositionModifiers { extern const string::value_type* const ERROR; } } #endif // VMIME_CONSTANTS_HPP_INCLUDED libvmime-0.9.1/vmime/fileAttachment.hpp0000644000175000017500000001143211314151075020404 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_FILEATTACHMENT_HPP_INCLUDED #define VMIME_FILEATTACHMENT_HPP_INCLUDED #include "vmime/defaultAttachment.hpp" #include "vmime/dateTime.hpp" namespace vmime { /** Attachment of type 'file'. */ class fileAttachment : public defaultAttachment { public: fileAttachment(const string& filepath, const mediaType& type); fileAttachment(const string& filepath, const mediaType& type, const text& desc); fileAttachment(const string& filepath, const mediaType& type, const text& desc, const encoding& enc); fileAttachment(ref is, const word& filename, const mediaType& type); fileAttachment(ref is, const word& filename, const mediaType& type, const text& desc); fileAttachment(ref is, const word& filename, const mediaType& type, const text& desc, const encoding& enc); /** Stores information about a file attachment. */ class fileInfo { public: fileInfo(); ~fileInfo(); /** Check whether the 'filename' property is present. * * @return true if the 'filename' property is set, * false otherwise */ bool hasFilename() const; /** Return the value of the 'filename' property. * * @return file name */ const word& getFilename() const; /** Set the value of the 'filename' property. * * @param name file name */ void setFilename(const string& name); /** Set the value of the 'filename' property. * * @param name file name */ void setFilename(const word& name); /** Check whether the 'creation-date' property is present. * * @return true if the 'creation-date' property is set, * false otherwise */ bool hasCreationDate() const; /** Return the value of the 'creation-date' property. * * @return file creation time */ const datetime& getCreationDate() const; /** Set the value of the 'creation-date' property. * * @param date file creation time */ void setCreationDate(const datetime& date); /** Check whether the 'modification-date' property is present. * * @return true if the 'modification-date' property is set, * false otherwise */ bool hasModificationDate() const; /** Return the value of the 'modification-date' property. * * @return file modification time */ const datetime& getModificationDate() const; /** Set the value of the 'modification-date' property. * * @param date file modification time */ void setModificationDate(const datetime& date); /** Check whether the 'read-date' property is set. * * @return true if the 'read-date' property is set, * false otherwise */ bool hasReadDate() const; /** Return the value of the 'read-date' property. * * @return file access time */ const datetime& getReadDate() const; /** Set the value of the 'read-date' property. * * @param date file access time */ void setReadDate(const datetime& date); /** Check whether the value of the 'size' property is set. * * @return true if the 'size' property is set, * false otherwise */ bool hasSize() const; /** Return the value of the 'size' property. * * @return file size */ unsigned int getSize() const; /** Set the value of the 'size' property. * * @param size file size */ void setSize(const unsigned int& size); private: word* m_filename; unsigned int* m_size; datetime* m_creationDate; datetime* m_modifDate; datetime* m_readDate; }; const fileInfo& getFileInfo() const; fileInfo& getFileInfo(); private: void setData(const string& filepath); void setData(ref is); fileInfo m_fileInfo; void generatePart(ref part) const; }; } // vmime #endif // VMIME_FILEATTACHMENT_HPP_INCLUDED libvmime-0.9.1/vmime/word.hpp0000644000175000017500000001044411333330451016427 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_WORD_HPP_INCLUDED #define VMIME_WORD_HPP_INCLUDED #include "vmime/headerFieldValue.hpp" #include "vmime/charset.hpp" namespace vmime { /** A class that encapsulates an encoded-word (RFC-2047): * some text encoded into one specified charset. */ class word : public headerFieldValue { friend class text; public: word(); word(const word& w); word(const string& buffer); // Defaults to locale charset word(const string& buffer, const charset& charset); /** Return the raw data for this encoded word. * * @return raw data buffer */ const string& getBuffer() const; /** Return the raw data for this encoded word. * * @return raw data buffer */ string& getBuffer(); /** Tests whether this word is empty. * * @return true if the buffer is empty, false otherwise */ bool isEmpty() const; /** Set the raw data for this encoded word. * * @param buffer raw data buffer */ void setBuffer(const string& buffer); /** Return the charset of this word. * * @return charset for this word */ const charset& getCharset() const; /** Set the charset of this word. * * @param ch charset of this word */ void setCharset(const charset& ch); word& operator=(const word& w); word& operator=(const string& s); bool operator==(const word& w) const; bool operator!=(const word& w) const; /** Return the contained text converted to the specified charset. * * @param dest output charset * @return word converted to the specified charset */ const string getConvertedText(const charset& dest) const; /** Replace data in this word by data in other word. * * @param other other word to copy data from */ void copyFrom(const component& other); /** Clone this word. * * @return a copy of this word */ ref clone() const; #ifndef VMIME_BUILDING_DOC class generatorState { public: generatorState() : isFirstWord(true), prevWordIsEncoded(false), lastCharIsSpace(false) { } bool isFirstWord; bool prevWordIsEncoded; bool lastCharIsSpace; }; #endif using component::parse; using component::generate; void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; void generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos, const int flags, generatorState* state) const; const std::vector > getChildComponents() const; private: static ref parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition, bool prevIsEncoded, bool* isEncoded, bool isFirst); static const std::vector > parseMultiple(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition); // The "m_buffer" of this word holds the data, and this data is encoded // in the specified "m_charset". string m_buffer; charset m_charset; }; } // vmime #endif // VMIME_WORD_HPP_INCLUDED libvmime-0.9.1/vmime/parameterizedHeaderField.hpp0000644000175000017500000001374011250723264022375 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PARAMETERIZEDHEADERFIELD_HPP_INCLUDED #define VMIME_PARAMETERIZEDHEADERFIELD_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldFactory.hpp" #include "vmime/parameter.hpp" #include "vmime/exception.hpp" namespace vmime { /** A header field that can also contain parameters (name=value pairs). * Parameters can be created using vmime::parameterFactory. */ class parameterizedHeaderField : virtual public headerField { friend class vmime::creator; // create ref protected: // Protected constructor to prevent the user from creating // new objects without using 'headerFieldFactory' parameterizedHeaderField(); public: ~parameterizedHeaderField(); void copyFrom(const component& other); parameterizedHeaderField& operator=(const parameterizedHeaderField& other); /** Checks whether (at least) one parameter with this name exists. * * @return true if at least one parameter with the specified name * exists, or false otherwise */ bool hasParameter(const string& paramName) const; /** Find the first parameter that matches the specified name. * If no parameter is found, an exception is thrown. * * @throw exceptions::no_such_parameter if no parameter with this name exists * @return first parameter with the specified name */ ref findParameter(const string& paramName) const; /** Find the first parameter that matches the specified name. * If no parameter is found, one will be created and inserted into * the parameter list. * * @return first parameter with the specified name or a new field * if no parameter is found */ ref getParameter(const string& paramName); /** Add a parameter at the end of the list. * * @param param parameter to append */ void appendParameter(ref param); /** Insert a new parameter before the specified parameter. * * @param beforeParam parameter before which the new parameter will be inserted * @param param parameter to insert * @throw exceptions::no_such_parameter if the parameter is not in the list */ void insertParameterBefore(ref beforeParam, ref param); /** Insert a new parameter before the specified position. * * @param pos position at which to insert the new parameter (0 to insert at * the beginning of the list) * @param param parameter to insert */ void insertParameterBefore(const int pos, ref param); /** Insert a new parameter after the specified parameter. * * @param afterParam parameter after which the new parameter will be inserted * @param param parameter to insert * @throw exceptions::no_such_parameter if the parameter is not in the list */ void insertParameterAfter(ref afterParam, ref param); /** Insert a new parameter after the specified position. * * @param pos position of the parameter before the new parameter * @param param parameter to insert */ void insertParameterAfter(const int pos, ref param); /** Remove the specified parameter from the list. * * @param param parameter to remove * @throw exceptions::no_such_parameter if the parameter is not in the list */ void removeParameter(ref param); /** Remove the parameter at the specified position. * * @param pos position of the parameter to remove */ void removeParameter(const int pos); /** Remove all parameters from the list. */ void removeAllParameters(); /** Return the number of parameters in the list. * * @return number of parameters */ int getParameterCount() const; /** Tests whether the list of parameters is empty. * * @return true if there is no parameter, false otherwise */ bool isEmpty() const; /** Return the parameter at the specified position. * * @param pos position * @return parameter at position 'pos' */ const ref getParameterAt(const int pos); /** Return the parameter at the specified position. * * @param pos position * @return parameter at position 'pos' */ const ref getParameterAt(const int pos) const; /** Return the parameter list. * * @return list of parameters */ const std::vector > getParameterList() const; /** Return the parameter list. * * @return list of parameters */ const std::vector > getParameterList(); private: std::vector > m_params; public: using headerField::parse; using headerField::generate; void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; const std::vector > getChildComponents() const; }; } // vmime #endif // VMIME_PARAMETERIZEDHEADERFIELD_HPP_INCLUDED libvmime-0.9.1/vmime/address.hpp0000644000175000017500000000470611250723264017113 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_ADDRESS_HPP_INCLUDED #define VMIME_ADDRESS_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" namespace vmime { /** Abstract class representing a mailbox or a group of mailboxes. * * This class define a common behaviour for the mailbox * and mailboxGroup classes. */ class address : public headerFieldValue { friend class addressList; protected: address(); public: /** Check whether this address is empty (no mailboxes specified * if this is a mailboxGroup -or- no email specified if this is * a mailbox). * * @return true if this address is empty */ virtual bool isEmpty() const = 0; /** Test whether this is object is a mailboxGroup. * * @return true if this is a mailboxGroup, false otherwise */ virtual bool isGroup() const = 0; virtual ref clone() const = 0; protected: /** Parse an address from an input buffer. * * @param buffer input buffer * @param position position in the input buffer * @param end end position in the input buffer * @param newPosition will receive the new position in the input buffer * @return a new address object, or null if no more address is available in the input buffer */ static ref
parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition); }; } // vmime #endif // VMIME_ADDRESS_HPP_INCLUDED libvmime-0.9.1/vmime/contentDispositionField.hpp0000644000175000017500000000703011250723264022322 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_CONTENTDISPOSITIONFIELD_HPP_INCLUDED #define VMIME_CONTENTDISPOSITIONFIELD_HPP_INCLUDED #include "vmime/parameterizedHeaderField.hpp" #include "vmime/contentDisposition.hpp" #include "vmime/dateTime.hpp" #include "vmime/word.hpp" namespace vmime { class contentDispositionField : public parameterizedHeaderField { friend class vmime::creator; // create ref protected: contentDispositionField(); contentDispositionField(contentDispositionField&); public: /** Return the value of the "creation-date" parameter. * * @return value of the "creation-date" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const datetime getCreationDate() const; /** Set the value of the "creation-date" parameter. * * @param creationDate new value for the "creation-date" parameter */ void setCreationDate(const datetime& creationDate); /** Return the value of the "modification-date" parameter. * * @return value of the "modification-date" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const datetime getModificationDate() const; /** Set the value of the "modification-date" parameter. * * @param modificationDate new value for the "modification-date" parameter */ void setModificationDate(const datetime& modificationDate); /** Return the value of the "read-date" parameter. * * @return value of the "read-date" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const datetime getReadDate() const; /** Set the value of the "read-date" parameter. * * @param readDate new value for the "read-date" parameter */ void setReadDate(const datetime& readDate); /** Return the value of the "filename" parameter. * * @return value of the "filename" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const word getFilename() const; /** Set the value of the "filename" parameter. * * @param filename new value for the "filename" parameter */ void setFilename(const word& filename); /** Return the value of the "size" parameter. * * @return value of the "size" parameter * @throw exceptions::no_such_parameter if the parameter does not exist */ const string getSize() const; /** Set the value of the "size" parameter. * * @param size new value for the "size" parameter */ void setSize(const string& size); }; } // vmime #endif // VMIME_CONTENTDISPOSITIONFIELD_HPP_INCLUDED libvmime-0.9.1/vmime/dateTime.hpp0000644000175000017500000001311011250723264017207 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_DATETIME_HPP_INCLUDED #define VMIME_DATETIME_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" #include namespace vmime { /** Date and time (basic type). */ class datetime : public headerFieldValue { public: // Constructors datetime(); datetime(const int year, const int month, const int day); datetime(const int year, const int month, const int day, const int hour, const int minute, const int second, const int zone = GMT); datetime(const datetime& d); datetime(const string& date); datetime(const time_t t, const int zone = GMT); // Destructor ~datetime(); // Some time zones (in minutes) enum TimeZones { GMT_12 = -720, // GMT-12h GMT_11 = -660, // GMT-11h GMT_10 = -600, // GMT-10h GMT_9 = -540, // GMT-9h GMT_8 = -480, // GMT-8h GMT_7 = -420, // GMT-7h GMT_6 = -360, // GMT-6h GMT_5 = -300, // GMT-5h GMT_4 = -240, // GMT-4h GMT_3 = -180, // GMT-3h GMT_2 = -120, // GMT-2h GMT_1 = -60, // GMT-1h GMT = 0, // GMT GMT1 = 60, // GMT+1h GMT2 = 120, // GMT+2h GMT3 = 180, // GMT+3h GMT4 = 240, // GMT+4h GMT5 = 300, // GMT+5h GMT6 = 360, // GMT+6h GMT7 = 420, // GMT+7h GMT8 = 480, // GMT+8h GMT9 = 540, // GMT+9h GMT10 = 600, // GMT+10h GMT11 = 660, // GMT+11h GMT12 = 720, // GMT+12h UT = GMT, // Universal Time EST = GMT_5, // Eastern EDT = GMT_4, CST = GMT_6, // Central CDT = GMT_5, MST = GMT_7, // Mountain MDT = GMT_6, PST = GMT_8, // Pacific PDT = GMT_7, // Military time zones A = GMT_1, B = GMT_2, C = GMT_3, D = GMT_4, E = GMT_5, F = GMT_6, G = GMT_7, H = GMT_8, I = GMT_9, // J not used K = GMT_10, L = GMT_11, M = GMT_12, N = GMT1, O = GMT2, P = GMT3, Q = GMT4, R = GMT5, S = GMT6, T = GMT7, U = GMT8, V = GMT9, W = GMT10, X = GMT11, Y = GMT12, Z = GMT }; // Months list enum Months { // Long JANUARY = 1, FEBRUARY = 2, MARCH = 3, APRIL = 4, MAY = 5, JUNE = 6, JULY = 7, AUGUST = 8, SEPTEMBER = 9, OCTOBER = 10, NOVEMBER = 11, DECEMBER = 12, // Short JAN = 1, FEB = 2, MAR = 3, APR = 4, JUN = 6, JUL = 7, AUG = 8, SEP = 9, OCT = 10, NOV = 11, DEC = 12 }; // Days of week list enum DaysOfWeek { // Long SUNDAY = 0, MONDAY = 1, TUESDAY = 2, WEDNESDAY = 3, THURSDAY = 4, FRIDAY = 5, SATURDAY = 6, // Short SUN = 0, MON = 1, TUE = 2, WED = 3, THU = 4, FRI = 5, SAT = 6 }; private: // Date components int m_year; int m_month; int m_day; // Time components int m_hour; int m_minute; int m_second; int m_zone; public: // Get int getYear() const; int getMonth() const; int getDay() const; int getHour() const; int getMinute() const; int getSecond() const; int getZone() const; int getWeekDay() const; int getWeek() const; void getTime(int& hour, int& minute, int& second, int& zone) const; void getTime(int& hour, int& minute, int& second) const; void getDate(int& year, int& month, int& day) const; // Set void setYear(const int year); void setMonth(const int month); void setDay(const int day); void setHour(const int hour); void setMinute(const int minute); void setSecond(const int second); void setZone(const int zone); void setTime(const int hour = 0, const int minute = 0, const int second = 0, const int zone = GMT); void setDate(const int year, const int month, const int day); // Assignment datetime& operator=(const datetime& other); datetime& operator=(const string& s); void copyFrom(const component& other); ref clone() const; // Comparison bool operator==(const datetime& other) const; bool operator!=(const datetime& other) const; bool operator<(const datetime& other) const; bool operator<=(const datetime& other) const; bool operator>(const datetime& other) const; bool operator>=(const datetime& other) const; // Current date and time static const datetime now(); const std::vector > getChildComponents() const; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_DATETIME_HPP_INCLUDED libvmime-0.9.1/vmime/attachment.hpp0000644000175000017500000000612111250723264017607 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_ATTACHMENT_HPP_INCLUDED #define VMIME_ATTACHMENT_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/bodyPart.hpp" #include "vmime/mediaType.hpp" #include "vmime/text.hpp" #include "vmime/contentHandler.hpp" #include "vmime/encoding.hpp" namespace vmime { /** Base class for all types of attachment. */ class attachment : public object { friend class messageBuilder; friend class messageParser; friend class attachmentHelper; protected: attachment() { } public: virtual ~attachment() { } /** Return the media type of this attachment. * * @return content type of the attachment */ virtual const mediaType getType() const = 0; /** Return the description of this attachment. * * @return attachment description, or an empty text * if no description is available */ virtual const text getDescription() const = 0; /** Return the (file) name of this attachment. * * @return attachment name, or an empty word if no * name is available */ virtual const word getName() const = 0; /** Return the data contained in this attachment. * * @return attachment data */ virtual const ref getData() const = 0; /** Return the encoding used for this attachment. * * @return attachment data encoding */ virtual const encoding getEncoding() const = 0; /** Return the part in which the attachment has been found. * This can be a vmime::bodyPart or a vmime::net::part object. * * @return attachment part or NULL if the attachment is not * attached to a part */ virtual ref getPart() const = 0; /** Return the header of the attachment part. * * @return attachment part header or NULL if the attachment * is not attached to a part */ virtual ref getHeader() const = 0; protected: /** Generate the attachment in the specified body part. * * @param parent body part in which to generate the attachment */ virtual void generateIn(ref parent) const = 0; }; } // vmime #endif // VMIME_ATTACHMENT_HPP_INCLUDED libvmime-0.9.1/vmime/bodyPart.hpp0000644000175000017500000000560511376237655017266 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_BODYPART_HPP_INCLUDED #define VMIME_BODYPART_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" #include "vmime/header.hpp" #include "vmime/body.hpp" namespace vmime { /** A MIME part. */ class bodyPart : public component { friend class body; public: bodyPart(); bodyPart(weak_ref parentPart); /** Return the header section of this part. * * @return header section */ const ref getHeader() const; /** Return the header section of this part. * * @return header section */ ref
getHeader(); /** Return the body section of this part. * * @return body section */ const ref getBody() const; /** Return the body section of this part. * * @return body section */ ref getBody(); /** Return the parent part of this part. * * @return parent part or NULL if not known */ ref getParentPart(); /** Return the parent part of this part (const version). * * @return parent part or NULL if not known */ ref getParentPart() const; ref clone() const; void copyFrom(const component& other); bodyPart& operator=(const bodyPart& other); const std::vector > getChildComponents() const; private: ref
m_header; ref m_body; weak_ref m_parent; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_BODYPART_HPP_INCLUDED libvmime-0.9.1/vmime/headerField.hpp0000644000175000017500000000747511250723264017670 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_HEADERFIELD_HPP_INCLUDED #define VMIME_HEADERFIELD_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" #include "vmime/headerFieldValue.hpp" namespace vmime { /** Base class for header fields. */ class headerField : public component { friend class headerFieldFactory; friend class header; friend class vmime::creator; // create ref protected: // Protected constructor to prevent the user from creating // new objects without using 'headerFieldFactory' headerField(); headerField(const string& fieldName); public: ~headerField(); ref clone() const; void copyFrom(const component& other); headerField& operator=(const headerField& other); const std::vector > getChildComponents() const; /** Sets the name of this field. * * @param name field name (eg: "From" or "X-MyField"). */ void setName(const string& name); /** Return the name of this field. * * @return field name */ const string getName() const; /** Check whether this field is a custom (non-standard) field. * Custom fields have a name beginning with "X-". * * @return true if the field is a custom field, false otherwise */ bool isCustom() const; /** Return the read-only value object attached to this field. * * @return read-only value object */ virtual ref getValue() const; /** Return the value object attached to this field. * * @return value object */ virtual ref getValue(); /** Set the value of this field. * * @param value new value */ virtual void setValue(ref value); /** Set the value of this field by cloning the specified value. * * @param value new value */ virtual void setValueConst(ref value); /** Set the value of this field (reference version). * The value will be cloned. * * @param value new value */ virtual void setValue(const headerFieldValue& value); /** Set the value of this field given a character string. * * @param value value string to parse */ void setValue(const string& value); using component::parse; using component::generate; void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; protected: static ref parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); string m_name; ref m_value; }; } // vmime #endif // VMIME_HEADERFIELD_HPP_INCLUDED libvmime-0.9.1/vmime/utility/0000755000175000017500000000000011607302336016450 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/utility/childProcess.hpp0000644000175000017500000000535511314151075021610 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_CHILDPROCESS_HPP_INCLUDED #define VMIME_UTILITY_CHILDPROCESS_HPP_INCLUDED #include "vmime/utility/stream.hpp" #include "vmime/utility/file.hpp" #include namespace vmime { namespace utility { /** Spawn a process and redirect its standard input * and/or standard output. */ class childProcess : public object { public: virtual ~childProcess() { } /** Flags used with start(). */ enum Flags { FLAG_REDIRECT_STDIN = (1 << 0), FLAG_REDIRECT_STDOUT = (1 << 1) }; /** Start the child process. * * @param args list of arguments * @param flags one or more childProcess::Flags * @throws exceptions::system_error if the an error occurs * before the process can be started */ virtual void start(const std::vector args, const int flags = 0) = 0; /** Return a wrapper to the child process standard input. * * @return output stream wrapper for child's stdin */ virtual ref getStdIn() = 0; /** Return a wrapper to the child process standard output. * * @return input stream wrapper for child's stdout */ virtual ref getStdOut() = 0; /** Wait for the process to finish. * * @throws exceptions::system_error if the process does * not exit normally */ virtual void waitForFinish() = 0; }; /** Create 'childProcess' objects. */ class childProcessFactory : public object { public: virtual ~childProcessFactory() { } /** Create a new child process. * * @param path full path of the process executable file */ virtual ref create(const utility::file::path& path) const = 0; }; } // utility } // vmime #endif // VMIME_UTILITY_CHILDPROCESS_HPP_INCLUDED libvmime-0.9.1/vmime/utility/random.hpp0000644000175000017500000000417711250723263020452 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_RANDOM_HPP_INCLUDED #define VMIME_UTILITY_RANDOM_HPP_INCLUDED #include "vmime/types.hpp" namespace vmime { namespace utility { /** Pseudo-random number generator. */ class random { public: /** Return a new random number. * * @return random number */ static unsigned int getNext(); /** Return the current time as a number (may be used to * build "random" strings). * * @return time as a number */ static unsigned int getTime(); /** Return the current process number (may be user to * build "random" strings). * * @return process number */ static unsigned int getProcess(); /** Return a random character string with the specified length. * * @param length length of the string to generate * @param randomChars list of characters to use * @return random string */ static const string getString(const int length, const string& randomChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); protected: static unsigned int m_next; }; } // utility } // vmime #endif // VMIME_UTILITY_RANDOM_HPP_INCLUDED libvmime-0.9.1/vmime/utility/smartPtr.hpp0000644000175000017500000002410011250723263020772 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_SMARTPTR_HPP_INCLUDED #define VMIME_UTILITY_SMARTPTR_HPP_INCLUDED #include // Forward reference to 'object' namespace vmime { class object; } namespace vmime { namespace utility { /** Simple auto-delete pointer. */ template class auto_ptr { private: T* const m_ptr; public: auto_ptr(T* const ptr) : m_ptr(ptr) { } ~auto_ptr() { delete (m_ptr); } operator T*() { return (m_ptr); } T* operator ->() { return (m_ptr); } T& operator *() { return (*m_ptr); } }; /** Manage the life cycle of an object. */ class refManager { protected: refManager() {} public: virtual ~refManager() {} /** Create a ref manager for the specified object. * * @return a new manager */ static refManager* create(object* obj); /** Add a strong reference to the managed object. */ virtual bool addStrong() = 0; /** Release a strong reference to the managed object. * If it is the last reference, the object is destroyed. */ virtual void releaseStrong() = 0; /** Add a weak reference to the managed object. */ virtual void addWeak() = 0; /** Release a weak reference to the managed object. * If it is the last weak reference, the manager is destroyed. */ virtual void releaseWeak() = 0; /** Return a raw pointer to the managed object. * * @return pointer to the managed object */ virtual object* getObject() = 0; /** Return the number of strong refs to this object. * For debugging purposes only. * * @return strong reference count */ virtual long getStrongRefCount() const = 0; /** Return the number of weak refs to this object. * For debugging purposes only. * * @return weak reference count */ virtual long getWeakRefCount() const = 0; protected: void deleteObjectImpl(object* obj); }; /** Null reference. */ class null_ref { private: int foo; }; template class weak_ref; /** Shared ownership (strong reference to an object). */ template class ref { public: template friend class ref; template friend class weak_ref; ref() : m_ptr(0) { } ref(const ref& r) : m_ptr(0) { attach(r); } ref(const null_ref&) : m_ptr(0) { } virtual ~ref() throw() { detach(); } // Allow creating NULL ref (NULL casts to anything*) ref(class null_pointer*) : m_ptr(0) { } // Access to wrapped object // operator const T*() const { return m_ptr; } operator const void*() const { return m_ptr; } T& operator *() { return *m_ptr; } const T& operator *() const { return *m_ptr; } T* operator ->() { return m_ptr; } const T* operator ->() const { return m_ptr; } const T* get() const { return m_ptr; } T* get() { return m_ptr; } // dynamic_cast template ref dynamicCast() const { U* p = dynamic_cast (const_cast (m_ptr)); if (!p) return ref (); if (m_ptr) m_ptr->getRefManager()->addStrong(); return ref ::fromPtrImpl(p); } // static_cast template ref staticCast() const { U* p = static_cast (const_cast (m_ptr)); if (!p) return ref (); if (m_ptr) m_ptr->getRefManager()->addStrong(); return ref ::fromPtrImpl(p); } // const_cast template ref constCast() const { U* p = const_cast (m_ptr); if (!p) return ref (); if (m_ptr) m_ptr->getRefManager()->addStrong(); return ref ::fromPtrImpl(p); } // Implicit downcast template operator ref () const { if (m_ptr) m_ptr->getRefManager()->addStrong(); ref r; r.m_ptr = m_ptr; // will type check at compile-time (prevent from implicit upcast) return r; } template operator ref () { if (m_ptr) m_ptr->getRefManager()->addStrong(); ref r; r.m_ptr = m_ptr; // will type check at compile-time (prevent from implicit upcast) return r; } template ref & operator=(const ref & other) { U* ptr = other.m_ptr; // will type check at compile-time (prevent from implicit upcast) if (ptr) ptr->getRefManager()->addStrong(); detach(); m_ptr = ptr; return *this; } // Implicit non-const => const conversion operator ref () const { if (m_ptr) m_ptr->getRefManager()->addStrong(); #if defined(_MSC_VER) // VC++ compiler bug (stack overflow) ref r; r.m_ptr = m_ptr; return r; #else return ref ::fromPtrImpl(m_ptr); #endif // defined(_MSC_VER) } // Copy ref& operator=(const ref& p) { attach(p); return *this; } // NULL-pointer comparison bool operator==(const class null_pointer*) const { return m_ptr == 0; } bool operator!=(const class null_pointer*) const { return m_ptr != 0; } bool operator==(const null_ref&) const { return m_ptr == 0; } bool operator!=(const null_ref&) const { return m_ptr != 0; } /** Create a ref<> from a raw pointer. * * WARNING: you should use this function only if you know what * you are doing. In general, you should create ref objects using * vmime::create(). * * When this function returns, the pointer is owned by the ref, * you should not attempt to delete it manually. * * @param ptr raw pointer to encapsulate * @return a ref which encapsulates the specified raw pointer */ static ref fromPtr(T* const ptr) { return ref ::fromPtrImpl(ptr); } static ref fromPtrConst(const T* const ptr) { return ref ::fromPtrImpl(ptr); } static ref fromWeak(weak_ref wr) { refManager* mgr = wr.getManager(); if (mgr && mgr->addStrong()) return ref ::fromPtrImpl(dynamic_cast (mgr->getObject())); else return ref (); } static ref fromWeakConst(weak_ref wr) { refManager* mgr = wr.getManager(); if (mgr && mgr->addStrong()) return ref ::fromPtrImpl(dynamic_cast (mgr->getObject())); else return ref (); } protected: template static ref fromPtrImpl(U* ptr) { ref r; r.m_ptr = ptr; return r; } void detach() { if (m_ptr) { m_ptr->getRefManager()->releaseStrong(); m_ptr = 0; } } template void attach(U* const ptr) { if (ptr) ptr->getRefManager()->addStrong(); detach(); m_ptr = ptr; } template void attach(const ref & r) { if (r.m_ptr) r.m_ptr->getRefManager()->addStrong(); detach(); m_ptr = r.m_ptr; } private: T* m_ptr; }; template bool operator==(const ref & a, const ref & b) { return (a.get() == b.get()); } template bool operator!=(const ref & a, const ref & b) { return (a.get() != b.get()); } template bool operator==(const ref & a, T* const p) { return (a.get() == p); } template bool operator!=(const ref & a, T* const p) { return (a.get() != p); } template bool operator==(T* const p, const ref & a) { return (a.get() == p); } template bool operator!=(T* const p, const ref & a) { return (a.get() != p); } template bool operator==(const null_ref&, const ref & r) { return (r.get() == 0); } template bool operator!=(const null_ref&, const ref & r) { return (r.get() != 0); } /** Weak reference. * Avoid circular references. */ template class weak_ref { public: template friend class weak_ref; weak_ref() : m_mgr(0) { } weak_ref(const ref & r) : m_mgr(0) { attach(r); } weak_ref(const weak_ref& r) : m_mgr(0) { attach(r); } weak_ref(const null_ref&) : m_mgr(0) { } weak_ref(class null_pointer*) : m_mgr(0) { } ~weak_ref() { detach(); } /** Return the manager for the object. * * @return pointer to the object which manages the object * or NULL if the weak reference points to nothing */ refManager* getManager() { return m_mgr; } /** Try to acquire a strong reference to the object (const version). * * @return strong reference or null reference if the * object is not available anymore */ ref acquire() const { return ref ::fromWeakConst(*this); } /** Try to acquire a strong reference to the object. * * @return strong reference or null reference if the * object is not available anymore */ ref acquire() { return ref ::fromWeak(*this); } // Implicit non-const => const conversion operator weak_ref () const { if (m_mgr) m_mgr->addWeak(); weak_ref r; r.m_mgr = m_mgr; return r; } template operator weak_ref () const { if (m_mgr) m_mgr->addWeak(); weak_ref r; r.m_mgr = m_mgr; return r; } // Copy weak_ref& operator=(const weak_ref& p) { attach(p); return *this; } private: void detach() { if (m_mgr) { m_mgr->releaseWeak(); m_mgr = 0; } } void attach(const ref & r) { if (r.m_ptr) r.m_ptr->getRefManager()->addWeak(); detach(); if (r.m_ptr) m_mgr = r.m_ptr->getRefManager(); else m_mgr = 0; } void attach(const weak_ref& r) { if (r.m_mgr) r.m_mgr->addWeak(); detach(); m_mgr = r.m_mgr; } refManager* m_mgr; }; } // utility } // vmime #endif // VMIME_UTILITY_SMARTPTR_HPP_INCLUDED libvmime-0.9.1/vmime/utility/datetimeUtils.hpp0000644000175000017500000000644511314151075022004 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_DATETIMEUTILS_HPP_INCLUDED #define VMIME_DATETIMEUTILS_HPP_INCLUDED #include "vmime/dateTime.hpp" namespace vmime { namespace utility { /** Miscellaneous functions related to date/time. */ class datetimeUtils { public: /** Test whether the specified year is a leap year. * * @param year year in 4-digit format * @return true if year is a leap year, false otherwise */ static bool isLeapYear(const int year); /** Return the number of days in the specified month. * * @param year year in 4-digit format (this is needed to check * for leap years) * @param month month, January is 1, December is 12 (see datetime::Months enum) * @return the number of days in the month */ static int getDaysInMonth(const int year, const int month); /** Convert the specified date/time to UT (GMT). * * @param date date/time to convert * @return GMT date/time */ static const datetime toUniversalTime(const datetime& date); /** Convert the specified date/time to the specified time zone. * * @param date date/time to convert * @param zone local zone to convert to (see datetime::TimeZones enum) * @return local time and date */ static const datetime toLocalTime(const datetime& date, const int zone); /** Return the day of the week from the specified date. * * @param year year in 4-digit format * @param month month (1-12), January is 1, December is 12 (see datetime::Months enum) * @param day month day (1-31) * @return the day of the week, Sunday is 0, Monday is 1 (see datetime::DaysOfWeek enum) */ static int getDayOfWeek(const int year, const int month, const int day); /** Return the week number in the year (ISO 8601). * * @param year year in 4-digit format * @param month month (1-12), January is 1, December is 12 (see datetime::Months enum) * @param day month day (1-31) * @param iso if TRUE, use ISO week-numbering year (default is to use calendar year). * For more information, read here: http://en.wikipedia.org/wiki/ISO_8601#Week_dates * @return the week number (1 is the first week of the year) */ static int getWeekOfYear(const int year, const int month, const int day, const bool iso = false); }; } // utility } // vmime #endif // VMIME_DATETIMEUTILS_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/0000755000175000017500000000000011607302336020067 5ustar mnordstrmnordstrlibvmime-0.9.1/vmime/utility/encoder/encoderFactory.hpp0000644000175000017500000000731211250723263023552 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_ENCODERFACTORY_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_ENCODERFACTORY_HPP_INCLUDED #include "vmime/utility/encoder/encoder.hpp" #include "vmime/utility/stringUtils.hpp" namespace vmime { namespace utility { namespace encoder { /** A factory to create 'encoder' objects for the specified encoding. */ class encoderFactory { private: encoderFactory(); ~encoderFactory(); public: static encoderFactory* getInstance(); /** Information about a registered encoder. */ class registeredEncoder : public object { protected: virtual ~registeredEncoder() { } public: virtual ref create() const = 0; virtual const string& getName() const = 0; }; private: template class registeredEncoderImpl : public registeredEncoder { friend class vmime::creator; protected: registeredEncoderImpl(const string& name) : m_name(name) { } public: ref create() const { return vmime::create (); } const string& getName() const { return (m_name); } private: const string m_name; }; std::vector > m_encoders; public: /** Register a new encoder by its encoding name. * * @param name encoding name */ template void registerName(const string& name) { m_encoders.push_back(vmime::create >(utility::stringUtils::toLower(name))); } /** Create a new encoder instance from an encoding name. * * @param name encoding name (eg. "base64") * @return a new encoder instance for the specified encoding * @throw exceptions::no_encoder_available if no encoder is registered * for this encoding */ ref create(const string& name); /** Return information about a registered encoder. * * @param name encoding name * @return information about this encoder * @throw exceptions::no_encoder_available if no encoder is registered * for this encoding */ const ref getEncoderByName(const string& name) const; /** Return the number of registered encoders. * * @return number of registered encoders */ int getEncoderCount() const; /** Return the registered encoder at the specified position. * * @param pos position of the registered encoder to return * @return registered encoder at the specified position */ const ref getEncoderAt(const int pos) const; /** Return a list of all registered encoders. * * @return list of registered encoders */ const std::vector > getEncoderList() const; }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_ENCODERFACTORY_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/qpEncoder.hpp0000644000175000017500000000406111455065052022523 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_QPENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_QPENCODER_HPP_INCLUDED #include "vmime/utility/encoder/encoder.hpp" namespace vmime { namespace utility { namespace encoder { /** Quoted-printable encoder. */ class qpEncoder : public encoder { public: qpEncoder(); utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); const std::vector getAvailableProperties() const; static bool RFC2047_isEncodingNeededForChar(const unsigned char c); static int RFC2047_getEncodedLength(const unsigned char c); protected: static const unsigned char sm_hexDigits[17]; static const unsigned char sm_hexDecodeTable[256]; static const unsigned char sm_RFC2047EncodeTable[128]; }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_QPENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/encoder.hpp0000644000175000017500000000607011376176715022237 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_ENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_ENCODER_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/propertySet.hpp" #include "vmime/exception.hpp" #include "vmime/utility/progressListener.hpp" namespace vmime { namespace utility { namespace encoder { /** Encode/decode data in different encodings. */ class encoder : public object { public: encoder(); virtual ~encoder(); /** Encode data. * * @param in input data (decoded) * @param out output stream for encoded data * @param progress progress listener, or NULL if you do not * want to receive progress notifications * @return number of bytes written into output stream */ virtual utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL) = 0; /** Decode data. * * @param in input data (encoded) * @param out output stream for decoded data * @param progress progress listener, or NULL if you do not * want to receive progress notifications * @return number of bytes written into output stream */ virtual utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL) = 0; /** Return the properties of the encoder. * * @return properties of the encoder */ const propertySet& getProperties() const; /** Return the properties of the encoder. * * @return properties of the encoder */ propertySet& getProperties(); /** Return a list of property names that can be set for * this encoder. * * @return list of property names */ virtual const std::vector getAvailableProperties() const; /** Return the results returned by this encoder. * * @return results returned by the encoder */ const propertySet& getResults() const; protected: propertySet& getResults(); private: propertySet m_props; propertySet m_results; }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_ENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/eightBitEncoder.hpp0000644000175000017500000000273611250723263023647 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_EIGHTBITENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_EIGHTBITENCODER_HPP_INCLUDED #include "vmime/utility/encoder/defaultEncoder.hpp" namespace vmime { namespace utility { namespace encoder { /** 8-bit encoder. */ class eightBitEncoder : public defaultEncoder { public: eightBitEncoder(); }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_EIGHTBITENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/uuEncoder.hpp0000644000175000017500000000337711250723263022543 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_UUENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_UUENCODER_HPP_INCLUDED #include "vmime/utility/encoder/encoder.hpp" namespace vmime { namespace utility { namespace encoder { /** UUEncode encoder. */ class uuEncoder : public encoder { public: uuEncoder(); utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); const std::vector getAvailableProperties() const; }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_UUENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/b64Encoder.hpp0000644000175000017500000000355111250723263022477 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_B64ENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_B64ENCODER_HPP_INCLUDED #include "vmime/utility/encoder/encoder.hpp" namespace vmime { namespace utility { namespace encoder { /** Base64 encoder. */ class b64Encoder : public encoder { public: b64Encoder(); utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); const std::vector getAvailableProperties() const; protected: static const unsigned char sm_alphabet[]; static const unsigned char sm_decodeMap[256]; }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_B64ENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/binaryEncoder.hpp0000644000175000017500000000272511250723263023372 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_BINARYENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_BINARYENCODER_HPP_INCLUDED #include "vmime/utility/encoder/defaultEncoder.hpp" namespace vmime { namespace utility { namespace encoder { /** Binary encoder. */ class binaryEncoder : public defaultEncoder { public: binaryEncoder(); }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_BINARYENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/defaultEncoder.hpp0000644000175000017500000000341311250723263023525 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_DEFAULTENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_DEFAULTENCODER_HPP_INCLUDED #include "vmime/utility/encoder/encoder.hpp" namespace vmime { namespace utility { namespace encoder { /** Default encoder (simple copy, no encoding/decoding is performed). */ class defaultEncoder : public encoder { public: defaultEncoder(); utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_DEFAULTENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/encoder/sevenBitEncoder.hpp0000644000175000017500000000273611250723263023667 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_ENCODER_SEVENBITENCODER_HPP_INCLUDED #define VMIME_UTILITY_ENCODER_SEVENBITENCODER_HPP_INCLUDED #include "vmime/utility/encoder/defaultEncoder.hpp" namespace vmime { namespace utility { namespace encoder { /** 7-bit encoder. */ class sevenBitEncoder : public defaultEncoder { public: sevenBitEncoder(); }; } // encoder } // utility } // vmime #endif // VMIME_UTILITY_ENCODER_SEVENBITENCODER_HPP_INCLUDED libvmime-0.9.1/vmime/utility/filteredStream.hpp0000644000175000017500000001621411250723263022137 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_FILTEREDSTREAM_HPP_INCLUDED #define VMIME_UTILITY_FILTEREDSTREAM_HPP_INCLUDED #include #include "vmime/utility/stream.hpp" namespace vmime { namespace utility { /** A stream whose input is filtered. */ class filteredInputStream : public inputStream { public: virtual size_type getBlockSize(); /** Return a reference to the stream being filtered. * * @return stream being filtered */ virtual inputStream& getPreviousInputStream() = 0; }; /** A stream whose output is filtered. */ class filteredOutputStream : public outputStream { public: virtual size_type getBlockSize(); /** Return a reference to the stream being filtered. * * @return destination stream for filtered data */ virtual outputStream& getNextOutputStream() = 0; }; /** A filtered input stream which replaces "\n.." * sequences with "\n." sequences. */ class dotFilteredInputStream : public filteredInputStream { public: /** Construct a new filter for the specified input stream. * * @param is stream from which to read data to be filtered */ dotFilteredInputStream(inputStream& is); inputStream& getPreviousInputStream(); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: inputStream& m_stream; value_type m_previousChar2; // (N - 1)th character of previous buffer value_type m_previousChar1; // (N)th (last) character of previous buffer }; /** A filtered output stream which replaces "\n." * sequences with "\n.." sequences. */ class dotFilteredOutputStream : public filteredOutputStream { public: /** Construct a new filter for the specified output stream. * * @param os stream into which write filtered data */ dotFilteredOutputStream(outputStream& os); outputStream& getNextOutputStream(); void write(const value_type* const data, const size_type count); void flush(); private: outputStream& m_stream; value_type m_previousChar; }; /** A filtered output stream which replaces CRLF sequences * with single LF characters. */ class CRLFToLFFilteredOutputStream : public filteredOutputStream { public: /** Construct a new filter for the specified output stream. * * @param os stream into which write filtered data */ CRLFToLFFilteredOutputStream(outputStream& os); outputStream& getNextOutputStream(); void write(const value_type* const data, const size_type count); void flush(); private: outputStream& m_stream; value_type m_previousChar; }; /** A filtered input stream which stops when a specified sequence * is found (eof() method will return 'true'). */ template class stopSequenceFilteredInputStream : public filteredInputStream { public: /** Construct a new filter for the specified input stream. * * @param is stream from which to read data to be filtered * @param sequence sequence on which to stop */ stopSequenceFilteredInputStream(inputStream& is, const value_type* sequence) : m_stream(is), m_sequence(sequence), m_found(0), m_eof(false) { } inputStream& getPreviousInputStream() { return (m_stream); } bool eof() const { return (m_found == COUNT || m_eof); } void reset() { m_found = 0; m_stream.reset(); } size_type read(value_type* const data, const size_type count); size_type skip(const size_type /* count */) { // Not supported return 0; } private: inputStream& m_stream; const value_type* m_sequence; size_type m_found; bool m_eof; }; template <> stream::size_type stopSequenceFilteredInputStream <1>::read (value_type* const data, const size_type count); template stream::size_type stopSequenceFilteredInputStream ::read (value_type* const data, const size_type count) { // Read buffer must be at least 'COUNT' size + 1 byte if (eof() || count <= COUNT) return 0; if (m_stream.eof()) { if (m_found != 0) { const size_type found = m_found; for (size_type f = 0 ; f < found ; ++f) data[f] = m_sequence[f]; m_found = 0; m_eof = true; return (found); } else { m_eof = true; return 0; } } size_type read = m_stream.read(data, count - COUNT); value_type* end = data + read; value_type* pos = data; while (pos < end) { // Very simple case, search for the whole sequence if (m_found == 0) { while (pos < end) { pos = std::find(pos, end, m_sequence[0]); if (pos == end) return (read); m_found = 1; ++pos; while (pos < end && m_found < COUNT && m_sequence[m_found] == *pos) { ++m_found; ++pos; } // Didn't found whole sequence if (m_found != COUNT) { // We reached the end of the buffer if (pos == end) { return (read - m_found); } // Common prefix but not whole sequence else { m_found = 0; } } // Whole sequence found else { // End of stream return (pos - data - m_found); } } } // More complex case: search for a sequence which has begun // in a previous buffer else { // Search for the end of the previously started sequence while (pos < end && m_found < COUNT && m_sequence[m_found] == *pos) { ++m_found; ++pos; } if (m_found != COUNT) { // End of buffer if (pos == end) { // No data: this buffer is a sub-sequence of the // searched sequence return 0; } // Common prefix else { // We have to reinject the incomplete sequence into // the stream data // -- shift right data const size_type n = pos - data; value_type* newEnd = data + read + m_found - n; value_type* oldEnd = data + read; for (size_type i = 0 ; i < read - n ; ++i) { --newEnd; --oldEnd; *newEnd = *oldEnd; } // -- copy the prefix just before data for (size_type f = 0 ; f < m_found ; ++f) data[f] = m_sequence[f]; read += m_found - n; end += m_found - n; m_found = 0; } } else { return 0; // no more data } } } return read; } } // utility } // vmime #endif // VMIME_UTILITY_FILTEREDSTREAM_HPP_INCLUDED libvmime-0.9.1/vmime/utility/smartPtrInt.hpp0000644000175000017500000000452011250723263021451 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED #define VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/utility/smartPtr.hpp" namespace vmime { namespace utility { /** Reference counter for shared pointers. */ class refCounter { public: refCounter(const long initialValue); ~refCounter(); long increment(); long decrement(); operator long() const; private: #if defined(_WIN32) long m_value; #elif defined(__GNUC__) && (defined(__GLIBCPP__) || defined(__GLIBCXX__)) mutable volatile int m_value; #elif defined (VMIME_HAVE_PTHREAD) volatile long m_value; pthread_mutex_t m_mutex; #else // not thread-safe implementation long m_value; #endif }; /** Separate implementation of refManager, to avoid polluting global * namespace with system-specific inclusions/definitions. */ class refManagerImpl : public refManager { public: refManagerImpl(object* obj); ~refManagerImpl(); bool addStrong(); void releaseStrong(); void addWeak(); void releaseWeak(); object* getObject(); long getStrongRefCount() const; long getWeakRefCount() const; private: void deleteManager(); void deleteObject(); object* m_object; refCounter m_strongCount; refCounter m_weakCount; }; } // utility } // vmime #endif // VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED libvmime-0.9.1/vmime/utility/file.hpp0000644000175000017500000001460411314151075020102 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_FILE_HPP_INCLUDED #define VMIME_UTILITY_FILE_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/utility/path.hpp" #include "vmime/utility/stream.hpp" #if VMIME_HAVE_FILESYSTEM_FEATURES namespace vmime { namespace utility { class file; /** File list iterator (see file::getFiles). */ class fileIterator : public object { public: virtual ~fileIterator() { } /** Check whether the cursor has reach the end of the list. * * @return true if you can call nextElement(), or false * if no more file is available */ virtual bool hasMoreElements() const = 0; /** Return the next file in the list. * * @return next file or NULL */ virtual ref nextElement() = 0; }; /** Write to a file. */ class fileWriter : public object { public: virtual ~fileWriter() { } virtual ref getOutputStream() = 0; }; /** Read from a file. */ class fileReader : public object { public: virtual ~fileReader() { } virtual ref getInputStream() = 0; }; /** Abstract representation of a file or directory. */ class file : public object { public: typedef utility::path path; typedef unsigned long length_type; virtual ~file() { } /** Create the file pointed by this file object. * * @throw exceptions::filesystem_exception if an error occurs */ virtual void createFile() = 0; /** Create the directory pointed by this file object. * * @param createAll if set to true, recursively create all * parent directories if they do not exist * @throw exceptions::filesystem_exception if an error occurs */ virtual void createDirectory(const bool createAll = false) = 0; /** Test whether this is a file. * * @return true if this is a file, false otherwise */ virtual bool isFile() const = 0; /** Test whether this is a directory. * * @return true if this is a directory, false otherwise */ virtual bool isDirectory() const = 0; /** Test whether this file is readible. * * @return true if we can read this file, false otherwise */ virtual bool canRead() const = 0; /** Test whether this file is writeable. * * @return true if we can write to this file, false otherwise */ virtual bool canWrite() const = 0; /** Return the length of this file. * * @return file size (in bytes) */ virtual length_type getLength() = 0; /** Return the full path of this file/directory. * * @return full path of the file */ virtual const path& getFullPath() const = 0; /** Test whether this file/directory exists. * * @return true if the file exists, false otherwise */ virtual bool exists() const = 0; /** Return the parent directory of this file/directory. * * @return parent directory (or NULL if root) */ virtual ref getParent() const = 0; /** Rename the file/directory. * * @param newName full path of the new file * @throw exceptions::filesystem_exception if an error occurs */ virtual void rename(const path& newName) = 0; /** Deletes this file/directory. * If this is a directory, it must be empty. * * @throw exceptions::filesystem_exception if an error occurs */ virtual void remove() = 0; /** Return an object capable of writing to this file. * * @return file writer object */ virtual ref getFileWriter() = 0; /** Return an object capable of reading from this file. * * @return file reader object */ virtual ref getFileReader() = 0; /** Enumerate files contained in this directory. * * @return file iterator to enumerate files * @throw exceptions::not_a_directory if this is not a directory, * exceptions::filesystem_exception if another error occurs */ virtual ref getFiles() const = 0; protected: file() { } private: file(const file&) : object() { } }; /** Constructs 'file' objects. */ class fileSystemFactory : public object { public: virtual ~fileSystemFactory() { } /** Create a new file object from the specified path. * * @param path full path (absolute) of the file * @return new file object for the path */ virtual ref create(const file::path& path) const = 0; /** Parse a path contained in a string. * * @param str string containing a path in a system-dependent representation * @return path object (abstract representation) */ virtual const file::path stringToPath(const string& str) const = 0; /** Return the system-dependent string representation for the specified path. * * @param path abstract representation of the path * @return string representation of the path */ virtual const string pathToString(const file::path& path) const = 0; /** Test whether the specified path component is syntactically * valid (ie: does not contain any 'special' character). * * @param comp path component to test * @return true if the component is valid, false otherwise */ virtual bool isValidPathComponent(const file::path::component& comp) const = 0; /** Test whether the specified path is syntactically valid * (ie: components do not contain any 'special' character). * * @param path path to test * @return true if the path is valid, false otherwise */ virtual bool isValidPath(const file::path& path) const = 0; }; } // utility } // vmime #endif // VMIME_HAVE_FILESYSTEM_FEATURES #endif // VMIME_UTILITY_FILE_HPP_INCLUDED libvmime-0.9.1/vmime/utility/path.hpp0000644000175000017500000001046611250723263020124 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_PATH_HPP_INCLUDED #define VMIME_UTILITY_PATH_HPP_INCLUDED #include #include "vmime/types.hpp" #include "vmime/word.hpp" namespace vmime { namespace utility { /** Abstract representation of a path (filesystem, mailbox, etc). */ class path : public object { public: typedef vmime::word component; typedef std::vector list; // Construct a path path(); path(const component& c); path(const path& p); explicit path(const string& s); // Append a component to a path path operator/(const path& p) const; path operator/(const component& c) const; path& operator/=(const path& p); path& operator/=(const component& c); // Return the parent path path getParent() const; // Assignment path& operator=(const path& p); path& operator=(const component& c); // Path comparison bool operator==(const path& p) const; bool operator!=(const path& p) const; /** Append a component to the path. * * @param c component to add */ void appendComponent(const component& c); /** Return the component at the specified position. * * @param pos position * @return component at position 'pos' */ const component& getComponentAt(const int pos) const; /** Return the component at the specified position. * * @param pos position * @return component at position 'pos' */ component& getComponentAt(const int pos); /** Test whether this path is empty (root). * * @return true if the path is empty (no components = root) */ bool isEmpty() const; /** Test whether this path is the root (alias for isEmpty()). * * @return true if the path is the root */ bool isRoot() const; /** Return the last component of this path (const version). * * @return last component */ const component getLastComponent() const; /** Return the last component of this path (non-const version). * * @return last component */ component& getLastComponent(); /** Return the number of components in this path. * * @return number of components */ int getSize() const; /** Return the specified component of the path (const version). * * @param x index of the component * @return component at the specified index */ const component& operator[](const int x) const; /** Return the specified component of the path (non-const version). * * @param x index of the component * @return component at the specified index */ component& operator[](const int x); /** Test whether this path is a direct parent of another one. * * @param p other path * @return true if the specified path is a child * of this path, false otherwise */ bool isDirectParentOf(const path& p) const; /** Test whether this path is a parent of another one. * * @param p other path * @return true if the specified path is a child (direct or * indirect) of this path, false otherwise */ bool isParentOf(const path& p) const; /** Rename a parent component in the path. * Example: path("a/b/c/d").renameParent("a/b", "x/y/z") * will return path("x/y/z/c/d"). * * @param oldPath old parent path * @param newPath new parent path */ void renameParent(const path& oldPath, const path& newPath); private: list m_list; }; } // utility } // vmime #endif // VMIME_UTILITY_PATH_HPP_INCLUDED libvmime-0.9.1/vmime/utility/urlUtils.hpp0000644000175000017500000000322711250723263021010 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_URLUTILS_HPP_INCLUDED #define VMIME_UTILITY_URLUTILS_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/base.hpp" namespace vmime { namespace utility { /** Miscellaneous functions related to URLs. */ class urlUtils { public: /** Encode extended characters in a URL string (ASCII characters * are unmodified, other are encoded as '%' followed by hex code). */ static const string encode(const string& s); /** Decode an hex-encoded URL (see encode()). */ static const string decode(const string& s); }; } // utility } // vmime #endif // VMIME_UTILITY_URLUTILS_HPP_INCLUDED libvmime-0.9.1/vmime/utility/stringUtils.hpp0000644000175000017500000001154211375252715021522 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_STRINGUTILS_HPP_INCLUDED #define VMIME_UTILITY_STRINGUTILS_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/base.hpp" #include namespace vmime { namespace utility { /** Miscellaneous functions related to strings. */ class stringUtils { public: /** Test two strings for equality (case insensitive). * \warning Use this with ASCII-only strings. * * @param s1 first string * @param s2 second string (must be in lower-case!) * @param n length of the second string * @return true if the two strings compare equally, false otherwise */ static bool isStringEqualNoCase(const string& s1, const char* s2, const string::size_type n); /** Test two strings for equality (case insensitive). * \warning Use this with ASCII-only strings. * * @param s1 first string * @param s2 second string * @return true if the two strings compare equally, false otherwise */ static bool isStringEqualNoCase(const string& s1, const string& s2); /** Test two strings for equality (case insensitive). * \warning Use this with ASCII-only strings. * * @param begin start position of the first string * @param end end position of the first string * @param s second string (must be in lower-case!) * @param n length of the second string * @return true if the two strings compare equally, false otherwise */ static bool isStringEqualNoCase(const string::const_iterator begin, const string::const_iterator end, const char* s, const string::size_type n); /** Transform all the characters in a string to lower-case. * \warning Use this with ASCII-only strings. * * @param str the string to transform * @return a new string in lower-case */ static const string toLower(const string& str); /** Transform all the characters in a string to upper-case. * \warning Use this with ASCII-only strings. * * @param str the string to transform * @return a new string in upper-case */ static const string toUpper(const string& str); /** Strip the space characters (SPC, TAB, CR, LF) at the beginning * and at the end of the specified string. * * @param str string in which to strip spaces * @return a new string with space characters removed */ static const string trim(const string& str); /** Return the number of 7-bit US-ASCII characters in a string. * * @param begin start position * @param end end position * @return number of ASCII characters */ static string::size_type countASCIIchars(const string::const_iterator begin, const string::const_iterator end); /** Returns the position of the first non 7-bit US-ASCII character in a string. * * @param begin start position * @param end end position * @return position since begin, or string::npos */ static string::size_type findFirstNonASCIIchar(const string::const_iterator begin, const string::const_iterator end); /** Convert the specified value to a string value. * * @param value to convert * @return value converted from type 'TYPE' */ template static const string toString(const TYPE& value) { std::ostringstream oss; oss.imbue(std::locale::classic()); oss << value; return (oss.str()); } /** Convert the specified string value to a value of * the specified type. * * @param value value to convert * @return value converted into type 'TYPE' */ template static const TYPE fromString(const string& value) { TYPE ret; std::istringstream iss(value); iss.imbue(std::locale::classic()); iss >> ret; return (ret); } /** Unquote the specified string and transform escaped characters. * * @param string from which to remove quotes * @return unquoted string */ static const string unquote(const string& str); }; } // utility } // vmime #endif // VMIME_UTILITY_STRINGUTILS_HPP_INCLUDED libvmime-0.9.1/vmime/utility/stringProxy.hpp0000644000175000017500000000554311250723263021540 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_STRINGPROXY_HPP_INCLUDED #define VMIME_UTILITY_STRINGPROXY_HPP_INCLUDED #include #include "vmime/types.hpp" #include "vmime/utility/stream.hpp" #include "vmime/utility/progressListener.hpp" namespace vmime { namespace utility { /** This class is a proxy for the string class. This takes * advantage of the COW (copy-on-write) system that might * be used in "std::string" implementation. */ class stringProxy { public: typedef string::size_type size_type; typedef string string_type; // Consruction stringProxy(); stringProxy(const stringProxy& s); stringProxy(const string_type& s, const size_type start = 0, const size_type end = std::numeric_limits ::max()); // Assignment void set(const string_type& s, const size_type start = 0, const size_type end = std::numeric_limits ::max()); void detach(); stringProxy& operator=(const stringProxy& s); stringProxy& operator=(const string_type& s); // Extract some portion (or whole) of the string // and output it into a stream. void extract(outputStream& os, const size_type start = 0, const size_type end = std::numeric_limits ::max(), utility::progressListener* progress = NULL) const; // Return the "virtual" length of the string size_type length() const; // Return the boundaries of the "virtual" string size_type start() const; size_type end() const; string::const_iterator it_begin() const { return (m_buffer.begin() + m_start); } string::const_iterator it_end() const { return (m_buffer.begin() + m_end); } private: string_type m_buffer; size_type m_start; size_type m_end; }; std::ostream& operator<<(std::ostream& os, const stringProxy& s); outputStream& operator<<(outputStream& os, const stringProxy& s); } // utility } // vmime #endif // VMIME_UTILITY_STRINGPROXY_HPP_INCLUDED libvmime-0.9.1/vmime/utility/stream.hpp0000644000175000017500000002217711250723263020465 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_STREAM_HPP_INCLUDED #define VMIME_UTILITY_STREAM_HPP_INCLUDED #include #include #include #include "vmime/config.hpp" #include "vmime/types.hpp" #include "vmime/utility/progressListener.hpp" #if VMIME_HAVE_MESSAGING_FEATURES namespace vmime { namespace net { class socket; // forward reference } // net } // vmime #endif #if defined(_MSC_VER) && (_MSC_VER <= 1200) // VC++6 # include #endif namespace vmime { namespace utility { class stringProxy; /** Base class for input/output stream. */ class stream : public object { public: virtual ~stream() { } /** Type used to read/write one byte in the stream. */ typedef string::value_type value_type; /** Type used for lengths in streams. */ typedef string::size_type size_type; /** Return the preferred maximum block size when reading * from or writing to this stream. * * @return block size, in bytes */ virtual size_type getBlockSize(); }; /** Simple output stream. */ class outputStream : public stream { public: /** Write data to the stream. * * @param data buffer containing data to write * @param count number of bytes to write */ virtual void write(const value_type* const data, const size_type count) = 0; /** Flush this output stream and forces any buffered output * bytes to be written out to the stream. */ virtual void flush() = 0; }; /** Simple input stream. */ class inputStream : public stream { public: /** Test for end of stream (no more data to read). * * @return true if we have reached the end of stream, false otherwise */ virtual bool eof() const = 0; /** Set the read pointer to the beginning of the stream. * * @warning WARNING: this may not work for all stream types. */ virtual void reset() = 0; /** Read data from the stream. * * @param data will receive the data read * @param count maximum number of bytes to read * @return number of bytes read */ virtual size_type read(value_type* const data, const size_type count) = 0; /** Skip a number of bytes. * * @param count maximum number of bytes to ignore * @return number of bytes skipped */ virtual size_type skip(const size_type count) = 0; }; // Helpers functions outputStream& operator<<(outputStream& os, const string& str); outputStream& operator<<(outputStream& os, const stream::value_type c); #if defined(_MSC_VER) && (_MSC_VER <= 1200) // Internal compiler error with VC++6 inline outputStream& operator<<(outputStream& os, const char* str) { os.write(str, ::strlen(str)); return (os); } #else template outputStream& operator<<(outputStream& os, const char (&str)[N]) { os.write(str, N - 1); return (os); } #endif // defined(_MSC_VER) && (_MSC_VER <= 1200) template outputStream& operator<<(outputStream& os, const T& t) { std::ostringstream oss; oss.imbue(std::locale::classic()); // no formatting oss << t; os << oss.str(); return (os); } /** Copy data from one stream into another stream using a buffered method. * * @param is input stream (source data) * @param os output stream (destination for data) * @return number of bytes copied */ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os); /** Copy data from one stream into another stream using a buffered method * and notify progress state of the operation. * * @param is input stream (source data) * @param os output stream (destination for data) * @param length predicted number of bytes to copy * @param progress listener to notify * @return number of bytes copied */ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os, const stream::size_type length, progressListener* progress); // Adapters /** An adapter class for C++ standard output streams. */ class outputStreamAdapter : public outputStream { public: /** @param os output stream to wrap */ outputStreamAdapter(std::ostream& os); void write(const value_type* const data, const size_type count); void flush(); private: std::ostream& m_stream; }; /** An adapter class for string output. */ class outputStreamStringAdapter : public outputStream { public: outputStreamStringAdapter(string& buffer); void write(const value_type* const data, const size_type count); void flush(); size_type getBlockSize(){return 8192;} private: string& m_buffer; }; /** An adapter class for byte array output. */ class outputStreamByteArrayAdapter : public outputStream { public: outputStreamByteArrayAdapter(byteArray& array); void write(const value_type* const data, const size_type count); void flush(); private: byteArray& m_array; }; /** An adapter class for C++ standard input streams. */ class inputStreamAdapter : public inputStream { public: /** @param is input stream to wrap */ inputStreamAdapter(std::istream& is); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: std::istream& m_stream; }; /** An adapter class for string input. */ class inputStreamStringAdapter : public inputStream { public: inputStreamStringAdapter(const string& buffer); inputStreamStringAdapter(const string& buffer, const string::size_type begin, const string::size_type end); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: inputStreamStringAdapter(const inputStreamStringAdapter&); const string m_buffer; // do _NOT_ keep a reference... const string::size_type m_begin; const string::size_type m_end; string::size_type m_pos; }; /** An adapter class for stringProxy input. */ class inputStreamStringProxyAdapter : public inputStream { public: /** @param buffer stringProxy object to wrap */ inputStreamStringProxyAdapter(const stringProxy& buffer); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: inputStreamStringProxyAdapter(const inputStreamStringProxyAdapter&); const stringProxy& m_buffer; string::size_type m_pos; }; /** An adapter class for pointer to C++ standard input stream. */ class inputStreamPointerAdapter : public inputStream { public: /** @param is input stream to wrap * @param own if set to 'true', the pointer will be deleted when * this object is destroyed */ inputStreamPointerAdapter(std::istream* is, const bool own = true); ~inputStreamPointerAdapter(); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: inputStreamPointerAdapter(const inputStreamPointerAdapter&); std::istream* m_stream; const bool m_own; }; /** An adapter class for reading from an array of bytes. */ class inputStreamByteBufferAdapter : public inputStream { public: inputStreamByteBufferAdapter(const byte_t* buffer, size_type length); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); private: const byte_t* m_buffer; const size_type m_length; size_type m_pos; }; #if VMIME_HAVE_MESSAGING_FEATURES /** An output stream that is connected to a socket. */ class outputStreamSocketAdapter : public outputStream { public: outputStreamSocketAdapter(net::socket& sok); void write(const value_type* const data, const size_type count); void flush(); size_type getBlockSize(); private: outputStreamSocketAdapter(const outputStreamSocketAdapter&); net::socket& m_socket; }; /** An input stream that is connected to a socket. */ class inputStreamSocketAdapter : public inputStream { public: inputStreamSocketAdapter(net::socket& sok); bool eof() const; void reset(); size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); size_type getBlockSize(); private: inputStreamSocketAdapter(const inputStreamSocketAdapter&); net::socket& m_socket; }; #endif // VMIME_HAVE_MESSAGING_FEATURES } // utility } // vmime #endif // VMIME_UTILITY_STREAM_HPP_INCLUDED libvmime-0.9.1/vmime/utility/url.hpp0000644000175000017500000001166211250723263017771 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_URL_HPP_INCLUDED #define VMIME_UTILITY_URL_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/base.hpp" #include "vmime/propertySet.hpp" namespace vmime { namespace utility { /** This class represents a Uniform Resource Locator (a pointer * to a "resource" on the World Wide Web). */ class url { public: /** Means "port not specified" (use default port). */ static const port_t UNSPECIFIED_PORT; /** Standard name for FILE protocol (local file-system). */ static const string PROTOCOL_FILE; /** Standard name for HTTP protocol. */ static const string PROTOCOL_HTTP; /** Standard name for FTP protocol. */ static const string PROTOCOL_FTP; /** Construct an URL from a string (parse the URL components). * * @param s full URL string (eg. http://www.vmime.org:80/download.html) * @throw exceptions::malformed_url if URL is malformed */ url(const string& s); /** Construct an URL from another URL object. * * @param u other URL object */ url(const url& u); /** Construct an URL from the components. * * @param protocol protocol (eg. "http", "ftp"...) * @param host host name (eg. "vmime.sourceforge.net", "123.45.67.89") * @param port optional port number (eg. 80, 110 or UNSPECIFIED_PORT to mean "default") * @param path optional full path (eg. "download.html") * @param username optional user name * @param password optional user password */ url(const string& protocol, const string& host, const port_t port = UNSPECIFIED_PORT, const string& path = "", const string& username = "", const string& password = ""); /** Return the protocol of the URL (eg: "http"). * * @return protocol of the URL */ const string& getProtocol() const; /** Set the protocol of the URL. * * @param protocol new protocol (eg: "http") */ void setProtocol(const string& protocol); /** Return the username specified in the URL * or empty if not specified. * * @return user name */ const string& getUsername() const; /** Set the username of the URL. * * @param username user name */ void setUsername(const string& username); /** Return the password specified in the URL * or empty if not specified. * * @return user password */ const string& getPassword() const; /** Set the password of the URL. * * @param password user password */ void setPassword(const string& password); /** Return the host name of the URL (server name or IP address). * * @return host name */ const string& getHost() const; /** Set the host name of the URL. * * @param host server name or IP address */ void setHost(const string& host); /** Return the port of the URL, or url::UNSPECIFIED_PORT if * the default port if used. * * @return server port */ port_t getPort() const; /** Set the port of the URL. * * @param port server port or url::UNSPECIFIED_PORT to * use the default port of the protocol */ void setPort(const port_t port); /** Return the path portion of the URL, * or empty if not specified. * * @return path */ const string& getPath() const; /** Set the part portion of the URL. * * @param path path */ void setPath(const string& path); /** Return the parameters of the URL (read-only). * * @return parameters */ const propertySet& getParams() const; /** Return the parameters of the URL. * * @return parameters */ propertySet& getParams(); /** Build a string URL from this object. */ operator string() const; url& operator=(const url& u); url& operator=(const string& s); private: const string build() const; void parse(const string& str); // Format: // "protocol://[username[:password]@]host[:port][/path]" string m_protocol; string m_username; string m_password; string m_host; port_t m_port; string m_path; propertySet m_params; }; } // utility } // vmime #endif // VMIME_UTILITY_URL_HPP_INCLUDED libvmime-0.9.1/vmime/utility/progressListener.hpp0000644000175000017500000000567711250723263022552 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_UTILITY_PROGRESSLISTENER_HPP_INCLUDED #define VMIME_UTILITY_PROGRESSLISTENER_HPP_INCLUDED namespace vmime { namespace utility { /** An interface to implement if you want to be notified * of a state of progress by some objects. */ class progressListener { protected: virtual ~progressListener() { } public: /** Allow the caller object to cancel the current operation. * * @warning WARNING: this is implementation-dependent: cancelling * may not be supported by the notifier object. * * @return true to cancel the operation, false otherwise */ virtual bool cancel() const = 0; /** Called at the beginning of the operation. * * @param predictedTotal predicted amount of units (this has * no concrete meaning: these are not bytes, nor percentage...) */ virtual void start(const int predictedTotal) = 0; /** Called during the operation (can be called several times). * * @param current current position * @param currentTotal adjusted total amount of units */ virtual void progress(const int current, const int currentTotal) = 0; /** Called at the end of the operation. * * @param total final total amount of units */ virtual void stop(const int total) = 0; }; /** A progress listener used when total size is known by the * receiver, but not by the notifier. */ class progressListenerSizeAdapter : public progressListener { public: /** Construct a new progressListenerSizeAdapter object. * * @param list wrapped progress listener (can be NULL) * @param total predicted total */ progressListenerSizeAdapter(progressListener* list, const int total); bool cancel() const; void start(const int predictedTotal); void progress(const int current, const int currentTotal); void stop(const int total); private: progressListener* m_wrapped; int m_total; }; } // utility } // vmime #endif // VMIME_UTILITY_PROGRESSLISTENER_HPP_INCLUDED libvmime-0.9.1/vmime/headerFieldValue.hpp0000644000175000017500000000263511250723264020656 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_HEADERFIELDVALUE_HPP_INCLUDED #define VMIME_HEADERFIELDVALUE_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" namespace vmime { /** Base class for all classes that can be used as a value * for a header field. */ class headerFieldValue : public component { public: }; } // vmime #endif // VMIME_HEADERFIELDVALUE_HPP_INCLUDED libvmime-0.9.1/vmime/mediaType.hpp0000644000175000017500000000602011250723264017376 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_MEDIATYPE_HPP_INCLUDED #define VMIME_MEDIATYPE_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" namespace vmime { /** Content media type (basic type). */ class mediaType : public headerFieldValue { public: mediaType(); mediaType(const string& type); mediaType(const string& type, const string& subType); public: bool operator==(const mediaType& type) const; bool operator!=(const mediaType& type) const; mediaType& operator=(const string& type); ref clone() const; void copyFrom(const component& other); mediaType& operator=(const mediaType& other); const std::vector > getChildComponents() const; /** Return the media type. * See the constants in vmime::mediaTypes. * * @return media type */ const string& getType() const; /** Set the media type. * See the constants in vmime::mediaTypes. * * @param type media type */ void setType(const string& type); /** Return the media subtype. * See the constants in vmime::mediaTypes. * * @return media subtype */ const string& getSubType() const; /** Set the media subtype. * See the constants in vmime::mediaTypes. * * @param subType media subtype */ void setSubType(const string& subType); /** Set the media type and subtype from a string * in the form "type/subtype" (eg: "image/jpeg"). * * @param type media type and subtype */ void setFromString(const string& type); protected: string m_type; string m_subType; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_MEDIATYPE_HPP_INCLUDED libvmime-0.9.1/vmime/generatedMessageAttachment.hpp0000644000175000017500000000402311250723264022732 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_GENERATEDMESSAGEATTACHMENT_HPP_INCLUDED #define VMIME_GENERATEDMESSAGEATTACHMENT_HPP_INCLUDED #ifndef VMIME_BUILDING_DOC // implementation detail #include "vmime/messageAttachment.hpp" #include "vmime/bodyPartAttachment.hpp" namespace vmime { /** A message attachment that can be extracted from a message. */ class generatedMessageAttachment : public messageAttachment { public: generatedMessageAttachment(ref part); const mediaType getType() const; const text getDescription() const; const word getName() const; const ref getData() const; const encoding getEncoding() const; ref getPart() const; ref getHeader() const; ref getMessage() const; protected: void generateIn(ref parent) const; private: ref m_bpa; mutable ref m_msg; }; } // vmime #endif // !VMIME_BUILDING_DOC #endif // VMIME_GENERATEDMESSAGEATTACHMENT_HPP_INCLUDED libvmime-0.9.1/vmime/body.hpp0000644000175000017500000002043411376242147016424 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_BODY_HPP_INCLUDED #define VMIME_BODY_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" #include "vmime/header.hpp" #include "vmime/mediaType.hpp" #include "vmime/charset.hpp" #include "vmime/encoding.hpp" #include "vmime/contentHandler.hpp" namespace vmime { class bodyPart; /** Body section of a MIME part. */ class body : public component { friend class bodyPart; public: body(); ~body(); /** Add a part at the end of the list. * * @param part part to append */ void appendPart(ref part); /** Insert a new part before the specified part. * * @param beforePart part before which the new part will be inserted * @param part part to insert * @throw exceptions::no_such_part if the part is not in the list */ void insertPartBefore(ref beforePart, ref part); /** Insert a new part before the specified position. * * @param pos position at which to insert the new part (0 to insert at * the beginning of the list) * @param part part to insert */ void insertPartBefore(const int pos, ref part); /** Insert a new part after the specified part. * * @param afterPart part after which the new part will be inserted * @param part part to insert * @throw exceptions::no_such_part if the part is not in the list */ void insertPartAfter(ref afterPart, ref part); /** Insert a new part after the specified position. * * @param pos position of the part before the new part * @param part part to insert */ void insertPartAfter(const int pos, ref part); /** Remove the specified part from the list. * * @param part part to remove * @throw exceptions::no_such_part if the part is not in the list */ void removePart(ref part); /** Remove the part at the specified position. * * @param pos position of the part to remove */ void removePart(const int pos); /** Remove all parts from the list. */ void removeAllParts(); /** Return the number of parts in the list. * * @return number of parts */ int getPartCount() const; /** Tests whether the list of parts is empty. * * @return true if there is no part, false otherwise */ bool isEmpty() const; /** Return the part at the specified position. * * @param pos position * @return part at position 'pos' */ ref getPartAt(const int pos); /** Return the part at the specified position. * * @param pos position * @return part at position 'pos' */ const ref getPartAt(const int pos) const; /** Return the part list. * * @return list of parts */ const std::vector > getPartList() const; /** Return the part list. * * @return list of parts */ const std::vector > getPartList(); /** Return the prolog text. * * @return prolog text */ const string& getPrologText() const; /** Set the prolog text. * * @param prologText new prolog text */ void setPrologText(const string& prologText); /** Return the epilog text. * * @return epilog text */ const string& getEpilogText() const; /** Set the epilog text. * * @param epilogText new epilog text */ void setEpilogText(const string& epilogText); /** Return a read-only reference to body contents. * * @return read-only body contents */ const ref getContents() const; /** Set the body contents. * * @param contents new body contents */ void setContents(ref contents); /** Set the body contents and type. * * @param contents new body contents * @param type type of contents */ void setContents(ref contents, const mediaType& type); /** Set the body contents, type and charset. * * @param contents new body contents * @param type type of contents * @param charset charset of contents */ void setContents(ref contents, const mediaType& type, const charset& chset); /** Set the body contents, type, charset and encoding. * * @param contents new body contents * @param type type of contents * @param charset charset of contents * @param encoding contents encoding */ void setContents(ref contents, const mediaType& type, const charset& chset, const encoding& enc); /** Set the MIME type and charset of contents. * If a charset is defined, it will not be modified. * * @param type MIME media type of contents * @param chset charset of contents */ void setContentType(const mediaType& type, const charset& chset); /** Set the MIME type of contents. * * @param type MIME media type of contents */ void setContentType(const mediaType& type); /** Return the media type of the data contained in the body contents. * This is a shortcut for getHeader()->ContentType()->getValue() * on the parent part. * * @return media type of body contents */ const mediaType getContentType() const; /** Set the charset of contents. * If the type is not set, it will be set to default "text/plain" type. * * @param chset charset of contents */ void setCharset(const charset& chset); /** Return the charset of the data contained in the body contents. * This is a shortcut for getHeader()->ContentType()->getCharset() * on the parent part. * * @return charset of body contents */ const charset getCharset() const; /** Set the output encoding of contents. * Contents will be encoded (or re-encoded) when this node is being generated. * * @param enc encoding of contents */ void setEncoding(const encoding& enc); /** Return the encoding used to encode the body contents. * This is a shortcut for getHeader()->ContentTransferEncoding()->getValue() * on the parent part. * * @return encoding of body contents */ const encoding getEncoding() const; /** Generate a new random boundary string. * * @return randomly generated boundary string */ static const string generateRandomBoundaryString(); /** Test a boundary string for validity (as defined in RFC #1521, page 19). * * @param boundary boundary string to test * @return true if the boundary string is valid, false otherwise */ static bool isValidBoundary(const string& boundary); ref clone() const; void copyFrom(const component& other); body& operator=(const body& other); const std::vector > getChildComponents() const; private: void setParentPart(ref parent); string m_prologText; string m_epilogText; ref m_contents; weak_ref m_part; weak_ref
m_header; std::vector > m_parts; bool isRootPart() const; void initNewPart(ref part); public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_BODY_HPP_INCLUDED libvmime-0.9.1/vmime/contentDisposition.hpp0000644000175000017500000000527211250723264021364 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_CONTENTDISPOSITION_HPP_INCLUDED #define VMIME_CONTENTDISPOSITION_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" namespace vmime { /** Content disposition (basic type). */ class contentDisposition : public headerFieldValue { public: contentDisposition(); contentDisposition(const string& name); contentDisposition(const contentDisposition& disp); /** Return the content disposition type. * See the constants in vmime::dispositionTypes. * * @return name of the disposition type (eg. "inline") */ const string& getName() const; /** Set the content disposition type. * See the constants in vmime::dispositionTypes. * * @param name name of the disposition type */ void setName(const string& name); ref clone() const; void copyFrom(const component& other); contentDisposition& operator=(const contentDisposition& other); const std::vector > getChildComponents() const; contentDisposition& operator=(const string& name); bool operator==(const contentDisposition& value) const; bool operator!=(const contentDisposition& value) const; private: string m_name; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_CONTENTDISPOSITION_HPP_INCLUDED libvmime-0.9.1/vmime/stringContentHandler.hpp0000644000175000017500000000714711376250117021630 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_STRINGCONTENTHANDLER_HPP_INCLUDED #define VMIME_STRINGCONTENTHANDLER_HPP_INCLUDED #include "vmime/contentHandler.hpp" namespace vmime { class stringContentHandler : public contentHandler { public: stringContentHandler(); stringContentHandler(const string& buffer, const vmime::encoding& enc = NO_ENCODING); stringContentHandler(const utility::stringProxy& str, const vmime::encoding& enc = NO_ENCODING); stringContentHandler(const string& buffer, const string::size_type start, const string::size_type end, const vmime::encoding& enc = NO_ENCODING); ~stringContentHandler(); stringContentHandler(const stringContentHandler& cts); stringContentHandler& operator=(const stringContentHandler& cts); ref clone() const; // Set the data contained in the body. // // The two first functions take advantage of the COW (copy-on-write) system that // might be implemented into std::string. This is done using "stringProxy" object. // // Set "enc" parameter to anything other than NO_ENCODING if the data managed by // this content handler is already encoded with the specified encoding (so, no // encoding/decoding will be performed on generate()/extract()). Note that the // data may be re-encoded (that is, decoded and encoded) if the encoding passed // to generate() is different from this one... // // The 'length' parameter is optional (user-defined). You can pass 0 if you want, // VMime does not make use of it. void setData(const utility::stringProxy& str, const vmime::encoding& enc = NO_ENCODING); void setData(const string& buffer, const vmime::encoding& enc = NO_ENCODING); void setData(const string& buffer, const string::size_type start, const string::size_type end, const vmime::encoding& enc = NO_ENCODING); stringContentHandler& operator=(const string& buffer); void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; string::size_type getLength() const; bool isEncoded() const; const vmime::encoding& getEncoding() const; bool isEmpty() const; bool isBuffered() const; private: // Equals to NO_ENCODING if data is not encoded, otherwise this // specifies the encoding that have been used to encode the data. vmime::encoding m_encoding; // The actual data utility::stringProxy m_string; }; } // vmime #endif // VMIME_STRINGCONTENTHANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/attachmentHelper.hpp0000644000175000017500000000774711441357477021001 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_ATTACHMENTHELPER_HPP_INCLUDED #define VMIME_ATTACHMENTHELPER_HPP_INCLUDED #include "vmime/config.hpp" #include "vmime/attachment.hpp" #include "vmime/message.hpp" namespace vmime { /** Retrieve attachment information from message parts. */ class attachmentHelper { public: /** Options for use with the following functions: * findAttachmentsInMessage, * getBodyPartAttachment, * and isBodyPartAnAttachment. */ enum FindOptions { INLINE_OBJECTS = (1 << 0) /**< Recognize and return inline objects. The aim is to consider MHTML objects (parts with a "Content-Id" or a "Content-Location", such as inline images) as attachments. */ }; /** Test whether a body part is an attachment. * * @param part message part to test * @param options search options (see FindOptions) * @return true if the part is an attachment, false otherwise */ static bool isBodyPartAnAttachment(ref part, const unsigned int options = 0); /** Return attachment information in the specified body part. * If the specified body part does not contain attachment * information (ie. is not an attachment), NULL is returned. * * @param part message part in which to search * @param options search options (see FindOptions) * @return attachment found in the part, or NULL */ static ref getBodyPartAttachment(ref part, const unsigned int options = 0); /** Find all attachments contained in the specified part * and all its children parts. * This is simply a recursive call to getBodyPartAttachment(). * * @param part part in which to search * @param options search options (see FindOptions) * @return a list of attachments found */ static const std::vector > findAttachmentsInBodyPart(ref part, const unsigned int options = 0); /** Find all attachments contained in the specified message. * This is simply a recursive call to getBodyPartAttachment(). * * @param msg message in which to search * @param options search options (see FindOptions) * @return a list of attachments found */ static const std::vector > findAttachmentsInMessage(ref msg, const unsigned int options = 0); /** Add an attachment to the specified message. * * @param msg message into which to add the attachment * @param att attachment to add */ static void addAttachment(ref msg, ref att); /** Add a message attachment to the specified message. * * @param msg message into which to add the attachment * @param amsg message to attach */ static void addAttachment(ref msg, ref amsg); protected: static ref findBodyPart (ref part, const mediaType& type); }; } // vmime #endif // VMIME_ATTACHMENTHELPER_HPP_INCLUDED libvmime-0.9.1/vmime/parserHelpers.hpp0000644000175000017500000000414011250723264020275 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PARSERHELPERS_HPP_INCLUDED #define VMIME_PARSERHELPERS_HPP_INCLUDED #include "vmime/types.hpp" #include "vmime/utility/stringUtils.hpp" #include namespace vmime { class parserHelpers { public: static bool isSpace(const char_t c) { return (c == ' ' || c == '\t' || c == '\n' || c == '\r'); } static bool isDigit(const char_t c) { return (c >= '0' && c <= '9'); } static bool isAlpha(const char_t c) { return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); } static char_t toLower(const char_t c) { if (c >= 'A' && c <= 'Z') return ('a' + (c - 'A')); else return c; } // Checks whether a character is in the 7-bit US-ASCII charset static bool isAscii(const char_t c) { const unsigned int x = static_cast (c); return (x <= 127); } // Checks whether a character has a visual representation static bool isPrint(const char_t c) { const unsigned int x = static_cast (c); return (x >= 0x20 && x <= 0x7E); } }; } // vmime #endif // VMIME_PARSERHELPERS_HPP_INCLUDED libvmime-0.9.1/vmime/propertySet.hpp0000644000175000017500000002403211314151075020014 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_PROPERTY_HPP_INCLUDED #define VMIME_PROPERTY_HPP_INCLUDED #include #include #include #include #include "vmime/base.hpp" #include "vmime/exception.hpp" #include "vmime/utility/stringUtils.hpp" namespace vmime { /** Manage a list of (name,value) pairs. */ class propertySet : public object { public: /** A property holds a (name,value) pair. */ class property : public object { public: property(const string& name, const string& value); property(const string& name); property(const property& prop); /** Return the name of the property. * * @return property name */ const string& getName() const; /** Return the value of the property as a string. * * @return current value of the property */ const string& getValue() const; /** Set the value of the property as a string. * * @param value new value for property */ void setValue(const string& value); /** Set the value of the property as a generic type. * * @param value new value for property */ template void setValue(const TYPE& value) { std::ostringstream oss; oss.imbue(std::locale::classic()); // no formatting oss << value; m_value = oss.str(); } /** Get the value of the property as a generic type. * * @throw exceptions::invalid_property_type if the specified * type is incompatible with the string value (cannot be * converted using std::istringstream) * @return current value of the property */ template TYPE getValue() const { TYPE val = TYPE(); std::istringstream iss(m_value); iss.imbue(std::locale::classic()); // no formatting iss >> val; if (iss.fail()) throw exceptions::invalid_property_type(); return (val); } #ifdef VMIME_INLINE_TEMPLATE_SPECIALIZATION template <> void propertySet::property::setValue(const string& value) { m_value = value; } template <> void propertySet::property::setValue(const bool& value) { m_value = value ? "true" : "false"; } template <> string propertySet::property::getValue() const { return (m_value); } template <> bool propertySet::property::getValue() const { if (utility::stringUtils::toLower(m_value) == "true") return true; else { int val = 0; std::istringstream iss(m_value); iss.imbue(std::locale::classic()); // no formatting iss >> val; return (!iss.fail() && val != 0); } } #endif // VMIME_INLINE_TEMPLATE_SPECIALIZATION private: const string m_name; string m_value; }; protected: class propertyProxy { public: propertyProxy(const string& name, propertySet* set) : m_name(name), m_set(set) { } template propertyProxy& operator=(const TYPE& value) { m_set->setProperty(m_name, value); return (*this); } template void setValue(const TYPE& value) { m_set->setProperty(m_name, value); } template const TYPE getValue() const { return (m_set->getProperty (m_name)); } operator string() const { return (m_set->getProperty (m_name)); } private: const string m_name; propertySet* m_set; }; class constPropertyProxy { public: constPropertyProxy(const string& name, const propertySet* set) : m_name(name), m_set(set) { } template const TYPE getValue() const { return (m_set->getProperty (m_name)); } operator string() const { return (m_set->getProperty (m_name)); } private: const string m_name; const propertySet* m_set; }; public: propertySet(); propertySet(const string& props); propertySet(const propertySet& set); ~propertySet(); propertySet& operator=(const propertySet& set); /** Parse a string and extract one or more properties. * The string format is: name[=value](;name[=value])*. * * @param props string representing a list of properties */ void setFromString(const string& props); /** Remove all properties from the list. */ void removeAllProperties(); /** Remove the specified property. * * @param name name of the property to remove */ void removeProperty(const string& name); /** Test whether the specified property is set. * * @param name name of the property to test * @return true if the property is set (has a value), * false otherwise */ bool hasProperty(const string& name) const; /** Get the value of the specified property. * * @throw exceptions::no_such_property if the property does not exist * @param name property name * @return value of the specified property */ template const TYPE getProperty(const string& name) const { const ref prop = find(name); if (!prop) throw exceptions::no_such_property(name); //return (prop->getValue ()); // BUG: with g++ < 3.4 return (prop->template getValue ()); } /** Get the value of the specified property. * A default value can be returned if the property is not set. * * @param name property name * @param defaultValue value to return if the specified property * does not exist * @return value of the specified property or default value * if if does not exist */ template const TYPE getProperty(const string& name, const TYPE defaultValue) const { const ref prop = find(name); //return (prop ? prop->getValue () : defaultValue); // BUG: with g++ < 3.4 return (prop ? prop->template getValue () : defaultValue); } /** Change the value of the specified property or create * a new property set to the specified a value. * * @param name property name * @param value property value */ template void setProperty(const string& name, const TYPE& value) { findOrCreate(name)->setValue(value); } /** Return a proxy object to access the specified property * suitable for reading or writing. If the property does not * exist and the value is changed, a new property will * be created. * * @param name property name * @return proxy object for the specified property */ propertyProxy operator[](const string& name); /** Return a proxy object to access the specified property * suitable for reading only. * * @throw exceptions::no_such_property if the property does not exist * @return read-only proxy object for the specified property */ const constPropertyProxy operator[](const string& name) const; private: void parse(const string& props); class propFinder : public std::unary_function , bool> { public: propFinder(const string& name) : m_name(utility::stringUtils::toLower(name)) { } bool operator()(ref p) const { return (utility::stringUtils::toLower(p->getName()) == m_name); } private: const std::string m_name; }; ref find(const string& name) const; ref findOrCreate(const string& name); typedef std::list > list_type; list_type m_props; public: template static TYPE valueFromString(const string& value) { TYPE v = TYPE(); std::istringstream iss(value); iss.imbue(std::locale::classic()); // no formatting iss >> v; return v; } template static string valueToString(const TYPE& value) { std::ostringstream oss(value); oss.imbue(std::locale::classic()); // no formatting oss << value; return oss.str(); } #ifdef VMIME_INLINE_TEMPLATE_SPECIALIZATION template <> static string valueFromString(const string& value) { return value; } template <> static string valueToString(const string& value) { return value; } template <> static bool valueFromString(const string& value) { if (utility::stringUtils::toLower(value) == "true") return true; else { int val = 0; std::istringstream iss(value); iss.imbue(std::locale::classic()); // no formatting iss >> val; return (!iss.fail() && val != 0); } } template <> static string valueToString(const bool& value) { return (value ? "true" : "false"); } #endif // VMIME_INLINE_TEMPLATE_SPECIALIZATION /** Return the property list. * * @return list of properties */ const std::vector > getPropertyList() const; /** Return the property list. * * @return list of properties */ const std::vector > getPropertyList(); }; #ifndef VMIME_INLINE_TEMPLATE_SPECIALIZATION template <> void propertySet::property::setValue (const string& value); template <> void propertySet::property::setValue(const bool& value); template <> string propertySet::property::getValue() const; template <> bool propertySet::property::getValue() const; template <> string propertySet::valueFromString(const string& value); template <> string propertySet::valueToString(const string& value); template <> bool propertySet::valueFromString(const string& value); template <> string propertySet::valueToString(const bool& value); #endif // VMIME_INLINE_TEMPLATE_SPECIALIZATION } // vmime #endif // VMIME_PROPERTY_HPP_INCLUDED libvmime-0.9.1/vmime/streamContentHandler.hpp0000644000175000017500000000503511376250215021606 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_STREAMCONTENTHANDLER_HPP_INCLUDED #define VMIME_STREAMCONTENTHANDLER_HPP_INCLUDED #include "vmime/contentHandler.hpp" namespace vmime { class streamContentHandler : public contentHandler { public: streamContentHandler(); streamContentHandler(ref is, const utility::stream::size_type length, const vmime::encoding& enc = NO_ENCODING); ~streamContentHandler(); streamContentHandler(const streamContentHandler& cts); streamContentHandler& operator=(const streamContentHandler& cts); ref clone() const; void setData(ref is, const utility::stream::size_type length, const vmime::encoding& enc = NO_ENCODING); void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const; void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const; string::size_type getLength() const; bool isEncoded() const; const vmime::encoding& getEncoding() const; bool isEmpty() const; bool isBuffered() const; private: // Equals to NO_ENCODING if data is not encoded, otherwise this // specifies the encoding that have been used to encode the data. vmime::encoding m_encoding; // Actual data mutable ref m_stream; string::size_type m_length; }; } // vmime #endif // VMIME_STREAMCONTENTHANDLER_HPP_INCLUDED libvmime-0.9.1/vmime/header.hpp0000644000175000017500000001743011250723264016714 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_HEADER_HPP_INCLUDED #define VMIME_HEADER_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/component.hpp" #include "vmime/exception.hpp" #include "vmime/headerField.hpp" #include "vmime/headerFieldFactory.hpp" namespace vmime { class bodyPart; /** Header section of a MIME part. */ class header : public component { friend class bodyPart; friend class body; friend class message; public: header(); ~header(); #define FIELD_ACCESS(methodName, fieldName) \ ref methodName() { return getField(fields::fieldName); } \ ref methodName() const { return findField(fields::fieldName); } FIELD_ACCESS(From, FROM) FIELD_ACCESS(Sender, SENDER) FIELD_ACCESS(ReplyTo, REPLY_TO) FIELD_ACCESS(DeliveredTo, DELIVERED_TO) FIELD_ACCESS(InReplyTo, IN_REPLY_TO) FIELD_ACCESS(ReturnPath, RETURN_PATH) FIELD_ACCESS(References, REFERENCES) FIELD_ACCESS(To, TO) FIELD_ACCESS(Cc, CC) FIELD_ACCESS(Bcc, BCC) FIELD_ACCESS(Date, DATE) FIELD_ACCESS(Subject, SUBJECT) FIELD_ACCESS(Organization, ORGANIZATION) FIELD_ACCESS(UserAgent, USER_AGENT) FIELD_ACCESS(ContentType, CONTENT_TYPE) FIELD_ACCESS(ContentDescription, CONTENT_DESCRIPTION) FIELD_ACCESS(ContentTransferEncoding, CONTENT_TRANSFER_ENCODING) FIELD_ACCESS(MimeVersion, MIME_VERSION) FIELD_ACCESS(ContentDisposition, CONTENT_DISPOSITION) FIELD_ACCESS(ContentId, CONTENT_ID) FIELD_ACCESS(MessageId, MESSAGE_ID) FIELD_ACCESS(ContentLocation, CONTENT_LOCATION) FIELD_ACCESS(OriginalMessageId, ORIGINAL_MESSAGE_ID) FIELD_ACCESS(Disposition, DISPOSITION) FIELD_ACCESS(DispositionNotificationTo, DISPOSITION_NOTIFICATION_TO) #undef FIELD_ACCESS /** Checks whether (at least) one field with this name exists. * * @return true if at least one field with the specified name * exists, or false otherwise */ bool hasField(const string& fieldName) const; /** Find the first field that matches the specified name. * If no field is found, an exception is thrown. * * @throw exceptions::no_such_field if no field with this name exists * @return first field with the specified name */ ref findField(const string& fieldName) const; /** Find all fields that match the specified name. * If no field is found, an empty vector is returned. * * @return list of fields with the specified name */ std::vector > findAllFields(const string& fieldName); /** Find the first field that matches the specified name. * If no field is found, one will be created and inserted into * the header. * * @return first field with the specified name or a new field * if no field is found */ ref getField(const string& fieldName); /** Add a field at the end of the list. * * @param field field to append */ void appendField(ref field); /** Insert a new field before the specified field. * * @param beforeField field before which the new field will be inserted * @param field field to insert * @throw exceptions::no_such_field if the field is not in the list */ void insertFieldBefore(ref beforeField, ref field); /** Insert a new field before the specified position. * * @param pos position at which to insert the new field (0 to insert at * the beginning of the list) * @param field field to insert */ void insertFieldBefore(const int pos, ref field); /** Insert a new field after the specified field. * * @param afterField field after which the new field will be inserted * @param field field to insert * @throw exceptions::no_such_field if the field is not in the list */ void insertFieldAfter(ref afterField, ref field); /** Insert a new field after the specified position. * * @param pos position of the field before the new field * @param field field to insert */ void insertFieldAfter(const int pos, ref field); /** Remove the specified field from the list. * * @param field field to remove * @throw exceptions::no_such_field if the field is not in the list */ void removeField(ref field); /** Remove the field at the specified position. * * @param pos position of the field to remove */ void removeField(const int pos); /** Remove all fields from the list. */ void removeAllFields(); /** Remove all fields with the specified name. */ void removeAllFields(const string& fieldName); /** Return the number of fields in the list. * * @return number of fields */ int getFieldCount() const; /** Tests whether the list of fields is empty. * * @return true if there is no field, false otherwise */ bool isEmpty() const; /** Return the field at the specified position. * * @param pos position * @return field at position 'pos' */ const ref getFieldAt(const int pos); /** Return the field at the specified position. * * @param pos position * @return field at position 'pos' */ const ref getFieldAt(const int pos) const; /** Return the field list. * * @return list of fields */ const std::vector > getFieldList() const; /** Return the field list. * * @return list of fields */ const std::vector > getFieldList(); ref clone() const; void copyFrom(const component& other); header& operator=(const header& other); const std::vector > getChildComponents() const; private: std::vector > m_fields; class fieldHasName { public: fieldHasName(const string& name); bool operator() (const ref & field); private: string m_name; }; class fieldHasNotName { public: fieldHasNotName(const string& name); bool operator() (const ref & field); private: string m_name; }; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_HEADER_HPP_INCLUDED libvmime-0.9.1/vmime/addressList.hpp0000644000175000017500000001172311250723264017744 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_ADDRESSLIST_HPP_INCLUDED #define VMIME_ADDRESSLIST_HPP_INCLUDED #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" #include "vmime/address.hpp" namespace vmime { class mailboxList; /** A list of addresses. */ class addressList : public headerFieldValue { public: addressList(); addressList(const addressList& addrList); ~addressList(); ref clone() const; void copyFrom(const component& other); addressList& operator=(const addressList& other); addressList& operator=(const mailboxList& other); const std::vector > getChildComponents() const; /** Add a address at the end of the list. * * @param addr address to append */ void appendAddress(ref
addr); /** Insert a new address before the specified address. * * @param beforeAddress address before which the new address will be inserted * @param addr address to insert * @throw exceptions::no_such_address if the address is not in the list */ void insertAddressBefore(ref
beforeAddress, ref
addr); /** Insert a new address before the specified position. * * @param pos position at which to insert the new address (0 to insert at * the beginning of the list) * @param addr address to insert */ void insertAddressBefore(const int pos, ref
addr); /** Insert a new address after the specified address. * * @param afterAddress address after which the new address will be inserted * @param addr address to insert * @throw exceptions::no_such_address if the address is not in the list */ void insertAddressAfter(ref
afterAddress, ref
addr); /** Insert a new address after the specified position. * * @param pos position of the address before the new address * @param addr address to insert */ void insertAddressAfter(const int pos, ref
addr); /** Remove the specified address from the list. * * @param addr address to remove * @throw exceptions::no_such_address if the address is not in the list */ void removeAddress(ref
addr); /** Remove the address at the specified position. * * @param pos position of the address to remove */ void removeAddress(const int pos); /** Remove all addresses from the list. */ void removeAllAddresses(); /** Return the number of addresses in the list. * * @return number of addresses */ int getAddressCount() const; /** Tests whether the list of addresses is empty. * * @return true if there is no address, false otherwise */ bool isEmpty() const; /** Return the address at the specified position. * * @param pos position * @return address at position 'pos' */ ref
getAddressAt(const int pos); /** Return the address at the specified position. * * @param pos position * @return address at position 'pos' */ const ref getAddressAt(const int pos) const; /** Return the address list. * * @return list of addresses */ const std::vector > getAddressList() const; /** Return the address list. * * @return list of addresses */ const std::vector > getAddressList(); /** Return a list of mailboxes. * If some addresses are actually groups, mailboxes are recursively * extracted from these groups. * * @return list of mailboxes */ ref toMailboxList() const; private: std::vector > m_list; public: using component::parse; using component::generate; // Component parsing & assembling void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; }; } // vmime #endif // VMIME_ADDRESSLIST_HPP_INCLUDED libvmime-0.9.1/vmime/base.hpp0000644000175000017500000001711011333330451016363 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_BASE_HPP_INCLUDED #define VMIME_BASE_HPP_INCLUDED #include #include #include #include #include #include #include "vmime/config.hpp" #include "vmime/types.hpp" #include "vmime/constants.hpp" #include "vmime/utility/stream.hpp" #include "vmime/utility/smartPtr.hpp" namespace vmime { class text; class word; class charset; // "Null" strings extern const string NULL_STRING; extern const text NULL_TEXT; extern const word NULL_WORD; // // Library name and version // const string libname(); const string libversion(); const string libapi(); // // Helpful functions used for array -> iterator conversion // template inline T const* begin(T const (&array)[N]) { return (array); } template inline T const* end(T const (&array)[N]) { return (array + N); } template inline size_t count(T const (&array)[N]) { return (N); } // Copy one vector to another, with type conversion template void copy_vector(const T1& v1, T2& v2) { const typename T1::size_type count = v1.size(); v2.resize(count); for (typename T1::size_type i = 0 ; i < count ; ++i) v2[i] = v1[i]; } /* RFC#2822 2.1.1. Line Length Limits There are two limits that this standard places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF. The 998 character limit is due to limitations in many implementations which send, receive, or store Internet Message Format messages that simply cannot handle more than 998 characters on a line. Receiving implementations would do well to handle an arbitrarily large number of characters in a line for robustness sake. However, there are so many implementations which (in compliance with the transport requirements of [RFC2821]) do not accept messages containing more than 1000 character including the CR and LF per line, it is important for implementations not to create such messages. The more conservative 78 character recommendation is to accommodate the many implementations of user interfaces that display these messages which may truncate, or disastrously wrap, the display of more than 78 characters per line, in spite of the fact that such implementations are non-conformant to the intent of this specification (and that of [RFC2821] if they actually cause information to be lost). Again, even though this limitation is put on messages, it is encumbant upon implementations which display messages to handle an arbitrarily large number of characters in a line (certainly at least up to the 998 character limit) for the sake of robustness. */ namespace lineLengthLimits { extern const string::size_type infinite; enum { max = 998, convenient = 78 }; } // New line sequence to be used when folding header fields. extern const string NEW_LINE_SEQUENCE; extern const string::size_type NEW_LINE_SEQUENCE_LENGTH; // CR-LF sequence extern const string CRLF; // Mime version extern const string SUPPORTED_MIME_VERSION; /** Utility classes. */ namespace utility { } #ifndef VMIME_BUILDING_DOC /** Work-around for friend template functions. * * Make this class a friend if you want to be able to use * vmime::create() with private/protected constructors. */ class creator { public: template static ref create() { return ref ::fromPtr(new T); } template static ref create(const P0& p0) { return ref ::fromPtr(new T(p0)); } template static ref create(const P0& p0, const P1& p1) { return ref ::fromPtr(new T(p0, p1)); } template static ref create(const P0& p0, const P1& p1, const P2& p2) { return ref ::fromPtr(new T(p0, p1, p2)); } template static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3) { return ref ::fromPtr(new T(p0, p1, p2, p3)); } template static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { return ref ::fromPtr(new T(p0, p1, p2, p3, p4)); } }; #endif // VMIME_BUILDING_DOC /** Create a new object and return a reference to it. * @return reference to the new object */ template static ref create() { return creator::create (); } /** Create a new object and return a reference to it. * @return reference to the new object */ template static ref create(const P0& p0) { return creator::create (p0); } /** Create a new object and return a reference to it. * @return reference to the new object */ template static ref create(const P0& p0, const P1& p1) { return creator::create (p0, p1); } /** Create a new object and return a reference to it. * @return reference to the new object */ template static ref create(const P0& p0, const P1& p1, const P2& p2) { return creator::create (p0, p1, p2); } /** Create a new object and return a reference to it. * @return reference to the new object */ template static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3) { return creator::create (p0, p1, p2, p3); } /** Create a new object and return a reference to it. * @return reference to the new object */ template static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { return creator::create (p0, p1, p2, p3, p4); } /** Clone helper. * Use "vmime::clone(obj)" instead of "obj->clone().cast ()". */ template ref clone(ref x) { return x->clone().template dynamicCast (); } /** Clone helper. * Use "vmime::clone(obj)" instead of "obj.clone().cast ()". */ template ref clone(const T& x) { return x.clone().template dynamicCast (); } /** Downcast helper. * Usage: vmime::dynamicCast (obj), where 'obj' is of * type Type, and DerivedType is derived from Type. */ template ref dynamicCast(ref y) { return y.dynamicCast (); } } // vmime #endif // VMIME_BASE_HPP_INCLUDED libvmime-0.9.1/vmime/htmlTextPart.hpp0000644000175000017500000001310311250723264020115 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_HTMLTEXTPART_HPP_INCLUDED #define VMIME_HTMLTEXTPART_HPP_INCLUDED #include "vmime/textPart.hpp" #include "vmime/messageId.hpp" #include "vmime/encoding.hpp" #include "vmime/contentHandler.hpp" namespace vmime { /** Text part of type 'text/html'. */ class htmlTextPart : public textPart { public: htmlTextPart(); ~htmlTextPart(); const mediaType getType() const; const charset& getCharset() const; void setCharset(const charset& ch); const ref getPlainText() const; void setPlainText(ref plainText); const ref getText() const; void setText(ref text); /** Embedded object (eg: image for <IMG> tag). */ class embeddedObject : public object { public: embeddedObject(ref data, const encoding& enc, const string& id, const mediaType& type); /** Return data stored in this embedded object. * * @return stored data */ const ref getData() const; /** Return the encoding used for data in this * embedded object. * * @return data encoding */ const vmime::encoding& getEncoding() const; /** Return the identifier of this embedded object. * * @return object identifier */ const string& getId() const; /** Return the content type of data stored in * this embedded object. * * @return data type */ const mediaType& getType() const; private: ref m_data; encoding m_encoding; string m_id; mediaType m_type; }; /** Test the existence of an embedded object given its identifier. * * @param id object identifier * @return true if an object with this identifier exists, * false otherwise */ bool hasObject(const string& id) const; /** Return the embedded object with the specified identifier. * * @throw exceptions::no_object_found() if no object has been found * @param id object identifier * @return embedded object with the specified identifier */ const ref findObject(const string& id) const; /** Return the number of embedded objects. * * @return number of embedded objects */ int getObjectCount() const; /** Return the embedded object at the specified position. * * @param pos position of the embedded object * @return embedded object at position 'pos' */ const ref getObjectAt(const int pos) const; /** Embed an object and returns a string which identifies it. * The returned identifier is suitable for use in the 'src' attribute * of an tag. * * \deprecated Use the addObject() methods which take a 'contentHandler' * parameter type instead. * * @param data object data * @param type data type * @return an unique object identifier used to identify the new * object among all other embedded objects */ const string addObject(const string& data, const mediaType& type); /** Embed an object and returns a string which identifies it. * The returned identifier is suitable for use in the 'src' attribute * of an tag. * * @param data object data * @param type data type * @return an unique object identifier used to identify the new * object among all other embedded objects */ const string addObject(ref data, const mediaType& type); /** Embed an object and returns a string which identifies it. * The returned identifier is suitable for use in the 'src' attribute * of an tag. * * @param data object data * @param enc data encoding * @param type data type * @return an unique object identifier used to identify the new * object among all other embedded objects */ const string addObject(ref data, const encoding& enc, const mediaType& type); int getPartCount() const; void generateIn(ref message, ref parent) const; void parse(ref message, ref parent, ref textPart); private: ref m_plainText; ref m_text; charset m_charset; std::vector > m_objects; void findEmbeddedParts(const bodyPart& part, std::vector >& cidParts, std::vector >& locParts); void addEmbeddedObject(const bodyPart& part, const string& id); bool findPlainTextPart(const bodyPart& part, const bodyPart& parent, const bodyPart& textPart); static const string cleanId(const string& id); }; } // vmime #endif // VMIME_HTMLTEXTPART_HPP_INCLUDED libvmime-0.9.1/vmime/textPart.hpp0000644000175000017500000000611611250723264017276 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #ifndef VMIME_TEXTPART_HPP_INCLUDED #define VMIME_TEXTPART_HPP_INCLUDED #include "vmime/bodyPart.hpp" #include "vmime/mediaType.hpp" #include "vmime/charset.hpp" #include "vmime/contentHandler.hpp" namespace vmime { /** Generic text part. */ class textPart : public object { friend class textPartFactory; friend class messageBuilder; // for generateIn, getPartCount friend class messageParser; // for parse public: virtual ~textPart() { } /** Return the type of text part (eg: "text/html"). * * @return type of text part */ virtual const mediaType getType() const = 0; /** Return the charset used to encode text in the * text part. * * @return text charset */ virtual const charset& getCharset() const = 0; /** Set the charset used to encode text in the * text part. * * @param ch text charset */ virtual void setCharset(const charset& ch) = 0; /** Return the text contained in the part. * * @return text of the part */ virtual const ref getText() const = 0; /** Set the text contained in the part. * * @param text text of the part */ virtual void setText(ref text) = 0; /** Return the actual body parts this text part is composed of. * For example, HTML parts are composed of two parts: one "text/html" * part, and the plain text part "text/plain". * * @return number of body parts */ virtual int getPartCount() const = 0; /** Generate the text part(s) into the specified message. * * @param message the message * @param parent body part into which generate this part */ virtual void generateIn(ref message, ref parent) const = 0; /** Parse the text part(s) from the specified message. * * @param message message containing the text part * @param parent part containing the text part * @param textPart actual text part */ virtual void parse(ref message, ref parent, ref textPart) = 0; }; } // vmime #endif // VMIME_TEXTPART_HPP_INCLUDED libvmime-0.9.1/README0000644000175000017500000000000611250723264014505 0ustar mnordstrmnordstr TODO libvmime-0.9.1/configure0000755000175000017500000260047111470477540015561 0ustar mnordstrmnordstr#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for VMime Library 0.9.1. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: vincent@vincent-richard.net about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error ERROR [LINENO LOG_FD] # --------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with status $?, using 1 if that was 0. as_fn_error () { as_status=$?; test $as_status -eq 0 && as_status=1 if test "$3"; then as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 fi $as_echo "$as_me: error: $1" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='VMime Library' PACKAGE_TARNAME='vmime' PACKAGE_VERSION='0.9.1' PACKAGE_STRING='VMime Library 0.9.1' PACKAGE_BUGREPORT='vincent@vincent-richard.net' PACKAGE_URL='' ac_unique_file="src/base.cpp" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS VMIME_ADDITIONAL_PC_LIBS EXTRA_LIBS EXTRA_CFLAGS PKGCONFIG_LIBS PKGCONFIG_CFLAGS LIBRARY_LD_FLAGS VMIME_PKGCONFIGDIR VMIME_BUILTIN_PLATFORM_POSIX_FALSE VMIME_BUILTIN_PLATFORM_POSIX_TRUE VMIME_BUILTIN_PLATFORM_WINDOWS_FALSE VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE PTHREAD_CFLAGS PTHREAD_LIBS acx_pthread_config SENDMAIL VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_FALSE VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE VMIME_BUILTIN_MESSAGING_PROTO_IMAP_FALSE VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE VMIME_BUILTIN_MESSAGING_PROTO_SMTP_FALSE VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE VMIME_BUILTIN_MESSAGING_PROTO_POP3_FALSE VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE VMIME_HAVE_TLS_SUPPORT_FALSE VMIME_HAVE_TLS_SUPPORT_TRUE LIBGNUTLS_LIBS LIBGNUTLS_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG GSASL_LIBS GSASL_REQUIRED VMIME_HAVE_SASL_SUPPORT_FALSE VMIME_HAVE_SASL_SUPPORT_TRUE GSASL_AVAIL_REQUIRED GSASL_AVAIL_LIBS VMIME_HAVE_MESSAGING_FEATURES_FALSE VMIME_HAVE_MESSAGING_FEATURES_TRUE VMIME_DEBUG_FALSE VMIME_DEBUG_TRUE LTLIBICONV LIBICONV PTHREAD_CC THREAD_LIBS THREAD_FLAGS thrprefix CXXCPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL RANLIB AR OBJDUMP NM ac_ct_DUMPBIN DUMPBIN LD FGREP SED LIBTOOL LN_S EGREP GREP CPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_os target_vendor target_cpu target host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBRARY_RELEASE LIBRARY_VERSION LIBRARY_NAME GENERIC_VERSIONED_LIBRARY_NAME GENERIC_LIBRARY_NAME target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_maintainer_mode enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_gnu_ld enable_libtool_lock with_pthread with_linuxthreads enable_rpath with_libiconv_prefix enable_debug enable_messaging enable_sasl enable_tls enable_messaging_proto_pop3 enable_messaging_proto_smtp enable_messaging_proto_imap enable_messaging_proto_maildir enable_messaging_proto_sendmail enable_platform_windows enable_platform_posix ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC CPP CXXCPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR LIBGNUTLS_CFLAGS LIBGNUTLS_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error "unrecognized option: \`$ac_option' Try \`$0 --help' for more information." ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures VMime Library 0.9.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/vmime] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of VMime Library 0.9.1:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-rpath do not hardcode runtime library paths --enable-debug Turn on debugging, default: disabled --enable-messaging Enable messaging support and connection to mail servers, default: enabled --enable-sasl Enable SASL support with GNU SASL, default: enabled --enable-tls Enable TLS/SSL support with GNU TLS, default: enabled --enable-messaging-proto-pop3 Enable built-in support for protocol 'pop3', default: enabled --enable-messaging-proto-smtp Enable built-in support for protocol 'smtp', default: enabled --enable-messaging-proto-imap Enable built-in support for protocol 'imap', default: enabled --enable-messaging-proto-maildir Enable built-in support for protocol 'maildir', default: enabled --enable-messaging-proto-sendmail Enable built-in support for protocol 'sendmail', default: enabled --enable-platform-windows Compile built-in platform handler for 'windows' , default: disabled, except if default for your platform --enable-platform-posix Compile built-in platform handler for 'posix' , default: disabled, except if default for your platform Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-pthread=lib using specified pthread library --with-linuxthreads use linux kernel mode library --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags CPP C preprocessor CXXCPP C++ preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path LIBGNUTLS_CFLAGS C compiler flags for LIBGNUTLS, overriding pkg-config LIBGNUTLS_LIBS linker flags for LIBGNUTLS, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF VMime Library configure 0.9.1 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_type # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to vincent@vincent-richard.net ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_check_func LINENO FUNC VAR # ------------------------------------ # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_cxx_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_func # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_compute_int LINENO EXPR VAR INCLUDES # ---------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_cxx_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by VMime Library $as_me 0.9.1, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then ac_site_file1=$CONFIG_SITE elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in autotools "$srcdir"/autotools; do for ac_t in install-sh install.sh shtool; do if test -f "$ac_dir/$ac_t"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/$ac_t -c" break 2 fi done done if test -z "$ac_aux_dir"; then as_fn_error "cannot find install-sh, install.sh, or shtool in autotools \"$srcdir\"/autotools" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Library name GENERIC_LIBRARY_NAME="vmime" GENERIC_VERSIONED_LIBRARY_NAME="vmime" LIBRARY_NAME="libvmime" # Library version LIBRARY_VERSION="0:0:0" LIBRARY_RELEASE="0" # # Miscellaneous init stuff # # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if test "${ac_cv_path_mkdir+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE=vmime VERSION=0.9.1 cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers config.h" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE VMIME_ADDITIONAL_DEFINES="" VMIME_ADDITIONAL_PC_LIBS="" # # Check compilers, processors, etc # ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "no acceptable C compiler found in \$PATH See \`config.log' for more details." "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { as_fn_set_status 77 as_fn_error "C compiler cannot create executables See \`config.log' for more details." "$LINENO" 5; }; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "cannot compute suffix of object files: cannot compile See \`config.log' for more details." "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if test "${ac_cv_c_const+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if test "${ac_cv_c_inline+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " eval as_val=\$$as_ac_Header if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if test "${ac_cv_header_stdbool_h+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; bool e = &s; char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; # if defined __xlc__ || defined __GNUC__ /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 reported by James Lemley on 2005-10-05; see http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html This test is not quite right, since xlc is allowed to reject this program, as the initializer for xlcbug is not one of the forms that C requires support for. However, doing the test right would require a runtime test, and that would make cross-compilation harder. Let us hope that IBM fixes the xlc bug, and also adds support for this kind of constant expression. In the meantime, this test will reject xlc, which is OK, since our stdbool.h substitute should suffice. We also test this with GCC, where it should work, to detect more quickly whether someone messes up the test in the future. */ char digs[] = "0123456789"; int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); # endif /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_ac_Header=yes" else eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Header if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if test "${ac_cv_search_opendir+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then : break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if test "${ac_cv_search_opendir+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then : break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if test "${ac_cv_c_const+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.2.10' macro_revision='1.3175' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`print -r -- -n 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if test "${lt_cv_path_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if test "${lt_cv_prog_gnu_ld+set}" = set; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if test "${lt_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if test "${lt_cv_nm_interface+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if test "${lt_cv_sys_max_cmd_len+set}" = set; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if test "${lt_cv_ld_reload_flag+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if test "${lt_cv_deplibs_check_method+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi else AR="$ac_cv_prog_AR" fi test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if test "${lt_cv_cc_needs_belf+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_NMEDIT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_OTOOL64+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if test "${lt_cv_apple_cc_single_mod+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if test "${lt_cv_ld_force_load+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; pic_mode="$withval" else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if test "${lt_cv_objdir+set}" = set; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' lt_prog_compiler_pic='-Xcompiler -fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ F* | *Sun*Fortran*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 $as_echo "$lt_prog_compiler_pic" >&6; } # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if test "${lt_cv_prog_compiler_static_works+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld='-rpath $libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path='`cygpath -w "$srcfile"`' enable_shared_with_static_runtimes=yes ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; freebsd1*) ld_shlibs=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if test "${lt_cv_prog_compiler__b+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo(void) {} _ACEOF if ac_fn_c_try_link "$LINENO"; then : archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if test "${lt_cv_archive_cmds_need_lc+set}" = set; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = x""yes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if test "${ac_cv_lib_dld_shl_load+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if test "${ac_cv_lib_svld_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if test "${ac_cv_lib_dld_dld_link+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if test "${lt_cv_dlopen_self+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) void fnord () __attribute__((visibility("default"))); #endif void fnord () { int i=42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if test "${lt_cv_dlopen_self_static+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) void fnord () __attribute__((visibility("default"))); #endif void fnord () { int i=42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CC="$lt_save_CC" if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if test "${ac_cv_prog_CXXCPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details." "$LINENO" 5; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_flag_spec_ld_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds reload_flag_CXX=$reload_flag reload_cmds_CXX=$reload_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC compiler_CXX=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if test "${lt_cv_path_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if test "${lt_cv_prog_gnu_ld+set}" = set; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec_CXX='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty # executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' ${wl}-bernotok' allow_undefined_flag_CXX=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' fi archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared # libraries. archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' export_dynamic_flag_spec_CXX='${wl}--export-all-symbols' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec_CXX='' fi link_all_deplibs_CXX=yes allow_undefined_flag_CXX="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" if test "$lt_cv_apple_cc_single_mod" != "yes"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi else ld_shlibs_CXX=no fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd[12]*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; gnu*) ;; haiku*) archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs_CXX=yes ;; hpux9*) hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='${wl}-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5].* | *pgcpp\ [1-5].*) prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) ld_shlibs_CXX=yes ;; openbsd2*) # C++ shared libraries are fairly broken ld_shlibs_CXX=no ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='${wl}-E' whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else ld_shlibs_CXX=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then no_undefined_flag_CXX=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='${wl}-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_CXX='${wl}-z,text' allow_undefined_flag_CXX='${wl}-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ '"$old_archive_cmds_CXX" reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ '"$reload_cmds_CXX" ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no GCC_CXX="$GXX" LD_CXX="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p in -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX="${prev}${p}" else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX="${prev}${p}" else postdeps_CXX="${postdeps_CXX} ${prev}${p}" fi fi ;; *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$predep_objects_CXX"; then predep_objects_CXX="$p" else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX="$p" else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext # PORTME: override above test on systems where it is broken case $host_os in interix[3-9]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static_CXX= ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix[4-9]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) # IBM XL 8.0, 9.0 on PPC and BlueGene lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_CXX" >&5 $as_echo "$lt_prog_compiler_pic_CXX" >&6; } # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works_CXX=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then : else lt_prog_compiler_static_CXX= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if test "${lt_cv_archive_cmds_need_lc_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc_CXX=no else lt_cv_archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 $as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test "X$hardcode_automatic_CXX" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct_CXX" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && test "$hardcode_minus_L_CXX" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } if test "$hardcode_action_CXX" = relink || test "$inherit_rpath_CXX" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi fi # test -n "$compiler" CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_config_commands="$ac_config_commands libtool" # Only expand once: ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "no acceptable C compiler found in \$PATH See \`config.log' for more details." "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." "$LINENO" 5; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if test "${ac_cv_search_strerror+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char strerror (); int main () { return strerror (); ; return 0; } _ACEOF for ac_lib in '' cposix; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_strerror=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_strerror+set}" = set; then : break fi done if test "${ac_cv_search_strerror+set}" = set; then : else ac_cv_search_strerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5 $as_echo "$ac_cv_search_strerror" >&6; } ac_res=$ac_cv_search_strerror if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system meets Posix.1" >&5 $as_echo_n "checking whether system meets Posix.1... " >&6; } if test "${ost_cv_sys_posix1+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #ifndef _POSIX_VERSION fatal #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ost_cv_sys_posix1=yes else ost_cv_sys_posix1=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ost_cv_sys_posix1" >&5 $as_echo "$ost_cv_sys_posix1" >&6; } if test $ost_cv_sys_posix1 = no ; then for ac_header in unistd.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" if test "x$ac_cv_header_unistd_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UNISTD_H 1 _ACEOF fi done else $as_echo "#define HAVE_UNISTD_H 1" >>confdefs.h fi for ac_header in features.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "features.h" "ac_cv_header_features_h" "$ac_includes_default" if test "x$ac_cv_header_features_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FEATURES_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi for ac_header in sys/time.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" if test "x$ac_cv_header_sys_time_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_TIME_H 1 _ACEOF fi done THREAD_FLAGS="" THREAD_LIBS="" ost_cv_thread_library="none" ost_cv_rt_library="none" ost_cv_cxx_mode=false # Check whether --with-pthread was given. if test "${with_pthread+set}" = set; then : withval=$with_pthread; if test "$withval" != "" ; then ost_cv_thread_library=$withval ; fi fi # Check whether --with-linuxthreads was given. if test "${with_linuxthreads+set}" = set; then : withval=$with_linuxthreads; ost_cv_thread_library=lthread $as_echo "#define WITH_LINUXTHREADS 1" >>confdefs.h if test "$withval" != "yes" ; then THREAD_FLAGS="-D__USE_GNU -D__USE_UNIX98 -I$withval $THREAD_FLAGS" CFLAGS="-D__USE_GNU -D__USE_UNIX98 -I$withval $CFLAGS" else THREAD_FLAGS="-D__USE_GNU -D__USE_UNIX98 -I/usr/local/include/pthread/linuxthreads $THREAD_FLAGS" CFLAGS="-D__USE_GNU -D__USE_UNIX98 -I/usr/local/include/pthread/linuxthreads $CFLAGS" fi fi for ac_header in pthread.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF $as_echo "#define HAVE_PTHREAD_H 1" >>confdefs.h ost_cv_posix_threads=yes else ost_cv_posix_threads=no fi done if test $ost_cv_posix_threads = no ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu SAVE_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -pthread" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define HAVE_PTHREAD_H 1" >>confdefs.h ost_cv_cxx_mode=true ost_cv_posix_threads=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="$SAVE_CXXFLAGS" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ost_cv_posix_atomic=no for ac_header in sys/atomic_op.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/atomic_op.h" "ac_cv_header_sys_atomic_op_h" "$ac_includes_default" if test "x$ac_cv_header_sys_atomic_op_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_ATOMIC_OP_H 1 _ACEOF $as_echo "#define HAVE_ATOMIC_AIX 1" >>confdefs.h fi done for ac_header in sys/atomic.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/atomic.h" "ac_cv_header_sys_atomic_h" "$ac_includes_default" if test "x$ac_cv_header_sys_atomic_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_ATOMIC_H 1 _ACEOF ost_cv_posix_sys_atomic=yes else ost_cv_posix_sys_atomic=no fi done if test $ost_cv_posix_sys_atomic = yes ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for atomic_t" >&5 $as_echo_n "checking for atomic_t... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { atomic_t at; at.counter = 1; atomic_dec_and_test(&at); atomic_sub(4, &at); atomic_inc(&at); atomic_add(3, &at); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ost_cv_posix_atomic=yes $as_echo "#define HAVE_WORKING_SYS_ATOMIC_H 1" >>confdefs.h else ost_cv_posix_atomic=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ost_cv_posix_atomic" >&5 $as_echo "$ost_cv_posix_atomic" >&6; } fi for ac_header in bits/atomicity.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "bits/atomicity.h" "ac_cv_header_bits_atomicity_h" "$ac_includes_default" if test "x$ac_cv_header_bits_atomicity_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_BITS_ATOMICITY_H 1 _ACEOF ost_cv_bits_atomicity=yes else ost_cv_bits_atomicity=no fi done if test $ost_cv_bits_atomicity = yes ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _Atomic_word" >&5 $as_echo_n "checking for _Atomic_word... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { _Atomic_word i = 0; __atomic_add(&i, 1); __exchange_and_add(&i, 1); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ost_cv_gcc_atomic=yes $as_echo "#define HAVE_GCC_BITS_ATOMIC 1" >>confdefs.h else ost_cv_gcc_atomic=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ost_cv_gcc_atomic" >&5 $as_echo "$ost_cv_gcc_atomic" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __gnu_cxx::_Atomic_word" >&5 $as_echo_n "checking for __gnu_cxx::_Atomic_word... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { using namespace __gnu_cxx; _Atomic_word i = 0; __atomic_add(&i, 1); __exchange_and_add(&i, 1); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ost_cv_gcc_cxx_atomic=yes $as_echo "#define HAVE_GCC_CXX_BITS_ATOMIC 1" >>confdefs.h else ost_cv_gcc_cxx_atomic=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ost_cv_gcc_cxx_atomic" >&5 $as_echo "$ost_cv_gcc_cxx_atomic" >&6; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test "$target" = NONE ; then targetdir="" else targetdir="$target" fi for ac_header in thread.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "thread.h" "ac_cv_header_thread_h" "$ac_includes_default" if test "x$ac_cv_header_thread_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_THREAD_H 1 _ACEOF fi done if test "$prefix" = NONE ; then thrprefix="/usr/$targetdir/include" if test -d /usr/$targetdir/sys-include ; then thrprefix="$prefix/$targetdir/sys-include" ; fi else thrprefix="$prefix/$targetdir/include" if test -d "$prefix/$targetdir/sys-include" ; then thrprefix="$prefix/$targetdir/sys-include" ; fi fi if test ! -f $thrprefix/thread.h ; then thrprefix=/usr/include fi if test $ost_cv_posix_threads = yes ; then if test "$ost_cv_thread_library" = "none" ; then ost_cv_thread_flags="" for flags in -kthread -pthread -mthreads -pthreads -Kthread --threadsafe -mt ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC-cc} accepts $flags" >&5 $as_echo_n "checking whether ${CC-cc} accepts $flags... " >&6; } echo 'void f(){}' >conftest.c if test -z "`${CC-cc} $flags -c conftest.c 2>&1`"; then ost_cv_thread_flags=$flags { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* if test ! -z "$ost_cv_thread_flags" ; then break ; fi done # if test "$ost_cv_prog_cc_pthread" = "no" ; then # AC_CACHE_CHECK(whether ${CC-cc} accepts -mthreads, # ost_cv_prog_cc_mthreads, # [echo 'void f(){}' >conftest.c # if test -z "`${CC-cc} -mthreads -c conftest.c 2>&1`"; then # ost_cv_prog_cc_mthreads=yes # else # ost_cv_prog_cc_mthreads=no # fi # rm -f conftest* # ]) # fi ost_cv_thread_library=none { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5 $as_echo_n "checking for pthread_self in -lpthread... " >&6; } if test "${ac_cv_lib_pthread_pthread_self+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_self (); int main () { return pthread_self (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_self=yes else ac_cv_lib_pthread_pthread_self=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5 $as_echo "$ac_cv_lib_pthread_pthread_self" >&6; } if test "x$ac_cv_lib_pthread_pthread_self" = x""yes; then : ost_cv_thread_library=pthread else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lc_r" >&5 $as_echo_n "checking for pthread_self in -lc_r... " >&6; } if test "${ac_cv_lib_c_r_pthread_self+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lc_r $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_self (); int main () { return pthread_self (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_c_r_pthread_self=yes else ac_cv_lib_c_r_pthread_self=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_self" >&5 $as_echo "$ac_cv_lib_c_r_pthread_self" >&6; } if test "x$ac_cv_lib_c_r_pthread_self" = x""yes; then : ost_cv_thread_library=c_r else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 $as_echo_n "checking for pthread_kill in -lpthread... " >&6; } if test "${ac_cv_lib_pthread_pthread_kill+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_kill (); int main () { return pthread_kill (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_kill=yes else ac_cv_lib_pthread_pthread_kill=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 $as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; } if test "x$ac_cv_lib_pthread_pthread_kill" = x""yes; then : ost_cv_thread_library=pthread else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthreads" >&5 $as_echo_n "checking for pthread_self in -lpthreads... " >&6; } if test "${ac_cv_lib_pthreads_pthread_self+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthreads $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_self (); int main () { return pthread_self (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_pthreads_pthread_self=yes else ac_cv_lib_pthreads_pthread_self=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_pthread_self" >&5 $as_echo "$ac_cv_lib_pthreads_pthread_self" >&6; } if test "x$ac_cv_lib_pthreads_pthread_self" = x""yes; then : ost_cv_thread_library=pthreads else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lthread" >&5 $as_echo_n "checking for pthread_self in -lthread... " >&6; } if test "${ac_cv_lib_thread_pthread_self+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_self (); int main () { return pthread_self (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_thread_pthread_self=yes else ac_cv_lib_thread_pthread_self=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_thread_pthread_self" >&5 $as_echo "$ac_cv_lib_thread_pthread_self" >&6; } if test "x$ac_cv_lib_thread_pthread_self" = x""yes; then : ost_cv_thread_library=thread fi fi fi fi fi if test $ost_cv_thread_library = none ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lgthreads" >&5 $as_echo_n "checking for pthread_self in -lgthreads... " >&6; } if test "${ac_cv_lib_gthreads_pthread_self+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgthreads $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_self (); int main () { return pthread_self (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_gthreads_pthread_self=yes else ac_cv_lib_gthreads_pthread_self=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gthreads_pthread_self" >&5 $as_echo "$ac_cv_lib_gthreads_pthread_self" >&6; } if test "x$ac_cv_lib_gthreads_pthread_self" = x""yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -lmalloc" >&5 $as_echo_n "checking for malloc in -lmalloc... " >&6; } if test "${ac_cv_lib_malloc_malloc+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmalloc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char malloc (); int main () { return malloc (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_malloc_malloc=yes else ac_cv_lib_malloc_malloc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_malloc_malloc" >&5 $as_echo "$ac_cv_lib_malloc_malloc" >&6; } if test "x$ac_cv_lib_malloc_malloc" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBMALLOC 1 _ACEOF LIBS="-lmalloc $LIBS" fi ost_cv_thread_library=gthreads fi fi if test $ost_cv_thread_library = none ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lcma" >&5 $as_echo_n "checking for pthread_self in -lcma... " >&6; } if test "${ac_cv_lib_cma_pthread_self+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcma $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_self (); int main () { return pthread_self (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_cma_pthread_self=yes else ac_cv_lib_cma_pthread_self=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cma_pthread_self" >&5 $as_echo "$ac_cv_lib_cma_pthread_self" >&6; } if test "x$ac_cv_lib_cma_pthread_self" = x""yes; then : ost_cv_thread_library=cma fi fi if test $ost_cv_thread_library = none ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lc" >&5 $as_echo_n "checking for pthread_self in -lc... " >&6; } if test "${ac_cv_lib_c_pthread_self+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_self (); int main () { return pthread_self (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_c_pthread_self=yes else ac_cv_lib_c_pthread_self=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_pthread_self" >&5 $as_echo "$ac_cv_lib_c_pthread_self" >&6; } if test "x$ac_cv_lib_c_pthread_self" = x""yes; then : ost_cv_thread_library=c fi fi if test $ost_cv_thread_library = none ; then as_fn_error "no library for posix threads found!" "$LINENO" 5 fi else # ost_cv_prog_cc_pthread=no # ost_cv_prog_cc_mthreads=no ost_cv_thread_flags="" fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_mach_thread_np" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mach_thread_np in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_mach_thread_np in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_mach_thread_np (); int main () { return pthread_mach_thread_np (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_MACH_THREAD_NP 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_nanosleep" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nanosleep in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for nanosleep in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char nanosleep (); int main () { return nanosleep (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_NANOSLEEP 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nanosleep in -lposix4" >&5 $as_echo_n "checking for nanosleep in -lposix4... " >&6; } if test "${ac_cv_lib_posix4_nanosleep+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix4 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char nanosleep (); int main () { return nanosleep (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_posix4_nanosleep=yes else ac_cv_lib_posix4_nanosleep=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix4_nanosleep" >&5 $as_echo "$ac_cv_lib_posix4_nanosleep" >&6; } if test "x$ac_cv_lib_posix4_nanosleep" = x""yes; then : $as_echo "#define HAVE_PTHREAD_NANOSLEEP 1" >>confdefs.h THREAD_LIBS="$THREAD_LIBS -lposix4" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nanosleep in -lrt" >&5 $as_echo_n "checking for nanosleep in -lrt... " >&6; } if test "${ac_cv_lib_rt_nanosleep+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char nanosleep (); int main () { return nanosleep (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_rt_nanosleep=yes else ac_cv_lib_rt_nanosleep=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_nanosleep" >&5 $as_echo "$ac_cv_lib_rt_nanosleep" >&6; } if test "x$ac_cv_lib_rt_nanosleep" = x""yes; then : $as_echo "#define HAVE_PTHREAD_NANOSLEEP 1" >>confdefs.h ost_cv_rt_library="-lrt" fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 $as_echo_n "checking for clock_gettime in -lrt... " >&6; } if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_rt_clock_gettime=yes else ac_cv_lib_rt_clock_gettime=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 $as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then : ost_cv_rt_library="-lrt" $as_echo "#define HAVE_HIRES_TIMER 1" >>confdefs.h else for ac_func in clock_gettime do : ac_fn_cxx_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" if test "x$ac_cv_func_clock_gettime" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CLOCK_GETTIME 1 _ACEOF $as_echo "#define HAVE_HIRES_TIMER 1" >>confdefs.h fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mlockall in -lrt" >&5 $as_echo_n "checking for mlockall in -lrt... " >&6; } if test "${ac_cv_lib_rt_mlockall+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char mlockall (); int main () { return mlockall (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_rt_mlockall=yes else ac_cv_lib_rt_mlockall=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_mlockall" >&5 $as_echo "$ac_cv_lib_rt_mlockall" >&6; } if test "x$ac_cv_lib_rt_mlockall" = x""yes; then : $as_echo "#define HAVE_MLOCK 1" >>confdefs.h $as_echo "#define HAVE_MLOCKALL 1" >>confdefs.h ost_cv_rt_library="-lrt" else for ac_func in mlock do : ac_fn_cxx_check_func "$LINENO" "mlock" "ac_cv_func_mlock" if test "x$ac_cv_func_mlock" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MLOCK 1 _ACEOF fi done for ac_func in mlockall do : ac_fn_cxx_check_func "$LINENO" "mlockall" "ac_cv_func_mlockall" if test "x$ac_cv_func_mlockall" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MLOCKALL 1 _ACEOF fi done fi if test "$ost_cv_rt_library" != "none" ; then THREAD_LIBS="$THREAD_LIBS $ost_cv_rt_library" ; fi if test ! -z "$ost_cv_thread_flags" ; then THREAD_LIBS="$THREAD_LIBS $ost_cv_thread_flags" else THREAD_LIBS="$THREAD_LIBS -l$ost_cv_thread_library" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; *solaris* | alpha*-osf*) flag="-D_REENTRANT";; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 $as_echo "${flag}" >&6; } if test "x$flag" != xno; then THREAD_FLAGS="$flag" fi # LIBS="$THREAD_LIBS $LIBS" if test "$ost_cv_thread_library" != "lthread" ; then for ac_header in pthread_np.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "pthread_np.h" "ac_cv_header_pthread_np_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_np_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_NP_H 1 _ACEOF fi done fi for ac_header in semaphore.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "semaphore.h" "ac_cv_header_semaphore_h" "$ac_includes_default" if test "x$ac_cv_header_semaphore_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SEMAPHORE_H 1 _ACEOF fi done for ac_header in sched.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default" if test "x$ac_cv_header_sched_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SCHED_H 1 _ACEOF fi done for ac_header in sys/sched.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/sched.h" "ac_cv_header_sys_sched_h" "$ac_includes_default" if test "x$ac_cv_header_sys_sched_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SCHED_H 1 _ACEOF fi done for ac_func in sched_getscheduler do : ac_fn_cxx_check_func "$LINENO" "sched_getscheduler" "ac_cv_func_sched_getscheduler" if test "x$ac_cv_func_sched_getscheduler" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SCHED_GETSCHEDULER 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for recursive mutex type support" >&5 $as_echo_n "checking for recursive mutex type support... " >&6; } if test "${ost_cv_mutex_recursive+set}" = set; then : $as_echo_n "(cached) " >&6 else ost_cv_mutex_recursive="none" if test "$ost_cv_cxx_mode" = true ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu SAVE_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -pthread" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef PTHREAD_MUTEXTYPE_RECURSIVE #ifdef PTHREAD_MUTEX_RECURSIVE #define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEX_RECURSIVE #endif #endif return (int)PTHREAD_MUTEXTYPE_RECURSIVE; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ost_cv_mutex_recursive="portable" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "PTHREAD_MUTEXTYPE_RECURSIVE_NP" >/dev/null 2>&1; then : ost_cv_mutex_recursive=non-portable fi rm -f conftest* cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP" >/dev/null 2>&1; then : ost_cv_mutex_recursive=lthread fi rm -f conftest* cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "PTHREAD_MUTEX_RECURSIVE_NP" >/dev/null 2>&1; then : ost_cv_mutex_recursive=linux fi rm -f conftest* cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "MUTEX_TYPE_COUNTING_FAST" >/dev/null 2>&1; then : ost_cv_mutex_recursive=counting fi rm -f conftest* fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ost_cv_mutex_recursive = "none" ; then if test $ost_cv_thread_library = "lthread" ; then ost_cv_mutex_recursive=linux fi fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ost_cv_mutex_recursive" >&5 $as_echo "$ost_cv_mutex_recursive" >&6; } if test $ost_cv_mutex_recursive = "none" ; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { return MUTEX_TYPE_COUNTING_FAST; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ost_cv_mutex_recursive=counting fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$ost_cv_cxx_mode" = true ; then CXXFLAGS="$SAVE_CXXFLAGS" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi case $ost_cv_mutex_recursive in non-portable) $as_echo "#define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEXTYPE_RECURSIVE_NP" >>confdefs.h ;; linux) $as_echo "#define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP" >>confdefs.h ;; counting) $as_echo "#define PTHREAD_MUTEXTYPE_RECURSIVE MUTEX_TYPE_COUNTING_FAST" >>confdefs.h ;; esac as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_mutexattr_settype" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutexattr_settype in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_mutexattr_settype in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_mutexattr_settype (); int main () { return pthread_mutexattr_settype (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_MUTEXATTR_SETTYPE 1" >>confdefs.h else as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_mutexattr_settype_np" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutexattr_settype_np in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_mutexattr_settype_np in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_mutexattr_settype_np (); int main () { return pthread_mutexattr_settype_np (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_MUTEXATTR_SETTYPE_NP 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_mutexattr_setkind_np" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutexattr_setkind_np in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_mutexattr_setkind_np in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_mutexattr_setkind_np (); int main () { return pthread_mutexattr_setkind_np (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_MUTEXATTR_SETKIND_NP 1" >>confdefs.h fi fi ost_cv_thread_rwlock=false as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_rwlock_init" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_rwlock_init in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_rwlock_init in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_rwlock_init (); int main () { return pthread_rwlock_init (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : ost_cv_thread_rwlock=true $as_echo "#define HAVE_PTHREAD_RWLOCK 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pread in -lc" >&5 $as_echo_n "checking for pread in -lc... " >&6; } if test "${ac_cv_lib_c_pread+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pread (); int main () { return pread (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_c_pread=yes else ac_cv_lib_c_pread=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_pread" >&5 $as_echo "$ac_cv_lib_c_pread" >&6; } if test "x$ac_cv_lib_c_pread" = x""yes; then : $as_echo "#define HAVE_PREAD_PWRITE 1" >>confdefs.h else as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pread" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pread in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pread in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pread (); int main () { return pread (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PREAD_PWRITE 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pread in -lc_r" >&5 $as_echo_n "checking for pread in -lc_r... " >&6; } if test "${ac_cv_lib_c_r_pread+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lc_r $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pread (); int main () { return pread (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_c_r_pread=yes else ac_cv_lib_c_r_pread=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pread" >&5 $as_echo "$ac_cv_lib_c_r_pread" >&6; } if test "x$ac_cv_lib_c_r_pread" = x""yes; then : $as_echo "#define HAVE_PREAD_PWRITE 1" >>confdefs.h fi fi fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_suspend" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_suspend in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_suspend in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_suspend (); int main () { return pthread_suspend (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_SUSPEND 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_attr_setstacksize" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_attr_setstacksize in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_attr_setstacksize in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_attr_setstacksize (); int main () { return pthread_attr_setstacksize (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_yield_np" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_yield_np in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_yield_np in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_yield_np (); int main () { return pthread_yield_np (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_YIELD_NP 1" >>confdefs.h else as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_yield" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_yield in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_yield in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_yield (); int main () { return pthread_yield (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_YIELD 1" >>confdefs.h else as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_sched_yield" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for sched_yield in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sched_yield (); int main () { return sched_yield (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_SCHED_YIELD 1" >>confdefs.h fi fi fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_cancel" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_cancel in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_cancel in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_cancel (); int main () { return pthread_cancel (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_CANCEL 1" >>confdefs.h as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_setcanceltype" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_setcanceltype in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_setcanceltype in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_setcanceltype (); int main () { return pthread_setcanceltype (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_SETCANCELTYPE 1" >>confdefs.h else as_ac_Lib=`$as_echo "ac_cv_lib_$ost_cv_thread_library''_pthread_setcanel" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_setcanel in -l$ost_cv_thread_library" >&5 $as_echo_n "checking for pthread_setcanel in -l$ost_cv_thread_library... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$ost_cv_thread_library $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_setcanel (); int main () { return pthread_setcanel (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_SETCANCEL 1" >>confdefs.h fi fi else as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_setcanceltype" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_setcanceltype in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_setcanceltype in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_setcanceltype (); int main () { return pthread_setcanceltype (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_CANCEL 1" >>confdefs.h $as_echo "#define HAVE_PTHREAD_SETCANCELTYPE 1" >>confdefs.h fi fi as_ac_Lib=`$as_echo "ac_cv_lib_${ost_cv_thread_library}''_pthread_delay_np" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_delay_np in -l${ost_cv_thread_library}" >&5 $as_echo_n "checking for pthread_delay_np in -l${ost_cv_thread_library}... " >&6; } if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${ost_cv_thread_library} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_delay_np (); int main () { return pthread_delay_np (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval as_val=\$$as_ac_Lib if test "x$as_val" = x""yes; then : $as_echo "#define HAVE_PTHREAD_DELAY_NP 1" >>confdefs.h fi fi UNAME=`uname` if test "$UNAME" = "AIX" ; then # Extract the first word of "cc_r", so it can be a program name with args. set dummy cc_r; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PTHREAD_CC="cc_r" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_PTHREAD_CC" && ac_cv_prog_PTHREAD_CC="${CC}" fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi CC=$PTHREAD_CC $as_echo "#define COMMON_AIX_FIXES 1" >>confdefs.h fi # from GNU Commons C++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5 $as_echo_n "checking for ld used by GCC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | [A-Za-z]:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if test "${acl_cv_path_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi fi LD="$acl_cv_path_LD" if test -n "$LD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if test "${acl_cv_prog_gnu_ld+set}" = set; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 &5 $as_echo "$acl_cv_prog_gnu_ld" >&6; } with_gnu_ld=$acl_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 $as_echo_n "checking for shared library run path origin... " >&6; } if test "${acl_cv_rpath+set}" = set; then : $as_echo_n "(cached) " >&6 else CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 $as_echo "$acl_cv_rpath" >&6; } wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" # Check whether --enable-rpath was given. if test "${enable_rpath+set}" = set; then : enableval=$enable_rpath; : else enable_rpath=yes fi acl_libdirstem=lib searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libiconv-prefix was given. if test "${with_libiconv_prefix+set}" = set; then : withval=$with_libiconv_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi fi LIBICONV= LTLIBICONV= INCICONV= LIBICONV_PREFIX= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='iconv ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" else LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` LIBICONV_PREFIX="$basedir" additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" ;; esac done fi else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" done fi am_save_CPPFLAGS="$CPPFLAGS" for element in $INCICONV; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if test "${am_cv_func_iconv+set}" = set; then : $as_echo_n "(cached) " >&6 else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : am_cv_lib_iconv=yes am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$am_save_LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 $as_echo "$am_cv_func_iconv" >&6; } if test "$am_cv_func_iconv" = yes; then $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5 $as_echo_n "checking for iconv declaration... " >&6; } if test "${am_cv_proto_iconv+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : am_cv_proto_iconv_arg1="" else am_cv_proto_iconv_arg1="const" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" fi am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_t:- }$am_cv_proto_iconv" >&5 $as_echo "${ac_t:- }$am_cv_proto_iconv" >&6; } cat >>confdefs.h <<_ACEOF #define ICONV_CONST $am_cv_proto_iconv_arg1 _ACEOF fi # # Some checks # # -- iconv { $as_echo "$as_me:${as_lineno-$LINENO}: checking if an usable version of iconv exists (required)" >&5 $as_echo_n "checking if an usable version of iconv exists (required)... " >&6; } if test "x$am_cv_func_iconv" = "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error "no usable version of iconv has been found" "$LINENO" 5 fi # -- global constructors (stolen from 'configure.in' in libsigc++) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports global constructors" >&5 $as_echo_n "checking if linker supports global constructors... " >&6; } cat > mylib.$ac_ext < struct A { A() { printf("PASS\n"); } }; A a; int foo() { return 1; } EOF cat > mytest.$ac_ext < extern int foo(); int main(int, char**) { int i = foo(); if(i != 1) printf("FAIL\n"); return 0; } EOF sh libtool --mode=compile $CXX -c mylib.$ac_ext >&5 sh libtool --mode=link $CXX -o libtest.la -rpath / -version-info 0 mylib.lo >&5 $CXX -c $CFLAGS $CPPFLAGS mytest.$ac_ext >&5 sh libtool --mode=link $CXX -o mytest mytest.o libtest.la >&5 2>/dev/null if test -x mytest -a "$cross_compiling" != yes; then myresult=`./mytest` if test "X$myresult" = "XPASS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error " =================================================================== ERROR: This platform lacks support of construction of global objects in shared libraries. See ftp://rtfm.mit.edu/pub/usenet/news.answers/g++-FAQ/plain for details about this problem. Also for possible solutions http://www.informatik.uni-frankfurt.de/~fp/Tcl/tcl-c++/tcl-c++.html ===================================================================" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5 $as_echo "unknown" >&6; } fi rm -f mylib.* mytest.* libtest.la .libs/libtest* mytest .libs/mytest .libs/lt-mytest .libs/mylib.* >&5 rmdir .libs >&5 # -- const_cast { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C++ compiler supports const_cast<> (required)" >&5 $as_echo_n "checking if C++ compiler supports const_cast<> (required)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ class foo; int main () { const foo *c=0; foo *c1=const_cast(c); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error "C++ compiler const_cast<> does not work" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -- dynamic_cast { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C++ compiler supports dynamic_cast<> (required)" >&5 $as_echo_n "checking if C++ compiler supports dynamic_cast<> (required)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ class foo { public: virtual ~foo() { } }; class bar : public foo { public: virtual ~bar() { } }; int main () { foo *c=0; bar *c1=dynamic_cast(c); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error "C++ compiler dynamic_cast<> does not work" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -- mutable { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C++ compiler supports mutable (required)" >&5 $as_echo_n "checking if C++ compiler supports mutable (required)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ class k { mutable char *c; public: void foo() const { c=0; } }; int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error "C++ compiler does not support 'mutable'" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -- namespace { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C++ compiler supports name spaces (required)" >&5 $as_echo_n "checking if C++ compiler supports name spaces (required)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ namespace Check { int i; } int main () { Check::i=1; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error "C++ compiler does not support 'namespace'" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # # Target OS and architecture # VMIME_TARGET_ARCH=${target_cpu} VMIME_TARGET_OS=${target_os} # # Byte Order # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac if test "x$ac_cv_c_bigendian" = "xyes"; then VMIME_BYTE_ORDER_BIG_ENDIAN=1 VMIME_BYTE_ORDER_LITTLE_ENDIAN=0 else VMIME_BYTE_ORDER_BIG_ENDIAN=0 VMIME_BYTE_ORDER_LITTLE_ENDIAN=1 fi # # Generic Type Size # # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 $as_echo_n "checking size of char... " >&6; } if test "${ac_cv_sizeof_char+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default"; then : else if test "$ac_cv_type_char" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { as_fn_set_status 77 as_fn_error "cannot compute sizeof (char) See \`config.log' for more details." "$LINENO" 5; }; } else ac_cv_sizeof_char=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 $as_echo "$ac_cv_sizeof_char" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_CHAR $ac_cv_sizeof_char _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 $as_echo_n "checking size of short... " >&6; } if test "${ac_cv_sizeof_short+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : else if test "$ac_cv_type_short" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { as_fn_set_status 77 as_fn_error "cannot compute sizeof (short) See \`config.log' for more details." "$LINENO" 5; }; } else ac_cv_sizeof_short=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 $as_echo "$ac_cv_sizeof_short" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } if test "${ac_cv_sizeof_int+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : else if test "$ac_cv_type_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { as_fn_set_status 77 as_fn_error "cannot compute sizeof (int) See \`config.log' for more details." "$LINENO" 5; }; } else ac_cv_sizeof_int=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 $as_echo "$ac_cv_sizeof_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } if test "${ac_cv_sizeof_long+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { as_fn_set_status 77 as_fn_error "cannot compute sizeof (long) See \`config.log' for more details." "$LINENO" 5; }; } else ac_cv_sizeof_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 $as_echo "$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF case 1 in $ac_cv_sizeof_char) VMIME_TYPE_INT8=char ;; *) as_fn_error "no 8-bit type available" "$LINENO" 5 esac case 2 in $ac_cv_sizeof_short) VMIME_TYPE_INT16=short ;; $ac_cv_sizeof_int) VMIME_TYPE_INT16=int ;; *) as_fn_error "no 16-bit type available" "$LINENO" 5 esac case 4 in $ac_cv_sizeof_int) VMIME_TYPE_INT32=int ;; $ac_cv_sizeof_long) VMIME_TYPE_INT32=long ;; *) as_fn_error "no 32-bit type available" "$LINENO" 5 esac # # Options # # ** debug # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; case "${enableval}" in yes) conf_debug=yes ;; no) conf_debug=no ;; *) as_fn_error "bad value ${enableval} for --enable-debug" "$LINENO" 5 ;; esac else conf_debug=no fi if test "x$conf_debug" = "xyes"; then if true; then VMIME_DEBUG_TRUE= VMIME_DEBUG_FALSE='#' else VMIME_DEBUG_TRUE='#' VMIME_DEBUG_FALSE= fi VMIME_DEBUG=1 else if false; then VMIME_DEBUG_TRUE= VMIME_DEBUG_FALSE='#' else VMIME_DEBUG_TRUE='#' VMIME_DEBUG_FALSE= fi VMIME_DEBUG=0 fi # ** messaging # Check whether --enable-messaging was given. if test "${enable_messaging+set}" = set; then : enableval=$enable_messaging; case "${enableval}" in yes) conf_messaging=yes ;; no) conf_messaging=no ;; *) as_fn_error "bad value ${enableval} for --enable-messaging" "$LINENO" 5 ;; esac else conf_messaging=yes fi if test "x$conf_messaging" = "xyes"; then if true; then VMIME_HAVE_MESSAGING_FEATURES_TRUE= VMIME_HAVE_MESSAGING_FEATURES_FALSE='#' else VMIME_HAVE_MESSAGING_FEATURES_TRUE='#' VMIME_HAVE_MESSAGING_FEATURES_FALSE= fi VMIME_HAVE_MESSAGING_FEATURES=1 else if false; then VMIME_HAVE_MESSAGING_FEATURES_TRUE= VMIME_HAVE_MESSAGING_FEATURES_FALSE='#' else VMIME_HAVE_MESSAGING_FEATURES_TRUE='#' VMIME_HAVE_MESSAGING_FEATURES_FALSE= fi VMIME_HAVE_MESSAGING_FEATURES=0 fi # ** SASL # Check whether --enable-sasl was given. if test "${enable_sasl+set}" = set; then : enableval=$enable_sasl; case "${enableval}" in yes) conf_sasl=yes ;; no) conf_sasl=no ;; *) as_fn_error "bad value ${enableval} for --enable-sasl" "$LINENO" 5 ;; esac else conf_sasl=yes fi if test "x$conf_sasl" = "xyes"; then # -- GNU SASL Library (http://www.gnu.org/software/gsasl/) ac_fn_cxx_check_header_mongrel "$LINENO" "gsasl.h" "ac_cv_header_gsasl_h" "$ac_includes_default" if test "x$ac_cv_header_gsasl_h" = x""yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gsasl_check_version in -lgsasl" >&5 $as_echo_n "checking for gsasl_check_version in -lgsasl... " >&6; } if test "${ac_cv_lib_gsasl_gsasl_check_version+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgsasl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gsasl_check_version (); int main () { return gsasl_check_version (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_gsasl_gsasl_check_version=yes else ac_cv_lib_gsasl_gsasl_check_version=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gsasl_gsasl_check_version" >&5 $as_echo "$ac_cv_lib_gsasl_gsasl_check_version" >&6; } if test "x$ac_cv_lib_gsasl_gsasl_check_version" = x""yes; then : have_gsasl=yes GSASL_AVAIL_LIBS=-lgsasl GSASL_AVAIL_REQUIRED=libgsasl else have_gsasl=no fi else have_gsasl=no fi if test "x$have_gsasl" = "xyes"; then if true; then VMIME_HAVE_SASL_SUPPORT_TRUE= VMIME_HAVE_SASL_SUPPORT_FALSE='#' else VMIME_HAVE_SASL_SUPPORT_TRUE='#' VMIME_HAVE_SASL_SUPPORT_FALSE= fi VMIME_HAVE_SASL_SUPPORT=1 GSASL_REQUIRED=${GSASL_AVAIL_REQUIRED} GSASL_LIBS=${GSASL_AVAIL_LIBS} else as_fn_error "can't find an usable version of GNU SASL library" "$LINENO" 5 fi else if false; then VMIME_HAVE_SASL_SUPPORT_TRUE= VMIME_HAVE_SASL_SUPPORT_FALSE='#' else VMIME_HAVE_SASL_SUPPORT_TRUE='#' VMIME_HAVE_SASL_SUPPORT_FALSE= fi VMIME_HAVE_SASL_SUPPORT=0 GSASL_REQUIRED= GSASL_LIBS= fi # ** TLS # Check whether --enable-tls was given. if test "${enable_tls+set}" = set; then : enableval=$enable_tls; case "${enableval}" in yes) conf_tls=yes ;; no) conf_tls=no ;; *) as_fn_error "bad value ${enableval} for --enable-tls" "$LINENO" 5 ;; esac else conf_tls=yes fi if test "x$conf_tls" = "xyes"; then # -- GNU TLS Library (http://www.gnu.org/software/gnutls/) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBGNUTLS" >&5 $as_echo_n "checking for LIBGNUTLS... " >&6; } if test -n "$LIBGNUTLS_CFLAGS"; then pkg_cv_LIBGNUTLS_CFLAGS="$LIBGNUTLS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls >= 1.2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls >= 1.2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGNUTLS_CFLAGS=`$PKG_CONFIG --cflags "gnutls >= 1.2.0" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBGNUTLS_LIBS"; then pkg_cv_LIBGNUTLS_LIBS="$LIBGNUTLS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls >= 1.2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls >= 1.2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGNUTLS_LIBS=`$PKG_CONFIG --libs "gnutls >= 1.2.0" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBGNUTLS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gnutls >= 1.2.0" 2>&1` else LIBGNUTLS_PKG_ERRORS=`$PKG_CONFIG --print-errors "gnutls >= 1.2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBGNUTLS_PKG_ERRORS" >&5 have_gnutls=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_gnutls=no else LIBGNUTLS_CFLAGS=$pkg_cv_LIBGNUTLS_CFLAGS LIBGNUTLS_LIBS=$pkg_cv_LIBGNUTLS_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_gnutls=yes fi if test "x$have_gnutls" = "xyes"; then if true; then VMIME_HAVE_TLS_SUPPORT_TRUE= VMIME_HAVE_TLS_SUPPORT_FALSE='#' else VMIME_HAVE_TLS_SUPPORT_TRUE='#' VMIME_HAVE_TLS_SUPPORT_FALSE= fi VMIME_HAVE_TLS_SUPPORT=1 else as_fn_error "can't find an usable version of GNU TLS library" "$LINENO" 5 fi else if false; then VMIME_HAVE_TLS_SUPPORT_TRUE= VMIME_HAVE_TLS_SUPPORT_FALSE='#' else VMIME_HAVE_TLS_SUPPORT_TRUE='#' VMIME_HAVE_TLS_SUPPORT_FALSE= fi VMIME_HAVE_TLS_SUPPORT=0 fi # ** platform handlers VMIME_BUILTIN_PLATFORMS='' VMIME_DETECT_PLATFORM='' case "x${target_os}" in xwin* | xmingw* | xcygwin*) VMIME_DETECT_PLATFORM='windows' ;; x*) # Default is POSIX VMIME_DETECT_PLATFORM='posix' ;; esac # ** messaging protocols VMIME_BUILTIN_MESSAGING_PROTOS='' # Check whether --enable-messaging-proto-pop3 was given. if test "${enable_messaging_proto_pop3+set}" = set; then : enableval=$enable_messaging_proto_pop3; case "${enableval}" in yes) conf_messaging_proto_pop3=yes ;; no) conf_messaging_proto_pop3=no ;; *) as_fn_error "bad value ${enableval} for --enable-messaging-proto-pop3" "$LINENO" 5 ;; esac else conf_messaging_proto_pop3=yes fi if test "x$conf_messaging_proto_pop3" = "xyes"; then if true; then VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_POP3_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_POP3_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_POP3=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS pop3" else if false; then VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_POP3_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_POP3_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_POP3=0 fi # Check whether --enable-messaging-proto-smtp was given. if test "${enable_messaging_proto_smtp+set}" = set; then : enableval=$enable_messaging_proto_smtp; case "${enableval}" in yes) conf_messaging_proto_smtp=yes ;; no) conf_messaging_proto_smtp=no ;; *) as_fn_error "bad value ${enableval} for --enable-messaging-proto-smtp" "$LINENO" 5 ;; esac else conf_messaging_proto_smtp=yes fi if test "x$conf_messaging_proto_smtp" = "xyes"; then if true; then VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_SMTP_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_SMTP_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_SMTP=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS smtp" else if false; then VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_SMTP_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_SMTP_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_SMTP=0 fi # Check whether --enable-messaging-proto-imap was given. if test "${enable_messaging_proto_imap+set}" = set; then : enableval=$enable_messaging_proto_imap; case "${enableval}" in yes) conf_messaging_proto_imap=yes ;; no) conf_messaging_proto_imap=no ;; *) as_fn_error "bad value ${enableval} for --enable-messaging-proto-imap" "$LINENO" 5 ;; esac else conf_messaging_proto_imap=yes fi if test "x$conf_messaging_proto_imap" = "xyes"; then if true; then VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_IMAP_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_IMAP_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_IMAP=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS imap" else if false; then VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_IMAP_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_IMAP_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_IMAP=0 fi # Check whether --enable-messaging-proto-maildir was given. if test "${enable_messaging_proto_maildir+set}" = set; then : enableval=$enable_messaging_proto_maildir; case "${enableval}" in yes) conf_messaging_proto_maildir=yes ;; no) conf_messaging_proto_maildir=no ;; *) as_fn_error "bad value ${enableval} for --enable-messaging-proto-maildir" "$LINENO" 5 ;; esac else conf_messaging_proto_maildir=yes fi if test "x$conf_messaging_proto_maildir" = "xyes"; then if true; then VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS maildir" else if false; then VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR=0 fi # Check whether --enable-messaging-proto-sendmail was given. if test "${enable_messaging_proto_sendmail+set}" = set; then : enableval=$enable_messaging_proto_sendmail; case "${enableval}" in yes) conf_messaging_proto_sendmail=yes ;; no) conf_messaging_proto_sendmail=no ;; *) as_fn_error "bad value ${enableval} for --enable-messaging-proto-sendmail" "$LINENO" 5 ;; esac else conf_messaging_proto_sendmail=yes fi if test "x$conf_messaging_proto_sendmail" = "xyes"; then if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then if true; then VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS sendmail" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: sendmail is only available on POSIX platforms" >&5 $as_echo "$as_me: WARNING: sendmail is only available on POSIX platforms" >&2;} if false; then VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL=0 fi else if false; then VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE= VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE='#' else VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE='#' VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE= fi VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL=0 fi # # System mail # # Extract the first word of "sendmail", so it can be a program name with args. set dummy sendmail; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_SENDMAIL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SENDMAIL in [\\/]* | ?:[\\/]*) ac_cv_path_SENDMAIL="$SENDMAIL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="/usr/sbin:/usr/lib" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_SENDMAIL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SENDMAIL" && ac_cv_path_SENDMAIL="/usr/sbin/sendmail" ;; esac fi SENDMAIL=$ac_cv_path_SENDMAIL if test -n "$SENDMAIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SENDMAIL" >&5 $as_echo "$SENDMAIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # # Detect some platform-specific stuff # # -- MLang (Windows) if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then ac_fn_cxx_check_header_mongrel "$LINENO" "mlang.h" "ac_cv_header_mlang_h" "$ac_includes_default" if test "x$ac_cv_header_mlang_h" = x""yes; then : VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_MLANG_H" fi fi # -- Link with Winsock (Windows) if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then VMIME_ADDITIONAL_PC_LIBS="$VMIME_ADDITIONAL_PC_LIBS -lwsock32" fi # -- getaddrinfo (POSIX) if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then for ac_header in netdb.h sys/types.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" eval as_val=\$$as_ac_Header if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_cxx_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" if test "x$ac_cv_func_getaddrinfo" = x""yes; then : VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_GETADDRINFO" fi fi # -- pthreads (POSIX) ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_join (); int main () { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthread or # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 $as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_acx_pthread_config+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$acx_pthread_config"; then ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_acx_pthread_config="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no" fi fi acx_pthread_config=$ac_cv_prog_acx_pthread_config if test -n "$acx_pthread_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5 $as_echo "$acx_pthread_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 $as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int attr=$attr; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : attr_name=$attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 $as_echo "$attr_name" >&6; } if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then cat >>confdefs.h <<_ACEOF #define PTHREAD_CREATE_JOINABLE $attr_name _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 $as_echo "${flag}" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with cc_r # Extract the first word of "cc_r", so it can be a program name with args. set dummy cc_r; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PTHREAD_CC="cc_r" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_PTHREAD_CC" && ac_cv_prog_PTHREAD_CC="${CC}" fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else PTHREAD_CC="$CC" fi # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_PTHREAD" : else acx_pthread_ok=no fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then conf_platform_windows=yes else conf_platform_windows=no fi # Check whether --enable-platform-windows was given. if test "${enable_platform_windows+set}" = set; then : enableval=$enable_platform_windows; case "${enableval}" in yes) conf_platform_windows=yes ;; no) conf_platform_windows=no ;; *) as_fn_error "bad value ${enableval} for --enable-platform-windows" "$LINENO" 5 ;; esac fi if test "x$conf_platform_windows" = "xyes"; then if true; then VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE= VMIME_BUILTIN_PLATFORM_WINDOWS_FALSE='#' else VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE='#' VMIME_BUILTIN_PLATFORM_WINDOWS_FALSE= fi VMIME_BUILTIN_PLATFORM_WINDOWS=1 VMIME_BUILTIN_PLATFORMS="$VMIME_BUILTIN_PLATFORMS windows" else if false; then VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE= VMIME_BUILTIN_PLATFORM_WINDOWS_FALSE='#' else VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE='#' VMIME_BUILTIN_PLATFORM_WINDOWS_FALSE= fi VMIME_BUILTIN_PLATFORM_WINDOWS=0 fi if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then conf_platform_posix=yes else conf_platform_posix=no fi # Check whether --enable-platform-posix was given. if test "${enable_platform_posix+set}" = set; then : enableval=$enable_platform_posix; case "${enableval}" in yes) conf_platform_posix=yes ;; no) conf_platform_posix=no ;; *) as_fn_error "bad value ${enableval} for --enable-platform-posix" "$LINENO" 5 ;; esac fi if test "x$conf_platform_posix" = "xyes"; then if true; then VMIME_BUILTIN_PLATFORM_POSIX_TRUE= VMIME_BUILTIN_PLATFORM_POSIX_FALSE='#' else VMIME_BUILTIN_PLATFORM_POSIX_TRUE='#' VMIME_BUILTIN_PLATFORM_POSIX_FALSE= fi VMIME_BUILTIN_PLATFORM_POSIX=1 VMIME_BUILTIN_PLATFORMS="$VMIME_BUILTIN_PLATFORMS posix" else if false; then VMIME_BUILTIN_PLATFORM_POSIX_TRUE= VMIME_BUILTIN_PLATFORM_POSIX_FALSE='#' else VMIME_BUILTIN_PLATFORM_POSIX_TRUE='#' VMIME_BUILTIN_PLATFORM_POSIX_FALSE= fi VMIME_BUILTIN_PLATFORM_POSIX=0 fi # # Workarounds for some platforms # # -- pkgconfigdir case "x${target_os}" in xfreebsd*) VMIME_PKGCONFIGDIR='$(prefix)/libdata/pkgconfig' ;; x*) VMIME_PKGCONFIGDIR='$(libdir)/pkgconfig' ;; esac # -- libtool 'CXX' tag case "x${target_os}" in xfreebsd*) # FIXME: temporary hack until I find a better solution # to make libtool use the C++ tag... LIBTOOL="$LIBTOOL --tag=CXX" ;; esac # # Flags # LIBRARY_LD_FLAGS="\$(top_builddir)/src/\$(LIBRARY_NAME).la" PKGCONFIG_CFLAGS="" PKGCONFIG_LIBS="" EXTRA_CFLAGS="$EXTRA_CFLAGS -D_REENTRANT=1 -D_THREAD_SAFE=1 $LIBGNUTLS_CFLAGS" EXTRA_LIBS="$GSASL_LIBS $LIBGNUTLS_LIBS" CFLAGS="" CXXFLAGS="" # -- Debug if test x$VMIME_DEBUG = x1 ; then # -g OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -g" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -g" >&5 $as_echo_n "checking whether cc accepts -g... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; CXXFLAGS="$OLD_CXXFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else # -O2 OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -O2" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -O2" >&5 $as_echo_n "checking whether cc accepts -O2... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; CXXFLAGS="$OLD_CXXFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # -- HACK: add -fPIC or -fpic on static library object files EXTRA_CFLAGS="$EXTRA_CFLAGS $lt_prog_compiler_pic" # # Check to see if the compiler can handle some flags # # -ansi OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -ansi" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -ansi" >&5 $as_echo_n "checking whether cc accepts -ansi... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -pedantic OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -pedantic" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -pedantic" >&5 $as_echo_n "checking whether cc accepts -pedantic... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -W OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -W" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -W" >&5 $as_echo_n "checking whether cc accepts -W... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -Wall OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -Wall" >&5 $as_echo_n "checking whether cc accepts -Wall... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -Wpointer-arith OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wpointer-arith" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -Wpointer-arith" >&5 $as_echo_n "checking whether cc accepts -Wpointer-arith... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -Wold-style-cast OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wold-style-cast" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -Wold-style-cast" >&5 $as_echo_n "checking whether cc accepts -Wold-style-cast... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -Wconversion OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wconversion" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc accepts -Wconversion" >&5 $as_echo_n "checking whether cc accepts -Wconversion... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : echo yes else echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext #EXTRA_CFLAGS=`echo $EXTRA_CFLAGS | sed -e 's| |\n|g' | sort | uniq | tr '\n' ' '` EXTRA_CFLAGS=`echo $EXTRA_CFLAGS | tr '\n' ' ' | sort | uniq | tr '\n' ' '` EXTRA_LIBS=`echo $EXTRA_LIBS | sed -e 's|^ ||g' | sed -e 's| | |g'` LIBS=`echo $LIBS | sed -e 's|^ ||g' | sed -e 's| | |g'` ac_config_files="$ac_config_files vmime.pc Makefile src/Makefile vmime/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_DEBUG_TRUE}" && test -z "${VMIME_DEBUG_FALSE}"; then as_fn_error "conditional \"VMIME_DEBUG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_DEBUG_TRUE}" && test -z "${VMIME_DEBUG_FALSE}"; then as_fn_error "conditional \"VMIME_DEBUG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_HAVE_MESSAGING_FEATURES_TRUE}" && test -z "${VMIME_HAVE_MESSAGING_FEATURES_FALSE}"; then as_fn_error "conditional \"VMIME_HAVE_MESSAGING_FEATURES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_HAVE_MESSAGING_FEATURES_TRUE}" && test -z "${VMIME_HAVE_MESSAGING_FEATURES_FALSE}"; then as_fn_error "conditional \"VMIME_HAVE_MESSAGING_FEATURES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_HAVE_SASL_SUPPORT_TRUE}" && test -z "${VMIME_HAVE_SASL_SUPPORT_FALSE}"; then as_fn_error "conditional \"VMIME_HAVE_SASL_SUPPORT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_HAVE_SASL_SUPPORT_TRUE}" && test -z "${VMIME_HAVE_SASL_SUPPORT_FALSE}"; then as_fn_error "conditional \"VMIME_HAVE_SASL_SUPPORT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_HAVE_TLS_SUPPORT_TRUE}" && test -z "${VMIME_HAVE_TLS_SUPPORT_FALSE}"; then as_fn_error "conditional \"VMIME_HAVE_TLS_SUPPORT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_HAVE_TLS_SUPPORT_TRUE}" && test -z "${VMIME_HAVE_TLS_SUPPORT_FALSE}"; then as_fn_error "conditional \"VMIME_HAVE_TLS_SUPPORT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_POP3_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_POP3\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_POP3_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_POP3_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_POP3\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SMTP_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_SMTP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SMTP_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SMTP_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_SMTP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_IMAP_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_IMAP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_IMAP_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_IMAP_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_IMAP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_TRUE}" && test -z "${VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE}" && test -z "${VMIME_BUILTIN_PLATFORM_WINDOWS_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_PLATFORM_WINDOWS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_PLATFORM_WINDOWS_TRUE}" && test -z "${VMIME_BUILTIN_PLATFORM_WINDOWS_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_PLATFORM_WINDOWS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_PLATFORM_POSIX_TRUE}" && test -z "${VMIME_BUILTIN_PLATFORM_POSIX_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_PLATFORM_POSIX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VMIME_BUILTIN_PLATFORM_POSIX_TRUE}" && test -z "${VMIME_BUILTIN_PLATFORM_POSIX_FALSE}"; then as_fn_error "conditional \"VMIME_BUILTIN_PLATFORM_POSIX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error ERROR [LINENO LOG_FD] # --------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with status $?, using 1 if that was 0. as_fn_error () { as_status=$?; test $as_status -eq 0 && as_status=1 if test "$3"; then as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 fi $as_echo "$as_me: error: $1" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by VMime Library $as_me 0.9.1, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ VMime Library config.status 0.9.1 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" Copyright (C) 2009 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' fix_srcfile_path='`$ECHO "$fix_srcfile_path" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld_CXX='`$ECHO "$hardcode_libdir_flag_spec_ld_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' fix_srcfile_path_CXX='`$ECHO "$fix_srcfile_path_CXX" | $SED "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ AR \ AR_FLAGS \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_wl \ lt_prog_compiler_pic \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ fix_srcfile_path \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ reload_flag_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_flag_spec_ld_CXX \ hardcode_libdir_separator_CXX \ fix_srcfile_path_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec \ reload_cmds_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "vmime.pc") CONFIG_FILES="$CONFIG_FILES vmime.pc" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "vmime/Makefile") CONFIG_FILES="$CONFIG_FILES vmime/Makefile" ;; *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ || as_fn_error "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || as_fn_error "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ || as_fn_error "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="CXX " # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == "file_magic". file_magic_cmd=$lt_file_magic_cmd # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $* )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[^=]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$@"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1+=\$2" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1=\$$1\$2" } _LT_EOF ;; esac sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # How to create reloadable object files. reload_flag=$lt_reload_flag_CXX reload_cmds=$lt_reload_cmds_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit $? fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi # # Generate vmime/config.hpp # echo " // // This file was automatically generated by configuration script. // #ifndef VMIME_CONFIG_HPP_INCLUDED #define VMIME_CONFIG_HPP_INCLUDED // Name of package #define VMIME_PACKAGE \"libvmime\" // Version number of package #define VMIME_VERSION \"0.9.1\" #define VMIME_API \"0:0:0\" // Target OS and architecture #define VMIME_TARGET_ARCH \"${VMIME_TARGET_ARCH}\" #define VMIME_TARGET_OS \"${VMIME_TARGET_OS}\" // Set to 1 if debugging should be activated #define VMIME_DEBUG ${VMIME_DEBUG} // Byte order (set one or the other, but not both!) #define VMIME_BYTE_ORDER_BIG_ENDIAN ${VMIME_BYTE_ORDER_BIG_ENDIAN} #define VMIME_BYTE_ORDER_LITTLE_ENDIAN ${VMIME_BYTE_ORDER_LITTLE_ENDIAN} // Generic types // -- 8-bit typedef signed ${VMIME_TYPE_INT8} vmime_int8; typedef unsigned ${VMIME_TYPE_INT8} vmime_uint8; // -- 16-bit typedef signed ${VMIME_TYPE_INT16} vmime_int16; typedef unsigned ${VMIME_TYPE_INT16} vmime_uint16; // -- 32-bit typedef signed ${VMIME_TYPE_INT32} vmime_int32; typedef unsigned ${VMIME_TYPE_INT32} vmime_uint32; // Options // -- File-system support #define VMIME_HAVE_FILESYSTEM_FEATURES 1 // -- SASL support #define VMIME_HAVE_SASL_SUPPORT ${VMIME_HAVE_SASL_SUPPORT} // -- TLS support #define VMIME_HAVE_TLS_SUPPORT ${VMIME_HAVE_TLS_SUPPORT} // -- Messaging support #define VMIME_HAVE_MESSAGING_FEATURES ${VMIME_HAVE_MESSAGING_FEATURES} // -- Built-in messaging protocols #define VMIME_BUILTIN_MESSAGING_PROTOS \"$VMIME_BUILTIN_MESSAGING_PROTOS\" #define VMIME_BUILTIN_MESSAGING_PROTO_POP3 $VMIME_BUILTIN_MESSAGING_PROTO_POP3 #define VMIME_BUILTIN_MESSAGING_PROTO_SMTP $VMIME_BUILTIN_MESSAGING_PROTO_SMTP #define VMIME_BUILTIN_MESSAGING_PROTO_IMAP $VMIME_BUILTIN_MESSAGING_PROTO_IMAP #define VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR $VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR #define VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL $VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL // -- Built-in platform handlers #define VMIME_BUILTIN_PLATFORMS \"$VMIME_BUILTIN_PLATFORMS\" #define VMIME_BUILTIN_PLATFORM_WINDOWS $VMIME_BUILTIN_PLATFORM_WINDOWS #define VMIME_BUILTIN_PLATFORM_POSIX $VMIME_BUILTIN_PLATFORM_POSIX " > vmime/config.hpp # Miscellaneous flags echo "// Miscellaneous flags" >> vmime/config.hpp echo "#define VMIME_SENDMAIL_PATH \"$SENDMAIL\"" >> vmime/config.hpp echo "" >> vmime/config.hpp # Additional defines echo "// Additional defines" >> vmime/config.hpp for d in $VMIME_ADDITIONAL_DEFINES ; do echo "#define VMIME_$d 1" >> vmime/config.hpp done echo "" >> vmime/config.hpp echo "#endif // VMIME_CONFIG_HPP_INCLUDED" >> vmime/config.hpp { $as_echo "$as_me:${as_lineno-$LINENO}: result: +=================+ | CONFIGURATION | +=================+ Installation prefix : $prefix Debugging mode : $conf_debug Messaging support : $conf_messaging * protocols :$VMIME_BUILTIN_MESSAGING_PROTOS File-system support : yes Platform handlers :$VMIME_BUILTIN_PLATFORMS SASL support : $conf_sasl TLS/SSL support : $conf_tls Please check 'vmime/config.hpp' to ensure the configuration is correct. " >&5 $as_echo " +=================+ | CONFIGURATION | +=================+ Installation prefix : $prefix Debugging mode : $conf_debug Messaging support : $conf_messaging * protocols :$VMIME_BUILTIN_MESSAGING_PROTOS File-system support : yes Platform handlers :$VMIME_BUILTIN_PLATFORMS SASL support : $conf_sasl TLS/SSL support : $conf_tls Please check 'vmime/config.hpp' to ensure the configuration is correct. " >&6; } libvmime-0.9.1/vmime.sln0000644000175000017500000000155611470477543015505 0ustar mnordstrmnordstrMicrosoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmime", "vmime.vcproj", "{B2B47E11-DB57-49E1-8895-F03BDF78A221}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Debug.ActiveCfg = Debug|Win32 {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Debug.Build.0 = Debug|Win32 {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Release.ActiveCfg = Release|Win32 {B2B47E11-DB57-49E1-8895-F03BDF78A221}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal libvmime-0.9.1/configure.in0000644000175000017500000005032011470477531016151 0ustar mnordstrmnordstr # configure.in # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! # Init AC_INIT([VMime Library], [0.9.1], [vincent@vincent-richard.net], [vmime]) AC_PREREQ([2.53]) AC_CONFIG_AUX_DIR(autotools) # Library name GENERIC_LIBRARY_NAME="vmime" AC_SUBST(GENERIC_LIBRARY_NAME) GENERIC_VERSIONED_LIBRARY_NAME="vmime" AC_SUBST(GENERIC_VERSIONED_LIBRARY_NAME) LIBRARY_NAME="libvmime" AC_SUBST(LIBRARY_NAME) # Library version LIBRARY_VERSION="0:0:0" AC_SUBST(LIBRARY_VERSION) LIBRARY_RELEASE="0" AC_SUBST(LIBRARY_RELEASE) # # Miscellaneous init stuff # AC_CANONICAL_HOST AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(vmime, 0.9.1) AC_CONFIG_SRCDIR([src/base.cpp]) AM_CONFIG_HEADER([config.h]) AM_MAINTAINER_MODE VMIME_ADDITIONAL_DEFINES="" VMIME_ADDITIONAL_PC_LIBS="" # # Check compilers, processors, etc # AC_PROG_CC AC_PROG_CXX AC_PROG_CPP AC_C_CONST AC_C_INLINE AC_HEADER_STDC AC_HEADER_STDBOOL AC_HEADER_DIRENT AC_HEADER_TIME AC_C_CONST AC_LANG(C++) AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_LN_S AC_PROG_LIBTOOL OST_LIB_PTHREAD # from GNU Commons C++ AM_SANITY_CHECK AM_PROG_LIBTOOL AM_PROG_CC_C_O AM_ICONV # # Some checks # # -- iconv AC_MSG_CHECKING([if an usable version of iconv exists (required)]) if test "x$am_cv_func_iconv" = "xyes"; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_ERROR(no usable version of iconv has been found) fi # -- global constructors (stolen from 'configure.in' in libsigc++) AC_MSG_CHECKING([if linker supports global constructors]) cat > mylib.$ac_ext < struct A { A() { printf("PASS\n"); } }; A a; int foo() { return 1; } EOF cat > mytest.$ac_ext < extern int foo(); int main(int, char**) { int i = foo(); if(i != 1) printf("FAIL\n"); return 0; } EOF sh libtool --mode=compile $CXX -c mylib.$ac_ext >&5 sh libtool --mode=link $CXX -o libtest.la -rpath / -version-info 0 mylib.lo >&5 $CXX -c $CFLAGS $CPPFLAGS mytest.$ac_ext >&5 sh libtool --mode=link $CXX -o mytest mytest.o libtest.la >&5 2>/dev/null if test -x mytest -a "$cross_compiling" != yes; then myresult=`./mytest` if test "X$myresult" = "XPASS"; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_ERROR([ =================================================================== ERROR: This platform lacks support of construction of global objects in shared libraries. See ftp://rtfm.mit.edu/pub/usenet/news.answers/g++-FAQ/plain for details about this problem. Also for possible solutions http://www.informatik.uni-frankfurt.de/~fp/Tcl/tcl-c++/tcl-c++.html ===================================================================]) fi else AC_MSG_RESULT(unknown) fi rm -f mylib.* mytest.* libtest.la .libs/libtest* mytest .libs/mytest .libs/lt-mytest .libs/mylib.* >&5 rmdir .libs >&5 # -- const_cast AC_MSG_CHECKING([if C++ compiler supports const_cast<> (required)]) AC_TRY_COMPILE( [ class foo; ],[ const foo *c=0; foo *c1=const_cast(c); ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler const_cast<> does not work) ]) # -- dynamic_cast AC_MSG_CHECKING([if C++ compiler supports dynamic_cast<> (required)]) AC_TRY_COMPILE( [ class foo { public: virtual ~foo() { } }; class bar : public foo { public: virtual ~bar() { } }; ],[ foo *c=0; bar *c1=dynamic_cast(c); ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler dynamic_cast<> does not work) ]) # -- mutable AC_MSG_CHECKING(if C++ compiler supports mutable (required)) AC_TRY_COMPILE( [ class k { mutable char *c; public: void foo() const { c=0; } }; ],[ ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler does not support 'mutable') ]) # -- namespace AC_MSG_CHECKING(if C++ compiler supports name spaces (required)) AC_TRY_COMPILE( [ namespace Check { int i; } ],[ Check::i=1; ],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_ERROR(C++ compiler does not support 'namespace') ]) # # Target OS and architecture # VMIME_TARGET_ARCH=${target_cpu} VMIME_TARGET_OS=${target_os} # # Byte Order # AC_C_BIGENDIAN if test "x$ac_cv_c_bigendian" = "xyes"; then VMIME_BYTE_ORDER_BIG_ENDIAN=1 VMIME_BYTE_ORDER_LITTLE_ENDIAN=0 else VMIME_BYTE_ORDER_BIG_ENDIAN=0 VMIME_BYTE_ORDER_LITTLE_ENDIAN=1 fi # # Generic Type Size # AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) case 1 in $ac_cv_sizeof_char) VMIME_TYPE_INT8=char ;; *) AC_MSG_ERROR([no 8-bit type available]) esac case 2 in $ac_cv_sizeof_short) VMIME_TYPE_INT16=short ;; $ac_cv_sizeof_int) VMIME_TYPE_INT16=int ;; *) AC_MSG_ERROR([no 16-bit type available]) esac case 4 in $ac_cv_sizeof_int) VMIME_TYPE_INT32=int ;; $ac_cv_sizeof_long) VMIME_TYPE_INT32=long ;; *) AC_MSG_ERROR([no 32-bit type available]) esac # # Options # # ** debug AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Turn on debugging, default: disabled]), [case "${enableval}" in yes) conf_debug=yes ;; no) conf_debug=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; esac], [conf_debug=no]) if test "x$conf_debug" = "xyes"; then AM_CONDITIONAL(VMIME_DEBUG, true) VMIME_DEBUG=1 else AM_CONDITIONAL(VMIME_DEBUG, false) VMIME_DEBUG=0 fi # ** messaging AC_ARG_ENABLE(messaging, AC_HELP_STRING([--enable-messaging], [Enable messaging support and connection to mail servers, default: enabled]), [case "${enableval}" in yes) conf_messaging=yes ;; no) conf_messaging=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-messaging) ;; esac], [conf_messaging=yes]) if test "x$conf_messaging" = "xyes"; then AM_CONDITIONAL(VMIME_HAVE_MESSAGING_FEATURES, true) VMIME_HAVE_MESSAGING_FEATURES=1 else AM_CONDITIONAL(VMIME_HAVE_MESSAGING_FEATURES, false) VMIME_HAVE_MESSAGING_FEATURES=0 fi # ** SASL AC_ARG_ENABLE(sasl, AC_HELP_STRING([--enable-sasl], [Enable SASL support with GNU SASL, default: enabled]), [case "${enableval}" in yes) conf_sasl=yes ;; no) conf_sasl=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-sasl) ;; esac], [conf_sasl=yes]) if test "x$conf_sasl" = "xyes"; then # -- GNU SASL Library (http://www.gnu.org/software/gsasl/) AC_CHECK_HEADER(gsasl.h, AC_CHECK_LIB(gsasl, gsasl_check_version, [have_gsasl=yes AC_SUBST(GSASL_AVAIL_LIBS, -lgsasl) AC_SUBST(GSASL_AVAIL_REQUIRED, libgsasl)], have_gsasl=no), have_gsasl=no) if test "x$have_gsasl" = "xyes"; then AM_CONDITIONAL(VMIME_HAVE_SASL_SUPPORT, true) VMIME_HAVE_SASL_SUPPORT=1 GSASL_REQUIRED=${GSASL_AVAIL_REQUIRED} GSASL_LIBS=${GSASL_AVAIL_LIBS} else AC_MSG_ERROR(can't find an usable version of GNU SASL library) fi else AM_CONDITIONAL(VMIME_HAVE_SASL_SUPPORT, false) VMIME_HAVE_SASL_SUPPORT=0 GSASL_REQUIRED= GSASL_LIBS= fi AC_SUBST(GSASL_REQUIRED) AC_SUBST(GSASL_LIBS) # ** TLS AC_ARG_ENABLE(tls, AC_HELP_STRING([--enable-tls], [Enable TLS/SSL support with GNU TLS, default: enabled]), [case "${enableval}" in yes) conf_tls=yes ;; no) conf_tls=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-tls) ;; esac], [conf_tls=yes]) if test "x$conf_tls" = "xyes"; then # -- GNU TLS Library (http://www.gnu.org/software/gnutls/) PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 1.2.0], have_gnutls=yes, have_gnutls=no) if test "x$have_gnutls" = "xyes"; then AM_CONDITIONAL(VMIME_HAVE_TLS_SUPPORT, true) VMIME_HAVE_TLS_SUPPORT=1 else AC_MSG_ERROR(can't find an usable version of GNU TLS library) fi else AM_CONDITIONAL(VMIME_HAVE_TLS_SUPPORT, false) VMIME_HAVE_TLS_SUPPORT=0 fi # ** platform handlers VMIME_BUILTIN_PLATFORMS='' VMIME_DETECT_PLATFORM='' case "x${target_os}" in xwin* | xmingw* | xcygwin*) VMIME_DETECT_PLATFORM='windows' ;; x*) # Default is POSIX VMIME_DETECT_PLATFORM='posix' ;; esac # ** messaging protocols VMIME_BUILTIN_MESSAGING_PROTOS='' AC_ARG_ENABLE(messaging-proto-pop3, AC_HELP_STRING([--enable-messaging-proto-pop3], [Enable built-in support for protocol 'pop3', default: enabled]), [case "${enableval}" in yes) conf_messaging_proto_pop3=yes ;; no) conf_messaging_proto_pop3=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-messaging-proto-pop3) ;; esac], [conf_messaging_proto_pop3=yes]) if test "x$conf_messaging_proto_pop3" = "xyes"; then AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_POP3, true) VMIME_BUILTIN_MESSAGING_PROTO_POP3=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS pop3" else AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_POP3, false) VMIME_BUILTIN_MESSAGING_PROTO_POP3=0 fi AC_ARG_ENABLE(messaging-proto-smtp, AC_HELP_STRING([--enable-messaging-proto-smtp], [Enable built-in support for protocol 'smtp', default: enabled]), [case "${enableval}" in yes) conf_messaging_proto_smtp=yes ;; no) conf_messaging_proto_smtp=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-messaging-proto-smtp) ;; esac], [conf_messaging_proto_smtp=yes]) if test "x$conf_messaging_proto_smtp" = "xyes"; then AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_SMTP, true) VMIME_BUILTIN_MESSAGING_PROTO_SMTP=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS smtp" else AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_SMTP, false) VMIME_BUILTIN_MESSAGING_PROTO_SMTP=0 fi AC_ARG_ENABLE(messaging-proto-imap, AC_HELP_STRING([--enable-messaging-proto-imap], [Enable built-in support for protocol 'imap', default: enabled]), [case "${enableval}" in yes) conf_messaging_proto_imap=yes ;; no) conf_messaging_proto_imap=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-messaging-proto-imap) ;; esac], [conf_messaging_proto_imap=yes]) if test "x$conf_messaging_proto_imap" = "xyes"; then AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_IMAP, true) VMIME_BUILTIN_MESSAGING_PROTO_IMAP=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS imap" else AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_IMAP, false) VMIME_BUILTIN_MESSAGING_PROTO_IMAP=0 fi AC_ARG_ENABLE(messaging-proto-maildir, AC_HELP_STRING([--enable-messaging-proto-maildir], [Enable built-in support for protocol 'maildir', default: enabled]), [case "${enableval}" in yes) conf_messaging_proto_maildir=yes ;; no) conf_messaging_proto_maildir=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-messaging-proto-maildir) ;; esac], [conf_messaging_proto_maildir=yes]) if test "x$conf_messaging_proto_maildir" = "xyes"; then AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR, true) VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS maildir" else AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR, false) VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR=0 fi AC_ARG_ENABLE(messaging-proto-sendmail, AC_HELP_STRING([--enable-messaging-proto-sendmail], [Enable built-in support for protocol 'sendmail', default: enabled]), [case "${enableval}" in yes) conf_messaging_proto_sendmail=yes ;; no) conf_messaging_proto_sendmail=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-messaging-proto-sendmail) ;; esac], [conf_messaging_proto_sendmail=yes]) if test "x$conf_messaging_proto_sendmail" = "xyes"; then if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL, true) VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL=1 VMIME_BUILTIN_MESSAGING_PROTOS="$VMIME_BUILTIN_MESSAGING_PROTOS sendmail" else AC_MSG_WARN(sendmail is only available on POSIX platforms) AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL, false) VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL=0 fi else AM_CONDITIONAL(VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL, false) VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL=0 fi # # System mail # AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, /usr/sbin:/usr/lib) # # Detect some platform-specific stuff # # -- MLang (Windows) if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then AC_CHECK_HEADER(mlang.h, [VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_MLANG_H"]) fi # -- Link with Winsock (Windows) if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then VMIME_ADDITIONAL_PC_LIBS="$VMIME_ADDITIONAL_PC_LIBS -lwsock32" fi # -- getaddrinfo (POSIX) if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then AC_CHECK_HEADERS(netdb.h sys/types.h sys/socket.h,) AC_CHECK_FUNC(getaddrinfo, [VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_GETADDRINFO"]) fi # -- pthreads (POSIX) ACX_PTHREAD([VMIME_ADDITIONAL_DEFINES="$VMIME_ADDITIONAL_DEFINES HAVE_PTHREAD"]) if test "x$VMIME_DETECT_PLATFORM" = "xwindows"; then conf_platform_windows=yes else conf_platform_windows=no fi AC_ARG_ENABLE(platform-windows, AC_HELP_STRING([--enable-platform-windows], [Compile built-in platform handler for 'windows' , default: disabled, except if default for your platform]), [case "${enableval}" in yes) conf_platform_windows=yes ;; no) conf_platform_windows=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-platform-windows) ;; esac], []) if test "x$conf_platform_windows" = "xyes"; then AM_CONDITIONAL(VMIME_BUILTIN_PLATFORM_WINDOWS, true) VMIME_BUILTIN_PLATFORM_WINDOWS=1 VMIME_BUILTIN_PLATFORMS="$VMIME_BUILTIN_PLATFORMS windows" else AM_CONDITIONAL(VMIME_BUILTIN_PLATFORM_WINDOWS, false) VMIME_BUILTIN_PLATFORM_WINDOWS=0 fi if test "x$VMIME_DETECT_PLATFORM" = "xposix"; then conf_platform_posix=yes else conf_platform_posix=no fi AC_ARG_ENABLE(platform-posix, AC_HELP_STRING([--enable-platform-posix], [Compile built-in platform handler for 'posix' , default: disabled, except if default for your platform]), [case "${enableval}" in yes) conf_platform_posix=yes ;; no) conf_platform_posix=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-platform-posix) ;; esac], []) if test "x$conf_platform_posix" = "xyes"; then AM_CONDITIONAL(VMIME_BUILTIN_PLATFORM_POSIX, true) VMIME_BUILTIN_PLATFORM_POSIX=1 VMIME_BUILTIN_PLATFORMS="$VMIME_BUILTIN_PLATFORMS posix" else AM_CONDITIONAL(VMIME_BUILTIN_PLATFORM_POSIX, false) VMIME_BUILTIN_PLATFORM_POSIX=0 fi # # Workarounds for some platforms # # -- pkgconfigdir case "x${target_os}" in xfreebsd*) VMIME_PKGCONFIGDIR='$(prefix)/libdata/pkgconfig' ;; x*) VMIME_PKGCONFIGDIR='$(libdir)/pkgconfig' ;; esac AC_SUBST(VMIME_PKGCONFIGDIR) # -- libtool 'CXX' tag case "x${target_os}" in xfreebsd*) # FIXME: temporary hack until I find a better solution # to make libtool use the C++ tag... LIBTOOL="$LIBTOOL --tag=CXX" ;; esac # # Flags # LIBRARY_LD_FLAGS="\$(top_builddir)/src/\$(LIBRARY_NAME).la" AC_SUBST(LIBRARY_LD_FLAGS) PKGCONFIG_CFLAGS="" PKGCONFIG_LIBS="" AC_SUBST(PKGCONFIG_CFLAGS) AC_SUBST(PKGCONFIG_LIBS) EXTRA_CFLAGS="$EXTRA_CFLAGS -D_REENTRANT=1 -D_THREAD_SAFE=1 $LIBGNUTLS_CFLAGS" EXTRA_LIBS="$GSASL_LIBS $LIBGNUTLS_LIBS" CFLAGS="" CXXFLAGS="" # -- Debug if test x$VMIME_DEBUG = x1 ; then # -g OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -g" AC_MSG_CHECKING(whether cc accepts -g) AC_TRY_COMPILE(,,echo yes,echo no; CXXFLAGS="$OLD_CXXFLAGS") else # -O2 OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -O2" AC_MSG_CHECKING(whether cc accepts -O2) AC_TRY_COMPILE(,,echo yes,echo no; CXXFLAGS="$OLD_CXXFLAGS") fi # -- HACK: add -fPIC or -fpic on static library object files EXTRA_CFLAGS="$EXTRA_CFLAGS $lt_prog_compiler_pic" # # Check to see if the compiler can handle some flags # # -ansi OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -ansi" AC_MSG_CHECKING(whether cc accepts -ansi) AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS") # -pedantic OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -pedantic" AC_MSG_CHECKING(whether cc accepts -pedantic) AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS") # -W OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -W" AC_MSG_CHECKING(whether cc accepts -W) AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS") # -Wall OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall" AC_MSG_CHECKING(whether cc accepts -Wall) AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS") # -Wpointer-arith OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wpointer-arith" AC_MSG_CHECKING(whether cc accepts -Wpointer-arith) AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS") # -Wold-style-cast OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wold-style-cast" AC_MSG_CHECKING(whether cc accepts -Wold-style-cast) AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS") # -Wconversion OLD_EXTRA_CFLAGS="$EXTRA_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wconversion" AC_MSG_CHECKING(whether cc accepts -Wconversion) AC_TRY_COMPILE(,,echo yes,echo no; EXTRA_CFLAGS="$OLD_EXTRA_CFLAGS") #EXTRA_CFLAGS=`echo $EXTRA_CFLAGS | sed -e 's| |\n|g' | sort | uniq | tr '\n' ' '` EXTRA_CFLAGS=`echo $EXTRA_CFLAGS | tr '\n' ' ' | sort | uniq | tr '\n' ' '` EXTRA_LIBS=`echo $EXTRA_LIBS | sed -e 's|^ ||g' | sed -e 's| | |g'` AC_SUBST(CFLAGS) AC_SUBST(CXXFLAGS) AC_SUBST(EXTRA_CFLAGS) AC_SUBST(EXTRA_LIBS) AC_SUBST(VMIME_ADDITIONAL_PC_LIBS) LIBS=`echo $LIBS | sed -e 's|^ ||g' | sed -e 's| | |g'` AC_CONFIG_FILES([ vmime.pc Makefile src/Makefile vmime/Makefile ]) AC_OUTPUT # # Generate vmime/config.hpp # echo " // // This file was automatically generated by configuration script. // #ifndef VMIME_CONFIG_HPP_INCLUDED #define VMIME_CONFIG_HPP_INCLUDED // Name of package #define VMIME_PACKAGE \"libvmime\" // Version number of package #define VMIME_VERSION \"0.9.1\" #define VMIME_API \"0:0:0\" // Target OS and architecture #define VMIME_TARGET_ARCH \"${VMIME_TARGET_ARCH}\" #define VMIME_TARGET_OS \"${VMIME_TARGET_OS}\" // Set to 1 if debugging should be activated #define VMIME_DEBUG ${VMIME_DEBUG} // Byte order (set one or the other, but not both!) #define VMIME_BYTE_ORDER_BIG_ENDIAN ${VMIME_BYTE_ORDER_BIG_ENDIAN} #define VMIME_BYTE_ORDER_LITTLE_ENDIAN ${VMIME_BYTE_ORDER_LITTLE_ENDIAN} // Generic types // -- 8-bit typedef signed ${VMIME_TYPE_INT8} vmime_int8; typedef unsigned ${VMIME_TYPE_INT8} vmime_uint8; // -- 16-bit typedef signed ${VMIME_TYPE_INT16} vmime_int16; typedef unsigned ${VMIME_TYPE_INT16} vmime_uint16; // -- 32-bit typedef signed ${VMIME_TYPE_INT32} vmime_int32; typedef unsigned ${VMIME_TYPE_INT32} vmime_uint32; // Options // -- File-system support #define VMIME_HAVE_FILESYSTEM_FEATURES 1 // -- SASL support #define VMIME_HAVE_SASL_SUPPORT ${VMIME_HAVE_SASL_SUPPORT} // -- TLS support #define VMIME_HAVE_TLS_SUPPORT ${VMIME_HAVE_TLS_SUPPORT} // -- Messaging support #define VMIME_HAVE_MESSAGING_FEATURES ${VMIME_HAVE_MESSAGING_FEATURES} // -- Built-in messaging protocols #define VMIME_BUILTIN_MESSAGING_PROTOS \"$VMIME_BUILTIN_MESSAGING_PROTOS\" #define VMIME_BUILTIN_MESSAGING_PROTO_POP3 $VMIME_BUILTIN_MESSAGING_PROTO_POP3 #define VMIME_BUILTIN_MESSAGING_PROTO_SMTP $VMIME_BUILTIN_MESSAGING_PROTO_SMTP #define VMIME_BUILTIN_MESSAGING_PROTO_IMAP $VMIME_BUILTIN_MESSAGING_PROTO_IMAP #define VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR $VMIME_BUILTIN_MESSAGING_PROTO_MAILDIR #define VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL $VMIME_BUILTIN_MESSAGING_PROTO_SENDMAIL // -- Built-in platform handlers #define VMIME_BUILTIN_PLATFORMS \"$VMIME_BUILTIN_PLATFORMS\" #define VMIME_BUILTIN_PLATFORM_WINDOWS $VMIME_BUILTIN_PLATFORM_WINDOWS #define VMIME_BUILTIN_PLATFORM_POSIX $VMIME_BUILTIN_PLATFORM_POSIX " > vmime/config.hpp # Miscellaneous flags echo "// Miscellaneous flags" >> vmime/config.hpp echo "#define VMIME_SENDMAIL_PATH \"$SENDMAIL\"" >> vmime/config.hpp echo "" >> vmime/config.hpp # Additional defines echo "// Additional defines" >> vmime/config.hpp for d in $VMIME_ADDITIONAL_DEFINES ; do echo "#define VMIME_$d 1" >> vmime/config.hpp done echo "" >> vmime/config.hpp echo "#endif // VMIME_CONFIG_HPP_INCLUDED" >> vmime/config.hpp AC_MSG_RESULT([ +=================+ | CONFIGURATION | +=================+ Installation prefix : $prefix Debugging mode : $conf_debug Messaging support : $conf_messaging * protocols :$VMIME_BUILTIN_MESSAGING_PROTOS File-system support : yes Platform handlers :$VMIME_BUILTIN_PLATFORMS SASL support : $conf_sasl TLS/SSL support : $conf_tls Please check 'vmime/config.hpp' to ensure the configuration is correct. ]) libvmime-0.9.1/HACKING0000644000175000017500000001514611250723264014627 0ustar mnordstrmnordstr This file contains coding guidelines for VMime. You should follow these guidelines if you want to contribute to VMime. It guarantees some minimal quality of the code. 1. General guidelines 1.1. Language 1.2. Unit tests 1.3. CVS 1.4. ChangeLog 1.5. Warnings 2. Style, indentation and braces 2.1. Indentation 2.2. Brace position 2.3. "switch" statement 2.4. Single instruction 2.5. Line length 2.6. Spaces and parentheses 2.7. End-of-line character 3. Naming conventions 3.1. Classes 3.2. Variables/parameters/member variables 3.3. Member variables 3.4. Files 3.5. Namespaces 4. Comments 5. Miscellaneous 1. General guidelines ===================== 1.1. Language ------------- The project language is English. All comments, variable names, class names, commit messages and so on, must be in English. 1.2. Unit tests --------------- Unit tests are very important. For each new class you write, you should also write a unit test for it. If you write a new method, add a new test case in the unit test of the class. When you fix a bug, also add a new test case to ensure the bug will not happen anymore. 1.3. CVS -------- Each commit MUST be done with a message ('-m' flag) that briefly describes what changes have been done. DO NOT use commit messages like -m "Updated"! 1.4. ChangeLog -------------- ChangeLog must be updated when a major change has occured. It is not required (but not forbidden) to report minor bug fixes in the ChangeLog. Each ChangeLog entry must have an author and a date. 1.5. Warnings ------------- The code should compile WITHOUT ANY WARNING, even those for unused parameters! 2. Style, indentation and braces ================================ 2.1. Indentation ---------------- Use TABS (ASCII character #9) and _not_ SPACES. This allow everyone to set tab width to its preferred settings (eg. 4 or 8 spaces). 2.2. Brace position ------------------- Open braces should always be at the beginning of the line after the statement that begins the block. Contents of the brace should be indented by 1 tab. if (expr) { do_something(); do_another_thing(); } else { do_something_else(); } 2.3. "switch" statement ----------------------- switch (expr) { case 0: something; break; case 1: something_else; break; case 2: { int var = 42; another_thing; break; } } 2.4. Single instruction ----------------------- Omit braces around simple single-statement body: if (...) something; and not: if (...) { something; } Except when body spans over multiple lines: if (...) { something_too_long_for( a_single_line); } 2.5. Line length ---------------- Line length should not exceed 80 characters. 2.6. Spaces and parentheses --------------------------- Put spaces around operators: =, >, <, !=, +, -, /, *, ^, %, ||, &&, &, |: x = (a * (b + (c - d))) Do not put spaces around parentheses. if ((a == b) || (c == d)) Do not put spaces around "->": object->method() Do not put spaces inside brackets: x = array[index] and _NOT_: x = array[ index ] Do not use space between a function name and parenthesis. No extra spaces between parameters and arguments, just after commas: method(arg1, arg2, ...) Do use a single space before flow control statements: while (x == y) and _NOT_: while(x==y) 2.7. End-of-line character -------------------------- Configure your editor to use "\n" (UNIX convention) for end-of-line sequence, and not "\r\n" (Windows), nor "\n\r", nor any other combination. 3. Naming conventions ===================== 3.1. Classes ------------ Classes names are in lower-case. However, each word should start with an upper-case letter. Examples: "object", "exampleClass", "anotherExampleClass"... 3.2. Variables/parameters/member variables ------------------------------------------ Variable names should be enough explicit so that someone reading the code can instantly understand what the variable contains and is used for. Variables names are in lower-case. DO NOT use Hungarian notation. Examples: "address", "recipientMailbox", ... Avoid variable names with less than 5 characters, except for loop indices and iterators. NOTE: variable names like "it", "jt" and so on are commonly used when iterating over STL containers. 3.3. Member variables --------------------- Use a prefix for class members: "m_" for normal class members, and "sm_" for static members, if they are not public. Examples: "m_mailboxList", "sm_instance"... 3.4. Files ---------- Use ".hpp" for header files, and ".cpp" for implementation files. ".inc" should be used for implementation files not directly compiled, but included from other implementation files. Files have to be named exactly like the class they define. For example, class "mailboxList" should be declared in "mailboxList.hpp" and implemented in "mailboxList.cpp". Header files must be placed in 'vmime/' directory. Implementation files must be placed in 'src/' directory. 3.5. Namespaces --------------- Namespaces are named exactly like variables. 4. Comments =========== The // (two slashes) style of comment tags should be used in most situations. Where ever possible, place comments above the code instead of beside it. Comments can be placed at the end of a line when one or more spaces follow. Tabs should NOT be used to indent at the end of a line: class myClass { private: int m_member1; // first member int m_secondMember; // second member }; 5. Miscellaneous ================ * No code should be put in header files, only declarations (except for templates). * Try to avoid public member variables. Write accessors instead (get/set). * Do NOT use 'using namespace'. All namespaces should be explicitely named. * Use the 'get' and 'set' prefix for accessors: Variable: m_foo Get method: getFoo() Set method: setFoo() * No more than one class per file (except for inner classes). * Put the inclusion for the class's header file as the first inclusion in the implementation file. * Put the copyright header at the top of each file. * Write "unique inclusion #ifdef's" for header files: #ifndef N1_N2_FILENAME_HPP_INCLUDED #define N1_N2_FILENAME_HPP_INCLUDED // ... #endif // N1_N2_FILENAME_HPP_INCLUDED where N1 is the top-level namespace, N2 the sub-namespace, and so on. For example, class "vmime::utility::stringUtils" uses the following #ifdef name: VMIME_UTILITY_STRINGUTILS_HPP_INCLUDED. libvmime-0.9.1/vmime.vcproj0000644000175000017500000005244711470477543016221 0ustar mnordstrmnordstr libvmime-0.9.1/Makefile.am0000644000175000017500000000111111470477531015666 0ustar mnordstrmnordstr # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! BINDING = INCLUDE = vmime #examples tests SUBDIRS = src $(INCLUDE) $(BINDING) DIST_SUBDIRS = $(SUBDIRS) autotools #AUTOMAKE_OPTIONS = dist-bzip2 AUTOMAKE_OPTIONS = no-dist pkgconfigdir = $(VMIME_PKGCONFIGDIR) pkgconfig_DATA = $(GENERIC_VERSIONED_LIBRARY_NAME).pc EXTRA_DIST=SConstruct bootstrap dist: @ echo "" @ echo "Please use 'scons dist' to generate distribution tarball." @ echo "" doc_DATA = AUTHORS ChangeLog COPYING INSTALL NEWS README docdir = $(datadir)/doc/$(GENERIC_LIBRARY_NAME) libvmime-0.9.1/Makefile.in0000644000175000017500000004605111470477543015716 0ustar mnordstrmnordstr# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # File automatically generated by SConstruct ('scons autotools') # DO NOT EDIT! VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in $(srcdir)/vmime.pc.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ $(top_srcdir)/m4/ost_posix.m4 $(top_srcdir)/m4/ost_prog.m4 \ $(top_srcdir)/m4/ost_pthread.m4 \ $(top_srcdir)/m4/ost_systime.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = vmime.pc CONFIG_CLEAN_VPATH_FILES = SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)" DATA = $(doc_DATA) $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS ETAGS = etags CTAGS = ctags ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ EXTRA_LIBS = @EXTRA_LIBS@ FGREP = @FGREP@ GENERIC_LIBRARY_NAME = @GENERIC_LIBRARY_NAME@ GENERIC_VERSIONED_LIBRARY_NAME = @GENERIC_VERSIONED_LIBRARY_NAME@ GREP = @GREP@ GSASL_AVAIL_LIBS = @GSASL_AVAIL_LIBS@ GSASL_AVAIL_REQUIRED = @GSASL_AVAIL_REQUIRED@ GSASL_LIBS = @GSASL_LIBS@ GSASL_REQUIRED = @GSASL_REQUIRED@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBRARY_LD_FLAGS = @LIBRARY_LD_FLAGS@ LIBRARY_NAME = @LIBRARY_NAME@ LIBRARY_RELEASE = @LIBRARY_RELEASE@ LIBRARY_VERSION = @LIBRARY_VERSION@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKGCONFIG_CFLAGS = @PKGCONFIG_CFLAGS@ PKGCONFIG_LIBS = @PKGCONFIG_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ SED = @SED@ SENDMAIL = @SENDMAIL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ THREAD_FLAGS = @THREAD_FLAGS@ THREAD_LIBS = @THREAD_LIBS@ VERSION = @VERSION@ VMIME_ADDITIONAL_PC_LIBS = @VMIME_ADDITIONAL_PC_LIBS@ VMIME_PKGCONFIGDIR = @VMIME_PKGCONFIGDIR@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = $(datadir)/doc/$(GENERIC_LIBRARY_NAME) dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ thrprefix = @thrprefix@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ BINDING = INCLUDE = vmime #examples tests SUBDIRS = src $(INCLUDE) $(BINDING) DIST_SUBDIRS = $(SUBDIRS) autotools #AUTOMAKE_OPTIONS = dist-bzip2 AUTOMAKE_OPTIONS = no-dist pkgconfigdir = $(VMIME_PKGCONFIGDIR) pkgconfig_DATA = $(GENERIC_VERSIONED_LIBRARY_NAME).pc EXTRA_DIST = SConstruct bootstrap doc_DATA = AUTHORS ChangeLog COPYING INSTALL NEWS README all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 vmime.pc: $(top_builddir)/config.status $(srcdir)/vmime.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-docDATA: $(doc_DATA) @$(NORMAL_INSTALL) test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ done uninstall-docDATA: @$(NORMAL_UNINSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(docdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(docdir)" && rm -f $$files install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-am: all-am check: check-recursive all-am: Makefile $(DATA) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-docDATA install-pkgconfigDATA install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-docDATA uninstall-pkgconfigDATA .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-libtool ctags ctags-recursive distclean \ distclean-generic distclean-hdr distclean-libtool \ distclean-tags dvi dvi-am html html-am info info-am install \ install-am install-data install-data-am install-docDATA \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ install-man install-pdf install-pdf-am install-pkgconfigDATA \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am uninstall-docDATA \ uninstall-pkgconfigDATA dist: @ echo "" @ echo "Please use 'scons dist' to generate distribution tarball." @ echo "" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libvmime-0.9.1/README.refcounting0000644000175000017500000000606511250723264017042 0ustar mnordstrmnordstr============================================== Reference counting and smart pointers in VMime ============================================== I. Introduction =============== Since version 0.7.2cvs, VMime has been modified to use smart pointers and reference counting instead of raw pointers. This simplifies a lot using VMime objects as you don't have to worry about freeing memory occupied by objects, or even wondering which of your program or VMime is responsible for deleting the object. This is also convenient when a function returns a list of objects. Before, you wrote: std::vector subFolders = folder->getFolders(); ...do something with result... for (std::vector ::iterator it = subFolders.begin() ; it != subFolders.end() ; ++it) { delete *it; } Now, you can simply write: std::vector subFolders = folder->getFolders(); ...do something with result... and nothing more! Two new template classes were introduced: - vmime::ref <> holds a strong reference to an object. When there is no more strong reference pointing to an object, the object is deleted. - vmime::weak_ref <> holds a weak reference to an object. A weak reference automatically points to NULL when the last strong reference is released. It can be used to bypass the problems with circular references: A holds a strong reference to B, which holds a strong reference back to A. II. Creating objects ==================== You should not use 'new' to allocate VMime objects anymore. Instead, you should use the vmime::create() helper function: vmime::ref mbox = vmime::create ("me@somewhere.com"); III. Casting ============ Like raw C++ pointers, you can cast VMime references. Implicit downcast is also supported. To do a dynamic cast, write: vmime::ref foo = ... vmime::ref mbox = foo.dynamicCast () then 'mbox' will be set to null ref if the dynamic cast failed (ie. if dynamic type of 'foo' is not/is not derived from 'vmime::mailbox'). The same thing is possible with static cast: vmime::ref foo = ... vmime::ref mbox = foo.staticCast () Like in standard C++, if 'foo' is not really a 'vmime::mailbox', the 'mbox' reference can point to anything (ie. "invalid"), so be careful... Finally, const cast is also supported: vmime::ref foo_const = ... vmime::ref foo = foo_const.constCast(); IV. Upgrading your code from version <= 0.7.1 ============================================= 1. vmime::text -------------- In v0.7.1 and below: vmime::text t1; vmime::newFromString("blah blah", vmime::charset(...), &t1); vmime::text* t2 = vmime::newFromString("foo", vmime::charset(...)); In v0.7.2: vmime::text t1; t1.createFromString("blah blah", vmime::charset(...)); vmime::ref t2 = vmime::newFromString("foo", vmime::charset(...)); libvmime-0.9.1/config.h.in0000644000175000017500000002512511470477541015671 0ustar mnordstrmnordstr/* config.h.in. Generated from configure.in by autoheader. */ /* hack for BROKEN autoheader, since it will not predicitably order macros by any obvious means. */ #undef HAVE_UNISTD_H #undef HAVE_FEATURES_H #undef HAVE_SYS_TYPES_H #ifdef HAVE_UNISTD_H #include #endif #ifndef WIN32 #ifdef HAVE_FEATURES_H #include #endif #endif #ifdef HAVE_SYS_TYPES_H #include #endif #undef HAVE_SYS_TIME_H #if TIME_WITH_SYS_TIME #include #include #else #if HAVE_SYS_TIME_H #include #else #include #endif #endif /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* aix fixes needed */ #undef COMMON_AIX_FIXES /* atomic aix operations */ #undef HAVE_ATOMIC_AIX /* Define to 1 if you have the header file. */ #undef HAVE_BITS_ATOMICITY_H /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_FEATURES_H /* has gcc atomic functions */ #undef HAVE_GCC_BITS_ATOMIC /* has __gnu_cxx atomic functions */ #undef HAVE_GCC_CXX_BITS_ATOMIC /* have hires */ #undef HAVE_HIRES_TIMER /* Define if you have the iconv() function. */ #undef HAVE_ICONV /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `malloc' library (-lmalloc). */ #undef HAVE_LIBMALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mlock' function. */ #undef HAVE_MLOCK /* Define to 1 if you have the `mlockall' function. */ #undef HAVE_MLOCKALL /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* has pwrite */ #undef HAVE_PREAD_PWRITE /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* has stack size */ #undef HAVE_PTHREAD_ATTR_SETSTACKSIZE /* has cancel */ #undef HAVE_PTHREAD_CANCEL /* has non portable delay */ #undef HAVE_PTHREAD_DELAY_NP /* posix thread header */ #undef HAVE_PTHREAD_H /* has mach link */ #undef HAVE_PTHREAD_MACH_THREAD_NP /* has non portable setkind */ #undef HAVE_PTHREAD_MUTEXATTR_SETKIND_NP /* has setttype */ #undef HAVE_PTHREAD_MUTEXATTR_SETTYPE /* has non portable settype */ #undef HAVE_PTHREAD_MUTEXATTR_SETTYPE_NP /* has nanosleep */ #undef HAVE_PTHREAD_NANOSLEEP /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_NP_H /* has rwlock support */ #undef HAVE_PTHREAD_RWLOCK /* has sched yield */ #undef HAVE_PTHREAD_SCHED_YIELD /* has setcancel */ #undef HAVE_PTHREAD_SETCANCEL /* has setcanceltype */ #undef HAVE_PTHREAD_SETCANCELTYPE /* has suspend */ #undef HAVE_PTHREAD_SUSPEND /* has yield */ #undef HAVE_PTHREAD_YIELD /* has np yield */ #undef HAVE_PTHREAD_YIELD_NP /* Define to 1 if you have the `sched_getscheduler' function. */ #undef HAVE_SCHED_GETSCHEDULER /* Define to 1 if you have the header file. */ #undef HAVE_SCHED_H /* Define to 1 if you have the header file. */ #undef HAVE_SEMAPHORE_H /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_ATOMIC_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_ATOMIC_OP_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCHED_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_THREAD_H /* have unix header */ #undef HAVE_UNISTD_H /* has usable atomic functions */ #undef HAVE_WORKING_SYS_ATOMIC_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* mutex type */ #undef PTHREAD_MUTEXTYPE_RECURSIVE /* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* bsd system using linuxthreads */ #undef WITH_LINUXTHREADS /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif #ifdef HAVE_THREAD_H #include "@thrprefix@/thread.h" #if defined(i386) && defined(__svr4__) && !defined(__sun) #define _THR_UNIXWARE #endif #if defined(__SVR4) && defined(__sun) #define _THR_SUNOS5 #else #if defined(__SVR4__) && defined(__SUN__) #define _THR_SUNOS5 #endif #endif #endif #ifdef HAVE_WORKING_SYS_ATOMIC_H #include #define HAVE_ATOMIC #elif defined(HAVE_ATOMIC_AIX) #include #ifndef HAVE_ATOMIC #define HAVE_ATOMIC #endif #endif #if defined(__cplusplus) #if defined(HAVE_GCC_BITS_ATOMIC) || defined(HAVE_GCC_CXX_BITS_ATOMIC) #include #define HAVE_ATOMIC #endif #endif #if defined(HAVE_PTHREAD_H) && ( defined(_THREAD_SAFE) || defined(_REENTRANT) ) #ifdef __QNX__ #define __EXT_QNX #endif #include #ifdef HAVE_PTHREAD_NP_H #include #endif #ifdef HAVE_SEMAPHORE_H #include #endif #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef HAVE_SCHED_H #include #else #ifdef HAVE_SYS_SCHED_H #include #endif #endif #endif #define __PTHREAD_H__ #ifndef PTHREAD_MUTEXTYPE_RECURSIVE #ifdef MUTEX_TYPE_COUNTING_FAST #define PTHREAD_MUTEXTYPE_RECURSIVE MUTEX_TYPE_COUNTING_FAST #endif #endif #ifndef PTHREAD_MUTEXTYPE_RECURSIVE #ifdef PTHREAD_MUTEX_RECURSIVE #define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEX_RECURSIVE #endif #endif #ifndef HAVE_PTHREAD_MUTEXATTR_SETTYPE #if HAVE_PTHREAD_MUTEXATTR_SETKIND_NP #ifndef PTHREAD_MUTEXTYPE_RECURSIVE #define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP #endif #define pthread_mutexattr_gettype(x, y) pthread_mutexattr_getkind_np(x, y) #define pthread_mutexattr_settype(x, y) pthread_mutexattr_setkind_np(x, y) #endif #if HAVE_PTHREAD_MUTEXATTR_SETTYPE_NP #ifndef PTHREAD_MUTEXTYPE_RECURSIVE #define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEXTYPE_RECURSIVE_NP #endif #define pthread_mutexattr_settype(x, y) pthread_mutexattr_settype_np(x, y) #define pthread_mutexattr_gettype(x, y) pthread_mutexattr_gettype_np(x, y) #endif #endif #ifdef HAVE_PTHREAD_MACH_THREAD_NP #define _THR_MACH #endif #ifndef HAVE_PTHREAD_YIELD #ifdef HAVE_PTHREAD_YIELD_NP #define pthread_yield() pthread_yield_np() #define HAVE_PTHREAD_YIELD #endif #endif #ifndef HAVE_PTHREAD_YIELD #ifdef HAVE_PTHREAD_SCHED_YIELD #define pthread_yield() sched_yield() #define HAVE_PTHREAD_YIELD #endif #endif #ifndef HAVE_PTHREAD_DELAY #ifdef HAVE_PTHREAD_DELAY_NP #define HAVE_PTHREAD_DELAY #define pthread_delay(x) pthread_delay_np(x) #endif #if defined(HAVE_PTHREAD_NANOSLEEP) #ifndef HAVE_PTHREAD_DELAY #define HAVE_PTHREAD_DELAY #ifdef __FreeBSD__ #ifdef __cplusplus extern "C" int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); #endif #endif #define pthread_delay(x) nanosleep(x, NULL) #endif #endif #endif #ifdef HAVE_PTHREAD_ATTR_SETSTACK #ifndef PTHREAD_STACK_MIN #define PTHREAD_STACK_MIN 32768 #endif #endif #ifndef HAVE_PTHREAD_CANCEL #ifdef SIGCANCEL #define CCXX_SIG_THREAD_CANCEL SIGCANCEL #else #define CCXX_SIG_THREAD_CANCEL SIGQUIT #endif #define pthread_cancel(x) pthread_kill(x, CCXX_SIG_THREAD_CANCEL) #define pthread_setcanceltype(x, y) #define pthread_setcancelstate(x, y) #endif #ifndef HAVE_PTHREAD_SETCANCELTYPE #ifdef HAVE_PTHREAD_SETCANCEL enum { PTHREAD_CANCEL_ASYNCHRONOUS = CANCEL_ON, PTHREAD_CANCEL_DEFERRED = CANCEL_OFF}; enum { PTHREAD_CANCEL_ENABLE = CANCEL_ON, PTHREAD_CANCEL_DISABLE = CANCEL_OFF}; #define pthread_setcancelstate(x, y) \ (y == NULL) ? pthread_setcancel(x) : *y = pthread_setcancel #define pthread_setcanceltype(x, y) \ (y == NULL) ? pthread_setasynccancel(x) | *y = pthread_setasynccancel(x) #else #define pthread_setcanceltype(x, y) #define pthread_setcancelstate(x, y) #endif #endif #ifdef _AIX #ifdef HAVE_PTHREAD_SUSPEND #undef HAVE_PTHREAD_SUSPEND #endif #endif #endif libvmime-0.9.1/AUTHORS0000644000175000017500000000233511457325212014704 0ustar mnordstrmnordstr VMIME AUTHOR ============ Vincent Richard Project owner and creator. VMime was created in 1998, and publicly released under the GNU GPL license in 2003. VMIME CONTRIBUTORS ================== VMime is Open Source software, you are free and welcome to contribute! If you have a patch and you want it to be included into official VMime release, you have to release your patch into the public domain or assign the copyright to "VMime authors". You will then be credited in this AUTHORS file. - Stefan Uhrig - Rafael Fernandez - Xin Li - Benjamin Biron - Bertrand Benoit - Tim Teulings - Georg Sauthoff - Pierre Thierry (patches for STL algorithms) - Zarafa - Bartek Szurgot - Achim Brandt Please apologize if I have forgotten someone here. ;) Send me an email to if you want your name to be listed. See SVN Changelog for full list. libvmime-0.9.1/vmime.doxygen0000644000175000017500000012017211250723264016350 0ustar mnordstrmnordstr# # Doxygen settings for VMime # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") # #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = VMime # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ./doc/ # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en # (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, # Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian. OUTPUT_LANGUAGE = English # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these class will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = YES # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. #HIDE_IN_BODY_DOCS = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = NO # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited # members of a class in the documentation of that class as if those members were # ordinary class members. Constructors, destructors and assignment operators of # the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. It is allowed to use relative paths in the argument list. STRIP_FROM_PATH = # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower case letters. If set to YES upper case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # users are adviced to set this option to NO. CASE_SENSE_NAMES = YES # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = YES # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explict @brief command for a brief description. JAVADOC_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # reimplements. INHERIT_DOCS = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = NO # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consist of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. # For instance some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = YES # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. #WARN_IF_DOC_ERROR = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ./src/ ./vmime/ # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp # *.h++ *.idl *.odl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories # that are symbolic links (a Unix filesystem feature) are excluded from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = */config.hpp */IMAPTag* */IMAPParser* */IMAPUtils* */IMAPConnection* */md5* */smartPtr* */authHelper* */maildirUtils* # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. INPUT_FILTER = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. SOURCE_BROWSER = NO # YES --> sources visibles # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 1 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output dir. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non empty doxygen will try to run # the html help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the Html help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, # or Internet explorer 4.0+). Note that for large projects the tree generation # can take a very long time. In such cases it is better to disable this feature. # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 300 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimised for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assigments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_XML = NO # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. #GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. #PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. #PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. #PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. PREDEFINED = VMIME_BUILDING_DOC VMIME_HAVE_SASL_SUPPORT VMIME_HAVE_TLS_SUPPORT # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse the # parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tagfiles. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or # super classes. Setting the tag to NO turns the diagrams off. Note that this # option is superceded by the HAVE_DOT option below. This is only a fallback. It is # recommended to install and use dot, since it yield more powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermedate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO # The CGI_NAME tag should be the name of the CGI script that # starts the search engine (doxysearch) with the correct parameters. # A script with this name will be generated by doxygen. #CGI_NAME = search.cgi # The CGI_URL tag should be the absolute URL to the directory where the # cgi binaries are located. See the documentation of your http daemon for # details. #CGI_URL = # The DOC_URL tag should be the absolute URL to the directory where the # documentation is located. If left blank the absolute path to the # documentation, with file:// prepended to it, will be used. #DOC_URL = # The DOC_ABSPATH tag should be the absolute path to the directory where the # documentation is located. If left blank the directory on the local machine # will be used. #DOC_ABSPATH = # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. #BIN_ABSPATH = /usr/local/bin/ # The EXT_DOC_PATHS tag can be used to specify one or more paths to # documentation generated for other projects. This allows doxysearch to search # the documentation for these projects as well. #EXT_DOC_PATHS = libvmime-0.9.1/INSTALL0000644000175000017500000003633211470477543014703 0ustar mnordstrmnordstrInstallation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. libvmime-0.9.1/README.msvc0000644000175000017500000000550611250723264015466 0ustar mnordstrmnordstr========================================================== Using VMime library with Microsoft Visual Studio .NET 2003 ========================================================== I. Prerequisites ================ To use VMime with Microsoft Visual Studio .NET 2003 you need * Microsoft Visual Studio .NET 2003 * The GNU libiconv library * The GNU gettext package (libiconv depends on it) * SCons if you'd like to compile from the CVS repository 1. Retrieve GNU libiconv and GNU gettext ------------------------------------------ Download libiconv (http://www.gnu.org/software/libiconv/) and gettext (http://www.gnu.org/software/gettext/). Currently libiconv-1.9.1 and gettext-0.13.1 works fine with Visual Studio .NET 2003 and VMime. However I was experiencing problems trying to compile gettext-0.14.3. 2. Compile GNU libiconv and GNU gettext ----------------------------------------- You have to compile libiconv first, then compile gettext and afterwards you have to compile libiconv again. Follow the instructions in the files README.woe32 coming with both packages. Before compiling you have to decide if you want to use the library in single-threaded projects only or not. If in doubt choose the multi-threaded version. According to your choice you have to specify the right MFLAGS (explained in the README.woe32 of both packages). 3. Install the libraries --------------------------- Once the libraries are compiled copy the files from C:\usr\include to your Microsoft Visual Studio .NET 2003 include directory (...\Vc7\include). Copy the files from C:\usr\lib to your library directory (...\Vc7\lib). 4. Retrieve and install SCons ----------------------------- If you'd like to compile from the CVS repository you need SCons to build the MSVC project files. You can download it from http://www.scons.org/. II. Compiling VMime =================== 1. Build the project files -------------------------- If you'd like to compile the code in the CVS repository you need to build the project files first. You do so by changing to your VMime directory and typing scons msvc on the command line. 2. Build VMime -------------- Use the vmime.sln file to build the library. 3. Install VMime ---------------- Copy the compiled library file to your library directory (...\Vc7\lib). Copy the whole vmime directory to your include directory (...\Vc7\include). Don't copy all files in the vmime directory to your include directory but the directory itself, so that all headers are in ...\Vc7\include\vmime. 4. Use VMime ------------ Now you are ready to use VMime (hopefully). Probably you'd like to disable warnings 4101, 4244, 4250, 4267 and 4355. Do so in your project using Project -> vmime Properties -> C/C++ -> Advanced -> Disable specific warnings. libvmime-0.9.1/autotools/0000755000175000017500000000000011607302336015661 5ustar mnordstrmnordstrlibvmime-0.9.1/autotools/ltmain.sh0000755000175000017500000075634111470477542017536 0ustar mnordstrmnordstr# Generated from ltmain.m4sh. # libtool (GNU libtool) 2.2.10 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.2.10 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . PROGRAM=libtool PACKAGE=libtool VERSION=2.2.10 TIMESTAMP="" package_revision=1.3175 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${EGREP="grep -E"} : ${FGREP="grep -F"} : ${GREP="grep"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SED="sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # Generated shell functions inserted here. # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=: for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname${mode+: }$mode: $*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_version # Echo version message to standard output and exit. func_version () { $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $SED -n '/^# Usage:/,/# Report bugs to/ { s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ p }' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { func_error "missing argument for $1." exit_cmd=exit } exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. # $mode is unset nonopt= execute_dlfiles= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 opt_dry_run=false opt_duplicate_deps=false opt_silent=false opt_debug=: # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # Parse options once, thoroughly. This comes as soon as possible in # the script to make things like `libtool --version' happen quickly. { # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Parse non-mode specific arguments: while test "$#" -gt 0; do opt="$1" shift case $opt in --config) func_config ;; --debug) preserve_args="$preserve_args $opt" func_echo "enabling shell trace mode" opt_debug='set -x' $opt_debug ;; -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break execute_dlfiles="$execute_dlfiles $1" shift ;; --dry-run | -n) opt_dry_run=: ;; --features) func_features ;; --finish) mode="finish" ;; --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break case $1 in # Valid mode arguments: clean) ;; compile) ;; execute) ;; finish) ;; install) ;; link) ;; relink) ;; uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac mode="$1" shift ;; --preserve-dup-deps) opt_duplicate_deps=: ;; --quiet|--silent) preserve_args="$preserve_args $opt" opt_silent=: opt_verbose=false ;; --no-quiet|--no-silent) preserve_args="$preserve_args $opt" opt_silent=false ;; --verbose| -v) preserve_args="$preserve_args $opt" opt_silent=false opt_verbose=: ;; --no-verbose) preserve_args="$preserve_args $opt" opt_verbose=false ;; --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break preserve_args="$preserve_args $opt $1" func_enable_tag "$1" # tagname is set here shift ;; # Separate optargs to long options: -dlopen=*|--mode=*|--tag=*) func_opt_split "$opt" set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} shift ;; -\?|-h) func_usage ;; --help) opt_help=: ;; --help-all) opt_help=': help-all' ;; --version) func_version ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) nonopt="$opt" break ;; esac done case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_duplicate_deps ;; esac # Having warned about all mis-specified options, bail out if # anything was wrong. $exit_cmd $EXIT_FAILURE } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } ## ----------- ## ## Main. ## ## ----------- ## $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi test -z "$mode" && func_fatal_error "error: you must specify a MODE." # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$mode' for more information." } # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_ltwrapper_scriptname_result="" if func_ltwrapper_executable_p "$1"; then func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" fi } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_quote_for_eval "$arg" CC_quoted="$CC_quoted $func_quote_for_eval_result" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_quote_for_eval "$arg" CC_quoted="$CC_quoted $func_quote_for_eval_result" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T <?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi removelist="$removelist $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist removelist="$removelist $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir command="$command -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then command="$command -o $obj" fi # Suppress compiler output if we already did a PIC compilation. command="$command$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $execute_dlfiles; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then dir="$dir/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_quote_for_eval "$file" args="$args $func_quote_for_eval_result" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" exit $EXIT_SUCCESS } test "$mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" install_prog="$install_prog$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then files="$files $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" install_prog="$install_prog $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi install_shared_prog="$install_shared_prog $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. staticlibs="$staticlibs $file" ;; *.la) # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" dir="$dir$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_verbose "extracting global C symbols from \`$progfile'" $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" } done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; " case $host in *cygwin* | *mingw* | *cegcc* ) echo >> "$output_objdir/$my_dlsyms" "\ /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */" lt_dlsym_const= ;; *osf5*) echo >> "$output_objdir/$my_dlsyms" "\ /* This system does not cope well with relocations in const data */" lt_dlsym_const= ;; *) lt_dlsym_const=const ;; esac echo >> "$output_objdir/$my_dlsyms" "\ extern $lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; $lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) symtab_cflags="$symtab_cflags $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then win32_nmres=`eval $NM -f posix -A $1 | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_to_host_path arg # # Convert paths to host format when used with build tools. # Intended for use with "native" mingw (where libtool itself # is running under the msys shell), or in the following cross- # build environments: # $build $host # mingw (msys) mingw [e.g. native] # cygwin mingw # *nix + wine mingw # where wine is equipped with the `winepath' executable. # In the native mingw case, the (msys) shell automatically # converts paths for any non-msys applications it launches, # but that facility isn't available from inside the cwrapper. # Similar accommodations are necessary for $host mingw and # $build cygwin. Calling this function does no harm for other # $host/$build combinations not listed above. # # ARG is the path (on $build) that should be converted to # the proper representation for $host. The result is stored # in $func_to_host_path_result. func_to_host_path () { func_to_host_path_result="$1" if test -n "$1"; then case $host in *mingw* ) lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' case $build in *mingw* ) # actually, msys # awkward: cmd appends spaces to result func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` ;; *cygwin* ) func_to_host_path_result=`cygpath -w "$1" | $SED -e "$lt_sed_naive_backslashify"` ;; * ) # Unfortunately, winepath does not exit with a non-zero # error code, so we are forced to check the contents of # stdout. On the other hand, if the command is not # found, the shell will set an exit code of 127 and print # *an error message* to stdout. So we must check for both # error code of zero AND non-empty stdout, which explains # the odd construction: func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" | $SED -e "$lt_sed_naive_backslashify"` else # Allow warning below. func_to_host_path_result= fi ;; esac if test -z "$func_to_host_path_result" ; then func_error "Could not determine host path corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_path_result="$1" fi ;; esac fi } # end: func_to_host_path # func_to_host_pathlist arg # # Convert pathlists to host format when used with build tools. # See func_to_host_path(), above. This function supports the # following $build/$host combinations (but does no harm for # combinations not listed here): # $build $host # mingw (msys) mingw [e.g. native] # cygwin mingw # *nix + wine mingw # # Path separators are also converted from $build format to # $host format. If ARG begins or ends with a path separator # character, it is preserved (but converted to $host format) # on output. # # ARG is a pathlist (on $build) that should be converted to # the proper representation on $host. The result is stored # in $func_to_host_pathlist_result. func_to_host_pathlist () { func_to_host_pathlist_result="$1" if test -n "$1"; then case $host in *mingw* ) lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_pathlist_tmp1=$func_stripname_result case $build in *mingw* ) # Actually, msys. # Awkward: cmd appends spaces to result. func_to_host_pathlist_result=` ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` ;; *cygwin* ) func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" | $SED -e "$lt_sed_naive_backslashify"` ;; * ) # unfortunately, winepath doesn't convert pathlists func_to_host_pathlist_result="" func_to_host_pathlist_oldIFS=$IFS IFS=: for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do IFS=$func_to_host_pathlist_oldIFS if test -n "$func_to_host_pathlist_f" ; then func_to_host_path "$func_to_host_pathlist_f" if test -n "$func_to_host_path_result" ; then if test -z "$func_to_host_pathlist_result" ; then func_to_host_pathlist_result="$func_to_host_path_result" else func_append func_to_host_pathlist_result ";$func_to_host_path_result" fi fi fi done IFS=$func_to_host_pathlist_oldIFS ;; esac if test -z "$func_to_host_pathlist_result"; then func_error "Could not determine the host path(s) corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This may break if $1 contains DOS-style drive # specifications. The fix is not to complicate the expression # below, but for the user to provide a working wine installation # with winepath so that path translation in the cross-to-mingw # case works properly. lt_replace_pathsep_nix_to_dos="s|:|;|g" func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ $SED -e "$lt_replace_pathsep_nix_to_dos"` fi # Now, add the leading and trailing path separators back case "$1" in :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" ;; esac case "$1" in *: ) func_append func_to_host_pathlist_result ";" ;; esac ;; esac fi } # end: func_to_host_pathlist # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) deplibs="$deplibs $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # moreargs="$moreargs $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) weak_libs="$weak_libs $arg" prev= continue ;; xcclinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname '-L' '' "$arg" dir=$func_stripname_result if test -z "$dir"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) dllsearchpath="$dllsearchpath:$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework deplibs="$deplibs System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi deplibs="$deplibs $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot) compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" arg="$arg $func_quote_for_eval_result" compiler_flags="$compiler_flags $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" arg="$arg $wl$func_quote_for_eval_result" compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" linker_flags="$linker_flags $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" compiler_flags="$compiler_flags $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. objs="$objs $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_duplicate_deps ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; esac pre_post_deps="$pre_post_deps $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= case $lib in *.la) func_source "$lib" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) deplibs="$deplibs $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else compiler_flags="$compiler_flags $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" dir=$func_stripname_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. dlprefiles="$dlprefiles $lib $dependency_libs" else newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$newdlprefiles $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) temp_rpath="$temp_rpath$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded notinst_deplibs="$notinst_deplibs $lib" need_relink=no ;; *) if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_dirname "$deplib" "" "." dir="$func_dirname_result" # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then tmp_libs="$tmp_libs $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" objs="$objs$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. verstring="$verstring:${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" libobjs="$libobjs $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi removelist="$removelist $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) dlfiles="$dlfiles $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$deplibs System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then deplibs="$deplibs -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) newdeplibs="$newdeplibs $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do linknames="$linknames $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" delfiles="$delfiles $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" func_len " $cmd" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then func_show_eval "$cmd" 'exit $?' skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) tmp_deplibs="$tmp_deplibs $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $convenience libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do $ECHO "$obj" >> $output done echo ')' >> $output delfiles="$delfiles $output" elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do $ECHO "$obj" >> $output done delfiles="$delfiles $output" output=$firstobj\"$file_list_spec$output\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi delfiles="$delfiles $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $dlprefiles libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" generated="$generated $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) compile_command="$compile_command ${wl}-bind_at_load" finalize_command="$finalize_command ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done compile_deplibs="$new_libs" compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) dllsearchpath="$dllsearchpath:$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then oldobjs="$oldobjs $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $addlibs oldobjs="$oldobjs $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $dlprefiles oldobjs="$oldobjs $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" oldobjs="$oldobjs $gentop/$newobj" ;; *) oldobjs="$oldobjs $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" newdlfiles="$newdlfiles $libdir/$name" ;; *) newdlfiles="$newdlfiles $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" newdlprefiles="$newdlprefiles $libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlfiles="$newdlfiles $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlprefiles="$newdlprefiles $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$mode" = link || test "$mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) RM="$RM $arg"; rmforce=yes ;; -*) RM="$RM $arg" ;; *) files="$files $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= origobjdir="$objdir" for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then objdir="$origobjdir" else objdir="$dir/$origobjdir" fi func_basename "$file" name="$func_basename_result" test "$mode" = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test "$mode" = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" case "$mode" in clean) case " $library_names " in # " " in the beginning catches empty $dlname *" $dlname "*) ;; *) rmfiles="$rmfiles $objdir/$dlname" ;; esac test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then rmfiles="$rmfiles $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then rmfiles="$rmfiles $dir/$non_pic_object" fi fi ;; *) if test "$mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe rmfiles="$rmfiles $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result rmfiles="$rmfiles $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi if test "X$noexename" != "X$name" ; then rmfiles="$rmfiles $objdir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$mode" = uninstall || test "$mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 libvmime-0.9.1/autotools/config.guess0000755000175000017500000012761511470477543020230 0ustar mnordstrmnordstr#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. timestamp='2009-11-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[456]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else echo ${UNAME_MACHINE}-unknown-linux-gnueabi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libvmime-0.9.1/autotools/install-sh0000755000175000017500000003253711470477543017712 0ustar mnordstrmnordstr#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libvmime-0.9.1/autotools/config.sub0000755000175000017500000010316711470477543017667 0ustar mnordstrmnordstr#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. timestamp='2009-11-20' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libvmime-0.9.1/autotools/missing0000755000175000017500000002623311470477543017301 0ustar mnordstrmnordstr#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program 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 General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libvmime-0.9.1/examples/0000755000175000017500000000000011607302336015446 5ustar mnordstrmnordstrlibvmime-0.9.1/examples/README0000644000175000017500000000055211250723264016331 0ustar mnordstrmnordstr========================================= Instructions for compiling VMime examples ========================================= 1) Configure, compile and install vmime library 2) Compile the sample programs with: $ g++ -o exampleX exampleX.cpp `pkg-config libvmime` 3) For a more complete documentation, please visit: http://www.vmime.org/documentation/ libvmime-0.9.1/examples/example1.cpp0000644000175000017500000000531311250723264017671 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // EXAMPLE DESCRIPTION: // ==================== // This sample program demonstrate the use of the messageBuilder component // to build a simple message. // // For more information, please visit: // http://www.vmime.org/ // #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" int main() { std::cout << std::endl; // VMime initialization vmime::platform::setHandler(); try { vmime::messageBuilder mb; // Fill in the basic fields mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; to.appendAddress(vmime::create ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder")); // Message body mb.getTextPart()->setText(vmime::create ( "I'm writing this short text to test message construction " \ "using the vmime::messageBuilder component.")); // Construction vmime::ref msg = mb.construct(); // Raw text generation std::cout << "Generated message:" << std::endl; std::cout << "==================" << std::endl; vmime::utility::outputStreamAdapter out(std::cout); msg->generate(out); } // VMime exception catch (vmime::exception& e) { std::cout << "vmime::exception: " << e.what() << std::endl; throw; } // Standard exception catch (std::exception& e) { std::cout << "std::exception: " << e.what() << std::endl; //throw; } std::cout << std::endl; } libvmime-0.9.1/examples/example2.cpp0000644000175000017500000000634611250723264017701 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // EXAMPLE DESCRIPTION: // ==================== // This sample program demonstrate the use of the messageBuilder component // to build a simple message with an attachment. // // For more information, please visit: // http://www.vmime.org/ // #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" int main() { std::cout << std::endl; // VMime initialization vmime::platform::setHandler(); try { vmime::messageBuilder mb; // Fill in the basic fields mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; to.appendAddress(vmime::create ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder")); // Message body mb.getTextPart()->setText(vmime::create ( "I'm writing this short text to test message construction " \ "with attachment, using the vmime::messageBuilder component.")); // Adding an attachment vmime::ref a = vmime::create ( "./example2.cpp", // full path to file vmime::mediaType("application/octet-stream"), // content type vmime::text("My first attachment") // description ); a->getFileInfo().setFilename("example2.cpp"); a->getFileInfo().setCreationDate(vmime::datetime("30 Apr 2003 14:30:00 +0200")); mb.attach(a); // Construction vmime::ref msg = mb.construct(); // Raw text generation vmime::string dataToSend = msg->generate(); std::cout << "Generated message:" << std::endl; std::cout << "==================" << std::endl; std::cout << std::endl; std::cout << dataToSend << std::endl; } // VMime exception catch (vmime::exception& e) { std::cout << "vmime::exception: " << e.what() << std::endl; throw; } // Standard exception catch (std::exception& e) { std::cout << "std::exception: " << e.what() << std::endl; throw; } std::cout << std::endl; } libvmime-0.9.1/examples/example3.cpp0000644000175000017500000000774611376252111017704 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // EXAMPLE DESCRIPTION: // ==================== // This sample program demonstrate the use of the messageBuilder component // to build a complex message (HTML content, plain text and embedded image). // // For more information, please visit: // http://www.vmime.org/ // #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" int main() { std::cout << std::endl; // VMime initialization vmime::platform::setHandler(); try { vmime::messageBuilder mb; // Fill in the basic fields mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; to.appendAddress(vmime::create ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder")); // Set the content-type to "text/html" mb.constructTextPart(vmime::mediaType (vmime::mediaTypes::TEXT, vmime::mediaTypes::TEXT_HTML)); // Fill in the text part: the message is available in two formats: HTML and plain text. // HTML text part also includes an inline image (embedded into the message). vmime::htmlTextPart& textPart = *mb.getTextPart().dynamicCast (); // -- embed an image (the returned "CID" (content identifier) is used to reference // -- the image into HTML content). vmime::ref fs = vmime::platform::getHandler()->getFileSystemFactory(); vmime::ref imageFile = fs->create(fs->stringToPath("/path/to/image.jpg")); vmime::ref fileReader = imageFile->getFileReader(); vmime::ref imageCts = vmime::create (fileReader->getInputStream(), imageFile->getLength()); const vmime::string cid = textPart.addObject(imageCts, vmime::mediaType(vmime::mediaTypes::IMAGE, vmime::mediaTypes::IMAGE_JPEG)); // -- message text textPart.setText(vmime::create (vmime::string("This is the HTML text.
"))); textPart.setPlainText(vmime::create ("This is the plain text (without HTML formatting).")); // Construction vmime::ref msg = mb.construct(); // Raw text generation vmime::string dataToSend = msg->generate(); std::cout << "Generated message:" << std::endl; std::cout << "==================" << std::endl; std::cout << std::endl; std::cout << dataToSend << std::endl; } // VMime exception catch (vmime::exception& e) { std::cout << "vmime::exception: " << e.what() << std::endl; throw; } // Standard exception catch (std::exception& e) { std::cout << "std::exception: " << e.what() << std::endl; throw; } std::cout << std::endl; } libvmime-0.9.1/examples/example4.cpp0000644000175000017500000000543611250723264017702 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // EXAMPLE DESCRIPTION: // ==================== // This sample program demonstrate the use of the messageParser component // to enumerate the text parts in a message. // // For more information, please visit: // http://www.vmime.org/ // #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" int main() { std::cout << std::endl; // VMime initialization vmime::platform::setHandler(); try { vmime::messageParser mp("<...MIME message content...>"); // Enumerate text parts for (int i = 0 ; i < mp.getTextPartCount() ; ++i) { const vmime::textPart& part = *mp.getTextPartAt(i); // Output content-type of the part std::cout << part.getType().generate() << std::endl; // text/html if (part.getType().getSubType() == vmime::mediaTypes::TEXT_HTML) { const vmime::htmlTextPart& hp = dynamic_cast(part); // HTML text is in "hp.getText()" // Corresponding plain text is in "hp.getPlainText()" // Enumerate embedded objects (eg. images) for (int j = 0 ; j < hp.getObjectCount() ; ++j) { const vmime::htmlTextPart::embeddedObject& obj = *hp.getObjectAt(j); // Identifier (content-id or content-location) is in "obj.getId()" // Object data is in "obj.getData()" } } // text/plain else { const vmime::textPart& tp = dynamic_cast(part); // Text is in "tp.getText()" } } } // VMime exception catch (vmime::exception& e) { std::cout << "vmime::exception: " << e.what() << std::endl; throw; } // Standard exception catch (std::exception& e) { std::cout << "std::exception: " << e.what() << std::endl; throw; } std::cout << std::endl; } libvmime-0.9.1/examples/example5.cpp0000644000175000017500000000423411250723264017676 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // EXAMPLE DESCRIPTION: // ==================== // This sample program demonstrate the use of the messageParser component // to enumerate the attachments in a message. // // For more information, please visit: // http://www.vmime.org/ // #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" int main() { std::cout << std::endl; // VMime initialization vmime::platform::setHandler(); try { vmime::messageParser mp("<...MIME message content...>"); // Enumerate attachments for (int i = 0 ; i < mp.getAttachmentCount() ; ++i) { const vmime::attachment& att = *mp.getAttachmentAt(i); // Media type (content type) is in "att.getType()" // Name is in "att.getName()" // Description is in "att.getDescription()" // Data is in "att.getData()" } } // VMime exception catch (vmime::exception& e) { std::cout << "vmime::exception: " << e.what() << std::endl; throw; } // Standard exception catch (std::exception& e) { std::cout << "std::exception: " << e.what() << std::endl; throw; } std::cout << std::endl; } libvmime-0.9.1/examples/example6.cpp0000644000175000017500000005005311250723264017677 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // #include #include #include #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" // Global session object static vmime::ref g_session = vmime::create (); #if VMIME_HAVE_SASL_SUPPORT // SASL authentication handler class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthenticator { const std::vector > getAcceptableMechanisms (const std::vector >& available, vmime::ref suggested) const { std::cout << std::endl << "Available SASL mechanisms:" << std::endl; for (unsigned int i = 0 ; i < available.size() ; ++i) { std::cout << " " << available[i]->getName(); if (suggested && available[i]->getName() == suggested->getName()) std::cout << "(suggested)"; } std::cout << std::endl << std::endl; return defaultSASLAuthenticator::getAcceptableMechanisms(available, suggested); } void setSASLMechanism(vmime::ref mech) { std::cout << "Trying '" << mech->getName() << "' authentication mechanism" << std::endl; defaultSASLAuthenticator::setSASLMechanism(mech); } const vmime::string getUsername() const { if (m_username.empty()) m_username = getUserInput("Username"); return m_username; } const vmime::string getPassword() const { if (m_password.empty()) m_password = getUserInput("Password"); return m_password; } static const vmime::string getUserInput(const std::string& prompt) { std::cout << prompt << ": "; std::cout.flush(); vmime::string res; std::getline(std::cin, res); return res; } private: mutable vmime::string m_username; mutable vmime::string m_password; }; #else // !VMIME_HAVE_SASL_SUPPORT // Simple authentication handler class interactiveAuthenticator : public vmime::security::defaultAuthenticator { const vmime::string getUsername() const { if (m_username.empty()) m_username = getUserInput("Username"); return m_username; } const vmime::string getPassword() const { if (m_password.empty()) m_password = getUserInput("Password"); return m_password; } static const vmime::string getUserInput(const std::string& prompt) { std::cout << prompt << ": "; std::cout.flush(); vmime::string res; std::getline(std::cin, res); return res; } private: mutable vmime::string m_username; mutable vmime::string m_password; }; #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT // Certificate verifier (TLS/SSL) class interactiveCertificateVerifier : public vmime::security::cert::defaultCertificateVerifier { public: void verify(vmime::ref chain) { try { setX509TrustedCerts(m_trustedCerts); defaultCertificateVerifier::verify(chain); } catch (vmime::exceptions::certificate_verification_exception&) { // Obtain subject's certificate vmime::ref cert = chain->getAt(0); std::cout << std::endl; std::cout << "Server sent a '" << cert->getType() << "'" << " certificate." << std::endl; std::cout << "Do you want to accept this certificate? (Y/n) "; std::cout.flush(); std::string answer; std::getline(std::cin, answer); if (answer.length() != 0 && (answer[0] == 'Y' || answer[0] == 'y')) { // Accept it, and remember user's choice for later if (cert->getType() == "X.509") { m_trustedCerts.push_back(cert.dynamicCast ()); } return; } throw vmime::exceptions::certificate_verification_exception ("User did not accept the certificate."); } } private: static std::vector > m_trustedCerts; }; std::vector > interactiveCertificateVerifier::m_trustedCerts; #endif // VMIME_HAVE_TLS_SUPPORT /** Returns the messaging protocols supported by VMime. * * @param type service type (vmime::net::service::TYPE_STORE or * vmime::net::service::TYPE_TRANSPORT) */ static const std::string findAvailableProtocols(const vmime::net::service::Type type) { vmime::net::serviceFactory* sf = vmime::net::serviceFactory::getInstance(); std::ostringstream res; int count = 0; for (int i = 0 ; i < sf->getServiceCount() ; ++i) { const vmime::net::serviceFactory::registeredService& serv = *sf->getServiceAt(i); if (serv.getType() == type) { if (count != 0) res << ", "; res << serv.getName(); ++count; } } return res.str(); } // Exception helper static std::ostream& operator<<(std::ostream& os, const vmime::exception& e) { os << "* vmime::exceptions::" << e.name() << std::endl; os << " what = " << e.what() << std::endl; // More information for special exceptions if (dynamic_cast (&e)) { const vmime::exceptions::command_error& cee = dynamic_cast (e); os << " command = " << cee.command() << std::endl; os << " response = " << cee.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::invalid_response& ir = dynamic_cast (e); os << " response = " << ir.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::connection_greeting_error& cgee = dynamic_cast (e); os << " response = " << cgee.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::authentication_error& aee = dynamic_cast (e); os << " response = " << aee.response() << std::endl; } if (dynamic_cast (&e)) { const vmime::exceptions::filesystem_exception& fse = dynamic_cast (e); os << " path = " << vmime::platform::getHandler()-> getFileSystemFactory()->pathToString(fse.path()) << std::endl; } if (e.other() != NULL) os << *e.other(); return os; } /** Print the MIME structure of a message on the standard output. * * @param s structure object * @param level current depth */ static void printStructure(vmime::ref s, const int level = 0) { for (int i = 0 ; i < s->getPartCount() ; ++i) { vmime::ref part = s->getPartAt(i); for (int j = 0 ; j < level * 2 ; ++j) std::cout << " "; std::cout << (part->getNumber() + 1) << ". " << part->getType().generate() << " [" << part->getSize() << " byte(s)]" << std::endl; printStructure(part->getStructure(), level + 1); } } static const vmime::string getFolderPathString(vmime::ref f) { const vmime::string n = f->getName().getBuffer(); if (n.empty()) // root folder { return "/"; } else { vmime::ref p = f->getParent(); return getFolderPathString(p) + n + "/"; } } /** Print folders and sub-folders on the standard output. * * @param folder current folder */ static void printFolders(vmime::ref folder, const int level = 0) { for (int j = 0 ; j < level * 2 ; ++j) std::cout << " "; std::cout << getFolderPathString(folder) << std::endl; std::vector > subFolders = folder->getFolders(false); for (unsigned int i = 0 ; i < subFolders.size() ; ++i) printFolders(subFolders[i], level + 1); } /** Print a menu on the standard output. * * @param choices menu choices */ static unsigned int printMenu(const std::vector & choices) { std::cout << std::endl; for (unsigned int i = 0 ; i < choices.size() ; ++i) std::cout << " " << (i + 1) << ". " << choices[i] << std::endl; std::cout << std::endl; std::cout << " Your choice? [1-" << choices.size() << "] "; std::cout.flush(); std::string line; std::getline(std::cin, line); std::istringstream iss(line); unsigned int choice = 0; iss >> choice; std::cout << std::endl; if (choice < 1 || choice > choices.size()) return 0; else return choice; } /** Send a message interactively. */ static void sendMessage() { try { // Request user to enter an URL std::cout << "Enter an URL to connect to transport service." << std::endl; std::cout << "Available protocols: " << findAvailableProtocols(vmime::net::service::TYPE_TRANSPORT) << std::endl; std::cout << "(eg. smtp://myserver.com, sendmail://localhost)" << std::endl; std::cout << "> "; std::cout.flush(); vmime::string urlString; std::getline(std::cin, urlString); vmime::utility::url url(urlString); vmime::ref tr = g_session->getTransport(url, vmime::create ()); #if VMIME_HAVE_TLS_SUPPORT // Enable TLS support if available tr->setProperty("connection.tls", true); // Set the object responsible for verifying certificates, in the // case a secured connection is used (TLS/SSL) tr->setCertificateVerifier (vmime::create ()); #endif // VMIME_HAVE_TLS_SUPPORT // You can also set some properties (see example7 to know the properties // available for each service). For example, for SMTP: // tr->setProperty("options.need-authentication", true); // Information about the mail std::cout << "Enter email of the expeditor (eg. me@somewhere.com): "; std::cout.flush(); vmime::string fromString; std::getline(std::cin, fromString); vmime::mailbox from(fromString); vmime::mailboxList to; for (bool cont = true ; cont ; ) { std::cout << "Enter email of the recipient (empty to stop): "; std::cout.flush(); vmime::string toString; std::getline(std::cin, toString); cont = (toString.size() != 0); if (cont) to.appendMailbox(vmime::create (toString)); } std::cout << "Enter message data, including headers (end with '.' on a single line):" << std::endl; std::ostringstream data; for (bool cont = true ; cont ; ) { std::string line; std::getline(std::cin, line); if (line == ".") cont = false; else data << line << "\r\n"; } // Connect to server tr->connect(); // Send the message vmime::string msgData = data.str(); vmime::utility::inputStreamStringAdapter vis(msgData); tr->send(from, to, vis, msgData.length()); // Note: you could also write this: // vmime::message msg; // ... // tr->send(&msg); tr->disconnect(); } catch (vmime::exception& e) { std::cerr << std::endl; std::cerr << e << std::endl; throw; } catch (std::exception& e) { std::cerr << std::endl; std::cerr << "std::exception: " << e.what() << std::endl; throw; } } /** Connect to a message store interactively. */ static void connectStore() { try { // Request user to enter an URL std::cout << "Enter an URL to connect to store service." << std::endl; std::cout << "Available protocols: " << findAvailableProtocols(vmime::net::service::TYPE_STORE) << std::endl; std::cout << "(eg. pop3://user:pass@myserver.com, imap://myserver.com:123)" << std::endl; std::cout << "> "; std::cout.flush(); vmime::string urlString; std::getline(std::cin, urlString); vmime::utility::url url(urlString); // If no authenticator is given in argument to getStore(), a default one // is used. Its behaviour is to get the user credentials from the // session properties "auth.username" and "auth.password". vmime::ref st; if (url.getUsername().empty() || url.getPassword().empty()) st = g_session->getStore(url, vmime::create ()); else st = g_session->getStore(url); #if VMIME_HAVE_TLS_SUPPORT // Enable TLS support if available st->setProperty("connection.tls", true); // Set the object responsible for verifying certificates, in the // case a secured connection is used (TLS/SSL) st->setCertificateVerifier (vmime::create ()); #endif // VMIME_HAVE_TLS_SUPPORT // Connect to the mail store st->connect(); // Display some information about the connection vmime::ref ci = st->getConnectionInfos(); std::cout << std::endl; std::cout << "Connected to '" << ci->getHost() << "' (port " << ci->getPort() << ")" << std::endl; std::cout << "Connection is " << (st->isSecuredConnection() ? "" : "NOT ") << "secured." << std::endl; // Open the default folder in this store vmime::ref f = st->getDefaultFolder(); // vmime::ref f = st->getFolder(vmime::utility::path("a")); f->open(vmime::net::folder::MODE_READ_WRITE); int count = f->getMessageCount(); std::cout << std::endl; std::cout << count << " message(s) in your inbox" << std::endl; for (bool cont = true ; cont ; ) { typedef std::map > MessageList; MessageList msgList; try { std::vector choices; choices.push_back("Show message flags"); choices.push_back("Show message structure"); choices.push_back("Show message header"); choices.push_back("Show message envelope"); choices.push_back("Extract whole message"); choices.push_back("List folders"); choices.push_back("Change folder"); choices.push_back("Return to main menu"); const int choice = printMenu(choices); // Request message number vmime::ref msg; if (choice != 6 && choice != 7 && choice != 8) { std::cout << "Enter message number: "; std::cout.flush(); std::string line; std::getline(std::cin, line); std::istringstream iss(line); int num = 0; iss >> num; if (num < 1 || num > count) { std::cerr << "Invalid message number." << std::endl; continue; } MessageList::iterator it = msgList.find(num); if (it != msgList.end()) { msg = (*it).second; } else { msg = f->getMessage(num); msgList.insert(MessageList::value_type(num, msg)); } std::cout << std::endl; } switch (choice) { // Show message flags case 1: f->fetchMessage(msg, vmime::net::folder::FETCH_FLAGS); if (msg->getFlags() & vmime::net::message::FLAG_SEEN) std::cout << "FLAG_SEEN" << std::endl; if (msg->getFlags() & vmime::net::message::FLAG_RECENT) std::cout << "FLAG_RECENT" << std::endl; if (msg->getFlags() & vmime::net::message::FLAG_REPLIED) std::cout << "FLAG_REPLIED" << std::endl; if (msg->getFlags() & vmime::net::message::FLAG_DELETED) std::cout << "FLAG_DELETED" << std::endl; if (msg->getFlags() & vmime::net::message::FLAG_MARKED) std::cout << "FLAG_MARKED" << std::endl; if (msg->getFlags() & vmime::net::message::FLAG_PASSED) std::cout << "FLAG_PASSED" << std::endl; break; // Show message structure case 2: f->fetchMessage(msg, vmime::net::folder::FETCH_STRUCTURE); printStructure(msg->getStructure()); break; // Show message header case 3: f->fetchMessage(msg, vmime::net::folder::FETCH_FULL_HEADER); std::cout << msg->getHeader()->generate() << std::endl; break; // Show message envelope case 4: f->fetchMessage(msg, vmime::net::folder::FETCH_ENVELOPE); #define ENV_HELPER(x) \ try { std::cout << msg->getHeader()->x()->generate() << std::endl; } \ catch (vmime::exception) { /* In case the header field does not exist. */ } ENV_HELPER(From) ENV_HELPER(To) ENV_HELPER(Date) ENV_HELPER(Subject) #undef ENV_HELPER break; // Extract whole message case 5: { vmime::utility::outputStreamAdapter out(std::cout); msg->extract(out); break; } // List folders case 6: { vmime::ref root = st->getRootFolder(); printFolders(root); break; } // Change folder case 7: { std::cout << "Enter folder path (eg. /root/subfolder):" << std::endl; std::cout.flush(); std::string path; std::getline(std::cin, path); vmime::ref newFolder = st->getRootFolder(); for (std::string::size_type s = 0, p = 0 ; ; s = p + 1) { p = path.find_first_of('/', s); const std::string x = (p == std::string::npos) ? std::string(path.begin() + s, path.end()) : std::string(path.begin() + s, path.begin() + p); if (!x.empty()) newFolder = newFolder->getFolder(x); if (p == std::string::npos) break; } newFolder->open(vmime::net::folder::MODE_READ_WRITE); count = newFolder->getMessageCount(); std::cout << std::endl; std::cout << count << " message(s) in this folder" << std::endl; f->close(true); // 'true' to expunge deleted messages f = newFolder; break; } // Main menu case 8: f->close(true); // 'true' to expunge deleted messages cont = false; break; } /* // Append message std::istringstream iss( "From: me@localhost\r\n" "To: you@localhost\r\n" "Subject: Message Text\r\n" "\r\n" "This is a test message...\r\n" "Bye bye!\r\n" ); f->addMessage(iss, iss.str().size()); // Folder renaming { vmime::ref f = st->getFolder(vmime::net::folder::path("c")); f->rename(vmime::net::folder::path("c2")); vmime::ref g = st->getFolder(vmime::net::folder::path("c2")); g->rename(vmime::net::folder::path("c")); } // Message copy: copy all messages from 'f' to 'g' { vmime::ref g = st->getFolder(vmime::net::folder::path("TEMP")); if (!g->exists()) g->create(vmime::net::folder::TYPE_CONTAINS_MESSAGES); f->copyMessages(g->getFullPath()); } */ } catch (vmime::exception& e) { std::cerr << std::endl; std::cerr << e << std::endl; } catch (std::exception& e) { std::cerr << std::endl; std::cerr << "std::exception: " << e.what() << std::endl; } } } catch (vmime::exception& e) { std::cerr << std::endl; std::cerr << e << std::endl; throw; } catch (std::exception& e) { std::cerr << std::endl; std::cerr << "std::exception: " << e.what() << std::endl; throw; } } /* Show the main menu. * * @return true to quit the program, false to continue */ static bool menu() { std::vector items; items.push_back("Connect to a message store"); items.push_back("Send a message"); items.push_back("Quit"); switch (printMenu(items)) { // Connect to store case 1: connectStore(); return false; // Send a message case 2: sendMessage(); return false; // Quit case 3: return true; // Other choice default: return false; } } int main() { // VMime initialization vmime::platform::setHandler(); for (bool quit = false ; !quit ; ) { // Loop on main menu quit = menu(); } return 0; } libvmime-0.9.1/examples/example7.cpp0000644000175000017500000000721511250723264017702 0ustar mnordstrmnordstr// // VMime library (http://www.vmime.org) // Copyright (C) 2002-2009 Vincent Richard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Linking this library statically or dynamically with other modules is making // a combined work based on this library. Thus, the terms and conditions of // the GNU General Public License cover the whole combination. // // // EXAMPLE DESCRIPTION: // ==================== // This sample program demonstrates how to enumerate encoders and // messaging services in VMime. // // For more information, please visit: // http://www.vmime.org/ // #include #include "vmime/vmime.hpp" #include "vmime/platforms/posix/posixHandler.hpp" int main() { // VMime initialization vmime::platform::setHandler(); // Enumerate encoders vmime::encoderFactory* ef = vmime::encoderFactory::getInstance(); std::cout << "Available encoders:" << std::endl; for (int i = 0 ; i < ef->getEncoderCount() ; ++i) { vmime::ref enc = ef->getEncoderAt(i); std::cout << " * " << enc->getName() << std::endl; vmime::ref e = enc->create(); std::vector props = e->getAvailableProperties(); for (std::vector ::const_iterator it = props.begin() ; it != props.end() ; ++it) std::cout << " - " << *it << std::endl; } std::cout << std::endl; // Enumerate messaging services and their properties vmime::net::serviceFactory* sf = vmime::net::serviceFactory::getInstance(); std::cout << "Available messaging services:" << std::endl; for (int i = 0 ; i < sf->getServiceCount() ; ++i) { const vmime::net::serviceFactory::registeredService& serv = *sf->getServiceAt(i); std::cout << " * " << serv.getName() << std::endl; std::vector props = serv.getInfos().getAvailableProperties(); for (std::vector ::const_iterator it = props.begin() ; it != props.end() ; ++it) { const vmime::net::serviceInfos::property& p = *it; const vmime::string name = serv.getInfos().getPropertyPrefix() + p.getName(); vmime::string type; switch (p.getType()) { case vmime::net::serviceInfos::property::TYPE_INTEGER: type = "TYPE_INTEGER"; break; case vmime::net::serviceInfos::property::TYPE_STRING: type = "TYPE_STRING"; break; case vmime::net::serviceInfos::property::TYPE_BOOL: type = "TYPE_BOOL"; break; default: type = "(unknown)"; break; } vmime::string flags; if (p.getFlags() & vmime::net::serviceInfos::property::FLAG_REQUIRED) flags += " FLAG_REQUIRED"; if (p.getFlags() & vmime::net::serviceInfos::property::FLAG_HIDDEN) flags += " FLAG_HIDDEN"; std::cout << " - " << serv.getInfos().getPropertyPrefix() + p.getName(); std::cout << " (type=" << type << ", flags=" << flags; std::cout << ", defaultValue=" << p.getDefaultValue() << ")" << std::endl; } } std::cout << std::endl; } libvmime-0.9.1/ChangeLog0000644000175000017500000011010311470477266015413 0ustar mnordstrmnordstr VERSION 0.9.1 ============= 2010-05-18 Vincent Richard * net/*: added helper function vmime::net::message::getParsedMessage() to construct a RFC-822 parsed message from a net message. 2009-09-06 Vincent Richard * Relicensed VMime under the GNU GPL license version 3. Dual licensing is now available. More info here: http://www.vmime.org/pages/Licensing 2008-10-19 Vincent Richard * Started version 0.9.1. VERSION 0.9.0 ============= 2008-01-28 Vincent Richard * fileAttachment: fixed constructor ambiguity due to implicit conversions. Removed default values and reordered parameters (API breaking change). Many thanks to Philipp Frenkel. More information here: http://sourceforge.net/forum/message.php?msg_id=4739926 2007-11-20 Vincent Richard * text, word: fixed incorrect white-space between words. 2007-07-09 Vincent Richard * IMAPUtils.cpp: fixed bug in modified UTF-7 encoding (IMAP). 2007-05-22 Vincent Richard * Implemented thread-safe reference counting for smart pointers, whenever possible (GCC built-in functions / pthread / Win32). 2007-03-28 Vincent Richard * SMTPTransport.cpp: better parsing of ESMTP extensions. 2007-03-02 Vincent Richard * Maildir: added support for "Courier" Maildir. 2006-12-20 Vincent Richard * Started version 0.8.2. VERSION 0.8.1 ============= 2006-11-08 Vincent Richard * Imbue classic "C" locale for the output of message parts and protocol commands (thanks to Mörtsell Anders). 2006-10-11 Vincent Richard * Renamed 'vmime::platformDependant' to 'vmime::platform'. The old name has been kept for compatibility with previous versions. 2006-10-02 Vincent Richard * SMTPTransport.cpp: reissue EHLO command after a successful STARTTLS negociation. * word, wordEncoder: fixed bug #1096610 which caused encoding of a non-integral number of characters (and then, generation of incorrectly-formed words) with multi-bytes charsets. 2006-07-13 Vincent Richard * Fixed bugs in MHTML code: 'CID' prefix should not be case-sensitive; fixed detection of parts identified by a 'Content-Location'. 2006-04-23 Vincent Richard * Added vmime::net::folder::destroy() to delete folders on IMAP and maildir stores. 2006-04-18 Vincent Richard * Renamed 'byte' to 'byte_t' to fix compilation problems on Fedora core 5 (thanks to Rafael Fernandez). 2006-02-20 Vincent Richard * net/imap/IMAPParser.hpp: added a "relaxed" mode to allow 8-bit characters where not allowed by the standard (thanks to Tim Teulings for having found the bug). 2006-01-29 Vincent Richard * Added service::isSecuredConnection() and service::getConnectionInfos() to retrieve information about the connection. 2006-01-16 Vincent Richard * Added support for attachments of type "message/rfc822". 2006-01-15 Vincent Richard * IMAP: implemented multi-fetching. Now using "FETCH x:y" instead of sending (y-x+1) "FETCH" requests. 2005-12-26 Vincent Richard * posixSocket.cpp: use getaddrinfo() if available. This should bring thread-safe DNS resolution and IPv6 support. 2005-12-18 Vincent Richard * IMAPParser.hpp: compatibility bugs + enhanced debugging trace. 2005-12-04 Vincent Richard * exception.{hpp|cpp}: fixed segfault in destructor when destroying an exception chain with more than 2 elements (thanks to Bertrand Benoit). * posixChildProcess.cpp: fixed a bug in argument vector; last argument was not NULL (thanks to Bertrand Benoit). 2005-11-27 Vincent Richard * maildirUtils.cpp: fixed problem with ':' in filename on Windows platform (thanks to Benjamin Biron). * random.cpp: fixed buffer overrun in random::getString (thanks to Benjamin Biron). 2005-11-07 Vincent Richard * SMTPTransport.cpp: fixed bug in disconnect() when authentication is not needed (thanks to Benjamin Biron). * dateTime.cpp: gmtime() and localtime() are reentrant when using MS C runtime library (MinGW/MSVC). 2005-11-06 Vincent Richard * Started version 0.8.1. VERSION 0.8.0 ============= 2005-11-06 Vincent Richard * First version of the VMime Book. 2005-11-05 Vincent Richard * Refactored header field values and parameters. 2005-10-19 Vincent Richard * charsetConverter.{hpp|cpp}: new object 'charsetConverter' for converting between charsets (code moved from static functions in 'charset' class). * Added 'charsetFilteredOutputStream': provide charset conversion while writing to an output stream. 2005-10-16 Vincent Richard * SConstruct: fixed compilation problems on FreeBSD (thanks to Xin LI). 2005-10-13 Vincent Richard * attachmentHelper.{hpp|cpp}: the attachmentHelper allows listing all attachments in a message, as well as adding new attachments. 2005-10-06 Vincent Richard * utility/progressionListener.{hpp|cpp}: renamed 'progressionListener' to 'progressListener'. 2005-10-04 Vincent Richard * net/service: removed "server.socket-factory" property; added the service::setSocketFactory() function instead. Removed "name" parameter from platformDependant::getSocketFactory() function. * net/service: removed "timeout.factory" property; added the function service::setTimeoutHandlerFactory() instead. Removed the function platformDependant::getTimeoutHandlerFactory(). 2005-10-03 Vincent Richard * Added TLS/SSL support, using GNU TLS library. 2005-09-17 Vincent Richard * Added SASL support, based on GNU SASL library. Slightly modified auhenticator object; see 'example6' which has been updated. 2005-09-06 Vincent Richard * Created 'vmime::security' and 'vmime::security::digest' namespaces. MD5 has been moved here. Added SHA-1 hash algorithm. 2005-09-03 Vincent Richard * encoder*, *contentHandler: added progression notifications. 2005-08-25 Vincent Richard * Tests: moved to CppUnit for unit tests framework. 2005-08-23 Vincent Richard * All sources: renamed 'vmime::messaging' to 'vmime::net'. An alias has been kept for compatibility with previous versions (its use should be considered as deprecated). 2005-08-19 Vincent Richard * exception.hpp: vmime::exception now inherits from std::exception. 2005-07-25 Vincent Richard * Messaging folder: added a FETCH_IMPORTANCE flag to fetch the fields used with 'misc::importanceHelper'. 2005-07-23 Vincent Richard * POP3, IMAP, maildir: fixed getMessages() when default arguments are given: no message were returned, instead of the real message count. 2005-07-15 Vincent Richard * *attachment, messageParser: added a getName() parameter to retrieve the attachment filename either from the "filename" parameter of the "Content-Disposition" field, or from the "name" parameter of the "Content-Type" field (if available). 2005-07-13 Vincent Richard * All files: added reference counting and smart pointers to simplify the use of VMime objects. Please see README.refcounting for more information. 2005-07-06 Vincent Richard * *contentHandler.{hpp|cpp}: added extractRaw() method to allow extracting data without performing any decoding. 2005-06-22 Vincent Richard * Started version 0.7.2. VERSION 0.7.1 ============= 2005-06-21 Vincent Richard * Fixed compilation errors with g++ 4.0. * defaultParameter.cpp: fixed a bug in RFC-2231 implementation. 2005-06-13 Vincent Richard * word.cpp: fixed a bug in parsing, when the first character of word data was encoded in QP (thanks to Wolf Jiang). 2005-06-03 Vincent Richard * parameterizedHeaderField.{hpp|cpp}: fixed a memory leak in the destructor (thanks to Rafael Fernandez). 2005-05-27 Vincent Richard * messaging/*/*Message.{hpp|cpp}: added a 'peek' parameter to extract message contents without marking the message as seen. 2005-05-19 Vincent Richard * messaging/imap/IMAPFolder.cpp: fixed bug in subfolders enumeration. * examples/example6.cpp: enhanced 'example6' into an interactive program to show some of the features of the messaging module. 2005-05-15 Vincent Richard * messaging/serviceInfos.{hpp|cpp}: changed getAvailableProperties() to return 'serviceInfos::property' objects instead of strings. This permits setting service properties in a more generic manner. 2005-05-03 Vincent Richard * messaging/imap/IMAPFolder.cpp: fixed missing space in "STATUS" command + parsing error in 'status_info'. 2005-04-30 Vincent Richard * utility/childProcess.{hpp|cpp}: added a 'childProcess' class to help with spawning child processes (used in 'sendmail' implementation). 2005-04-28 Stefan Uhrig * README.msvc: added guide describing how to compile VMime using Visual Studio .NET 2003 2005-04-27 Vincent Richard * progressionListener.{hpp|cpp}: moved to 'vmime::utility' package since this can be of general use. * stream.{hpp|cpp}: added a bufferedStreamCopy() function which can take a 'progressionListener' parameter. * filteredStream.{hpp|cpp}: new feature added: filtered input and output streams. * Added 'sendmail' transport service for local delivery. 2005-04-19 Vincent Richard * defaultParameter.cpp: fixed a bug in implementation of RFC-2231 (values were cut if longer than maxLineLength, and no line wrapping occured). 2005-04-15 Vincent Richard * url.{hpp|cpp}, urlUtils.{hpp|cpp}: fixed a lot of bugs in URLs parsing and encoding/decoding + added unit tests. 2005-04-14 Vincent Richard * url.{hpp|cpp}, urlUtils.{hpp|cpp}: moved 'url' and 'urlUtils' from 'vmime::messaging' namespace to 'vmime::utility' namespace. 2005-04-12 Vincent Richard * Started version 0.7.1. VERSION 0.7.0 ============= 2005-04-12 Vincent Richard * parameter.{cpp|hpp}, contentDispositionField.{cpp|hpp}: added support for RFC-2231 (encoded word extensions). Changed 'filename' parameter type from 'vmime::string' to 'vmime::word'. Default parameter type is now vmime::word, and not vmime::string. 2005-04-09 Vincent Richard * encoderB64.cpp: fixed a bug in Base64 decoding. Bytes to be decoded were not correctly initialized. 2005-04-03 Vincent Richard * messaging/*: moved IMAP, POP3, maildir and SMTP files to separate namespaces. 2005-03-31 Vincent Richard * misc/importanceHelper.{cpp|hpp}: added support for message importance: "X-Priority:" and "Importance:" fields. 2005-03-28 Vincent Richard * messaging/POP3Store.cpp: fixed POP3Store::sendPacket() to send "\r\n" in the same packet as the request. This caused problems with some servers (thanks to Donald Dade). * SConstruct: modified 'msvc' target to generate automatically the config file 'config.hpp.msvc'. 2005-03-27 Stefan Uhrig * Added Windows platform handlers. 2005-03-27 Vincent Richard * messageIdSequence.{cpp|hpp}: added a new basic type "messageIdSequence" for a list of message-ids separated by CFWS (used in "References:" field, for example). * SConstruct: added 'msvc' target to generate MSVC project files. 2005-03-25 Vincent Richard * mdn/*.{cpp|hpp}: added support for Message Disposition Notifications (MDN), as defined by RFC-3798 and RFC-1892. This is a very first implementation, API is subject to changes... * Some fixes for Visual C++/Windows. 2005-03-24 Vincent Richard * Added 'HACKING' file. 2005-03-23 Vincent Richard * messaging/POP3*: fixed incorrect message size. Fixed a bug in deleteMessages() when 'to == -1' and last message not being deleted (thanks to Stefan Uhrig). * SConstruct: fixed compilation/linking problem with g++ and X86-64 on static library: added -fPIC/-fpic in compiler flags. * messaging/POP3*: added notifications. * constants.{cpp|hpp}, contentTypeField.{cpp|hpp}: added support for content types and parameters defined in RFC-1892. 2005-03-17 Vincent Richard * base.{cpp|hpp}: renamed 'MIME_VERSION' to 'SUPPORTED_MIME_VERSION'. * Added "Viewer" example in /examples/viewer: demonstrate the parsing capabilities of VMime and it can help when debugging... 2005-03-16 Vincent Richard * Fixed compilation problems on Solaris 9. 2005-03-15 Vincent Richard * tests/parser/textTest.cpp: added more unit tests for 'text' class. * text.{cpp|hpp}, word.{cpp|hpp}: moved word parsing from 'text' class to 'word' class, which now inherits from 'component'. 2005-03-14 Vincent Richard * removed singleton<> and singletonManager classes: useless and quite confusing in Doxygen-generated documentation. 2005-02-06 Vincent Richard * mailboxList.{cpp|hpp}: dropped protected inheritance which was not appropriate for this type of composition. 2005-02-05 Vincent Richard * parserHelpers.hpp: moved 'static' functions into 'parserHelpers' class. 2005-02-05 Vincent Richard * platforms/posix/posixHandler.cpp: removed extra '::' before numeric constants. 2005-02-05 Vincent Richard * utility/md5.cpp: fixed forward use of swapUint32Array() with gcc 3.3 (Apple). 2005-02-01 Vincent Richard * text.cpp: fixed possible segfault when encoding is Base64 (typo). 2005-01-28 Vincent Richard * Started version 0.6.4. VERSION 0.6.3 ============= 2005-01-28 Vincent Richard * Splitted 'contentHandler' into three classes: 'emptyContentHandler', 'stringContentHandler' and 'streamContentHandler'. * Fixed bugs with signed/unsigned char in 'parserHelpers'. 2005-01-15 Vincent Richard * Fixed missing 'vmime/config.hpp' include when installing VMime using 'make install'. 2005-01-13 Vincent Richard * messaging/events.*: prefixed function names with 'get' + written some documentation for functions. 2005-01-05 Vincent Richard * Started version 0.6.3. VERSION 0.6.2 ============= 2005-01-04 Vincent Richard * Added diagnostic error string for 'exceptions::connection_error'. * Fixed a bug in 'posixSocket::connect()' that prevented connecting to servers by specifying an IP address instead of a server name. 2005-01-03 Vincent Richard * Fixed linking error on 'typeAdapter ::parse()' with g++ versions older than 3.3. 2005-01-02 Vincent Richard * Added unit tests for utility::path and bodyPart. * Added 'utility::datetimeUtils' to provide some time-related functions. * Fixed 'stringUtils' not in namespace 'utility'. * Moved 'datetime::getDayOfWeek()' to 'datetimeUtils'. 2005-01-01 Vincent Richard * Converted all C-style casts to C++-style casts. * Added unit tests for utility::md5, utility::stringProxy and utility::stringUtils. 2004-12-31 Vincent Richard * Started version 0.6.2. VERSION 0.6.1 ============= 2004-12-27 Vincent Richard * Added support for 'libtool'. All files needed for autoconf/automake can be generated with SConstruct script, using the 'autotools' target ("scons autotools"). These are also built and included automatically in the distribution tarball ("scons dist"). 2004-12-26 Vincent Richard * Removed relative paths from #include's and moved all header files to 'vmime/' directory. * Renamed main VMime include from 'vmime' to 'vmime.hpp'. So, in your program, you have to #include . * Added support for 'pkg-config'. * Allow creating a service from an URL (session::getStore("url") and session::getTransport("url")) 2004-12-24 Vincent Richard * Renamed class 'disposition' to 'contentDisposition' and the enum namespace 'dispositionTypes' to 'contentDispositionTypes'. 2004-12-23 Vincent Richard * maildir: when connecting to the store, create root directory on the file system if it does not exist. 2004-12-22 Vincent Richard * Fixed missing files in distribution (src/platform/*). * Fixed empty 'COPYING' file. * Started version 0.6.1. VERSION 0.6.0 ============= 2004-12-22 Vincent Richard * Finished 'maildir' implementation. This is EXPERIMENTAL! * Added a getCapabilities() function on 'vmime::messaging::store' to quickly check which features are available. * New functions in 'component': getParsedOffset(), getParsedLength() and getChildComponents(). 2004-12-19 Vincent Richard * Added chaining in exception handling. vmime::exception::other() returns the exception which is encapsulated in the current exception (if any). This allows to retrieve the exception "stack" (for example, this is used for 'maildir' implementation, where some functions return a 'filesystem_exception' encapsulated in a 'messaging_exception'). * Fixed bugs and memory leaks in POP3/IMAP/maildir implementations. 2004-12-17 Vincent Richard * Made default platform handlers (currently, only "posix"). Source files are in src/platforms/[platform-name]. To use a default platform handler, do the following: - #include - call vmime::platformDependant::setHandler() with the appropriate class - link your program with both 'libvmime' and 'libvmime-[platform-name]' For example, to use the default platform handler for POSIX (GNU/Linux): #include int main() { vmime::platformDependant::setHandler (); // ... } and link your program with "-lvmime" and "-lvmime-posix". 2004-10-21 Vincent Richard * A _LOT_ of cleaning/refactoring in VMime code: - got rid of field types (only using field names now). - removed iterators on 'header', 'text', 'addressList', 'mailboxGroup', 'propertySet' and 'bodyPart': use access functions instead (iterators made the code difficult to understand). You can always use standard iterators on the container returned by getFieldList(), and so on. - migrated to get/set convention for accessors (most of time, just add 'get' or 'set' before method name, depending on what it does). - dropped 'comp_t' typedef on 'datetime' (useless). - moved a lot of code from header (.hpp) to implementation files (.cpp). - made all objects cloneable and copiable at the 'component' level: methods component::clone() and component::copyFrom(). - made a 'typeAdapter' to allow using fondamental/no-vmime types in header field and parameter values. - implicit 'operator=' on header fields to set value is not allowed anymore: use setValue() instead or you will get a std::bad_cast exception. - 'textParameter' renamed to 'defaultParameter'. - vmime::makeWordsFromText() is now vmime::text::newFromString(). - changed a lot of return type value from reference to pointer, to to avoid confusion. 2004-10-05 Vincent Richard * added clone() method on 'component' object. 2004-09-09 Vincent Richard * IMAPFolder.cpp: fixed rename(): folder name is now updated. 2004-08-21 Vincent Richard * charset.cpp: workaround (hack?) for different 'iconv' prototypes (they may differ in the second parameter being 'const' or not). 2004-08-20 Vincent Richard * renamed "messaging/folderPath" to "utility/path" for common use in "messaging/folder" and "utility/file". * moved "stream" and "stringProxy" into "utility" namespace. * started to write some "JavaDoc-like" comments, for use with Doxygen. 2004-08-18 Vincent Richard * stringProxy.hpp: fixed stringProxy::it_end() which returned wrong value (typo...). 2004-07-26 Vincent Richard * fileAttachment: fixed the encoding param (not set to default anymore) and provided a new constructor to specify your own encoding. 2004-07-22 Vincent Richard * wide-char support is disabled by default. To enable, set the flag "with_wide_char_support=yes" on the SCons command line. 2004-07-08 Vincent Richard * renamed messaging/POP3*, messaging/IMAP* and messaging/SMTP* classes to follow the same convention as other class names. 2004-07-03 Vincent Richard * moved some files to "utility" subdirectory ("vmime::utility" namespace). VERSION 0.5.1 ============= 2004-06-15 Vincent Richard * contentHandler, htmlTextPart: Fixed some compilation issues with g++ version < 3.4: [error: declaration of `const vmime::encoding& encoding() const' changes meaning of `encoding' from `class vmime::encoding']. * Fixed errors in SConstruct with Windows NT (2k, XP...). VERSION 0.5.0 ============= 2004-05-26 Vincent Richard * added methods receiveRaw() and sendRaw() on vmime::socket object. Do not forget to implement it, or you will get a compile error. 2004-05-21 Vincent Richard * added some unit tests in the "tests" directory. To run all the tests, 'cd' to the "tests" directory, compile test programs by running "make" and then execute the "run-tests.sh" script. * charset: added a convert() function to perform stream conversion. 2004-05-18 Vincent Richard * encoder*: updated all encoders so they use input streams and output streams instead of a in-memory string. You can use the stream adapters (inputStreamStringAdapter and outputStreamStringAdapter) for your code to continue working the old-fashioned way... 2004-05-17 Vincent Richard * messaging/transport.hpp: added a "size" parameter to send() function. 2004-05-16 Vincent Richard * body: body contents and data in text parts are now handled via a proxy object: contentHandler. This allow more flexibility, including providing data from an input stream instead of storing whole data in memory into a string object. This also provide a big performance and memory usage improvement. For more information, please see the comments in the file "contentHandler.hpp". 2004-05-15 Vincent Richard * all files: modified the parsing in depth (not using iterators anymore), the code is clearer and faster. * IMAPutils.cpp: corrected a bug (typo) in IMAPutils::dateTime(). 2004-05-13 Vincent Richard * all files: added a generate() method on vmime::component to generate objects into an output stream (outputStream). This offers a large performance and memory usage improvement when generating big messages. * stream.cpp/.hpp: new objects "inputStream" and "outputStream" to provide more flexibility than with standard C++ streams. There are also adapters for standard i/o streams, provided for compatibility. VERSION 0.4.2 ============= 2004-05-08 Vincent Richard * messaging: added a system of event notification (message change, folder renamed, etc...). For more information about this, please consult "src/messaging/events.hpp". 2004-05-03 Vincent Richard * messaging: added a lot of useful features to message stores (set/get message flags, message deletion, copy, rename folder, adding messages, unique identifiers, MIME part/header fetch, partial fetch...). 2004-04-30 Vincent Richard * messaging/message.hpp: added a fetchPartHeader() method to extract the header of a specific MIME part. 2004-04-25 Vincent Richard * all files: removed (illegal) extra ';' after namespace declarations. * all files: fixed some compilation errors with g++-3.4 (the parser is more strict and more standard-compliant). 2004-04-24 Vincent Richard * messaging/*: splitted "progressListener" into two objects: "progressionListener" and "timeoutHandler". The last one is used internally in VMime. The "progressionListener" parameter is no more passed as argument to the constructor of a "service" object. Instead, it can be given in argument to the functions that use it: - message::extract[Part]() - folder::fetchMessages() - transport::send() 2004-04-04 Vincent Richard * messaging/folder.hpp: added a (optional) parameter "recursive" to getFolders() to allow enumeration of all sub-folders (that is, direct and indirect). 2004-04-03 Vincent Richard * messaging/authenti[fi]cationInfos: renamed class 'authentificationInfos' to 'authenticationInfos'. * exception.hpp: renamed class 'authentification_error' to 'authentication_error'. * messaging/SMTPtransport: renamed 'options.need-authentification' to 'options.need-authentication'. 2004-04-02 Vincent Richard * added basic IMAP support. This is EXPERIMENTAL. 2004-03-25 Vincent Richard * messaging::folder::path: changed type of 'component' from 'string' to 'word' to allow multiple charsets to be used in a path. * implemented a noop() command on vmime::messaging::service class. * messageParser.cpp: it is now possible to get more information on an attachment using the "Content-Disposition" (use the attachmentInfo() fonction to retrieve the "Content-Disposition" field related to the attachment). VERSION 0.4.1 ============= 2004-03-24 Vincent Richard * SMTPtransport.cpp: fixed a bug in send(). VERSION 0.4.0 ============= 2004-02-19 Vincent Richard * mailboxGroup.cpp: fixed a segfault when generating() an empty group (eg. "undisclosed-recipient"). 2004-02-17 Vincent Richard * === MAJOR CHANGE === Removed old "network features". Now, this is called "messaging system" and a new (incompatible) interface is provided. 2003-12-30 Vincent Richard * encoderFactory.cpp/.hpp: added stuff to allow iterating through registered encoders. * encoder*.cpp/.hpp: changed the way options/results are set in encoders: now, a vmime::propertySet is used. This provides more flexibility. 2003-12-25 Vincent Richard * constants.cpp/.hpp: media types constants: removed "sub" namespace and translated "sub::[TYPE]::[SUBTYPE]" to "[TYPE]_[SUBTYPE]". 2003-12-08 Vincent Richard * constants.cpp/.hpp, dateTime.cpp/.hpp: translated all constants/enums from lower-case to upper-case letters. 2003-12-04 Vincent Richard * Created a new class for singleton. Derived all concerned class from this new class. This concerns: "encoderFactory", "headerFieldFactory", "parameterFactory", "options" and "textPartFactory". 2003-12-02 Vincent Richard * Moved to SCons building system (http://www.scons.org/) and dropped old autoconf/automake system. Type 'scons' to build the library and use 'scons install' to install it on your system. 2003-12-01 Vincent Richard * mailboxGroup.cpp: fixed a bug in typeid() comparison: changed "typeid(parsedAddress)" to "typeid(*parsedAddress)" to test the object dynamic type (the previous test was always false). VERSION 0.3.5 ============= 2003-10-24 Vincent Richard * included some sample programs in the "examples/" directory. For a more complete documentation, please visit: http://www.kisli.com/vmime/doc/ . * all files: it is not possible to create header fields directly anymore (ie. you cannot call the constructor directly); instead, you should use the "headerFieldFactory" object. VERSION 0.3.4 ============= 2003-10-05 Vincent Richard * all files: changed all calls 'std::isspace(???)' to '[vmime::]isspace(???)' since no locale was passed (anyway, no locale is needed: text is ASCII). 2003-10-04 Kai Stammerjohann * included a Visual C++ 7 solution/project for vmime: see "vmime.sln" and "vmime.vcproj" in the root directory. VERSION 0.3.3 ============= 2003-09-22 Vincent Richard * moved all constants (media types, charsets...) from base.cpp/.hpp to new files constants.cpp/.hpp. 2003-09-21 Vincent Richard * messageBuilder.cpp (construct): fixed algorithm for generating text parts. Single and multiple text parts, with or without attachments are now handled correctly (as recommended by the RFCs). * bodyPart.cpp/.hpp, body.cpp/.hpp, header.cpp/.hpp: added clone() and operator=() functions to be able to duplicate body parts. * messageParser.cpp (findTextParts): handled the case in which the message is not "multipart/*": we use the main part if its type is "text/*". * messageParser.cpp (destructor): added code for deleting the text parts created by the findTextParts() function. VERSION 0.3.2 ============= 2003-09-19 Bevan Collins * encoderQP.cpp: fixed a bug in quoted-printable encoding: "=20\r\n" is appended to the line ending with a space. 2003-09-13 Vincent Richard * charset.cpp/.hpp: dropped internal conversion from charset name (string) to charset type (enum). We keep only the name of the charset. * base.cpp/.hpp: added string constants for some charsets. 2003-09-12 Vincent Richard * messageParser.cpp (findAttachments): fixed the search for attachment parts. The right test is "cdf.value().name() != dispositionTypes::_inline" and not "cdf.value().name() != dispositionTypes::attachment"... 2003-09-11 Vincent Richard * plainTextPart.cpp/htmlTextPart.cpp: fixed a bug in parse(): when getting the "charset" parameter, "no_such_parameter" exception was not caught if the parameter was not present. 2003-09-06 Vincent Richard * base.cpp: added a special case when encoding to Quoted-Printable: lines are no more limited to 76 characters (the maximum length recommended by the RFC) if maxLineLength == lineLengthLimits::infinite. However, this SHOULD NOT be used when generating mails (not RFC compliant). VERSION 0.3.1 ============= 2003-08-24 Vincent Richard * mailbox.hpp: added "const" functions for name() and email(). 2003-07-26 Vincent Richard * charset.cpp: fixed a bug in "charset::iconvert()". Also, the conversion is now done using a buffer, and not in one block. 2003-07-24 Vincent Richard * receiveProtocol[POP3].hpp/.cpp: a socket factory can now be passed in argument to the constructor so that it is possible to override the use of the default factory (set in vmime::platformDependantHandler). VERSION 0.3.0 ============= 2003-07-21 Vincent Richard * configure.in: changed 'libdir' to install lib files in {PREFIX}/lib instead of {PREFIX}/lib/vmime. However, include files remain in the {PREFIX}/include/vmime directory. 2003-06-28 Vincent Richard * base.hpp/.cpp: changed the return type of "libname()" and "libversion()" from "string::value_type*" to "string". 2003-06-16 Vincent Richard * platformDependant.hpp: added "getSocketFactory()" function to be used with the new network features. * configure.in: modified the file to permit passing arguments to the "configure" script: . --disable-net: disable network support (new in 0.3.0) . --enable-debug: enable debug mode (not used for now) * started version 0.3.0: added network features: connection to mail servers via POP3, IMAP... Related classes: "receiveProtocol*", "serverInfos" and "socket", an abstract socket class. VERSION 0.2.1 ============= 2003-05-28 Vincent Richard * messageId.cpp: added "vmime." at the beginning of random-generated message-ids (to make them more unique). 2003-05-26 Vincent Richard * all source files: replaced "_VMIME_xxxxx_HPP_INCLUDED_" macros with "VMIME_xxxxx_HPP_INCLUDED". Names beginning with "_" (underscore) and followed by an uppercase letter are reserved to the implementation (see the C++ standard: 17.4.3.1.2 Global names). VERSION 0.2.0 ============= 2003-05-18 Vincent Richard * messageParser.cpp: added a message parser (to be used parallely with messageBuilder). Extraction of attachment, plain text parts and HTML text parts (with embedded objects) is supported. 2003-05-09 Vincent Richard * body.cpp (generate): the default prolog & epilog text (as defined in vmime::options) are not written anymore in sub-parts (only for the "root" part). Added a "isRoot" member to vmime::header. 2003-05-08 Vincent Richard * encoding.cpp (decide): added some code to choose "quoted-printable" when there are lines with more than "lineLengthLimits::convenient" characters (or with a '.' just after a '\n'). * base.cpp (makeWordsFromText): enhanced algorithm. 2003-05-04 Vincent Richard * address.cpp, mailbox.cpp, mailboxGroup.cpp: added empty() function. * messageBuilder.cpp (construct): some validity checks: we now check there is one expeditor and at least one recipient. VERSION 0.1.0 ============= 2003-05-03 Vincent Richard * First (beta) version released. libvmime-0.9.1/COPYING0000644000175000017500000010451311250723264014670 0ustar mnordstrmnordstr GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . libvmime-0.9.1/bootstrap0000755000175000017500000000412511374031010015562 0ustar mnordstrmnordstr#! /usr/bin/env bash # # Bootstrap file for 'autotools' build # export WANT_AUTOCONF="latest" export WANT_AUTOMAKE="1.9" export LANG=C rm -f aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh INSTALL rm -Rf autom4te.cache (mkdir autotools >& /dev/null) (cd autotools && rm -f config.guess config.sub missing mkinstalldirs compile ltmain.sh depcomp install-sh) # Check for "glibtoolize" instead of "libtoolize" on OSX LIBTOOLIZE=libtoolize if which glibtoolize > /dev/null 2>&1; then LIBTOOLIZE=glibtoolize fi DIE=0 echo "" if test $DIE = 0 ; then echo -n "* Running aclocal... " ; (aclocal -I m4 >& bootstrap.tmpout) \ && (echo "[OK]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout) \ || (echo "[NO]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout ; not_a_command >& /dev/null) || DIE=1 fi if test $DIE = 0 ; then echo -n "* Running autoconf... " ; (autoconf >& bootstrap.tmpout) \ && (echo "[OK]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout) \ || (echo "[NO]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout ; not_a_command >& /dev/null) || DIE=1 fi if test $DIE = 0 ; then echo -n "* Running autoheader... " ; (autoheader >& bootstrap.tmpout) \ && (echo "[OK]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout) \ || (echo "[NO]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout ; not_a_command >& /dev/null) || DIE=1 fi if test $DIE = 0 ; then echo -n "* Running libtoolize... " ; ($LIBTOOLIZE --copy --force --automake >& bootstrap.tmpout) \ && (echo "[OK]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout) \ || (echo "[NO]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout ; not_a_command >& /dev/null) || DIE=1 fi # Bug with automake 1.10? touch autotools/config.rpath if test $DIE = 0 ; then echo -n "* Running automake... " ; (automake --add-missing --copy >& bootstrap.tmpout) \ && (echo "[OK]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout) \ || (echo "[NO]" ; cat bootstrap.tmpout ; rm -f bootstrap.tmpout ; not_a_command >& /dev/null) || DIE=1 fi echo ""