[svn] assuan - r376 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Thu Jun 10 19:27:25 CEST 2010
Author: marcus
Date: 2010-06-10 19:27:24 +0200 (Thu, 10 Jun 2010)
New Revision: 376
Modified:
trunk/src/ChangeLog
trunk/src/system-w32ce.c
trunk/src/w32ce-add.h
Log:
2010-06-10 Marcus Brinkmann <marcus at g10code.de>
* w32ce-add.h (ASSUAN_STDIN, ASSUAN_STDOUT): Define magic handle values.
* system-w32ce.c (__assuan_read, __assuan_write): Handle magic
handle values differently.
* system-w32ce.c (_assuan_w32ce_finish_pipe): Return error on RVID 0.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2010-06-09 13:12:31 UTC (rev 375)
+++ trunk/src/ChangeLog 2010-06-10 17:27:24 UTC (rev 376)
@@ -1,3 +1,11 @@
+2010-06-10 Marcus Brinkmann <marcus at g10code.de>
+
+ * w32ce-add.h (ASSUAN_STDIN, ASSUAN_STDOUT): Define magic handle values.
+ * system-w32ce.c (__assuan_read, __assuan_write): Handle magic
+ handle values differently.
+
+ * system-w32ce.c (_assuan_w32ce_finish_pipe): Return error on RVID 0.
+
2010-06-09 Marcus Brinkmann <marcus at g10code.de>
* gpgcedev.c (GPGCEDEV_IOCTL_UNBLOCK): New ioctl.
Modified: trunk/src/system-w32ce.c
===================================================================
--- trunk/src/system-w32ce.c 2010-06-09 13:12:31 UTC (rev 375)
+++ trunk/src/system-w32ce.c 2010-06-10 17:27:24 UTC (rev 376)
@@ -158,6 +158,9 @@
{
HANDLE hd;
+ if (!rvid)
+ return INVALID_HANDLE_VALUE;
+
hd = CreateFile (L"GPG1:", write_end? GENERIC_WRITE : GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
@@ -281,6 +284,28 @@
TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "__assuan_read", ctx,
"fd=0x%x, buffer=%p, size=%i", fd, buffer, size);
+#ifdef HAVE_W32CE_SYSTEM
+ /* This is a bit of a hack to support stdin over ssh. Note that
+ fread buffers fully while getchar is line buffered. Weird, but
+ that's the way it is. ASSUAN_STDIN and ASSUAN_STDOUT are
+ special handle values that shouldn't occur in the wild. */
+ if (fd == ASSUAN_STDIN)
+ {
+ int i = 0;
+ int chr;
+ while (i < size)
+ {
+ chr = getchar();
+ if (chr == EOF)
+ break;
+ ((char*)buffer)[i++] = (char) chr;
+ if (chr == '\n')
+ break;
+ }
+ return TRACE_SYSRES (i);
+ }
+#endif
+
res = recv (HANDLE2SOCKET (fd), buffer, size, 0);
if (res == -1)
{
@@ -346,6 +371,18 @@
TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "__assuan_write", ctx,
"fd=0x%x, buffer=%p, size=%i", fd, buffer, size);
+#ifdef HAVE_W32CE_SYSTEM
+ /* This is a bit of a hack to support stdout over ssh. Note that
+ fread buffers fully while getchar is line buffered. Weird, but
+ that's the way it is. ASSUAN_STDIN and ASSUAN_STDOUT are
+ special handle values that shouldn't occur in the wild. */
+ if (fd == ASSUAN_STDOUT)
+ {
+ res = fwrite (buffer, 1, size, stdout);
+ return TRACE_SYSRES (res);
+ }
+#endif
+
res = send ((int)fd, buffer, size, 0);
if (res == -1 && WSAGetLastError () == WSAENOTSOCK)
{
Modified: trunk/src/w32ce-add.h
===================================================================
--- trunk/src/w32ce-add.h 2010-06-09 13:12:31 UTC (rev 375)
+++ trunk/src/w32ce-add.h 2010-06-10 17:27:24 UTC (rev 376)
@@ -26,3 +26,8 @@
LPSECURITY_ATTRIBUTES sec_attr, DWORD size);
#define CreatePipe(a,b,c,d) _assuan_w32ce_create_pipe ((a),(b),(c),(d))
+/* Magic handle values. Let's hope those never occur legitimately as
+ handles or sockets. (Sockets are numbered sequentially from 0,
+ while handles seem aligned to wordsize. */
+#define ASSUAN_STDIN (void*)0x7ffffffd
+#define ASSUAN_STDOUT (void*)0x7fffffff
More information about the Gnupg-commits
mailing list