📄 fhandler.h
字号:
int ioctl (unsigned int cmd, void *); void init (HANDLE, DWORD, mode_t); bool mouse_aware () {return dev_state->use_mouse;} select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s); void fixup_after_exec (HANDLE); void set_close_on_exec (int val); void fixup_after_fork (HANDLE parent); void set_input_state (); void send_winch_maybe (); static tty_min *get_tty_stuff (int);};class fhandler_tty_common: public fhandler_termios{ public: fhandler_tty_common (DWORD dev, int unit = 0) : fhandler_termios (dev, unit), output_done_event (NULL), ioctl_request_event (NULL), ioctl_done_event (NULL), output_mutex (NULL), input_mutex (NULL), input_available_event (NULL), inuse (NULL), ttynum (unit) { // nothing to do } HANDLE output_done_event; // Raised by master when tty's output buffer // written. Write status in tty::write_retval. HANDLE ioctl_request_event; // Raised by slave to perform ioctl() request. // Ioctl() request in tty::cmd/arg. HANDLE ioctl_done_event; // Raised by master on ioctl() completion. // Ioctl() status in tty::ioctl_retval. HANDLE output_mutex, input_mutex; HANDLE input_available_event; HANDLE inuse; // used to indicate that a tty is in use int ttynum; // Master tty num. DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms); void __release_output_mutex (const char *fn, int ln); virtual int dup (fhandler_base *child); tty *get_ttyp () { return (tty *)tc; } int get_unit () { return ttynum; } int close (); void set_close_on_exec (int val); void fixup_after_fork (HANDLE parent); select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s);};class fhandler_tty_slave: public fhandler_tty_common{ public: /* Constructor */ fhandler_tty_slave (); fhandler_tty_slave (int); int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); void init (HANDLE, DWORD, mode_t); int tcsetattr (int a, const struct termios *t); int tcgetattr (struct termios *t); int tcflush (int); int ioctl (unsigned int cmd, void *); __off64_t lseek (__off64_t, int) { return 0; } select_record *select_read (select_record *s); int cygserver_attach_tty (HANDLE*, HANDLE*);};class fhandler_pty_master: public fhandler_tty_common{ int pktmode; // non-zero if pty in a packet mode. public: int need_nl; // Next read should start with \n /* Constructor */ fhandler_pty_master (DWORD devtype = FH_PTYM, int unit = -1); int process_slave_output (char *buf, size_t len, int pktmode_on); void doecho (const void *str, DWORD len); int accept_input (); int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); int close (); int tcsetattr (int a, const struct termios *t); int tcgetattr (struct termios *t); int tcflush (int); int ioctl (unsigned int cmd, void *); __off64_t lseek (__off64_t, int) { return 0; } char *ptsname (); void set_close_on_exec (int val); bool hit_eof ();};class fhandler_tty_master: public fhandler_pty_master{ public: /* Constructor */ fhandler_console *console; // device handler to perform real i/o. fhandler_tty_master (int unit); int init (int); int init_console (); void fixup_after_fork (HANDLE parent); void fixup_after_exec (HANDLE);};class fhandler_dev_null: public fhandler_base{ public: fhandler_dev_null (); void dump (); select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s);};class fhandler_dev_zero: public fhandler_base{ public: fhandler_dev_zero (); int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); __off64_t lseek (__off64_t offset, int whence); void dump ();};class fhandler_dev_random: public fhandler_base{ protected: int unit; HCRYPTPROV crypt_prov; long pseudo; BOOL crypt_gen_random (void *ptr, size_t len); int pseudo_write (const void *ptr, size_t len); int pseudo_read (void *ptr, size_t len); public: fhandler_dev_random (int unit); int get_unit () { return unit; } int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); __off64_t lseek (__off64_t offset, int whence); int close (void); int dup (fhandler_base *child); void dump ();};class fhandler_dev_mem: public fhandler_base{ protected: int unit; DWORD mem_size; __off64_t pos; public: fhandler_dev_mem (int unit); ~fhandler_dev_mem (void); int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t ulen); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); __off64_t lseek (__off64_t offset, int whence); int close (void); int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); int dup (fhandler_base *child); HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, __off64_t off); int munmap (HANDLE h, caddr_t addr, size_t len); int msync (HANDLE h, caddr_t addr, size_t len, int flags); BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset, DWORD size, void *address); void dump ();} ;class fhandler_dev_clipboard: public fhandler_base{ public: fhandler_dev_clipboard (); int is_windows (void) { return 1; } int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); __off64_t lseek (__off64_t offset, int whence); int close (void); int dup (fhandler_base *child); void dump (); private: __off64_t pos; void *membuffer; size_t msize; bool eof;};class fhandler_windows: public fhandler_base{ private: HWND hWnd_; // the window whose messages are to be retrieved by read() call int method_; // write method (Post or Send) public: fhandler_windows (); int is_windows (void) { return 1; } int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); int ioctl (unsigned int cmd, void *); __off64_t lseek (__off64_t, int) { return 0; } int close (void) { return 0; } void set_close_on_exec (int val); void fixup_after_fork (HANDLE parent); select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s);};class fhandler_dev_dsp : public fhandler_base{ private: int audioformat_; int audiofreq_; int audiobits_; int audiochannels_; bool setupwav(const char *pData, int nBytes); public: fhandler_dev_dsp (); ~fhandler_dev_dsp(); int open (path_conv *, int flags, mode_t mode = 0); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); int ioctl (unsigned int cmd, void *); __off64_t lseek (__off64_t, int); int close (void); int dup (fhandler_base * child); void dump (void); void fixup_after_exec (HANDLE);};class fhandler_virtual : public fhandler_base{ protected: char *filebuf; size_t bufalloc, filesize; __off64_t position; int fileid; // unique within each class public: fhandler_virtual (DWORD devtype); virtual ~fhandler_virtual(); virtual int exists(); DIR *opendir (path_conv& pc); __off64_t telldir (DIR *); void seekdir (DIR *, __off64_t); void rewinddir (DIR *); int closedir (DIR *); int write (const void *ptr, size_t len); int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); __off64_t lseek (__off64_t, int); int dup (fhandler_base * child); int open (path_conv *, int flags, mode_t mode = 0); int close (void); int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3))); virtual bool fill_filebuf (); void fixup_after_exec (HANDLE);};class fhandler_proc: public fhandler_virtual{ public: fhandler_proc (); fhandler_proc (DWORD devtype); int exists(); struct dirent *readdir (DIR *); static DWORD get_proc_fhandler(const char *path); int open (path_conv *real_path, int flags, mode_t mode = 0); int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); bool fill_filebuf ();};class fhandler_registry: public fhandler_proc{ private: char *value_name; public: fhandler_registry (); int exists(); struct dirent *readdir (DIR *); __off64_t telldir (DIR *); void seekdir (DIR *, __off64_t); void rewinddir (DIR *); int closedir (DIR *); int open (path_conv *real_path, int flags, mode_t mode = 0); int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); bool fill_filebuf (); int close (void);};class pinfo;class fhandler_process: public fhandler_proc{ pid_t pid; public: fhandler_process (); int exists(); struct dirent *readdir (DIR *); int open (path_conv *real_path, int flags, mode_t mode = 0); int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); bool fill_filebuf ();};typedef union{ char __base[sizeof (fhandler_base)]; char __console[sizeof (fhandler_console)]; char __cygdrive[sizeof (fhandler_cygdrive)]; char __dev_clipboard[sizeof (fhandler_dev_clipboard)]; char __dev_dsp[sizeof (fhandler_dev_dsp)]; char __dev_floppy[sizeof (fhandler_dev_floppy)]; char __dev_mem[sizeof (fhandler_dev_mem)]; char __dev_null[sizeof (fhandler_dev_null)]; char __dev_random[sizeof (fhandler_dev_random)]; char __dev_raw[sizeof (fhandler_dev_raw)]; char __dev_tape[sizeof (fhandler_dev_tape)]; char __dev_zero[sizeof (fhandler_dev_zero)]; char __disk_file[sizeof (fhandler_disk_file)]; char __pipe[sizeof (fhandler_pipe)]; char __proc[sizeof (fhandler_proc)]; char __process[sizeof (fhandler_process)]; char __pty_master[sizeof (fhandler_pty_master)]; char __registry[sizeof (fhandler_registry)]; char __serial[sizeof (fhandler_serial)]; char __socket[sizeof (fhandler_socket)]; char __termios[sizeof (fhandler_termios)]; char __tty_common[sizeof (fhandler_tty_common)]; char __tty_master[sizeof (fhandler_tty_master)]; char __tty_slave[sizeof (fhandler_tty_slave)]; char __virtual[sizeof (fhandler_virtual)]; char __windows[sizeof (fhandler_windows)];} fhandler_union;struct select_record{ int fd; HANDLE h; fhandler_base *fh; bool saw_error; bool windows_handle; bool read_ready, write_ready, except_ready; bool read_selected, write_selected, except_selected; bool except_on_write; int (*startup) (select_record *me, class select_stuff *stuff); int (*peek) (select_record *, bool); int (*verify) (select_record *me, fd_set *readfds, fd_set *writefds, fd_set *exceptfds); void (*cleanup) (select_record *me, class select_stuff *stuff); struct select_record *next; select_record (fhandler_base *in_fh = NULL) : fd (0), h (NULL), fh (in_fh), saw_error (false), windows_handle (false), read_ready (false), write_ready (false), except_ready (false), read_selected (false), write_selected (false), except_selected (false), except_on_write (false), startup (NULL), peek (NULL), verify (NULL), cleanup (NULL), next (NULL) {}};class select_stuff{ public: ~select_stuff (); select_stuff (): always_ready (0), windows_used (0), start (0) { memset (device_specific, 0, sizeof (device_specific)); } bool always_ready, windows_used; select_record start; void *device_specific[FH_NDEV]; int test_and_set (int i, fd_set *readfds, fd_set *writefds, fd_set *exceptfds); int poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds); int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms); void cleanup ();};int __stdcall set_console_state_for_spawn ();#endif /* _FHANDLER_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -