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

First steps towards supporting W32.

This is mainly source code reorganization.
Update gnulib.
g10/ does currently not build.
This commit is contained in:
Werner Koch 2007-06-06 18:12:30 +00:00
parent c2b08ff908
commit 2c9791db55
116 changed files with 2722 additions and 5565 deletions

View File

@ -1,3 +1,22 @@
2007-06-06 Werner Koch <wk@g10code.com>
* configure.ac: Add a few notices message so make browsing of the
log file easier.
(CC_FOR_BUILD): New.
2007-05-30 Werner Koch <wk@g10code.com>
* configure.ac [W32]: Do not create a symlink to w32-pth.h.
Require the installation of the w32pth package.
2007-05-29 Werner Koch <wk@g10code.com>
* gl/: Updated to a newer version.
2007-05-24 Werner Koch <wk@g10code.com>
* configure.ac: Use -Wpointer-arith is possible.
2007-05-15 Werner Koch <wk@g10code.com>
* configure.ac: Renamed the estream macros. Remove -Wformat-nonliteral.

2
TODO
View File

@ -79,6 +79,8 @@
* sm/
** check that we issue NO_SECKEY xxx if a -u key was not found
We don't. The messages returned are also wrong (recipient vs. signer).
** gpgsm_format_name2
Replace by an estream based implementation.
* jnlib/
** provide jnlib_malloc and try to remove all jnlib_xmalloc.

View File

@ -1,3 +1,15 @@
2007-06-06 Werner Koch <wk@g10code.com>
* minip12.c (enum): Rename CONTEXT to ASNCONTEXT as winnt.h
defines such a symbol to access the process context.
* call-pinentry.c (dump_mutex_state) [W32]: Handle the W32Pth case.
* call-scd.c (dump_mutex_state): Ditto.
* protect-tool.c (i18n_init): Remove.
* preset-passphrase.c (i18n_init): Remove.
* gpg-agent.c (i18n_init): Remove.
2007-05-19 Marcus Brinkmann <marcus@g10code.de>
* protect-tool.c (get_passphrase): Free ORIG_CODESET on error.

View File

@ -103,12 +103,16 @@ initialize_module_query (void)
static void
dump_mutex_state (pth_mutex_t *m)
{
#ifdef _W32_PTH_H
log_printf ("unknown under W32");
#else
if (!(m->mx_state & PTH_MUTEX_INITIALIZED))
log_printf ("not_initialized");
else if (!(m->mx_state & PTH_MUTEX_LOCKED))
log_printf ("not_locked");
else
log_printf ("locked tid=0x%lx count=%lu", (long)m->mx_owner, m->mx_count);
#endif
}

View File

@ -135,12 +135,16 @@ initialize_module_call_scd (void)
static void
dump_mutex_state (pth_mutex_t *m)
{
#ifdef _W32_PTH_H
log_printf ("unknown under W32");
#else
if (!(m->mx_state & PTH_MUTEX_INITIALIZED))
log_printf ("not_initialized");
else if (!(m->mx_state & PTH_MUTEX_LOCKED))
log_printf ("not_locked");
else
log_printf ("locked tid=0x%lx count=%lu", (long)m->mx_owner, m->mx_count);
#endif
}

View File

@ -260,22 +260,6 @@ my_strusage (int level)
static void
i18n_init (void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file( PACKAGE_GT );
#else
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT);
#endif
#endif
}
/* Setup the debugging. With the global variable DEBUG_LEVEL set to NULL
only the active debug flags are propagated to the subsystems. With
DEBUG_LEVEL set, a specific set of debug flags is set; thus overriding

View File

@ -52,7 +52,7 @@ enum
{
UNIVERSAL = 0,
APPLICATION = 1,
CONTEXT = 2,
ASNCONTEXT = 2,
PRIVATE = 3
};
@ -638,7 +638,7 @@ parse_bag_encrypted_data (const unsigned char *buffer, size_t length,
where = "start";
if (parse_tag (&p, &n, &ti))
goto bailout;
if (ti.class != CONTEXT || ti.tag)
if (ti.class != ASNCONTEXT || ti.tag)
goto bailout;
if (parse_tag (&p, &n, &ti))
goto bailout;
@ -722,7 +722,7 @@ parse_bag_encrypted_data (const unsigned char *buffer, size_t length,
goto bailout;
consumed = p - p_start;
if (ti.class == CONTEXT && ti.tag == 0 && ti.is_constructed && ti.ndef)
if (ti.class == ASNCONTEXT && ti.tag == 0 && ti.is_constructed && ti.ndef)
{
/* Mozilla exported certs now come with single byte chunks of
octect strings. (Mozilla Firefox 1.0.4). Arghh. */
@ -736,7 +736,7 @@ parse_bag_encrypted_data (const unsigned char *buffer, size_t length,
r_consumed = NULL; /* Ugly hack to not update that value any further. */
ti.length = n;
}
else if (ti.class == CONTEXT && ti.tag == 0 && ti.length )
else if (ti.class == ASNCONTEXT && ti.tag == 0 && ti.length )
;
else
goto bailout;
@ -818,7 +818,7 @@ parse_bag_encrypted_data (const unsigned char *buffer, size_t length,
where = "certbag.before.certheader";
if (parse_tag (&p, &n, &ti))
goto bailout;
if (ti.class != CONTEXT || ti.tag)
if (ti.class != ASNCONTEXT || ti.tag)
goto bailout;
if (iscrlbag)
{
@ -937,7 +937,7 @@ parse_bag_encrypted_data (const unsigned char *buffer, size_t length,
where = "certbag.before.octetstring";
if (parse_tag (&p, &n, &ti))
goto bailout;
if (ti.class != CONTEXT || ti.tag)
if (ti.class != ASNCONTEXT || ti.tag)
goto bailout;
if (parse_tag (&p, &n, &ti))
goto bailout;
@ -1065,7 +1065,7 @@ parse_bag_data (const unsigned char *buffer, size_t length, int startoffset,
where = "start";
if (parse_tag (&p, &n, &ti))
goto bailout;
if (ti.class != CONTEXT || ti.tag)
if (ti.class != ASNCONTEXT || ti.tag)
goto bailout;
if (parse_tag (&p, &n, &ti))
goto bailout;
@ -1112,7 +1112,7 @@ parse_bag_data (const unsigned char *buffer, size_t length, int startoffset,
where = "shrouded,outerseqs";
if (parse_tag (&p, &n, &ti))
goto bailout;
if (ti.class != CONTEXT || ti.tag)
if (ti.class != ASNCONTEXT || ti.tag)
goto bailout;
if (parse_tag (&p, &n, &ti))
goto bailout;
@ -1324,7 +1324,7 @@ p12_parse (const unsigned char *buffer, size_t length, const char *pw,
if (parse_tag (&p, &n, &ti))
goto bailout;
if (ti.class != CONTEXT || ti.tag)
if (ti.class != ASNCONTEXT || ti.tag)
goto bailout;
if (parse_tag (&p, &n, &ti))
goto bailout;

View File

@ -110,21 +110,6 @@ my_strusage (int level)
}
static void
i18n_init (void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file( PACKAGE_GT );
#else
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT);
#endif
#endif
}
static gpg_error_t
map_spwq_error (int err)

View File

@ -161,22 +161,6 @@ my_strusage (int level)
static void
i18n_init (void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file( PACKAGE_GT );
#else
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT);
#endif
#endif
}
/* static void */
/* print_mpi (const char *text, gcry_mpi_t a) */
/* { */

View File

@ -92,7 +92,7 @@ if test "$1" = "--build-w32"; then
--with-libassuan-prefix=${w32root} \
--with-zlib=${w32root} \
--with-pth-prefix=${w32root} \
--disable-gpg
--without-included-gettext
rc=$?
exit $rc
fi

View File

@ -1,3 +1,40 @@
2007-06-06 Werner Koch <wk@g10code.com>
* Makefile.am: Include am/cmacros.am.
* sysutils.h [W32]: Remove prototypes for the registry access.
* w32reg.c: Move to ../jnlib/w32-reg.c.
* i18n.c (i18n_init): New.
* simple-gettext.c: Remove.
* iobuf.c (iobuf_get_filelength): Rename SIZE to EXSIZE to silent
shadowing warning.
2007-06-04 Werner Koch <wk@g10code.com>
* http.c [W32]: Include unistd.h also in this case.
(write_server) [W32]: Fixed error code.
(init_sockets): Fixed syntax error.
(cookie_close): Replace close by sock_close macro.
* estream.c [w32]: Do not init Mutex.
* Makefile.am (common_sources) [USE_SNS_SRV]: Build srv.c only
when needed.
* ttyio.c (init_ttyfp) [W32]: Do not use TTYFP.
* util.h: Include ../jnlib/dynload.h.
* dynload.h: Move to ../jnlib.
2007-05-30 Werner Koch <wk@g10code.com>
* estream.c (MEM_FREE, MEM_ALLOC, MEM_REALLOC): Prefix with ES_ as
windows.h also has such definitions,
2007-05-15 Werner Koch <wk@g10code.com>
* util.h: Do not include gnulib's vasprintf. Redefine asprintf

View File

@ -28,9 +28,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl
AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS)
include $(top_srcdir)/am/cmacros.am
common_sources = \
common-defs.h \
util.h i18n.h \
util.h i18n.c i18n.h \
errors.h \
openpgpdefs.h \
keyserver.h \
@ -50,20 +52,23 @@ common_sources = \
ttyio.c ttyio.h \
asshelp.c asshelp.h \
exechelp.c exechelp.h \
simple-gettext.c \
w32reg.c \
signal.c \
dynload.h \
estream.c estream.h estream-printf.c estream-printf.h \
srv.c srv.h \
srv.h \
dns-cert.c dns-cert.h \
pka.c pka.h \
http.c http.h
libcommon_a_SOURCES = $(common_sources)
if USE_DNS_SRV
libcommon_a_SOURCES += srv.c
endif
libcommon_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) -DWITHOUT_GNU_PTH=1
libcommonpth_a_SOURCES = $(common_sources)
if USE_DNS_SRV
libcommonpth_a_SOURCES += srv.c
endif
libcommonpth_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_PTH_CFLAGS) $(PTH_CFLAGS)
libsimple_pwquery_a_SOURCES = \

View File

@ -1,72 +0,0 @@
/* dlfcn.h - W32 functions for run-time dynamic loading
* Copyright (C) 2003 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of 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.
*
* GnuPG 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef GNUPG_DYNLOAD_H
#define GNUPG_DYNLOAD_H
#ifndef __MINGW32__
#include <dlfcn.h>
#else
#include <windows.h>
#define RTLD_LAZY 0
static inline void *
dlopen (const char * name, int flag)
{
void * hd = LoadLibrary (name);
return hd;
}
static inline void *
dlsym (void *hd, const char *sym)
{
if (hd && sym)
{
void * fnc = GetProcAddress (hd, sym);
if (!fnc)
return NULL;
return fnc;
}
return NULL;
}
static inline const char *
dlerror (void)
{
static char buf[32];
sprintf (buf, "ec=%lu", GetLastError ());
return buf;
}
static inline int
dlclose (void * hd)
{
if (hd)
{
CloseHandle (hd);
return 0;
}
return -1;
}
#endif /*__MINGW32__*/
#endif /*GNUPG_DYNLOAD_H*/

View File

@ -125,9 +125,9 @@ typedef void *estream_mutex_t;
/* Memory allocator functions. */
#define MEM_ALLOC malloc
#define MEM_REALLOC realloc
#define MEM_FREE free
#define ES_MEM_ALLOC malloc
#define ES_MEM_REALLOC realloc
#define ES_MEM_FREE free
/* Primitive system I/O. */
@ -194,7 +194,13 @@ struct estream_list
static estream_list_t estream_list;
#ifdef HAVE_PTH
static estream_mutex_t estream_list_lock = ESTREAM_MUTEX_INITIALIZER;
/* Note that we can't use a static initialization with W32Pth; however
W32Pth does an implicit initialization anyway. */
static estream_mutex_t estream_list_lock
# ifndef _W32_PTH_H
= ESTREAM_MUTEX_INITIALIZER
# endif
;
#endif
#define ESTREAM_LIST_LOCK ESTREAM_MUTEX_LOCK (estream_list_lock)
@ -236,7 +242,7 @@ es_list_add (estream_t stream)
estream_list_t list_obj;
int ret;
list_obj = MEM_ALLOC (sizeof (*list_obj));
list_obj = ES_MEM_ALLOC (sizeof (*list_obj));
if (! list_obj)
ret = -1;
else
@ -268,7 +274,7 @@ es_list_remove (estream_t stream)
*list_obj->prev_cdr = list_obj->cdr;
if (list_obj->cdr)
list_obj->cdr->prev_cdr = list_obj->prev_cdr;
MEM_FREE (list_obj);
ES_MEM_FREE (list_obj);
break;
}
ESTREAM_LIST_UNLOCK;
@ -349,7 +355,7 @@ es_func_mem_create (void *ES__RESTRICT *ES__RESTRICT cookie,
estream_cookie_mem_t mem_cookie;
int err;
mem_cookie = MEM_ALLOC (sizeof (*mem_cookie));
mem_cookie = ES_MEM_ALLOC (sizeof (*mem_cookie));
if (! mem_cookie)
err = -1;
else
@ -365,8 +371,8 @@ es_func_mem_create (void *ES__RESTRICT *ES__RESTRICT cookie,
mem_cookie->dont_free = dont_free ? 1 : 0;
mem_cookie->ptr = ptr;
mem_cookie->size = size;
mem_cookie->func_realloc = func_realloc ? func_realloc : MEM_REALLOC;
mem_cookie->func_free = func_free ? func_free : MEM_FREE;
mem_cookie->func_realloc = func_realloc ? func_realloc : ES_MEM_REALLOC;
mem_cookie->func_free = func_free ? func_free : ES_MEM_FREE;
mem_cookie->offset = 0;
*cookie = mem_cookie;
err = 0;
@ -575,7 +581,7 @@ es_func_mem_destroy (void *cookie)
if (! mem_cookie->dont_free)
(*func_free) (mem_cookie->memory);
MEM_FREE (mem_cookie);
ES_MEM_FREE (mem_cookie);
return 0;
}
@ -603,7 +609,7 @@ es_func_fd_create (void **cookie, int fd, unsigned int flags)
estream_cookie_fd_t fd_cookie;
int err;
fd_cookie = MEM_ALLOC (sizeof (*fd_cookie));
fd_cookie = ES_MEM_ALLOC (sizeof (*fd_cookie));
if (! fd_cookie)
err = -1;
else
@ -676,7 +682,7 @@ es_func_fd_destroy (void *cookie)
if (fd_cookie)
{
err = close (fd_cookie->fd);
MEM_FREE (fd_cookie);
ES_MEM_FREE (fd_cookie);
}
else
err = 0;
@ -706,7 +712,7 @@ es_func_file_create (void **cookie, int *filedes,
err = 0;
fd = -1;
file_cookie = MEM_ALLOC (sizeof (*file_cookie));
file_cookie = ES_MEM_ALLOC (sizeof (*file_cookie));
if (! file_cookie)
{
err = -1;
@ -727,7 +733,7 @@ es_func_file_create (void **cookie, int *filedes,
out:
if (err)
MEM_FREE (file_cookie);
ES_MEM_FREE (file_cookie);
return err;
}
@ -1004,14 +1010,14 @@ es_create (estream_t *stream, void *cookie, int fd,
stream_new = NULL;
stream_internal_new = NULL;
stream_new = MEM_ALLOC (sizeof (*stream_new));
stream_new = ES_MEM_ALLOC (sizeof (*stream_new));
if (! stream_new)
{
err = -1;
goto out;
}
stream_internal_new = MEM_ALLOC (sizeof (*stream_internal_new));
stream_internal_new = ES_MEM_ALLOC (sizeof (*stream_internal_new));
if (! stream_internal_new)
{
err = -1;
@ -1040,7 +1046,7 @@ es_create (estream_t *stream, void *cookie, int fd,
if (stream_new)
{
es_deinitialize (stream_new);
MEM_FREE (stream_new);
ES_MEM_FREE (stream_new);
}
}
@ -1057,8 +1063,8 @@ es_destroy (estream_t stream)
{
es_list_remove (stream);
err = es_deinitialize (stream);
MEM_FREE (stream->intern);
MEM_FREE (stream);
ES_MEM_FREE (stream->intern);
ES_MEM_FREE (stream);
}
return err;
@ -1567,7 +1573,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
line_stream_cookie = NULL;
err = es_func_mem_create (&line_stream_cookie, NULL, 0, 0, BUFFER_BLOCK_SIZE,
1, 0, 0, NULL, 0, MEM_REALLOC, MEM_FREE, O_RDWR);
1, 0, 0, NULL, 0, ES_MEM_REALLOC, ES_MEM_FREE, O_RDWR);
if (err)
goto out;
@ -1633,7 +1639,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
if (! *line)
{
line_new = MEM_ALLOC (line_size + 1);
line_new = ES_MEM_ALLOC (line_size + 1);
if (! line_new)
{
err = -1;
@ -1664,7 +1670,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
if (err)
{
if (! *line)
MEM_FREE (line_new);
ES_MEM_FREE (line_new);
stream->intern->indicators.err = 1;
}
@ -1748,7 +1754,7 @@ es_set_buffering (estream_t ES__RESTRICT stream,
if (stream->intern->deallocate_buffer)
{
stream->intern->deallocate_buffer = 0;
MEM_FREE (stream->buffer);
ES_MEM_FREE (stream->buffer);
stream->buffer = NULL;
}
@ -1762,7 +1768,7 @@ es_set_buffering (estream_t ES__RESTRICT stream,
buffer_new = buffer;
else
{
buffer_new = MEM_ALLOC (size);
buffer_new = ES_MEM_ALLOC (size);
if (! buffer_new)
{
err = -1;
@ -1921,7 +1927,7 @@ es_open_memstream (char **ptr, size_t *size)
err = es_func_mem_create (&cookie, NULL, 0, 0,
BUFFER_BLOCK_SIZE, 1, 1, 1,
ptr, size, MEM_REALLOC, MEM_FREE, flags);
ptr, size, ES_MEM_REALLOC, ES_MEM_FREE, flags);
if (err)
goto out;
@ -2454,7 +2460,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n,
void *p;
p = MEM_REALLOC (*lineptr, line_n + 1);
p = ES_MEM_REALLOC (*lineptr, line_n + 1);
if (! p)
err = -1;
else
@ -2470,7 +2476,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n,
if (*n != line_n)
*n = line_n;
}
MEM_FREE (line);
ES_MEM_FREE (line);
}
else
{
@ -2530,7 +2536,7 @@ es_read_line (estream_t stream,
{
/* No buffer given - allocate a new one. */
length = 256;
buffer = MEM_ALLOC (length);
buffer = ES_MEM_ALLOC (length);
*addr_of_buffer = buffer;
if (!buffer)
{
@ -2571,11 +2577,11 @@ es_read_line (estream_t stream,
}
length += 3; /* Adjust for the reserved bytes. */
length += length < 1024? 256 : 1024;
*addr_of_buffer = MEM_REALLOC (buffer, length);
*addr_of_buffer = ES_MEM_REALLOC (buffer, length);
if (!*addr_of_buffer)
{
int save_errno = errno;
MEM_FREE (buffer);
ES_MEM_FREE (buffer);
*length_of_buffer = *max_length = 0;
ESTREAM_UNLOCK (stream);
errno = save_errno;
@ -2604,7 +2610,7 @@ void
es_free (void *a)
{
if (a)
MEM_FREE (a);
ES_MEM_FREE (a);
}

View File

@ -41,11 +41,11 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#ifdef HAVE_W32_SYSTEM
# include <windows.h>
#else /*!HAVE_W32_SYSTEM*/
# include <unistd.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/time.h>
@ -236,7 +236,7 @@ init_sockets (void)
|| HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR )
{
log_error ("socket library version is %x.%x - but %d.%d needed\n",
LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion)
LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion),
REQ_WINSOCK_MAJOR, REQ_WINSOCK_MINOR);
WSACleanup();
return;
@ -1693,7 +1693,7 @@ write_server (int sock, const char *data, size_t length)
if ( nwritten == SOCKET_ERROR )
{
log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ());
return G10ERR_NETWORK;
return gpg_error (GPG_ERR_NETWORK);
}
#else /*!HAVE_W32_SYSTEM*/
int nwritten = write (sock, data, nleft);
@ -1829,14 +1829,14 @@ cookie_close (void *cookie)
if (!c)
return 0;
#ifdef HTTP_USE_GNUTLS
#ifdef HTTP_USE_GNUTLS
if (c->tls_session && !c->keep_socket)
{
gnutls_bye (c->tls_session, GNUTLS_SHUT_RDWR);
}
#endif /*HTTP_USE_GNUTLS*/
if (c->fd != -1 && !c->keep_socket)
close (c->fd);
sock_close (c->fd);
xfree (c);
return 0;

39
common/i18n.c Normal file
View File

@ -0,0 +1,39 @@
/* i18n.c - gettext initialization
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of 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.
*
* GnuPG 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include "i18n.h"
void
i18n_init (void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file (PACKAGE_GT, "Software\\GNU\\GnuPG");
#else
# ifdef ENABLE_NLS
setlocale (LC_ALL, "" );
bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT);
# endif
#endif
}

View File

@ -14,11 +14,9 @@
#ifndef GNUPG_COMMON_I18N_H
#define GNUPG_COMMON_I18N_H
#ifdef USE_SIMPLE_GETTEXT
int set_gettext_file( const char *filename );
const char *gettext( const char *msgid );
const char *ngettext(const char *msgid1, const char *msgid2,
unsigned long int n);
# include "../jnlib/w32help.h"
# define _(a) gettext (a)
# define N_(a) (a)
#else
@ -40,4 +38,7 @@
# endif
#endif /*!USE_SIMPLE_GETTEXT*/
void i18n_init (void);
#endif /*GNUPG_COMMON_I18N_H*/

View File

@ -271,7 +271,7 @@ fd_cache_close (const char *fname, FILEP_OR_FD fp)
close (fp);
#endif
if (DBG_IOBUF)
log_debug ("fd_cache_close (%d) real\n", fp);
log_debug ("fd_cache_close (%d) real\n", (int)fp);
return;
}
/* try to reuse a slot */
@ -2006,78 +2006,79 @@ iobuf_set_limit (iobuf_t a, off_t nlimit)
off_t
iobuf_get_filelength (iobuf_t a, int *overflow)
{
struct stat st;
struct stat st;
if (overflow)
*overflow = 0;
if( a->directfp ) {
FILE *fp = a->directfp;
if( !fstat(fileno(fp), &st) )
return st.st_size;
log_error("fstat() failed: %s\n", strerror(errno) );
return 0;
if (overflow)
*overflow = 0;
if ( a->directfp )
{
FILE *fp = a->directfp;
if ( !fstat(fileno(fp), &st) )
return st.st_size;
log_error("fstat() failed: %s\n", strerror(errno) );
return 0;
}
/* Hmmm: file_filter may have already been removed */
for( ; a; a = a->chain )
if( !a->chain && a->filter == file_filter ) {
file_filter_ctx_t *b = a->filter_ov;
FILEP_OR_FD fp = b->fp;
/* Hmmm: file_filter may have already been removed */
for ( ; a; a = a->chain )
if ( !a->chain && a->filter == file_filter )
{
file_filter_ctx_t *b = a->filter_ov;
FILEP_OR_FD fp = b->fp;
#if defined(HAVE_DOSISH_SYSTEM) && !defined(FILE_FILTER_USES_STDIO)
ulong size;
static int (* __stdcall get_file_size_ex)
(void *handle, LARGE_INTEGER *size);
static int get_file_size_ex_initialized;
ulong size;
static int (* __stdcall get_file_size_ex) (void *handle,
LARGE_INTEGER *r_size);
static int get_file_size_ex_initialized;
if (!get_file_size_ex_initialized)
if (!get_file_size_ex_initialized)
{
void *handle;
handle = dlopen ("kernel32.dll", RTLD_LAZY);
if (handle)
{
void *handle;
handle = dlopen ("kernel32.dll", RTLD_LAZY);
if (handle)
{
get_file_size_ex = dlsym (handle, "GetFileSizeEx");
if (!get_file_size_ex)
dlclose (handle);
}
get_file_size_ex_initialized = 1;
get_file_size_ex = dlsym (handle, "GetFileSizeEx");
if (!get_file_size_ex)
dlclose (handle);
}
if (get_file_size_ex)
get_file_size_ex_initialized = 1;
}
if (get_file_size_ex)
{
/* This is a newer system with GetFileSizeEx; we use this
then because it seem that GetFileSize won't return a
proper error in case a file is larger than 4GB. */
LARGE_INTEGER exsize;
if (get_file_size_ex (fp, &exsize))
{
/* This is a newer system with GetFileSizeEx; we use
this then becuase it seem that GetFileSize won't
return a proper error in case a file is larger than
4GB. */
LARGE_INTEGER size;
if (get_file_size_ex (fp, &size))
{
if (!size.u.HighPart)
return size.u.LowPart;
if (overflow)
*overflow = 1;
return 0;
}
if (!exsize.u.HighPart)
return exsize.u.LowPart;
if (overflow)
*overflow = 1;
return 0;
}
else
{
if ((size=GetFileSize (fp, NULL)) != 0xffffffff)
return size;
}
log_error ("GetFileSize for handle %p failed: %s\n",
fp, w32_strerror (0));
}
else
{
if ((size=GetFileSize (fp, NULL)) != 0xffffffff)
return size;
}
log_error ("GetFileSize for handle %p failed: %s\n",
fp, w32_strerror (0));
#else
if( !fstat(my_fileno(fp), &st) )
return st.st_size;
log_error("fstat() failed: %s\n", strerror(errno) );
if ( !fstat(my_fileno(fp), &st) )
return st.st_size;
log_error("fstat() failed: %s\n", strerror(errno) );
#endif
break;
}
break/*the for loop*/;
}
return 0;
}

View File

@ -1,447 +0,0 @@
/* simple-gettext.c - a simplified version of gettext.
* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of 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.
*
* GnuPG 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
/* This is a simplified version of gettext written by Ulrich Drepper.
* It is used for the Win32 version of GnuPG beucase all the overhead
* of gettext is not needed and we have to do some special Win32 stuff.
* I decided that this is far easier than to tweak gettext for the special
* cases (I tried it but it is a lot of code). wk 15.09.99
*/
#include <config.h>
#ifdef USE_SIMPLE_GETTEXT
#if !defined (_WIN32) && !defined (__CYGWIN32__)
#error This file can only be used under Windows or Cygwin32
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "util.h"
#include "sysutils.h"
/* The magic number of the GNU message catalog format. */
#define MAGIC 0x950412de
#define MAGIC_SWAPPED 0xde120495
/* Revision number of the currently used .mo (binary) file format. */
#define MO_REVISION_NUMBER 0
/* Header for binary .mo file format. */
struct mo_file_header
{
/* The magic number. */
u32 magic;
/* The revision number of the file format. */
u32 revision;
/* The number of strings pairs. */
u32 nstrings;
/* Offset of table with start offsets of original strings. */
u32 orig_tab_offset;
/* Offset of table with start offsets of translation strings. */
u32 trans_tab_offset;
/* Size of hashing table. */
u32 hash_tab_size;
/* Offset of first hashing entry. */
u32 hash_tab_offset;
};
struct string_desc
{
/* Length of addressed string. */
u32 length;
/* Offset of string in file. */
u32 offset;
};
struct overflow_space_s
{
struct overflow_space_s *next;
u32 idx;
char d[1];
};
struct loaded_domain
{
char *data;
int must_swap;
u32 nstrings;
char *mapped; /* 0 = not yet mapped, 1 = mapped,
2 = mapped to
overflow space */
struct overflow_space_s *overflow_space;
struct string_desc *orig_tab;
struct string_desc *trans_tab;
u32 hash_size;
u32 *hash_tab;
};
static struct loaded_domain *the_domain;
static __inline__ u32
do_swap_u32( u32 i )
{
return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
}
#define SWAPIT(flag, data) ((flag) ? do_swap_u32(data) : (data) )
/* We assume to have `unsigned long int' value with at least 32 bits. */
#define HASHWORDBITS 32
/* The so called `hashpjw' function by P.J. Weinberger
[see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
1986, 1987 Bell Telephone Laboratories, Inc.] */
static __inline__ ulong
hash_string( const char *str_param )
{
unsigned long int hval, g;
const char *str = str_param;
hval = 0;
while (*str != '\0')
{
hval <<= 4;
hval += (unsigned long int) *str++;
g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
if (g != 0)
{
hval ^= g >> (HASHWORDBITS - 8);
hval ^= g;
}
}
return hval;
}
static struct loaded_domain *
load_domain( const char *filename )
{
FILE *fp;
size_t size;
struct stat st;
struct mo_file_header *data = NULL;
struct loaded_domain *domain = NULL;
size_t to_read;
char *read_ptr;
fp = fopen( filename, "rb" );
if( !fp )
return NULL; /* can't open the file */
/* we must know about the size of the file */
if( fstat( fileno(fp ), &st )
|| (size = (size_t)st.st_size) != st.st_size
|| size < sizeof (struct mo_file_header) ) {
fclose( fp );
return NULL;
}
data = malloc( size );
if( !data ) {
fclose( fp );
return NULL; /* out of memory */
}
to_read = size;
read_ptr = (char *) data;
do {
long int nb = fread( read_ptr, 1, to_read, fp );
if( nb < to_read ) {
fclose (fp);
free(data);
return NULL; /* read error */
}
read_ptr += nb;
to_read -= nb;
} while( to_read > 0 );
fclose (fp);
/* Using the magic number we can test whether it really is a message
* catalog file. */
if( data->magic != MAGIC && data->magic != MAGIC_SWAPPED ) {
/* The magic number is wrong: not a message catalog file. */
free( data );
return NULL;
}
domain = calloc( 1, sizeof *domain );
if( !domain ) {
free( data );
return NULL;
}
domain->data = (char *) data;
domain->must_swap = data->magic != MAGIC;
/* Fill in the information about the available tables. */
switch( SWAPIT(domain->must_swap, data->revision) ) {
case 0:
domain->nstrings = SWAPIT(domain->must_swap, data->nstrings);
domain->orig_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->orig_tab_offset));
domain->trans_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->trans_tab_offset));
domain->hash_size = SWAPIT(domain->must_swap, data->hash_tab_size);
domain->hash_tab = (u32 *)
((char *) data + SWAPIT(domain->must_swap, data->hash_tab_offset));
break;
default: /* This is an invalid revision. */
free( data );
free( domain );
return NULL;
}
/* Allocate an array to keep track of code page mappings. */
domain->mapped = calloc( 1, domain->nstrings );
if( !domain->mapped ) {
free( data );
free( domain );
return NULL;
}
return domain;
}
/****************
* Set the file used for translations. Pass a NULL to disable
* translation. A new filename may be set at anytime.
* WARNING: After changing the filename you should not access any data
* retrieved by gettext().
*/
int
set_gettext_file( const char *filename )
{
struct loaded_domain *domain = NULL;
if( filename && *filename ) {
if( filename[0] == '/'
#ifdef HAVE_DRIVE_LETTERS
|| ( isalpha(filename[0])
&& filename[1] == ':'
&& (filename[2] == '/' || filename[2] == '\\') )
#endif
) {
/* absolute path - use it as is */
domain = load_domain( filename );
}
else { /* relative path - append ".mo" and get dir from the environment */
char *buf = NULL;
char *dir;
char *p;
dir = read_w32_registry_string( NULL,
"Control Panel\\Mingw32\\NLS",
"MODir" );
if( dir && (buf=malloc(strlen(dir)+strlen(filename)+1+3+1)) ) {
strcpy(stpcpy(stpcpy(stpcpy( buf, dir),"\\"), filename),".mo");
/* Better make sure that we don't mix forward and
backward slashes. It seems that some Windoze
versions don't accept this. */
for (p=buf; *p; p++)
{
if (*p == '/')
*p = '\\';
}
domain = load_domain( buf );
free(buf);
}
free(dir);
}
if( !domain )
return -1;
}
if( the_domain ) {
struct overflow_space_s *os, *os2;
free( the_domain->data );
free( the_domain->mapped );
for (os=the_domain->overflow_space; os; os = os2) {
os2 = os->next;
free (os);
}
free( the_domain );
the_domain = NULL;
}
the_domain = domain;
return 0;
}
static const char*
get_string( struct loaded_domain *domain, u32 idx )
{
struct overflow_space_s *os;
char *p;
p = domain->data + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset);
if (!domain->mapped[idx])
{
size_t plen, buflen;
char *buf;
domain->mapped[idx] = 1;
plen = strlen (p);
buf = utf8_to_native (p, plen, -1);
buflen = strlen (buf);
if (buflen <= plen)
strcpy (p, buf);
else
{
/* There is not enough space for the translation - store it
in the overflow_space else and mark that in the mapped
array. Because we expect that this won't happen too
often, we use a simple linked list. */
os = malloc (sizeof *os + buflen);
if (os)
{
os->idx = idx;
strcpy (os->d, buf);
os->next = domain->overflow_space;
domain->overflow_space = os;
p = os->d;
}
else
p = "ERROR in GETTEXT MALLOC";
}
xfree (buf);
}
else if (domain->mapped[idx] == 2)
{ /* We need to get the string from the overflow_space. */
for (os=domain->overflow_space; os; os = os->next)
if (os->idx == idx)
return (const char*)os->d;
p = "ERROR in GETTEXT\n";
}
return (const char*)p;
}
const char *
gettext( const char *msgid )
{
struct loaded_domain *domain;
size_t act = 0;
size_t top, bottom;
if( !(domain = the_domain) )
goto not_found;
/* Locate the MSGID and its translation. */
if( domain->hash_size > 2 && domain->hash_tab ) {
/* Use the hashing table. */
u32 len = strlen (msgid);
u32 hash_val = hash_string (msgid);
u32 idx = hash_val % domain->hash_size;
u32 incr = 1 + (hash_val % (domain->hash_size - 2));
u32 nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
if ( !nstr ) /* Hash table entry is empty. */
goto not_found;
if( SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].length) == len
&& !strcmp( msgid,
domain->data + SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].offset)) )
return get_string( domain, nstr - 1 );
for(;;) {
if (idx >= domain->hash_size - incr)
idx -= domain->hash_size - incr;
else
idx += incr;
nstr = SWAPIT(domain->must_swap, domain->hash_tab[idx]);
if( !nstr )
goto not_found; /* Hash table entry is empty. */
if ( SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].length) == len
&& !strcmp (msgid,
domain->data + SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].offset)))
return get_string( domain, nstr-1 );
}
/* NOTREACHED */
}
/* Now we try the default method: binary search in the sorted
array of messages. */
bottom = 0;
top = domain->nstrings;
while( bottom < top ) {
int cmp_val;
act = (bottom + top) / 2;
cmp_val = strcmp(msgid, domain->data
+ SWAPIT(domain->must_swap,
domain->orig_tab[act].offset));
if (cmp_val < 0)
top = act;
else if (cmp_val > 0)
bottom = act + 1;
else
return get_string( domain, act );
}
not_found:
return msgid;
}
const char *
ngettext (const char *msgid1, const char *msgid2, unsigned long int n)
{
/* We use the simple Germanic plural rule. */
return gettext (n==1? msgid1 : msgid2);
}
#if 0
unsigned int cp1, cp2;
cp1 = GetConsoleCP();
cp2 = GetConsoleOutputCP();
log_info("InputCP=%u OutputCP=%u\n", cp1, cp2 );
if( !SetConsoleOutputCP( 1252 ) )
log_info("SetConsoleOutputCP failed: %s\n", w32_strerror (0));
cp1 = GetConsoleCP();
cp2 = GetConsoleOutputCP();
log_info("InputCP=%u OutputCP=%u after switch1\n", cp1, cp2 );
#endif
#endif /* USE_SIMPLE_GETTEXT */

