Templatize sieve rules editor; return success/fail state of serverwrite
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 2 Jul 2011 21:10:16 +0000 (21:10 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:20:03 +0000 (21:20 +0000)
 - return status of sending stuff to citserver, so we can abort loops in time if our connection dies.
 - add sieve scripts lists with content to the session for one request
 - add hooks for listing sieve scripts and their contents
 - add parser for our webcit embedded sieve editor
 - add hooks for our webcit embedded sieve editor
 - add templates with the contents from sieve.c

17 files changed:
webcit/config.guess
webcit/config.sub
webcit/sieve.c
webcit/static/t/sieve/add.html [new file with mode: 0644]
webcit/static/t/sieve/display.html [new file with mode: 0644]
webcit/static/t/sieve/display_one.html [new file with mode: 0644]
webcit/static/t/sieve/display_one_script.html [new file with mode: 0644]
webcit/static/t/sieve/empty.html [new file with mode: 0644]
webcit/static/t/sieve/list.html [new file with mode: 0644]
webcit/static/t/sieve/list_select_one.html [new file with mode: 0644]
webcit/static/t/sieve/none.html [new file with mode: 0644]
webcit/static/t/sieve/roomlist.html [new file with mode: 0644]
webcit/static/t/sieve/script_select.html [new file with mode: 0644]
webcit/subst.c
webcit/subst.h
webcit/tcp_sockets.c
webcit/webcit.h

index c2246a4f7f4c78281ccfc4238a54cf7d83c4f421..40eaed4821ec09567afae2b5e90cdc7aa2a55082 100755 (executable)
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #! /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, 2010
-#   Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+#   2011 Free Software Foundation, Inc.
 
 
-timestamp='2009-12-30'
+timestamp='2011-05-11'
 
 # 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
 
 # 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
@@ -57,7 +57,7 @@ GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
 
 Originally written by Per Bothner.
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
 Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -181,7 +181,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                fi
                ;;
            *)
                fi
                ;;
            *)
-               os=netbsd
+               os=netbsd
                ;;
        esac
        # The OS release
                ;;
        esac
        # The OS release
@@ -224,7 +224,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
                ;;
        *5.*)
                UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
                ;;
        *5.*)
-               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
                ;;
        esac
        # According to Compaq, /usr/sbin/psrinfo has been available on
                ;;
        esac
        # According to Compaq, /usr/sbin/psrinfo has been available on
@@ -270,7 +270,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        # 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'`
        # 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 ;;
+       # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+       exitcode=$?
+       trap '' 0
+       exit $exitcode ;;
     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
     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
@@ -296,7 +299,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        echo s390-ibm-zvmoe
        exit ;;
     *:OS400:*:*)
        echo s390-ibm-zvmoe
        exit ;;
     *:OS400:*:*)
-        echo powerpc-ibm-os400
+       echo powerpc-ibm-os400
        exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
        echo arm-acorn-riscix${UNAME_RELEASE}
        exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
        echo arm-acorn-riscix${UNAME_RELEASE}
@@ -395,23 +398,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
     # 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}
+       echo m68k-atari-mint${UNAME_RELEASE}
        exit ;;
     atari*:*MiNT:*:* | atari*:*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 ;;
+       exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
+       echo m68k-atari-mint${UNAME_RELEASE}
        exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
        exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
+       echo m68k-milan-mint${UNAME_RELEASE}
+       exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
+       echo m68k-hades-mint${UNAME_RELEASE}
+       exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
+       echo m68k-unknown-mint${UNAME_RELEASE}
+       exit ;;
     m68k:machten:*:*)
        echo m68k-apple-machten${UNAME_RELEASE}
        exit ;;
     m68k:machten:*:*)
        echo m68k-apple-machten${UNAME_RELEASE}
        exit ;;
@@ -481,8 +484,8 @@ EOF
        echo m88k-motorola-sysv3
        exit ;;
     AViiON:dgux:*:*)
        echo m88k-motorola-sysv3
        exit ;;
     AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       # 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 ] || \
        if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
        then
            if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -495,7 +498,7 @@ EOF
        else
            echo i586-dg-dgux${UNAME_RELEASE}
        fi
        else
            echo i586-dg-dgux${UNAME_RELEASE}
        fi
-       exit ;;
+       exit ;;
     M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
        echo m88k-dolphin-sysv3
        exit ;;
     M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
        echo m88k-dolphin-sysv3
        exit ;;
@@ -552,7 +555,7 @@ EOF
                echo rs6000-ibm-aix3.2
        fi
        exit ;;
                echo rs6000-ibm-aix3.2
        fi
        exit ;;
-    *:AIX:*:[456])
+    *:AIX:*:[4567])
        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
        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
@@ -595,52 +598,52 @@ EOF
            9000/[678][0-9][0-9])
                if [ -x /usr/bin/getconf ]; then
                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
            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" ;;
+                   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
                          '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
+                       esac ;;
+                   esac
                fi
                if [ "${HP_ARCH}" = "" ]; then
                    eval $set_cc_for_build
                fi
                if [ "${HP_ARCH}" = "" ]; then
                    eval $set_cc_for_build
-                   sed 's/^              //' << EOF >$dummy.c
+                   sed 's/^            //' << EOF >$dummy.c
 
 
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
+               #define _HPUX_SOURCE
+               #include <stdlib.h>
+               #include <unistd.h>
 
 
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
+               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);
-              }
+                   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
 EOF
                    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
                    test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -731,22 +734,22 @@ EOF
        exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
        echo c1-convex-bsd
        exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
        echo c1-convex-bsd
-        exit ;;
+       exit ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
        if getsysinfo -f scalar_acc
        then echo c32-convex-bsd
        else echo c2-convex-bsd
        fi
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
        if getsysinfo -f scalar_acc
        then echo c32-convex-bsd
        else echo c2-convex-bsd
        fi
-        exit ;;
+       exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
        echo c34-convex-bsd
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
        echo c34-convex-bsd
-        exit ;;
+       exit ;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
        echo c38-convex-bsd
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
        echo c38-convex-bsd
-        exit ;;
+       exit ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
        echo c4-convex-bsd
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
        echo c4-convex-bsd
-        exit ;;
+       exit ;;
     CRAY*Y-MP:*:*:*)
        echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*Y-MP:*:*:*)
        echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
        exit ;;
@@ -770,14 +773,14 @@ EOF
        exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
        FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
        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 ;;
+       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.*:*)
     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}"
+       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 ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
        echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@@ -805,14 +808,14 @@ EOF
        echo ${UNAME_MACHINE}-pc-mingw32
        exit ;;
     i*:windows32*:*)
        echo ${UNAME_MACHINE}-pc-mingw32
        exit ;;
     i*:windows32*:*)
-       # uname -m includes "-pc" on this system.
-       echo ${UNAME_MACHINE}-mingw32
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
        exit ;;
     i*:PW*:*)
        echo ${UNAME_MACHINE}-pc-pw32
        exit ;;
     *:Interix*:*)
        exit ;;
     i*:PW*:*)
        echo ${UNAME_MACHINE}-pc-pw32
        exit ;;
     *:Interix*:*)
-       case ${UNAME_MACHINE} in
+       case ${UNAME_MACHINE} in
            x86)
                echo i586-pc-interix${UNAME_RELEASE}
                exit ;;
            x86)
                echo i586-pc-interix${UNAME_RELEASE}
                exit ;;
@@ -867,7 +870,7 @@ EOF
          EV6)   UNAME_MACHINE=alphaev6 ;;
          EV67)  UNAME_MACHINE=alphaev67 ;;
          EV68*) UNAME_MACHINE=alphaev68 ;;
          EV6)   UNAME_MACHINE=alphaev6 ;;
          EV67)  UNAME_MACHINE=alphaev67 ;;
          EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
+       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}
        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}
@@ -879,7 +882,13 @@ EOF
        then
            echo ${UNAME_MACHINE}-unknown-linux-gnu
        else
        then
            echo ${UNAME_MACHINE}-unknown-linux-gnu
        else
-           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+           if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+               | grep -q __ARM_PCS_VFP
+           then
+               echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+           else
+               echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+           fi
        fi
        exit ;;
     avr32*:Linux:*:*)
        fi
        exit ;;
     avr32*:Linux:*:*)
@@ -892,7 +901,7 @@ EOF
        echo crisv32-axis-linux-gnu
        exit ;;
     frv:Linux:*:*)
        echo crisv32-axis-linux-gnu
        exit ;;
     frv:Linux:*:*)
-       echo frv-unknown-linux-gnu
+       echo frv-unknown-linux-gnu
        exit ;;
     i*86:Linux:*:*)
        LIBC=gnu
        exit ;;
     i*86:Linux:*:*)
        LIBC=gnu
@@ -960,7 +969,7 @@ EOF
        echo ${UNAME_MACHINE}-ibm-linux
        exit ;;
     sh64*:Linux:*:*)
        echo ${UNAME_MACHINE}-ibm-linux
        exit ;;
     sh64*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
        exit ;;
     sh*:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
        exit ;;
     sh*:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -968,6 +977,9 @@ EOF
     sparc:Linux:*:* | sparc64:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
        exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
        exit ;;
+    tile*:Linux:*:*)
+       echo ${UNAME_MACHINE}-tilera-linux-gnu
+       exit ;;
     vax:Linux:*:*)
        echo ${UNAME_MACHINE}-dec-linux-gnu
        exit ;;
     vax:Linux:*:*)
        echo ${UNAME_MACHINE}-dec-linux-gnu
        exit ;;
@@ -975,7 +987,7 @@ EOF
        echo x86_64-unknown-linux-gnu
        exit ;;
     xtensa*:Linux:*:*)
        echo x86_64-unknown-linux-gnu
        exit ;;
     xtensa*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
        exit ;;
     i*86:DYNIX/ptx:4*:*)
        # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
        exit ;;
     i*86:DYNIX/ptx:4*:*)
        # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -984,11 +996,11 @@ EOF
        echo i386-sequent-sysv4
        exit ;;
     i*86:UNIX_SV:4.2MP:2.*)
        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,
+       # 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.
        # I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
+       # Use sysv4.2uw... so that sysv4* matches it.
        echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
        exit ;;
     i*86:OS/2:*:*)
        echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
        exit ;;
     i*86:OS/2:*:*)
@@ -1020,7 +1032,7 @@ EOF
        fi
        exit ;;
     i*86:*:5:[678]*)
        fi
        exit ;;
     i*86:*:5:[678]*)
-       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
        case `/bin/uname -X | grep "^Machine"` in
            *486*)           UNAME_MACHINE=i486 ;;
            *Pentium)        UNAME_MACHINE=i586 ;;
        case `/bin/uname -X | grep "^Machine"` in
            *486*)           UNAME_MACHINE=i486 ;;
            *Pentium)        UNAME_MACHINE=i586 ;;
@@ -1048,13 +1060,13 @@ EOF
        exit ;;
     pc:*:*:*)
        # Left here for compatibility:
        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.
+       # 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
        # 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 ;;
+       exit ;;
     Intel:Mach:3*:*)
        echo i386-pc-mach3
        exit ;;
     Intel:Mach:3*:*)
        echo i386-pc-mach3
        exit ;;
@@ -1089,8 +1101,8 @@ EOF
        /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 | /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; } ;;
+       /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 \
     NCR*:*:4.2:* | MPRAS*:*:4.2:*)
        OS_REL='.3'
        test -r /etc/.relid \
@@ -1133,10 +1145,10 @@ EOF
                echo ns32k-sni-sysv
        fi
        exit ;;
                echo ns32k-sni-sysv
        fi
        exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel@ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
+    PENTIUM:*:4.0*:*)  # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                       # says <Richard.M.Bartel@ccMail.Census.GOV>
+       echo i586-unisys-sysv4
+       exit ;;
     *:UNIX_System_V:4*:FTX*)
        # From Gerald Hewes <hewes@openmarket.com>.
        # How about differentiating between stratus architectures? -djm
     *:UNIX_System_V:4*:FTX*)
        # From Gerald Hewes <hewes@openmarket.com>.
        # How about differentiating between stratus architectures? -djm
@@ -1162,11 +1174,11 @@ EOF
        exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
        if [ -d /usr/nec ]; then
        exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
        if [ -d /usr/nec ]; then
-               echo mips-nec-sysv${UNAME_RELEASE}
+               echo mips-nec-sysv${UNAME_RELEASE}
        else
        else
