xref: /illumos-gate/usr/src/cmd/sendmail/libsm/flags.c (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
1 /*
2  * Copyright (c) 2000-2001, 2003 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 #include <sm/gen.h>
18 SM_RCSID("@(#)$Id: flags.c,v 1.20.2.1 2003/09/03 18:51:56 ca Exp $")
19 #include <sys/types.h>
20 #include <sys/file.h>
21 #include <errno.h>
22 #include <sm/io.h>
23 
24 /*
25 **  SM_FLAGS -- translate external (user) flags into internal flags
26 **
27 **	Paramters:
28 **		flags -- user select flags
29 **
30 **	Returns:
31 **		Internal flag value matching user selected flags
32 */
33 
34 int
35 sm_flags(flags)
36 	register int flags;
37 {
38 	register int ret;
39 
40 	switch(SM_IO_MODE(flags))
41 	{
42 	  case SM_IO_RDONLY:	/* open for reading */
43 		ret = SMRD;
44 		break;
45 
46 	  case SM_IO_WRONLY:	/* open for writing */
47 		ret = SMWR;
48 		break;
49 
50 	  case SM_IO_APPEND:	/* open for appending */
51 		ret = SMWR;
52 		break;
53 
54 	  case SM_IO_RDWR:	/* open for read and write */
55 		ret = SMRW;
56 		break;
57 
58 	  default:
59 		ret = 0;
60 		break;
61 	}
62 	if (SM_IS_BINARY(flags))
63 		ret |= SM_IO_BINARY;
64 	return ret;
65 }
66