epoc32/include/libc/sys/fcntl.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 /**
    21  @file
    22  @publishedAll
    23  @released
    24 */
    25 
    26 #ifndef	_FCNTL_
    27 #define	_FCNTL_
    28 
    29 #ifdef __cplusplus
    30 extern "C" {
    31 #endif
    32 
    33 #include <_ansi.h>
    34 #define	_FOPEN		(-1)	/* from sys/file.h, kernel use only */
    35 #define	_FREAD		0x0001	/* read enabled */
    36 #define	_FWRITE		0x0002	/* write enabled */
    37 #define	_FNDELAY	0x0004	/* non blocking I/O (4.2 style) */
    38 #define	_FAPPEND	0x0008	/* append (writes guaranteed at the end) */
    39 #define	_FMARK		0x0010	/* internal; mark during gc() */
    40 #define	_FDEFER		0x0020	/* internal; defer for next gc pass */
    41 #define	_FASYNC		0x0040	/* signal pgrp when data ready */
    42 #define	_FSHLOCK	0x0080	/* BSD flock() shared lock present */
    43 #define	_FEXLOCK	0x0100	/* BSD flock() exclusive lock present */
    44 #define	_FCREAT		0x0200	/* open with file create */
    45 #define	_FTRUNC		0x0400	/* open with truncation */
    46 #define	_FEXCL		0x0800	/* error on open if file exists */
    47 #define	_FNBIO		0x1000	/* non blocking I/O (sys5 style) */
    48 #define	_FSYNC		0x2000	/* do all writes synchronously */
    49 #define	_FNONBLOCK	0x4000	/* non blocking I/O (POSIX style) */
    50 #define	_FNOCTTY	0x8000	/* don't assign a ctty on this open */
    51 
    52 #define _FBUFFERED  0x10000 /* buffer at the interface to the file system */
    53 
    54 #define	O_ACCMODE	(O_RDONLY|O_WRONLY|O_RDWR)
    55 
    56 /**
    57 Flag values for open(2) and fcntl(2)
    58 The kernel adds 1 to the open modes to turn it into some
    59 combination of FREAD and FWRITE.
    60 */
    61 #define	O_RDONLY	0		/* +1 == FREAD */
    62 #define	O_WRONLY	1		/* +1 == FWRITE */
    63 #define	O_RDWR		2		/* +1 == FREAD|FWRITE */
    64 #define	O_APPEND	_FAPPEND
    65 #define	O_CREAT		_FCREAT
    66 #define	O_TRUNC		_FTRUNC
    67 #define	O_EXCL		_FEXCL
    68 /*	O_SYNC		_FSYNC		not posix, defined below */
    69 /*	O_NDELAY	_FNDELAY 	set in include/fcntl.h */
    70 /*	O_NDELAY	_FNBIO 		set in 5include/fcntl.h */
    71 #define	O_NONBLOCK	_FNONBLOCK
    72 #define	O_NOCTTY	_FNOCTTY
    73 
    74 #define _FBINARY        0x10000
    75 #define _FTEXT          0x20000
    76 #define O_BINARY	_FBINARY
    77 #define O_TEXT		_FTEXT
    78 #define O_BUFFERED  _FBUFFERED
    79 
    80 #ifndef	_POSIX_SOURCE
    81 
    82 #define	O_SYNC		_FSYNC
    83 
    84 /**
    85 Flags that work for fcntl(fd, F_SETFL, FXXXX)
    86 */
    87 #define	FAPPEND		_FAPPEND
    88 #define	FSYNC		_FSYNC
    89 #define	FASYNC		_FASYNC
    90 #define	FNBIO		_FNBIO
    91 #define	FNONBIO		_FNONBLOCK	/* XXX fix to be NONBLOCK everywhere */
    92 #define	FNDELAY		_FNDELAY
    93 
    94 /**
    95 Flags that are disallowed for fcntl's (FCNTLCANT);
    96 used for opens, internal state, or locking.
    97 */
    98 #define	FREAD		_FREAD
    99 #define	FWRITE		_FWRITE
   100 #define	FMARK		_FMARK
   101 #define	FDEFER		_FDEFER
   102 #define	FSHLOCK		_FSHLOCK
   103 #define	FEXLOCK		_FEXLOCK
   104 
   105 /**
   106 The rest of the flags, used only for opens
   107 */
   108 #define	FOPEN		_FOPEN
   109 #define	FCREAT		_FCREAT
   110 #define	FTRUNC		_FTRUNC
   111 #define	FEXCL		_FEXCL
   112 #define	FNOCTTY		_FNOCTTY
   113 #define FBUFFERED   _FBUFFERED
   114 
   115 #endif	/* !_POSIX_SOURCE */
   116 
   117 /**
   118 XXX close on exec request; must match UF_EXCLOSE in user.h 
   119 */
   120 #define	FD_CLOEXEC	1	/* posix */
   121 
   122 /** 
   123 fcntl(2) requests 
   124 */
   125 #define	F_DUPFD		0	/* Duplicate fildes */
   126 #define	F_GETFD		1	/* Get fildes flags (close on exec) */
   127 #define	F_SETFD		2	/* Set fildes flags (close on exec) */
   128 #define	F_GETFL		3	/* Get file flags */
   129 #define	F_SETFL		4	/* Set file flags */
   130 #ifndef	_POSIX_SOURCE
   131 #define	F_GETOWN 	5	/* Get owner - for ASYNC */
   132 #define	F_SETOWN 	6	/* Set owner - for ASYNC */
   133 #endif	/* !_POSIX_SOURCE */
   134 #define	F_GETLK  	7	/* Get record-locking information */
   135 #define	F_SETLK  	8	/* Set or Clear a record-lock (Non-Blocking) */
   136 #define	F_SETLKW 	9	/* Set or Clear a record-lock (Blocking) */
   137 #ifndef	_POSIX_SOURCE
   138 #define	F_RGETLK 	10	/* Test a remote lock to see if it is blocked */
   139 #define	F_RSETLK 	11	/* Set or unlock a remote lock */
   140 #define	F_CNVT 		12	/* Convert a fhandle to an open fd */
   141 #define	F_RSETLKW 	13	/* Set or Clear remote record-lock(Blocking) */
   142 #endif	/* !_POSIX_SOURCE */
   143 
   144 /** 
   145 fcntl(2) flags (l_type field of flock structure) 
   146 */
   147 #define	F_RDLCK		1	/* read lock */
   148 #define	F_WRLCK		2	/* write lock */
   149 #define	F_UNLCK		3	/* remove lock(s) */
   150 #ifndef	_POSIX_SOURCE
   151 #define	F_UNLKSYS	4	/* remove remote locks for a given system */
   152 #endif	/* !_POSIX_SOURCE */
   153 
   154 /*#include <sys/stdtypes.h>*/
   155 
   156 /** 
   157 file segment locking set data type - information passed to system by user 
   158 */
   159 struct flock {
   160 	short	l_type;		/* F_RDLCK, F_WRLCK, or F_UNLCK */
   161 	short	l_whence;	/* flag to choose starting offset */
   162 	long	l_start;	/* relative offset, in bytes */
   163 	long	l_len;		/* length, in bytes; 0 means lock to EOF */
   164 	short	l_pid;		/* returned with F_GETLK */
   165 	short	l_xxx;		/* reserved for future use */
   166 };
   167 
   168 #ifndef	_POSIX_SOURCE
   169 /** 
   170 extended file segment locking set data type 
   171 */
   172 struct eflock {
   173 	short	l_type;		/* F_RDLCK, F_WRLCK, or F_UNLCK */
   174 	short	l_whence;	/* flag to choose starting offset */
   175 	long	l_start;	/* relative offset, in bytes */
   176 	long	l_len;		/* length, in bytes; 0 means lock to EOF */
   177 	short	l_pid;		/* returned with F_GETLK */
   178 	short	l_xxx;		/* reserved for future use */
   179 	long	l_rpid;		/* Remote process id wanting this lock */
   180 	long	l_rsys;		/* Remote system id wanting this lock */
   181 };
   182 #endif	/* !_POSIX_SOURCE */
   183 
   184 
   185 #include <sys/types.h>
   186 #include <sys/stat.h>		/* sigh. for the mode bits for open/creat */
   187 
   188 #define creat(n,m)	open(n,O_WRONLY|O_CREAT|O_TRUNC,m)
   189 IMPORT_C int open	(const char *, int, ...);
   190 IMPORT_C int wopen	(const wchar_t *, int, ...);
   191 extern int fcntl	(int, int, ...);
   192 
   193 #ifdef __cplusplus
   194 }
   195 #endif
   196 #endif	/* !_FCNTL_ */