1 /* @(#)filemopen.c 1.5 10/08/21 Copyright 1986, 1995-2010 J. Schilling */
2 /*
3 * Copyright (c) 1986, 1995-2010 J. Schilling
4 */
5 /*
6 * The contents of this file are subject to the terms of the
7 * Common Development and Distribution License, Version 1.0 only
8 * (the "License"). You may not use this file except in compliance
9 * with the License.
10 *
11 * See the file CDDL.Schily.txt in this distribution for details.
12 * A copy of the CDDL is also available via the Internet at
13 * http://www.opensource.org/licenses/cddl1.txt
14 *
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file CDDL.Schily.txt from this distribution.
17 */
18
19 #include "schilyio.h"
20
21 EXPORT FILE *
22 #ifdef PROTOTYPES
filemopen(const char * name,const char * mode,mode_t cmode)23 filemopen(const char *name, const char *mode, mode_t cmode)
24 #else
25 filemopen(name, mode, cmode)
26 const char *name;
27 const char *mode;
28 mode_t cmode;
29 #endif
30 {
31 int ret;
32 int omode = 0;
33 int flag = 0;
34
35 if (!_cvmod(mode, &omode, &flag))
36 return ((FILE *)NULL);
37
38 if ((ret = open(name, omode, cmode)) < 0)
39 return ((FILE *)NULL);
40
41 return (_fcons((FILE *)0, ret, flag | FI_CLOSE));
42 }
43