1 /*
2  * Copyright (c) 2011 QUALCOMM Incorporated. All rights reserved.
3  *
4  * Description:
5  *   maillock() and mailunlock() try to emulate the SysV functions
6  *   to create the user.lock file.
7  *   call touchlock() to update the lock.
8  *
9  * Caveats:
10  *   mailunlock() will only remove the lockfile created from previous
11  *   maillock(). maillock() called for different users with out the
12  *   intermediate calls for mailunlock() would leave the initial locks.
13  *   Process termination would not clean the .lock files.
14  *
15  * Revisions:
16  *
17  *   01/30/01 [rcg]
18  *        - Qmaillock now takes bNo_atomic_open and pSpool_dir parameters
19  *          instead of using compile-time constants.
20  *
21  *   01/19/01 [rcg]
22  *        - Modified to pass drop name instead of user name (based on
23  *          patch by Fergal Daly).
24  *
25  *   06/07/00 [rcg]
26  *        - Added file and line from whence called to trace records.
27  *        - Added Qmailerr to return lock error string.
28  *
29  *   04/21/00 [rcg]
30  *        - Renamed to Qmaillock(), Qmailunlock(), and Qtouchlock().
31  *
32  *   12/06/99 [rcg]
33  *        - Added bDebugging parameter.
34  *        - Removed K&R junk.
35  *
36  *   11/23/99 [rcg]
37  *        - File added.
38  *
39  */
40 
41 
42 
43 
44 #ifndef _QMAILLOCK_H
45 #  define   _QMAILLOCK_H
46 
47 #include "utils.h" /* for TRUE, FALSE, and BOOL */
48 
49 
50 /*
51  * Return values for Qmaillock()
52  */
53 #define L_SUCCESS   0
54 #define L_NAMELEN   1   /* recipient name > 13 chars */
55 #define L_TMPLOCK   2   /* problem creating temp lockfile */
56 #define L_TMPWRITE  3   /* problem writing pid into temp lockfile */
57 #define L_MAXTRYS   4   /* cannot link to lockfile after N tries */
58 #define L_ERROR     5   /* Something other than EEXIST happened */
59 #define L_MANLOCK   6   /* cannot set mandatory lock on temp lockfile */
60 
61 /*
62  * Must call Qtouchlock at least this many seconds
63  */
64 #define LOCK_REFRESH_INTERVAL ( 60 * 3 ) /* three minutes */
65 
66 
67 int Qmaillock   ( char *drop_name, int retrycnt, BOOL bNo_atomic_open, char *pSpool_dir, void *fTrace, const char *fn, size_t ln, int bDebugging );
68 int Qmailunlock ( const char *fn, size_t ln );
69 int Qtouchlock  ( const char *fn, size_t ln );
70 const char *Qlockerr  ( int e );
71 
72 
73 #endif /* _QMAILLOCK_H */
74 
75