aboutsummaryrefslogtreecommitdiffstats
path: root/daemon/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/conf.c')
-rw-r--r--daemon/conf.c84
1 files changed, 60 insertions, 24 deletions
diff --git a/daemon/conf.c b/daemon/conf.c
index 2255369..78f95c2 100644
--- a/daemon/conf.c
+++ b/daemon/conf.c
@@ -676,6 +676,64 @@ 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?
+ logpath->source->encoding : "UTF-8";
+ char *destination_encoding = logpath->destination->encoding?
+ logpath->destination->encoding : "UTF-8";
+
+ if( strcasecmp( source_encoding, destination_encoding ) != 0 )
+ {
+ logpath->message_cd = g_iconv_open( destination_encoding, source_encoding );
+ if( logpath->message_cd == (GIConv) -1 )
+ {
+ ERR( "Cannot convert messages from %s to %s\n",
+ source_encoding, destination_encoding );
+ }
+ else
+ {
+ TRACE( "Log path %s-%s: converting messages from %s to %s\n",
+ logpath->source->name, logpath->destination->name,
+ source_encoding, destination_encoding );
+ }
+ }
+ }
+
+ /* create charset conversion descriptor for program name */
+ if( logpath->source->encoding )
+ {
+ const gchar *destination_encoding;
+
+ g_get_charset( &destination_encoding );
+
+ 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 )
+ {
+ ERR( "Cannot convert program names from %s to %s\n",
+ logpath->source->encoding, destination_encoding );
+ }
+ else
+ {
+ TRACE( "Log path %s-%s: converting program name from %s to %s\n",
+ logpath->source->name, logpath->destination->name,
+ logpath->source->encoding, destination_encoding );
+ }
+ }
+ }
+}
+
+/******************************************************************************
* resolve_logpaths
*
* replace logpath_names structures
@@ -695,6 +753,7 @@ static void resolve_logpaths()
logpath = g_malloc( sizeof(struct logpath) );
logpath->message_cd = (GIConv) -1;
+ logpath->program_cd = (GIConv) -1;
/* find source */
for( item = sources; item; item = item->next )
@@ -741,30 +800,7 @@ static void resolve_logpaths()
logpath->filter = NULL;
}
- /* create message charset conversion descriptor */
- if( logpath->source->encoding || logpath->destination->encoding )
- {
- char *source_encoding = logpath->source->encoding?
- logpath->source->encoding : "UTF-8";
- char *destination_encoding = logpath->destination->encoding?
- logpath->destination->encoding : "UTF-8";
-
- if( strcasecmp( source_encoding, destination_encoding ) != 0 )
- {
- logpath->message_cd = g_iconv_open( destination_encoding, source_encoding );
- if( logpath->message_cd == (GIConv) -1 )
- {
- ERR( "Cannot convert messages from %s to %s\n",
- source_encoding, destination_encoding );
- }
- else
- {
- TRACE( "Log path %s-%s: converting messages from %s to %s\n",
- logpath->source->name, logpath->destination->name,
- source_encoding, destination_encoding );
- }
- }
- }
+ create_conversion_descriptors( logpath );
/* add item to paths */
paths = g_list_append( paths, logpath );