summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-11-19 17:11:37 +0100
committerWerner Koch <wk@gnupg.org>1999-11-19 17:11:37 +0100
commit2694bceb45f71b7808aec66f30d8ee720a92eb67 (patch)
tree358ee56c220c853334ec604d653c3483be72ff2f /include
parentSee ChangeLog: Mon Nov 15 21:36:02 CET 1999 Werner Koch (diff)
downloadgnupg2-2694bceb45f71b7808aec66f30d8ee720a92eb67.tar.xz
gnupg2-2694bceb45f71b7808aec66f30d8ee720a92eb67.zip
See ChangeLog: Fri Nov 19 17:15:20 CET 1999 Werner Koch
Diffstat (limited to 'include')
-rw-r--r--include/g10lib.h94
-rw-r--r--include/memory.h1
-rw-r--r--include/util.h11
3 files changed, 93 insertions, 13 deletions
diff --git a/include/g10lib.h b/include/g10lib.h
index aa2977825..158901c0f 100644
--- a/include/g10lib.h
+++ b/include/g10lib.h
@@ -28,8 +28,13 @@
#ifdef _GCRYPT_H
#error gcrypt.h already included
#endif
+/* because libgcrypt is distributed along with GnuPG, we need some way
+ * to do a sanity check. If this macro is defined, we are inside of
+ * libgcrypt */
+#define _GCRYPT_IN_LIBGCRYPT 1
#include <gcrypt.h>
+#include "types.h"
#ifdef G10_I18N_H
#error i18n should not be included here
@@ -54,20 +59,45 @@ void *g10_xcalloc_secure( size_t n, size_t m );
void *g10_xrealloc( void *a, size_t n );
char *g10_xstrdup( const char * a);
void g10_free( void *p );
+int g10_is_secure( const void *a );
+void g10_check_heap( const void *a );
/*-- gcrypt/misc.c --*/
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
+#define G10_GCC_A_NR __attribute__ ((noreturn))
+#define G10_GCC_A_PRINTF( f, a ) \
+ __attribute__ ((format (printf,f,a)))
+#define G10_GCC_A_NR_PRINTF( f, a ) \
+ __attribute__ ((noreturn, format (printf,f,a)))
+void g10_bug( const char *file, int line, const char *func ) G10_GCC_A_NR;
+#else
+#define G10_GCC_A_NR
+#define G10_GCC_A_PRINTF( f, a )
+#define G10_GCC_A_NR_PRINTF( f, a )
+void g10_bug( const char *file, int line );
+#endif
+
const char *g10_gettext( const char *key );
-void g10_fatal_error(int rc, const char *text );
+void g10_fatal_error(int rc, const char *text ) G10_GCC_A_NR;
+void g10_log( int level, const char *fmt, ... ) G10_GCC_A_PRINTF(2,3);
+void g10_log_bug( const char *fmt, ... ) G10_GCC_A_NR_PRINTF(1,2);
+void g10_log_fatal( const char *fmt, ... ) G10_GCC_A_NR_PRINTF(1,2);
+void g10_log_error( const char *fmt, ... ) G10_GCC_A_PRINTF(1,2);
+void g10_log_info( const char *fmt, ... ) G10_GCC_A_PRINTF(1,2);
+void g10_log_debug( const char *fmt, ... ) G10_GCC_A_PRINTF(1,2);
-/*-- util/memory.c --*/
+/*-- util/{secmem,memory}.c --*/
+
+void *g10_private_malloc( size_t n );
+void *g10_private_malloc_secure( size_t n );
+int g10_private_is_secure( const void *p );
+void g10_private_check_heap( const void *p );
+void *g10_private_realloc( void *a, size_t n );
+void g10_private_free( void *p );
-#define g10_private_malloc(n) m_alloc((n))
-#define g10_private_malloc_secure(n) m_alloc_secure((n))
-#define g10_private_is_secure(n) m_is_secure((n))
-#define g10_private_realloc(a,n) m_realloc((a),(n))
-#define g10_private_free(p) m_free((p))
/*-- cipher/pubkey.c --*/
@@ -96,4 +126,54 @@ MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits,
+/* logging macros */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
+ #define BUG() g10_bug( __FILE__ , __LINE__, __FUNCTION__ )
+#else
+ #define BUG() g10_bug( __FILE__ , __LINE__ )
+#endif
+
+#define log_hexdump g10_log_hexdump
+#define log_bug g10_log_bug
+#define log_fatal g10_log_fatal
+#define log_error g10_log_error
+#define log_info g10_log_info
+#define log_debug g10_log_debug
+
+
+/* replacements of missing functions */
+#ifndef HAVE_MEMICMP
+int memicmp( const char *a, const char *b, size_t n );
+#endif
+#ifndef HAVE_STPCPY
+char *stpcpy(char *a,const char *b);
+#endif
+#ifndef HAVE_STRLWR
+char *strlwr(char *a);
+#endif
+#ifndef HAVE_STRTOUL
+ #define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c)))
+#endif
+#ifndef HAVE_MEMMOVE
+ #define memmove(d, s, n) bcopy((s), (d), (n))
+#endif
+#ifndef HAVE_STRICMP
+ #define stricmp(a,b) strcasecmp( (a), (b) )
+#endif
+#ifndef HAVE_ATEXIT
+ #define atexit(a) (on_exit((a),0))
+#endif
+#ifndef HAVE_RAISE
+ #define raise(a) kill(getpid(), (a))
+#endif
+
+/* some handy macros */
+#ifndef STR
+ #define STR(v) #v
+#endif
+#define STR2(v) STR(v)
+#define DIM(v) (sizeof(v)/sizeof((v)[0]))
+#define DIMof(type,member) DIM(((type *)0)->member)
+
+
#endif /* G10LIB_H */
diff --git a/include/memory.h b/include/memory.h
index 84b7337c6..d7d7aabeb 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -67,7 +67,6 @@ void secmem_term( void );
void *secmem_malloc( size_t size );
void *secmem_realloc( void *a, size_t newsize );
void secmem_free( void *a );
-int m_is_secure( const void *p );
void secmem_dump_stats(void);
void secmem_set_flags( unsigned flags );
unsigned secmem_get_flags(void);
diff --git a/include/util.h b/include/util.h
index 8eec982cc..cf656f625 100644
--- a/include/util.h
+++ b/include/util.h
@@ -1,5 +1,5 @@
/* util.h
- * Copyright (C) 1998 Free Software Foundation, Inc.
+ * Copyright (C) 1998,1999 Free Software Foundation, Inc.
*
* This file is part of GNUPG.
*
@@ -20,6 +20,10 @@
#ifndef G10_UTIL_H
#define G10_UTIL_H
+#ifdef _GCRYPT_IN_LIBGCRYPT
+ #error This header should not be used internally by libgcrypt
+#endif
+
#include "types.h"
#include "errors.h"
#include "types.h"
@@ -120,11 +124,8 @@ int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
int optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
void usage( int level );
-const char *default_strusage( int level );
-
-
-/*-- (main program) --*/
const char *strusage( int level );
+void set_strusage( const char *(*f)( int ) );
/*-- dotlock.c --*/