libkdenetwork Library API Documentation

libgpgme-copy/gpgme/data.h

00001 /* data.h - Internal data object abstraction interface.
00002    Copyright (C) 2002 g10 Code GmbH
00003  
00004    This file is part of GPGME.
00005  
00006    GPGME is free software; you can redistribute it and/or modify it
00007    under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010  
00011    GPGME is distributed in the hope that it will be useful, but
00012    WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    General Public License for more details.
00015  
00016    You should have received a copy of the GNU General Public License
00017    along with GPGME; if not, write to the Free Software Foundation,
00018    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00019 
00020 #ifndef DATA_H
00021 #define DATA_H
00022 
00023 #if HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <sys/types.h>
00028 #include <limits.h>
00029 
00030 #include "gpgme.h"
00031 
00032 
00033 /* Read up to SIZE bytes into buffer BUFFER from the data object with
00034    the handle DH.  Return the number of characters read, 0 on EOF and
00035    -1 on error.  If an error occurs, errno is set.  */
00036 typedef ssize_t (*gpgme_data_read_cb) (gpgme_data_t dh, void *buffer,
00037                        size_t size);
00038 
00039 /* Write up to SIZE bytes from buffer BUFFER to the data object with
00040    the handle DH.  Return the number of characters written, or -1 on
00041    error.  If an error occurs, errno is set.  */
00042 typedef ssize_t (*gpgme_data_write_cb) (gpgme_data_t dh, const void *buffer,
00043                     size_t size);
00044 
00045 /* Set the current position from where the next read or write starts
00046    in the data object with the handle DH to OFFSET, relativ to
00047    WHENCE.  */
00048 typedef off_t (*gpgme_data_seek_cb) (gpgme_data_t dh, off_t offset,
00049                      int whence);
00050 
00051 /* Release the data object with the handle DH.  */
00052 typedef void (*gpgme_data_release_cb) (gpgme_data_t dh);
00053 
00054 struct _gpgme_data_cbs
00055 {
00056   gpgme_data_read_cb read;
00057   gpgme_data_write_cb write;
00058   gpgme_data_seek_cb seek;
00059   gpgme_data_release_cb release;
00060 };
00061 
00062 struct gpgme_data
00063 {
00064   struct _gpgme_data_cbs *cbs;
00065   gpgme_data_encoding_t encoding;
00066 
00067 #ifdef PIPE_BUF
00068 #define BUFFER_SIZE PIPE_BUF
00069 #else
00070 #ifdef _POSIX_PIPE_BUF
00071 #define BUFFER_SIZE _POSIX_PIPE_BUF
00072 #else
00073 #define BUFFER_SIZE 512
00074 #endif
00075 #endif
00076   char pending[BUFFER_SIZE];
00077   int pending_len;
00078 
00079   union
00080   {
00081     /* For gpgme_data_new_from_fd.  */
00082     int fd;
00083 
00084     /* For gpgme_data_new_from_stream.  */
00085     FILE *stream;
00086 
00087     /* For gpgme_data_new_from_cbs.  */
00088     struct
00089     {
00090       gpgme_data_cbs_t cbs;
00091       void *handle;
00092     } user;
00093 
00094     /* For gpgme_data_new_from_mem.  */
00095     struct
00096     {
00097       char *buffer;
00098       const char *orig_buffer;
00099       /* Allocated size of BUFFER.  */
00100       size_t size;
00101       size_t length;
00102       size_t offset;
00103     } mem;
00104 
00105     /* For gpgme_data_new_from_read_cb.  */
00106     struct
00107     {
00108       int (*cb) (void *, char *, size_t, size_t *);
00109       void *handle;
00110     } old_user;
00111   } data;
00112 };
00113 
00114 
00115 gpgme_error_t _gpgme_data_new (gpgme_data_t *r_dh,
00116                    struct _gpgme_data_cbs *cbs);
00117 
00118 void _gpgme_data_release (gpgme_data_t dh);
00119 
00120 #endif  /* DATA_H */
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Dec 21 14:21:38 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003