aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog12
-rw-r--r--include/distfiles1
-rw-r--r--include/estream-printf.h110
-rw-r--r--include/memory.h6
-rw-r--r--include/types.h6
-rw-r--r--include/util.h18
6 files changed, 148 insertions, 5 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index 581904cc7..572830ccb 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,15 @@
+2009-07-21 Werner Koch <[email protected]>
+
+ * estream-printf.h: New. Taken from libestream.x
+
+2009-07-20 Werner Koch <[email protected]>
+
+ * types.h (strlist_t): Add new alias for STRLIST.
+
+ * memory.h (xtrymalloc,xtrystrdup): New.
+
+ * util.h: Add prototypes for util/convert.c.
+
2009-05-26 David Shaw <[email protected]>
* http.h: Pass in a STRLIST for additional headers on http_open
diff --git a/include/distfiles b/include/distfiles
index 4415193fb..6b1f560f3 100644
--- a/include/distfiles
+++ b/include/distfiles
@@ -15,5 +15,6 @@ dynload.h
assuan.h
compat.h
srv.h
+estream-printf.h
ChangeLog
diff --git a/include/estream-printf.h b/include/estream-printf.h
new file mode 100644
index 000000000..3987b33f2
--- /dev/null
+++ b/include/estream-printf.h
@@ -0,0 +1,110 @@
+/* estream-printf.h - Versatile C-99 compliant printf formatting.
+ * Copyright (C) 2007 g10 Code GmbH
+ *
+ * This file is part of Libestream.
+ *
+ * Libestream is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * Libestream is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Libestream; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ESTREAM_PRINTF_H
+#define ESTREAM_PRINTF_H
+
+#include <stdarg.h>
+#include <stdio.h>
+
+/* To use this file with libraries the following macro is useful:
+
+ #define _ESTREAM_EXT_SYM_PREFIX _foo_
+
+ This prefixes all external symbols with "_foo_".
+
+ For the implementation of the code (estream-printf.c) the following
+ macros may be used to tune the implementation for certain systems:
+
+ #define _ESTREAM_PRINTF_MALLOC foo_malloc
+ #define _ESTREAM_PRINTF_FREE foo_free
+
+ Make estream_asprintf and estream_vasprintf use foo_malloc and
+ foo_free instead of the standard malloc and free functions to
+ allocate the memory returned to the caller.
+
+ #define _ESTREAM_PRINTF_EXTRA_INCLUDE "foo.h"
+
+ This includes the file "foo.h" which may provide prototypes for
+ the custom memory allocation functions.
+ */
+
+
+#ifdef _ESTREAM_EXT_SYM_PREFIX
+#ifndef _ESTREAM_PREFIX
+#define _ESTREAM_PREFIX1(x,y) x ## y
+#define _ESTREAM_PREFIX2(x,y) _ESTREAM_PREFIX1(x,y)
+#define _ESTREAM_PREFIX(x) _ESTREAM_PREFIX2(_ESTREAM_EXT_SYM_PREFIX,x)
+#endif /*_ESTREAM_PREFIX*/
+#define estream_printf_out_t _ESTREAM_PREFIX(estream_printf_out_t)
+#define estream_format _ESTREAM_PREFIX(estream_format)
+#define estream_printf _ESTREAM_PREFIX(estream_printf)
+#define estream_fprintf _ESTREAM_PREFIX(estream_fprintf)
+#define estream_vfprintf _ESTREAM_PREFIX(estream_vfprintf)
+#define estream_snprintf _ESTREAM_PREFIX(estream_snprintf)
+#define estream_vsnprintf _ESTREAM_PREFIX(estream_vsnprintf)
+#define estream_asprintf _ESTREAM_PREFIX(estream_asprintf)
+#define estream_vasprintf _ESTREAM_PREFIX(estream_vasprintf)
+#endif /*_ESTREAM_EXT_SYM_PREFIX*/
+
+#ifndef _ESTREAM_GCC_A_PRINTF
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
+# define _ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a)))
+#else
+# define _ESTREAM_GCC_A_PRINTF( f, a )
+#endif
+#endif /*_ESTREAM_GCC_A_PRINTF*/
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0
+}
+#endif
+#endif
+
+
+typedef int (*estream_printf_out_t)
+ (void *outfncarg, const char *buf, size_t buflen);
+
+int estream_format (estream_printf_out_t outfnc, void *outfncarg,
+ const char *format, va_list vaargs)
+ _ESTREAM_GCC_A_PRINTF(3,0);
+int estream_printf (const char *format, ...)
+ _ESTREAM_GCC_A_PRINTF(1,2);
+int estream_fprintf (FILE *fp, const char *format, ... )
+ _ESTREAM_GCC_A_PRINTF(2,3);
+int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr)
+ _ESTREAM_GCC_A_PRINTF(2,0);
+int estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
+ _ESTREAM_GCC_A_PRINTF(3,4);
+int estream_vsnprintf (char *buf,size_t bufsize,
+ const char *format, va_list arg_ptr)
+ _ESTREAM_GCC_A_PRINTF(3,0);
+int estream_asprintf (char **bufp, const char *format, ...)
+ _ESTREAM_GCC_A_PRINTF(2,3);
+int estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
+ _ESTREAM_GCC_A_PRINTF(2,0);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*ESTREAM_PRINTF_H*/
diff --git a/include/memory.h b/include/memory.h
index 84e92b473..d414a9b2e 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -30,6 +30,7 @@
#define M_DBGINFO(a) "["__FILE__ ":" STR(a) "]"
#endif /* __riscos__ */
#define xmalloc(n) m_debug_alloc((n), M_DBGINFO( __LINE__ ) )
+#define xtrymalloc(n) m_debug_trymalloc ((n), M_DBGINFO( __LINE__ ))
#define xmalloc_clear(n) m_debug_alloc_clear((n), M_DBGINFO(__LINE__) )
#define xmalloc_secure(n) m_debug_alloc_secure(n), M_DBGINFO(__LINE__) )
#define xmalloc_secure_clear(n) m_debug_alloc_secure_clear((n), M_DBGINFO(__LINE__) )
@@ -38,8 +39,10 @@
#define m_check(n) m_debug_check((n), M_DBGINFO(__LINE__) )
/*#define m_copy(a) m_debug_copy((a), M_DBGINFO(__LINE__) )*/
#define xstrdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) )
+#define xtrystrdup(a) m_debug_trystrdup((a), M_DBGINFO(__LINE__) )
void *m_debug_alloc( size_t n, const char *info );
+void *m_debug_trymalloc (size_t n, const char *info);
void *m_debug_alloc_clear( size_t n, const char *info );
void *m_debug_alloc_secure( size_t n, const char *info );
void *m_debug_alloc_secure_clear( size_t n, const char *info );
@@ -48,9 +51,11 @@ void m_debug_free( void *p, const char *info );
void m_debug_check( const void *a, const char *info );
/*void *m_debug_copy( const void *a, const char *info );*/
char *m_debug_strdup( const char *a, const char *info );
+char *m_debug_trystrdup (const char *a, const char *info);
#else
void *xmalloc( size_t n );
+void *xtrymalloc (size_t n);
void *xmalloc_clear( size_t n );
void *xmalloc_secure( size_t n );
void *xmalloc_secure_clear( size_t n );
@@ -59,6 +64,7 @@ void xfree( void *p );
void m_check( const void *a );
/*void *m_copy( const void *a );*/
char *xstrdup( const char * a);
+char *xtrystrdup (const char *a);
#endif
size_t m_size( const void *a );
diff --git a/include/types.h b/include/types.h
index f57f33ab6..d6cd0735a 100644
--- a/include/types.h
+++ b/include/types.h
@@ -131,10 +131,12 @@ typedef union {
double g;
} PROPERLY_ALIGNED_TYPE;
-typedef struct string_list {
+struct string_list {
struct string_list *next;
unsigned int flags;
char d[1];
-} *STRLIST;
+};
+typedef struct string_list *STRLIST;
+typedef struct string_list *strlist_t;
#endif /*G10_TYPES_H*/
diff --git a/include/util.h b/include/util.h
index ffae3d211..b15181eed 100644
--- a/include/util.h
+++ b/include/util.h
@@ -240,11 +240,13 @@ char *read_w32_registry_string( const char *root,
int write_w32_registry_string(const char *root, const char *dir,
const char *name, const char *value);
-/*-- strgutil.c --*/
-int vasprintf (char **result, const char *format, va_list args);
-int asprintf (char **buf, const char *fmt, ...);
#endif /*_WIN32*/
+/*-- strgutil.c --*/
+char *xasprintf (const char *fmt, ...);
+char *xtryasprintf (const char *fmt, ...);
+
+
/*-- pka.c --*/
char *get_pka_info (const char *address, unsigned char *fpr);
@@ -252,6 +254,16 @@ char *get_pka_info (const char *address, unsigned char *fpr);
int get_cert(const char *name,size_t max_size,IOBUF *iobuf,
unsigned char **fpr,size_t *fpr_len,char **url);
+/*-- convert.c --*/
+int hex2bin (const char *string, void *buffer, size_t length);
+int hexcolon2bin (const char *string, void *buffer, size_t length);
+char *bin2hex (const void *buffer, size_t length, char *stringbuf);
+char *bin2hexcolon (const void *buffer, size_t length, char *stringbuf);
+const char *hex2str (const char *hexstring,
+ char *buffer, size_t bufsize, size_t *buflen);
+char *hex2str_alloc (const char *hexstring, size_t *r_count);
+
+
/**** other missing stuff ****/
#ifndef HAVE_ATEXIT /* For SunOS */
#define atexit(a) (on_exit((a),0))