diff options
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | Makefile.in | 9 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | README | 25 | ||||
-rw-r--r-- | TODO | 15 | ||||
-rwxr-xr-x | configure | 201 | ||||
-rw-r--r-- | debug.h | 6 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 19 | ||||
-rw-r--r-- | mail.c | 31 | ||||
-rw-r--r-- | mail.h | 9 | ||||
-rw-r--r-- | mail2.c | 358 | ||||
-rw-r--r-- | parser.c | 6 | ||||
-rw-r--r-- | parser.h | 7 | ||||
-rw-r--r-- | processor.c | 15 | ||||
-rw-r--r-- | socket.c | 151 | ||||
-rw-r--r-- | socket.h | 40 |
16 files changed, 773 insertions, 128 deletions
diff --git a/Makefile.am b/Makefile.am index cb11a3b..4e0c311 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,7 +27,9 @@ udelay.c udelay.h \ display.c display.h \ pixmap.c pixmap.h \ fontmap.c fontmap.h \ -exec.c exec.h +exec.c exec.h \ +mail2.c \ +socket.c socket.h EXTRA_lcd4linux_SOURCES= \ acconfig.h \ diff --git a/Makefile.in b/Makefile.in index 65cd610..852c5fe 100644 --- a/Makefile.in +++ b/Makefile.in @@ -76,7 +76,7 @@ lcd4linux_LDFLAGS = $(X_LIBS) lcd4linux_LDADD = @DRIVERS@ @DRVLIBS@ lcd4linux_DEPENDENCIES = @DRIVERS@ -lcd4linux_SOURCES = lcd4linux.c debug.c debug.h cfg.c cfg.h lock.c lock.h parser.c parser.h processor.c processor.h system.c system.h isdn.c isdn.h mail.c mail.h seti.c seti.h battery.c battery.h filter.c filter.h udelay.c udelay.h display.c display.h pixmap.c pixmap.h fontmap.c fontmap.h exec.c exec.h +lcd4linux_SOURCES = lcd4linux.c debug.c debug.h cfg.c cfg.h lock.c lock.h parser.c parser.h processor.c processor.h system.c system.h isdn.c isdn.h mail.c mail.h seti.c seti.h battery.c battery.h filter.c filter.h udelay.c udelay.h display.c display.h pixmap.c pixmap.h fontmap.c fontmap.h exec.c exec.h mail2.c socket.c socket.h EXTRA_lcd4linux_SOURCES = acconfig.h BeckmannEgle.c Crystalfontz.c Crystalfontz.h HD44780.c MatrixOrbital.c PalmPilot.c Raster.c SIN.c Skeleton.c XWindow.c Text.c @@ -101,7 +101,7 @@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ lcd4linux_OBJECTS = lcd4linux.o debug.o cfg.o lock.o parser.o \ processor.o system.o isdn.o mail.o seti.o battery.o filter.o udelay.o \ -display.o pixmap.o fontmap.o exec.o +display.o pixmap.o fontmap.o exec.o mail2.o socket.o CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) @@ -120,8 +120,9 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/HD44780.P \ .deps/Skeleton.P .deps/Text.P .deps/XWindow.P .deps/battery.P \ .deps/cfg.P .deps/debug.P .deps/display.P .deps/exec.P .deps/filter.P \ .deps/fontmap.P .deps/isdn.P .deps/lcd4linux.P .deps/lock.P \ -.deps/mail.P .deps/parser.P .deps/pixmap.P .deps/processor.P \ -.deps/seti.P .deps/system.P .deps/udelay.P +.deps/mail.P .deps/mail2.P .deps/parser.P .deps/pixmap.P \ +.deps/processor.P .deps/seti.P .deps/socket.P .deps/system.P \ +.deps/udelay.P SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES) OBJECTS = $(lcd4linux_OBJECTS) @@ -40,3 +40,8 @@ lcd4linux-0.98 - seti@home client: new tokens 'hc' (% completed) and 'ht' (cpu time needed) - simple web-server driver (see README.Webinterface) + +- mail suport for pop3 and imap4, token 'u1' ..'u9' show unseen mail + (which is propably incorrect for normal mbox) + +- added another verbose level (-vvv) for debugging socket traffic @@ -1,5 +1,5 @@ # -# $Id: README,v 1.17 2001/03/13 07:41:22 reinelt Exp $ +# $Id: README,v 1.18 2001/03/14 13:19:29 ltoetsch Exp $ # This is the README file for lcd4linux @@ -8,8 +8,8 @@ This is the README file for lcd4linux INTRODUCTION lcd4linux is a small program that reads various information from the kernel -(and probably from other subsystems, especially ISDN) and displays them on a -LCD. +(and from other subsystems, especially ISDN) and displays them on a LCD or +other display device. It supports displaying text values and different types of bars: Horizontal and vertical bars, logarithmic bars, split bars (two independent bars in one row). @@ -37,6 +37,8 @@ lcd4linux [-c key=val] [-F] [-f config-file] [-o output] [-q] [-v] suppress startup splash screen with '-q' generate info messages with '-v' generate debugging messages with '-vv' + debug socket traffic too, with '-vvv' + DIAGNOSTICS @@ -154,6 +156,18 @@ Data-specific options: Min_x1 ..9 min value for bars (default 0) battery: Battwarning 10 (default 10) + + Mailbox: + The option string may be a plain mbox file or a pop3/imap4 server + string with the following format: + + pop3:[user[:pass]@]machine[:port] + imap4:[user[:pass]@]machine[:port][/dir] + + Port defaults to 110 and 143 respectively. + If /dir is not given, INBOX is assumed. + + Delay_e1..e9 delay in seconds for querying the MailboxN (default 5) Driver-specific options: @@ -228,9 +242,10 @@ Tokens: 'bp', battery percentage (APM by now) 'bs', battery status ('=' = online, '+' = charging, '-' discharging) 'bd', battery duration in s{econds}, m{ins}, h{ours} or d{ays} - 'e*', mails in mailbox 1-9, + 'e*', mails in mailbox 1-9, total mail + 'u*', mails in mailbox 1-9, unseen mail 'x*', output of command 1-9 Please have a look at lcd4linux.conf.sample, where you can find examples -of all options. +of all options and there usage. @@ -50,9 +50,10 @@ will be done with the big config-rework 2001-03-07 Michael Reinelt <reinelt@eunet.at> use ppdev instead of ugly outb() -2001-03-09 Michael Reinelt <reinelt@eunet.at> -replace udelay() assembly loop with rdtsc (read time stamp counter) -at least try to.... +// 2001-03-09 Michael Reinelt <reinelt@eunet.at> +// replace udelay() assembly loop with rdtsc (read time stamp counter) +// at least try to.... +// done -mr 2001-03-09 Leo Tötsch <lt@toetsch.at> read configuration file earlier (before forking) so that specific drivers @@ -62,5 +63,9 @@ There's a reason for forking that early, but I forgot... 2001-03-12 Michael Reinelt <reinelt@eunet.at> remove USE_OLD_UDELAY after wide testing of new udelay code -2001-03-12 Michael Reinelt <reinelt@eunet.at> -create a NEWS file with changes/enhancements of every release +// 2001-03-12 Michael Reinelt <reinelt@eunet.at> +// crate a NEWS file with changes/enhancements of every release +// done -mr + +2001-03-14 Leopold Toetsch <lt@toetsch.at> +improve unseen for mbox (check Status:) @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 +# Generated automatically using autoconf version 2.14 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -344,7 +344,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" + echo "configure generated by autoconf version 2.14" exit 0 ;; -with-* | --with-*) @@ -1680,6 +1680,7 @@ else /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname(); +char (*f)(); int main() { @@ -1689,12 +1690,12 @@ int main() { #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) choke me #else -gethostbyname(); +f = gethostbyname; #endif ; return 0; } EOF -if { (eval echo configure:1698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1699: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -1715,7 +1716,7 @@ fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:1719: checking for gethostbyname in -lnsl" >&5 +echo "configure:1720: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1723,7 +1724,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <<EOF -#line 1727 "configure" +#line 1728 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1734,7 +1735,7 @@ int main() { gethostbyname() ; return 0; } EOF -if { (eval echo configure:1738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1764,12 +1765,12 @@ fi # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:1768: checking for connect" >&5 +echo "configure:1769: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1773 "configure" +#line 1774 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char connect(); below. */ @@ -1778,6 +1779,7 @@ else /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char connect(); +char (*f)(); int main() { @@ -1787,12 +1789,12 @@ int main() { #if defined (__stub_connect) || defined (__stub___connect) choke me #else -connect(); +f = connect; #endif ; return 0; } EOF -if { (eval echo configure:1796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -1813,7 +1815,7 @@ fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:1817: checking for connect in -lsocket" >&5 +echo "configure:1819: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1821,7 +1823,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 1825 "configure" +#line 1827 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1832,7 +1834,7 @@ int main() { connect() ; return 0; } EOF -if { (eval echo configure:1836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1856,12 +1858,12 @@ fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 -echo "configure:1860: checking for remove" >&5 +echo "configure:1862: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1865 "configure" +#line 1867 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char remove(); below. */ @@ -1870,6 +1872,7 @@ else /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char remove(); +char (*f)(); int main() { @@ -1879,12 +1882,12 @@ int main() { #if defined (__stub_remove) || defined (__stub___remove) choke me #else -remove(); +f = remove; #endif ; return 0; } EOF -if { (eval echo configure:1888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1891: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_remove=yes" else @@ -1905,7 +1908,7 @@ fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 -echo "configure:1909: checking for remove in -lposix" >&5 +echo "configure:1912: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1913,7 +1916,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <<EOF -#line 1917 "configure" +#line 1920 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1924,7 +1927,7 @@ int main() { remove() ; return 0; } EOF -if { (eval echo configure:1928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1948,12 +1951,12 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 -echo "configure:1952: checking for shmat" >&5 +echo "configure:1955: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1957 "configure" +#line 1960 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shmat(); below. */ @@ -1962,6 +1965,7 @@ else /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shmat(); +char (*f)(); int main() { @@ -1971,12 +1975,12 @@ int main() { #if defined (__stub_shmat) || defined (__stub___shmat) choke me #else -shmat(); +f = shmat; #endif ; return 0; } EOF -if { (eval echo configure:1980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else @@ -1997,7 +2001,7 @@ fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 -echo "configure:2001: checking for shmat in -lipc" >&5 +echo "configure:2005: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2005,7 +2009,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <<EOF -#line 2009 "configure" +#line 2013 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2016,7 +2020,7 @@ int main() { shmat() ; return 0; } EOF -if { (eval echo configure:2020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2049,7 +2053,7 @@ fi # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 -echo "configure:2053: checking for IceConnectionNumber in -lICE" >&5 +echo "configure:2057: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2057,7 +2061,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 2061 "configure" +#line 2065 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2068,7 +2072,7 @@ int main() { IceConnectionNumber() ; return 0; } EOF -if { (eval echo configure:2072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2094,7 +2098,7 @@ fi echo $ac_n "checking which drivers to compile""... $ac_c" 1>&6 -echo "configure:2098: checking which drivers to compile" >&5 +echo "configure:2102: checking which drivers to compile" >&5 # Check whether --with-drivers or --without-drivers was given. if test "${with_drivers+set}" = set; then withval="$with_drivers" @@ -2285,12 +2289,12 @@ fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2289: checking for ANSI C header files" >&5 +echo "configure:2293: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2294 "configure" +#line 2298 "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> @@ -2298,7 +2302,7 @@ else #include <float.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2315,7 +2319,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 2319 "configure" +#line 2323 "configure" #include "confdefs.h" #include <string.h> EOF @@ -2333,7 +2337,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 2337 "configure" +#line 2341 "configure" #include "confdefs.h" #include <stdlib.h> EOF @@ -2354,7 +2358,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext <<EOF -#line 2358 "configure" +#line 2362 "configure" #include "confdefs.h" #include <ctype.h> #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2365,7 +2369,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2393,12 +2397,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:2397: checking for $ac_hdr that defines DIR" >&5 +echo "configure:2401: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2402 "configure" +#line 2406 "configure" #include "confdefs.h" #include <sys/types.h> #include <$ac_hdr> @@ -2406,7 +2410,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:2410: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2414: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -2431,7 +2435,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:2435: checking for opendir in -ldir" >&5 +echo "configure:2439: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2439,7 +2443,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <<EOF -#line 2443 "configure" +#line 2447 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2450,7 +2454,7 @@ int main() { opendir() ; return 0; } EOF -if { (eval echo configure:2454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2472,7 +2476,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:2476: checking for opendir in -lx" >&5 +echo "configure:2480: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2480,7 +2484,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <<EOF -#line 2484 "configure" +#line 2488 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2491,7 +2495,7 @@ int main() { opendir() ; return 0; } EOF -if { (eval echo configure:2495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2514,12 +2518,12 @@ fi fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:2518: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:2522: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2523 "configure" +#line 2527 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/wait.h> @@ -2535,7 +2539,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:2539: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2543: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -2559,17 +2563,17 @@ for ac_hdr in fcntl.h limits.h strings.h sys/ioctl.h sys/time.h syslog.h unistd. do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2563: checking for $ac_hdr" >&5 +echo "configure:2567: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2568 "configure" +#line 2572 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2573: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2599,17 +2603,17 @@ for ac_hdr in sys/io.h asm/io.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2603: checking for $ac_hdr" >&5 +echo "configure:2607: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2608 "configure" +#line 2612 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2613: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2617: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2639,17 +2643,17 @@ for ac_hdr in gd/gd.h gd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2643: checking for $ac_hdr" >&5 +echo "configure:2647: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2648 "configure" +#line 2652 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2653: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2657: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2679,17 +2683,17 @@ for ac_hdr in net/if_ppp.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2683: checking for $ac_hdr" >&5 +echo "configure:2687: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2688 "configure" +#line 2692 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2693: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2697: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2719,17 +2723,17 @@ for ac_hdr in asm/msr.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2723: checking for $ac_hdr" >&5 +echo "configure:2727: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2728 "configure" +#line 2732 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2733: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2757,12 +2761,12 @@ done echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:2761: checking for working const" >&5 +echo "configure:2765: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2766 "configure" +#line 2770 "configure" #include "confdefs.h" int main() { @@ -2811,7 +2815,7 @@ ccp = (char const *const *) p; ; return 0; } EOF -if { (eval echo configure:2815: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2819: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -2832,21 +2836,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:2836: checking for inline" >&5 +echo "configure:2840: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <<EOF -#line 2843 "configure" +#line 2847 "configure" #include "confdefs.h" int main() { } $ac_kw foo() { ; return 0; } EOF -if { (eval echo configure:2850: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2854: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -2872,12 +2876,12 @@ EOF esac echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:2876: checking for pid_t" >&5 +echo "configure:2880: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2881 "configure" +#line 2885 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -2905,12 +2909,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:2909: checking for size_t" >&5 +echo "configure:2913: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2914 "configure" +#line 2918 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -2938,12 +2942,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:2942: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:2946: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2947 "configure" +#line 2951 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/time.h> @@ -2952,7 +2956,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:2956: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2960: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -2973,12 +2977,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:2977: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:2981: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2982 "configure" +#line 2986 "configure" #include "confdefs.h" #include <sys/types.h> #include <time.h> @@ -2986,7 +2990,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:2990: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2994: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -3007,12 +3011,12 @@ EOF fi echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:3011: checking for uid_t in sys/types.h" >&5 +echo "configure:3015: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3016 "configure" +#line 3020 "configure" #include "confdefs.h" #include <sys/types.h> EOF @@ -3043,13 +3047,13 @@ fi if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:3047: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:3051: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext <<EOF -#line 3053 "configure" +#line 3057 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -3067,7 +3071,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 3071 "configure" +#line 3075 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -3089,7 +3093,7 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 fi echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:3093: checking for 8-bit clean memcmp" >&5 +echo "configure:3097: checking for 8-bit clean memcmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3097,7 +3101,7 @@ else ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <<EOF -#line 3101 "configure" +#line 3105 "configure" #include "confdefs.h" main() @@ -3107,7 +3111,7 @@ main() } EOF -if { (eval echo configure:3111: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -3125,12 +3129,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:3129: checking return type of signal handlers" >&5 +echo "configure:3133: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3134 "configure" +#line 3138 "configure" #include "confdefs.h" #include <sys/types.h> #include <signal.h> @@ -3147,7 +3151,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:3151: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -3168,12 +3172,12 @@ EOF for ac_func in gettimeofday putenv select socket strdup strerror strstr strtol uname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3172: checking for $ac_func" >&5 +echo "configure:3176: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3177 "configure" +#line 3181 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3182,6 +3186,7 @@ else /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); +char (*f)(); int main() { @@ -3191,12 +3196,12 @@ int main() { #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +f = $ac_func; #endif ; return 0; } EOF -if { (eval echo configure:3200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3311,7 +3316,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" + echo "$CONFIG_STATUS generated by autoconf version 2.14" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -1,4 +1,4 @@ -/* $Id: debug.h,v 1.2 2000/08/10 09:44:09 reinelt Exp $ +/* $Id: debug.h,v 1.3 2001/03/14 13:19:29 ltoetsch Exp $ * * debug messages * @@ -20,6 +20,9 @@ * * * $Log: debug.h,v $ + * Revision 1.3 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * * Revision 1.2 2000/08/10 09:44:09 reinelt * * new debugging scheme: error(), info(), debug() @@ -39,6 +42,7 @@ void message (int level, const char *format, ...); +#define sockdebug(args...) message (3, args) #define debug(args...) message (2, __FILE__ ": " args) #define info(args...) message (1, args) #define error(args...) message (0, args) diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 6724650..a0870a7 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -105,8 +105,27 @@ Overload 2.0 Battwarning 10 SetiDir /etc/setiathome + +# normal local mbox Mailbox1 /var/spool/mail/michi +# POP3 mail @ machine +Mailbox2 pop3:user:pass@machine + +# IMAP4 mail folder @ machine +Mailbox3 imap4:user:pass@machine/folder + +# Full syntax of pop3/imap4 is: +# [user[:pass]@]machine[:port][/dir] +# +# display total/unseen mails of Mailbox3 +# Row6 "Mails %e3/%u3" + +# delay query of MailboxN in seconds (default = 5) +Delay_e1 5 +Delay_e2 20 +Delay_e3 20 + Sensor1 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp1 Sensor1_min 30 Sensor1_max 50 @@ -1,4 +1,4 @@ -/* $Id: mail.c,v 1.5 2001/03/13 08:34:15 reinelt Exp $ +/* $Id: mail.c,v 1.6 2001/03/14 13:19:29 ltoetsch Exp $ * * email specific functions * @@ -20,6 +20,9 @@ * * * $Log: mail.c,v $ + * Revision 1.6 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * * Revision 1.5 2001/03/13 08:34:15 reinelt * * corrected a off-by-one bug with sensors @@ -69,7 +72,7 @@ #include "debug.h" #include "mail.h" -int Mail (int index, int *num) +int Mail (int index, int *num, int *unseen) { FILE *fstr; char buffer[32]; @@ -89,7 +92,15 @@ int Mail (int index, int *num) if (index<0 || index>MAILBOXES) return -1; - if (time(NULL)==now[index]) return 0; // More then 1 second after last check + if (now[index] == 0) { /* not first time, to give faster a chance */ + now[index] = -1; + return 0; + } + if (now[index] > 0) { /* first time, immediately, else wait */ + sprintf(txt1, "Delay_e%d", index); + if (time(NULL)<=now[index]+atoi(cfg_get(txt1)?:"5")) + return 0; // More then 5/Delay_eX seconds after last check? + } time(&now[index]); // for Mailbox #index /* Build the filename from the config @@ -109,7 +120,15 @@ int Mail (int index, int *num) */ rc=stat(fnp1, &fst); if ( rc != 0 ) { - error ("Error getting stat of Mailbox%d", index ); + /* + is it pop3 or imap4? + */ + rc = Mail_pop_imap(fnp1, num, unseen); + if (rc == 0) + return 0; + else + cfgmbx[index] = FALSE; /* don't try again */ + error ("Error getting stat of Mailbox%d", index); return (-1); } if ( mbxlt[index] != fst.st_mtime ) { @@ -145,6 +164,10 @@ int Mail (int index, int *num) } } } + /* FIXME look at the Status of Mails */ + *unseen = v1 - mbxnum[index]; + if (*unseen < 0) + *unseen = 0; mbxnum[index]=v1; *num=v1; return (0); @@ -1,4 +1,4 @@ -/* $Id: mail.h,v 1.2 2001/03/08 09:02:04 reinelt Exp $ +/* $Id: mail.h,v 1.3 2001/03/14 13:19:29 ltoetsch Exp $ * * email specific functions * @@ -20,6 +20,9 @@ * * * $Log: mail.h,v $ + * Revision 1.3 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * * Revision 1.2 2001/03/08 09:02:04 reinelt * * seti client cleanup @@ -34,6 +37,6 @@ #define MAILBOXES 9 -int Mail (int index, int *num); - +int Mail (int index, int *num, int *unseen); +int Mail_pop_imap(char *mbx, int *num, int *unseen); /* mail2.c */ #endif @@ -0,0 +1,358 @@ +/* $Id: mail2.c,v 1.1 2001/03/14 13:19:29 ltoetsch Exp $ + * + * mail: pop3, imap functions + * + * Copyright 2001 by Leopold Tötsch (lt@toetsch.at) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: mail2.c,v $ + * Revision 1.1 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * + * + * Exported Functions: + * + * int Mail_pop_imap(char *mbox, int *total_mails, int *unseen); + * returns -1 on error, 0 on success + * + */ + +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <malloc.h> +#include <errno.h> + +#include "debug.h" +#include "socket.h" + +#define PROTO_UNKNOWN -1 +#define PROTO_POP3 110 +#define PROTO_IMAP4 143 + +/* + * parse_proto() + * + * parse a MailboxN entry in 's' as + * + * proto:[user[:pass]@]machine[:port][/dir] + * + * 's' get's destroyed + * returns 0 on success, -1 on error + * + */ + +static int parse_proto(char *s, int *proto, char **user, char **pass, + char **machine, int *port, char **dir) +{ + struct + { + char *prefix; + int proto; + } + protos[] = + { + { "pop3:", PROTO_POP3 }, + { "imap4:", PROTO_IMAP4 }, + }; + int i; + char *p, *q; + static char empty[] = ""; + static char INBOX[] = "INBOX"; + + *proto = *port = PROTO_UNKNOWN; + for (i=0; i< sizeof(protos)/sizeof(protos[0]); i++) + { + if (memcmp(s, protos[i].prefix, strlen(protos[i].prefix)) == 0) + { + *proto = *port = protos[i].proto; + break; + } + } + if (*proto == PROTO_UNKNOWN) + return -1; + + p = s + strlen(protos[i].prefix); + /* + * this might fail if user or pass contains a '/' + * + */ + if ((q = strchr(p, '/')) != NULL) + { + /* /dir */ + *dir = q + 1; + *q = '\0'; + } + else + *dir = empty; + + if ((q = strchr(p, '@')) != NULL) + { + /* user, pass is present */ + *machine = q + 1; + *q = '\0'; + *user = p; + if ((q = strchr(p, ':')) != NULL) + { + /* user[:pass] */ + *q = '\0'; + *pass = q+1; + } + else + *pass = empty; + } + else + { + *machine = p; + *user = *pass = empty; + } + + if ((q = strchr(*machine, ':')) != NULL) + { + /* machine[:pass] */ + *q = '\0'; + *port = atoi(q+1); + if (*port <= 0 || *port >= 0xffff) + return -1; + } + if (!**machine) + return -1; + if (*proto == PROTO_POP3 && **dir) + return -1; + if (*proto == PROTO_IMAP4 && !**dir) + *dir = INBOX; + return 0; +} + + +/* write buffer, compare with match */ + +#define BUFLEN 256 +static int wr_rd(int fd, char *buf, char *match, + char *err, char *machine, int port) +{ + int n; + n = write_socket(fd, buf); + if (n <= 0) + { + error("Couldn't write to %s:%d (%s)", machine, port, strerror(errno)); + close(fd); + return -1; + } + n = read_socket_match(fd, buf, BUFLEN-1, match); + if (n <= 0) + { + error("%s %s:%d (%s)", err, machine, port, strerror(errno)); + close(fd); + return -1; + } + return n; +} + +static int check_imap4(char *user, char *pass, char *machine, + int port, char *dir, int *total, int *unseen) +{ + int fd = open_socket(machine, port); + int n; + char buf[BUFLEN]; + char *p; + + if (fd < 0) + { + error("Couldn't connect to %s:%d (%s)", machine, port, strerror(errno)); + return -1; + } + n = read_socket_match(fd, buf, BUFLEN-1, "* OK"); + if (n <= 0) { + error("Server doesn't respond %s:%d (%s)", machine, port, strerror(errno)); + close(fd); + return -1; + } + sprintf(buf, ". LOGIN %s %s\r\n", user, pass); + if (wr_rd(fd, buf, ". OK", "Wrong User/PASS?", machine, port) <= 0) + return -1; + sprintf(buf, ". STATUS %s (MESSAGES UNSEEN)\r\n", dir); + if (wr_rd(fd, buf, "*", "Wrong dir?", machine, port) <= 0) + return -1; + if ((p = strstr(buf, "MESSAGES")) != NULL) + sscanf(p, "%*s %d", total); + else { + error("Server doesn't provide MESSAGES (%s)", machine, port, strerror(errno)); + close(fd); + return -1; + } + if ((p = strstr(buf, "UNSEEN")) != NULL) + sscanf(p, "%*s %d", unseen); + else { + error("Server doesn't provide UNSEEN (%s)", machine, port, strerror(errno)); + close(fd); + return -1; + } + close(fd); + return 0; +} + +static int check_pop3(char *user, char *pass, char *machine, + int port, int *total, int *unseen) +{ + int fd = open_socket(machine, port); + int n; + char buf[BUFLEN]; + + if (fd < 0) + { + error("Couldn't connect to %s:%d (%s)", machine, port, strerror(errno)); + return -1; + } + n = read_socket_match(fd, buf, BUFLEN-1, "+OK"); + if (n <= 0) { + error("Server doesn't respond %s:%d (%s)", machine, port, strerror(errno)); + close(fd); + return -1; + } + if (*user) + { + sprintf(buf, "USER %s\r\n", user); + if (wr_rd(fd, buf, "+OK", "Wrong USER?", machine, port) <= 0) + return -1; + } + if (*pass) + { + sprintf(buf, "PASS %s\r\n", pass); + if (wr_rd(fd, buf, "+OK", "Wrong PASS?", machine, port) <= 0) + return -1; + } + sprintf(buf, "STAT\r\n"); + if (wr_rd(fd, buf, "+OK", "Wrong STAT answer?", machine, port) <= 0) + return -1; + sscanf(buf, "+OK %d", total); + if (*total) { + sprintf(buf, "LAST\r\n"); + if (wr_rd(fd, buf, "+OK", "Wrong LAST answer?", machine, port) <= 0) + return -1; + sscanf(buf, "+OK %d", unseen); + *unseen = *total - *unseen; + } + close(fd); + return 0; +} + +int Mail_pop_imap(char *s, int *total, int *unseen) +{ + int proto, port, ret; + char *user, *pass, *machine, *dir, *ds; + + ds = strdup(s); + if (ds == NULL) + { + error("Out of mem"); + return -1; + } + ret = parse_proto(ds, &proto, &user, &pass, + &machine, &port, &dir) ; + if (ret < 0) + error("Not a pop3/imap4 mailbox"); + else + ret = (proto == PROTO_POP3) ? + check_pop3(user, pass, machine, port, total, unseen) : + check_imap4(user, pass, machine, port, dir, total, unseen); + free(ds); + return ret; +} + +#ifdef STANDALONE + +/* + * test parse_proto with some garbage + * + */ + +int foreground = 1; +int debugging = 3; + +/* + * for STANDALONE tests, disable Text driver and + * + * cc -DSTANDALONE mail2.c socket.c debug.c -g -Wall -o mail2 + * + */ + +#ifdef CHECK_PARSER + +static int test(char *s) +{ + int ret; + int proto, port; + char *user, *pass, *machine, *dir, *ds; + + ds = strdup(s); + ret = parse_proto(ds, &proto, &user, &pass, + &machine, &port, &dir) ; + printf("parse_proto(%s) ret=%d\n", s, ret); + if (!ret) + printf( + "\tproto='%d'\n" + "\tuser='%s'\n" + "\tpass='%s'\n" + "\tmachine='%s'\n" + "\tport='%d'\n" + "\tdir='%s'\n", + proto,user,pass,machine,port,dir); + free(ds); + return ret; +} +#endif + +int main(int argc, char *argv[]) +{ + +#ifdef CHECK_PARSER + int i, ret; + /* proto:[user[:pass]@]machine[:port][/dir] */ + char *t[] = + { + "pop3:sepp:Geheim@Rechner:123", + "pop3:sepp@Rechner", + "pop3:Rechner:123", + "imap4:sepp:Geheim@Rechner/dir@/:pfad", + "imap4:sepp:Geheim@Rechner", + "imap4sepp:Geheim@Rechner/dir@/:pfad", + "imap4:sepp:Geheim/Rechner/dir@/:pfad", + "pop3:sepp@:", + 0 + }; + + ret = 0; + if (argc > 1) + ret |= test(argv[1]); + else + for (i = 0; t[i]; i++) + ret |= test(t[i]); + return ret; +# else + + int total = -1, unseen = -1; + char *mbx = "imap4:user:pass@server/folder/file"; + int ret = Mail_pop_imap(mbx, &total, &unseen); + printf("ret = %d, total = %d unseen = %d\n", ret, total, unseen); + return ret; + +# endif +} + +#endif @@ -1,4 +1,4 @@ -/* $Id: parser.c,v 1.14 2001/03/13 08:34:15 reinelt Exp $ +/* $Id: parser.c,v 1.15 2001/03/14 13:19:29 ltoetsch Exp $ * * row definition parser * @@ -20,6 +20,9 @@ * * * $Log: parser.c,v $ + * Revision 1.15 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * * Revision 1.14 2001/03/13 08:34:15 reinelt * * corrected a off-by-one bug with sensors @@ -162,6 +165,7 @@ static SYMTAB Symtab[] = {{ "%", T_PERCENT, C_GENERIC, 0 }, { "bs", T_BATT_STAT, C_BATT, 0 }, { "bd", T_BATT_DUR, C_BATT, 0 }, { "e*", T_MAIL, C_MAIL, 0 }, + { "u*", T_MAIL_UNSEEN,C_MAIL, 0 }, { "s*", T_SENSOR, C_SENSOR, 1 }, { "x*", T_EXEC, C_EXEC, 1 }, { "", -1, 0 }}; @@ -1,4 +1,4 @@ -/* $Id: parser.h,v 1.10 2001/03/07 18:10:21 ltoetsch Exp $ +/* $Id: parser.h,v 1.11 2001/03/14 13:19:29 ltoetsch Exp $ * * row definition parser * @@ -20,6 +20,9 @@ * * * $Log: parser.h,v $ + * Revision 1.11 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * * Revision 1.10 2001/03/07 18:10:21 ltoetsch * added e(x)ec commands * @@ -84,7 +87,7 @@ typedef enum { T_SETI_PRC, T_SETI_CPU, T_BATT_PERC, T_BATT_STAT, T_BATT_DUR, T_EXTENDED, - T_MAIL, + T_MAIL, T_MAIL_UNSEEN, T_SENSOR, T_EXEC } TOKEN; diff --git a/processor.c b/processor.c index 8676747..45eaff7 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.19 2001/03/13 08:34:15 reinelt Exp $ +/* $Id: processor.c,v 1.20 2001/03/14 13:19:29 ltoetsch Exp $ * * main data processing * @@ -20,6 +20,9 @@ * * * $Log: processor.c,v $ + * Revision 1.20 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * * Revision 1.19 2001/03/13 08:34:15 reinelt * * corrected a off-by-one bug with sensors @@ -152,7 +155,7 @@ struct { int usage, in, out, total, max, peak; } isdn; struct { int rx, tx, total, max, peak; } ppp; struct { int perc, stat; double dur; } batt; struct { double perc, cput; } seti; -struct { int num; } mail[MAILBOXES+1]; +struct { int num, unseen;} mail[MAILBOXES+1]; struct { double val, min, max; } sensor[SENSORS+1]; static double query (int token) @@ -245,6 +248,9 @@ static double query (int token) case T_MAIL: return mail[(token>>8)-'0'].num; + case T_MAIL_UNSEEN: + return mail[(token>>8)-'0'].unseen; + case T_SENSOR: return sensor[(token>>8)-'0'].val; @@ -450,6 +456,7 @@ static void print_token (int token, char **p, char *start, int maxlen) break; case T_MAIL: + case T_MAIL_UNSEEN: val=query(token); *p+=sprintf (*p, "%3.0f", val); break; @@ -521,8 +528,8 @@ static void collect_data (void) } for (i=0; i<=MAILBOXES; i++) { - if (token_usage[T_MAIL]&(1<<i)) { - Mail (i, &mail[i].num); + if (token_usage[T_MAIL]&(1<<i) || token_usage[T_MAIL_UNSEEN]&(1<<i) ) { + Mail (i, &mail[i].num, &mail[i].unseen); } } diff --git a/socket.c b/socket.c new file mode 100644 index 0000000..fa57b53 --- /dev/null +++ b/socket.c @@ -0,0 +1,151 @@ +/* $Id: socket.c,v 1.1 2001/03/14 13:19:29 ltoetsch Exp $ + * + * simple socket functions + * + * Copyright 2001 by Leopold Tötsch (lt@toetsch.at) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: socket.c,v $ + * Revision 1.1 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * + * + */ + +/* + * Exported Functions: + * + * int open_socket(char *machine, int port); + * + * open and connect to socket on machine:port + * returns fd on success or -1 on error + * + * + * int read_socket(int fd, char *buf, size_t size); + * + * read maximum size chars into buf + * returns n byte read, 0 on timeout, -1 on error + * + * + * int read_socket_match(int fd, char *buf, size_t size, char *match); + * + * read maximum size chars into buf and check if the start of line + * matches 'match' + * returns n on successful match, 0 on timeout/mismatch, -1 on error + * + * + * int write_socket(int fd, char *string); + * + * write string to socket fd + * returns n byte written, -1 on error + * + * with debuglevel 3, traffic on socket is logged + * + */ + +#include <stdio.h> +#include <errno.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> + +#include "debug.h" + +#define TIMEOUT 2 /* 2 seconds timeout */ + +int open_socket(char *machine, int port) +{ + struct hostent *addr; + struct sockaddr_in s; + int fd; + + addr = gethostbyname (machine); + if (addr) + memcpy (&s.sin_addr, addr->h_addr, sizeof (struct in_addr)); + else + return -1; + + fd = socket (AF_INET, SOCK_STREAM, 0); + if (fd < 0) + return -1; + + s.sin_family = AF_INET; + s.sin_port = htons (port); + + if (connect (fd, (struct sockaddr *)&s, sizeof (s)) < 0) + return -1; + return fd; +} + +int read_socket(int fd, char *buf, size_t size) +{ + fd_set readfds; + struct timeval tv; + int n = 0; + + FD_ZERO(&readfds); + FD_SET(fd, &readfds); + tv.tv_sec = TIMEOUT; + tv.tv_usec = 0; + + if (select(fd+1, &readfds, NULL, NULL, &tv) > 0) + n = read(fd, buf, size); + if (n >= 0) + buf[n] = '\0'; + else + buf[0] = '\0'; + sockdebug("<(%d),%s", n, buf); + return n; +} + +int read_socket_match(int fd, char *buf, size_t size, char *match) +{ + int n = read_socket(fd, buf, size); + int len; + if (n <= 0) + return n; + len = strlen(match); + if (n >= len && memcmp(buf, match, len) == 0) + return n; + return 0; +} + +static char *del_pass(char *s) +{ + char *p; + /* del pop3 pass from log */ + if (memcmp(s, "PASS ", 5) == 0) + for (p = s+5; *p && *p != '\r'; p++) + *p = '*'; + /* del imap4 pass from log */ + else if (memcmp(s, ". LOGIN", 7) == 0) + for (p = s + strlen(s)-3 ; p > s && *p != ' '; p--) + *p = '*'; + return s; +} + +int write_socket(int fd, char *buf) +{ + int n = write(fd, buf, strlen(buf)); + sockdebug(">(%d),%s", n, del_pass(buf)); + return n; +} + diff --git a/socket.h b/socket.h new file mode 100644 index 0000000..95c0e1d --- /dev/null +++ b/socket.h @@ -0,0 +1,40 @@ +/* $Id: socket.h,v 1.1 2001/03/14 13:19:29 ltoetsch Exp $ + * + * simple socket functions + * + * Copyright 2001 by Leopold Tötsch (lt@toetsch.at) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: socket.h,v $ + * Revision 1.1 2001/03/14 13:19:29 ltoetsch + * Added pop3/imap4 mail support + * + * + */ + +#ifndef __SOCKET_H_ +#define __SOCKET_H_ + +int open_socket(char *machine, int port); +int read_socket(int fd, char *buf, size_t size); +int read_socket_match(int fd, char *buf, size_t size, char *match); +int write_socket(int fd, char *buf); + +#endif + + + |