View File

@ -23,13 +23,13 @@
#define GNUPG_COMMON_SRV_H
#ifdef USE_DNS_SRV
#ifdef _WIN32
#include <windows.h>
#else
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#endif /* !_WIN32 */
# ifdef _WIN32
# include <windows.h>
# else
# include <netinet/in.h>
# include <arpa/nameser.h>
# include <resolv.h>
# endif /* !_WIN32 */
#endif /* USE_DNS_SRV */

View File

@ -125,7 +125,7 @@ get_session_marker( size_t *rlen )
ulong a, b;
initialized = 1;
/* also this marker is guessable it is not easy to use this
/* Although this marker is guessable it is not easy to use
* for a faked control packet because an attacker does not
* have enough control about the time the verification does
* take place. Of course, we can add just more random but

View File

@ -33,11 +33,7 @@ int check_permissions (const char *path,int extension,int checkonly);
_sleep but non for the still existing sleep. */
#define sleep(a) _sleep ((a))
/*-- w32reg.c --*/
char *read_w32_registry_string( const char *root,
const char *dir, const char *name );
int write_w32_registry_string(const char *root, const char *dir,
const char *name, const char *value);
#include "../jnlib/w32help.h"
#endif /*HAVE_W32_SYSTEM*/

View File

@ -168,6 +168,8 @@ init_ttyfp(void)
#elif defined(__EMX__)
ttyfp = stdout; /* Fixme: replace by the real functions: see wklib */
if (my_rl_init_stream)
my_rl_init_stream (ttyfp);
#else
ttyfp = batchmode? stderr : fopen (tty_get_ttyname (), "r+");
if( !ttyfp ) {
@ -175,10 +177,10 @@ init_ttyfp(void)
strerror(errno) );
exit(2);
}
#endif
if (my_rl_init_stream)
my_rl_init_stream (ttyfp);
#endif
#ifdef HAVE_TCGETATTR
atexit( cleanup );

View File

@ -38,6 +38,7 @@
#include "../jnlib/strlist.h"
#include "../jnlib/dotlock.h"
#include "../jnlib/utf8conv.h"
#include "../jnlib/dynload.h"
/* Redefine asprintf by our estream version which uses our own memory
allocator.. */
@ -204,8 +205,8 @@ int match_multistr (const char *multistr,const char *match);
static inline char *
ttyname (int fd)
{
return NULL
};
return NULL;
}
#endif /* !HAVE_TTYNAME */

View File

@ -1,174 +0,0 @@
/* w32reg.c - MS-Windows Registry access
* Copyright (C) 1999, 2002 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of 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.
*
* GnuPG 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#ifdef HAVE_W32_SYSTEM
/* This module is only used in this environment */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <windows.h>
#include "util.h"
#include "sysutils.h"
static HKEY
get_root_key(const char *root)
{
HKEY root_key;
if( !root )
root_key = HKEY_CURRENT_USER;
else if( !strcmp( root, "HKEY_CLASSES_ROOT" ) )
root_key = HKEY_CLASSES_ROOT;
else if( !strcmp( root, "HKEY_CURRENT_USER" ) )
root_key = HKEY_CURRENT_USER;
else if( !strcmp( root, "HKEY_LOCAL_MACHINE" ) )
root_key = HKEY_LOCAL_MACHINE;
else if( !strcmp( root, "HKEY_USERS" ) )
root_key = HKEY_USERS;
else if( !strcmp( root, "HKEY_PERFORMANCE_DATA" ) )
root_key = HKEY_PERFORMANCE_DATA;
else if( !strcmp( root, "HKEY_CURRENT_CONFIG" ) )
root_key = HKEY_CURRENT_CONFIG;
else
return NULL;
return root_key;
}
/****************
* Return a string from the Win32 Registry or NULL in case of
* error. Caller must release the return value. A NULL for root
* is an alias for HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE in turn.
* NOTE: The value is allocated with a plain malloc() - use free() and not
* the usual m_free()!!!
*/
char *
read_w32_registry_string( const char *root, const char *dir, const char *name )
{
HKEY root_key, key_handle;
DWORD n1, nbytes, type;
char *result = NULL;
if ( !(root_key = get_root_key(root) ) )
return NULL;
if( RegOpenKeyEx( root_key, dir, 0, KEY_READ, &key_handle ) )
{
if (root)
return NULL; /* no need for a RegClose, so return direct */
/* It seems to be common practise to fall back to HLM. */
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle) )
return NULL; /* still no need for a RegClose, so return direct */
}
nbytes = 1;
if( RegQueryValueEx( key_handle, name, 0, NULL, NULL, &nbytes ) )
goto leave;
result = malloc( (n1=nbytes+1) );
if( !result )
goto leave;
if( RegQueryValueEx( key_handle, name, 0, &type, result, &n1 ) ) {
free(result); result = NULL;
goto leave;
}
result[nbytes] = 0; /* make sure it is really a string */
if (type == REG_EXPAND_SZ && strchr (result, '%')) {
char *tmp;
n1 += 1000;
tmp = malloc (n1+1);
if (!tmp)
goto leave;
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
if (nbytes && nbytes > n1) {
free (tmp);
n1 = nbytes;
tmp = malloc (n1 + 1);
if (!tmp)
goto leave;
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
if (nbytes && nbytes > n1) {
free (tmp); /* oops - truncated, better don't expand at all */
goto leave;
}
tmp[nbytes] = 0;
free (result);
result = tmp;
}
else if (nbytes) { /* okay, reduce the length */
tmp[nbytes] = 0;
free (result);
result = malloc (strlen (tmp)+1);
if (!result)
result = tmp;
else {
strcpy (result, tmp);
free (tmp);
}
}
else { /* error - don't expand */
free (tmp);
}
}
leave:
RegCloseKey( key_handle );
return result;
}
int
write_w32_registry_string(const char *root, const char *dir,
const char *name, const char *value)
{
HKEY root_key, reg_key;
if ( !(root_key = get_root_key(root) ) )
return -1;
if ( RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, &reg_key )
!= ERROR_SUCCESS )
return -1;
if ( RegSetValueEx( reg_key, name, 0, REG_SZ, (BYTE *)value,
strlen( value ) ) != ERROR_SUCCESS ) {
if ( RegCreateKey( root_key, name, &reg_key ) != ERROR_SUCCESS ) {
RegCloseKey(reg_key);
return -1;
}
if ( RegSetValueEx( reg_key, name, 0, REG_SZ, (BYTE *)value,
strlen( value ) ) != ERROR_SUCCESS ) {
RegCloseKey(reg_key);
return -1;
}
}
RegCloseKey( reg_key );
return 0;
}
#endif /*HAVE_W32_SYSTEM*/

View File

@ -439,6 +439,7 @@ AH_BOTTOM([
AM_MAINTAINER_MODE
# Checks for programs.
AC_MSG_NOTICE([checking for programs])
AC_PROG_MAKE_SET
AM_SANITY_CHECK
missing_dir=`cd $ac_aux_dir && pwd`
@ -465,6 +466,22 @@ AC_SYS_LARGEFILE
GNUPG_CHECK_FAQPROG
GNUPG_CHECK_USTAR
# We need to compile and run a program on the build machine. A
# comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
# the AC archive is broken for autoconf 2.57. Given that tehre is no
# newer version of that macro, we assume that it is also broken for
# autoconf 2.61 and thus we use a simple but usually sufficient
# approach.
AC_MSG_CHECKING(for cc for build)
if test "$cross_compiling" = "yes"; then
CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
else
CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
fi
AC_MSG_RESULT($CC_FOR_BUILD)
AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
try_gettext=yes
have_dosish_system=no
@ -573,6 +590,7 @@ fi
#
# Checks for libraries.
#
AC_MSG_NOTICE([checking for libraries])
#
@ -674,6 +692,7 @@ else
fi
AC_MSG_NOTICE([checking for networking options])
#
# Must check for network library requirements before doing link tests
@ -863,6 +882,7 @@ AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
#
# Check for gettext
#
AC_MSG_NOTICE([checking for gettext])
AM_GNU_GETTEXT_VERSION([0.16.1])
if test "$try_gettext" = yes; then
AM_GNU_GETTEXT(,[need-ngettext])
@ -893,6 +913,7 @@ fi
#
# Checks for header files.
#
AC_MSG_NOTICE([checking for header files])
AC_HEADER_STDC
AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h])
AC_CHECK_HEADERS([pty.h pwd.h inttypes.h])
@ -902,6 +923,7 @@ AC_HEADER_TIME
#
# Checks for typedefs, structures, and compiler characteristics.
#
AC_MSG_NOTICE([checking for system characteristics])
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
@ -965,6 +987,7 @@ fi
#
# Checks for library functions.
#
AC_MSG_NOTICE([checking for library functions])
AC_CHECK_DECLS(getpagesize)
AC_FUNC_FSEEKO
AC_FUNC_VPRINTF
@ -991,11 +1014,10 @@ AC_CHECK_FUNCS([flockfile funlockfile fopencookie funopen])
#
gl_SOURCE_BASE([gl])
gl_M4_BASE([gl/m4])
gl_MODULES([setenv mkdtemp xsize])
gl_MODULES([setenv mkdtemp xsize strpbrk])
gl_INIT
#
# W32 specific test
#
@ -1151,6 +1173,7 @@ AC_SUBST(NETLIBS)
#
# Setup gcc specific options
#
AC_MSG_NOTICE([checking for cc features])
if test "$GCC" = yes; then
# Note that it is okay to use CFLAGS here because this are just
# warning options and the user should have a chance of overriding
@ -1171,6 +1194,16 @@ if test "$GCC" = yes; then
if test x"$_gcc_psign" = xyes ; then
CFLAGS="$CFLAGS -Wno-pointer-sign"
fi
AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
_gcc_cflags_save=$CFLAGS
CFLAGS="-Wpointer-arith"
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no)
AC_MSG_RESULT($_gcc_psign)
CFLAGS=$_gcc_cflags_save;
if test x"$_gcc_psign" = xyes ; then
CFLAGS="$CFLAGS -Wpointer-arith"
fi
fi
@ -1185,14 +1218,6 @@ AC_ARG_ENABLE(optimization,
CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
fi])
#
# For W32 we need to use our Pth emulation code
#
if test "$have_w32_system" = yes; then
AC_CONFIG_LINKS(pth.h:jnlib/w32-pth.h)
fi
#
# Prepare building of estream
#
@ -1308,6 +1333,9 @@ if test "$missing_pth" = "yes"; then
*** ftp://ftp.gnu.org/gnu/pth/
*** On a Debian GNU/Linux system you can install it using
*** apt-get install libpth-dev
*** To build GnuPG for Windows you need to use the W32PTH
*** package; available at:
*** ftp://ftp.g10code.com/g10code/w32pth/
***]])
die=yes
fi

View File

@ -1,3 +1,10 @@
2007-06-06 Werner Koch <wk@g10code.com>
* Makefile.am (yat2m): Use a plain rule to build it for the sake
of cross-compiling.
* yat2m.c (finish_page): Init SECT to NULL.
2007-05-11 Werner Koch <wk@g10code.com>
* gpgsm.texi (--export): Enhanced description.

View File

@ -28,13 +28,11 @@ EXTRA_DIST = DETAILS HACKING TRANSLATE OpenPGP KEYSERVER samplekeys.asc \
gnupg-card-architecture.pdf \
faq.raw FAQ faq.html gnupg7.texi \
opt-homedir.texi see-also-note.texi specify-user-id.texi \
gpgv.texi texi.css $(examples)
gpgv.texi texi.css $(examples) yat2m.c
BUILT_SOURCES = gnupg-card-architecture.eps gnupg-card-architecture.png \
gnupg-card-architecture.pdf FAQ faq.html
noinst_PROGRAMS = yat2m
info_TEXINFOS = gnupg.texi
dist_pkgdata_DATA = qualified.txt FAQ faq.html com-certs.pem
@ -65,13 +63,13 @@ noinst_MANS = gnupg.7
watchgnupg_SOURCE = gnupg.texi
CLEANFILES = faq.raw.xref
CLEANFILES = faq.raw.xref yat2m
DISTCLEANFILES = gnupg.tmp gnupg.ops yat2m-stamp.tmp yat2m-stamp \
$(myman_pages) gnupg.7
yat2m_SOURCES = yat2m.c
yat2m: yat2m.c
$(CC_FOR_BUILD) -o $@ $(srcdir)/yat2m.c
.fig.png:

View File

