Index: /emailtotracscript/trunk/Makefile.in
===================================================================
--- /emailtotracscript/trunk/Makefile.in	(revision 21)
+++ /emailtotracscript/trunk/Makefile.in	(revision 22)
@@ -8,7 +8,4 @@
 # defaullt values are:
 #
-# MTA_USER "nobody"
-# TRAC_USER "www-data"
-# TRAC_SCRIPT_NAME "email2trac"
 #
 PREFIX=@prefix@
@@ -16,5 +13,10 @@
 PYTHON_BIN=@PYTHON@
 
-CC=gcc
+# User names 
+#
+TRAC_USER=@trac_user@
+MTA_USER=@mta_user@
+
+CC=@CC@
 DEBUG=0
 CFLAGS=-DMTA_USER=\"$(MTA_USER)\" -DTRAC_USER=\"$(TRAC_USER)\" -DTRAC_SCRIPT_NAME=\"$(TRAC_SCRIPT_NAME)\" -DTRAC_SCRIPT_PATH=\"$(INSTALL_BIN)\" -DDEBUG=$(DEBUG)
@@ -32,9 +34,8 @@
 	for script in $(PYTHON_FILES) ; \
 	do \
-          name=`basename email2trac.py '.py'`
-	  sed -e "s%^\#\!/usr/bin/python%\#\!$(PYTHON_BIN)%" $$script > $(INSTALL_BIN)/$$name ; \
-	  chmod a+x $(INSTALL_BIN)/$$name ; \
+          name=`basename $$script '.py'` ; \
+	  install --mode=755 --owner=root $$script  $(INSTALL_BIN)/$$name 
 	done
 
 clean:
-	rm run_email2trac
+	rm run_email2trac 
Index: /emailtotracscript/trunk/configure
===================================================================
--- /emailtotracscript/trunk/configure	(revision 21)
+++ /emailtotracscript/trunk/configure	(revision 22)
@@ -273,5 +273,5 @@
 
 ac_unique_file="email2trac.py"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS pyexecdir PYTHON PYTHON_VERSION PYTHON_PREFIX PYTHON_EXEC_PREFIX PYTHON_PLATFORM pythondir pkgpythondir pkgpyexecdir LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS pyexecdir trac_user mta_user PYTHON PYTHON_VERSION PYTHON_PREFIX PYTHON_EXEC_PREFIX PYTHON_PLATFORM pythondir pkgpythondir pkgpyexecdir CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
@@ -714,4 +714,24 @@
 ac_cv_env_target_alias_set=${target_alias+set}
 ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
 
 #
@@ -780,4 +800,26 @@
 
   cat <<\_ACEOF
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+
+  --with-trac_user=USER    Specify the name of the user that trac use,
+                          default=www-data
+
+  --with-mta_user=USER    Specify the name of the user that your MTA use,
+                          default=nobody
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
+              headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
 
 _ACEOF
@@ -1224,4 +1266,6 @@
 
 
+
+
         # Find any Python interpreter.
     for ac_prog in python python2 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5
@@ -1340,6 +1384,1253 @@
 
 
-
-          ac_config_files="$ac_config_files Makefile"
+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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$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"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+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
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl
+  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
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$ac_ct_CC" && break
+done
+
+  CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+     "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+  (eval $ac_compiler --version </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+  (eval $ac_compiler -v </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+  (eval $ac_compiler -V </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out 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.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+  (eval $ac_link_default) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Find the output, starting from the most likely.  This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+	;;
+    conftest.$ac_ext )
+	# This is the source file.
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+	ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	# FIXME: I believe we export ac_cv_exeext for Libtool,
+	# but it would be cool to find out if it's true.  Does anybody
+	# maintain Libtool? --akim.
+	export ac_cv_exeext
+	break;;
+    * )
+	break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+  fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; 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 | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  export ac_cv_exeext
+	  break;;
+    * ) break;;
+  esac
+done
+else
+  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$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
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* 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 -std1 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 -std1.  */
+int osf4_cc_array ['\x00' == 0 ? 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
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
+# SVR4			-Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  for ac_declaration in \
+   '' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext 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
+
+
+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
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&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
+  echo $ECHO_N "(cached) $ECHO_C" >&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 <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> 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 >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # 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
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$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 <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> 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 >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # 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
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+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
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+if test $ac_cv_c_compiler_gnu = yes; then
+    echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5
+echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6
+if test "${ac_cv_prog_gcc_traditional+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+    ac_pattern="Autoconf.*'x'"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sgtty.h>
+Autoconf TIOCGETP
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then
+  ac_cv_prog_gcc_traditional=yes
+else
+  ac_cv_prog_gcc_traditional=no
+fi
+rm -f conftest*
+
+
+  if test $ac_cv_prog_gcc_traditional = no; then
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <termio.h>
+Autoconf TCGETA
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then
+  ac_cv_prog_gcc_traditional=yes
+fi
+rm -f conftest*
+
+  fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5
+echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
+  if test $ac_cv_prog_gcc_traditional = yes; then
+    CC="$CC -traditional"
+  fi
+fi
+
+
+
+
+# Check whether --with-trac_user or --without-trac_user was given.
+if test "${with_trac_user+set}" = set; then
+  withval="$with_trac_user"
+  case "${withval}" in
+        *) trac_user="${withval}" ;;
+  esac
+else
+  trac_user="www-data"
+
+fi;
+
+# Check whether --with-mta_user or --without-mta_user was given.
+if test "${with_mta_user+set}" = set; then
+  withval="$with_mta_user"
+  case "${withval}" in
+        *) mta_user="${withval}" ;;
+  esac
+else
+  mta_user="nobody"
+
+fi;                               ac_config_files="$ac_config_files Makefile email2trac.py delete_spam.py"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -1893,4 +3184,6 @@
   # Handling of arguments.
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+  "email2trac.py" ) CONFIG_FILES="$CONFIG_FILES email2trac.py" ;;
+  "delete_spam.py" ) CONFIG_FILES="$CONFIG_FILES delete_spam.py" ;;
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -1977,4 +3270,6 @@
 s,@LIBS@,$LIBS,;t t
 s,@pyexecdir@,$pyexecdir,;t t
