GRASS GIS 8 Programmer's Manual  8.5.0dev(2025)-565e82de51
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fcntl.c
Go to the documentation of this file.
1 /*!
2  * \file msvc/fcntl.c
3  *
4  * \brief Wrapper functions for MSVC _open() and _creat() that convert
5  * permission mode.
6  *
7  * (C) 2025 by the GRASS Development Team
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  *
11  * \author Huidae Cho
12  *
13  * \date 2025
14  */
15 
16 #include <stdarg.h>
17 #include <fcntl.h>
18 #include <sys/stat.h>
19 
20 #define O_TMPFILE O_TEMPORARY
21 
22 int __open(const char *pathname, int flags, ...)
23 {
24  if (flags & (O_CREAT | O_TMPFILE)) {
25  va_list ap;
26  int mode;
27 
28  va_start(ap, flags);
29  mode = va_arg(ap, int);
30  va_end(ap);
31 
32  return _open(pathname, flags,
33  (mode & 0400 ? _S_IREAD : 0) |
34  (mode & 0200 ? _S_IWRITE : 0));
35  }
36 
37  return _open(pathname, flags);
38 }
39 
40 int __creat(const char *pathname, int mode)
41 {
42  return _creat(pathname,
43  (mode & 0400 ? _S_IREAD : 0) | (mode & 0200 ? _S_IWRITE : 0));
44 }
#define O_TMPFILE
Definition: fcntl.c:20
int __creat(const char *pathname, int mode)
Definition: fcntl.c:40
int __open(const char *pathname, int flags,...)
Definition: fcntl.c:22
Header file for msvc/open.c and msvc/creat.c.