vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / glibc / libio / strfile.h
blobbcac784717cb0dcea1d433f7b489c4c4368d02fc
1 /* Copyright (C) 1993, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA.
19 As a special exception, if you link the code in this file with
20 files compiled with a GNU compiler to produce an executable,
21 that does not cause the resulting executable to be covered by
22 the GNU Lesser General Public License. This exception does not
23 however invalidate any other reasons why the executable file
24 might be covered by the GNU Lesser General Public License.
25 This exception applies to code released by its copyright holders
26 in files containing the exception. */
28 #include <libio.h>
29 #ifdef TODO
30 Merge into libio.h ?
31 #endif
33 typedef void *(*_IO_alloc_type) (_IO_size_t);
34 typedef void (*_IO_free_type) (void*);
36 struct _IO_str_fields
38 _IO_alloc_type _allocate_buffer;
39 _IO_free_type _free_buffer;
42 /* This is needed for the Irix6 N32 ABI, which has a 64 bit off_t type,
43 but a 32 bit pointer type. In this case, we get 4 bytes of padding
44 after the vtable pointer. Putting them in a structure together solves
45 this problem. */
47 struct _IO_streambuf
49 struct _IO_FILE _f;
50 const void *_vtable;
53 typedef struct _IO_strfile_
55 struct _IO_streambuf _sbf;
56 struct _IO_str_fields _s;
57 } _IO_strfile;
59 /* dynamic: set when the array object is allocated (or reallocated) as
60 necessary to hold a character sequence that can change in length. */
61 #define _IO_STR_DYNAMIC(FP) ((FP)->_s._allocate_buffer != (_IO_alloc_type)0)
63 /* frozen: set when the program has requested that the array object not
64 be altered, reallocated, or freed. */
65 #define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF)