]> mj.ucw.cz Git - umpf.git/commitdiff
integrate locks to the source
authorAnicka Bernathova <anicka@anicka.net>
Sat, 30 Aug 2008 11:42:38 +0000 (13:42 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Sat, 30 Aug 2008 11:42:38 +0000 (13:42 +0200)
Makefile
brum.c
brum.h
lock.c

index 35976424351e3a090ef809505359cda66f6688be..7979cc9eca77c48470ba99a07641909a1b2eb917 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,10 +4,10 @@ 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
+brum: brum.c cond.tab.o int.o lex.o ham.o lists.o lock.o
        gcc -o $@ $^ $(LDLIBS)
 
-lock: lex.o cond.tab.o
+lock.o: lex.o cond.tab.o
 
 cond.tab.o: cond.tab.c lex.o
 
diff --git a/brum.c b/brum.c
index b6fa451f87f64150f0c225f466725e3e46bc7b3a..d72fa6adb1028377c9ee1ac39147ffd83e2b3a77 100644 (file)
--- a/brum.c
+++ b/brum.c
@@ -9,6 +9,7 @@ main(int argc, char** argv)
        if (argc < 2)
                die("Usage: ./brum conf_file");
 
+       save_gids();
        read_conf(argv[1]);
 
 //     yydebug=1;
diff --git a/brum.h b/brum.h
index f5e2372ed77092d8d3041501515cbc287a53943c..9942a92070028d18c8f634050078a0f506635ebe 100644 (file)
--- a/brum.h
+++ b/brum.h
@@ -118,3 +118,8 @@ struct list* make_hlist(void);
 void print_headers(struct list* l);
 void do_action(struct action* a);
 char* 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/lock.c b/lock.c
index 0b04ef29a10946d479fe6447940f06c6bd31f1e6..571de8d0b2b6e24b4c1b222293da00a257d2dd1c 100644 (file)
--- a/lock.c
+++ b/lock.c
@@ -1,8 +1,9 @@
+#define _GNU_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#define _GNU_SOURCE
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -11,7 +12,6 @@
 #include "brum.h"
 
 #define LOCK_MAX_TRIES 30
-
 gid_t rgid, egid, sgid;
 
 void
@@ -169,24 +169,3 @@ open_mailbox(char* path, int is_default_mailbox)
 
        return fd;
 }
-
-int
-main(int argc, char** argv)
-{
-       /* FIXME: move somewhere */
-       int fd;
-       if (argc < 3)
-               return 1;
-       char* mb = argv[1];
-       int is_default_mailbox = atoi(argv[2]);
-       save_gids();
-       drop_gid(); 
-       fd = open_mailbox(mb, is_default_mailbox);
-       printf("%d\n", fd); 
-       if (fd < 0)
-               return 1;       
-
-       close_mailbox(fd, mb, is_default_mailbox);
-
-       return 0;
-}