![Marcus Brinkmann](/assets/img/avatar_default.png)
* debug.h (DEBUG_GLOBAL): New debug level. * conversion.c (gnupg_errors, _gpgme_map_gnupg_error): Removed. * data-user.c (gpgme_data_new_from_cbs): Add debug output. * data-fd.c (gpgme_data_new_from_fd): Likewise. * data-stream.c (gpgme_data_new_from_stream): Likewise. * decrypt.c (gpgme_op_decrypt_result, gpgme_op_decrypt_start) (gpgme_op_decrypt): Likewise. * delete.c (gpgme_op_delete_start, gpgme_op_delete): Likewise. * decrypt-verify.c (gpgme_op_decrypt_verify_start) (gpgme_op_decrypt_verify): Likewise. * sign.c (gpgme_op_sign_result): Fix debug message. * data-mem.c (gpgme_data_new): Improve debug output. * verify.c (parse_trust): Use atoi instead of _gpgme_map_gnupg_error. * decrypt.c (_gpgme_decrypt_status_handler): Likewise.
83 lines
1.8 KiB
C
83 lines
1.8 KiB
C
/* data-fd.c - A file descripor based data object.
|
||
Copyright (C) 2002, 2004 g10 Code GmbH
|
||
|
||
This file is part of GPGME.
|
||
|
||
GPGME is free software; you can redistribute it and/or modify it
|
||
under the terms of the GNU Lesser General Public License as
|
||
published by the Free Software Foundation; either version 2.1 of
|
||
the License, or (at your option) any later version.
|
||
|
||
GPGME is distributed in the hope that it will be useful, but
|
||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
Lesser General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Lesser General Public
|
||
License along with this program; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||
02111-1307, USA. */
|
||
|
||
#if HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include <unistd.h>
|
||
#include <sys/types.h>
|
||
|
||
#include "debug.h"
|
||
#include "data.h"
|
||
|
||
|
||
static ssize_t
|
||
fd_read (gpgme_data_t dh, void *buffer, size_t size)
|
||
{
|
||
return read (dh->data.fd, buffer, size);
|
||
}
|
||
|
||
|
||
static ssize_t
|
||
fd_write (gpgme_data_t dh, const void *buffer, size_t size)
|
||
{
|
||
return write (dh->data.fd, buffer, size);
|
||
}
|
||
|
||
|
||
static off_t
|
||
fd_seek (gpgme_data_t dh, off_t offset, int whence)
|
||
{
|
||
return lseek (dh->data.fd, offset, whence);
|
||
}
|
||
|
||
|
||
static int
|
||
fd_get_fd (gpgme_data_t dh)
|
||
{
|
||
return (dh->data.fd);
|
||
}
|
||
|
||
|
||
static struct _gpgme_data_cbs fd_cbs =
|
||
{
|
||
fd_read,
|
||
fd_write,
|
||
fd_seek,
|
||
NULL,
|
||
fd_get_fd
|
||
};
|
||
|
||
|
||
gpgme_error_t
|
||
gpgme_data_new_from_fd (gpgme_data_t *r_dh, int fd)
|
||
{
|
||
gpgme_error_t err;
|
||
TRACE_BEG1 (DEBUG_DATA, "gpgme_data_new_from_fd", r_dh, "fd=0x%x", fd);
|
||
|
||
err = _gpgme_data_new (r_dh, &fd_cbs);
|
||
if (err)
|
||
return TRACE_ERR (err);
|
||
|
||
(*r_dh)->data.fd = fd;
|
||
return TRACE_SUC1 ("dh=%p", *r_dh);
|
||
}
|