1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Add logging to GPG2: [W32CE].

This commit is contained in:
Werner Koch 2010-12-02 13:56:28 +00:00
parent 6dda170e32
commit b25155613a
2 changed files with 47 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2010-12-02 Werner Koch <wk@g10code.com>
* logging.c (fun_cookie_s) [W32CE]: Add field USE_WRITEFILE.
(fun_writer) [W32CE]: Make use of it.
(set_file_fd) [W32CE]: Implement special filename "GPG2:".
2010-11-25 Werner Koch <wk@g10code.com>
* asshelp.c (start_new_gpg_agent): Change style of startup info.

View File

@ -117,6 +117,9 @@ struct fun_cookie_s
int quiet;
int want_socket;
int is_socket;
#ifdef HAVE_W32CE_SYSTEM
int use_writefile;
#endif
char name[1];
};
@ -356,8 +359,20 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
}
log_socket = cookie->fd;
if (cookie->fd != -1 && !writen (cookie->fd, buffer, size, cookie->is_socket))
return (ssize_t)size; /* Okay. */
if (cookie->fd != -1)
{
#ifdef HAVE_W32CE_SYSTEM
if (cookie->use_writefile)
{
DWORD nwritten;
WriteFile ((HANDLE)cookie->fd, buffer, size, &nwritten, NULL);
return (ssize_t)size; /* Okay. */
}
#endif
if (!writen (cookie->fd, buffer, size, cookie->is_socket))
return (ssize_t)size; /* Okay. */
}
if (!running_detached && cookie->fd != -1
&& isatty (es_fileno (es_stderr)))
@ -400,6 +415,9 @@ set_file_fd (const char *name, int fd)
{
estream_t fp;
int want_socket;
#ifdef HAVE_W32CE_SYSTEM
int use_writefile = 0;
#endif
struct fun_cookie_s *cookie;
/* Close an open log stream. */
@ -423,6 +441,23 @@ set_file_fd (const char *name, int fd)
else if (name && !strncmp (name, "socket://", 9) && name[9])
want_socket = 2;
#endif /*HAVE_W32_SYSTEM*/
#ifdef HAVE_W32CE_SYSTEM
else if (name && !strcmp (name, "GPG2:"))
{
HANDLE hd;
ActivateDevice (L"Drivers\\GnuPG_Log", 0);
/* Ignore a filename and write the debug output to the GPG2:
device. */
hd = CreateFile (L"GPG2:", GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
fd = (hd == INVALID_HANDLE_VALUE)? -1 : (int)hd;
name = NULL;
force_prefixes = 1;
use_writefile = 1;
}
#endif /*HAVE_W32CE_SYSTEM*/
/* Setup a new stream. */
@ -434,6 +469,9 @@ set_file_fd (const char *name, int fd)
cookie->quiet = 0;
cookie->is_socket = 0;
cookie->want_socket = want_socket;
#ifdef HAVE_W32CE_SYSTEM
cookie->use_writefile = use_writefile;
#endif
if (!name)
cookie->fd = fd;
else if (want_socket)