diff options
author | yaworsky <yaworsky> | 2005-11-29 13:34:12 +0000 |
---|---|---|
committer | yaworsky <yaworsky> | 2005-11-29 13:34:12 +0000 |
commit | 6cbd5fddd7e5be2746d0ceb017aaedd88717848b (patch) | |
tree | 0a0367e9c9b998786acdc01a99dd10fb60d0dee0 /daemon/conf.c | |
parent | 447ff54953c6fd528f161a6d5ab18593db9ad490 (diff) | |
download | syslog-win32-6cbd5fddd7e5be2746d0ceb017aaedd88717848b.tar.gz syslog-win32-6cbd5fddd7e5be2746d0ceb017aaedd88717848b.tar.xz syslog-win32-6cbd5fddd7e5be2746d0ceb017aaedd88717848b.zip |
Convert all parts of logged message to destination encoding.
This is required if destination encoding is UCS-2 or UCS-4 for example.
Otherwise the logfile will not be uniform.
Fixed a bug in charset conversion function: divide by zero when
cannot convert the first character and calculating new size for the output
buffer.
Diffstat (limited to 'daemon/conf.c')
-rw-r--r-- | daemon/conf.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/daemon/conf.c b/daemon/conf.c index 78f95c2..9be1c18 100644 --- a/daemon/conf.c +++ b/daemon/conf.c @@ -679,11 +679,9 @@ parsed: * create_conversion_descriptors * * helper function for resolve_logpaths; - * creates charset conversion descriptors for message and program name */ static void create_conversion_descriptors( struct logpath* logpath ) { - /* create message charset conversion descriptor */ if( logpath->source->encoding || logpath->destination->encoding ) { char *source_encoding = logpath->source->encoding? @@ -693,8 +691,8 @@ static void create_conversion_descriptors( struct logpath* logpath ) if( strcasecmp( source_encoding, destination_encoding ) != 0 ) { - logpath->message_cd = g_iconv_open( destination_encoding, source_encoding ); - if( logpath->message_cd == (GIConv) -1 ) + logpath->src2dest_cd = g_iconv_open( destination_encoding, source_encoding ); + if( logpath->src2dest_cd == (GIConv) -1 ) { ERR( "Cannot convert messages from %s to %s\n", source_encoding, destination_encoding ); @@ -706,9 +704,23 @@ static void create_conversion_descriptors( struct logpath* logpath ) source_encoding, destination_encoding ); } } + + if( strcasecmp( "ASCII", destination_encoding ) != 0 ) + { + logpath->ascii2dest_cd = g_iconv_open( destination_encoding, source_encoding ); + if( logpath->ascii2dest_cd == (GIConv) -1 ) + { + ERR( "Cannot convert messages from ASCII to %s\n", destination_encoding ); + } + else + { + TRACE( "Log path %s-%s: converting messages from ASCII to %s\n", + logpath->source->name, logpath->destination->name, + destination_encoding ); + } + } } - /* create charset conversion descriptor for program name */ if( logpath->source->encoding ) { const gchar *destination_encoding; @@ -717,15 +729,15 @@ static void create_conversion_descriptors( struct logpath* logpath ) if( strcasecmp( logpath->source->encoding, destination_encoding ) != 0 ) { - logpath->program_cd = g_iconv_open( destination_encoding, logpath->source->encoding ); - if( logpath->program_cd == (GIConv) -1 ) + logpath->src2locale_cd = g_iconv_open( destination_encoding, logpath->source->encoding ); + if( logpath->src2locale_cd == (GIConv) -1 ) { - ERR( "Cannot convert program names from %s to %s\n", + ERR( "Cannot convert locale parts from %s to %s\n", logpath->source->encoding, destination_encoding ); } else { - TRACE( "Log path %s-%s: converting program name from %s to %s\n", + TRACE( "Log path %s-%s: converting locale parts from %s to %s\n", logpath->source->name, logpath->destination->name, logpath->source->encoding, destination_encoding ); } @@ -752,8 +764,9 @@ static void resolve_logpaths() g_free( logpath ); logpath = g_malloc( sizeof(struct logpath) ); - logpath->message_cd = (GIConv) -1; - logpath->program_cd = (GIConv) -1; + logpath->src2dest_cd = (GIConv) -1; + logpath->ascii2dest_cd = (GIConv) -1; + logpath->src2locale_cd = (GIConv) -1; /* find source */ for( item = sources; item; item = item->next ) |