* util.h: Add the atoi_* and xtoi_* suite of macros from 1.9.

* dynload.h: New.  Taken from 1.9.
This commit is contained in:
Werner Koch 2003-09-28 13:42:18 +00:00
parent e369270a65
commit edb5762c5f
6 changed files with 90 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2003-09-28 Werner Koch <wk@gnupg.org>
* util.h: Add the atoi_* and xtoi_* suite of macros from 1.9.
* dynload.h: New. Taken from 1.9.
2003-09-27 Werner Koch <wk@gnupg.org>
* memory.h (xmalloc): Define xmalloc macros in terms of m_alloc.

View File

@ -11,5 +11,6 @@ host2net.h
http.h
keyserver.h
_regex.h
dynload.h
ChangeLog

71
include/dynload.h Normal file
View File

@ -0,0 +1,71 @@
/* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifndef GNUPG_DYNLOAD_H
#define GNUPG_DYNLOAD_H
#ifdef ENABLE_CARD_SUPPORT
#ifndef __MINGW32__
#include <dlfcn.h>
#else
#include <windows.h>
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 /*ENABLE_CARD_SUPPORT*/
#endif /*GNUPG_DYNLOAD_H*/

View File

@ -96,6 +96,8 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
#define xcalloc(n,m) m_alloc_clear ((n)*(m))
#define xmalloc_secure(n) m_alloc_secure (n)
#define xcalloc_secure(n) m_alloc_secure_clear ((n)*(m))
#define xrealloc(a,n) m_realloc ((a),(n))
#define xstrdup(a) m_strdup ((a))
#define xfree(a) m_free (a)

View File

@ -24,8 +24,11 @@ const char *tty_get_ttyname (void);
int tty_batchmode( int onoff );
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
void tty_printf (const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
void tty_fprintf (FILE *fp, const char *fmt, ... )
__attribute__ ((format (printf,2,3)));
#else
void tty_printf (const char *fmt, ... );
void tty_fprintf (FILE *fp, const char *fmt, ... );
#endif
void tty_print_string( byte *p, size_t n );
void tty_print_utf8_string( byte *p, size_t n );

View File

@ -270,6 +270,14 @@ int vasprintf ( char **result, const char *format, va_list args);
#define hexdigitp(a) (digitp (a) \
|| (*(a) >= 'A' && *(a) <= 'F') \
|| (*(a) >= 'a' && *(a) <= 'f'))
/* the atoi macros assume that the buffer has only valid digits */
#define atoi_1(p) (*(p) - '0' )
#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
#define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
*(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
/* Note this isn't identical to a C locale isspace() without \f and
\v, but works for the purposes used here. */
#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t')