@ -229,7 +229,7 @@ Update all configuration files with values taken from the global
configuration file (usually @file{/etc/gnupg/gpgconf.conf}).
@item --check-config [@var{filename}]
Run a syntax check ion the global configuration file. If @var{filename}
Run a syntax check on the global configuration file. If @var{filename}
is given, check that file instead.
@end table

View File

@ -755,7 +755,7 @@ static void
finish_page (void)
{
FILE *fp;
section_buffer_t sect;
section_buffer_t sect = NULL;
int idx;
const char *s;
int i;

View File

@ -1,3 +1,21 @@
2007-06-06 Werner Koch <wk@g10code.com>
* passphrase.c (passphrase_get) [!ENABLE_NLS]: Do not define
orig_codeset.
* Makefile.am (gpgv2_LDADD, gpg2_LDADD): Include LDADD before
libgcrypt.
* plaintext.c (handle_plaintext): Replace eof by eof_seen as W32's
io.h has a symbol with that name.
* misc.c: Do not include dynload.h.
(w32_shgetfolderpath): Remove. It is now in common/homedir.c.
* gpgv.c (i18n_init): Remove.
* gpg.c (i18n_init): Remove.
(main): Make --load-extension a dummy
2007-05-19 Marcus Brinkmann <marcus@g10code.de>
* passphrase.c (passphrase_get): Use PACKAGE_GT, not PACKAGE.

View File

@ -119,9 +119,9 @@ gpgv2_SOURCES = gpgv.c \
LDADD = $(needed_libs) ../common/libgpgrl.a \
$(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \
$(LIBINTL) $(CAPLIBS) $(NETLIBS)
gpg2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
gpg2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS)$(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
$(LIBICONV)
gpgv2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
$(LIBICONV)
$(PROGRAMS): $(needed_libs) ../common/libgpgrl.a

View File

@ -870,20 +870,6 @@ build_list( const char *text, char letter,
}
static void
i18n_init(void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file (PACKAGE_GT, "Software\\GNU\\GnuPG");
#else
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT);
#endif
#endif
}
static void
wrong_args( const char *text)
{
@ -2260,18 +2246,8 @@ main (int argc, char **argv )
}
break;
case oLoadExtension:
#ifndef __riscos__
#if defined(USE_DYNAMIC_LINKING) || defined(_WIN32)
if(check_permissions(pargs.r.ret_str,2))
log_info(_("cipher extension `%s' not loaded due to"
" unsafe permissions\n"),pargs.r.ret_str);
else
register_cipher_extension(orig_argc? *orig_argv:NULL,
pargs.r.ret_str);
#endif
#else /* __riscos__ */
riscos_not_implemented("load-extension");
#endif /* __riscos__ */
/* Dummy so that gpg 1.4 conf files can work. Should
eventually be removed. */
break;
case oRFC1991:
opt.compliance = CO_RFC1991;

View File

@ -110,21 +110,6 @@ my_strusage( int level )
}
static void
i18n_init(void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file (PACKAGE_GT, "Software\\GNU\\GnuPG");
#else
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT);
#endif
#endif
}
int
main( int argc, char **argv )

View File

@ -58,7 +58,6 @@
#include "gpg.h"
#ifdef HAVE_W32_SYSTEM
# include "errors.h"
# include "dynload.h"
#endif /*HAVE_W32_SYSTEM*/
#include "util.h"
#include "main.h"
@ -1225,46 +1224,6 @@ is_valid_mailbox (const char *name)
}
/* This is a helper function to load a Windows function from either of
one DLLs. */
#ifdef HAVE_W32_SYSTEM
static HRESULT
w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e)
{
static int initialized;
static HRESULT (WINAPI * func)(HWND,int,HANDLE,DWORD,LPSTR);
if (!initialized)
{
static char *dllnames[] = { "shell32.dll", "shfolder.dll", NULL };
void *handle;
int i;
initialized = 1;
for (i=0, handle = NULL; !handle && dllnames[i]; i++)
{
handle = dlopen (dllnames[i], RTLD_LAZY);
if (handle)
{
func = dlsym (handle, "SHGetFolderPathA");
if (!func)
{
dlclose (handle);
handle = NULL;
}
}
}
}
if (func)
return func (a,b,c,d,e);
else
return -1;
}
#endif /*HAVE_W32_SYSTEM*/
/* Return the name of the libexec directory. The name is allocated in
a static area on the first use. This function won't fail. */
const char *

View File

@ -259,7 +259,9 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid,
PKT_public_key *pk = xmalloc_clear( sizeof *pk );
byte fpr[MAX_FINGERPRINT_LEN];
int have_fpr = 0;
#ifdef ENABLE_NLS
char *orig_codeset = NULL;
#endif
char *my_prompt;
char hexfprbuf[20*2+1];
const char *my_cacheid;

View File

@ -297,8 +297,9 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
else { /* binary mode */
byte *buffer = xmalloc( 32768 );
int eof;
for( eof=0; !eof; ) {
int eof_seen = 0;
while ( !eof_seen ) {
/* Why do we check for len < 32768:
* If we won't, we would practically read 2 EOFs but
* the first one has already popped the block_filter
@ -309,7 +310,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
if( len == -1 )
break;
if( len < 32768 )
eof = 1;
eof_seen = 1;
if( mfx->md )
gcry_md_write ( mfx->md, buffer, len );
if( fp )

View File

@ -1,41 +1,46 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
# Copyright (C) 2004 Free Software Foundation, Inc.
# Copyright (C) 2004-2006 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Automake, under
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Invoked as: gnulib-tool --import
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=scripts alloca-opt allocsa mkdtemp setenv strpbrk vasnprintf vasprintf xsize
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=scripts --no-libtool --macro-prefix=gl alloca-opt allocsa mkdtemp setenv strpbrk xsize
AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
AUTOMAKE_OPTIONS = 1.5 gnits
noinst_LIBRARIES = libgnu.a
libgnu_a_SOURCES =
libgnu_a_LIBADD = @LIBOBJS@
libgnu_a_LIBADD = $(LIBOBJS)
noinst_HEADERS =
EXTRA_DIST =
BUILT_SOURCES =
SUFFIXES =
MOSTLYCLEANFILES =
MOSTLYCLEANFILES = core *.stackdump
MOSTLYCLEANDIRS =
CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
AM_CPPFLAGS =
## begin gnulib module alloca-opt
BUILT_SOURCES += $(ALLOCA_H)
EXTRA_DIST += alloca_.h
# We need the following in order to create an <alloca.h> when the system
# We need the following in order to create <alloca.h> when the system
# doesn't have one that works with the given compiler.
all-local $(libgnu_a_OBJECTS): $(ALLOCA_H)
alloca.h: alloca_.h
cp $(srcdir)/alloca_.h $@-t
mv $@-t $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
cat $(srcdir)/alloca_.h; \
} > $@-t
mv -f $@-t $@
MOSTLYCLEANFILES += alloca.h alloca.h-t
## end gnulib module alloca-opt
@ -59,6 +64,71 @@ libgnu_a_SOURCES += setenv.h
## end gnulib module setenv
## begin gnulib module size_max
libgnu_a_SOURCES += size_max.h
## end gnulib module size_max
## begin gnulib module stdint
BUILT_SOURCES += $(STDINT_H)
EXTRA_DIST += stdint_.h
# We need the following in order to create <stdint.h> when the system
# doesn't have one that works with the given compiler.
stdint.h: stdint_.h
rm -f $@-t $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
-e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
-e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \
-e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
-e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
-e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
-e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
-e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
-e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
-e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
-e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
-e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
-e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
-e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
-e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
-e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
< $(srcdir)/stdint_.h; \
} > $@-t
mv $@-t $@
MOSTLYCLEANFILES += stdint.h stdint.h-t
## end gnulib module stdint
## begin gnulib module strpbrk
libgnu_a_SOURCES += strpbrk.h
## end gnulib module strpbrk
## begin gnulib module unistd
BUILT_SOURCES += $(UNISTD_H)
# We need the following in order to create an empty placeholder for
# <unistd.h> when the system doesn't have one.
unistd.h:
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
echo '/* Empty placeholder for $@. */'; \
} > $@
MOSTLYCLEANFILES += unistd.h
## end gnulib module unistd
## begin gnulib module xsize
libgnu_a_SOURCES += xsize.h
@ -66,4 +136,10 @@ libgnu_a_SOURCES += xsize.h
## end gnulib module xsize
# Makefile.am ends here
mostlyclean-local: mostlyclean-generic
@test -z "$(MOSTLYCLEANDIRS)" || \
for dir in $(MOSTLYCLEANDIRS); do \
if test -d $$dir; then \
echo "rmdir $$dir"; rmdir $$dir; \
fi; \
done

View File

@ -1,6 +1,6 @@
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004 Free Software
Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004, 2006 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
@ -34,19 +34,21 @@
request, the program just crashes.
*/
#ifdef __GNUC__
# define alloca __builtin_alloca
#elif defined _AIX
# define alloca __alloca
#elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
#else
# include <stddef.h>
# ifdef __cplusplus
#ifndef alloca
# ifdef __GNUC__
# define alloca __builtin_alloca
# elif defined _AIX
# define alloca __alloca
# elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
# else
# include <stddef.h>
# ifdef __cplusplus
extern "C"
# endif
# endif
void *alloca (size_t);
# endif
#endif
#endif /* _GNULIB_ALLOCA_H */

View File

@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2006 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
@ -16,9 +16,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <config.h>
/* Specification. */
#include "allocsa.h"

View File

@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
Copyright (C) 2003-2004 Free Software Foundation, Inc.
Copyright (C) 2003-2006 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
@ -23,6 +23,12 @@
#include <stddef.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
alloca(N); otherwise it returns NULL. It either returns N bytes of
memory allocated on the stack, that lasts until the function returns,
@ -69,6 +75,11 @@ extern void freesa (void *p);
If this would be useful in your application. please speak up. */
#ifdef __cplusplus
}
#endif
/* ------------------- Auxiliary, non-public definitions ------------------- */
/* Determine the alignment of a type at compile time. */
@ -81,6 +92,10 @@ extern void freesa (void *p);
/* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
values. */
# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
#elif defined _AIX
/* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
values. */
# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
#else
# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
#endif

44
gl/m4/absolute-header.m4 Normal file
View File

@ -0,0 +1,44 @@
# absolute-header.m4 serial 6
dnl Copyright (C) 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Derek Price.
# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
# ---------------------------------------
# Find the absolute name of a header file, assuming the header exists.
# If the header were sys/inttypes.h, this macro would define
# ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h
# in config.h
# (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
# The three "///" are to pacify Sun C 5.8, which otherwise would say
# "warning: #include of /usr/include/... may be non-portable".
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
AC_DEFUN([gl_ABSOLUTE_HEADER],
[AC_LANG_PREPROC_REQUIRE()dnl
AC_FOREACH([gl_HEADER_NAME], [$1],
[AS_VAR_PUSHDEF([gl_absolute_header],
[gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
AC_CACHE_CHECK([absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
m4_quote(m4_defn([gl_absolute_header])),
[AS_VAR_PUSHDEF([ac_header_exists],
[ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
if test AS_VAR_GET(ac_header_exists) = yes; then
AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
dnl eval is necessary to expand ac_cpp.
dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
AS_VAR_SET(gl_absolute_header,
[`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#;s#^/[^/]#//&#;p;q;}'`])
fi
AS_VAR_POPDEF([ac_header_exists])dnl
])dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_quote(m4_defn([gl_HEADER_NAME]))),
["AS_VAR_GET(gl_absolute_header)"],
[Define this to an absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
AS_VAR_POPDEF([gl_absolute_header])dnl
])dnl
])# gl_ABSOLUTE_HEADER

View File

@ -1,64 +0,0 @@
# eoverflow.m4 serial 1
dnl Copyright (C) 2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
# POSIX. But some systems (like AIX 3) don't define it, and some systems
# (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
# Define EOVERFLOW as a C macro and as a substituted macro in such a way that
# 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
# 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
# value.
AC_DEFUN([gl_EOVERFLOW],
[
AC_REQUIRE([AC_PROG_CC])dnl
AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
AC_EGREP_CPP(yes,[
#include <errno.h>
#ifdef EOVERFLOW
yes
#endif
], have_eoverflow=1)
if test -n "$have_eoverflow"; then
dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves.
ac_cv_decl_EOVERFLOW=yes
else
AC_EGREP_CPP(yes,[
#define _XOPEN_SOURCE_EXTENDED 1
#include <errno.h>
#ifdef EOVERFLOW
yes
#endif
], have_eoverflow=1)
if test -n "$have_eoverflow"; then
dnl EOVERFLOW exists but is hidden.
dnl Define it to the same value.
_AC_COMPUTE_INT([EOVERFLOW], ac_cv_decl_EOVERFLOW, [
#define _XOPEN_SOURCE_EXTENDED 1
#include <errno.h>
/* The following two lines are a workaround against an autoconf-2.52 bug. */
#include <stdio.h>
#include <stdlib.h>
])
else
dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but
dnl don't define it as EINVAL, because snprintf() callers want to
dnl distinguish EINVAL and EOVERFLOW.
ac_cv_decl_EOVERFLOW=E2BIG
fi
fi
])
if test "$ac_cv_decl_EOVERFLOW" != yes; then
AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
[Define as good substitute value for EOVERFLOW.])
EOVERFLOW="$ac_cv_decl_EOVERFLOW"
AC_SUBST(EOVERFLOW)
fi
])

30
gl/m4/gnulib-cache.m4 Normal file
View File

@ -0,0 +1,30 @@
# Copyright (C) 2004-2006 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# This file represents the specification of how gnulib-tool is used.
# It acts as a cache: It is written and read by gnulib-tool.
# In projects using CVS, this file is meant to be stored in CVS,
# like the configure.ac and various Makefile.am files.
# Specification in the form of a command-line invocation:
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=scripts --no-libtool --macro-prefix=gl alloca-opt allocsa mkdtemp setenv strpbrk xsize
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([alloca-opt allocsa mkdtemp setenv strpbrk xsize])
gl_AVOID([])
gl_SOURCE_BASE([gl])
gl_M4_BASE([gl/m4])
gl_DOC_BASE([doc])
gl_TESTS_BASE([tests])
gl_LIB([libgnu])
gl_MAKEFILE_NAME([])
gl_MACRO_PREFIX([gl])

83
gl/m4/gnulib-comp.m4 Normal file
View File

@ -0,0 +1,83 @@
# DO NOT EDIT! GENERATED AUTOMATICALLY!
# Copyright (C) 2004-2006 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# This file represents the compiled summary of the specification in
# gnulib-cache.m4. It lists the computed macro invocations that need
# to be invoked from configure.ac.
# In projects using CVS, this file can be treated like other built files.
# This macro should be invoked from ./configure.ac, in the section
# "Checks for programs", right after AC_PROG_CC, and certainly before
# any checks for libraries, header files, types and library functions.
AC_DEFUN([gl_EARLY],
[
m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace
m4_pattern_allow([^gl_ES$])dnl a valid locale name
AC_REQUIRE([AC_PROG_RANLIB])
])
# This macro should be invoked from ./configure.ac, in the section
# "Check for header files, types and library functions".
AC_DEFUN([gl_INIT],
[
AM_CONDITIONAL([GL_COND_LIBTOOL], [false])
gl_cond_libtool=false
gl_libdeps=
gl_ltlibdeps=
gl_source_base='gl'
gl_FUNC_ALLOCA
gl_ALLOCSA
gt_FUNC_MKDTEMP
gt_FUNC_SETENV
gl_SIZE_MAX
gl_STDINT_H
gl_FUNC_STRPBRK
gl_HEADER_UNISTD
gl_XSIZE
LIBGNU_LIBDEPS="$gl_libdeps"
AC_SUBST([LIBGNU_LIBDEPS])
LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
AC_SUBST([LIBGNU_LTLIBDEPS])
])
# This macro records the list of files which have been installed by
# gnulib-tool and may be removed by future gnulib-tool invocations.
AC_DEFUN([gl_FILE_LIST], [
lib/alloca_.h
lib/allocsa.c
lib/allocsa.h
lib/allocsa.valgrind
lib/mkdtemp.c
lib/mkdtemp.h
lib/setenv.c
lib/setenv.h
lib/size_max.h
lib/stdint_.h
lib/strpbrk.c
lib/strpbrk.h
lib/unsetenv.c
lib/xsize.h
m4/absolute-header.m4
m4/alloca.m4
m4/allocsa.m4
m4/eealloc.m4
m4/longdouble.m4
m4/longlong.m4
m4/mkdtemp.m4
m4/setenv.m4
m4/size_max.m4
m4/stdint.m4
m4/strpbrk.m4
m4/ulonglong.m4
m4/unistd_h.m4
m4/xsize.m4
])

33
gl/m4/gnulib-tool.m4 Normal file
View File

@ -0,0 +1,33 @@
# gnulib-tool.m4 serial 1
dnl Copyright (C) 2004-2005 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl The following macros need not be invoked explicitly.
dnl Invoking them does nothing except to declare default arguments
dnl for "gnulib-tool --import".
dnl Usage: gl_MODULES([module1 module2 ...])
AC_DEFUN([gl_MODULES], [])
dnl Usage: gl_AVOID([module1 module2 ...])
AC_DEFUN([gl_AVOID], [])
dnl Usage: gl_SOURCE_BASE([DIR])
AC_DEFUN([gl_SOURCE_BASE], [])
dnl Usage: gl_M4_BASE([DIR])
AC_DEFUN([gl_M4_BASE], [])
dnl Usage: gl_LIB([LIBNAME])
AC_DEFUN([gl_LIB], [])
dnl Usage: gl_LGPL
AC_DEFUN([gl_LGPL], [])
dnl Usage: gl_LIBTOOL
AC_DEFUN([gl_LIBTOOL], [])
dnl Usage: gl_MACRO_PREFIX([PREFIX])
AC_DEFUN([gl_MACRO_PREFIX], [])

View File

@ -1,44 +0,0 @@
# Copyright (C) 2004 Free Software Foundation, Inc.
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# Invoked as: gnulib-tool --import
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=scripts alloca-opt allocsa mkdtemp setenv strpbrk vasnprintf vasprintf xsize
AC_DEFUN([gl_EARLY],
[
AC_GNU_SOURCE
])
AC_DEFUN([gl_INIT],
[
gl_FUNC_ALLOCA
gl_ALLOCSA
gt_FUNC_MKDTEMP
gt_FUNC_SETENV
gl_FUNC_VASNPRINTF
gl_FUNC_VASPRINTF
gl_XSIZE
])
dnl Usage: gl_MODULES(module1 module2 ...)
AC_DEFUN([gl_MODULES], [])
dnl Usage: gl_SOURCE_BASE(DIR)
AC_DEFUN([gl_SOURCE_BASE], [])
dnl Usage: gl_M4_BASE(DIR)
AC_DEFUN([gl_M4_BASE], [])
dnl Usage: gl_LIB(LIBNAME)
AC_DEFUN([gl_LIB], [])
dnl Usage: gl_LGPL
AC_DEFUN([gl_LGPL], [])
# gnulib.m4 ends here

View File

@ -1,61 +0,0 @@
# intmax_t.m4 serial 4
dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
AC_PREREQ(2.13)
# Define intmax_t to 'long' or 'long long'
# if it is not already defined in <stdint.h> or <inttypes.h>.
AC_DEFUN([gl_AC_TYPE_INTMAX_T],
[
dnl For simplicity, we assume that a header file defines 'intmax_t' if and
dnl only if it defines 'uintmax_t'.
AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
AC_REQUIRE([gl_AC_HEADER_STDINT_H])
if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
test $ac_cv_type_long_long = yes \
&& ac_type='long long' \
|| ac_type='long'
AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
[Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
else
AC_DEFINE(HAVE_INTMAX_T, 1,
[Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
fi
])
dnl An alternative would be to explicitly test for 'intmax_t'.
AC_DEFUN([gt_AC_TYPE_INTMAX_T],
[
AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
AC_REQUIRE([gl_AC_HEADER_STDINT_H])
AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t,
[AC_TRY_COMPILE([
#include <stddef.h>
#include <stdlib.h>
#if HAVE_STDINT_H_WITH_UINTMAX
#include <stdint.h>
#endif
#if HAVE_INTTYPES_H_WITH_UINTMAX
#include <inttypes.h>
#endif
], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
if test $gt_cv_c_intmax_t = yes; then
AC_DEFINE(HAVE_INTMAX_T, 1,
[Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
else
AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
test $ac_cv_type_long_long = yes \
&& ac_type='long long' \
|| ac_type='long'
AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
[Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
fi
])

View File

@ -1,26 +0,0 @@
# inttypes_h.m4 serial 6
dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
# doesn't clash with <sys/types.h>, and declares uintmax_t.
AC_DEFUN([gl_AC_HEADER_INTTYPES_H],
[
AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <inttypes.h>],
[uintmax_t i = (uintmax_t) -1;],
gl_cv_header_inttypes_h=yes,
gl_cv_header_inttypes_h=no)])
if test $gl_cv_header_inttypes_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
[Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
and declares uintmax_t. ])
fi
])

View File

@ -1,5 +1,5 @@
# longdouble.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
# longdouble.m4 serial 2 (gettext-0.15)
dnl Copyright (C) 2002-2003, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@ -8,6 +8,9 @@ dnl From Bruno Haible.
dnl Test whether the compiler supports the 'long double' type.
dnl Prerequisite: AC_PROG_CC
dnl This file is only needed in autoconf <= 2.59. Newer versions of autoconf
dnl have a macro AC_TYPE_LONG_DOUBLE with identical semantics.
AC_DEFUN([gt_TYPE_LONGDOUBLE],
[
AC_CACHE_CHECK([for long double], gt_cv_c_long_double,

View File

@ -1,23 +0,0 @@
# longlong.m4 serial 5
dnl Copyright (C) 1999-2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
# Define HAVE_LONG_LONG if 'long long' works.
AC_DEFUN([gl_AC_TYPE_LONG_LONG],
[
AC_CACHE_CHECK([for long long], ac_cv_type_long_long,
[AC_TRY_LINK([long long ll = 1LL; int i = 63;],
[long long llmax = (long long) -1;
return ll << i | ll >> i | llmax / ll | llmax % ll;],
ac_cv_type_long_long=yes,
ac_cv_type_long_long=no)])
if test $ac_cv_type_long_long = yes; then
AC_DEFINE(HAVE_LONG_LONG, 1,
[Define if you have the 'long long' type.])
fi
])

View File

@ -1,5 +1,5 @@
# mkdtemp.m4 serial 3
dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
# mkdtemp.m4 serial 4
dnl Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@ -18,6 +18,5 @@ AC_DEFUN([gl_PREREQ_MKDTEMP],
AC_REQUIRE([AC_HEADER_STAT])
AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
AC_CHECK_HEADERS(time.h)
AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
AC_CHECK_FUNCS(gettimeofday)
])

View File

@ -1,86 +0,0 @@
# onceonly_2_57.m4 serial 3
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl This file defines some "once only" variants of standard autoconf macros.
dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
dnl AC_REQUIRE([AC_HEADER_STDC]) like AC_HEADER_STDC
dnl The advantage is that the check for each of the headers/functions/decls
dnl will be put only once into the 'configure' file. It keeps the size of
dnl the 'configure' file down, and avoids redundant output when 'configure'
dnl is run.
dnl The drawback is that the checks cannot be conditionalized. If you write
dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
dnl empty, and the check will be inserted before the body of the AC_DEFUNed
dnl function.
dnl This is like onceonly.m4, except that it uses diversions to named sections
dnl DEFAULTS and INIT_PREPARE in order to check all requested headers at once,
dnl thus reducing the size of 'configure'. Works with autoconf-2.57. The
dnl size reduction is ca. 9%.
dnl Autoconf version 2.57 or newer is recommended.
AC_PREREQ(2.54)
# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
:
AC_FOREACH([gl_HEADER_NAME], [$1], [
AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
[./-], [___])), [
m4_divert_text([INIT_PREPARE],
[gl_header_list="$gl_header_list gl_HEADER_NAME"])
gl_HEADERS_EXPANSION
AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
[Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
])
AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
[./-], [___])))
])
])
m4_define([gl_HEADERS_EXPANSION], [
m4_divert_text([DEFAULTS], [gl_header_list=])
AC_CHECK_HEADERS([$gl_header_list])
m4_define([gl_HEADERS_EXPANSION], [])
])
# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
:
AC_FOREACH([gl_FUNC_NAME], [$1], [
AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
m4_divert_text([INIT_PREPARE],
[gl_func_list="$gl_func_list gl_FUNC_NAME"])
gl_FUNCS_EXPANSION
AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
[Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.])
])
AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
])
])
m4_define([gl_FUNCS_EXPANSION], [
m4_divert_text([DEFAULTS], [gl_func_list=])
AC_CHECK_FUNCS([$gl_func_list])
m4_define([gl_FUNCS_EXPANSION], [])
])
# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
# AC_CHECK_DECLS(DECL1, DECL2, ...).
AC_DEFUN([AC_CHECK_DECLS_ONCE], [
:
AC_FOREACH([gl_DECL_NAME], [$1], [
AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
])
AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
])
])

View File

@ -1,5 +1,5 @@
# setenv.m4 serial 5
dnl Copyright (C) 2001-2004 Free Software Foundation, Inc.
# setenv.m4 serial 6
dnl Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@ -57,7 +57,6 @@ AC_DEFUN([gl_PREREQ_SETENV],
AC_CHECK_HEADERS_ONCE(unistd.h)
AC_CHECK_HEADERS(search.h)
AC_CHECK_FUNCS(tsearch)
gt_CHECK_VAR_DECL([#include <errno.h>], errno)
gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
])
@ -65,6 +64,5 @@ AC_DEFUN([gl_PREREQ_SETENV],
AC_DEFUN([gl_PREREQ_UNSETENV],
[
AC_CHECK_HEADERS_ONCE(unistd.h)
gt_CHECK_VAR_DECL([#include <errno.h>], errno)
gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
])

View File

@ -1,17 +0,0 @@
# signed.m4 serial 1 (gettext-0.10.40)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_DEFUN([bh_C_SIGNED],
[
AC_CACHE_CHECK([for signed], bh_cv_c_signed,
[AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)])
if test $bh_cv_c_signed = no; then
AC_DEFINE(signed, ,
[Define to empty if the C compiler doesn't support this keyword.])
fi
])

View File

@ -1,5 +1,5 @@
# size_max.m4 serial 2
dnl Copyright (C) 2003 Free Software Foundation, Inc.
# size_max.m4 serial 4
dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@ -23,32 +23,33 @@ Found it
], result=yes)
if test -z "$result"; then
dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
dnl than the type 'unsigned long'.
dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr',
dnl which is guaranteed to work from LONG_MIN to LONG_MAX.
_AC_COMPUTE_INT([~(size_t)0 / 10], res_hi,
[#include <stddef.h>], result=?)
_AC_COMPUTE_INT([~(size_t)0 % 10], res_lo,
[#include <stddef.h>], result=?)
dnl than the type 'unsigned long'. Try hard to find a definition that can
dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
_AC_COMPUTE_INT([sizeof (size_t) * CHAR_BIT - 1], size_t_bits_minus_1,
[#include <stddef.h>
#include <limits.h>], size_t_bits_minus_1=)
_AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint,
[#include <stddef.h>], result=?)
if test "$fits_in_uint" = 1; then
dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
AC_TRY_COMPILE([#include <stddef.h>
extern size_t foo;
extern unsigned long foo;
], [], fits_in_uint=0)
fi
if test -z "$result"; then
if test "$fits_in_uint" = 1; then
result="$res_hi$res_lo"U
[#include <stddef.h>], fits_in_uint=)
if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
if test $fits_in_uint = 1; then
dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
AC_TRY_COMPILE([#include <stddef.h>
extern size_t foo;
extern unsigned long foo;
], [], fits_in_uint=0)
fi
dnl We cannot use 'expr' to simplify this expression, because 'expr'
dnl works only with 'long' integers in the host environment, while we
dnl might be cross-compiling from a 32-bit platform to a 64-bit platform.
if test $fits_in_uint = 1; then
result="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)"
else
result="$res_hi$res_lo"UL
result="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)"
fi
else
dnl Shouldn't happen, but who knows...
result='~(size_t)0'
result='((size_t)~(size_t)0)'
fi
fi
AC_MSG_RESULT([$result])

368
gl/m4/stdint.m4 Normal file
View File

@ -0,0 +1,368 @@
# stdint.m4 serial 19
dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert and Bruno Haible.
dnl Test whether <stdint.h> is supported or must be substituted.
AC_DEFUN([gl_STDINT_H],
[
AC_PREREQ(2.59)dnl
dnl Check for long long int and unsigned long long int.
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
if test $ac_cv_type_long_long_int = yes; then
HAVE_LONG_LONG_INT=1
else
HAVE_LONG_LONG_INT=0
fi
AC_SUBST([HAVE_LONG_LONG_INT])
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
if test $ac_cv_type_unsigned_long_long_int = yes; then
HAVE_UNSIGNED_LONG_LONG_INT=1
else
HAVE_UNSIGNED_LONG_LONG_INT=0
fi
AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
dnl Check for <wchar.h>.
AC_CHECK_HEADERS_ONCE([wchar.h])
if test $ac_cv_header_wchar_h = yes; then
HAVE_WCHAR_H=1
else
HAVE_WCHAR_H=0
fi
AC_SUBST([HAVE_WCHAR_H])
dnl Check for <inttypes.h>.
dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
if test $ac_cv_header_inttypes_h = yes; then
HAVE_INTTYPES_H=1
else
HAVE_INTTYPES_H=0
fi
AC_SUBST([HAVE_INTTYPES_H])
dnl Check for <sys/types.h>.
dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h.
if test $ac_cv_header_sys_types_h = yes; then
HAVE_SYS_TYPES_H=1
else
HAVE_SYS_TYPES_H=0
fi
AC_SUBST([HAVE_SYS_TYPES_H])
dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_stdint_h.
if test $ac_cv_header_stdint_h = yes; then
gl_ABSOLUTE_HEADER([stdint.h])
ABSOLUTE_STDINT_H=\"$gl_cv_absolute_stdint_h\"
HAVE_STDINT_H=1
else
ABSOLUTE_STDINT_H=\"no/such/file/stdint.h\"
HAVE_STDINT_H=0
fi
AC_SUBST([ABSOLUTE_STDINT_H])
AC_SUBST([HAVE_STDINT_H])
dnl Now see whether we need a substitute <stdint.h>. Use
dnl ABSOLUTE_STDINT_H, not <stdint.h>, so that it also works during
dnl a "config.status --recheck" if a stdint.h has been
dnl created in the build directory.
if test $ac_cv_header_stdint_h = yes; then
AC_CACHE_CHECK([whether stdint.h conforms to C99],
[gl_cv_header_working_stdint_h],
[gl_cv_header_working_stdint_h=no
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <stddef.h>
#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
#include ABSOLUTE_STDINT_H
#ifdef INT8_MAX
int8_t a1 = INT8_MAX;
int8_t a1min = INT8_MIN;
#endif
#ifdef INT16_MAX
int16_t a2 = INT16_MAX;
int16_t a2min = INT16_MIN;
#endif
#ifdef INT32_MAX
int32_t a3 = INT32_MAX;
int32_t a3min = INT32_MIN;
#endif
#ifdef INT64_MAX
int64_t a4 = INT64_MAX;
int64_t a4min = INT64_MIN;
#endif
#ifdef UINT8_MAX
uint8_t b1 = UINT8_MAX;
#else
typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
#endif
#ifdef UINT16_MAX
uint16_t b2 = UINT16_MAX;
#endif
#ifdef UINT32_MAX
uint32_t b3 = UINT32_MAX;
#endif
#ifdef UINT64_MAX
uint64_t b4 = UINT64_MAX;
#endif
int_least8_t c1 = INT8_C (0x7f);
int_least8_t c1max = INT_LEAST8_MAX;
int_least8_t c1min = INT_LEAST8_MIN;
int_least16_t c2 = INT16_C (0x7fff);
int_least16_t c2max = INT_LEAST16_MAX;
int_least16_t c2min = INT_LEAST16_MIN;
int_least32_t c3 = INT32_C (0x7fffffff);
int_least32_t c3max = INT_LEAST32_MAX;
int_least32_t c3min = INT_LEAST32_MIN;
int_least64_t c4 = INT64_C (0x7fffffffffffffff);
int_least64_t c4max = INT_LEAST64_MAX;
int_least64_t c4min = INT_LEAST64_MIN;
uint_least8_t d1 = UINT8_C (0xff);
uint_least8_t d1max = UINT_LEAST8_MAX;
uint_least16_t d2 = UINT16_C (0xffff);
uint_least16_t d2max = UINT_LEAST16_MAX;
uint_least32_t d3 = UINT32_C (0xffffffff);
uint_least32_t d3max = UINT_LEAST32_MAX;
uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
uint_least64_t d4max = UINT_LEAST64_MAX;
int_fast8_t e1 = INT_FAST8_MAX;
int_fast8_t e1min = INT_FAST8_MIN;
int_fast16_t e2 = INT_FAST16_MAX;
int_fast16_t e2min = INT_FAST16_MIN;
int_fast32_t e3 = INT_FAST32_MAX;
int_fast32_t e3min = INT_FAST32_MIN;
int_fast64_t e4 = INT_FAST64_MAX;
int_fast64_t e4min = INT_FAST64_MIN;
uint_fast8_t f1 = UINT_FAST8_MAX;
uint_fast16_t f2 = UINT_FAST16_MAX;
uint_fast32_t f3 = UINT_FAST32_MAX;
uint_fast64_t f4 = UINT_FAST64_MAX;
#ifdef INTPTR_MAX
intptr_t g = INTPTR_MAX;
intptr_t gmin = INTPTR_MIN;
#endif
#ifdef UINTPTR_MAX
uintptr_t h = UINTPTR_MAX;
#endif
intmax_t i = INTMAX_MAX;
uintmax_t j = UINTMAX_MAX;
struct s {
int check_PTRDIFF: PTRDIFF_MIN < 0 && 0 < PTRDIFF_MAX ? 1 : -1;
int check_SIG_ATOMIC: SIG_ATOMIC_MIN <= 0 && 0 < SIG_ATOMIC_MAX ? 1 : -1;
int check_SIZE: 0 < SIZE_MAX ? 1 : -1;
int check_WCHAR: WCHAR_MIN <= 0 && 0 < WCHAR_MAX ? 1 : -1;
int check_WINT: WINT_MIN <= 0 && 0 < WINT_MAX ? 1 : -1;
/* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */
int check_UINT8_C:
(-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
int check_UINT16_C:
(-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
/* Detect bugs in OpenBSD 3.9 stdint.h. */
#ifdef UINT8_MAX
int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
#endif
#ifdef UINT16_MAX
int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
#endif
#ifdef UINT32_MAX
int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
#endif
#ifdef UINT64_MAX
int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
#endif
int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
};
]])],
[gl_cv_header_working_stdint_h=yes])])
fi
if test "$gl_cv_header_working_stdint_h" != yes; then
dnl Check for <sys/inttypes.h>, and for
dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
if test $ac_cv_header_sys_inttypes_h = yes; then
HAVE_SYS_INTTYPES_H=1
else
HAVE_SYS_INTTYPES_H=0
fi
AC_SUBST([HAVE_SYS_INTTYPES_H])
if test $ac_cv_header_sys_bitypes_h = yes; then
HAVE_SYS_BITYPES_H=1
else
HAVE_SYS_BITYPES_H=0
fi
AC_SUBST([HAVE_SYS_BITYPES_H])
gl_STDINT_TYPE_PROPERTIES
STDINT_H=stdint.h
fi
AC_SUBST(STDINT_H)
])
dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
dnl Determine the size of each of the given types in bits.
AC_DEFUN([gl_STDINT_BITSIZEOF],
[
dnl Use a shell loop, to avoid bloating configure, and
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
dnl config.h.in,
dnl - extra AC_SUBST calls, so that the right substitutions are made.
AC_FOREACH([gltype], [$1],
[AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
[Define to the number of bits in type ']gltype['.])])
for gltype in $1 ; do
AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
[_AC_COMPUTE_INT([sizeof ($gltype) * CHAR_BIT], result,
[$2
#include <limits.h>], [result=unknown])
eval gl_cv_bitsizeof_${gltype}=\$result
])
eval result=\$gl_cv_bitsizeof_${gltype}
if test $result = unknown; then
dnl Use a nonempty default, because some compilers, such as IRIX 5 cc,
dnl do a syntax check even on unused #if conditions and give an error
dnl on valid C code like this:
dnl #if 0
dnl # if > 32
dnl # endif
dnl #endif
result=0
fi
GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
eval BITSIZEOF_${GLTYPE}=\$result
done
AC_FOREACH([gltype], [$1],
[AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
])
dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
dnl Determine the signedness of each of the given types.
dnl Define HAVE_SIGNED_TYPE if type is signed.
AC_DEFUN([gl_CHECK_TYPES_SIGNED],
[
dnl Use a shell loop, to avoid bloating configure, and
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
dnl config.h.in,
dnl - extra AC_SUBST calls, so that the right substitutions are made.
AC_FOREACH([gltype], [$1],
[AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
[Define to 1 if ']gltype[' is a signed integer type.])])
for gltype in $1 ; do
AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([$2[
int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])],
result=yes, result=no)
eval gl_cv_type_${gltype}_signed=\$result
])
eval result=\$gl_cv_type_${gltype}_signed
GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
if test "$result" = yes; then
AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], 1)
eval HAVE_SIGNED_${GLTYPE}=1
else
eval HAVE_SIGNED_${GLTYPE}=0
fi
done
AC_FOREACH([gltype], [$1],
[AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
])
dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
dnl Determine the suffix to use for integer constants of the given types.
dnl Define t_SUFFIX for each such type.
AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
[
dnl Use a shell loop, to avoid bloating configure, and
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
dnl config.h.in,
dnl - extra AC_SUBST calls, so that the right substitutions are made.
AC_FOREACH([gltype], [$1],
[AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
[Define to l, ll, u, ul, ull, etc., as suitable for
constants of type ']gltype['.])])
for gltype in $1 ; do
AC_CACHE_CHECK([for $gltype integer literal suffix],
[gl_cv_type_${gltype}_suffix],
[eval gl_cv_type_${gltype}_suffix=no
eval result=\$gl_cv_type_${gltype}_signed
if test "$result" = yes; then
glsufu=
else
glsufu=u
fi
for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
case $glsuf in
'') gltype1='int';;
l) gltype1='long int';;
ll) gltype1='long long int';;
i64) gltype1='__int64';;
u) gltype1='unsigned int';;
ul) gltype1='unsigned long int';;
ull) gltype1='unsigned long long int';;
ui64)gltype1='unsigned __int64';;
esac
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([$2
extern $gltype foo;
extern $gltype1 foo;])],
[eval gl_cv_type_${gltype}_suffix=\$glsuf])
eval result=\$gl_cv_type_${gltype}_suffix
test "$result" != no && break
done])
GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
eval result=\$gl_cv_type_${gltype}_suffix
test "$result" = no && result=
eval ${GLTYPE}_SUFFIX=\$result
AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], $result)
done
AC_FOREACH([gltype], [$1],
[AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
])
dnl gl_STDINT_INCLUDES
AC_DEFUN([gl_STDINT_INCLUDES],
[[
#include <stddef.h>
#include <signal.h>
#if HAVE_WCHAR_H
/* BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
<wchar.h>. */
# include <stdio.h>
# include <time.h>
# include <wchar.h>
#endif
]])
dnl gl_STDINT_TYPE_PROPERTIES
dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
dnl of interest to stdint_.h.
AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
[
gl_STDINT_BITSIZEOF([ptrdiff_t sig_atomic_t size_t wchar_t wint_t],
[gl_STDINT_INCLUDES])
gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
[gl_STDINT_INCLUDES])
gl_cv_type_ptrdiff_t_signed=yes
gl_cv_type_size_t_signed=no
gl_INTEGER_TYPE_SUFFIX([ptrdiff_t sig_atomic_t size_t wchar_t wint_t],
[gl_STDINT_INCLUDES])
])

View File

@ -1,26 +0,0 @@
# stdint_h.m4 serial 5
dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
# doesn't clash with <sys/types.h>, and declares uintmax_t.
AC_DEFUN([gl_AC_HEADER_STDINT_H],
[
AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <stdint.h>],
[uintmax_t i = (uintmax_t) -1;],
gl_cv_header_stdint_h=yes,
gl_cv_header_stdint_h=no)])
if test $gl_cv_header_stdint_h = yes; then
AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
[Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
and declares uintmax_t. ])
fi
])

16
gl/m4/strpbrk.m4 Normal file
View File

@ -0,0 +1,16 @@
# strpbrk.m4 serial 2
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_STRPBRK],
[
AC_REPLACE_FUNCS(strpbrk)
if test $ac_cv_func_strpbrk = no; then
gl_PREREQ_STRPBRK
fi
])
# Prerequisites of lib/strpbrk.c.
AC_DEFUN([gl_PREREQ_STRPBRK], [:])

View File

@ -1,30 +0,0 @@
# uintmax_t.m4 serial 9
dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
AC_PREREQ(2.13)
# Define uintmax_t to 'unsigned long' or 'unsigned long long'
# if it is not already defined in <stdint.h> or <inttypes.h>.
AC_DEFUN([gl_AC_TYPE_UINTMAX_T],
[
AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
AC_REQUIRE([gl_AC_HEADER_STDINT_H])
if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
AC_REQUIRE([gl_AC_TYPE_UNSIGNED_LONG_LONG])
test $ac_cv_type_unsigned_long_long = yes \
&& ac_type='unsigned long long' \
|| ac_type='unsigned long'
AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
[Define to unsigned long or unsigned long long
if <stdint.h> and <inttypes.h> don't define.])
else
AC_DEFINE(HAVE_UINTMAX_T, 1,
[Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
fi
])

View File

@ -1,23 +0,0 @@
# ulonglong.m4 serial 4
dnl Copyright (C) 1999-2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
# Define HAVE_UNSIGNED_LONG_LONG if 'unsigned long long' works.
AC_DEFUN([gl_AC_TYPE_UNSIGNED_LONG_LONG],
[
AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
[AC_TRY_LINK([unsigned long long ull = 1ULL; int i = 63;],
[unsigned long long ullmax = (unsigned long long) -1;
return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
ac_cv_type_unsigned_long_long=yes,
ac_cv_type_unsigned_long_long=no)])
if test $ac_cv_type_unsigned_long_long = yes; then
AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
[Define if you have the 'unsigned long long' type.])
fi
])

18
gl/m4/unistd_h.m4 Normal file
View File

@ -0,0 +1,18 @@
# unistd_h.m4 serial 2
dnl Copyright (C) 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Written by Simon Josefsson
AC_DEFUN([gl_HEADER_UNISTD],
[
dnl Prerequisites of lib/unistd.h.
AC_CHECK_HEADERS([unistd.h], [
UNISTD_H=''
], [
UNISTD_H='unistd.h'
])
AC_SUBST(UNISTD_H)
])

View File

@ -1,58 +0,0 @@
# vasnprintf.m4 serial 5
dnl Copyright (C) 2002-2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_VASNPRINTF],
[
AC_REQUIRE([gl_EOVERFLOW])
AC_REPLACE_FUNCS(vasnprintf)
if test $ac_cv_func_vasnprintf = no; then
AC_LIBOBJ(printf-args)
AC_LIBOBJ(printf-parse)
AC_LIBOBJ(asnprintf)
gl_PREREQ_PRINTF_ARGS
gl_PREREQ_PRINTF_PARSE
gl_PREREQ_VASNPRINTF
gl_PREREQ_ASNPRINTF
fi
])
# Prequisites of lib/printf-args.h, lib/printf-args.c.
AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
[
AC_REQUIRE([bh_C_SIGNED])
AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
AC_REQUIRE([gt_TYPE_LONGDOUBLE])
AC_REQUIRE([gt_TYPE_WCHAR_T])
AC_REQUIRE([gt_TYPE_WINT_T])
])
# Prequisites of lib/printf-parse.h, lib/printf-parse.c.
AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
[
AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
AC_REQUIRE([gt_TYPE_LONGDOUBLE])
AC_REQUIRE([gt_TYPE_WCHAR_T])
AC_REQUIRE([gt_TYPE_WINT_T])
AC_REQUIRE([AC_TYPE_SIZE_T])
AC_CHECK_TYPES(ptrdiff_t)
AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
])
# Prerequisites of lib/vasnprintf.c.
AC_DEFUN([gl_PREREQ_VASNPRINTF],
[
AC_REQUIRE([AC_FUNC_ALLOCA])
AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
AC_REQUIRE([gt_TYPE_LONGDOUBLE])
AC_REQUIRE([gt_TYPE_WCHAR_T])
AC_REQUIRE([gt_TYPE_WINT_T])
AC_CHECK_FUNCS(snprintf wcslen)
])
# Prerequisites of lib/asnprintf.c.
AC_DEFUN([gl_PREREQ_ASNPRINTF],
[
])

View File

@ -1,25 +0,0 @@
# vasprintf.m4 serial 1
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_VASPRINTF],
[
AC_REPLACE_FUNCS(vasprintf)
if test $ac_cv_func_vasprintf = no; then
AC_LIBOBJ(asprintf)
gl_PREREQ_VASPRINTF
gl_PREREQ_ASPRINTF
fi
])
# Prerequisites of lib/vasprintf.c.
AC_DEFUN([gl_PREREQ_VASPRINTF],
[
])
# Prerequisites of lib/asprintf.c.
AC_DEFUN([gl_PREREQ_ASPRINTF],
[
])

View File

@ -1,20 +0,0 @@
# wchar_t.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl Test whether <stddef.h> has the 'wchar_t' type.
dnl Prerequisite: AC_PROG_CC
AC_DEFUN([gt_TYPE_WCHAR_T],
[
AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t,
[AC_TRY_COMPILE([#include <stddef.h>
wchar_t foo = (wchar_t)'\0';], ,
gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)])
if test $gt_cv_c_wchar_t = yes; then
AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.])
fi
])

View File

@ -1,20 +0,0 @@
# wint_t.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2003 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl Test whether <wchar.h> has the 'wint_t' type.
dnl Prerequisite: AC_PROG_CC
AC_DEFUN([gt_TYPE_WINT_T],
[
AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
[AC_TRY_COMPILE([#include <wchar.h>
wint_t foo = (wchar_t)'\0';], ,
gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
if test $gt_cv_c_wint_t = yes; then
AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
fi
])

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1999, 2001-2003 Free Software Foundation, Inc.
/* Copyright (C) 1999, 2001-2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@ -17,9 +17,7 @@
/* Extracted from misc/mkdtemp.c and sysdeps/posix/tempname.c. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <config.h>
/* Specification. */
#include "mkdtemp.h"
@ -30,6 +28,7 @@
#endif
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -38,16 +37,7 @@
# define TMP_MAX 238328
#endif
#if HAVE_STDINT_H || _LIBC
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if HAVE_UNISTD_H || _LIBC
# include <unistd.h>
#endif
#include <unistd.h>
#if HAVE_GETTIMEOFDAY || _LIBC
# if HAVE_SYS_TIME_H || _LIBC
@ -60,9 +50,6 @@
#endif
#include <sys/stat.h>
#if STAT_MACROS_BROKEN
# undef S_ISDIR
#endif
#if !defined S_ISDIR && defined S_IFDIR
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
@ -86,9 +73,10 @@
#endif
#ifdef __MINGW32__
/* mingw's mkdir() function has 1 argument, but we pass 2 arguments.
# include <io.h>
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
Therefore we have to disable the argument count checking. */
# define mkdir ((int (*)()) mkdir)
# define mkdir ((int (*)()) _mkdir)
#endif
#if !_LIBC
@ -126,9 +114,26 @@ gen_tempname (char *tmpl)
char *XXXXXX;
static uint64_t value;
uint64_t random_time_bits;
int count, fd = -1;
unsigned int count;
int fd = -1;
int save_errno = errno;
/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
can exist for a given template is 62**6. It should never be
necessary to try all these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
give the system administrator the chance to remove the problems. */
#define ATTEMPTS_MIN (62 * 62 * 62)
/* The number of times to attempt to generate a temporary file. To
conform to POSIX, this must be no smaller than TMP_MAX. */
#if ATTEMPTS_MIN < TMP_MAX
unsigned int attempts = TMP_MAX;
#else
unsigned int attempts = ATTEMPTS_MIN;
#endif
len = strlen (tmpl);
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
{
@ -155,7 +160,7 @@ gen_tempname (char *tmpl)
#endif
value += random_time_bits ^ __getpid ();
for (count = 0; count < TMP_MAX; value += 7777, ++count)
for (count = 0; count < attempts; value += 7777, ++count)
{
uint64_t v = value;

View File

@ -1,118 +0,0 @@
/* Decomposed printf argument list.
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* Specification. */
#include "printf-args.h"
#ifdef STATIC
STATIC
#endif
int
printf_fetchargs (va_list args, arguments *a)
{
size_t i;
argument *ap;
for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
switch (ap->type)
{
case TYPE_SCHAR:
ap->a.a_schar = va_arg (args, /*signed char*/ int);
break;
case TYPE_UCHAR:
ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
break;
case TYPE_SHORT:
ap->a.a_short = va_arg (args, /*short*/ int);
break;
case TYPE_USHORT:
ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
break;
case TYPE_INT:
ap->a.a_int = va_arg (args, int);
break;
case TYPE_UINT:
ap->a.a_uint = va_arg (args, unsigned int);
break;
case TYPE_LONGINT:
ap->a.a_longint = va_arg (args, long int);
break;
case TYPE_ULONGINT:
ap->a.a_ulongint = va_arg (args, unsigned long int);
break;
#ifdef HAVE_LONG_LONG
case TYPE_LONGLONGINT:
ap->a.a_longlongint = va_arg (args, long long int);
break;
case TYPE_ULONGLONGINT:
ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
break;
#endif
case TYPE_DOUBLE:
ap->a.a_double = va_arg (args, double);
break;
#ifdef HAVE_LONG_DOUBLE
case TYPE_LONGDOUBLE:
ap->a.a_longdouble = va_arg (args, long double);
break;
#endif
case TYPE_CHAR:
ap->a.a_char = va_arg (args, int);
break;
#ifdef HAVE_WINT_T
case TYPE_WIDE_CHAR:
ap->a.a_wide_char = va_arg (args, wint_t);
break;
#endif
case TYPE_STRING:
ap->a.a_string = va_arg (args, const char *);
break;
#ifdef HAVE_WCHAR_T
case TYPE_WIDE_STRING:
ap->a.a_wide_string = va_arg (args, const wchar_t *);
break;
#endif
case TYPE_POINTER:
ap->a.a_pointer = va_arg (args, void *);
break;
case TYPE_COUNT_SCHAR_POINTER:
ap->a.a_count_schar_pointer = va_arg (args, signed char *);
break;
case TYPE_COUNT_SHORT_POINTER:
ap->a.a_count_short_pointer = va_arg (args, short *);
break;
case TYPE_COUNT_INT_POINTER:
ap->a.a_count_int_pointer = va_arg (args, int *);
break;
case TYPE_COUNT_LONGINT_POINTER:
ap->a.a_count_longint_pointer = va_arg (args, long int *);
break;
#ifdef HAVE_LONG_LONG
case TYPE_COUNT_LONGLONGINT_POINTER:
ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
break;
#endif
default:
/* Unknown type. */
return -1;
}
return 0;
}

View File

@ -1,136 +0,0 @@
/* Decomposed printf argument list.
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _PRINTF_ARGS_H
#define _PRINTF_ARGS_H
/* Get size_t. */
#include <stddef.h>
/* Get wchar_t. */
#ifdef HAVE_WCHAR_T
# include <stddef.h>
#endif
/* Get wint_t. */
#ifdef HAVE_WINT_T
# include <wchar.h>
#endif
/* Get va_list. */
#include <stdarg.h>
/* Argument types */
typedef enum
{
TYPE_NONE,
TYPE_SCHAR,
TYPE_UCHAR,
TYPE_SHORT,
TYPE_USHORT,
TYPE_INT,
TYPE_UINT,
TYPE_LONGINT,
TYPE_ULONGINT,
#ifdef HAVE_LONG_LONG
TYPE_LONGLONGINT,
TYPE_ULONGLONGINT,
#endif
TYPE_DOUBLE,
#ifdef HAVE_LONG_DOUBLE
TYPE_LONGDOUBLE,
#endif
TYPE_CHAR,
#ifdef HAVE_WINT_T
TYPE_WIDE_CHAR,
#endif
TYPE_STRING,
#ifdef HAVE_WCHAR_T
TYPE_WIDE_STRING,
#endif
TYPE_POINTER,
TYPE_COUNT_SCHAR_POINTER,
TYPE_COUNT_SHORT_POINTER,
TYPE_COUNT_INT_POINTER,
TYPE_COUNT_LONGINT_POINTER
#ifdef HAVE_LONG_LONG
, TYPE_COUNT_LONGLONGINT_POINTER
#endif
} arg_type;
/* Polymorphic argument */
typedef struct
{
arg_type type;
union
{
signed char a_schar;
unsigned char a_uchar;
short a_short;
unsigned short a_ushort;
int a_int;
unsigned int a_uint;
long int a_longint;
unsigned long int a_ulongint;
#ifdef HAVE_LONG_LONG
long long int a_longlongint;
unsigned long long int a_ulonglongint;
#endif
float a_float;
double a_double;
#ifdef HAVE_LONG_DOUBLE
long double a_longdouble;
#endif
int a_char;
#ifdef HAVE_WINT_T
wint_t a_wide_char;
#endif
const char* a_string;
#ifdef HAVE_WCHAR_T
const wchar_t* a_wide_string;
#endif
void* a_pointer;
signed char * a_count_schar_pointer;
short * a_count_short_pointer;
int * a_count_int_pointer;
long int * a_count_longint_pointer;
#ifdef HAVE_LONG_LONG
long long int * a_count_longlongint_pointer;
#endif
}
a;
}
argument;
typedef struct
{
size_t count;
argument *arg;
}
arguments;
/* Fetch the arguments, putting them into a. */
#ifdef STATIC
STATIC
#else
extern
#endif
int printf_fetchargs (va_list args, arguments *a);
#endif /* _PRINTF_ARGS_H */

View File

@ -1,536 +0,0 @@
/* Formatted output to strings.
Copyright (C) 1999-2000, 2002-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* Specification. */
#if WIDE_CHAR_VERSION
# include "wprintf-parse.h"
#else
# include "printf-parse.h"
#endif
/* Get size_t, NULL. */
#include <stddef.h>
/* Get intmax_t. */
#if HAVE_STDINT_H_WITH_UINTMAX
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H_WITH_UINTMAX
# include <inttypes.h>
#endif
/* malloc(), realloc(), free(). */
#include <stdlib.h>
/* Checked size_t computations. */
#include "xsize.h"
#if WIDE_CHAR_VERSION
# define PRINTF_PARSE wprintf_parse
# define CHAR_T wchar_t
# define DIRECTIVE wchar_t_directive
# define DIRECTIVES wchar_t_directives
#else
# define PRINTF_PARSE printf_parse
# define CHAR_T char
# define DIRECTIVE char_directive
# define DIRECTIVES char_directives
#endif
#ifdef STATIC
STATIC
#endif
int
PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
{
const CHAR_T *cp = format; /* pointer into format */
size_t arg_posn = 0; /* number of regular arguments consumed */
size_t d_allocated; /* allocated elements of d->dir */
size_t a_allocated; /* allocated elements of a->arg */
size_t max_width_length = 0;
size_t max_precision_length = 0;
d->count = 0;
d_allocated = 1;
d->dir = malloc (d_allocated * sizeof (DIRECTIVE));
if (d->dir == NULL)
/* Out of memory. */
return -1;
a->count = 0;
a_allocated = 0;
a->arg = NULL;
#define REGISTER_ARG(_index_,_type_) \
{ \
size_t n = (_index_); \
if (n >= a_allocated) \
{ \
size_t memory_size; \
argument *memory; \
\
a_allocated = xtimes (a_allocated, 2); \
if (a_allocated <= n) \
a_allocated = xsum (n, 1); \
memory_size = xtimes (a_allocated, sizeof (argument)); \
if (size_overflow_p (memory_size)) \
/* Overflow, would lead to out of memory. */ \
goto error; \
memory = (a->arg \
? realloc (a->arg, memory_size) \
: malloc (memory_size)); \
if (memory == NULL) \
/* Out of memory. */ \
goto error; \
a->arg = memory; \
} \
while (a->count <= n) \
a->arg[a->count++].type = TYPE_NONE; \
if (a->arg[n].type == TYPE_NONE) \
a->arg[n].type = (_type_); \
else if (a->arg[n].type != (_type_)) \
/* Ambiguous type for positional argument. */ \
goto error; \
}
while (*cp != '\0')
{
CHAR_T c = *cp++;
if (c == '%')
{
size_t arg_index = ARG_NONE;
DIRECTIVE *dp = &d->dir[d->count];/* pointer to next directive */
/* Initialize the next directive. */
dp->dir_start = cp - 1;
dp->flags = 0;
dp->width_start = NULL;
dp->width_end = NULL;
dp->width_arg_index = ARG_NONE;
dp->precision_start = NULL;
dp->precision_end = NULL;
dp->precision_arg_index = ARG_NONE;
dp->arg_index = ARG_NONE;
/* Test for positional argument. */
if (*cp >= '0' && *cp <= '9')
{
const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++)
;
if (*np == '$')
{
size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0');
if (n == 0)
/* Positional argument 0. */
goto error;
if (size_overflow_p (n))
/* n too large, would lead to out of memory later. */
goto error;
arg_index = n - 1;
cp = np + 1;
}
}
/* Read the flags. */
for (;;)
{
if (*cp == '\'')
{
dp->flags |= FLAG_GROUP;
cp++;
}
else if (*cp == '-')
{
dp->flags |= FLAG_LEFT;
cp++;
}
else if (*cp == '+')
{
dp->flags |= FLAG_SHOWSIGN;
cp++;
}
else if (*cp == ' ')
{
dp->flags |= FLAG_SPACE;
cp++;
}
else if (*cp == '#')
{
dp->flags |= FLAG_ALT;
cp++;
}
else if (*cp == '0')
{
dp->flags |= FLAG_ZERO;
cp++;
}
else
break;
}
/* Parse the field width. */
if (*cp == '*')
{
dp->width_start = cp;
cp++;
dp->width_end = cp;
if (max_width_length < 1)
max_width_length = 1;
/* Test for positional argument. */
if (*cp >= '0' && *cp <= '9')
{
const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++)
;
if (*np == '$')
{
size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0');
if (n == 0)
/* Positional argument 0. */
goto error;
if (size_overflow_p (n))
/* n too large, would lead to out of memory later. */
goto error;
dp->width_arg_index = n - 1;
cp = np + 1;
}
}
if (dp->width_arg_index == ARG_NONE)
{
dp->width_arg_index = arg_posn++;
if (dp->width_arg_index == ARG_NONE)
/* arg_posn wrapped around. */
goto error;
}
REGISTER_ARG (dp->width_arg_index, TYPE_INT);
}
else if (*cp >= '0' && *cp <= '9')
{
size_t width_length;
dp->width_start = cp;
for (; *cp >= '0' && *cp <= '9'; cp++)
;
dp->width_end = cp;
width_length = dp->width_end - dp->width_start;
if (max_width_length < width_length)
max_width_length = width_length;
}
/* Parse the precision. */
if (*cp == '.')
{
cp++;
if (*cp == '*')
{
dp->precision_start = cp - 1;
cp++;
dp->precision_end = cp;
if (max_precision_length < 2)
max_precision_length = 2;
/* Test for positional argument. */
if (*cp >= '0' && *cp <= '9')
{
const CHAR_T *np;
for (np = cp; *np >= '0' && *np <= '9'; np++)
;
if (*np == '$')
{
size_t n = 0;
for (np = cp; *np >= '0' && *np <= '9'; np++)
n = xsum (xtimes (n, 10), *np - '0');
if (n == 0)
/* Positional argument 0. */
goto error;
if (size_overflow_p (n))
/* n too large, would lead to out of memory
later. */
goto error;
dp->precision_arg_index = n - 1;
cp = np + 1;
}
}
if (dp->precision_arg_index == ARG_NONE)
{
dp->precision_arg_index = arg_posn++;
if (dp->precision_arg_index == ARG_NONE)
/* arg_posn wrapped around. */
goto error;
}
REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
}
else
{
size_t precision_length;
dp->precision_start = cp - 1;
for (; *cp >= '0' && *cp <= '9'; cp++)
;
dp->precision_end = cp;
precision_length = dp->precision_end - dp->precision_start;
if (max_precision_length < precision_length)
max_precision_length = precision_length;
}
}
{
arg_type type;
/* Parse argument type/size specifiers. */
{
int flags = 0;
for (;;)
{
if (*cp == 'h')
{
flags |= (1 << (flags & 1));
cp++;
}
else if (*cp == 'L')
{
flags |= 4;
cp++;
}
else if (*cp == 'l')
{
flags += 8;
cp++;
}
#ifdef HAVE_INTMAX_T
else if (*cp == 'j')
{
if (sizeof (intmax_t) > sizeof (long))
{
/* intmax_t = long long */
flags += 16;
}
else if (sizeof (intmax_t) > sizeof (int))
{
/* intmax_t = long */
flags += 8;
}
cp++;
}
#endif
else if (*cp == 'z' || *cp == 'Z')
{
/* 'z' is standardized in ISO C 99, but glibc uses 'Z'
because the warning facility in gcc-2.95.2 understands
only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
if (sizeof (size_t) > sizeof (long))
{
/* size_t = long long */
flags += 16;
}
else if (sizeof (size_t) > sizeof (int))
{
/* size_t = long */
flags += 8;
}
cp++;
}
else if (*cp == 't')
{
if (sizeof (ptrdiff_t) > sizeof (long))
{
/* ptrdiff_t = long long */
flags += 16;
}
else if (sizeof (ptrdiff_t) > sizeof (int))
{
/* ptrdiff_t = long */
flags += 8;
}
cp++;
}
else
break;
}
/* Read the conversion character. */
c = *cp++;
switch (c)
{
case 'd': case 'i':
#ifdef HAVE_LONG_LONG
if (flags >= 16 || (flags & 4))
type = TYPE_LONGLONGINT;
else
#endif
if (flags >= 8)
type = TYPE_LONGINT;
else if (flags & 2)
type = TYPE_SCHAR;
else if (flags & 1)
type = TYPE_SHORT;
else
type = TYPE_INT;
break;
case 'o': case 'u': case 'x': case 'X':
#ifdef HAVE_LONG_LONG
if (flags >= 16 || (flags & 4))
type = TYPE_ULONGLONGINT;
else
#endif
if (flags >= 8)
type = TYPE_ULONGINT;
else if (flags & 2)
type = TYPE_UCHAR;
else if (flags & 1)
type = TYPE_USHORT;
else
type = TYPE_UINT;
break;
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
case 'a': case 'A':
#ifdef HAVE_LONG_DOUBLE
if (flags >= 16 || (flags & 4))
type = TYPE_LONGDOUBLE;
else
#endif
type = TYPE_DOUBLE;
break;
case 'c':
if (flags >= 8)
#ifdef HAVE_WINT_T
type = TYPE_WIDE_CHAR;
#else
goto error;
#endif
else
type = TYPE_CHAR;
break;
#ifdef HAVE_WINT_T
case 'C':
type = TYPE_WIDE_CHAR;
c = 'c';
break;
#endif
case 's':
if (flags >= 8)
#ifdef HAVE_WCHAR_T
type = TYPE_WIDE_STRING;
#else
goto error;
#endif
else
type = TYPE_STRING;
break;
#ifdef HAVE_WCHAR_T
case 'S':
type = TYPE_WIDE_STRING;
c = 's';
break;
#endif
case 'p':
type = TYPE_POINTER;
break;
case 'n':
#ifdef HAVE_LONG_LONG
if (flags >= 16 || (flags & 4))
type = TYPE_COUNT_LONGLONGINT_POINTER;
else
#endif
if (flags >= 8)
type = TYPE_COUNT_LONGINT_POINTER;
else if (flags & 2)
type = TYPE_COUNT_SCHAR_POINTER;
else if (flags & 1)
type = TYPE_COUNT_SHORT_POINTER;
else
type = TYPE_COUNT_INT_POINTER;
break;
case '%':
type = TYPE_NONE;
break;
default:
/* Unknown conversion character. */
goto error;
}
}
if (type != TYPE_NONE)
{
dp->arg_index = arg_index;
if (dp->arg_index == ARG_NONE)
{
dp->arg_index = arg_posn++;
if (dp->arg_index == ARG_NONE)
/* arg_posn wrapped around. */
goto error;
}
REGISTER_ARG (dp->arg_index, type);
}
dp->conversion = c;
dp->dir_end = cp;
}
d->count++;
if (d->count >= d_allocated)
{
size_t memory_size;
DIRECTIVE *memory;
d_allocated = xtimes (d_allocated, 2);
memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
if (size_overflow_p (memory_size))
/* Overflow, would lead to out of memory. */
goto error;
memory = realloc (d->dir, memory_size);
if (memory == NULL)
/* Out of memory. */
goto error;
d->dir = memory;
}
}
}
d->dir[d->count].dir_start = cp;
d->max_width_length = max_width_length;
d->max_precision_length = max_precision_length;
return 0;
error:
if (a->arg)
free (a->arg);
if (d->dir)
free (d->dir);
return -1;
}
#undef DIRECTIVES
#undef DIRECTIVE
#undef CHAR_T
#undef PRINTF_PARSE

View File

@ -1,74 +0,0 @@
/* Parse printf format string.
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _PRINTF_PARSE_H
#define _PRINTF_PARSE_H
#include "printf-args.h"
/* Flags */
#define FLAG_GROUP 1 /* ' flag */
#define FLAG_LEFT 2 /* - flag */
#define FLAG_SHOWSIGN 4 /* + flag */
#define FLAG_SPACE 8 /* space flag */
#define FLAG_ALT 16 /* # flag */
#define FLAG_ZERO 32
/* arg_index value indicating that no argument is consumed. */
#define ARG_NONE (~(size_t)0)
/* A parsed directive. */
typedef struct
{
const char* dir_start;
const char* dir_end;
int flags;
const char* width_start;
const char* width_end;
size_t width_arg_index;
const char* precision_start;
const char* precision_end;
size_t precision_arg_index;
char conversion; /* d i o u x X f e E g G c s p n U % but not C S */
size_t arg_index;
}
char_directive;
/* A parsed format string. */
typedef struct
{
size_t count;
char_directive *dir;
size_t max_width_length;
size_t max_precision_length;
}
char_directives;
/* Parses the format string. Fills in the number N of directives, and fills
in directives[0], ..., directives[N-1], and sets directives[N].dir_start
to the end of the format string. Also fills in the arg_type fields of the
arguments and the needed count of arguments. */
#ifdef STATIC
STATIC
#else
extern
#endif
int printf_parse (const char *format, char_directives *d, arguments *a);
#endif /* _PRINTF_PARSE_H */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1992,1995-1999,2000-2003 Free Software Foundation, Inc.
/* Copyright (C) 1992,1995-1999,2000-2003,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@ -13,9 +13,9 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
#if !_LIBC
# include <config.h>
#endif
#include <alloca.h>

View File

@ -1,5 +1,6 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
/* size_max.h -- declare SIZE_MAX through system headers
Copyright (C) 2005-2006 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -11,27 +12,20 @@
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 along
with this program; if not, write to the Free Software Foundation,
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef GNULIB_SIZE_MAX_H
#define GNULIB_SIZE_MAX_H
/* Specification. */
#include "vasnprintf.h"
/* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */
# include <limits.h>
/* Get SIZE_MAX declaration on systems like glibc 2. */
# if HAVE_STDINT_H
# include <stdint.h>
# endif
/* On systems where these include files don't define it, SIZE_MAX is defined
in config.h. */
#include <stdarg.h>
char *
asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
{
va_list args;
char *result;
va_start (args, format);
result = vasnprintf (resultbuf, lengthp, format, args);
va_end (args);
return result;
}
#endif /* GNULIB_SIZE_MAX_H */

492
gl/stdint_.h Normal file
View File

@ -0,0 +1,492 @@
/* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
This file is part of gnulib.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _GL_STDINT_H
#define _GL_STDINT_H
/*
* ISO C 99 <stdint.h> for platforms that lack it.
* <http://www.opengroup.org/susv3xbd/stdint.h.html>
*/
/* Get those types that are already defined in other system include
files, so that we can "#define int8_t signed char" below without
worrying about a later system include file containing a "typedef
signed char int8_t;" that will get messed up by our macro. Our
macros should all be consistent with the system versions, except
for the "fast" types and macros, which we recommend against using
in public interfaces due to compiler differences. */
#if @HAVE_STDINT_H@
# if defined __sgi && ! defined __c99
/* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
with "This header file is to be used only for c99 mode compilations"
diagnostics. */
# define __STDINT_H__
# endif
/* Other systems may have an incomplete or buggy <stdint.h>.
Include it before <inttypes.h>, since any "#include <stdint.h>"
in <inttypes.h> would reinclude us, skipping our contents because
_GL_STDINT_H is defined. */
# include @ABSOLUTE_STDINT_H@
#endif
/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
relies on the system <stdint.h> definitions, so include
<sys/types.h> after @ABSOLUTE_STDINT_H@. */
#if @HAVE_SYS_TYPES_H@
# include <sys/types.h>
#endif
/* Get LONG_MIN, LONG_MAX, ULONG_MAX. */
#include <limits.h>
#if @HAVE_INTTYPES_H@
/* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
<inttypes.h> also defines intptr_t and uintptr_t. */
# define _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
# include <inttypes.h>
# undef _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
#elif @HAVE_SYS_INTTYPES_H@
/* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
# include <sys/inttypes.h>
#endif
#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
/* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
included by <sys/types.h>. */
# include <sys/bitypes.h>
#endif
#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
/* Get WCHAR_MIN, WCHAR_MAX. */
# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
/* BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
<wchar.h>. */
# include <stdio.h>
# include <time.h>
# include <wchar.h>
# endif
#endif
/* Minimum and maximum values for a integer type under the usual assumption.
Return an unspecified value if BITS == 0, adding a check to pacify
picky compilers. */
#define _STDINT_MIN(signed, bits, zero) \
((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero))
#define _STDINT_MAX(signed, bits, zero) \
((signed) \
? ~ _STDINT_MIN (signed, bits, zero) \
: ((((zero) + 1) << ((bits) ? (bits) - 1 : 0)) - 1) * 2 + 1)
/* 7.18.1.1. Exact-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. */
#undef int8_t
#undef uint8_t
#define int8_t signed char
#define uint8_t unsigned char
#undef int16_t
#undef uint16_t
#define int16_t short int
#define uint16_t unsigned short int
#undef int32_t
#undef uint32_t
#define int32_t int
#define uint32_t unsigned int
#undef int64_t
#if LONG_MAX >> 31 >> 31 == 1
# define int64_t long int
#elif defined _MSC_VER
# define int64_t __int64
#elif @HAVE_LONG_LONG_INT@
# define int64_t long long int
#endif
#undef uint64_t
#if ULONG_MAX >> 31 >> 31 >> 1 == 1
# define uint64_t unsigned long int
#elif defined _MSC_VER
# define uint64_t unsigned __int64
#elif @HAVE_UNSIGNED_LONG_LONG_INT@
# define uint64_t unsigned long long int
#endif
/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
#define _UINT8_T
#define _UINT32_T
#define _UINT64_T
/* 7.18.1.2. Minimum-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
are the same as the corresponding N_t types. */
#undef int_least8_t
#undef uint_least8_t
#undef int_least16_t
#undef uint_least16_t
#undef int_least32_t
#undef uint_least32_t
#undef int_least64_t
#undef uint_least64_t
#define int_least8_t int8_t
#define uint_least8_t uint8_t
#define int_least16_t int16_t
#define uint_least16_t uint16_t
#define int_least32_t int32_t
#define uint_least32_t uint32_t
#ifdef int64_t
# define int_least64_t int64_t
#endif
#ifdef uint64_t
# define uint_least64_t uint64_t
#endif
/* 7.18.1.3. Fastest minimum-width integer types */
/* Note: Other <stdint.h> substitutes may define these types differently.
It is not recommended to use these types in public header files. */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
are taken from the same list of types. Assume that 'long int'
is fast enough for all narrower integers. */
#undef int_fast8_t
#undef uint_fast8_t
#undef int_fast16_t
#undef uint_fast16_t
#undef int_fast32_t
#undef uint_fast32_t
#undef int_fast64_t
#undef uint_fast64_t
#define int_fast8_t long int
#define uint_fast8_t unsigned int_fast8_t
#define int_fast16_t long int
#define uint_fast16_t unsigned int_fast16_t
#define int_fast32_t long int
#define uint_fast32_t unsigned int_fast32_t
#ifdef int64_t
# define int_fast64_t int64_t
#endif
#ifdef uint64_t
# define uint_fast64_t uint64_t
#endif
/* 7.18.1.4. Integer types capable of holding object pointers */
#undef intptr_t
#undef uintptr_t
#define intptr_t long int
#define uintptr_t unsigned long int
/* 7.18.1.5. Greatest-width integer types */
/* Note: These types are compiler dependent. It may be unwise to use them in
public header files. */
#undef intmax_t
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
# define intmax_t long long int
#elif defined int64_t
# define intmax_t int64_t
#else
# define intmax_t long int
#endif
#undef uintmax_t
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
# define uintmax_t unsigned long long int
#elif defined int64_t
# define uintmax_t uint64_t
#else
# define uintmax_t unsigned long int
#endif
/* 7.18.2. Limits of specified-width integer types */
#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS
/* 7.18.2.1. Limits of exact-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. */
#undef INT8_MIN
#undef INT8_MAX
#undef UINT8_MAX
#define INT8_MIN (~ INT8_MAX)
#define INT8_MAX 127
#define UINT8_MAX 255
#undef INT16_MIN
#undef INT16_MAX
#undef UINT16_MAX
#define INT16_MIN (~ INT16_MAX)
#define INT16_MAX 32767
#define UINT16_MAX 65535
#undef INT32_MIN
#undef INT32_MAX
#undef UINT32_MAX
#define INT32_MIN (~ INT32_MAX)
#define INT32_MAX 2147483647
#define UINT32_MAX 4294967295U
#undef INT64_MIN
#undef INT64_MAX
#ifdef int64_t
# define INT64_MIN (~ INT64_MAX)
# define INT64_MAX INTMAX_C (9223372036854775807)
#endif
#undef UINT64_MAX
#ifdef uint64_t
# define UINT64_MAX UINTMAX_C (18446744073709551615)
#endif
/* 7.18.2.2. Limits of minimum-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
are the same as the corresponding N_t types. */
#undef INT_LEAST8_MIN
#undef INT_LEAST8_MAX
#undef UINT_LEAST8_MAX
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#undef INT_LEAST16_MIN
#undef INT_LEAST16_MAX
#undef UINT_LEAST16_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#undef INT_LEAST32_MIN
#undef INT_LEAST32_MAX
#undef UINT_LEAST32_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#undef INT_LEAST64_MIN
#undef INT_LEAST64_MAX
#ifdef int64_t
# define INT_LEAST64_MIN INT64_MIN
# define INT_LEAST64_MAX INT64_MAX
#endif
#undef UINT_LEAST64_MAX
#ifdef uint64_t
# define UINT_LEAST64_MAX UINT64_MAX
#endif
/* 7.18.2.3. Limits of fastest minimum-width integer types */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
are taken from the same list of types. */
#undef INT_FAST8_MIN
#undef INT_FAST8_MAX
#undef UINT_FAST8_MAX
#define INT_FAST8_MIN LONG_MIN
#define INT_FAST8_MAX LONG_MAX
#define UINT_FAST8_MAX ULONG_MAX
#undef INT_FAST16_MIN
#undef INT_FAST16_MAX
#undef UINT_FAST16_MAX
#define INT_FAST16_MIN LONG_MIN
#define INT_FAST16_MAX LONG_MAX
#define UINT_FAST16_MAX ULONG_MAX
#undef INT_FAST32_MIN
#undef INT_FAST32_MAX
#undef UINT_FAST32_MAX
#define INT_FAST32_MIN LONG_MIN
#define INT_FAST32_MAX LONG_MAX
#define UINT_FAST32_MAX ULONG_MAX
#undef INT_FAST64_MIN
#undef INT_FAST64_MAX
#ifdef int64_t
# define INT_FAST64_MIN INT64_MIN
# define INT_FAST64_MAX INT64_MAX
#endif
#undef UINT_FAST64_MAX
#ifdef uint64_t
# define UINT_FAST64_MAX UINT64_MAX
#endif
/* 7.18.2.4. Limits of integer types capable of holding object pointers */
#undef INTPTR_MIN
#undef INTPTR_MAX
#undef UINTPTR_MAX
#define INTPTR_MIN LONG_MIN
#define INTPTR_MAX LONG_MAX
#define UINTPTR_MAX ULONG_MAX
/* 7.18.2.5. Limits of greatest-width integer types */
#undef INTMAX_MIN
#undef INTMAX_MAX
#define INTMAX_MIN (~ INTMAX_MAX)
#ifdef INT64_MAX
# define INTMAX_MAX INT64_MAX
#else
# define INTMAX_MAX INT32_MAX
#endif
#undef UINTMAX_MAX
#ifdef UINT64_MAX
# define UINTMAX_MAX UINT64_MAX
#else
# define UINTMAX_MAX UINT32_MAX
#endif
/* 7.18.3. Limits of other integer types */
/* ptrdiff_t limits */
#undef PTRDIFF_MIN
#undef PTRDIFF_MAX
#define PTRDIFF_MIN \
_STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
#define PTRDIFF_MAX \
_STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
/* sig_atomic_t limits */
#undef SIG_ATOMIC_MIN
#undef SIG_ATOMIC_MAX
#define SIG_ATOMIC_MIN \
_STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
0@SIG_ATOMIC_T_SUFFIX@)
#define SIG_ATOMIC_MAX \
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
0@SIG_ATOMIC_T_SUFFIX@)
/* size_t limit */
#undef SIZE_MAX
#define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
/* wchar_t limits */
#undef WCHAR_MIN
#undef WCHAR_MAX
#define WCHAR_MIN \
_STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
#define WCHAR_MAX \
_STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
/* wint_t limits */
#undef WINT_MIN
#undef WINT_MAX
#define WINT_MIN \
_STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
#define WINT_MAX \
_STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
/* 7.18.4. Macros for integer constants */
#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
/* 7.18.4.1. Macros for minimum-width integer constants */
/* According to ISO C 99 Technical Corrigendum 1 */
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
#undef INT8_C
#undef UINT8_C
#define INT8_C(x) x
#define UINT8_C(x) x
#undef INT16_C
#undef UINT16_C
#define INT16_C(x) x
#define UINT16_C(x) x
#undef INT32_C
#undef UINT32_C
#define INT32_C(x) x
#define UINT32_C(x) x ## U
#undef INT64_C
#undef UINT64_C
#if LONG_MAX >> 31 >> 31 == 1
# define INT64_C(x) x##L
#elif defined _MSC_VER
# define INT64_C(x) x##i64
#elif @HAVE_LONG_LONG_INT@
# define INT64_C(x) x##LL
#endif
#if ULONG_MAX >> 31 >> 31 >> 1 == 1
# define UINT64_C(x) x##UL
#elif defined _MSC_VER
# define UINT64_C(x) x##ui64
#elif @HAVE_UNSIGNED_LONG_LONG_INT@
# define UINT64_C(x) x##ULL
#endif
/* 7.18.4.2. Macros for greatest-width integer constants */
#undef INTMAX_C
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
# define INTMAX_C(x) x##LL
#elif defined int64_t
# define INTMAX_C(x) INT64_C(x)
#else
# define INTMAX_C(x) x##L
#endif
#undef UINTMAX_C
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
# define UINTMAX_C(x) x##ULL
#elif defined uint64_t
# define UINTMAX_C(x) UINT64_C(x)
#else
# define UINTMAX_C(x) x##UL
#endif
#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */
#endif /* _GL_STDINT_H */

42
gl/strpbrk.c Normal file
View File

@ -0,0 +1,42 @@
/* Copyright (C) 1991, 1994, 2000, 2002-2003, 2006 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#include <config.h>
#include <stddef.h>
#include <string.h>
#undef strpbrk
/* Find the first occurrence in S of any character in ACCEPT. */
char *
strpbrk (const char *s, const char *accept)
{
while (*s != '\0')
{
const char *a = accept;
while (*a != '\0')
if (*a++ == *s)
return (char *) s;
++s;
}
return NULL;
}

View File

@ -1,5 +1,5 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
/* Searching in a string.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -11,27 +11,18 @@
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 along
with this program; if not, write to the Free Software Foundation,
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#if HAVE_STRPBRK
/* Get strpbrk() declaration. */
#include <string.h>
#else
/* Find the first occurrence in S of any character in ACCEPT. */
extern char *strpbrk (const char *s, const char *accept);
#endif
/* Specification. */
#include "vasprintf.h"
#include <stdarg.h>
int
asprintf (char **resultp, const char *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = vasprintf (resultp, format, args);
va_end (args);
return result;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc.
/* Copyright (C) 1992,1995-1999,2000-2002,2005-2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@ -13,25 +13,18 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <config.h>
#include <errno.h>
#if !_LIBC
# if !defined errno && !defined HAVE_ERRNO_DECL
extern int errno;
# endif
# define __set_errno(ev) ((errno) = (ev))
#endif
#include <stdlib.h>
#include <string.h>
#if _LIBC || HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <unistd.h>
#if !_LIBC
# define __environ environ

View File

@ -1,901 +0,0 @@
/* vsprintf with automatic memory allocation.
Copyright (C) 1999, 2002-2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
This must come before <config.h> because <config.h> may include
<features.h>, and once <features.h> has been included, it's too late. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef IN_LIBINTL
# include <alloca.h>
#endif
/* Specification. */
#if WIDE_CHAR_VERSION
# include "vasnwprintf.h"
#else
# include "vasnprintf.h"
#endif
#include <stdio.h> /* snprintf(), sprintf() */
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
#include <string.h> /* memcpy(), strlen() */
#include <errno.h> /* errno */
#include <limits.h> /* CHAR_BIT, INT_MAX */
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
#if WIDE_CHAR_VERSION
# include "wprintf-parse.h"
#else
# include "printf-parse.h"
#endif
/* Checked size_t computations. */
#include "xsize.h"
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
#ifndef EOVERFLOW
# define EOVERFLOW E2BIG
#endif
#ifdef HAVE_WCHAR_T
# ifdef HAVE_WCSLEN
# define local_wcslen wcslen
# else
/* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
a dependency towards this library, here is a local substitute.
Define this substitute only once, even if this file is included
twice in the same compilation unit. */
# ifndef local_wcslen_defined
# define local_wcslen_defined 1
static size_t
local_wcslen (const wchar_t *s)
{
const wchar_t *ptr;
for (ptr = s; *ptr != (wchar_t) 0; ptr++)
;
return ptr - s;
}
# endif
# endif
#endif
#if WIDE_CHAR_VERSION
# define VASNPRINTF vasnwprintf
# define CHAR_T wchar_t
# define DIRECTIVE wchar_t_directive
# define DIRECTIVES wchar_t_directives
# define PRINTF_PARSE wprintf_parse
# define USE_SNPRINTF 1
# if HAVE_DECL__SNWPRINTF
/* On Windows, the function swprintf() has a different signature than
on Unix; we use the _snwprintf() function instead. */
# define SNPRINTF _snwprintf
# else
/* Unix. */
# define SNPRINTF swprintf
# endif
#else
# define VASNPRINTF vasnprintf
# define CHAR_T char
# define DIRECTIVE char_directive
# define DIRECTIVES char_directives
# define PRINTF_PARSE printf_parse
# define USE_SNPRINTF (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF)
# if HAVE_DECL__SNPRINTF
/* Windows. */
# define SNPRINTF _snprintf
# else
/* Unix. */
# define SNPRINTF snprintf
# endif
#endif
CHAR_T *
VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list args)
{
DIRECTIVES d;
arguments a;
if (PRINTF_PARSE (format, &d, &a) < 0)
{
errno = EINVAL;
return NULL;
}
#define CLEANUP() \
free (d.dir); \
if (a.arg) \
free (a.arg);
if (printf_fetchargs (args, &a) < 0)
{
CLEANUP ();
errno = EINVAL;
return NULL;
}
{
size_t buf_neededlength;
CHAR_T *buf;
CHAR_T *buf_malloced;
const CHAR_T *cp;
size_t i;
DIRECTIVE *dp;
/* Output string accumulator. */
CHAR_T *result;
size_t allocated;
size_t length;
/* Allocate a small buffer that will hold a directive passed to
sprintf or snprintf. */
buf_neededlength =
xsum4 (7, d.max_width_length, d.max_precision_length, 6);
#if HAVE_ALLOCA
if (buf_neededlength < 4000 / sizeof (CHAR_T))
{
buf = (CHAR_T *) alloca (buf_neededlength * sizeof (CHAR_T));
buf_malloced = NULL;
}
else
#endif
{
size_t buf_memsize = xtimes (buf_neededlength, sizeof (CHAR_T));
if (size_overflow_p (buf_memsize))
goto out_of_memory_1;
buf = (CHAR_T *) malloc (buf_memsize);
if (buf == NULL)
goto out_of_memory_1;
buf_malloced = buf;
}
if (resultbuf != NULL)
{
result = resultbuf;
allocated = *lengthp;
}
else
{
result = NULL;
allocated = 0;
}
length = 0;
/* Invariants:
result is either == resultbuf or == NULL or malloc-allocated.
If length > 0, then result != NULL. */
/* Ensures that allocated >= needed. Aborts through a jump to
out_of_memory if needed is SIZE_MAX or otherwise too big. */
#define ENSURE_ALLOCATION(needed) \
if ((needed) > allocated) \
{ \
size_t memory_size; \
CHAR_T *memory; \
\
allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
if ((needed) > allocated) \
allocated = (needed); \
memory_size = xtimes (allocated, sizeof (CHAR_T)); \
if (size_overflow_p (memory_size)) \
goto out_of_memory; \
if (result == resultbuf || result == NULL) \
memory = (CHAR_T *) malloc (memory_size); \
else \
memory = (CHAR_T *) realloc (result, memory_size); \
if (memory == NULL) \
goto out_of_memory; \
if (result == resultbuf && length > 0) \
memcpy (memory, result, length * sizeof (CHAR_T)); \
result = memory; \
}
for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
{
if (cp != dp->dir_start)
{
size_t n = dp->dir_start - cp;
size_t augmented_length = xsum (length, n);
ENSURE_ALLOCATION (augmented_length);
memcpy (result + length, cp, n * sizeof (CHAR_T));
length = augmented_length;
}
if (i == d.count)
break;
/* Execute a single directive. */
if (dp->conversion == '%')
{
size_t augmented_length;
if (!(dp->arg_index == ARG_NONE))
abort ();
augmented_length = xsum (length, 1);
ENSURE_ALLOCATION (augmented_length);
result[length] = '%';
length = augmented_length;
}
else
{
if (!(dp->arg_index != ARG_NONE))
abort ();
if (dp->conversion == 'n')
{
switch (a.arg[dp->arg_index].type)
{
case TYPE_COUNT_SCHAR_POINTER:
*a.arg[dp->arg_index].a.a_count_schar_pointer = length;
break;
case TYPE_COUNT_SHORT_POINTER:
*a.arg[dp->arg_index].a.a_count_short_pointer = length;
break;
case TYPE_COUNT_INT_POINTER:
*a.arg[dp->arg_index].a.a_count_int_pointer = length;
break;
case TYPE_COUNT_LONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longint_pointer = length;
break;
#ifdef HAVE_LONG_LONG
case TYPE_COUNT_LONGLONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
break;
#endif
default:
abort ();
}
}
else
{
arg_type type = a.arg[dp->arg_index].type;
CHAR_T *p;
unsigned int prefix_count;
int prefixes[2];
#if !USE_SNPRINTF
size_t tmp_length;
CHAR_T tmpbuf[700];
CHAR_T *tmp;
/* Allocate a temporary buffer of sufficient size for calling
sprintf. */
{
size_t width;
size_t precision;
width = 0;
if (dp->width_start != dp->width_end)
{
if (dp->width_arg_index != ARG_NONE)
{
int arg;
if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
abort ();
arg = a.arg[dp->width_arg_index].a.a_int;
width = (arg < 0 ? (unsigned int) (-arg) : arg);
}
else
{
const CHAR_T *digitp = dp->width_start;
do
width = xsum (xtimes (width, 10), *digitp++ - '0');
while (digitp != dp->width_end);
}
}
precision = 6;
if (dp->precision_start != dp->precision_end)
{
if (dp->precision_arg_index != ARG_NONE)
{
int arg;
if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
abort ();
arg = a.arg[dp->precision_arg_index].a.a_int;
precision = (arg < 0 ? 0 : arg);
}
else
{
const CHAR_T *digitp = dp->precision_start + 1;
precision = 0;
while (digitp != dp->precision_end)
precision = xsum (xtimes (precision, 10), *digitp++ - '0');
}
}
switch (dp->conversion)
{
case 'd': case 'i': case 'u':
# ifdef HAVE_LONG_LONG
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
* 0.30103 /* binary -> decimal */
* 2 /* estimate for FLAG_GROUP */
)
+ 1 /* turn floor into ceil */
+ 1; /* account for leading sign */
else
# endif
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
* 0.30103 /* binary -> decimal */
* 2 /* estimate for FLAG_GROUP */
)
+ 1 /* turn floor into ceil */
+ 1; /* account for leading sign */
else
tmp_length =
(unsigned int) (sizeof (unsigned int) * CHAR_BIT
* 0.30103 /* binary -> decimal */
* 2 /* estimate for FLAG_GROUP */
)
+ 1 /* turn floor into ceil */
+ 1; /* account for leading sign */
break;
case 'o':
# ifdef HAVE_LONG_LONG
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
* 0.333334 /* binary -> octal */
)
+ 1 /* turn floor into ceil */
+ 1; /* account for leading sign */
else
# endif
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
* 0.333334 /* binary -> octal */
)
+ 1 /* turn floor into ceil */
+ 1; /* account for leading sign */
else
tmp_length =
(unsigned int) (sizeof (unsigned int) * CHAR_BIT
* 0.333334 /* binary -> octal */
)
+ 1 /* turn floor into ceil */
+ 1; /* account for leading sign */
break;
case 'x': case 'X':
# ifdef HAVE_LONG_LONG
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
* 0.25 /* binary -> hexadecimal */
)
+ 1 /* turn floor into ceil */
+ 2; /* account for leading sign or alternate form */
else
# endif
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
* 0.25 /* binary -> hexadecimal */
)
+ 1 /* turn floor into ceil */
+ 2; /* account for leading sign or alternate form */
else
tmp_length =
(unsigned int) (sizeof (unsigned int) * CHAR_BIT
* 0.25 /* binary -> hexadecimal */
)
+ 1 /* turn floor into ceil */
+ 2; /* account for leading sign or alternate form */
break;
case 'f': case 'F':
# ifdef HAVE_LONG_DOUBLE
if (type == TYPE_LONGDOUBLE)
tmp_length =
(unsigned int) (LDBL_MAX_EXP
* 0.30103 /* binary -> decimal */
* 2 /* estimate for FLAG_GROUP */
)
+ 1 /* turn floor into ceil */
+ 10; /* sign, decimal point etc. */
else
# endif
tmp_length =
(unsigned int) (DBL_MAX_EXP
* 0.30103 /* binary -> decimal */
* 2 /* estimate for FLAG_GROUP */
)
+ 1 /* turn floor into ceil */
+ 10; /* sign, decimal point etc. */
tmp_length = xsum (tmp_length, precision);
break;
case 'e': case 'E': case 'g': case 'G':
case 'a': case 'A':
tmp_length =
12; /* sign, decimal point, exponent etc. */
tmp_length = xsum (tmp_length, precision);
break;
case 'c':
# if defined HAVE_WINT_T && !WIDE_CHAR_VERSION
if (type == TYPE_WIDE_CHAR)
tmp_length = MB_CUR_MAX;
else
# endif
tmp_length = 1;
break;
case 's':
# ifdef HAVE_WCHAR_T
if (type == TYPE_WIDE_STRING)
{
tmp_length =
local_wcslen (a.arg[dp->arg_index].a.a_wide_string);
# if !WIDE_CHAR_VERSION
tmp_length = xtimes (tmp_length, MB_CUR_MAX);
# endif
}
else
# endif
tmp_length = strlen (a.arg[dp->arg_index].a.a_string);
break;
case 'p':
tmp_length =
(unsigned int) (sizeof (void *) * CHAR_BIT
* 0.25 /* binary -> hexadecimal */
)
+ 1 /* turn floor into ceil */
+ 2; /* account for leading 0x */
break;
default:
abort ();
}
if (tmp_length < width)
tmp_length = width;
tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
}
if (tmp_length <= sizeof (tmpbuf) / sizeof (CHAR_T))
tmp = tmpbuf;
else
{
size_t tmp_memsize = xtimes (tmp_length, sizeof (CHAR_T));
if (size_overflow_p (tmp_memsize))
/* Overflow, would lead to out of memory. */
goto out_of_memory;
tmp = (CHAR_T *) malloc (tmp_memsize);
if (tmp == NULL)
/* Out of memory. */
goto out_of_memory;
}
#endif
/* Construct the format string for calling snprintf or
sprintf. */
p = buf;
*p++ = '%';
if (dp->flags & FLAG_GROUP)
*p++ = '\'';
if (dp->flags & FLAG_LEFT)
*p++ = '-';
if (dp->flags & FLAG_SHOWSIGN)
*p++ = '+';
if (dp->flags & FLAG_SPACE)
*p++ = ' ';
if (dp->flags & FLAG_ALT)
*p++ = '#';
if (dp->flags & FLAG_ZERO)
*p++ = '0';
if (dp->width_start != dp->width_end)
{
size_t n = dp->width_end - dp->width_start;
memcpy (p, dp->width_start, n * sizeof (CHAR_T));
p += n;
}
if (dp->precision_start != dp->precision_end)
{
size_t n = dp->precision_end - dp->precision_start;
memcpy (p, dp->precision_start, n * sizeof (CHAR_T));
p += n;
}
switch (type)
{
#ifdef HAVE_LONG_LONG
case TYPE_LONGLONGINT:
case TYPE_ULONGLONGINT:
*p++ = 'l';
/*FALLTHROUGH*/
#endif
case TYPE_LONGINT:
case TYPE_ULONGINT:
#ifdef HAVE_WINT_T
case TYPE_WIDE_CHAR:
#endif
#ifdef HAVE_WCHAR_T
case TYPE_WIDE_STRING:
#endif
*p++ = 'l';
break;
#ifdef HAVE_LONG_DOUBLE
case TYPE_LONGDOUBLE:
*p++ = 'L';
break;
#endif
default:
break;
}
*p = dp->conversion;
#if USE_SNPRINTF
p[1] = '%';
p[2] = 'n';
p[3] = '\0';
#else
p[1] = '\0';
#endif
/* Construct the arguments for calling snprintf or sprintf. */
prefix_count = 0;
if (dp->width_arg_index != ARG_NONE)
{
if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
abort ();
prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
}
if (dp->precision_arg_index != ARG_NONE)
{
if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
abort ();
prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
}
#if USE_SNPRINTF
/* Prepare checking whether snprintf returns the count
via %n. */
ENSURE_ALLOCATION (xsum (length, 1));
result[length] = '\0';
#endif
for (;;)
{
size_t maxlen;
int count;
int retcount;
maxlen = allocated - length;
count = -1;
retcount = 0;
#if USE_SNPRINTF
# define SNPRINTF_BUF(arg) \
switch (prefix_count) \
{ \
case 0: \
retcount = SNPRINTF (result + length, maxlen, buf, \
arg, &count); \
break; \
case 1: \
retcount = SNPRINTF (result + length, maxlen, buf, \
prefixes[0], arg, &count); \
break; \
case 2: \
retcount = SNPRINTF (result + length, maxlen, buf, \
prefixes[0], prefixes[1], arg, \
&count); \
break; \
default: \
abort (); \
}
#else
# define SNPRINTF_BUF(arg) \
switch (prefix_count) \
{ \
case 0: \
count = sprintf (tmp, buf, arg); \
break; \
case 1: \
count = sprintf (tmp, buf, prefixes[0], arg); \
break; \
case 2: \
count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
arg); \
break; \
default: \
abort (); \
}
#endif
switch (type)
{
case TYPE_SCHAR:
{
int arg = a.arg[dp->arg_index].a.a_schar;
SNPRINTF_BUF (arg);
}
break;
case TYPE_UCHAR:
{
unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
SNPRINTF_BUF (arg);
}
break;
case TYPE_SHORT:
{
int arg = a.arg[dp->arg_index].a.a_short;
SNPRINTF_BUF (arg);
}
break;
case TYPE_USHORT:
{
unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
SNPRINTF_BUF (arg);
}
break;
case TYPE_INT:
{
int arg = a.arg[dp->arg_index].a.a_int;
SNPRINTF_BUF (arg);
}
break;
case TYPE_UINT:
{
unsigned int arg = a.arg[dp->arg_index].a.a_uint;
SNPRINTF_BUF (arg);
}
break;
case TYPE_LONGINT:
{
long int arg = a.arg[dp->arg_index].a.a_longint;
SNPRINTF_BUF (arg);
}
break;
case TYPE_ULONGINT:
{
unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
SNPRINTF_BUF (arg);
}
break;
#ifdef HAVE_LONG_LONG
case TYPE_LONGLONGINT:
{
long long int arg = a.arg[dp->arg_index].a.a_longlongint;
SNPRINTF_BUF (arg);
}
break;
case TYPE_ULONGLONGINT:
{
unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
SNPRINTF_BUF (arg);
}
break;
#endif
case TYPE_DOUBLE:
{
double arg = a.arg[dp->arg_index].a.a_double;
SNPRINTF_BUF (arg);
}
break;
#ifdef HAVE_LONG_DOUBLE
case TYPE_LONGDOUBLE:
{
long double arg = a.arg[dp->arg_index].a.a_longdouble;
SNPRINTF_BUF (arg);
}
break;
#endif
case TYPE_CHAR:
{
int arg = a.arg[dp->arg_index].a.a_char;
SNPRINTF_BUF (arg);
}
break;
#ifdef HAVE_WINT_T
case TYPE_WIDE_CHAR:
{
wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
SNPRINTF_BUF (arg);
}
break;
#endif
case TYPE_STRING:
{
const char *arg = a.arg[dp->arg_index].a.a_string;
SNPRINTF_BUF (arg);
}
break;
#ifdef HAVE_WCHAR_T
case TYPE_WIDE_STRING:
{
const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
SNPRINTF_BUF (arg);
}
break;
#endif
case TYPE_POINTER:
{
void *arg = a.arg[dp->arg_index].a.a_pointer;
SNPRINTF_BUF (arg);
}
break;
default:
abort ();
}
#if USE_SNPRINTF
/* Portability: Not all implementations of snprintf()
are ISO C 99 compliant. Determine the number of
bytes that snprintf() has produced or would have
produced. */
if (count >= 0)
{
/* Verify that snprintf() has NUL-terminated its
result. */
if (count < maxlen && result[length + count] != '\0')
abort ();
/* Portability hack. */
if (retcount > count)
count = retcount;
}
else
{
/* snprintf() doesn't understand the '%n'
directive. */
if (p[1] != '\0')
{
/* Don't use the '%n' directive; instead, look
at the snprintf() return value. */
p[1] = '\0';
continue;
}
else
{
/* Look at the snprintf() return value. */
if (retcount < 0)
{
/* HP-UX 10.20 snprintf() is doubly deficient:
It doesn't understand the '%n' directive,
*and* it returns -1 (rather than the length
that would have been required) when the
buffer is too small. */
size_t bigger_need =
xsum (xtimes (allocated, 2), 12);
ENSURE_ALLOCATION (bigger_need);
continue;
}
else
count = retcount;
}
}
#endif
/* Attempt to handle failure. */
if (count < 0)
{
if (!(result == resultbuf || result == NULL))
free (result);
if (buf_malloced != NULL)
free (buf_malloced);
CLEANUP ();
errno = EINVAL;
return NULL;
}
#if !USE_SNPRINTF
if (count >= tmp_length)
/* tmp_length was incorrectly calculated - fix the
code above! */
abort ();
#endif
/* Make room for the result. */
if (count >= maxlen)
{
/* Need at least count bytes. But allocate
proportionally, to avoid looping eternally if
snprintf() reports a too small count. */
size_t n =
xmax (xsum (length, count), xtimes (allocated, 2));
ENSURE_ALLOCATION (n);
#if USE_SNPRINTF
continue;
#endif
}
#if USE_SNPRINTF
/* The snprintf() result did fit. */
#else
/* Append the sprintf() result. */
memcpy (result + length, tmp, count * sizeof (CHAR_T));
if (tmp != tmpbuf)
free (tmp);
#endif
length += count;
break;
}
}
}
}
/* Add the final NUL. */
ENSURE_ALLOCATION (xsum (length, 1));
result[length] = '\0';
if (result != resultbuf && length + 1 < allocated)
{
/* Shrink the allocated memory if possible. */
CHAR_T *memory;
memory = (CHAR_T *) realloc (result, (length + 1) * sizeof (CHAR_T));
if (memory != NULL)
result = memory;
}
if (buf_malloced != NULL)
free (buf_malloced);
CLEANUP ();
*lengthp = length;
if (length > INT_MAX)
goto length_overflow;
return result;
length_overflow:
/* We could produce such a big string, but its length doesn't fit into
an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in
this case. */
if (result != resultbuf)
free (result);
errno = EOVERFLOW;
return NULL;
out_of_memory:
if (!(result == resultbuf || result == NULL))
free (result);
if (buf_malloced != NULL)
free (buf_malloced);
out_of_memory_1:
CLEANUP ();
errno = ENOMEM;
return NULL;
}
}
#undef SNPRINTF
#undef USE_SNPRINTF
#undef PRINTF_PARSE
#undef DIRECTIVES
#undef DIRECTIVE
#undef CHAR_T
#undef VASNPRINTF

View File

@ -1,77 +0,0 @@
/* vsprintf with automatic memory allocation.
Copyright (C) 2002-2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _VASNPRINTF_H
#define _VASNPRINTF_H
/* Get va_list. */
#include <stdarg.h>
/* Get size_t. */
#include <stddef.h>
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Write formatted output to a string dynamically allocated with malloc().
You can pass a preallocated buffer for the result in RESULTBUF and its
size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
If successful, return the address of the string (this may be = RESULTBUF
if no dynamic memory allocation was necessary) and set *LENGTHP to the
number of resulting bytes, excluding the trailing NUL. Upon error, set
errno and return NULL.
When dynamic memory allocation occurs, the preallocated buffer is left
alone (with possibly modified contents). This makes it possible to use
a statically allocated or stack-allocated buffer, like this:
char buf[100];
size_t len = sizeof (buf);
char *output = vasnprintf (buf, &len, format, args);
if (output == NULL)
... error handling ...;
else
{
... use the output string ...;
if (output != buf)
free (output);
}
*/
extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 3, 0)));
#ifdef __cplusplus
}
#endif
#endif /* _VASNPRINTF_H */

View File

@ -1,42 +0,0 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* Specification. */
#include "vasprintf.h"
#include <stdlib.h>
#include "vasnprintf.h"
int
vasprintf (char **resultp, const char *format, va_list args)
{
size_t length;
char *result = vasnprintf (NULL, &length, format, args);
if (result == NULL)
return -1;
*resultp = result;
/* Return the number of resulting bytes, excluding the trailing NUL.
If it wouldn't fit in an 'int', vasnprintf() would have returned NULL
and set errno to EOVERFLOW. */
return length;
}

View File

@ -1,63 +0,0 @@
/* vsprintf with automatic memory allocation.
Copyright (C) 2002-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _VASPRINTF_H
#define _VASPRINTF_H
#if HAVE_VASPRINTF
/* Get asprintf(), vasprintf() declarations. */
#include <stdio.h>
#else
/* Get va_list. */
#include <stdarg.h>
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Write formatted output to a string dynamically allocated with malloc().
If the memory allocation succeeds, store the address of the string in
*RESULT and return the number of resulting bytes, excluding the trailing
NUL. Upon memory allocation error, or some other error, return -1. */
extern int asprintf (char **result, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
extern int vasprintf (char **result, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0)));
#ifdef __cplusplus
}
#endif
#endif
#endif /* _VASPRINTF_H */

View File

@ -1,3 +1,25 @@
2007-06-06 Werner Koch <wk@g10code.com>
* w32help.h: New.
* w32-gettext.c: New. Taken from gnupg 1.4, added ngettext,
changed to use jnlib malloc functions and put under the LGPL.
* w32-reg.c: New. Taken from../common/w32reg.c and changed to
LGPL. Changed API to use the jnlib malloc functions.
* Makefile.am (libjnlib_a_SOURCES) [!W32]: Do not build the w32
specific modules.
* dotlock.c: Include stringhelp.h for stpcpy prototype.
2007-06-04 Werner Koch <wk@g10code.com>
* dynload.h: New. Taken from ../common and changed to LGPL.
* utf8conv.c (load_libiconv): New. Taken from GnuPG 1.4
2007-05-30 Werner Koch <wk@g10code.com>
* w32-pth.h, w32-pth.c: Remove.
2007-04-25 Werner Koch <wk@g10code.com>
* argparse.c (long_opt_strlen): Fixed for utf-8.

View File

@ -41,9 +41,12 @@ libjnlib_a_SOURCES = \
argparse.c argparse.h \
logging.c logging.h \
dotlock.c dotlock.h \
types.h mischelp.c mischelp.h \
w32-pth.c w32-pth.h \
w32-afunix.c w32-afunix.h
types.h mischelp.c mischelp.h dynload.h w32help.h
if HAVE_W32_SYSTEM
libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h w32-gettext.c
endif
# For GnuPG we don't need the xmalloc stuff.
# xmalloc.c xmalloc.h

View File

@ -37,6 +37,7 @@
#include <signal.h>
#include "libjnlib-config.h"
#include "stringhelp.h"
#include "dotlock.h"
#if !defined(DIRSEP_C) && !defined(EXTSEP_C) \

73
jnlib/dynload.h Normal file
View File

@ -0,0 +1,73 @@
/* dynload.h - Wrapper functions for run-time dynamic loading
* Copyright (C) 2003 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
* JNLIB 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.
*
* JNLIB 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef LIBJNLIB_DYNLOAD_H
#define LIBJNLIB_DYNLOAD_H
#ifndef __MINGW32__
# include <dlfcn.h>
#else
# include <windows.h>
# define RTLD_LAZY 0
static inline void *
dlopen (const char * name, int flag)
{
void * hd = LoadLibrary (name);
return hd;
}
static inline void *
dlsym (void *hd, const char *sym)
{
if (hd && sym)
{
void * fnc = GetProcAddress (hd, sym);
if (!fnc)
return NULL;
return fnc;
}
return NULL;
}
static inline const char *
dlerror (void)
{
static char buf[32];
sprintf (buf, "ec=%lu", GetLastError ());
return buf;
}
static inline int
dlclose (void * hd)
{
if (hd)
{
CloseHandle (hd);
return 0;
}
return -1;
}
# endif /*__MINGW32__*/
#endif /*LIBJNLIB_DYNLOAD_H*/

View File

@ -34,11 +34,14 @@
#define JNLIB_NEED_UTF8CONV 1
#if !defined(JNLIB_NEED_UTF8CONV) && defined(HAVE_W32_SYSTEM)
#define JNLIB_NEED_UTF8CONV 1
#endif
/* Gettext stuff */
#ifdef USE_SIMPLE_GETTEXT
int set_gettext_file( const char *filename );
const char *gettext( const char *msgid );
# include "w32help.h"
# define _(a) gettext (a)
# define N_(a) (a)
@ -61,7 +64,9 @@
#endif
#endif /* !USE_SIMPLE_GETTEXT */
/* Malloc functions to be jused by jnlib. */
/* Malloc functions to be used by jnlib. */
#define jnlib_malloc(a) gcry_malloc( (a) )
#define jnlib_calloc(a,b) gcry_calloc( (a), (b) )
#define jnlib_xmalloc(a) gcry_xmalloc( (a) )
#define jnlib_xcalloc(a,b) gcry_xcalloc( (a), (b) )
#define jnlib_xrealloc(a,n) gcry_xrealloc( (a), (n) )

View File

@ -821,7 +821,7 @@ memrchr (const void *buffer, int c, size_t n)
for (p += n; n ; n--)
if (*--p == c)
return p;
return (void *)p;
return NULL;
}
#endif /*HAVE_MEMRCHR*/

View File

@ -29,10 +29,13 @@
#include <langinfo.h>
#endif
#include <errno.h>
#include <iconv.h>
#ifndef HAVE_W32_SYSTEM
# include <iconv.h>
#endif
#include "libjnlib-config.h"
#include "stringhelp.h"
#include "dynload.h"
#include "utf8conv.h"
#ifndef MB_LEN_MAX
@ -45,6 +48,58 @@ static int no_translation; /* Set to true if we let simply pass through. */
static int use_iconv; /* iconv comversion fucntions required. */
/* Under W32 we dlopen the iconv dll and don't require any iconv
related headers at all. However we need to define some stuff. */
#ifdef HAVE_W32_SYSTEM
typedef void *iconv_t;
#ifndef ICONV_CONST
#define ICONV_CONST const
#endif
static iconv_t (* __stdcall iconv_open) (const char *tocode,
const char *fromcode);
static size_t (* __stdcall iconv) (iconv_t cd,
const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
static int (* __stdcall iconv_close) (iconv_t cd);
static int
load_libiconv (void)
{
static int done;
if (!done)
{
void *handle;
done = 1; /* Do it right now because we might get called recursivly
through gettext. */
handle = dlopen ("iconv.dll", RTLD_LAZY);
if (handle)
{
iconv_open = dlsym (handle, "libiconv_open");
if (iconv_open)
iconv = dlsym (handle, "libiconv");
if (iconv)
iconv_close = dlsym (handle, "libiconv_close");
}
if (!handle || !iconv_close)
{
log_info (_("error loading `%s': %s\n"),
"iconv.dll", dlerror ());
log_info (_("please see http://www.gnupg.org/download/iconv.html "
"for more information\n"));
iconv_open = NULL;
iconv = NULL;
iconv_close = NULL;
if (handle)
dlclose (handle);
}
}
return iconv_open? 0: -1;
}
#endif /*HAVE_W32_SYSTEM*/
/* Error handler for iconv failures. This is needed to not clutter the
output with repeated diagnostics about a missing conversion. */

556
jnlib/w32-gettext.c Normal file
View File

@ -0,0 +1,556 @@
/* w32-gettext.c - A simplified version of gettext for use under W32.
* Copyright (C) 1995, 1996, 1997, 1999,
* 2005, 2007 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
* JNLIB 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.
*
* JNLIB 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/*
This is a simplified version of gettext written by Ulrich Drepper.
It is used for the Win32 version of GnuPG becaise all the overhead
of gettext is not needed and we have to do some special Win32
stuff. I decided that this is far easier than to tweak gettext for
the special cases (I tried it but it is a lot of code). wk 15.09.99
*/
#include <config.h>
#ifdef USE_SIMPLE_GETTEXT
#if !defined (_WIN32) && !defined (__CYGWIN32__)
#error This module may only be build for Windows or Cygwin32
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "libjnlib-config.h"
#include "types.h"
#include "stringhelp.h"
#include "utf8conv.h"
#include "w32help.h"
#include "windows.h" /* For GetModuleFileName. */
/* The magic number of the GNU message catalog format. */
#define MAGIC 0x950412de
#define MAGIC_SWAPPED 0xde120495
/* Revision number of the currently used .mo (binary) file format. */
#define MO_REVISION_NUMBER 0
/* Header for binary .mo file format. */
struct mo_file_header
{
/* The magic number. */
u32 magic;
/* The revision number of the file format. */
u32 revision;
/* The number of strings pairs. */
u32 nstrings;
/* Offset of table with start offsets of original strings. */
u32 orig_tab_offset;
/* Offset of table with start offsets of translation strings. */
u32 trans_tab_offset;
/* Size of hashing table. */
u32 hash_tab_size;
/* Offset of first hashing entry. */
u32 hash_tab_offset;
};
struct string_desc
{
/* Length of addressed string. */
u32 length;
/* Offset of string in file. */
u32 offset;
};
struct overflow_space_s
{
struct overflow_space_s *next;
u32 idx;
char d[1];
};
struct loaded_domain
{
char *data;
int must_swap;
u32 nstrings;
char *mapped; /* 0 = not yet mapped, 1 = mapped,
2 = mapped to
overflow space */
struct overflow_space_s *overflow_space;
struct string_desc *orig_tab;
struct string_desc *trans_tab;
u32 hash_size;
u32 *hash_tab;
};
static struct loaded_domain *the_domain;
static __inline__ u32
do_swap_u32( u32 i )
{
return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
}
#define SWAPIT(flag, data) ((flag) ? do_swap_u32(data) : (data) )
/* We assume to have `unsigned long int' value with at least 32 bits. */
#define HASHWORDBITS 32
/* The so called `hashpjw' function by P.J. Weinberger
[see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
1986, 1987 Bell Telephone Laboratories, Inc.] */
static __inline__ ulong
hash_string (const char *str_param)
{
unsigned long int hval, g;
const char *str = str_param;
hval = 0;
while (*str != '\0')
{
hval <<= 4;
hval += (unsigned long int) *str++;
g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
if (g != 0)
{
hval ^= g >> (HASHWORDBITS - 8);
hval ^= g;
}
}
return hval;
}
static struct loaded_domain *
load_domain (const char *filename)
{
FILE *fp;
size_t size;
struct stat st;
struct mo_file_header *data = NULL;
struct loaded_domain *domain = NULL;
size_t to_read;
char *read_ptr;
fp = fopen( filename, "rb" );
if (!fp)
return NULL; /* Can't open the file. */
/* We need to know the size of the file. */
if (fstat( fileno(fp ), &st )
|| (size = (size_t)st.st_size) != st.st_size
|| size < sizeof (struct mo_file_header) )
{
fclose (fp);
return NULL;
}
data = jnlib_malloc (size);
if (!data)
{
fclose (fp);
return NULL; /* Out of memory. */
}
to_read = size;
read_ptr = (char *) data;
do
{
long int nb;
nb = fread (read_ptr, 1, to_read, fp);
if (nb < to_read )
{
fclose (fp);
jnlib_free (data);
return NULL; /* Read error. */
}
read_ptr += nb;
to_read -= nb;
}
while (to_read > 0);
fclose (fp);
/* Using the magic number we test whether it is really a message
catalog file. */
if (data->magic != MAGIC && data->magic != MAGIC_SWAPPED)
{
/* The magic number is wrong: not a message catalog file. */
jnlib_free (data);
return NULL;
}
domain = jnlib_calloc (1, sizeof *domain);
if (!domain)
{
jnlib_free (data);
return NULL;
}
domain->data = (char *) data;
domain->must_swap = data->magic != MAGIC;
/* Fill in the information about the available tables. */
switch (SWAPIT(domain->must_swap, data->revision))
{
case 0:
domain->nstrings = SWAPIT(domain->must_swap, data->nstrings);
domain->orig_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->orig_tab_offset));
domain->trans_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->trans_tab_offset));
domain->hash_size = SWAPIT(domain->must_swap, data->hash_tab_size);
domain->hash_tab = (u32 *)
((char *) data + SWAPIT(domain->must_swap, data->hash_tab_offset));
break;
default: /* This is an invalid revision. */
jnlib_free( data );
jnlib_free( domain );
return NULL;
}
/* Allocate an array to keep track of code page mappings. */
domain->mapped = jnlib_calloc (1, domain->nstrings);
if (!domain->mapped)
{
jnlib_free (data);
jnlib_free (domain);
return NULL;
}
return domain;
}
/* Set the file used for translations. Pass a NULL to disable
translation. A new filename may be set at anytime. WARNING: After
changing the filename you should not access any data retrieved by
gettext().
If REGKEY is not NULL, the function tries to selected the language
the registry key "Lang" below that key. If in addition the
environment variable LANGUAGE has been set, that value will
override a value set by the registry key.
*/
int
set_gettext_file ( const char *filename, const char *regkey )
{
struct loaded_domain *domain = NULL;
if ( filename && *filename )
{
if ( filename[0] == '/'
#ifdef HAVE_DRIVE_LETTERS
|| ( isalpha(filename[0])
&& filename[1] == ':'
&& (filename[2] == '/' || filename[2] == '\\') )
#endif
)
{
/* absolute path - use it as is */
domain = load_domain( filename );
}
else if (regkey) /* Standard. */
{
char *instdir, *langid, *fname;
char *p;
int envvar_mode = 0;
again:
if (!envvar_mode && (p = getenv ("LANGUAGE")) && *p)
{
envvar_mode = 1;
langid = jnlib_malloc (strlen (p)+1);
if (!langid)
return -1;
strcpy (langid, p);
/* We only make use of the first language given. Strip
the rest. */
p = strchr (langid, ':');
if (p)
*p = 0;
/* In the $LANGUAGE case we do not use the registered
installation directory but the one where the gpg
binary has been found. */
instdir = jnlib_malloc (MAX_PATH+5);
if ( !instdir || !GetModuleFileName (NULL, instdir, MAX_PATH) )
{
jnlib_free (langid);
jnlib_free (instdir);
return -1; /* Error getting the process' file name. */
}
p = strrchr (instdir, DIRSEP_C);
if (!p)
{
jnlib_free (langid);
jnlib_free (instdir);
return -1; /* Invalid file name returned. */
}
*p = 0;
}
else
{
instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
regkey,
"Install Directory");
if (!instdir)
return -1;
langid = read_w32_registry_string (NULL, /* HKCU then HKLM */
regkey,
"Lang");
if (!langid)
{
jnlib_free (instdir);
return -1;
}
}
/* Strip stuff after a dot in case the user tried to enter
the entire locale syntacs as usual for POSIX. */
p = strchr (langid, '.');
if (p)
*p = 0;
/* Build the key: "<instdir>/<domain>.nls/<langid>.mo" We
use a directory below the installation directory with the
domain included in case the software has been insalled
with other software altogether at the same place. */
fname = jnlib_malloc (strlen (instdir) + 1 + strlen (filename) + 5
+ strlen (langid) + 3 + 1);
if (!fname)
{
jnlib_free (instdir);
jnlib_free (langid);
return -1;
}
strcpy (stpcpy (stpcpy (stpcpy (stpcpy ( stpcpy (fname,
instdir),"\\"), filename), ".nls\\"), langid), ".mo");
jnlib_free (instdir);
jnlib_free (langid);
/* Better make sure that we don't mix forward and backward
slashes. It seems that some Windoze versions don't
accept this. */
for (p=fname; *p; p++)
{
if (*p == '/')
*p = '\\';
}
domain = load_domain (fname);
jnlib_free(fname);
if (!domain && envvar_mode == 1)
{
/* In case it failed, we try again using the registry
method. */
envvar_mode++;
goto again;
}
}
if (!domain)
return -1;
}
if ( the_domain )
{
struct overflow_space_s *os, *os2;
jnlib_free ( the_domain->data );
jnlib_free ( the_domain->mapped );
for (os=the_domain->overflow_space; os; os = os2)
{
os2 = os->next;
jnlib_free (os);
}
jnlib_free ( the_domain );
the_domain = NULL;
}
the_domain = domain;
return 0;
}
static const char*
get_string( struct loaded_domain *domain, u32 idx )
{
struct overflow_space_s *os;
char *p;
p = domain->data + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset);
if (!domain->mapped[idx])
{
size_t plen, buflen;
char *buf;
domain->mapped[idx] = 1;
plen = strlen (p);
buf = utf8_to_native (p, plen, -1);
buflen = strlen (buf);
if (buflen <= plen)
strcpy (p, buf);
else
{
/* There is not enough space for the translation - store it
in the overflow_space else and mark that in the mapped
array. Because we expect that this won't happen too
often, we use a simple linked list. */
os = jnlib_malloc (sizeof *os + buflen);
if (os)
{
os->idx = idx;
strcpy (os->d, buf);
os->next = domain->overflow_space;
domain->overflow_space = os;
p = os->d;
}
else
p = "ERROR in GETTEXT MALLOC";
}
jnlib_free (buf);
}
else if (domain->mapped[idx] == 2)
{ /* We need to get the string from the overflow_space. */
for (os=domain->overflow_space; os; os = os->next)
if (os->idx == idx)
return (const char*)os->d;
p = "ERROR in GETTEXT\n";
}
return (const char*)p;
}
const char *
gettext( const char *msgid )
{
struct loaded_domain *domain;
size_t act = 0;
size_t top, bottom;
if (!(domain = the_domain))
goto not_found;
/* Locate the MSGID and its translation. */
if (domain->hash_size > 2 && domain->hash_tab)
{
/* Use the hashing table. */
u32 len = strlen (msgid);
u32 hash_val = hash_string (msgid);
u32 idx = hash_val % domain->hash_size;
u32 incr = 1 + (hash_val % (domain->hash_size - 2));
u32 nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
if ( !nstr ) /* Hash table entry is empty. */
goto not_found;
if (SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].length) == len
&& !strcmp (msgid,
domain->data + SWAPIT(domain->must_swap,
domain->orig_tab[nstr-1].offset)))
return get_string( domain, nstr - 1 );
for (;;)
{
if (idx >= domain->hash_size - incr)
idx -= domain->hash_size - incr;
else
idx += incr;
nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
if (!nstr)
goto not_found; /* Hash table entry is empty. */
if ( SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].length) == len
&& !strcmp (msgid,
domain->data
+ SWAPIT(domain->must_swap,
domain->orig_tab[nstr-1].offset)))
return get_string( domain, nstr-1 );
}
/*NOTREACHED*/
}
/* Now we try the default method: binary search in the sorted array
of messages. */
bottom = 0;
top = domain->nstrings;
while (bottom < top)
{
int cmp_val;
act = (bottom + top) / 2;
cmp_val = strcmp(msgid, domain->data
+ SWAPIT(domain->must_swap,
domain->orig_tab[act].offset));
if (cmp_val < 0)
top = act;
else if (cmp_val > 0)
bottom = act + 1;
else
return get_string (domain, act);
}
not_found:
return msgid;
}
const char *
ngettext (const char *msgid1, const char *msgid2, unsigned long int n)
{
/* We use the simple Germanic plural rule. */
return gettext (n==1? msgid1 : msgid2);
}
#if 0
unsigned int cp1, cp2;
cp1 = GetConsoleCP();
cp2 = GetConsoleOutputCP();
log_info("InputCP=%u OutputCP=%u\n", cp1, cp2 );
if( !SetConsoleOutputCP( 1252 ) )
log_info("SetConsoleOutputCP failed: %s\n", w32_strerror (0));
cp1 = GetConsoleCP();
cp2 = GetConsoleOutputCP();
log_info("InputCP=%u OutputCP=%u after switch1\n", cp1, cp2 );
#endif
#endif /* USE_SIMPLE_GETTEXT */

File diff suppressed because it is too large Load Diff

View File

@ -1,245 +0,0 @@
/* w32-pth.h - GNU Pth emulation for W32 (MS Windows).
* Copyright (c) 1999-2003 Ralf S. Engelschall <rse@engelschall.com>
* Copyright (C) 2004, 2006 g10 Code GmbH
*
* This file is part of JNLIB.
*
* JNLIB 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.
*
* JNLIB 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* ------------------------------------------------------------------
* This code is based on Ralf Engelschall's GNU Pth, a non-preemptive
* thread scheduling library which can be found at
* http://www.gnu.org/software/pth/.
*/
/* Note that this header is usually used through a symlinked pth.h
file. This is needed so that we don't have a pth.h file here which
would conflict if a system really has pth available. */
#ifndef W32_PTH_H
#define W32_PTH_H
#include <windows.h> /* We need this for sockaddr et al. FIXME: too
heavyweight - may be we should factor such
code out to a second header and adjust all
user files to include it only if required. */
#ifndef W32_PTH_HANDLE_INTERNAL
#define W32_PTH_HANDLE_INTERNAL int
#endif
/* Filedescriptor blocking modes. */
enum
{
PTH_FDMODE_ERROR = -1,
PTH_FDMODE_POLL = 0,
PTH_FDMODE_BLOCK,
PTH_FDMODE_NONBLOCK
};
/* Mutex values. */
#define PTH_MUTEX_INITIALIZED (1<<0)
#define PTH_MUTEX_LOCKED (1<<1)
/* Note: We can't do static initialization, thus we don't define the
initializer PTH_MUTEX_INIT. */
#define PTH_KEY_INIT (1<<0)
/* Event subject classes. */
#define PTH_EVENT_FD (1<<1)
#define PTH_EVENT_SELECT (1<<2)
#define PTH_EVENT_SIGS (1<<3)
#define PTH_EVENT_TIME (1<<4)
#define PTH_EVENT_MSG (1<<5)
#define PTH_EVENT_MUTEX (1<<6)
#define PTH_EVENT_COND (1<<7)
#define PTH_EVENT_TID (1<<8)
#define PTH_EVENT_FUNC (1<<9)
/* Event occurrence restrictions. */
#define PTH_UNTIL_OCCURRED (1<<11)
#define PTH_UNTIL_FD_READABLE (1<<12)
#define PTH_UNTIL_FD_WRITEABLE (1<<13)
#define PTH_UNTIL_FD_EXCEPTION (1<<14)
#define PTH_UNTIL_TID_NEW (1<<15)
#define PTH_UNTIL_TID_READY (1<<16)
#define PTH_UNTIL_TID_WAITING (1<<17)
#define PTH_UNTIL_TID_DEAD (1<<18)
/* Event structure handling modes. */
#define PTH_MODE_REUSE (1<<20)
#define PTH_MODE_CHAIN (1<<21)
#define PTH_MODE_STATIC (1<<22)
/* Attribute commands for pth_attr_get and pth_attr_set(). */
enum
{
PTH_ATTR_PRIO, /* RW [int] Priority of thread. */
PTH_ATTR_NAME, /* RW [char *] Name of thread. */
PTH_ATTR_JOINABLE, /* RW [int] Thread detachment type. */
PTH_ATTR_CANCEL_STATE, /* RW [unsigned int] Thread cancellation state.*/
PTH_ATTR_STACK_SIZE, /* RW [unsigned int] Stack size. */
PTH_ATTR_STACK_ADDR, /* RW [char *] Stack lower address. */
PTH_ATTR_DISPATCHES, /* RO [int] Total number of
thread dispatches. */
PTH_ATTR_TIME_SPAWN, /* RO [pth_time_t] Time thread was spawned. */
PTH_ATTR_TIME_LAST, /* RO [pth_time_t] Time thread was
last dispatched. */
PTH_ATTR_TIME_RAN, /* RO [pth_time_t] Time thread was running. */
PTH_ATTR_START_FUNC, /* RO [void *(*)(void *)] Thread start function.*/
PTH_ATTR_START_ARG, /* RO [void *] Thread start argument. */
PTH_ATTR_STATE, /* RO [pth_state_t] Scheduling state. */
PTH_ATTR_EVENTS, /* RO [pth_event_t] Events the thread
is waiting for. */
PTH_ATTR_BOUND /* RO [int] Whether object is
bound to thread. */
};
/* Queries for pth_ctrl(). */
#define PTH_CTRL_GETAVLOAD (1<<1)
#define PTH_CTRL_GETPRIO (1<<2)
#define PTH_CTRL_GETNAME (1<<3)
#define PTH_CTRL_GETTHREADS_NEW (1<<4)
#define PTH_CTRL_GETTHREADS_READY (1<<5)
#define PTH_CTRL_GETTHREADS_RUNNING (1<<6)
#define PTH_CTRL_GETTHREADS_WAITING (1<<7)
#define PTH_CTRL_GETTHREADS_SUSPENDED (1<<8)
#define PTH_CTRL_GETTHREADS_DEAD (1<<9)
#define PTH_CTRL_DUMPSTATE (1<<10)
#define PTH_CTRL_GETTHREADS ( PTH_CTRL_GETTHREADS_NEW \
| PTH_CTRL_GETTHREADS_READY \
| PTH_CTRL_GETTHREADS_RUNNING \
| PTH_CTRL_GETTHREADS_WAITING \
| PTH_CTRL_GETTHREADS_SUSPENDED \
| PTH_CTRL_GETTHREADS_DEAD )
/* Event status codes. */
typedef enum
{
PTH_STATUS_PENDING,
PTH_STATUS_OCCURRED,
PTH_STATUS_FAILED
}
pth_status_t;
/* Event deallocation types. */
enum
{
PTH_FREE_THIS,
PTH_FREE_ALL
};
/* The Pth thread handle object. */
typedef void *pth_t;
/* The Mutex object. */
typedef W32_PTH_HANDLE_INTERNAL pth_mutex_t;
/* The Event object. */
struct pth_event_s;
typedef struct pth_event_s *pth_event_t;
/* The Attribute object. */
struct pth_attr_s;
typedef struct pth_attr_s *pth_attr_t;
/* The Key object. */
typedef int pth_key_t;
/* The Pth time object. */
typedef struct timeval pth_time_t;
/* Function prototypes. */
int pth_init (void);
int pth_kill (void);
long pth_ctrl (unsigned long query, ...);
int pth_read_ev (int fd, void *buffer, size_t size, pth_event_t ev);
int pth_read (int fd, void *buffer, size_t size);
int pth_write_ev (int fd, const void *buffer, size_t size, pth_event_t ev);
int pth_write (int fd, const void *buffer, size_t size);
int pth_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds,
const struct timeval *timeout);
int pth_accept (int fd, struct sockaddr *addr, int *addrlen);
int pth_accept_ev (int fd, struct sockaddr *addr, int *addrlen,
pth_event_t hd);
int pth_connect (int fd, struct sockaddr *name, int namelen);
int pth_mutex_release (pth_mutex_t *hd);
int pth_mutex_acquire(pth_mutex_t *hd, int try_only, pth_event_t ev_extra);
int pth_mutex_init (pth_mutex_t *hd);
pth_attr_t pth_attr_new (void);
int pth_attr_destroy (pth_attr_t hd);
int pth_attr_set (pth_attr_t hd, int field, ...);
pth_t pth_spawn (pth_attr_t hd, void *(*func)(void *), void *arg);
pth_t pth_self (void);
int pth_join (pth_t hd, void **value);
int pth_abort (pth_t hd);
void pth_exit (void *value);
unsigned int pth_waitpid (unsigned int, int *status, int options);
int pth_wait (pth_event_t hd);
int pth_sleep (int n);
pth_time_t pth_timeout (long sec, long usec);
pth_event_t pth_event_isolate (pth_event_t hd);
int pth_event_free (pth_event_t hd, int mode);
int pth_event_status (pth_event_t hd);
int pth_event_occurred (pth_event_t hd);
pth_event_t pth_event_concat (pth_event_t ev, ...);
pth_event_t pth_event (unsigned long spec, ...);
/*-- pth_util.c --*/
/* void sigemptyset (struct sigset_s * ss); */
/* int sigaddset (struct sigset_s * ss, int signo); */
#endif /*W32_PTH_H*/

184
jnlib/w32-reg.c Normal file
View File

@ -0,0 +1,184 @@
/* w32-reg.c - MS-Windows Registry access
* Copyright (C) 1999, 2002, 2007 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
* JNLIB 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.
*
* JNLIB 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include <config.h>
#ifdef HAVE_W32_SYSTEM
/* This module is only used in this environment */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <windows.h>
#include "libjnlib-config.h"
#include "w32help.h"
static HKEY
get_root_key(const char *root)
{
HKEY root_key;
if (!root)
root_key = HKEY_CURRENT_USER;
else if (!strcmp( root, "HKEY_CLASSES_ROOT" ) )
root_key = HKEY_CLASSES_ROOT;
else if (!strcmp( root, "HKEY_CURRENT_USER" ) )
root_key = HKEY_CURRENT_USER;
else if (!strcmp( root, "HKEY_LOCAL_MACHINE" ) )
root_key = HKEY_LOCAL_MACHINE;
else if (!strcmp( root, "HKEY_USERS" ) )
root_key = HKEY_USERS;
else if (!strcmp( root, "HKEY_PERFORMANCE_DATA" ) )
root_key = HKEY_PERFORMANCE_DATA;
else if (!strcmp( root, "HKEY_CURRENT_CONFIG" ) )
root_key = HKEY_CURRENT_CONFIG;
else
return NULL;
return root_key;
}
/* Return a string from the Win32 Registry or NULL in case of error.
Caller must release the return value. A NULL for root is an alias
for HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE in turn. */
char *
read_w32_registry_string (const char *root, const char *dir, const char *name)
{
HKEY root_key, key_handle;
DWORD n1, nbytes, type;
char *result = NULL;
if ( !(root_key = get_root_key(root) ) )
return NULL;
if ( RegOpenKeyEx( root_key, dir, 0, KEY_READ, &key_handle ) )
{
if (root)
return NULL; /* No need for a RegClose, so return immediately. */
/* It seems to be common practise to fall back to HKLM. */
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle) )
return NULL; /* Still no need for a RegClose. */
}
nbytes = 1;
if (RegQueryValueEx( key_handle, name, 0, NULL, NULL, &nbytes ) )
goto leave;
result = jnlib_malloc ((n1=nbytes+1));
if (!result)
goto leave;
if (RegQueryValueEx( key_handle, name, 0, &type, result, &n1 ))
{
jnlib_free (result);
result = NULL;
goto leave;
}
result[nbytes] = 0; /* Make sure it is a string. */
if (type == REG_EXPAND_SZ && strchr (result, '%'))
{
char *tmp;
n1 += 1000;
tmp = jnlib_malloc (n1+1);
if (!tmp)
goto leave;
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
if (nbytes && nbytes > n1)
{
jnlib_free (tmp);
n1 = nbytes;
tmp = jnlib_malloc (n1 + 1);
if (!tmp)
goto leave;
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
if (nbytes && nbytes > n1)
{
/* Oops - truncated, better don't expand at all. */
jnlib_free (tmp);
goto leave;
}
tmp[nbytes] = 0;
jnlib_free (result);
result = tmp;
}
else if (nbytes)
{
/* Okay, reduce the length. */
tmp[nbytes] = 0;
jnlib_free (result);
result = jnlib_malloc (strlen (tmp)+1);
if (!result)
result = tmp;
else
{
strcpy (result, tmp);
jnlib_free (tmp);
}
}
else
{
/* Error - don't expand. */
jnlib_free (tmp);
}
}
leave:
RegCloseKey (key_handle);
return result;
}
int
write_w32_registry_string (const char *root, const char *dir,
const char *name, const char *value)
{
HKEY root_key, reg_key;
if ( !(root_key = get_root_key(root) ) )
return -1;
if ( RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, &reg_key )
!= ERROR_SUCCESS )
return -1;
if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value,
strlen( value ) ) != ERROR_SUCCESS )
{
if ( RegCreateKey( root_key, name, &reg_key ) != ERROR_SUCCESS )
{
RegCloseKey(reg_key);
return -1;
}
if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value,
strlen( value ) ) != ERROR_SUCCESS )
{
RegCloseKey(reg_key);
return -1;
}
}
RegCloseKey (reg_key);
return 0;
}
#endif /*HAVE_W32_SYSTEM*/

41
jnlib/w32help.h Normal file
View File

@ -0,0 +1,41 @@
/* w32help.h - W32 speicif functions
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
* JNLIB 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.
*
* JNLIB 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef LIBJNLIB_W32HELP_H
#define LIBJNLIB_W32HELP_H
#ifdef HAVE_W32_SYSTEM
/*-- w32-reg.c --*/
char *read_w32_registry_string (const char *root,
const char *dir, const char *name );
int write_w32_registry_string (const char *root, const char *dir,
const char *name, const char *value);
#ifdef USE_SIMPLE_GETTEXT
int set_gettext_file (const char *filename, const char *regkey);
const char *gettext (const char *msgid );
const char *ngettext (const char *msgid1, const char *msgid2,
unsigned long int n);
#endif /*USE_SIMPLE_GETTEXT*/
#endif /*HAVE_W32_SYSTEM*/
#endif /*LIBJNLIB_MISCHELP_H*/

View File

@ -1,3 +1,7 @@
2007-06-06 Werner Koch <wk@g10code.com>
* kbxutil.c (i18n_init): Remove.
2007-03-20 Werner Koch <wk@g10code.com>
* keybox.h (KEYBOX_FLAG_BLOB_SECRET, KEYBOX_FLAG_BLOB_EPHEMERAL):

View File

@ -123,20 +123,6 @@ my_strusage( int level )
}
static void
i18n_init(void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file( PACKAGE_GT );
#else
#ifdef ENABLE_NLS
setlocale( LC_ALL, "" );
bindtextdomain( PACKAGE_GT, LOCALEDIR );
textdomain( PACKAGE_GT );
#endif
#endif
}
/* Used by gcry for logging */
static void
my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr)

View File

@ -1,3 +1,9 @@
2007-06-06 Werner Koch <wk@g10code.com>
* gpgkeys_ldap.c (send_key, send_key_keyserver): Rename eof to
r_eof as some Windows file has such a symbol.
(main): Likewise.
2007-05-07 Werner Koch <wk@g10code.com>
* Makefile.am (gpg2keys_ldap_LDADD): Add GPG_ERROR_LIBS.

View File

@ -575,7 +575,7 @@ free_mod_values(LDAPMod *mod)
}
static int
send_key(int *eof)
send_key(int *r_eof)
{
int err,begin=0,end=0,keysize=1,ret=KEYSERVER_INTERNAL_ERROR;
char *dn=NULL,line[MAX_LINE],*key=NULL;
@ -631,14 +631,14 @@ send_key(int *eof)
{
/* i.e. eof before the INFO BEGIN was found. This isn't an
error. */
*eof=1;
*r_eof=1;
ret=KEYSERVER_OK;
goto fail;
}
if(strlen(keyid)!=16)
{
*eof=1;
*r_eof=1;
ret=KEYSERVER_KEY_INCOMPLETE;
goto fail;
}
@ -678,7 +678,7 @@ send_key(int *eof)
if(!end)
{
fprintf(console,"gpgkeys: no INFO %s END found\n",keyid);
*eof=1;
*r_eof=1;
ret=KEYSERVER_KEY_INCOMPLETE;
goto fail;
}
@ -699,7 +699,7 @@ send_key(int *eof)
{
/* i.e. eof before the KEY BEGIN was found. This isn't an
error. */
*eof=1;
*r_eof=1;
ret=KEYSERVER_OK;
goto fail;
}
@ -733,7 +733,7 @@ send_key(int *eof)
if(!end)
{
fprintf(console,"gpgkeys: no KEY %s END found\n",keyid);
*eof=1;
*r_eof=1;
ret=KEYSERVER_KEY_INCOMPLETE;
goto fail;
}
@ -791,7 +791,7 @@ send_key(int *eof)
}
static int
send_key_keyserver(int *eof)
send_key_keyserver(int *r_eof)
{
int err,begin=0,end=0,keysize=1,ret=KEYSERVER_INTERNAL_ERROR;
char *dn=NULL,line[MAX_LINE],*key[2]={NULL,NULL};
@ -840,7 +840,7 @@ send_key_keyserver(int *eof)
{
/* i.e. eof before the KEY BEGIN was found. This isn't an
error. */
*eof=1;
*r_eof=1;
ret=KEYSERVER_OK;
goto fail;
}
@ -871,7 +871,7 @@ send_key_keyserver(int *eof)
if(!end)
{
fprintf(console,"gpgkeys: no KEY %s END found\n",keyid);
*eof=1;
*r_eof=1;
ret=KEYSERVER_KEY_INCOMPLETE;
goto fail;
}
@ -2272,7 +2272,7 @@ main(int argc,char *argv[])
}
else if(opt->action==KS_SEND)
{
int eof=0;
int eof_seen = 0;
do
{
@ -2280,16 +2280,16 @@ main(int argc,char *argv[])
if(real_ldap)
{
if(send_key(&eof)!=KEYSERVER_OK)
if (send_key(&eof_seen) != KEYSERVER_OK)
failed++;
}
else
{
if(send_key_keyserver(&eof)!=KEYSERVER_OK)
if (send_key_keyserver(&eof_seen) != KEYSERVER_OK)
failed++;
}
}
while(!eof);
while (!eof_seen);
}
else if(opt->action==KS_SEARCH)
{

View File

@ -1,3 +1,12 @@
2007-05-30 Werner Koch <wk@g10code.com>
* gnupg-pth.m4: Remove W32 kludge.
2007-05-29 Werner Koch <wk@g10code.com>
* longlong.m4, ulonglong.m4: Remove. We now require autoconf
2.61.
2007-05-15 Werner Koch <wk@g10code.com>
* estream.m4: New.

View File

@ -73,13 +73,11 @@ AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
])
#
# GNUPG_PATH_PTH([MINIMUM_VERSION])
#
# This is a special version of the check whioch assumes that a
# emulation for W32 systems is available. The test assumes that
# $have_w32_system has already been set. On return $have_pth is set
# as well as HAVE_PTH is defined and PTH_CLFAGS and PTH_LIBS are AS_SUBST.
# On return $have_pth is set as well as HAVE_PTH is defined and
# PTH_CLFAGS and PTH_LIBS are AS_SUBST.
#
AC_DEFUN([GNUPG_PATH_PTH],
[ AC_ARG_WITH(pth-prefix,
@ -91,9 +89,7 @@ AC_DEFUN([GNUPG_PATH_PTH],
fi
AC_PATH_PROG(PTH_CONFIG, pth-config, no)
tmp=ifelse([$1], ,1.3.7,$1)
test -z "$have_w32_system" && have_w32_system="no"
if test "$have_w32_system" = no; then
if test "$PTH_CONFIG" != "no"; then
if test "$PTH_CONFIG" != "no"; then
GNUPG_PTH_VERSION_CHECK($tmp)
if test $have_pth = yes; then
PTH_CFLAGS=`$PTH_CONFIG --cflags`
@ -102,12 +98,6 @@ AC_DEFUN([GNUPG_PATH_PTH],
AC_DEFINE(HAVE_PTH, 1,
[Defined if the GNU Pth is available])
fi
fi
else
have_pth=yes
PTH_CFLAGS=""
PTH_LIBS=""
AC_DEFINE(HAVE_PTH, 1)
fi
AC_SUBST(PTH_CFLAGS)
AC_SUBST(PTH_LIBS)

View File

@ -1,48 +0,0 @@
# longlong.m4 serial 8
dnl Copyright (C) 1999-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
# Define HAVE_LONG_LONG_INT if 'long long int' works.
# This fixes a bug in Autoconf 2.60, but can be removed once we
# assume 2.61 everywhere.
# Note: If the type 'long long int' exists but is only 32 bits large
# (as on some very old compilers), AC_TYPE_LONG_LONG_INT will not be
# defined. In this case you can treat 'long long int' like 'long int'.
AC_DEFUN([AC_TYPE_LONG_LONG_INT],
[
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[long long int ll = 9223372036854775807ll;
long long int nll = -9223372036854775807LL;
typedef int a[((-9223372036854775807LL < 0
&& 0 < 9223372036854775807ll)
? 1 : -1)];
int i = 63;]],
[[long long int llmax = 9223372036854775807ll;
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
| (llmax / ll) | (llmax % ll));]])],
[ac_cv_type_long_long_int=yes],
[ac_cv_type_long_long_int=no])])
if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], 1,
[Define to 1 if the system has the type `long long int'.])
fi
])
# This macro is obsolescent and should go away soon.
AC_DEFUN([gl_AC_TYPE_LONG_LONG],
[
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
ac_cv_type_long_long=$ac_cv_type_long_long_int
if test $ac_cv_type_long_long = yes; then
AC_DEFINE(HAVE_LONG_LONG, 1,
[Define if you have the 'long long' type.])
fi
])

Some files were not shown because too many files have changed in this diff Show More