OSDN Git Service

* fhandler.h (fhandler_tty_slave): Declare new methods.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / fhandler.h
index 9010a17..90ded24 100644 (file)
@@ -122,6 +122,22 @@ class select_record;
 class path_conv;
 class fhandler_disk_file;
 
+enum bg_check_types
+{
+  bg_error = -1,
+  bg_eof = 0,
+  bg_ok = 1,
+  bg_signalled = 2
+};
+
+enum executable_states
+{
+  is_executable,
+  not_executable,
+  dont_care_if_executable,
+  dont_know_if_executable
+};
+
 class fhandler_base
 {
 private:
@@ -211,7 +227,10 @@ public:
   void set_socket_p () { FHSETF (LOCAL); }
 
   int get_execable_p () { return FHISSETF (EXECABL); }
-  void set_execable_p (int val) { FHCONDSETF (val, EXECABL); }
+  void set_execable_p (executable_states val)
+  {
+    FHCONDSETF (val == is_executable, EXECABL);
+  }
   void set_execable_p () { FHSETF (EXECABL); }
 
   int get_append_p () { return FHISSETF (APPEND); }
@@ -271,6 +290,8 @@ public:
                        int flags, off_t off);
   virtual int munmap (HANDLE h, caddr_t addr, size_t len);
   virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
+  virtual BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
+                                     DWORD size, void *address);
 
   void *operator new (size_t, void *p) {return p;}
 
@@ -296,9 +317,9 @@ public:
 
   /* Virtual accessor functions to hide the fact
      that some fd's have two handles. */
-  virtual HANDLE get_handle () const { return io_handle; }
-  virtual HANDLE get_io_handle () const { return io_handle; }
-  virtual HANDLE get_output_handle () const { return io_handle; }
+  virtual HANDLE& get_handle () { return io_handle; }
+  virtual HANDLE& get_io_handle () { return io_handle; }
+  virtual HANDLE& get_output_handle () { return io_handle; }
   virtual BOOL hit_eof () {return FALSE;}
   virtual select_record *select_read (select_record *s);
   virtual select_record *select_write (select_record *s);
@@ -308,7 +329,7 @@ public:
   {
     return windows_device_names[FHDEVN (status)];
   }
-  virtual int bg_check (int) {return 1;}
+  virtual bg_check_types bg_check (int) {return bg_ok;}
   void clear_readahead ()
   {
     raixput = raixget = ralen = rabuflen = 0;
@@ -326,7 +347,7 @@ private:
 public:
   fhandler_socket (const char *name = 0);
   ~fhandler_socket ();
-  int get_socket () const { return (int) get_handle(); }
+  int get_socket () { return (int) get_handle(); }
   fhandler_socket * is_socket () { return this; }
   int write (const void *ptr, size_t len);
   int read (void *ptr, size_t len);
@@ -467,9 +488,6 @@ private:
 
 class fhandler_disk_file: public fhandler_base
 {
-private:
-  int check_execable_p (const char *path);
-
 public:
   fhandler_disk_file (const char *name);
 
@@ -483,6 +501,8 @@ public:
   HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_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);
 };
 
 class fhandler_serial: public fhandler_base
@@ -548,9 +568,9 @@ public:
   fhandler_termios (DWORD dev, const char *name = 0, int unit = 0) :
   fhandler_base (dev, name, unit)
   {
-    // nothing to do
+    set_need_fork_fixup ();
   }
-  HANDLE get_output_handle () const { return output_handle; }
+  HANDLE& get_output_handle () { return output_handle; }
   int line_edit (const char *rptr, int nread, int always_accept = 0);
   void set_output_handle (HANDLE h) { output_handle = h; }
   void tcinit (tty_min *this_tc, int force = FALSE);
@@ -558,19 +578,21 @@ public:
   int tcgetpgrp ();
   int tcsetpgrp (int pid);
   void set_ctty (int ttynum, int flags);
-  int bg_check (int sig);
+  bg_check_types bg_check (int sig);
   virtual DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms) {return 1;}
   virtual void __release_output_mutex (const char *fn, int ln) {}
+  void fixup_after_fork (HANDLE);
+  void fixup_after_exec (HANDLE parent) { fixup_after_fork (parent); }
 };
 
-/* This is a input and output console handle */
-class fhandler_console: public fhandler_termios
+enum ansi_intensity
 {
-private:
-
-/* Output state */
+  INTENSITY_INVISIBLE,
+  INTENSITY_DIM,
+  INTENSITY_NORMAL,
+  INTENSITY_BOLD
+};
 
-  // enum {normal, gotesc, gotsquare, gotarg1, gotcommand} state;
 #define normal 1
 #define gotesc 2
 #define gotsquare 3
@@ -580,13 +602,58 @@ private:
 #define gettitle 7
 #define eattitle 8
 #define MAXARGS 10
+
+/* This is a input and output console handle */
+class fhandler_console: public fhandler_termios
+{
+private:
+
+  WORD default_color, underline_color, dim_color;
+
+  /* Used to determine if an input keystroke should be modified with META. */
+  int meta_mask;
+
+/* Output state */
   int state_;
   int args_[MAXARGS];
   int nargs_;
-
-  DWORD default_color;
+  unsigned rarg;
+  BOOL saw_question_mark;
+
+  char my_title_buf [TITLESIZE + 1];
+
+  WORD current_win32_attr;
+  ansi_intensity intensity;
+  BOOL underline, blink, reverse;
+  WORD fg, bg;
+
+  /* saved cursor coordinates */
+  int savex, savey;
+
+  struct
+    {
+      short Top, Bottom;
+    } scroll_region;
+  struct
+    {
+      SHORT winTop;
+      SHORT winBottom;
+      COORD dwWinSize;
+      COORD dwBufferSize;
+      COORD dwCursorPosition;
+      WORD wAttributes;
+    } info;
+
+  COORD dwLastCursorPosition;
+  DWORD dwLastButtonState;
+  int nModifiers;
+
+  BOOL use_mouse;
+  BOOL raw_win32_keyboard_mode;
 
 /* Output calls */
+  void set_default_attr ();
+  WORD get_win32_attr ();
 
   BOOL fillin_info ();
   void clear_screen (int, int, int, int);
@@ -596,6 +663,7 @@ private:
   void cursor_rel (int, int);
   const unsigned char * write_normal (unsigned const char*, unsigned const char *);
   void char_command (char);
+  BOOL set_raw_win32_keyboard_mode (BOOL);
   int output_tcsetattr (int a, const struct termios *t);
 
 /* Input calls */
@@ -625,6 +693,7 @@ public:
 
   int ioctl (unsigned int cmd, void *);
   void init (HANDLE, DWORD, mode_t);
+  bool mouse_aware () {return use_mouse;}
 
   select_record *select_read (select_record *s);
   select_record *select_write (select_record *s);
@@ -651,7 +720,8 @@ public:
                                // 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;
+  HANDLE output_mutex, input_mutex;
+  HANDLE input_available_event;
   HANDLE inuse;                        // used to indicate that a tty is in use
 
 
@@ -691,6 +761,8 @@ public:
   int ioctl (unsigned int cmd, void *);
 
   off_t lseek (off_t, int) { return 0; }
+  select_record *select_read (select_record *s);
+  int ready_for_read (int fd, DWORD howlong, int ignra);
 };
 
 class fhandler_pty_master: public fhandler_tty_common
@@ -806,6 +878,8 @@ public:
   HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_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 ();
 } ;