2000-08-12 07:35:42 +02:00
|
|
|
/* dtable.h: fd table definition.
|
|
|
|
|
|
|
|
Copyright 2000 Red Hat, Inc.
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
/* Initial and increment values for cygwin's fd table */
|
|
|
|
#define NOFILE_INCR 32
|
|
|
|
|
2000-08-12 07:35:42 +02:00
|
|
|
class dtable
|
|
|
|
{
|
|
|
|
fhandler_base **fds;
|
|
|
|
fhandler_base **fds_on_hold;
|
|
|
|
int first_fd_for_open;
|
2000-10-26 12:13:41 +02:00
|
|
|
int cnt_need_fixup_before;
|
2000-08-12 07:35:42 +02:00
|
|
|
public:
|
|
|
|
size_t size;
|
2000-10-26 12:13:41 +02:00
|
|
|
|
2000-11-03 05:27:03 +01:00
|
|
|
dtable () : first_fd_for_open(3), cnt_need_fixup_before(0) {}
|
2000-10-26 12:13:41 +02:00
|
|
|
|
|
|
|
void dec_need_fixup_before ()
|
|
|
|
{ if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
|
|
|
|
void inc_need_fixup_before ()
|
|
|
|
{ ++cnt_need_fixup_before; }
|
|
|
|
BOOL need_fixup_before ()
|
|
|
|
{ return cnt_need_fixup_before > 0; }
|
|
|
|
|
2000-08-12 07:35:42 +02:00
|
|
|
int vfork_child_dup ();
|
|
|
|
void vfork_parent_restore ();
|
|
|
|
fhandler_base *dup_worker (fhandler_base *oldfh);
|
|
|
|
int extend (int howmuch);
|
2000-10-26 12:13:41 +02:00
|
|
|
void fixup_before_exec (DWORD win_proc_id);
|
|
|
|
void fixup_before_fork (DWORD win_proc_id);
|
2000-08-12 07:35:42 +02:00
|
|
|
void fixup_after_fork (HANDLE);
|
|
|
|
fhandler_base *build_fhandler (int fd, DWORD dev, const char *name,
|
|
|
|
int unit = -1);
|
|
|
|
fhandler_base *build_fhandler (int fd, const char *name, HANDLE h);
|
2000-10-17 01:55:58 +02:00
|
|
|
int not_open (int n) __attribute__ ((regparm(1)));
|
2000-08-12 07:35:42 +02:00
|
|
|
int find_unused_handle (int start);
|
|
|
|
int find_unused_handle () { return find_unused_handle (first_fd_for_open);}
|
|
|
|
void release (int fd);
|
|
|
|
void init_std_file_from_handle (int fd, HANDLE handle, DWORD access, const char *name);
|
|
|
|
int dup2 (int oldfd, int newfd);
|
2000-09-03 06:16:35 +02:00
|
|
|
void fixup_after_exec (HANDLE, size_t, fhandler_base **);
|
2000-10-17 01:55:58 +02:00
|
|
|
inline fhandler_base *operator [](int fd) { return fds[fd]; }
|
2000-08-12 07:35:42 +02:00
|
|
|
select_record *select_read (int fd, select_record *s);
|
|
|
|
select_record *select_write (int fd, select_record *s);
|
|
|
|
select_record *select_except (int fd, select_record *s);
|
|
|
|
operator fhandler_base **() {return fds;}
|
|
|
|
};
|
|
|
|
|
|
|
|
void dtable_init (void);
|
|
|
|
void stdio_init (void);
|
|
|
|
extern dtable fdtab;
|
2000-09-08 04:56:55 +02:00
|
|
|
|
|
|
|
extern "C" int getfdtabsize ();
|
|
|
|
extern "C" void setfdtabsize (int);
|