1/*
2 * FCntl.h -- faccess(), fcntl(), and open() mode flags
3 *
4 * Portions copyright American Telephone & Telegraph
5 * Used with permission, Apple Computer Inc. (1985,1988,1990,1992)
6 * All rights reserved.
7 */
8
9#ifndef __FCNTL__
10#define __FCNTL__
11
12#ifndef __TYPES__
13#include <Types.h>
14#endif
15
16/*
17 *	For use by lseek():
18 */
19
20#ifndef __STDIO__			/* these defns exactly paralled in StdIO.h for fseek() */
21#define SEEK_CUR	1
22#define SEEK_END	2
23#define SEEK_SET	0
24#endif
25
26/*
27 * faccess() commands; for general use
28 */
29 					/* 'd' => "directory" ops */
30#define F_DELETE		(('d'<<8)|0x01)
31#define F_RENAME		(('d'<<8)|0x02)
32
33/*
34 * more faccess() commands; for use only by MPW tools
35 */
36
37#define F_OPEN 			(('d'<<8)|0x00)		/* reserved for operating system use */
38					/* 'e' => "editor" ops */
39#define F_GTABINFO 		(('e'<<8)|0x00)		/* get tab offset for file */
40#define F_STABINFO 		(('e'<<8)|0x01)		/* set 	"	"		"	"  */
41#define F_GFONTINFO		(('e'<<8)|0x02)		/* get font number and size for file */
42#define F_SFONTINFO		(('e'<<8)|0x03)		/* set 	"		"	"	"	"	" 	 */
43#define F_GPRINTREC		(('e'<<8)|0x04)		/* get print record for file */
44#define F_SPRINTREC		(('e'<<8)|0x05)		/* set 	"		"	"	" 	 */
45#define F_GSELINFO 		(('e'<<8)|0x06)		/* get selection information for file */
46#define F_SSELINFO 		(('e'<<8)|0x07)		/* set		"		"		"		" */
47#define F_GWININFO 		(('e'<<8)|0x08)		/* get current window position */
48#define F_SWININFO 		(('e'<<8)|0x09)		/* set	"		"		" 	   */
49#define F_GSCROLLINFO	(('e'<<8)|0x0A)		/* get scroll information */
50#define F_SSCROLLINFO	(('e'<<8)|0x0B)		/* set    "   		"  	  */
51#define F_GMARKER		(('e'<<8)|0x0D)		/* Get Marker */
52#define F_SMARKER		(('e'<<8)|0x0C)		/* Set   " 	  */
53#define F_GSAVEONCLOSE	(('e'<<8)|0x0F)		/* Get Save on close */
54#define F_SSAVEONCLOSE	(('e'<<8)|0x0E)		/* Set   "	 "	 " 	 */
55
56/*
57 *	argument structures used by various faccess() commands
58 */
59
60struct MarkElement {
61	int				start;			/* start position of mark */
62	int				end;			/* end position */
63	unsigned char	charCount;		/* number of chars in mark name */
64	char			name[64];		/* mark name */
65} ;									/* note: marker names may be up to 64 characters long */
66
67#ifndef __cplusplus
68typedef struct MarkElement MarkElement;
69#endif
70
71struct SelectionRecord {
72	long	startingPos;
73	long	endingPos;
74	long	displayTop;
75};
76
77#ifndef __cplusplus
78typedef struct SelectionRecord SelectionRecord;
79#endif
80
81
82/*
83 * Mode values accessible to open()
84 */
85#define O_RDONLY		 0 		/* Bits 0 and 1 are used internally */
86#define O_WRONLY		 1 		/* Values 0..2 are historical */
87#define O_RDWR 			 2		/* NOTE: it goes 0, 1, 2, *!* 8, 16, 32, ... */
88#define O_APPEND	(1<< 3)		/* append (writes guaranteed at the end) */
89#define O_RSRC 		(1<< 4)		/* Open the resource fork */
90#define O_ALIAS		(1<< 5)		/* Open alias file */
91#define O_CREAT		(1<< 8)		/* Open with file create */
92#define O_TRUNC		(1<< 9)		/* Open with truncation */
93#define O_EXCL 		(1<<10) 	/* w/ O_CREAT:  Exclusive "create-only" */
94#define O_BINARY	(1<<11) 	/* Open as a binary stream */
95#define O_NRESOLVE	(1<<14)		/* Don't resolve any aliases */
96
97#ifdef __cplusplus
98extern "C" {
99#endif
100
101/*
102 *		function prototypes
103 */
104int  close(int);
105int  creat(const char*);
106int	 dup(int filedes);		/* OBSOLETE: fcntl(filedes, F_DUPFD, 0) is preferred */
107int	 faccess(char*, unsigned int, long*);
108int  fcntl(int, unsigned int, int);
109long lseek(int, long, int);
110int  open(const char*, int, ...);
111int  read(int, char*, unsigned);
112int  unlink(char*);
113int  write(int, const char*, unsigned);
114
115#ifdef __cplusplus
116}
117#endif
118
119/*
120 * fcntl() commands
121 */
122#define F_DUPFD 0	   /* Duplicate files (file descriptor) */
123
124#endif __FCNTL__
125