2003-08-05 19:11:04 +02:00
|
|
|
/* membuf.h - A simple implementation of a dynamic buffer
|
|
|
|
* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
Change license for some files in common to LGPLv3+/GPLv2+.
Having the LGPL on the common GnuPG code helps to share code
between GnuPG and related projects (like GPGME and Libassuan). This
is good for interoperability and to reduces bugs.
* common/asshelp.c, common/asshelp.h, common/asshelp2.c, common/b64dec.c
* common/b64enc.c, common/convert.c, common/dns-cert.c
* common/dns-cert.h common/exechelp-posix.c, common/exechelp-w32.c
* common/exechelp-w32ce.c, common/exechelp.h, common/get-passphrase.c
* common/get-passphrase.h, common/gettime.c, common/gpgrlhelp.c
* common/helpfile.c, common/homedir.c, common/http.c, common/http.h
* common/i18n.c, common/init.c, common/init.h, common/iobuf.c
* common/iobuf.h, common/localename.c, common/membuf.c, common/membuf.h
* common/miscellaneous.c, common/openpgp-oid.c, common/openpgpdefs.h
* common/percent.c, common/pka.c, common/pka.h, common/session-env.c
* common/session-env.h, common/sexp-parse.h, common/sexputil.c
* common/signal.c, common/srv.c, common/srv.h, common/ssh-utils.c
* common/ssh-utils.h, common/sysutils.c, common/sysutils.h
* common/tlv.c, common/tlv.h, common/ttyio.c, common/ttyio.h
* common/userids.c, common/userids.h, common/xasprintf.c: Change
license to LGPLv3+/GPLv2+/
2012-04-20 15:43:06 +02:00
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of either
|
2003-08-05 19:11:04 +02:00
|
|
|
*
|
Change license for some files in common to LGPLv3+/GPLv2+.
Having the LGPL on the common GnuPG code helps to share code
between GnuPG and related projects (like GPGME and Libassuan). This
is good for interoperability and to reduces bugs.
* common/asshelp.c, common/asshelp.h, common/asshelp2.c, common/b64dec.c
* common/b64enc.c, common/convert.c, common/dns-cert.c
* common/dns-cert.h common/exechelp-posix.c, common/exechelp-w32.c
* common/exechelp-w32ce.c, common/exechelp.h, common/get-passphrase.c
* common/get-passphrase.h, common/gettime.c, common/gpgrlhelp.c
* common/helpfile.c, common/homedir.c, common/http.c, common/http.h
* common/i18n.c, common/init.c, common/init.h, common/iobuf.c
* common/iobuf.h, common/localename.c, common/membuf.c, common/membuf.h
* common/miscellaneous.c, common/openpgp-oid.c, common/openpgpdefs.h
* common/percent.c, common/pka.c, common/pka.h, common/session-env.c
* common/session-env.h, common/sexp-parse.h, common/sexputil.c
* common/signal.c, common/srv.c, common/srv.h, common/ssh-utils.c
* common/ssh-utils.h, common/sysutils.c, common/sysutils.h
* common/tlv.c, common/tlv.h, common/ttyio.c, common/ttyio.h
* common/userids.c, common/userids.h, common/xasprintf.c: Change
license to LGPLv3+/GPLv2+/
2012-04-20 15:43:06 +02:00
|
|
|
* - the GNU Lesser General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 3 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or
|
|
|
|
*
|
|
|
|
* - the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or both in parallel, as here.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
2003-08-05 19:11:04 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2003-08-05 19:11:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNUPG_COMMON_MEMBUF_H
|
|
|
|
#define GNUPG_COMMON_MEMBUF_H
|
|
|
|
|
2013-11-29 15:37:23 +01:00
|
|
|
#include "mischelp.h"
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
/* The definition of the structure is private, we only need it here,
|
|
|
|
so it can be allocated on the stack. */
|
2011-02-04 12:57:53 +01:00
|
|
|
struct private_membuf_s
|
2006-10-04 18:45:04 +02:00
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
size_t len;
|
|
|
|
size_t size;
|
|
|
|
char *buf;
|
|
|
|
int out_of_core;
|
2003-08-05 19:11:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct private_membuf_s membuf_t;
|
|
|
|
|
2007-06-21 20:44:48 +02:00
|
|
|
/* Return the current length of the membuf. */
|
2007-12-04 12:23:31 +01:00
|
|
|
#define get_membuf_len(a) ((a)->len)
|
|
|
|
#define is_membuf_ready(a) ((a)->buf || (a)->out_of_core)
|
|
|
|
#define MEMBUF_ZERO { 0, 0, NULL, 0}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
void init_membuf (membuf_t *mb, int initiallen);
|
2006-10-04 18:45:04 +02:00
|
|
|
void init_membuf_secure (membuf_t *mb, int initiallen);
|
2011-01-18 12:50:02 +01:00
|
|
|
void clear_membuf (membuf_t *mb, size_t amount);
|
2003-08-05 19:11:04 +02:00
|
|
|
void put_membuf (membuf_t *mb, const void *buf, size_t len);
|
2016-01-08 06:33:27 +01:00
|
|
|
gpg_error_t put_membuf_cb (void *opaque, const void *buf, size_t len);
|
2007-06-21 20:44:48 +02:00
|
|
|
void put_membuf_str (membuf_t *mb, const char *string);
|
2013-11-29 15:37:23 +01:00
|
|
|
void put_membuf_printf (membuf_t *mb, const char *format,
|
2015-07-26 12:50:16 +02:00
|
|
|
...) GPGRT_ATTR_PRINTF(2,3);
|
2003-08-05 19:11:04 +02:00
|
|
|
void *get_membuf (membuf_t *mb, size_t *len);
|
2014-02-26 16:16:30 +01:00
|
|
|
void *get_membuf_shrink (membuf_t *mb, size_t *len);
|
2011-01-18 12:50:02 +01:00
|
|
|
const void *peek_membuf (membuf_t *mb, size_t *len);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
#endif /*GNUPG_COMMON_MEMBUF_H*/
|