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