From 249866e3d1e11dc72eaa1305f4bb479ded92ef38 Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Tue, 9 Jul 2024 13:58:20 +0200 Subject: reorganized file structure Moved c files into src/. Corrected VERSION file. Removed BUILD and FILES. --- src/lock.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/lock.c (limited to 'src/lock.c') diff --git a/src/lock.c b/src/lock.c new file mode 100644 index 0000000..4ac6b40 --- /dev/null +++ b/src/lock.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include "lock.h" + +/** + @file lock.c + @author djb + @source qmail + @brief locking of resources +*/ + +#ifdef HASFLOCK +int lock_ex(int fd) { return flock(fd,LOCK_EX); } +int lock_exnb(int fd) { return flock(fd,LOCK_EX | LOCK_NB); } +int lock_un(int fd) { return flock(fd,LOCK_UN); } +#else +int lock_ex(int fd) { return lockf(fd,1,0); } +int lock_exnb(int fd) { return lockf(fd,2,0); } +int lock_un(int fd) { return lockf(fd,0,0); } +#endif -- cgit v1.2.3