]> mj.ucw.cz Git - umpf.git/commitdiff
rename to umpf, guess default mailbox
authorAnicka Bernathova <anicka@anicka.net>
Sun, 31 Aug 2008 12:16:08 +0000 (14:16 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Sun, 31 Aug 2008 12:16:08 +0000 (14:16 +0200)
Makefile
brum.c [deleted file]
brum.h [deleted file]
cond.y
ham.c
int.c
lex.c
lock.c
umpf.c [new file with mode: 0644]
umpf.h [new file with mode: 0644]

index 7979cc9eca77c48470ba99a07641909a1b2eb917..62772323215281a56f3313c6e364d74893bc40a5 100644 (file)
--- 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/brum.c b/brum.c
deleted file mode 100644 (file)
index facd0f9..0000000
--- a/brum.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <stdio.h>
-#include "brum.h"
-
-int
-main(int argc, char** argv)
-{
-       int res;
-
-       if (argc < 2)
-               die("Usage: ./brum conf_file");
-
-       save_gids();
-       read_conf(argv[1]);
-       //FIXME:
-       get_default_mailbox("/var/mail/anicka");
-
-//     yydebug=1;
-       res = yyparse ();
-
-       if (res)
-               return res;
-
-//     print_tree(input_tree,0);
-
-       var_hash = new_var_hash();
-
-       current_headers = make_hlist();
-       current_body = get_body();
-//     print_headers(current_headers);
-
-       save_current_headers(var_hash);
-       interp(input_tree, var_hash);
-       
-//     print_vars(var_hash);
-
-       return 0;
-}
diff --git a/brum.h b/brum.h
deleted file mode 100644 (file)
index c72f7ac..0000000
--- a/brum.h
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "lists.h"
-
-/* cond.h */
-int yylex (void);
-void yyerror (char const *);
-
-struct tree {
-       enum {
-               ST_IF,
-               ST_COND,
-               ST_BLOCK,
-               ST_ASS,
-               ST_LEAF,
-               ST_EMPTY,
-               ST_ARROW,
-               ST_OP
-       } st;   /* subtree type */
-       union {
-               struct {
-                       struct tree* c; /* condition */
-                       struct tree* i; /* if */
-                       struct tree* e; /* else */
-               } tif;
-
-               struct {
-                       int op;
-                       enum {
-                               OP_REL,
-                               OP_BOOL 
-                       } type;
-                       struct tree* left;
-                       struct tree* right;
-               } cond; /* binary operator */
-
-               struct {
-                       struct tree* head;
-                       struct tree* tail;
-               } block;
-
-               struct {
-                       struct tree* left;
-                       struct tree* right;
-               } ass;
-
-               struct {
-                       enum {
-                               L_VAR,
-                               L_CONST,
-                       } type;
-                       char* value;
-               } leaf;
-
-               struct {
-                       char* kw_left;
-                       char* kw_right; 
-                       struct tree* s;
-               } arrow;
-
-               struct {
-                       int op;
-                       struct tree* left;
-                       struct tree* right;
-               } op;
-
-       } pt;
-};
-
-struct tree* input_tree;
-
-/* lex.c */
-#define CC(a,b) ((a<<8)|b)
-void* xmalloc(size_t size);
-void* xrealloc(void* buf, size_t size);
-char* xstrdup(char* s);
-void __attribute__ ((noreturn)) die(char* msg, ...);
-void read_conf(char* filename);
-int line;
-FILE* conf;
-
-/* int.c */
-struct variable {
-       struct node car;
-       char* name;
-       char* value;
-       int modified;
-};
-
-struct hlist {
-       struct node car;
-       char* name;
-       char* value;
-};
-
-struct email {
-       struct list* headers;
-       char* body;
-       int body_len;
-};
-
-struct action {
-       char* l;
-       char* r;
-       char* s;
-       struct email e;
-};
-
-struct list* var_hash;
-char* default_mailbox;
-
-void print_tree(struct tree* t, int ind);
-void interp(struct tree* t, struct list* hash);
-struct list* new_var_hash(void);
-void print_vars(struct list* hash);
-void save_current_headers(struct list* hash);
-
-/* ham.c */
-struct list* current_headers;
-struct email* current_body;
-struct list* make_hlist(void);
-void print_headers(struct list* l);
-void do_action(struct action* a);
-struct email* get_body(void);
-
-/* lock.c */
-void save_gids(void);
-void close_mailbox(int fd, char* path, int is_default_mailbox);
-int open_mailbox(char* path, int is_default_mailbox);
diff --git a/cond.y b/cond.y
index fd5dc304303c6f8f14d38b52f743dddf15a93536..6ae17e896e46ec27285a6f39fba878d38aa31001 100644 (file)
--- a/cond.y
+++ b/cond.y
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "brum.h"
+#include "umpf.h"
 
 static struct tree* tree_malloc(int type);
 
diff --git a/ham.c b/ham.c
index 03102e720a125a282166fae869be91da6ab59e19..d74a1bf404a7af1fbc16eedbb7c337ad2e4206b7 100644 (file)
--- a/ham.c
+++ b/ham.c
@@ -4,7 +4,7 @@
 
 #include <unistd.h>
 
-#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 80cf6639f2ca231a186e46e2cbec3c29b08213d4..f7fe023b592f5c5538c33d003251a2494e02d86a 100644 (file)
--- a/int.c
+++ b/int.c
@@ -4,7 +4,7 @@
 #include <ctype.h>
 
 #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 4beb8bb1afaf3ac8f438dd425895f21b533b1549..d1c7b4e1a05be4cf5eb385a270d1e016f330cea1 100644 (file)
--- a/lex.c
+++ b/lex.c
@@ -5,7 +5,7 @@
 #include <stdarg.h>
 
 #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 d6d1155660ec9fe6ca6935d31d837cae22ec81f2..1dfa7ebdd58ac1781af2e430828e6c18e2f7ec55 100644 (file)
--- a/lock.c
+++ b/lock.c
@@ -9,7 +9,7 @@
 #include <errno.h>
 #include <sys/stat.h>
 
-#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/umpf.c b/umpf.c
new file mode 100644 (file)
index 0000000..266fe7a
--- /dev/null
+++ b/umpf.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <pwd.h>
+
+#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: ./umpf conf_file");
+
+       save_gids();
+       read_conf(argv[1]);
+
+//     yydebug=1;
+       res = yyparse ();
+
+       if (res)
+               return res;
+
+//     print_tree(input_tree,0);
+
+       var_hash = new_var_hash();
+
+       current_headers = make_hlist();
+       current_body = get_body();
+//     print_headers(current_headers);
+
+       save_current_headers(var_hash);
+       interp(input_tree, var_hash);
+       
+//     print_vars(var_hash);
+
+       return 0;
+}
diff --git a/umpf.h b/umpf.h
new file mode 100644 (file)
index 0000000..7cac968
--- /dev/null
+++ b/umpf.h
@@ -0,0 +1,128 @@
+#include "lists.h"
+
+/* cond.h */
+int yylex (void);
+void yyerror (char const *);
+
+struct tree {
+       enum {
+               ST_IF,
+               ST_COND,
+               ST_BLOCK,
+               ST_ASS,
+               ST_LEAF,
+               ST_EMPTY,
+               ST_ARROW,
+               ST_OP
+       } st;   /* subtree type */
+       union {
+               struct {
+                       struct tree* c; /* condition */
+                       struct tree* i; /* if */
+                       struct tree* e; /* else */
+               } tif;
+
+               struct {
+                       int op;
+                       enum {
+                               OP_REL,
+                               OP_BOOL 
+                       } type;
+                       struct tree* left;
+                       struct tree* right;
+               } cond; /* binary operator */
+
+               struct {
+                       struct tree* head;
+                       struct tree* tail;
+               } block;
+
+               struct {
+                       struct tree* left;
+                       struct tree* right;
+               } ass;
+
+               struct {
+                       enum {
+                               L_VAR,
+                               L_CONST,
+                       } type;
+                       char* value;
+               } leaf;
+
+               struct {
+                       char* kw_left;
+                       char* kw_right; 
+                       struct tree* s;
+               } arrow;
+
+               struct {
+                       int op;
+                       struct tree* left;
+                       struct tree* right;
+               } op;
+
+       } pt;
+};
+
+struct tree* input_tree;
+
+/* lex.c */
+#define CC(a,b) ((a<<8)|b)
+void* xmalloc(size_t size);
+void* xrealloc(void* buf, size_t size);
+char* xstrdup(char* s);
+void __attribute__ ((noreturn)) die(char* msg, ...);
+void read_conf(char* filename);
+int line;
+FILE* conf;
+
+/* int.c */
+struct variable {
+       struct node car;
+       char* name;
+       char* value;
+       int modified;
+};
+
+struct hlist {
+       struct node car;
+       char* name;
+       char* value;
+};
+
+struct email {
+       struct list* headers;
+       char* body;
+       int body_len;
+};
+
+struct action {
+       char* l;
+       char* r;
+       char* s;
+       struct email e;
+};
+
+struct list* var_hash;
+char* default_mailbox;
+
+void print_tree(struct tree* t, int ind);
+void interp(struct tree* t, struct list* hash);
+struct list* new_var_hash(void);
+void print_vars(struct list* hash);
+void save_current_headers(struct list* hash);
+
+/* ham.c */
+struct list* current_headers;
+struct email* current_body;
+struct list* make_hlist(void);
+void print_headers(struct list* l);
+void do_action(struct action* a);
+struct email* get_body(void);
+
+/* lock.c */
+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);