-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
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
+++ /dev/null
-#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;
-}
+++ /dev/null
-#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);
#include <stdio.h>
#include <string.h>
-#include "brum.h"
+#include "umpf.h"
static struct tree* tree_malloc(int type);
#include <unistd.h>
-#include "brum.h"
+#include "umpf.h"
#define BUFSIZE 1024
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);
#include <ctype.h>
#include "cond.tab.h"
-#include "brum.h"
+#include "umpf.h"
#define OVECCOUNT 3
#define HASHSIZE 103
#include <stdarg.h>
#include "cond.tab.h"
-#include "brum.h"
+#include "umpf.h"
#define BUFSIZE 4096
#define KLEN 10
#include <errno.h>
#include <sys/stat.h>
-#include "brum.h"
+#include "umpf.h"
#define LOCK_MAX_TRIES 3
gid_t rgid, egid, sgid;
usleep(about * 1000000 + myrand * 500000);
}
-static char*
+char*
cat(char* l, char* r)
{
char* res = xmalloc(strlen(l) + strlen (r) + 1);
--- /dev/null
+#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;
+}
--- /dev/null
+#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);