From fe8a488cd0901903cf93448366b3164c94674ac9 Mon Sep 17 00:00:00 2001 From: Anicka Bernathova Date: Sun, 31 Aug 2008 14:16:08 +0200 Subject: [PATCH] rename to umpf, guess default mailbox --- Makefile | 6 +++--- cond.y | 2 +- ham.c | 15 +++++++++++---- int.c | 2 +- lex.c | 2 +- lock.c | 4 ++-- brum.c => umpf.c | 14 ++++++++++---- brum.h => umpf.h | 1 + 8 files changed, 30 insertions(+), 16 deletions(-) rename brum.c => umpf.c (68%) rename brum.h => umpf.h (98%) diff --git a/Makefile b/Makefile index 7979cc9..6277232 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -all: brum +all: umpf CC=gcc CFLAGS=-Wall -W -Wno-pointer-sign -Wstrict-prototypes -Wmissing-prototypes -O2 -g LDLIBS=-lpcre -brum: brum.c cond.tab.o int.o lex.o ham.o lists.o lock.o +umpf: umpf.c cond.tab.o int.o lex.o ham.o lists.o lock.o gcc -o $@ $^ $(LDLIBS) lock.o: lex.o cond.tab.o @@ -23,4 +23,4 @@ cond.tab.c: cond.y bison -dvt cond.y clean: - rm -rf cond.tab.[ch] cond.output cond brum *.o core + rm -rf cond.tab.[ch] cond.output cond umpf *.o core diff --git a/cond.y b/cond.y index fd5dc30..6ae17e8 100644 --- a/cond.y +++ b/cond.y @@ -3,7 +3,7 @@ #include #include -#include "brum.h" +#include "umpf.h" static struct tree* tree_malloc(int type); diff --git a/ham.c b/ham.c index 03102e7..d74a1bf 100644 --- a/ham.c +++ b/ham.c @@ -4,7 +4,7 @@ #include -#include "brum.h" +#include "umpf.h" #define BUFSIZE 1024 @@ -163,9 +163,16 @@ copy_email(int fd, struct email* email) write_char_to_mailbox('\n', fd); /* body */ - //FIXME that nasty FROM - for (pc = email->body; *pc; pc++){ - write_char_to_mailbox(*pc, fd); + /* FIXME: do not forget change Content-Length */ + for (pc = email->body; pc < email->body + email->body_len; pc++){ + write_char_to_mailbox(*pc, fd); + if (*pc == '\n'){ + if ((pc + 5 < email->body + email->body_len) + && pc[1] == 'F' && pc[2] == 'r' + && pc[3] == 'o' && pc[4] == 'm' + && pc[5] == ' ') + write_char_to_mailbox('>', fd); + } } flush_mbox_buffer(fd); diff --git a/int.c b/int.c index 80cf663..f7fe023 100644 --- a/int.c +++ b/int.c @@ -4,7 +4,7 @@ #include #include "cond.tab.h" -#include "brum.h" +#include "umpf.h" #define OVECCOUNT 3 #define HASHSIZE 103 diff --git a/lex.c b/lex.c index 4beb8bb..d1c7b4e 100644 --- a/lex.c +++ b/lex.c @@ -5,7 +5,7 @@ #include #include "cond.tab.h" -#include "brum.h" +#include "umpf.h" #define BUFSIZE 4096 #define KLEN 10 diff --git a/lock.c b/lock.c index d6d1155..1dfa7eb 100644 --- a/lock.c +++ b/lock.c @@ -9,7 +9,7 @@ #include #include -#include "brum.h" +#include "umpf.h" #define LOCK_MAX_TRIES 3 gid_t rgid, egid, sgid; @@ -45,7 +45,7 @@ random_sleep(unsigned int about, unsigned int offset) usleep(about * 1000000 + myrand * 500000); } -static char* +char* cat(char* l, char* r) { char* res = xmalloc(strlen(l) + strlen (r) + 1); diff --git a/brum.c b/umpf.c similarity index 68% rename from brum.c rename to umpf.c index facd0f9..266fe7a 100644 --- a/brum.c +++ b/umpf.c @@ -1,18 +1,24 @@ #include -#include "brum.h" +#include + +#include "umpf.h" int main(int argc, char** argv) { int res; + + //FIXME: + struct passwd* p; + p = getpwuid(getuid()); + char* default_mbox = cat("/var/mail/", p->pw_name); + get_default_mailbox(default_mbox); if (argc < 2) - die("Usage: ./brum conf_file"); + die("Usage: ./umpf conf_file"); save_gids(); read_conf(argv[1]); - //FIXME: - get_default_mailbox("/var/mail/anicka"); // yydebug=1; res = yyparse (); diff --git a/brum.h b/umpf.h similarity index 98% rename from brum.h rename to umpf.h index c72f7ac..7cac968 100644 --- a/brum.h +++ b/umpf.h @@ -125,3 +125,4 @@ struct email* get_body(void); void save_gids(void); void close_mailbox(int fd, char* path, int is_default_mailbox); int open_mailbox(char* path, int is_default_mailbox); +char* cat(char* l, char* r); -- 2.39.2