about summary refs log tree commit diff stats
path: root/src/LYUtils.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2023-11-06 01:21:57 +0000
committerThomas E. Dickey <dickey@invisible-island.net>2023-11-06 01:36:39 +0000
commitc244c640f9b4f69f521d286b77db0be566a5a610 (patch)
tree4cfff9a71e729662d748f8af597a82e5dd7b10e4 /src/LYUtils.c
parentae8afd251f08aa6ce99daf430c411dda178327c6 (diff)
downloadlynx-snapshots-c244c640f9b4f69f521d286b77db0be566a5a610.tar.gz
snapshot of project "lynx", label v2-9-0dev_12m
Diffstat (limited to 'src/LYUtils.c')
-rw-r--r--src/LYUtils.c189
1 files changed, 92 insertions, 97 deletions
diff --git a/src/LYUtils.c b/src/LYUtils.c
index c9c42489..9b5ac476 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.306 2023/10/24 00:12:43 tom Exp $
+ * $LynxId: LYUtils.c,v 1.308 2023/10/27 21:48:46 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -7560,9 +7560,96 @@ void get_clip_release(void)
     unmorph_PM();
 }
 
-#else /* !( defined __EMX__ ) */
+#elif defined(WIN_EX) /* 1997/10/16 (Thu) 20:13:28 */
 
-#  if !defined(WIN_EX) && defined(HAVE_POPEN)
+int put_clip(const char *szBuffer)
+{
+    HANDLE hWnd;
+    HANDLE m_hLogData;
+    LPTSTR pLogData;
+    HANDLE hClip;
+    int len;
+
+    if (szBuffer == NULL)
+	return EOF;
+
+    len = (int) strlen(szBuffer);
+    if (len == 0)
+	return EOF;
+    else
+	len++;
+
+    m_hLogData = GlobalAlloc(GHND, len);
+    if (m_hLogData == NULL) {
+	return EOF;
+    }
+
+    hWnd = NULL;
+    if (!OpenClipboard(hWnd)) {
+	return EOF;
+    }
+    /* Remove the current Clipboard contents */
+    if (!EmptyClipboard()) {
+	GlobalFree(m_hLogData);
+	return EOF;
+    }
+
+    /* Lock the global memory while we write to it. */
+    pLogData = (LPTSTR) GlobalLock(m_hLogData);
+
+    lstrcpy((LPTSTR) pLogData, szBuffer);
+    GlobalUnlock(m_hLogData);
+
+    /* If there were any lines at all then copy them to clipboard. */
+    hClip = SetClipboardData(CF_TEXT, m_hLogData);
+    if (!hClip) {
+	/* If we couldn't clip the data then free the global handle. */
+	GlobalFree(m_hLogData);
+    }
+
+    CloseClipboard();
+    return 0;
+}
+
+static HANDLE m_hLogData;
+static int m_locked;
+
+/* get_clip_grab() returns a pointer to the string in the system area.
+   get_clip_release() should be called ASAP after this. */
+
+char *get_clip_grab()
+{
+    HANDLE hWnd;
+    LPTSTR pLogData;
+
+    hWnd = NULL;
+    if (!OpenClipboard(hWnd)) {
+	return 0;
+    }
+
+    m_hLogData = GetClipboardData(CF_TEXT);
+
+    if (m_hLogData == NULL) {
+	CloseClipboard();
+	m_locked = 0;
+	return 0;
+    }
+    pLogData = (LPTSTR) GlobalLock(m_hLogData);
+
+    m_locked = 1;
+    return pLogData;
+}
+
+void get_clip_release()
+{
+    if (!m_locked)
+	return;
+    GlobalUnlock(m_hLogData);
+    CloseClipboard();
+    m_locked = 0;
+}
+
+#elif defined(HAVE_POPEN)
 
 static FILE *paste_handle = 0;
 static char *paste_buf = NULL;
@@ -7643,9 +7730,8 @@ int put_clip(const char *s)
     return 0;
 }
 
-#  endif /* !defined(WIN_EX) && defined(HAVE_POPEN) */
-
-#endif /* __EMX__ */
+#endif /* __EMX__ ... HAVE_POPEN */
+#endif /* CAN_CUT_AND_PASTE */
 
 /*
  * Sleep for a number of milli-sec.
@@ -7671,97 +7757,6 @@ void LYmsec_delay(unsigned msec)
 #endif
 }
 
-#if defined(WIN_EX)		/* 1997/10/16 (Thu) 20:13:28 */
-
-int put_clip(const char *szBuffer)
-{
-    HANDLE hWnd;
-    HANDLE m_hLogData;
-    LPTSTR pLogData;
-    HANDLE hClip;
-    int len;
-
-    if (szBuffer == NULL)
-	return EOF;
-
-    len = (int) strlen(szBuffer);
-    if (len == 0)
-	return EOF;
-    else
-	len++;
-
-    m_hLogData = GlobalAlloc(GHND, len);
-    if (m_hLogData == NULL) {
-	return EOF;
-    }
-
-    hWnd = NULL;
-    if (!OpenClipboard(hWnd)) {
-	return EOF;
-    }
-    /* Remove the current Clipboard contents */
-    if (!EmptyClipboard()) {
-	GlobalFree(m_hLogData);
-	return EOF;
-    }
-
-    /* Lock the global memory while we write to it. */
-    pLogData = (LPTSTR) GlobalLock(m_hLogData);
-
-    lstrcpy((LPTSTR) pLogData, szBuffer);
-    GlobalUnlock(m_hLogData);
-
-    /* If there were any lines at all then copy them to clipboard. */
-    hClip = SetClipboardData(CF_TEXT, m_hLogData);
-    if (!hClip) {
-	/* If we couldn't clip the data then free the global handle. */
-	GlobalFree(m_hLogData);
-    }
-
-    CloseClipboard();
-    return 0;
-}
-
-static HANDLE m_hLogData;
-static int m_locked;
-
-/* get_clip_grab() returns a pointer to the string in the system area.
-   get_clip_release() should be called ASAP after this. */
-
-char *get_clip_grab()
-{
-    HANDLE hWnd;
-    LPTSTR pLogData;
-
-    hWnd = NULL;
-    if (!OpenClipboard(hWnd)) {
-	return 0;
-    }
-
-    m_hLogData = GetClipboardData(CF_TEXT);
-
-    if (m_hLogData == NULL) {
-	CloseClipboard();
-	m_locked = 0;
-	return 0;
-    }
-    pLogData = (LPTSTR) GlobalLock(m_hLogData);
-
-    m_locked = 1;
-    return pLogData;
-}
-
-void get_clip_release()
-{
-    if (!m_locked)
-	return;
-    GlobalUnlock(m_hLogData);
-    CloseClipboard();
-    m_locked = 0;
-}
-#endif /* WIN_EX */
-#endif /* CAN_CUT_AND_PASTE */
-
 #if defined(WIN_EX)
 
 #ifndef WSABASEERR