mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
common: Add an info callback to dotlock.
* common/dotlock.h (enum dotlock_reasons): New. (DOTLOCK_PREPARE_CREATE): New flag. * common/dotlock.c (struct dotlock_handle): Add info_cb and info_cb_value. (dotlock_create): Support the new flag. (dotlock_finish_create): New. (read_lockfile): Silence in case of ENOENT. (dotlock_set_info_cb): New. Use callback after all error and info messages. (dotlock_take_unix, dotlock_take_w32): Allow termination by callback.
This commit is contained in:
parent
f57717bf23
commit
937aeb1904
3 changed files with 203 additions and 11 deletions
|
@ -97,12 +97,32 @@ extern "C"
|
|||
struct dotlock_handle;
|
||||
typedef struct dotlock_handle *dotlock_t;
|
||||
|
||||
enum dotlock_reasons
|
||||
{
|
||||
DOTLOCK_CONFIG_TEST, /* Can't check system - function terminates. */
|
||||
DOTLOCK_FILE_ERROR, /* General file error - function terminates. */
|
||||
DOTLOCK_INV_FILE, /* Invalid file - function terminates. */
|
||||
DOTLOCK_CONFLICT, /* Something is wrong - function terminates. */
|
||||
DOTLOCK_NOT_LOCKED, /* Not locked - No action required. */
|
||||
DOTLOCK_STALE_REMOVED, /* Stale lock file was removed - retrying. */
|
||||
DOTLOCK_WAITING /* Waiting for the lock - may be terminated. */
|
||||
};
|
||||
|
||||
#define DOTLOCK_PREPARE_CREATE (1<<5) /* Require dotlock_finish_create. */
|
||||
|
||||
void dotlock_disable (void);
|
||||
dotlock_t dotlock_create (const char *file_to_lock, unsigned int flags);
|
||||
dotlock_t dotlock_finish_create (dotlock_t h, const char *file_to_lock);
|
||||
void dotlock_set_fd (dotlock_t h, int fd);
|
||||
int dotlock_get_fd (dotlock_t h);
|
||||
void dotlock_set_info_cb (dotlock_t h,
|
||||
int (*cb)(dotlock_t, void *,
|
||||
enum dotlock_reasons reason,
|
||||
const char *,...),
|
||||
void *opaque);
|
||||
void dotlock_destroy (dotlock_t h);
|
||||
int dotlock_take (dotlock_t h, long timeout);
|
||||
int dotlock_is_locked (dotlock_t h);
|
||||
int dotlock_release (dotlock_t h);
|
||||
void dotlock_remove_lockfiles (void);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue