mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
See ChangeLog: Sat May 22 22:47:26 CEST 1999 Werner Koch
This commit is contained in:
parent
77d6309e21
commit
9131432b4d
25 changed files with 374 additions and 170 deletions
|
@ -1,3 +1,7 @@
|
|||
Sat May 22 22:47:26 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
|
||||
|
||||
* logger.c (log_set_logfile): New.
|
||||
|
||||
Thu May 20 14:04:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
|
||||
|
||||
* memory.c (membug): Nanu, there was a const instead of a static.
|
||||
|
|
|
@ -428,6 +428,7 @@ int
|
|||
iobuf_print_chain( IOBUF a )
|
||||
{
|
||||
print_chain(a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "i18n.h"
|
||||
|
@ -29,6 +31,40 @@
|
|||
static char pidstring[15];
|
||||
static char *pgm_name;
|
||||
static int errorcount;
|
||||
static FILE *logfp;
|
||||
|
||||
/****************
|
||||
* Set the logfile to use (not yet implemneted) or, if logfile is NULL,
|
||||
* the Fd where logoutputs should go.
|
||||
*/
|
||||
void
|
||||
log_set_logfile( const char *name, int fd )
|
||||
{
|
||||
if( name )
|
||||
BUG();
|
||||
|
||||
if( logfp && logfp != stderr && logfp != stdout )
|
||||
fclose( logfp );
|
||||
if( fd == 1 )
|
||||
logfp = stdout;
|
||||
else if( fd == 2 )
|
||||
logfp = stderr;
|
||||
else
|
||||
logfp = fdopen( fd, "a" );
|
||||
if( !logfp ) {
|
||||
logfp = stderr;
|
||||
log_fatal("can't open fd %d for logging: %s\n", fd, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
FILE *
|
||||
log_stream()
|
||||
{
|
||||
if( !logfp )
|
||||
logfp = stderr;
|
||||
return logfp;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
log_set_name( const char *name )
|
||||
|
@ -69,19 +105,23 @@ log_get_errorcount( int clear)
|
|||
static void
|
||||
print_prefix(const char *text)
|
||||
{
|
||||
if( !logfp )
|
||||
logfp = stderr;
|
||||
if( pgm_name )
|
||||
fprintf(stderr, "%s%s: %s", pgm_name, pidstring, text );
|
||||
fprintf(logfp, "%s%s: %s", pgm_name, pidstring, text );
|
||||
else
|
||||
fprintf(stderr, "?%s: %s", pidstring, text );
|
||||
fprintf(logfp, "?%s: %s", pidstring, text );
|
||||
}
|
||||
|
||||
static void
|
||||
print_prefix_f(const char *text, const char *fname)
|
||||
{
|
||||
if( !logfp )
|
||||
logfp = stderr;
|
||||
if( pgm_name )
|
||||
fprintf(stderr, "%s%s:%s: %s", pgm_name, pidstring, fname, text );
|
||||
fprintf(logfp, "%s%s:%s: %s", pgm_name, pidstring, fname, text );
|
||||
else
|
||||
fprintf(stderr, "?%s:%s: %s", pidstring, fname, text );
|
||||
fprintf(logfp, "?%s:%s: %s", pidstring, fname, text );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -91,7 +131,7 @@ g10_log_info( const char *fmt, ... )
|
|||
|
||||
print_prefix("");
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
}
|
||||
|
||||
|
@ -102,7 +142,7 @@ g10_log_info_f( const char *fname, const char *fmt, ... )
|
|||
|
||||
print_prefix_f("", fname);
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
}
|
||||
|
||||
|
@ -113,7 +153,7 @@ g10_log_error( const char *fmt, ... )
|
|||
|
||||
print_prefix("");
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
errorcount++;
|
||||
}
|
||||
|
@ -125,7 +165,7 @@ g10_log_error_f( const char *fname, const char *fmt, ... )
|
|||
|
||||
print_prefix_f("", fname);
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
errorcount++;
|
||||
}
|
||||
|
@ -137,7 +177,7 @@ g10_log_fatal( const char *fmt, ... )
|
|||
|
||||
print_prefix("fatal: ");
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
secmem_dump_stats();
|
||||
exit(2);
|
||||
|
@ -150,7 +190,7 @@ g10_log_fatal_f( const char *fname, const char *fmt, ... )
|
|||
|
||||
print_prefix_f("fatal: ", fname);
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
secmem_dump_stats();
|
||||
exit(2);
|
||||
|
@ -192,7 +232,7 @@ g10_log_debug( const char *fmt, ... )
|
|||
|
||||
print_prefix("DBG: ");
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
}
|
||||
|
||||
|
@ -203,7 +243,7 @@ g10_log_debug_f( const char *fname, const char *fmt, ... )
|
|||
|
||||
print_prefix_f("DBG: ", fname);
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
vfprintf(stderr,fmt,arg_ptr) ;
|
||||
vfprintf(logfp,fmt,arg_ptr) ;
|
||||
va_end(arg_ptr);
|
||||
}
|
||||
|
||||
|
@ -216,8 +256,8 @@ g10_log_hexdump( const char *text, const char *buf, size_t len )
|
|||
|
||||
print_prefix(text);
|
||||
for(i=0; i < len; i++ )
|
||||
fprintf(stderr, " %02X", ((const byte*)buf)[i] );
|
||||
fputc('\n', stderr);
|
||||
fprintf(logfp, " %02X", ((const byte*)buf)[i] );
|
||||
fputc('\n', logfp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,7 +265,7 @@ void
|
|||
g10_log_mpidump( const char *text, MPI a )
|
||||
{
|
||||
print_prefix(text);
|
||||
mpi_print(stderr, a, 1 );
|
||||
fputc('\n', stderr);
|
||||
mpi_print(logfp, a, 1 );
|
||||
fputc('\n', logfp);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ static ushort koi82unicode[128] = {
|
|||
0x042c,0x042b,0x0417,0x0428,0x042d,0x0429,0x0427,0x042a
|
||||
};
|
||||
|
||||
#if 0
|
||||
static ushort latin2_unicode[128] = {
|
||||
0x0080,0x0081,0x0082,0x0083,0x0084,0x0085,0x0086,0x0087,
|
||||
0x0088,0x0089,0x008A,0x008B,0x008C,0x008D,0x008E,0x008F,
|
||||
|
@ -65,7 +66,7 @@ static ushort latin2_unicode[128] = {
|
|||
0x0111,0x0144,0x0148,0x00F3,0x00F4,0x0151,0x00F6,0x00F7,
|
||||
0x0159,0x016F,0x00FA,0x0171,0x00FC,0x00FD,0x0163,0x02D9
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue