7 /* mailbox lock configuration
9 /* #include <mbox_conf.h>
11 /* int mbox_lock_mask(string)
12 /* const char *string;
14 /* ARGV *mbox_lock_names()
16 /* The functions in this module translate between external
17 /* mailbox locking method names and internal representations.
19 /* mbox_lock_mask() translates a string with locking method names
20 /* into a bit mask. Names are separated by comma or whitespace.
21 /* The following gives the method names and corresponding bit
23 /* .IP "flock (MBOX_FLOCK_LOCK)"
24 /* Use flock() style lock after opening the file. This is the mailbox
25 /* locking method traditionally used on BSD-ish systems (including
26 /* Ultrix and SunOS). It is not suitable for remote file systems.
27 /* .IP "fcntl (MBOX_FCNTL_LOCK)"
28 /* Use fcntl() style lock after opening the file. This is the mailbox
29 /* locking method on System-V-ish systems (Solaris, AIX, IRIX, HP-UX).
30 /* This method is supposed to work for remote systems, but often
32 /* .IP "dotlock (MBOX_DOT_LOCK)"
33 /* Create a lock file with the name \fIfilename\fB.lock\fR. This
34 /* method pre-dates kernel locks. This works with remote file systems,
35 /* modulo cache coherency problems.
37 /* mbox_lock_names() returns an array with the names of available
38 /* mailbox locking methods. The result should be given to argv_free().
40 /* Fatal errors: undefined locking method name.
44 /* The Secure Mailer license must be distributed with this software.
47 /* IBM T.J. Watson Research
49 /* Yorktown Heights, NY 10598, USA
56 /* Utility library. */
58 #include <name_mask.h>
63 #include <mail_params.h>
64 #include <mbox_conf.h>
67 * The table with available mailbox locking methods. Some systems have
68 * flock() locks; all POSIX-compatible systems have fcntl() locks. Even
69 * though some systems do not use dotlock files by default (4.4BSD), such
70 * locks can be necessary when accessing mailbox files over NFS.
72 static const NAME_MASK mbox_mask
[] = {
74 "flock", MBOX_FLOCK_LOCK
,
77 "fcntl", MBOX_FCNTL_LOCK
,
79 "dotlock", MBOX_DOT_LOCK
,
83 /* mbox_lock_mask - translate mailbox lock names to bit mask */
85 int mbox_lock_mask(const char *string
)
87 return (name_mask(VAR_MAILBOX_LOCK
, mbox_mask
, string
));
90 /* mbox_lock_names - return available mailbox lock method names */
92 ARGV
*mbox_lock_names(void)
98 for (np
= mbox_mask
; np
->name
!= 0; np
++)
99 argv_add(argv
, np
->name
, ARGV_END
);
100 argv_terminate(argv
);