+s,@trac_user@,$trac_user,;t t
+s,@mta_user@,$mta_user,;t t
 s,@PYTHON@,$PYTHON,;t t
 s,@PYTHON_VERSION@,$PYTHON_VERSION,;t t
@@ -1985,4 +3280,13 @@
 s,@pkgpythondir@,$pkgpythondir,;t t
 s,@pkgpyexecdir@,$pkgpyexecdir,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
Index: /emailtotracscript/trunk/configure.in
===================================================================
--- /emailtotracscript/trunk/configure.in	(revision 21)
+++ /emailtotracscript/trunk/configure.in	(revision 22)
@@ -3,8 +3,37 @@
 AC_SUBST(exec_prefix)
 AC_SUBST(pyexecdir)
+AC_SUBST(trac_user)
+AC_SUBST(mta_user)
 
 AM_PATH_PYTHON
+AC_PROG_GCC_TRADITIONAL
 
+
+AC_ARG_WITH(trac_user,
+[
+  --with-trac_user=USER    Specify the name of the user that trac use,
+                          default=www-data],
+
+  [case "${withval}" in
+        *) trac_user="${withval}" ;;
+  esac],
+
+  [trac_user="www-data"]
+)dnl            
+
+AC_ARG_WITH(mta_user,
+[
+  --with-mta_user=USER    Specify the name of the user that your MTA use,
+                          default=nobody],
+
+  [case "${withval}" in
+        *) mta_user="${withval}" ;;
+  esac],
+
+  [mta_user="nobody"]
+)dnl            
 AC_OUTPUT(
         Makefile
+	email2trac.py
+	delete_spam.py
 	)
Index: ailtotracscript/trunk/delete_spam.py
===================================================================
--- /emailtotracscript/trunk/delete_spam.py	(revision 21)
+++ 	(revision )
@@ -1,116 +1,0 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2002
-#
-# This file is part of the pxeconfig utils
-#
-# This program is free software; you can 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
-#
-"""
-Author: Bas van der Vlies
-Date  : 29 September 2205
-Desc. : Delete Spam tickets from database. Else we get an lot of 
-        tickets
-
-Usage :
-	delete_spam [ -f <configfile> ]
-
-defaults:
-	configfile = /etc/email2trac.conf
-
-SVN Info:
-        $Id: delete_spam.py 1512 2005-10-26 09:20:37Z jaap $
-"""
-from trac import Environment, Ticket
-
-import os
-import sys
-import getopt
-import shutil
-import ConfigParser
-
-def ReadConfig(file):
-	"""
-	Parse the config file
-	"""
-
-	if not os.path.isfile(file):
-		print 'File %s does not exists' %file
-		sys.exit(1)
-
-	config = ConfigParser.ConfigParser()
-
-	try:
-	  config.read(file)
-	except ConfigParser.MissingSectionHeaderError,detail:
-	  print detail
-	  sys.exit(1)
-
-	defaults = config.defaults()
-	if not defaults.has_key('project'):
-		print 'You have define the location of your trac project, eg:'
-		print '\t project: /var/trac/<projectname>'
-		sys.exit(1)
-	  
-	return defaults
-
-
-def delete_spam(project, debug):
-			env = Environment.Environment(project, create=0)
-			db = env.get_db_cnx()
-			
-			cursor = db.cursor()
-
-			# Delete the attachments associated with Spam tickets
-			#
-			cursor.execute("SELECT id FROM ticket WHERE  component = 'Spam';") 
-			while 1:
-				row = cursor.fetchone()
-				if not row:
-					break
-				spam_id =  row[0]
-				attachment_dir = os.path.join(env.get_attachments_dir(), 'ticket', str(spam_id)) 
-				if os.path.exists(attachment_dir):
-					if debug:
-						print 'delete %s : %s' %(spam_id, attachment_dir)
-					shutil.rmtree(attachment_dir)
-
-			cursor.execute("DELETE FROM ticket WHERE  component = 'Spam';") 
-			db.commit()
-
-if __name__ == '__main__':
-	# Default config file
-	#
-	configfile = '/etc/email2trac.conf'
-
-	try:
-		 opts, args = getopt.getopt(sys.argv[1:], 'hf:', ['help', 'file='])
-	except getopt.error,detail:
-		print __doc__
-		print detail
-		sys.exit(1)
-
-	for opt,value in opts:
-		if opt in [ '-h', '--help']:
-			print __doc__ 
-			sys.exit(0) 
-		elif opt in ['-f', '--file']:
-			configfile = value
-	
-	settings = ReadConfig(configfile)
-	delete_spam(settings['project'], int(settings['debug']))
-	print 'Spam is deleted succesfully..' 
-
-# EOB
Index: /emailtotracscript/trunk/delete_spam.py.in
===================================================================
--- /emailtotracscript/trunk/delete_spam.py.in	(revision 22)
+++ /emailtotracscript/trunk/delete_spam.py.in	(revision 22)
@@ -0,0 +1,116 @@
+#!@PYTHON@
+#
+# Copyright (C) 2002
+#
+# This file is part of the pxeconfig utils
+#
+# This program is free software; you can 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
+#
+"""
+Author: Bas van der Vlies
+Date  : 29 September 2205
+Desc. : Delete Spam tickets from database. Else we get an lot of 
+        tickets
+
+Usage :
+	delete_spam [ -f <configfile> ]
+
+defaults:
+	configfile = /etc/email2trac.conf
+
+SVN Info:
+        $Id$
+"""
+from trac import Environment, Ticket
+
+import os
+import sys
+import getopt
+import shutil
+import ConfigParser
+
+def ReadConfig(file):
+	"""
+	Parse the config file
+	"""
+
+	if not os.path.isfile(file):
+		print 'File %s does not exists' %file
+		sys.exit(1)
+
+	config = ConfigParser.ConfigParser()
+
+	try:
+	  config.read(file)
+	except ConfigParser.MissingSectionHeaderError,detail:
+	  print detail
+	  sys.exit(1)
+
+	defaults = config.defaults()
+	if not defaults.has_key('project'):
+		print 'You have define the location of your trac project, eg:'
+		print '\t project: /var/trac/<projectname>'
+		sys.exit(1)
+	  
+	return defaults
+
+
+def delete_spam(project, debug):
+			env = Environment.Environment(project, create=0)
+			db = env.get_db_cnx()
+			
+			cursor = db.cursor()
+
+			# Delete the attachments associated with Spam tickets
+			#
+			cursor.execute("SELECT id FROM ticket WHERE  component = 'Spam';") 
+			while 1:
+				row = cursor.fetchone()
+				if not row:
+					break
+				spam_id =  row[0]
+				attachment_dir = os.path.join(env.get_attachments_dir(), 'ticket', str(spam_id)) 
+				if os.path.exists(attachment_dir):
+					if debug:
+						print 'delete %s : %s' %(spam_id, attachment_dir)
+					shutil.rmtree(attachment_dir)
+
+			cursor.execute("DELETE FROM ticket WHERE  component = 'Spam';") 
+			db.commit()
+
+if __name__ == '__main__':
+	# Default config file
+	#
+	configfile = '/etc/email2trac.conf'
+
+	try:
+		 opts, args = getopt.getopt(sys.argv[1:], 'hf:', ['help', 'file='])
+	except getopt.error,detail:
+		print __doc__
+		print detail
+		sys.exit(1)
+
+	for opt,value in opts:
+		if opt in [ '-h', '--help']:
+			print __doc__ 
+			sys.exit(0) 
+		elif opt in ['-f', '--file']:
+			configfile = value
+	
+	settings = ReadConfig(configfile)
+	delete_spam(settings['project'], int(settings['debug']))
+	print 'Spam is deleted succesfully..' 
+
+# EOB
Index: ailtotracscript/trunk/email2trac.py
===================================================================
--- /emailtotracscript/trunk/email2trac.py	(revision 21)
+++ 	(revision )
@@ -1,544 +1,0 @@
-#!/usr/bin/python
-# Copyright (C) 2002
-#
-# This file is part of the email2trac utils
-#
-# This program is free software; you can 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
-#
-"""
-emailfilter.py -- Email tickets to Trac.
-
-A simple MTA filter to create Trac tickets from inbound emails.
-
-Copyright 2005, Daniel Lundin <daniel@edgewall.com>
-Copyright 2005, Edgewall Software
-
-Changed By: Bas van der Vlies <basv@sara.nl>
-Date      : 13 September 2005
-Descr.    : Added config file and command line options, spam level
-            detection, reply address and mailto option. Unicode support
-
-Changed By: Walter de Jong <walter@sara.nl>
-Descr.    : multipart-message code and trac attachments
-
-
-The scripts reads emails from stdin and inserts directly into a Trac database.
-MIME headers are mapped as follows:
-
-	* From:      => Reporter
-	             => CC (Optional via reply_address option)
-	* Subject:   => Summary
-	* Body       => Description
-	* Component  => Can be set to SPAM via spam_level option
-
-How to use
-----------
- * Create an config file:
-	[DEFAULT]                        # REQUIRED
-	project      : /data/trac/test   # REQUIRED
-	debug        : 1                 # OPTIONAL, if set print some DEBUG info
-	spam_level   : 4                 # OPTIONAL, if set check for SPAM mail 
-	reply_address: 1                 # OPTIONAL, if set then fill in ticket CC field
-        umask        : 022               # OPTIONAL, if set then use this umask for creation of the attachments
-	mailto_link  : 1                 # OPTIONAL, if set then [mailto:<CC>] in description 
-	trac_version : 0.8               # OPTIONAL, default is 0.9
-
-	[jouvin]                         # OPTIONAL project declaration, if set both fields necessary
-	project      : /data/trac/jouvin # use -p|--project jouvin.  
-        
- * default config file is : /etc/email2trac.conf
-
- * Commandline opions:
-                -h | --help
-                -c <value> | --component=<value>
-                -f <config file> | --file=<config file>
-                -p <project name> | --project=<project name>
-
-SVN Info:
-        $Id: email2trac.py 1523 2005-11-01 09:27:51Z bas $
-"""
-
-import os
-import sys
-import string
-import getopt
-import stat
-import time
-import email
-import re
-import urllib
-import unicodedata
-import ConfigParser
-from email import Header
-from stat import *
-import mimetypes
-
-trac_default_version = 0.9
-
-class TicketEmailParser(object):
-	env = None
-	comment = '> '
-    
-	def __init__(self, env, parameters, version):
-		self.env = env
-
-		# Database connection
-		#
-		self.db = None
-
-		self.VERSION = version
-		if self.VERSION > 0.8:
-			self.new_ticket = ticket.Ticket
-			self.get_config = self.env.config.get
-		else:
-			self.new_ticket = Ticket.Ticket
-			self.get_config = self.env.get_config
-
-		if parameters.has_key('umask'):
-			os.umask(int(parameters['umask'], 8))
-
-		if parameters.has_key('debug'):
-			self.DEBUG = int(parameters['debug'])
-		else:
-			self.DEBUG = 0
-
-		if parameters.has_key('reply_address'):
-			self.CC = int(parameters['reply_address'])
-		else:
-			self.CC = 0
-
-		if parameters.has_key('mailto_link'):
-			self.MAILTO = int(parameters['mailto_link'])
-		else:
-			self.MAILTO = 0
-
-		if parameters.has_key('spam_level'):
-			self.SPAM_LEVEL = int(parameters['spam_level'])
-		else:
-			self.SPAM_LEVEL = 0
-
-		if parameters.has_key('email_comment'):
-			self.comment = str(parameters['email_comment'])
-
-		if parameters.has_key('email_header'):
-			self.EMAIL_HEADER = int(parameters['email_header'])
-		else:
-			self.EMAIL_HEADER = 0
-
-
-	# X-Spam-Score: *** (3.255) BAYES_50,DNS_FROM_AHBL_RHSBL,HTML_
-	# Note if Spam_level then '*' are included
-	def spam(self, message):
-		if message.has_key('X-Spam-Score'):
-			spam_l = string.split(message['X-Spam-Score'])
-			number = spam_l[0].count('*')
-
-			if number >= self.SPAM_LEVEL:
-				return number
-
-		return 0
-
-	def to_unicode(self, str):
-		"""
-		Email has 7 bit ASCII code, convert it to unicode with the charset
-		that is encoded in 7-bit ASCII code and encode it as utf-8 so TRAC 
-		understands it.
-		"""
-		results =  Header.decode_header(str)
-		str = None
-		for text,format in results:
-			if format:
-				try:
-					temp = unicode(text, format)
-				except UnicodeError:
-					# This always works 
-					#
-					temp = unicode(text, 'iso-8859-15')
-				temp =  temp.encode('utf-8')
-			else:
-				temp = string.strip(text)
-
-			if str:
-				str = '%s %s' %(str, temp)
-			else:
-				str = temp
-
-		return str
-
-	def debug_attachments(self, message):
-		n = 0
-		for part in message.walk():
-			if part.get_content_maintype() == 'multipart':      # multipart/* is just a container
-				print 'TD: multipart container'
-				continue
-
-			n = n + 1
-			print 'TD: part%d: Content-Type: %s' % (n, part.get_content_type())
-			print 'TD: part%d: filename: %s' % (n, part.get_filename())
-
-			if part.is_multipart():
-				print 'TD: this part is multipart'
-				payload = part.get_payload(decode=1)
-				print 'TD: payload:', payload
-			else:
-				print 'TD: this part is not multipart'
-
-			part_file = '/var/tmp/part%d' % n
-			print 'TD: writing part%d (%s)' % (n,part_file)
-			fx = open(part_file, 'wb')
-			text = part.get_payload(decode=1)
-			if not text:
-				text = '(None)'
-			fx.write(text)
-			fx.close()
-			try:
-				os.chmod(part_file,S_IRWXU|S_IRWXG|S_IRWXO)
-			except OSError:
-				pass
-
-	def email_header_txt(self, m):
-#		if not m['Subject']:
-#			subject = '(geen subject)'
-#		else:
-#			subject = self.to_unicode(m['Subject'])
-#
-#		head = "'''Subject:''' %s [[BR]]" % subject
-#		if m['From'] and len(m['From']) > 0:
-#			head = "%s'''From:''' %s [[BR]]" % (head, m['From'])
-#		if m['Date'] and len(m['Date']) > 0:
-#			head = "%s'''Date:''' %s [[BR]]" %(head, m['Date'])
-
-		str = ''
-		if m['To'] and len(m['To']) > 0 and m['To'] != 'hic@sara.nl':
-			str = "'''To:''' %s [[BR]]" %(m['To'])
-		if m['Cc'] and len(m['Cc']) > 0:
-			str = "%s'''Cc:''' %s [[BR]]" % (str, m['Cc'])
-
-		return str
-
-	def parse(self, fp):
-		msg = email.message_from_file(fp)
-		if not msg:
-			return
-
-		if self.DEBUG > 1:	  # save the entire e-mail message text
-			msg_file = '/var/tmp/msg.txt' 
-			print 'TD: saving email to %s' % msg_file
-			fx = open(msg_file, 'wb')
-			fx.write('%s' % msg)
-			fx.close()
-			try:
-				os.chmod(msg_file,S_IRWXU|S_IRWXG|S_IRWXO)
-			except OSError:
-				pass
-
-		self.db = self.env.get_db_cnx()
-		tkt = self.new_ticket(self.env)
-		tkt['status'] = 'new'
-
-		# Some defaults
-		#
-		tkt['milestone'] = self.get_config('ticket', 'default_milestone')
-		tkt['priority'] = self.get_config('ticket', 'default_priority')
-		tkt['severity'] = self.get_config('ticket', 'default_severity')
-		tkt['version'] = self.get_config('ticket', 'default_version')
-
-		if not msg['Subject']:
-			tkt['summary'] = '(geen subject)'
-		else:
-			tkt['summary'] = self.to_unicode(msg['Subject'])
-
-		if self.SPAM_LEVEL and self.spam(msg):
-			print 'This message is a SPAM. Automatic ticket insertion refused (SPAM level > %d' % self.SPAM_LEVEL
-			sys.exit(1)
-
-		if settings.has_key('component'):
-			tkt['component'] = settings['component']
-		else:
-			tkt['component'] = self.get_config('ticket', 'default_component')
-
-		# Get default owner for component
-		#
-		cursor = self.db.cursor()
-		sql = 'SELECT owner FROM component WHERE name=\'%s\'' % tkt['component']
-		cursor.execute(sql)
-		tkt['owner'] = cursor.fetchone()[0]
-
-		from_str = self.to_unicode(msg['from'])
-		tkt['reporter'] = from_str
-		if self.CC:
-			tkt['cc'] = from_str
-
-# produce e-mail like header
-		head = ''
-		if self.EMAIL_HEADER > 0:
-			head = self.email_header_txt(msg)
-
-		if self.DEBUG > 0:
-			self.debug_attachments(msg)
-
-#
-#	put the message text in the ticket description
-#	message text can be plain text or html or something else
-#
-		has_description = 0
-		for part in msg.walk():
-			if part.get_content_maintype() == 'multipart':			# 'multipart/*' is a container for multipart messages
-				continue
-
-			if part.get_content_type() == 'text/plain':
-				body_text = part.get_payload(decode=1)			# try to decode
-				if not body_text:					# decode failed
-					body_text = part.get_payload(decode=0)		# do not decode
-
-				tkt['description'] = '\n{{{\n\n%s\n}}}\n' % body_text
-
-			elif part.get_content_type() == 'text/html':
-				tkt['description'] = '%s\n\n(see attachment for HTML mail message)\n' % head
-				body_text = tkt['description']
-
-			else:
-				tkt['description'] = '%s\n\n(see attachment for message)\n' % head
-				body_text = tkt['description']
-
-			has_description = 1
-			break		# we have the description, so break
-
-		if not has_description:
-			tkt['description'] = '%s\n\n(no plain text message, see attachments)' % head
-			has_description = 1
-
-		author, email_addr  = email.Utils.parseaddr(msg['from'])
-		if self.MAILTO:
-			mailto = self.html_mailto_link(author, email_addr, self.to_unicode(msg['subject']), body_text)
-			tkt['description'] = '%s\n%s %s' %(head, mailto, tkt['description'])
-
-		if self.VERSION > 0.8:
-			tkt['id'] = tkt.insert()
-		else:
-			tkt['id'] = tkt.insert(self.db)
-
-		#
-		# Just how to show to update description
-		#
-		#tkt['description'] = '\n{{{\n\n Bas is op nieuw bezig\n\n }}}\n' 
-		#tkt.save_changes(self.db, author, "Lekker bezig")
-		#
-		self.attachments(msg, tkt, author)
-
-
-	def mail_line(self, str):
-		return '%s %s' % (self.comment, str)
-
-
-	def html_mailto_link(self, author, mail_addr, subject, body):
-		if not author:
-			author = mail_addr
-		else:	
-			author = self.to_unicode(author)
-
-		# Must find a fix
-		#
-		#arr = string.split(body, '\n')
-		#arr = map(self.mail_line, arr)
-
-		#body = string.join(arr, '\n')
-		#body = '%s wrote:\n%s' %(author, body)
-
-		# Obsolete for reference
-		#
-		#body = self.to_unicode(body)
-		#body = urllib.quote(body)
-		#body = Header.encode(body)
-		#
-
-		# Temporary fix
-		body = '> Type your reply'
-		str = 'mailto:%s?subject=%s&body=%s' % (urllib.quote(mail_addr), urllib.quote('Re: %s' % subject), urllib.quote(body))
-		str = '\n{{{\n#!html\n<a href="%s">Reply to: %s</a>\n}}}\n' %(str, author)
-
-		return str
-
-	def attachments(self, message, ticket, user):
-		'''save any attachments as file in the ticket's directory'''
-
-		count = 0
-		first = 0
-		for part in message.walk():
-			if part.get_content_maintype() == 'multipart':		# multipart/* is just a container
-				continue
-
-			if not first:										# first content is the message
-				first = 1
-				if part.get_content_type() == 'text/plain':		# if first is text, is was already put in the description
-					continue
-
-			filename = part.get_filename() 
-			if not filename:
-				count = count + 1
-				filename = 'part%04d' % count
-
-				ext = mimetypes.guess_extension(part.get_type())
-				if not ext:
-					ext = '.bin'
-
-				filename = '%s%s' % (filename, ext)
-			else:
-				filename = self.to_unicode(filename)
-
-			if '/' in filename:
-				filename = os.path.basename(filename)
-
-			url_filename = urllib.quote(filename)
-
-			if self.VERSION > 0.8:
-				tmpfile = '/tmp/email2trac-ticket%sattachment' % str(ticket['id'])
-			else:
-				dir = os.path.join(self.env.get_attachments_dir(), 'ticket', 
-				                    	urllib.quote(str(ticket['id'])))
-				if not os.path.exists(dir):
-					mkdir_p(dir, 0755)
-
-				tmpfile = os.path.join(dir, url_filename)
-
-			f = open(tmpfile, 'wb')
-			text = part.get_payload(decode=1)
-			if not text:
-				text = '(None)'
-			f.write(text)
-
-			# get the filesize
-			#
-			stats = os.lstat(tmpfile) 
-			filesize = stats[stat.ST_SIZE]
-
-			# Insert the attachment it differs for the different TRAC versions
-			#
-			if self.VERSION > 0.8:
-				att = attachment.Attachment(self.env,'ticket',ticket['id'])
-				att.insert(url_filename,f,filesize)
-				f.close()
-			else:
-				cursor = self.db.cursor()
-				cursor.execute('INSERT INTO attachment VALUES("%s","%s","%s",%d,%d,"%s","%s","%s")' 
-					%('ticket', urllib.quote(str(ticket['id'])), filename + '?format=raw', filesize, 
-					  int(time.time()),'', user, 'e-mail') ) 
-				self.db.commit()
-
-
-def mkdir_p(dir, mode):
-	'''do a mkdir -p'''
-
-	arr = string.split(dir, '/')
-	path = ''
-	for part in arr:
-		path = '%s/%s' % (path, part)
-		try:
-			stats = os.stat(path)
-		except OSError:
-			os.mkdir(path, mode)
-
-
-def ReadConfig(file, name):
-	"""
-	Parse the config file
-	"""
-
-	if not os.path.isfile(file):
-		print 'File %s does not exists' %file
-		sys.exit(1)
-
-	config = ConfigParser.ConfigParser()
-	try:
-		config.read(file)
-	except ConfigParser.MissingSectionHeaderError,detail:
-		print detail
-	  	sys.exit(1)
-
-
-  	# Use given project name else use defaults
-  	#
-	if name:
-		if not config.has_section(name):
-			print "Not an valid project name: %s" %name
-			print "Valid names: %s" %config.sections()
-			sys.exit(1)
-
-		project =  dict()
-		for option in  config.options(name):
-			project[option] = config.get(name, option) 
-
-	else:
-		project = config.defaults()
-
-	return project
-
-if __name__ == '__main__':
-	# Default config file
-	#
-	configfile = '/etc/email2trac.conf'
-	# configfile = './email2trac.conf'
-	project = ''
-	component = ''
-	
-	try:
-		opts, args = getopt.getopt(sys.argv[1:], 'chf:p:', ['component=','help', 'file=', 'project='])
-	except getopt.error,detail:
-		print __doc__
-		print detail
-		sys.exit(1)
-
-	project_name = None
-	for opt,value in opts:
-		if opt in [ '-h', '--help']:
-			print __doc__
-			sys.exit(0)
-		elif opt in ['-c', '--component']:
-			component = value
-		elif opt in ['-f', '--file']:
-			configfile = value
-		elif opt in ['-p', '--project']:
-			project_name = value
-
-	settings = ReadConfig(configfile, project_name)
-	if not settings.has_key('project'):
-		print __doc__
-		print 'No project defined in config file, eg:\n\t project: /data/trac/bas'
-		sys.exit(1)
-
-	if component:
-		settings['component'] = component
-
-	if settings.has_key('trac_version'):
-		version = float(settings['trac_version'])
-	else:
-		version = trac_default_version
-
-	#debug HvB
-	#print settings
-
-	if version > 0.8:
-		from trac import attachment, config, env, ticket
-		env = env.Environment(settings['project'], create=0)
-		ticket_mod = ticket
-	else:
-		from trac import Environment, Ticket
-		env = Environment.Environment(settings['project'], create=0)
-		ticket_mod = Ticket
-		
-	tktparser = TicketEmailParser(env, settings, version)
-	tktparser.parse(sys.stdin)
-
-# EOB
Index: /emailtotracscript/trunk/email2trac.py.in
===================================================================
--- /emailtotracscript/trunk/email2trac.py.in	(revision 22)
+++ /emailtotracscript/trunk/email2trac.py.in	(revision 22)
@@ -0,0 +1,544 @@
+#!@PYTHON@
+# Copyright (C) 2002
+#
+# This file is part of the email2trac utils
+#
+# This program is free software; you can 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
+#
+"""
+emailfilter.py -- Email tickets to Trac.
+
+A simple MTA filter to create Trac tickets from inbound emails.
+
+Copyright 2005, Daniel Lundin <daniel@edgewall.com>
+Copyright 2005, Edgewall Software
+
+Changed By: Bas van der Vlies <basv@sara.nl>
+Date      : 13 September 2005
+Descr.    : Added config file and command line options, spam level
+            detection, reply address and mailto option. Unicode support
+
+Changed By: Walter de Jong <walter@sara.nl>
+Descr.    : multipart-message code and trac attachments
+
+
+The scripts reads emails from stdin and inserts directly into a Trac database.
+MIME headers are mapped as follows:
+
+	* From:      => Reporter
+	             => CC (Optional via reply_address option)
+	* Subject:   => Summary
+	* Body       => Description
+	* Component  => Can be set to SPAM via spam_level option
+
+How to use
+----------
+ * Create an config file:
+	[DEFAULT]                        # REQUIRED
+	project      : /data/trac/test   # REQUIRED
+	debug        : 1                 # OPTIONAL, if set print some DEBUG info
+	spam_level   : 4                 # OPTIONAL, if set check for SPAM mail 
+	reply_address: 1                 # OPTIONAL, if set then fill in ticket CC field
+        umask        : 022               # OPTIONAL, if set then use this umask for creation of the attachments
+	mailto_link  : 1                 # OPTIONAL, if set then [mailto:<CC>] in description 
+	trac_version : 0.8               # OPTIONAL, default is 0.9
+
+	[jouvin]                         # OPTIONAL project declaration, if set both fields necessary
+	project      : /data/trac/jouvin # use -p|--project jouvin.  
+        
+ * default config file is : /etc/email2trac.conf
+
+ * Commandline opions:
+                -h | --help
+                -c <value> | --component=<value>
+                -f <config file> | --file=<config file>
+                -p <project name> | --project=<project name>
+
+SVN Info:
+        $Id$
+"""
+
+import os
+import sys
+import string
+import getopt
+import stat
+import time
+import email
+import re
+import urllib
+import unicodedata
+import ConfigParser
+from email import Header
+from stat import *
+import mimetypes
+
+trac_default_version = 0.9
+
+class TicketEmailParser(object):
+	env = None
+	comment = '> '
+    
+	def __init__(self, env, parameters, version):
+		self.env = env
+
+		# Database connection
+		#
+		self.db = None
+
+		self.VERSION = version
+		if self.VERSION > 0.8:
+			self.new_ticket = ticket.Ticket
+			self.get_config = self.env.config.get
+		else:
+			self.new_ticket = Ticket.Ticket
+			self.get_config = self.env.get_config
+
+		if parameters.has_key('umask'):
+			os.umask(int(parameters['umask'], 8))
+
+		if parameters.has_key('debug'):
+			self.DEBUG = int(parameters['debug'])
+		else:
+			self.DEBUG = 0
+
+		if parameters.has_key('reply_address'):
+			self.CC = int(parameters['reply_address'])
+		else:
+			self.CC = 0
+
+		if parameters.has_key('mailto_link'):
+			self.MAILTO = int(parameters['mailto_link'])
+		else:
+			self.MAILTO = 0
+
+		if parameters.has_key('spam_level'):
+			self.SPAM_LEVEL = int(parameters['spam_level'])
+		else:
+			self.SPAM_LEVEL = 0
+
+		if parameters.has_key('email_comment'):
+			self.comment = str(parameters['email_comment'])
+
+		if parameters.has_key('email_header'):
+			self.EMAIL_HEADER = int(parameters['email_header'])
+		else:
+			self.EMAIL_HEADER = 0
+
+
+	# X-Spam-Score: *** (3.255) BAYES_50,DNS_FROM_AHBL_RHSBL,HTML_
+	# Note if Spam_level then '*' are included
+	def spam(self, message):
+		if message.has_key('X-Spam-Score'):
+			spam_l = string.split(message['X-Spam-Score'])
+			number = spam_l[0].count('*')
+
+			if number >= self.SPAM_LEVEL:
+				return number
+
+		return 0
+
+	def to_unicode(self, str):
+		"""
+		Email has 7 bit ASCII code, convert it to unicode with the charset
+		that is encoded in 7-bit ASCII code and encode it as utf-8 so TRAC 
+		understands it.
+		"""
+		results =  Header.decode_header(str)
+		str = None
+		for text,format in results:
+			if format:
+				try:
+					temp = unicode(text, format)
+				except UnicodeError:
+					# This always works 
+					#
+					temp = unicode(text, 'iso-8859-15')
+				temp =  temp.encode('utf-8')
+			else:
+				temp = string.strip(text)
+
+			if str:
+				str = '%s %s' %(str, temp)
+			else:
+				str = temp
+
+		return str
+
+	def debug_attachments(self, message):
+		n = 0
+		for part in message.walk():
+			if part.get_content_maintype() == 'multipart':      # multipart/* is just a container
+				print 'TD: multipart container'
+				continue
+
+			n = n + 1
+			print 'TD: part%d: Content-Type: %s' % (n, part.get_content_type())
+			print 'TD: part%d: filename: %s' % (n, part.get_filename())
+
+			if part.is_multipart():
+				print 'TD: this part is multipart'
+				payload = part.get_payload(decode=1)
+				print 'TD: payload:', payload
+			else:
+				print 'TD: this part is not multipart'
+
+			part_file = '/var/tmp/part%d' % n
+			print 'TD: writing part%d (%s)' % (n,part_file)
+			fx = open(part_file, 'wb')
+			text = part.get_payload(decode=1)
+			if not text:
+				text = '(None)'
+			fx.write(text)
+			fx.close()
+			try:
+				os.chmod(part_file,S_IRWXU|S_IRWXG|S_IRWXO)
+			except OSError:
+				pass
+
+	def email_header_txt(self, m):
+#		if not m['Subject']:
+#			subject = '(geen subject)'
+#		else:
+#			subject = self.to_unicode(m['Subject'])
+#
+#		head = "'''Subject:''' %s [[BR]]" % subject
+#		if m['From'] and len(m['From']) > 0:
+#			head = "%s'''From:''' %s [[BR]]" % (head, m['From'])
+#		if m['Date'] and len(m['Date']) > 0:
+#			head = "%s'''Date:''' %s [[BR]]" %(head, m['Date'])
+
+		str = ''
+		if m['To'] and len(m['To']) > 0 and m['To'] != 'hic@sara.nl':
+			str = "'''To:''' %s [[BR]]" %(m['To'])
+		if m['Cc'] and len(m['Cc']) > 0:
+			str = "%s'''Cc:''' %s [[BR]]" % (str, m['Cc'])
+
+		return str
+
+	def parse(self, fp):
+		msg = email.message_from_file(fp)
+		if not msg:
+			return
+
+		if self.DEBUG > 1:	  # save the entire e-mail message text
+			msg_file = '/var/tmp/msg.txt' 
+			print 'TD: saving email to %s' % msg_file
+			fx = open(msg_file, 'wb')
+			fx.write('%s' % msg)
+			fx.close()
+			try:
+				os.chmod(msg_file,S_IRWXU|S_IRWXG|S_IRWXO)
+			except OSError:
+				pass
+
+		self.db = self.env.get_db_cnx()
+		tkt = self.new_ticket(self.env)
+		tkt['status'] = 'new'
+
+		# Some defaults
+		#
+		tkt['milestone'] = self.get_config('ticket', 'default_milestone')
+		tkt['priority'] = self.get_config('ticket', 'default_priority')
+		tkt['severity'] = self.get_config('ticket', 'default_severity')
+		tkt['version'] = self.get_config('ticket', 'default_version')
+
+		if not msg['Subject']:
+			tkt['summary'] = '(geen subject)'
+		else:
+			tkt['summary'] = self.to_unicode(msg['Subject'])
+
+		if self.SPAM_LEVEL and self.spam(msg):
+			print 'This message is a SPAM. Automatic ticket insertion refused (SPAM level > %d' % self.SPAM_LEVEL
+			sys.exit(1)
+
+		if settings.has_key('component'):
+			tkt['component'] = settings['component']
+		else:
+			tkt['component'] = self.get_config('ticket', 'default_component')
+
+		# Get default owner for component
+		#
+		cursor = self.db.cursor()
+		sql = 'SELECT owner FROM component WHERE name=\'%s\'' % tkt['component']
+		cursor.execute(sql)
+		tkt['owner'] = cursor.fetchone()[0]
+
+		from_str = self.to_unicode(msg['from'])
+		tkt['reporter'] = from_str
+		if self.CC:
+			tkt['cc'] = from_str
+
+# produce e-mail like header
+		head = ''
+		if self.EMAIL_HEADER > 0:
+			head = self.email_header_txt(msg)
+
+		if self.DEBUG > 0:
+			self.debug_attachments(msg)
+
+#
+#	put the message text in the ticket description
+#	message text can be plain text or html or something else
+#
+		has_description = 0
+		for part in msg.walk():
+			if part.get_content_maintype() == 'multipart':			# 'multipart/*' is a container for multipart messages
+				continue
+
+			if part.get_content_type() == 'text/plain':
+				body_text = part.get_payload(decode=1)			# try to decode
+				if not body_text:					# decode failed
+					body_text = part.get_payload(decode=0)		# do not decode
+
+				tkt['description'] = '\n{{{\n\n%s\n}}}\n' % body_text
+
+			elif part.get_content_type() == 'text/html':
+				tkt['description'] = '%s\n\n(see attachment for HTML mail message)\n' % head
+				body_text = tkt['description']
+
+			else:
+				tkt['description'] = '%s\n\n(see attachment for message)\n' % head
+				body_text = tkt['description']
+
+			has_description = 1
+			break		# we have the description, so break
+
+		if not has_description:
+			tkt['description'] = '%s\n\n(no plain text message, see attachments)' % head
+			has_description = 1
+
+		author, email_addr  = email.Utils.parseaddr(msg['from'])
+		if self.MAILTO:
+			mailto = self.html_mailto_link(author, email_addr, self.to_unicode(msg['subject']), body_text)
+			tkt['description'] = '%s\n%s %s' %(head, mailto, tkt['description'])
+
+		if self.VERSION > 0.8:
+			tkt['id'] = tkt.insert()
+		else:
+			tkt['id'] = tkt.insert(self.db)
+
+		#
+		# Just how to show to update description
+		#
+		#tkt['description'] = '\n{{{\n\n Bas is op nieuw bezig\n\n }}}\n' 
+		#tkt.save_changes(self.db, author, "Lekker bezig")
+		#
+		self.attachments(msg, tkt, author)
+
+
+	def mail_line(self, str):
+		return '%s %s' % (self.comment, str)
+
+
+	def html_mailto_link(self, author, mail_addr, subject, body):
+		if not author:
+			author = mail_addr
+		else:	
+			author = self.to_unicode(author)
+
+		# Must find a fix
+		#
+		#arr = string.split(body, '\n')
+		#arr = map(self.mail_line, arr)
+
+		#body = string.join(arr, '\n')
+		#body = '%s wrote:\n%s' %(author, body)
+
+		# Obsolete for reference
+		#
+		#body = self.to_unicode(body)
+		#body = urllib.quote(body)
+		#body = Header.encode(body)
+		#
+
+		# Temporary fix
+		body = '> Type your reply'
+		str = 'mailto:%s?subject=%s&body=%s' % (urllib.quote(mail_addr), urllib.quote('Re: %s' % subject), urllib.quote(body))
+		str = '\n{{{\n#!html\n<a href="%s">Reply to: %s</a>\n}}}\n' %(str, author)
+
+		return str
+
+	def attachments(self, message, ticket, user):
+		'''save any attachments as file in the ticket's directory'''
+
+		count = 0
+		first = 0
+		for part in message.walk():
+			if part.get_content_maintype() == 'multipart':		# multipart/* is just a container
+				continue
+
+			if not first:										# first content is the message
+				first = 1
+				if part.get_content_type() == 'text/plain':		# if first is text, is was already put in the description
+					continue
+
+			filename = part.get_filename() 
+			if not filename:
+				count = count + 1
+				filename = 'part%04d' % count
+
+				ext = mimetypes.guess_extension(part.get_type())
+				if not ext:
+					ext = '.bin'
+
+				filename = '%s%s' % (filename, ext)
+			else:
+				filename = self.to_unicode(filename)
+
+			if '/' in filename:
+				filename = os.path.basename(filename)
+
+			url_filename = urllib.quote(filename)
+
+			if self.VERSION > 0.8:
+				tmpfile = '/tmp/email2trac-ticket%sattachment' % str(ticket['id'])
+			else:
+				dir = os.path.join(self.env.get_attachments_dir(), 'ticket', 
+				                    	urllib.quote(str(ticket['id'])))
+				if not os.path.exists(dir):
+					mkdir_p(dir, 0755)
+
+				tmpfile = os.path.join(dir, url_filename)
+
+			f = open(tmpfile, 'wb')
+			text = part.get_payload(decode=1)
+			if not text:
+				text = '(None)'
+			f.write(text)
+
+			# get the filesize
+			#
+			stats = os.lstat(tmpfile) 
+			filesize = stats[stat.ST_SIZE]
+
+			# Insert the attachment it differs for the different TRAC versions
+			#
+			if self.VERSION > 0.8:
+				att = attachment.Attachment(self.env,'ticket',ticket['id'])
+				att.insert(url_filename,f,filesize)
+				f.close()
+			else:
+				cursor = self.db.cursor()
+				cursor.execute('INSERT INTO attachment VALUES("%s","%s","%s",%d,%d,"%s","%s","%s")' 
+					%('ticket', urllib.quote(str(ticket['id'])), filename + '?format=raw', filesize, 
+					  int(time.time()),'', user, 'e-mail') ) 
+				self.db.commit()
+
+
+def mkdir_p(dir, mode):
+	'''do a mkdir -p'''
+
+	arr = string.split(dir, '/')
+	path = ''
+	for part in arr:
+		path = '%s/%s' % (path, part)
+		try:
+			stats = os.stat(path)
+		except OSError:
+			os.mkdir(path, mode)
+
+
+def ReadConfig(file, name):
+	"""
+	Parse the config file
+	"""
+
+	if not os.path.isfile(file):
+		print 'File %s does not exists' %file
+		sys.exit(1)
+
+	config = ConfigParser.ConfigParser()
+	try:
+		config.read(file)
+	except ConfigParser.MissingSectionHeaderError,detail:
+		print detail
+	  	sys.exit(1)
+
+
+  	# Use given project name else use defaults
+  	#
+	if name:
+		if not config.has_section(name):
+			print "Not an valid project name: %s" %name
+			print "Valid names: %s" %config.sections()
+			sys.exit(1)
+
+		project =  dict()
+		for option in  config.options(name):
+			project[option] = config.get(name, option) 
+
+	else:
+		project = config.defaults()
+
+	return project
+
+if __name__ == '__main__':
+	# Default config file
+	#
+	configfile = '/etc/email2trac.conf'
+	# configfile = './email2trac.conf'
+	project = ''
+	component = ''
+	
+	try:
+		opts, args = getopt.getopt(sys.argv[1:], 'chf:p:', ['component=','help', 'file=', 'project='])
+	except getopt.error,detail:
+		print __doc__
+		print detail
+		sys.exit(1)
+
+	project_name = None
+	for opt,value in opts:
+		if opt in [ '-h', '--help']:
+			print __doc__
+			sys.exit(0)
+		elif opt in ['-c', '--component']:
+			component = value
+		elif opt in ['-f', '--file']:
+			configfile = value
+		elif opt in ['-p', '--project']:
+			project_name = value
+
+	settings = ReadConfig(configfile, project_name)
+	if not settings.has_key('project'):
+		print __doc__
+		print 'No project defined in config file, eg:\n\t project: /data/trac/bas'
+		sys.exit(1)
+
+	if component:
+		settings['component'] = component
+
+	if settings.has_key('trac_version'):
+		version = float(settings['trac_version'])
+	else:
+		version = trac_default_version
+
+	#debug HvB
+	#print settings
+
+	if version > 0.8:
+		from trac import attachment, config, env, ticket
+		env = env.Environment(settings['project'], create=0)
+		ticket_mod = ticket
+	else:
+		from trac import Environment, Ticket
+		env = Environment.Environment(settings['project'], create=0)
+		ticket_mod = Ticket
+		
+	tktparser = TicketEmailParser(env, settings, version)
+	tktparser.parse(sys.stdin)
+
+# EOB
