Merge from vendor branch CVS:
[dragonfly.git] / contrib / sendmail-8.13.4 / libsm / flags.c
1 /*
2  * Copyright (c) 2000-2001, 2004 Sendmail, Inc. and its suppliers.
3  *      All rights reserved.
4  * Copyright (c) 1990, 1993
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Chris Torek.
9  *
10  * By using this file, you agree to the terms and conditions set
11  * forth in the LICENSE file which can be found at the top level of
12  * the sendmail distribution.
13  */
14
15 #include <sm/gen.h>
16 SM_RCSID("@(#)$Id: flags.c,v 1.22 2004/03/03 19:20:29 ca Exp $")
17 #include <sys/types.h>
18 #include <sys/file.h>
19 #include <errno.h>
20 #include <sm/io.h>
21
22 /*
23 **  SM_FLAGS -- translate external (user) flags into internal flags
24 **
25 **      Paramters:
26 **              flags -- user select flags
27 **
28 **      Returns:
29 **              Internal flag value matching user selected flags
30 */
31
32 int
33 sm_flags(flags)
34         register int flags;
35 {
36         register int ret;
37
38         switch(SM_IO_MODE(flags))
39         {
40           case SM_IO_RDONLY:    /* open for reading */
41                 ret = SMRD;
42                 break;
43
44           case SM_IO_WRONLY:    /* open for writing */
45                 ret = SMWR;
46                 break;
47
48           case SM_IO_APPEND:    /* open for appending */
49                 ret = SMWR;
50                 break;
51
52           case SM_IO_RDWR:      /* open for read and write */
53                 ret = SMRW;
54                 break;
55
56           default:
57                 ret = 0;
58                 break;
59         }
60         if (SM_IS_BINARY(flags))
61                 ret |= SM_IO_BINARY;
62         return ret;
63 }