[patch] partial /dev/clipboard support for cygwin
Charles Wilson
cwilson@ece.gatech.edu
Thu Oct 12 22:54:00 GMT 2000
(my apologies if this is a duplicate message; I'm having trouble with my
mail server)
This patch provides limited /dev/clipboard capability for cygwin. The
limitations are:
1) read-only
2) /dev/clipboard can only be read all-at-once -- no buffering. It
should be possible to provide seek() capability so that the contents of
the clipboard can be read in multiple small chunks, but thread safety is
an issue. I felt it best to get the initial support into cygwin, and
then try to add seek() support and buffering.
Note that since /bin/cat uses a small buffer (1024 bytes), "cat
/dev/clipboard" only works reliably if the contents of the clipboard is
smaller than 1024. The following snippet of code can be used to
demonstrate that, with a large enough buffer, "read the whole thing at
once" *does* work. Just change 'BUFSZ' to a value larger than the
clipboard contents. (For testing purposes, I found the "putclip"
program useful -- so I could "put" a file of known size into the windows
clipboard. You can get putclip from
http://cygutils.netpedia.net/misc.tar.gz )
----clip-----
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define BUFSZ 72000
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);
}
------clip-----
--Chuck
2000-10-13 Charles Wilson <cwilson@ece.gatech.edu>
* winsup/cygwin/Makefile.in: add libuser32.a to the list of
DLL_IMPORTS,
and include fhandler_clipboard.o in the list of DLL_OFILES
* winsup/cygwin/dtable.cc (dtable::build_fhander): check for
FH_CLIPBOARD
* winsup/cygwin/fhandler.h: add fhandler_dev_clipboard to comments, add
FH_CLIPBOARD to fhandler enum
* winsup/cygwin/fhandler.h (fhandler_dev_clipboard): new declaration
* winsup/cygwin/path.cc (windows_device_names): add "\\dev\\clipboard"
* winsup/cygwin/path.cc (get_device_number): check for FH_CLIPBOARD
* winsup/cygwin/winsup.h: add a few more #defines from winuser.h
* winsup/cygwin/fhandler_clipboard.cc: new file
fhandler_clipboard.cc.gz
clipboard.patch6a.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/20001012/2b4af7b8/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/20001012/2b4af7b8/attachment-0001.bin>
More information about the Cygwin-patches
mailing list