Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <39887033.1D40E2BA@ece.gatech.edu> Date: Wed, 02 Aug 2000 15:02:11 -0400 From: Charles Wilson X-Mailer: Mozilla 4.73 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: cygwin AT sourceware DOT cygnus DOT com Subject: Re: Clipboard from Cygwin? References: <003b01bffc0a$6da278a0$3c5350d8 AT guinness> <200008012327 DOT TAA29658 AT envy DOT delorie DOT com> <398783D9 DOT E25355B6 AT ece DOT gatech DOT edu> <200008020225 DOT WAA31321 AT envy DOT delorie DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Okay, here's the most recent version of my experimental /dev/clipboard stuff. I'm gonna have to leave off for a while, but I wanted to post it here so it'd be available if anybody wants to play with it. It compiles (*) but be warned: the compiled kernel hangs -- this may or may not be related to the clipboard patch itself. (*) There are a few build problems with the CVS version of winsup -- that's why there haven't been any snapshots since June 25. DJ & Chris are working on fixing that. I was able to --build-- by playing a few games with stuff unrelated to /dev/clipboard. Those 'games' are not included in the patch below. Anyway, I'd wait a day or so until the regular CVS version of cygwin is buildable, and the snapshots show up again, and then start playing with this stuff. So, FWIW, here ya go: contains both a patch and a new file, fhandler_clipboard.cc, that should be copied into winsup/cygwin. Both are pasted in plaintext below the uue file. --Chuck begin 664 clipboard-patch.tar.gz M'XL("-ENB#D``V-L:7!B;V%R9"UP871C:"YT87(`[1C];]I8LK_&?\6(;B4H M!&P^$W*]:TIHDUL2HD`W=Z=*R)AGL&)L[[,=FNWV?]^9L0TVX&VCNTUU4IX$ MSWYOOM[,>#Z>85O>U-7EK.KI@;%X\5<,357;[2:\`-`Z+95G5=5HIJ'5FVH; MH*,UZPC64ENTU&FT7H#ZETBS-4(_T"7`"V-EV;[KY,)=N8YX"G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77)PZW%2J,:[OFL&*UV*J#$T$O[(>.7*.^R<#.%0M*"X+*/`*.32CZ.D M$A%+P*H`U[:@PHP:@-`.&($%*/3^_0$CTV1PT>M?C?H%"C_*3`0ZBLZQ1GD9 M7ZS`WZ(;[L7?-TN%)+D44F#)%20"*CDJ[WYWYX0J[F9[`RBFJX,*1&"8X\$7 MP<280I'Z%=3#ZP`5B;'UJZ)@4Y(KRFY;M:>EVC#@9>PV::+`O>G4OL5H3P^6 MZ:V814P-W[])[\_Z-*9U_F$P?'X*Q)ZB8FC%`CB.WR]:A:+D6I+P)+B M9 AT 4*K_Q")2+&9",R'QT[10BV\V5:Y8F2N`7-5=-NGYI6M/I--:>;V5U,6LY% MC5M]QL+/7'<0>!(KI$#W'I6Q_-X'L_C_WK\`0`0 &1%@`*``` ` end -----------------beginning of patch------------------------- ? cygwin/fhandler_clipboard.cc Index: cygwin/Makefile.in =================================================================== RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v retrieving revision 1.26 diff -u -r1.26 Makefile.in --- Makefile.in 2000/08/02 16:28:17 1.26 +++ Makefile.in 2000/08/02 18:45:15 @@ -114,18 +114,19 @@ EXTRA_OFILES=$(bupdir1)/libiberty/random.o $(bupdir1)/libiberty/strsignal.o -DLL_IMPORTS:=$(w32api_lib)/libkernel32.a +DLL_IMPORTS:=$(w32api_lib)/libkernel32.a $(w32api_lib)/libuser32.a DLL_OFILES:=assert.o dcrt0.o debug.o delqueue.o dir.o dlfcn.o dll_init.o \ environ.o errno.o exceptions.o exec.o external.o fcntl.o fhandler.o \ fhandler_console.o fhandler_floppy.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 hinfo.o \ - init.o ioctl.o localtime.o malloc.o mmap.o net.o ntea.o passwd.o \ - path.o pinfo.o pipe.o poll.o regexp.o regerror.o regsub.o registry.o \ - resource.o scandir.o security.o select.o shared.o signal.o sigproc.o \ - smallprint.o spawn.o strace.o strsep.o sync.o syscalls.o sysconf.o \ - syslog.o termios.o times.o tty.o uinfo.o uname.o wait.o window.o \ + fhandler_windows.o fhandler_zero.o fhandler_clipboard.o fork.o glob.o \ + grp.o heap.o hinfo.o init.o ioctl.o localtime.o malloc.o mmap.o net.o \ + ntea.o passwd.o path.o pinfo.o pipe.o poll.o regexp.o regerror.o \ + regsub.o registry.o resource.o scandir.o security.o select.o shared.o \ + signal.o sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o \ + syscalls.o sysconf.o syslog.o termios.o times.o tty.o uinfo.o uname.o \ + wait.o window.o \ $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MT_SAFE_OBJECTS) GMON_OFILES:= gmon.o mcount.o profil.o @@ -307,6 +308,7 @@ fhandler_floppy.o: $(WINSUP_H) fhandler_tape.o: $(WINSUP_H) fhandler_zero.o: $(WINSUP_H) +fhandler_clipboard.o: $(WINSUP_H) fhandler_random.o: $(WINSUP_H) fork.o: $(WINSUP_H) dll_init.h glob.o: include/glob.h Index: cygwin/fhandler.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler.h,v retrieving revision 1.16 diff -u -r1.16 fhandler.h --- fhandler.h 2000/07/29 04:19:24 1.16 +++ fhandler.h 2000/08/02 18:45:16 @@ -27,6 +27,7 @@ fhandler_dev_raw (fhandler_raw.cc) fhandler_dev_floppy (fhandler_floppy.cc) fhandler_dev_tape (fhandler_tape.cc) + fhandler_dev_clipboard (fhandler_clip.cc) fhandler_pipe fhandler_socket (net.cc) @@ -94,8 +95,9 @@ FH_NULL = 0x00000013, /* is the null device */ FH_ZERO = 0x00000014, /* is the zero device */ FH_RANDOM = 0x00000015, /* is a random device */ + FH_CLIPBOARD = 0x00000016, /* is the windows clipboard */ - FH_NDEV = 0x00000016, /* Maximum number of devices */ + FH_NDEV = 0x00000017, /* Maximum number of devices */ FH_DEVMASK = 0x00000fff, /* devices live here */ FH_BAD = 0xffffffff }; @@ -761,6 +763,21 @@ int dup (fhandler_base *child); void dump (); +}; + +class fhandler_dev_clipboard: public fhandler_base +{ +public: + fhandler_dev_clipboard (const char *name); + + void dump (); + + 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, int); + int close (void); }; class fhandler_windows: public fhandler_base Index: cygwin/hinfo.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/hinfo.cc,v retrieving revision 1.12 diff -u -r1.12 hinfo.cc --- hinfo.cc 2000/08/02 16:28:17 1.12 +++ hinfo.cc 2000/08/02 18:45:17 @@ -282,6 +282,9 @@ case FH_ZERO: fh = new (buf) fhandler_dev_zero (name); break; + case FH_CLIPBOARD: + fh = new (buf) fhandler_dev_clipboard (name); + break; case FH_RANDOM: fh = new (buf) fhandler_dev_random (name, unit); break; Index: cygwin/path.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/path.cc,v retrieving revision 1.41 diff -u -r1.41 path.cc --- path.cc 2000/08/02 16:28:17 1.41 +++ path.cc 2000/08/02 18:45:21 @@ -437,6 +437,7 @@ "\\dev\\st%d", "nul", "\\dev\\zero", + "\\dev\\clipboard", "\\dev\\%srandom", }; @@ -502,6 +503,8 @@ devn = FH_NULL; else if (deveq ("zero")) devn = FH_ZERO; + else if (deveq ("clipboard")) + devn = FH_CLIPBOARD; else if (deveq ("random") || deveq ("urandom")) { devn = FH_RANDOM; Index: cygwin/winsup.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v retrieving revision 1.25 diff -u -r1.25 winsup.h --- winsup.h 2000/08/02 16:28:18 1.25 +++ winsup.h 2000/08/02 18:45:24 @@ -72,8 +72,12 @@ #undef _WINNETWK_H #undef _WINSVC_H -/* The one function we use from winuser.h most of the time */ +/* The few functions we use from winuser.h most of the time */ extern "C" DWORD WINAPI GetLastError (void); +#define CF_TEXT 1 +extern "C" BOOL WINAPI OpenClipboard(HWND); +extern "C" HANDLE WINAPI GetClipboardData(UINT); +extern "C" BOOL WINAPI CloseClipboard(void); /* Used for runtime OS check/decisions. */ enum os_type {winNT = 1, win95, win98, win32s, unknown}; -----------------------------end of patch------------------------ ----------------------------fhandler_clipboard.cc---------------- /* fhandler_dev_clipboard: code to access /dev/clipboard Copyright 2000 Red Hat Written by Charles Wilson (cwilson AT ece DOT gatech DOT 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 #include "winsup.h" #include fhandler_dev_clipboard::fhandler_dev_clipboard (const char *name) : fhandler_base (FH_CLIPBOARD, name) { set_cb (sizeof *this); } int fhandler_dev_clipboard::open (const char *, int flags, mode_t) { set_flags (flags); 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; OpenClipboard(0); hglb = GetClipboardData(CF_TEXT); lpstr = (LPSTR) GlobalLock(hglb); len = snprintf((char *) ptr, len, "%s", lpstr); GlobalUnlock(hglb); CloseClipboard(); return len; } off_t fhandler_dev_clipboard::lseek (off_t, int) { return 0; } int fhandler_dev_clipboard::close (void) { return 0; } void fhandler_dev_clipboard::dump () { paranoid_printf("here, fhandler_dev_clipboard"); } -------------------end of fhandler_clipboard.cc--------- -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com