aboutsummaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2011-07-07 15:41:53 +0200
committerStefan Reinauer <stefan.reinauer@coreboot.org>2011-08-04 08:10:41 +0200
commit3b77b723ca209199c8a224702812441e2196d452 (patch)
treecbf3be2c724139ec80a33dbf8e002b7871ef9307 /payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c
parent1ac19e28eed4f6c53a4f295eb55500c65fc80f8d (diff)
libpayload: Add PDCurses and ncurses' libform/libmenu
PDCurses provides an alternative implementation of the curses library standard in addition to tinycurses. Where tinycurses is really tiny, PDCurses is more complete and provides virtually unlimited windows and the full API. The PDCurses code is brought in "vanilla", with all local changes residing in curses/pdcurses-backend/ In addition to a curses library, this change also provides libpanel (as part of the PDCurses code), and libform and libmenu which were derived from ncurses-5.9. As they rely on ncurses internals (and PDCurses is not ncurses), more changes were required for these libraries to work. The build system is extended to install the right set of header files depending on the selected curses implementation. Change-Id: I9e5b920f94b6510da01da2f656196a993170d1c5 Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/106 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones <marcj303@gmail.com>
Diffstat (limited to 'payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c')
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c185
1 files changed, 185 insertions, 0 deletions
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c
new file mode 100644
index 0000000000..ddc61d9029
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c
@@ -0,0 +1,185 @@
+/* Public Domain Curses */
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdcclip.c,v 1.33 2008/07/14 04:24:51 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+int PDC_getclipboard(char **contents, long *length)
+{
+#ifndef EMXVIDEO
+ HMQ hmq;
+ HAB hab;
+ PTIB ptib;
+ PPIB ppib;
+ ULONG ulRet;
+ long len;
+ int rc;
+#endif
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+#ifndef EMXVIDEO
+ DosGetInfoBlocks(&ptib, &ppib);
+ ppib->pib_ultype = 3;
+ hab = WinInitialize(0);
+ hmq = WinCreateMsgQueue(hab, 0);
+
+ if (!WinOpenClipbrd(hab))
+ {
+ WinDestroyMsgQueue(hmq);
+ WinTerminate(hab);
+ return PDC_CLIP_ACCESS_ERROR;
+ }
+
+ rc = PDC_CLIP_EMPTY;
+
+ ulRet = WinQueryClipbrdData(hab, CF_TEXT);
+
+ if (ulRet)
+ {
+ len = strlen((char *)ulRet);
+ *contents = malloc(len + 1);
+
+ if (!*contents)
+ rc = PDC_CLIP_MEMORY_ERROR;
+ else
+ {
+ strcpy((char *)*contents, (char *)ulRet);
+ *length = len;
+ rc = PDC_CLIP_SUCCESS;
+ }
+ }
+
+ WinCloseClipbrd(hab);
+ WinDestroyMsgQueue(hmq);
+ WinTerminate(hab);
+
+ return rc;
+#else
+ return PDC_CLIP_ACCESS_ERROR;
+#endif
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+#ifndef EMXVIDEO
+ HAB hab;
+ PTIB ptib;
+ PPIB ppib;
+ ULONG ulRC;
+ PSZ szTextOut = NULL;
+ int rc;
+#endif
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+#ifndef EMXVIDEO
+ DosGetInfoBlocks(&ptib, &ppib);
+ ppib->pib_ultype = 3;
+ hab = WinInitialize(0);
+
+ if (!WinOpenClipbrd(hab))
+ {
+ WinTerminate(hab);
+ return PDC_CLIP_ACCESS_ERROR;
+ }
+
+ rc = PDC_CLIP_MEMORY_ERROR;
+
+ ulRC = DosAllocSharedMem((PVOID)&szTextOut, NULL, length + 1,
+ PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE);
+
+ if (ulRC == 0)
+ {
+ strcpy(szTextOut, contents);
+ WinEmptyClipbrd(hab);
+
+ if (WinSetClipbrdData(hab, (ULONG)szTextOut, CF_TEXT, CFI_POINTER))
+ rc = PDC_CLIP_SUCCESS;
+ else
+ {
+ DosFreeMem(szTextOut);
+ rc = PDC_CLIP_ACCESS_ERROR;
+ }
+ }
+
+ WinCloseClipbrd(hab);
+ WinTerminate(hab);
+
+ return rc;
+#else
+ return PDC_CLIP_ACCESS_ERROR;
+#endif
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ if (contents)
+ free(contents);
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+#ifndef EMXVIDEO
+ HAB hab;
+ PTIB ptib;
+ PPIB ppib;
+#endif
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+#ifndef EMXVIDEO
+ DosGetInfoBlocks(&ptib, &ppib);
+ ppib->pib_ultype = 3;
+ hab = WinInitialize(0);
+
+ WinEmptyClipbrd(hab);
+
+ WinCloseClipbrd(hab);
+ WinTerminate(hab);
+
+ return PDC_CLIP_SUCCESS;
+#else
+ return PDC_CLIP_ACCESS_ERROR;
+#endif
+}