Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2000-10-17 05:46:26 +0400
committerDJ Delorie <dj@redhat.com>2000-10-17 05:46:26 +0400
commite6f5c9d57d2c36296d8eed223c92a3084ccf4a93 (patch)
tree6876b004384dfa260cea9f2c8fbcbe8cc452c8f9 /winsup/cygwin
parent92e1969051640fe2c25a8862162eb1a59bd0b888 (diff)
* 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().
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/Makefile.in3
-rw-r--r--winsup/cygwin/dcrt0.cc3
-rw-r--r--winsup/cygwin/dtable.cc3
-rw-r--r--winsup/cygwin/fhandler.h19
-rw-r--r--winsup/cygwin/fhandler_clipboard.cc95
-rw-r--r--winsup/cygwin/path.cc3
7 files changed, 136 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 19b19f3d9..82543c267 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 2d2f4083c..fb0b65825 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -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 \
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 117cb75c6..bba242533 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -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)
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index be92bfce4..accf7070a 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -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);
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 94615ba83..d9219f6b9 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -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
index 000000000..6be0b1200
--- /dev/null
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -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");
+}
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index cbd6e5493..63a8efde8 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -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;