-               echo mips-unknown-sysv${UNAME_RELEASE}
+               echo mips-unknown-sysv${UNAME_RELEASE}
        fi
        fi
-        exit ;;
+       exit ;;
     BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
        echo powerpc-be-beos
        exit ;;
     BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
        echo powerpc-be-beos
        exit ;;
@@ -1231,6 +1243,9 @@ EOF
     *:QNX:*:4*)
        echo i386-pc-qnx
        exit ;;
     *:QNX:*:4*)
        echo i386-pc-qnx
        exit ;;
+    NEO-?:NONSTOP_KERNEL:*:*)
+       echo neo-tandem-nsk${UNAME_RELEASE}
+       exit ;;
     NSE-?:NONSTOP_KERNEL:*:*)
        echo nse-tandem-nsk${UNAME_RELEASE}
        exit ;;
     NSE-?:NONSTOP_KERNEL:*:*)
        echo nse-tandem-nsk${UNAME_RELEASE}
        exit ;;
@@ -1276,13 +1291,13 @@ EOF
        echo pdp10-unknown-its
        exit ;;
     SEI:*:*:SEIUX)
        echo pdp10-unknown-its
        exit ;;
     SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
+       echo mips-sei-seiux${UNAME_RELEASE}
        exit ;;
     *:DragonFly:*:*)
        echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
        exit ;;
     *:*VMS:*:*)
        exit ;;
     *:DragonFly:*:*)
        echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
        exit ;;
     *:*VMS:*:*)
-       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
        case "${UNAME_MACHINE}" in
            A*) echo alpha-dec-vms ; exit ;;
            I*) echo ia64-dec-vms ; exit ;;
        case "${UNAME_MACHINE}" in
            A*) echo alpha-dec-vms ; exit ;;
            I*) echo ia64-dec-vms ; exit ;;
@@ -1322,11 +1337,11 @@ main ()
 #include <sys/param.h>
   printf ("m68k-sony-newsos%s\n",
 #ifdef NEWSOS4
 #include <sys/param.h>
   printf ("m68k-sony-newsos%s\n",
 #ifdef NEWSOS4
-          "4"
+       "4"
 #else
 #else
-         ""
+       ""
 #endif
 #endif
-         ); exit (0);
+       ); exit (0);
 #endif
 #endif
 
 #endif
 #endif
 
index c2d125724c0ed2d2c6da5308c54567649554e5f3..30fdca81215f7b8a3e71430dc026507740b2c900 100755 (executable)
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #! /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, 2010
-#   Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+#   2011 Free Software Foundation, Inc.
 
 
-timestamp='2010-01-22'
+timestamp='2011-03-23'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -76,7 +76,7 @@ version="\
 GNU config.sub ($timestamp)
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
 GNU config.sub ($timestamp)
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
 Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -124,8 +124,9 @@ esac
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
 # 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* | \
+  nto-qnx* | linux-gnu* | linux-android* | 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
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
@@ -157,8 +158,8 @@ case $os in
                os=
                basic_machine=$1
                ;;
                os=
                basic_machine=$1
                ;;
-        -bluegene*)
-               os=-cnk
+       -bluegene*)
+               os=-cnk
                ;;
        -sim | -cisco | -oki | -wec | -winbond)
                os=
                ;;
        -sim | -cisco | -oki | -wec | -winbond)
                os=
@@ -174,10 +175,10 @@ case $os in
                os=-chorusos
                basic_machine=$1
                ;;
                os=-chorusos
                basic_machine=$1
                ;;
-       -chorusrdb)
-               os=-chorusrdb
+       -chorusrdb)
+               os=-chorusrdb
                basic_machine=$1
                basic_machine=$1
-               ;;
+               ;;
        -hiux*)
                os=-hiuxwe2
                ;;
        -hiux*)
                os=-hiuxwe2
                ;;
@@ -282,11 +283,13 @@ case $basic_machine in
        | moxie \
        | mt \
        | msp430 \
        | moxie \
        | mt \
        | msp430 \
+       | nds32 | nds32le | nds32be \
        | nios | nios2 \
        | ns16k | ns32k \
        | nios | nios2 \
        | ns16k | ns32k \
+       | open8 \
        | or32 \
        | pdp10 | pdp11 | pj | pjl \
        | or32 \
        | pdp10 | pdp11 | pj | pjl \
-       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | powerpc | powerpc64 | powerpc64le | powerpcle \
        | pyramid \
        | rx \
        | score \
        | pyramid \
        | rx \
        | score \
@@ -294,15 +297,24 @@ case $basic_machine in
        | sh64 | sh64le \
        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
        | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
        | sh64 | sh64le \
        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
        | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-       | spu | strongarm \
-       | tahoe | thumb | tic4x | tic80 | tron \
+       | spu \
+       | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
        | ubicom32 \
        | v850 | v850e \
        | we32k \
        | ubicom32 \
        | v850 | v850e \
        | we32k \
-       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | x86 | xc16x | xstormy16 | xtensa \
        | z8k | z80)
                basic_machine=$basic_machine-unknown
                ;;
        | z8k | z80)
                basic_machine=$basic_machine-unknown
                ;;
+       c54x)
+               basic_machine=tic54x-unknown
+               ;;
+       c55x)
+               basic_machine=tic55x-unknown
+               ;;
+       c6x)
+               basic_machine=tic6x-unknown
+               ;;
        m6811 | m68hc11 | m6812 | m68hc12 | picochip)
                # Motorola 68HC11/12.
                basic_machine=$basic_machine-unknown
        m6811 | m68hc11 | m6812 | m68hc12 | picochip)
                # Motorola 68HC11/12.
                basic_machine=$basic_machine-unknown
@@ -314,6 +326,18 @@ case $basic_machine in
                basic_machine=mt-unknown
                ;;
 
                basic_machine=mt-unknown
                ;;
 
+       strongarm | thumb | xscale)
+               basic_machine=arm-unknown
+               ;;
+
+       xscaleeb)
+               basic_machine=armeb-unknown
+               ;;
+
+       xscaleel)
+               basic_machine=armel-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.
        # We use `pc' rather than `unknown'
        # because (1) that's what they normally are, and
        # (2) the word "unknown" tends to confuse beginning users.
@@ -334,7 +358,7 @@ case $basic_machine in
        | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
        | avr-* | avr32-* \
        | bfin-* | bs2000-* \
        | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
        | avr-* | avr32-* \
        | bfin-* | bs2000-* \
-       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* \
        | clipper-* | craynv-* | cydra-* \
        | d10v-* | d30v-* | dlx-* \
        | elxsi-* \
        | clipper-* | craynv-* | cydra-* \
        | d10v-* | d30v-* | dlx-* \
        | elxsi-* \
@@ -368,26 +392,28 @@ case $basic_machine in
        | mmix-* \
        | mt-* \
        | msp430-* \
        | mmix-* \
        | mt-* \
        | msp430-* \
+       | nds32-* | nds32le-* | nds32be-* \
        | nios-* | nios2-* \
        | none-* | np1-* | ns16k-* | ns32k-* \
        | nios-* | nios2-* \
        | none-* | np1-* | ns16k-* | ns32k-* \
+       | open8-* \
        | orion-* \
        | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
        | orion-* \
        | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
        | 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-* \
        | 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-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+       | tahoe-* \
        | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
        | tile-* | tilegx-* \
        | tron-* \
        | ubicom32-* \
        | v850-* | v850e-* | vax-* \
        | we32k-* \
        | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
        | tile-* | tilegx-* \
        | tron-* \
        | ubicom32-* \
        | v850-* | v850e-* | vax-* \
        | we32k-* \
-       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* \
        | xstormy16-* | xtensa*-* \
        | ymp-* \
        | z8k-* | z80-*)
        | xstormy16-* | xtensa*-* \
        | ymp-* \
        | z8k-* | z80-*)
@@ -412,7 +438,7 @@ case $basic_machine in
                basic_machine=a29k-amd
                os=-udi
                ;;
                basic_machine=a29k-amd
                os=-udi
                ;;
-       abacus)
+       abacus)
                basic_machine=abacus-unknown
                ;;
        adobe68k)
                basic_machine=abacus-unknown
                ;;
        adobe68k)
@@ -482,11 +508,20 @@ case $basic_machine in
                basic_machine=powerpc-ibm
                os=-cnk
                ;;
                basic_machine=powerpc-ibm
                os=-cnk
                ;;
+       c54x-*)
+               basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       c55x-*)
+               basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       c6x-*)
+               basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
        c90)
                basic_machine=c90-cray
                os=-unicos
                ;;
        c90)
                basic_machine=c90-cray
                os=-unicos
                ;;
-        cegcc)
+       cegcc)
                basic_machine=arm-unknown
                os=-cegcc
                ;;
                basic_machine=arm-unknown
                os=-cegcc
                ;;
@@ -518,7 +553,7 @@ case $basic_machine in
                basic_machine=craynv-cray
                os=-unicosmp
                ;;
                basic_machine=craynv-cray
                os=-unicosmp
                ;;
-       cr16)
+       cr16 | cr16-*)
                basic_machine=cr16-unknown
                os=-elf
                ;;
                basic_machine=cr16-unknown
                os=-elf
                ;;
@@ -734,7 +769,7 @@ case $basic_machine in
                basic_machine=ns32k-utek
                os=-sysv
                ;;
                basic_machine=ns32k-utek
                os=-sysv
                ;;
-        microblaze)
+       microblaze)
                basic_machine=microblaze-xilinx
                ;;
        mingw32)
                basic_machine=microblaze-xilinx
                ;;
        mingw32)
@@ -841,6 +876,12 @@ case $basic_machine in
        np1)
                basic_machine=np1-gould
                ;;
        np1)
                basic_machine=np1-gould
                ;;
+       neo-tandem)
+               basic_machine=neo-tandem
+               ;;
+       nse-tandem)
+               basic_machine=nse-tandem
+               ;;
        nsr-tandem)
                basic_machine=nsr-tandem
                ;;
        nsr-tandem)
                basic_machine=nsr-tandem
                ;;
@@ -923,9 +964,10 @@ case $basic_machine in
                ;;
        power)  basic_machine=power-ibm
                ;;
                ;;
        power)  basic_machine=power-ibm
                ;;
-       ppc)    basic_machine=powerpc-unknown
+       ppc | ppcbe)    basic_machine=powerpc-unknown
                ;;
                ;;
-       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+       ppc-* | ppcbe-*)
+               basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
                ;;
        ppcle | powerpclittle | ppc-le | powerpc-little)
                basic_machine=powerpcle-unknown
                ;;
        ppcle | powerpclittle | ppc-le | powerpc-little)
                basic_machine=powerpcle-unknown
@@ -1019,6 +1061,9 @@ case $basic_machine in
                basic_machine=i860-stratus
                os=-sysv4
                ;;
                basic_machine=i860-stratus
                os=-sysv4
                ;;
+       strongarm-* | thumb-*)
+               basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
        sun2)
                basic_machine=m68000-sun
                ;;
        sun2)
                basic_machine=m68000-sun
                ;;
@@ -1075,20 +1120,8 @@ case $basic_machine in
                basic_machine=t90-cray
                os=-unicos
                ;;
                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
-               ;;
-        # This must be matched before tile*.
-        tilegx*)
+       # This must be matched before tile*.
+       tilegx*)
                basic_machine=tilegx-unknown
                os=-linux-gnu
                ;;
                basic_machine=tilegx-unknown
                os=-linux-gnu
                ;;
@@ -1163,6 +1196,9 @@ case $basic_machine in
        xps | xps100)
                basic_machine=xps100-honeywell
                ;;
        xps | xps100)
                basic_machine=xps100-honeywell
                ;;
+       xscale-* | xscalee[bl]-*)
+               basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+               ;;
        ymp)
                basic_machine=ymp-cray
                os=-unicos
        ymp)
                basic_machine=ymp-cray
                os=-unicos
@@ -1260,11 +1296,11 @@ esac
 if [ x"$os" != x"" ]
 then
 case $os in
 if [ x"$os" != x"" ]
 then
 case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
+       # First match some system type aliases
+       # that might get confused with valid system types.
        # -solaris* is a basic system type, with this one exception.
        # -solaris* is a basic system type, with this one exception.
-        -auroraux)
-               os=-auroraux
+       -auroraux)
+               os=-auroraux
                ;;
        -solaris1 | -solaris1.*)
                os=`echo $os | sed -e 's|solaris1|sunos4|'`
                ;;
        -solaris1 | -solaris1.*)
                os=`echo $os | sed -e 's|solaris1|sunos4|'`
@@ -1301,7 +1337,8 @@ case $os in
              | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
              | -chorusos* | -chorusrdb* | -cegcc* \
              | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
              | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
              | -chorusos* | -chorusrdb* | -cegcc* \
              | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+             | -mingw32* | -linux-gnu* | -linux-android* \
+             | -linux-newlib* | -linux-uclibc* \
              | -uxpv* | -beos* | -mpeix* | -udk* \
              | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
              | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
              | -uxpv* | -beos* | -mpeix* | -udk* \
              | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
              | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@@ -1348,7 +1385,7 @@ case $os in
        -opened*)
                os=-openedition
                ;;
        -opened*)
                os=-openedition
                ;;
-        -os400*)
+       -os400*)
                os=-os400
                ;;
        -wince*)
                os=-os400
                ;;
        -wince*)
@@ -1397,7 +1434,7 @@ case $os in
        -sinix*)
                os=-sysv4
                ;;
        -sinix*)
                os=-sysv4
                ;;
-        -tpf*)
+       -tpf*)
                os=-tpf
                ;;
        -triton*)
                os=-tpf
                ;;
        -triton*)
@@ -1442,8 +1479,8 @@ case $os in
        -dicos*)
                os=-dicos
                ;;
        -dicos*)
                os=-dicos
                ;;
-        -nacl*)
-               ;;
+       -nacl*)
+               ;;
        -none)
                ;;
        *)
        -none)
                ;;
        *)
@@ -1466,10 +1503,10 @@ else
 # system, and we'll never get to this point.
 
 case $basic_machine in
 # system, and we'll never get to this point.
 
 case $basic_machine in
-        score-*)
+       score-*)
                os=-elf
                ;;
                os=-elf
                ;;
-        spu-*)
+       spu-*)
                os=-elf
                ;;
        *-acorn)
                os=-elf
                ;;
        *-acorn)
@@ -1481,8 +1518,17 @@ case $basic_machine in
        arm*-semi)
                os=-aout
                ;;
        arm*-semi)
                os=-aout
                ;;
-        c4x-* | tic4x-*)
-               os=-coff
+       c4x-* | tic4x-*)
+               os=-coff
+               ;;
+       tic54x-*)
+               os=-coff
+               ;;
+       tic55x-*)
+               os=-coff
+               ;;
+       tic6x-*)
+               os=-coff
                ;;
        # This must come before the *-dec entry.
        pdp10-*)
                ;;
        # This must come before the *-dec entry.
        pdp10-*)
@@ -1509,7 +1555,7 @@ case $basic_machine in
        m68*-cisco)
                os=-aout
                ;;
        m68*-cisco)
                os=-aout
                ;;
-        mep-*)
+       mep-*)
                os=-elf
                ;;
        mips*-cisco)
                os=-elf
                ;;
        mips*-cisco)
@@ -1536,7 +1582,7 @@ case $basic_machine in
        *-ibm)
                os=-aix
                ;;
        *-ibm)
                os=-aix
                ;;
-       *-knuth)
+       *-knuth)
                os=-mmixware
                ;;
        *-wec)
                os=-mmixware
                ;;
        *-wec)
index 635b2fc5314daf01c737b76b2eff0a67169d53d5..80142ebeae93ef3c2a16d3b455a07f4dc3b053b0 100644 (file)
 #define MAX_SCRIPTS    100
 #define MAX_RULES      50
 #define RULES_SCRIPT   "__WebCit_Generated_Script__"
 #define MAX_SCRIPTS    100
 #define MAX_RULES      50
 #define RULES_SCRIPT   "__WebCit_Generated_Script__"
-
-
-/*
- * dummy panel indicating to the user that the server doesn't support Sieve
- */
-void display_no_sieve(void) {
-
-       output_headers(1, 1, 2, 0, 0, 0);
-
-       wc_printf("<div id=\"banner\">\n");
-       wc_printf("<img src=\"static/icons/essen/32x32/config.png\">");
-       wc_printf("<h1>");
-       wc_printf(_("View/edit server-side mail filters"));
-       wc_printf("</h1>\n");
-       wc_printf("</div>\n");
-
-       wc_printf("<div id=\"content\" class=\"service\">\n");
-
-       wc_printf("<table class=\"sieve_background\">"
-               "<tr><td valign=top>\n");
-
-       wc_printf(_("This installation of Citadel was built without support for server-side mail filtering."
-               "<br>Please contact your system administrator if you require this feature.<br>"));
-
-       wc_printf("</td></tr></table>\n");
-       wDumpContent(1);
-}
-
-
-/*
- * view/edit sieve config
- */
-void display_sieve(void)
-{
-       char script_names[MAX_SCRIPTS][64];
-       int num_scripts = 0;
-       int active_script = (-1);
-       char buf[SIZ];          /* Don't make this buffer smaller or it will restrict line length */
-       int i;
-       int rules_script_is_active = 0;
-
-       if (!WC->serv_info->serv_supports_sieve) {
-               display_no_sieve();
-               return;
-       }
-
-       memset(script_names, 0, sizeof script_names);
-
-       serv_puts("MSIV listscripts");
-       serv_getln(buf, sizeof(buf));
-       if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
-               if (num_scripts < MAX_SCRIPTS) {
-                       extract_token(script_names[num_scripts], buf, 0, '|', 64);
-                       if (extract_int(buf, 1) > 0) {
-                               active_script = num_scripts;
-                               if (!strcasecmp(script_names[num_scripts], RULES_SCRIPT)) {
-                                       rules_script_is_active = 1;
-                               }
-                       }
-                       ++num_scripts;
-               }
-       }
-
-       output_headers(1, 1, 2, 0, 0, 0);
-
-       wc_printf("<script type=\"text/javascript\">                                    \n"
-               "                                                                       \n"
-               "var previously_active_script;                                          \n"
-               "                                                                       \n"
-               "function ToggleSievePanels() {                                         \n"
-               " d = ($('sieveform').bigaction.options[$('sieveform').bigaction.selectedIndex].value); \n"
-               " for (i=0; i<3; ++i) {                                                 \n"
-               "  if (i == d) {                                                        \n"
-               "   $('sievediv' + i).style.display = 'block';                          \n"
-               "  }                                                                    \n"
-               "  else {                                                               \n"
-               "   $('sievediv' + i).style.display = 'none';                           \n"
-               "  }                                                                    \n"
-               " }                                                                     \n"
-               "}                                                                      \n"
-               "                                                                       \n"
-               "function ToggleScriptPanels() {                                        \n"
-               " d = ($('sieveform').active_script.options[$('sieveform').active_script.selectedIndex].value); \n"
-               " if ($('script_' + previously_active_script)) {                        \n"
-               "  $('script_' + previously_active_script).style.display = 'none';      \n"
-               " }                                                                     \n"
-               " $('script_' + d).style.display = 'block';                             \n"
-               " previously_active_script = d;                                         \n"
-               "}                                                                      \n"
-               "                                                                       \n"
-               "</script>                                                              \n"
-       );
-
-       wc_printf("<div id=\"banner\">\n");
-       wc_printf("<img src=\"static/icons/essen/32x32/config.png\">");
-       wc_printf("<h1>");
-       wc_printf(_("View/edit server-side mail filters"));
-       wc_printf("</h1>\n");
-       wc_printf("</div>\n");
-
-       wc_printf("<div id=\"content\" class=\"service\">\n");
-
-       wc_printf("<table class=\"sieve_background\">"
-               "<tr><td valign=top>\n");
-
-
-       wc_printf("<form id=\"sieveform\" method=\"post\" action=\"save_sieve\">\n");
-       wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-
-       wc_printf(_("When new mail arrives: "));
-        wc_printf("<select name=\"bigaction\" size=1 onChange=\"ToggleSievePanels();\">\n");
-
-       wc_printf("<option %s value=\"0\">", ((active_script < 0) ? "selected" : ""));
-       wc_printf(_("Leave it in my inbox without filtering"));
-       wc_printf("</option>\n");
-
-       wc_printf("<option %s value=\"1\">", ((rules_script_is_active) ? "selected" : ""));
-       wc_printf(_("Filter it according to rules selected below"));
-       wc_printf("</option>\n");
-
-       wc_printf("<option %s value=\"2\">",
-                       (((active_script >= 0) && (!rules_script_is_active)) ? "selected" : ""));
-       wc_printf(_("Filter it through a manually edited script (advanced users only)"));
-       wc_printf("</option>\n");
-
-       wc_printf("</select>");
-
-
-
-       /* The "no filtering" div */
-
-       wc_printf("<div id=\"sievediv0\" style=\"display:none\">\n");
-       wc_printf("<div align=\"center\"><br><br>");
-       wc_printf(_("Your incoming mail will not be filtered through any scripts."));
-       wc_printf("<br><br></div>\n");
-       wc_printf("</div>\n");
-
-       /* The "webcit managed scripts" div */
-
-       wc_printf("<div id=\"sievediv1\" style=\"display:none\">\n");
-       display_rules_editor_inner_div();
-       wc_printf("</div>\n");
-
-       /* The "I'm smart and can write my own Sieve scripts" div */
-
-       wc_printf("<div id=\"sievediv2\" style=\"display:none\">\n");
-
-       if (num_scripts > 0) {
-               wc_printf(_("The currently active script is: "));
-               wc_printf("<select name=\"active_script\" size=1 onChange=\"ToggleScriptPanels();\">\n");
-               for (i=0; i<num_scripts; ++i) {
-                       if (strcasecmp(script_names[i], RULES_SCRIPT)) {
-                               wc_printf("<option %s value=\"%s\">%s</option>\n",
-                                       ((active_script == i) ? "selected" : ""),
-                                       script_names[i],
-                                       script_names[i]
-                               );
-                       }
-               }
-               wc_printf("</select>\n");
-       }
-
-       wc_printf("&nbsp;&nbsp;&nbsp;");
-       wc_printf("<a href=\"display_add_remove_scripts\">%s</a>\n", _("Add or delete scripts"));
-
-       wc_printf("<br>\n");
-
-       if (num_scripts > 0) {
-               for (i=0; i<num_scripts; ++i) {
-                       if (strcasecmp(script_names[i], RULES_SCRIPT)) {
-                               wc_printf("<div id=\"script_%s\" style=\"display:none\">\n", script_names[i]);
-                               wc_printf("<textarea name=\"text_%s\" wrap=soft rows=20 cols=80 width=80>\n",
-                                       script_names[i]);
-                               serv_printf("MSIV getscript|%s", script_names[i]);
-                               serv_getln(buf, sizeof buf);
-                               if (buf[0] == '1') while(serv_getln(buf, sizeof (buf)), strcmp(buf, "000")) {
-                                       wc_printf("%s\n", buf);
-                               }
-                               wc_printf("</textarea>\n");
-                               wc_printf("</div>\n");
-                       }
-               }
-       }
-
-       wc_printf("<script type=\"text/javascript\">    \n"
-               "ToggleScriptPanels();                  \n"
-               "</script>                              \n"
-       );
-
-       wc_printf("</div>\n");
-
-
-       /* The rest of this is common for all panels... */
-
-       wc_printf("<div align=\"center\"><br>");
-       wc_printf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
-       wc_printf("&nbsp;");
-       wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
-       wc_printf("</div></form>\n");
-
-       wc_printf("</td></tr></table>\n");
-
-       wc_printf("<script type=\"text/javascript\">    \n"
-               "ToggleSievePanels();                   \n"
-               "</script>                              \n"
-       );
-
-       wDumpContent(1);
-
-}
-
-
+#define FOO 1
 
 /*
  * Helper function for output_sieve_rule() to output strings with quotes escaped
 
 /*
  * Helper function for output_sieve_rule() to output strings with quotes escaped
@@ -252,6 +41,12 @@ void osr_sanitize(char *str) {
        }
 }
 
        }
 }
 
+void display_add_remove_scripts(char *message);
+
+
+
+
+
 
 /*
  * Output parseable Sieve script code based on rules input
 
 /*
  * Output parseable Sieve script code based on rules input
@@ -570,82 +365,330 @@ void parse_fields_from_rule_editor(void) {
 
 
 
 
 
 
-/*
- * save sieve config
- */
-void save_sieve(void) {
-       int bigaction;
-       char script_names[MAX_SCRIPTS][64];
-       int num_scripts = 0;
-       int active_script = (-1);
-       int i;
-       char this_name[64];
-       char buf[256];
+/*
+ * save sieve config
+ */
+void save_sieve(void) {
+       int bigaction;
+       char script_names[MAX_SCRIPTS][64];
+       int num_scripts = 0;
+       int active_script = (-1);
+       int i;
+       char this_name[64];
+       char buf[256];
+
+       if (!havebstr("save_button")) {
+               strcpy(WC->ImportantMessage,
+                       _("Cancelled.  Changes were not saved."));
+               display_main_menu();
+               return;
+       }
+
+       parse_fields_from_rule_editor();
+
+       serv_puts("MSIV listscripts");
+       serv_getln(buf, sizeof(buf));
+       if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
+               if (num_scripts < MAX_SCRIPTS) {
+                       extract_token(script_names[num_scripts], buf, 0, '|', 64);
+                       if (extract_int(buf, 1) > 0) {
+                               active_script = num_scripts;
+                       }
+                       ++num_scripts;
+               }
+       }
+
+       bigaction = ibstr("bigaction");
+
+       if (bigaction == 0) {
+               serv_puts("MSIV setactive||");
+               serv_getln(buf, sizeof buf);
+       }
+
+       else if (bigaction == 1) {
+               serv_printf("MSIV setactive|%s|", RULES_SCRIPT);
+               serv_getln(buf, sizeof buf);
+       }
+
+       else if (bigaction == 2) {
+               serv_printf("MSIV setactive|%s|", bstr("active_script"));
+               serv_getln(buf, sizeof buf);
+       }
+
+       if (num_scripts > 0) {
+               for (i=0; i<num_scripts; ++i) {
+                       /*
+                        * We only want to save the scripts from the "manually edited scripts"
+                        * screen.  The script that WebCit generates from its ruleset will be
+                        * auto-generated by parse_fields_from_rule_editor() and saved there.
+                        */
+                       if (strcasecmp(script_names[i], RULES_SCRIPT)) {
+                               serv_printf("MSIV putscript|%s|", script_names[i]);
+                               serv_getln(buf, sizeof buf);
+                               if (buf[0] == '4') {
+                                       snprintf(this_name, sizeof this_name, "text_%s", script_names[i]);
+                                       striplt((char *)BSTR(this_name)); /* TODO: get rid of typecast*/
+                                       serv_write(BSTR(this_name), strlen(BSTR(this_name)));
+                                       serv_puts("\n000");
+                               }
+                       }
+               }
+       }
+
+       strcpy(WC->ImportantMessage, _("Your changes have been saved."));
+       display_main_menu();
+       return;
+}
+
+/*
+ * create a new script
+ * take the web environment script name and create it on the citadel server
+ */
+void create_script(void) {
+       char buf[256];
+
+       serv_printf("MSIV getscript|%s", bstr("script_name"));
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '1') {
+               while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
+                       /* flush */
+               }
+#if FOO
+               display_add_remove_scripts(_("A script by that name already exists."));
+#endif
+               return;
+       }
+       
+       serv_printf("MSIV putscript|%s", bstr("script_name"));
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '4') {
+               serv_puts("keep;");
+               serv_puts("000");
+#if FOO
+               display_add_remove_scripts(_("A new script has been created.  Return to the script editing screen to edit and activate it."));
+#endif
+               return;
+       }
+
+#if FOO
+       display_add_remove_scripts(&buf[4]);
+#endif
+}
+
+
+
+
+/*
+ * delete a script
+ */
+void delete_script(void) {
+       char buf[256];
+
+       serv_printf("MSIV deletescript|%s", bstr("script_name"));
+       serv_getln(buf, sizeof buf);
+#if FOO
+       display_add_remove_scripts(&buf[4]);
+#endif
+}
+               
+
+
+/*
+ * dummy panel indicating to the user that the server doesn't support Sieve
+ */
+void display_no_sieve(void) {
+
+       output_headers(1, 1, 2, 0, 0, 0);
+       do_template("sieve_none");
+       wDumpContent(1);
+}
+
+#if FOO
+/*
+ * view/edit sieve config
+ */
+void display_sieve(void)
+{
+       char script_names[MAX_SCRIPTS][64];
+       int num_scripts = 0;
+       int active_script = (-1);
+       char buf[SIZ];          /* Don't make this buffer smaller or it will restrict line length */
+       int i;
+       int rules_script_is_active = 0;
+
+       if (!WC->serv_info->serv_supports_sieve) {
+               display_no_sieve();
+               return;
+       }
+
+       memset(script_names, 0, sizeof script_names);
+
+       serv_puts("MSIV listscripts");
+       serv_getln(buf, sizeof(buf));
+       if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
+               if (num_scripts < MAX_SCRIPTS) {
+                       extract_token(script_names[num_scripts], buf, 0, '|', 64);
+                       if (extract_int(buf, 1) > 0) {
+                               active_script = num_scripts;
+                               if (!strcasecmp(script_names[num_scripts], RULES_SCRIPT)) {
+                                       rules_script_is_active = 1;
+                               }
+                       }
+                       ++num_scripts;
+               }
+       }
+
+       output_headers(1, 1, 2, 0, 0, 0);
+
+       wc_printf("<script type=\"text/javascript\">                                    \n"
+               "                                                                       \n"
+               "var previously_active_script;                                          \n"
+               "                                                                       \n"
+               "function ToggleSievePanels() {                                         \n"
+               " d = ($('sieveform').bigaction.options[$('sieveform').bigaction.selectedIndex].value); \n"
+               " for (i=0; i<3; ++i) {                                                 \n"
+               "  if (i == d) {                                                        \n"
+               "   $('sievediv' + i).style.display = 'block';                          \n"
+               "  }                                                                    \n"
+               "  else {                                                               \n"
+               "   $('sievediv' + i).style.display = 'none';                           \n"
+               "  }                                                                    \n"
+               " }                                                                     \n"
+               "}                                                                      \n"
+               "                                                                       \n"
+               "function ToggleScriptPanels() {                                        \n"
+               " d = ($('sieveform').active_script.options[$('sieveform').active_script.selectedIndex].value); \n"
+               " if ($('script_' + previously_active_script)) {                        \n"
+               "  $('script_' + previously_active_script).style.display = 'none';      \n"
+               " }                                                                     \n"
+               " $('script_' + d).style.display = 'block';                             \n"
+               " previously_active_script = d;                                         \n"
+               "}                                                                      \n"
+               "                                                                       \n"
+               "</script>                                                              \n"
+       );
+
+       wc_printf("<div id=\"banner\">\n");
+       wc_printf("<img src=\"static/advanpage2_48x.gif\">");
+       wc_printf("<h1>");
+       wc_printf(_("View/edit server-side mail filters"));
+       wc_printf("</h1>\n");
+       wc_printf("</div>\n");
+
+       wc_printf("<div id=\"content\" class=\"service\">\n");
+
+       wc_printf("<table class=\"sieve_background\">"
+               "<tr><td valign=top>\n");
+
+
+       wc_printf("<form id=\"sieveform\" method=\"post\" action=\"save_sieve\">\n");
+       wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+
+       wc_printf(_("When new mail arrives: "));
+        wc_printf("<select name=\"bigaction\" size=1 onChange=\"ToggleSievePanels();\">\n");
+
+       wc_printf("<option %s value=\"0\">", ((active_script < 0) ? "selected" : ""));
+       wc_printf(_("Leave it in my inbox without filtering"));
+       wc_printf("</option>\n");
+
+       wc_printf("<option %s value=\"1\">", ((rules_script_is_active) ? "selected" : ""));
+       wc_printf(_("Filter it according to rules selected below"));
+       wc_printf("</option>\n");
+
+       wc_printf("<option %s value=\"2\">",
+                       (((active_script >= 0) && (!rules_script_is_active)) ? "selected" : ""));
+       wc_printf(_("Filter it through a manually edited script (advanced users only)"));
+       wc_printf("</option>\n");
+
+       wc_printf("</select>");
+
+
+
+       /* The "no filtering" div */
+
+       wc_printf("<div id=\"sievediv0\" style=\"display:none\">\n");
+       wc_printf("<div align=\"center\"><br><br>");
+       wc_printf(_("Your incoming mail will not be filtered through any scripts."));
+       wc_printf("<br><br></div>\n");
+       wc_printf("</div>\n");
 
 
-       if (!havebstr("save_button")) {
-               strcpy(WC->ImportantMessage,
-                       _("Cancelled.  Changes were not saved."));
-               display_main_menu();
-               return;
-       }
+       /* The "webcit managed scripts" div */
 
 
-       parse_fields_from_rule_editor();
+       wc_printf("<div id=\"sievediv1\" style=\"display:none\">\n");
+       display_rules_editor_inner_div();
+       wc_printf("</div>\n");
 
 
-       serv_puts("MSIV listscripts");
-       serv_getln(buf, sizeof(buf));
-       if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
-               if (num_scripts < MAX_SCRIPTS) {
-                       extract_token(script_names[num_scripts], buf, 0, '|', 64);
-                       if (extract_int(buf, 1) > 0) {
-                               active_script = num_scripts;
-                       }
-                       ++num_scripts;
-               }
-       }
+       /* The "I'm smart and can write my own Sieve scripts" div */
 
 
-       bigaction = ibstr("bigaction");
+       wc_printf("<div id=\"sievediv2\" style=\"display:none\">\n");
 
 
-       if (bigaction == 0) {
-               serv_puts("MSIV setactive||");
-               serv_getln(buf, sizeof buf);
+       if (num_scripts > 0) {
+               wc_printf(_("The currently active script is: "));
+               wc_printf("<select name=\"active_script\" size=1 onChange=\"ToggleScriptPanels();\">\n");
+               for (i=0; i<num_scripts; ++i) {
+                       if (strcasecmp(script_names[i], RULES_SCRIPT)) {
+                               wc_printf("<option %s value=\"%s\">%s</option>\n",
+                                       ((active_script == i) ? "selected" : ""),
+                                       script_names[i],
+                                       script_names[i]
+                               );
+                       }
+               }
+               wc_printf("</select>\n");
        }
 
        }
 
-       else if (bigaction == 1) {
-               serv_printf("MSIV setactive|%s|", RULES_SCRIPT);
-               serv_getln(buf, sizeof buf);
-       }
+       wc_printf("&nbsp;&nbsp;&nbsp;");
+       wc_printf("<a href=\"display_add_remove_scripts\">%s</a>\n", _("Add or delete scripts"));
 
 
-       else if (bigaction == 2) {
-               serv_printf("MSIV setactive|%s|", bstr("active_script"));
-               serv_getln(buf, sizeof buf);
-       }
+       wc_printf("<br>\n");
 
        if (num_scripts > 0) {
                for (i=0; i<num_scripts; ++i) {
 
        if (num_scripts > 0) {
                for (i=0; i<num_scripts; ++i) {
-                       /*
-                        * We only want to save the scripts from the "manually edited scripts"
-                        * screen.  The script that WebCit generates from its ruleset will be
-                        * auto-generated by parse_fields_from_rule_editor() and saved there.
-                        */
                        if (strcasecmp(script_names[i], RULES_SCRIPT)) {
                        if (strcasecmp(script_names[i], RULES_SCRIPT)) {
-                               serv_printf("MSIV putscript|%s|", script_names[i]);
+                               wc_printf("<div id=\"script_%s\" style=\"display:none\">\n", script_names[i]);
+                               wc_printf("<textarea name=\"text_%s\" wrap=soft rows=20 cols=80 width=80>\n",
+                                       script_names[i]);
+                               serv_printf("MSIV getscript|%s", script_names[i]);
                                serv_getln(buf, sizeof buf);
                                serv_getln(buf, sizeof buf);
-                               if (buf[0] == '4') {
-                                       snprintf(this_name, sizeof this_name, "text_%s", script_names[i]);
-                                       striplt((char *)BSTR(this_name)); /* TODO: get rid of typecast*/
-                                       serv_write(BSTR(this_name), strlen(BSTR(this_name)));
-                                       serv_puts("\n000");
+                               if (buf[0] == '1') while(serv_getln(buf, sizeof (buf)), strcmp(buf, "000")) {
+                                       wc_printf("%s\n", buf);
                                }
                                }
+                               wc_printf("</textarea>\n");
+                               wc_printf("</div>\n");
                        }
                }
        }
 
                        }
                }
        }
 
-       strcpy(WC->ImportantMessage, _("Your changes have been saved."));
-       display_main_menu();
-       return;
+       wc_printf("<script type=\"text/javascript\">    \n"
+               "ToggleScriptPanels();                  \n"
+               "</script>                              \n"
+       );
+
+       wc_printf("</div>\n");
+
+
+       /* The rest of this is common for all panels... */
+
+       wc_printf("<div align=\"center\"><br>");
+       wc_printf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
+       wc_printf("&nbsp;");
+       wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
+       wc_printf("</div></form>\n");
+
+       wc_printf("</td></tr></table>\n");
+
+       wc_printf("<script type=\"text/javascript\">    \n"
+               "ToggleSievePanels();                   \n"
+               "</script>                              \n"
+       );
+
+       wDumpContent(1);
+
 }
 
 
 }
 
 
+
+
 /*
  * show a list of available scripts to add/remove them
  */
 /*
  * show a list of available scripts to add/remove them
  */
@@ -735,48 +778,6 @@ void display_add_remove_scripts(char *message)
 
 
 
 
 
 
-/*
- * delete a script
- */
-void delete_script(void) {
-       char buf[256];
-
-       serv_printf("MSIV deletescript|%s", bstr("script_name"));
-       serv_getln(buf, sizeof buf);
-       display_add_remove_scripts(&buf[4]);
-}
-               
-
-
-/*
- * create a new script
- * take the web environment script name and create it on the citadel server
- */
-void create_script(void) {
-       char buf[256];
-
-       serv_printf("MSIV getscript|%s", bstr("script_name"));
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') {
-               while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
-                       /* flush */
-               }
-               display_add_remove_scripts(_("A script by that name already exists."));
-               return;
-       }
-       
-       serv_printf("MSIV putscript|%s", bstr("script_name"));
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '4') {
-               serv_puts("keep;");
-               serv_puts("000");
-               display_add_remove_scripts(_("A new script has been created.  Return to the script editing screen to edit and activate it."));
-               return;
-       }
-
-       display_add_remove_scripts(&buf[4]);
-}
-
 
 
 
 
 
 
@@ -1180,16 +1181,501 @@ void display_rules_editor_inner_div(void) {
 
        free(rooms);
 }
 
        free(rooms);
 }
-
 void _display_add_remove_scripts(void) {display_add_remove_scripts(NULL);}
 void _display_add_remove_scripts(void) {display_add_remove_scripts(NULL);}
+#endif
+
+
+typedef struct __SieveListing {
+       int IsActive;
+       int IsRulesScript;
+       StrBuf *Name;
+       StrBuf *Content;
+} SieveListing;
+
+int ConditionalSieveScriptIsActive(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveListing     *SieveList = (SieveListing *)CTX;
+       return SieveList->IsActive;
+}
+int ConditionalSieveScriptIsRulesScript(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveListing     *SieveList = (SieveListing *)CTX;
+       return SieveList->IsActive;
+}
+void tmplput_SieveScriptName(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveListing     *SieveList = (SieveListing *)CTX;
+       StrBufAppendTemplate(Target, TP, SieveList->Name, 0);
+}
+void tmplput_SieveScriptContent(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveListing     *SieveList = (SieveListing *)CTX;
+       StrBufAppendTemplate(Target, TP, SieveList->Content, 0);
+}
+void FreeSieveListing(void *vSieveListing)
+{
+       SieveListing *List = (SieveListing*) vSieveListing;
+
+       FreeStrBuf(&List->Name);
+       free(List);
+}
+
+HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
+{
+        wcsession *WCC = WC;
+       StrBuf *Line;
+       int num_scripts = 0;
+       int rules_script_active = 0;
+       int have_rules_script = 0;
+       const char *pch;
+       HashPos  *it;
+       int Done = 0;
+       SieveListing *Ruleset;
+
+       if (WCC->KnownSieveScripts != NULL)
+               return WCC->KnownSieveScripts;
+
+       serv_puts("MSIV listscripts");
+       Line = NewStrBuf();
+       StrBuf_ServGetln(Line);
+       if (GetServerStatus(Line, NULL) == 1) 
+       {
+               WCC->KnownSieveScripts = NewHash(1, Flathash);
+
+               while(!Done && (StrBuf_ServGetln(Line) >= 0) )
+                       if ( (StrLength(Line)==3) && 
+                            !strcmp(ChrPtr(Line), "000")) 
+                       {
+                               Done = 1;
+                       }
+                       else
+                       {
+                               pch = NULL;
+                               Ruleset = (SieveListing *) malloc(sizeof(SieveListing));
+                               Ruleset->Name = NewStrBufPlain(NULL, StrLength(Line));
+                               StrBufExtract_NextToken(Ruleset->Name, Line, &pch, '|');
+                               Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|'); 
+
+                               if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT))
+                               {
+                                       Ruleset->IsRulesScript = 1;
+                                       have_rules_script = 1;
+                                       if (Ruleset->IsActive)
+                                       {
+                                               rules_script_active = 1;
+                                               PutBstr(HKEY("__SIEVE:RULESSCRIPT"), NewStrBufPlain(HKEY("1")));
+                                       }
+                               }
+                               Put(WCC->KnownSieveScripts, IKEY(num_scripts), Ruleset, FreeSieveListing);
+
+                               ++num_scripts;
+                       }
+       }
+       if ((num_scripts > 0) && (rules_script_active == 0))
+               PutBstr(HKEY("__SIEVE:EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
+
+       if (num_scripts > have_rules_script)
+       {
+               long rc;
+               long len;
+               const char *Key;
+               void *vRuleset;
+
+               /* 
+                * ok; we have custom scripts, expose that via bstr, and load the payload.
+                */
+               PutBstr(HKEY("__SIEVE:HAVE_EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
+
+               it = GetNewHashPos(WCC->KnownSieveScripts, 0);
+               while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) && 
+                      (vRuleset != NULL))
+               {
+                       Ruleset = (SieveListing *) vRuleset;
+
+                       /*
+                        * its the webcit rule? we don't need to load that here.
+                        */
+                       if (Ruleset->IsRulesScript)
+                               continue;
+
+                       if (!serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name)))
+                               break;
+                       StrBuf_ServGetln(Line);
+                       if (GetServerStatus(Line, NULL) == 1) 
+                       {
+                               Ruleset->Content = NewStrBuf();
+                               while(!Done && (rc = StrBuf_ServGetln(Line), rc >= 0) )
+                                       if ( (StrLength(Line)==3) && 
+                                            !strcmp(ChrPtr(Line), "000")) 
+                                       {
+                                               Done = 1;
+                                       }
+                                       else
+                                       {
+                                               if (StrLength(Ruleset->Content)>0)
+                                                       StrBufAppendBufPlain(Ruleset->Content, HKEY("\n"), 0);
+                                               StrBufAppendBuf(Ruleset->Content, Line, 0);
+                                       }
+                               if (rc < 0) break;
+                       }
+               }
+       }
+       FreeStrBuf(&Line);
+       return WCC->KnownSieveScripts;
+}
+
+
+typedef enum __eSieveHfield 
+{
+       from,           
+       tocc,           
+       subject,        
+       replyto,        
+       sender, 
+       resentfrom,     
+       resentto,       
+       envfrom,        
+       envto,  
+       xmailer,        
+       xspamflag,      
+       xspamstatus,    
+       listid, 
+       size,           
+       all
+} eSieveHfield;
+
+typedef enum __eSieveCompare {
+       contains,
+       notcontains,
+       is,
+       isnot,
+       matches,
+       notmatches
+} eSieveCompare;
+
+typedef enum __eSieveAction {
+       keep,
+       discard,
+       reject,
+       fileinto,
+       redirect,
+       vacation
+} eSieveAction;
+
+
+typedef enum __eSieveSizeComp {
+       larger,
+       smaller
+} eSieveSizeComp;
+
+typedef enum __eSieveFinal {
+       econtinue,
+       estop
+} eSieveFinal;
+
+
+typedef struct __SieveRule {
+       int active;
+       int sizeval;
+       eSieveHfield hfield;
+       eSieveCompare compare;
+       StrBuf *htext;
+       eSieveSizeComp sizecomp;
+       eSieveAction Action;
+       StrBuf *fileinto;
+       StrBuf *redirect;
+       StrBuf *automsg;
+       eSieveFinal final;
+}SieveRule;
+
+
+
+int ConditionalSieveRule_hfield(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       
+        return GetTemplateTokenNumber(Target, 
+                                      TP, 
+                                      3, 
+                                      from)
+                ==
+                Rule->hfield;
+}
+int ConditionalSieveRule_compare(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+        return GetTemplateTokenNumber(Target, 
+                                      TP, 
+                                      3, 
+                                      contains)
+                ==
+               Rule->compare;
+}
+int ConditionalSieveRule_action(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+        return GetTemplateTokenNumber(Target, 
+                                      TP, 
+                                      3, 
+                                      keep)
+                ==
+               Rule->Action; 
+}
+int ConditionalSieveRule_sizecomp(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+        return GetTemplateTokenNumber(Target, 
+                                      TP, 
+                                      3, 
+                                      larger)
+                ==
+               Rule->sizecomp;
+}
+int ConditionalSieveRule_final(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+        return GetTemplateTokenNumber(Target, 
+                                      TP, 
+                                      3, 
+                                      econtinue)
+                ==
+               Rule->final;
+}
+int ConditionalSieveRule_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+        return GetTemplateTokenNumber(Target, 
+                                      TP, 
+                                      3, 
+                                      econtinue)
+                ==
+               Rule->final;
+}
+int ConditionalSieveRule_Active(StrBuf *Target, WCTemplputParams *TP)
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+        return Rule->active;
+}
+
+
+/*
+void tmplput_SieveRule_hfield(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->hfield, 0);
+}
+void tmplput_SieveRule_compare(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->compare, 0);
+}
+*/
+void tmplput_SieveRule_htext(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->htext, 0);
+}
+/*
+void tmplput_SieveRule_sizecomp(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->sizecomp, 0);
+}
+void tmplput_SieveRule_action(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->action, 0);
+       }*/
+void tmplput_SieveRule_fileinto(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->fileinto, 0);
+}
+void tmplput_SieveRule_redirect(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->redirect, 0);
+}
+void tmplput_SieveRule_automsg(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->automsg, 0);
+}
+/*
+void tmplput_SieveRule_final(StrBuf *Target, WCTemplputParams *TP) 
+{
+       SieveRule     *Rule = (SieveRule *)CTX;
+       StrBufAppendTemplate(Target, TP, Rule->final, 0);
+}
+*/
+void FreeSieveRule(void *vRule)
+{
+       SieveRule *Rule = (SieveRule*) Rule;
+
+       FreeStrBuf(&Rule->htext);
+       FreeStrBuf(&Rule->fileinto);
+       FreeStrBuf(&Rule->redirect);
+       FreeStrBuf(&Rule->automsg);
+       
+       free(Rule);
+}
+
+#define WC_RULE_HEADER "# WEBCIT_RULE|"
+HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
+{
+       StrBuf *Line;
+       StrBuf *EncodedRule;
+       int n;
+       const char *pch;
+       HashList *SieveRules = NULL;
+       int Done = 0;
+       SieveRule *Rule;
+
+       serv_printf("MSIV getscript|"RULES_SCRIPT);
+       Line = NewStrBuf();
+       EncodedRule = NewStrBuf();
+       StrBuf_ServGetln(Line);
+       if (GetServerStatus(Line, NULL) == 1) 
+       {
+               SieveRules = NewHash(1, Flathash);
+
+               while(!Done && (StrBuf_ServGetln(Line) >= 0) )
+                       if ( (StrLength(Line)==3) && 
+                            !strcmp(ChrPtr(Line), "000")) 
+                       {
+                               Done = 1;
+                       }
+                       else
+                       {
+                               pch = NULL;
+                               /* We just care for our encoded header and skip everything else */
+                               if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1) &&
+                                   (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER))))
+                               {
+                                       StrBufSkip_NTokenS(Line, &pch, '|', 1);
+                                       n = StrBufExtractNext_int(Line, &pch, '|'); 
+                                       StrBufExtract_NextToken(EncodedRule, Line, &pch, '|');
+                                       StrBufDecodeBase64(EncodedRule);
+
+                                       Rule = (SieveRule*) malloc(sizeof(SieveRule));
+
+                                       Rule->htext = NewStrBufPlain (NULL, StrLength(EncodedRule));
+
+                                       Rule->fileinto = NewStrBufPlain (NULL, StrLength(EncodedRule));
+                                       Rule->redirect = NewStrBufPlain (NULL, StrLength(EncodedRule));
+                                       Rule->automsg = NewStrBufPlain (NULL, StrLength(EncodedRule));
+
+                                       /* Grab our existing values to populate */
+                                       pch = NULL;
+                                       Rule->active = StrBufExtractNext_int(EncodedRule, &pch, '|');
+                                       StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
+                                       
+                                       Rule->hfield = (eSieveHfield) GetTokenDefine(SKEY(Line), tocc);
+                                       StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
+                                       Rule->compare = (eSieveCompare) GetTokenDefine(SKEY(Line), contains);
+                                       StrBufExtract_NextToken(Rule->htext, EncodedRule, &pch, '|');
+                                       StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
+                                       Rule->sizecomp = (eSieveSizeComp) GetTokenDefine(SKEY(Line), larger);
+                                       Rule->sizeval = StrBufExtractNext_int(EncodedRule, &pch, '|');
+                                       StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
+                                       Rule->Action = (eSieveAction) GetTokenDefine(SKEY(Line), keep);
+                                       StrBufExtract_NextToken(Rule->fileinto, EncodedRule, &pch, '|');
+                                       StrBufExtract_NextToken(Rule->redirect, EncodedRule, &pch, '|');
+                                       StrBufExtract_NextToken(Rule->automsg, EncodedRule, &pch, '|');
+                                       StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
+                                       Rule->final = (eSieveFinal) GetTokenDefine(SKEY(Line), econtinue);
+                                       Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
+                               }
+                       }
+       }
+
+       FreeStrBuf(&EncodedRule);
+       FreeStrBuf(&Line);
+       return SieveRules;
+}
+
+void
+SessionDetachModule_SIEVE
+(wcsession *sess)
+{
+       DeleteHash(&sess->KnownSieveScripts);
+}
 
 void 
 InitModule_SIEVE
 (void)
 {
 
 void 
 InitModule_SIEVE
 (void)
 {
+       REGISTERTokenParamDefine(from);         
+       REGISTERTokenParamDefine(tocc);         
+       REGISTERTokenParamDefine(subject);      
+       REGISTERTokenParamDefine(replyto);      
+       REGISTERTokenParamDefine(sender);       
+       REGISTERTokenParamDefine(resentfrom);   
+       REGISTERTokenParamDefine(resentto);     
+       REGISTERTokenParamDefine(envfrom);      
+       REGISTERTokenParamDefine(envto);        
+       REGISTERTokenParamDefine(xmailer);      
+       REGISTERTokenParamDefine(xspamflag);    
+       REGISTERTokenParamDefine(xspamstatus);  
+       REGISTERTokenParamDefine(listid);       
+       REGISTERTokenParamDefine(size);         
+       REGISTERTokenParamDefine(all);
+
+       REGISTERTokenParamDefine(contains);
+       REGISTERTokenParamDefine(notcontains);
+       REGISTERTokenParamDefine(is);
+       REGISTERTokenParamDefine(isnot);
+       REGISTERTokenParamDefine(matches);
+       REGISTERTokenParamDefine(notmatches);
+
+       REGISTERTokenParamDefine(keep);
+       REGISTERTokenParamDefine(discard);
+       REGISTERTokenParamDefine(reject);
+       REGISTERTokenParamDefine(fileinto);
+       REGISTERTokenParamDefine(redirect);
+       REGISTERTokenParamDefine(vacation);
+
+       REGISTERTokenParamDefine(larger);
+       REGISTERTokenParamDefine(smaller);
+
+       /* these are c-keyworads, so do it by hand. */
+       RegisterTokenParamDefine(HKEY("continue"), econtinue);
+       RegisterTokenParamDefine(HKEY("stop"), estop);
+
+       RegisterIterator("SIEVE:SCRIPTS", 0, NULL, GetSieveRules, NULL, NULL, CTX_SIEVELIST, CTX_NONE, IT_NOFLAG);
+
+       RegisterIterator("SIEVE:RULES", 0, NULL, GetSieveRules, NULL, DeleteHash, CTX_SIEVESCRIPT, CTX_NONE, IT_NOFLAG);
+
+       RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ACTIVE"), 0, ConditionalSieveScriptIsActive, CTX_SIEVELIST);
+       RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ISRULES"), 0, ConditionalSieveScriptIsRulesScript, CTX_SIEVELIST);
+       RegisterNamespace("SIEVE:SCRIPT:NAME", 0, 1, tmplput_SieveScriptName, NULL, CTX_ROOMS);
+       RegisterNamespace("SIEVE:SCRIPT:CONTENT", 0, 1, tmplput_SieveScriptContent, NULL, CTX_SIEVELIST);
+
+       RegisterConditional(HKEY("COND:SIEVE:ACTIVE"), 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT);
+       RegisterConditional(HKEY("COND:SIEVE:HFIELD"), 1, ConditionalSieveRule_hfield, CTX_SIEVESCRIPT);
+       RegisterConditional(HKEY("COND:SIEVE:COMPARE"), 1, ConditionalSieveRule_compare, CTX_SIEVESCRIPT);
+       RegisterConditional(HKEY("COND:SIEVE:ACTION"), 1, ConditionalSieveRule_action, CTX_SIEVESCRIPT);
+       RegisterConditional(HKEY("COND:SIEVE:SIZECOMP"), 1, ConditionalSieveRule_sizecomp, CTX_SIEVESCRIPT);
+       RegisterConditional(HKEY("COND:SIEVE:FINAL"), 1, ConditionalSieveRule_final, CTX_SIEVESCRIPT);
+       RegisterConditional(HKEY("COND:SIEVE:THISROOM"), 1, ConditionalSieveRule_ThisRoom, CTX_SIEVESCRIPT);
+
+       //RegisterNamespace("SIEVE:SCRIPT:HFIELD", 0, 1, tmplput_SieveRule_hfield, NULL, CTX_SIEVESCRIPT);
+       //RegisterNamespace("SIEVE:SCRIPT:COMPARE", 0, 1, tmplput_SieveRule_compare, NULL, CTX_SIEVESCRIPT);
+       RegisterNamespace("SIEVE:SCRIPT:HTEXT", 0, 1, tmplput_SieveRule_htext, NULL, CTX_SIEVESCRIPT);
+       //RegisterNamespace("SIEVE:SCRIPT:SIZECOMP", 0, 1, tmplput_SieveRule_sizecomp, NULL, CTX_SIEVESCRIPT);
+       ///RegisterNamespace("SIEVE:SCRIPT:ACTION", 0, 1, tmplput_SieveRule_action, NULL, CTX_SIEVESCRIPT);
+       RegisterNamespace("SIEVE:SCRIPT:FILEINTO", 0, 1, tmplput_SieveRule_fileinto, NULL, CTX_SIEVESCRIPT);
+       RegisterNamespace("SIEVE:SCRIPT:REDIRECT", 0, 1, tmplput_SieveRule_redirect, NULL, CTX_SIEVESCRIPT);
+       RegisterNamespace("SIEVE:SCRIPT:AUTOMSG", 0, 1, tmplput_SieveRule_automsg, NULL, CTX_SIEVESCRIPT);
+       ///RegisterNamespace("SIEVE:SCRIPT:FINAL", 0, 1, tmplput_SieveRule_final, NULL, CTX_SIEVESCRIPT);
+
+#if FOO
        WebcitAddUrlHandler(HKEY("display_sieve"), "", 0, display_sieve, 0);
        WebcitAddUrlHandler(HKEY("display_sieve"), "", 0, display_sieve, 0);
-       WebcitAddUrlHandler(HKEY("save_sieve"), "", 0, save_sieve, 0);
        WebcitAddUrlHandler(HKEY("display_add_remove_scripts"), "", 0, _display_add_remove_scripts, 0);
        WebcitAddUrlHandler(HKEY("display_add_remove_scripts"), "", 0, _display_add_remove_scripts, 0);
+#endif
+       WebcitAddUrlHandler(HKEY("save_sieve"), "", 0, save_sieve, 0);
+
        WebcitAddUrlHandler(HKEY("create_script"), "", 0, create_script, 0);
        WebcitAddUrlHandler(HKEY("delete_script"), "", 0, delete_script, 0);
 }
        WebcitAddUrlHandler(HKEY("create_script"), "", 0, create_script, 0);
        WebcitAddUrlHandler(HKEY("delete_script"), "", 0, delete_script, 0);
 }
diff --git a/webcit/static/t/sieve/add.html b/webcit/static/t/sieve/add.html
new file mode 100644 (file)
index 0000000..9eea08e
--- /dev/null
@@ -0,0 +1,32 @@
+<div id="banner">
+<img src="static/advanpage2_48x.gif">
+<?_("Add or delete scripts")>
+</h1>
+</div>
+       
+<div id="content" class="service">
+<?SIEVE:MESSAGE>
+
+<table border=0 cellspacing=10><tr valign=top><td>
+<?=("beginbox_1")> <?_("Add a new script")><?=("beginbox_2")>
+<?_("To create a new script, enter the desired script name in the box below and click 'Create'.")>
+<br><br>
+
+<center><form method="POST" action="create_script">
+<input type="hidden" name="nonce" value="<?NONCE>">
+<?_("Script name: ")>
+<input type="text" name="script_name"><br>
+<input type="submit" name="create_button" value='<?_("Create")>'></form></center>
+<?=("endbox")>
+<?=("beginbox_1")><?_("Edit scripts")><?=("beginbox_2")>
+<br><div align=center><a href="display_sieve"><?_("Return to the script editing screen")></a><br><br>
+<?=("endbox")>
+</td><td>
+<?=("beginbox_1")><?_("Delete scripts")><?=("beginbox_2")>
+<?_("To delete an existing script, select the script name from the list and click 'Delete'.")>
+<br><br>
+<center><form method="POST" action="delete_script">
+<input type="hidden" name="nonce" value="<?NONCE>">
+<select name="script_name" size=10 style="width:100%%">
+<?ITERATE("SIEVE:SCRIPTS", ="sieve_script_select")>
+</select>
diff --git a/webcit/static/t/sieve/display.html b/webcit/static/t/sieve/display.html
new file mode 100644 (file)
index 0000000..222dd34
--- /dev/null
@@ -0,0 +1,123 @@
+
+/*
+ * This script should get called by every onChange event...
+ *
+ */
+<script type="text/javascript">
+
+var highest_active_rule = (-1);
+
+function UpdateRules() {
+/*
+ * Show only the active rows...
+ */
+  highest_active_rule = (-1);
+  for (i=0; i< <?SIEVE:MAX_RULES>; ++i) {
+   if ($('active'+i).checked) {
+     $('rule' + i).style.display = 'block';
+     highest_active_rule = i;
+   }
+   else {
+     $('rule' + i).style.display = 'none';
+   }
+  }
+/*
+ * Show only the fields relevant to the rules...
+ */
+  for (i=0; i<=highest_active_rule; ++i) {
+    d = ($('movedown'+i));
+    if (i < highest_active_rule) {
+      d.style.display = 'block';
+    }
+    else {
+      d.style.display = 'none';
+    }
+    d = ($('hfield'+i).options[$('hfield'+i).selectedIndex].value);
+    if (d == 'all') {
+      $('div_size'+i).style.display = 'none';   
+      $('div_compare'+i).style.display = 'none';
+      $('div_nocompare'+i).style.display = 'block';
+    }
+    else if (d == 'size') {
+      $('div_size'+i).style.display = 'block';  
+      $('div_compare'+i).style.display = 'none';
+      $('div_nocompare'+i).style.display = 'none';
+    }
+    else {
+      $('div_size'+i).style.display = 'none';   
+      $('div_compare'+i).style.display = 'block';
+      $('div_nocompare'+i).style.display = 'none';
+    }
+    d = ($('action'+i).options[$('action'+i).selectedIndex].value);
+    if (d == 'fileinto') {
+      $('div_fileinto'+i).style.display = 'block';
+      $('div_redirect'+i).style.display = 'none';
+      $('div_automsg'+i).style.display = 'none';
+    } else if (d == 'redirect') {
+      $('div_fileinto'+i).style.display = 'none';
+      $('div_redirect'+i).style.display = 'block';
+      $('div_automsg'+i).style.display = 'none';
+    } else if ((d == 'reject') || (d == 'vacation'))  {
+      $('div_fileinto'+i).style.display = 'none';
+      $('div_redirect'+i).style.display = 'none';
+      $('div_automsg'+i).style.display = 'block';
+    } else {
+      $('div_fileinto'+i).style.display = 'none';
+      $('div_redirect'+i).style.display = 'none';
+      $('div_automsg'+i).style.display = 'none';
+    }
+    if (highest_active_rule < <?SIEVE:MAX_RULES> - 1) {
+      $('div_addrule').style.display = 'block';
+    } else {
+      $('div_addrule').style.display = 'none';
+    }
+  }
+}
+/*
+ * Add a rule (really, just un-hide it)
+ */
+function AddRule() {
+  highest_active_rule = highest_active_rule + 1;
+  $('active'+highest_active_rule).checked = true;
+  UpdateRules();
+}
+/*
+ * Swap two rules
+ */
+function SwapRules(ra, rb) {
+
+  var things = new Array();
+  things[0] = 'hfield';
+  things[1] = 'compare';
+  things[2] = 'htext';
+  things[3] = 'action';
+  things[4] = 'fileinto';
+  things[5] = 'redirect';
+  things[6] = 'final';
+  things[7] = 'sizecomp';
+  things[8] = 'sizeval';
+  things[9] = 'automsg';
+
+  for (i=0; i<=9; ++i) {
+    tempval=$(things[i]+ra).value;
+    $(things[i]+ra).value = $(things[i]+rb).value;
+    $(things[i]+rb).value = tempval;
+  }
+}
+/*
+ * Delete a rule (percolate the deleted rule out to the end, then deactivate it)
+ */
+function DeleteRule(rd) {
+  for (j=rd; j<=highest_active_rule; ++j) {
+    SwapRules(j, (j+1));
+  }
+  $('active'+highest_active_rule).checked = false;
+}
+</script>
+
+
+<br>
+
+<div id="div_addrule"><a href="javascript:AddRule();"><?_("Add rule")></a><br></div>
+<script type="text/javascript">UpdateRules();</script>
+
diff --git a/webcit/static/t/sieve/display_one.html b/webcit/static/t/sieve/display_one.html
new file mode 100644 (file)
index 0000000..49329c4
--- /dev/null
@@ -0,0 +1,100 @@
+<table cellpadding=2 width=100%>
+<tr id="rule<?ITERATE:N>" class="<?ITERATE:ODDEVEN>">
+<td width=5% align="center">
+<div style="display:none">
+<input type="checkbox" name="active<?ITERATE:N>" id="active<?ITERATE:N>" <?%("COND:SIEVE:ACTIVE", 1, "checked", "")>>
+</div>
+
+<a href="javascript:SwapRules(<?ITERATE:N>,<?ITERATE:N> - 1);UpdateRules();"><img border="0" src="static/up_pointer.gif" title='<?_("Move rule up")>'/></a>
+<a href="javascript:SwapRules(<?ITERATE:N>,<?ITERATE:N> + 1);UpdateRules();"><img id="movedown%d" border="0" src="static/down_pointer.gif" title='<?_("Move rule down")>'/></a>
+<a href="javascript:DeleteRule(<?ITERATE:N>);UpdateRules();"><img id="delete<?ITERATE:N>" border="0" src="static/delete.gif" title='<?_("Delete rule")>'/></a>
+
+</td>
+
+<td width=5% align="center">
+<font size=+2><script type="text/javascript"> echo '<?ITERATE:N> + 1';</script></font>
+</td>
+
+<td width=20%><?_("If")>
+
+<select id="hfield<?ITERATE:N>" name="hfield<?ITERATE:N>" size=1 onChange="UpdateRules();">
+
+<option <?%("COND:SIEVE:HFIELD", 1, #"from",           "checked", "")> value="from"            ><?_("From")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"tocc",           "checked", "")> value="tocc"            ><?_("To or Cc")></option>              
+<option <?%("COND:SIEVE:HFIELD", 1, #"subject",        "checked", ""> value="subject",         )><?_("Subject")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"replyto",        "checked", ""> value="replyto"          )><?_("Reply-to")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"sender",         "checked", "")> value="sender"          ><?_("Sender")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"resentfrom",     "checked", "")> value="resentfrom"      ><?_("Resent-From")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"resentto",       "checked", "")> value="resentto"                ><?_("Resent-To")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"envfrom",        "checked", ""> value="envfrom"          )><?_("Envelope From")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"envto",          "checked", "")> value="envto"           ><?_("Envelope To")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"xmailer",        "checked", ""> value="xmailer"          )><?_("X-Mailer")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"xspamflag",      "checked", "")> value="xspamflag"       ><?_("X-Spam-Flag")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"xspamstatus",    "checked", "")> value="xspamstatus"     ><?_("X-Spam-Status")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"listid",         "checked", "")> value="listid"          ><?_("List-ID")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"size",           "checked", "")> value="size"            ><?_("Message size")></option>
+<option <?%("COND:SIEVE:HFIELD", 1, #"all",            "checked", "")> value="all"             ><?_("All")></option>
+</select>
+</td>
+
+<td width=20%>
+<div id="div_compare<?ITERATE:N>">
+<select id="compare<?ITERATE:N>" name="compare<?ITERATE:N>" size=1 onChange="UpdateRules();">
+<option <?%("COND:SIEVE:COMPARE", 1, #"contains",      "checked", "")>><?_("contains"          )></option>
+<option <?%("COND:SIEVE:COMPARE", 1, #"notcontains",   "checked", "")>><?_("does not contain"  )></option>
+<option <?%("COND:SIEVE:COMPARE", 1, #"is",            "checked", "")>><?_("is"                )></option>
+<option <?%("COND:SIEVE:COMPARE", 1, #"isnot",         "checked", "")>><?_("is not"            )></option>
+<option <?%("COND:SIEVE:COMPARE", 1, #"matches",       "checked", "")>><?_("matches"           )></option>
+<option <?%("COND:SIEVE:COMPARE", 1, #"notmatches",    "checked", "")>><?_("does not match"    )></option>
+</select>
+
+<input type="text" id="htext<?ITERATE:N>" name="htext<?ITERATE:N>" value="<?SIEVE:TEXT("X")>"> escputs(htext);
+</div>
+
+<div id="div_nocompare<?ITERATE:N>"><?_("(All messages)")></div>
+
+<div id="div_size<?ITERATE:N>">
+<select id="sizecomp<?ITERATE:N>" name="sizecomp<?ITERATE:N>" size=1 onChange="UpdateRules();">
+<option <?%("COND:SIEVE:SIZECOMP", 1, #"larger", "selected", ""> value="larger"><?_("is larger than")></option>
+<option <?%("COND:SIEVE:SIZECOMP", 1, #"smaller", "selected", ""> value="smaler"><?_("is smaller than")></option>
+</select>
+<input type="text" id="sizeval<?ITERATE:N>" name="sizeval<?ITERATE:N>" value="<?SIEVE:BYTES>">
+</div>
+</td>
+
+<td width=20%>
+<select id="action<?ITERATE:N>" name="action<?ITERATE:N>" size=1 onChange="UpdateRules();">
+<option <?%("COND:SIEVE:ACTION", 1, #"keep",   "selected", "")>><?_("Keep")>           </option>
+<option <?%("COND:SIEVE:ACTION", 1, #"discard",        "selected", "")>><?_("Discard silently")></option>
+<option <?%("COND:SIEVE:ACTION", 1, #"reject", "selected", "")>><?_("Reject")>         </option>
+<option <?%("COND:SIEVE:ACTION", 1, #"fileinto","selected", "")>><?_("Move message to")></option>
+<option <?%("COND:SIEVE:ACTION", 1, #"redirect","selected", "")>><?_("Forward to")>    </option>
+<option <?%("COND:SIEVE:ACTION", 1, #"vacation","selected", "")>><?_("Vacation")>      </option>
+</select>
+
+<div id="div_fileinto<?ITERATE:N>">
+<select name="fileinto<?ITERATE:N>" id="fileinto<?ITERATE:N>">
+<?ITERATE("LKRA", ="sieve_roomlist")>
+</select>
+</div>
+
+<div id="div_redirect<?ITERATE:N>">
+<input type="text" id="redirect<?ITERATE:N>" name="redirect<?ITERATE:N>" value='<?SIEVE:REDIRECT("X")>'></div>
+
+<div id="div_automsg<?ITERATE:N>"><?_("Message:")><br>
+<textarea name="automsg<?ITERATE:N>" id="automsg<?ITERATE:N>" wrap=soft rows=5>
+<?SIEVE:AUTOMSG("X")>
+</textarea>
+</div>
+
+</td>
+
+<td width=10% align="center">< _("and then")></td>
+<td width=20%>
+<select name="final<?ITERATE:N>" id="final<?ITERATE:N>" size=1 onChange="UpdateRules();">
+<option <?%("COND:SIEVE:FINAL", 1, #"continue", "select", "")> value="continue"><?_("continue processing")></option>
+<option <?%("COND:SIEVE:FINAL", 1, #"stop", "select", "")> value="stop"><?_("stop")></option>
+</select>
+</td>
+</tr>
+</table>
diff --git a/webcit/static/t/sieve/display_one_script.html b/webcit/static/t/sieve/display_one_script.html
new file mode 100644 (file)
index 0000000..658d75a
--- /dev/null
@@ -0,0 +1,3 @@
+<div id="script_<?SIEVE:SCRIPT:NAME("U")>" style="display:none">
+<textarea name="text_<?SIEVE:SCRIPT:NAME("U")>" wrap=soft rows=20 cols=80 width=80><?SIEVE:SCRIPT:CONTENT("X")></textarea>
+</div>
diff --git a/webcit/static/t/sieve/empty.html b/webcit/static/t/sieve/empty.html
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/webcit/static/t/sieve/list.html b/webcit/static/t/sieve/list.html
new file mode 100644 (file)
index 0000000..f564250
--- /dev/null
@@ -0,0 +1,85 @@
+<?--("iterate over an empty template, so we have the states already loaded for below")><?ITERATE("SIEVE:SCRIPTS", ="sieve_empty")><script type="text/javascript">
+var previously_active_script;                                                                  
+function ToggleSievePanels() {
+ d = ($('sieveform').bigaction.options[$('sieveform').bigaction.selectedIndex].value);
+ for (i=0; i<3; ++i) {
+  if (i == d) {
+   $('sievediv' + i).style.display = 'block';
+  }
+  else {
+   $('sievediv' + i).style.display = 'none';
+  }
+ }
+}
+                                                                       
+function ToggleScriptPanels() {
+ d = ($('sieveform').active_script.options[$('sieveform').active_script.selectedIndex].value);
+ if ($('script_' + previously_active_script)) {
+  $('script_' + previously_active_script).style.display = 'none';
+ }
+ $('script_' + d).style.display = 'block';
+ previously_active_script = d;
+}
+</script>                                                              
+<div id="banner">
+<img src="static/advanpage2_48x.gif">
+<h1><?_("View/edit server-side mail filters")></h1>
+</div>
+
+<div id="content" class="service">
+
+<table class="sieve_background">
+<tr><td valign=top>
+<form id="sieveform" method="post" action="save_sieve">
+<input type="hidden" name="nonce" value="<?NONCE>">
+
+<?--("The no filtering div")>
+<?_("When new mail arrives: ")>
+<select name="bigaction" size=1 onChange="ToggleSievePanels();">
+ <option <?%("COND:BSTR", 1, "__SIEVE:RULESSCRIPT", 1, "", "selected")> value="0"><?_("Leave it in my inbox without filtering")></option>
+ <option <?%("COND:BSTR", 1, "__SIEVE:RULESSCRIPT", 1, "selected", "")> value="1"><?_("Filter it according to rules selected below")></option>
+ <option <?%("COND:BSTR", 1, "__SIEVE:EXTERNAL_SCRIPT", 1, "selected", "")> value="2"><?_("Filter it through a manually edited script (advanced users only)")></option>
+</select>
+
+<div id="sievediv0" style="display:none">
+<div align="center"><br><br>
+<?_("Your incoming mail will not be filtered through any scripts.")>
+<br><br></div>
+</div>
+<?--("The webcit managed scripts div")>
+
+<div id="sievediv1" style="display:none">
+       display_rules_editor_inner_div();
+</div>
+<?--("The I am smart and can write my own Sieve scripts div ")>
+
+<div id="sievediv2" style="display:none">
+
+<?!("COND:BSTR", 1, "__SIEVE:RULESSCRIPT", 1)>
+<?_("The currently active script is: ")>
+<select name="active_script" size=1 onChange="ToggleScriptPanels();">
+<?ITERATE("SIEVE:SCRIPTS", ="sieve_list_select_one")>
+</select>
+
+&nbsp;&nbsp;&nbsp;
+<a href="display_add_remove_scripts"><?_("Add or delete scripts")></a>
+<br>
+<?ITERATE("SIEVE:SCRIPTS", ="sieve_display_one_script")>
+
+<??("X", 1)>
+
+<script type="text/javascript">ToggleScriptPanels();</script>
+</div>
+<?--("The rest of this is common for all panels... ")>
+
+<div align="center"><br>
+<input type="submit" name="save_button" value='<?_("Save changes")>'>
+&nbsp;
+<input type="submit" name="cancel_button" value='(?_("Cancel")>'>
+</div></form>
+
+</td></tr></table>
+
+<script type="text/javascript">ToggleSievePanels();</script>
+
+
diff --git a/webcit/static/t/sieve/list_select_one.html b/webcit/static/t/sieve/list_select_one.html
new file mode 100644 (file)
index 0000000..f546351
--- /dev/null
@@ -0,0 +1 @@
+<option <?%("COND:SIEVE:SCRIPT:ACTIVE" 1, 0, "selected", "")> value="<?SIEVE:SCRIPT:NAME("U")>"><?SIEVE:SCRIPT:NAME("X")></option>
diff --git a/webcit/static/t/sieve/none.html b/webcit/static/t/sieve/none.html
new file mode 100644 (file)
index 0000000..61d62c3
--- /dev/null
@@ -0,0 +1,14 @@
+<?=("head")>
+<?=("important_msg")><?%("COND:LOGGEDIN", 1, 1, 1, "", ="paging")>
+<div id="banner">
+<img src="static/advanpage2_48x.gif">
+<h1>
+<?_("View/edit server-side mail filters")>
+</h1>
+</div>
+<div id="content" class="service">
+<table class="sieve_background"><tr><td valign=top>
+<?_("This installation of Citadel was built without support for server-side mail filtering.<br>Please contact your system administrator if you require this feature.<br>")>
+
+</td></tr></table>
+<?=("trailing")>
diff --git a/webcit/static/t/sieve/roomlist.html b/webcit/static/t/sieve/roomlist.html
new file mode 100644 (file)
index 0000000..818b5f9
--- /dev/null
@@ -0,0 +1 @@
+<option <?%("COND:SIEVE:THISROOM", 1, 0, "checked", "")> value='<?ROOM:INFO:NAME("U")>' ><?ROOM:INFO:NAME("X")></select>
diff --git a/webcit/static/t/sieve/script_select.html b/webcit/static/t/sieve/script_select.html
new file mode 100644 (file)
index 0000000..3887a54
--- /dev/null
@@ -0,0 +1 @@
+<option <?%("COND:SIEVE:SCRIPT:ACTIVE", 1, 0, "selected", "")> value="<?SIEVE:SCRIPT:NAME("U")>"><?SIEVE:SCRIPT:NAME("X")></option>
index 354b51601623c3e77496df87c661df1b325c4bad..c737e75fb8502c446fd16475c3ae7ccf26bd0a3f 100644 (file)
@@ -109,6 +109,8 @@ const char *CtxNames[]  = {
        "Context DavNamespace",
        "Context TAB",
        "Context VCARD",
        "Context DavNamespace",
        "Context TAB",
        "Context VCARD",
+       "Context SIEVE List",
+       "Context SIEVE Script",
        "Context UNKNOWN"
 };
 
        "Context UNKNOWN"
 };
 
index ed0d4500a2e457372d0e789da51d266350280958..644b55950ad2a815d29abedd5af43b241b9ee4c4 100644 (file)
@@ -16,7 +16,7 @@ extern HashList *LocalTemplateCache;
 #define TYPE_BSTR 6
 #define TYPE_SUBTEMPLATE 7
 #define TYPE_INTDEFINE 8
 #define TYPE_BSTR 6
 #define TYPE_SUBTEMPLATE 7
 #define TYPE_INTDEFINE 8
-#define MAXPARAM  20
+#define MAXPARAM  25
 
 #define IS_NUMBER(a) ((a == TYPE_LONG) || (a == TYPE_PREFINT) || (a == TYPE_INTDEFINE))
 
 
 #define IS_NUMBER(a) ((a == TYPE_LONG) || (a == TYPE_PREFINT) || (a == TYPE_INTDEFINE))
 
@@ -57,8 +57,10 @@ enum {
 #define CTX_DAVNS 19
 #define CTX_TAB 20
 #define CTX_VCARD 21
 #define CTX_DAVNS 19
 #define CTX_TAB 20
 #define CTX_VCARD 21
+#define CTX_SIEVELIST 22
+#define CTX_SIEVESCRIPT 23
 
 
-#define CTX_UNKNOWN 22
+#define CTX_UNKNOWN 24
 
 
 /**
 
 
 /**
index 687580e2de359c8b790e0c61cc0ca54a2ca65ed8..8d3c6a885d442b736a56a202d267f5989ace6541 100644 (file)
@@ -275,7 +275,7 @@ void FlushReadBuf (void)
                pche = pch + len;
                if (WCC->ReadPos != pche)
                {
                pche = pch + len;
                if (WCC->ReadPos != pche)
                {
-                       syslog(1, "ERROR: somebody didn't eat his soup! Remaing Chars: %d [%s]\n", 
+                       syslog(1, "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n", 
                                pche - WCC->ReadPos, pche);
                        syslog(1, 
                                "--------------------------------------------------------------------------------\n"
                                pche - WCC->ReadPos, pche);
                        syslog(1, 
                                "--------------------------------------------------------------------------------\n"
@@ -298,7 +298,7 @@ void FlushReadBuf (void)
  *  buf the buffer to write to citadel server
  *  nbytes how many bytes to send to citadel server
  */
  *  buf the buffer to write to citadel server
  *  nbytes how many bytes to send to citadel server
  */
-void serv_write(const char *buf, int nbytes)
+int serv_write(const char *buf, int nbytes)
 {
        wcsession *WCC = WC;
        int bytes_written = 0;
 {
        wcsession *WCC = WC;
        int bytes_written = 0;
@@ -316,10 +316,11 @@ void serv_write(const char *buf, int nbytes)
                        WCC->serv_sock = (-1);
                        WCC->connected = 0;
                        WCC->logged_in = 0;
                        WCC->serv_sock = (-1);
                        WCC->connected = 0;
                        WCC->logged_in = 0;
-                       return;
+                       return 0;
                }
                bytes_written = bytes_written + retval;
        }
                }
                bytes_written = bytes_written + retval;
        }
+       return 1;
 }
 
 
 }
 
 
@@ -327,30 +328,32 @@ void serv_write(const char *buf, int nbytes)
  *  send line to server
  *  string the line to send to the citadel server
  */
  *  send line to server
  *  string the line to send to the citadel server
  */
-void serv_puts(const char *string)
+int serv_puts(const char *string)
 {
 #ifdef SERV_TRACE
        syslog(9, "%3d>>>%s\n", WC->serv_sock, string);
 #endif
        FlushReadBuf();
 
 {
 #ifdef SERV_TRACE
        syslog(9, "%3d>>>%s\n", WC->serv_sock, string);
 #endif
        FlushReadBuf();
 
-       serv_write(string, strlen(string));
-       serv_write("\n", 1);
+       if (!serv_write(string, strlen(string)))
+               return 0;
+       return serv_write("\n", 1);
 }
 
 /*
  *  send line to server
  *  string the line to send to the citadel server
  */
 }
 
 /*
  *  send line to server
  *  string the line to send to the citadel server
  */
-void serv_putbuf(const StrBuf *string)
+int serv_putbuf(const StrBuf *string)
 {
 #ifdef SERV_TRACE
        syslog(9, "%3d>>>%s\n", WC->serv_sock, ChrPtr(string));
 #endif
        FlushReadBuf();
 
 {
 #ifdef SERV_TRACE
        syslog(9, "%3d>>>%s\n", WC->serv_sock, ChrPtr(string));
 #endif
        FlushReadBuf();
 
-       serv_write(ChrPtr(string), StrLength(string));
-       serv_write("\n", 1);
+       if (!serv_write(ChrPtr(string), StrLength(string)))
+               return 0;
+       return serv_write("\n", 1);
 }
 
 
 }
 
 
@@ -359,11 +362,12 @@ void serv_putbuf(const StrBuf *string)
  *  format the formatstring
  *  ... the entities to insert into format 
  */
  *  format the formatstring
  *  ... the entities to insert into format 
  */
-void serv_printf(const char *format,...)
+int serv_printf(const char *format,...)
 {
        va_list arg_ptr;
        char buf[SIZ];
        size_t len;
 {
        va_list arg_ptr;
        char buf[SIZ];
        size_t len;
+       int rc;
 
        FlushReadBuf();
 
 
        FlushReadBuf();
 
@@ -374,10 +378,11 @@ void serv_printf(const char *format,...)
        len = strlen(buf);
        buf[len++] = '\n';
        buf[len] = '\0';
        len = strlen(buf);
        buf[len++] = '\n';
        buf[len] = '\0';
-       serv_write(buf, len);
+       rc = serv_write(buf, len);
 #ifdef SERV_TRACE
        syslog(9, ">>>%s", buf);
 #endif
 #ifdef SERV_TRACE
        syslog(9, ">>>%s", buf);
 #endif
+       return rc;
 }
 
 
 }
 
 
@@ -403,7 +408,7 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf)
                        return -1; 
                }
 
                        return -1; 
                }
 
-               serv_printf("READ %d|%d", bytes_read, total_len-bytes_read);
+               serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, bytes_read, total_len-bytes_read);
                if ( (rc = StrBuf_ServGetln(Buf) > 0) && (GetServerStatus(Buf, NULL) == 6) ) 
                {
                        if (rc < 0)
                if ( (rc = StrBuf_ServGetln(Buf) > 0) && (GetServerStatus(Buf, NULL) == 6) ) 
                {
                        if (rc < 0)
index 9872800b42b140dccbb5964fdd2e8f81952342bf..efb7f8242bd8e8b4b9df6c2a51af6bb406fcc7cb 100644 (file)
@@ -564,6 +564,9 @@ struct wcsession {
        int ib_wholist_expanded;
        int ib_roomlist_expanded;
 
        int ib_wholist_expanded;
        int ib_roomlist_expanded;
 
+/* our known Sieve scripts; loaded by SIEVE:SCRIPTS iterator. */
+       HashList *KnownSieveScripts;
+
 /* Transcoding cache buffers; used to avoid to frequent realloc */
        StrBuf *ConvertBuf1;
        StrBuf *ConvertBuf2;
 /* Transcoding cache buffers; used to avoid to frequent realloc */
        StrBuf *ConvertBuf1;
        StrBuf *ConvertBuf2;
@@ -662,7 +665,7 @@ int tcp_connectsock(char *, char *);
 int serv_getln(char *strbuf, int bufsize);
 int StrBuf_ServGetln(StrBuf *buf);
 int GetServerStatus(StrBuf *Line, long* FullState);
 int serv_getln(char *strbuf, int bufsize);
 int StrBuf_ServGetln(StrBuf *buf);
 int GetServerStatus(StrBuf *Line, long* FullState);
-void serv_puts(const char *string);
+int serv_puts(const char *string);
 void who(void);
 void push_destination(void);
 void pop_destination(void);
 void who(void);
 void push_destination(void);
 void pop_destination(void);
@@ -734,11 +737,6 @@ long gotoroom(const StrBuf *gname);
 void remove_march(const StrBuf *aaa);
 void dotskip(void);
 void validate(void);
 void remove_march(const StrBuf *aaa);
 void dotskip(void);
 void validate(void);
-void display_graphics_upload(char *, char *, char *);
-void do_graphics_upload(char *upl_cmd);
-void serv_write(const char *buf, int nbytes);
-void serv_putbuf(const StrBuf *string);
-void serv_printf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
 void shutdown_sessions(void);
 void do_housekeeping(void);
 void smart_goto(const StrBuf *);
 void shutdown_sessions(void);
 void do_housekeeping(void);
 void smart_goto(const StrBuf *);
@@ -809,6 +807,11 @@ int ical_ctdl_is_overlap(
 
 extern char *months[];
 extern char *days[];
 
 extern char *months[];
 extern char *days[];
+void display_graphics_upload(char *, char *, char *);
+void do_graphics_upload(char *upl_cmd);
+int serv_write(const char *buf, int nbytes);
+int serv_putbuf(const StrBuf *string);
+int serv_printf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
 int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf);
 int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize);
 int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize);
 int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf);
 int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize);
 int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize);