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

Switch to the libgpg-error provided estream.

* configure.ac (NEED_GPG_ERROR_VERSION): Reguire 1.14.
(GPGRT_ENABLE_ES_MACROS): Define.
(estream_INIT): Remove.
* m4/estream.m4: Remove.
* common/estream-printf.c, common/estream-printf.h: Remove.
* common/estream.c, common/estream.h: Remove.
* common/init.c (_init_common_subsystems): Call gpgrt initialization.
This commit is contained in:
Werner Koch 2014-08-26 17:47:22 +02:00
parent a731c22952
commit 519305feb8
38 changed files with 93 additions and 7134 deletions

View File

@ -59,7 +59,6 @@ endif
common_sources = \ common_sources = \
common-defs.h \ common-defs.h \
util.h i18n.c i18n.h \ util.h i18n.c i18n.h \
estream.c estream.h estream-printf.c estream-printf.h \
status.c status.h\ status.c status.h\
shareddefs.h \ shareddefs.h \
openpgpdefs.h \ openpgpdefs.h \

View File

@ -47,7 +47,7 @@ vprint_assuan_status (assuan_context_t ctx,
int rc; int rc;
char *buf; char *buf;
rc = estream_vasprintf (&buf, format, arg_ptr); rc = gpgrt_vasprintf (&buf, format, arg_ptr);
if (rc < 0) if (rc < 0)
return gpg_err_make (default_errsource, gpg_err_code_from_syserror ()); return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
rc = assuan_write_status (ctx, keyword, buf); rc = assuan_write_status (ctx, keyword, buf);

View File

@ -381,7 +381,7 @@ writeout_v (audit_ctx_t ctx, const char *format, va_list arg_ptr)
{ {
char *buf; char *buf;
estream_vasprintf (&buf, format, arg_ptr); gpgrt_vasprintf (&buf, format, arg_ptr);
if (buf) if (buf)
{ {
writeout (ctx, buf); writeout (ctx, buf);

View File

@ -22,8 +22,6 @@
#include <ksba.h> #include <ksba.h>
#include "../common/estream.h"
struct audit_ctx_s; struct audit_ctx_s;
typedef struct audit_ctx_s *audit_ctx_t; typedef struct audit_ctx_s *audit_ctx_t;

File diff suppressed because it is too large Load Diff

View File

@ -1,149 +0,0 @@
/* estream-printf.h - Versatile mostly C-99 compliant printf formatting.
* Copyright (C) 2007, 2010, 2012 g10 Code GmbH
*
* This file is part of Libestream.
*
* Libestream 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.
*
* Libestream 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 Libestream; if not, see <http://www.gnu.org/licenses/>.
*
* ALTERNATIVELY, Libestream may be distributed under the terms of the
* following license, in which case the provisions of this license are
* required INSTEAD OF the GNU General Public License. If you wish to
* allow use of your version of this file only under the terms of the
* GNU General Public License, and not to allow others to use your
* version of this file under the terms of the following license,
* indicate your decision by deleting this paragraph and the license
* below.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ESTREAM_PRINTF_H
#define ESTREAM_PRINTF_H
#include <stdarg.h>
#include <stdio.h>
/* To use this file with libraries the following macro is useful:
#define _ESTREAM_EXT_SYM_PREFIX _foo_
This prefixes all external symbols with "_foo_".
For the implementation of the code (estream-printf.c) the following
macros may be used to tune the implementation for certain systems:
#define _ESTREAM_PRINTF_REALLOC foo_realloc
Make estream_asprintf and estream_vasprintf use foo_realloc
instead of the standard realloc to allocate memory returned to
the caller. Note that foo_realloc needs to be C-90 compliant:
foo_realloc (NULL,n) is the same as a call to malloc(n) and
foo_realloc (a, 0) is the same as a call to free (a).
#define _ESTREAM_PRINTF_EXTRA_INCLUDE "foo.h"
This includes the file "foo.h" which may provide prototypes for
the custom memory allocation functions.
*/
#ifdef _ESTREAM_EXT_SYM_PREFIX
#ifndef _ESTREAM_PREFIX
#define _ESTREAM_PREFIX1(x,y) x ## y
#define _ESTREAM_PREFIX2(x,y) _ESTREAM_PREFIX1(x,y)
#define _ESTREAM_PREFIX(x) _ESTREAM_PREFIX2(_ESTREAM_EXT_SYM_PREFIX,x)
#endif /*_ESTREAM_PREFIX*/
#define estream_printf_out_t _ESTREAM_PREFIX(estream_printf_out_t)
#define estream_format _ESTREAM_PREFIX(estream_format)
#define estream_printf _ESTREAM_PREFIX(estream_printf)
#define estream_fprintf _ESTREAM_PREFIX(estream_fprintf)
#define estream_vfprintf _ESTREAM_PREFIX(estream_vfprintf)
#define estream_snprintf _ESTREAM_PREFIX(estream_snprintf)
#define estream_vsnprintf _ESTREAM_PREFIX(estream_vsnprintf)
#define estream_asprintf _ESTREAM_PREFIX(estream_asprintf)
#define estream_vasprintf _ESTREAM_PREFIX(estream_vasprintf)
#endif /*_ESTREAM_EXT_SYM_PREFIX*/
#ifndef _ESTREAM_GCC_A_PRINTF
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
# define _ESTREAM_GCC_A_PRINTF( f, a ) \
__attribute__ ((format (__gnu_printf__,f,a)))
# elif __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
# define _ESTREAM_GCC_A_PRINTF( f, a ) \
__attribute__ ((format (printf,f,a)))
# else
# define _ESTREAM_GCC_A_PRINTF( f, a )
# endif
#endif /*_ESTREAM_GCC_A_PRINTF*/
#ifdef __cplusplus
extern "C"
{
#if 0
}
#endif
#endif
typedef int (*estream_printf_out_t)
(void *outfncarg, const char *buf, size_t buflen);
int estream_format (estream_printf_out_t outfnc, void *outfncarg,
const char *format, va_list vaargs)
_ESTREAM_GCC_A_PRINTF(3,0);
int estream_printf (const char *format, ...)
_ESTREAM_GCC_A_PRINTF(1,2);
int estream_fprintf (FILE *fp, const char *format, ... )
_ESTREAM_GCC_A_PRINTF(2,3);
int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr)
_ESTREAM_GCC_A_PRINTF(2,0);
int estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
_ESTREAM_GCC_A_PRINTF(3,4);
int estream_vsnprintf (char *buf,size_t bufsize,
const char *format, va_list arg_ptr)
_ESTREAM_GCC_A_PRINTF(3,0);
int estream_asprintf (char **bufp, const char *format, ...)
_ESTREAM_GCC_A_PRINTF(2,3);
int estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
_ESTREAM_GCC_A_PRINTF(2,0);
#ifdef __cplusplus
}
#endif
#endif /*ESTREAM_PRINTF_H*/

File diff suppressed because it is too large Load Diff

View File

@ -1,434 +0,0 @@
/* estream.h - Extended stream I/O Library
* Copyright (C) 2004, 2005, 2006, 2007, 2010, 2011 g10 Code GmbH
*
* This file is part of Libestream.
*
* Libestream 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.
*
* Libestream 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 Libestream; if not, see <http://www.gnu.org/licenses/>.
*
* ALTERNATIVELY, Libestream may be distributed under the terms of the
* following license, in which case the provisions of this license are
* required INSTEAD OF the GNU General Public License. If you wish to
* allow use of your version of this file only under the terms of the
* GNU General Public License, and not to allow others to use your
* version of this file under the terms of the following license,
* indicate your decision by deleting this paragraph and the license
* below.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ESTREAM_H
#define ESTREAM_H
#include <sys/types.h>
#include <stdarg.h>
#include <stdio.h>
/* To use this file with libraries the following macro is useful:
#define _ESTREAM_EXT_SYM_PREFIX _foo_
This prefixes all external symbols with "_foo_".
*/
#ifdef _ESTREAM_EXT_SYM_PREFIX
#ifndef _ESTREAM_PREFIX
#define _ESTREAM_PREFIX1(x,y) x ## y
#define _ESTREAM_PREFIX2(x,y) _ESTREAM_PREFIX1(x,y)
#define _ESTREAM_PREFIX(x) _ESTREAM_PREFIX2(_ESTREAM_EXT_SYM_PREFIX,x)
#endif /*_ESTREAM_PREFIX*/
#define es_fopen _ESTREAM_PREFIX(es_fopen)
#define es_mopen _ESTREAM_PREFIX(es_mopen)
#define es_fopenmem _ESTREAM_PREFIX(es_fopenmem)
#define es_fopenmem_init _ESTREAM_PREFIX(es_fopenmem_init)
#define es_fdopen _ESTREAM_PREFIX(es_fdopen)
#define es_fdopen_nc _ESTREAM_PREFIX(es_fdopen_nc)
#define es_sysopen _ESTREAM_PREFIX(es_sysopen)
#define es_sysopen_nc _ESTREAM_PREFIX(es_sysopen_nc)
#define es_fpopen _ESTREAM_PREFIX(es_fpopen)
#define es_fpopen_nc _ESTREAM_PREFIX(es_fpopen_nc)
#define _es_set_std_fd _ESTREAM_PREFIX(_es_set_std_fd)
#define _es_get_std_stream _ESTREAM_PREFIX(_es_get_std_stream)
#define es_freopen _ESTREAM_PREFIX(es_freopen)
#define es_fopencookie _ESTREAM_PREFIX(es_fopencookie)
#define es_fclose _ESTREAM_PREFIX(es_fclose)
#define es_fclose_snatch _ESTREAM_PREFIX(es_fclose_snatch)
#define es_onclose _ESTREAM_PREFIX(es_onclose)
#define es_fileno _ESTREAM_PREFIX(es_fileno)
#define es_fileno_unlocked _ESTREAM_PREFIX(es_fileno_unlocked)
#define es_flockfile _ESTREAM_PREFIX(es_flockfile)
#define es_ftrylockfile _ESTREAM_PREFIX(es_ftrylockfile)
#define es_funlockfile _ESTREAM_PREFIX(es_funlockfile)
#define es_feof _ESTREAM_PREFIX(es_feof)
#define es_feof_unlocked _ESTREAM_PREFIX(es_feof_unlocked)
#define es_ferror _ESTREAM_PREFIX(es_ferror)
#define es_ferror_unlocked _ESTREAM_PREFIX(es_ferror_unlocked)
#define es_clearerr _ESTREAM_PREFIX(es_clearerr)
#define es_clearerr_unlocked _ESTREAM_PREFIX(es_clearerr_unlocked)
#define es_fflush _ESTREAM_PREFIX(es_fflush)
#define es_fseek _ESTREAM_PREFIX(es_fseek)
#define es_fseeko _ESTREAM_PREFIX(es_fseeko)
#define es_ftell _ESTREAM_PREFIX(es_ftell)
#define es_ftello _ESTREAM_PREFIX(es_ftello)
#define es_rewind _ESTREAM_PREFIX(es_rewind)
#define es_fgetc _ESTREAM_PREFIX(es_fgetc)
#define es_fputc _ESTREAM_PREFIX(es_fputc)
#define _es_getc_underflow _ESTREAM_PREFIX(_es_getc_underflow)
#define _es_putc_overflow _ESTREAM_PREFIX(_es_putc_overflow)
#define es_ungetc _ESTREAM_PREFIX(es_ungetc)
#define es_read _ESTREAM_PREFIX(es_read)
#define es_write _ESTREAM_PREFIX(es_write)
#define es_write_sanitized _ESTREAM_PREFIX(es_write_sanitized)
#define es_write_hexstring _ESTREAM_PREFIX(es_write_hexstring)
#define es_fread _ESTREAM_PREFIX(es_fread)
#define es_fwrite _ESTREAM_PREFIX(es_fwrite)
#define es_fgets _ESTREAM_PREFIX(es_fgets)
#define es_fputs _ESTREAM_PREFIX(es_fputs)
#define es_fputs_unlocked _ESTREAM_PREFIX(es_fputs_unlocked)
#define es_getline _ESTREAM_PREFIX(es_getline)
#define es_read_line _ESTREAM_PREFIX(es_read_line)
#define es_free _ESTREAM_PREFIX(es_free)
#define es_fprintf _ESTREAM_PREFIX(es_fprintf)
#define es_fprintf_unlocked _ESTREAM_PREFIX(es_fprintf_unlocked)
#define es_printf _ESTREAM_PREFIX(es_printf)
#define es_printf_unlocked _ESTREAM_PREFIX(es_printf_unlocked)
#define es_vfprintf _ESTREAM_PREFIX(es_vfprint)
#define es_vfprintf_unlocked _ESTREAM_PREFIX(es_vfprint_unlocked)
#define es_setvbuf _ESTREAM_PREFIX(es_setvbuf)
#define es_setbuf _ESTREAM_PREFIX(es_setbuf)
#define es_set_binary _ESTREAM_PREFIX(es_set_binary)
#define es_tmpfile _ESTREAM_PREFIX(es_tmpfile)
#define es_opaque_set _ESTREAM_PREFIX(es_opaque_set)
#define es_opaque_get _ESTREAM_PREFIX(es_opaque_get)
#define es_fname_set _ESTREAM_PREFIX(es_fname_set)
#define es_fname_get _ESTREAM_PREFIX(es_fname_get)
#define es_write_sanitized_utf8_buffer \
_ESTREAM_PREFIX(es_write_sanitized_utf8_buffer)
#endif /*_ESTREAM_EXT_SYM_PREFIX*/
#ifdef __cplusplus
extern "C"
{
#if 0
}
#endif
#endif
/* Forward declaration for the (opaque) internal type. */
struct estream_internal;
/* The definition of this struct is entirely private. You must not
use it for anything. It is only here so some functions can be
implemented as macros. */
struct es__stream
{
/* The layout of this struct must never change. It may be grown,
but only if all functions which access the new members are
versioned. */
/* A pointer to the stream buffer. */
unsigned char *buffer;
/* The size of the buffer in bytes. */
size_t buffer_size;
/* The length of the usable data in the buffer, only valid when in
read mode (see flags). */
size_t data_len;
/* The current position of the offset pointer, valid in read and
write mode. */
size_t data_offset;
size_t data_flushed;
unsigned char *unread_buffer;
size_t unread_buffer_size;
/* The number of unread bytes. */
size_t unread_data_len;
/* Various flags. */
struct {
unsigned int writing: 1;
unsigned int reserved: 7;
} flags;
/* A pointer to our internal data for this stream. */
struct estream_internal *intern;
};
/* The opaque type for an estream. */
typedef struct es__stream *estream_t;
typedef ssize_t (*es_cookie_read_function_t) (void *cookie,
void *buffer, size_t size);
typedef ssize_t (*es_cookie_write_function_t) (void *cookie,
const void *buffer,
size_t size);
typedef int (*es_cookie_seek_function_t) (void *cookie,
off_t *pos, int whence);
typedef int (*es_cookie_close_function_t) (void *cookie);
typedef struct es_cookie_io_functions
{
es_cookie_read_function_t func_read;
es_cookie_write_function_t func_write;
es_cookie_seek_function_t func_seek;
es_cookie_close_function_t func_close;
} es_cookie_io_functions_t;
enum es_syshd_types
{
ES_SYSHD_NONE, /* No system handle available. */
ES_SYSHD_FD, /* A file descriptor as returned by open(). */
ES_SYSHD_SOCK, /* A socket as returned by socket(). */
ES_SYSHD_RVID, /* A rendevous id (see libassuan's gpgcedev.c). */
ES_SYSHD_HANDLE /* A HANDLE object (Windows). */
};
typedef struct
{
enum es_syshd_types type;
union {
int fd;
int sock;
int rvid;
void *handle;
} u;
} es_syshd_t;
#ifndef _ESTREAM_GCC_A_PRINTF
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
# define _ESTREAM_GCC_A_PRINTF( f, a ) \
__attribute__ ((format (__gnu_printf__,f,a)))
# elif __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
# define _ESTREAM_GCC_A_PRINTF( f, a ) \
__attribute__ ((format (printf,f,a)))
# else
# define _ESTREAM_GCC_A_PRINTF( f, a )
# endif
#endif /*_ESTREAM_GCC_A_PRINTF*/
#ifndef ES__RESTRICT
# if defined __GNUC__ && defined __GNUC_MINOR__
# if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 92))
# define ES__RESTRICT __restrict__
# endif
# endif
#endif
#ifndef ES__RESTRICT
# define ES__RESTRICT
#endif
int es_init (void);
estream_t es_fopen (const char *ES__RESTRICT path,
const char *ES__RESTRICT mode);
estream_t es_mopen (void *ES__RESTRICT data,
size_t data_n, size_t data_len,
unsigned int grow,
void *(*func_realloc) (void *mem, size_t size),
void (*func_free) (void *mem),
const char *ES__RESTRICT mode);
estream_t es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode);
estream_t es_fopenmem_init (size_t memlimit, const char *ES__RESTRICT mode,
const void *data, size_t datalen);
estream_t es_fdopen (int filedes, const char *mode);
estream_t es_fdopen_nc (int filedes, const char *mode);
estream_t es_sysopen (es_syshd_t *syshd, const char *mode);
estream_t es_sysopen_nc (es_syshd_t *syshd, const char *mode);
estream_t es_fpopen (FILE *fp, const char *mode);
estream_t es_fpopen_nc (FILE *fp, const char *mode);
estream_t es_freopen (const char *ES__RESTRICT path,
const char *ES__RESTRICT mode,
estream_t ES__RESTRICT stream);
estream_t es_fopencookie (void *ES__RESTRICT cookie,
const char *ES__RESTRICT mode,
es_cookie_io_functions_t functions);
int es_fclose (estream_t stream);
int es_fclose_snatch (estream_t stream, void **r_buffer, size_t *r_buflen);
int es_onclose (estream_t stream, int mode,
void (*fnc) (estream_t, void*), void *fnc_value);
int es_fileno (estream_t stream);
int es_fileno_unlocked (estream_t stream);
int es_syshd (estream_t stream, es_syshd_t *syshd);
int es_syshd_unlocked (estream_t stream, es_syshd_t *syshd);
void _es_set_std_fd (int no, int fd);
estream_t _es_get_std_stream (int fd);
#define es_stdin _es_get_std_stream (0)
#define es_stdout _es_get_std_stream (1)
#define es_stderr _es_get_std_stream (2)
void es_flockfile (estream_t stream);
int es_ftrylockfile (estream_t stream);
void es_funlockfile (estream_t stream);
int es_feof (estream_t stream);
int es_feof_unlocked (estream_t stream);
int es_ferror (estream_t stream);
int es_ferror_unlocked (estream_t stream);
void es_clearerr (estream_t stream);
void es_clearerr_unlocked (estream_t stream);
int es_fflush (estream_t stream);
int es_fseek (estream_t stream, long int offset, int whence);
int es_fseeko (estream_t stream, off_t offset, int whence);
long int es_ftell (estream_t stream);
off_t es_ftello (estream_t stream);
void es_rewind (estream_t stream);
int es_fgetc (estream_t stream);
int es_fputc (int c, estream_t stream);
int _es_getc_underflow (estream_t stream);
int _es_putc_overflow (int c, estream_t stream);
#define es_getc_unlocked(stream) \
(((!(stream)->flags.writing) \
&& ((stream)->data_offset < (stream)->data_len) \
&& (! (stream)->unread_data_len)) \
? ((int) (stream)->buffer[((stream)->data_offset)++]) \
: _es_getc_underflow ((stream)))
#define es_putc_unlocked(c, stream) \
(((stream)->flags.writing \
&& ((stream)->data_offset < (stream)->buffer_size) \
&& (c != '\n')) \
? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \
: _es_putc_overflow ((c), (stream)))
#define es_getc(stream) es_fgetc (stream)
#define es_putc(c, stream) es_fputc (c, stream)
int es_ungetc (int c, estream_t stream);
int es_read (estream_t ES__RESTRICT stream,
void *ES__RESTRICT buffer, size_t bytes_to_read,
size_t *ES__RESTRICT bytes_read);
int es_write (estream_t ES__RESTRICT stream,
const void *ES__RESTRICT buffer, size_t bytes_to_write,
size_t *ES__RESTRICT bytes_written);
int es_write_sanitized (estream_t ES__RESTRICT stream,
const void *ES__RESTRICT buffer, size_t length,
const char *delimiters,
size_t *ES__RESTRICT bytes_written);
int es_write_hexstring (estream_t ES__RESTRICT stream,
const void *ES__RESTRICT buffer, size_t length,
int reserved, size_t *ES__RESTRICT bytes_written);
size_t es_fread (void *ES__RESTRICT ptr, size_t size, size_t nitems,
estream_t ES__RESTRICT stream);
size_t es_fwrite (const void *ES__RESTRICT ptr, size_t size, size_t memb,
estream_t ES__RESTRICT stream);
char *es_fgets (char *ES__RESTRICT s, int n, estream_t ES__RESTRICT stream);
int es_fputs (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream);
int es_fputs_unlocked (const char *ES__RESTRICT s,
estream_t ES__RESTRICT stream);
ssize_t es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr,
size_t *ES__RESTRICT n,
estream_t stream);
ssize_t es_read_line (estream_t stream,
char **addr_of_buffer, size_t *length_of_buffer,
size_t *max_length);
void es_free (void *a);
int es_fprintf (estream_t ES__RESTRICT stream,
const char *ES__RESTRICT format, ...)
_ESTREAM_GCC_A_PRINTF(2,3);
int es_fprintf_unlocked (estream_t ES__RESTRICT stream,
const char *ES__RESTRICT format, ...)
_ESTREAM_GCC_A_PRINTF(2,3);
int es_printf (const char *ES__RESTRICT format, ...)
_ESTREAM_GCC_A_PRINTF(1,2);
int es_printf_unlocked (const char *ES__RESTRICT format, ...)
_ESTREAM_GCC_A_PRINTF(1,2);
int es_vfprintf (estream_t ES__RESTRICT stream,
const char *ES__RESTRICT format, va_list ap)
_ESTREAM_GCC_A_PRINTF(2,0);
int es_vfprintf_unlocked (estream_t ES__RESTRICT stream,
const char *ES__RESTRICT format, va_list ap)
_ESTREAM_GCC_A_PRINTF(2,0);
char *es_asprintf (const char *ES__RESTRICT format, ...)
_ESTREAM_GCC_A_PRINTF(1,2);
char *es_vasprintf (const char *ES__RESTRICT format, va_list ap)
_ESTREAM_GCC_A_PRINTF(1,0);
int es_setvbuf (estream_t ES__RESTRICT stream,
char *ES__RESTRICT buf, int mode, size_t size);
void es_setbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf);
void es_set_binary (estream_t stream);
estream_t es_tmpfile (void);
void es_opaque_set (estream_t ES__RESTRICT stream, void *ES__RESTRICT opaque);
void *es_opaque_get (estream_t stream);
void es_fname_set (estream_t stream, const char *fname);
const char *es_fname_get (estream_t stream);
#ifdef GNUPG_MAJOR_VERSION
int es_write_sanitized_utf8_buffer (estream_t stream,
const void *buffer, size_t length,
const char *delimiters,
size_t *bytes_written);
#endif /*GNUPG_MAJOR_VERSION*/
#ifdef __cplusplus
}
#endif
#endif /*ESTREAM_H*/

