1/*++ 2/* NAME 3/* mbox_conf 3 4/* SUMMARY 5/* mailbox lock configuration 6/* SYNOPSIS 7/* #include <mbox_conf.h> 8/* 9/* int mbox_lock_mask(string) 10/* const char *string; 11/* 12/* ARGV *mbox_lock_names() 13/* DESCRIPTION 14/* The functions in this module translate between external 15/* mailbox locking method names and internal representations. 16/* 17/* mbox_lock_mask() translates a string with locking method names 18/* into a bit mask. Names are separated by comma or whitespace. 19/* The following gives the method names and corresponding bit 20/* mask value: 21/* .IP "flock (MBOX_FLOCK_LOCK)" 22/* Use flock() style lock after opening the file. This is the mailbox 23/* locking method traditionally used on BSD-ish systems (including 24/* Ultrix and SunOS). It is not suitable for remote file systems. 25/* .IP "fcntl (MBOX_FCNTL_LOCK)" 26/* Use fcntl() style lock after opening the file. This is the mailbox 27/* locking method on System-V-ish systems (Solaris, AIX, IRIX, HP-UX). 28/* This method is supposed to work for remote systems, but often 29/* has problems. 30/* .IP "dotlock (MBOX_DOT_LOCK)" 31/* Create a lock file with the name \fIfilename\fB.lock\fR. This 32/* method pre-dates kernel locks. This works with remote file systems, 33/* modulo cache coherency problems. 34/* .PP 35/* mbox_lock_names() returns an array with the names of available 36/* mailbox locking methods. The result should be given to argv_free(). 37/* DIAGNOSTICS 38/* Fatal errors: undefined locking method name. 39/* LICENSE 40/* .ad 41/* .fi 42/* The Secure Mailer license must be distributed with this software. 43/* AUTHOR(S) 44/* Wietse Venema 45/* IBM T.J. Watson Research 46/* P.O. Box 704 47/* Yorktown Heights, NY 10598, USA 48/*--*/ 49 50/* System library. */ 51 52#include <sys_defs.h> 53 54/* Utility library. */ 55 56#include <name_mask.h> 57#include <argv.h> 58 59/* Global library. */ 60 61#include <mail_params.h> 62#include <mbox_conf.h> 63 64 /* 65 * The table with available mailbox locking methods. Some systems have 66 * flock() locks; all POSIX-compatible systems have fcntl() locks. Even 67 * though some systems do not use dotlock files by default (4.4BSD), such 68 * locks can be necessary when accessing mailbox files over NFS. 69 */ 70static const NAME_MASK mbox_mask[] = { 71#ifdef HAS_FLOCK_LOCK 72 "flock", MBOX_FLOCK_LOCK, 73#endif 74#ifdef HAS_FCNTL_LOCK 75 "fcntl", MBOX_FCNTL_LOCK, 76#endif 77 "dotlock", MBOX_DOT_LOCK, 78 0, 79}; 80 81/* mbox_lock_mask - translate mailbox lock names to bit mask */ 82 83int mbox_lock_mask(const char *string) 84{ 85 return (name_mask(VAR_MAILBOX_LOCK, mbox_mask, string)); 86} 87 88/* mbox_lock_names - return available mailbox lock method names */ 89 90ARGV *mbox_lock_names(void) 91{ 92 const NAME_MASK *np; 93 ARGV *argv; 94 95 argv = argv_alloc(2); 96 for (np = mbox_mask; np->name != 0; np++) 97 argv_add(argv, np->name, ARGV_END); 98 argv_terminate(argv); 99 return (argv); 100} 101