Back to index

lightning-sunbird  0.9+nobinonly
fcntl.h
Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1983, 1990, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  * (c) UNIX System Laboratories, Inc.
00005  * All or some portions of this file are derived from material licensed
00006  * to the University of California by American Telephone and Telegraph
00007  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
00008  * the permission of UNIX System Laboratories, Inc.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * [3 Deleted as of 22Jul99, see
00019  *     ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
00020  *        for details]
00021  * 4. Neither the name of the University nor the names of its contributors
00022  *    may be used to endorse or promote products derived from this software
00023  *    without specific prior written permission.
00024  *
00025  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00026  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00029  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00031  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00032  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00034  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00035  * SUCH DAMAGE.
00036  *
00037  *     @(#)fcntl.h   8.3 (Berkeley) 1/21/94
00038  *
00039  * Adapted for GUSI by Matthias Neeracher <neeri@iis.ee.ethz.ch>
00040  */
00041 
00042 #ifndef _FCNTL_H_
00043 #define       _FCNTL_H_
00044 
00045 /*
00046  * This file includes the definitions for open and fcntl
00047  * described by POSIX for <fcntl.h>; it also includes
00048  * related kernel definitions.
00049  */
00050 
00051 #include <sys/types.h>
00052 
00053 /* open-only flags */
00054 #define       O_RDONLY      0x0001        /* open for reading only */
00055 #define       O_WRONLY      0x0002        /* open for writing only */
00056 #define       O_RDWR        0x0000        /* open for reading and writing */
00057 #define       O_ACCMODE     0x0003        /* mask for above modes */
00058 
00059 #define       O_NONBLOCK    0x0004        /* no delay */
00060 #define       O_APPEND      0x0008        /* set append mode */
00061 #define       O_CREAT              0x0200        /* create if nonexistant */
00062 #define       O_TRUNC              0x0400        /* truncate to zero length */
00063 #define       O_EXCL        0x0800        /* error if already exists */
00064 
00065 #ifndef _POSIX_SOURCE
00066 /* Mac specific */
00067 #define O_ALIAS             0x2000        /* Open alias file (if the file is an alias) */
00068 #define O_RSRC              0x4000        /* Open the resource fork */
00069 #endif
00070 
00071 /* defined by POSIX 1003.1; BSD default, so no bit required */
00072 #define       O_NOCTTY      0             /* don't assign controlling terminal */
00073 
00074 #ifndef _POSIX_SOURCE
00075 #define       FNDELAY              O_NONBLOCK    /* compat */
00076 #endif
00077 
00078 /*
00079  * Constants used for fcntl(2)
00080  */
00081 
00082 /* command values */
00083 #define       F_DUPFD              0             /* duplicate file descriptor */
00084 #define       F_GETFD              1             /* get file descriptor flags */
00085 #define       F_SETFD              2             /* set file descriptor flags */
00086 #define       F_GETFL              3             /* get file status flags */
00087 #define       F_SETFL              4             /* set file status flags */
00088 #define F_GETOWN    5       /* get SIGIO/SIGURG proc/pgrp */
00089 #define F_SETOWN    6       /* set SIGIO/SIGURG proc/pgrp */
00090 #define       F_GETLK              7             /* get record locking information */
00091 #define       F_SETLK              8             /* set record locking information */
00092 #define       F_SETLKW      9             /* F_SETLK; wait if blocked */
00093 
00094 /* file descriptor flags (F_GETFD, F_SETFD) */
00095 #define       FD_CLOEXEC    1             /* close-on-exec flag */
00096 
00097 /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
00098 #define       F_RDLCK              1             /* shared or read lock */
00099 #define       F_UNLCK              2             /* unlock */
00100 #define       F_WRLCK              3             /* exclusive or write lock */
00101 
00102 /*
00103  * Advisory file segment locking data type -
00104  * information passed to system by user
00105  */
00106 struct flock {
00107        off_t  l_start;      /* starting offset */
00108        off_t  l_len;        /* len = 0 means until end of file */
00109        pid_t  l_pid;        /* lock owner */
00110        short  l_type;              /* lock type: read/write, etc. */
00111        short  l_whence;     /* type of l_start */
00112 };
00113 
00114 #include <sys/cdefs.h>
00115 #include <stdio.h>
00116 
00117 __BEGIN_DECLS
00118 int    open __P((const char *, int, ...));
00119 int    creat __P((const char *, ...));
00120 int    fcntl __P((int, int, ...));
00121 
00122 /* This properly belongs into stdio.h, but that header is outside of
00123    GUSI's control
00124 */
00125 #ifdef __MWERKS__
00126 FILE * fdopen(int fildes, char *type);
00127 #else
00128 FILE * fdopen(int fildes, const char *type);
00129 #endif
00130 __END_DECLS
00131 
00132 #endif /* !_FCNTL_H_ */
00133