* 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().
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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 \ | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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 | ||||
| }; | ||||
| @@ -793,6 +796,20 @@ public: | ||||
|   int munmap (HANDLE h, caddr_t addr, size_t len); | ||||
|   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 (); | ||||
| }; | ||||
|  | ||||
|   | ||||
							
								
								
									
										95
									
								
								winsup/cygwin/fhandler_clipboard.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								winsup/cygwin/fhandler_clipboard.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -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"); | ||||
| } | ||||
| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user