#ifndef FILE_LOCK_H
#define FILE_LOCK_H
#include <unistd.h>
#include <fcntl.h>
#define DEFAULT_LOCK_TIMEOUT 120
struct file_lock;
enum file_lock_method {
FILE_LOCK_METHOD_FCNTL,
FILE_LOCK_METHOD_FLOCK,
FILE_LOCK_METHOD_DOTLOCK
};
bool file_lock_method_parse(const char *name, enum file_lock_method *method_r);
int file_try_lock(int fd, const char *path, int lock_type,
enum file_lock_method lock_method,
struct file_lock **lock_r);
int file_wait_lock(int fd, const char *path, int lock_type,
enum file_lock_method lock_method,
unsigned int timeout_secs,
struct file_lock **lock_r);
int file_lock_try_update(struct file_lock *lock, int lock_type);
void file_unlock(struct file_lock **lock);
void file_lock_free(struct file_lock **lock);
int file_wait_lock_multiclient(int fd, const char *path, int lock_type,
enum file_lock_method lock_method,
unsigned int timeout_secs,
struct file_lock **lock_r,
uintmax_t client_id);
void file_unlock_multiclient(struct file_lock **lock, uintmax_t client_id);
#endif