dmc

dynamic mail client
git clone git://git.suckless.org/dmc
Log | Files | Refs | README | LICENSE

commit 4a2d861498b554c60ee70a4ede1cf4750bcfaacd
parent 80b2c4152281151f6e8103b258e929bcd624b0c4
Author: pancake@localhost.localdomain <unknown>
Date:   Mon, 12 Oct 2009 18:12:37 +0200

* Remove test account. Must use the ~/.dmc/acc ones
* Remove getpid() stuff of pop3.c
* Added addressbook support to dmc
* Added dummy smtp.c
* Add make un|install in makefile
Diffstat:
src/Makefile | 32+++++++++++++++++++++++++++-----
src/dmc | 54++++++++++++++++++++++++++++++++++++++----------------
src/pop3.c | 11-----------
src/smtp.c | 3+++
4 files changed, 68 insertions(+), 32 deletions(-)

diff --git a/src/Makefile b/src/Makefile @@ -1,10 +1,32 @@ -all: -# gcc muxin.c -o muxin - gcc -Wall pop3.c -o dmc-pop3 - gcc -Wall imap4.c -o dmc-imap4 +CC?=gcc +PREFIX?=/usr +CFLAGS?=-Wall + +all: dmc-smtp dmc-pop3 dmc-imap4 + +dmc-smtp: smtp.o + ${CC} ${LDFLAGS} smtp.o -o dmc-smtp + +dmc-pop3: pop3.o + ${CC} ${LDFLAGS} pop3.o -o dmc-pop3 + +dmc-imap4: imap4.o + ${CC} ${LDFLAGS} imap4.o -o dmc-imap4 + +install: + cp -f dmc ${PREFIX}/bin + cp -f dmc-smtp ${PREFIX}/bin + cp -f dmc-pop3 ${PREFIX}/bin + cp -f dmc-imap4 ${PREFIX}/bin + +uninstall: + rm -f ${PREFIX}/bin/dmc + rm -f ${PREFIX}/bin/dmc-smtp + rm -f ${PREFIX}/bin/dmc-pop3 + rm -f ${PREFIX}/bin/dmc-imap4 clean: - rm -f dmc-pop3 dmc-imap4 + rm -f dmc-pop3 dmc-imap4 dmc-smtp *.o loc: sloccount . diff --git a/src/dmc b/src/dmc @@ -6,6 +6,7 @@ VERSION="0.1" COPYRIGHT="Copyleft -- pancake@nopcode.org" +[ -n "${EDITOR}" ] && EDITOR=vim mkdir -p ~/.dmc/mail mkdir -p ~/.dmc/tmp mkdir -p ~/.dmc/acc @@ -25,6 +26,7 @@ function acc_daemon { rm -f ${INPUT} mkfifo ${INPUT} +# echo login ${USER} ${PASS} > ${INPUT} (while : ; do cat ${INPUT} ; done) | \ ./dmc-${PROTOCOL} $FIFO 2> ${OUTPUT} | $NETCMD > $FIFO rm -f ${INPUT} @@ -32,7 +34,7 @@ function acc_daemon { function start_account_daemons { i=0 - for a in ~/.dmc/accounts/* ; do + for a in ~/.dmc/acc/* ; do ( source $a ; acc_daemon ) & i=$(($i+1)) done @@ -42,33 +44,53 @@ function start_account_daemons { fi } -function start_test_daemon { - NAME="test" - SSL=0 - PROTOCOL="pop3" - HOST=radare.org - PORT=110 - acc_daemon +function print_account_template { + echo "NAME='test'" + echo "SSL=0" + echo "PROTOCOL='pop3,imap4'" + echo "HOST=serverhost.com" + echo "PORT=110" + echo "USER='username'" + echo "PASS='password'" } case "$1" in -"--test") - start_test_daemon - ;; -"--start") +"-d"|"--start") start_account_daemons ;; -"--stop") - for a in ~/.dmc/tmp/*.pid ; do +"-k"|"--stop") + for a in ~/.dmc/tmp/*.input ; do echo $a - kill -INT `cat $a` + echo exit > $a + rm -f ~/.dmc/tmp/$a done ;; +"-e"|"--edit") + if [ -n "$2" ]; then + if [ -n "`cat ~/.dmc/acc/$2`" ]; then + print_account_template "$2" > ~/.dmc/acc/$2 + fi + vim ~/.dmc/acc/$2 + # Remove account if empty + if [ -z "`cat ~/.dmc/acc/$2`" ]; then + rm ~/.dmc/acc/$2 + fi + else + echo "Usage: dmc -e [accountname]" + fi + ;; +"-a"|"--addr") + if [ -n "$2" ]; then + grep -e "$2" ~/.dmc/addrbook + else + ${EDITOR} ~/.dmc/addrbook + fi + ;; "-v"|"--version") echo "dmc v${VERSION} ${COPYRIGHT}" ;; "--help"|"-h"|*) - echo "Usage: dmc [--start|--stop|--test|--version|--help]" + echo "Usage: dmc [-e acc] [-a addr] [-hvdk]" ;; esac diff --git a/src/pop3.c b/src/pop3.c @@ -121,16 +121,6 @@ static void cleanup(int foo) { exit(0); } -/* XXX: do not use system here */ -static int storepid(const char *fifo) { - int ret; - char *cmd = malloc(strlen(fifo)+32); - sprintf(cmd, "echo %d > %s.pid", getpid(), fifo); - ret = system(cmd); - free(cmd); - return ret; -} - int main(int argc, char **argv) { if (argc>1) { signal(SIGINT, cleanup); @@ -141,7 +131,6 @@ int main(int argc, char **argv) { fprintf(stderr, "Cannot open fifo file.\n"); return 1; } - storepid(fifo); waitreply(1); while(doword(getword())); cleanup(0); diff --git a/src/smtp.c b/src/smtp.c @@ -0,0 +1,3 @@ +int main() { + return 0; +}