diff options
author | Werner Koch <wk@gnupg.org> | 2001-12-06 20:36:39 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2001-12-06 20:36:39 +0000 |
commit | cc3a1c0738702afe09c853d18f61cd688ec05601 (patch) | |
tree | 3e5290cba2842ea39bfd4a6f7500db3fb39e15fe | |
parent | e866596ca32a8cf91d12edadfc9ca4acec09ae57 (diff) | |
download | libgcrypt-cc3a1c0738702afe09c853d18f61cd688ec05601.tar.gz |
* misc.c (_gcry_log_printf): New.
* sexp.c (dump_string,gcry_sexp_dump): Use logging functions
instead of stderr.
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/g10lib.h | 2 | ||||
-rw-r--r-- | src/misc.c | 12 | ||||
-rw-r--r-- | src/sexp.c | 111 |
5 files changed, 84 insertions, 53 deletions
@@ -0,0 +1,6 @@ +* see where we should use the ascii_strcasecmp() functions. +* switching from encrypt to decrypt requires a close and open. + Wouldn't it be better if we have a reste function or integrate that + with setkey? +* add more tests. Even basic is very minimal. +* udiv-qrnbd.o sollte als *.lo gebaut werden (HPUX)
\ No newline at end of file diff --git a/src/ChangeLog b/src/ChangeLog index 43df104c..9e173db8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-12-05 Werner Koch <wk@gnupg.org> + + * misc.c (_gcry_log_printf): New. + * sexp.c (dump_string,gcry_sexp_dump): Use logging functions + instead of stderr. + 2001-11-16 Werner Koch <wk@gnupg.org> * gcrypt.h: New constant GCRYCTL_IS_ALGO_ENABLED. diff --git a/src/g10lib.h b/src/g10lib.h index ae5b9269..71aaf824 100644 --- a/src/g10lib.h +++ b/src/g10lib.h @@ -69,6 +69,7 @@ void _gcry_log_fatal( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2); void _gcry_log_error( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); void _gcry_log_info( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); void _gcry_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); +void _gcry_log_printf ( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); void _gcry_set_log_verbosity( int level ); int _gcry_log_verbosity( int level ); @@ -85,6 +86,7 @@ int _gcry_log_verbosity( int level ); #define log_error _gcry_log_error #define log_info _gcry_log_info #define log_debug _gcry_log_debug +#define log_printf _gcry_log_printf @@ -217,3 +217,15 @@ _gcry_log_debug( const char *fmt, ... ) va_end(arg_ptr); } +void +_gcry_log_printf (const char *fmt, ...) +{ + va_list arg_ptr = 0; + + if (fmt) + { + va_start( arg_ptr, fmt ) ; + _gcry_logv (GCRY_LOG_CONT, fmt, arg_ptr); + va_end(arg_ptr); + } +} @@ -61,69 +61,74 @@ dump_mpi( GCRY_MPI a ) #endif static void -dump_string( FILE *fp, const byte *p, size_t n, int delim ) +dump_string (const byte *p, size_t n, int delim ) { - for( ; n; n--, p++ ) - if( (*p & 0x80) || iscntrl( *p ) || *p == delim ) { - putc('\\', fp); - if( *p == '\n' ) - putc('n', fp); - else if( *p == '\r' ) - putc('r', fp); - else if( *p == '\f' ) - putc('f', fp); - else if( *p == '\v' ) - putc('v', fp); + for (; n; n--, p++ ) + { + if ((*p & 0x80) || iscntrl( *p ) || *p == delim ) + { + if( *p == '\n' ) + log_printf ("\\n"); + else if( *p == '\r' ) + log_printf ("\\r"); + else if( *p == '\f' ) + log_printf ("\\f"); + else if( *p == '\v' ) + log_printf ("\\v"); else if( *p == '\b' ) - putc('b', fp); - else if( !*p ) - putc('0', fp); - else - fprintf(fp, "x%02x", *p ); + log_printf ("\\b"); + else if( !*p ) + log_printf ("\\0"); + else + log_printf ("\\x%02x", *p ); } - else - putc(*p, fp); + else + log_printf ("%c", *p); + } } void -gcry_sexp_dump( const GCRY_SEXP a ) +gcry_sexp_dump (const GCRY_SEXP a) { - const byte *p; - int indent = 0; - int type; - - if ( !a ) { - fputs ( "[nil]\n", stderr ); - return; + const byte *p; + int indent = 0; + int type; + + if (!a) + { + log_printf ( "[nil]\n"); + return; } - p = a->d; - while ( (type = *p) != ST_STOP ) { - p++; - switch ( type ) { - case ST_OPEN: - fprintf ( stderr, "%*s[open]\n", 2*indent, "" ); - indent++; - break; - case ST_CLOSE: - if( indent ) - indent--; - fprintf ( stderr, "%*s[close]\n", 2*indent, "" ); - break; - case ST_DATA: { - DATALEN n; - memcpy ( &n, p, sizeof n ); - p += sizeof n; - fprintf ( stderr, "%*s[data=\"", 2*indent, "" ); - dump_string ( stderr, p, n, '\"' ); - fputs ( "\"]\n", stderr ); - p += n; - } - break; - default: - fprintf ( stderr, "%*s[unknown tag %d]\n", 2*indent, "", type ); - break; + p = a->d; + while ( (type = *p) != ST_STOP ) + { + p++; + switch ( type ) + { + case ST_OPEN: + log_printf ("%*s[open]\n", 2*indent, ""); + indent++; + break; + case ST_CLOSE: + if( indent ) + indent--; + log_printf ("%*s[close]\n", 2*indent, ""); + break; + case ST_DATA: { + DATALEN n; + memcpy ( &n, p, sizeof n ); + p += sizeof n; + log_printf ("%*s[data=\"", 2*indent, "" ); + dump_string (p, n, '\"' ); + log_printf ("\"]\n"); + p += n; + } + break; + default: + log_printf ("%*s[unknown tag %d]\n", 2*indent, "", type); + break; } } } |