OSDN Git Service

* fhandler_clipboard.cc: new file
authordj <dj>
Tue, 17 Oct 2000 01:46:26 +0000 (01:46 +0000)
committerdj <dj>
Tue, 17 Oct 2000 01:46:26 +0000 (01:46 +0000)
* Makefile.in: include fhandler_clipboard.o in DLL_OFILES list.
* fhandler.h: add FH_CLIPBOARD to the devices enum.
(fhandler_dev_clipboard): new
* path.cc (windows_device_names): add "\\dev\\clipboard"
(get_device_number): check for "clipboard"
* dcrt0.cc: declare a few more functions from winuser.h
* dtable.cc (dtable::build_fhandler): check for FH_CLIPBOARD in
switch().

winsup/cygwin/ChangeLog
winsup/cygwin/Makefile.in
winsup/cygwin/dcrt0.cc
winsup/cygwin/dtable.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_clipboard.cc [new file with mode: 0644]
winsup/cygwin/path.cc

index 19b19f3..82543c2 100644 (file)
@@ -1,3 +1,15 @@
+2000-10-16  Charles Wilson  <cwilson@ece.gatech.edu>
+
+       * fhandler_clipboard.cc: new file
+       * Makefile.in: include fhandler_clipboard.o in DLL_OFILES list.
+       * fhandler.h: add FH_CLIPBOARD to the devices enum.
+       (fhandler_dev_clipboard): new
+       * path.cc (windows_device_names): add "\\dev\\clipboard"
+       (get_device_number): check for "clipboard"
+       * dcrt0.cc: declare a few more functions from winuser.h
+       * dtable.cc (dtable::build_fhandler): check for FH_CLIPBOARD in
+       switch().
+
 Mon Oct 16 21:36:57 2000  Christopher Faylor <cgf@cygnus.com>
 
        * debug.cc (add_handle): Issue warning on attempts to add the same
index 2d2f408..fb0b658 100644 (file)
@@ -114,7 +114,8 @@ DLL_IMPORTS:=$(w32api_lib)/libkernel32.a
 
 DLL_OFILES:=assert.o cygheap.o dcrt0.o debug.o delqueue.o dir.o dlfcn.o \
        dll_init.o dtable.o environ.o  errno.o exceptions.o exec.o external.o \
-       fcntl.o fhandler.o fhandler_console.o fhandler_floppy.o fhandler_mem.o \
+       fcntl.o fhandler.o fhandler_clipboard.o fhandler_console.o \
+       fhandler_floppy.o fhandler_mem.o \
        fhandler_random.o fhandler_raw.o fhandler_serial.o fhandler_tape.o \
        fhandler_termios.o fhandler_tty.o fhandler_windows.o fhandler_zero.o \
        fork.o glob.o grp.o heap.o init.o ioctl.o localtime.o malloc.o mmap.o \
index 117cb75..bba2425 100644 (file)
@@ -1211,10 +1211,12 @@ dummy_autoload (void)
 {
 LoadDLLinit (user32)
 LoadDLLfunc (CharToOemBuffA, 12, user32)
+LoadDLLfunc (CloseClipboard, 0, user32)
 LoadDLLfunc (CreateWindowExA, 48, user32)
 LoadDLLfunc (DefWindowProcA, 16, user32)
 LoadDLLfunc (DispatchMessageA, 4, user32)
 LoadDLLfunc (FindWindowA, 8, user32)
+LoadDLLfunc (GetClipboardData, 4, user32)
 LoadDLLfunc (GetMessageA, 16, user32)
 LoadDLLfunc (GetProcessWindowStation, 0, user32)
 LoadDLLfunc (GetThreadDesktop, 4, user32)
@@ -1223,6 +1225,7 @@ LoadDLLfunc (KillTimer, 8, user32)
 LoadDLLfunc (MessageBoxA, 16, user32)
 LoadDLLfunc (MsgWaitForMultipleObjects, 20, user32)
 LoadDLLfunc (OemToCharBuffA, 12, user32)
+LoadDLLfunc (OpenClipboard, 4, user32)
 LoadDLLfunc (PeekMessageA, 20, user32)
 LoadDLLfunc (PostMessageA, 16, user32)
 LoadDLLfunc (PostQuitMessage, 4, user32)
index be92bfc..accf707 100644 (file)
@@ -299,6 +299,9 @@ dtable::build_fhandler (int fd, DWORD dev, const char *name, int unit)
       case FH_MEM:
        fh = new (buf) fhandler_dev_mem (name, unit);
        break;
+      case FH_CLIPBOARD:
+       fh = new (buf) fhandler_dev_clipboard (name);
+       break;
       default:
        /* FIXME - this could recurse forever */
        return build_fhandler (fd, name, NULL);
index 94615ba..d9219f6 100644 (file)
@@ -43,6 +43,8 @@ details. */
 
      fhandler_dev_mem     /dev/mem implementation (fhandler_mem.cc)
 
+     fhandler_dev_clipboard    /dev/clipboard implementation (fhandler_clipboard.cc)
+
      fhandler_proc       Interesting possibility, not implemented yet
 */
 
@@ -97,8 +99,9 @@ enum
   FH_ZERO    = 0x00000014,     /* is the zero device */
   FH_RANDOM  = 0x00000015,     /* is a random device */
   FH_MEM     = 0x00000016,     /* is a mem device */
+  FH_CLIPBOARD = 0x00000017, /* is a clipbaord device */
 
-  FH_NDEV    = 0x00000017,     /* Maximum number of devices */
+  FH_NDEV    = 0x00000018,     /* Maximum number of devices */
   FH_DEVMASK = 0x00000fff,     /* devices live here */
   FH_BAD     = 0xffffffff
 };
@@ -794,6 +797,20 @@ public:
   int msync (HANDLE h, caddr_t addr, size_t len, int flags);
 
   void dump ();
+} ;
+class fhandler_dev_clipboard: public fhandler_base
+{
+public:
+  fhandler_dev_clipboard (const char *name);
+  int is_windows (void) { return 1; }
+  int open (const char *path, int flags, mode_t mode = 0);
+  int write (const void *ptr, size_t len);
+  int read (void *ptr, size_t len);
+  off_t lseek (off_t offset, int whence);
+  int close (void);
+
+  void dump ();
 };
 
 class fhandler_windows: public fhandler_base
diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
new file mode 100644 (file)
index 0000000..6be0b12
--- /dev/null
@@ -0,0 +1,95 @@
+/* fhandler_dev_clipboard: code to access /dev/clipboard
+
+   Copyright 2000 Red Hat, Inc
+
+   Written by Charles Wilson (cwilson@ece.gatech.edu)
+
+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. */
+
+#include "winsup.h"
+#include <stdio.h>
+#include <errno.h>
+#include "cygerrno.h"
+#include "fhandler.h"
+#include <windows.h>
+#include <wingdi.h>
+#include <winuser.h>
+
+static BOOL clipboard_eof; // NOT THREAD-SAFE
+
+fhandler_dev_clipboard::fhandler_dev_clipboard (const char *name)
+  : fhandler_base (FH_CLIPBOARD, name)
+{
+  set_cb (sizeof *this);
+  clipboard_eof = false;
+}
+
+int
+fhandler_dev_clipboard::open (const char *, int flags, mode_t)
+{
+  set_flags (flags);
+  clipboard_eof = false;
+  return 1;
+}
+
+int
+fhandler_dev_clipboard::write (const void *, size_t len)
+{
+  return len;
+}
+
+int
+fhandler_dev_clipboard::read (void *ptr, size_t len)
+{
+  HGLOBAL hglb;
+  LPSTR lpstr;
+  int ret;
+  if (!clipboard_eof)
+    {
+      OpenClipboard(0);
+      hglb = GetClipboardData(CF_TEXT);
+      lpstr = (LPSTR) GlobalLock(hglb);
+      if (len < sizeof (lpstr))
+        {
+          set_errno (EINVAL);
+          GlobalUnlock (hglb);
+          CloseClipboard ();
+          return -1;
+        }
+
+      ret = snprintf((char *) ptr, len, "%s", lpstr);
+      GlobalUnlock(hglb);
+      CloseClipboard();
+      set_errno (0);
+      clipboard_eof = true;
+      return ret;
+    }
+  else
+    {
+      return 0;
+    }
+}
+
+off_t
+fhandler_dev_clipboard::lseek (off_t offset, int whence)
+{
+  return 0;
+}
+
+int
+fhandler_dev_clipboard::close (void)
+{
+  clipboard_eof = false;
+  return 0;
+}
+
+void
+fhandler_dev_clipboard::dump ()
+{
+  paranoid_printf("here, fhandler_dev_clipboard");
+}
index cbd6e54..63a8efd 100644 (file)
@@ -431,6 +431,7 @@ const char *windows_device_names[] =
   "\\dev\\zero",
   "\\dev\\%srandom",
   "\\dev\\mem",
+  "\\dev\\clipboard",
 };
 
 static int
@@ -505,6 +506,8 @@ get_device_number (const char *name, int &unit, BOOL from_conv)
           devn = FH_MEM;
           unit = 1;
         }
+      else if (deveq ("clipboard"))
+        devn = FH_CLIPBOARD;
       else if (deveq ("port"))
         {
           devn = FH_MEM;