View File

@ -30,8 +30,6 @@
#ifndef GNUPG_COMMON_EXECHELP_H #ifndef GNUPG_COMMON_EXECHELP_H
#define GNUPG_COMMON_EXECHELP_H #define GNUPG_COMMON_EXECHELP_H
#include "../common/estream.h"
/* Return the maximum number of currently allowed file descriptors. /* Return the maximum number of currently allowed file descriptors.
Only useful on POSIX systems. */ Only useful on POSIX systems. */

View File

@ -1565,7 +1565,7 @@ send_request (http_t hd, const char *httphost, const char *auth,
if (http_proxy && *http_proxy) if (http_proxy && *http_proxy)
{ {
request = es_asprintf request = es_bsprintf
("%s %s://%s:%hu%s%s HTTP/1.0\r\n%s%s", ("%s %s://%s:%hu%s%s HTTP/1.0\r\n%s%s",
hd->req_type == HTTP_REQ_GET ? "GET" : hd->req_type == HTTP_REQ_GET ? "GET" :
hd->req_type == HTTP_REQ_HEAD ? "HEAD" : hd->req_type == HTTP_REQ_HEAD ? "HEAD" :
@ -1585,7 +1585,7 @@ send_request (http_t hd, const char *httphost, const char *auth,
else else
snprintf (portstr, sizeof portstr, ":%u", port); snprintf (portstr, sizeof portstr, ":%u", port);
request = es_asprintf request = es_bsprintf
("%s %s%s HTTP/1.0\r\nHost: %s%s\r\n%s", ("%s %s%s HTTP/1.0\r\nHost: %s%s\r\n%s",
hd->req_type == HTTP_REQ_GET ? "GET" : hd->req_type == HTTP_REQ_GET ? "GET" :
hd->req_type == HTTP_REQ_HEAD ? "HEAD" : hd->req_type == HTTP_REQ_HEAD ? "HEAD" :

View File

@ -31,7 +31,6 @@
#define GNUPG_COMMON_HTTP_H #define GNUPG_COMMON_HTTP_H
#include <gpg-error.h> #include <gpg-error.h>
#include "../common/estream.h"
struct uri_tuple_s struct uri_tuple_s
{ {

View File

@ -173,7 +173,11 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp)
#endif #endif
/* Initialize the Estream library. */ /* Initialize the Estream library. */
es_init (); gpgrt_init ();
gpgrt_set_alloc_func (gcry_realloc);
#ifdef USE_NPTH
gpgrt_set_syscall_clamp (npth_unprotect, npth_protect);
#endif
/* Special hack for Windows CE: We extract some options from arg /* Special hack for Windows CE: We extract some options from arg
to setup the standard handles. */ to setup the standard handles. */
@ -191,7 +195,7 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp)
{ {
int i; int i;
for (i=0; i < 3; i++) for (i=0; i < 3; i++)
(void)_es_get_std_stream (i); (void)_gpgrt_get_std_stream (i);
} }
/* --version et al shall use estream as well. */ /* --version et al shall use estream as well. */

View File

@ -33,7 +33,6 @@
#include "../common/types.h" #include "../common/types.h"
#include "../common/sysutils.h" #include "../common/sysutils.h"
#include "../common/estream.h"
#define DBG_IOBUF iobuf_debug_mode #define DBG_IOBUF iobuf_debug_mode

View File

@ -33,7 +33,6 @@
#define LIBJNLIB_LOGGING_H #define LIBJNLIB_LOGGING_H
#include <stdio.h> #include <stdio.h>
#include "estream.h"
#include "mischelp.h" #include "mischelp.h"
#include "w32help.h" #include "w32help.h"

View File

@ -132,7 +132,7 @@ put_membuf_printf (membuf_t *mb, const char *format, ...)
char *buf; char *buf;
va_start (arg_ptr, format); va_start (arg_ptr, format);
rc = estream_vasprintf (&buf, format, arg_ptr); rc = gpgrt_vasprintf (&buf, format, arg_ptr);
if (rc < 0) if (rc < 0)
mb->out_of_core = errno ? errno : ENOMEM; mb->out_of_core = errno ? errno : ENOMEM;
va_end (arg_ptr); va_end (arg_ptr);

View File

@ -145,6 +145,47 @@ print_fname_stdin (const char *s)
} }
static int
do_print_utf8_buffer (estream_t stream,
const void *buffer, size_t length,
const char *delimiters, size_t *bytes_written)
{
const char *p = buffer;
size_t i;
/* We can handle plain ascii simpler, so check for it first. */
for (i=0; i < length; i++ )
{
if ( (p[i] & 0x80) )
break;
}
if (i < length)
{
int delim = delimiters? *delimiters : 0;
char *buf;
int ret;
/*(utf8 conversion already does the control character quoting). */
buf = utf8_to_native (p, length, delim);
if (bytes_written)
*bytes_written = strlen (buf);
ret = es_fputs (buf, stream);
xfree (buf);
return ret == EOF? ret : (int)i;
}
else
return es_write_sanitized (stream, p, length, delimiters, bytes_written);
}
void
print_utf8_buffer3 (estream_t stream, const void *p, size_t n,
const char *delim)
{
do_print_utf8_buffer (stream, p, n, delim, NULL);
}
void void
print_utf8_buffer2 (estream_t stream, const void *p, size_t n, int delim) print_utf8_buffer2 (estream_t stream, const void *p, size_t n, int delim)
{ {
@ -152,14 +193,14 @@ print_utf8_buffer2 (estream_t stream, const void *p, size_t n, int delim)
tmp[0] = delim; tmp[0] = delim;
tmp[1] = 0; tmp[1] = 0;
es_write_sanitized_utf8_buffer (stream, p, n, tmp, NULL); do_print_utf8_buffer (stream, p, n, tmp, NULL);
} }
void void
print_utf8_buffer (estream_t stream, const void *p, size_t n) print_utf8_buffer (estream_t stream, const void *p, size_t n)
{ {
es_write_sanitized_utf8_buffer (stream, p, n, NULL, NULL); do_print_utf8_buffer (stream, p, n, NULL, NULL);
} }
/* Write LENGTH bytes of BUFFER to FP as a hex encoded string. /* Write LENGTH bytes of BUFFER to FP as a hex encoded string.

View File

@ -148,7 +148,7 @@ main (int argc, char **argv)
const char *cafile = NULL; const char *cafile = NULL;
http_session_t session = NULL; http_session_t session = NULL;
es_init (); gpgrt_init ();
log_set_prefix (PGM, 1 | 4); log_set_prefix (PGM, 1 | 4);
if (argc) if (argc)
{ argc--; argv++; } { argc--; argv++; }

View File

@ -648,7 +648,7 @@ tty_getf (const char *promptfmt, ... )
char *answer; char *answer;
va_start (arg_ptr, promptfmt); va_start (arg_ptr, promptfmt);
if (estream_vasprintf (&prompt, promptfmt, arg_ptr) < 0) if (gpgrt_vasprintf (&prompt, promptfmt, arg_ptr) < 0)
log_fatal ("estream_vasprintf failed: %s\n", strerror (errno)); log_fatal ("estream_vasprintf failed: %s\n", strerror (errno));
va_end (arg_ptr); va_end (arg_ptr);
answer = tty_get (prompt); answer = tty_get (prompt);

View File

@ -33,16 +33,12 @@
#include <gcrypt.h> /* We need this for the memory function protos. */ #include <gcrypt.h> /* We need this for the memory function protos. */
#include <errno.h> /* We need errno. */ #include <errno.h> /* We need errno. */
#include <gpg-error.h> /* We need gpg_error_t. */ #include <gpg-error.h> /* We need gpg_error_t and estream. */
/* Hash function used with libksba. */ /* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write) #define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
/* Estream replaces most uses of stdio. */
#include "../common/estream.h"
#include "../common/estream-printf.h"
/* Get all the stuff from jnlib. */ /* Get all the stuff from jnlib. */
#include "../common/logging.h" #include "../common/logging.h"
#include "../common/argparse.h" #include "../common/argparse.h"
@ -57,13 +53,13 @@
/* Redefine asprintf by our estream version which uses our own memory /* Redefine asprintf by our estream version which uses our own memory
allocator.. */ allocator.. */
#define asprintf estream_asprintf #define asprintf gpgrt_asprintf
#define vasprintf estream_vasprintf #define vasprintf gpgrt_vasprintf
/* Due to a bug in mingw32's snprintf related to the 'l' modifier and /* Due to a bug in mingw32's snprintf related to the 'l' modifier and
for increased portability we use our snprintf on all systems. */ for increased portability we use our snprintf on all systems. */
#undef snprintf #undef snprintf
#define snprintf estream_snprintf #define snprintf gpgrt_snprintf
/* GCC attributes. */ /* GCC attributes. */
@ -278,6 +274,8 @@ const char *gnupg_cipher_algo_name (int algo);
const char *print_fname_stdout (const char *s); const char *print_fname_stdout (const char *s);
const char *print_fname_stdin (const char *s); const char *print_fname_stdin (const char *s);
void print_utf8_buffer3 (estream_t fp, const void *p, size_t n,
const char *delim);
void print_utf8_buffer2 (estream_t fp, const void *p, size_t n, int delim); void print_utf8_buffer2 (estream_t fp, const void *p, size_t n, int delim);
void print_utf8_buffer (estream_t fp, const void *p, size_t n); void print_utf8_buffer (estream_t fp, const void *p, size_t n);
void print_hexstring (FILE *fp, const void *buffer, size_t length, void print_hexstring (FILE *fp, const void *buffer, size_t length,

View File

@ -32,15 +32,14 @@
#include <errno.h> #include <errno.h>
#include "util.h" #include "util.h"
#include "iobuf.h"
#if !defined(_ESTREAM_PRINTF_REALLOC)
#error Need to define _ESTREAM_PRINTF_REALLOC
#endif
/* Same as asprintf but return an allocated buffer suitable to be /* Same as asprintf but return an allocated buffer suitable to be
freed using xfree. This function simply dies on memory failure, freed using xfree. This function simply dies on memory failure,
thus no extra check is required. */ thus no extra check is required.
FIXME: We should remove these functions in favor of gpgrt_bsprintf
and a xgpgrt_bsprintf or rename them to xbsprintf and
xtrybsprintf. */
char * char *
xasprintf (const char *fmt, ...) xasprintf (const char *fmt, ...)
{ {
@ -48,7 +47,7 @@ xasprintf (const char *fmt, ...)
char *buf; char *buf;
va_start (ap, fmt); va_start (ap, fmt);
if (estream_vasprintf (&buf, fmt, ap) < 0) if (gpgrt_vasprintf (&buf, fmt, ap) < 0)
log_fatal ("estream_asprintf failed: %s\n", strerror (errno)); log_fatal ("estream_asprintf failed: %s\n", strerror (errno));
va_end (ap); va_end (ap);
return buf; return buf;
@ -63,7 +62,7 @@ xtryasprintf (const char *fmt, ...)
char *buf; char *buf;
va_start (ap, fmt); va_start (ap, fmt);
rc = estream_vasprintf (&buf, fmt, ap); rc = gpgrt_vasprintf (&buf, fmt, ap);
va_end (ap); va_end (ap);
if (rc < 0) if (rc < 0)
return NULL; return NULL;

View File

@ -50,7 +50,7 @@ m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
m4_esyscmd([echo ]mym4_version[>VERSION]) m4_esyscmd([echo ]mym4_version[>VERSION])
AC_INIT([mym4_package],[mym4_version], [http://bugs.gnupg.org]) AC_INIT([mym4_package],[mym4_version], [http://bugs.gnupg.org])
NEED_GPG_ERROR_VERSION=1.13 NEED_GPG_ERROR_VERSION=1.14
NEED_LIBGCRYPT_API=1 NEED_LIBGCRYPT_API=1
NEED_LIBGCRYPT_VERSION=1.6.0 NEED_LIBGCRYPT_VERSION=1.6.0
@ -497,6 +497,8 @@ AH_BOTTOM([
# endif # endif
#endif #endif
/* Provide the es_ macro for estream. */
#define GPGRT_ENABLE_ES_MACROS 1
/* Tell libgcrypt not to use its own libgpg-error implementation. */ /* Tell libgcrypt not to use its own libgpg-error implementation. */
#define USE_LIBGPG_ERROR 1 #define USE_LIBGPG_ERROR 1
@ -515,11 +517,6 @@ AH_BOTTOM([
handler. */ handler. */
#define HTTP_NO_WSASTARTUP #define HTTP_NO_WSASTARTUP
/* We want to use the libgcrypt provided memory allocation for
asprintf. */
#define _ESTREAM_PRINTF_REALLOC gcry_realloc
#define _ESTREAM_PRINTF_EXTRA_INCLUDE "../common/util.h"
/* Under Windows we use the gettext code from libgpg-error. */ /* Under Windows we use the gettext code from libgpg-error. */
#define GPG_ERR_ENABLE_GETTEXT_MACROS #define GPG_ERR_ENABLE_GETTEXT_MACROS
@ -1495,14 +1492,6 @@ if test "$GCC" = yes; then
if test x"$_gcc_psign" = xyes ; then if test x"$_gcc_psign" = xyes ; then
CFLAGS="$CFLAGS -Wpointer-arith" CFLAGS="$CFLAGS -Wpointer-arith"
fi fi
# The undocumented option -Wno-psabi suppresses the annoying
# "the ABI of passing union with long double has changed in GCC 4.4"
# which is emitted in estream-printf.c but entirely irrelvant
# because that union is local to the file.
if test x"$_gcc_silent_wno" = xyes ; then
CFLAGS="$CFLAGS -Wno-psabi"
fi
fi fi
@ -1517,12 +1506,6 @@ AC_ARG_ENABLE(optimization,
CFLAGS=`echo $CFLAGS | sed s/-O[[1-9]]\ /-O0\ /g` CFLAGS=`echo $CFLAGS | sed s/-O[[1-9]]\ /-O0\ /g`
fi]) fi])
#
# Prepare building of estream
#
estream_INIT
# #
# Decide what to build # Decide what to build
# #

View File

@ -113,7 +113,6 @@
#include "crlfetch.h" #include "crlfetch.h"
#include "misc.h" #include "misc.h"
#include "cdb.h" #include "cdb.h"
#include "estream-printf.h"
/* Change this whenever the format changes */ /* Change this whenever the format changes */
#define DBDIR_D (opt.system_daemon? "crls.d" : "dirmngr-cache.d") #define DBDIR_D (opt.system_daemon? "crls.d" : "dirmngr-cache.d")
@ -818,8 +817,8 @@ update_dir (crl_cache_t cache)
nodename = utsbuf.nodename; nodename = utsbuf.nodename;
#endif #endif
estream_asprintf (&tmpbuf, "DIR-tmp-%s-%u-%p.txt.tmp", gpgrt_asprintf (&tmpbuf, "DIR-tmp-%s-%u-%p.txt.tmp",
nodename, (unsigned int)getpid (), &tmpbuf); nodename, (unsigned int)getpid (), &tmpbuf);
if (!tmpbuf) if (!tmpbuf)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_errno (errno);
@ -2022,8 +2021,8 @@ crl_cache_insert (ctrl_t ctrl, const char *url, ksba_reader_t reader)
nodename = utsbuf.nodename; nodename = utsbuf.nodename;
#endif #endif
estream_asprintf (&tmpfname, "crl-tmp-%s-%u-%p.db.tmp", gpgrt_asprintf (&tmpfname, "crl-tmp-%s-%u-%p.db.tmp",
nodename, (unsigned int)getpid (), &tmpfname); nodename, (unsigned int)getpid (), &tmpfname);
if (!tmpfname) if (!tmpfname)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();

View File

@ -29,7 +29,6 @@
#include "misc.h" #include "misc.h"
#include "http.h" #include "http.h"
#include "estream.h"
#include "ldap-wrapper.h" #include "ldap-wrapper.h"

View File

@ -50,6 +50,7 @@
#define JNLIB_NEED_LOG_LOGV #define JNLIB_NEED_LOG_LOGV
#include <gpg-error.h>
#include "../common/logging.h" #include "../common/logging.h"
#include "../common/argparse.h" #include "../common/argparse.h"
#include "../common/stringhelp.h" #include "../common/stringhelp.h"

View File

@ -67,7 +67,7 @@ ks_printf_help (ctrl_t ctrl, const char *format, ...)
char *buf; char *buf;
va_start (arg_ptr, format); va_start (arg_ptr, format);
buf = es_vasprintf (format, arg_ptr); buf = es_vbsprintf (format, arg_ptr);
err = buf? 0 : gpg_error_from_syserror (); err = buf? 0 : gpg_error_from_syserror ();
va_end (arg_ptr); va_end (arg_ptr);
if (!err) if (!err)

View File

@ -20,13 +20,12 @@
#ifndef DIRMNGR_KS_ENGINE_H #ifndef DIRMNGR_KS_ENGINE_H
#define DIRMNGR_KS_ENGINE_H 1 #define DIRMNGR_KS_ENGINE_H 1
#include "../common/estream.h"
#include "../common/http.h" #include "../common/http.h"
/*-- ks-action.c --*/ /*-- ks-action.c --*/
gpg_error_t ks_print_help (ctrl_t ctrl, const char *text); gpg_error_t ks_print_help (ctrl_t ctrl, const char *text);
gpg_error_t ks_printf_help (ctrl_t ctrl, const char *format, gpg_error_t ks_printf_help (ctrl_t ctrl, const char *format,
...) _ESTREAM_GCC_A_PRINTF(2,3); ...) JNLIB_GCC_A_PRINTF(2,3);
/*-- ks-engine-hkp.c --*/ /*-- ks-engine-hkp.c --*/
gpg_error_t ks_hkp_resolve (ctrl_t ctrl, parsed_uri_t uri); gpg_error_t ks_hkp_resolve (ctrl_t ctrl, parsed_uri_t uri);

View File

@ -30,7 +30,6 @@
#include "validate.h" #include "validate.h"
#include "certcache.h" #include "certcache.h"
#include "ocsp.h" #include "ocsp.h"
#include "estream.h"
/* The maximum size we allow as a response from an OCSP reponder. */ /* The maximum size we allow as a response from an OCSP reponder. */
#define MAX_RESPONSE_SIZE 65536 #define MAX_RESPONSE_SIZE 65536

View File

@ -34,7 +34,6 @@
#include "backend.h" #include "backend.h"
#include "utils.h" #include "utils.h"
#include "call-gpg.h" #include "call-gpg.h"
#include "estream.h"
/* Create a new blob with all the session keys and other meta /* Create a new blob with all the session keys and other meta
information which are to be stored encrypted in the crypto information which are to be stored encrypted in the crypto

View File

@ -28,7 +28,6 @@
#include "../common/util.h" #include "../common/util.h"
#include "../common/status.h" #include "../common/status.h"
#include "../common/estream.h"
#include "../common/session-env.h" #include "../common/session-env.h"
/* A large struct named "opt" to keep global flags. */ /* A large struct named "opt" to keep global flags. */

View File

@ -34,7 +34,6 @@
#include "backend.h" #include "backend.h"
#include "utils.h" #include "utils.h"
#include "call-gpg.h" #include "call-gpg.h"
#include "estream.h"
#include "mountinfo.h" #include "mountinfo.h"
#include "runner.h" #include "runner.h"

View File

@ -29,6 +29,7 @@
#include <assert.h> #include <assert.h>
#define JNLIB_NEED_LOG_LOGV #define JNLIB_NEED_LOG_LOGV
#include <gpg-error.h>
#include "../common/logging.h" #include "../common/logging.h"
#include "../common/argparse.h" #include "../common/argparse.h"
#include "../common/stringhelp.h" #include "../common/stringhelp.h"

View File

@ -8,8 +8,6 @@ EXTRA_DIST += gpg-error.m4 libgcrypt.m4 libassuan.m4 ksba.m4
EXTRA_DIST += autobuild.m4 EXTRA_DIST += autobuild.m4
EXTRA_DIST += estream.m4
EXTRA_DIST += sys_socket_h.m4 socklen.m4 EXTRA_DIST += sys_socket_h.m4 socklen.m4
EXTRA_DIST += ChangeLog-2011 EXTRA_DIST += ChangeLog-2011

View File

@ -1,49 +0,0 @@
dnl Autoconf macros for libestream
dnl Copyright (C) 2007 g10 Code GmbH
dnl
dnl This file is free software; as a special exception the author gives
dnl unlimited permission to copy and/or distribute it, with or without
dnl modifications, as long as this notice is preserved.
dnl
dnl This file is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
dnl estream_PRINTF_INIT
dnl Prepare build of source included estream-printf.c
dnl
AC_DEFUN([estream_PRINTF_INIT],
[
AC_MSG_NOTICE([checking system features for estream-printf])
AC_CHECK_HEADERS(stdint.h)
AC_TYPE_LONG_LONG_INT
AC_TYPE_LONG_DOUBLE
AC_TYPE_INTMAX_T
AC_TYPE_UINTMAX_T
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_SIZEOF([unsigned long])
AC_CHECK_SIZEOF([void *])
AC_CACHE_CHECK([for nl_langinfo and THOUSANDS_SEP],
estream_cv_langinfo_thousands_sep,
[AC_TRY_LINK([#include <langinfo.h>],
[char* cs = nl_langinfo(THOUSANDS_SEP); return !cs;],
estream_cv_langinfo_thousands_sep=yes,
estream_cv_langinfo_thousands_sep=no)
])
if test $estream_cv_langinfo_thousands_sep = yes; then
AC_DEFINE(HAVE_LANGINFO_THOUSANDS_SEP, 1,
[Define if you have <langinfo.h> and nl_langinfo(THOUSANDS_SEP).])
fi
])
dnl estream_INIT
dnl Prepare build of source included estream.c
dnl
AC_DEFUN([estream_INIT],
[
AC_REQUIRE([estream_PRINTF_INIT])
AC_MSG_NOTICE([checking system features for estream])
])

View File

@ -1448,9 +1448,8 @@ get_public_key (app_t app, int keyno)
} }
hexkeyid = fpr + 24; hexkeyid = fpr + 24;
ret = estream_asprintf (&command, ret = gpgrt_asprintf
"gpg --list-keys --with-colons --with-key-data '%s'", (&command, "gpg --list-keys --with-colons --with-key-data '%s'", fpr);
fpr);
if (ret < 0) if (ret < 0)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();

View File

@ -24,7 +24,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include "../common/estream.h" #include <gpg-error.h>
#include "../common/logging.h" #include "../common/logging.h"
#include "atr.h" #include "atr.h"

View File

@ -686,8 +686,8 @@ cmd_learn (assuan_context_t ctx, char *line)
{ {
char *command; char *command;
rc = estream_asprintf (&command, "KNOWNCARDP %s %lu", rc = gpgrt_asprintf (&command, "KNOWNCARDP %s %lu",
serial, (unsigned long)stamp); serial, (unsigned long)stamp);
if (rc < 0) if (rc < 0)
{ {
xfree (serial); xfree (serial);
@ -915,7 +915,7 @@ pin_cb (void *opaque, const char *info, char **retstr)
if (info) if (info)
{ {
log_debug ("prompting for pinpad entry '%s'\n", info); log_debug ("prompting for pinpad entry '%s'\n", info);
rc = estream_asprintf (&command, "POPUPPINPADPROMPT %s", info); rc = gpgrt_asprintf (&command, "POPUPPINPADPROMPT %s", info);
if (rc < 0) if (rc < 0)
return gpg_error (gpg_err_code_from_errno (errno)); return gpg_error (gpg_err_code_from_errno (errno));
rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN); rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN);
@ -935,7 +935,7 @@ pin_cb (void *opaque, const char *info, char **retstr)
*retstr = NULL; *retstr = NULL;
log_debug ("asking for PIN '%s'\n", info); log_debug ("asking for PIN '%s'\n", info);
rc = estream_asprintf (&command, "NEEDPIN %s", info); rc = gpgrt_asprintf (&command, "NEEDPIN %s", info);
if (rc < 0) if (rc < 0)
return gpg_error (gpg_err_code_from_errno (errno)); return gpg_error (gpg_err_code_from_errno (errno));
@ -2340,7 +2340,7 @@ update_reader_status_file (int set_card_removed_flag)
gpg_error_t err; gpg_error_t err;
homestr = make_filename (opt.homedir, NULL); homestr = make_filename (opt.homedir, NULL);
if (estream_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0) if (gpgrt_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0)
log_error ("out of core while building environment\n"); log_error ("out of core while building environment\n");
else else
{ {

View File

@ -826,8 +826,8 @@ main (int argc, char **argv )
close (fd); close (fd);
/* create the info string: <name>:<pid>:<protocol_version> */ /* create the info string: <name>:<pid>:<protocol_version> */
if (estream_asprintf (&infostr, "SCDAEMON_INFO=%s:%lu:1", if (gpgrt_asprintf (&infostr, "SCDAEMON_INFO=%s:%lu:1",
socket_name, (ulong) pid) < 0) socket_name, (ulong) pid) < 0)
{ {
log_error ("out of core\n"); log_error ("out of core\n");
kill (pid, SIGTERM); kill (pid, SIGTERM);

View File

@ -504,9 +504,8 @@ print_dn_part (FILE *fp, estream_t stream,
{ {
es_fprintf (stream, "/%s=", dn->key); es_fprintf (stream, "/%s=", dn->key);
if (translate) if (translate)
es_write_sanitized_utf8_buffer (stream, dn->value, print_utf8_buffer3 (stream, dn->value, strlen (dn->value),
strlen (dn->value), "/");
"/", NULL);
else else
es_write_sanitized (stream, dn->value, strlen (dn->value), es_write_sanitized (stream, dn->value, strlen (dn->value),
"/", NULL); "/", NULL);
@ -716,8 +715,7 @@ gpgsm_es_print_name2 (estream_t fp, const char *name, int translate)
if (s2) if (s2)
{ {
if (translate) if (translate)
es_write_sanitized_utf8_buffer (fp, s + 1, s2 - (char*)s - 1, print_utf8_buffer (fp, s + 1, s2 - (char*)s - 1);
NULL, NULL);
else else
es_write_sanitized (fp, s + 1, s2 - (char*)s - 1, NULL, NULL); es_write_sanitized (fp, s + 1, s2 - (char*)s - 1, NULL, NULL);
} }