delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2000/08/11/18:31:12

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Message-ID: <39947F5A.DC110FFD@ece.gatech.edu>
Date: Fri, 11 Aug 2000 18:34:02 -0400
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
X-Mailer: Mozilla 4.73 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin-developers AT sourceware DOT cygnus DOT com
Subject: Clipboard from Cygwin (read-only)
References: <nZFGdDAMA1h5IwZi AT almide DOT demon DOT co DOT uk> <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> <39887033 DOT 1D40E2BA AT ece DOT gatech DOT edu>

This patch against current CVS sources adds read-only access to the
windows clipboard by creating a /dev/clipboard device. The uuencoded
tar.gz file contains a patch, clipboard.patch2, and a new file,
winsup/cygwin/fhandler_clipboard.cc.  Both the patch and the new file
are pasted in plaintext below the .tar.gz.uue.

2000-08-11  Charles Wilson  cwilson AT ece DOT gatech DOT edu

	* winsup/cygwin/Makefile.in: add fhandler_clipboard.o
	to build list
	* winsup/cygwin/fhandler.h fhandler_dev_clipboard:
	new class definition
	* winsup/cygwin/fhandler.h: add FH_CLIPBOARD to 
	device enum
	* winsup/cygwin/hinfo.cc build_fhandler: add case
	for FH_CLIPBOARD
	* winsup/cygwin/path.cc: add \dev\clipboard to
	windows_device_names[]
	* winsup/cygwin/path.cc get_device_number: add
	case for clipboard to deveq
	* winsup/cygwin/winsup.h: add definitions for
	CF_TEXT, OpenClipboard, GetClipboard, and
	CloseClipboard.
	* winsup/cygwin/fhandler_clipboard.cc: new file

--Chuck

begin 644 clipboard-patch2.tar.gz
M'XL("%1WE#D``V-L:7!B;V%R9"UP871C:#(N=&%R`.T8:6_;5C)?S5\QJS:`
M%%VD3EMNNG%D)?96E AT Q;B7<7`02*>I0(4R3+PXKKYK_OS/#64<?8K8L%_&#K
MD>_-]6:&<SS--)R9K;KSFJ/ZVK+QZD\8BBQW.BUX!:!TVS+/LJS03$-I-)LM
M@*[2:LO=9K/3P:6FW&B_`OG/$&9S!)ZON@"OM+5A>K:U%VYD6^(YY'GF\7?0
MEZHU-X4[U1)7T#3IW)J+KSVX4&^%;IBB9EC2V_]^2%?]:R!Z/:AK=U[=<S7^
M7QN6%SAU[7Z!3_4,T\J=Y`K?-<2=82W`Q<DS;`N46J,CS0U=AVH`59=><Z)6
MJ]7L^T%#EN6Z?%B7&Z!T>HW#GM(]8!KE<GDGH*)`0^FU6[W6D?3N'505I551
M#J',\Q&\>R>!!(-_3JY.IN,/Y\/!]=L?B[/`F1NN4JJ;QLR8"=>_K[NH6GM5
MLV'GKN>[GK&P5+-F([GJZ7`X/;^X'%]-KGM(;MULJ(XQ17#&N16N)<QFHZ9*
MY>^%A*V]P!,NTT#QB4HH?.^MZN&&CX+.-=>7:1:S8,&S^6L@`D&/ADN_IJY9
M/)M3PS((YXL$!\*Z,UR;-D"XKF7C AT _BJ"<='<WG\(C2>?)2 DOT 3 AT Q(QN<Y\K^(
M4.J.B&B;(@,QU4W;<>ZS*XF",ROK34IX-$/-LIKZJI,CC$*M#-O++?GW3*>:
MTD'?G-OK'-1OPJ6CZK9[B]/"M&<TN0[^+H7*DV'I=D0ITI=A:WQRT]94TS=6
M),I*-?&5'E:,9 AT F"M'RAXN2@>=;SB`C&Z26M170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[:]458;>HQ?R1\=IV;[&=
MTH1%<84BN!N&4.&NO"B>2B&Q&*P&<&D**MJH*PA,GQ%8@$+_7Q\QADV'Y_W!
MZ'I0H$`ES86OHN@<E:0?HFL6^"F\[U[^G"X5XC14R(#%%Y((**'/^5CQ<ZA,
M5#H5MGX,]3J,QA.8G%T-3DZK=+\E27LLU/ON[@LMTLOW%U#,UAL5",&P:@!/
M^%-M!D7J>5!M;WS4.P7MO*`8 AT 745BY-CZ9LD8<>S5\;MGFU'OY9RYF5L96GZ
M(ZZ0]H>/2;"C\\MU=,P[HH;OC]+[H^Z0:9U]'([?GPQAN3!G).GP\GIR!:;C
M^2Z]AAVF'S;F5-O]+7?&L(A[B$JY?(*62W%E2+11&UL).4KY"1QS1<`B"U&"
MCZ8]4\VAK=T6B40"1W+@`>`GB.Q>9,Q,2?F0%I=L*79[*`[.1Y]/A AT D=&B&/
M3Y:)7"#/AD:^*."+@'0SLD-521>_25*RAR?Q++ZHUHO%T)U*P$9`X2M0>.T5
M*N&9$ZI9:?+";%0GR7KF=*G"-_W0=P-Q+.6$#HW*$H>5>\Z2$9`<@^"Q^.9@
MKY]M7R]D/55^U$^S=Q",^=BG%)(D^+TTHZL;)H<16K40>!K9HT#W6)4]Z:10
<(N)_=;9[&2_C9;R,E_$R7@:-_P`7(2DX`"@``(<1
`
end

--------------------- clipboard.patch2 ------------------------
? fhandler_clipboard.cc
Index: 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/11 21:54:49
@@ -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: 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/11 21:54:52
@@ -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: hinfo.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/hinfo.cc,v
retrieving revision 1.13
diff -u -r1.13 hinfo.cc
--- hinfo.cc	2000/08/04 04:04:46	1.13
+++ hinfo.cc	2000/08/11 21:54:53
@@ -283,6 +283,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: 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/11 21:54:58
@@ -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: winsup.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v
retrieving revision 1.27
diff -u -r1.27 winsup.h
--- winsup.h	2000/08/10 19:33:54	1.27
+++ winsup.h	2000/08/11 21:55:02
@@ -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 clipboard.patch2 ------------------------


----------------- winsup/cygwin/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 <errno.h>
#include "winsup.h"
#include <windows.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, int)
{
  return 0;
}

int
fhandler_dev_clipboard::close (void)
{
  clipboard_eof = false;
  return 0;
}

void
fhandler_dev_clipboard::dump ()
{
  paranoid_printf("here, fhandler_dev_clipboard");
}
------------- end winsup/cygwin/fhandler_clipboard.cc ----------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019