diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-06-09 08:54:21 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-06-09 08:54:21 +0000 |
commit | 27c0d00eb23c5d6c07551d94bfea2766101c909c (patch) | |
tree | 7eaf24875021fcf88ea3ab4b623099f9d78f5a7f | |
parent | 1a3711cb70edc22417d6017b8d48d5c24f431c73 (diff) | |
download | gnutls-27c0d00eb23c5d6c07551d94bfea2766101c909c.tar.gz |
Added check for C99 macro support. Stubs are used if they are not supported by the compile. A more elegant solution is required.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | acconfig.h | 2 | ||||
-rw-r--r-- | configure.in | 15 | ||||
-rw-r--r-- | lib/gnutls_alert.c | 32 | ||||
-rw-r--r-- | lib/gnutls_errors.c | 17 | ||||
-rw-r--r-- | lib/gnutls_errors.h | 34 | ||||
-rw-r--r-- | lib/gnutls_global.c | 8 | ||||
-rw-r--r-- | lib/gnutls_mem.c | 3 | ||||
-rw-r--r-- | lib/gnutls_mem.h | 3 |
9 files changed, 85 insertions, 30 deletions
@@ -6,6 +6,7 @@ Version ?.?.? - Added gnutls_handshake_set_private_extensions() function. This function can be used to enable private (gnutls specific) cipher suites and compression algorithms. +- Added check for C99 macro support by the compiler. Version 0.4.3 (23/05/2002) - The gnutls-extra library now compiles fine, if the opencdk library is diff --git a/acconfig.h b/acconfig.h index 25a513c7f7..626985ae31 100644 --- a/acconfig.h +++ b/acconfig.h @@ -33,3 +33,5 @@ #undef ENABLE_ANON #undef HAVE_LIBOPENCDK + +#undef C99_MACROS diff --git a/configure.in b/configure.in index 2bc0c6b54f..3d08b5428c 100644 --- a/configure.in +++ b/configure.in @@ -95,6 +95,21 @@ AC_MSG_RESULT([*** AC_C_CONST AC_C_INLINE +AC_MSG_CHECKING([whether C99 macros are supported]) +AC_TRY_COMPILE(,[ +#define test_mac(...) +int z,y,x; +test_mac(x,y,z); +return 0; +], +dnl ***** OK +AC_DEFINE(C99_MACROS) +AC_MSG_RESULT(yes), +dnl ***** NOT FOUND +AC_MSG_RESULT(no) +AC_MSG_WARN([C99 macros are not supported by your compiler. This may +affect performance.]) +) if test $ac_cv_c_compiler_gnu != no; then diff --git a/lib/gnutls_alert.c b/lib/gnutls_alert.c index 1495194e6c..db51754523 100644 --- a/lib/gnutls_alert.c +++ b/lib/gnutls_alert.c @@ -64,6 +64,21 @@ static const gnutls_alert_entry sup_alerts[] = { GNUTLS_ALERT_LOOP( if(p->alert == alert) { a; break; }) +/** + * gnutls_alert_get_name - Returns a string describing the alert number given + * @alert: is an alert number &GNUTLS_STATE structure. + * + * Returns a string that describes the given alert number. + * See. gnutls_alert_get(). + * + **/ +const char* gnutls_alert_get_name( int alert) { +char* ret = NULL; + + GNUTLS_ALERT_ID_LOOP( ret = p->desc); + + return ret; +} /** * gnutls_alert_send - This function sends an alert message to the peer @@ -86,7 +101,7 @@ int gnutls_alert_send( GNUTLS_STATE state, GNUTLS_AlertLevel level, GNUTLS_Alert data[0] = (uint8) level; data[1] = (uint8) desc; - _gnutls_record_log( "REC: Sending Alert[%d|%d] - %s\n", data[0], data[1], _gnutls_alert_get_name((int)data[1])); + _gnutls_record_log( "REC: Sending Alert[%d|%d] - %s\n", data[0], data[1], gnutls_alert_get_name((int)data[1])); if ( (ret = gnutls_send_int( state, GNUTLS_ALERT, -1, data, 2)) >= 0) return 0; @@ -179,18 +194,3 @@ GNUTLS_AlertDescription gnutls_alert_get( GNUTLS_STATE state) { return state->gnutls_internals.last_alert; } -/** - * gnutls_alert_get_name - Returns a string describing the alert number given - * @alert: is an alert number &GNUTLS_STATE structure. - * - * Returns a string that describes the given alert number. - * See. gnutls_alert_get(). - * - **/ -const char* gnutls_alert_get_name( int alert) { -char* ret = NULL; - - GNUTLS_ALERT_ID_LOOP( ret = p->desc); - - return ret; -} diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c index ae27700d4f..70c0149208 100644 --- a/lib/gnutls_errors.c +++ b/lib/gnutls_errors.c @@ -218,6 +218,7 @@ int _gnutls_asn2err( int asn_err) { } } + /* this function will output a message using the * caller provided function */ @@ -237,4 +238,18 @@ void _gnutls_log( const char *fmt, ...) { return; } -#endif +#else /* not DEBUG */ +# ifndef C99_MACROS + +/* Without C99 macros these functions have to + * be called. This may affect performance. + */ +void _gnutls_null_log( void* x, ...) { return; } +char* GET_CN( gnutls_datum x) { return NULL; } +const char* _gnutls_handshake2str( int handshake) { return NULL; } +char * _gnutls_bin2hex(const unsigned char *old, const size_t oldlen) + { return NULL; } +const char* _gnutls_packet2str( int packet) { return NULL; } + +# endif /* C99_MACROS */ +#endif /* DEBUG */ diff --git a/lib/gnutls_errors.h b/lib/gnutls_errors.h index d720bd1130..f47b100019 100644 --- a/lib/gnutls_errors.h +++ b/lib/gnutls_errors.h @@ -95,14 +95,30 @@ int gnutls_error_is_fatal( int error); /* FIXME: These macros only work with C99 compliant compilers */ -# define _gnutls_log(...) -# define _gnutls_handshake_log( ...) -# define _gnutls_io_log( ...) -# define _gnutls_buffers_log( ...) -# define _gnutls_hard_log( ...) -# define _gnutls_record_log( ...) -# define _gnutls_read_log( ...) -# define _gnutls_write_log( ...) -# define _gnutls_x509_log( ...) +# ifdef C99_MACROS +# define _gnutls_log(...) +# define _gnutls_handshake_log( ...) +# define _gnutls_io_log( ...) +# define _gnutls_buffers_log( ...) +# define _gnutls_hard_log( ...) +# define _gnutls_record_log( ...) +# define _gnutls_read_log( ...) +# define _gnutls_write_log( ...) +# define _gnutls_x509_log( ...) +# else +# define _gnutls_log _gnutls_null_log +# define _gnutls_handshake_log _gnutls_null_log +# define _gnutls_io_log _gnutls_null_log +# define _gnutls_buffers_log _gnutls_null_log +# define _gnutls_hard_log _gnutls_null_log +# define _gnutls_record_log _gnutls_null_log +# define _gnutls_read_log _gnutls_null_log +# define _gnutls_write_log _gnutls_null_log +# define _gnutls_x509_log _gnutls_null_log + +void _gnutls_null_log( void*, ...); + +# endif /* C99_MACROS */ + #endif /* DEBUG */ diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c index 59ec0de0c2..c849216c17 100644 --- a/lib/gnutls_global.c +++ b/lib/gnutls_global.c @@ -76,6 +76,7 @@ extern void (*gnutls_free)(void*); extern int (*_gnutls_is_secure_memory)(const void*); extern void* (*gnutls_realloc)(void*, size_t); extern char* (*gnutls_strdup)(const char*); +extern void* (*gnutls_calloc)(size_t, size_t); int _gnutls_is_secure_mem_null( const void*); @@ -114,10 +115,13 @@ void gnutls_global_set_mem_func( /* if using the libc's default malloc * then also use the libc's strdup. */ - if ( gnutls_malloc == malloc) + if ( gnutls_malloc == malloc) { gnutls_strdup = strdup; - else /* use the included one */ + gnutls_calloc = calloc; + } else { /* use the included ones */ gnutls_strdup = _gnutls_strdup; + gnutls_calloc = _gnutls_calloc; + } return; } diff --git a/lib/gnutls_mem.c b/lib/gnutls_mem.c index a953d1d6b0..d62b973eff 100644 --- a/lib/gnutls_mem.c +++ b/lib/gnutls_mem.c @@ -25,6 +25,7 @@ void* (*gnutls_secure_malloc)(size_t) = malloc; void* (*gnutls_malloc)(size_t) = malloc; +void* (*gnutls_calloc)(size_t, size_t) = calloc; void (*gnutls_free)(void*) = free; char* (*gnutls_strdup)(const char*) = strdup; @@ -34,7 +35,7 @@ int (*_gnutls_is_secure_memory)(const void*) = _gnutls_is_secure_mem_null; void* (*gnutls_realloc)(void*, size_t) = realloc; -void *gnutls_calloc(size_t nmemb, size_t size) +void *_gnutls_calloc(size_t nmemb, size_t size) { void *ret; ret = gnutls_malloc(size); diff --git a/lib/gnutls_mem.h b/lib/gnutls_mem.h index cafd5d1232..88a255c182 100644 --- a/lib/gnutls_mem.h +++ b/lib/gnutls_mem.h @@ -24,12 +24,13 @@ extern void* (*gnutls_malloc)(size_t); extern void (*gnutls_free)(void*); extern int (*_gnutls_is_secure_memory)(const void*); extern void* (*gnutls_realloc)(void*, size_t); +extern void* (*gnutls_calloc)(size_t, size_t); extern char* (*gnutls_strdup)( const char*); #define gnutls_realloc_fast(x, y) (y==0?x:realloc(x, y)) svoid* gnutls_secure_calloc( size_t nmemb, size_t size); -void* gnutls_calloc( size_t nmemb, size_t size); +void* _gnutls_calloc( size_t nmemb, size_t size); char* _gnutls_strdup( const char*); |