epoc32/include/libc/sys/fcntl.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/libc/sys/fcntl.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/libc/sys/fcntl.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,199 @@
     1.4 -fcntl.h
     1.5 +/*
     1.6 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +/**
    1.28 + @file
    1.29 + @publishedAll
    1.30 + @released
    1.31 +*/
    1.32 +
    1.33 +#ifndef	_FCNTL_
    1.34 +#define	_FCNTL_
    1.35 +
    1.36 +#ifdef __cplusplus
    1.37 +extern "C" {
    1.38 +#endif
    1.39 +
    1.40 +#include <_ansi.h>
    1.41 +#define	_FOPEN		(-1)	/* from sys/file.h, kernel use only */
    1.42 +#define	_FREAD		0x0001	/* read enabled */
    1.43 +#define	_FWRITE		0x0002	/* write enabled */
    1.44 +#define	_FNDELAY	0x0004	/* non blocking I/O (4.2 style) */
    1.45 +#define	_FAPPEND	0x0008	/* append (writes guaranteed at the end) */
    1.46 +#define	_FMARK		0x0010	/* internal; mark during gc() */
    1.47 +#define	_FDEFER		0x0020	/* internal; defer for next gc pass */
    1.48 +#define	_FASYNC		0x0040	/* signal pgrp when data ready */
    1.49 +#define	_FSHLOCK	0x0080	/* BSD flock() shared lock present */
    1.50 +#define	_FEXLOCK	0x0100	/* BSD flock() exclusive lock present */
    1.51 +#define	_FCREAT		0x0200	/* open with file create */
    1.52 +#define	_FTRUNC		0x0400	/* open with truncation */
    1.53 +#define	_FEXCL		0x0800	/* error on open if file exists */
    1.54 +#define	_FNBIO		0x1000	/* non blocking I/O (sys5 style) */
    1.55 +#define	_FSYNC		0x2000	/* do all writes synchronously */
    1.56 +#define	_FNONBLOCK	0x4000	/* non blocking I/O (POSIX style) */
    1.57 +#define	_FNOCTTY	0x8000	/* don't assign a ctty on this open */
    1.58 +
    1.59 +#define _FBUFFERED  0x10000 /* buffer at the interface to the file system */
    1.60 +
    1.61 +#define	O_ACCMODE	(O_RDONLY|O_WRONLY|O_RDWR)
    1.62 +
    1.63 +/**
    1.64 +Flag values for open(2) and fcntl(2)
    1.65 +The kernel adds 1 to the open modes to turn it into some
    1.66 +combination of FREAD and FWRITE.
    1.67 +*/
    1.68 +#define	O_RDONLY	0		/* +1 == FREAD */
    1.69 +#define	O_WRONLY	1		/* +1 == FWRITE */
    1.70 +#define	O_RDWR		2		/* +1 == FREAD|FWRITE */
    1.71 +#define	O_APPEND	_FAPPEND
    1.72 +#define	O_CREAT		_FCREAT
    1.73 +#define	O_TRUNC		_FTRUNC
    1.74 +#define	O_EXCL		_FEXCL
    1.75 +/*	O_SYNC		_FSYNC		not posix, defined below */
    1.76 +/*	O_NDELAY	_FNDELAY 	set in include/fcntl.h */
    1.77 +/*	O_NDELAY	_FNBIO 		set in 5include/fcntl.h */
    1.78 +#define	O_NONBLOCK	_FNONBLOCK
    1.79 +#define	O_NOCTTY	_FNOCTTY
    1.80 +
    1.81 +#define _FBINARY        0x10000
    1.82 +#define _FTEXT          0x20000
    1.83 +#define O_BINARY	_FBINARY
    1.84 +#define O_TEXT		_FTEXT
    1.85 +#define O_BUFFERED  _FBUFFERED
    1.86 +
    1.87 +#ifndef	_POSIX_SOURCE
    1.88 +
    1.89 +#define	O_SYNC		_FSYNC
    1.90 +
    1.91 +/**
    1.92 +Flags that work for fcntl(fd, F_SETFL, FXXXX)
    1.93 +*/
    1.94 +#define	FAPPEND		_FAPPEND
    1.95 +#define	FSYNC		_FSYNC
    1.96 +#define	FASYNC		_FASYNC
    1.97 +#define	FNBIO		_FNBIO
    1.98 +#define	FNONBIO		_FNONBLOCK	/* XXX fix to be NONBLOCK everywhere */
    1.99 +#define	FNDELAY		_FNDELAY
   1.100 +
   1.101 +/**
   1.102 +Flags that are disallowed for fcntl's (FCNTLCANT);
   1.103 +used for opens, internal state, or locking.
   1.104 +*/
   1.105 +#define	FREAD		_FREAD
   1.106 +#define	FWRITE		_FWRITE
   1.107 +#define	FMARK		_FMARK
   1.108 +#define	FDEFER		_FDEFER
   1.109 +#define	FSHLOCK		_FSHLOCK
   1.110 +#define	FEXLOCK		_FEXLOCK
   1.111 +
   1.112 +/**
   1.113 +The rest of the flags, used only for opens
   1.114 +*/
   1.115 +#define	FOPEN		_FOPEN
   1.116 +#define	FCREAT		_FCREAT
   1.117 +#define	FTRUNC		_FTRUNC
   1.118 +#define	FEXCL		_FEXCL
   1.119 +#define	FNOCTTY		_FNOCTTY
   1.120 +#define FBUFFERED   _FBUFFERED
   1.121 +
   1.122 +#endif	/* !_POSIX_SOURCE */
   1.123 +
   1.124 +/**
   1.125 +XXX close on exec request; must match UF_EXCLOSE in user.h 
   1.126 +*/
   1.127 +#define	FD_CLOEXEC	1	/* posix */
   1.128 +
   1.129 +/** 
   1.130 +fcntl(2) requests 
   1.131 +*/
   1.132 +#define	F_DUPFD		0	/* Duplicate fildes */
   1.133 +#define	F_GETFD		1	/* Get fildes flags (close on exec) */
   1.134 +#define	F_SETFD		2	/* Set fildes flags (close on exec) */
   1.135 +#define	F_GETFL		3	/* Get file flags */
   1.136 +#define	F_SETFL		4	/* Set file flags */
   1.137 +#ifndef	_POSIX_SOURCE
   1.138 +#define	F_GETOWN 	5	/* Get owner - for ASYNC */
   1.139 +#define	F_SETOWN 	6	/* Set owner - for ASYNC */
   1.140 +#endif	/* !_POSIX_SOURCE */
   1.141 +#define	F_GETLK  	7	/* Get record-locking information */
   1.142 +#define	F_SETLK  	8	/* Set or Clear a record-lock (Non-Blocking) */
   1.143 +#define	F_SETLKW 	9	/* Set or Clear a record-lock (Blocking) */
   1.144 +#ifndef	_POSIX_SOURCE
   1.145 +#define	F_RGETLK 	10	/* Test a remote lock to see if it is blocked */
   1.146 +#define	F_RSETLK 	11	/* Set or unlock a remote lock */
   1.147 +#define	F_CNVT 		12	/* Convert a fhandle to an open fd */
   1.148 +#define	F_RSETLKW 	13	/* Set or Clear remote record-lock(Blocking) */
   1.149 +#endif	/* !_POSIX_SOURCE */
   1.150 +
   1.151 +/** 
   1.152 +fcntl(2) flags (l_type field of flock structure) 
   1.153 +*/
   1.154 +#define	F_RDLCK		1	/* read lock */
   1.155 +#define	F_WRLCK		2	/* write lock */
   1.156 +#define	F_UNLCK		3	/* remove lock(s) */
   1.157 +#ifndef	_POSIX_SOURCE
   1.158 +#define	F_UNLKSYS	4	/* remove remote locks for a given system */
   1.159 +#endif	/* !_POSIX_SOURCE */
   1.160 +
   1.161 +/*#include <sys/stdtypes.h>*/
   1.162 +
   1.163 +/** 
   1.164 +file segment locking set data type - information passed to system by user 
   1.165 +*/
   1.166 +struct flock {
   1.167 +	short	l_type;		/* F_RDLCK, F_WRLCK, or F_UNLCK */
   1.168 +	short	l_whence;	/* flag to choose starting offset */
   1.169 +	long	l_start;	/* relative offset, in bytes */
   1.170 +	long	l_len;		/* length, in bytes; 0 means lock to EOF */
   1.171 +	short	l_pid;		/* returned with F_GETLK */
   1.172 +	short	l_xxx;		/* reserved for future use */
   1.173 +};
   1.174 +
   1.175 +#ifndef	_POSIX_SOURCE
   1.176 +/** 
   1.177 +extended file segment locking set data type 
   1.178 +*/
   1.179 +struct eflock {
   1.180 +	short	l_type;		/* F_RDLCK, F_WRLCK, or F_UNLCK */
   1.181 +	short	l_whence;	/* flag to choose starting offset */
   1.182 +	long	l_start;	/* relative offset, in bytes */
   1.183 +	long	l_len;		/* length, in bytes; 0 means lock to EOF */
   1.184 +	short	l_pid;		/* returned with F_GETLK */
   1.185 +	short	l_xxx;		/* reserved for future use */
   1.186 +	long	l_rpid;		/* Remote process id wanting this lock */
   1.187 +	long	l_rsys;		/* Remote system id wanting this lock */
   1.188 +};
   1.189 +#endif	/* !_POSIX_SOURCE */
   1.190 +
   1.191 +
   1.192 +#include <sys/types.h>
   1.193 +#include <sys/stat.h>		/* sigh. for the mode bits for open/creat */
   1.194 +
   1.195 +#define creat(n,m)	open(n,O_WRONLY|O_CREAT|O_TRUNC,m)
   1.196 +IMPORT_C int open	(const char *, int, ...);
   1.197 +IMPORT_C int wopen	(const wchar_t *, int, ...);
   1.198 +extern int fcntl	(int, int, ...);
   1.199 +
   1.200 +#ifdef __cplusplus
   1.201 +}
   1.202 +#endif
   1.203 +#endif	/* !_FCNTL_ */