[patch] limited /dev/clipboard support
Charles Wilson
cwilson@ece.gatech.edu
Sat Oct 14 17:04:00 GMT 2000
This patch provides limited /dev/clipboard support for cygwin. The
limitations are:
1) read-only
2) /dev/clipboard must be read as a whole, not in small chunks.
(/bin/cat seems to use a 1024 byte buffer, so if the contents of the
clipboard is more than 1023 bytes, "cat /dev/clipboard" returns 1023
good characters followed either by (length - 1023) garbage chars or
"Hangup")
#2 shouldn't be too difficult to fix, but I'm not sure how to go about
it and still be thread-safe. However, I figured it was best to get this
in, and then try to fix it. The following test program shows that
"all-at-once" reads will work okay; change BUFSZ to be larger than
whatever you put into the clipboard (using notepad or putclip.exe from
http://cygutils.netpedia.net/misc.tar.gz ).
----snip----
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define BUFSZ 4096
int main(int argc, char * argv[])
{
char buf[BUFSZ+1];
int fd;
fd = open("/dev/clipboard", O_BINARY | O_RDONLY );
read(fd, buf, BUFSZ);
buf[BUFSZ] = '\0';
printf("%s", buf);
}
----snip----
--Chuck
2000-10-12 Charles Wilson <cwilson@ece.gatech.edu>
* winsup/cygwin/fhandler_clipboard.cc: new file
* winsup/cygwin/Makefile.in: add libuser32.a to the DLL_IMPORTS list,
and include fhandler_clipboard.o in DLL_OFILES list.
* winsup/cygwin/fhandler.h: add FH_CLIPBOARD to the devices enum.
* winsup/cygwin/fhandler.h (fhandler_dev_clipboard): new
* winsup/cygwin/path.cc (windows_device_names): add "\\dev\\clipboard"
* winsup/cygwin/path.cc (get_device_number): check for "clipboard"
* winsup/cygwin/winsup.h: declare a few more functions from winuser.h
* winsup/cygwin/dtable.cc (dtable::build_fhandler): check for
FH_CLIPBOARD in switch().
clipboard.patch6a.gz
fhandler_clipboard.cc.gz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clipboard.patch6a.gz
Type: application/x-gzip
Size: 1742 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20001014/c559a173/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fhandler_clipboard.cc.gz
Type: application/x-gzip
Size: 784 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20001014/c559a173/attachment-0001.bin>
More information about the Cygwin-patches
mailing list