cdff861bc801eaf7b5c7d7711b06e0a022c928a4
[reactos.git] / posix / include / psx / fdtable.h
1 /* $Id: fdtable.h,v 1.3 2002/03/11 20:50:49 hyperion Exp $
2 */
3 /*
4 * psx/fdtable.h
5 *
6 * POSIX+ subsystem file descriptor table data structure
7 *
8 * This file is part of the ReactOS Operating System.
9 *
10 * Contributors:
11 * Created by KJK::Hyperion <noog@libero.it>
12 *
13 * THIS SOFTWARE IS NOT COPYRIGHTED
14 *
15 * This source code is offered for use in the public domain. You may
16 * use, modify or distribute it freely.
17 *
18 * This code is distributed in the hope that it will be useful but
19 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
20 * DISCLAMED. This includes but is not limited to warranties of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 *
23 */
24 #ifndef __PSX_FDTABLE_H_INCLUDED__
25 #define __PSX_FDTABLE_H_INCLUDED__
26
27 /* INCLUDES */
28 #include <limits.h>
29 #include <inttypes.h>
30 #include <stddef.h>
31 #include <psx/safeobj.h>
32
33 /* OBJECTS */
34
35 /* TYPES */
36 typedef struct __tagfildes_t
37 {
38 void *FileHandle;
39 int OpenFlags;
40 int FdFlags;
41 size_t ExtraDataSize;
42 void *ExtraData;
43 } __fildes_t;
44
45 typedef struct __tagfdtable_t
46 {
47 __magic_t Signature;
48 int32_t LowestUnusedFileNo;
49 int32_t UsedDescriptors;
50 int32_t AllocatedDescriptors;
51 uint32_t DescriptorsBitmap[OPEN_MAX / 32];
52 __fildes_t *Descriptors;
53 } __fdtable_t;
54
55 /* CONSTANTS */
56
57 /* PROTOTYPES */
58 int __fdtable_init(__fdtable_t *);
59 int __fdtable_free(__fdtable_t *);
60
61 int __fdtable_entry_isavail(__fdtable_t *, int);
62 int __fdtable_entry_nextavail(__fdtable_t *, int);
63 int __fdtable_entry_add(__fdtable_t *, int, __fildes_t *, __fildes_t **);
64 int __fdtable_entry_remove(__fdtable_t *, int);
65 __fildes_t *__fdtable_entry_get(__fdtable_t *, int);
66
67 /* MACROS */
68 #define __FDTABLE_MAGIC MAGIC('F', 'D', 'T', 'B')
69
70 #endif /* __PSX_FDTABLE_H_INCLUDED__ */
71
72 /* EOF */
73