Beispiel #1
0
/* WindowsCE does not provide a pipe feature.  However we need
   something like a pipe to convey data between processes and in some
   cases within a process.  This replacement is not only used by
   libassuan but exported and thus usable by gnupg and gpgme as well.  */
DWORD
_assuan_w32ce_create_pipe (HANDLE *read_hd, HANDLE *write_hd,
                           LPSECURITY_ATTRIBUTES sec_attr, DWORD size)
{
  HANDLE hd[2] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE};
  int rvid;
  int rc = 0;

  hd[0] = _assuan_w32ce_prepare_pipe (&rvid, 0);
  if (hd[0] != INVALID_HANDLE_VALUE)
    {
      hd[1] = _assuan_w32ce_finish_pipe (rvid, 1);
      if (hd[1] != INVALID_HANDLE_VALUE)
        rc = 1;
      else
        {
          DWORD lastrc = GetLastError ();
          CloseHandle (hd[0]);
          hd[0] = INVALID_HANDLE_VALUE;
          SetLastError (lastrc);
        }
    }
  
  *read_hd = hd[0];
  *write_hd = hd[1];
  return rc;
}
Beispiel #2
0
static gpg_error_t
cmd_message (assuan_context_t ctx, char *line)
{
  int rc;
  gnupg_fd_t sysfd;
  int fd;
  ctrl_t ctrl = assuan_get_pointer (ctx);

  rc = assuan_command_parse_fd (ctx, line, &sysfd);
  if (rc)
    return rc;

#ifdef HAVE_W32CE_SYSTEM
  sysfd = _assuan_w32ce_finish_pipe ((int)sysfd, 0);
  if (sysfd == INVALID_HANDLE_VALUE)
    return set_error (gpg_err_code_from_syserror (),
		      "rvid conversion failed");
#endif

  fd = translate_sys2libc_fd (sysfd, 0);
  if (fd == -1)
    return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
  ctrl->server_local->message_fd = fd;
  return 0;
}
Beispiel #3
0
/* Format is OUTPUT FD=<n> */
static gpg_error_t
std_handler_output (assuan_context_t ctx, char *line)
{
  gpg_error_t rc;
  assuan_fd_t fd, oldfd;

  rc = assuan_command_parse_fd (ctx, line, &fd);
  if (rc)
    return PROCESS_DONE (ctx, rc);

#ifdef HAVE_W32CE_SYSTEM
  oldfd = fd;
  fd = _assuan_w32ce_finish_pipe ((int)fd, 1);
  if (fd == INVALID_HANDLE_VALUE)
    return PROCESS_DONE (ctx, set_error (ctx, gpg_err_code_from_syserror (),
					 "rvid conversion failed"));
  TRACE2 (ctx, ASSUAN_LOG_SYSIO, "std_handler_output", ctx,
	  "turned RVID 0x%x into handle 0x%x", oldfd, fd);
#endif

  if (ctx->output_notify_fnc)
    {
      oldfd = ctx->output_fd;
      ctx->output_fd = fd;
      rc = ctx->output_notify_fnc (ctx, line);
      if (rc)
        ctx->output_fd = oldfd;
    }
  else if (!rc)
    ctx->output_fd = fd;
  return PROCESS_DONE (ctx, rc);
}