view src/lib/file-lock.h @ 953:411006be3c66 HEAD

Naming change for function typedefs.
author Timo Sirainen <tss@iki.fi>
date Sat, 11 Jan 2003 21:55:56 +0200
parents b7aefd0d7611
children f1d77064884c
line wrap: on
line source

#ifndef __FILE_LOCK_H
#define __FILE_LOCK_H

#include <unistd.h>
#include <fcntl.h>

#define DEFAULT_LOCK_TIMEOUT 120

/* Lock whole file descriptor. Returns 1 if successful, 0 if lock failed,
   or -1 if error. lock_type is F_WRLCK, F_RDLCK or F_UNLCK. */
int file_try_lock(int fd, int lock_type);

/* Lock whole file descriptor. Returns 1 if successful, 0 if timeout or
   -1 if error. When returning 0, errno is also set to EAGAIN. Timeouts after
   DEFAULT_LOCK_TIMEOUT. */
int file_wait_lock(int fd, int lock_type);

/* Like file_wait_lock(), but you can specify the timout and a callback which
   is called once in a while if waiting takes longer. */
int file_wait_lock_full(int fd, int lock_type, unsigned int timeout,
			void (*callback)(unsigned int secs_left, void *context),
			void *context);

#endif