aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/ChangeLog5
-rw-r--r--include/distfiles1
-rw-r--r--include/dynload.h71
-rw-r--r--include/memory.h2
-rw-r--r--include/ttyio.h3
-rw-r--r--include/util.h8
6 files changed, 90 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index f83aae32b..44eed96bf 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2003-09-28 Werner Koch <[email protected]>
+
+ * 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 <[email protected]>
* memory.h (xmalloc): Define xmalloc macros in terms of m_alloc.
diff --git a/include/distfiles b/include/distfiles
index 20a9091e6..11c5a0b47 100644
--- a/include/distfiles
+++ b/include/distfiles
@@ -11,5 +11,6 @@ host2net.h
http.h
keyserver.h
_regex.h
+dynload.h
ChangeLog
diff --git a/include/dynload.h b/include/dynload.h
new file mode 100644
index 000000000..a2e051c25
--- /dev/null
+++ b/include/dynload.h
@@ -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*/
diff --git a/include/memory.h b/include/memory.h
index 2482d083f..56f34ad00 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -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)
diff --git a/include/ttyio.h b/include/ttyio.h
index 5f6557930..8e8722d7c 100644
--- a/include/ttyio.h
+++ b/include/ttyio.h
@@ -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 );
diff --git a/include/util.h b/include/util.h
index 179f05f16..b0d8613ce 100644
--- a/include/util.h
+++ b/include/util.h
@@ -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')