From 033e9aab8b14481a3df731f2c24dfc557eac1927 Mon Sep 17 00:00:00 2001 From: Anicka Bernathova Date: Sat, 30 Aug 2008 13:42:38 +0200 Subject: [PATCH] integrate locks to the source --- Makefile | 4 ++-- brum.c | 1 + brum.h | 5 +++++ lock.c | 25 ++----------------------- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 3597642..7979cc9 100644 --- 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 b6fa451..d72fa6a 100644 --- 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 f5e2372..9942a92 100644 --- 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 0b04ef2..571de8d 100644 --- a/lock.c +++ b/lock.c @@ -1,8 +1,9 @@ +#define _GNU_SOURCE + #include #include #include -#define _GNU_SOURCE #include #include #include @@ -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; -} -- 2.39.2